32 const Foam::label Foam::enrichedPatch::enrichedFaceRatio_ = 3;
43 if (enrichedFacesPtr_)
47 "void enrichedPatch::calcEnrichedFaces\n" 49 " const labelListList& pointsIntoMasterEdges,\n" 50 " const labelListList& pointsIntoSlaveEdges,\n" 51 " const pointField& projectedSlavePoints\n" 53 ) <<
"Enriched faces already calculated." 66 enrichedFacesPtr_ =
new faceList(masterPatch_.size() + slavePatch_.size());
67 faceList& enrichedFaces = *enrichedFacesPtr_;
69 label nEnrichedFaces = 0;
71 const pointField& masterLocalPoints = masterPatch_.localPoints();
72 const faceList& masterLocalFaces = masterPatch_.localFaces();
73 const labelListList& masterFaceEdges = masterPatch_.faceEdges();
75 const faceList& slaveLocalFaces = slavePatch_.localFaces();
76 const labelListList& slaveFaceEdges = slavePatch_.faceEdges();
89 const face oldFace = slavePatch_[faceI];
90 const face oldLocalFace = slaveLocalFaces[faceI];
92 const labelList& curEdges = slaveFaceEdges[faceI];
102 pmm.
find(oldFace[i]);
104 if (mpIter == pmm.
end())
107 newFace.append(oldFace[i]);
113 projectedSlavePoints[oldLocalFace[i]]
119 newFace.append(mpIter());
125 projectedSlavePoints[oldLocalFace[i]]
132 pointsIntoSlaveEdges[curEdges[i]];
140 if (slavePointsOnEdge.
size())
144 const point& startPoint = projectedSlavePoints[oldLocalFace[i]];
147 projectedSlavePoints[oldLocalFace.nextLabel(i)]
150 scalar magSqrE =
magSqr(e);
160 "void enrichedPatch::calcEnrichedFaces\n" 162 " const labelListList& pointsIntoMasterEdges,\n" 163 " const labelListList& pointsIntoSlaveEdges,\n" 164 " const pointField& projectedSlavePoints\n" 166 ) <<
"Zero length edge in slave patch for face " << i
167 <<
". This is not allowed." 173 forAll(slavePointsOnEdge, edgePointI)
175 slavePosOnEdge[edgePointI] =
176 pointMap().find(slavePointsOnEdge[edgePointI])();
178 edgePointWeights[edgePointI] =
179 (e & (slavePosOnEdge[edgePointI] - startPoint));
185 if (
min(edgePointWeights) < 0 ||
max(edgePointWeights) > 1)
189 "void enrichedPatch::calcEnrichedFaces\n" 191 " const labelListList& pointsIntoMasterEdges,\n" 192 " const labelListList& pointsIntoSlaveEdges,\n" 193 " const pointField& projectedSlavePoints\n" 195 ) <<
"Invalid point edge weights. Some of points are" 196 <<
" not on the edge for edge " << curEdges[i]
197 <<
" of face " << faceI <<
" in slave patch." <<
nl 198 <<
"Min weight: " <<
min(edgePointWeights)
199 <<
" Max weight: " <<
max(edgePointWeights)
207 forAll(edgePointWeights, passI)
211 label nextPoint = -1;
214 forAll(edgePointWeights, wI)
216 if (edgePointWeights[wI] < dist)
218 dist = edgePointWeights[wI];
225 newFace.append(slavePointsOnEdge[nextPoint]);
226 edgePointWeights[nextPoint] = GREAT;
231 slavePointsOnEdge[nextPoint],
232 slavePosOnEdge[nextPoint]
240 enrichedFaces[nEnrichedFaces].transfer(newFace);
246 forAll(masterPatch_, faceI)
248 const face& oldFace = masterPatch_[faceI];
249 const face& oldLocalFace = masterLocalFaces[faceI];
251 const labelList& curEdges = masterFaceEdges[faceI];
261 pmm.
find(oldFace[i]);
263 if (mpIter == pmm.
end())
266 newFace.append(oldFace[i]);
272 masterLocalPoints[oldLocalFace[i]]
278 newFace.append(mpIter());
281 pointMap().insert(mpIter(), masterLocalPoints[oldLocalFace[i]]);
287 pointsIntoMasterEdges[curEdges[i]];
291 if (masterPointsOnEdge.
size())
295 const point& startPoint = masterLocalPoints[oldLocalFace[i]];
298 masterLocalPoints[oldLocalFace.nextLabel(i)]
301 scalar magSqrE =
magSqr(e);
311 "void enrichedPatch::calcEnrichedFaces\n" 313 " const labelListList& pointsIntoMasterEdges,\n" 314 " const labelListList& pointsIntoSlaveEdges,\n" 315 " const pointField& projectedSlavePoints\n" 317 ) <<
"Zero length edge in master patch for face " << i
318 <<
". This is not allowed." 324 forAll(masterPointsOnEdge, edgePointI)
326 masterPosOnEdge[edgePointI] =
327 pointMap().find(masterPointsOnEdge[edgePointI])();
329 edgePointWeights[edgePointI] =
330 (e & (masterPosOnEdge[edgePointI] - startPoint));
336 if (
min(edgePointWeights) < 0 ||
max(edgePointWeights) > 1)
340 "void enrichedPatch::calcEnrichedFaces\n" 342 " const labelListList& pointsIntoMasterEdges,\n" 343 " const labelListList& pointsIntoSlaveEdges,\n" 344 " const pointField& projectedSlavePoints\n" 346 ) <<
"Invalid point edge weights. Some of points are" 347 <<
" not on the edge for edge " << curEdges[i]
348 <<
" of face " << faceI <<
" in master patch." <<
nl 349 <<
"Min weight: " <<
min(edgePointWeights)
350 <<
" Max weight: " <<
max(edgePointWeights)
358 forAll(edgePointWeights, passI)
362 label nextPoint = -1;
365 forAll(edgePointWeights, wI)
367 if (edgePointWeights[wI] < dist)
369 dist = edgePointWeights[wI];
376 newFace.append(masterPointsOnEdge[nextPoint]);
377 edgePointWeights[nextPoint] = GREAT;
382 masterPointsOnEdge[nextPoint],
383 masterPosOnEdge[nextPoint]
391 enrichedFaces[nEnrichedFaces].transfer(newFace);
400 Info<<
"Enriched patch support OK. Slave faces: " 401 << slavePatch_.size() <<
" Master faces: " 402 << masterPatch_.size() <<
endl;
408 "void enrichedPatch::calcEnrichedFaces\n" 410 " const labelListList& pointsIntoMasterEdges,\n" 411 " const labelListList& pointsIntoSlaveEdges,\n" 412 " const pointField& projectedSlavePoints\n" 414 ) <<
"Error in enriched patch support" 425 if (!enrichedFacesPtr_)
427 FatalErrorIn(
"const faceList& enrichedPatch::enrichedFaces() const")
428 <<
"Enriched faces not available yet. Please use " 429 <<
"void enrichedPatch::calcEnrichedFaces\n" 431 <<
" const labelListList& pointsIntoMasterEdges,\n" 432 <<
" const labelListList& pointsIntoSlaveEdges,\n" 433 <<
" const pointField& projectedSlavePoints\n" 435 <<
" before trying to access faces." 439 return *enrichedFacesPtr_;
dimensioned< scalar > magSqr(const dimensioned< Type > &)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void size(const label)
Override size to be inconsistent with allocated storage.
A face is a list of labels corresponding to mesh vertices.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void calcEnrichedFaces(const labelListList &pointsIntoMasterEdges, const labelListList &pointsIntoSlaveEdges, const pointField &projectedSlavePoints)
Calculate enriched faces.
const dimensionedScalar e
Elementary charge.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
errorManip< error > abort(error &err)
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
const faceList & enrichedFaces() const
Return enriched faces.
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)