70 int main(
int argc,
char *argv[])
76 "Utility to reorder the patches of a case.\n"
86 "specify the list of patch names in the new order"
93 "specify the reference case path"
100 "specify the reference region"
122 const fileName caseDirReference = referenceCasePath.
name();
124 const string caseDirOrig =
getEnv(
"FOAM_CASE");
125 const string caseNameOrig =
getEnv(
"FOAM_CASENAME");
126 setEnv(
"FOAM_CASE", rootDirReference/caseDirReference,
true);
127 setEnv(
"FOAM_CASENAME", caseDirReference,
true);
128 Time referenceRunTime
135 setEnv(
"FOAM_CASE", caseDirOrig,
true);
136 setEnv(
"FOAM_CASENAME", caseNameOrig,
true);
138 word referenceRegion;
141 referenceRegion =
args[
"referenceRegion"];
142 Info<<
"Reference region: " << referenceRegion <<
endl;
150 referenceRunTime.findInstance
163 if (ioObj.headerOk())
167 referencePatchNames.
setSize(patchEntries.size());
171 referencePatchNames[
patchi] = patchEntries[
patchi].keyword();
177 <<
"Cannot find or read the boundary file for reference case "
179 <<
" " << referenceCasePath
186 <<
"Reference patch order not specified"
198 const word oldInstance = mesh.pointsInstance();
208 && mesh.boundaryMesh().size() != referencePatchNames.
size()
212 <<
"Number of reference patches " << referencePatchNames.
size()
213 <<
" is not equal to the number of patches in the mesh "
214 << mesh.boundaryMesh().size()
223 const label oldPatchi =
224 mesh.boundaryMesh().findIndex(referencePatchNames[
patchi]);
228 newToOldPatches[
patchi] = oldPatchi;
233 <<
"Cannot find reference patch " << referencePatchNames[
patchi]
234 <<
" in the mesh which has patches "
235 << mesh.boundaryMesh().names()
239 mesh.reorderPatches(newToOldPatches,
false);
243 mesh.setInstance(oldInstance);
246 Info<<
"Writing mesh to " << mesh.facesInstance() <<
endl;
#define forAll(list, i)
Loop across all elements in list.
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
virtual Ostream & write(const char)=0
Write character.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static word controlDictName
The default control dictionary name (normally "controlDict")
static bool & parRun()
Is this a parallel run?
static void addOption(const word &opt, const string ¶m="", const string &usage="")
Add to an option to validOptions with usage information.
static void addNote(const string &)
Add extra notes for the usage information.
bool optionFound(const word &opt) const
Return true if the named option is found.
fileName path() const
Return the path to the caseName.
IStringStream optionLookup(const word &opt) const
Return an IStringStream from the named option.
T optionLookupOrDefault(const word &opt, const T &deflt) const
Read a value from the named option if present.
A class for handling file names.
word name() const
Return file name (part beyond last /)
fileName & toAbsolute()
Convert from relative to absolute.
fileName path() const
Return directory path name (part before last /)
Foam::polyBoundaryMeshEntries.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
static void addOptions(const bool constant=true, const bool withZero=false)
Add the options handled by timeSelector to argList::validOptions.
static instantList selectIfPresent(Time &runTime, const argList &args)
If any time option provided return the set of times (as select0)
Templated form of IOobject providing type information for file reading and header type checking.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
int main(int argc, char *argv[])
errorManipArg< error, int > exit(error &err, const int errNo=1)
bool setEnv(const word &name, const std::string &value, const bool overwrite)
Set an environment variable.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
string getEnv(const word &)
Return environment variable of given name.
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
Foam::argList args(argc, argv)