41 void Foam::faMeshReconstructor::calcAddressing
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];
392 for (
const label sortedEdgei : patchEdgeLabels)
394 remapGlobal.insert(sortedEdgei, remapGlobal.size());
401 labelList newEdgeProcAddr(faEdgeProcAddr_);
405 for (
const faPatch& fap : procMesh_.
boundary())
407 for (
const label patchEdgei : fap.edgeLabels())
409 const label globalEdgei = faEdgeProcAddr_[patchEdgei];
411 const auto fnd = remapGlobal.cfind(globalEdgei);
414 newEdgeProcAddr[edgei] = fnd.val();
420 <<
"Failed to find edge " << globalEdgei
421 <<
" this indicates a programming error" <<
nl 427 faEdgeProcAddr_ = std::move(newEdgeProcAddr);
432 void Foam::faMeshReconstructor::initPatch()
const 434 serialPatchPtr_.reset
438 SubList<face>(singlePatchFaces_),
445 void Foam::faMeshReconstructor::createMesh()
462 procMesh_.mesh().name(),
463 procMesh_.mesh().facesInstance(),
480 serialAreaMesh_.reset
489 auto& completeMesh = *serialAreaMesh_;
492 faPatchList completePatches(singlePatchEdgeLabels_.size());
493 forAll(completePatches, patchi)
495 const labelList& patchEdgeLabels = singlePatchEdgeLabels_[patchi];
497 const faPatch& fap = procMesh_.boundary()[patchi];
499 const label neiPolyPatchId = fap.ngbPolyPatchIndex();
506 completeMesh.boundary(),
518 completeMesh.addFaPatches(completePatches);
526 Foam::faMeshReconstructor::faMeshReconstructor
538 <<
"Can only be called in parallel!!" <<
nl 544 "faceProcAddressing",
579 calcAddressing(fvFaceProcAddr);
588 Foam::faMeshReconstructor::faMeshReconstructor
590 const faMesh& procMesh,
600 <<
"Can only be called in parallel!!" <<
nl 604 calcAddressing(fvFaceProcAddressing);
618 serialAreaMesh_.reset(
nullptr);
619 serialVolMesh_.reset(
nullptr);
620 serialRunTime_.reset(
nullptr);
626 if (!serialPatchPtr_)
631 return *serialPatchPtr_;
637 if (!serialPatchPtr_)
642 return *serialPatchPtr_;
648 if (!serialAreaMesh_)
653 return *serialAreaMesh_;
659 writeAddressing(procMesh_.mesh().facesInstance());
679 ioAddr.
rename(
"boundaryProcAddressing");
683 ioAddr.
rename(
"faceProcAddressing");
687 ioAddr.
rename(
"pointProcAddressing");
691 ioAddr.
rename(
"edgeProcAddressing");
698 writeMesh(procMesh_.mesh().facesInstance());
706 const bool oldDistributed =
fileHandler().distributed();
PtrList< faPatch > faPatchList
Store lists of faPatch as a PtrList.
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
void writeMesh() const
Write equivalent mesh information at the polyMesh faceInstances time.
const faMesh & mesh() const
Serial equivalent faMesh.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const fileName & facesInstance() const
Return the current instance directory for faces.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void resize(const label len)
Adjust allocated size of list.
~faMeshReconstructor()
Destructor.
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.
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
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.
static rangeType allProcs(const label communicator=worldComm)
Range of process indices for all processes.
constexpr char nl
The newline '\n' character (0x0a)
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
virtual void rename(const word &newName)
Rename the object.
List< face > faceList
A List of faces.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
T & first()
Access first element of the list, position [0].
static bool & parRun() noexcept
Test if this a parallel run.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
static int debug
Debug flag.
autoPtr< fileOperation > fileHandler(std::nullptr_t)
Delete current file handler.
static int & msgType() noexcept
Message tag of standard messages.
SubList< label > subList
Declare type of subList.
autoPtr< globalIndex > mergePoints(labelList &pointToGlobal, labelList &uniquePoints) const
Helper for merging (collocated!) mesh point data.
Ignore writing from objectRegistry::writeObject()
A bare-bones reconstructor for finiteArea meshes when processor meshes are available (in parallel) bu...
const primitivePatch & patch() const
Serial equivalent patch.
label nFaces() const noexcept
Number of patch faces.
UList< label > labelUList
A UList of labels.
static void broadcast(Type &value, const label comm=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all processes in communicator.
#define forAll(list, i)
Loop across all elements in list.
const uindirectPrimitivePatch & patch() const
Return constant reference to primitive patch.
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
A list of faces which address into the list of points.
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
const labelList & faceLabels() const noexcept
Return the underlying polyMesh face labels.
static void reduceAnd(bool &value, const label communicator=worldComm)
Logical (and) reduction (cf. MPI AllReduce)
"scheduled" : (MPI_Send, MPI_Recv)
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
void clear()
Clear the list, i.e. set size to zero.
A class for handling words, derived from Foam::string.
const Time & time() const noexcept
Return time registry.
void sort(UList< T > &list)
Sort the list.
static constexpr int masterNo() noexcept
Process index of the master (always 0)
label size() const noexcept
The number of elements in the list.
const globalMeshData & globalData() const
Return parallel info.
static void combineReduce(const List< commsStruct > &comms, T &value, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) applying cop to inplace combine value from different processors...
fileName & toAbsolute()
Convert from relative to absolute.
const polyMesh & mesh() const
Return access to polyMesh.
virtual void rename(const word &newName)
Rename.
const faBoundaryMesh & boundary() const noexcept
Return constant reference to boundary mesh.
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
A PrimitivePatch with a SubList addressing for the faces, const reference for the point field...
label nEdges() const noexcept
Number of local mesh edges.
void writeAddressing() const
Write proc addressing at the polyMesh faceInstances time.
static word meshSubDir
The mesh sub-directory name (usually "faMesh")
PrimitivePatch< UIndirectList< face >, const pointField & > uindirectPrimitivePatch
A PrimitivePatch with UIndirectList for the faces, const reference for the point field.
label nInternalEdges() const noexcept
Number of internal faces.
label nNonProcessor() const
The number of patches before the first processor patch.
static bool master(const label communicator=worldComm)
Am I the master rank.
"nonBlocking" : (MPI_Isend, MPI_Irecv)
static rangeType subProcs(const label communicator=worldComm)
Range of process indices for sub-processes.
List< label > labelList
A List of labels.
virtual bool write(const bool valid=true) const
Write using setting from DB.
A IOList wrapper for writing external data.
Defines the attributes of an object for which implicit objectRegistry management is supported...
const objectRegistry & thisDb() const noexcept
Return the object registry.
Do not request registration (bool: false)
const dimensionedScalar mp
Proton mass.
IOList< label > labelIOList
Label container classes.
fileName globalPath() const
Return global path for the case.
static autoPtr< fileOperation > NewUncollated()
Static construct the commonly used uncollatedFileOperation.
static constexpr const zero Zero
Global zero (0)
readOption
Enumeration defining read preferences.