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;
320template<
class GeoField>
321void 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;
349template<
class TopoSet>
367 const TopoSet&
set = sets[seti];
377 if (
set.contains(map[i]))
398void createCoupledBaffles
408 forAll(coupledWantedPatch, facei)
410 if (coupledWantedPatch[facei] != -1)
413 label zoneID = faceZones.
whichZone(facei);
414 bool zoneFlip =
false;
418 const faceZone& fZone = faceZones[zoneID];
428 mesh.faceOwner()[facei],
430 coupledWantedPatch[facei],
436 if (
mesh.isInternalFace(facei))
438 label zoneID = faceZones.
whichZone(facei);
439 bool zoneFlip =
false;
443 const faceZone& fZone = faceZones[zoneID];
452 mesh.faceNeighbour()[facei],
454 coupledWantedPatch[facei],
465void createCyclicCoupledBaffles
476 forAll(cyclicMasterPatch, facei)
478 if (cyclicMasterPatch[facei] != -1)
482 label zoneID = faceZones.
whichZone(facei);
483 bool zoneFlip =
false;
487 const faceZone& fZone = faceZones[zoneID];
496 mesh.faceNeighbour()[facei],
498 cyclicMasterPatch[facei],
506 forAll(cyclicSlavePatch, facei)
508 if (cyclicSlavePatch[facei] != -1)
511 if (
mesh.isInternalFace(facei))
513 label zoneID = faceZones.
whichZone(facei);
514 bool zoneFlip =
false;
518 const faceZone& fZone = faceZones[zoneID];
527 mesh.faceOwner()[facei],
529 cyclicSlavePatch[facei],
548 Info <<
"faceZone:createBaffle " << faceZones <<
endl;
549 forAll(wantedPatch, facei)
551 if (wantedPatch[facei] != -1)
555 label zoneID = faceZones.
whichZone(facei);
556 bool zoneFlip =
false;
560 const faceZone& fZone = faceZones[zoneID];
570 mesh.faceOwner()[facei],
580 if (
mesh.isInternalFace(facei))
582 label zoneID = faceZones.
whichZone(facei);
583 bool zoneFlip =
false;
587 const faceZone& fZone = faceZones[zoneID];
596 mesh.faceNeighbour()[facei],
616 const label patchi =
patches.findPatchID(patchName);
621 <<
"Illegal patch " << patchName
622 <<
nl <<
"Valid patches are " <<
patches.names()
630 if (newPatchi != patchi)
633 <<
"Patch " << patchName
634 <<
" should have the same patch index on all processors." <<
nl
635 <<
"On my processor it has index " << patchi
636 <<
" ; on some other processor it has index " << newPatchi
646int main(
int argc,
char *argv[])
650 "Mesh and field preparation utility for PDR type simulations."
676 const List<Pair<word>> setsAndPatches(
dict.lookup(
"blockedFaces"));
683 for (
const entry& dEntry : functionDicts)
685 if (!dEntry.isDict())
690 const word&
key = dEntry.keyword();
693 const word cyclicName =
dict.get<
word>(
"cyclicMasterPatch");
696 nameAndType[0] =
key;
697 nameAndType[1] = wallName;
698 nameAndType[2] = cyclicName;
699 coupledAndPatches.append(nameAndType);
702 forAll(setsAndPatches, setI)
704 Info<<
"Faces in faceSet " << setsAndPatches[setI][0]
705 <<
" become baffles in patch " << setsAndPatches[setI][1]
709 forAll(coupledAndPatches, setI)
711 Info<<
"Faces in faceSet " << coupledAndPatches[setI][0]
712 <<
" become coupled baffles in patch " << coupledAndPatches[setI][1]
717 const word defaultPatch(
dict.get<
word>(
"defaultPatch"));
719 Info<<
"Faces that get exposed become boundary faces in patch "
720 << defaultPatch <<
endl;
722 const word blockedSetName(
dict.get<
word>(
"blockedCells"));
724 Info<<
"Reading blocked cells from cellSet " << blockedSetName
727 const bool overwrite =
args.found(
"overwrite");
735 forAll(setsAndPatches, setI)
739 label patchi = findPatch
742 setsAndPatches[setI][1]
745 for (
const label facei : fSet)
747 if (wantedPatch[facei] != -1)
751 <<
" is in faceSet " << setsAndPatches[setI][0]
752 <<
" destined for patch " << setsAndPatches[setI][1]
753 <<
" but also in patch " << wantedPatch[facei]
756 wantedPatch[facei] = patchi;
765 forAll(coupledAndPatches, setI)
768 const label cyclicId =
769 findPatch(
patches, coupledAndPatches[setI][2]);
771 const label cyclicSlaveId = findPatch
776 mesh.boundary()[cyclicId]
777 ).neighbFvPatch().name()
781 label patchi = findPatch(
patches, coupledAndPatches[setI][1]);
783 for (
const label facei : fSet)
785 if (coupledWantedPatch[facei] != -1)
789 <<
" is in faceSet " << coupledAndPatches[setI][0]
790 <<
" destined for patch " << coupledAndPatches[setI][1]
791 <<
" but also in patch " << coupledWantedPatch[facei]
795 coupledWantedPatch[facei] = patchi;
796 cyclicWantedPatch_half0[facei] = cyclicId;
797 cyclicWantedPatch_half1[facei] = cyclicSlaveId;
802 label defaultPatchi = findPatch(
mesh.boundaryMesh(), defaultPatch);
837 cyclicWantedPatch_half0,
843 cyclicWantedPatch_half1,
856 const auto& obj = *objPtr;
872 subsetVolFields<scalar>
883 subsetVolFields<vector>
894 subsetVolFields<sphericalTensor>
905 subsetVolFields<symmTensor>
916 subsetVolFields<tensor>
928 subsetSurfaceFields<scalar>
939 subsetSurfaceFields<vector>
950 subsetSurfaceFields<sphericalTensor>
961 subsetSurfaceFields<symmTensor>
972 subsetSurfaceFields<tensor>
1020 Info<<
"Writing mesh without blockedCells to time "
1051 cyclicWantedPatch_half0,
1059 cyclicWantedPatch_half1,
1068 bitSet modifiedFace(
mesh.nFaces());
1071 createCoupledBaffles
1080 createCyclicCoupledBaffles
1083 cyclicWantedPatch_half0,
1084 cyclicWantedPatch_half1,
1112 initCreatedPatches<volScalarField>
1118 initCreatedPatches<volVectorField>
1124 initCreatedPatches<volSphericalTensorField>
1130 initCreatedPatches<volSymmTensorField>
1136 initCreatedPatches<volTensorField>
1143 initCreatedPatches<surfaceScalarField>
1149 initCreatedPatches<surfaceVectorField>
1155 initCreatedPatches<surfaceSphericalTensorField>
1161 initCreatedPatches<surfaceSymmTensorField>
1167 initCreatedPatches<surfaceTensorField>
1186 Info<<
"Writing mesh with split blockedFaces to time " <<
runTime.value()
1201 if (cellRegion.nRegions() > 1)
1204 <<
"Removing blocked faces and cells created "
1205 << cellRegion.nRegions()
1206 <<
" regions that are not connected via a face." <<
nl
1207 <<
" This is not supported in solvers." <<
nl
1208 <<
" Use" <<
nl <<
nl
1209 <<
" splitMeshRegions <root> <case> -largestOnly" <<
nl <<
nl
1210 <<
" to extract a single region of the mesh." <<
nl
1211 <<
" This mesh will be written to a new timedirectory"
1212 <<
" so might have to be moved back to constant/" <<
nl
1217 if (startFrom !=
"latestTime")
1220 <<
"To run splitMeshRegions please set your"
1221 <<
" startFrom entry to latestTime" <<
endl;
Field reading functions for post-processing utilities.
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
A 1D vector of objects of type <T> with a fixed length <N>.
Generic GeometricField class.
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,...
UPtrList< const IOobject > csorted() const
The sorted list of IOobjects with headerClassName == Type::typeName.
bool add(std::unique_ptr< IOobject > &&objectPtr)
Move insert IOobject into the list.
@ NO_REGISTER
Do not request registration (bool: false).
@ 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,...
A List with indirect addressing.
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,...
void resize_null(const label newLen)
Set the addressed list to the given size, deleting all existing entries. Afterwards the list contains...
void size(const label n)
Older name for setAddressableSize.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
label size() const noexcept
The number of entries in the list.
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
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.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
void set(const bitSet &bitset)
Set specified bits from another bitset.
A collection of cell labels.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A keyword and a list of tokens is an 'entry'.
A subset of mesh faces organised as a primitive patch.
label whichFace(const label meshFaceID) const
The local index of the given mesh face, -1 if not in the zone.
const boolList & flipMap() const noexcept
Return face flip map.
A face is a list of labels corresponding to mesh vertices.
Holds a reference to the original mesh (the baseMesh) and optionally to a subset of that mesh (the su...
const fvMesh & baseMesh() const noexcept
Original mesh.
const labelList & faceMap() const
Return face map.
const labelList & cellMap() const
Return cell map.
static tmp< DimensionedField< Type, volMesh > > interpolate(const DimensionedField< Type, volMesh > &, const fvMesh &sMesh, const labelUList &cellMap)
Map volume internal (dimensioned) field.
const fvMesh & subMesh() const
Return reference to subset mesh.
const labelList & patchMap() const
Return patch map.
const labelList & pointMap() const
Return point map.
Mesh data needed to do the Finite Volume discretisation.
virtual void updateMesh(const mapPolyMesh &mpm)
Update mesh corresponding to the given map.
virtual bool write(const bool writeOnProc=true) const
Write mesh using IO settings from time.
virtual void movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
const fvPatch & patch() const noexcept
Return the patch.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
const polyPatch & patch() const noexcept
Return the polyPatch.
const fvPatch & patch() const noexcept
Return the patch.
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const pointField & preMotionPoints() const noexcept
Pre-motion point positions.
bool hasMotionPoints() const noexcept
Has valid preMotionPoints?
const labelList & oldPatchSizes() const noexcept
Return list of the old patch sizes.
A face addition data class. A face can be inflated either from a point or from another face and can e...
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
const fileName & facesInstance() const
Return the current instance directory for faces.
Class describing modification of a face.
label start() const noexcept
Return start label of this patch in the polyMesh face list.
Direct mesh changes based on v1.3 polyTopoChange syntax.
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.
autoPtr< mapPolyMesh > changeMesh(polyMesh &mesh, const labelUList &patchMap, const bool inflate, const bool syncParallel=true, const bool orderCells=false, const bool orderPoints=false)
Inplace changes mesh without change of patches.
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
Tensor of scalars, i.e. Tensor<scalar>.
virtual void updateMesh(const mapPolyMesh &morphMap)
Update any stored data for new labels. Not implemented.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
A class for handling words, derived from Foam::string.
const polyBoundaryMesh & patches
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
return returnReduce(nRefine-oldNRefine, sumOp< label >())
#define WarningInFunction
Report a warning using Foam::Warning.
void set(List< bool > &bools, const labelUList &locations)
Set the listed locations (assign 'true').
bitSet create(const label n, const labelHashSet &locations, const bool on=true)
Create a bitSet with length n with the specified on locations.
bool is_volume(const word &clsName)
Test if the class name appears to be a volume field.
bool is_surface(const word &clsName)
Test if the class name appears to be a surface field.
constexpr auto key(const Type &t) noexcept
Helper function to return the enum value.
wordList ReadFields(const typename GeoMesh::Mesh &mesh, const IOobjectList &objects, PtrList< GeometricField< Type, PatchField, GeoMesh > > &fields, const bool syncPar=true, const bool readOldTime=false)
Read Geometric fields of templated type.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
List< label > labelList
A List of labels.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
messageStream Info
Information stream (stdout output on master, null elsewhere).
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with faceZone content on a polyMesh.
List< T > subset(const BoolListType &select, const UList< T > &input, const bool invert=false)
Extract elements of the input list when select is true.
Ostream & endl(Ostream &os)
Add newline and flush stream.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars, i.e. SphericalTensor<scalar>.
SymmTensor< scalar > symmTensor
SymmTensor of scalars, i.e. SymmTensor<scalar>.
constexpr char nl
The newline '\n' character (0x0a).
Foam::argList args(argc, argv)
Us boundaryFieldRef().evaluateCoupled< coupledFaPatch >()
#define forAll(list, i)
Loop across all elements in list.
#define forAllIters(container, iter)
Iterate across all elements in the container object.