36 void Foam::slidingInterface::calcAttachedAddressing()
const 41 <<
" for object " <<
name() <<
" : " 42 <<
"Calculating zone face-cell addressing." 49 clearAttachedAddressing();
59 faceZones[masterFaceZoneID_.
index()]();
62 faceZones[masterFaceZoneID_.
index()];
65 faceZones[masterFaceZoneID_.
index()].flipMap();
67 masterFaceCellsPtr_.reset(
new labelList(masterPatchFaces.size()));
68 auto& mfc = *masterFaceCellsPtr_;
70 forAll(masterPatchFaces, facei)
72 if (masterFlip[facei])
74 mfc[facei] = nei[masterPatchFaces[facei]];
78 mfc[facei] = own[masterPatchFaces[facei]];
85 faceZones[slaveFaceZoneID_.
index()]();
88 faceZones[slaveFaceZoneID_.
index()];
91 faceZones[slaveFaceZoneID_.
index()].flipMap();
93 slaveFaceCellsPtr_.reset(
new labelList(slavePatchFaces.size()));
94 auto& sfc = *slaveFaceCellsPtr_;
96 forAll(slavePatchFaces, facei)
100 sfc[facei] = nei[slavePatchFaces[facei]];
104 sfc[facei] = own[slavePatchFaces[facei]];
109 if (
min(mfc) < 0 ||
min(sfc) < 0)
117 Pout<<
"No cell next to master patch face " << facei
118 <<
". Global face no: " << mfc[facei]
119 <<
" own: " << own[masterPatchFaces[facei]]
120 <<
" nei: " << nei[masterPatchFaces[facei]]
121 <<
" flip: " << masterFlip[facei] <<
endl;
129 Pout<<
"No cell next to slave patch face " << facei
130 <<
". Global face no: " << sfc[facei]
131 <<
" own: " << own[slavePatchFaces[facei]]
132 <<
" nei: " << nei[slavePatchFaces[facei]]
133 <<
" flip: " << slaveFlip[facei] <<
endl;
139 <<
"decoupled mesh or sliding interface definition." 149 *
max(masterPatch.size(), slavePatch.size())
153 const labelList& masterMeshPoints = masterPatch.meshPoints();
155 stickOutFaceMap.
clear();
157 for (
const label pointi : masterMeshPoints)
159 for (
const label facei : pointFaces[pointi])
161 const label zoneIdx = faceZones.whichZone(facei);
167 zoneIdx != masterFaceZoneID_.
index()
168 && zoneIdx != slaveFaceZoneID_.
index()
171 stickOutFaceMap.insert(facei);
176 masterStickOutFacesPtr_.reset(
new labelList(stickOutFaceMap.toc()));
185 const labelList& slaveMeshPoints = slavePatch.meshPoints();
187 stickOutFaceMap.
clear();
189 for (
const label pointi : slaveMeshPoints)
191 for (
const label facei : pointFaces[pointi])
193 const label zoneIdx = faceZones.whichZone(facei);
199 zoneIdx != masterFaceZoneID_.
index()
200 && zoneIdx != slaveFaceZoneID_.
index()
203 stickOutFaceMap.insert(facei);
208 slaveStickOutFacesPtr_.reset(
new labelList(stickOutFaceMap.toc()));
216 stickOutFaceMap.clear();
220 retiredPointMapPtr_.reset
229 cutPointEdgePairMapPtr_.reset
233 faceZones[slaveFaceZoneID_.
index()]().nEdges()
240 <<
"cannot be assembled for object " <<
name()
247 <<
" for object " <<
name() <<
" : " 248 <<
"Finished calculating zone face-cell addressing." 254 void Foam::slidingInterface::clearAttachedAddressing()
const 256 masterFaceCellsPtr_.reset(
nullptr);
257 slaveFaceCellsPtr_.reset(
nullptr);
259 masterStickOutFacesPtr_.reset(
nullptr);
260 slaveStickOutFacesPtr_.reset(
nullptr);
262 retiredPointMapPtr_.reset(
nullptr);
263 cutPointEdgePairMapPtr_.reset(
nullptr);
267 void Foam::slidingInterface::renumberAttachedAddressing
275 const labelList& reverseCellMap = m.reverseCellMap();
277 const labelList& mfc = masterFaceCells();
281 std::unique_ptr<labelList> newMfcPtr(
new labelList(mfc.size(), -1));
282 auto& newMfc = *newMfcPtr;
285 m.faceZoneFaceMap()[masterFaceZoneID_.index()];
289 label newCelli = reverseCellMap[mfc[mfzRenumber[facei]]];
293 newMfc[facei] = newCelli;
298 std::unique_ptr<labelList> newSfcPtr(
new labelList(sfc.size(), -1));
299 auto& newSfc = *newSfcPtr;
302 m.faceZoneFaceMap()[slaveFaceZoneID_.index()];
306 label newCelli = reverseCellMap[sfc[sfzRenumber[facei]]];
310 newSfc[facei] = newCelli;
317 if (
min(newMfc) < 0 ||
min(newSfc) < 0)
320 <<
"Error in cell renumbering for object " <<
name()
321 <<
". Some of master cells next " 322 <<
"to the interface have been removed." 329 const labelList& reverseFaceMap = m.reverseFaceMap();
332 const labelList& msof = masterStickOutFaces();
334 std::unique_ptr<labelList> newMsofPtr(
new labelList(msof.size(), -1));
335 auto& newMsof = *newMsofPtr;
339 label newFacei = reverseFaceMap[msof[facei]];
343 newMsof[facei] = newFacei;
348 const labelList& ssof = slaveStickOutFaces();
350 std::unique_ptr<labelList> newSsofPtr(
new labelList(ssof.size(), -1));
351 auto& newSsof = *newSsofPtr;
355 label newFacei = reverseFaceMap[ssof[facei]];
359 newSsof[facei] = newFacei;
366 if (
min(newMsof) < 0 ||
min(newSsof) < 0)
369 <<
"Error in face renumbering for object " <<
name()
370 <<
". Some of stick-out next " 371 <<
"to the interface have been removed." 377 const Map<label> rpm = retiredPointMap();
379 std::unique_ptr<Map<label>> newRpmPtr(
new Map<label>(rpm.size()));
380 auto& newRpm = *newRpmPtr;
383 const labelList& reversePointMap = m.reversePointMap();
387 const label
key = reversePointMap[iter.key()];
388 const label val = reversePointMap[iter.val()];
393 if (
key < 0 || val < 0)
396 <<
"Error in retired point numbering for object " 397 <<
name() <<
". Some of master " 398 <<
"points have been removed." 403 newRpm.insert(
key, val);
407 const Map<Pair<edge>> cpepm = cutPointEdgePairMap();
409 std::unique_ptr<Map<Pair<edge>>> newCpepmPtr
411 new Map<Pair<edge>>(cpepm.size())
413 auto& newCpepm = *newCpepmPtr;
417 const label
key = reversePointMap[iter.key()];
419 const Pair<edge>& oldPe = iter.val();
422 const label ms = reversePointMap[oldPe.first().start()];
423 const label
me = reversePointMap[oldPe.first().end()];
425 const label ss = reversePointMap[oldPe.second().start()];
426 const label se = reversePointMap[oldPe.second().end()];
431 if (
key < 0 || ms < 0 ||
me < 0 || ss < 0 || se < 0)
434 <<
"Error in cut point edge pair map numbering for object " 435 <<
name() <<
". Some of master points have been removed." 440 newCpepm.insert(
key, Pair<edge>(edge(ms,
me), edge(ss, se)));
443 if (!projectedSlavePointsPtr_)
446 <<
"Error in projected point numbering for object " <<
name()
451 const pointField& projectedSlavePoints = *projectedSlavePointsPtr_;
453 std::unique_ptr<pointField> newProjectedSlavePointsPtr
457 auto& newProjectedSlavePoints = *newProjectedSlavePointsPtr;
460 m.faceZonePointMap()[slaveFaceZoneID_.index()];
462 forAll(newProjectedSlavePoints, pointi)
464 if (sfzPointRenumber[pointi] > -1)
466 newProjectedSlavePoints[pointi] =
467 projectedSlavePoints[sfzPointRenumber[pointi]];
472 clearAttachedAddressing();
474 projectedSlavePointsPtr_.reset(
nullptr);
476 masterFaceCellsPtr_ = std::move(newMfcPtr);
477 slaveFaceCellsPtr_ = std::move(newSfcPtr);
479 masterStickOutFacesPtr_ = std::move(newMsofPtr);
480 slaveStickOutFacesPtr_ = std::move(newSsofPtr);
482 retiredPointMapPtr_ = std::move(newRpmPtr);
483 cutPointEdgePairMapPtr_ = std::move(newCpepmPtr);
484 projectedSlavePointsPtr_ = std::move(newProjectedSlavePointsPtr);
490 if (!masterFaceCellsPtr_)
493 <<
"Master zone face-cell addressing not available for object " 498 return *masterFaceCellsPtr_;
504 if (!slaveFaceCellsPtr_)
507 <<
"Slave zone face-cell addressing not available for object " 512 return *slaveFaceCellsPtr_;
516 const Foam::labelList& Foam::slidingInterface::masterStickOutFaces()
const 518 if (!masterStickOutFacesPtr_)
521 <<
"Master zone stick-out face addressing not available for object " 526 return *masterStickOutFacesPtr_;
530 const Foam::labelList& Foam::slidingInterface::slaveStickOutFaces()
const 532 if (!slaveStickOutFacesPtr_)
535 <<
"Slave zone stick-out face addressing not available for object " 540 return *slaveStickOutFacesPtr_;
546 if (!retiredPointMapPtr_)
549 <<
"Retired point map not available for object " <<
name()
553 return *retiredPointMapPtr_;
558 Foam::slidingInterface::cutPointEdgePairMap()
const 560 if (!cutPointEdgePairMapPtr_)
563 <<
"Retired point map not available for object " <<
name()
567 return *cutPointEdgePairMapPtr_;
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with the type faceZone.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Ostream & endl(Ostream &os)
Add newline and flush stream.
List< labelList > labelListList
List of labelList.
const dimensionedScalar me
Electron mass.
#define forAll(list, i)
Loop across all elements in list.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
static const unsigned facesPerCell_
Estimated number of faces per cell.
vectorField pointField
pointField is a vectorField.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
void clear()
Clear the list, i.e. set size to zero.
void sort(UList< T > &list)
Sort the list.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
label index() const
The index of the first matching items, -1 if no matches.
int debug
Static debugging option.
PrimitivePatch< List< face >, const pointField & > primitiveFacePatch
A PrimitivePatch with List storage for the faces, const reference for the point field.
const polyTopoChanger & topoChanger() const
Return reference to morph engine.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
const word & name() const
Return name of this modifier.
List< label > labelList
A List of labels.
const polyMesh & mesh() const
Return the mesh reference.
List< bool > boolList
A List of bools.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
forAllConstIters(mixture.phases(), phase)
A HashTable to objects of type <T> with a label key.