Go to the documentation of this file.
50 #include "readFields.H"
57 int main(
int argc,
char *argv[])
67 "Write in ASCII format instead of the controlDict setting"
73 "Alternative dictionary for setExprBoundaryFieldsDict"
78 "Cache fields between calls",
85 "Specify field or fields to preload. Eg, 'T' or '(p T U)'",
91 "Preserve sub-entry as .backup",
96 "Evaluate but do not write"
103 const bool backup =
args.
found(
"backup");
104 const bool cacheFields =
args.
found(
"cache-fields");
109 <<
"The current cache-fields behaviour (caching disk reads) "
110 <<
"may lead to unexpected behaviour as previous modifications "
111 <<
"will not be visible."
124 <<
"No times selected." <<
nl
157 setExprDict.readIfPresent(
"readFields", preloadFields);
161 for (
const entry& dEntry : setExprDict)
163 if (!dEntry.isDict())
165 if (dEntry.keyword() !=
"readFields")
167 Info<<
"Ignoring non-dictionary entry "
168 << dEntry.keyword() <<
nl;
180 if (exprDicts.empty())
182 Info<<
"No expressions for " << fieldName <<
nl;
189 const word oldTypeName = IOdictionary::typeName;
202 const bool headOk = fieldHeader.typeHeaderOk<
IOdictionary>(
false);
207 const_cast<word&
>(IOdictionary::typeName) = oldTypeName;
210 <<
"Requested field to change " << fieldName
211 <<
" does not exist in " << fieldHeader.path() <<
endl;
218 const_cast<word&
>(IOdictionary::typeName) = oldTypeName;
221 const_cast<word&
>(fieldDict.type()) = fieldDict.headerClassName();
223 Info<<
"Processing field " << fieldName <<
nl;
229 const word patchName(currDict.get<
word>(
"patch"));
230 const word targetName(currDict.get<
word>(
"target"));
244 Info<<
"Set boundaryField/" << patchName <<
'/'
246 <<
"with expression" <<
nl
248 << valueExpr_.c_str() <<
nl
254 driver.setSearchBehaviour
260 driver.clearVariables();
261 driver.parse(valueExpr_);
267 if (backup && !dryrun)
272 word(targetName +
".backup"),
277 patchDict.
set(targetName, serialize.
str().c_str());
283 << serialize.
str().c_str()
290 Info<<
"Write " << fieldDict.filePath() <<
nl;
291 fieldDict.regIOobject::writeObject(streamOpt,
true);
A keyword and a list of tokens is an 'entry'.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Defines the attributes of an object for which implicit objectRegistry management is supported,...
static exprString getEntry(const word &keyword, const dictionary &dict, const bool stripComments=true)
bool changeKeyword(const keyType &oldKeyword, const keyType &newKeyword, bool overwrite=false)
A class for handling words, derived from Foam::string.
virtual const objectRegistry & thisDb() const
IOstream::streamFormat writeFormat() const
const word dictName("faMeshDefinition")
static word timeName(const scalar t, const int precision=precision_)
bool readListIfPresent(const word &optName, List< T > &list) const
Ostream & endl(Ostream &os)
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
entry * set(entry *entryPtr)
virtual readUpdateState readUpdate()
static void noFunctionObjects(bool addWithOption=false)
int dryRun() const noexcept
@ SEARCH_FILES
Search disk (eg, standalone app)
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
The IOstreamOption is a simple container for options an IOstream can normally have.
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Driver for patch expressions.
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)
@ ASCII
"ascii" (normal default)
#define FatalErrorInFunction
bool execute(const UList< word > &fieldNames)
static void addOptions(const bool constant=true, const bool withZero=false)
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
virtual void setTime(const Time &t)
Ostream & writeEntry(const keyType &key, const T &value)
A simple field-loader, as per the readFields function object.
static instantList select0(Time &runTime, const argList &args)
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Foam::argList args(argc, argv)
#define WarningInFunction
const Time & time() const noexcept
bool found(const word &optName) const