41void Foam::faMeshReconstructor::calcAddressing
43 const labelUList& fvFaceProcAddr
46 const globalIndex globalFaceNum(procMesh_.
nFaces());
65 faBoundaryProcAddr_[patchi] = -1;
77 for (label& facei : faFaceProcAddr_)
80 facei =
mag(fvFaceProcAddr[facei])-1;
88 globalFaceNum.gather(faFaceProcAddr_, singlePatchFaceLabels_);
92 singlePatchFaceLabels_ =
93 labelList(singlePatchFaceLabels_, globalOrder);
98 label patchFirstMeshfacei
100 singlePatchFaceLabels_.
empty()
102 : singlePatchFaceLabels_.
first()
106 for (label& facei : faFaceProcAddr_)
108 facei -= patchFirstMeshfacei;
118 labelList procTargets(globalFaceNum.totalSize());
124 globalFaceNum.range(proci),
129 labelList procStarts(globalFaceNum.offsets());
130 labelList procOrders(globalFaceNum.totalSize());
132 for (
const label globali : globalOrder)
134 const label proci = procTargets[globali];
136 procOrders[procStarts[proci]++] =
137 (globali - globalFaceNum.localStart(proci));
143 SubList<label> localOrder
146 globalFaceNum.range(proci)
149 UOPstream toProc(proci, pBufs);
150 toProc << localOrder;
153 SubList<label> localOrder(procOrders, globalFaceNum.range(0));
155 faFaceProcAddr_ =
labelList(faFaceProcAddr_, localOrder);
158 pBufs.finishedScatters();
165 fromProc >> localOrder;
167 faFaceProcAddr_ =
labelList(faFaceProcAddr_, localOrder);
187 faPointProcAddr_.
clear();
214 autoPtr<globalIndex> globalPointsPtr =
217 procPatch.meshPoints(),
218 procPatch.meshPointMap(),
220 uniqueMeshPointLabels
224 faceList tmpFaces(globalFaceNum.localSize());
229 face(pointToGlobal, procPatch.localFaces()[facei]);
235 singlePatchProcFaces,
240 globalPointsPtr().gather
245 uniqueMeshPointLabels
251 singlePatchFaces_.
resize(singlePatchProcFaces.size());
255 globalFaceNum.gather(faFaceProcAddr_, singlePatchProcAddr);
257 forAll(singlePatchProcAddr, facei)
259 const label targetFacei = singlePatchProcAddr[facei];
260 singlePatchFaces_[targetFacei] = singlePatchProcFaces[facei];
269 SubList<face>(singlePatchFaces_),
274 tmpFaces = initialPatch.localFaces();
275 pointField tmpPoints(initialPatch.localPoints());
278 labelList mpm(initialPatch.points().size(), -1);
289 for (label& pointi : pointToGlobal)
291 pointi = mpm[pointi];
295 faPointProcAddr_ = std::move(pointToGlobal);
297 singlePatchFaces_ = std::move(tmpFaces);
298 singlePatchPoints_ = std::move(tmpPoints);
310 SubList<face>(singlePatchFaces_),
314 faEdgeProcAddr_.
clear();
318 EdgeMap<label> globalEdgeMapping(2*onePatch.nEdges());
326 for (
const edge&
e : onePatch.edges())
328 globalEdgeMapping.insert(
e, globalEdgeMapping.
size());
332 for (label edgei = 0; edgei < procPatch.nEdges(); ++edgei)
334 const edge globalEdge(faPointProcAddr_, procPatch.edges()[edgei]);
336 const auto fnd = globalEdgeMapping.cfind(globalEdge);
340 faEdgeProcAddr_[edgei] = fnd.val();
345 <<
"Failed to find edge " << globalEdge
346 <<
" this indicates a programming error" <<
nl
360 Map<label> remapGlobal(2*onePatch.nEdges());
361 for (label edgei = 0; edgei < onePatch.nInternalEdges(); ++edgei)
363 remapGlobal.insert(edgei, remapGlobal.size());
367 singlePatchEdgeLabels_.
clear();
370 forAll(singlePatchEdgeLabels_, patchi)
372 const faPatch& fap = procMesh_.
boundary()[patchi];
374 labelList& patchEdgeLabels = singlePatchEdgeLabels_[patchi];
375 patchEdgeLabels = fap.edgeLabels();
378 for (label& edgeId : patchEdgeLabels)
380 edgeId = faEdgeProcAddr_[edgeId];
391 ListOps::appendEqOp<label>()
397 for (
const label sortedEdgei : patchEdgeLabels)
399 remapGlobal.insert(sortedEdgei, remapGlobal.size());
406 labelList newEdgeProcAddr(faEdgeProcAddr_);
410 for (
const faPatch& fap : procMesh_.
boundary())
412 for (
const label patchEdgei : fap.edgeLabels())
414 const label globalEdgei = faEdgeProcAddr_[patchEdgei];
416 const auto fnd = remapGlobal.cfind(globalEdgei);
419 newEdgeProcAddr[edgei] = fnd.val();
425 <<
"Failed to find edge " << globalEdgei
426 <<
" this indicates a programming error" <<
nl
432 faEdgeProcAddr_ = std::move(newEdgeProcAddr);
437void Foam::faMeshReconstructor::initPatch()
const
439 serialPatchPtr_.reset
443 SubList<face>(singlePatchFaces_),
450void Foam::faMeshReconstructor::createMesh()
467 procMesh_.mesh().name(),
468 procMesh_.mesh().facesInstance(),
485 serialAreaMesh_.reset
494 auto& completeMesh = *serialAreaMesh_;
497 faPatchList completePatches(singlePatchEdgeLabels_.size());
498 forAll(completePatches, patchi)
500 const labelList& patchEdgeLabels = singlePatchEdgeLabels_[patchi];
502 const faPatch& fap = procMesh_.boundary()[patchi];
504 const label neiPolyPatchId = fap.ngbPolyPatchIndex();
511 completeMesh.boundary(),
523 completeMesh.addFaPatches(completePatches);
541 <<
"Can only be called in parallel!!" <<
nl
550 "faceProcAddressing",
570 calcAddressing(fvFaceProcAddressing);
585 <<
"Can only be called in parallel!!" <<
nl
589 calcAddressing(fvFaceProcAddressing);
603 serialAreaMesh_.reset(
nullptr);
604 serialVolMesh_.reset(
nullptr);
605 serialRunTime_.reset(
nullptr);
611 if (!serialPatchPtr_)
616 return *serialPatchPtr_;
622 if (!serialPatchPtr_)
627 return *serialPatchPtr_;
633 if (!serialAreaMesh_)
638 return *serialAreaMesh_;
644 writeAddressing(procMesh_.mesh().facesInstance());
664 ioAddr.
rename(
"boundaryProcAddressing");
668 ioAddr.
rename(
"faceProcAddressing");
672 ioAddr.
rename(
"pointProcAddressing");
676 ioAddr.
rename(
"edgeProcAddressing");
683 writeMesh(procMesh_.mesh().facesInstance());
A IOList wrapper for writing external data.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
virtual void rename(const word &newName)
Rename the object.
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type set(const label i, bool val=true)
A bitSet::set() method for a list of bool.
SubList< label > subList
Declare type of subList.
void resize(const label len)
Adjust allocated size of list.
void clear()
Clear the list, i.e. set size to zero.
A list of faces which address into the list of points.
UPstream::rangeType allProcs() const noexcept
Range of ranks indices associated with PstreamBuffers.
UPstream::rangeType subProcs() const noexcept
Range of sub-processes indices associated with PstreamBuffers.
static void combineAllGather(const List< commsStruct > &comms, T &value, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
static void scatter(const List< commsStruct > &comms, T &value, const int tag, const label comm)
Broadcast data: Distribute without modification.
fileName globalPath() const
Return global path for the case.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
T & first()
Return the first element of the list.
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
void size(const label n)
Older name for setAddressableSize.
@ nonBlocking
"nonBlocking"
static int & msgType() noexcept
Message tag of standard messages.
static constexpr int masterNo() noexcept
Process index of the master (always 0)
static bool & parRun() noexcept
Test if this a parallel run.
label size() const noexcept
The number of elements in the list.
label nNonProcessor() const
The number of patches before the first processor patch.
A bare-bones reconstructor for finiteArea meshes when processor meshes are available (in parallel) bu...
const faMesh & mesh() const
Serial equivalent faMesh.
~faMeshReconstructor()
Destructor.
const primitivePatch & patch() const
Serial equivalent patch.
void writeMesh() const
Write equivalent mesh information at the polyMesh faceInstances time.
void writeAddressing() const
Write proc addressing at the polyMesh faceInstances time.
static int debug
Debug flag.
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
const faBoundaryMesh & boundary() const noexcept
Return constant reference to boundary mesh.
label nEdges() const noexcept
Number of local mesh edges.
const polyMesh & mesh() const
Return access to polyMesh.
const uindirectPrimitivePatch & patch() const
Return constant reference to primitive patch.
label nInternalEdges() const noexcept
Number of internal faces.
label nFaces() const noexcept
Number of patch faces.
const labelList & faceLabels() const noexcept
Return the underlying polyMesh face labels.
static word meshSubDir
The mesh sub-directory name (usually "faMesh")
fileName & toAbsolute()
Convert from relative to absolute.
bool distributed() const noexcept
Distributed roots (parallel run)
static autoPtr< fileOperation > NewUncollated()
Static construct the commonly used uncollatedFileOperation.
autoPtr< globalIndex > mergePoints(labelList &pointToGlobal, labelList &uniquePoints) const
Helper for merging (collocated!) mesh point data.
const Time & time() const noexcept
Return time registry.
const objectRegistry & thisDb() const noexcept
Return the object registry.
const fileName & facesInstance() const
Return the current instance directory for faces.
const globalMeshData & globalData() const
Return parallel info.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
virtual bool write(const bool valid=true) const
Write using setting from DB.
splitCell * master() const
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
const dimensionedScalar mp
Proton mass.
const fileOperation & fileHandler()
Get current file handler.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
List< label > labelList
A List of labels.
vectorField pointField
pointField is a vectorField.
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
A PrimitivePatch with a SubList addressing for the faces, const reference for the point field.
PrimitivePatch< UIndirectList< face >, const pointField & > uindirectPrimitivePatch
A PrimitivePatch with UIndirectList for the faces, const reference for the point field.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
void sort(UList< T > &list)
Sort the list.
static constexpr const zero Zero
Global zero (0)
PtrList< faPatch > faPatchList
Store lists of faPatch as a PtrList.
List< face > faceList
A List of faces.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.