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;
119 label nOldPatches =
patches.size();
120 patches.setSize(nOldPatches+nOldCyclics);
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++;
148 string::size_type i =
name.rfind(
"_half0");
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++;
251 << (
patches.objectPath() +
".old") <<
nl;
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;
374int 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"
405 const bool dryrun =
args.dryRun();
408 Info<<
"-dry-run option: no changes made" <<
nl <<
endl;
410 const bool enableEntries =
args.found(
"enableFunctionEntries");
454 runTime.setTime(timeDirs[timei], timei);
496 #define rewriteFields(FieldType) \
497 for (const word& fieldName : objects.sortedNames<FieldType>()) \
499 rewriteField(dryrun, runTime, fieldName, thisNames, nbrNames); \
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. Implemented as a HashTable,...
@ NO_REGISTER
Do not request registration (bool: false).
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
static fileCheckTypes fileModificationChecking
Type of file modification checking.
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.
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 addNote(const string ¬e)
Add extra notes for the usage information.
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
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
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
Find 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.
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
static int disableFunctionEntries
Enable or disable use of function entries and variable expansions.
A class for handling file names.
static const word & regionName(const word ®ion)
The mesh region name or word::null if polyMesh::defaultRegion.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh").
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 defineTemplateTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information for templates, useful.
const polyBoundaryMesh & patches
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
GeometricField< vector, fvsPatchField, surfaceMesh > surfaceVectorField
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
GeometricField< vector, fvPatchField, volMesh > volVectorField
GeometricField< tensor, pointPatchField, pointMesh > pointTensorField
GeometricField< scalar, pointPatchField, pointMesh > pointScalarField
List< label > labelList
A List of labels.
GeometricField< sphericalTensor, pointPatchField, pointMesh > pointSphericalTensorField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
messageStream Info
Information stream (stdout output on master, null elsewhere).
GeometricField< vector, pointPatchField, pointMesh > pointVectorField
List< instant > instantList
List of instants.
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
GeometricField< symmTensor, pointPatchField, pointMesh > pointSymmTensorField
Ostream & endl(Ostream &os)
Add newline and flush stream.
GeometricField< tensor, fvPatchField, volMesh > volTensorField
GeometricField< tensor, fvsPatchField, surfaceMesh > surfaceTensorField
GeometricField< sphericalTensor, fvPatchField, volMesh > volSphericalTensorField
GeometricField< sphericalTensor, fvsPatchField, surfaceMesh > surfaceSphericalTensorField
GeometricField< symmTensor, fvPatchField, volMesh > volSymmTensorField
bool mvBak(const fileName &src, const std::string &ext="bak")
Rename to a corresponding backup file.
GeometricField< symmTensor, fvsPatchField, surfaceMesh > surfaceSymmTensorField
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.