57int 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"
103 const bool dryrun =
args.dryRun();
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
135 if (
args.found(
"ascii"))
142 runTime.setTime(times[timei], timei);
152 args.readListIfPresent(
"load-fields", preloadFields);
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;
178 List<dictionary> exprDicts;
179 dict.readEntry(
"expressions", exprDicts);
181 if (exprDicts.
empty())
183 Info<<
"No expressions for " << fieldName <<
nl;
190 const word oldTypeName = IOdictionary::typeName;
196 mesh.thisDb().time().timeName(),
203 const bool headOk = fieldHeader.typeHeaderOk<
IOdictionary>(
false);
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);
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
@ NO_REGISTER
Do not request registration (bool: false).
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
A simple container for options an IOstream can normally have.
@ ASCII
"ascii" (normal default)
Output to string buffer, using a OSstream. Always UNCOMPRESSED.
Foam::string str() const
Get the string. As Foam::string instead of std::string (may change in future).
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
bool empty() const noexcept
True if List is empty (ie, size() is zero).
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
static void addDryRunOption(const string &usage, bool advanced=false)
Enable a 'dry-run' bool option, with usage information.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
bool changeKeyword(const keyType &oldKeyword, const keyType &newKeyword, bool overwrite=false)
Change the keyword for an entry,.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
A keyword and a list of tokens is an 'entry'.
@ SEARCH_FILES
Search disk (eg, standalone app).
A variant of Foam::string with expansion of dictionary variables into a comma-separated form.
A simple field-loader, as per the readFields function object.
bool execute(const UList< word > &fieldNames)
static void addOptions(const bool constant=true, const bool withZero=false)
Add timeSelector options to argList::validOptions.
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...
A class for handling words, derived from Foam::string.
static const word null
An empty word.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const word dictName("faMeshDefinition")
#define WarningInFunction
Report a warning using Foam::Warning.
patchExpr::parseDriver patchExprDriver
Typedef for patchExpr parseDriver.
List< word > wordList
List of word.
messageStream Info
Information stream (stdout output on master, null elsewhere).
List< instant > instantList
List of instants.
Ostream & endl(Ostream &os)
Add newline and flush stream.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
messageStream Warning
Warning stream (stdout output on master, null elsewhere), with additional 'FOAM Warning' header text.
constexpr char nl
The newline '\n' character (0x0a).
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.