52 if (have_inside_pt ==
false) {
54 "ArbitraryDomain::ArbitraryDomain()",
55 "No point inside geometry found/set!");
59 "This domain is currently not available.");
72 int zGhostOffsetLeft = (localId[2].first()== 0) ? 0 : 1;
73 int zGhostOffsetRight = (localId[2].last() ==
nr_m[2] - 1) ? 0 : 1;
74 int yGhostOffsetLeft = (localId[1].first()== 0) ? 0 : 1;
75 int yGhostOffsetRight = (localId[1].last() ==
nr_m[1] - 1) ? 0 : 1;
76 int xGhostOffsetLeft = (localId[0].first()== 0) ? 0 : 1;
77 int xGhostOffsetRight = (localId[0].last() ==
nr_m[0] - 1) ? 0 : 1;
95 for (
int idz = localId[2].first()-zGhostOffsetLeft; idz <= localId[2].last()+zGhostOffsetRight; idz++) {
99 for (
int idy = localId[1].first()-yGhostOffsetLeft; idy <= localId[1].last()+yGhostOffsetRight; idy++) {
103 for (
int idx = localId[0].first()-xGhostOffsetLeft; idx <= localId[0].last()+xGhostOffsetRight; idx++) {
120 std::tuple<int, int, int> pos(idx, idy, idz);
125 intersectHiZ_m.insert(std::pair< std::tuple<int, int, int>,
double >(pos, I[2]));
127 #ifdef DEBUG_INTERSECT_RAY_BOUNDARY
128 *
gmsg <<
"zdir=+1 " << dir <<
" x,y,z= " << idx <<
"," << idy
129 <<
"," << idz <<
" P=" << P <<
" I=" << I <<
endl;
134 intersectLoZ_m.insert(std::pair< std::tuple<int, int, int>,
double >(pos, I[2]));
136 #ifdef DEBUG_INTERSECT_RAY_BOUNDARY
137 *
gmsg <<
"zdir=-1 " << -dir <<
" x,y,z= " << idx <<
"," << idy
138 <<
"," << idz <<
" P=" << P <<
" I=" << I <<
endl;
145 intersectHiY_m.insert(std::pair< std::tuple<int, int, int>,
double >(pos, I[1]));
147 #ifdef DEBUG_INTERSECT_RAY_BOUNDARY
148 *
gmsg <<
"ydir=+1 " << dir <<
" x,y,z= " << idx <<
"," << idy
149 <<
"," << idz <<
" P=" << P <<
" I=" << I <<
endl;
154 intersectLoY_m.insert(std::pair< std::tuple<int, int, int>,
double >(pos, I[1]));
156 #ifdef DEBUG_INTERSECT_RAY_BOUNDARY
157 *
gmsg <<
"ydir=-1" << -dir <<
" x,y,z= " << idx <<
"," << idy
158 <<
"," << idz <<
" P=" << P <<
" I=" << I <<
endl;
165 intersectHiX_m.insert(std::pair< std::tuple<int, int, int>,
double >(pos, I[0]));
167 #ifdef DEBUG_INTERSECT_RAY_BOUNDARY
168 *
gmsg <<
"xdir=+1 " << dir <<
" x,y,z= " << idx <<
"," << idy
169 <<
"," << idz <<
" P=" << P <<
" I=" << I <<
endl;
174 intersectLoX_m.insert(std::pair< std::tuple<int, int, int>,
double >(pos, I[0]));
176 #ifdef DEBUG_INTERSECT_RAY_BOUNDARY
177 *
gmsg <<
"xdir=-1 " << -dir <<
" x,y,z= " << idx <<
"," << idy
178 <<
"," << idz <<
" P=" << P <<
" I=" << I <<
endl;
183 #ifdef DEBUG_INTERSECT_RAY_BOUNDARY
184 *
gmsg <<
"OUTSIDE" <<
" x,y,z= " << idx <<
"," << idy
185 <<
"," << idz <<
" P=" << P <<
" I=" << I <<
endl;
195 int numGhostNodesLeft = 0;
196 if(localId[2].first() != 0) {
197 for(
int idx = 0; idx <
nr_m[0]; idx++) {
198 for(
int idy = 0; idy <
nr_m[1]; idy++) {
199 if(
isInside(idx, idy, localId[2].first() - zGhostOffsetLeft))
205 INFOMSG(
level2 <<
"* Finding number of xy points in each plane along z..." <<
endl);
210 for(
int idz = localId[2].first(); idz <= localId[2].last(); idz++) {
212 for(
int idx = 0; idx <
nr_m[0]; idx++) {
213 for(
int idy = 0; idy <
nr_m[1]; idy++) {
218 numXY_m[idz-localId[2].first()] = numxy;
223 MPI_Scan(&numtotal, &startIdx, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
224 startIdx -= numtotal;
229 int index = startIdx - numGhostNodesLeft;
233 for(
int idz = localId[2].first() - zGhostOffsetLeft; idz <= localId[2].last() + zGhostOffsetRight; idz++) {
234 for(
int idy = 0; idy <
nr_m[1]; idy++) {
235 for(
int idx = 0; idx <
nr_m[0]; idx++) {
280 double cx = (idx - (
nr_m[0]-1)/2.0)*
hr_m[0];
281 double cy = (idy - (
nr_m[1]-1)/2.0)*
hr_m[1];
282 double cz = (idz - (
nr_m[2]-1)/2.0)*
hr_m[2];
292 std::tuple<int, int, int> coordxyz(idx, idy, idz);
294 if (idx ==
nr_m[0]-1)
298 if (idy ==
nr_m[1]-1)
302 if (idz ==
nr_m[2]-1)
308 value.
west = -(dz_f + dz_b) * (dy_n + dy_s) / dx_w;
312 value.
east = -(dz_f + dz_b) * (dy_n + dy_s) / dx_e;
316 value.
north = -(dz_f + dz_b) * (dx_w + dx_e) / dy_n;
320 value.
south = -(dz_f + dz_b) * (dx_w + dx_e) / dy_s;
324 value.
front = -(dx_w + dx_e) * (dy_n + dy_s) / dz_f;
328 value.
back = -(dx_w + dx_e) * (dy_n + dy_s) / dz_b;
337 scaleFactor *= (dx_w + dx_e);
339 scaleFactor *= (dy_n + dy_s);
341 scaleFactor *= (dz_f + dz_b);
344 double m1 = dx_w * dx_e;
345 double m2 = dy_n * dy_s;
356 if(dx_w != 0 || dx_e != 0)
357 value.
center *= (dx_w + dx_e);
358 if(dy_n != 0 || dy_s != 0)
359 value.
center *= (dy_n + dy_s);
360 if(dx_w != 0 || dx_e != 0)
361 value.
center += (dz_f + dz_b) * (dy_n + dy_s) * (dx_w + dx_e) / m1;
362 if(dy_n != 0 || dy_s != 0)
363 value.
center += (dz_f + dz_b) * (dx_w + dx_e) * (dy_n + dy_s) / m2;
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
Inform & endl(Inform &inf)
Inform & level2(Inform &inf)
PointList_t intersectHiY_m
all intersection points with gridlines in Y direction
std::map< int, bool > isInsideMap_m
void linearInterpolation(int idx, int idy, int idz, StencilValue_t &value, double &scaleFactor) const override
PointList_t intersectLoZ_m
BoundaryGeometry * bgeom_m
Vector_t globalInsideP0_m
int toCoordIdx(int idx, int idy, int idz) const
PointList_t intersectHiZ_m
all intersection points with gridlines in Z direction
std::map< int, int > numXY_m
PointList_t intersectHiX_m
all intersection points with gridlines in X direction
PointList_t intersectLoX_m
ArbitraryDomain(BoundaryGeometry *bgeom, IntVector_t nr, Vector_t hr, std::string interpl)
void constantInterpolation(int idx, int idy, int idz, StencilValue_t &value, double &scaleFactor) const override
different interpolation methods for boundary points
void compute(Vector_t hr, NDIndex< 3 > localId)
PointList_t intersectLoY_m
bool isInside(int idx, int idy, int idz) const
queries if a given (x,y,z) coordinate lies inside the domain
IntVector_t nr_m
number of mesh points in each direction
std::map< int, int > coordMap_m
mapping idx -> (x,y,z)
void setRangeMin(const Vector_t &min)
bool hasGeometryChanged_m
flag indicating if geometry has changed for the current time-step
double getZRangeMin() const
double getXRangeMin() const
std::map< int, int > idxMap_m
mapping (x,y,z) -> idx
double getYRangeMin() const
Vector_t hr_m
mesh-spacings in each direction
void setRangeMax(const Vector_t &max)
int fastIsInside(const Vector_t &reference_pt, const Vector_t &P)
int intersectRayBoundary(const Vector_t &P, const Vector_t &v, Vector_t &I)
bool getInsidePoint(Vector_t &pt)
The base class for all OPAL exceptions.
Vektor< double, 3 > Vector_t