50#include "readFields.H"
57int main(
int argc,
char *argv[])
59 argList::noFunctionObjects(
true);
62 timeSelector::addOptions(
false);
64 argList::addBoolOption
67 "Write in ASCII format instead of the controlDict setting"
73 "Alternative dictionary for setExprBoundaryFieldsDict"
75 argList::addBoolOption
78 "Cache fields between calls",
85 "Specify field or fields to preload. Eg, 'T' or '(p T U)'",
88 argList::addBoolOption
91 "Preserve sub-entry as .backup",
94 argList::addDryRunOption
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
136 streamOpt.format(IOstream::ASCII);
141 runTime.setTime(times[timei], timei);
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;
178 dict.readEntry(
"expressions", exprDicts);
180 if (exprDicts.
empty())
182 Info<<
"No expressions for " << fieldName <<
nl;
189 const word oldTypeName = IOdictionary::typeName;
195 mesh.thisDb().time().timeName(),
197 IOobject::MUST_READ_IF_MODIFIED,
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"));
236 expressions::exprString::getEntry
244 Info<<
"Set boundaryField/" << patchName <<
'/'
246 <<
"with expression" <<
nl
248 << valueExpr_.c_str() <<
nl
254 driver.setSearchBehaviour
256 expressions::exprDriver::SEARCH_FILES,
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);
Foam::string str() const
Get the string - as Foam::string rather than std::string.
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,...
The IOstreamOption is a simple container for options an IOstream can normally have.
Output to string buffer, using a OSstream. Always UNCOMPRESSED.
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
int dryRun() const noexcept
Return the dry-run flag.
bool readListIfPresent(const word &optName, List< T > &list) const
bool found(const word &optName) const
Return true if the named option is found.
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'.
Driver for patch expressions.
A simple field-loader, as per the readFields function object.
bool execute(const UList< word > &fieldNames)
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const word dictName("faMeshDefinition")
#define WarningInFunction
Report a warning using Foam::Warning.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.