11 #ifndef _CUTCELLMOMENTSIMPLEM_H_ 12 #define _CUTCELLMOMENTSIMPLEM_H_ 14 #if defined(CH_Darwin) && defined(__GNUC__) && ( __GNUC__ == 3 ) 17 #define _GLIBCPP_USE_C99 1 32 #include "NamespaceHeader.H" 41 :m_moments (a_cutCellMoments.m_moments),
42 m_EBmoments (a_cutCellMoments.m_EBmoments),
43 m_bdCutCellMoments(a_cutCellMoments.m_bdCutCellMoments),
44 m_IFData (a_cutCellMoments.m_IFData),
45 m_bdCCOn (a_cutCellMoments.m_bdCCOn),
46 m_residual (a_cutCellMoments.m_residual),
47 m_numActiveBounds (a_cutCellMoments.m_numActiveBounds),
48 m_badNormal (a_cutCellMoments.m_badNormal)
60 for (
int hilo = 0; hilo < 2; ++hilo)
62 for (
int idir = 0; idir <
dim; ++idir)
69 #if RECURSIVE_GEOMETRY_GENERATION == 0 70 IFData<dim-1> reducedInfo(a_info,idir,hilo);
80 if (reducedInfo.m_allVerticesOn)
86 if (reducedInfo.m_badNormal)
119 const int & a_degreeP,
121 const int & a_degreePmax,
123 const bool & a_useConstraints,
136 #if RECURSIVE_GEOMETRY_GENERATION == 0 137 for (
int iDegree = a_degreeP; iDegree > 0; iDegree--)
139 for (
int iDegree = a_degreePmax; iDegree > 0; iDegree--)
147 for (
typename PthMomentLoc::const_iterator it = momMap.begin(); it != momMap.end(); ++it)
154 #if RECURSIVE_GEOMETRY_GENERATION == 0 155 for (
int iDegree = a_degreeP; iDegree > 0; iDegree--)
157 for (
int iDegree = a_degreePmax; iDegree > 0; iDegree--)
167 for (
typename PthMomentLoc::const_iterator it = momMap.begin(); it != momMap.end(); ++it)
169 Real bdMoment =
getBdMoment(it->first,a_IFData,a_refinedCenterDelta,fullCellMap);
170 a_coarseBdCutCell.
m_moments[it->first] += bdMoment;
176 #if RECURSIVE_GEOMETRY_GENERATION == 0 177 for (
int iDegree = a_degreeP; iDegree > 0; iDegree--)
179 for (
int iDegree = a_degreePmax; iDegree > 0; iDegree--)
189 for (
typename PthMomentLoc::const_iterator it = momMap.begin(); it != momMap.end(); ++it)
192 a_coarseBdCutCell.
m_moments[it->first] += bdMoment;
197 #if RECURSIVE_GEOMETRY_GENERATION == 0 198 for (
int iDegree = a_degreeP; iDegree >= 0; iDegree--)
200 for (
int iDegree = a_degreePmax; iDegree >= 0; iDegree--)
209 for (
typename PthMomentLoc::const_iterator it = momMapP.begin(); it != momMapP.end(); ++it)
212 a_coarseBdCutCell.
m_EBmoments[it->first] += bdEBMoment;
218 for (
int idir = 0; idir <
dim; idir++)
228 for (
int jdir = 0; jdir <
dim; jdir++)
232 localRefinedCellCenter[jdir] = a_refinedCenterDelta[jdir];
233 localHilo[jdir] = a_hilo[jdir];
235 else if (jdir > idir)
237 localRefinedCellCenter[jdir-1] = a_refinedCenterDelta[jdir];
238 localHilo[jdir-1] = a_hilo[jdir];
244 bdId[1] = a_hilo[idir];
248 #if RECURSIVE_GEOMETRY_GENERATION == 0 256 for (
int side = 0; side < 2; side++)
259 #if RECURSIVE_GEOMETRY_GENERATION == 0 274 for (
int idir = 0; idir <
dim; ++idir)
284 Real idirInt = pow(hiPt,a_mono[idir] + 1) - pow(loPt,a_mono[idir] + 1);
286 idirInt /= (a_mono[idir] + 1);
307 for (
int i = 0; i <
dim; i++)
309 degree += a_monomial[i];
315 for (
int r = 0; r <= degree; r++)
322 for (
int idir = 0; idir <
dim; ++idir)
324 derivative[idir] = 0;
329 for (
int j = 1; j < dim-1; ++j)
332 for (
int k = j+1; k <
dim; ++k)
337 if (derivative[j] > t)
339 derivative[j+1] += 1;
348 if (derivative[dim-1] > r)
355 for (
int j = 1; j <
dim; ++j)
357 derivative[0] -= derivative[j];
362 Real factorial = 1.0;
364 for (
int idir = 0; idir <
dim; idir++)
366 for (
int j = 0; j < derivative[idir]; j++)
368 coeff *= a_monomial[idir] - j;
374 if (a_monomial[idir]-derivative[idir] < 0)
378 MayDay::Abort(
"Coeff should be zero when the derivative has higher coefficient than the monomial");
383 coeff *= pow(a_refinedCenterDelta[idir],a_monomial[idir]-derivative[idir]);
388 moment += coeff * a_refinedMomentMap[derivative] / factorial;
403 delta -=
m_IFData.m_parentCoord .m_origin;
406 for (
typename PthMoment::const_iterator it = copyMoments.begin();
407 it != copyMoments.end(); ++it)
409 IvDim mono = it->first;
414 for (
typename PthMoment::const_iterator it = copyEBMoments.begin(); it != copyEBMoments.end(); ++it)
416 IvDim mono = it->first;
425 delta -=
m_IFData.m_cellCenterCoord.m_origin;
428 for (
typename PthMoment::const_iterator it = copyMoments.begin();
429 it != copyMoments.end(); ++it)
431 IvDim mono = it->first;
436 for (
typename PthMoment::const_iterator it = copyEBMoments.begin(); it != copyEBMoments.end(); ++it)
438 IvDim mono = it->first;
453 for (
int idir = 0; idir <
dim; idir++)
457 for (
int hilo = 0; hilo < 2; hilo++)
470 for (
typename PthMomentLesserDimension::const_iterator it = a_map2.begin(); it != a_map2.end(); ++it)
472 a_map1[it->first] = 0.0;
479 for (
typename PthMoment::const_iterator it = a_map2.begin(); it != a_map2.end(); ++it)
481 a_map1[it->first] = 0.0;
488 for (
typename OneDMoments::const_iterator it = a_map2.begin(); it != a_map2.end(); ++it)
490 a_map1[it->first] = 0.0;
542 const EBorVol & a_EBorVol)
const 549 typename PthMoment::const_iterator it =
m_moments.find(a_mono);
563 typename PthMoment::const_iterator it =
m_EBmoments.find(a_mono);
601 for (
int idir = 0; idir <
dim; ++idir)
603 IvDim mono = BASISV_TM<int,dim>(idir);
604 centroid[idir] =
getMoment(mono,a_EBorVol);
608 MayDay::Warning(
"CutCellMoments::getCentroid: Volume fraction is negative");
610 else if (volume == 0.0)
615 centroid[idir] /= volume;
622 const int & a_normJ)
const 638 const int & a_iDegree,
643 MayDay::Abort(
"Invalid assignment to m_residual in covered or full cell");
655 pout()<<
"Dim = "<<
dim << endl;
656 MayDay::Abort(
"Invalid attemtp to slice of m_residual in a covered or full CCM");
676 string padding =
" ";
682 a_out << padding <<
"Dim = " << dim <<
"\n";
683 a_out << padding <<
"\n";
685 for (
typename PthMoment::const_iterator it =
m_moments.begin(); it !=
m_moments.end(); ++it)
687 std::ios::fmtflags origFlags = a_out.flags();
688 int origWidth = a_out.width();
689 int origPrecision = a_out.precision();
691 a_out << padding <<
"Integral " 696 << setiosflags(ios::showpoint)
697 << setiosflags(ios::scientific)
701 a_out.flags(origFlags);
702 a_out.width(origWidth);
703 a_out.precision(origPrecision);
708 a_out << padding <<
"\n";
713 std::ios::fmtflags origFlags = a_out.flags();
714 int origWidth = a_out.width();
715 int origPrecision = a_out.precision();
717 a_out << padding <<
"EBIntegral " 722 << setiosflags(ios::showpoint)
723 << setiosflags(ios::scientific)
727 a_out.flags(origFlags);
728 a_out.width(origWidth);
729 a_out.precision(origPrecision);
734 a_out << padding <<
"\n";
737 a_out << padding <<
"Residuals:" <<
"\n";
740 a_out << padding <<
" " << i <<
":";
742 std::ios::fmtflags origFlags = a_out.flags();
743 int origWidth = a_out.width();
744 int origPrecision = a_out.precision();
752 << setiosflags(ios::showpoint)
753 << setiosflags(ios::scientific)
757 a_out.flags(origFlags);
758 a_out.width(origWidth);
759 a_out.precision(origPrecision);
761 a_out << padding <<
"\n";
763 a_out << padding <<
"\n";
765 a_out << padding <<
"IFData:" <<
"\n";
766 a_out << padding <<
"\n";
769 a_out << padding <<
"Number of bdCutCellMoments = " 772 a_out << padding <<
"\n";
776 a_out << padding <<
"BdId = " << it->first <<
"\n";
790 if (
this != &a_cutCellMoments)
806 a_cutCellMoments.
print(a_out);
810 #include "NamespaceFooter.H" std::ostream & pout()
Use this in place of std::cout for program output.
Real convertDir(const Real &a_coord, const CoordinateSystem< dim > &a_system, const int &a_dir) const
Definition: CoordinateSystemImplem.H:91
#define BDID_HILO
Definition: Notation.H:89
bool isCovered() const
Definition: CutCellMomentsImplem.H:664
Real getVol(const EBorVol &a_EBorVol) const
Definition: CutCellMomentsImplem.H:582
BdCutCellMoments m_bdCutCellMoments
Definition: CutCellMoments.H:144
Definition: CoordinateSystem.H:34
map< IndexTM< int, 1 >, Real > OneDMoments
Definition: CutCellMoments.H:42
#define LARGEREALVAL
Definition: Notation.H:77
Real getResidual(const int &a_iDegree, const int &a_normJ) const
Definition: CutCellMomentsImplem.H:621
void changeMomentCoordinatesToCellCenter()
Definition: CutCellMomentsImplem.H:399
#define LARGEINTVAL
Definition: Notation.H:76
EBorVol
Definition: Notation.H:101
Vector< Real > sliceResidual(const int &a_iDegree) const
Definition: CutCellMomentsImplem.H:651
Real getMoment(const IvDim &a_mono, const EBorVol &a_EBorVOL) const
Definition: CutCellMomentsImplem.H:541
bool m_badNormal
Definition: CutCellMoments.H:159
Definition: ComputeCutCellMoments.H:35
~CutCellMoments()
Definition: CutCellMomentsImplem.H:96
void print(ostream &out) const
Definition: CutCellMomentsImplem.H:674
CutCellMoments()
Definition: CutCellMomentsImplem.H:35
void setResidual(const Real &a_value, const int &a_iDegree, const int &a_normJ)
Definition: CutCellMomentsImplem.H:637
Definition: Notation.H:103
const PthMomentLoc & getMonomialLocMapDegreeP() const
Definition: LSProblem.H:94
IFData< dim > m_IFData
Definition: CutCellMoments.H:147
Vector< Vector< Real > > m_residual
Definition: CutCellMoments.H:153
const PthMomentLoc & getMonomialLocMapDegreePLess1() const
Definition: LSProblem.H:99
#define BDID_DIR
Definition: Notation.H:88
bool m_bdCCOn
Definition: CutCellMoments.H:150
double Real
Definition: REAL.H:33
Real fullCellQuadrature(const IndexTM< int, dim > &a_mono, const CoordinateSystem< dim > &a_coord)
Definition: CutCellMomentsImplem.H:269
bool isRegular() const
Definition: CutCellMomentsImplem.H:669
map< IvDim, int, LexLT< IvDim > > PthMomentLoc
Definition: CutCellMoments.H:44
map< IndexTM< int, dim-1 >, Real, LexLT< IndexTM< int, dim-1 > > > PthMomentLesserDimension
Definition: CutCellMoments.H:40
size_t size() const
Definition: Vector.H:177
bool m_allVerticesIn
Definition: IFData.H:64
Definition: Notation.H:104
void initialize(CutCellMoments< dim > &a_refinedCutCell)
Definition: CutCellMomentsImplem.H:443
static void Warning(const char *const a_msg=m_nullString)
Print out message to cerr and continue.
int m_numActiveBounds
Definition: CutCellMoments.H:156
void changeMomentCoordinatesToParentCenter()
Definition: CutCellMomentsImplem.H:421
PthMoment m_moments
Definition: CutCellMoments.H:138
bool m_allVerticesOut
Definition: IFData.H:65
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)
Definition: CutCellMomentsImplem.H:116
Real getBdMoment(const IvDim &a_mono, const IFData< dim+1 > &a_IFData, const IndexTM< Real, dim > &a_refinedCenterDelta, PthMoment a_fullCellMap=PthMoment())
Definition: CutCellMomentsImplem.H:494
void initializeMap(PthMoment &a_map1, PthMoment &a_map2)
Definition: CutCellMomentsImplem.H:476
RvDim getCentroid(const EBorVol &a_EBorVOL) const
Definition: CutCellMomentsImplem.H:593
int m_maxOrder
Definition: IFData.H:60
PthMoment m_EBmoments
Definition: CutCellMoments.H:141
const CutCellMoments< dim - 1 > getBdCutCellMoments(const Iv2 &a_bdId) const
Definition: CutCellMomentsImplem.H:100
map< IvDim, Real, LexLT< IvDim > > PthMoment
Definition: CutCellMoments.H:38
void operator=(const CutCellMoments< dim > &a_cutCellMoments)
Definition: CutCellMomentsImplem.H:787
Real getBdEBMoment(const IvDim &a_mono, const IFData< dim+1 > &a_IFData, const IndexTM< Real, dim > &a_refinedCenterDelta)
Definition: CutCellMomentsImplem.H:520
void dump() const
Definition: CutCellMomentsImplem.H:781
int dim
Definition: EBInterface.H:146
ostream & operator<<(ostream &a_out, const CutCellMoments< dim > &a_cutCellMoments)
Definition: CutCellMomentsImplem.H:803
#define GLOBALDIM
Definition: Notation.H:35
Definition: CutCellMoments.H:32
static const IndexTM Zero
Definition: IndexTM.H:431
Real changeMomentCoordinates(PthMoment &a_refinedMomentMap, const IndexTM< int, dim > &a_monomial, const IndexTM< Real, dim > &a_refinedCenterDelta)
Definition: CutCellMomentsImplem.H:293
#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).