11 #ifndef _COMPUTECUTCELLMOMENTSIMPLEM_H_ 12 #define _COMPUTECUTCELLMOMENTSIMPLEM_H_ 14 #if defined(CH_Darwin) && defined(__GNUC__) && ( __GNUC__ == 3 ) 17 #define _GLIBCPP_USE_C99 1 33 #include "NamespaceHeader.H" 42 :m_cutCellMoments(a_computeCutCellMoments.m_cutCellMoments)
52 for (
int hilo = 0; hilo < 2; ++hilo)
54 for (
int idir = 0; idir <
dim; ++idir)
61 #if RECURSIVE_GEOMETRY_GENERATION == 0 62 IFData<dim-1> reducedInfo(a_info,idir,hilo);
73 if (reducedInfo.m_allVerticesOn)
86 #if RECURSIVE_GEOMETRY_GENERATION == 0 88 const int & a_degreeP,
89 const bool & a_useConstraints,
91 const int & a_numberOfRefinements)
96 for (
int i = 0; i < 3; i++)
101 for (
int i = 0; i < a_degreeP + 1; i++)
108 for (
int iDegree = a_degreeP; iDegree >= 0; --iDegree)
114 for (
typename PthMomentLoc::const_iterator it = monDegreeP.begin(); it != monDegreeP.end(); ++it)
120 for (
typename PthMomentLoc::const_iterator it = monDegreePLess1.begin(); it != monDegreePLess1.end(); ++it)
128 for (
int iDegree = a_degreeP; iDegree >= 0; --iDegree)
134 for (
typename PthMomentLoc::const_iterator it = monDegreeP.begin(); it != monDegreeP.end(); ++it)
140 for (
typename PthMomentLoc::const_iterator it = monDegreePLess1.begin(); it != monDegreePLess1.end(); ++it)
153 subProblem.computeMoments(a_order,a_degreeP+1,a_useConstraints,noRefinement);
154 it->second = subProblem.m_cutCellMoments;
158 for (
int iDegree = a_degreeP; iDegree >= 0; --iDegree)
166 if (a_useConstraints)
176 pout() <<
"Geometry generation least squares problem failed with residual: " 180 pout () << endl <<
"Problem occurred generating geometry for these cut cell moments:\n" 198 for (
typename PthMomentLoc::const_iterator it = monDegreePLess1.begin();
199 it != monDegreePLess1.end(); ++it)
205 for (
typename PthMomentLoc::const_iterator it = monDegreeP.begin(); it != monDegreeP.end(); ++it)
216 for (
typename PthMoment::const_iterator it = copyMoments.begin();
217 it != copyMoments.end(); ++it)
219 IvDim mono = it->first;
224 for (
typename PthMoment::const_iterator it = copyEBMoments.begin(); it != copyEBMoments.end(); ++it)
226 IvDim mono = it->first;
235 it->second.changeMomentCoordinatesToCellCenter();
260 for (
typename PthMoment::const_iterator it = copyMoments.begin();
261 it != copyMoments.end(); ++it)
263 IvDim mono = it->first;
268 for (
typename PthMoment::const_iterator it = copyEBMoments.begin(); it != copyEBMoments.end(); ++it)
270 IvDim mono = it->first;
278 const int & a_degreePmax,
279 const bool & a_useConstraints,
281 const int & a_numberOfRefinements)
283 int zerothOrderOfAccuracy = 0;
284 int highestDegree = a_orderPmax + a_degreePmax;
287 for (
int i = 0; i < 3; i++)
292 for (
int i = 0; i <= highestDegree; i++)
299 computeMomentsRecursively(zerothOrderOfAccuracy,
302 a_refinementCriterion,
303 a_numberOfRefinements);
325 for (
typename PthMoment::const_iterator it = copyMoments.begin();
326 it != copyMoments.end(); ++it)
328 IvDim mono = it->first;
333 for (
typename PthMoment::const_iterator it = copyEBMoments.begin(); it != copyEBMoments.end(); ++it)
335 IvDim mono = it->first;
344 it->second.changeMomentCoordinatesToCellCenter();
353 for (
typename PthMoment::const_iterator it = copyMoments.begin();
354 it != copyMoments.end(); ++it)
356 IvDim mono = it->first;
361 for (
typename PthMoment::const_iterator it = copyEBMoments.begin(); it != copyEBMoments.end(); ++it)
363 IvDim mono = it->first;
369 const int & a_degreePmax,
370 const bool & a_useConstraints,
372 const int & a_numberOfRefinements)
378 for (
int iOrder = 0; iOrder <= a_orderPmax; ++iOrder)
384 for (
typename PthMomentLoc::const_iterator it = monDegreeP.begin(); it != monDegreeP.end(); ++it)
390 for (
typename PthMomentLoc::const_iterator it = monDegreePLess1.begin(); it != monDegreePLess1.end(); ++it)
398 for (
int iOrder = 0; iOrder <= a_orderPmax; ++iOrder)
404 for (
typename PthMomentLoc::const_iterator it = monDegreeP.begin(); it != monDegreeP.end(); ++it)
410 for (
typename PthMomentLoc::const_iterator it = monDegreePLess1.begin(); it != monDegreePLess1.end(); ++it)
427 subProblem.computeMoments(a_orderPmax,a_degreePmax+1,a_useConstraints,noRefinement);
428 it->second = subProblem.m_cutCellMoments;
440 if (a_useConstraints)
449 pout() <<
"Geometry generation least squares problem failed with residual:" 452 pout () <<
"Problem occurred generating geometry for these cut cell moments: " <<
m_cutCellMoments << endl;
459 for (
typename PthMomentLoc::const_iterator it = monDegreePLess1.begin();
460 it != monDegreePLess1.end(); ++it)
466 for (
typename PthMomentLoc::const_iterator it = monDegreeP.begin(); it != monDegreeP.end(); ++it)
473 if (a_degreePmax > 0)
475 computeMomentsRecursively(a_orderPmax + 1,
478 a_refinementCriterion,
479 a_numberOfRefinements);
489 const int & a_orderPmax)
499 for (
typename LocPthMoment::const_iterator it = locMap.begin(); it != locMap.end(); ++it)
502 IvDim mono = it->second;
508 for (
int idir = 0; idir <
dim; ++idir)
512 for (
int jdir = 0; jdir <
dim; ++jdir)
516 mono1Less[jdir] = mono[jdir];
518 else if (jdir > idir)
520 mono1Less[jdir-1] = mono[jdir];
532 int exponent = it->second[idir];
545 Real loFactor = pow(loSideValue,exponent);
546 Real hiFactor = pow(hiSideValue,exponent);
548 rhs[(dim*jth) + idir] = hiMom*hiFactor - loMom*loFactor;
551 #if RECURSIVE_GEOMETRY_GENERATION == 0 552 for (
int order = 1; order <= a_order; order++)
554 for (
int order = 1; order <= a_orderPmax; order++)
561 for (
int i = 0; i < taylorMonomials.
size(); i++)
563 const IvDim & taylorMonomial = taylorMonomials[i];
565 IvDim totalMonomial = mono + taylorMonomial;
575 rhs[(dim*jth) + idir] += normalDerivative * moment / fact;
577 #if RECURSIVE_GEOMETRY_GENERATION != 0 580 MayDay::Error(
"Unable to find needed monomial for Taylor series");
591 #if RECURSIVE_GEOMETRY_GENERATION == 0 593 const int & a_degreeP,
596 const int & a_degreePmax,
598 const bool & a_useConstraints,
601 const int & a_numberOfRefinements)
613 for (
int idir = 0; idir <
dim; idir++)
615 if (a_refineInDir[idir] != 0)
618 refinedDx[idir] /= 2.0;
637 for (
int idir = 0; idir <
dim; idir++)
639 if (a_refineInDir[idir] != 0)
641 int sign = 2*curIter[idir] - 1;
642 refinedCellCenter[idir] += sign * 0.5*refinedDx[idir];
649 #if RECURSIVE_GEOMETRY_GENERATION == 0 655 pout() <<
"refinedIFData" <<
"\n";
656 pout() << refinedIFData<<endl;
662 int numberOfRefinements = a_numberOfRefinements + 1;
665 #if RECURSIVE_GEOMETRY_GENERATION == 0 666 refinedComputeCCMom.
computeMoments(a_order,a_degreeP,a_useConstraints,a_refinementCriterion,numberOfRefinements);
668 refinedComputeCCMom.
computeMoments(a_orderPmax,a_degreePmax,a_useConstraints,a_refinementCriterion,numberOfRefinements);
674 for (idir = 0; idir <
dim; idir++)
676 if (curIter[idir] < maxIter[idir])
697 return refinedCutCellMoments;
702 const int & a_degreeP,
704 const int & a_degreePmax,
706 const bool & a_useConstraints)
708 int numberOfRefinedCC = a_refinedCutCellVector.size();
719 while (k < numberOfRefinedCC && (a_refinedCutCellVector[k].m_IFData.m_allVerticesOut ||
720 (a_refinedCutCellVector[k].m_IFData.m_allVerticesIn && !
m_cutCellMoments.m_bdCCOn)))
725 if (k >= numberOfRefinedCC)
727 MayDay::Abort(
"Exceeded the number of refined ComputeCutCellMoments in vector");
732 cutCell = a_refinedCutCellVector[k];
739 for (
int i = 0; i < numberOfRefinedCC; i++)
749 for (
int j = 0; j <
dim; ++j)
757 for (
int idir = 0; idir <
dim; idir++)
759 refinedCenterDelta[idir] = 0.25*sign[idir]*
m_cutCellMoments.m_IFData.m_globalCoord.m_dx[idir];
767 for (
int idir = 0; idir <
dim; idir++)
777 for (
int jdir = 0; jdir <
dim; jdir++)
781 localRefinedCenterDelta[jdir] = refinedCenterDelta[jdir];
782 localHilo[jdir] = hilo[jdir];
784 else if (jdir > idir)
786 localRefinedCenterDelta[jdir-1] = refinedCenterDelta[jdir];
787 localHilo[jdir-1] = hilo[jdir];
793 bdId[1] = hilo[idir];
807 localRefinedCenterDelta,
812 for (
int side = 0; side < 2; side++)
824 localRefinedCenterDelta,
838 for (
typename PthMoment::const_iterator it = a_refinedMomentMap.begin(); it != a_refinedMomentMap.end(); ++it)
841 Real moment =
m_cutCellMoments.changeMomentCoordinates(a_refinedMomentMap,monomial,a_refinedCenterDelta);
843 a_momentMap[it->first] += moment;
847 #if RECURSIVE_GEOMETRY_GENERATION == 0 849 const int & a_degreeP,
852 const int & a_degreePmax,
854 const bool & a_useConstraints)
856 #if RECURSIVE_GEOMETRY_GENERATION == 0 857 for (
int iDegree = a_degreeP; iDegree >= 0; iDegree--)
859 for (
int iDegree = a_degreePmax; iDegree >= 0; iDegree--)
866 for (
int i = 0; i < nNorm; i++)
873 #if RECURSIVE_GEOMETRY_GENERATION == 0 881 #if RECURSIVE_GEOMETRY_GENERATION == 0 890 for (
typename PthMomentLoc::const_iterator it = lsp.
m_monoLocP.begin(); it != lsp.
m_monoLocP.end(); ++it)
909 AtimeX += lsp.
m_matrix[i][j] * unknowns[j];
912 Real ri = AtimeX - rhs[i];
930 const int & a_degreeP)
932 const int & a_degreePmax)
935 #if RECURSIVE_GEOMETRY_GENERATION == 0 936 for (
int iDegree = 0; iDegree <= a_degreeP; iDegree++)
938 for (
int iDegree = 0; iDegree <= a_degreePmax; iDegree++)
945 for (
int i = 0; i < a_refinedCCMoms.size(); i++)
947 Real res0 = a_refinedCCMoms[i].getResidual(iDegree,0);
948 Real res1 = a_refinedCCMoms[i].getResidual(iDegree,1);
949 Real res2 = a_refinedCCMoms[i].getResidual(iDegree,2);
964 tempRes2 += res2*res2;
991 if (
this != &a_computeCutCellMoments)
1000 a_computeCutCellMoments.
print(a_out);
1008 for (
int i = 0; i <
dim; i++)
1010 for (
int j = 2; j <= a_multiIndex[i]; j++)
1019 #include "NamespaceFooter.H" std::ostream & pout()
Use this in place of std::cout for program output.
void computeBounds(const IndexTM< Real, dim > &a_dx, const CutCellMoments< dim > &a_ccm)
Definition: LSProblemImplem.H:94
#define BDID_HILO
Definition: Notation.H:89
BdCutCellMoments m_bdCutCellMoments
Definition: CutCellMoments.H:138
Real factorial(const IvDim &a_multiIndex) const
Definition: ComputeCutCellMomentsImplem.H:1004
void print(ostream &a_out) const
Definition: LSProblemImplem.H:560
ostream & operator<<(ostream &a_out, const ComputeCutCellMoments< dim > &a_computeCutCellMoments)
Definition: ComputeCutCellMomentsImplem.H:997
void addMoments(PthMoment &a_momentMap, PthMoment &a_refinedMomentMap, const IndexTM< Real, dim > &a_refinedCenterDelta)
Definition: ComputeCutCellMomentsImplem.H:832
int m_numP
Definition: LSProblem.H:186
#define CH_assert(cond)
Definition: CHArray.H:37
Definition: NoRefinement.H:22
map< int, IvDim > LocPthMoment
Definition: ComputeCutCellMoments.H:48
#define LARGEREALVAL
Definition: Notation.H:77
void operator=(const ComputeCutCellMoments< dim > &a_computeCutCellMoments)
Definition: ComputeCutCellMomentsImplem.H:988
Definition: ComputeCutCellMoments.H:37
int sign(const CH_XD::Side::LoHiSide &a_side)
#define LARGEINTVAL
Definition: Notation.H:76
Vector< CutCellMoments< dim > > refine(const int &a_order, const int &a_degreeP, const bool &a_useConstraints, RefinementCriterion< dim > &a_refinementCriterion, const IndexTM< int, dim > &a_refineInDir, const int &a_numberOfRefinements)
Definition: ComputeCutCellMomentsImplem.H:592
virtual bool doRefine(IndexTM< int, dim > &a_refineInDir, const CutCellMoments< dim > &a_ccm, const int &a_numberOfRefinements)
Definition: RefinementCriterion.H:101
map< IvDim, Real, LexLT< IvDim > > PthMoment
Definition: ComputeCutCellMoments.H:43
Vector< Real > computeRhs(LSProblem< dim > &a_lsp, const int &a_order)
Definition: ComputeCutCellMomentsImplem.H:485
~ComputeCutCellMoments()
Definition: ComputeCutCellMomentsImplem.H:82
Real getUnknown(int loc)
Definition: LSProblem.H:104
void setConstrantSuccessStatus(const bool &a_status)
Definition: RefinementCriterion.H:110
CutCellMoments< dim > m_cutCellMoments
Definition: ComputeCutCellMoments.H:149
Definition: ComputeCutCellMoments.H:35
Definition: RefinementCriterion.H:27
PthMomentLoc m_monoLocPLess1
Definition: LSProblem.H:189
void addBdMoments(CutCellMoments< dim > &a_coarseCutCell, const IFData< dim+1 > &a_IFData, const int &a_degreeP, const bool &a_useConstraints, const IndexTM< Real, dim > &a_refinedCenterDelta, const IndexTM< int, dim > &a_localHilo)
void computeResiduals(const int &a_order, const int &a_degreeP, const bool &a_useConstraints)
Definition: ComputeCutCellMomentsImplem.H:848
void push_back(const T &in)
Definition: Vector.H:295
int numActiveBounds() const
Definition: LSProblem.H:119
const PthMomentLoc & getMonomialLocMapDegreeP() const
Definition: LSProblem.H:94
IFData< dim > m_IFData
Definition: CutCellMoments.H:141
const PthMomentLoc & getMonomialLocMapDegreePLess1() const
Definition: LSProblem.H:99
#define BDID_DIR
Definition: Notation.H:88
double Real
Definition: REAL.H:33
void addMomentMaps(const Vector< CutCellMoments< dim > > &a_refinedCutCellVector, const int &a_degreeP, const bool &a_useConstraints)
Definition: ComputeCutCellMomentsImplem.H:700
int invertNormalEq(const Vector< Real > &a_rhs, Vector< Real > &a_residual)
Definition: LSProblemImplem.H:317
T Abs(const T &a_a)
Definition: Misc.H:53
size_t size() const
Definition: Vector.H:192
PthMomentLoc m_monoLocP
Definition: LSProblem.H:182
static void Error(const char *const a_msg=m_nullString, int m_exitCode=CH_DEFAULT_ERROR_CODE)
Print out message to cerr and exit with the specified exit code.
void computeMoments(const int &a_order, const int &a_degreeP, const bool &a_useConstraints, RefinementCriterion< dim > &a_refinementCriterion, const int &a_numberOfRefinements=0)
Definition: ComputeCutCellMomentsImplem.H:87
int m_numPLess1
Definition: LSProblem.H:193
PthMoment m_moments
Definition: CutCellMoments.H:132
Real ** m_matrix
Definition: LSProblem.H:197
void dump() const
Definition: ComputeCutCellMomentsImplem.H:982
const LocPthMoment & getLocMonomialMapDegreeP() const
Definition: LSProblem.H:89
int getNumberDegP()
Definition: LSProblem.H:109
int m_maxOrder
Definition: IFData.H:67
void print(ostream &out) const
Definition: ComputeCutCellMomentsImplem.H:977
PthMoment m_EBmoments
Definition: CutCellMoments.H:135
ComputeCutCellMoments()
Definition: ComputeCutCellMomentsImplem.H:36
void generateMultiIndices(Vector< IndexTM< int, dim > > &a_indices, const int &a_magnitude)
Definition: MultiIndexImplem.H:18
int dim
Definition: EBInterface.H:146
bool m_boundaryMomentsComputed
Definition: ComputeCutCellMoments.H:152
Definition: CutCellMoments.H:32
virtual bool baseDoRefine(IndexTM< int, dim > &a_refineInDir, const CutCellMoments< dim > &a_ccm, const int &a_numberOfRefinements)
Should a cell be subdivided and in which directions.
Definition: RefinementCriterion.H:63
#define RECURSIVE_GEOMETRY_GENERATION
Definition: Notation.H:40
static void Abort(const char *const a_msg=m_nullString)
Print out message to cerr and exit via abort() (if serial) or MPI_Abort() (if parallel).
map< IvDim, int, LexLT< IvDim > > PthMomentLoc
Definition: ComputeCutCellMoments.H:49