setSet.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-2018 OpenFOAM Foundation
9  Copyright (C) 2017-2018 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  setSet
29 
30 Group
31  grpMeshManipulationUtilities
32 
33 Description
34  Manipulate a cell/face/point Set or Zone interactively.
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #include "argList.H"
39 #include "Time.H"
40 #include "polyMesh.H"
41 #include "globalMeshData.H"
42 #include "StringStream.H"
43 #include "cellSet.H"
44 #include "faceSet.H"
45 #include "pointSet.H"
46 #include "topoSetSource.H"
47 #include "Fstream.H"
48 #include "demandDrivenData.H"
49 #include "foamVtkWriteTopoSet.H"
50 #include "IOobjectList.H"
51 #include "cellZoneSet.H"
52 #include "faceZoneSet.H"
53 #include "pointZoneSet.H"
54 #include "timeSelector.H"
55 
56 #include <stdio.h>
57 
58 #ifdef HAVE_LIBREADLINE
59  #include <readline/readline.h>
60  #include <readline/history.h>
61 
62  static const char* historyFile = ".setSet";
63 #endif
64 
65 using namespace Foam;
66 
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 
69 
70 // Write set to VTK readable files
71 void writeVTK
72 (
73  const polyMesh& mesh,
74  const topoSet& currSet,
75  const fileName& outputName
76 )
77 {
78  if
79  (
81  (
82  mesh,
83  currSet,
84  vtk::formatType::INLINE_BASE64, // XML-binary
85  // vtk::formatType::LEGACY_BINARY,
86  outputName,
87  false // Not parallel
88  )
89  )
90  {
92  << "Don't know how to handle set of type "
93  << currSet.type() << nl;
94  }
95 }
96 
97 
98 void printHelp(Ostream& os)
99 {
100  os << "Please type 'help', 'list', 'quit', 'time ddd'"
101  << " or a set command after prompt." << nl
102  << "'list' will show all current cell/face/point sets." << nl
103  << "'time ddd' will change the current time." << nl
104  << nl
105  << "A set command should be of the following form" << nl
106  << nl
107  << " cellSet|faceSet|pointSet <setName> <action> <source>"
108  << nl
109  << nl
110  << "The <action> is one of" << nl
111  << " list - prints the contents of the set" << nl
112  << " clear - clears the set" << nl
113  << " invert - inverts the set" << nl
114  << " remove - remove the set" << nl
115  << " new <source> - use all elements from the source set" << nl
116  << " add <source> - adds all elements from the source set" << nl
117  << " subtract <source> - subtract the source set elements" << nl
118  << " subset <source> - combines current set with the source set"
119  << nl
120  << nl
121  << "The sources come in various forms. Type a wrong source"
122  << " to see all the types available." << nl
123  << nl
124  << "Example: pick up all cells connected by point or face to patch"
125  << " movingWall" << nl
126  << nl
127  << "Pick up all faces of patch:" << nl
128  << " faceSet f0 new patchToFace movingWall" << nl
129  << "Add faces 0,1,2:" << nl
130  << " faceSet f0 add labelToFace (0 1 2)" << nl
131  << "Pick up all points used by faces in faceSet f0:" << nl
132  << " pointSet p0 new faceToPoint f0 all" << nl
133  << "Pick up cell which has any face in f0:" << nl
134  << " cellSet c0 new faceToCell f0 any" << nl
135  << "Add cells which have any point in p0:" << nl
136  << " cellSet c0 add pointToCell p0 any" << nl
137  << "List set:" << nl
138  << " cellSet c0 list" << nl
139  << nl
140  << "Zones can be set using zoneSets from corresponding sets:" << nl
141  << " cellZoneSet c0Zone new setToCellZone c0" << nl
142  << " faceZoneSet f0Zone new setToFaceZone f0" << nl
143  << nl
144  << "or if orientation is important:" << nl
145  << " faceZoneSet f0Zone new setsToFaceZone f0 c0" << nl
146  << nl
147  << "ZoneSets can be manipulated using the general actions:" << nl
148  << " list - prints the contents of the set" << nl
149  << " clear - clears the set" << nl
150  << " invert - inverts the set (undefined orientation)"
151  << nl
152  << " remove - remove the set" << nl
153  << endl;
154 }
155 
156 
157 void printAllSets(const polyMesh& mesh, Ostream& os)
158 {
159  IOobjectList objects
160  (
161  mesh,
163  (
164  polyMesh::meshSubDir/"sets",
165  word::null,
168  ),
169  polyMesh::meshSubDir/"sets"
170  );
171  IOobjectList cellSets(objects.lookupClass(cellSet::typeName));
172  if (cellSets.size())
173  {
174  os << "cellSets:" << endl;
175  forAllConstIters(cellSets, iter)
176  {
177  cellSet set(*iter());
178  os << '\t' << set.name() << "\tsize:" << set.size() << endl;
179  }
180  }
181  IOobjectList faceSets(objects.lookupClass(faceSet::typeName));
182  if (faceSets.size())
183  {
184  os << "faceSets:" << endl;
185  forAllConstIters(faceSets, iter)
186  {
187  faceSet set(*iter());
188  os << '\t' << set.name() << "\tsize:" << set.size() << endl;
189  }
190  }
191  IOobjectList pointSets(objects.lookupClass(pointSet::typeName));
192  if (pointSets.size())
193  {
194  os << "pointSets:" << endl;
195  forAllConstIters(pointSets, iter)
196  {
197  pointSet set(*iter());
198  os << '\t' << set.name() << "\tsize:" << set.size() << endl;
199  }
200  }
201 
202  const cellZoneMesh& cellZones = mesh.cellZones();
203  if (cellZones.size())
204  {
205  os << "cellZones:" << endl;
206  for (const cellZone& zone : cellZones)
207  {
208  os << '\t' << zone.name() << "\tsize:" << zone.size() << endl;
209  }
210  }
211  const faceZoneMesh& faceZones = mesh.faceZones();
212  if (faceZones.size())
213  {
214  os << "faceZones:" << endl;
215  for (const faceZone& zone : faceZones)
216  {
217  os << '\t' << zone.name() << "\tsize:" << zone.size() << endl;
218  }
219  }
220  const pointZoneMesh& pointZones = mesh.pointZones();
221  if (pointZones.size())
222  {
223  os << "pointZones:" << endl;
224  for (const pointZone& zone : pointZones)
225  {
226  os << '\t' << zone.name() << "\tsize:" << zone.size() << endl;
227  }
228  }
229 
230  os << endl;
231 }
232 
233 
234 template<class ZoneType>
235 void removeZone
236 (
238  const word& setName
239 )
240 {
241  label zoneID = zones.findZoneID(setName);
242 
243  if (zoneID != -1)
244  {
245  Info<< "Removing zone " << setName << " at index " << zoneID << endl;
246  // Shuffle to last position
247  labelList oldToNew(zones.size());
248  label newI = 0;
249  forAll(oldToNew, i)
250  {
251  if (i != zoneID)
252  {
253  oldToNew[i] = newI++;
254  }
255  }
256  oldToNew[zoneID] = newI;
257  zones.reorder(oldToNew);
258  // Remove last element
259  zones.setSize(zones.size()-1);
260  zones.clearAddressing();
261  if (!zones.write())
262  {
263  WarningInFunction << "Failed writing zone " << setName << endl;
264  }
265  zones.write();
266  // Force flushing so we know it has finished writing
267  fileHandler().flush();
268  }
269 }
270 
271 
272 // Physically remove a set
273 void removeSet
274 (
275  const polyMesh& mesh,
276  const word& setType,
277  const word& setName
278 )
279 {
280  // Remove the file
281  IOobjectList objects
282  (
283  mesh,
285  (
286  polyMesh::meshSubDir/"sets",
287  word::null,
290  ),
291  polyMesh::meshSubDir/"sets"
292  );
293 
294  if (objects.found(setName))
295  {
296  // Remove file
297  fileName object = objects[setName]->objectPath();
298  Info<< "Removing file " << object << endl;
299  rm(object);
300  }
301 
302  // See if zone
303  if (setType == cellZoneSet::typeName)
304  {
305  removeZone
306  (
307  const_cast<cellZoneMesh&>(mesh.cellZones()),
308  setName
309  );
310  }
311  else if (setType == faceZoneSet::typeName)
312  {
313  removeZone
314  (
315  const_cast<faceZoneMesh&>(mesh.faceZones()),
316  setName
317  );
318  }
319  else if (setType == pointZoneSet::typeName)
320  {
321  removeZone
322  (
323  const_cast<pointZoneMesh&>(mesh.pointZones()),
324  setName
325  );
326  }
327 }
328 
329 
330 // Read command and execute. Return true if ok, false otherwise.
331 bool doCommand
332 (
333  const polyMesh& mesh,
334  const word& setType,
335  const word& setName,
336  const word& actionName,
337  const bool writeVTKFile,
338  const bool writeCurrentTime,
339  const bool noSync,
340  Istream& is
341 )
342 {
343  // Get some size estimate for set.
344  const globalMeshData& parData = mesh.globalData();
345 
346  label typSize =
347  max
348  (
349  parData.nTotalCells(),
350  max
351  (
352  parData.nTotalFaces(),
353  parData.nTotalPoints()
354  )
355  )
356  / (10*Pstream::nProcs());
357 
358 
359  bool ok = true;
360 
361  // Set to work on
362  autoPtr<topoSet> currentSetPtr;
363 
364  word sourceType;
365 
366  try
367  {
368  topoSetSource::setAction action =
369  topoSetSource::actionNames[actionName];
370 
371 
373 
374  if (action == topoSetSource::REMOVE)
375  {
376  removeSet(mesh, setType, setName);
377  }
378  else if
379  (
380  (action == topoSetSource::NEW)
381  || (action == topoSetSource::CLEAR)
382  )
383  {
384  r = IOobject::NO_READ;
385  currentSetPtr = topoSet::New(setType, mesh, setName, typSize);
386  }
387  else
388  {
390  currentSetPtr = topoSet::New(setType, mesh, setName, r);
391  topoSet& currentSet = currentSetPtr();
392  // Presize it according to current mesh data.
393  currentSet.resize(max(currentSet.size(), typSize));
394  }
395 
396  if (currentSetPtr.valid())
397  {
398  topoSet& currentSet = currentSetPtr();
399 
400  Info<< " Set:" << currentSet.name()
401  << " Size:" << returnReduce(currentSet.size(), sumOp<label>())
402  << " Action:" << actionName
403  << endl;
404 
405  switch (action)
406  {
408  {
409  // Already handled above by not reading
410  break;
411  }
413  {
414  currentSet.invert(currentSet.maxSize(mesh));
415  break;
416  }
417  case topoSetSource::LIST:
418  {
419  currentSet.writeDebug(Pout, mesh, 100);
420  Pout<< endl;
421  break;
422  }
424  {
425  if (is >> sourceType)
426  {
427  autoPtr<topoSetSource> setSource
428  (
430  (
431  sourceType,
432  mesh,
433  is
434  )
435  );
436 
437  // Backup current set.
438  autoPtr<topoSet> oldSet
439  (
441  (
442  setType,
443  mesh,
444  currentSet.name() + "_old2",
445  currentSet
446  )
447  );
448 
449  currentSet.clear();
450  setSource().applyToSet(topoSetSource::NEW, currentSet);
451 
452  // Combine new value of currentSet with old one.
453  currentSet.subset(oldSet());
454  }
455  break;
456  }
457  default:
458  {
459  if (is >> sourceType)
460  {
461  autoPtr<topoSetSource> setSource
462  (
464  (
465  sourceType,
466  mesh,
467  is
468  )
469  );
470 
471  setSource().applyToSet(action, currentSet);
472  }
473  }
474  }
475 
476 
477  if (action != topoSetSource::LIST)
478  {
479  // Set will have been modified.
480 
481  // Synchronize for coupled patches.
482  if (!noSync) currentSet.sync(mesh);
483 
484  // Write
485  Info<< " Writing " << currentSet.name()
486  << " (size "
487  << returnReduce(currentSet.size(), sumOp<label>())
488  << ") to "
489  << (
490  currentSet.instance()/currentSet.local()
491  / currentSet.name()
492  );
493 
494 
495  if (writeVTKFile)
496  {
497  fileName outputName
498  (
499  mesh.time().path()/"VTK"/currentSet.name()
500  / currentSet.name() + "_"
502  );
503  mkDir(outputName.path());
504 
505  Info<< " and to vtk file "
506  << outputName.relative(mesh.time().path())
507  << nl << nl;
508 
509  writeVTK(mesh, currentSet, outputName);
510  }
511  else
512  {
513  Info<< nl << nl;
514  }
515 
516  if (writeCurrentTime)
517  {
518  currentSet.instance() = mesh.time().timeName();
519  }
520  if (!currentSet.write())
521  {
523  << "Failed writing set "
524  << currentSet.objectPath() << endl;
525  }
526  // Make sure writing is finished
527  fileHandler().flush();
528  }
529  }
530  }
531  catch (const Foam::IOerror& fIOErr)
532  {
533  ok = false;
534 
535  Pout<< fIOErr.message().c_str() << endl;
536 
537  if (sourceType.size())
538  {
539  Pout<< topoSetSource::usage(sourceType).c_str();
540  }
541  }
542  catch (const Foam::error& fErr)
543  {
544  ok = false;
545 
546  Pout<< fErr.message().c_str() << endl;
547 
548  if (sourceType.size())
549  {
550  Pout<< topoSetSource::usage(sourceType).c_str();
551  }
552  }
553 
554  return ok;
555 }
556 
557 
558 // Status returned from parsing the first token of the line
559 enum commandStatus
560 {
561  QUIT, // quit program
562  INVALID, // token is not a valid set manipulation command
563  VALIDSETCMD, // ,, is a valid ,,
564  VALIDZONECMD // ,, is a valid zone ,,
565 };
566 
567 
568 void printMesh(const Time& runTime, const polyMesh& mesh)
569 {
570  Info<< "Time:" << runTime.timeName()
571  << " cells:" << mesh.globalData().nTotalCells()
572  << " faces:" << mesh.globalData().nTotalFaces()
573  << " points:" << mesh.globalData().nTotalPoints()
574  << " patches:" << mesh.boundaryMesh().size()
575  << " bb:" << mesh.bounds() << nl;
576 }
577 
578 
579 polyMesh::readUpdateState meshReadUpdate(polyMesh& mesh)
580 {
582 
583  switch(stat)
584  {
585  case polyMesh::UNCHANGED:
586  {
587  Info<< " mesh not changed." << endl;
588  break;
589  }
591  {
592  Info<< " points moved; topology unchanged." << endl;
593  break;
594  }
596  {
597  Info<< " topology changed; patches unchanged." << nl
598  << " ";
599  printMesh(mesh.time(), mesh);
600  break;
601  }
603  {
604  Info<< " topology changed and patches changed." << nl
605  << " ";
606  printMesh(mesh.time(), mesh);
607 
608  break;
609  }
610  default:
611  {
613  << "Illegal mesh update state "
614  << stat << abort(FatalError);
615  break;
616  }
617  }
618  return stat;
619 }
620 
621 
622 commandStatus parseType
623 (
624  Time& runTime,
625  polyMesh& mesh,
626  const word& setType,
627  IStringStream& is
628 )
629 {
630  if (setType.empty())
631  {
632  Info<< "Type 'help' for usage information" << endl;
633 
634  return INVALID;
635  }
636  else if (setType == "help")
637  {
638  printHelp(Info);
639 
640  return INVALID;
641  }
642  else if (setType == "list")
643  {
644  printAllSets(mesh, Info);
645 
646  return INVALID;
647  }
648  else if (setType == "time")
649  {
650  scalar requestedTime = readScalar(is);
651  instantList Times = runTime.times();
652 
653  label nearestIndex = Time::findClosestTimeIndex(Times, requestedTime);
654 
655  Info<< "Changing time from " << runTime.timeName()
656  << " to " << Times[nearestIndex].name()
657  << endl;
658 
659  // Set time
660  runTime.setTime(Times[nearestIndex], nearestIndex);
661  // Optionally re-read mesh
662  meshReadUpdate(mesh);
663 
664  return INVALID;
665  }
666  else if (setType == "quit")
667  {
668  Info<< "Quitting ..." << endl;
669 
670  return QUIT;
671  }
672  else if
673  (
674  setType == "cellSet"
675  || setType == "faceSet"
676  || setType == "pointSet"
677  )
678  {
679  return VALIDSETCMD;
680  }
681  else if
682  (
683  setType == "cellZoneSet"
684  || setType == "faceZoneSet"
685  || setType == "pointZoneSet"
686  )
687  {
688  return VALIDZONECMD;
689  }
690  else
691  {
693  << "Illegal command " << setType << endl
694  << "Should be one of 'help', 'list', 'time' or a set type :"
695  << " 'cellSet', 'faceSet', 'pointSet', 'faceZoneSet'"
696  << endl;
697 
698  return INVALID;
699  }
700 }
701 
702 
703 commandStatus parseAction(const word& actionName)
704 {
705  return
706  (
707  actionName.size() && topoSetSource::actionNames.found(actionName)
708  ? VALIDSETCMD : INVALID
709  );
710 }
711 
712 
713 
714 int main(int argc, char *argv[])
715 {
717  (
718  "Manipulate a cell/face/point Set or Zone interactively."
719  );
720 
721  // Specific to topoSet/setSet: quite often we want to block upon writing
722  // a set so we can immediately re-read it. So avoid use of threading
723  // for set writing.
724 
725  timeSelector::addOptions(true, false); // constant(true), zero(false)
726 
727  #include "addRegionOption.H"
728  argList::addBoolOption("noVTK", "Do not write VTK files");
729  argList::addBoolOption("loop", "Execute batch commands for all timesteps");
731  (
732  "batch",
733  "file",
734  "Process in batch mode, using input from specified file"
735  );
737  (
738  "noSync",
739  "Do not synchronise selection across coupled patches"
740  );
741 
742  #include "setRootCase.H"
743  #include "createTime.H"
745 
746  const bool writeVTK = !args.found("noVTK");
747  const bool loop = args.found("loop");
748  const bool batch = args.found("batch");
749  const bool noSync = args.found("noSync");
750 
751  if (loop && !batch)
752  {
754  << "Can only loop in batch mode."
755  << exit(FatalError);
756  }
757 
758 
759  #include "createNamedPolyMesh.H"
760 
761  // Print some mesh info
762  printMesh(runTime, mesh);
763 
764  // Print current sets
765  printAllSets(mesh, Info);
766 
767  // Read history if interactive
768  #ifdef HAVE_LIBREADLINE
769  if (!batch && !read_history((runTime.path()/historyFile).c_str()))
770  {
771  Info<< "Successfully read history from " << historyFile << endl;
772  }
773  #endif
774 
775 
776  // Exit status
777  int status = 0;
778 
779 
780  forAll(timeDirs, timeI)
781  {
782  runTime.setTime(timeDirs[timeI], timeI);
783  Info<< "Time = " << runTime.timeName() << endl;
784 
785  // Handle geometry/topology changes
786  meshReadUpdate(mesh);
787 
788 
789  // Main command read & execute loop
790  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
791 
792  autoPtr<IFstream> fileStreamPtr;
793 
794  if (batch)
795  {
796  const fileName batchFile = args["batch"];
797 
798  Info<< "Reading commands from file " << batchFile << endl;
799 
800  // we cannot handle .gz files
801  if (!isFile(batchFile, false))
802  {
804  << "Cannot open file " << batchFile << exit(FatalError);
805  }
806 
807  fileStreamPtr.reset(new IFstream(batchFile));
808  }
809 
810  Info<< "Please type 'help', 'quit' or a set command after prompt."
811  << endl;
812 
813  // Whether to quit
814  bool quit = false;
815 
818 
819  do
820  {
821  string rawLine;
822 
823  // Type: cellSet, faceSet, pointSet
824  word setType;
825  // Name of destination set.
826  word setName;
827  // Action (new, invert etc.)
828  word actionName;
829 
830  commandStatus stat = INVALID;
831 
832  if (fileStreamPtr.valid())
833  {
834  if (!fileStreamPtr().good())
835  {
836  Info<< "End of batch file" << endl;
837  // No error.
838  break;
839  }
840 
841  fileStreamPtr().getLine(rawLine);
842 
843  if (rawLine.size())
844  {
845  Info<< "Doing:" << rawLine << endl;
846  }
847  }
848  else
849  {
850  #ifdef HAVE_LIBREADLINE
851  {
852  char* linePtr = readline("readline>");
853 
854  if (linePtr)
855  {
856  rawLine = string(linePtr);
857 
858  if (*linePtr)
859  {
860  add_history(linePtr);
861  write_history(historyFile);
862  }
863 
864  free(linePtr); // readline uses malloc, not new.
865  }
866  else
867  {
868  break;
869  }
870  }
871  #else
872  {
873  if (!std::cin.good())
874  {
875  Info<< "End of cin" << endl;
876  // No error.
877  break;
878  }
879  Info<< "Command>" << flush;
880  std::getline(std::cin, rawLine);
881  }
882  #endif
883  }
884 
885  // Strip off anything after #
886  string::size_type i = rawLine.find('#');
887  if (i != string::npos)
888  {
889  rawLine.resize(i);
890  }
891 
892  if (rawLine.empty())
893  {
894  continue;
895  }
896 
897  IStringStream is(rawLine + ' ');
898 
899  // Type: cellSet, faceSet, pointSet, faceZoneSet
900  is >> setType;
901 
902  stat = parseType(runTime, mesh, setType, is);
903 
904  if (stat == VALIDSETCMD || stat == VALIDZONECMD)
905  {
906  if (is >> setName)
907  {
908  if (is >> actionName)
909  {
910  stat = parseAction(actionName);
911  }
912  }
913  }
914 
915  if (stat == QUIT)
916  {
917  // Make sure to quit
918  quit = true;
919  }
920  else if (stat == VALIDSETCMD || stat == VALIDZONECMD)
921  {
922  bool ok = doCommand
923  (
924  mesh,
925  setType,
926  setName,
927  actionName,
928  writeVTK,
929  loop, // if in looping mode dump sets to time directory
930  noSync,
931  is
932  );
933 
934  if (!ok && batch)
935  {
936  // Exit with error.
937  quit = true;
938  status = 1;
939  }
940  }
941 
942  } while (!quit);
943 
944  if (quit)
945  {
946  break;
947  }
948  }
949 
950  Info<< "End\n" << endl;
951 
952  return status;
953 }
954 
955 
956 // ************************************************************************* //
Foam::topoSet::writeDebug
void writeDebug(Ostream &os, const label maxElem, topoSet::const_iterator &iter, label &elemI) const
Write part of contents nicely formatted. Prints labels only.
Definition: topoSet.C:221
Foam::TimePaths::findClosestTimeIndex
static label findClosestTimeIndex(const instantList &timeDirs, const scalar t, const word &constantName="constant")
Search instantList for the time index closest to the specified time.
Definition: TimePaths.C:156
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::HashTable::size
label size() const noexcept
The number of elements in table.
Definition: HashTableI.H:52
Foam::autoPtr::reset
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
Definition: autoPtrI.H:109
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::topoSetSource::CLEAR
Clear the set, possibly creating it.
Definition: topoSetSource.H:105
Foam::IOobject::name
const word & name() const
Return name.
Definition: IOobjectI.H:70
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::Enum::found
bool found(const word &enumName) const
Test if there is an enumeration corresponding to the given name.
Definition: EnumI.H:88
Foam::returnReduce
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:94
Foam::polyMesh::POINTS_MOVED
Definition: polyMesh.H:94
Foam::fileName::path
static std::string path(const std::string &str)
Return directory path name (part before last /)
Definition: fileNameI.H:186
Foam::IFstream
Input from file stream, using an ISstream.
Definition: IFstream.H:85
faceZoneSet.H
globalMeshData.H
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
Foam::IOobject::instance
const fileName & instance() const
Definition: IOobjectI.H:191
Foam::pointZone
A subset of mesh points.
Definition: pointZone.H:65
Foam::UPstream::nProcs
static label nProcs(const label communicator=0)
Number of processes in parallel run.
Definition: UPstream.H:427
Foam::topoSetSource::usage
static const string & usage(const word &name)
Definition: topoSetSource.H:283
Foam::globalMeshData::nTotalPoints
label nTotalPoints() const
Return total number of points in decomposed mesh. Not.
Definition: globalMeshData.H:381
Foam::polyMesh::meshSubDir
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Definition: polyMesh.H:315
Foam::Time::timeName
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:785
Foam::fileOperation::flush
virtual void flush() const
Forcibly wait until all output done. Flush any cached data.
Definition: fileOperation.C:977
Foam::globalMeshData::nTotalCells
label nTotalCells() const
Return total number of cells in decomposed mesh.
Definition: globalMeshData.H:394
Foam::zone
Base class for mesh zones.
Definition: zone.H:63
Foam::argList::addNote
static void addNote(const string &note)
Add extra notes for the usage information.
Definition: argList.C:413
Foam::polyMesh::facesInstance
const fileName & facesInstance() const
Return the current instance directory for faces.
Definition: polyMesh.C:821
Foam::polyMesh::cellZones
const cellZoneMesh & cellZones() const
Return cell zone mesh.
Definition: polyMesh.H:483
Foam::faceSet
A list of face labels.
Definition: faceSet.H:51
Foam::topoSet::subset
virtual void subset(const topoSet &set)
Subset contents. Only elements present in both sets remain.
Definition: topoSet.C:562
Foam::isFile
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
Definition: MSwindows.C:658
StringStream.H
Input/output from string buffers.
Foam::rm
bool rm(const fileName &file)
Remove a file (or its gz equivalent), returning true if successful.
Definition: MSwindows.C:994
Foam::fileHandler
const fileOperation & fileHandler()
Get current file handler.
Definition: fileOperation.C:1170
Foam::autoPtr::valid
bool valid() const noexcept
True if the managed pointer is non-null.
Definition: autoPtr.H:148
Foam::FatalIOError
IOerror FatalIOError
IOobjectList.H
Foam::polyMesh::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:435
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::topoSetSource::setAction
setAction
Enumeration defining the valid actions.
Definition: topoSetSource.H:99
Foam::globalMeshData::nTotalFaces
label nTotalFaces() const
Return total number of faces in decomposed mesh. Not.
Definition: globalMeshData.H:388
Foam::string
A class for handling character strings derived from std::string.
Definition: string.H:73
Foam::topoSet::New
static autoPtr< topoSet > New(const word &setType, const polyMesh &mesh, const word &name, readOption r=MUST_READ, writeOption w=NO_WRITE)
Return a pointer to a toposet read from file.
Definition: topoSet.C:54
Foam::topoSetSource::NEW
Create a new set and ADD elements to it.
Definition: topoSetSource.H:106
Foam::Pout
prefixOSstream Pout
An Ostream wrapper for parallel output to std::cout.
Foam::fileName::relative
fileName relative(const fileName &parent, const bool caseTag=false) const
Definition: fileName.C:431
polyMesh.H
Foam::topoSet::invert
virtual void invert(const label maxLen)
Invert contents.
Definition: topoSet.C:541
createNamedPolyMesh.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::sumOp
Definition: ops.H:213
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::writeVTK
void writeVTK(OFstream &os, const Type &value)
Foam::cellZone
A subset of mesh cells.
Definition: cellZone.H:62
Foam::polyMesh::faceZones
const faceZoneMesh & faceZones() const
Return face zone mesh.
Definition: polyMesh.H:477
Foam::fvMesh::readUpdate
virtual readUpdateState readUpdate()
Update the mesh based on the mesh files saved in time.
Definition: fvMesh.C:519
Foam::polyMesh::TOPO_PATCH_CHANGE
Definition: polyMesh.H:96
Foam::flush
Ostream & flush(Ostream &os)
Flush stream.
Definition: Ostream.H:342
Foam::IOobject::local
const fileName & local() const
Definition: IOobjectI.H:203
Foam::vtk::writeTopoSet
bool writeTopoSet(const polyMesh &mesh, const topoSet &set, const vtk::outputOptions opts, const fileName &file, bool parallel=Pstream::parRun())
Dispatch to vtk::writeCellSetFaces, vtk::writeFaceSet, vtk::writePointSet.
Definition: foamVtkWriteTopoSet.C:38
Foam::regIOobject::write
virtual bool write(const bool valid=true) const
Write using setting from DB.
Definition: regIOobjectWrite.C:165
Foam::faceZone
A subset of mesh faces organised as a primitive patch.
Definition: faceZone.H:65
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::polyMesh::pointZones
const pointZoneMesh & pointZones() const
Return point zone mesh.
Definition: polyMesh.H:471
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
argList.H
faceSet.H
Foam::IOobject::READ_IF_PRESENT
Definition: IOobject.H:122
Foam::TimePaths::times
instantList times() const
Search the case for valid time directories.
Definition: TimePaths.C:149
SeriousErrorInFunction
#define SeriousErrorInFunction
Report an error message using Foam::SeriousError.
Definition: messageStream.H:276
addRegionOption.H
Foam::HashTable::resize
void resize(const label sz)
Resize the hash table for efficiency.
Definition: HashTable.C:553
Foam::ZoneMesh< cellZone, polyMesh >
Foam::polyMesh::UNCHANGED
Definition: polyMesh.H:93
Foam::IOstream::name
virtual const fileName & name() const
Return the name of the stream.
Definition: IOstream.C:39
size_type
graph_traits< Graph >::vertices_size_type size_type
Definition: SloanRenumber.C:76
Foam::polyMesh::TOPO_CHANGE
Definition: polyMesh.H:95
Foam::topoSet
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:63
Foam::topoSet::maxSize
virtual label maxSize(const polyMesh &mesh) const =0
Return max allowable index (+1). Not implemented.
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
Foam::topoSetSource::SUBSET
Subset with elements in the set.
Definition: topoSetSource.H:103
Foam::FatalError
error FatalError
Foam::globalMeshData
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
Definition: globalMeshData.H:106
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::vtk::formatType::INLINE_BASE64
XML inline base64, base64Formatter.
zoneID
const labelIOList & zoneID
Definition: interpolatedFaces.H:22
Foam::topoSetSource::New
static autoPtr< topoSetSource > New(const word &topoSetSourceType, const polyMesh &mesh, const dictionary &dict)
Return a reference to the selected topoSetSource.
Definition: topoSetSource.C:109
Foam::error::message
string message() const
The accumulated error message.
Definition: error.C:214
Foam::IStringStream
Input from string buffer, using a ISstream.
Definition: StringStream.H:111
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:137
Foam::zone::name
const word & name() const
Return name.
Definition: zone.H:158
Foam::cellSet
A collection of cell labels.
Definition: cellSet.H:51
Foam::ZoneMesh::findZoneID
label findZoneID(const word &zoneName) const
Find zone index given a name, return -1 if not found.
Definition: ZoneMesh.C:484
Foam::IOobjectList
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:55
Foam::Time::findInstance
word findInstance(const fileName &dir, const word &name=word::null, const IOobject::readOption rOpt=IOobject::MUST_READ, const word &stopInstance=word::null) const
Definition: Time.C:802
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::polyMesh::readUpdateState
readUpdateState
Enumeration defining the state of the mesh after a read update.
Definition: polyMesh.H:91
Foam::polyMesh::bounds
const boundBox & bounds() const
Return mesh bounding box.
Definition: polyMesh.H:441
Foam::argList::addBoolOption
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
Definition: argList.C:325
Time.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
setRootCase.H
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:372
Foam::topoSetSource::LIST
Print contents of the set.
Definition: topoSetSource.H:108
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::Time::path
fileName path() const
Return path.
Definition: Time.H:358
forAllConstIters
forAllConstIters(mixture.phases(), phase)
Definition: pEqn.H:28
Foam::pointSet
A set of point labels.
Definition: pointSet.H:51
Fstream.H
Input/output from file streams.
Foam::HashTable::clear
void clear()
Clear all entries from table.
Definition: HashTable.C:630
Foam::timeSelector::addOptions
static void addOptions(const bool constant=true, const bool withZero=false)
Add timeSelector options to argList::validOptions.
Definition: timeSelector.C:108
cellZoneSet.H
Foam::List< label >
Foam::Time::setTime
virtual void setTime(const Time &t)
Reset the time and time-index to those of the given time.
Definition: Time.C:1006
topoSetSource.H
Foam::topoSetSource::REMOVE
Remove the set (from the file system)
Definition: topoSetSource.H:107
Foam::word::null
static const word null
An empty word.
Definition: word.H:77
timeSelector.H
createTime.H
Foam::topoSetSource::INVERT
Invert the elements in the set.
Definition: topoSetSource.H:104
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:248
Foam::IOerror
Report an I/O error.
Definition: error.H:229
foamVtkWriteTopoSet.H
Write topoSet in VTK format.
cellSet.H
Foam::IOobject::readOption
readOption
Enumeration defining the read options.
Definition: IOobject.H:118
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::ZoneMesh::clearAddressing
void clearAddressing()
Clear addressing.
Definition: ZoneMesh.C:618
Foam::polyMesh::globalData
const globalMeshData & globalData() const
Return parallel info.
Definition: polyMesh.C:1234
Foam::TimeState::timeIndex
label timeIndex() const
Return current time index.
Definition: TimeStateI.H:36
Foam::topoSet::sync
virtual void sync(const polyMesh &mesh)
Sync set across coupled patches.
Definition: topoSet.C:589
Foam::IOobject::objectPath
fileName objectPath() const
The complete path + object name.
Definition: IOobjectI.H:209
Foam::timeSelector::select0
static instantList select0(Time &runTime, const argList &args)
Definition: timeSelector.C:241
Foam::argList::addOption
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:336
Foam::IOobject::NO_READ
Definition: IOobject.H:123
args
Foam::argList args(argc, argv)
Foam::mkDir
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
Definition: MSwindows.C:507
Foam::error::throwExceptions
bool throwExceptions(bool doThrow)
Activate/deactivate exception throwing.
Definition: error.H:145
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:298
Foam::error
Class to handle errors and exceptions in a simple, consistent stream-based manner.
Definition: error.H:64
pointZoneSet.H
Foam::argList::found
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:157
Foam::IOobject::MUST_READ
Definition: IOobject.H:120
Foam::topoSetSource::actionNames
static const Enum< setAction > actionNames
The setActions text representations.
Definition: topoSetSource.H:113
pointSet.H