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-2023 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 {
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 DimensionedField/GeometricField
153 //
154 template<class FieldType>
155 PtrList<FieldType> subsetFields
156 (
157  const fvMeshSubset& subsetter,
158  const IOobjectList& objects
159 )
160 {
161  const fvMesh& baseMesh = subsetter.baseMesh();
162 
163  const UPtrList<const IOobject> fieldObjects
164  (
165  objects.csorted<FieldType>()
166  );
167 
168  PtrList<FieldType> subFields(fieldObjects.size());
169 
170  label nFields = 0;
171  for (const IOobject& io : fieldObjects)
172  {
173  if (!nFields)
174  {
175  Info<< "Subsetting " << FieldType::typeName << " (";
176  }
177  else
178  {
179  Info<< ' ';
180  }
181  Info<< io.name();
182 
183  FieldType fld
184  (
185  IOobject
186  (
187  io.name(),
188  baseMesh.time().timeName(),
189  baseMesh,
193  ),
194  baseMesh
195  );
196 
197  subFields.set(nFields, subsetter.interpolate(fld));
198  auto& subField = subFields[nFields];
199  ++nFields;
200 
201  // Subsetting adds 'subset' prefix - rename to match original.
202  subField.rename(io.name());
203  }
204 
205  if (nFields)
206  {
207  Info<< ')' << nl;
208  }
209 
210  return subFields;
211 }
212 
213 
214 // Subset point fields
215 template<class FieldType>
216 PtrList<FieldType> subsetFields
217 (
218  const fvMeshSubset& subsetter,
219  const IOobjectList& objects,
220  const pointMesh& pMesh
221 )
222 {
223  const fvMesh& baseMesh = subsetter.baseMesh();
224 
225  const UPtrList<const IOobject> fieldObjects
226  (
227  objects.csorted<FieldType>()
228  );
229 
230  PtrList<FieldType> subFields(fieldObjects.size());
231 
232  label nFields = 0;
233  for (const IOobject& io : fieldObjects)
234  {
235  if (!nFields)
236  {
237  Info<< "Subsetting " << FieldType::typeName << " (";
238  }
239  else
240  {
241  Info<< ' ';
242  }
243  Info<< io.name();
244 
245  FieldType fld
246  (
247  IOobject
248  (
249  io.name(),
250  baseMesh.time().timeName(),
251  baseMesh,
255  ),
256  pMesh
257  );
258 
259  subFields.set(nFields, subsetter.interpolate(fld));
260  auto& subField = subFields[nFields];
261  ++nFields;
262 
263  // Subsetting adds 'subset' prefix - rename to match original.
264  subField.rename(io.name());
265  }
266 
267  if (nFields)
268  {
269  Info<< ')' << nl;
270  }
271 
272  return subFields;
273 }
274 
275 
276 template<class TopoSet>
277 void subsetTopoSets
278 (
279  const fvMesh& mesh,
280  const IOobjectList& objects,
281  const labelList& map,
282  const fvMesh& subMesh,
283  PtrList<TopoSet>& subSets
284 )
285 {
286  // Read original sets
287  PtrList<TopoSet> sets;
288  ReadFields<TopoSet>(objects, sets);
289 
290  subSets.resize_null(sets.size());
291 
292  forAll(sets, seti)
293  {
294  const TopoSet& set = sets[seti];
295 
296  Info<< "Subsetting " << set.type() << " " << set.name() << endl;
297 
298  labelHashSet subset(2*min(set.size(), map.size()));
299 
300  // Map the data
301  forAll(map, i)
302  {
303  if (set.found(map[i]))
304  {
305  subset.insert(i);
306  }
307  }
308 
309  subSets.set
310  (
311  seti,
312  new TopoSet
313  (
314  subMesh,
315  set.name(),
316  std::move(subset),
318  )
319  );
320  }
321 }
322 
323 
324 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
325 
326 int main(int argc, char *argv[])
327 {
329  (
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"
333  " various shapes."
334  );
335 
336  #include "addOverwriteOption.H"
337  #include "addRegionOption.H"
339  (
340  "cell-selection",
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.*\" )'"
344  );
345 
347  (
348  "patch",
349  "name",
350  "Add exposed internal faces to specified patch"
351  " instead of \"oldInternalFaces\""
352  );
354  (
355  "patches",
356  "wordRes",
357  "Add exposed internal faces to closest of specified patches"
358  " instead of \"oldInternalFaces\""
359  );
361  (
362  "exclude-patches",
363  "wordRes",
364  "Exclude single or multiple patches from the -patches selection"
365  );
367  (
368  "zone",
369  "Subset with cellZone(s) instead of cellSet."
370  " The command argument may be a list of words or regexs"
371  );
373  (
374  "resultTime",
375  "time",
376  "Specify a time for the resulting mesh"
377  );
378 
379  argList::noFunctionObjects(); // Never use function objects
380 
381  #include "setRootCase.H"
382  #include "createTime.H"
383 
384  #include "createNamedMesh.H"
385 
386  // arg[1] = word (cellSet) or wordRes (cellZone)
387  // const word selectionName = args[1];
388 
389  word meshInstance = mesh.pointsInstance();
390  word fieldsInstance = runTime.timeName();
391 
392  const bool useCellZone = args.found("zone");
393  const bool overwrite = args.found("overwrite");
394  const bool specifiedInstance = args.readIfPresent
395  (
396  "resultTime",
397  fieldsInstance
398  );
399  if (specifiedInstance)
400  {
401  // Set both mesh and field to this time
402  meshInstance = fieldsInstance;
403  }
404 
405 
406  // Default exposed patch id
407  labelList exposedPatchIDs(one{}, -1);
408 
409  wordRes includePatches, excludePatches;
410 
411  if (!args.readListIfPresent<wordRe>("patches", includePatches))
412  {
413  if (args.found("patch"))
414  {
415  includePatches.resize(1);
416  includePatches.front() = args.get<word>("patch");
417  }
418  }
419  args.readListIfPresent<wordRe>("exclude-patches", excludePatches);
420 
421  if (includePatches.size() == 1 && includePatches.front().isLiteral())
422  {
423  // Select a single patch - no exclude possible
424  exposedPatchIDs.front() =
425  getExposedPatchId(mesh, includePatches.front());
426  }
427  else if (!includePatches.empty())
428  {
429  // Patches selected (sorted order)
430  exposedPatchIDs =
431  mesh.boundaryMesh().indices(includePatches, excludePatches);
432 
433  // Only retain initial, non-processor patches
434  const label nNonProcessor
435  (
437  );
438 
439  forAll(exposedPatchIDs, i)
440  {
441  if (exposedPatchIDs[i] > nNonProcessor)
442  {
443  exposedPatchIDs.resize(i);
444  break;
445  }
446  }
447 
448  const wordList allPatchNames(mesh.boundaryMesh().names());
449 
450  Info<< "Adding exposed internal faces to nearest of patches:" << nl
451  << " include: " << flatOutput(includePatches) << nl
452  << " exclude: " << flatOutput(excludePatches) << nl
453  << nl;
454 
455  if (exposedPatchIDs.empty())
456  {
458  << nl << "No patches matched. Patches: "
459  << flatOutput(allPatchNames) << nl
460  << exit(FatalError);
461  }
462  }
463  else
464  {
465  Info<< "Adding exposed internal faces to patch \""
467  << "\" (created if necessary)" << nl
468  << nl;
469  }
470 
471 
472  autoPtr<cellSet> cellSetPtr;
473 
474  // arg[1] can be a word (for cellSet) or wordRes (for cellZone)
475 
476  wordRes zoneNames;
477  if (useCellZone)
478  {
479  wordRes selectionNames(args.getList<wordRe>(1));
480  zoneNames.transfer(selectionNames);
481 
482  Info<< "Using cellZone " << flatOutput(zoneNames) << nl << endl;
483 
484  if (mesh.cellZones().findIndex(zoneNames) == -1)
485  {
487  << "No cellZones found: " << flatOutput(zoneNames) << nl << nl
488  << exit(FatalError);
489  }
490  }
491  else
492  {
493  const word selectionName = args[1];
494 
495  Info<< "Using cellSet " << selectionName << nl << endl;
496 
497  cellSetPtr.emplace(mesh, selectionName);
498  }
499 
500 
501  // Two-step mesh subsetting engine
502  fvMeshSubsetter subsetter(mesh);
503 
504  {
505  bitSet selectedCells =
506  (
507  cellSetPtr
508  ? BitSetOps::create(mesh.nCells(), *cellSetPtr)
509  : mesh.cellZones().selection(zoneNames)
510  );
511 
512  if (exposedPatchIDs.size() == 1)
513  {
514  // Single patch for exposed faces (syncPar)
515  subsetter.reset(selectedCells, exposedPatchIDs.front(), true);
516  }
517  else
518  {
519  // The nearest patch per face
520  labelList nearestExposedPatch(nearestPatch(mesh, exposedPatchIDs));
521 
522  labelList exposedFaces
523  (
524  subsetter.getExposedFaces(selectedCells, true) // syncPar
525  );
526 
527  subsetter.setCellSubset
528  (
529  selectedCells,
530  exposedFaces,
531  labelUIndList(nearestExposedPatch, exposedFaces)(),
532  true // syncPar
533  );
534  }
535 
536  FixedList<label, 2> cellCount;
537  cellCount[0] = subsetter.subMesh().nCells();
538  cellCount[1] = mesh.nCells();
539  reduce(cellCount, sumOp<label>());
540 
541  Info<< "Subset " << cellCount[0] << " of " << cellCount[1]
542  << " cells" << nl << nl;
543  }
544 
545 
546  IOobjectList objects(mesh, runTime.timeName());
547 
548 
549  // Read fields and subset
550  #undef createSubsetFields
551  #define createSubsetFields(FieldType, Variable) \
552  PtrList<FieldType> Variable \
553  ( \
554  subsetFields<FieldType>(subsetter, objects) \
555  );
556 
557 
558  // Read vol fields and subset
559  // ~~~~~~~~~~~~~~~~~~~~~~~~~~
560  createSubsetFields(volScalarField, vScalarFlds);
561  createSubsetFields(volVectorField, vVectorFlds);
562  createSubsetFields(volSphericalTensorField, vSphTensorFlds);
563  createSubsetFields(volSymmTensorField, vSymmTensorFlds);
564  createSubsetFields(volTensorField, vTensorFlds);
565 
566  // Read surface fields and subset
567  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
568  createSubsetFields(surfaceScalarField, sScalarFlds);
569  createSubsetFields(surfaceVectorField, sVectorFlds);
570  createSubsetFields(surfaceSphericalTensorField, sSphTensorFlds);
571  createSubsetFields(surfaceSymmTensorField, sSymmTensorFlds);
572  createSubsetFields(surfaceTensorField, sTensorFlds);
573 
574  // Read dimensioned fields and subset
575  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
576  createSubsetFields(volScalarField::Internal, dScalarFlds);
577  createSubsetFields(volVectorField::Internal, dVectorFlds);
578  createSubsetFields(volSphericalTensorField::Internal, dSphTensorFlds);
579  createSubsetFields(volSymmTensorField::Internal, dSymmTensorFlds);
580  createSubsetFields(volTensorField::Internal, dTensorFlds);
581 
582 
583  // Read point fields and subset
584  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
585 
586  const pointMesh& pMesh = pointMesh::New(mesh);
587 
588  #undef createSubsetFields
589  #define createSubsetFields(FieldType, Variable) \
590  PtrList<FieldType> Variable \
591  ( \
592  subsetFields<FieldType>(subsetter, objects, pMesh) \
593  );
594 
595  createSubsetFields(pointScalarField, pScalarFlds);
596  createSubsetFields(pointVectorField, pVectorFlds);
597  createSubsetFields(pointSphericalTensorField, pSphTensorFlds);
598  createSubsetFields(pointSymmTensorField, pSymmTensorFlds);
599  createSubsetFields(pointTensorField, pTensorFlds);
600 
601  #undef createSubsetFields
602 
603 
604  // Read topoSets and subset
605  // ~~~~~~~~~~~~~~~~~~~~~~~~
606 
607  PtrList<cellSet> cellSets;
608  PtrList<faceSet> faceSets;
609  PtrList<pointSet> pointSets;
610 
611  {
612  IOobjectList objects(mesh, mesh.facesInstance(), "polyMesh/sets");
613  if (cellSetPtr)
614  {
615  objects.remove(*cellSetPtr);
616  }
617  subsetTopoSets
618  (
619  mesh,
620  objects,
621  subsetter.cellMap(),
622  subsetter.subMesh(),
623  cellSets
624  );
625  subsetTopoSets
626  (
627  mesh,
628  objects,
629  subsetter.faceMap(),
630  subsetter.subMesh(),
631  faceSets
632  );
633  subsetTopoSets
634  (
635  mesh,
636  objects,
637  subsetter.pointMap(),
638  subsetter.subMesh(),
639  pointSets
640  );
641  }
642 
643 
644  // Write mesh and fields to new time
645  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
646 
647  if (overwrite || specifiedInstance)
648  {
649  runTime.setTime(instant(fieldsInstance), 0);
650  subsetter.subMesh().setInstance(meshInstance);
651  topoSet::setInstance(meshInstance, cellSets);
652  topoSet::setInstance(meshInstance, faceSets);
653  topoSet::setInstance(meshInstance, pointSets);
654  }
655  else
656  {
657  ++runTime;
658  subsetter.subMesh().setInstance(runTime.timeName());
659  }
660 
661  Info<< "Writing subsetted mesh and fields to time " << runTime.timeName()
662  << endl;
663  subsetter.subMesh().write();
665 
666 
667  // Volume fields
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(); }
673 
674  // Surface fields
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(); }
680 
681  // Dimensioned fields
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(); }
687 
688  // Point fields
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(); }
694 
695  Info<< "\nEnd\n" << endl;
696 
697  return 0;
698 }
699 
700 
701 // ************************************************************************* //
label findPatchID(const word &patchName, const bool allowNotFound=true) const
Find patch index given a name, return -1 if not found.
label patchId(-1)
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 &#39;-noFunctionObjects&#39; option and ignore any occurrences.
Definition: argList.C:547
static void addNote(const string &note)
Add extra notes for the usage information.
Definition: argList.C:462
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
static void removeFiles(const polyMesh &mesh)
Helper: remove all procAddressing files from mesh instance.
T * front()
The first entry in the list.
Definition: UILList.H:141
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:859
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:153
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
Definition: List.C:326
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:608
label findIndex(const wordRe &key) const
Zone index for the first match, return -1 if not found.
Definition: ZoneMesh.C:690
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:195
static const pointMesh & New(const polyMesh &mesh, Args &&... args)
Get existing or create MeshObject registered with typeName.
Definition: MeshObject.C:53
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:50
T * data() noexcept
Return pointer to the underlying array serving as data storage.
Definition: UListI.H:265
UIndirectList< label > labelUIndList
UIndirectList of labels.
Definition: IndirectList.H:65
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
Wave propagation of information through grid. Every iteration information goes through one layer of c...
Definition: FaceCellWave.H:206
List< T > getList(const label index) const
Get a List of values from the argument at index.
Required Classes.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
Definition: argList.C:374
Field reading functions for post-processing utilities.
const fvMesh & baseMesh() const noexcept
Original mesh.
Definition: fvMeshSubsetI.H:23
T & emplace(Args &&... args)
Reset with emplace construction. Return reference to the new content.
Definition: autoPtrI.H:59
Ignore writing from objectRegistry::writeObject()
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:360
label nFaces() const noexcept
Number of mesh faces.
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:421
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.
Definition: fvMeshSubsetI.H:41
void resize_null(const label newLen)
Set the addressed list to the given size, deleting all existing entries. Afterwards the list contains...
Definition: PtrListI.H:96
Required Classes.
const fileName & pointsInstance() const
Return the current instance directory for points.
Definition: polyMesh.C:853
dynamicFvMesh & mesh
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Definition: polyMesh.H:609
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 entries in the list.
Definition: UPtrListI.H:106
const labelList & pointMap() const
Return point map.
Definition: fvMeshSubsetI.H:57
void reset()
Reset subMesh and all maps. Same as clear()
Definition: fvMeshSubset.C:485
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:53
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:385
const globalMeshData & globalData() const
Return parallel info (demand-driven)
Definition: polyMesh.C:1311
virtual void setTime(const Time &t)
Reset the time and time-index to those of the given time.
Definition: Time.C:902
const labelList & cellMap() const
Return cell map.
Definition: fvMeshSubsetI.H:84
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:26
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: HashTable.H:106
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:159
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings...
Definition: wordRe.H:78
virtual bool write(const bool writeOnProc=true) const
Write mesh using IO settings from time.
Definition: fvMesh.C:1113
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.
Definition: Time.C:714
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...
Definition: argListI.H:387
Holds a reference to the original mesh (the baseMesh) and optionally to a subset of that mesh (the su...
Definition: fvMeshSubset.H:75
label nTotalCells() const noexcept
Total global number of mesh cells.
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
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
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
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.
Definition: argList.C:351
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
Definition: polyMesh.H:679
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:795
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:75
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
Definition: argListI.H:316
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.
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:228
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...
Definition: IOobject.H:180
UPtrList< const IOobject > csorted() const
The sorted list of IOobjects with headerClassName == Type::typeName.
bool found
Do not request registration (bool: false)
void reduce(T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) using linear/tree communication schedule.
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:171
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
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:56
static void setInstance(const fileName &instance, Container &items)
Helper: set instance on all items in container.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
Definition: FlatOutput.H:225