Go to the documentation of this file.
56 #include <readline/readline.h>
57 #include <readline/history.h>
66 static const char* historyFile =
".setSet";
78 if (isA<faceSet>(currentSet))
88 setFaces[setFaceI] =
mesh.
faces()[iter.key()];
89 faceValues[setFaceI] = iter.key();
105 else if (isA<cellSet>(currentSet))
113 label cellI = iter.key();
119 label faceI = cFaces[i];
125 if (otherCellI == cellI)
130 if (!currentSet.
found(otherCellI))
132 cellFaces.insert(faceI, cellI);
137 cellFaces.insert(faceI, cellI);
142 faceList setFaces(cellFaces.size());
148 setFaces[setFaceI] =
mesh.
faces()[iter.key()];
149 faceValues[setFaceI] = iter();
165 else if (isA<pointSet>(currentSet))
178 <<
"Don't know how to handle set of type " << currentSet.type()
186 os <<
"Please type 'help', 'list', 'quit', 'time ddd'"
187 <<
" or a set command after prompt." <<
endl
188 <<
"'list' will show all current cell/face/point sets." <<
endl
189 <<
"'time ddd' will change the current time." <<
endl
191 <<
"A set command should be of the following form" <<
endl
193 <<
" cellSet|faceSet|pointSet <setName> <action> <source>"
196 <<
"The <action> is one of" <<
endl
197 <<
" list - prints the contents of the set" <<
endl
198 <<
" clear - clears the set" <<
endl
199 <<
" invert - inverts the set" <<
endl
200 <<
" remove - remove the set" <<
endl
201 <<
" new <source> - sets to set to the source set" <<
endl
202 <<
" add <source> - adds all elements from the source set" <<
endl
203 <<
" delete <source> - deletes ,," <<
endl
204 <<
" subset <source> - combines current set with the source set"
207 <<
"The sources come in various forms. Type a wrong source"
208 <<
" to see all the types available." <<
endl
210 <<
"Example: pick up all cells connected by point or face to patch"
211 <<
" movingWall" <<
endl
213 <<
"Pick up all faces of patch:" <<
endl
214 <<
" faceSet f0 new patchToFace movingWall" <<
endl
215 <<
"Add faces 0,1,2:" <<
endl
216 <<
" faceSet f0 add labelToFace (0 1 2)" <<
endl
217 <<
"Pick up all points used by faces in faceSet f0:" <<
endl
218 <<
" pointSet p0 new faceToPoint f0 all" <<
endl
219 <<
"Pick up cell which has any face in f0:" <<
endl
220 <<
" cellSet c0 new faceToCell f0 any" <<
endl
221 <<
"Add cells which have any point in p0:" <<
endl
222 <<
" cellSet c0 add pointToCell p0 any" <<
endl
223 <<
"List set:" <<
endl
224 <<
" cellSet c0 list" <<
endl
226 <<
"Zones can be set using zoneSets from corresponding sets:" <<
endl
227 <<
" cellZoneSet c0Zone new setToCellZone c0" <<
endl
228 <<
" faceZoneSet f0Zone new setToFaceZone f0" <<
endl
230 <<
"or if orientation is important:" <<
endl
231 <<
" faceZoneSet f0Zone new setsToFaceZone f0 c0" <<
endl
233 <<
"ZoneSets can be manipulated using the general actions:" <<
endl
234 <<
" list - prints the contents of the set" <<
endl
235 <<
" clear - clears the set" <<
endl
236 <<
" invert - inverts the set (undefined orientation)"
238 <<
" remove - remove the set" <<
endl
260 os <<
"cellSets:" <<
endl;
264 os <<
'\t' << set.
name() <<
"\tsize:" << set.
size() <<
endl;
270 os <<
"faceSets:" <<
endl;
274 os <<
'\t' << set.
name() <<
"\tsize:" << set.
size() <<
endl;
278 if (pointSets.size())
280 os <<
"pointSets:" <<
endl;
284 os <<
'\t' << set.
name() <<
"\tsize:" << set.
size() <<
endl;
289 if (cellZones.size())
291 os <<
"cellZones:" <<
endl;
299 if (faceZones.size())
301 os <<
"faceZones:" <<
endl;
309 if (pointZones.size())
311 os <<
"pointZones:" <<
endl;
323 template<
class ZoneType>
334 Info<<
"Removing zone " << setName <<
" at index " << zoneID <<
endl;
342 oldToNew[i] = newI++;
345 oldToNew[zoneID] = newI;
346 zones.reorder(oldToNew);
348 zones.setSize(zones.size()-1);
377 if (objects.found(setName))
380 fileName object = objects[setName]->objectPath();
381 Info<<
"Removing file " <<
object <<
endl;
386 if (setType == cellZoneSet::typeName)
394 else if (setType == faceZoneSet::typeName)
402 else if (setType == pointZoneSet::typeName)
419 const word& actionName,
420 const bool writeVTKFile,
421 const bool writeCurrentTime,
474 topoSet& currentSet = currentSetPtr();
479 if (currentSetPtr.
valid())
481 topoSet& currentSet = currentSetPtr();
485 <<
" Action:" << actionName
508 if (is >> sourceType)
527 currentSet.
name() +
"_old2",
536 currentSet.
subset(oldSet);
542 if (is >> sourceType)
554 setSource().applyToSet(action, currentSet);
574 "VTK"/currentSet.
name()/currentSet.
name()
580 Info<<
" Writing " << currentSet.
name()
586 <<
" and to vtk file " << vtkName <<
endl <<
endl;
592 Info<<
" Writing " << currentSet.
name()
600 if (writeCurrentTime)
614 if (sourceType.size())
625 if (sourceType.size())
664 Info<<
" mesh not changed." <<
endl;
669 Info<<
" points moved; topology unchanged." <<
endl;
674 Info<<
" topology changed; patches unchanged." <<
nl
681 Info<<
" topology changed and patches changed." <<
nl
690 <<
"Illegal mesh update state "
709 Info<<
"Type 'help' for usage information" <<
endl;
713 else if (setType ==
"help")
719 else if (setType ==
"list")
725 else if (setType ==
"time")
733 <<
" to " << Times[nearestIndex].name()
737 runTime.
setTime(Times[nearestIndex], nearestIndex);
743 else if (setType ==
"quit")
752 || setType ==
"faceSet"
753 || setType ==
"pointSet"
760 setType ==
"cellZoneSet"
761 || setType ==
"faceZoneSet"
762 || setType ==
"pointZoneSet"
770 <<
"Illegal command " << setType <<
endl
771 <<
"Should be one of 'help', 'list', 'time' or a set type :"
772 <<
" 'cellSet', 'faceSet', 'pointSet', 'faceZoneSet'"
784 if (actionName.size())
806 std::string
replaceChar(std::string & SourceString,
const std::string & strsrc,
const std::string & strdst)
812 std::string stringsource_new = SourceString;
814 while ((
pos = stringsource_new.find(strsrc,
pos)) != std::string::npos)
816 stringsource_new.replace(
pos, srclen, strdst);
819 return stringsource_new;
824 int main(
int argc,
char *argv[])
835 "process in batch mode, using input from specified file"
840 "do not synchronise selection across coupled patches"
855 <<
"Can only loop in batch mode."
870 if (!batch && !read_history((runTime.
path()/historyFile).c_str()))
872 Info<<
"Successfully read history from " << historyFile <<
endl;
893 string inputstring=
"";
897 Info <<
"Read command from strings!" <<
endl;
898 inputstring =
args[
"batch"];
902 Info<<
"Please type 'help', 'quit' or a set command after prompt."
931 Info <<
"go to else no inputstring ,not fileStreamPtr! danger " <<
endl;
934 char* linePtr = readline(
"readline>");
938 rawLine =
string(linePtr);
939 Info <<
"readline string is =" << rawLine <<
endl;
942 add_history(linePtr);
943 write_history(historyFile);
955 if (!std::cin.good())
962 std::getline(std::cin, rawLine);
969 if (i != string::npos)
971 rawLine = rawLine(0, i);
990 if (is >> actionName)
void writeDebug(Ostream &os, const label maxElem, topoSet::const_iterator &iter, label &elemI) const
Write part of contents nicely formatted. Prints labels only.
void removeSet(const polyMesh &mesh, const word &setType, const word &setName)
virtual const pointField & points() const
Return raw points.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A class for handling words, derived from string.
A class for handling file names.
void resize(const label newSize)
Resize the hash table for efficiency.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
static void addOption(const word &opt, const string ¶m="", const string &usage="")
Add to an option to validOptions with usage information.
#define forAll(list, i)
Loop across all elements in list.
static setAction toAction(const word &actionName)
Convert string to action.
bool rm(const fileName &)
Remove a file, returning true if successful otherwise false.
instantList times() const
Search the case for valid time directories.
Template functions to aid in the implementation of demand driven data.
A subset of mesh points. The labels of points in the zone can be obtained from the addressing() list.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
static const string & usage(const word &name)
label nTotalPoints() const
Return total number of points in decomposed mesh. Not.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
const cellList & cells() const
label nTotalCells() const
Return total number of cells in decomposed mesh.
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
int main(int argc, char *argv[])
const fileName & facesInstance() const
Return the current instance directory for faces.
const cellZoneMesh & cellZones() const
Return cell zone mesh.
virtual bool write() const
Write using setting from DB.
virtual void subset(const topoSet &set)
Subset contents. Only elements present in both sets remain.
static label findClosestTimeIndex(const instantList &, const scalar, const word &constantName="constant")
Search instantList for the time index closest to the given time.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Ostream & endl(Ostream &os)
Add newline and flush stream.
setAction
Enumeration defining the valid actions.
label nTotalFaces() const
Return total number of faces in decomposed mesh. Not.
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)
Return a pointer to a toposet read from file.
const fileName & instance() const
virtual void invert(const label maxLen)
Invert contents. (insert all members 0..maxLen-1 which were not in.
Mesh consisting of general polyhedral cells.
bool doCommand(const polyMesh &mesh, const word &setType, const word &setName, const word &actionName, const bool writeVTKFile, const bool writeCurrentTime, const bool noSync, Istream &is)
void writeVTK(OFstream &os, const Type &value)
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
const faceZoneMesh & faceZones() const
Return face zone mesh.
virtual readUpdateState readUpdate()
Update the mesh based on the mesh files saved in time.
Ostream & flush(Ostream &os)
Flush stream.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
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)....
Write faceSet to vtk polydata file. Only one data which is original faceID.
const pointZoneMesh & pointZones() const
Return point zone mesh.
virtual const labelList & faceOwner() const
Return face owner.
void printAllSets(const polyMesh &mesh, Ostream &os)
#define SeriousErrorInFunction
Report an error message using Foam::SeriousError.
const word & name() const
Return name.
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
Return max allowable index (+1). Not implemented.
std::string replaceChar(std::string &SourceString, const std::string &strsrc, const std::string &strdst)
label size() const
Return number of elements in table.
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
virtual void setTime(const Time &)
Reset the time and time-index to those of the given time.
bool found(const Key &) const
Return true if hashedEntry is found in table.
static autoPtr< topoSetSource > New(const word &topoSetSourceType, const polyMesh &mesh, const dictionary &dict)
Return a reference to the selected topoSetSource.
void removeZone(ZoneMesh< ZoneType, polyMesh > &zones, const word &setName)
Input from memory buffer stream.
errorManip< error > abort(error &err)
const word & name() const
Return name.
A collection of cell labels.
IOobjectList lookupClass(const word &className) const
Return the list for all IOobjects of a given class.
label findZoneID(const word &zoneName) const
Find zone index given a name.
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
Return the location of "dir" containing the file "name".
void printMesh(const Time &runTime, const polyMesh &mesh)
errorManipArg< error, int > exit(error &err, const int errNo=1)
readUpdateState
Enumeration defining the state of the mesh after a read update.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
const boundBox & bounds() const
Return mesh bounding box.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
static instantList timeDirs
virtual const faceList & faces() const
Return raw faces.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
polyMesh::readUpdateState meshReadUpdate(polyMesh &mesh)
fileName path() const
Return path.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
prefixOSstream Pout(cout, "Pout")
void clear()
Clear all entries from table.
static void addOptions(const bool constant=true, const bool withZero=false)
Add the options handled by timeSelector to argList::validOptions.
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set).
label size() const
Return the number of elements in the PtrList.
static const word null
An empty word.
bool optionFound(const word &opt) const
Return true if the named option is found.
Write pointSet to vtk polydata file. Only one data which is original pointID.
const Time & time() const
Return the top-level database.
commandStatus parseAction(const word &actionName)
void writePatch(const bool binary, const word &setName, const primitiveFacePatch &fp, const word &fieldName, labelList &fieldValues, const fileName &fileName)
readOption
Enumeration defining the read options.
void size(const label)
Override size to be inconsistent with allocated storage.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
commandStatus parseType(Time &runTime, polyMesh &mesh, const word &setType, IStringStream &is)
void clearAddressing()
Clear addressing.
const globalMeshData & globalData() const
Return parallel info.
label timeIndex() const
Return current time index.
virtual void sync(const polyMesh &mesh)
Sync set across coupled patches.
static instantList select0(Time &runTime, const argList &args)
Return the set of times selected based on the argList options.
Foam::argList args(argc, argv)
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
#define WarningInFunction
Report a warning using Foam::Warning.
A cell is defined as a list of faces with extra functionality.
Class to handle errors and exceptions in a simple, consistent stream-based manner.
const fileName & local() const
void printHelp(Ostream &os)
word name(const complex &)
Return a string representation of a complex.
virtual const labelList & faceNeighbour() const
Return face neighbour.
void writePointSet(const bool binary, const primitiveMesh &mesh, const topoSet &set, const fileName &fileName)
Write pointSet to vtk polydata file.
A list of faces which address into the list of points.
dimensionedScalar pos(const dimensionedScalar &ds)