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;
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)
Change the keyword for an entry,.
A class for handling words, derived from Foam::string.
virtual const objectRegistry & thisDb() const
Return the object registry - resolve conflict polyMesh/lduMesh.
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.
IOstream::streamFormat writeFormat() const
The write stream format.
const word dictName("faMeshDefinition")
static word timeName(const scalar t, const int precision=precision_)
streamFormat format() const noexcept
Get the current stream format.
bool readListIfPresent(const word &optName, List< T > &list) const
Ostream & endl(Ostream &os)
Add newline and flush stream.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
#define forAll(list, i)
Loop across all elements in list.
virtual readUpdateState readUpdate()
Update the mesh based on the mesh files saved in time.
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
int dryRun() const noexcept
Return the dry-run flag.
Search disk (eg, standalone app)
messageStream Info
Information stream (stdout output on master, null elsewhere)
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
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)
Enable a 'dry-run' bool option, with usage information.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Foam::string str() const
Get the string - as Foam::string rather than std::string.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
bool execute(const UList< word > &fieldNames)
static void addOptions(const bool constant=true, const bool withZero=false)
Add timeSelector options to argList::validOptions.
Output to string buffer, using a OSstream. Always UNCOMPRESSED.
virtual void setTime(const Time &t)
Reset the time and time-index to those of the given time.
static const word null
An empty word.
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
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)
Add an option to validOptions with usage information.
Foam::argList args(argc, argv)
#define WarningInFunction
Report a warning using Foam::Warning.
const Time & time() const noexcept
Return time registry.
bool found(const word &optName) const
Return true if the named option is found.