83 const bool flipFaceFlux,
84 const label newPatchi,
91 if (modifiedFace.
set(facei))
139 const Type& exposedValue,
155 Info<<
"Subsetting " << GeoField::typeName <<
nl;
159 GeoField origField(*ioptr, baseMesh);
161 subFields.set(nFields, subsetter.
interpolate(origField));
167 subFields[nFields].boundaryFieldRef()[patchi];
169 const label newStart =
fld.patch().patch().start();
170 const label oldPatchi = subsetter.
patchMap()[patchi];
183 origField.boundaryField()[oldPatchi];
185 const label oldSize = origPfld.
size();
190 const label oldFacei = subsetter.
faceMap()[newStart+j];
192 if (oldFacei < oldStart || oldFacei >= oldStart+oldSize)
194 fld[j] = exposedValue;
206 void subsetSurfaceFields
211 const Type& exposedValue,
227 Info<<
"Subsetting " << GeoField::typeName <<
nl;
231 GeoField origField(*ioptr, baseMesh);
233 subFields.set(nFields, subsetter.
interpolate(origField));
239 subFields[nFields].boundaryFieldRef()[patchi];
241 const label newStart =
fld.patch().patch().start();
242 const label oldPatchi = subsetter.
patchMap()[patchi];
255 origField.boundaryField()[oldPatchi];
257 const label oldSize = origPfld.
size();
262 const label oldFacei = subsetter.
faceMap()[newStart+j];
264 if (oldFacei < oldStart || oldFacei >= oldStart+oldSize)
266 fld[j] = exposedValue;
279 template<
class GeoField>
280 void initCreatedPatches
284 const typename GeoField::value_type initValue
289 mesh.objectRegistry::lookupClass<GeoField>()
294 GeoField&
field =
const_cast<GeoField&
>(*fieldIter());
296 auto& fieldBf =
field.boundaryFieldRef();
303 fieldBf[patchi] = initValue;
305 if (fieldBf[patchi].fixesValue())
307 fieldBf[patchi] == initValue;
315 template<
class TopoSet>
327 ReadFields<TopoSet>(objects, sets);
332 TopoSet&
set = sets[seti];
334 Info<<
"Subsetting " <<
set.type() <<
" " <<
set.name() <<
endl;
338 for (
const label
id :
set)
344 for (
const label
id : map)
357 TopoSet& subSet = subSets[seti];
361 if (isSet.test(map[i]))
370 void createCoupledBaffles
380 forAll(coupledWantedPatch, facei)
382 if (coupledWantedPatch[facei] != -1)
385 label zoneID = faceZones.
whichZone(facei);
386 bool zoneFlip =
false;
390 const faceZone& fZone = faceZones[zoneID];
402 coupledWantedPatch[facei],
410 label zoneID = faceZones.
whichZone(facei);
411 bool zoneFlip =
false;
415 const faceZone& fZone = faceZones[zoneID];
426 coupledWantedPatch[facei],
437 void createCyclicCoupledBaffles
448 forAll(cyclicMasterPatch, facei)
450 if (cyclicMasterPatch[facei] != -1)
454 label zoneID = faceZones.
whichZone(facei);
455 bool zoneFlip =
false;
459 const faceZone& fZone = faceZones[zoneID];
470 cyclicMasterPatch[facei],
478 forAll(cyclicSlavePatch, facei)
480 if (cyclicSlavePatch[facei] != -1)
485 label zoneID = faceZones.
whichZone(facei);
486 bool zoneFlip =
false;
490 const faceZone& fZone = faceZones[zoneID];
501 cyclicSlavePatch[facei],
520 Info <<
"faceZone:createBaffle " << faceZones <<
endl;
521 forAll(wantedPatch, facei)
523 if (wantedPatch[facei] != -1)
527 label zoneID = faceZones.
whichZone(facei);
528 bool zoneFlip =
false;
532 const faceZone& fZone = faceZones[zoneID];
554 label zoneID = faceZones.
whichZone(facei);
555 bool zoneFlip =
false;
559 const faceZone& fZone = faceZones[zoneID];
593 <<
"Illegal patch " << patchName
602 if (newPatchi != patchi)
605 <<
"Patch " << patchName
606 <<
" should have the same patch index on all processors." <<
nl 607 <<
"On my processor it has index " << patchi
608 <<
" ; on some other processor it has index " << newPatchi
617 int main(
int argc,
char *argv[])
621 "Mesh and field preparation utility for PDR type simulations." 654 for (
const entry& dEntry : functionDicts)
656 if (!dEntry.isDict())
661 const word&
key = dEntry.keyword();
667 nameAndType[0] =
key;
668 nameAndType[1] = wallName;
669 nameAndType[2] = cyclicName;
670 coupledAndPatches.append(nameAndType);
673 forAll(setsAndPatches, setI)
675 Info<<
"Faces in faceSet " << setsAndPatches[setI][0]
676 <<
" become baffles in patch " << setsAndPatches[setI][1]
680 forAll(coupledAndPatches, setI)
682 Info<<
"Faces in faceSet " << coupledAndPatches[setI][0]
683 <<
" become coupled baffles in patch " << coupledAndPatches[setI][1]
690 Info<<
"Faces that get exposed become boundary faces in patch " 691 << defaultPatch <<
endl;
695 Info<<
"Reading blocked cells from cellSet " << blockedSetName
698 const bool overwrite =
args.
found(
"overwrite");
706 forAll(setsAndPatches, setI)
710 label patchi = findPatch
713 setsAndPatches[setI][1]
716 for (
const label facei : fSet)
718 if (wantedPatch[facei] != -1)
722 <<
" is in faceSet " << setsAndPatches[setI][0]
723 <<
" destined for patch " << setsAndPatches[setI][1]
724 <<
" but also in patch " << wantedPatch[facei]
727 wantedPatch[facei] = patchi;
736 forAll(coupledAndPatches, setI)
739 const label cyclicId =
740 findPatch(
patches, coupledAndPatches[setI][2]);
742 const label cyclicSlaveId = findPatch
745 refCast<const cyclicFvPatch>
748 ).neighbFvPatch().
name()
752 label patchi = findPatch(
patches, coupledAndPatches[setI][1]);
754 for (
const label facei : fSet)
756 if (coupledWantedPatch[facei] != -1)
760 <<
" is in faceSet " << coupledAndPatches[setI][0]
761 <<
" destined for patch " << coupledAndPatches[setI][1]
762 <<
" but also in patch " << coupledWantedPatch[facei]
766 coupledWantedPatch[facei] = patchi;
767 cyclicWantedPatch_half0[facei] = cyclicId;
768 cyclicWantedPatch_half1[facei] = cyclicSlaveId;
808 cyclicWantedPatch_half0,
814 cyclicWantedPatch_half1,
827 const auto& obj = *objPtr;
877 sphTensorNames.size()
940 surfSphTensorNames.size()
948 surfSphericalTensorFlds
958 surfSymmTensorNames.size()
1026 scalarFlds[i].rename(scalarNames[i]);
1031 vectorFlds[i].rename(vectorNames[i]);
1036 sphTensorFlds[i].rename(sphTensorNames[i]);
1039 forAll(symmTensorFlds, i)
1041 symmTensorFlds[i].rename(symmTensorNames[i]);
1046 tensorFlds[i].rename(tensorNames[i]);
1051 forAll(surfScalarFlds, i)
1053 surfScalarFlds[i].rename(surfScalarNames[i]);
1056 forAll(surfVectorFlds, i)
1058 surfVectorFlds[i].rename(surfVectorNames[i]);
1061 forAll(surfSphericalTensorFlds, i)
1063 surfSphericalTensorFlds[i].rename(surfSphTensorNames[i]);
1066 forAll(surfSymmTensorFlds, i)
1068 surfSymmTensorFlds[i].rename(surfSymmTensorNames[i]);
1071 forAll(surfTensorNames, i)
1073 surfTensorFlds[i].rename(surfTensorNames[i]);
1105 cyclicWantedPatch_half0,
1113 cyclicWantedPatch_half1,
1125 createCoupledBaffles
1134 createCyclicCoupledBaffles
1137 cyclicWantedPatch_half0,
1138 cyclicWantedPatch_half1,
1158 meshMod.changeMesh(subsetter.
subMesh(),
false);
1166 initCreatedPatches<volScalarField>
1172 initCreatedPatches<volVectorField>
1178 initCreatedPatches<volSphericalTensorField>
1184 initCreatedPatches<volSymmTensorField>
1190 initCreatedPatches<volTensorField>
1197 initCreatedPatches<surfaceScalarField>
1203 initCreatedPatches<surfaceVectorField>
1209 initCreatedPatches<surfaceSphericalTensorField>
1215 initCreatedPatches<surfaceSymmTensorField>
1221 initCreatedPatches<surfaceTensorField>
1255 if (cellRegion.nRegions() > 1)
1258 <<
"Removing blocked faces and cells created " 1259 << cellRegion.nRegions()
1260 <<
" regions that are not connected via a face." <<
nl 1261 <<
" This is not supported in solvers." <<
nl 1262 <<
" Use" <<
nl <<
nl 1263 <<
" splitMeshRegions <root> <case> -largestOnly" <<
nl <<
nl 1264 <<
" to extract a single region of the mesh." <<
nl 1265 <<
" This mesh will be written to a new timedirectory" 1266 <<
" so might have to be moved back to constant/" <<
nl 1271 if (startFrom !=
"latestTime")
1274 <<
"To run splitMeshRegions please set your" 1275 <<
" startFrom entry to latestTime" <<
endl;
label findPatchID(const word &patchName, const bool allowNotFound=true) const
Find patch index given a name, return -1 if not found.
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
ITstream & lookup(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return an entry data stream. FatalIOError if not found, or not a stream. ...
const Type & value() const noexcept
Return const reference to value.
static tmp< DimensionedField< Type, volMesh > > interpolate(const DimensionedField< Type, volMesh > &, const fvMesh &sMesh, const labelUList &cellMap)
Map volume internal (dimensioned) field.
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
static void addNote(const string ¬e)
Add extra notes for the usage information.
void size(const label n)
Older name for setAddressableSize.
void set(const bitSet &bitset)
Set specified bits from another bitset.
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable, so the various sorted methods should be used if traversing in parallel.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Class describing modification of a face.
const fileName & facesInstance() const
Return the current instance directory for faces.
A face is a list of labels corresponding to mesh vertices.
A 1D vector of objects of type <T> with a fixed length <N>.
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...
const fvPatch & patch() const noexcept
Return the patch.
label start() const noexcept
Return start label of this patch in the polyMesh face list.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual const labelList & faceNeighbour() const
Return face neighbour.
const word & name() const noexcept
Return the object name.
constexpr char nl
The newline '\n' character (0x0a)
wordList sortedNames() const
The sorted names of the IOobjects.
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual void movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
const fvPatch & patch() const noexcept
Return the patch.
Generic GeometricField class.
label whichFace(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
Field reading functions for post-processing utilities.
const fvMesh & baseMesh() const noexcept
Original mesh.
Ignore writing from objectRegistry::writeObject()
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
label nFaces() const noexcept
Number of mesh faces.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
bool hasMotionPoints() const
Has valid preMotionPoints?
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A face addition data class. A face can be inflated either from a point or from another face and can e...
bool isInternalFace(const label faceIndex) const noexcept
Return true if given face label is internal to the mesh.
const labelList & faceMap() const
Return face map.
multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
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 labelList & oldPatchSizes() const
Return list of the old patch sizes.
const fvMesh & subMesh() const
Return reference to subset mesh.
const labelList & patchMap() const
Return patch map.
virtual void updateMesh(const mapPolyMesh &mpm)
Update mesh corresponding to the given map.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
SymmTensor< scalar > symmTensor
SymmTensor of scalars, i.e. SymmTensor<scalar>.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
A class for handling words, derived from Foam::string.
wordList names() const
Return a list of patch names.
label size() const noexcept
The number of entries in the list.
const word & system() const noexcept
Return system name.
virtual const labelList & faceOwner() const
Return face owner.
#define forAllIters(container, iter)
Iterate across all elements in the container object.
const labelList & pointMap() const
Return point map.
const IOobject * findObject(const word &objName) const
Return const pointer to the object found by name.
const labelList & cellMap() const
Return cell map.
virtual const faceList & faces() const
Return raw faces.
A HashTable similar to std::unordered_map.
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.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
static word timeName(const scalar t, const int precision=precision_)
Return time name of given scalar time formatted with the given precision.
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
Holds a reference to the original mesh (the baseMesh) and optionally to a subset of that mesh (the su...
void resize(const label newLen)
Adjust size of PtrList.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
#define WarningInFunction
Report a warning using Foam::Warning.
label nCells() const noexcept
Number of mesh cells.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
A collection of cell labels.
Mesh data needed to do the Finite Volume discretisation.
Direct mesh changes based on v1.3 polyTopoChange syntax.
const polyBoundaryMesh & patches
Automatically write from objectRegistry::writeObject()
const dictionary & controlDict() const
Return read access to the controlDict dictionary.
const boolList & flipMap() const noexcept
Return face flip map.
messageStream Info
Information stream (stdout output on master, null elsewhere)
const fvBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
A subset of mesh faces organised as a primitive patch.
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars, i.e. SphericalTensor<scalar>.
bitSet create(const label n, const labelHashSet &locations, const bool on=true)
Create a bitSet with length n with the specified on locations.
const polyPatch & patch() const noexcept
Return the polyPatch.
Foam::argList args(argc, argv)
Defines the attributes of an object for which implicit objectRegistry management is supported...
virtual void updateMesh(const mapPolyMesh &morphMap)
Update any stored data for new labels. Not implemented.
A List with indirect addressing.
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
bool found(const word &optName) const
Return true if the named option is found.
const pointField & preMotionPoints() const
Pre-motion point positions.
A keyword and a list of tokens is an 'entry'.
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.
static constexpr const zero Zero
Global zero (0)