71 Info<<
"Adding exposed internal faces to " 72 << (
patchId == -1 ?
"new" :
"existing")
73 <<
" patch: " << patchName <<
nl <<
endl;
104 patchFaces[nFaces] =
pp.start()+i;
125 bool haveWarned =
false;
128 if (!faceData[faceI].valid(deltaCalc.data()))
133 <<
"Did not visit some faces, e.g. face " << faceI
135 <<
"Using patch " <<
patchIDs[0] <<
" as nearest" 143 nearest[faceI] = faceData[faceI].
data();
154 template<
class FieldType>
175 Info<<
"Subsetting " << FieldType::typeName <<
" (";
198 auto& subField = subFields[nFields];
202 subField.rename(
io.
name());
215 template<
class FieldType>
237 Info<<
"Subsetting " << FieldType::typeName <<
" (";
260 auto& subField = subFields[nFields];
264 subField.rename(
io.
name());
276 template<
class TopoSet>
288 ReadFields<TopoSet>(objects, sets);
294 const TopoSet&
set = sets[seti];
296 Info<<
"Subsetting " <<
set.type() <<
" " <<
set.name() <<
endl;
303 if (
set.
found(map[i]))
326 int main(
int argc,
char *argv[])
330 "Create a mesh subset for a particular region of interest based on a" 331 " cellSet or cellZone(s) specified as the first command argument.\n" 332 "See setSet/topoSet utilities on how to select cells based on" 341 "The cellSet name, but with the -zone option this is interpreted" 342 " to be a cellZone selection by name(s) or regex.\n" 343 "Eg 'mixer' or '( mixer \"moving.*\" )'" 350 "Add exposed internal faces to specified patch" 351 " instead of \"oldInternalFaces\"" 357 "Add exposed internal faces to closest of specified patches" 358 " instead of \"oldInternalFaces\"" 364 "Exclude single or multiple patches from the -patches selection" 369 "Subset with cellZone(s) instead of cellSet." 370 " The command argument may be a list of words or regexs" 376 "Specify a time for the resulting mesh" 392 const bool useCellZone =
args.
found(
"zone");
393 const bool overwrite =
args.
found(
"overwrite");
399 if (specifiedInstance)
402 meshInstance = fieldsInstance;
409 wordRes includePatches, excludePatches;
421 if (includePatches.size() == 1 && includePatches.front().isLiteral())
424 exposedPatchIDs.front() =
425 getExposedPatchId(
mesh, includePatches.
front());
427 else if (!includePatches.empty())
434 const label nNonProcessor
439 forAll(exposedPatchIDs, i)
441 if (exposedPatchIDs[i] > nNonProcessor)
443 exposedPatchIDs.resize(i);
450 Info<<
"Adding exposed internal faces to nearest of patches:" <<
nl 455 if (exposedPatchIDs.empty())
458 <<
nl <<
"No patches matched. Patches: " 465 Info<<
"Adding exposed internal faces to patch \"" 467 <<
"\" (created if necessary)" <<
nl 495 Info<<
"Using cellSet " << selectionName <<
nl <<
endl;
512 if (exposedPatchIDs.size() == 1)
515 subsetter.
reset(selectedCells, exposedPatchIDs.front(),
true);
520 labelList nearestExposedPatch(nearestPatch(
mesh, exposedPatchIDs));
524 subsetter.getExposedFaces(selectedCells,
true)
541 Info<<
"Subset " << cellCount[0] <<
" of " << cellCount[1]
542 <<
" cells" <<
nl <<
nl;
550 #undef createSubsetFields 551 #define createSubsetFields(FieldType, Variable) \ 552 PtrList<FieldType> Variable \ 554 subsetFields<FieldType>(subsetter, objects) \ 588 #undef createSubsetFields 589 #define createSubsetFields(FieldType, Variable) \ 590 PtrList<FieldType> Variable \ 592 subsetFields<FieldType>(subsetter, objects, pMesh) \ 601 #undef createSubsetFields 615 objects.
remove(*cellSetPtr);
647 if (overwrite || specifiedInstance)
668 for (
const auto&
fld : vScalarFlds) {
fld.write(); }
669 for (
const auto&
fld : vVectorFlds) {
fld.write(); }
670 for (
const auto&
fld : vSphTensorFlds) {
fld.write(); }
671 for (
const auto&
fld : vSymmTensorFlds) {
fld.write(); }
672 for (
const auto&
fld : vTensorFlds) {
fld.write(); }
675 for (
const auto&
fld : sScalarFlds) {
fld.write(); }
676 for (
const auto&
fld : sVectorFlds) {
fld.write(); }
677 for (
const auto&
fld : sSphTensorFlds) {
fld.write(); }
678 for (
const auto&
fld : sSymmTensorFlds) {
fld.write(); }
679 for (
const auto&
fld : sTensorFlds) {
fld.write(); }
682 for (
const auto&
fld : dScalarFlds) {
fld.write(); }
683 for (
const auto&
fld : dVectorFlds) {
fld.write(); }
684 for (
const auto&
fld : dSphTensorFlds) {
fld.write(); }
685 for (
const auto&
fld : dSymmTensorFlds) {
fld.write(); }
686 for (
const auto&
fld : dTensorFlds) {
fld.write(); }
689 for (
const auto&
fld : pScalarFlds) {
fld.write(); }
690 for (
const auto&
fld : pVectorFlds) {
fld.write(); }
691 for (
const auto&
fld : pSphTensorFlds) {
fld.write(); }
692 for (
const auto&
fld : pSymmTensorFlds) {
fld.write(); }
693 for (
const auto&
fld : pTensorFlds) {
fld.write(); }
label findPatchID(const word &patchName, const bool allowNotFound=true) const
Find patch index given a name, return -1 if not found.
const labelList patchIDs(pbm.indices(polyPatchNames, true))
const polyBoundaryMesh & pbm
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.
static void removeFiles(const polyMesh &mesh)
Helper: remove all procAddressing files from mesh instance.
T * front()
The first entry in the list.
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)
const fileName & facesInstance() const
Return the current instance directory for faces.
void resize(const label len)
Adjust allocated size of list.
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label findIndex(const wordRe &key) const
Zone index for the first match, return -1 if not found.
const word & name() const noexcept
Return the object name.
static const pointMesh & New(const polyMesh &mesh, Args &&... args)
Get existing or create a new MeshObject. Registered with typeName.
void setCellSubset(const bitSet &selectedCells, const label patchID=-1, const bool syncPar=true)
Use the specified subset of cells. Same as reset()
constexpr char nl
The newline '\n' character (0x0a)
T * data() noexcept
Return pointer to the underlying array serving as data storage.
UIndirectList< label > labelUIndList
UIndirectList of labels.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Wave propagation of information through grid. Every iteration information goes through one layer of c...
List< T > getList(const label index) const
Get a List of values from the argument at index.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
Field reading functions for post-processing utilities.
const fvMesh & baseMesh() const noexcept
Original mesh.
T & emplace(Args &&... args)
Reset with emplace construction. Return reference to the new content.
Ignore writing from objectRegistry::writeObject()
const Time & time() const
Return the top-level database.
label nFaces() const noexcept
Number of mesh faces.
const labelList & faceMap() const
Return face map.
Mesh representing a set of points created from polyMesh.
#define forAll(list, i)
Loop across all elements in list.
labelList indices(const wordRe &matcher, const bool useGroups=true) const
Return (sorted) patch indices for all matches.
const fvMesh & subMesh() const
Return reference to subset mesh.
void resize_null(const label newLen)
Set the addressed list to the given size, deleting all existing entries. Afterwards the list contains...
const fileName & pointsInstance() const
Return the current instance directory for points.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
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 labelList & pointMap() const
Return point map.
void reset()
Reset subMesh and all maps. Same as clear()
A List of wordRe with additional matching capabilities.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
const globalMeshData & globalData() const
Return parallel info (demand-driven)
virtual void setTime(const Time &t)
Reset the time and time-index to those of the given time.
const labelList & cellMap() const
Return cell map.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
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...
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings...
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.
bool readListIfPresent(const word &optName, List< T > &list) const
If named option is present, get a List of values treating a single entry like a list of size 1...
Holds a reference to the original mesh (the baseMesh) and optionally to a subset of that mesh (the su...
label nTotalCells() const noexcept
Return total number of cells in decomposed mesh.
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))
const vectorField & faceCentres() const
List< T > subset(const BoolListType &select, const UList< T > &input, const bool invert=false)
Extract elements of the input list when select is true.
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name...
static word exposedPatchName
Name for exposed internal faces (default: oldInternalFaces)
T get(const label index) const
Get a value from the argument at index.
void setInstance(const fileName &instance, const IOobjectOption::writeOption wOpt=IOobject::AUTO_WRITE)
Set the instance for mesh files.
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.
autoPtr< IOobject > remove(const IOobject &io)
Remove object from the list by its IOobject::name().
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
static void setInstance(const fileName &instance, Container &)
Helper: set instance on all sets in container.
Mesh data needed to do the Finite Volume discretisation.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Automatically write from objectRegistry::writeObject()
For use with FaceCellWave. Determines topological distance to starting faces. Templated on passive tr...
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
messageStream Info
Information stream (stdout output on master, null elsewhere)
bitSet selection(const labelUList &zoneIds) const
Return all elements (cells, faces, points) contained in the listed zones.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Mesh consisting of general polyhedral cells.
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
A patch is a list of labels that address the faces in the global face list.
bitSet create(const label n, const labelHashSet &locations, const bool on=true)
Create a bitSet with length n with the specified on locations.
label nNonProcessor() const
The number of patches before the first processor patch.
Foam::argList args(argc, argv)
Extends Foam::fvMeshSubset with two-step subsetting (uses polyTopoChange modification).
Defines the attributes of an object for which implicit objectRegistry management is supported...
UPtrList< const IOobject > csorted() const
The sorted list of IOobjects with headerClassName == Type::typeName.
Do not request registration (bool: false)
bool found(const word &optName) const
Return true if the named option is found.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.