49 const word& defaultPatchFieldType,
50 const bool validBoundary
55 label patchi = polyPatches.
findPatchID(patch.name());
64 label insertPatchi = polyPatches.size();
65 label startFacei =
mesh.nFaces();
69 forAll(polyPatches, patchi)
75 insertPatchi = patchi;
76 startFacei =
pp.start();
89 label sz = polyPatches.size();
106 fvPatches.resize(sz+1);
121 #define doLocalCode(FieldType) \
123 addPatchFields<FieldType> \
125 mesh, patchFieldDict, defaultPatchFieldType, Zero \
154 for (label i = insertPatchi; i < sz; ++i)
158 oldToNew[sz] = insertPatchi;
162 polyPatches.reorder(oldToNew, validBoundary);
163 fvPatches.reorder(oldToNew);
168 #define doLocalCode(FieldType) \
170 reorderPatchFields<FieldType>(mesh, oldToNew); \
195void Foam::fvMeshTools::setPatchFields
205 #define doLocalCode(FieldType) \
207 setPatchFields<FieldType>(mesh, patchi, patchFieldDict); \
235 #define doLocalCode(FieldType) \
237 setPatchFields<FieldType>(mesh, patchi, Zero); \
269 if (polyPatches.empty())
272 <<
"No patches in mesh"
277 for (label patchi =
nPatches; patchi < polyPatches.size(); patchi++)
279 nFaces += polyPatches[patchi].size();
286 <<
"There are still " << nFaces
287 <<
" faces in " << polyPatches.size()-
nPatches
298 #define doLocalCode(FieldType) \
300 trimPatchFields<FieldType>(mesh, nPatches); \
327 const label nNewPatches,
328 const bool validBoundary
331 auto& polyPatches =
const_cast<polyBoundaryMesh&
>(
mesh.boundaryMesh());
332 auto& fvPatches =
const_cast<fvBoundaryMesh&
>(
mesh.boundary());
335 polyPatches.reorder(oldToNew, validBoundary);
336 fvPatches.reorder(oldToNew);
341 #define doLocalCode(FieldType) \
343 reorderPatchFields<FieldType>(mesh, oldToNew); \
365 trimPatches(
mesh, nNewPatches);
373 const bool validBoundary
390 if (keepPatches.
found(
pp.name()))
392 newToOld[newI] = patchI;
393 oldToNew[patchI] = newI++;
397 label nFaces =
pp.size();
400 reduce(nFaces, sumOp<label>());
405 newToOld[newI] = patchI;
406 oldToNew[patchI] = newI++;
422 || keepPatches.
found(
pp.name())
426 newToOld[newI] = patchI;
427 oldToNew[patchI] = newI++;
436 if (oldToNew[patchI] == -1)
438 oldToNew[patchI] = newI++;
451 const bool validBoundary
473 mesh.geometry(basicGeometry);
481 const bool masterOnlyReading,
506 facesInstance =
io.time().findInstance
512 pointsInstance =
io.time().findInstance
553 meshIO.instance() = facesInstance;
557 IOobject cmptIO(meshIO,
"points", meshSubDir);
560 cmptIO.registerObject(
false);
564 const fileName meshDir =
io.time().path()/facesInstance/meshSubDir;
565 bool haveMesh =
isDir(meshDir);
593 cmptIO.instance() = pointsInstance;
594 cmptIO.rename(
"points");
598 cmptIO.instance() = facesInstance;
601 cmptIO.rename(
"faces");
605 cmptIO.rename(
"owner");
609 cmptIO.rename(
"neighbour");
653 forAll(patchEntries, patchi)
655 const entry&
e = patchEntries[patchi];
661 type == processorPolyPatch::typeName
662 ||
type == processorCyclicPolyPatch::typeName
674 patchDict.set(
"nFaces", 0);
675 patchDict.set(
"startFace", 0);
750 if (pz.size() || fz.size() || cz.size())
760Foam::autoPtr<Foam::fvMesh>
761Foam::fvMeshTools::loadOrCreateMeshImpl
765 const bool decompose,
789 const fileName facesInstance =
io.time().findInstance
823 bool haveLocalMesh =
false;
828 haveLocalMesh = (*readHandlerPtr).good();
869 forAll(patchEntries, patchi)
871 const entry&
e = patchEntries[patchi];
877 type == processorPolyPatch::typeName
878 ||
type == processorCyclicPolyPatch::typeName
888 patchDict.set(
"nFaces", 0);
889 patchDict.set(
"startFace", 0);
952 else if (readHandlerPtr && haveLocalMesh)
961 auto& readHandler = *readHandlerPtr;
993 meshPtr().polyMesh::comm() = realWorldComm;
1024 forAll(patchEntries, patchi)
1026 const entry&
e = patchEntries[patchi];
1032 type == processorPolyPatch::typeName
1033 ||
type == processorCyclicPolyPatch::typeName
1042 <<
"Non-processor patches not synchronised." <<
endl
1045 <<
" patches, master has "
1057 <<
"Non-processor patches not synchronised." <<
endl
1058 <<
"Master patch " << patchi
1062 <<
" patch " << patchi
1064 <<
" type:" <<
patches[patchi].type()
1096 forAll(pointZoneNames, i)
1112 mesh.
addZones(std::move(pz), std::move(fz), std::move(cz));
1120 if (!readHandlerPtr)
1133 pointSetNames = objects.sortedNames<
pointSet>();
1134 faceSetNames = objects.sortedNames<
faceSet>();
1135 cellSetNames = objects.sortedNames<
cellSet>();
1147 for (
const word& setName : pointSetNames)
1151 for (
const word& setName : faceSetNames)
1155 for (
const word& setName : cellSetNames)
1187 mesh.pointZones().checkParallelSync(verbose);
1197 const bool decompose,
1201 return fvMeshTools::loadOrCreateMeshImpl
1219 return fvMeshTools::loadOrCreateMeshImpl
1241 mesh.time().system(),
1260 IOdictionary(
io,
dict).regIOobject::write();
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
const polyBoundaryMesh & pbm
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable,...
@ NO_REGISTER
Do not request registration (bool: false).
readOption readOpt() const noexcept
Get the read option.
writeOption writeOpt() const noexcept
Get the write option.
bool registerObject() const noexcept
Should objects created with this IOobject be registered?
@ NO_READ
Nothing to be read.
@ READ_IF_PRESENT
Reading is optional [identical to LAZY_READ].
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
@ AUTO_WRITE
Automatically write from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const word & name() const noexcept
Return the object name.
const fileName & instance() const noexcept
Read access to instance path component.
static fileCheckTypes fileModificationChecking
Type of file modification checking.
virtual void rename(const word &newName)
Rename the object.
label size() const noexcept
The number of elements in the list.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void resize(const label len)
Adjust allocated size of list.
static const List< word > & null() noexcept
static void broadcasts(const int communicator, Type &value, Args &&... values)
Broadcast multiple items to all communicator ranks. Does nothing in non-parallel.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie,...
PtrList< T > clone(Args &&... args) const
Make a copy by cloning each of the list elements.
void resize(const label newLen)
Adjust size of PtrList.
const word & system() const noexcept
Return system name.
bool found(const T &val, label pos=0) const
Same as contains().
bool get(const label i) const
Return bool value at specified position, always false for out-of-range access.
void size(const label n)
Older name for setAddressableSize.
Wrapper for internally indexed communicator label. Always invokes UPstream::allocateCommunicatorCompo...
static label commWorld() noexcept
Communicator for all ranks (respecting any local worlds).
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
static bool sameProcs(int communicator1, int communicator2)
Test for communicator equality.
static List< T > allGatherValues(const T &localValue, const int communicator=UPstream::worldComm)
Allgather individual values into list locations.
@ broadcast
broadcast [MPI]
static bool & parRun() noexcept
Test if this a parallel run.
void reorder(const labelUList &oldToNew, const bool check=false)
Reorder elements. Reordering must be unique (ie, shuffle).
bool empty() const noexcept
True if the list is empty (ie, size() is zero).
label size() const noexcept
The number of entries in the list.
bool checkDefinition(const bool report=false) const
Check zone definition. Return true if in error.
void clear()
Clear the zones.
wordList names() const
A list of the zone names.
bool checkParallelSync(const bool report=false) const
Check whether all procs have all zones and in same order.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Default geometry calculation scheme. Slight stabilisation for bad meshes.
A collection of cell labels.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
virtual bool init(const bool doInit)
Initialise all non-demand-driven data.
A keyword and a list of tokens is an 'entry'.
A subset of mesh faces organised as a primitive patch.
A class for handling file names.
An encapsulation of filesystem-related operations.
static const fileOperation & fileHandler()
Return the current file handler. Will create the default file handler if necessary.
static int cacheLevel() noexcept
Return cache level.
A fvBoundaryMesh is a fvPatch list with a reference to the associated fvMesh, with additional search ...
Mesh data needed to do the Finite Volume discretisation.
virtual const objectRegistry & thisDb() const
Return the object registry - resolve conflict polyMesh/lduMesh.
void addFvPatches(polyPatchList &plist, const bool validBoundary=true)
Add boundary patches. Constructor helper.
const Time & time() const
Return the top-level database.
const fvBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
virtual bool write(const bool writeOnProc=true) const
Write mesh using IO settings from time.
void removeFvBoundary()
Remove boundary patches. Warning: fvPatchFields hold ref to these fvPatches.
void clearOut(const bool isMeshUpdate=false)
Clear all geometry and addressing.
static autoPtr< fvPatch > New(const polyPatch &, const fvBoundaryMesh &)
Return a pointer to a new patch created on freestore from polyPatch.
Registry of regIOobjects.
Read and store dictionary entries for boundary patches The object is *never* registered to avoid regi...
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
bool checkDefinition(const bool report=false) const
Check boundary definition.
label findPatchID(const word &patchName, const bool allowNotFound=true) const
Find patch index given a name, return -1 if not found.
bool checkParallelSync(const bool report=false) const
Check whether all procs have all patches and in same order.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
const fileName & facesInstance() const
Return the current instance directory for faces.
fileName meshDir() const
Return the local mesh directory (dbDir()/meshSubDir).
const labelIOList & tetBasePtIs() const
Return the tetBasePtIs.
const globalMeshData & globalData() const
Return parallel info (demand-driven).
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
void addZones(PtrList< pointZone > &&pz, PtrList< faceZone > &&fz, PtrList< cellZone > &&cz)
Add mesh zones.
const pointZoneMesh & pointZones() const noexcept
Return point zone mesh.
const Vector< label > & geometricD() const
Return the vector of geometric directions in mesh.
A patch is a list of labels that address the faces in the global face list.
static autoPtr< polyPatch > New(const word &patchType, const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm)
Return pointer to a new patch created on freestore from components.
label nInternalFaces() const noexcept
Number of internal faces.
A class for managing references or pointers (no reference counting).
virtual bool write(const bool writeOnProc=true) const
Write using setting from DB.
A class for managing temporary objects.
A class for handling words, derived from Foam::string.
const polyBoundaryMesh & patches
Foam::autoPtr< Foam::dynamicFvMesh > meshPtr
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define doLocalCode(FieldType, Variable)
List< label > sortedToc(const UList< bool > &bools)
Return the (sorted) values corresponding to 'true' entries.
GeometricField< vector, fvsPatchField, surfaceMesh > surfaceVectorField
PtrList< polyPatch > polyPatchList
Store lists of polyPatch as a PtrList.
List< word > wordList
List of word.
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
GeometricField< vector, fvPatchField, volMesh > volVectorField
List< label > labelList
A List of labels.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
IOList< label > labelIOList
IO for a List of label.
refPtr< fileOperation > fileHandler(std::nullptr_t)
Delete current file handler - forwards to fileOperation::handler().
CompactIOList< face > faceCompactIOList
Compact IO for a List of face.
messageStream Info
Information stream (stdout output on master, null elsewhere).
vectorIOField pointIOField
pointIOField is a vectorIOField.
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Ostream & endl(Ostream &os)
Add newline and flush stream.
GeometricField< tensor, fvPatchField, volMesh > volTensorField
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
GeometricField< tensor, fvsPatchField, surfaceMesh > surfaceTensorField
GeometricField< sphericalTensor, fvPatchField, volMesh > volSphericalTensorField
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
GeometricField< sphericalTensor, fvsPatchField, surfaceMesh > surfaceSphericalTensorField
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...
errorManip< error > abort(error &err)
GeometricField< symmTensor, fvPatchField, volMesh > volSymmTensorField
List< bool > boolList
A List of bools.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
GeometricField< symmTensor, fvsPatchField, surfaceMesh > surfaceSymmTensorField
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
#define forAll(list, i)
Loop across all elements in list.