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;
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);
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);
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;
191 patches.
set(patchi, oldPatches.set(patchi,
nullptr));
192 oldToNew[patchi] = newPatchi++;
194 thisPatchDict.
add(
"neighbourPatch", nbrName);
195 thisPatchDict.
set(
"nFaces", nFaces/2);
196 patches[patchi].keyword() = thisName;
209 oldToNew[addedPatchi] = newPatchi++;
211 nbrPatchDict.
set(
"neighbourPatch", thisName);
212 nbrPatchDict.
set(
"nFaces", nFaces/2);
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++;
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;
294 const_cast<word&
>(IOdictionary::typeName) = oldTypeName;
296 const_cast<word&
>(fieldDict.type()) = fieldDict.headerClassName();
302 bool hasChange =
false;
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)
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)
397 int main(
int argc,
char *argv[])
401 "Tool to upgrade mesh and fields for split cyclics" 409 "Test only do not change any files" 413 "enableFunctionEntries",
414 "Enable expansion of dictionary directives - #include, #codeStream etc" 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");
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...
constexpr char nl
The newline '\n' character (0x0a)
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
wordList names() const
The unsorted names of all objects.
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.
static void addOptionCompat(const word &optName, std::pair< const char *, int > compat)
Specify an alias for the option name.
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.
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'.
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.
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.
Foam::word regionName(Foam::polyMesh::defaultRegion)
static int disableFunctionEntries
Enable or disable use of function entries and variable expansions.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for 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.
Reading required, file watched for runTime modification.
static word defaultRegion
Return the default region name.
label size() const noexcept
The number of elements in the list.
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
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 (uses typeFilePath to find file) and check its info.
static word timeName(const scalar t, const int precision=precision_)
Return time name of given scalar time 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()
const word typeName("volScalarField::Internal")
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.
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.
bool changeKeyword(const keyType &oldKeyword, const keyType &newKeyword, bool overwrite=false)
Change the keyword for an entry,.
virtual bool write(const bool valid=true) const
Write using setting from DB.
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...
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)