subsetMesh.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2016-2022 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Application
28  subsetMesh
29 
30 Group
31  grpMeshManipulationUtilities
32 
33 Description
34  Create a mesh subset for a particular region of interest based on a
35  cellSet or cellZone.
36 
37  See setSet/topoSet utilities on how to define select cells based on
38  various shapes.
39 
40  Will subset all points, faces and cells needed to make a sub-mesh,
41  but not preserve attached boundary types.
42 
43 \*---------------------------------------------------------------------------*/
44 
45 #include "fvMeshSubsetter.H" // Not fvMeshSubset (need two-step subsetting)
46 #include "argList.H"
47 #include "IOobjectList.H"
48 #include "volFields.H"
49 #include "topoDistanceData.H"
50 #include "FaceCellWave.H"
51 #include "cellSet.H"
52 #include "faceSet.H"
53 #include "pointSet.H"
54 #include "ReadFields.H"
55 #include "processorMeshes.H"
56 
57 using namespace Foam;
58 
59 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60 
61 // Get the exposed patchId or define the exposedPatchName in fvMeshSubset
62 label getExposedPatchId(const polyMesh& mesh, const word& patchName)
63 {
64  const label patchId = mesh.boundaryMesh().findPatchID(patchName);
65 
66  if (patchId == -1)
67  {
69  }
70 
71  Info<< "Adding exposed internal faces to "
72  << (patchId == -1 ? "new" : "existing")
73  << " patch \"" << patchName << "\"" << nl << endl;
74 
75  return patchId;
76 }
77 
78 
79 labelList nearestPatch(const polyMesh& mesh, const labelList& patchIDs)
80 {
81  const polyBoundaryMesh& pbm = mesh.boundaryMesh();
82 
83  // Count number of faces in exposedPatchIDs
84  label nFaces = 0;
85  for (const label patchi : patchIDs)
86  {
87  nFaces += pbm[patchi].size();
88  }
89 
90  // Field on cells and faces.
93 
94  // Start of changes
95  labelList patchFaces(nFaces);
96  List<topoDistanceData<label>> patchData(nFaces);
97  nFaces = 0;
98  for (const label patchi : patchIDs)
99  {
100  const polyPatch& pp = pbm[patchi];
101 
102  forAll(pp, i)
103  {
104  patchFaces[nFaces] = pp.start()+i;
105  patchData[nFaces] = topoDistanceData<label>(0, patchi);
106  ++nFaces;
107  }
108  }
109 
110  // Propagate information inwards
112  (
113  mesh,
114  patchFaces,
115  patchData,
116  faceData,
117  cellData,
119  );
120 
121  // And extract
122 
123  labelList nearest(mesh.nFaces());
124 
125  bool haveWarned = false;
126  forAll(faceData, faceI)
127  {
128  if (!faceData[faceI].valid(deltaCalc.data()))
129  {
130  if (!haveWarned)
131  {
133  << "Did not visit some faces, e.g. face " << faceI
134  << " at " << mesh.faceCentres()[faceI] << nl
135  << "Using patch " << patchIDs[0] << " as nearest"
136  << endl;
137  haveWarned = true;
138  }
139  nearest[faceI] = patchIDs[0];
140  }
141  else
142  {
143  nearest[faceI] = faceData[faceI].data();
144  }
145  }
146 
147  return nearest;
148 }
149 
150 
151 //
152 // Subset field-type, availability information cached
153 // in the availableFields hashtable.
154 //
155 template<class Type, template<class> class PatchField, class GeoMesh>
156 void subsetFields
157 (
158  const fvMeshSubset& subsetter,
159  HashTable<wordHashSet>& availableFields,
161 )
162 {
164  const word fieldType = FieldType::typeName;
165 
166  const wordList fieldNames = availableFields(fieldType).sortedToc();
167  subFields.setSize(fieldNames.size());
168 
169  const fvMesh& baseMesh = subsetter.baseMesh();
170 
171  label nFields = 0;
172  for (const word& fieldName : fieldNames)
173  {
174  if (!nFields)
175  {
176  Info<< "Subsetting " << fieldType << " (";
177  }
178  else
179  {
180  Info<< ' ';
181  }
182  Info<< fieldName;
183 
184  FieldType fld
185  (
186  IOobject
187  (
188  fieldName,
189  baseMesh.time().timeName(),
190  baseMesh,
193  ),
194  baseMesh
195  );
196 
197  subFields.set(nFields, subsetter.interpolate(fld));
198 
199  // Subsetting adds 'subset' prefix - rename to match original.
200  subFields[nFields].rename(fieldName);
201 
202  ++nFields;
203  }
204 
205  if (nFields)
206  {
207  Info<< ')' << nl;
208  }
209 }
210 
211 
212 template<class Type>
213 void subsetPointFields
214 (
215  const fvMeshSubset& subsetter,
216  const pointMesh& pMesh,
217  HashTable<wordHashSet>& availableFields,
219 )
220 {
222  const word fieldType = FieldType::typeName;
223 
224  const wordList fieldNames = availableFields(fieldType).sortedToc();
225  subFields.setSize(fieldNames.size());
226 
227  const fvMesh& baseMesh = subsetter.baseMesh();
228 
229  label nFields = 0;
230  for (const word& fieldName : fieldNames)
231  {
232  if (!nFields)
233  {
234  Info<< "Subsetting " << fieldType << " (";
235  }
236  else
237  {
238  Info<< ' ';
239  }
240  Info<< fieldName;
241 
242  FieldType fld
243  (
244  IOobject
245  (
246  fieldName,
247  baseMesh.time().timeName(),
248  baseMesh,
251  ),
252  pMesh
253  );
254 
255  subFields.set(nFields, subsetter.interpolate(fld));
256 
257  // Subsetting adds 'subset' prefix - rename to match original.
258  subFields[nFields].rename(fieldName);
259 
260  ++nFields;
261  }
262 
263  if (nFields)
264  {
265  Info<< ')' << nl;
266  }
267 }
268 
269 
270 template<class Type>
271 void subsetDimensionedFields
272 (
273  const fvMeshSubset& subsetter,
274  HashTable<wordHashSet>& availableFields,
276 )
277 {
278  typedef DimensionedField<Type, volMesh> FieldType;
279  const word fieldType = FieldType::typeName;
280 
281  const wordList fieldNames = availableFields(fieldType).sortedToc();
282  subFields.setSize(fieldNames.size());
283 
284  const fvMesh& baseMesh = subsetter.baseMesh();
285 
286  label nFields = 0;
287  for (const word& fieldName : fieldNames)
288  {
289  if (!nFields)
290  {
291  Info<< "Subsetting " << fieldType << " (";
292  }
293  else
294  {
295  Info<< ' ';
296  }
297  Info<< fieldName;
298 
299  FieldType fld
300  (
301  IOobject
302  (
303  fieldName,
304  baseMesh.time().timeName(),
305  baseMesh,
308  ),
309  baseMesh
310  );
311 
312  subFields.set(nFields, subsetter.interpolate(fld));
313 
314  // Subsetting adds 'subset' prefix - rename to match original.
315  subFields[nFields].rename(fieldName);
316 
317  ++nFields;
318  }
319 
320  if (nFields)
321  {
322  Info<< ')' << nl;
323  }
324 }
325 
326 
327 template<class TopoSet>
328 void subsetTopoSets
329 (
330  const fvMesh& mesh,
331  const IOobjectList& objects,
332  const labelList& map,
333  const fvMesh& subMesh,
334  PtrList<TopoSet>& subSets
335 )
336 {
337  // Read original sets
338  PtrList<TopoSet> sets;
339  ReadFields<TopoSet>(objects, sets);
340 
341  subSets.setSize(sets.size());
342  forAll(sets, seti)
343  {
344  const TopoSet& set = sets[seti];
345 
346  Info<< "Subsetting " << set.type() << " " << set.name() << endl;
347 
348  labelHashSet subset(2*min(set.size(), map.size()));
349 
350  forAll(map, i)
351  {
352  if (set.found(map[i]))
353  {
354  subset.insert(i);
355  }
356  }
357 
358  subSets.set
359  (
360  seti,
361  new TopoSet
362  (
363  subMesh,
364  set.name(),
365  std::move(subset),
367  )
368  );
369  }
370 }
371 
372 
373 
374 int main(int argc, char *argv[])
375 {
377  (
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"
381  " various shapes."
382  );
383 
384  #include "addOverwriteOption.H"
385  #include "addRegionOption.H"
387  (
388  "cell-selection",
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.*\" )'"
392  );
393 
395  (
396  "patch",
397  "name",
398  "Add exposed internal faces to specified patch"
399  " instead of \"oldInternalFaces\""
400  );
402  (
403  "patches",
404  "wordRes",
405  "Add exposed internal faces to closest of specified patches"
406  " instead of \"oldInternalFaces\""
407  );
409  (
410  "zone",
411  "Subset with cellZone(s) instead of cellSet."
412  " The command argument may be a list of words or regexs"
413  );
415  (
416  "resultTime",
417  "time",
418  "Specify a time for the resulting mesh"
419  );
420 
421  argList::noFunctionObjects(); // Never use function objects
422 
423  #include "setRootCase.H"
424  #include "createTime.H"
425 
426  #include "createNamedMesh.H"
427 
428  // arg[1] = word (cellSet) or wordRes (cellZone)
429  // const word selectionName = args[1];
430 
431  word meshInstance = mesh.pointsInstance();
432  word fieldsInstance = runTime.timeName();
433 
434  const bool useCellZone = args.found("zone");
435  const bool overwrite = args.found("overwrite");
436  const bool specifiedInstance = args.readIfPresent
437  (
438  "resultTime",
439  fieldsInstance
440  );
441  if (specifiedInstance)
442  {
443  // Set both mesh and field to this time
444  meshInstance = fieldsInstance;
445  }
446 
447 
448  // Default exposed patch id
449  labelList exposedPatchIDs(one{}, -1);
450 
451  if (args.found("patches"))
452  {
453  const wordRes patchNames(args.getList<wordRe>("patches"));
454 
455  if (patchNames.size() == 1 && patchNames.first().isLiteral())
456  {
457  exposedPatchIDs.first() =
458  getExposedPatchId(mesh, patchNames.first());
459  }
460  else
461  {
462  exposedPatchIDs =
464 
465  Info<< "Adding exposed internal faces to nearest of patches "
466  << flatOutput(patchNames) << nl << endl;
467 
468  if (exposedPatchIDs.empty())
469  {
471  << nl << "No patches matched. Patches: "
472  << mesh.boundaryMesh().names() << nl
473  << exit(FatalError);
474  }
475  }
476  }
477  else if (args.found("patch"))
478  {
479  exposedPatchIDs.first() =
480  getExposedPatchId(mesh, args.get<word>("patch"));
481  }
482  else
483  {
484  Info<< "Adding exposed internal faces to patch \""
486  << "\" (created if necessary)" << nl
487  << nl;
488  }
489 
490 
491  autoPtr<cellSet> cellSetPtr;
492 
493  // arg[1] can be a word (for cellSet) or wordRes (for cellZone)
494 
495  wordRes zoneNames;
496  if (useCellZone)
497  {
498  wordRes selectionNames(args.getList<wordRe>(1));
499  zoneNames.transfer(selectionNames);
500 
501  Info<< "Using cellZone " << flatOutput(zoneNames) << nl << endl;
502 
503  if (mesh.cellZones().findIndex(zoneNames) == -1)
504  {
506  << "No cellZones found: " << flatOutput(zoneNames) << nl << nl
507  << exit(FatalError);
508  }
509  }
510  else
511  {
512  const word selectionName = args[1];
513 
514  Info<< "Using cellSet " << selectionName << nl << endl;
515 
516  cellSetPtr = autoPtr<cellSet>::New(mesh, selectionName);
517  }
518 
519 
520  // Two-step mesh subsetting engine
521  fvMeshSubsetter subsetter(mesh);
522 
523  {
524  bitSet selectedCells =
525  (
526  cellSetPtr
527  ? BitSetOps::create(mesh.nCells(), *cellSetPtr)
528  : mesh.cellZones().selection(zoneNames)
529  );
530 
531  if (exposedPatchIDs.size() == 1)
532  {
533  // Single patch for exposed faces (syncPar)
534  subsetter.reset(selectedCells, exposedPatchIDs.first(), true);
535  }
536  else
537  {
538  // The nearest patch per face
539  labelList nearestExposedPatch(nearestPatch(mesh, exposedPatchIDs));
540 
541  labelList exposedFaces
542  (
543  subsetter.getExposedFaces(selectedCells, true) // syncPar
544  );
545 
546  subsetter.setCellSubset
547  (
548  selectedCells,
549  exposedFaces,
550  labelUIndList(nearestExposedPatch, exposedFaces)(),
551  true // syncPar
552  );
553  }
554 
555  Info<< "Subset "
556  << returnReduce(subsetter.subMesh().nCells(), sumOp<label>())
557  << " of "
559  << " cells" << nl << nl;
560  }
561 
562 
563  IOobjectList objects(mesh, runTime.timeName());
564  HashTable<wordHashSet> availableFields = objects.classes();
565 
566 
567  // Read vol fields and subset
568  // ~~~~~~~~~~~~~~~~~~~~~~~~~~
569 
570  PtrList<volScalarField> vScalarFlds;
571  subsetFields(subsetter, availableFields, vScalarFlds);
572 
573  PtrList<volVectorField> vVectorFlds;
574  subsetFields(subsetter, availableFields, vVectorFlds);
575 
576  PtrList<volSphericalTensorField> vSphTensorFlds;
577  subsetFields(subsetter, availableFields, vSphTensorFlds);
578 
579  PtrList<volSymmTensorField> vSymmTensorFlds;
580  subsetFields(subsetter, availableFields, vSymmTensorFlds);
581 
582  PtrList<volTensorField> vTensorFlds;
583  subsetFields(subsetter, availableFields, vTensorFlds);
584 
585 
586  // Read surface fields and subset
587  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
588 
589  PtrList<surfaceScalarField> sScalarFlds;
590  subsetFields(subsetter, availableFields, sScalarFlds);
591 
592  PtrList<surfaceVectorField> sVectorFlds;
593  subsetFields(subsetter, availableFields, sVectorFlds);
594 
596  subsetFields(subsetter, availableFields, sSphTensorFlds);
597 
598  PtrList<surfaceSymmTensorField> sSymmTensorFlds;
599  subsetFields(subsetter, availableFields, sSymmTensorFlds);
600 
601  PtrList<surfaceTensorField> sTensorFlds;
602  subsetFields(subsetter, availableFields, sTensorFlds);
603 
604 
605  // Read point fields and subset
606  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
607 
608  const pointMesh& pMesh = pointMesh::New(mesh);
609 
610  PtrList<pointScalarField> pScalarFlds;
611  subsetPointFields(subsetter, pMesh, availableFields, pScalarFlds);
612 
613  PtrList<pointVectorField> pVectorFlds;
614  subsetPointFields(subsetter, pMesh, availableFields, pVectorFlds);
615 
616  PtrList<pointSphericalTensorField> pSphTensorFlds;
617  subsetPointFields(subsetter, pMesh, availableFields, pSphTensorFlds);
618 
619  PtrList<pointSymmTensorField> pSymmTensorFlds;
620  subsetPointFields(subsetter, pMesh, availableFields, pSymmTensorFlds);
621 
622  PtrList<pointTensorField> pTensorFlds;
623  subsetPointFields(subsetter, pMesh, availableFields, pTensorFlds);
624 
625 
626  // Read dimensioned fields and subset
627  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
628 
630  subsetDimensionedFields(subsetter, availableFields, dScalarFlds);
631 
633  subsetDimensionedFields(subsetter, availableFields, dVectorFlds);
634 
636  subsetDimensionedFields(subsetter, availableFields, dSphTensorFlds);
637 
639  subsetDimensionedFields(subsetter, availableFields, dSymmTensorFlds);
640 
642  subsetDimensionedFields(subsetter, availableFields, dTensorFlds);
643 
644 
645  // Read topoSets and subset
646  // ~~~~~~~~~~~~~~~~~~~~~~~~
647 
648  PtrList<cellSet> cellSets;
649  PtrList<faceSet> faceSets;
650  PtrList<pointSet> pointSets;
651 
652  {
653  IOobjectList objects(mesh, mesh.facesInstance(), "polyMesh/sets");
654  if (cellSetPtr)
655  {
656  objects.remove(*cellSetPtr);
657  }
658  subsetTopoSets
659  (
660  mesh,
661  objects,
662  subsetter.cellMap(),
663  subsetter.subMesh(),
664  cellSets
665  );
666  subsetTopoSets
667  (
668  mesh,
669  objects,
670  subsetter.faceMap(),
671  subsetter.subMesh(),
672  faceSets
673  );
674  subsetTopoSets
675  (
676  mesh,
677  objects,
678  subsetter.pointMap(),
679  subsetter.subMesh(),
680  pointSets
681  );
682  }
683 
684 
685  // Write mesh and fields to new time
686  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
687 
688  if (overwrite || specifiedInstance)
689  {
690  runTime.setTime(instant(fieldsInstance), 0);
691  subsetter.subMesh().setInstance(meshInstance);
692  topoSet::setInstance(meshInstance, cellSets);
693  topoSet::setInstance(meshInstance, faceSets);
694  topoSet::setInstance(meshInstance, pointSets);
695  }
696  else
697  {
698  ++runTime;
699  subsetter.subMesh().setInstance(runTime.timeName());
700  }
701 
702  Info<< "Writing subsetted mesh and fields to time " << runTime.timeName()
703  << endl;
704  subsetter.subMesh().write();
706 
707 
708  // Volume fields
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(); }
714 
715  // Surface fields
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(); }
721 
722  // Point fields
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(); }
728 
729  // Dimensioned fields
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(); }
735 
736  Info<< "\nEnd\n" << endl;
737 
738  return 0;
739 }
740 
741 
742 // ************************************************************************* //
label findPatchID(const word &patchName, const bool allowNotFound=true) const
Find patch index given a name, return -1 if not found.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:584
label patchId(-1)
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 &#39;-noFunctionObjects&#39; option and ignore any occurrences.
Definition: argList.C:514
static void addNote(const string &note)
Add extra notes for the usage information.
Definition: argList.C:453
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:118
static void removeFiles(const polyMesh &mesh)
Helper: remove all procAddressing files from mesh instance.
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable, so the various sorted methods should be used if traversing in parallel.
Definition: IOobjectList.H:55
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
const fileName & facesInstance() const
Return the current instance directory for faces.
Definition: polyMesh.C:853
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
Definition: List.C:439
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:578
label findIndex(const wordRe &key) const
Zone index for the first match, return -1 if not found.
Definition: ZoneMesh.C:485
virtual bool write(const bool valid=true) const
Write mesh using IO settings from time.
Definition: fvMesh.C:1072
static const pointMesh & New(const polyMesh &mesh, Args &&... args)
Get existing or create a new MeshObject.
Definition: MeshObject.C:41
void setCellSubset(const bitSet &selectedCells, const label patchID=-1, const bool syncPar=true)
Use the specified subset of cells. Same as reset()
Definition: fvMeshSubset.H:374
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:49
T & first()
Access first element of the list, position [0].
Definition: UList.H:798
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:487
Wave propagation of information through grid. Every iteration information goes through one layer of c...
Definition: FaceCellWave.H:200
List< T > getList(const label index) const
Get a List of values from the argument at index.
Required Variables.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
Definition: argList.C:365
const TrackingData & data() const noexcept
Additional data to be passed into container.
Definition: FaceCellWave.H:500
Generic GeometricField class.
Definition: areaFieldsFwd.H:50
Field reading functions for post-processing utilities.
const fvMesh & baseMesh() const noexcept
Original mesh.
Definition: fvMeshSubsetI.H:23
Ignore writing from objectRegistry::writeObject()
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:361
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 labelList & faceMap() const
Return face map.
Definition: fvMeshSubsetI.H:65
Mesh representing a set of points created from polyMesh.
Definition: pointMesh.H:45
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:413
const fvMesh & subMesh() const
Return reference to subset mesh.
Definition: fvMeshSubsetI.H:41
const fileName & pointsInstance() const
Return the current instance directory for points.
Definition: polyMesh.C:847
void setSize(const label n)
Alias for resize()
Definition: List.H:289
dynamicFvMesh & mesh
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:52
A class for handling words, derived from Foam::string.
Definition: word.H:63
wordList names() const
Return a list of patch names.
label size() const noexcept
The number of elements in the list.
Definition: UPtrListI.H:99
wordList patchNames(nPatches)
const labelList & pointMap() const
Return point map.
Definition: fvMeshSubsetI.H:57
void reset()
Reset subMesh and all maps. Same as clear()
Definition: fvMeshSubset.C:486
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:47
static void addOption(const word &optName, const string &param="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
Definition: argList.C:376
const globalMeshData & globalData() const
Return parallel info.
Definition: polyMesh.C:1293
virtual void setTime(const Time &t)
Reset the time and time-index to those of the given time.
Definition: Time.C:977
const labelList & cellMap() const
Return cell map.
Definition: fvMeshSubsetI.H:84
A HashTable similar to std::unordered_map.
Definition: HashTable.H:102
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:26
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie...
Definition: PtrList.H:163
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings...
Definition: wordRe.H:78
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.
Definition: Time.C:760
Holds a reference to the original mesh (the baseMesh) and optionally to a subset of that mesh (the su...
Definition: fvMeshSubset.H:75
void setSize(const label newLen)
Same as resize()
Definition: PtrList.H:183
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...
Definition: instant.H:53
static word exposedPatchName
Name for exposed internal faces (default: oldInternalFaces)
Definition: fvMeshSubset.H:164
UIndirectList< label > labelUIndList
UIndirectList of labels.
Definition: IndirectList.H:65
T get(const label index) const
Get a value from the argument at index.
Definition: argListI.H:271
void setInstance(const fileName &instance, const IOobjectOption::writeOption wOpt=IOobject::AUTO_WRITE)
Set the instance for mesh files.
Definition: polyMeshIO.C:29
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:59
#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().
Definition: IOobjectList.H:302
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
static void setInstance(const fileName &instance, Container &)
Helper: set instance on all sets in container.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:79
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
Definition: HashTable.C:130
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:441
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
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.
Definition: argList.C:342
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
Definition: polyMesh.H:654
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.
Definition: ZoneMesh.C:593
labelHashSet patchSet(const UList< wordRe > &patchNames, const bool warnNotFound=true, const bool useGroups=true) const
Return the set of patch IDs corresponding to the given names.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:73
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
Definition: argListI.H:316
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Definition: GeoMesh.H:42
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Definition: autoPtr.H:178
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:69
bitSet create(const label n, const labelHashSet &locations, const bool on=true)
Create a bitSet with length n with the specified on locations.
Definition: BitOps.C:204
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...
Definition: IOobject.H:166
bool found
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:171
Namespace for OpenFOAM.
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
Definition: one.H:57
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
Definition: FlatOutput.H:225