82 Info<<
"Reading boundary from " 95 label nOldCyclics = 0;
100 if (patchDict.
get<
word>(
"type") == cyclicPolyPatch::typeName)
102 if (!patchDict.
found(
"neighbourPatch"))
105 <<
" does not have 'neighbourPatch' entry; assuming it" 106 <<
" is of the old type." <<
endl;
112 Info<<
"Detected " << nOldCyclics <<
" old cyclics." <<
nl <<
endl;
127 label addedPatchi = nOldPatches;
129 forAll(oldPatches, patchi)
131 const dictionary& patchDict = oldPatches[patchi].dict();
135 patchDict.
get<
word>(
"type") == cyclicPolyPatch::typeName
138 const word&
name = oldPatches[patchi].keyword();
140 if (patchDict.
found(
"neighbourPatch"))
142 patches.
set(patchi, oldPatches.release(patchi));
143 oldToNew[patchi] = newPatchi++;
149 if (i != string::npos)
151 oldName =
name.substr(0, i);
153 Info<<
"Detected converted cyclic patch " <<
name 154 <<
" ; assuming it originates from " << oldName
159 i =
name.rfind(
"_half1");
160 if (i != string::npos)
162 oldName =
name.substr(0, i);
164 Info<<
"Detected converted cyclic patch " <<
name 165 <<
" ; assuming it originates from " << oldName
172 label nFaces = patchDict.
get<label>(
"nFaces");
173 label startFace = patchDict.
get<label>(
"startFace");
175 Info<<
"Detected old style " << patchDict.
get<
word>(
"type")
176 <<
" patch " <<
name <<
" with" <<
nl 177 <<
" nFaces : " << nFaces <<
nl 178 <<
" startFace : " << startFace <<
endl;
190 patches.
set(patchi, oldPatches.release(patchi));
191 oldToNew[patchi] = newPatchi++;
193 thisPatchDict.
add(
"neighbourPatch", nbrName);
194 thisPatchDict.
set(
"nFaces", nFaces/2);
195 patches[patchi].keyword() = thisName;
208 oldToNew[addedPatchi] = newPatchi++;
210 nbrPatchDict.
set(
"neighbourPatch", thisName);
211 nbrPatchDict.
set(
"nFaces", nFaces/2);
212 nbrPatchDict.
set(
"startFace", startFace+nFaces/2);
213 patches[addedPatchi].keyword() = nbrName;
215 Info<<
"Replaced with patches" <<
nl 216 <<
patches[patchi].keyword() <<
" with" <<
nl 218 << thisPatchDict.
get<label>(
"nFaces") <<
nl 220 << thisPatchDict.
get<label>(
"startFace") <<
nl 221 <<
patches[addedPatchi].keyword() <<
" with" <<
nl 223 << nbrPatchDict.
get<label>(
"nFaces") <<
nl 225 << nbrPatchDict.
get<label>(
"startFace") <<
nl 233 patches.
set(patchi, oldPatches.release(patchi));
234 oldToNew[patchi] = newPatchi++;
261 Info<<
"No changes made to boundary file." <<
nl <<
endl;
270 const word& fieldName,
277 Info<<
"Loading field " << fieldName <<
endl;
278 const word oldTypeName = IOdictionary::typeName;
293 const_cast<word&
>(IOdictionary::typeName) = oldTypeName;
295 const_cast<word&
>(fieldDict.type()) = fieldDict.headerClassName();
301 bool hasChange =
false;
305 const word& patchName = iter.key();
306 const word& newName = iter.val();
308 Info<<
"Looking for entry for patch " << patchName <<
endl;
315 boundaryField.
found(patchName)
319 Info<<
" Changing entry " << patchName <<
" to " << newName
324 if (patchDict.
found(
"value"))
327 patchDict.
remove(
"value");
337 Info<<
" Adding entry " << nbrNames[patchName] <<
endl;
353 if (
mvBak(fieldDict.objectPath(),
"old"))
356 << (fieldDict.objectPath() +
".old") <<
nl;
360 << fieldDict.objectPath() <<
endl;
361 fieldDict.regIOobject::write();
366 Info<<
"No changes made to field " << fieldName <<
endl;
374 int main(
int argc,
char *argv[])
378 "Tool to upgrade mesh and fields for split cyclics" 385 "Test only do not change any files" 389 "enableFunctionEntries",
390 "Enable expansion of dictionary directives - #include, #codeStream etc" 408 Info<<
"-dry-run option: no changes made" <<
nl <<
endl;
410 const bool enableEntries =
args.
found(
"enableFunctionEntries");
496 #define rewriteFields(FieldType) \ 497 for (const word& fieldName : objects.sortedNames<FieldType>()) \ 499 rewriteField(dryrun, runTime, fieldName, thisNames, nbrNames); \
bool mvBak(const fileName &src, const std::string &ext="bak")
Rename to a corresponding backup file.
static void addNote(const string ¬e)
Add extra notes for the usage information.
A class for handling file names.
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable, so the various sorted methods should be used if traversing in parallel.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
const word & regionName() const
The mesh region name or word::null if polyMesh::defaultRegion.
constexpr char nl
The newline '\n' character (0x0a)
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
void reorder(const labelUList &oldToNew, const bool validBoundary)
Reorders patches. Ordering does not have to be done in.
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.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
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.
A keyword and a list of tokens is a 'dictionaryEntry'.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
fileName objectPath() const
The complete path + object name.
fileName typeFilePath(const bool search=true) const
Call localFilePath or globalFilePath for given type depending on its is_globalIOobject trait...
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
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 remove(const word &keyword)
Remove an entry specified by keyword.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
static int disableFunctionEntries
Enable or disable use of function entries and variable expansions.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
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.
int dryRun() const noexcept
Return the dry-run flag.
label size() const noexcept
The number of entries in the list.
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
virtual bool write(const bool writeOnProc=true) const
Write using setting from DB.
static const word null
An empty word.
virtual void setTime(const Time &t)
Reset the time and time-index to those of the given time.
A HashTable similar to std::unordered_map.
graph_traits< Graph >::vertices_size_type size_type
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie...
bool typeHeaderOk(const bool checkType=true, const bool search=true, const bool verbose=true)
Read header (respects is_globalIOobject trait) and check its info.
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
const word & constant() const noexcept
Return constant name.
defineTemplateTypeNameAndDebug(faScalarMatrix, 0)
static fileCheckTypes fileModificationChecking
Type of file modification checking.
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...
void setSize(const label newLen)
Same as resize()
A PtrList of objects of type <T> with automated input and output.
const word & headerClassName() const noexcept
Return name of the class name read from header.
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
const polyBoundaryMesh & patches
messageStream Info
Information stream (stdout output on master, null elsewhere)
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
bool changeKeyword(const keyType &oldKeyword, const keyType &newKeyword, bool overwrite=false)
Change the keyword for an entry,.
Foam::argList args(argc, argv)
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
Defines the attributes of an object for which implicit objectRegistry management is supported...
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.
forAllConstIters(mixture.phases(), phase)