42 void Foam::faMeshReconstructor::calcAddressing
47 const globalIndex globalFaceNum(procMesh_.
nFaces());
66 faBoundaryProcAddr_[patchi] = -1;
78 for (label& facei : faFaceProcAddr_)
81 facei =
mag(fvFaceProcAddr[facei])-1;
89 globalFaceNum.gather(faFaceProcAddr_, singlePatchFaceLabels_);
93 singlePatchFaceLabels_ =
94 labelList(singlePatchFaceLabels_, globalOrder);
99 label patchFirstMeshfacei
101 singlePatchFaceLabels_.
empty()
103 : singlePatchFaceLabels_.
first()
107 for (label& facei : faFaceProcAddr_)
109 facei -= patchFirstMeshfacei;
113 PstreamBuffers pBufs;
119 labelList procTargets(globalFaceNum.totalSize());
125 globalFaceNum.range(proci),
130 labelList procStarts(globalFaceNum.offsets());
131 labelList procOrders(globalFaceNum.totalSize());
133 for (
const label globali : globalOrder)
135 const label proci = procTargets[globali];
137 procOrders[procStarts[proci]++] =
138 (globali - globalFaceNum.localStart(proci));
144 SubList<label> localOrder
147 globalFaceNum.range(proci)
150 UOPstream toProc(proci, pBufs);
151 toProc << localOrder;
154 SubList<label> localOrder(procOrders, globalFaceNum.range(0));
156 faFaceProcAddr_ =
labelList(faFaceProcAddr_, localOrder);
159 pBufs.finishedScatters();
166 fromProc >> localOrder;
168 faFaceProcAddr_ =
labelList(faFaceProcAddr_, localOrder);
188 faPointProcAddr_.
clear();
215 autoPtr<globalIndex> globalPointsPtr =
218 procPatch.meshPoints(),
219 procPatch.meshPointMap(),
221 uniqueMeshPointLabels
225 faceList tmpFaces(globalFaceNum.localSize());
230 face(pointToGlobal, procPatch.localFaces()[facei]);
236 singlePatchProcFaces,
241 globalPointsPtr().gather
246 uniqueMeshPointLabels
252 singlePatchFaces_.
resize(singlePatchProcFaces.size());
256 globalFaceNum.gather(faFaceProcAddr_, singlePatchProcAddr);
258 forAll(singlePatchProcAddr, facei)
260 const label targetFacei = singlePatchProcAddr[facei];
261 singlePatchFaces_[targetFacei] = singlePatchProcFaces[facei];
270 SubList<face>(singlePatchFaces_),
275 tmpFaces = initialPatch.localFaces();
276 pointField tmpPoints(initialPatch.localPoints());
279 labelList mpm(initialPatch.points().size(), -1);
290 for (label& pointi : pointToGlobal)
292 pointi = mpm[pointi];
296 faPointProcAddr_ = std::move(pointToGlobal);
298 singlePatchFaces_ = std::move(tmpFaces);
299 singlePatchPoints_ = std::move(tmpPoints);
311 SubList<face>(singlePatchFaces_),
315 faEdgeProcAddr_.
clear();
319 EdgeMap<label> globalEdgeMapping(2*onePatch.nEdges());
327 for (
const edge&
e : onePatch.edges())
329 globalEdgeMapping.insert(
e, globalEdgeMapping.size());
333 for (label edgei = 0; edgei < procPatch.nEdges(); ++edgei)
335 const edge globalEdge(faPointProcAddr_, procPatch.edges()[edgei]);
337 const auto fnd = globalEdgeMapping.cfind(globalEdge);
341 faEdgeProcAddr_[edgei] = fnd.val();
346 <<
"Failed to find edge " << globalEdge
347 <<
" this indicates a programming error" <<
nl 361 Map<label> remapGlobal(2*onePatch.nEdges());
362 for (label edgei = 0; edgei < onePatch.nInternalEdges(); ++edgei)
364 remapGlobal.insert(edgei, remapGlobal.size());
368 singlePatchEdgeLabels_.
clear();
371 forAll(singlePatchEdgeLabels_, patchi)
373 const faPatch& fap = procMesh_.
boundary()[patchi];
375 if (isA<ignoreFaPatch>(fap))
381 labelList& patchEdgeLabels = singlePatchEdgeLabels_[patchi];
382 patchEdgeLabels = fap.edgeLabels();
385 for (label& edgeId : patchEdgeLabels)
387 edgeId = faEdgeProcAddr_[edgeId];
399 for (
const label sortedEdgei : patchEdgeLabels)
401 remapGlobal.insert(sortedEdgei, remapGlobal.size());
408 labelList newEdgeProcAddr(faEdgeProcAddr_);
412 for (
const faPatch& fap : procMesh_.
boundary())
414 for (
const label patchEdgei : fap.edgeLabels())
416 const label globalEdgei = faEdgeProcAddr_[patchEdgei];
418 const auto fnd = remapGlobal.cfind(globalEdgei);
421 newEdgeProcAddr[edgei] = fnd.val();
427 <<
"Failed to find edge " << globalEdgei
428 <<
" this indicates a programming error" <<
nl 434 faEdgeProcAddr_ = std::move(newEdgeProcAddr);
439 void Foam::faMeshReconstructor::initPatch()
const 441 serialPatchPtr_.reset
445 SubList<face>(singlePatchFaces_),
452 void Foam::faMeshReconstructor::createMesh()
469 procMesh_.mesh().name(),
470 procMesh_.mesh().facesInstance(),
487 serialAreaMesh_.reset
496 auto& completeMesh = *serialAreaMesh_;
499 faPatchList completePatches(singlePatchEdgeLabels_.size());
501 forAll(completePatches, patchi)
503 const labelList& patchEdgeLabels = singlePatchEdgeLabels_[patchi];
505 const faPatch& fap = procMesh_.boundary()[patchi];
507 if (isA<ignoreFaPatch>(fap))
513 const label neiPolyPatchId = fap.ngbPolyPatchIndex();
520 completeMesh.boundary(),
536 completeMesh.addFaPatches(completePatches);
544 Foam::faMeshReconstructor::faMeshReconstructor
556 <<
"Can only be called in parallel!!" <<
nl 562 "faceProcAddressing",
589 fvFaceProcAddr.isAnyRead()
597 calcAddressing(fvFaceProcAddr);
606 Foam::faMeshReconstructor::faMeshReconstructor
608 const faMesh& procMesh,
618 <<
"Can only be called in parallel!!" <<
nl 622 calcAddressing(fvFaceProcAddressing);
636 serialAreaMesh_.reset(
nullptr);
637 serialVolMesh_.reset(
nullptr);
638 serialRunTime_.reset(
nullptr);
644 if (!serialPatchPtr_)
649 return *serialPatchPtr_;
655 if (!serialPatchPtr_)
660 return *serialPatchPtr_;
666 if (!serialAreaMesh_)
671 return *serialAreaMesh_;
677 writeAddressing(procMesh_.mesh().facesInstance());
697 ioAddr.
rename(
"boundaryProcAddressing");
701 ioAddr.
rename(
"faceProcAddressing");
705 ioAddr.
rename(
"pointProcAddressing");
709 ioAddr.
rename(
"edgeProcAddressing");
716 writeMesh(procMesh_.mesh().facesInstance());
727 const bool oldDistributed =
fileHandler().distributed(
true);
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)
static autoPtr< Time > NewGlobalTime()
Construct (dummy) global Time - no functionObjects or libraries, using the global path information st...
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 List is empty (ie, size() is zero)
virtual void rename(const word &newName)
Rename the object.
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 int debug
Debug flag.
refPtr< fileOperation > fileHandler(std::nullptr_t)
Delete current file handler - forwards to fileOperation::handler()
static int & msgType() noexcept
Message tag of standard messages.
const faGlobalMeshData & globalData() const
Return parallel info (demand-driven)
SubList< label > subList
Declare type of subList.
Ignore writing from objectRegistry::writeObject()
A bare-bones reconstructor for finiteArea meshes when processor meshes are available (in parallel) bu...
A class for managing references or pointers (no reference counting)
static const faMesh & mesh(const polyMesh &pMesh)
The single-region finite-area region on the polyMesh. Uses lookupObject semantics - Fatal if non-exis...
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 communicator ranks. Does nothing in non-paral...
#define forAll(list, i)
Loop across all elements in list.
const uindirectPrimitivePatch & patch() const
Return constant reference to primitive patch.
List< face > faceList
List of faces.
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.
IOList< label > labelIOList
IO for a List of label.
const labelList & faceLabels() const noexcept
Return the underlying polyMesh face labels.
static void reduceAnd(bool &value, const label communicator=worldComm)
Logical (and) reduction (MPI_AllReduce)
"scheduled" (MPI standard) : (MPI_Send, MPI_Recv)
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
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 void combineReduce(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...
static constexpr int masterNo() noexcept
Relative rank for the master process - is always 0.
label size() const noexcept
The number of entries in the list.
virtual bool write(const bool writeOnProc=true) const
Write using setting from DB.
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")
const fileName & facesInstance() const
Return the current instance directory for faces.
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)
True if process corresponds to the master rank in the communicator.
static const fileOperation & fileHandler()
Return the current file handler. Will create the default file handler if necessary.
static rangeType subProcs(const label communicator=worldComm)
Range of process indices for sub-processes.
List< label > labelList
A List of labels.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
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.
static autoPtr< fileOperation > NewUncollated()
The commonly used uncollatedFileOperation.
static constexpr const zero Zero
Global zero (0)
readOption
Enumeration defining read preferences.