32 const Foam::label Foam::enrichedPatch::enrichedFaceRatio_ = 3;
43 if (enrichedFacesPtr_)
46 <<
"Enriched faces already calculated." 59 enrichedFacesPtr_ =
new faceList(masterPatch_.size() + slavePatch_.size());
60 faceList& enrichedFaces = *enrichedFacesPtr_;
62 label nEnrichedFaces = 0;
64 const pointField& masterLocalPoints = masterPatch_.localPoints();
65 const faceList& masterLocalFaces = masterPatch_.localFaces();
66 const labelListList& masterFaceEdges = masterPatch_.faceEdges();
68 const faceList& slaveLocalFaces = slavePatch_.localFaces();
69 const labelListList& slaveFaceEdges = slavePatch_.faceEdges();
82 const face oldFace = slavePatch_[facei];
83 const face oldLocalFace = slaveLocalFaces[facei];
85 const labelList& curEdges = slaveFaceEdges[facei];
97 if (mpIter == pmm.
end())
100 newFace.append(oldFace[i]);
106 projectedSlavePoints[oldLocalFace[i]]
112 newFace.append(mpIter());
118 projectedSlavePoints[oldLocalFace[i]]
125 pointsIntoSlaveEdges[curEdges[i]];
133 if (slavePointsOnEdge.
size())
137 const point& startPoint = projectedSlavePoints[oldLocalFace[i]];
140 projectedSlavePoints[oldLocalFace.nextLabel(i)]
143 scalar magSqrE =
magSqr(e);
152 <<
"Zero length edge in slave patch for face " << i
153 <<
". This is not allowed." 159 forAll(slavePointsOnEdge, edgePointi)
161 slavePosOnEdge[edgePointi] =
162 pointMap().find(slavePointsOnEdge[edgePointi])();
164 edgePointWeights[edgePointi] =
165 (e & (slavePosOnEdge[edgePointi] - startPoint));
171 if (
min(edgePointWeights) < 0 ||
max(edgePointWeights) > 1)
174 <<
" not on the edge for edge " << curEdges[i]
175 <<
" of face " << facei <<
" in slave patch." <<
nl 176 <<
"Min weight: " <<
min(edgePointWeights)
177 <<
" Max weight: " <<
max(edgePointWeights)
185 forAll(edgePointWeights, passI)
189 label nextPoint = -1;
192 forAll(edgePointWeights, wI)
194 if (edgePointWeights[wI] < dist)
196 dist = edgePointWeights[wI];
203 newFace.append(slavePointsOnEdge[nextPoint]);
204 edgePointWeights[nextPoint] = great;
209 slavePointsOnEdge[nextPoint],
210 slavePosOnEdge[nextPoint]
218 enrichedFaces[nEnrichedFaces].transfer(newFace);
224 forAll(masterPatch_, facei)
226 const face& oldFace = masterPatch_[facei];
227 const face& oldLocalFace = masterLocalFaces[facei];
229 const labelList& curEdges = masterFaceEdges[facei];
239 pmm.
find(oldFace[i]);
241 if (mpIter == pmm.
end())
244 newFace.append(oldFace[i]);
250 masterLocalPoints[oldLocalFace[i]]
256 newFace.append(mpIter());
259 pointMap().insert(mpIter(), masterLocalPoints[oldLocalFace[i]]);
265 pointsIntoMasterEdges[curEdges[i]];
269 if (masterPointsOnEdge.
size())
273 const point& startPoint = masterLocalPoints[oldLocalFace[i]];
276 masterLocalPoints[oldLocalFace.nextLabel(i)]
279 scalar magSqrE =
magSqr(e);
288 <<
"Zero length edge in master patch for face " << i
289 <<
". This is not allowed." 295 forAll(masterPointsOnEdge, edgePointi)
297 masterPosOnEdge[edgePointi] =
298 pointMap().find(masterPointsOnEdge[edgePointi])();
300 edgePointWeights[edgePointi] =
301 (e & (masterPosOnEdge[edgePointi] - startPoint));
307 if (
min(edgePointWeights) < 0 ||
max(edgePointWeights) > 1)
310 <<
" not on the edge for edge " << curEdges[i]
311 <<
" of face " << facei <<
" in master patch." <<
nl 312 <<
"Min weight: " <<
min(edgePointWeights)
313 <<
" Max weight: " <<
max(edgePointWeights)
321 forAll(edgePointWeights, passI)
325 label nextPoint = -1;
328 forAll(edgePointWeights, wI)
330 if (edgePointWeights[wI] < dist)
332 dist = edgePointWeights[wI];
339 newFace.append(masterPointsOnEdge[nextPoint]);
340 edgePointWeights[nextPoint] = great;
345 masterPointsOnEdge[nextPoint],
346 masterPosOnEdge[nextPoint]
354 enrichedFaces[nEnrichedFaces].transfer(newFace);
363 Info<<
"Enriched patch support OK. Slave faces: " 364 << slavePatch_.size() <<
" Master faces: " 365 << masterPatch_.size() <<
endl;
370 <<
"Error in enriched patch support" 381 if (!enrichedFacesPtr_)
384 <<
"void enrichedPatch::calcEnrichedFaces\n" 386 <<
" const labelListList& pointsIntoMasterEdges,\n" 387 <<
" const labelListList& pointsIntoSlaveEdges,\n" 388 <<
" const pointField& projectedSlavePoints\n" 390 <<
" before trying to access faces." 394 return *enrichedFacesPtr_;
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable
A face is a list of labels corresponding to mesh vertices.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
const faceList & enrichedFaces() const
Return enriched faces.
errorManip< error > abort(error &err)
dimensioned< scalar > magSqr(const dimensioned< Type > &)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
void calcEnrichedFaces(const labelListList &pointsIntoMasterEdges, const labelListList &pointsIntoSlaveEdges, const pointField &projectedSlavePoints)
Calculate enriched faces.
const dimensionedScalar e
Elementary charge.