50 #include "readFields.H" 57 int main(
int argc,
char *argv[])
68 "Write in ASCII format instead of the controlDict setting" 74 "Alternative dictionary for setExprBoundaryFieldsDict" 79 "Cache fields between calls",
86 "Specify field or fields to preload. Eg, 'T' or '(p T U)'",
92 "Preserve sub-entry as .backup",
97 "Evaluate but do not write" 104 const bool backup =
args.
found(
"backup");
105 const bool cacheFields =
args.
found(
"cache-fields");
110 <<
"The current cache-fields behaviour (caching disk reads) " 111 <<
"may lead to unexpected behaviour as previous modifications " 112 <<
"will not be visible." 125 <<
"No times selected." <<
nl 158 setExprDict.readIfPresent(
"readFields", preloadFields);
162 for (
const entry& dEntry : setExprDict)
164 if (!dEntry.isDict())
166 if (dEntry.keyword() !=
"readFields")
168 Info<<
"Ignoring non-dictionary entry " 169 << dEntry.keyword() <<
nl;
181 if (exprDicts.
empty())
183 Info<<
"No expressions for " << fieldName <<
nl;
190 const word oldTypeName = IOdictionary::typeName;
208 const_cast<word&
>(IOdictionary::typeName) = oldTypeName;
211 <<
"Requested field to change " << fieldName
212 <<
" does not exist in " << fieldHeader.path() <<
endl;
219 const_cast<word&
>(IOdictionary::typeName) = oldTypeName;
222 const_cast<word&
>(fieldDict.type()) = fieldDict.headerClassName();
224 Info<<
"Processing field " << fieldName <<
nl;
230 const word patchName(currDict.get<
word>(
"patch"));
231 const word targetName(currDict.get<
word>(
"target"));
237 Info<<
"Set boundaryField/" << patchName <<
'/' 239 <<
"with expression" <<
nl 241 << valueExpr_.c_str() <<
nl 247 driver.setSearchBehaviour
253 driver.clearVariables();
254 driver.parse(valueExpr_);
260 if (backup && !dryrun)
265 word(targetName +
".backup"),
270 patchDict.
set(targetName, serialize.
str().c_str());
276 << serialize.
str().c_str()
283 Info<<
"Write " << fieldDict.filePath() <<
nl;
284 fieldDict.regIOobject::writeObject(streamOpt,
true);
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Foam::string str() const
Get the string - as Foam::string rather than std::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A simple field-loader, as per the readFields function object.
constexpr char nl
The newline '\n' character (0x0a)
bool empty() const noexcept
True if List is empty (ie, size() is zero)
const word dictName("faMeshDefinition")
Ostream & endl(Ostream &os)
Add newline and flush stream.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
A simple container for options an IOstream can normally have.
Driver for patch expressions.
Ignore writing from objectRegistry::writeObject()
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
virtual const objectRegistry & thisDb() const
Return the object registry - resolve conflict polyMesh/lduMesh.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
#define forAll(list, i)
Loop across all elements in list.
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, IOobjectOption::readOption readOpt=IOobjectOption::MUST_READ) const
Find entry and assign to T val. FatalIOError if it is found and the number of tokens is incorrect...
virtual readUpdateState readUpdate()
Update the mesh based on the mesh files saved in time.
A class for handling words, derived from Foam::string.
static void addDryRunOption(const string &usage, bool advanced=false)
Enable a 'dry-run' bool option, with usage information.
const Time & time() const noexcept
Return time registry.
int dryRun() const noexcept
Return the dry-run flag.
static const word null
An empty word.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
virtual void setTime(const Time &t)
Reset the time and time-index to those of the given time.
bool typeHeaderOk(const bool checkType=true, const bool search=true, const bool verbose=true)
Read header (uses typeFilePath to find file) and check its info.
static word timeName(const scalar t, const int precision=precision_)
Return time name of given scalar time formatted with the given precision.
bool readListIfPresent(const word &optName, List< T > &list) const
If named option is present, get a List of values treating a single entry like a list of size 1...
static instantList select0(Time &runTime, const argList &args)
Return the set of times selected based on the argList options and also set the runTime to the first i...
IOstreamOption::streamFormat writeFormat() const noexcept
The write stream format.
messageStream Warning
Warning stream (stdout output on master, null elsewhere), with additional 'FOAM Warning' header text...
Search disk (eg, standalone app)
#define WarningInFunction
Report a warning using Foam::Warning.
messageStream Info
Information stream (stdout output on master, null elsewhere)
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
bool changeKeyword(const keyType &oldKeyword, const keyType &newKeyword, bool overwrite=false)
Change the keyword for an entry,.
Foam::argList args(argc, argv)
bool execute(const UList< word > &fieldNames)
Defines the attributes of an object for which implicit objectRegistry management is supported...
Output to string buffer, using a OSstream. Always UNCOMPRESSED.
streamFormat format() const noexcept
Get the current stream format.
Do not request registration (bool: false)
bool found(const word &optName) const
Return true if the named option is found.
static void addOptions(const bool constant=true, const bool withZero=false)
Add timeSelector options to argList::validOptions.
A keyword and a list of tokens is an 'entry'.