49 const word& defaultPatchFieldType,
50 const bool validBoundary
64 label insertPatchi = polyPatches.size();
65 label startFacei =
mesh.nFaces();
67 if (!isA<processorPolyPatch>(
patch))
69 forAll(polyPatches, patchi)
73 if (isA<processorPolyPatch>(
pp))
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); \ 195 void Foam::fvMeshTools::setPatchFields
205 #define doLocalCode(FieldType) \ 207 setPatchFields<FieldType>(mesh, patchi, patchFieldDict); \ 235 #define doLocalCode(FieldType) \ 237 setPatchFields<FieldType>(mesh, patchi, Zero); \ 261 void Foam::fvMeshTools::trimPatches(fvMesh&
mesh,
const label
nPatches)
267 auto& fvPatches =
const_cast<fvBoundaryMesh&
>(
mesh.
boundary());
269 if (polyPatches.empty())
272 <<
"No patches in mesh" 277 for (label patchi =
nPatches; patchi < polyPatches.size(); patchi++)
279 nFaces += polyPatches[patchi].size();
281 reduce(nFaces, sumOp<label>());
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
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);
372 const bool validBoundary
387 if (!isA<processorPolyPatch>(
pp))
389 label nFaces =
pp.size();
397 newToOld[newI] = patchI;
398 oldToNew[patchI] = newI++;
406 const polyPatch&
pp =
pbm[patchI];
408 if (isA<processorPolyPatch>(
pp) &&
pp.size())
410 newToOld[newI] = patchI;
411 oldToNew[patchI] = newI++;
420 if (oldToNew[patchI] == -1)
422 oldToNew[patchI] = newI++;
426 reorderPatches(
mesh, oldToNew, newToOld.
size(), validBoundary);
455 const bool masterOnlyReading,
527 meshIO.instance() = facesInstance;
531 IOobject cmptIO(meshIO,
"points", meshSubDir);
534 cmptIO.registerObject(
false);
538 const fileName meshDir =
io.
time().
path()/facesInstance/meshSubDir;
539 bool haveMesh =
isDir(meshDir);
567 cmptIO.instance() = pointsInstance;
568 cmptIO.rename(
"points");
572 cmptIO.instance() = facesInstance;
575 cmptIO.rename(
"faces");
579 cmptIO.rename(
"owner");
583 cmptIO.rename(
"neighbour");
604 DynamicList<polyPatch*> newPatches(patchEntries.
size());
627 forAll(patchEntries, patchi)
629 const entry&
e = patchEntries[patchi];
630 const word
type(
e.dict().get<word>(
"type"));
631 const word&
name =
e.keyword();
635 type == processorPolyPatch::typeName
636 ||
type == processorCyclicPolyPatch::typeName
648 patchDict.set(
"nFaces", 0);
649 patchDict.set(
"startFace", 0);
693 List<pointZone*> pz(pointZoneNames.size());
696 pz[i] =
new pointZone
703 List<faceZone*> fz(faceZoneNames.size());
713 List<cellZone*> cz(cellZoneNames.size());
724 if (pz.size() || fz.size() || cz.size())
735 Foam::fvMeshTools::loadOrCreateMeshImpl
738 refPtr<fileOperation>* readHandlerPtr,
739 const bool decompose,
746 const fileName meshSubDir
756 PtrList<entry> patchEntries;
770 patchEntries = polyBoundaryMeshEntries
787 const_cast<fileOperation&
>(
fileHandler()).nProcs(oldNumProcs);
797 bool haveLocalMesh =
false;
802 haveLocalMesh = (*readHandlerPtr).good();
808 UPstream::allGatherValues<bool>(haveLocalMesh)
814 const_cast<fileOperation&
>(
fileHandler()).nProcs(masterNProcs);
843 forAll(patchEntries, patchi)
845 const entry&
e = patchEntries[patchi];
846 const word
type(
e.dict().get<word>(
"type"));
847 const word&
name =
e.keyword();
851 type == processorPolyPatch::typeName
852 ||
type == processorCyclicPolyPatch::typeName
862 patchDict.set(
"nFaces", 0);
863 patchDict.set(
"startFace", 0);
922 const_cast<fileOperation&
>(
fileHandler()).nProcs(oldNumProcs);
926 else if (readHandlerPtr && haveLocalMesh)
930 UPstream::communicator newCommunicator;
933 auto& readHandler = *readHandlerPtr;
947 meshProcIds.size() == handlerProcIds.size()
950 meshProcIds.cbegin(),
952 handlerProcIds.cbegin()
1013 forAll(patchEntries, patchi)
1015 const entry&
e = patchEntries[patchi];
1016 const word
type(
e.dict().get<word>(
"type"));
1017 const word&
name =
e.keyword();
1021 type == processorPolyPatch::typeName
1022 ||
type == processorCyclicPolyPatch::typeName
1031 <<
"Non-processor patches not synchronised." <<
endl 1034 <<
" patches, master has " 1046 <<
"Non-processor patches not synchronised." <<
endl 1047 <<
"Master patch " << patchi
1051 <<
" patch " << patchi
1053 <<
" type:" <<
patches[patchi].type()
1084 PtrList<pointZone> pz(pointZoneNames.size());
1085 forAll(pointZoneNames, i)
1090 PtrList<faceZone> fz(faceZoneNames.size());
1096 PtrList<cellZone> cz(cellZoneNames.size());
1101 mesh.
addZones(std::move(pz), std::move(fz), std::move(cz));
1109 if (!readHandlerPtr)
1122 pointSetNames = objects.sortedNames<pointSet>();
1123 faceSetNames = objects.sortedNames<faceSet>();
1124 cellSetNames = objects.sortedNames<cellSet>();
1136 for (
const word& setName : pointSetNames)
1138 pointSet(
mesh, setName, 0).write();
1140 for (
const word& setName : faceSetNames)
1142 faceSet(
mesh, setName, 0).write();
1144 for (
const word& setName : cellSetNames)
1146 cellSet(
mesh, setName, 0).write();
1186 const bool decompose,
1190 return fvMeshTools::loadOrCreateMeshImpl
1208 return fvMeshTools::loadOrCreateMeshImpl
1249 IOdictionary(
io,
dict).regIOobject::write();
1271 IOdictionary(
io,
dict).regIOobject::write();
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 zones and in same order.
GeometricField< symmTensor, fvPatchField, volMesh > volSymmTensorField
const polyBoundaryMesh & pbm
fileName path() const
Return path = rootPath/caseName. Same as TimePaths::path()
void removeFvBoundary()
Remove boundary patches. Warning: fvPatchFields hold ref to these fvPatches.
A class for handling file names.
void clear()
Clear the zones.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const fileName & facesInstance() const
Return the current instance directory for faces.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const labelIOList & tetBasePtIs() const
Return the tetBasePtIs.
const word & name() const noexcept
Return the object name.
vectorIOField pointIOField
pointIOField is a vectorIOField.
GeometricField< tensor, fvPatchField, volMesh > volTensorField
PtrList< T > clone(Args &&... args) const
Make a copy by cloning each of the list elements.
GeometricField< vector, fvsPatchField, surfaceMesh > surfaceVectorField
GeometricField< sphericalTensor, fvsPatchField, surfaceMesh > surfaceSphericalTensorField
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
void clearOut(const bool isMeshUpdate=false)
Clear all geometry and addressing.
refPtr< fileOperation > fileHandler(std::nullptr_t)
Delete current file handler - forwards to fileOperation::handler()
virtual bool init(const bool doInit)
Initialise all non-demand-driven data.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
Ignore writing from objectRegistry::writeObject()
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
const Time & time() const
Return the top-level database.
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
GeometricField< vector, fvPatchField, volMesh > volVectorField
GeometricField< sphericalTensor, fvPatchField, volMesh > volSphericalTensorField
A class for managing references or pointers (no reference counting)
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...
Default geometry calculation scheme. Slight stabilisation for bad meshes.
virtual const objectRegistry & thisDb() const
Return the object registry - resolve conflict polyMesh/lduMesh.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
#define forAll(list, i)
Loop across all elements in list.
const Vector< label > & geometricD() const
Return the vector of geometric directions in mesh.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
PtrList< polyPatch > polyPatchList
Store lists of polyPatch as a PtrList.
label size() const noexcept
The number of elements in table.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
CompactIOList< face, label > faceCompactIOList
Compact IO for a List of face.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
const dimensionedScalar e
Elementary charge.
IOList< label > labelIOList
IO for a List of label.
GeometricField< symmTensor, fvsPatchField, surfaceMesh > surfaceSymmTensorField
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
word findInstance(const fileName &directory, const word &name=word::null, IOobjectOption::readOption rOpt=IOobjectOption::MUST_READ, const word &stopInstance=word::null, const bool constant_fallback=true) const
Return time instance (location) of directory containing the file name (eg, used in reading mesh data)...
Foam::autoPtr< Foam::dynamicFvMesh > meshPtr
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...
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
A class for handling words, derived from Foam::string.
bool checkDefinition(const bool report=false) const
Check boundary definition.
label size() const noexcept
The number of entries in the list.
const word & system() const noexcept
Return system name.
void addZones(PtrList< pointZone > &&pz, PtrList< faceZone > &&fz, PtrList< cellZone > &&cz)
Add mesh zones.
GeometricField< tensor, fvsPatchField, surfaceMesh > surfaceTensorField
Reading is optional [identical to LAZY_READ].
const objectRegistry & db() const noexcept
Return the local objectRegistry.
const globalMeshData & globalData() const
Return parallel info (demand-driven)
label nInternalFaces() const noexcept
Number of internal faces.
errorManip< error > abort(error &err)
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie...
virtual bool write(const bool writeOnProc=true) const
Write mesh using IO settings from time.
bool typeHeaderOk(const bool checkType=true, const bool search=true, const bool verbose=true)
Read header (respects is_globalIOobject trait) and check its info.
const Time & time() const noexcept
Return Time associated with the objectRegistry.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
bool checkParallelSync(const bool report=false) const
Check whether all procs have all patches and in same order.
static int cacheLevel() noexcept
Return cache level.
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
static fileCheckTypes fileModificationChecking
Type of file modification checking.
void addFvPatches(polyPatchList &plist, const bool validBoundary=true)
Add boundary patches. Constructor helper.
static label commWorld() noexcept
Communicator for all ranks (respecting any local worlds)
void resize(const label newLen)
Adjust size of PtrList.
static void broadcasts(const label comm, Type &arg1, Args &&... args)
Broadcast multiple items to all communicator ranks. Does nothing in non-parallel. ...
bool empty() const noexcept
True if the list is empty (ie, size() is zero)
const pointZoneMesh & pointZones() const noexcept
Return point zone mesh.
List< word > wordList
List of word.
static List< int > & procID(const label communicator)
The list of ranks within a given communicator.
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
Mesh data needed to do the Finite Volume discretisation.
fileName meshDir() const
Return the local mesh directory (dbDir()/meshSubDir)
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
const polyBoundaryMesh & patches
Automatically write from objectRegistry::writeObject()
const std::string patch
OpenFOAM patch number as a std::string.
virtual const fvGeometryScheme & geometry() const
Return reference to geometry calculation scheme.
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
bool checkDefinition(const bool report=false) const
Check zone definition. Return true if in error.
List< label > sortedToc(const UList< bool > &bools)
Return the (sorted) values corresponding to 'true' entries.
wordList names() const
A list of the zone names.
messageStream Info
Information stream (stdout output on master, null elsewhere)
const fvBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
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.
static autoPtr< fvPatch > New(const polyPatch &, const fvBoundaryMesh &)
Return a pointer to a new patch created on freestore from polyPatch.
static const fileOperation & fileHandler()
Return the current file handler. Will create the default file handler if necessary.
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 class for managing temporary objects.
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Registry of regIOobjects.
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
A patch is a list of labels that address the faces in the global face list.
Read and store dictionary entries for boundary patches The object is *never* registered to avoid regi...
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
Defines the attributes of an object for which implicit objectRegistry management is supported...
List< bool > boolList
A List of bools.
Do not request registration (bool: false)
void reduce(T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) using linear/tree communication schedule.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())