64 const label
patchId =
mesh.boundaryMesh().findPatchID(patchName);
68 fvMeshSubset::exposedPatchName = patchName;
71 Info<<
"Adding exposed internal faces to "
72 << (
patchId == -1 ?
"new" :
"existing")
73 <<
" patch \"" << patchName <<
"\"" << nl << endl;
85 for (
const label patchi : patchIDs)
98 for (
const label patchi : patchIDs)
118 mesh.globalData().nTotalCells()+1
125 bool haveWarned =
false;
128 if (!faceData[faceI].valid(deltaCalc.data()))
133 <<
"Did not visit some faces, e.g. face " << faceI
134 <<
" at " <<
mesh.faceCentres()[faceI] <<
nl
135 <<
"Using patch " << patchIDs[0] <<
" as nearest"
139 nearest[faceI] = patchIDs[0];
143 nearest[faceI] = faceData[faceI].data();
155template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
164 const word fieldType = FieldType::typeName;
167 subFields.setSize(fieldNames.
size());
172 for (
const word& fieldName : fieldNames)
176 Info<<
"Subsetting " << fieldType <<
" (";
200 subFields[nFields].rename(fieldName);
213void subsetPointFields
222 const word fieldType = FieldType::typeName;
225 subFields.setSize(fieldNames.
size());
230 for (
const word& fieldName : fieldNames)
234 Info<<
"Subsetting " << fieldType <<
" (";
258 subFields[nFields].rename(fieldName);
271void subsetDimensionedFields
279 const word fieldType = FieldType::typeName;
282 subFields.setSize(fieldNames.
size());
287 for (
const word& fieldName : fieldNames)
291 Info<<
"Subsetting " << fieldType <<
" (";
315 subFields[nFields].rename(fieldName);
327template<
class TopoSet>
339 ReadFields<TopoSet>(objects, sets);
344 const TopoSet&
set = sets[seti];
352 if (
set.found(map[i]))
374int main(
int argc,
char *argv[])
378 "Create a mesh subset for a particular region of interest based on a"
379 " cellSet or cellZone(s) specified as the first command argument.\n"
380 "See setSet/topoSet utilities on how to select cells based on"
389 "The cellSet name, but with the -zone option this is interpreted"
390 " to be a cellZone selection by name(s) or regex.\n"
391 "Eg 'mixer' or '( mixer \"moving.*\" )'"
398 "Add exposed internal faces to specified patch"
399 " instead of \"oldInternalFaces\""
405 "Add exposed internal faces to closest of specified patches"
406 " instead of \"oldInternalFaces\""
408 argList::addBoolOption
411 "Subset with cellZone(s) instead of cellSet."
412 " The command argument may be a list of words or regexs"
418 "Specify a time for the resulting mesh"
421 argList::noFunctionObjects();
431 word meshInstance =
mesh.pointsInstance();
434 const bool useCellZone =
args.
found(
"zone");
435 const bool overwrite =
args.
found(
"overwrite");
441 if (specifiedInstance)
444 meshInstance = fieldsInstance;
457 exposedPatchIDs.first() =
465 Info<<
"Adding exposed internal faces to nearest of patches "
468 if (exposedPatchIDs.empty())
471 <<
nl <<
"No patches matched. Patches: "
472 <<
mesh.boundaryMesh().names() <<
nl
479 exposedPatchIDs.first() =
484 Info<<
"Adding exposed internal faces to patch \""
485 << fvMeshSubset::exposedPatchName
486 <<
"\" (created if necessary)" <<
nl
503 if (
mesh.cellZones().findIndex(zoneNames) == -1)
514 Info<<
"Using cellSet " << selectionName <<
nl <<
endl;
527 ? BitSetOps::create(
mesh.nCells(), *cellSetPtr)
528 :
mesh.cellZones().selection(zoneNames)
531 if (exposedPatchIDs.size() == 1)
534 subsetter.
reset(selectedCells, exposedPatchIDs.first(),
true);
539 labelList nearestExposedPatch(nearestPatch(
mesh, exposedPatchIDs));
543 subsetter.getExposedFaces(selectedCells,
true)
559 <<
" cells" <<
nl <<
nl;
571 subsetFields(subsetter, availableFields, vScalarFlds);
574 subsetFields(subsetter, availableFields, vVectorFlds);
577 subsetFields(subsetter, availableFields, vSphTensorFlds);
580 subsetFields(subsetter, availableFields, vSymmTensorFlds);
583 subsetFields(subsetter, availableFields, vTensorFlds);
590 subsetFields(subsetter, availableFields, sScalarFlds);
593 subsetFields(subsetter, availableFields, sVectorFlds);
596 subsetFields(subsetter, availableFields, sSphTensorFlds);
599 subsetFields(subsetter, availableFields, sSymmTensorFlds);
602 subsetFields(subsetter, availableFields, sTensorFlds);
611 subsetPointFields(subsetter, pMesh, availableFields, pScalarFlds);
614 subsetPointFields(subsetter, pMesh, availableFields, pVectorFlds);
617 subsetPointFields(subsetter, pMesh, availableFields, pSphTensorFlds);
620 subsetPointFields(subsetter, pMesh, availableFields, pSymmTensorFlds);
623 subsetPointFields(subsetter, pMesh, availableFields, pTensorFlds);
630 subsetDimensionedFields(subsetter, availableFields, dScalarFlds);
633 subsetDimensionedFields(subsetter, availableFields, dVectorFlds);
636 subsetDimensionedFields(subsetter, availableFields, dSphTensorFlds);
639 subsetDimensionedFields(subsetter, availableFields, dSymmTensorFlds);
642 subsetDimensionedFields(subsetter, availableFields, dTensorFlds);
656 objects.
remove(*cellSetPtr);
688 if (overwrite || specifiedInstance)
692 topoSet::setInstance(meshInstance, cellSets);
693 topoSet::setInstance(meshInstance, faceSets);
694 topoSet::setInstance(meshInstance, pointSets);
702 Info<<
"Writing subsetted mesh and fields to time " <<
runTime.timeName()
705 processorMeshes::removeFiles(subsetter.
subMesh());
709 for (
const auto&
fld : vScalarFlds) {
fld.write(); }
710 for (
const auto&
fld : vVectorFlds) {
fld.write(); }
711 for (
const auto&
fld : vSphTensorFlds) {
fld.write(); }
712 for (
const auto&
fld : vSymmTensorFlds) {
fld.write(); }
713 for (
const auto&
fld : vTensorFlds) {
fld.write(); }
716 for (
const auto&
fld : sScalarFlds) {
fld.write(); }
717 for (
const auto&
fld : sVectorFlds) {
fld.write(); }
718 for (
const auto&
fld : sSphTensorFlds) {
fld.write(); }
719 for (
const auto&
fld : sSymmTensorFlds) {
fld.write(); }
720 for (
const auto&
fld : sTensorFlds) {
fld.write(); }
723 for (
const auto&
fld : pScalarFlds) {
fld.write(); }
724 for (
const auto&
fld : pVectorFlds) {
fld.write(); }
725 for (
const auto&
fld : pSphTensorFlds) {
fld.write(); }
726 for (
const auto&
fld : pSymmTensorFlds) {
fld.write(); }
727 for (
const auto&
fld : pTensorFlds) {
fld.write(); }
730 for (
const auto&
fld : dScalarFlds) {
fld.write(); }
731 for (
const auto&
fld : dVectorFlds) {
fld.write(); }
732 for (
const auto&
fld : dSphTensorFlds) {
fld.write(); }
733 for (
const auto&
fld : dSymmTensorFlds) {
fld.write(); }
734 for (
const auto&
fld : dTensorFlds) {
fld.write(); }
Field reading functions for post-processing utilities.
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Wave propagation of information through grid. Every iteration information goes through one layer of c...
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Generic GeometricField class.
A HashTable similar to std::unordered_map.
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
List of IOobjects with searching and retrieving facilities.
HashTable< wordHashSet > classes() const
A summary hash of classes used and their associated object names.
bool remove(const IOobject &io)
Remove IOobject from the list.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
void transfer(List< T > &list)
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
const T * set(const label i) const
void setSize(const label newLen)
Same as resize()
static word timeName(const scalar t, const int precision=precision_)
A List with indirect addressing. Like IndirectList but does not store addressing.
void size(const label n)
Older name for setAddressableSize.
label size() const noexcept
The number of elements in the list.
T get(const label index) const
Get a value from the argument at index.
bool found(const word &optName) const
Return true if the named option is found.
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
List< T > getList(const label index) const
Get a List of values from the argument at index.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
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.
void setCellSubset(const bitSet &selectedCells, const label patchID=-1, const bool syncPar=true)
Use the specified subset of cells. Same as reset()
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 & pointMap() const
Return point map.
void reset()
Reset subMesh and all maps. Same as clear()
Extends Foam::fvMeshSubset with two-step subsetting (uses polyTopoChange modification).
Mesh data needed to do the Finite Volume discretisation.
virtual bool write(const bool valid=true) const
Write mesh using IO settings from time.
const Time & time() const
Return the top-level database.
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name.
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
Mesh representing a set of points created from polyMesh.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Mesh consisting of general polyhedral cells.
void setInstance(const fileName &instance, const IOobject::writeOption wOpt=IOobject::AUTO_WRITE)
Set the instance for mesh files.
A patch is a list of labels that address the faces in the global face list.
label start() const
Return start label of this patch in the polyMesh face list.
label nCells() const noexcept
Number of mesh cells.
For use with FaceCellWave. Determines topological distance to starting faces. Templated on passive tr...
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
A List of wordRe with additional matching capabilities.
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const labelList nFaces(UPstream::listGatherValues< label >(aMesh.nFaces()))
#define WarningInFunction
Report a warning using Foam::Warning.
void set(List< bool > &bools, const labelUList &locations)
Set the listed locations (assign 'true').
messageStream Info
Information stream (stdout output on master, null elsewhere)
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.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
wordList patchNames(nPatches)
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.