83 Info<<
"Reading boundary from " << typeFilePath<IOPtrList<entry>>(
io)
96 label nOldCyclics = 0;
101 if (patchDict.
get<
word>(
"type") == cyclicPolyPatch::typeName)
103 if (!patchDict.
found(
"neighbourPatch"))
106 <<
" does not have 'neighbourPatch' entry; assuming it"
107 <<
" is of the old type." <<
endl;
113 Info<<
"Detected " << nOldCyclics <<
" old cyclics." <<
nl <<
endl;
120 label nOldPatches =
patches.size();
121 patches.setSize(nOldPatches+nOldCyclics);
128 label addedPatchi = nOldPatches;
130 forAll(oldPatches, patchi)
132 const dictionary& patchDict = oldPatches[patchi].dict();
136 patchDict.
get<
word>(
"type") == cyclicPolyPatch::typeName
139 const word&
name = oldPatches[patchi].keyword();
141 if (patchDict.
found(
"neighbourPatch"))
143 patches.set(patchi, oldPatches.set(patchi,
nullptr));
144 oldToNew[patchi] = newPatchi++;
150 if (i != string::npos)
152 oldName =
name.substr(0, i);
153 thisNames.
insert(oldName, name);
154 Info<<
"Detected converted cyclic patch " <<
name
155 <<
" ; assuming it originates from " << oldName
160 i =
name.rfind(
"_half1");
161 if (i != string::npos)
163 oldName =
name.substr(0, i);
164 nbrNames.
insert(oldName, name);
165 Info<<
"Detected converted cyclic patch " <<
name
166 <<
" ; assuming it originates from " << oldName
173 label
nFaces = patchDict.
get<label>(
"nFaces");
174 label startFace = patchDict.
get<label>(
"startFace");
176 Info<<
"Detected old style " << patchDict.
get<
word>(
"type")
177 <<
" patch " << name <<
" with" << nl
178 <<
" nFaces : " <<
nFaces << nl
179 <<
" startFace : " << startFace << endl;
184 thisNames.
insert(name, thisName);
185 nbrNames.
insert(name, nbrName);
191 patches.set(patchi, oldPatches.set(patchi,
nullptr));
192 oldToNew[patchi] = newPatchi++;
194 thisPatchDict.
add(
"neighbourPatch", nbrName);
196 patches[patchi].keyword() = thisName;
209 oldToNew[addedPatchi] = newPatchi++;
211 nbrPatchDict.
set(
"neighbourPatch", thisName);
213 nbrPatchDict.
set(
"startFace", startFace+
nFaces/2);
214 patches[addedPatchi].keyword() = nbrName;
216 Info<<
"Replaced with patches" <<
nl
217 <<
patches[patchi].keyword() <<
" with" <<
nl
219 << thisPatchDict.
get<label>(
"nFaces") << nl
221 << thisPatchDict.
get<label>(
"startFace") <<
nl
222 <<
patches[addedPatchi].keyword() <<
" with" <<
nl
224 << nbrPatchDict.
get<label>(
"nFaces") << nl
226 << nbrPatchDict.
get<label>(
"startFace") <<
nl
234 patches.set(patchi, oldPatches.set(patchi,
nullptr));
235 oldToNew[patchi] = newPatchi++;
252 << (
patches.objectPath() +
".old") << nl;
262 Info<<
"No changes made to boundary file." <<
nl <<
endl;
271 const word& fieldName,
278 Info<<
"Loading field " << fieldName <<
endl;
279 const word oldTypeName = IOdictionary::typeName;
289 IOobject::MUST_READ_IF_MODIFIED,
294 const_cast<word&
>(IOdictionary::typeName) = oldTypeName;
296 const_cast<word&
>(fieldDict.type()) = fieldDict.headerClassName();
306 const word& patchName = iter.key();
307 const word& newName = iter.val();
309 Info<<
"Looking for entry for patch " << patchName <<
endl;
316 boundaryField.
found(patchName)
317 && !boundaryField.
found(newName, keyType::LITERAL)
320 Info<<
" Changing entry " << patchName <<
" to " << newName
325 if (patchDict.
found(
"value"))
328 patchDict.
remove(
"value");
338 Info<<
" Adding entry " << nbrNames[patchName] <<
endl;
354 if (
mvBak(fieldDict.objectPath(),
"old"))
357 << (fieldDict.objectPath() +
".old") << nl;
361 << fieldDict.objectPath() <<
endl;
362 fieldDict.regIOobject::write();
367 Info<<
"No changes made to field " << fieldName <<
endl;
382 for (
const word& fieldName : fieldNames)
397int main(
int argc,
char *argv[])
401 "Tool to upgrade mesh and fields for split cyclics"
404 timeSelector::addOptions();
406 argList::addOptionCompat(
"dry-run", {
"test", 1806});
407 argList::addDryRunOption
409 "Test only do not change any files"
411 argList::addBoolOption
413 "enableFunctionEntries",
414 "Enable expansion of dictionary directives - #include, #codeStream etc"
424 IOobject::fileModificationChecking = IOobject::timeStamp;
429 const bool dryrun =
args.
found(
"dry-run");
432 Info<<
"-dry-run option: no changes made" <<
nl <<
endl;
434 const bool enableEntries =
args.
found(
"enableFunctionEntries");
455 polyMesh::meshSubDir,
480 runTime.setTime(timeDirs[timeI], timeI);
489 polyMesh::meshSubDir,
512 const int oldFlag = entry::disableFunctionEntries;
516 entry::disableFunctionEntries = 1;
526 objects.names(volScalarField::typeName),
534 objects.names(volVectorField::typeName),
542 objects.names(volSphericalTensorField::typeName),
550 objects.names(volSymmTensorField::typeName),
558 objects.names(volTensorField::typeName),
571 objects.names(pointScalarField::typeName),
579 objects.names(pointVectorField::typeName),
587 objects.names(pointSphericalTensorField::typeName),
595 objects.names(pointSymmTensorField::typeName),
603 objects.names(pointTensorField::typeName),
616 objects.names(surfaceScalarField::typeName),
624 objects.names(surfaceVectorField::typeName),
632 objects.names(surfaceSphericalTensorField::typeName),
640 objects.names(surfaceSymmTensorField::typeName),
648 objects.names(surfaceTensorField::typeName),
653 entry::disableFunctionEntries = oldFlag;
label size_type
The type to represent the size of a buffer.
A HashTable similar to std::unordered_map.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
A PtrList of objects of type <T> with automated input and output.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
List of IOobjects with searching and retrieving facilities.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
bool found(const word &optName) const
Return true if the named option is found.
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
A keyword and a list of tokens is a 'dictionaryEntry'.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
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.
bool remove(const word &keyword)
Remove an entry specified by keyword.
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
A class for handling file names.
A class for handling words, derived from Foam::string.
#define defineTemplateTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information for templates, useful.
const polyBoundaryMesh & patches
Foam::word regionName(Foam::polyMesh::defaultRegion)
const labelList nFaces(UPstream::listGatherValues< label >(aMesh.nFaces()))
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool mvBak(const fileName &src, const std::string &ext="bak")
Rename to a corresponding backup file.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
constexpr char nl
The newline '\n' character (0x0a)
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.