83 const bool flipFaceFlux,
84 const label newPatchi,
91 if (modifiedFace.
set(facei))
139 const Type& exposedValue
158 Info<<
"Subsetting " << GeoField::typeName <<
" (";
168 GeoField origField(rio, baseMesh);
170 subFields.set(nFields, subsetter.
interpolate(origField));
171 auto& subField = subFields[nFields];
176 subField.rename(
io.
name());
185 const label newStart =
fld.patch().patch().start();
186 const label oldPatchi = subsetter.
patchMap()[patchi];
199 origField.boundaryField()[oldPatchi];
201 const label oldSize = origPfld.
size();
206 const label oldFacei = subsetter.
faceMap()[newStart+j];
208 if (oldFacei < oldStart || oldFacei >= oldStart+oldSize)
210 fld[j] = exposedValue;
232 const Type& exposedValue
251 Info<<
"Subsetting " << GeoField::typeName <<
" (";
261 GeoField origField(rio, baseMesh);
263 subFields.set(nFields, subsetter.
interpolate(origField));
264 auto& subField = subFields[nFields];
268 subField.rename(
io.
name());
277 const label newStart =
fld.patch().patch().start();
278 const label oldPatchi = subsetter.
patchMap()[patchi];
291 origField.boundaryField()[oldPatchi];
293 const label oldSize = origPfld.
size();
298 const label oldFacei = subsetter.
faceMap()[newStart+j];
300 if (oldFacei < oldStart || oldFacei >= oldStart+oldSize)
302 fld[j] = exposedValue;
320 template<
class GeoField>
321 void initCreatedPatches
325 const typename GeoField::value_type initValue
328 for (
const GeoField&
field :
mesh.objectRegistry::csorted<GeoField>())
337 fieldBf[patchi] = initValue;
339 if (fieldBf[patchi].fixesValue())
341 fieldBf[patchi] == initValue;
349 template<
class TopoSet>
361 ReadFields<TopoSet>(objects, sets);
367 const TopoSet&
set = sets[seti];
369 Info<<
"Subsetting " <<
set.type() <<
' ' <<
set.name() <<
endl;
376 if (
set.contains(map[i]))
397 void createCoupledBaffles
407 forAll(coupledWantedPatch, facei)
409 if (coupledWantedPatch[facei] != -1)
412 label zoneID = faceZones.
whichZone(facei);
413 bool zoneFlip =
false;
417 const faceZone& fZone = faceZones[zoneID];
429 coupledWantedPatch[facei],
437 label zoneID = faceZones.
whichZone(facei);
438 bool zoneFlip =
false;
442 const faceZone& fZone = faceZones[zoneID];
453 coupledWantedPatch[facei],
464 void createCyclicCoupledBaffles
475 forAll(cyclicMasterPatch, facei)
477 if (cyclicMasterPatch[facei] != -1)
481 label zoneID = faceZones.
whichZone(facei);
482 bool zoneFlip =
false;
486 const faceZone& fZone = faceZones[zoneID];
497 cyclicMasterPatch[facei],
505 forAll(cyclicSlavePatch, facei)
507 if (cyclicSlavePatch[facei] != -1)
512 label zoneID = faceZones.
whichZone(facei);
513 bool zoneFlip =
false;
517 const faceZone& fZone = faceZones[zoneID];
528 cyclicSlavePatch[facei],
547 Info <<
"faceZone:createBaffle " << faceZones <<
endl;
548 forAll(wantedPatch, facei)
550 if (wantedPatch[facei] != -1)
554 label zoneID = faceZones.
whichZone(facei);
555 bool zoneFlip =
false;
559 const faceZone& fZone = faceZones[zoneID];
581 label zoneID = faceZones.
whichZone(facei);
582 bool zoneFlip =
false;
586 const faceZone& fZone = faceZones[zoneID];
620 <<
"Illegal patch " << patchName
629 if (newPatchi != patchi)
632 <<
"Patch " << patchName
633 <<
" should have the same patch index on all processors." <<
nl 634 <<
"On my processor it has index " << patchi
635 <<
" ; on some other processor it has index " << newPatchi
645 int main(
int argc,
char *argv[])
649 "Mesh and field preparation utility for PDR type simulations." 682 for (
const entry& dEntry : functionDicts)
684 if (!dEntry.isDict())
689 const word&
key = dEntry.keyword();
695 nameAndType[0] =
key;
696 nameAndType[1] = wallName;
697 nameAndType[2] = cyclicName;
698 coupledAndPatches.append(nameAndType);
701 forAll(setsAndPatches, setI)
703 Info<<
"Faces in faceSet " << setsAndPatches[setI][0]
704 <<
" become baffles in patch " << setsAndPatches[setI][1]
708 forAll(coupledAndPatches, setI)
710 Info<<
"Faces in faceSet " << coupledAndPatches[setI][0]
711 <<
" become coupled baffles in patch " << coupledAndPatches[setI][1]
718 Info<<
"Faces that get exposed become boundary faces in patch " 719 << defaultPatch <<
endl;
723 Info<<
"Reading blocked cells from cellSet " << blockedSetName
726 const bool overwrite =
args.
found(
"overwrite");
734 forAll(setsAndPatches, setI)
738 label patchi = findPatch
741 setsAndPatches[setI][1]
744 for (
const label facei : fSet)
746 if (wantedPatch[facei] != -1)
750 <<
" is in faceSet " << setsAndPatches[setI][0]
751 <<
" destined for patch " << setsAndPatches[setI][1]
752 <<
" but also in patch " << wantedPatch[facei]
755 wantedPatch[facei] = patchi;
764 forAll(coupledAndPatches, setI)
767 const label cyclicId =
768 findPatch(
patches, coupledAndPatches[setI][2]);
770 const label cyclicSlaveId = findPatch
773 refCast<const cyclicFvPatch>
776 ).neighbFvPatch().
name()
780 label patchi = findPatch(
patches, coupledAndPatches[setI][1]);
782 for (
const label facei : fSet)
784 if (coupledWantedPatch[facei] != -1)
788 <<
" is in faceSet " << coupledAndPatches[setI][0]
789 <<
" destined for patch " << coupledAndPatches[setI][1]
790 <<
" but also in patch " << coupledWantedPatch[facei]
794 coupledWantedPatch[facei] = patchi;
795 cyclicWantedPatch_half0[facei] = cyclicId;
796 cyclicWantedPatch_half1[facei] = cyclicSlaveId;
836 cyclicWantedPatch_half0,
842 cyclicWantedPatch_half1,
855 const auto& obj = *objPtr;
879 subsetVolFields<scalar>
890 subsetVolFields<vector>
901 subsetVolFields<sphericalTensor>
912 subsetVolFields<symmTensor>
923 subsetVolFields<tensor>
935 subsetSurfaceFields<scalar>
946 subsetSurfaceFields<vector>
957 subsetSurfaceFields<sphericalTensor>
968 subsetSurfaceFields<symmTensor>
979 subsetSurfaceFields<tensor>
1027 Info<<
"Writing mesh without blockedCells to time " 1058 cyclicWantedPatch_half0,
1066 cyclicWantedPatch_half1,
1078 createCoupledBaffles
1087 createCyclicCoupledBaffles
1090 cyclicWantedPatch_half0,
1091 cyclicWantedPatch_half1,
1111 meshMod.changeMesh(subsetter.
subMesh(),
false);
1119 initCreatedPatches<volScalarField>
1125 initCreatedPatches<volVectorField>
1131 initCreatedPatches<volSphericalTensorField>
1137 initCreatedPatches<volSymmTensorField>
1143 initCreatedPatches<volTensorField>
1150 initCreatedPatches<surfaceScalarField>
1156 initCreatedPatches<surfaceVectorField>
1162 initCreatedPatches<surfaceSphericalTensorField>
1168 initCreatedPatches<surfaceSymmTensorField>
1174 initCreatedPatches<surfaceTensorField>
1208 if (cellRegion.nRegions() > 1)
1211 <<
"Removing blocked faces and cells created " 1212 << cellRegion.nRegions()
1213 <<
" regions that are not connected via a face." <<
nl 1214 <<
" This is not supported in solvers." <<
nl 1215 <<
" Use" <<
nl <<
nl 1216 <<
" splitMeshRegions <root> <case> -largestOnly" <<
nl <<
nl 1217 <<
" to extract a single region of the mesh." <<
nl 1218 <<
" This mesh will be written to a new timedirectory" 1219 <<
" so might have to be moved back to constant/" <<
nl 1224 if (startFrom !=
"latestTime")
1227 <<
"To run splitMeshRegions please set your" 1228 <<
" 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)
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.
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.
void resize_null(const label newLen)
Set the addressed list to the given size, deleting all existing entries. Afterwards the list contains...
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 expressions::valueTypeCode::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 labelList & cellMap() const
Return cell map.
virtual const faceList & faces() const
Return raw faces.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
const dictionary & controlDict() const noexcept
Return read access to the controlDict dictionary.
A list of pointers to objects of type <T>, without 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...
Us boundaryFieldRef().evaluateCoupled< coupledFaPatch >()
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 a time name for the given scalar time value 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...
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.
List< T > subset(const BoolListType &select, const UList< T > &input, const bool invert=false)
Extract elements of the input list when select is true.
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 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>.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
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.
UPtrList< const IOobject > csorted() const
The sorted list of IOobjects with headerClassName == Type::typeName.
A List with indirect addressing.
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Do not request registration (bool: false)
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)