Go to the documentation of this file.
78 const regExp matcher(
"processors?[0-9]+(_[0-9]+-[0-9]+)?");
80 bool isProcessorDir(
const string& dir)
85 && (dir ==
"processors" || matcher.
match(dir))
100 { restoreMethod::MEAN,
"mean" },
101 { restoreMethod::ORIG,
"orig" },
107 { restoreMethod::MEAN,
"Mean" },
108 { restoreMethod::ORIG,
".orig" },
115 return ListOps::create<word>
124 bool dryrun =
false, verbose =
false;
133 const restoreMethod method,
140 const word ending(methodEndings[method]);
147 case restoreMethod::MEAN:
148 bak = methodEndings[restoreMethod::ORIG];
161 for (
word f : existingFiles)
164 if (
f.removeEnd(ending) &&
f.size())
179 for (
const word& dst : targets)
181 const word src(dst + ending);
183 if (!existingFiles.found(src))
188 if (bak.size() && existingFiles.found(dst))
190 if (dryrun ||
Foam::mv(dirName/dst, dirName/dst + bak))
192 Info<<
" mv " << dst <<
" " <<
word(dst + bak) <<
nl;
197 if (dryrun ||
Foam::mv(dirName/src, dirName/dst))
199 Info<<
" mv " << src <<
" " << dst <<
nl;
210 int main(
int argc,
char *argv[])
214 "Restore field names by removing the ending. Fields are selected"
215 " automatically or can be specified as optional command arguments"
225 "The restore method (mean|orig) [MANDATORY]. "
226 "With <mean> renames files ending with 'Mean' "
227 "(with backup of existing as '.orig'). "
228 "With <orig> renames files ending with '.orig'"
233 "In serial mode use times from processor0/ directory, but operate on "
234 "processor\\d+ directories"
239 "Report action without moving/renaming"
244 "Additional verbosity"
262 restoreMethod method = restoreMethod::ORIG;
269 && methodNames.found(methodName)
272 method = methodNames[methodName];
276 Info<<
"Unspecified or unknown method name" <<
nl
279 <<
"... stopping" <<
nl <<
nl;
291 for (label argi=1; argi <
args.
size(); ++argi)
295 targetNames[uniq.
size()-1] =
args[argi];
304 <<
"using method=" << methodNames[method] <<
nl
311 <<
"using method=" << methodNames[method] <<
nl
312 <<
"autodetect fields" <<
nl;
330 <<
"No processor* directories found"
353 label leadProcIdx = -1;
355 if (timeDirs.empty())
357 Info<<
"No times selected" <<
nl;
381 leadProcIdx = procDirs.find(
"processor0");
383 if (!procDirs.empty())
388 leadProcIdx = procDirs.find(
"processors");
394 leadProcIdx = procDirs.find(
"processors" +
Foam::name(nProcs));
400 const std::string prefix
407 if (procDirs[idx].starts_with(prefix))
424 for (
const instant& t : timeDirs)
435 if (leadProcIdx >= 0)
440 for (
const fileName& procDir : procDirs)
442 count += restoreFields
459 count += restoreFields
static autoPtr< T > New(Args &&... args)
Construct autoPtr of T with forwarding arguments.
label size() const noexcept
The number of elements in table.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
void inplaceSubsetList(ListType &input, const UnaryPredicate &pred, const bool invert=false)
Inplace subset of the list when predicate is true.
A class for handling words, derived from Foam::string.
A class for handling file names.
bool starts_with(const std::string &s) const
True if string starts with the given prefix (cf. C++20)
static std::string name(const std::string &str)
Return basename (part beyond last /), including its extension.
static bool & parRun()
Is this a parallel run?
static void addNote(const string ¬e)
Add extra notes for the usage information.
instantList select(const instantList ×) const
Select a list of Time values that are within the ranges.
static void scatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
Scatter data. Distribute without modification. Reverse of gather.
const fileOperation & fileHandler()
Get current file handler.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
static void noMandatoryArgs()
Flag command arguments as being optional (non-mandatory)
const fileName & rootPath() const
Return root path.
#define forAll(list, i)
Loop across all elements in list.
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
bool match(const std::string &text) const
Test for equality.
static void noJobInfo()
Suppress JobInfo, overriding controlDict setting.
messageStream Info
Information stream (uses stdout - output is on the master only)
word name(const complex &c)
Return string representation of complex.
virtual label nProcs(const fileName &dir, const fileName &local="") const
Get number of processor directories/results. Used for e.g.
instantList times() const
Search the case for valid time directories.
Extract name (as a word) from an object, typically using its name() method.
Wrapper around C++11 regular expressions.
void resize(const label newSize)
Adjust allocated size of list.
fileName path() const
Return the full path to the (processor local) case.
bool mv(const fileName &src, const fileName &dst, const bool followLink=false)
Rename src to dst.
static void disable()
Disallow profiling by forcing the InfoSwitch off.
errorManipArg< error, int > exit(error &err, const int errNo=1)
static bool master(const label communicator=0)
Am I the master process.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
label size() const noexcept
The number of arguments.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
FlatOutput< Container > flatOutput(const Container &obj, label len=0)
Global flatOutput function.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
static void addOptions(const bool constant=true, const bool withZero=false)
Add timeSelector options to argList::validOptions.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
Encapsulation of natural order sorting for algorithms.
HashSet< word > wordHashSet
A HashSet with word keys.
const fileName & caseName() const
Return case name (parallel run) or global case (serial run)
Various functions to operate on Lists.
An instant of time. Contains the time value and name.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
Foam::argList args(argc, argv)
fileNameList readDir(const fileName &directory, const fileName::Type type=fileName::FILE, const bool filtergz=true, const bool followLink=true)
Read a directory and return the entries as a fileName List.
bool found(const word &optName) const
Return true if the named option is found.