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