28 m_stlGeometry =
new typename GeometryXD<nDim>::type(solver, comm);
33 return m_stlGeometry->geometryContext().getNoSegments();
38 m_stlGeometry->getBoundingBox(bbox);
43 MBool*
const cutInfo) {
44 std::vector<MInt> nodeList;
45 MFloat targetRegion[2 * nDim];
46 for(
MInt dim = 0; dim < nDim; dim++) {
47 targetRegion[dim] = coords[dim] - cellHalfLength;
48 targetRegion[dim + nDim] = coords[dim] + cellHalfLength;
52 for(
MInt seg = 0; seg < noSegments(); seg++) {
57 m_stlGeometry->getIntersectionElements(targetRegion, nodeList, cellHalfLength, coords);
58 const MInt noNodes = nodeList.size();
61 for(
MInt n = 0; n < noNodes; n++) {
62 cutInfo[m_stlGeometry->elements[nodeList[n]].m_segmentId] =
true;
64 return (
MBool)noNodes;
69 std::vector<MInt> nodeList;
72 for(
MInt dim = 0; dim < nDim; dim++) {
73 tmp_line[dim] = line[dim];
74 tmp_line[dim + nDim] = line[dim + nDim];
78 m_stlGeometry->getLineIntersectionElements(tmp_line, nodeList);
80 return nodeList.size();
87 for(
MInt i = 0; i < nDim; i++) {
88 if(bbox[i + nDim] < bbox[i])
mTerm(1, AT_,
"invalid bounding box");
90 m_bbox[i + nDim] = bbox[i + nDim];
101 for(
MInt dim = 0; dim < nDim; dim++) {
102 bbox[dim] = m_bbox[dim];
103 bbox[dim + nDim] = m_bbox[dim + nDim];
109 const MFloat cellHalfLength,
110 MBool*
const cutInfo) {
111 MFloat cell_bbox[2 * nDim];
112 for(
MInt dim = 0; dim < nDim; dim++) {
113 cell_bbox[dim] = cell_coords[dim] - cellHalfLength;
114 cell_bbox[dim + nDim] = cell_coords[dim] + cellHalfLength;
117 if(maia::geom::doBoxesOverlap<MFloat, nDim>(cell_bbox, m_bbox)
118 && !maia::geom::isBoxInsideBox<MFloat, nDim>(cell_bbox, m_bbox)) {
129 const MBool p1_inside = maia::geom::isPointInsideBox<MFloat, nDim>(line, m_bbox);
130 const MBool p2_inside = maia::geom::isPointInsideBox<MFloat, nDim>(line + nDim, m_bbox);
132 if(p1_inside && p2_inside)
return 0;
134 if(p1_inside != p2_inside)
return 1;
137 if(maia::geom::doesLinePenetrateBox<nDim>(line, m_bbox))
147 for(
MInt i = 0; i < nDim; i++) {
160 for(
MInt dim = 0; dim < nDim; dim++) {
161 bbox[dim] = m_center[dim] - m_radius;
162 bbox[dim + nDim] = m_center[dim] + m_radius;
168 const MFloat cellHalfLength,
169 MBool*
const cutInfo) {
170 MFloat cell_bbox[2 * nDim];
171 for(
MInt dim = 0; dim < nDim; dim++) {
172 cell_bbox[dim] = cell_coords[dim] - cellHalfLength;
173 cell_bbox[dim + nDim] = cell_coords[dim] + cellHalfLength;
176 if(maia::geom::doBoxAndSphereOverlap<nDim>(cell_bbox, m_center, m_radius)
177 && !maia::geom::isBoxInsideSphere<nDim>(cell_bbox, m_center, m_radius)) {
187 if(!maia::geom::doesLinePenetrateSphere<nDim>(line, m_center, m_radius))
return 0;
190 const MBool p1_inside = maia::geom::isPointInsideSphere<nDim>(line, m_center, m_radius);
192 if(p1_inside)
return 1;
195 const MBool p2_inside = maia::geom::isPointInsideSphere<nDim>(line + nDim, m_center, m_radius);
220 "noSurfacesPerNode");
235 surfaceType = Context::getSolverProperty<MString>(
"solverSurfaceType", node, AT_, &surfaceType, srfc);
251 for(
MInt dir = 0; dir < 2 * nDim; dir++) {
252 bbox[dir] = Context::getSolverProperty<MFloat>(
"analyticSolverBoundingBox", i, AT_, dir);
260 for(
MInt dir = 0; dir < nDim; dir++) {
261 center[dir] = Context::getSolverProperty<MFloat>(
"analyticSolverBoundingSphere", i, AT_, dir);
263 const MFloat radius = Context::getSolverProperty<MFloat>(
"analyticSolverBoundingSphere", i, AT_, nDim);
268 mTerm(1, AT_,
"unknown surface type");
283 bBox[dim] = numeric_limits<MFloat>::max();
284 bBox[dim +
m_nDim] = numeric_limits<MFloat>::lowest();
290 tmpBB[dim] = numeric_limits<MFloat>::max();
291 tmpBB[dim +
m_nDim] = numeric_limits<MFloat>::lowest();
297 bBox[dim] =
mMin(bBox[dim], tmpBB[dim]);
308 bBox[dim] = numeric_limits<MFloat>::max();
309 bBox[dim +
m_nDim] = numeric_limits<MFloat>::lowest();
316 tmpBB[dim] = numeric_limits<MFloat>::max();
317 tmpBB[dim +
m_nDim] = numeric_limits<MFloat>::lowest();
323 bBox[dim] =
mMin(bBox[dim], tmpBB[dim]);
339 MFloat bbox[2 * MAX_SPACE_DIMENSIONS];
340 MFloat line[2 * MAX_SPACE_DIMENSIONS];
341 MFloat bbExtend[MAX_SPACE_DIMENSIONS];
346 line[dim] = point[dim];
347 bbExtend[dim] = bbox[dim +
m_nDim] - bbox[dim];
351 for(
MInt rayDim = 0; rayDim <
m_nDim; rayDim++) {
353 line[dim +
m_nDim] = point[dim];
355 line[rayDim +
m_nDim] += 2 * bbExtend[rayDim];
361 retVal = retVal && ((noIntersec % 2) == 1);
362 if(!retVal)
return false;
368 MBool*
const*
const cutInfo) {
369 MBool retVal =
false;
372 retVal = retVal || newCut;
380 MBool retVal =
false;
383 const MInt cutOffset = 0;
401 cout <<
"SolverGeometry constructor" << endl;
void mAlloc(T *&a, const MLong N, const MString &objectName, MString function)
allocates memory for one-dimensional array 'a' of size N
GeometryDistribution m_distribution
GeometryNode(GeometryBase *geometryRoot, MInt node, MPI_Comm comm)
GeometryBase * m_geometry
SolverSurface ** m_solverSurface
MBool getCellIntersectingSurfaces(const MFloat *const coords, const MFloat cellHalfLength, MBool *const *const cutInfo)
MBool isPointInside(const MFloat *const point)
void initGeometry(const MInt noSolvers)
void boundingBox(MFloat *const bBox)
MInt noSegmentsOfNode(const MInt node)
void setGeometryPointerToNode(Geometry< nDim > *&geometryPointer, const MInt node)
MBool getCellIntersectingSurfacesOfNode(const MFloat *const coords, const MFloat cellHalfLength, MBool *const cutInfo, const MInt node)
MBool isPointInsideNode(const MFloat *const point, const MInt node)
void boundingBoxOfNode(MFloat *const bBox, const MInt node)
MInt * m_solverSurfaceType
SolverAnalyticBoxSurface(const MFloat *const bbox)
MInt countLineIntersectingElements(const MFloat *const line)
void boundingBox(MFloat *const bbox)
MBool getCellIntersectingElements(const MFloat *const cell_coords, const MFloat cellHalfLength, MBool *const cutInfo)
SolverAnalyticSphereSurface(const MFloat *const c, const MFloat R)
MInt countLineIntersectingElements(const MFloat *const line)
MBool getCellIntersectingElements(const MFloat *const cell_coords, const MFloat cellHalfLength, MBool *const cutInfo)
void boundingBox(MFloat *const bbox)
MInt countLineIntersectingElements(const MFloat *const line)
MBool getCellIntersectingElements(const MFloat *const coords, const MFloat cellHalfLength, MBool *const cutInfo)
void boundingBox(MFloat *const bbox)
SolverSTLSurface(const MPI_Comm comm, const MInt solver)
virtual void boundingBox(MFloat *const)
virtual MInt countLineIntersectingElements(const MFloat *const)
virtual MInt noSegments()
virtual MBool getCellIntersectingElements(const MFloat *const, const MFloat, MBool *const)
virtual void setGeometryPointer(Geometry< 2 > *&)
MInt string2enum(MString theString)
This global function translates strings in their corresponding enum values (integer values)....
void mTerm(const MInt errorCode, const MString &location, const MString &message)
constexpr T mMin(const T &x, const T &y)
constexpr T mMax(const T &x, const T &y)
std::basic_string< char > MString