Go to the documentation of this file.
57 #ifdef HAVE_LIBREADLINE
58 #include <readline/readline.h>
59 #include <readline/history.h>
61 static const char* historyFile =
".setSet";
91 <<
"Don't know how to handle set of type "
92 << currSet.type() <<
nl;
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
104 <<
"A set command should be of the following form" <<
nl
106 <<
" cellSet|faceSet|pointSet <setName> <action> <source>"
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"
120 <<
"The sources come in various forms. Type a wrong source"
121 <<
" to see all the types available." <<
nl
123 <<
"Example: pick up all cells connected by point or face to patch"
124 <<
" movingWall" <<
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
137 <<
" cellSet c0 list" <<
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
143 <<
"or if orientation is important:" <<
nl
144 <<
" faceZoneSet f0Zone new setsToFaceZone f0 c0" <<
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)"
151 <<
" remove - remove the set" <<
nl
170 IOobjectList cellSets(objects.lookupClass(cellSet::typeName));
173 os <<
"cellSets:" <<
endl;
177 os <<
'\t' <<
set.name() <<
"\tsize:" <<
set.size() <<
endl;
180 IOobjectList faceSets(objects.lookupClass(faceSet::typeName));
183 os <<
"faceSets:" <<
endl;
187 os <<
'\t' <<
set.name() <<
"\tsize:" <<
set.size() <<
endl;
190 IOobjectList pointSets(objects.lookupClass(pointSet::typeName));
191 if (pointSets.size())
193 os <<
"pointSets:" <<
endl;
197 os <<
'\t' <<
set.name() <<
"\tsize:" <<
set.size() <<
endl;
202 if (cellZones.size())
204 os <<
"cellZones:" <<
endl;
211 if (faceZones.size())
213 os <<
"faceZones:" <<
endl;
220 if (pointZones.size())
222 os <<
"pointZones:" <<
endl;
233 template<
class ZoneType>
244 Info<<
"Removing zone " << setName <<
" at index " <<
zoneID <<
endl;
252 oldToNew[i] = newI++;
256 zones.reorder(oldToNew);
258 zones.setSize(zones.size()-1);
293 if (objects.found(setName))
296 fileName object = objects[setName]->objectPath();
297 Info<<
"Removing file " <<
object <<
endl;
302 if (setType == cellZoneSet::typeName)
310 else if (setType == faceZoneSet::typeName)
318 else if (setType == pointZoneSet::typeName)
335 const word& actionName,
336 const bool writeVTKFile,
337 const bool writeCurrentTime,
375 removeSet(
mesh, setType, setName);
390 topoSet& currentSet = currentSetPtr();
392 currentSet.resize(
max(currentSet.size(), typSize));
397 topoSet& currentSet = *currentSetPtr;
401 <<
" Action:" << actionName
424 if (is >> sourceType)
443 currentSet.
name() +
"_old2",
452 currentSet.
subset(oldSet());
458 if (is >> sourceType)
470 setSource().applyToSet(action, currentSet);
484 Info<<
" Writing " << currentSet.
name()
499 / currentSet.
name() +
"_"
504 Info<<
" and to vtk file "
515 if (writeCurrentTime)
519 if (!currentSet.
write())
522 <<
"Failed writing set "
536 if (sourceType.size())
547 if (sourceType.size())
586 Info<<
" mesh not changed." <<
endl;
591 Info<<
" points moved; topology unchanged." <<
endl;
596 Info<<
" topology changed; patches unchanged." <<
nl
603 Info<<
" topology changed and patches changed." <<
nl
612 <<
"Illegal mesh update state "
621 commandStatus parseType
631 Info<<
"Type 'help' for usage information" <<
endl;
635 else if (setType ==
"help")
641 else if (setType ==
"list")
647 else if (setType ==
"time")
649 scalar requestedTime = readScalar(is);
655 <<
" to " << Times[nearestIndex].name()
661 meshReadUpdate(
mesh);
665 else if (setType ==
"quit")
674 || setType ==
"faceSet"
675 || setType ==
"pointSet"
682 setType ==
"cellZoneSet"
683 || setType ==
"faceZoneSet"
684 || setType ==
"pointZoneSet"
692 <<
"Illegal command " << setType <<
endl
693 <<
"Should be one of 'help', 'list', 'time' or a set type :"
694 <<
" 'cellSet', 'faceSet', 'pointSet', 'faceZoneSet'"
702 commandStatus parseAction(
const word& actionName)
707 ? VALIDSETCMD : INVALID
713 int main(
int argc,
char *argv[])
717 "Manipulate a cell/face/point Set or Zone interactively."
733 "Process in batch mode, using input from specified file"
738 "Do not synchronise selection across coupled patches"
748 const bool noSync =
args.
found(
"noSync");
753 <<
"Can only loop in batch mode."
767 #ifdef HAVE_LIBREADLINE
768 if (!batch && !read_history((
runTime.
path()/historyFile).c_str()))
770 Info<<
"Successfully read history from " << historyFile <<
endl;
785 meshReadUpdate(
mesh);
797 Info<<
"Reading commands from file " << batchFile <<
endl;
800 if (!
isFile(batchFile,
false))
809 Info<<
"Please type 'help', 'quit' or a set command after prompt."
833 if (!fileStreamPtr->
good())
840 fileStreamPtr().getLine(rawLine);
849 #ifdef HAVE_LIBREADLINE
851 char* linePtr = readline(
"readline>");
855 rawLine =
string(linePtr);
859 add_history(linePtr);
860 write_history(historyFile);
872 if (!std::cin.good())
879 std::getline(std::cin, rawLine);
886 if (i != string::npos)
903 if (stat == VALIDSETCMD || stat == VALIDZONECMD)
907 if (is >> actionName)
909 stat = parseAction(actionName);
919 else if (stat == VALIDSETCMD || stat == VALIDZONECMD)
void writeDebug(Ostream &os, const label maxElem, topoSet::const_iterator &iter, label &elemI) const
static label findClosestTimeIndex(const instantList &timeDirs, const scalar t, const word &constantName="constant")
@ INVALID
Invalid/unknown/error type.
void set(List< bool > &bools, const labelRange &range)
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
@ CLEAR
Clear the set, possibly creating it.
A class for handling words, derived from Foam::string.
A class for handling file names.
bool found(const word &enumName) const
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Input from file stream, using an ISstream.
static const string & usage(const word &name)
static word timeName(const scalar t, const int precision=precision_)
virtual void flush() const
Base class for mesh zones.
bool throwing() const noexcept
static void addNote(const string ¬e)
const fileName & facesInstance() const
virtual void subset(const topoSet &set)
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Input/output from string buffers.
bool rm(const fileName &file)
const fileOperation & fileHandler()
const polyBoundaryMesh & boundaryMesh() const
Ostream & endl(Ostream &os)
A class for handling character strings derived from std::string.
static autoPtr< topoSet > New(const word &setType, const polyMesh &mesh, const word &name, readOption r=MUST_READ, writeOption w=NO_WRITE)
@ NEW
Create a new set and ADD elements to it.
T get(const label index) const
virtual void invert(const label maxLen)
Mesh consisting of general polyhedral cells.
void writeVTK(OFstream &os, const Type &value)
virtual readUpdateState readUpdate()
word outputName("finiteArea-edges.obj")
Ostream & flush(Ostream &os)
label timeIndex() const noexcept
bool writeTopoSet(const polyMesh &mesh, const topoSet &set, const vtk::outputOptions opts, const fileName &file, bool parallel=Pstream::parRun())
virtual bool write(const bool valid=true) const
A subset of mesh faces organised as a primitive patch.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
const fileName & local() const noexcept
const cellZoneMesh & cellZones() const noexcept
instantList times() const
#define SeriousErrorInFunction
const faceZoneMesh & faceZones() const noexcept
bool good() const noexcept
graph_traits< Graph >::vertices_size_type size_type
General set of labels of mesh quantity (points, cells, faces).
virtual label maxSize(const polyMesh &mesh) const =0
label max(const labelHashSet &set, label maxValue=labelMin)
@ SUBSET
Union of elements with current set.
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
OBJstream os(runTime.globalPath()/outputName)
@ INLINE_BASE64
XML inline base64, base64Formatter.
const labelIOList & zoneID
label nTotalPoints() const noexcept
static autoPtr< topoSetSource > New(const word &topoSetSourceType, const polyMesh &mesh, const dictionary &dict)
errorManip< error > abort(error &err)
A collection of cell labels.
label findZoneID(const word &zoneName) const
List of IOobjects with searching and retrieving facilities.
word findInstance(const fileName &dir, const word &name=word::null, const IOobject::readOption rOpt=IOobject::MUST_READ, const word &stopInstance=word::null) const
errorManipArg< error, int > exit(error &err, const int errNo=1)
const boundBox & bounds() const
void reset(autoPtr< T > &&other) noexcept
const word & name() const noexcept
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
#define FatalErrorInFunction
@ LIST
Print contents of the set.
forAllConstIters(mixture.phases(), phase)
const word & name() const noexcept
static void addOptions(const bool constant=true, const bool withZero=false)
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
virtual void setTime(const Time &t)
@ REMOVE
Remove the set (from the file system)
const pointZoneMesh & pointZones() const noexcept
const fileName & instance() const noexcept
@ INVERT
Invert the elements in the current set.
word name(const expressions::valueTypeCode typeCode)
const Time & time() const
label nTotalCells() const noexcept
Write topoSet in VTK format.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
const globalMeshData & globalData() const
virtual void sync(const polyMesh &mesh)
fileName objectPath() const
static instantList select0(Time &runTime, const argList &args)
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Foam::argList args(argc, argv)
bool mkDir(const fileName &pathName, mode_t mode=0777)
#define WarningInFunction
Class to handle errors and exceptions in a simple, consistent stream-based manner.
static label nProcs(const label communicator=worldComm)
label nTotalFaces() const noexcept
bool found(const word &optName) const
static const Enum< setAction > actionNames