11 #ifndef _IFDATAIMPLEM_H_ 12 #define _IFDATAIMPLEM_H_ 14 #if defined(CH_Darwin) && defined(__GNUC__) && ( __GNUC__ == 3 ) 17 #define _GLIBCPP_USE_C99 1 27 #include "NamespaceHeader.H" 37 :m_cornerSigns (a_IFData.m_cornerSigns),
38 m_intersections (a_IFData.m_intersections),
39 m_globalCoord (a_IFData.m_globalCoord),
40 m_cellCenterCoord (a_IFData.m_cellCenterCoord),
41 m_parentCoord (a_IFData.m_parentCoord),
42 m_localCoord (a_IFData.m_localCoord),
43 m_maxOrder (a_IFData.m_maxOrder),
44 m_normalDerivatives (a_IFData.m_normalDerivatives),
45 m_badNormal (a_IFData.m_badNormal),
46 m_allVerticesIn (a_IFData.m_allVerticesIn),
47 m_allVerticesOut (a_IFData.m_allVerticesOut),
48 m_allVerticesOn (a_IFData.m_allVerticesOn)
50 CH_TIME(
"ifdata constructor 1");
67 const RvDim & a_cellCenter,
68 const int & a_maxOrder)
74 CH_TIME(
"ifdata constructor 2");
97 const RvDim & a_cellCenter,
98 const int & a_maxOrder)
104 CH_TIME(
"ifdata constructor 3");
123 const int & a_maxOrder,
127 CH_TIME(
"ifdata constructor 4");
129 typedef map<HDEdgeIndex,Real > HDEdgeIntersections;
131 typedef map<HDVertex,int > HDCornerSigns;
139 int fixedComp = a_idir;
160 for (
typename HDCornerSigns::const_iterator it = a_hIFData.
m_cornerSigns.begin();
163 const HDVertex& hVertex = it->first;
164 if (hVertex[fixedComp] == a_hilo)
167 for (
int j = 0; j <
dim; ++j)
171 vertex[j] = hVertex[j];
175 vertex[j] = hVertex[j+1];
187 m_allVerticesIn =
false;
193 for (
typename HDEdgeIntersections::const_iterator it = a_hIFData.
m_intersections.begin();
196 const HDEdgeIndex& hEdgeIndex = it->first;
198 int hEdgeDir = hEdgeIndex[0];
206 if (hEdgeDir < fixedComp)
208 if (hEdgeIndex[fixedComp] == a_hilo)
210 edgeIndex[0] = hEdgeDir;
212 for (
int j = 1; j <
dim; ++j)
216 edgeIndex[j] = hEdgeIndex[j];
220 edgeIndex[j] = hEdgeIndex[j+1];
226 else if (hEdgeDir > fixedComp)
228 if (hEdgeIndex[fixedComp+1] == a_hilo)
230 edgeIndex[0] = hEdgeDir - 1;
232 for (
int j = 1; j <
dim; ++j)
236 edgeIndex[j] = hEdgeIndex[j];
240 edgeIndex[j] = hEdgeIndex[j+1];
275 CH_TIME(
"ifdata::setNormalDerivatives");
283 for (
int order = 0; order <=
m_maxOrder; order++)
289 for (
int i = 0; i < derivatives.
size(); ++i)
291 const IvDim & derivative = derivatives[i];
293 for (
int idir = 0; idir <
dim; idir++)
306 CH_TIME(
"ifdata::makeCornerSigns");
314 int numVertices = 1 <<
dim;
316 for (
int i = 0; i < numVertices; ++i)
321 for (
int j = 0; j <
dim; ++j)
324 vertex[j] = (ii & 1);
330 for (
int idir = 0; idir <
dim; ++idir)
332 corner[idir] = vertex[idir] - 0.5;
364 CH_TIME(
"ifdata::findIntersectionPoints");
366 for (
typename CornerSigns::const_iterator it0 =
m_cornerSigns.begin();
369 for (
typename CornerSigns::const_iterator it1 =
m_cornerSigns.begin();
383 CH_TIME(
"ifdata::defineLocalCoords");
403 const Real& intercept = it->second;
405 int varyDir = edgeIndex[0];
408 intersectPt[varyDir] = intercept;
410 for (
int i = 1; i <
dim; i++)
425 intersectPt[curDir] = loHi - 0.5;
443 CH_TIME(
"ifdata::isConnected");
444 bool connected =
true;
449 for (
int idir = 0; idir <
dim; ++idir)
451 if (a_vertex1[idir] != a_vertex2[idir])
476 CH_TIME(
"ifdata::makeedgekey");
479 thisEdge[0] = a_edgeDir;
481 for (
int idir = 0; idir <
dim; ++idir)
483 if (idir < a_edgeDir)
485 thisEdge[idir + 1] = a_vertex0[idir];
487 else if (idir > a_edgeDir)
489 thisEdge[idir] = a_vertex0[idir];
514 if ((lo ==
OUT && hi ==
IN) || (lo ==
IN && hi ==
OUT))
550 if (lo ==
IN && hi ==
ON)
555 else if (lo ==
ON && hi ==
IN)
569 int edgeDir = a_thisEdge[0];
577 for (
int idir = 0; idir <
dim; ++idir)
581 loEnd[idir] = a_thisEdge[idir + 1];
582 hiEnd[idir] = a_thisEdge[idir + 1];
584 else if (idir > edgeDir)
586 loEnd[idir] = a_thisEdge[idir];
587 hiEnd[idir] = a_thisEdge[idir];
595 for (
int idir = 0; idir <
dim; ++idir)
617 const RvDim & a_hiPt,
618 const int & a_edgeDir)
const 622 CH_TIME(
"ifdata::brentrootfinder");
624 const unsigned int MAXITER = 100;
625 const Real EPS = 3.0e-15;
638 RvDim physCoordAPt = a_loPt;
639 RvDim physCoordBPt = a_hiPt;
649 pout() <<
"fa " << fa <<
" fb " << fb <<endl;
650 MayDay::Abort(
"IFData::BrentRootFinder. Root must be bracketed, but instead the supplied end points have the same sign.");
655 for (i = 0; i < MAXITER; i++)
678 xm = 0.5 * (c - bPt);
680 if (
Abs(xm) <= tol1 || fb == 0.0)
698 p = s * (2.0 * xm * q * (q-r) - (bPt-aPt) * (r-1.0));
699 q = (q-1.0) * (r-1.0) * (s-1.0);
738 if (xm < 0) bPt = bPt - tol1;
739 else bPt = bPt + tol1;
742 physCoordBPt[a_edgeDir] = ((1.0 - bPt)/2.0) * a_loPt[a_edgeDir] + ((1.0 + bPt)/2.0) * a_hiPt[a_edgeDir];
748 cerr <<
"BrentRootFinder: exceeding maximum iterations: " 758 const Real & a_pt)
const 779 for (
typename CornerSigns::const_iterator it =
m_cornerSigns.begin();
782 if (it->second ==
IN)
787 if (it->second ==
OUT)
792 if (it->second !=
ON)
803 string padding =
" ";
811 a_out << padding <<
"undefined IFData\n";
815 for (
typename CornerSigns::const_iterator it =
m_cornerSigns.begin();
818 a_out << padding <<
"Vertex " 825 a_out << padding <<
"\n";
827 for (
typename EdgeIntersections::const_iterator it =
m_intersections.begin();
831 std::ios::fmtflags origFlags = a_out.flags();
832 int origWidth = a_out.width();
833 int origPrecision = a_out.precision();
835 a_out << padding <<
"EdgeIndex " 839 << setiosflags(ios::showpoint)
840 << setiosflags(ios::scientific)
845 a_out.flags(origFlags);
846 a_out.width(origWidth);
847 a_out.precision(origPrecision);
849 a_out << padding <<
"\n";
854 a_out << padding <<
"m_badNormal = " <<
m_badNormal <<
"\n";
855 a_out << padding <<
"\n";
857 if (!m_allVerticesOut)
863 a_out << padding <<
"\n";
865 a_out << padding <<
"m_maxOrder = " <<
m_maxOrder <<
"\n";
867 std::ios::fmtflags origFlags = a_out.flags();
868 int origWidth = a_out.width();
869 int origPrecision = a_out.precision();
871 a_out << padding <<
"m_normalDerivatives = " <<
"\n";
877 for (
int idir = 0; idir <
dim; idir++)
879 a_out << padding <<
" " 885 << setiosflags(ios::showpoint)
886 << setiosflags(ios::scientific)
887 << (it->second)[idir]
890 a_out << padding <<
"\n";
893 a_out.flags(origFlags);
894 a_out.width(origWidth);
895 a_out.precision(origPrecision);
899 a_out << padding <<
"All vertices out" <<
"\n";
901 a_out << padding <<
"\n";
908 a_IFData.
print(a_out);
916 if (
this != &a_IFData)
952 #include "NamespaceFooter.H" std::ostream & pout()
Use this in place of std::cout for program output.
NormalDerivatives m_normalDerivatives
Definition: IFData.H:68
Definition: CoordinateSystem.H:34
Real BrentRootFinder(const RvDim &a_loPt, const RvDim &a_hiPt, const int &a_edgeDir) const
Definition: IFDataImplem.H:616
void makeEdgeKey(const int &a_edgeDir, const Vertex &a_vertex1, const Vertex &a_vertex2)
Definition: IFDataImplem.H:472
~IFData()
Definition: IFDataImplem.H:265
#define LARGEREALVAL
Definition: Notation.H:77
void checkIntersection(bool &a_hiOn, bool &a_loOn, const Real &a_pt) const
Definition: IFDataImplem.H:756
#define LARGEINTVAL
Definition: Notation.H:76
one dimensional dynamic array
Definition: Vector.H:53
bool isConnected(int &a_edgeDir, const Vertex &a_vertex1, const Vertex &a_vertex2)
Definition: IFDataImplem.H:439
CoordinateSystem< dim > m_parentCoord
Definition: IFData.H:64
IFSlicer< dim > * m_function
Definition: IFData.H:60
#define TOLERANCE
Definition: Notation.H:78
IFData()
Definition: IFDataImplem.H:30
CoordinateSystem< dim > m_localCoord
Definition: IFData.H:65
void operator=(const IFData &a_ifData)
Definition: IFDataImplem.H:913
#define CH_TIME(name)
Definition: CH_Timer.H:82
void setNormalDerivatives()
Definition: IFDataImplem.H:273
CoordinateSystem< dim > m_globalCoord
Definition: IFData.H:62
This computes the derivatives of the normal of a sliced implicit function.
Definition: NormalDerivativeNew.H:26
bool m_allVerticesOn
Definition: IFData.H:73
double Real
Definition: REAL.H:33
void makeCornerSigns()
Definition: IFDataImplem.H:304
#define ON
Definition: Notation.H:84
T Abs(const T &a_a)
Definition: Misc.H:53
NormalDerivativeMap calculateAll(const int &a_maxP, const RvDim &a_point, const IFSlicer< dim > *a_implicitFunction)
Evaluate all derivatives of the normal of an IFSlicer class.
Definition: NormalDerivativeNew.H:84
size_t size() const
Definition: Vector.H:192
bool m_allVerticesIn
Definition: IFData.H:71
CoordinateSystem< dim > m_cellCenterCoord
Definition: IFData.H:63
static bool s_turnOffMoveLocalCoords
Definition: IFData.H:39
Definition: IFSlicer.H:27
map< IvDim, RvDim, LexLT< IvDim > > NormalDerivativeMap
Definition: NormalDerivativeNew.H:35
#define MACHINEPRECISION
Definition: Notation.H:79
bool m_allVerticesOut
Definition: IFData.H:72
T Min(const T &a_a, const T &a_b)
Definition: Misc.H:26
CornerSigns m_cornerSigns
Definition: IFData.H:58
void remakeCornerSigns()
Definition: IFDataImplem.H:773
ostream & operator<<(ostream &a_out, const IFData< dim > &a_IFData)
Definition: IFDataImplem.H:905
void defineLocalCoords()
Definition: IFDataImplem.H:381
int m_maxOrder
Definition: IFData.H:67
EdgeIntersections m_intersections
Definition: IFData.H:59
#define IN
Definition: Notation.H:85
void print(ostream &out) const
Definition: IFDataImplem.H:799
void findIntersectionPts()
Definition: IFDataImplem.H:362
#define OUT
Definition: Notation.H:83
Real rootFinder(const EdgeIndex &a_thisEdge)
Definition: IFDataImplem.H:562
void generateMultiIndices(Vector< IndexTM< int, dim > > &a_indices, const int &a_magnitude)
Definition: MultiIndexImplem.H:18
int dim
Definition: EBInterface.H:146
#define GLOBALDIM
Definition: Notation.H:35
static const IndexTM Zero
Definition: IndexTM.H:467
bool m_badNormal
Definition: IFData.H:69
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).