foamDictionary: Added support for reading files as case IOdictionary in parallel
If the -case option is specified time is created from the case
system/controlDict enabling support for parallel operation, e.g.
mpirun -np 4 \
foamDictionary -case . 0/U -entry boundaryField.movingWall.value \
-set "uniform (2 0 0)" \
-parallel
This will read and modify the 0/U field file from the processor directories even
if it is collated. To also write the 0/U file in collated format the collated
fileHandler can be specified, e.g.
mpirun -np 4 \
foamDictionary -case . 0/U -entry boundaryField.movingWall.value \
-set "uniform (2 0 0)" \
-fileHandler collated -parallel
This provides functionality for field manipulation equivalent to that provided
by the deprecated changeDictionary utility but in a more flexible and efficient
manner and with the support of fileHandlers for collated parallel operation.
This commit is contained in:
@ -29,6 +29,21 @@ Description
|
|||||||
|
|
||||||
Usage
|
Usage
|
||||||
\b foamDictionary [OPTION] dictionary
|
\b foamDictionary [OPTION] dictionary
|
||||||
|
- \par -case \<dir\>
|
||||||
|
Select a case directory,
|
||||||
|
required to process decomposed fields in parallel cases
|
||||||
|
|
||||||
|
- \par -parallel
|
||||||
|
Specify case as a parallel job
|
||||||
|
|
||||||
|
- \par -doc
|
||||||
|
Display the documentation in browser
|
||||||
|
|
||||||
|
- \par -srcDoc
|
||||||
|
Display the source documentation in browser
|
||||||
|
|
||||||
|
- \par -help
|
||||||
|
Print the usage
|
||||||
|
|
||||||
- \par -entry \<name\>
|
- \par -entry \<name\>
|
||||||
Selects an entry
|
Selects an entry
|
||||||
@ -88,6 +103,13 @@ Usage
|
|||||||
-set "uniform (2 0 0)"
|
-set "uniform (2 0 0)"
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
|
- Change bc parameter in parallel:
|
||||||
|
\verbatim
|
||||||
|
mpirun -np 4 foamDictionary -case . 0/U \
|
||||||
|
-entry boundaryField.movingWall.value \
|
||||||
|
-set "uniform (2 0 0)" -parallel
|
||||||
|
\endverbatim
|
||||||
|
|
||||||
- Change whole bc type:
|
- Change whole bc type:
|
||||||
\verbatim
|
\verbatim
|
||||||
foamDictionary 0/U -entry boundaryField.movingWall \
|
foamDictionary 0/U -entry boundaryField.movingWall \
|
||||||
@ -118,7 +140,8 @@ Usage
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "argList.H"
|
#include "argList.H"
|
||||||
#include "IOobject.H"
|
#include "Time.H"
|
||||||
|
#include "localIOdictionary.H"
|
||||||
#include "Pair.H"
|
#include "Pair.H"
|
||||||
#include "IFstream.H"
|
#include "IFstream.H"
|
||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
@ -290,8 +313,6 @@ void remove(dictionary& dict, const dictionary& removeDict)
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
#include "removeCaseOptions.H"
|
|
||||||
|
|
||||||
writeInfoHeader = false;
|
writeInfoHeader = false;
|
||||||
|
|
||||||
argList::addNote("manipulates dictionaries");
|
argList::addNote("manipulates dictionaries");
|
||||||
@ -360,7 +381,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (listIncludes)
|
if (listIncludes)
|
||||||
{
|
{
|
||||||
Foam::functionEntries::includeEntry::log = true;
|
functionEntries::includeEntry::log = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.optionFound("disableFunctionEntries"))
|
if (args.optionFound("disableFunctionEntries"))
|
||||||
@ -368,10 +389,49 @@ int main(int argc, char *argv[])
|
|||||||
entry::disableFunctionEntries = true;
|
entry::disableFunctionEntries = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const fileName dictFileName(args[1]);
|
const fileName dictFileName(args[1]);
|
||||||
dictionary dict;
|
|
||||||
IOstream::streamFormat dictFormat = readDict(dict, dictFileName);
|
Time* runTimePtr = nullptr;
|
||||||
|
localIOdictionary* localDictPtr = nullptr;
|
||||||
|
|
||||||
|
dictionary* dictPtr = nullptr;
|
||||||
|
IOstream::streamFormat dictFormat = IOstream::ASCII;
|
||||||
|
|
||||||
|
// If the case option is specified read the dictionary as a
|
||||||
|
// case localIOdictionary supporting parallel operation and file handlers
|
||||||
|
if (args.optionFound("case"))
|
||||||
|
{
|
||||||
|
if (!args.checkRootCase())
|
||||||
|
{
|
||||||
|
FatalError.exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
runTimePtr = new Time(Time::controlDictName, args);
|
||||||
|
|
||||||
|
const word oldTypeName = localIOdictionary::typeName;
|
||||||
|
const_cast<word&>(localIOdictionary::typeName) = word::null;
|
||||||
|
|
||||||
|
localDictPtr = new localIOdictionary
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
dictFileName,
|
||||||
|
*runTimePtr,
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::NO_WRITE,
|
||||||
|
false
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
const_cast<word&>(localIOdictionary::typeName) = oldTypeName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dictPtr = new dictionary;
|
||||||
|
dictFormat = readDict(*dictPtr, dictFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
dictionary& dict = localDictPtr ? *localDictPtr : *dictPtr;
|
||||||
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
@ -383,7 +443,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
IOobject::writeBanner(Info)
|
IOobject::writeBanner(Info)
|
||||||
<<"//\n// " << dictFileName << "\n//\n";
|
<<"//\n// " << dictFileName << "\n//\n";
|
||||||
dict.write(Info, false);
|
dict.dictionary::write(Info, false);
|
||||||
IOobject::writeDivider(Info);
|
IOobject::writeDivider(Info);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -581,20 +641,31 @@ int main(int argc, char *argv[])
|
|||||||
else if (args.optionFound("diff"))
|
else if (args.optionFound("diff"))
|
||||||
{
|
{
|
||||||
remove(dict, diffDict);
|
remove(dict, diffDict);
|
||||||
dict.write(Info, false);
|
dict.dictionary::write(Info, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dict.write(Info, false);
|
dict.dictionary::write(Info, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed)
|
if (changed)
|
||||||
|
{
|
||||||
|
if (localDictPtr)
|
||||||
|
{
|
||||||
|
localDictPtr->regIOobject::write();
|
||||||
|
}
|
||||||
|
else if (dictPtr)
|
||||||
{
|
{
|
||||||
OFstream os(dictFileName, dictFormat);
|
OFstream os(dictFileName, dictFormat);
|
||||||
IOobject::writeBanner(os);
|
IOobject::writeBanner(os);
|
||||||
dict.write(os, false);
|
dictPtr->write(os, false);
|
||||||
IOobject::writeEndDivider(os);
|
IOobject::writeEndDivider(os);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delete dictPtr;
|
||||||
|
delete localDictPtr;
|
||||||
|
delete runTimePtr;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user