mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop
This commit is contained in:
@ -50,17 +50,6 @@ namespace functionObjects
|
||||
}
|
||||
}
|
||||
|
||||
const Foam::Enum<Foam::functionObjects::externalCoupled::stateEnd>
|
||||
Foam::functionObjects::externalCoupled::stateEndNames_
|
||||
{
|
||||
{ stateEnd::REMOVE, "remove" },
|
||||
{ stateEnd::DONE, "done" }
|
||||
// 'IGNORE' is internal use only and thus without a name
|
||||
};
|
||||
|
||||
|
||||
Foam::word Foam::functionObjects::externalCoupled::lockName = "OpenFOAM";
|
||||
|
||||
Foam::string Foam::functionObjects::externalCoupled::patchKey = "// Patch:";
|
||||
|
||||
|
||||
@ -96,15 +85,6 @@ static void writeList(Ostream& os, const string& header, const UList<T>& L)
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::fileName Foam::functionObjects::externalCoupled::baseDir() const
|
||||
{
|
||||
fileName result(commsDir_);
|
||||
result.clean();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Foam::fileName Foam::functionObjects::externalCoupled::groupDir
|
||||
(
|
||||
const fileName& commsDir,
|
||||
@ -124,171 +104,6 @@ Foam::fileName Foam::functionObjects::externalCoupled::groupDir
|
||||
}
|
||||
|
||||
|
||||
Foam::fileName Foam::functionObjects::externalCoupled::lockFile() const
|
||||
{
|
||||
return fileName(baseDir()/(lockName + ".lock"));
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::externalCoupled::useMaster() const
|
||||
{
|
||||
if (Pstream::master())
|
||||
{
|
||||
const fileName lck(lockFile());
|
||||
|
||||
// Only create lock file if it doesn't already exist
|
||||
if (!Foam::isFile(lck))
|
||||
{
|
||||
Log << type() << ": creating lock file" << endl;
|
||||
|
||||
OFstream os(lck);
|
||||
os << "status=openfoam\n";
|
||||
os.flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::externalCoupled::useSlave() const
|
||||
{
|
||||
if (Pstream::master())
|
||||
{
|
||||
Log << type() << ": removing lock file" << endl;
|
||||
|
||||
Foam::rm(lockFile());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::externalCoupled::cleanup() const
|
||||
{
|
||||
if (Pstream::master())
|
||||
{
|
||||
const fileName lck(lockFile());
|
||||
switch (stateEnd_)
|
||||
{
|
||||
case REMOVE:
|
||||
{
|
||||
Log << type() << ": removing lock file" << endl;
|
||||
Foam::rm(lck);
|
||||
break;
|
||||
}
|
||||
case DONE:
|
||||
{
|
||||
Log << type() << ": lock file status=done" << endl;
|
||||
OFstream os(lck);
|
||||
os << "status=done\n";
|
||||
os.flush();
|
||||
break;
|
||||
}
|
||||
case IGNORE:
|
||||
break;
|
||||
}
|
||||
|
||||
stateEnd_ = IGNORE; // Avoid re-triggering in destructor
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::externalCoupled::removeDataSlave() const
|
||||
{
|
||||
if (!Pstream::master())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Log << type() << ": removing data files written by slave" << nl;
|
||||
|
||||
forAll(regionGroupNames_, regioni)
|
||||
{
|
||||
const word& compName = regionGroupNames_[regioni];
|
||||
|
||||
const labelList& groups = regionToGroups_[compName];
|
||||
forAll(groups, i)
|
||||
{
|
||||
label groupi = groups[i];
|
||||
const wordRe& groupName = groupNames_[groupi];
|
||||
|
||||
forAll(groupReadFields_[groupi], fieldi)
|
||||
{
|
||||
const word& fieldName = groupReadFields_[groupi][fieldi];
|
||||
rm
|
||||
(
|
||||
groupDir(commsDir_, compName, groupName)
|
||||
/ fieldName + ".in"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::externalCoupled::removeDataMaster() const
|
||||
{
|
||||
if (!Pstream::master())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Log << type() << ": removing data files written by master" << nl;
|
||||
|
||||
forAll(regionGroupNames_, regioni)
|
||||
{
|
||||
const word& compName = regionGroupNames_[regioni];
|
||||
|
||||
const labelList& groups = regionToGroups_[compName];
|
||||
forAll(groups, i)
|
||||
{
|
||||
label groupi = groups[i];
|
||||
const wordRe& groupName = groupNames_[groupi];
|
||||
|
||||
forAll(groupReadFields_[groupi], fieldi)
|
||||
{
|
||||
const word& fieldName = groupReadFields_[groupi][fieldi];
|
||||
rm
|
||||
(
|
||||
groupDir(commsDir_, compName, groupName)
|
||||
/ fieldName + ".out"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::externalCoupled::waitForSlave() const
|
||||
{
|
||||
bool waiting = true;
|
||||
if (Pstream::master())
|
||||
{
|
||||
const fileName lck(lockFile());
|
||||
unsigned totalTime = 0;
|
||||
|
||||
Log << type() << ": beginning wait for lock file " << lck << nl;
|
||||
|
||||
while ((waiting = !Foam::isFile(lck)) == true)
|
||||
{
|
||||
sleep(waitInterval_);
|
||||
totalTime += waitInterval_;
|
||||
|
||||
if (timeOut_ && totalTime > timeOut_)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Wait time exceeded timeout of " << timeOut_
|
||||
<< " s" << abort(FatalError);
|
||||
}
|
||||
|
||||
Log << type() << ": wait time = " << totalTime << endl;
|
||||
}
|
||||
|
||||
Log << type() << ": found lock file " << lck << endl;
|
||||
}
|
||||
|
||||
// MPI barrier
|
||||
Pstream::scatter(waiting);
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::externalCoupled::readColumns
|
||||
(
|
||||
const label nRows,
|
||||
@ -462,21 +277,19 @@ void Foam::functionObjects::externalCoupled::writeGeometry
|
||||
|
||||
labelList pointToGlobal;
|
||||
labelList uniquePointIDs;
|
||||
forAll(meshes, meshi)
|
||||
for (const fvMesh& mesh : meshes)
|
||||
{
|
||||
const fvMesh& mesh = meshes[meshi];
|
||||
|
||||
const labelList patchIDs
|
||||
(
|
||||
mesh.boundaryMesh().patchSet
|
||||
(
|
||||
List<wordRe>(1, groupName)
|
||||
List<wordRe>{groupName}
|
||||
).sortedToc()
|
||||
);
|
||||
|
||||
forAll(patchIDs, i)
|
||||
for (const label patchi : patchIDs)
|
||||
{
|
||||
const polyPatch& p = mesh.boundaryMesh()[patchIDs[i]];
|
||||
const polyPatch& p = mesh.boundaryMesh()[patchi];
|
||||
|
||||
mesh.globalData().mergePoints
|
||||
(
|
||||
@ -589,207 +402,62 @@ void Foam::functionObjects::externalCoupled::checkOrder
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::externalCoupled::readData()
|
||||
void Foam::functionObjects::externalCoupled::initCoupling()
|
||||
{
|
||||
forAll(regionGroupNames_, regioni)
|
||||
{
|
||||
const word& compName = regionGroupNames_[regioni];
|
||||
const wordList& regionNames = regionGroupRegions_[regioni];
|
||||
|
||||
// Get the meshes for the region-group
|
||||
UPtrList<const fvMesh> meshes(regionNames.size());
|
||||
forAll(regionNames, j)
|
||||
{
|
||||
const word& regionName = regionNames[j];
|
||||
meshes.set(j, &time_.lookupObject<fvMesh>(regionName));
|
||||
}
|
||||
|
||||
const labelList& groups = regionToGroups_[compName];
|
||||
|
||||
forAll(groups, i)
|
||||
{
|
||||
label groupi = groups[i];
|
||||
const wordRe& groupName = groupNames_[groupi];
|
||||
const wordList& fieldNames = groupReadFields_[groupi];
|
||||
|
||||
forAll(fieldNames, fieldi)
|
||||
{
|
||||
const word& fieldName = fieldNames[fieldi];
|
||||
|
||||
const bool ok =
|
||||
(
|
||||
readData<scalar>
|
||||
(
|
||||
meshes,
|
||||
groupName,
|
||||
fieldName
|
||||
)
|
||||
|| readData<vector>
|
||||
(
|
||||
meshes,
|
||||
groupName,
|
||||
fieldName
|
||||
)
|
||||
|| readData<sphericalTensor>
|
||||
(
|
||||
meshes,
|
||||
groupName,
|
||||
fieldName
|
||||
)
|
||||
|| readData<symmTensor>
|
||||
(
|
||||
meshes,
|
||||
groupName,
|
||||
fieldName
|
||||
)
|
||||
|| readData<tensor>
|
||||
(
|
||||
meshes,
|
||||
groupName,
|
||||
fieldName
|
||||
)
|
||||
);
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Field " << fieldName << " in regions " << compName
|
||||
<< " was not found." << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::externalCoupled::writeData() const
|
||||
{
|
||||
forAll(regionGroupNames_, regioni)
|
||||
{
|
||||
const word& compName = regionGroupNames_[regioni];
|
||||
const wordList& regionNames = regionGroupRegions_[regioni];
|
||||
|
||||
// Get the meshes for the region-group
|
||||
UPtrList<const fvMesh> meshes(regionNames.size());
|
||||
forAll(regionNames, j)
|
||||
{
|
||||
const word& regionName = regionNames[j];
|
||||
meshes.set(j, &time_.lookupObject<fvMesh>(regionName));
|
||||
}
|
||||
|
||||
const labelList& groups = regionToGroups_[compName];
|
||||
|
||||
forAll(groups, i)
|
||||
{
|
||||
label groupi = groups[i];
|
||||
const wordRe& groupName = groupNames_[groupi];
|
||||
const wordList& fieldNames = groupWriteFields_[groupi];
|
||||
|
||||
forAll(fieldNames, fieldi)
|
||||
{
|
||||
const word& fieldName = fieldNames[fieldi];
|
||||
|
||||
const bool ok =
|
||||
(
|
||||
writeData<scalar>
|
||||
(
|
||||
meshes,
|
||||
groupName,
|
||||
fieldName
|
||||
)
|
||||
|| writeData<vector>
|
||||
(
|
||||
meshes,
|
||||
groupName,
|
||||
fieldName
|
||||
)
|
||||
|| writeData<sphericalTensor>
|
||||
(
|
||||
meshes,
|
||||
groupName,
|
||||
fieldName
|
||||
)
|
||||
|| writeData<symmTensor>
|
||||
(
|
||||
meshes,
|
||||
groupName,
|
||||
fieldName
|
||||
)
|
||||
|| writeData<tensor>
|
||||
(
|
||||
meshes,
|
||||
groupName,
|
||||
fieldName
|
||||
)
|
||||
);
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Field " << fieldName << " in regions " << compName
|
||||
<< " was not found." << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::externalCoupled::initialise()
|
||||
{
|
||||
if (initialised_)
|
||||
if (initialisedCoupling_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Write the geometry if not already there
|
||||
forAll(regionGroupRegions_, i)
|
||||
forAll(regionGroupNames_, regioni)
|
||||
{
|
||||
const word& compName = regionGroupNames_[i];
|
||||
const wordList& regionNames = regionGroupRegions_[i];
|
||||
const word& compName = regionGroupNames_[regioni];
|
||||
const wordList& regionNames = regionGroupRegions_[regioni];
|
||||
|
||||
// Get the meshes for the region-group
|
||||
UPtrList<const fvMesh> meshes(regionNames.size());
|
||||
forAll(regionNames, j)
|
||||
forAll(regionNames, regi)
|
||||
{
|
||||
const word& regionName = regionNames[j];
|
||||
meshes.set(j, &time_.lookupObject<fvMesh>(regionName));
|
||||
const word& regionName = regionNames[regi];
|
||||
meshes.set(regi, &time_.lookupObject<fvMesh>(regionName));
|
||||
}
|
||||
|
||||
const labelList& groups = regionToGroups_[compName];
|
||||
|
||||
forAll(groups, i)
|
||||
for (const label groupi : groups)
|
||||
{
|
||||
label groupi = groups[i];
|
||||
const wordRe& groupName = groupNames_[groupi];
|
||||
|
||||
bool exists = false;
|
||||
bool geomExists = false;
|
||||
if (Pstream::master())
|
||||
{
|
||||
fileName dir(groupDir(commsDir_, compName, groupName));
|
||||
fileName dir(groupDir(commDirectory(), compName, groupName));
|
||||
|
||||
exists =
|
||||
geomExists =
|
||||
isFile(dir/"patchPoints")
|
||||
|| isFile(dir/"patchFaces");
|
||||
}
|
||||
|
||||
if (!returnReduce(exists, orOp<bool>()))
|
||||
Pstream::scatter(geomExists);
|
||||
|
||||
if (!geomExists)
|
||||
{
|
||||
writeGeometry(meshes, commsDir_, groupName);
|
||||
writeGeometry(meshes, commDirectory(), groupName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (slaveFirst_)
|
||||
if (slaveFirst())
|
||||
{
|
||||
// Wait for initial data to be made available
|
||||
waitForSlave();
|
||||
|
||||
// Read data passed back from external source
|
||||
readData();
|
||||
readDataMaster();
|
||||
}
|
||||
|
||||
initialised_ = true;
|
||||
initialisedCoupling_ = true;
|
||||
}
|
||||
|
||||
|
||||
@ -803,18 +471,13 @@ Foam::functionObjects::externalCoupled::externalCoupled
|
||||
)
|
||||
:
|
||||
functionObject(name),
|
||||
externalFileCoupler(),
|
||||
time_(runTime),
|
||||
stateEnd_(REMOVE),
|
||||
initialised_(false)
|
||||
initialisedCoupling_(false)
|
||||
{
|
||||
read(dict);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
mkDir(baseDir());
|
||||
}
|
||||
|
||||
if (!slaveFirst_)
|
||||
if (!slaveFirst())
|
||||
{
|
||||
useMaster();
|
||||
}
|
||||
@ -824,22 +487,20 @@ Foam::functionObjects::externalCoupled::externalCoupled
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::externalCoupled::~externalCoupled()
|
||||
{
|
||||
cleanup();
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::externalCoupled::execute()
|
||||
{
|
||||
if (!initialised_ || time_.timeIndex() % calcFrequency_ == 0)
|
||||
if (!initialisedCoupling_ || time_.timeIndex() % calcFrequency_ == 0)
|
||||
{
|
||||
// Initialise the coupling
|
||||
initialise();
|
||||
initCoupling();
|
||||
|
||||
// Write data for external source
|
||||
writeData();
|
||||
writeDataMaster();
|
||||
|
||||
// Signal external source to execute (by removing lock file)
|
||||
// - Wait for slave to provide data
|
||||
@ -852,7 +513,7 @@ bool Foam::functionObjects::externalCoupled::execute()
|
||||
removeDataMaster();
|
||||
|
||||
// Read data passed back from external source
|
||||
readData();
|
||||
readDataMaster();
|
||||
|
||||
// Signal external source to wait (by creating the lock file)
|
||||
useMaster();
|
||||
@ -873,7 +534,7 @@ bool Foam::functionObjects::externalCoupled::end()
|
||||
// Remove old data files
|
||||
removeDataMaster();
|
||||
removeDataSlave();
|
||||
cleanup();
|
||||
shutdown();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -882,33 +543,10 @@ bool Foam::functionObjects::externalCoupled::end()
|
||||
bool Foam::functionObjects::externalCoupled::read(const dictionary& dict)
|
||||
{
|
||||
functionObject::read(dict);
|
||||
|
||||
// NB: Cannot change directory or initialization
|
||||
// if things have already been initialized
|
||||
if (!initialised_)
|
||||
{
|
||||
dict.lookup("commsDir") >> commsDir_;
|
||||
commsDir_.expand();
|
||||
commsDir_.clean();
|
||||
|
||||
slaveFirst_ = readBool(dict.lookup("initByExternal"));
|
||||
// slaveFirst_ = dict.lookupOrDefault<bool>("initByExternal", false);
|
||||
}
|
||||
externalFileCoupler::readDict(dict);
|
||||
|
||||
calcFrequency_ = dict.lookupOrDefault("calcFrequency", 1);
|
||||
|
||||
waitInterval_ = dict.lookupOrDefault("waitInterval", 1u);
|
||||
if (!waitInterval_)
|
||||
{
|
||||
// Enforce non-zero sleep
|
||||
waitInterval_ = 1u;
|
||||
}
|
||||
|
||||
timeOut_ = dict.lookupOrDefault("timeOut", 100*waitInterval_);
|
||||
stateEnd_ =
|
||||
stateEndNames_.lookupOrDefault("stateEnd", dict, stateEnd::DONE);
|
||||
|
||||
|
||||
// Get names of all fvMeshes (and derived types)
|
||||
wordList allRegionNames(time_.lookupClass<fvMesh>().sortedToc());
|
||||
|
||||
@ -957,7 +595,7 @@ bool Foam::functionObjects::externalCoupled::read(const dictionary& dict)
|
||||
regionToGroups_.insert
|
||||
(
|
||||
regionGroupNames_.last(),
|
||||
labelList(1, nGroups)
|
||||
labelList{nGroups}
|
||||
);
|
||||
}
|
||||
groupNames_.append(groupName);
|
||||
@ -968,16 +606,12 @@ bool Foam::functionObjects::externalCoupled::read(const dictionary& dict)
|
||||
|
||||
|
||||
Info<< type() << ": Communicating with regions:" << endl;
|
||||
forAll(regionGroupNames_, rgi)
|
||||
for (const word& compName : regionGroupNames_)
|
||||
{
|
||||
//const wordList& regionNames = regionGroupRegions_[rgi];
|
||||
const word& compName = regionGroupNames_[rgi];
|
||||
|
||||
Info<< "Region: " << compName << endl << incrIndent;
|
||||
const labelList& groups = regionToGroups_[compName];
|
||||
forAll(groups, i)
|
||||
for (const label groupi : groups)
|
||||
{
|
||||
label groupi = groups[i];
|
||||
const wordRe& groupName = groupNames_[groupi];
|
||||
|
||||
Info<< indent << "patchGroup: " << groupName << "\t"
|
||||
@ -1000,17 +634,15 @@ bool Foam::functionObjects::externalCoupled::read(const dictionary& dict)
|
||||
// should already be written - but just make sure
|
||||
if (Pstream::master())
|
||||
{
|
||||
forAll(regionGroupNames_, rgi)
|
||||
for (const word& compName : regionGroupNames_)
|
||||
{
|
||||
const word& compName = regionGroupNames_[rgi];
|
||||
|
||||
const labelList& groups = regionToGroups_[compName];
|
||||
forAll(groups, i)
|
||||
for (const label groupi : groups)
|
||||
{
|
||||
label groupi = groups[i];
|
||||
const wordRe& groupName = groupNames_[groupi];
|
||||
|
||||
fileName dir(groupDir(commsDir_, compName, groupName));
|
||||
fileName dir(groupDir(commDirectory(), compName, groupName));
|
||||
|
||||
if (!isDir(dir))
|
||||
{
|
||||
Log << type() << ": creating communications directory "
|
||||
@ -1025,6 +657,156 @@ bool Foam::functionObjects::externalCoupled::read(const dictionary& dict)
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::externalCoupled::readDataMaster()
|
||||
{
|
||||
forAll(regionGroupNames_, regioni)
|
||||
{
|
||||
const word& compName = regionGroupNames_[regioni];
|
||||
const wordList& regionNames = regionGroupRegions_[regioni];
|
||||
|
||||
// Get the meshes for the region-group
|
||||
UPtrList<const fvMesh> meshes(regionNames.size());
|
||||
forAll(regionNames, j)
|
||||
{
|
||||
const word& regionName = regionNames[j];
|
||||
meshes.set(j, &time_.lookupObject<fvMesh>(regionName));
|
||||
}
|
||||
|
||||
const labelList& groups = regionToGroups_[compName];
|
||||
|
||||
for (const label groupi : groups)
|
||||
{
|
||||
const wordRe& groupName = groupNames_[groupi];
|
||||
const wordList& fieldNames = groupReadFields_[groupi];
|
||||
|
||||
for (const word& fieldName : fieldNames)
|
||||
{
|
||||
const bool ok =
|
||||
(
|
||||
readData<scalar>(meshes, groupName, fieldName)
|
||||
|| readData<vector>(meshes, groupName, fieldName)
|
||||
|| readData<sphericalTensor>(meshes, groupName, fieldName)
|
||||
|| readData<symmTensor>(meshes, groupName, fieldName)
|
||||
|| readData<tensor>(meshes, groupName, fieldName)
|
||||
);
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Field " << fieldName << " in regions " << compName
|
||||
<< " was not found." << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::externalCoupled::writeDataMaster() const
|
||||
{
|
||||
forAll(regionGroupNames_, regioni)
|
||||
{
|
||||
const word& compName = regionGroupNames_[regioni];
|
||||
const wordList& regionNames = regionGroupRegions_[regioni];
|
||||
|
||||
// Get the meshes for the region-group
|
||||
UPtrList<const fvMesh> meshes(regionNames.size());
|
||||
forAll(regionNames, j)
|
||||
{
|
||||
const word& regionName = regionNames[j];
|
||||
meshes.set(j, &time_.lookupObject<fvMesh>(regionName));
|
||||
}
|
||||
|
||||
const labelList& groups = regionToGroups_[compName];
|
||||
|
||||
for (const label groupi : groups)
|
||||
{
|
||||
const wordRe& groupName = groupNames_[groupi];
|
||||
const wordList& fieldNames = groupWriteFields_[groupi];
|
||||
|
||||
for (const word& fieldName : fieldNames)
|
||||
{
|
||||
const bool ok =
|
||||
(
|
||||
writeData<scalar>(meshes, groupName, fieldName)
|
||||
|| writeData<vector>(meshes, groupName, fieldName)
|
||||
|| writeData<sphericalTensor>(meshes, groupName, fieldName)
|
||||
|| writeData<symmTensor>(meshes, groupName, fieldName)
|
||||
|| writeData<tensor>(meshes, groupName, fieldName)
|
||||
);
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Field " << fieldName << " in regions " << compName
|
||||
<< " was not found." << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::externalCoupled::removeDataMaster() const
|
||||
{
|
||||
if (!Pstream::master())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Log << type() << ": removing data files written by master" << nl;
|
||||
|
||||
for (const word& compName : regionGroupNames_)
|
||||
{
|
||||
const labelList& groups = regionToGroups_[compName];
|
||||
for (const label groupi : groups)
|
||||
{
|
||||
const wordRe& groupName = groupNames_[groupi];
|
||||
const wordList& fieldNames = groupReadFields_[groupi];
|
||||
|
||||
for (const word& fieldName : fieldNames)
|
||||
{
|
||||
Foam::rm
|
||||
(
|
||||
groupDir(commDirectory(), compName, groupName)
|
||||
/ fieldName + ".out"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::externalCoupled::removeDataSlave() const
|
||||
{
|
||||
if (!Pstream::master())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Log << type() << ": removing data files written by slave" << nl;
|
||||
|
||||
for (const word& compName : regionGroupNames_)
|
||||
{
|
||||
const labelList& groups = regionToGroups_[compName];
|
||||
for (const label groupi : groups)
|
||||
{
|
||||
const wordRe& groupName = groupNames_[groupi];
|
||||
const wordList& fieldNames = groupReadFields_[groupi];
|
||||
|
||||
for (const word& fieldName : fieldNames)
|
||||
{
|
||||
Foam::rm
|
||||
(
|
||||
groupDir(commDirectory(), compName, groupName)
|
||||
/ fieldName + ".in"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::externalCoupled::write()
|
||||
{
|
||||
return true;
|
||||
|
||||
@ -42,7 +42,7 @@ Description
|
||||
|
||||
where the actual entries depend on the bc type:
|
||||
- mixed: value, snGrad, refValue, refGrad, valueFraction
|
||||
- externalCoupledMixed: output of writeData
|
||||
- externalCoupledMixed: output of writeDataMaster
|
||||
- other: value, snGrad
|
||||
|
||||
These text files are located in a user specified communications directory
|
||||
@ -146,6 +146,7 @@ SourceFiles
|
||||
#define functionObjects_externalCoupled_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "externalFileCoupler.H"
|
||||
#include "DynamicList.H"
|
||||
#include "wordReList.H"
|
||||
#include "scalarField.H"
|
||||
@ -171,7 +172,8 @@ namespace functionObjects
|
||||
|
||||
class externalCoupled
|
||||
:
|
||||
public functionObject
|
||||
public functionObject,
|
||||
public externalFileCoupler
|
||||
{
|
||||
public:
|
||||
|
||||
@ -190,30 +192,14 @@ private:
|
||||
//- State end names (NB, only selectable values itemized)
|
||||
static const Enum<stateEnd> stateEndNames_;
|
||||
|
||||
|
||||
// Private data
|
||||
|
||||
//- Reference to the time database
|
||||
const Time& time_;
|
||||
|
||||
//- Path to communications directory
|
||||
fileName commsDir_;
|
||||
|
||||
//- Interval time between checking for return data [s]
|
||||
unsigned waitInterval_;
|
||||
|
||||
//- Time out time [s]
|
||||
unsigned timeOut_;
|
||||
|
||||
//- Calculation frequency
|
||||
label calcFrequency_;
|
||||
|
||||
//- Flag to indicate values are initialised by external application
|
||||
bool slaveFirst_;
|
||||
|
||||
//- Lockfile state on termination
|
||||
mutable stateEnd stateEnd_;
|
||||
|
||||
//- Names of (composite) regions
|
||||
DynamicList<word> regionGroupNames_;
|
||||
|
||||
@ -232,8 +218,8 @@ private:
|
||||
// Per group the names of the fields to write
|
||||
DynamicList<wordList> groupWriteFields_;
|
||||
|
||||
//- Initialised flag
|
||||
bool initialised_;
|
||||
//- Initialised coupling
|
||||
bool initialisedCoupling_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
@ -246,32 +232,6 @@ private:
|
||||
const wordRe& groupName
|
||||
);
|
||||
|
||||
//- Return the file path to the base communications directory
|
||||
fileName baseDir() const;
|
||||
|
||||
//- Return the file path to the lock file
|
||||
fileName lockFile() const;
|
||||
|
||||
|
||||
//- Create lock file to indicate that OpenFOAM is in charge
|
||||
void useMaster() const;
|
||||
|
||||
//- Remove lock file to indicate that the external program is in charge
|
||||
void useSlave() const;
|
||||
|
||||
//- Remove lock file or status=done in lock.
|
||||
void cleanup() const;
|
||||
|
||||
//- Remove files written by OpenFOAM
|
||||
void removeDataMaster() const;
|
||||
|
||||
//- Remove files written by external code
|
||||
void removeDataSlave() const;
|
||||
|
||||
//- Wait for indication that the external program has supplied input
|
||||
// (ie, for the lock file to reappear).
|
||||
void waitForSlave() const;
|
||||
|
||||
|
||||
//- Read data for a single region, single field
|
||||
template<class Type>
|
||||
@ -281,8 +241,6 @@ private:
|
||||
const wordRe& groupName,
|
||||
const word& fieldName
|
||||
);
|
||||
//- Read data for all regions, all fields
|
||||
void readData();
|
||||
|
||||
//- Write data for a single region, single field
|
||||
template<class Type>
|
||||
@ -293,10 +251,7 @@ private:
|
||||
const word& fieldName
|
||||
) const;
|
||||
|
||||
//- Write data for all regions, all fields
|
||||
void writeData() const;
|
||||
|
||||
void initialise();
|
||||
void initCoupling();
|
||||
|
||||
//- Read (and distribute) scalar columns from stream. Every processor
|
||||
// gets nRows (= patch size) of these. Note: could make its argument
|
||||
@ -339,12 +294,12 @@ public:
|
||||
//- Runtime type information
|
||||
TypeName("externalCoupled");
|
||||
|
||||
//- Name of lock file (normally 'OpenFOAM.lock')
|
||||
static word lockName;
|
||||
|
||||
//- Name of patch key, e.g. '// Patch:' when looking for start of patch data
|
||||
static string patchKey;
|
||||
|
||||
//- Inherited variable for logging
|
||||
using functionObject::log;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
@ -378,6 +333,21 @@ public:
|
||||
virtual bool write();
|
||||
|
||||
|
||||
// File creation, removal
|
||||
|
||||
//- Write data files (all regions, all fields) from master (OpenFOAM)
|
||||
virtual void writeDataMaster() const;
|
||||
|
||||
//- Read data files (all regions, all fields) on master (OpenFOAM)
|
||||
virtual void readDataMaster();
|
||||
|
||||
//- Remove data files written by master (OpenFOAM)
|
||||
virtual void removeDataMaster() const;
|
||||
|
||||
//- Remove data files written by slave (external code)
|
||||
virtual void removeDataSlave() const;
|
||||
|
||||
|
||||
// Other
|
||||
|
||||
//- Create single name by appending words (in sorted order),
|
||||
|
||||
@ -33,7 +33,7 @@ License
|
||||
#include "mixedFvPatchFields.H"
|
||||
#include "fixedGradientFvPatchFields.H"
|
||||
#include "fixedValueFvPatchFields.H"
|
||||
#include "OStringStream.H"
|
||||
#include "StringStream.H"
|
||||
#include "globalIndex.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
@ -62,7 +62,7 @@ bool Foam::functionObjects::externalCoupled::readData
|
||||
{
|
||||
const fileName transferFile
|
||||
(
|
||||
groupDir(commsDir_, compositeName(regionNames), groupName)
|
||||
groupDir(commDirectory(), compositeName(regionNames), groupName)
|
||||
/ fieldName + ".in"
|
||||
);
|
||||
|
||||
@ -81,46 +81,40 @@ bool Foam::functionObjects::externalCoupled::readData
|
||||
|
||||
|
||||
label nFound = 0;
|
||||
forAll(meshes, i)
|
||||
for (const fvMesh& mesh : meshes)
|
||||
{
|
||||
const fvMesh& mesh = meshes[i];
|
||||
const volFieldType* vfptr =
|
||||
mesh.lookupObjectPtr<volFieldType>(fieldName);
|
||||
|
||||
if (!mesh.foundObject<volFieldType>(fieldName))
|
||||
if (!vfptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
nFound++;
|
||||
|
||||
const volFieldType& cvf = mesh.lookupObject<volFieldType>(fieldName);
|
||||
const typename volFieldType::Boundary& bf = cvf.boundaryField();
|
||||
|
||||
typename volFieldType::Boundary& bf =
|
||||
const_cast<volFieldType*>(vfptr)->boundaryFieldRef();
|
||||
|
||||
// Get the patches
|
||||
const labelList patchIDs
|
||||
(
|
||||
mesh.boundaryMesh().patchSet
|
||||
(
|
||||
List<wordRe>(1, groupName)
|
||||
List<wordRe>{groupName}
|
||||
).sortedToc()
|
||||
);
|
||||
|
||||
// Handle column-wise reading of patch data. Supports most easy types
|
||||
forAll(patchIDs, i)
|
||||
for (const label patchi : patchIDs)
|
||||
{
|
||||
label patchi = patchIDs[i];
|
||||
|
||||
if (isA<patchFieldType>(bf[patchi]))
|
||||
{
|
||||
// Explicit handling of externalCoupledMixed bcs - they
|
||||
// have specialised reading routines.
|
||||
|
||||
patchFieldType& pf = const_cast<patchFieldType&>
|
||||
patchFieldType& pf = refCast<patchFieldType>
|
||||
(
|
||||
refCast<const patchFieldType>
|
||||
(
|
||||
bf[patchi]
|
||||
)
|
||||
bf[patchi]
|
||||
);
|
||||
|
||||
// Read from master into local stream
|
||||
@ -141,6 +135,11 @@ bool Foam::functionObjects::externalCoupled::readData
|
||||
}
|
||||
else if (isA<mixedFvPatchField<Type>>(bf[patchi]))
|
||||
{
|
||||
mixedFvPatchField<Type>& pf = refCast<mixedFvPatchField<Type>>
|
||||
(
|
||||
bf[patchi]
|
||||
);
|
||||
|
||||
// Read columns from file for
|
||||
// value, snGrad, refValue, refGrad, valueFraction
|
||||
List<scalarField> data;
|
||||
@ -152,15 +151,6 @@ bool Foam::functionObjects::externalCoupled::readData
|
||||
data
|
||||
);
|
||||
|
||||
mixedFvPatchField<Type>& pf =
|
||||
const_cast<mixedFvPatchField<Type>&>
|
||||
(
|
||||
refCast<const mixedFvPatchField<Type>>
|
||||
(
|
||||
bf[patchi]
|
||||
)
|
||||
);
|
||||
|
||||
// Transfer read data to bc.
|
||||
// Skip value, snGrad
|
||||
direction columni = 2*pTraits<Type>::nComponents;
|
||||
@ -193,6 +183,9 @@ bool Foam::functionObjects::externalCoupled::readData
|
||||
}
|
||||
else if (isA<fixedGradientFvPatchField<Type>>(bf[patchi]))
|
||||
{
|
||||
fixedGradientFvPatchField<Type>& pf =
|
||||
refCast<fixedGradientFvPatchField<Type>>(bf[patchi]);
|
||||
|
||||
// Read columns for value and gradient
|
||||
List<scalarField> data;
|
||||
readColumns
|
||||
@ -203,15 +196,6 @@ bool Foam::functionObjects::externalCoupled::readData
|
||||
data
|
||||
);
|
||||
|
||||
fixedGradientFvPatchField<Type>& pf =
|
||||
const_cast<fixedGradientFvPatchField<Type>&>
|
||||
(
|
||||
refCast<const fixedGradientFvPatchField<Type>>
|
||||
(
|
||||
bf[patchi]
|
||||
)
|
||||
);
|
||||
|
||||
// Transfer gradient to bc
|
||||
Field<Type>& gradient = pf.gradient();
|
||||
for
|
||||
@ -234,6 +218,9 @@ bool Foam::functionObjects::externalCoupled::readData
|
||||
}
|
||||
else if (isA<fixedValueFvPatchField<Type>>(bf[patchi]))
|
||||
{
|
||||
fixedValueFvPatchField<Type>& pf =
|
||||
refCast<fixedValueFvPatchField<Type>>(bf[patchi]);
|
||||
|
||||
// Read columns for value only
|
||||
List<scalarField> data;
|
||||
readColumns
|
||||
@ -256,15 +243,6 @@ bool Foam::functionObjects::externalCoupled::readData
|
||||
value.replace(cmpt, data[cmpt]);
|
||||
}
|
||||
|
||||
fixedValueFvPatchField<Type>& pf =
|
||||
const_cast<fixedValueFvPatchField<Type>&>
|
||||
(
|
||||
refCast<const fixedValueFvPatchField<Type>>
|
||||
(
|
||||
bf[patchi]
|
||||
)
|
||||
);
|
||||
|
||||
pf == value;
|
||||
|
||||
// Update the value from the read coefficicient. Bypass any
|
||||
@ -280,7 +258,7 @@ bool Foam::functionObjects::externalCoupled::readData
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
initialised_ = true;
|
||||
initialisedCoupling_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -357,7 +335,7 @@ bool Foam::functionObjects::externalCoupled::writeData
|
||||
{
|
||||
const fileName transferFile
|
||||
(
|
||||
groupDir(commsDir_, compositeName(regionNames), groupName)
|
||||
groupDir(commDirectory(), compositeName(regionNames), groupName)
|
||||
/ fieldName + ".out"
|
||||
);
|
||||
|
||||
@ -379,35 +357,32 @@ bool Foam::functionObjects::externalCoupled::writeData
|
||||
|
||||
label nFound = 0;
|
||||
|
||||
forAll(meshes, i)
|
||||
for (const fvMesh& mesh : meshes)
|
||||
{
|
||||
const fvMesh& mesh = meshes[i];
|
||||
const volFieldType* vfptr =
|
||||
mesh.lookupObjectPtr<volFieldType>(fieldName);
|
||||
|
||||
if (!mesh.foundObject<volFieldType>(fieldName))
|
||||
if (!vfptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
nFound++;
|
||||
|
||||
const volFieldType& cvf = mesh.lookupObject<volFieldType>(fieldName);
|
||||
const typename volFieldType::Boundary& bf = cvf.boundaryField();
|
||||
|
||||
const typename volFieldType::Boundary& bf =
|
||||
vfptr->boundaryField();
|
||||
|
||||
// Get the patches
|
||||
const labelList patchIDs
|
||||
(
|
||||
mesh.boundaryMesh().patchSet
|
||||
(
|
||||
List<wordRe>(1, groupName)
|
||||
List<wordRe>{groupName}
|
||||
).sortedToc()
|
||||
);
|
||||
|
||||
// Handle column-wise writing of patch data. Supports most easy types
|
||||
forAll(patchIDs, i)
|
||||
for (const label patchi : patchIDs)
|
||||
{
|
||||
label patchi = patchIDs[i];
|
||||
|
||||
const globalIndex globalFaces(bf[patchi].size());
|
||||
|
||||
if (isA<patchFieldType>(bf[patchi]))
|
||||
|
||||
@ -37,18 +37,16 @@ const Foam::word Foam::functionObjects::fieldAverageItem::EXT_PRIME2MEAN
|
||||
"Prime2Mean"
|
||||
);
|
||||
|
||||
template<>
|
||||
const char* Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::fieldAverageItem::baseType,
|
||||
2
|
||||
>::names[] = { "iteration", "time"};
|
||||
|
||||
const Foam::NamedEnum
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::functionObjects::fieldAverageItem::baseType,
|
||||
2
|
||||
> Foam::functionObjects::fieldAverageItem::baseTypeNames_;
|
||||
Foam::functionObjects::fieldAverageItem::baseType
|
||||
>
|
||||
Foam::functionObjects::fieldAverageItem::baseTypeNames_
|
||||
{
|
||||
{ baseType::ITER, "iteration" },
|
||||
{ baseType::TIME, "time" },
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -50,7 +50,7 @@ SourceFiles
|
||||
#ifndef fieldAverageItem_H
|
||||
#define fieldAverageItem_H
|
||||
|
||||
#include "NamedEnum.H"
|
||||
#include "Enum.H"
|
||||
#include "Switch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -119,7 +119,7 @@ private:
|
||||
word prime2MeanFieldName_;
|
||||
|
||||
//- Averaging base type names
|
||||
static const NamedEnum<baseType, 2> baseTypeNames_;
|
||||
static const Enum<baseType> baseTypeNames_;
|
||||
|
||||
//- Averaging base type
|
||||
baseType base_;
|
||||
|
||||
@ -47,7 +47,7 @@ Foam::functionObjects::fieldAverageItem::fieldAverageItem(Istream& is)
|
||||
fieldName_ = entry.keyword();
|
||||
mean_ = readBool(entry.lookup("mean"));
|
||||
prime2Mean_ = readBool(entry.lookup("prime2Mean"));
|
||||
base_ = baseTypeNames_[entry.lookup("base")];
|
||||
base_ = baseTypeNames_.lookup("base", entry);
|
||||
window_ = entry.lookupOrDefault<scalar>("window", -1.0);
|
||||
windowName_ = entry.lookupOrDefault<word>("windowName", "");
|
||||
|
||||
@ -77,7 +77,7 @@ Foam::Istream& Foam::functionObjects::operator>>
|
||||
faItem.fieldName_ = entry.keyword();
|
||||
faItem.mean_ = readBool(entry.lookup("mean"));
|
||||
faItem.prime2Mean_ = readBool(entry.lookup("prime2Mean"));
|
||||
faItem.base_ = faItem.baseTypeNames_[entry.lookup("base")];
|
||||
faItem.base_ = faItem.baseTypeNames_.lookup("base", entry);
|
||||
faItem.window_ = entry.lookupOrDefault<scalar>("window", -1.0);
|
||||
faItem.windowName_ = entry.lookupOrDefault<word>("windowName", "");
|
||||
|
||||
|
||||
@ -38,18 +38,15 @@ namespace functionObjects
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
const char* Foam::NamedEnum
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::functionObjects::fieldMinMax::modeType,
|
||||
2
|
||||
>::names[] = {"magnitude", "component"};
|
||||
|
||||
const Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::fieldMinMax::modeType,
|
||||
2
|
||||
> Foam::functionObjects::fieldMinMax::modeTypeNames_;
|
||||
Foam::functionObjects::fieldMinMax::modeType
|
||||
>
|
||||
Foam::functionObjects::fieldMinMax::modeTypeNames_
|
||||
{
|
||||
{ modeType::mdMag, "magnitude" },
|
||||
{ modeType::mdCmpt, "component" },
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
@ -126,7 +123,7 @@ bool Foam::functionObjects::fieldMinMax::read(const dictionary& dict)
|
||||
|
||||
location_ = dict.lookupOrDefault<Switch>("location", true);
|
||||
|
||||
mode_ = modeTypeNames_[dict.lookupOrDefault<word>("mode", "magnitude")];
|
||||
mode_ = modeTypeNames_.lookupOrDefault("mode", dict, modeType::mdMag);
|
||||
dict.lookup("fields") >> fieldSet_;
|
||||
|
||||
return true;
|
||||
|
||||
@ -78,7 +78,7 @@ SourceFiles
|
||||
#define functionObjects_fieldMinMax_H
|
||||
|
||||
#include "Switch.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "Enum.H"
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "writeFile.H"
|
||||
#include "vector.H"
|
||||
@ -115,7 +115,7 @@ protected:
|
||||
// Protected data
|
||||
|
||||
//- Mode type names
|
||||
static const NamedEnum<modeType, 2> modeTypeNames_;
|
||||
static const Enum<modeType> modeTypeNames_;
|
||||
|
||||
//- Switch to write location of min/max values
|
||||
Switch location_;
|
||||
|
||||
@ -43,15 +43,14 @@ Foam::functionObjects::fieldValue::New
|
||||
Info<< "Selecting " << typeName << " " << modelType << endl;
|
||||
}
|
||||
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(modelType);
|
||||
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
|
||||
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown " << typeName << " type "
|
||||
<< modelType << nl << nl
|
||||
<< "Valid " << typeName << " types are:" << nl
|
||||
<< "Valid " << typeName << " types :" << nl
|
||||
<< dictionaryConstructorTablePtr_->sortedToc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -40,24 +40,19 @@ namespace fieldValues
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
const char* Foam::NamedEnum
|
||||
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::functionObjects::fieldValues::fieldValueDelta::operationType,
|
||||
5
|
||||
>::names[] =
|
||||
Foam::functionObjects::fieldValues::fieldValueDelta::operationType
|
||||
>
|
||||
Foam::functionObjects::fieldValues::fieldValueDelta::operationTypeNames_
|
||||
{
|
||||
"add",
|
||||
"subtract",
|
||||
"min",
|
||||
"max",
|
||||
"average"
|
||||
{ operationType::opAdd, "add" },
|
||||
{ operationType::opSubtract, "subtract" },
|
||||
{ operationType::opMin, "min" },
|
||||
{ operationType::opMax, "max" },
|
||||
{ operationType::opAverage, "average" },
|
||||
};
|
||||
const Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::fieldValues::fieldValueDelta::operationType,
|
||||
5
|
||||
> Foam::functionObjects::fieldValues::fieldValueDelta::operationTypeNames_;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||
@ -151,7 +146,7 @@ bool Foam::functionObjects::fieldValues::fieldValueDelta::read
|
||||
).ptr()
|
||||
);
|
||||
|
||||
operation_ = operationTypeNames_.read(dict.lookup("operation"));
|
||||
operation_ = operationTypeNames_.lookup("operation", dict);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -85,6 +85,7 @@ SourceFiles
|
||||
#include "stateFunctionObject.H"
|
||||
#include "writeFile.H"
|
||||
#include "fieldValue.H"
|
||||
#include "Enum.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -116,7 +117,7 @@ public:
|
||||
};
|
||||
|
||||
//- Operation type names
|
||||
static const NamedEnum<operationType, 5> operationTypeNames_;
|
||||
static const Enum<operationType> operationTypeNames_;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@ -49,75 +49,54 @@ namespace fieldValues
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
const char* Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::regionTypes,
|
||||
4
|
||||
>::names[] =
|
||||
{
|
||||
"faceZone",
|
||||
"patch",
|
||||
"surface",
|
||||
"sampledSurface"
|
||||
};
|
||||
|
||||
template<>
|
||||
const char* Foam::NamedEnum
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::operationType,
|
||||
17
|
||||
>::names[] =
|
||||
{
|
||||
"none",
|
||||
"sum",
|
||||
"weightedSum",
|
||||
"sumMag",
|
||||
"sumDirection",
|
||||
"sumDirectionBalance",
|
||||
"average",
|
||||
"weightedAverage",
|
||||
"areaAverage",
|
||||
"weightedAreaAverage",
|
||||
"areaIntegrate",
|
||||
"weightedAreaIntegrate",
|
||||
"min",
|
||||
"max",
|
||||
"CoV",
|
||||
"areaNormalAverage",
|
||||
"areaNormalIntegrate"
|
||||
};
|
||||
|
||||
template<>
|
||||
const char* Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::postOperationType,
|
||||
2
|
||||
>::names[] =
|
||||
{
|
||||
"none",
|
||||
"sqrt"
|
||||
};
|
||||
|
||||
|
||||
const Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::regionTypes,
|
||||
4
|
||||
> Foam::functionObjects::fieldValues::surfaceFieldValue::regionTypeNames_;
|
||||
|
||||
const Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::operationType,
|
||||
17
|
||||
> Foam::functionObjects::fieldValues::surfaceFieldValue::operationTypeNames_;
|
||||
|
||||
const Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::postOperationType,
|
||||
2
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::regionTypes
|
||||
>
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::postOperationTypeNames_;
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::regionTypeNames_
|
||||
{
|
||||
{ regionTypes::stFaceZone, "faceZone" },
|
||||
{ regionTypes::stPatch, "patch" },
|
||||
{ regionTypes::stSurface, "surface" },
|
||||
{ regionTypes::stSampledSurface, "sampledSurface" },
|
||||
};
|
||||
|
||||
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::operationType
|
||||
>
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::operationTypeNames_
|
||||
{
|
||||
{ operationType::opNone, "none" },
|
||||
{ operationType::opSum, "sum" },
|
||||
{ operationType::opWeightedSum, "weightedSum" },
|
||||
{ operationType::opSumMag, "sumMag" },
|
||||
{ operationType::opSumDirection, "sumDirection" },
|
||||
{ operationType::opSumDirectionBalance, "sumDirectionBalance" },
|
||||
{ operationType::opAverage, "average" },
|
||||
{ operationType::opWeightedAverage, "weightedAverage" },
|
||||
{ operationType::opAreaAverage, "areaAverage" },
|
||||
{ operationType::opWeightedAreaAverage, "weightedAreaAverage" },
|
||||
{ operationType::opAreaIntegrate, "areaIntegrate" },
|
||||
{ operationType::opWeightedAreaIntegrate, "weightedAreaIntegrate" },
|
||||
{ operationType::opMin, "min" },
|
||||
{ operationType::opMax, "max" },
|
||||
{ operationType::opCoV, "CoV" },
|
||||
{ operationType::opAreaNormalAverage, "areaNormalAverage" },
|
||||
{ operationType::opAreaNormalIntegrate, "areaNormalIntegrate" },
|
||||
};
|
||||
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::postOperationType
|
||||
>
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::postOperationTypeNames_
|
||||
{
|
||||
{ postOperationType::postOpNone, "none" },
|
||||
{ postOperationType::postOpSqrt, "sqrt" },
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
@ -832,12 +811,16 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue
|
||||
)
|
||||
:
|
||||
fieldValue(name, runTime, dict, typeName),
|
||||
regionType_(regionTypeNames_.read(dict.lookup("regionType"))),
|
||||
operation_(operationTypeNames_.read(dict.lookup("operation"))),
|
||||
regionType_(regionTypeNames_.lookup("regionType", dict)),
|
||||
operation_(operationTypeNames_.lookup("operation", dict)),
|
||||
postOperation_
|
||||
(
|
||||
postOperationTypeNames_
|
||||
[dict.lookupOrDefault<word>("postOperation", "none")]
|
||||
postOperationTypeNames_.lookupOrDefault
|
||||
(
|
||||
"postOperation",
|
||||
dict,
|
||||
postOperationType::postOpNone
|
||||
)
|
||||
),
|
||||
weightFieldName_("none"),
|
||||
writeArea_(dict.lookupOrDefault("writeArea", false)),
|
||||
@ -859,12 +842,16 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue
|
||||
)
|
||||
:
|
||||
fieldValue(name, obr, dict, typeName),
|
||||
regionType_(regionTypeNames_.read(dict.lookup("regionType"))),
|
||||
operation_(operationTypeNames_.read(dict.lookup("operation"))),
|
||||
regionType_(regionTypeNames_.lookup("regionType", dict)),
|
||||
operation_(operationTypeNames_.lookup("operation", dict)),
|
||||
postOperation_
|
||||
(
|
||||
postOperationTypeNames_
|
||||
[dict.lookupOrDefault<word>("postOperation", "none")]
|
||||
postOperationTypeNames_.lookupOrDefault
|
||||
(
|
||||
"postOperation",
|
||||
dict,
|
||||
postOperationType::postOpNone
|
||||
)
|
||||
),
|
||||
weightFieldName_("none"),
|
||||
writeArea_(dict.lookupOrDefault("writeArea", false)),
|
||||
|
||||
@ -156,7 +156,7 @@ SourceFiles
|
||||
#define functionObjects_surfaceFieldValue_H
|
||||
|
||||
#include "fieldValue.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "Enum.H"
|
||||
#include "meshedSurf.H"
|
||||
#include "surfaceMesh.H"
|
||||
#include "fvsPatchField.H"
|
||||
@ -198,7 +198,7 @@ public:
|
||||
};
|
||||
|
||||
//- Region type names
|
||||
static const NamedEnum<regionTypes, 4> regionTypeNames_;
|
||||
static const Enum<regionTypes> regionTypeNames_;
|
||||
|
||||
|
||||
//- Operation type enumeration
|
||||
@ -224,7 +224,7 @@ public:
|
||||
};
|
||||
|
||||
//- Operation type names
|
||||
static const NamedEnum<operationType, 17> operationTypeNames_;
|
||||
static const Enum<operationType> operationTypeNames_;
|
||||
|
||||
|
||||
//- Post-operation type enumeration
|
||||
@ -235,7 +235,7 @@ public:
|
||||
};
|
||||
|
||||
//- Operation type names
|
||||
static const NamedEnum<postOperationType, 2> postOperationTypeNames_;
|
||||
static const Enum<postOperationType> postOperationTypeNames_;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@ -43,35 +43,27 @@ namespace fieldValues
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
const char*
|
||||
Foam::NamedEnum
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::functionObjects::fieldValues::volFieldValue::operationType,
|
||||
13
|
||||
>::names[] =
|
||||
Foam::functionObjects::fieldValues::volFieldValue::operationType
|
||||
>
|
||||
Foam::functionObjects::fieldValues::volFieldValue::operationTypeNames_
|
||||
{
|
||||
"none",
|
||||
"sum",
|
||||
"weightedSum",
|
||||
"sumMag",
|
||||
"average",
|
||||
"weightedAverage",
|
||||
"volAverage",
|
||||
"weightedVolAverage",
|
||||
"volIntegrate",
|
||||
"weightedVolIntegrate",
|
||||
"min",
|
||||
"max",
|
||||
"CoV"
|
||||
{ operationType::opNone, "none" },
|
||||
{ operationType::opSum, "sum" },
|
||||
{ operationType::opWeightedSum, "weightedSum" },
|
||||
{ operationType::opSumMag, "sumMag" },
|
||||
{ operationType::opAverage, "average" },
|
||||
{ operationType::opWeightedAverage, "weightedAverage" },
|
||||
{ operationType::opVolAverage, "volAverage" },
|
||||
{ operationType::opWeightedVolAverage, "weightedVolAverage" },
|
||||
{ operationType::opVolIntegrate, "volIntegrate" },
|
||||
{ operationType::opWeightedVolIntegrate, "weightedVolIntegrate" },
|
||||
{ operationType::opMin, "min" },
|
||||
{ operationType::opMax, "max" },
|
||||
{ operationType::opCoV, "CoV" },
|
||||
};
|
||||
|
||||
const Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::fieldValues::volFieldValue::operationType,
|
||||
13
|
||||
> Foam::functionObjects::fieldValues::volFieldValue::operationTypeNames_;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -198,7 +190,7 @@ Foam::functionObjects::fieldValues::volFieldValue::volFieldValue
|
||||
:
|
||||
fieldValue(name, runTime, dict, typeName),
|
||||
volRegion(fieldValue::mesh_, dict),
|
||||
operation_(operationTypeNames_.read(dict.lookup("operation"))),
|
||||
operation_(operationTypeNames_.lookup("operation", dict)),
|
||||
weightFieldName_("none")
|
||||
{
|
||||
read(dict);
|
||||
@ -215,7 +207,7 @@ Foam::functionObjects::fieldValues::volFieldValue::volFieldValue
|
||||
:
|
||||
fieldValue(name, obr, dict, typeName),
|
||||
volRegion(fieldValue::mesh_, dict),
|
||||
operation_(operationTypeNames_.read(dict.lookup("operation"))),
|
||||
operation_(operationTypeNames_.lookup("operation", dict)),
|
||||
weightFieldName_("none")
|
||||
{
|
||||
read(dict);
|
||||
|
||||
@ -153,7 +153,7 @@ public:
|
||||
};
|
||||
|
||||
//- Operation type names
|
||||
static const NamedEnum<operationType, 13> operationTypeNames_;
|
||||
static const Enum<operationType> operationTypeNames_;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@ -52,24 +52,20 @@ namespace functionObjects
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
template<>
|
||||
const char* NamedEnum
|
||||
<
|
||||
functionObjects::fluxSummary::modeType,
|
||||
5
|
||||
>::names[] =
|
||||
{
|
||||
"faceZone",
|
||||
"faceZoneAndDirection",
|
||||
"cellZoneAndDirection",
|
||||
"surface",
|
||||
"surfaceAndDirection"
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
const Foam::NamedEnum<Foam::functionObjects::fluxSummary::modeType, 5>
|
||||
Foam::functionObjects::fluxSummary::modeTypeNames_;
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::functionObjects::fluxSummary::modeType
|
||||
>
|
||||
Foam::functionObjects::fluxSummary::modeTypeNames_
|
||||
{
|
||||
{ modeType::mdFaceZone , "faceZone" },
|
||||
{ modeType::mdFaceZoneAndDirection, "faceZoneAndDirection" },
|
||||
{ modeType::mdCellZoneAndDirection, "cellZoneAndDirection" },
|
||||
{ modeType::mdSurface, "surface" },
|
||||
{ modeType::mdSurfaceAndDirection, "surfaceAndDirection" },
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
@ -823,7 +819,7 @@ bool Foam::functionObjects::fluxSummary::read(const dictionary& dict)
|
||||
fvMeshFunctionObject::read(dict);
|
||||
writeFile::read(dict);
|
||||
|
||||
mode_ = modeTypeNames_.read(dict.lookup("mode"));
|
||||
mode_ = modeTypeNames_.lookup("mode", dict);
|
||||
phiName_ = dict.lookupOrDefault<word>("phi", "phi");
|
||||
scaleFactor_ = dict.lookupOrDefault<scalar>("scaleFactor", 1.0);
|
||||
tolerance_ = dict.lookupOrDefault<scalar>("tolerance", 0.8);
|
||||
|
||||
@ -124,7 +124,7 @@ public:
|
||||
};
|
||||
|
||||
//- Mode type names
|
||||
static const NamedEnum<modeType, 5> modeTypeNames_;
|
||||
static const Enum<modeType> modeTypeNames_;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@ -48,7 +48,10 @@ namespace functionObjects
|
||||
}
|
||||
|
||||
|
||||
const Foam::Enum<Foam::functionObjects::setFlow::modeType>
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::functionObjects::setFlow::modeType
|
||||
>
|
||||
Foam::functionObjects::setFlow::modeTypeNames
|
||||
{
|
||||
{ functionObjects::setFlow::modeType::FUNCTION, "function" },
|
||||
|
||||
@ -110,7 +110,7 @@ class setFlow
|
||||
VORTEX3D
|
||||
};
|
||||
|
||||
static const Foam::Enum<modeType> modeTypeNames;
|
||||
static const Enum<modeType> modeTypeNames;
|
||||
|
||||
|
||||
// Private Data
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -45,51 +45,39 @@ namespace functionObjects
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
const char* Foam::NamedEnum
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::functionObjects::turbulenceFields::compressibleField,
|
||||
9
|
||||
>::names[] =
|
||||
Foam::functionObjects::turbulenceFields::compressibleField
|
||||
>
|
||||
Foam::functionObjects::turbulenceFields::compressibleFieldNames_
|
||||
{
|
||||
"k",
|
||||
"epsilon",
|
||||
"omega",
|
||||
"mut",
|
||||
"muEff",
|
||||
"alphat",
|
||||
"alphaEff",
|
||||
"R",
|
||||
"devRhoReff"
|
||||
{ compressibleField::cfK, "k" },
|
||||
{ compressibleField::cfEpsilon, "epsilon" },
|
||||
{ compressibleField::cfOmega, "omega" },
|
||||
{ compressibleField::cfMut, "mut" },
|
||||
{ compressibleField::cfMuEff, "muEff" },
|
||||
{ compressibleField::cfAlphat, "alphat" },
|
||||
{ compressibleField::cfAlphaEff, "alphaEff" },
|
||||
{ compressibleField::cfR, "R" },
|
||||
{ compressibleField::cfDevRhoReff, "devRhoReff" },
|
||||
};
|
||||
|
||||
const Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::turbulenceFields::compressibleField,
|
||||
9
|
||||
> Foam::functionObjects::turbulenceFields::compressibleFieldNames_;
|
||||
|
||||
template<>
|
||||
const char* Foam::NamedEnum
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::functionObjects::turbulenceFields::incompressibleField,
|
||||
7
|
||||
>::names[] =
|
||||
Foam::functionObjects::turbulenceFields::incompressibleField
|
||||
>
|
||||
Foam::functionObjects::turbulenceFields::incompressibleFieldNames_
|
||||
{
|
||||
"k",
|
||||
"epsilon",
|
||||
"omega",
|
||||
"nut",
|
||||
"nuEff",
|
||||
"R",
|
||||
"devReff"
|
||||
{ incompressibleField::ifK, "k" },
|
||||
{ incompressibleField::ifEpsilon, "epsilon" },
|
||||
{ incompressibleField::ifOmega, "omega" },
|
||||
{ incompressibleField::ifNut, "nut" },
|
||||
{ incompressibleField::ifNuEff, "nuEff" },
|
||||
{ incompressibleField::ifR, "R" },
|
||||
{ incompressibleField::ifDevReff, "devReff" },
|
||||
};
|
||||
|
||||
const Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::turbulenceFields::incompressibleField,
|
||||
7
|
||||
> Foam::functionObjects::turbulenceFields::incompressibleFieldNames_;
|
||||
|
||||
const Foam::word Foam::functionObjects::turbulenceFields::modelName
|
||||
(
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -90,7 +90,7 @@ SourceFiles
|
||||
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "HashSet.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "Enum.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "Switch.H"
|
||||
|
||||
@ -123,7 +123,7 @@ public:
|
||||
cfR,
|
||||
cfDevRhoReff
|
||||
};
|
||||
static const NamedEnum<compressibleField, 9> compressibleFieldNames_;
|
||||
static const Enum<compressibleField> compressibleFieldNames_;
|
||||
|
||||
enum incompressibleField
|
||||
{
|
||||
@ -135,7 +135,7 @@ public:
|
||||
ifR,
|
||||
ifDevReff
|
||||
};
|
||||
static const NamedEnum<incompressibleField, 7> incompressibleFieldNames_;
|
||||
static const Enum<incompressibleField> incompressibleFieldNames_;
|
||||
|
||||
static const word modelName;
|
||||
|
||||
|
||||
@ -47,46 +47,27 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::functionObjects::fieldVisualisationBase::colourByType
|
||||
>
|
||||
Foam::functionObjects::fieldVisualisationBase::colourByTypeNames
|
||||
{
|
||||
template<>
|
||||
const char* NamedEnum
|
||||
<
|
||||
functionObjects::fieldVisualisationBase::colourByType,
|
||||
2
|
||||
>::names[] =
|
||||
{
|
||||
"colour",
|
||||
"field"
|
||||
};
|
||||
{ colourByType::cbColour, "colour" },
|
||||
{ colourByType::cbField, "field" },
|
||||
};
|
||||
|
||||
template<>
|
||||
const char* NamedEnum
|
||||
<
|
||||
functionObjects::fieldVisualisationBase::colourMapType,
|
||||
4
|
||||
>::names[] =
|
||||
{
|
||||
"rainbow",
|
||||
"blueWhiteRed",
|
||||
"fire",
|
||||
"greyscale"
|
||||
};
|
||||
}
|
||||
|
||||
const Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::fieldVisualisationBase::colourByType,
|
||||
2
|
||||
>
|
||||
Foam::functionObjects::fieldVisualisationBase::colourByTypeNames;
|
||||
|
||||
const Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::fieldVisualisationBase::colourMapType,
|
||||
4
|
||||
>
|
||||
Foam::functionObjects::fieldVisualisationBase::colourMapTypeNames;
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::functionObjects::fieldVisualisationBase::colourMapType
|
||||
>
|
||||
Foam::functionObjects::fieldVisualisationBase::colourMapTypeNames
|
||||
{
|
||||
{ colourMapType::cmRainbow, "rainbow" },
|
||||
{ colourMapType::cmBlueWhiteRed, "blueWhiteRed" },
|
||||
{ colourMapType::cmFire, "fire" },
|
||||
{ colourMapType::cmGreyscale, "greyscale" },
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
@ -100,8 +81,7 @@ void Foam::functionObjects::fieldVisualisationBase::setColourMap
|
||||
|
||||
lut->SetNumberOfColors(nColours);
|
||||
|
||||
vtkSmartPointer<vtkColorTransferFunction> ctf =
|
||||
vtkSmartPointer<vtkColorTransferFunction>::New();
|
||||
auto ctf = vtkSmartPointer<vtkColorTransferFunction>::New();
|
||||
|
||||
switch (colourMap_)
|
||||
{
|
||||
@ -163,8 +143,7 @@ void Foam::functionObjects::fieldVisualisationBase::addScalarBar
|
||||
return;
|
||||
}
|
||||
|
||||
vtkSmartPointer<vtkScalarBarActor> sbar =
|
||||
vtkSmartPointer<vtkScalarBarActor>::New();
|
||||
auto sbar = vtkSmartPointer<vtkScalarBarActor>::New();
|
||||
sbar->SetLookupTable(lut);
|
||||
sbar->SetNumberOfLabels(scalarBar_.numberOfLabels_);
|
||||
|
||||
@ -174,8 +153,7 @@ void Foam::functionObjects::fieldVisualisationBase::addScalarBar
|
||||
// - Default scalar bar title text is scales by the scalar bar box
|
||||
// dimensions so if the title is a long string, the text is shrunk to fit
|
||||
// Instead, suppress title and set the title using a vtkTextActor
|
||||
vtkSmartPointer<vtkTextActor> titleActor =
|
||||
vtkSmartPointer<vtkTextActor>::New();
|
||||
auto titleActor = vtkSmartPointer<vtkTextActor>::New();
|
||||
sbar->SetTitle(" ");
|
||||
titleActor->SetInput(scalarBar_.title_.c_str());
|
||||
titleActor->GetTextProperty()->SetFontFamilyToArial();
|
||||
@ -282,8 +260,7 @@ void Foam::functionObjects::fieldVisualisationBase::setField
|
||||
case cbField:
|
||||
{
|
||||
// Create look-up table for colours
|
||||
vtkSmartPointer<vtkLookupTable> lut =
|
||||
vtkSmartPointer<vtkLookupTable>::New();
|
||||
auto lut = vtkSmartPointer<vtkLookupTable>::New();
|
||||
setColourMap(lut);
|
||||
lut->SetVectorMode(vtkScalarsToColors::MAGNITUDE);
|
||||
|
||||
@ -337,9 +314,8 @@ void Foam::functionObjects::fieldVisualisationBase::addGlyphs
|
||||
vtkRenderer* renderer
|
||||
) const
|
||||
{
|
||||
vtkSmartPointer<vtkGlyph3D> glyph = vtkSmartPointer<vtkGlyph3D>::New();
|
||||
vtkSmartPointer<vtkPolyDataMapper> glyphMapper =
|
||||
vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
auto glyph = vtkSmartPointer<vtkGlyph3D>::New();
|
||||
auto glyphMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
glyphMapper->SetInputConnection(glyph->GetOutputPort());
|
||||
|
||||
glyph->SetInputData(data);
|
||||
@ -358,8 +334,7 @@ void Foam::functionObjects::fieldVisualisationBase::addGlyphs
|
||||
else if (data->GetCellData()->HasArray(scaleFieldNameChar) == 1)
|
||||
{
|
||||
// Need to convert cell data to point data
|
||||
vtkSmartPointer<vtkCellDataToPointData> cellToPoint =
|
||||
vtkSmartPointer<vtkCellDataToPointData>::New();
|
||||
auto cellToPoint = vtkSmartPointer<vtkCellDataToPointData>::New();
|
||||
cellToPoint->SetInputData(data);
|
||||
cellToPoint->Update();
|
||||
vtkDataSet* pds = cellToPoint->GetOutput();
|
||||
@ -380,8 +355,7 @@ void Foam::functionObjects::fieldVisualisationBase::addGlyphs
|
||||
|
||||
if (nComponents == 1)
|
||||
{
|
||||
vtkSmartPointer<vtkSphereSource> sphere =
|
||||
vtkSmartPointer<vtkSphereSource>::New();
|
||||
auto sphere = vtkSmartPointer<vtkSphereSource>::New();
|
||||
sphere->SetCenter(0, 0, 0);
|
||||
sphere->SetRadius(0.5);
|
||||
|
||||
@ -428,8 +402,7 @@ void Foam::functionObjects::fieldVisualisationBase::addGlyphs
|
||||
}
|
||||
else if (nComponents == 3)
|
||||
{
|
||||
vtkSmartPointer<vtkArrowSource> arrow =
|
||||
vtkSmartPointer<vtkArrowSource>::New();
|
||||
auto arrow = vtkSmartPointer<vtkArrowSource>::New();
|
||||
arrow->SetTipResolution(10);
|
||||
arrow->SetTipRadius(0.1);
|
||||
arrow->SetTipLength(0.35);
|
||||
@ -516,7 +489,7 @@ Foam::functionObjects::fieldVisualisationBase::fieldVisualisationBase
|
||||
colourMap_(cmRainbow),
|
||||
range_()
|
||||
{
|
||||
colourBy_ = colourByTypeNames.read(dict.lookup("colourBy"));
|
||||
colourBy_ = colourByTypeNames.lookup("colourBy", dict);
|
||||
|
||||
switch (colourBy_)
|
||||
{
|
||||
@ -531,7 +504,7 @@ Foam::functionObjects::fieldVisualisationBase::fieldVisualisationBase
|
||||
|
||||
if (dict.found("colourMap"))
|
||||
{
|
||||
colourMap_ = colourMapTypeNames.read(dict.lookup("colourMap"));
|
||||
colourMap_ = colourMapTypeNames.lookup("colourMap", dict);
|
||||
}
|
||||
|
||||
const dictionary& sbarDict = dict.subDict("scalarBar");
|
||||
|
||||
@ -37,7 +37,7 @@ SourceFiles
|
||||
|
||||
#include "dictionary.H"
|
||||
#include "Tuple2.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "Enum.H"
|
||||
#include "vector.H"
|
||||
#include "HashPtrTable.H"
|
||||
#include "Function1.H"
|
||||
@ -78,7 +78,7 @@ public:
|
||||
cbField
|
||||
};
|
||||
|
||||
static const NamedEnum<colourByType, 2> colourByTypeNames;
|
||||
static const Enum<colourByType> colourByTypeNames;
|
||||
|
||||
enum colourMapType
|
||||
{
|
||||
@ -88,7 +88,7 @@ public:
|
||||
cmGreyscale
|
||||
};
|
||||
|
||||
static const NamedEnum<colourMapType, 4> colourMapTypeNames;
|
||||
static const Enum<colourMapType> colourMapTypeNames;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@ -120,13 +120,11 @@ addGeometryToScene
|
||||
|
||||
if (fName.ext() == "vtk")
|
||||
{
|
||||
vtkSmartPointer<vtkPolyDataReader> points =
|
||||
vtkSmartPointer<vtkPolyDataReader>::New();
|
||||
auto points = vtkSmartPointer<vtkPolyDataReader>::New();
|
||||
points->SetFileName(fName.c_str());
|
||||
points->Update();
|
||||
|
||||
vtkSmartPointer<vtkPolyDataMapper> mapper =
|
||||
vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
|
||||
actor_->SetMapper(mapper);
|
||||
|
||||
|
||||
@ -101,13 +101,11 @@ addGeometryToScene
|
||||
|
||||
if (fName.ext() == "vtk")
|
||||
{
|
||||
vtkSmartPointer<vtkPolyDataReader> lines =
|
||||
vtkSmartPointer<vtkPolyDataReader>::New();
|
||||
auto lines = vtkSmartPointer<vtkPolyDataReader>::New();
|
||||
lines->SetFileName(fName.c_str());
|
||||
lines->Update();
|
||||
|
||||
vtkSmartPointer<vtkPolyDataMapper> mapper =
|
||||
vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
setField(position, fieldName_, mapper, renderer, lines->GetOutput());
|
||||
|
||||
actor_->SetMapper(mapper);
|
||||
|
||||
@ -101,8 +101,7 @@ addGeometryToScene
|
||||
|
||||
if (representation_ == rtGlyph)
|
||||
{
|
||||
vtkSmartPointer<vtkPolyDataReader> surf =
|
||||
vtkSmartPointer<vtkPolyDataReader>::New();
|
||||
auto surf = vtkSmartPointer<vtkPolyDataReader>::New();
|
||||
surf->SetFileName(fName.c_str());
|
||||
surf->Update();
|
||||
|
||||
@ -121,15 +120,13 @@ addGeometryToScene
|
||||
{
|
||||
if (fName.ext() == "vtk")
|
||||
{
|
||||
vtkSmartPointer<vtkPolyDataReader> surf =
|
||||
vtkSmartPointer<vtkPolyDataReader>::New();
|
||||
auto surf = vtkSmartPointer<vtkPolyDataReader>::New();
|
||||
surf->SetFileName(fName.c_str());
|
||||
surf->Update();
|
||||
|
||||
addFeatureEdges(renderer, surf->GetOutput());
|
||||
|
||||
vtkSmartPointer<vtkPolyDataMapper> mapper =
|
||||
vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
mapper->SetInputConnection(surf->GetOutputPort());
|
||||
|
||||
setField(position, fieldName_, mapper, renderer, surf->GetOutput());
|
||||
|
||||
@ -32,27 +32,16 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
template<>
|
||||
const char* NamedEnum
|
||||
<
|
||||
functionObjects::runTimePostPro::geometryBase::renderModeType,
|
||||
3
|
||||
>::names[] =
|
||||
{
|
||||
"flat",
|
||||
"gouraud",
|
||||
"phong"
|
||||
};
|
||||
}
|
||||
|
||||
const Foam::NamedEnum
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::functionObjects::runTimePostPro::geometryBase::renderModeType,
|
||||
3
|
||||
Foam::functionObjects::runTimePostPro::geometryBase::renderModeType
|
||||
>
|
||||
Foam::functionObjects::runTimePostPro::geometryBase::renderModeTypeNames;
|
||||
Foam::functionObjects::runTimePostPro::geometryBase::renderModeTypeNames
|
||||
{
|
||||
{ renderModeType::rmFlat, "flat" },
|
||||
{ renderModeType::rmGouraud, "gouraud" },
|
||||
{ renderModeType::rmPhong, "phong" },
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
@ -104,7 +93,7 @@ Foam::functionObjects::runTimePostPro::geometryBase::geometryBase
|
||||
{
|
||||
if (dict.found("renderMode"))
|
||||
{
|
||||
renderMode_ = renderModeTypeNames.read(dict.lookup("renderMode"));
|
||||
renderMode_ = renderModeTypeNames.lookup("renderMode", dict);
|
||||
}
|
||||
|
||||
if (dict.found("opacity"))
|
||||
|
||||
@ -39,7 +39,7 @@ SourceFiles
|
||||
#include "vector.H"
|
||||
#include "Function1.H"
|
||||
#include "HashPtrTable.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "Enum.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -75,7 +75,7 @@ public:
|
||||
rmPhong //!< Phong shading
|
||||
};
|
||||
|
||||
static const NamedEnum<renderModeType, 3> renderModeTypeNames;
|
||||
static const Enum<renderModeType> renderModeTypeNames;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@ -79,11 +79,9 @@ void Foam::functionObjects::runTimePostPro::geometrySurface::addGeometryToScene
|
||||
const Field<point>& surfPoints = surf.points();
|
||||
const Field<vector>& surfFaceNormals = surf.faceNormals();
|
||||
|
||||
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
|
||||
vtkSmartPointer<vtkCellArray> triangles =
|
||||
vtkSmartPointer<vtkCellArray>::New();
|
||||
vtkSmartPointer<vtkDoubleArray> faceNormals =
|
||||
vtkSmartPointer<vtkDoubleArray>::New();
|
||||
auto points = vtkSmartPointer<vtkPoints>::New();
|
||||
auto triangles = vtkSmartPointer<vtkCellArray>::New();
|
||||
auto faceNormals = vtkSmartPointer<vtkDoubleArray>::New();
|
||||
|
||||
faceNormals->SetNumberOfComponents(3);
|
||||
|
||||
@ -97,8 +95,7 @@ void Foam::functionObjects::runTimePostPro::geometrySurface::addGeometryToScene
|
||||
{
|
||||
const Foam::face& f = surf[i];
|
||||
|
||||
vtkSmartPointer<vtkTriangle> triangle =
|
||||
vtkSmartPointer<vtkTriangle>::New();
|
||||
auto triangle = vtkSmartPointer<vtkTriangle>::New();
|
||||
triangle->GetPointIds()->SetId(0, f[0]);
|
||||
triangle->GetPointIds()->SetId(1, f[1]);
|
||||
triangle->GetPointIds()->SetId(2, f[2]);
|
||||
@ -114,14 +111,12 @@ void Foam::functionObjects::runTimePostPro::geometrySurface::addGeometryToScene
|
||||
|
||||
surf.clearOut();
|
||||
|
||||
vtkSmartPointer<vtkPolyData> polyData =
|
||||
vtkSmartPointer<vtkPolyData>::New();
|
||||
auto polyData = vtkSmartPointer<vtkPolyData>::New();
|
||||
polyData->SetPoints(points);
|
||||
polyData->SetPolys(triangles);
|
||||
polyData->GetCellData()->SetNormals(faceNormals);
|
||||
|
||||
vtkSmartPointer<vtkPolyDataMapper> mapper =
|
||||
vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
mapper->ScalarVisibilityOff();
|
||||
mapper->SetInputData(polyData);
|
||||
|
||||
|
||||
@ -48,27 +48,19 @@ namespace runTimePostPro
|
||||
defineRunTimeSelectionTable(pathline, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
const char* NamedEnum
|
||||
<
|
||||
functionObjects::runTimePostPro::pathline::representationType,
|
||||
4
|
||||
>::names[] =
|
||||
{
|
||||
"none",
|
||||
"line",
|
||||
"tube",
|
||||
"vector"
|
||||
};
|
||||
}
|
||||
|
||||
const Foam::NamedEnum
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::functionObjects::runTimePostPro::pathline::representationType,
|
||||
4
|
||||
Foam::functionObjects::runTimePostPro::pathline::representationType
|
||||
>
|
||||
Foam::functionObjects::runTimePostPro::pathline::representationTypeNames;
|
||||
Foam::functionObjects::runTimePostPro::pathline::representationTypeNames
|
||||
{
|
||||
{ representationType::rtNone, "none" },
|
||||
{ representationType::rtLine, "line" },
|
||||
{ representationType::rtTube, "tube" },
|
||||
{ representationType::rtVector, "vector" },
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
@ -104,8 +96,7 @@ void Foam::functionObjects::runTimePostPro::pathline::addLines
|
||||
}
|
||||
case rtTube:
|
||||
{
|
||||
vtkSmartPointer<vtkTubeFilter> tubes =
|
||||
vtkSmartPointer<vtkTubeFilter>::New();
|
||||
auto tubes = vtkSmartPointer<vtkTubeFilter>::New();
|
||||
tubes->SetInputData(data);
|
||||
tubes->SetRadius(tubeRadius_);
|
||||
tubes->SetNumberOfSides(20);
|
||||
@ -138,7 +129,7 @@ Foam::functionObjects::runTimePostPro::pathline::pathline
|
||||
geometryBase(parent, dict, colours),
|
||||
representation_
|
||||
(
|
||||
representationTypeNames.read(dict.lookup("representation"))
|
||||
representationTypeNames.lookup("representation", dict)
|
||||
),
|
||||
tubeRadius_(0.0),
|
||||
lineColour_(nullptr)
|
||||
@ -192,15 +183,14 @@ Foam::functionObjects::runTimePostPro::pathline::New
|
||||
Info<< "Selecting pathline " << pathlineType << endl;
|
||||
}
|
||||
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(pathlineType);
|
||||
auto cstrIter = dictionaryConstructorTablePtr_->cfind(pathlineType);
|
||||
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown pathline type "
|
||||
<< pathlineType << nl << nl
|
||||
<< "Valid pathline types are:" << endl
|
||||
<< "Valid pathline types :" << endl
|
||||
<< dictionaryConstructorTablePtr_->sortedToc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ SourceFiles
|
||||
#define functionObjects_runTimePostPro_pathline_H
|
||||
|
||||
#include "geometryBase.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "Enum.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -71,7 +71,7 @@ public:
|
||||
rtVector
|
||||
};
|
||||
|
||||
static const NamedEnum<representationType, 4> representationTypeNames;
|
||||
static const Enum<representationType> representationTypeNames;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@ -48,24 +48,17 @@ namespace runTimePostPro
|
||||
defineRunTimeSelectionTable(pointData, dictionary);
|
||||
}
|
||||
}
|
||||
template<>
|
||||
const char* NamedEnum
|
||||
<
|
||||
functionObjects::runTimePostPro::pointData::representationType,
|
||||
2
|
||||
>::names[] =
|
||||
{
|
||||
"sphere",
|
||||
"vector"
|
||||
};
|
||||
}
|
||||
|
||||
const Foam::NamedEnum
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::functionObjects::runTimePostPro::pointData::representationType,
|
||||
2
|
||||
Foam::functionObjects::runTimePostPro::pointData::representationType
|
||||
>
|
||||
Foam::functionObjects::runTimePostPro::pointData::representationTypeNames;
|
||||
Foam::functionObjects::runTimePostPro::pointData::representationTypeNames
|
||||
{
|
||||
{ representationType::rtSphere, "sphere" },
|
||||
{ representationType::rtVector, "vector" },
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
@ -106,7 +99,7 @@ Foam::functionObjects::runTimePostPro::pointData::pointData
|
||||
geometryBase(parent, dict, colours),
|
||||
representation_
|
||||
(
|
||||
representationTypeNames.read(dict.lookup("representation"))
|
||||
representationTypeNames.lookup("representation", dict)
|
||||
),
|
||||
maxGlyphLength_(readScalar(dict.lookup("maxGlyphLength"))),
|
||||
pointColour_(nullptr)
|
||||
@ -150,15 +143,14 @@ Foam::autoPtr<Foam::functionObjects::runTimePostPro::pointData> Foam::functionOb
|
||||
Info<< "Selecting pointData " << pointDataType << endl;
|
||||
}
|
||||
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(pointDataType);
|
||||
auto cstrIter = dictionaryConstructorTablePtr_->cfind(pointDataType);
|
||||
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown pointData type "
|
||||
<< pointDataType << nl << nl
|
||||
<< "Valid pointData types are:" << endl
|
||||
<< "Valid pointData types :" << endl
|
||||
<< dictionaryConstructorTablePtr_->sortedToc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ SourceFiles
|
||||
#define functionObjects_runTimePostPro_pointData_H
|
||||
|
||||
#include "geometryBase.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "Enum.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -69,7 +69,7 @@ public:
|
||||
rtVector //!< Vector
|
||||
};
|
||||
|
||||
static const NamedEnum<representationType, 2> representationTypeNames;
|
||||
static const Enum<representationType> representationTypeNames;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@ -150,8 +150,7 @@ bool Foam::functionObjects::runTimePostProcessing::write()
|
||||
sigFpe::unset(false);
|
||||
|
||||
// Initialise render window
|
||||
vtkSmartPointer<vtkRenderWindow> renderWindow =
|
||||
vtkSmartPointer<vtkRenderWindow>::New();
|
||||
auto renderWindow = vtkSmartPointer<vtkRenderWindow>::New();
|
||||
renderWindow->OffScreenRenderingOn();
|
||||
renderWindow->SetSize(output_.width_, output_.height_);
|
||||
renderWindow->SetAAFrames(10);
|
||||
@ -159,7 +158,7 @@ bool Foam::functionObjects::runTimePostProcessing::write()
|
||||
renderWindow->SetMultiSamples(0);
|
||||
// renderWindow->PolygonSmoothingOn();
|
||||
|
||||
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
|
||||
auto renderer = vtkSmartPointer<vtkRenderer>::New();
|
||||
scene_.initialise(renderer, output_.name_);
|
||||
|
||||
renderWindow->AddRenderer(renderer);
|
||||
|
||||
@ -186,20 +186,19 @@ void Foam::functionObjects::runTimePostPro::scene::initialise
|
||||
renderer->SetOcclusionRatio(0);
|
||||
|
||||
// Set the camera
|
||||
vtkSmartPointer<vtkCamera> camera = vtkSmartPointer<vtkCamera>::New();
|
||||
auto camera = vtkSmartPointer<vtkCamera>::New();
|
||||
camera->SetParallelProjection(parallelProjection_);
|
||||
renderer->SetActiveCamera(camera);
|
||||
|
||||
// Add the lights
|
||||
vtkSmartPointer<vtkLightKit> lightKit = vtkSmartPointer<vtkLightKit>::New();
|
||||
auto lightKit = vtkSmartPointer<vtkLightKit>::New();
|
||||
lightKit->AddLightsToRenderer(renderer);
|
||||
|
||||
if (!clipBox_.empty())
|
||||
{
|
||||
const point& min = clipBox_.min();
|
||||
const point& max = clipBox_.max();
|
||||
vtkSmartPointer<vtkCubeSource> clipBox =
|
||||
vtkSmartPointer<vtkCubeSource>::New();
|
||||
auto clipBox = vtkSmartPointer<vtkCubeSource>::New();
|
||||
clipBox->SetXLength(max.x() - min.x());
|
||||
clipBox->SetYLength(max.y() - min.y());
|
||||
clipBox->SetZLength(max.z() - min.z());
|
||||
@ -209,8 +208,7 @@ void Foam::functionObjects::runTimePostPro::scene::initialise
|
||||
min.y() + 0.5*(max.y() - min.y()),
|
||||
min.z() + 0.5*(max.z() - min.z())
|
||||
);
|
||||
vtkSmartPointer<vtkPolyDataMapper> clipMapper =
|
||||
vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
auto clipMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
clipMapper->SetInputConnection(clipBox->GetOutputPort());
|
||||
|
||||
clipBoxActor_ = vtkSmartPointer<vtkActor>::New();
|
||||
@ -401,8 +399,7 @@ void Foam::functionObjects::runTimePostPro::scene::saveImage
|
||||
renderWindow->Render();
|
||||
|
||||
// Set up off-screen rendering
|
||||
vtkSmartPointer<vtkWindowToImageFilter> windowToImageFilter =
|
||||
vtkSmartPointer<vtkWindowToImageFilter>::New();
|
||||
auto windowToImageFilter = vtkSmartPointer<vtkWindowToImageFilter>::New();
|
||||
|
||||
windowToImageFilter->SetInput(renderWindow);
|
||||
|
||||
@ -414,7 +411,7 @@ void Foam::functionObjects::runTimePostPro::scene::saveImage
|
||||
windowToImageFilter->Update();
|
||||
|
||||
// Save the image
|
||||
vtkSmartPointer<vtkPNGWriter> writer = vtkSmartPointer<vtkPNGWriter>::New();
|
||||
auto writer = vtkSmartPointer<vtkPNGWriter>::New();
|
||||
fileName fName(prefix/outputName_ + '.' + frameIndexStr() + ".png");
|
||||
writer->SetFileName(fName.c_str());
|
||||
writer->SetInputConnection(windowToImageFilter->GetOutputPort());
|
||||
|
||||
@ -62,9 +62,8 @@ SourceFiles
|
||||
#include "vector.H"
|
||||
#include "point.H"
|
||||
#include "boundBox.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "Enum.H"
|
||||
#include "HashPtrTable.H"
|
||||
#include "vector.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkSmartPointer.h"
|
||||
|
||||
@ -48,27 +48,21 @@ namespace runTimePostPro
|
||||
defineRunTimeSelectionTable(surface, dictionary);
|
||||
}
|
||||
}
|
||||
template<>
|
||||
const char* NamedEnum
|
||||
<
|
||||
functionObjects::runTimePostPro::surface::representationType,
|
||||
5
|
||||
>::names[] =
|
||||
{
|
||||
"none",
|
||||
"wireframe",
|
||||
"surface",
|
||||
"surfaceWithEdges",
|
||||
"glyph"
|
||||
};
|
||||
}
|
||||
|
||||
const Foam::NamedEnum
|
||||
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::functionObjects::runTimePostPro::surface::representationType,
|
||||
5
|
||||
Foam::functionObjects::runTimePostPro::surface::representationType
|
||||
>
|
||||
Foam::functionObjects::runTimePostPro::surface::representationTypeNames;
|
||||
Foam::functionObjects::runTimePostPro::surface::representationTypeNames
|
||||
{
|
||||
{ representationType::rtNone, "none" },
|
||||
{ representationType::rtWireframe, "wireframe" },
|
||||
{ representationType::rtSurface, "surface" },
|
||||
{ representationType::rtSurfaceWithEdges, "surfaceWithEdges" },
|
||||
{ representationType::rtGlyph, "glyph" },
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
@ -120,8 +114,7 @@ void Foam::functionObjects::runTimePostPro::surface::addFeatureEdges
|
||||
return;
|
||||
}
|
||||
|
||||
vtkSmartPointer<vtkFeatureEdges> featureEdges =
|
||||
vtkSmartPointer<vtkFeatureEdges>::New();
|
||||
auto featureEdges = vtkSmartPointer<vtkFeatureEdges>::New();
|
||||
featureEdges->SetInputData(data);
|
||||
featureEdges->BoundaryEdgesOn();
|
||||
featureEdges->FeatureEdgesOn();
|
||||
@ -131,8 +124,7 @@ void Foam::functionObjects::runTimePostPro::surface::addFeatureEdges
|
||||
featureEdges->ColoringOff();
|
||||
featureEdges->Update();
|
||||
|
||||
vtkSmartPointer<vtkPolyDataMapper> mapper =
|
||||
vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
mapper->SetInputConnection(featureEdges->GetOutputPort());
|
||||
mapper->ScalarVisibilityOff();
|
||||
|
||||
@ -157,7 +149,7 @@ Foam::functionObjects::runTimePostPro::surface::surface
|
||||
geometryBase(parent, dict, colours),
|
||||
representation_
|
||||
(
|
||||
representationTypeNames.read(dict.lookup("representation"))
|
||||
representationTypeNames.lookup("representation", dict)
|
||||
),
|
||||
featureEdges_(false),
|
||||
surfaceColour_(nullptr),
|
||||
@ -217,15 +209,14 @@ Foam::functionObjects::runTimePostPro::surface::New
|
||||
Info<< "Selecting surface " << surfaceType << endl;
|
||||
}
|
||||
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(surfaceType);
|
||||
auto cstrIter = dictionaryConstructorTablePtr_->cfind(surfaceType);
|
||||
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown surface type "
|
||||
<< surfaceType << nl << nl
|
||||
<< "Valid surface types are:" << endl
|
||||
<< "Valid surface types :" << endl
|
||||
<< dictionaryConstructorTablePtr_->sortedToc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ SourceFiles
|
||||
#define functionObjects_runTimePostPro_surface_H
|
||||
|
||||
#include "geometryBase.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "Enum.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
|
||||
#include "vtkSmartPointer.h"
|
||||
@ -74,7 +74,7 @@ public:
|
||||
rtGlyph
|
||||
};
|
||||
|
||||
static const NamedEnum<representationType, 5> representationTypeNames;
|
||||
static const Enum<representationType> representationTypeNames;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@ -81,7 +81,7 @@ void Foam::functionObjects::runTimePostPro::text::addGeometryToScene
|
||||
return;
|
||||
}
|
||||
|
||||
vtkSmartPointer<vtkTextActor> actor = vtkSmartPointer<vtkTextActor>::New();
|
||||
auto actor = vtkSmartPointer<vtkTextActor>::New();
|
||||
|
||||
// Concatenate string with timeStamp if true
|
||||
string textAndTime = string_;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -48,38 +48,56 @@ namespace functionObjects
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
const char* Foam::NamedEnum
|
||||
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::functionObjects::abort::actionType,
|
||||
3
|
||||
>::names[] =
|
||||
Foam::Time::stopAtControls
|
||||
>
|
||||
Foam::functionObjects::abort::actionNames_
|
||||
{
|
||||
"noWriteNow",
|
||||
"writeNow",
|
||||
"nextWrite"
|
||||
{ Time::stopAtControls::saNoWriteNow, "noWriteNow" },
|
||||
{ Time::stopAtControls::saWriteNow, "writeNow" },
|
||||
{ Time::stopAtControls::saNextWrite, "nextWrite" },
|
||||
};
|
||||
|
||||
const Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::abort::actionType,
|
||||
3
|
||||
> Foam::functionObjects::abort::actionTypeNames_;
|
||||
|
||||
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::abort::removeFile() const
|
||||
// file-scope
|
||||
// Long description for the action name
|
||||
namespace Foam
|
||||
{
|
||||
bool hasAbort = isFile(abortFile_);
|
||||
reduce(hasAbort, orOp<bool>());
|
||||
|
||||
if (hasAbort && Pstream::master())
|
||||
static std::string longDescription(const Time::stopAtControls ctrl)
|
||||
{
|
||||
switch (ctrl)
|
||||
{
|
||||
// Cleanup ABORT file (on master only)
|
||||
rm(abortFile_);
|
||||
case Foam::Time::saNoWriteNow :
|
||||
{
|
||||
return "stop without writing data";
|
||||
break;
|
||||
}
|
||||
|
||||
case Time::saWriteNow :
|
||||
{
|
||||
return "stop and write data";
|
||||
break;
|
||||
}
|
||||
|
||||
case Time::saNextWrite :
|
||||
{
|
||||
return "stop after next data write";
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
// Invalid choices already filtered out by Enum
|
||||
return "abort";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
@ -94,13 +112,17 @@ Foam::functionObjects::abort::abort
|
||||
functionObject(name),
|
||||
time_(runTime),
|
||||
abortFile_("$FOAM_CASE/" + name),
|
||||
action_(nextWrite)
|
||||
action_(Time::stopAtControls::saNextWrite),
|
||||
triggered_(false)
|
||||
{
|
||||
abortFile_.expand();
|
||||
read(dict);
|
||||
|
||||
// Remove any old files from previous runs
|
||||
removeFile();
|
||||
// Cleanup old files from previous runs
|
||||
if (Pstream::master())
|
||||
{
|
||||
Foam::rm(abortFile_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -116,68 +138,56 @@ bool Foam::functionObjects::abort::read(const dictionary& dict)
|
||||
{
|
||||
functionObject::read(dict);
|
||||
|
||||
if (dict.found("action"))
|
||||
{
|
||||
action_ = actionTypeNames_.read(dict.lookup("action"));
|
||||
}
|
||||
else
|
||||
{
|
||||
action_ = nextWrite;
|
||||
}
|
||||
|
||||
if (dict.readIfPresent("file", abortFile_))
|
||||
{
|
||||
abortFile_.expand();
|
||||
}
|
||||
|
||||
const auto oldAction = action_;
|
||||
|
||||
action_ = actionNames_.lookupOrDefault
|
||||
(
|
||||
"action",
|
||||
dict,
|
||||
Time::stopAtControls::saNextWrite
|
||||
);
|
||||
|
||||
// User can change action and re-trigger the abort.
|
||||
// eg, they had nextWrite, but actually wanted writeNow.
|
||||
if (oldAction != action_)
|
||||
{
|
||||
triggered_ = false;
|
||||
}
|
||||
|
||||
Info<< type() << " activated ("
|
||||
<< longDescription(action_).c_str() <<")" << nl
|
||||
<< " File: " << abortFile_ << endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::abort::execute()
|
||||
{
|
||||
bool hasAbort = isFile(abortFile_);
|
||||
reduce(hasAbort, orOp<bool>());
|
||||
|
||||
if (hasAbort)
|
||||
// If it has been triggered (eg, nextWrite) don't need to check it again
|
||||
if (!triggered_)
|
||||
{
|
||||
switch (action_)
|
||||
bool hasAbort = (Pstream::master() && isFile(abortFile_));
|
||||
Pstream::scatter(hasAbort);
|
||||
|
||||
if (hasAbort)
|
||||
{
|
||||
case noWriteNow :
|
||||
triggered_ = time_.stopAt(action_);
|
||||
|
||||
if (triggered_)
|
||||
{
|
||||
if (time_.stopAt(Time::saNoWriteNow))
|
||||
{
|
||||
Info<< "USER REQUESTED ABORT (timeIndex="
|
||||
<< time_.timeIndex()
|
||||
<< "): stop without writing data"
|
||||
<< endl;
|
||||
}
|
||||
break;
|
||||
Info<< "USER REQUESTED ABORT (timeIndex="
|
||||
<< time_.timeIndex()
|
||||
<< "): " << longDescription(action_).c_str()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
case writeNow :
|
||||
{
|
||||
if (time_.stopAt(Time::saWriteNow))
|
||||
{
|
||||
Info<< "USER REQUESTED ABORT (timeIndex="
|
||||
<< time_.timeIndex()
|
||||
<< "): stop+write data"
|
||||
<< endl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case nextWrite :
|
||||
{
|
||||
if (time_.stopAt(Time::saNextWrite))
|
||||
{
|
||||
Info<< "USER REQUESTED ABORT (timeIndex="
|
||||
<< time_.timeIndex()
|
||||
<< "): stop after next data write"
|
||||
<< endl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
Pstream::scatter(triggered_);
|
||||
}
|
||||
}
|
||||
|
||||
@ -193,7 +203,12 @@ bool Foam::functionObjects::abort::write()
|
||||
|
||||
bool Foam::functionObjects::abort::end()
|
||||
{
|
||||
removeFile();
|
||||
// Cleanup ABORT file
|
||||
if (Pstream::master())
|
||||
{
|
||||
Foam::rm(abortFile_);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -30,12 +30,21 @@ Group
|
||||
Description
|
||||
Watches for presence of the named file in the $FOAM_CASE directory
|
||||
and aborts the calculation if it is present.
|
||||
The presence of the abort file is only checked on the master process.
|
||||
|
||||
Currently the following action types are supported:
|
||||
- noWriteNow
|
||||
- writeNow
|
||||
- nextWrite
|
||||
|
||||
\heading Function object usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | Type name: abort | yes |
|
||||
file | The abort filename | no | $FOAM_CASE/name
|
||||
action | Abort action | no | nextWrite
|
||||
\endtable
|
||||
|
||||
SourceFiles
|
||||
abort.C
|
||||
|
||||
@ -45,7 +54,7 @@ SourceFiles
|
||||
#define functionObjects_abort_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -55,52 +64,38 @@ namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class abort Declaration
|
||||
Class abort Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class abort
|
||||
:
|
||||
public functionObject
|
||||
{
|
||||
public:
|
||||
|
||||
// Public data
|
||||
|
||||
//- Enumeration defining the type of action
|
||||
enum actionType
|
||||
{
|
||||
noWriteNow, //!< stop immediately without writing data
|
||||
writeNow, //!< write data and stop immediately
|
||||
nextWrite //!< stop the next time data are written
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- A subset of Time stopAtControls
|
||||
static const Enum<Time::stopAtControls> actionNames_;
|
||||
|
||||
//- Reference to the Time
|
||||
const Time& time_;
|
||||
|
||||
//- The fully-qualified name of the abort file
|
||||
fileName abortFile_;
|
||||
|
||||
//- Action type names
|
||||
static const NamedEnum<actionType, 3> actionTypeNames_;
|
||||
|
||||
//- The type of action
|
||||
actionType action_;
|
||||
Time::stopAtControls action_;
|
||||
|
||||
//- Only trigger action once
|
||||
bool triggered_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Remove abort file.
|
||||
void removeFile() const;
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
abort(const abort&);
|
||||
abort(const abort&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const abort&);
|
||||
void operator=(const abort&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
@ -116,7 +111,7 @@ public:
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary&
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
@ -127,15 +122,15 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Read the dictionary settings
|
||||
virtual bool read(const dictionary&);
|
||||
virtual bool read(const dictionary& dict);
|
||||
|
||||
//- Execute, check existence of abort file and take action
|
||||
//- Check existence of abort file and take action
|
||||
virtual bool execute();
|
||||
|
||||
//- Execute, check existence of abort file and take action
|
||||
//- No-op
|
||||
virtual bool write();
|
||||
|
||||
//- Execute at the final time-loop, used for cleanup
|
||||
//- Remove abort file after the final time-loop.
|
||||
virtual bool end();
|
||||
};
|
||||
|
||||
|
||||
@ -47,32 +47,21 @@ namespace runTimeControls
|
||||
}
|
||||
}
|
||||
}
|
||||
template<>
|
||||
const char* Foam::NamedEnum
|
||||
<
|
||||
Foam
|
||||
::functionObjects
|
||||
::runTimeControls
|
||||
::equationInitialResidualCondition
|
||||
::operatingMode,
|
||||
2
|
||||
>::names[] =
|
||||
{
|
||||
"minimum",
|
||||
"maximum"
|
||||
};
|
||||
|
||||
const Foam::NamedEnum
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam
|
||||
::functionObjects
|
||||
::runTimeControls
|
||||
::equationInitialResidualCondition
|
||||
::operatingMode,
|
||||
2
|
||||
::operatingMode
|
||||
>
|
||||
Foam::functionObjects::runTimeControls::equationInitialResidualCondition::
|
||||
operatingModeNames;
|
||||
operatingModeNames
|
||||
{
|
||||
{ operatingMode::omMin, "minimum" },
|
||||
{ operatingMode::omMax, "maximum" },
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
@ -90,7 +79,7 @@ equationInitialResidualCondition
|
||||
fieldNames_(dict.lookup("fields")),
|
||||
value_(readScalar(dict.lookup("value"))),
|
||||
timeStart_(dict.lookupOrDefault("timeStart", -GREAT)),
|
||||
mode_(operatingModeNames.read(dict.lookup("mode")))
|
||||
mode_(operatingModeNames.lookup("mode", dict))
|
||||
{
|
||||
if (fieldNames_.size())
|
||||
{
|
||||
|
||||
@ -37,7 +37,7 @@ SourceFiles
|
||||
#define functionObjects_runTimeControls_equationInitialResidualCondition_H
|
||||
|
||||
#include "runTimeCondition.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "Enum.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -64,7 +64,7 @@ public:
|
||||
omMax //!< Maximum
|
||||
};
|
||||
|
||||
static const NamedEnum<operatingMode, 2> operatingModeNames;
|
||||
static const Enum<operatingMode> operatingModeNames;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@ -57,27 +57,19 @@ namespace runTimeControls
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
const char* Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::runTimeControls::minMaxCondition::modeType,
|
||||
2
|
||||
>::names[] =
|
||||
{
|
||||
"minimum",
|
||||
"maximum"
|
||||
};
|
||||
|
||||
const Foam::NamedEnum
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam
|
||||
::functionObjects
|
||||
::runTimeControls
|
||||
::minMaxCondition
|
||||
::modeType,
|
||||
2
|
||||
::modeType
|
||||
>
|
||||
Foam::functionObjects::runTimeControls::minMaxCondition::modeTypeNames_;
|
||||
Foam::functionObjects::runTimeControls::minMaxCondition::modeTypeNames_
|
||||
{
|
||||
{ modeType::mdMin, "minimum" },
|
||||
{ modeType::mdMax, "maximum" },
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
@ -92,7 +84,7 @@ Foam::functionObjects::runTimeControls::minMaxCondition::minMaxCondition
|
||||
:
|
||||
runTimeCondition(name, obr, dict, state),
|
||||
functionObjectName_(dict.lookup("functionObject")),
|
||||
mode_(modeTypeNames_.read(dict.lookup("mode"))),
|
||||
mode_(modeTypeNames_.lookup("mode", dict)),
|
||||
fieldNames_(dict.lookup("fields")),
|
||||
value_(readScalar(dict.lookup("value")))
|
||||
{}
|
||||
|
||||
@ -38,7 +38,7 @@ SourceFiles
|
||||
#define functionObjects_runTimeControls_minMaxCondition_H
|
||||
|
||||
#include "runTimeCondition.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "Enum.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -68,7 +68,7 @@ public:
|
||||
mdMax //!< Maximum
|
||||
};
|
||||
|
||||
static const NamedEnum<modeType, 2> modeTypeNames_;
|
||||
static const Enum<modeType> modeTypeNames_;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@ -37,7 +37,6 @@ SourceFiles
|
||||
#define functionObjects_runTimeConditions_minTimeStepCondition_H
|
||||
|
||||
#include "runTimeCondition.H"
|
||||
#include "NamedEnum.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -36,19 +36,18 @@ Foam::functionObjects::runTimeControls::runTimeCondition::New
|
||||
stateFunctionObject& state
|
||||
)
|
||||
{
|
||||
word conditionType(dict.lookup("type"));
|
||||
const word conditionType(dict.lookup("type"));
|
||||
|
||||
Info<< "Selecting runTimeCondition " << conditionType << endl;
|
||||
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(conditionType);
|
||||
auto cstrIter = dictionaryConstructorTablePtr_->cfind(conditionType);
|
||||
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown runTimeCondition type "
|
||||
<< conditionType << nl << nl
|
||||
<< "Valid runTimeCondition types are:" << nl
|
||||
<< "Valid runTimeCondition types :" << nl
|
||||
<< dictionaryConstructorTablePtr_->sortedToc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
@ -45,24 +45,17 @@ namespace functionObjects
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
const char* Foam::NamedEnum
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::functionObjects::writeObjects::writeOption,
|
||||
3
|
||||
>::names[] =
|
||||
Foam::functionObjects::writeObjects::writeOption
|
||||
>
|
||||
Foam::functionObjects::writeObjects::writeOptionNames_
|
||||
{
|
||||
"autoWrite",
|
||||
"noWrite",
|
||||
"anyWrite"
|
||||
{ writeOption::AUTO_WRITE, "autoWrite" },
|
||||
{ writeOption::NO_WRITE, "noWrite" },
|
||||
{ writeOption::ANY_WRITE, "anyWrite" },
|
||||
};
|
||||
|
||||
const Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::writeObjects::writeOption,
|
||||
3
|
||||
> Foam::functionObjects::writeObjects::writeOptionNames_;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -114,14 +107,12 @@ bool Foam::functionObjects::writeObjects::read(const dictionary& dict)
|
||||
dict.lookup("objects") >> objectNames_;
|
||||
}
|
||||
|
||||
if (dict.found("writeOption"))
|
||||
{
|
||||
writeOption_ = writeOptionNames_.read(dict.lookup("writeOption"));
|
||||
}
|
||||
else
|
||||
{
|
||||
writeOption_ = ANY_WRITE;
|
||||
}
|
||||
writeOption_ = writeOptionNames_.lookupOrDefault
|
||||
(
|
||||
"writeOption",
|
||||
dict,
|
||||
writeOption::ANY_WRITE
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -84,8 +84,8 @@ SourceFiles
|
||||
#define functionObjects_writeObjects_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "wordReList.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "wordRes.H"
|
||||
#include "Enum.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -119,7 +119,7 @@ public:
|
||||
ANY_WRITE
|
||||
};
|
||||
|
||||
static const NamedEnum<writeOption, 3> writeOptionNames_;
|
||||
static const Enum<writeOption> writeOptionNames_;
|
||||
|
||||
private:
|
||||
|
||||
@ -138,10 +138,10 @@ private:
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
writeObjects(const writeObjects&);
|
||||
writeObjects(const writeObjects&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const writeObjects&);
|
||||
void operator=(const writeObjects&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user