Go to the documentation of this file.
77 const regExp matcher(
"processors?[0-9]+(_[0-9]+-[0-9]+)?");
79 bool isProcessorDir(
const string& dir)
81 return (dir.
starts_with(
"processor") && matcher.match(dir));
95 { restoreMethod::MEAN,
"mean" },
96 { restoreMethod::ORIG,
"orig" },
102 { restoreMethod::MEAN,
"Mean" },
103 { restoreMethod::ORIG,
".orig" },
110 return ListOps::create<word>
119 bool dryrun =
false, verbose =
false;
128 const restoreMethod method,
135 const word ending(methodEndings[method]);
142 case restoreMethod::MEAN:
143 bak = methodEndings[restoreMethod::ORIG];
156 for (
word f : existingFiles)
159 if (
f.removeEnd(ending) &&
f.size())
174 for (
const word& dst : targets)
176 const word src(dst + ending);
178 if (!existingFiles.found(src))
183 if (bak.size() && existingFiles.found(dst))
185 if (dryrun ||
Foam::mv(dirName/dst, dirName/dst + bak))
187 Info<<
" mv " << dst <<
" " <<
word(dst + bak) <<
nl;
192 if (dryrun ||
Foam::mv(dirName/src, dirName/dst))
194 Info<<
" mv " << src <<
" " << dst <<
nl;
205 int main(
int argc,
char *argv[])
209 "Restore field names by removing the ending. Fields are selected"
210 " automatically or can be specified as optional command arguments"
220 "The restore method (mean|orig) [MANDATORY]. "
221 "With <mean> renames files ending with 'Mean' "
222 "(with backup of existing as '.orig'). "
223 "With <orig> renames files ending with '.orig'"
228 "In serial mode use times from processor0/ directory, but operate on "
229 "processor\\d+ directories"
233 "Report action without moving/renaming"
237 "Additional verbosity"
255 restoreMethod method = restoreMethod::ORIG;
262 && methodNames.found(methodName)
265 method = methodNames[methodName];
269 Info<<
"Unspecified or unknown method name" <<
nl
272 <<
"... stopping" <<
nl <<
nl;
284 for (label argi=1; argi <
args.
size(); ++argi)
288 targetNames[uniq.size()-1] =
args[argi];
292 targetNames.
resize(uniq.size());
297 <<
"using method=" << methodNames[method] <<
nl
304 <<
"using method=" << methodNames[method] <<
nl
305 <<
"autodetect fields" <<
nl;
323 <<
"No processor* directories found"
346 label leadProcIdx = -1;
348 if (timeDirs.empty())
350 Info<<
"No times selected" <<
nl;
374 leadProcIdx = procDirs.find(
"processor0");
376 if (!procDirs.empty())
381 leadProcIdx = procDirs.find(
"processors" +
Foam::name(nProcs));
387 const std::string prefix
394 if (procDirs[idx].starts_with(prefix))
411 for (
const instant& t : timeDirs)
422 if (leadProcIdx >= 0)
427 for (
const fileName& procDir : procDirs)
429 count += restoreFields
446 count += restoreFields
static autoPtr< T > New(Args &&... args)
Wrapper around POSIX extended regular expressions with some additional prefix-handling....
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)
A class for handling words, derived from Foam::string.
A class for handling file names.
void resize(const label len)
bool starts_with(const std::string &s) const
const fileName & caseName() const noexcept
static std::string name(const std::string &str)
static void addNote(const string ¬e)
instantList select(const instantList ×) const
static bool master(const label communicator=worldComm)
static void scatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
const fileOperation & fileHandler()
Ostream & endl(Ostream &os)
A HashTable with keys but without contents that is similar to std::unordered_set.
bool readIfPresent(const word &optName, T &val) const
static void noMandatoryArgs()
static void addArgument(const string &argName, const string &usage="")
static void noFunctionObjects(bool addWithOption=false)
int dryRun() const noexcept
virtual label nProcs(const fileName &dir, const fileName &local="") const
bool mv(const fileName &src, const fileName &dst, const bool followLink=false)
int verbose() const noexcept
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
static void addDryRunOption(const string &usage, bool advanced=false)
errorManipArg< error, int > exit(error &err, const int errNo=1)
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.
label size() const noexcept
#define FatalErrorInFunction
unsigned int count(const UList< bool > &bools, const bool val=true)
static void addOptions(const bool constant=true, const bool withZero=false)
static bool & parRun() noexcept
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
bool insert(const Key &key)
word name(const expressions::valueTypeCode typeCode)
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)
Foam::argList args(argc, argv)
fileNameList readDir(const fileName &directory, const fileName::Type type=fileName::FILE, const bool filtergz=true, const bool followLink=true)
const fileName & rootPath() const noexcept
static void addVerboseOption(const string &usage, bool advanced=false)
bool found(const word &optName) const