OpenFOAM: Simplified the handling of global switches and constants
to improve robustness and maintainability. Now all switches and constants are set correctly on constructions without the need for dynamic update after the system/controlDict is read. This significantly simplifies the code and make it much easier to add new switches, constants and settings without the need to ensure they are registered to a database for update.
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -40,38 +40,6 @@ int sigStopAtWriteNow::signal_
|
||||
debug::optimisationSwitch("stopAtWriteNowSignal", -1)
|
||||
);
|
||||
|
||||
// Register re-reader
|
||||
class addstopAtWriteNowSignalToOpt
|
||||
:
|
||||
public ::Foam::simpleRegIOobject
|
||||
{
|
||||
public:
|
||||
|
||||
addstopAtWriteNowSignalToOpt(const char* name)
|
||||
:
|
||||
::Foam::simpleRegIOobject(Foam::debug::addOptimisationObject, name)
|
||||
{}
|
||||
|
||||
virtual ~addstopAtWriteNowSignalToOpt()
|
||||
{}
|
||||
|
||||
virtual void readData(Foam::Istream& is)
|
||||
{
|
||||
sigStopAtWriteNow::signal_ = readLabel(is);
|
||||
sigStopAtWriteNow::set(writeInfoHeader);
|
||||
}
|
||||
|
||||
virtual void writeData(Foam::Ostream& os) const
|
||||
{
|
||||
os << sigStopAtWriteNow::signal_;
|
||||
}
|
||||
};
|
||||
|
||||
addstopAtWriteNowSignalToOpt addstopAtWriteNowSignalToOpt_
|
||||
(
|
||||
"stopAtWriteNowSignal"
|
||||
);
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -40,36 +40,6 @@ int sigWriteNow::signal_
|
||||
debug::optimisationSwitch("writeNowSignal", -1)
|
||||
);
|
||||
|
||||
// Register re-reader
|
||||
class addwriteNowSignalToOpt
|
||||
:
|
||||
public ::Foam::simpleRegIOobject
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
addwriteNowSignalToOpt(const char* name)
|
||||
:
|
||||
::Foam::simpleRegIOobject(Foam::debug::addOptimisationObject, name)
|
||||
{}
|
||||
|
||||
virtual ~addwriteNowSignalToOpt()
|
||||
{}
|
||||
|
||||
virtual void readData(Foam::Istream& is)
|
||||
{
|
||||
sigWriteNow::signal_ = readLabel(is);
|
||||
sigWriteNow::set(writeInfoHeader);
|
||||
}
|
||||
|
||||
virtual void writeData(Foam::Ostream& os) const
|
||||
{
|
||||
os << sigWriteNow::signal_;
|
||||
}
|
||||
};
|
||||
|
||||
addwriteNowSignalToOpt addwriteNowSignalToOpt_("writeNowSignal");
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
|
||||
@ -26,7 +26,6 @@ License
|
||||
#include "IOobject.H"
|
||||
#include "Time.H"
|
||||
#include "IFstream.H"
|
||||
#include "registerNamedEnum.H"
|
||||
#include "OSspecific.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
@ -59,15 +58,6 @@ Foam::IOobject::fileCheckTypes Foam::IOobject::fileModificationChecking
|
||||
)
|
||||
);
|
||||
|
||||
// Register re-reader
|
||||
registerOptNamedEnum
|
||||
(
|
||||
"fileModificationChecking",
|
||||
Foam::IOobject::fileCheckTypesNames,
|
||||
Foam::IOobject::fileModificationChecking
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::IOobject::fileNameComponents
|
||||
|
||||
@ -27,7 +27,6 @@ License
|
||||
#include "objectRegistry.H"
|
||||
#include "Pstream.H"
|
||||
#include "Time.H"
|
||||
#include "registerSwitch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -39,13 +38,6 @@ namespace Foam
|
||||
(
|
||||
debug::infoSwitch("writeDictionaries", 0)
|
||||
);
|
||||
|
||||
registerInfoSwitch
|
||||
(
|
||||
"writeDictionaries",
|
||||
bool,
|
||||
IOdictionary::writeDictionaries
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -25,8 +25,6 @@ License
|
||||
|
||||
#include "UPstream.H"
|
||||
#include "debug.H"
|
||||
#include "registerSwitch.H"
|
||||
#include "registerNamedEnum.H"
|
||||
#include "dictionary.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
@ -435,23 +433,11 @@ bool Foam::UPstream::floatTransfer
|
||||
(
|
||||
Foam::debug::optimisationSwitch("floatTransfer", 0)
|
||||
);
|
||||
registerOptSwitch
|
||||
(
|
||||
"floatTransfer",
|
||||
bool,
|
||||
Foam::UPstream::floatTransfer
|
||||
);
|
||||
|
||||
int Foam::UPstream::nProcsSimpleSum
|
||||
(
|
||||
Foam::debug::optimisationSwitch("nProcsSimpleSum", 16)
|
||||
);
|
||||
registerOptSwitch
|
||||
(
|
||||
"nProcsSimpleSum",
|
||||
int,
|
||||
Foam::UPstream::nProcsSimpleSum
|
||||
);
|
||||
|
||||
Foam::UPstream::commsTypes Foam::UPstream::defaultCommsType
|
||||
(
|
||||
@ -462,12 +448,6 @@ Foam::UPstream::commsTypes Foam::UPstream::defaultCommsType
|
||||
defaultCommsType
|
||||
)
|
||||
);
|
||||
registerOptNamedEnum
|
||||
(
|
||||
"commsType",
|
||||
Foam::UPstream::commsTypeNames,
|
||||
Foam::UPstream::defaultCommsType
|
||||
);
|
||||
|
||||
Foam::label Foam::UPstream::worldComm(0);
|
||||
|
||||
@ -477,12 +457,6 @@ int Foam::UPstream::nPollProcInterfaces
|
||||
(
|
||||
Foam::debug::optimisationSwitch("nPollProcInterfaces", 0)
|
||||
);
|
||||
registerOptSwitch
|
||||
(
|
||||
"nPollProcInterfaces",
|
||||
int,
|
||||
Foam::UPstream::nPollProcInterfaces
|
||||
);
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -24,11 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "Time.H"
|
||||
#include "PstreamReduceOps.H"
|
||||
#include "argList.H"
|
||||
#include "IOdictionary.H"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * * //
|
||||
|
||||
@ -446,6 +442,32 @@ Foam::Time::Time
|
||||
// from it reads as well (e.g. fvSolution).
|
||||
readOpt() = IOobject::MUST_READ_IF_MODIFIED;
|
||||
|
||||
if (args.options().found("case"))
|
||||
{
|
||||
const wordList switchSets
|
||||
(
|
||||
{
|
||||
"InfoSwitches",
|
||||
"OptimisationSwitches",
|
||||
"DebugSwitches",
|
||||
"DimensionedConstants",
|
||||
"DimensionSets"
|
||||
}
|
||||
);
|
||||
|
||||
forAll(switchSets, i)
|
||||
{
|
||||
if (controlDict_.found(switchSets[i]))
|
||||
{
|
||||
IOWarningInFunction(controlDict_)
|
||||
<< switchSets[i]
|
||||
<< " in system/controlDict are only processed if "
|
||||
<< args.executable() << " is run in the "
|
||||
<< args.path() << " directory" << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setControls();
|
||||
|
||||
// Add a watch on the controlDict file after runTimeModifiable_ is set
|
||||
|
||||
@ -24,12 +24,6 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "Time.H"
|
||||
#include "Pstream.H"
|
||||
#include "simpleObjectRegistry.H"
|
||||
#include "registerSwitch.H"
|
||||
#include "dimensionedConstants.H"
|
||||
#include "IOdictionary.H"
|
||||
#include "fileOperation.H"
|
||||
#include "OSspecific.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
@ -43,65 +37,6 @@ void Foam::Time::readDict()
|
||||
setEnv("FOAM_APPLICATION", application, false);
|
||||
}
|
||||
|
||||
// Check for local switches and settings and update
|
||||
debug::readSwitches("Debug", debug::debugObjects(), controlDict_);
|
||||
debug::readSwitches("Info", debug::infoObjects(), controlDict_);
|
||||
debug::readSwitches
|
||||
(
|
||||
"Optimisation",
|
||||
debug::optimisationObjects(),
|
||||
controlDict_
|
||||
);
|
||||
|
||||
// Handle fileHandler override explicitly since interacts with local
|
||||
// dictionary monitoring
|
||||
if (controlDict_.found("OptimisationSwitches"))
|
||||
{
|
||||
const dictionary& localSettings =
|
||||
controlDict_.subDict("OptimisationSwitches");
|
||||
|
||||
word fileHandlerName;
|
||||
if
|
||||
(
|
||||
localSettings.readIfPresent("fileHandler", fileHandlerName)
|
||||
&& fileHandler().type() != fileHandlerName
|
||||
)
|
||||
{
|
||||
// Remove the old watches since destroying the file
|
||||
fileNameList oldWatchedFiles(controlDict_.watchIndices());
|
||||
forAllReverse(controlDict_.watchIndices(), i)
|
||||
{
|
||||
label watchi = controlDict_.watchIndices()[i];
|
||||
oldWatchedFiles[i] = fileHandler().getFile(watchi);
|
||||
fileHandler().removeWatch(watchi);
|
||||
}
|
||||
controlDict_.watchIndices().clear();
|
||||
|
||||
// Installing the new handler
|
||||
InfoHeader
|
||||
<< "Overriding fileHandler to " << fileHandlerName << endl;
|
||||
|
||||
autoPtr<fileOperation> handler
|
||||
(
|
||||
fileOperation::New
|
||||
(
|
||||
fileHandlerName,
|
||||
true
|
||||
)
|
||||
);
|
||||
Foam::fileHandler(handler);
|
||||
|
||||
// Reinstall old watches
|
||||
fileHandler().addWatches(controlDict_, oldWatchedFiles);
|
||||
}
|
||||
}
|
||||
|
||||
// Check for local dimensionSets and update
|
||||
readDimensionSets(controlDict_);
|
||||
|
||||
// Check for local dimensionedConstants and update
|
||||
readDimensionedConstants(controlDict_);
|
||||
|
||||
if (!deltaTchanged_)
|
||||
{
|
||||
deltaT_ = controlDict_.lookup<scalar>("deltaT");
|
||||
|
||||
@ -31,7 +31,6 @@ License
|
||||
#include "DynamicList.H"
|
||||
#include "inputSyntaxEntry.H"
|
||||
#include "fileOperation.H"
|
||||
#include "registerSwitch.H"
|
||||
#include "stringOps.H"
|
||||
|
||||
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
|
||||
@ -48,13 +47,6 @@ bool Foam::dictionary::writeOptionalEntries
|
||||
Foam::debug::infoSwitch("writeOptionalEntries", 0)
|
||||
);
|
||||
|
||||
registerInfoSwitch
|
||||
(
|
||||
"writeOptionalEntries",
|
||||
bool,
|
||||
Foam::dictionary::writeOptionalEntries
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -26,7 +26,6 @@ License
|
||||
#include "entry.H"
|
||||
#include "dictionary.H"
|
||||
#include "OStringStream.H"
|
||||
#include "registerSwitch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -35,13 +34,6 @@ int Foam::entry::disableFunctionEntries
|
||||
Foam::debug::infoSwitch("disableFunctionEntries", 0)
|
||||
);
|
||||
|
||||
registerInfoSwitch
|
||||
(
|
||||
"disableFunctionEntries",
|
||||
int,
|
||||
Foam::entry::disableFunctionEntries
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -26,7 +26,6 @@ License
|
||||
#include "regIOobject.H"
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
#include "registerSwitch.H"
|
||||
#include "fileOperation.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -25,16 +25,12 @@ License
|
||||
|
||||
#include "dimensionSet.H"
|
||||
#include "dimensionedScalar.H"
|
||||
#include "simpleObjectRegistry.H"
|
||||
#include "demandDrivenData.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
|
||||
|
||||
// Since dimensionSystems() can be reread we actually store a copy of
|
||||
// the controlDict subDict (v.s. a reference to the subDict for e.g.
|
||||
// dimensionedConstants)
|
||||
@ -42,47 +38,11 @@ dictionary* dimensionSystemsPtr_(nullptr);
|
||||
HashTable<dimensionedScalar>* unitSetPtr_(nullptr);
|
||||
dimensionSets* writeUnitSetPtr_(nullptr);
|
||||
|
||||
// Helper class to
|
||||
// register re-reader
|
||||
// deallocate demand-driven data
|
||||
class addDimensionSetsToDebug
|
||||
:
|
||||
public simpleRegIOobject
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
addDimensionSetsToDebug(const char* name)
|
||||
:
|
||||
simpleRegIOobject(debug::addDimensionSetObject, name)
|
||||
{}
|
||||
|
||||
virtual ~addDimensionSetsToDebug()
|
||||
{
|
||||
deleteDemandDrivenData(dimensionSystemsPtr_);
|
||||
deleteDemandDrivenData(unitSetPtr_);
|
||||
deleteDemandDrivenData(writeUnitSetPtr_);
|
||||
|
||||
}
|
||||
|
||||
virtual void readData(Istream& is)
|
||||
{
|
||||
deleteDemandDrivenData(dimensionSystemsPtr_);
|
||||
deleteDemandDrivenData(unitSetPtr_);
|
||||
deleteDemandDrivenData(writeUnitSetPtr_);
|
||||
dimensionSystemsPtr_ = new dictionary(is);
|
||||
}
|
||||
|
||||
virtual void writeData(Ostream& os) const
|
||||
{
|
||||
os << dimensionSystems();
|
||||
}
|
||||
};
|
||||
|
||||
addDimensionSetsToDebug addDimensionSetsToDebug_("DimensionSets");
|
||||
|
||||
|
||||
dictionary& dimensionSystems()
|
||||
Foam::dictionary& Foam::dimensionSystems()
|
||||
{
|
||||
if (!dimensionSystemsPtr_)
|
||||
{
|
||||
@ -100,7 +60,7 @@ dictionary& dimensionSystems()
|
||||
}
|
||||
|
||||
|
||||
const HashTable<dimensionedScalar>& unitSet()
|
||||
const Foam::HashTable<Foam::dimensionedScalar>& Foam::unitSet()
|
||||
{
|
||||
if (!unitSetPtr_)
|
||||
{
|
||||
@ -166,7 +126,7 @@ const HashTable<dimensionedScalar>& unitSet()
|
||||
}
|
||||
|
||||
|
||||
const dimensionSets& writeUnitSet()
|
||||
const Foam::dimensionSets& Foam::writeUnitSet()
|
||||
{
|
||||
if (!writeUnitSetPtr_)
|
||||
{
|
||||
@ -176,72 +136,35 @@ const dimensionSets& writeUnitSet()
|
||||
}
|
||||
|
||||
|
||||
void readDimensionSets(const dictionary& dict)
|
||||
{
|
||||
if (dict.found("DimensionSets"))
|
||||
{
|
||||
InfoHeader
|
||||
<< "Overriding DimensionSets according to "
|
||||
<< dict.name() << endl;
|
||||
const Foam::dimensionSet Foam::dimless(0, 0, 0, 0, 0, 0, 0);
|
||||
|
||||
dictionary dimensionSetDict(Foam::dimensionSystems());
|
||||
dimensionSetDict.merge(dict.subDict("DimensionSets"));
|
||||
const Foam::dimensionSet Foam::dimMass(1, 0, 0, 0, 0, 0, 0);
|
||||
const Foam::dimensionSet Foam::dimLength(0, 1, 0, 0, 0, 0, 0);
|
||||
const Foam::dimensionSet Foam::dimTime(0, 0, 1, 0, 0, 0, 0);
|
||||
const Foam::dimensionSet Foam::dimTemperature(0, 0, 0, 1, 0, 0, 0);
|
||||
const Foam::dimensionSet Foam::dimMoles(0, 0, 0, 0, 1, 0, 0);
|
||||
const Foam::dimensionSet Foam::dimCurrent(0, 0, 0, 0, 0, 1, 0);
|
||||
const Foam::dimensionSet Foam::dimLuminousIntensity(0, 0, 0, 0, 0, 0, 1);
|
||||
|
||||
simpleObjectRegistry& objects = debug::dimensionSetObjects();
|
||||
simpleObjectRegistryEntry* objPtr = objects.lookupPtr("DimensionSets");
|
||||
const Foam::dimensionSet Foam::dimArea(sqr(dimLength));
|
||||
const Foam::dimensionSet Foam::dimVolume(pow3(dimLength));
|
||||
const Foam::dimensionSet Foam::dimVol(dimVolume);
|
||||
|
||||
if (objPtr)
|
||||
{
|
||||
InfoHeader << dict.subDict("DimensionSets") << endl;
|
||||
const Foam::dimensionSet Foam::dimVelocity(dimLength/dimTime);
|
||||
const Foam::dimensionSet Foam::dimAcceleration(dimVelocity/dimTime);
|
||||
|
||||
const List<simpleRegIOobject*>& objects = *objPtr;
|
||||
const Foam::dimensionSet Foam::dimDensity(dimMass/dimVolume);
|
||||
const Foam::dimensionSet Foam::dimForce(dimMass*dimAcceleration);
|
||||
const Foam::dimensionSet Foam::dimEnergy(dimForce*dimLength);
|
||||
const Foam::dimensionSet Foam::dimPower(dimEnergy/dimTime);
|
||||
|
||||
OStringStream os(IOstream::ASCII);
|
||||
os << dimensionSetDict;
|
||||
IStringStream is(os.str());
|
||||
const Foam::dimensionSet Foam::dimPressure(dimForce/dimArea);
|
||||
const Foam::dimensionSet Foam::dimCompressibility(dimDensity/dimPressure);
|
||||
const Foam::dimensionSet Foam::dimGasConstant(dimEnergy/dimMass/dimTemperature);
|
||||
const Foam::dimensionSet Foam::dimSpecificHeatCapacity(dimGasConstant);
|
||||
const Foam::dimensionSet Foam::dimViscosity(dimArea/dimTime);
|
||||
const Foam::dimensionSet Foam::dimDynamicViscosity(dimDensity*dimViscosity);
|
||||
|
||||
forAll(objects, i)
|
||||
{
|
||||
objects[i]->readData(is.rewind());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0);
|
||||
|
||||
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0);
|
||||
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0);
|
||||
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0);
|
||||
const dimensionSet dimTemperature(0, 0, 0, 1, 0, 0, 0);
|
||||
const dimensionSet dimMoles(0, 0, 0, 0, 1, 0, 0);
|
||||
const dimensionSet dimCurrent(0, 0, 0, 0, 0, 1, 0);
|
||||
const dimensionSet dimLuminousIntensity(0, 0, 0, 0, 0, 0, 1);
|
||||
|
||||
const dimensionSet dimArea(sqr(dimLength));
|
||||
const dimensionSet dimVolume(pow3(dimLength));
|
||||
const dimensionSet dimVol(dimVolume);
|
||||
|
||||
const dimensionSet dimVelocity(dimLength/dimTime);
|
||||
const dimensionSet dimAcceleration(dimVelocity/dimTime);
|
||||
|
||||
const dimensionSet dimDensity(dimMass/dimVolume);
|
||||
const dimensionSet dimForce(dimMass*dimAcceleration);
|
||||
const dimensionSet dimEnergy(dimForce*dimLength);
|
||||
const dimensionSet dimPower(dimEnergy/dimTime);
|
||||
|
||||
const dimensionSet dimPressure(dimForce/dimArea);
|
||||
const dimensionSet dimCompressibility(dimDensity/dimPressure);
|
||||
const dimensionSet dimGasConstant(dimEnergy/dimMass/dimTemperature);
|
||||
const dimensionSet dimSpecificHeatCapacity(dimGasConstant);
|
||||
const dimensionSet dimViscosity(dimArea/dimTime);
|
||||
const dimensionSet dimDynamicViscosity(dimDensity*dimViscosity);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -92,6 +92,7 @@ class dimensionSets
|
||||
//- Is LU decomposition valid
|
||||
bool valid_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
@ -132,9 +133,6 @@ const HashTable<dimensionedScalar>& unitSet();
|
||||
//- Set of units
|
||||
const dimensionSets& writeUnitSet();
|
||||
|
||||
//- Read and update the dimensionSets specified in dict
|
||||
void readDimensionSets(const dictionary& dict);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -40,80 +40,51 @@ namespace constant
|
||||
const char* const atomic::group = "atomic";
|
||||
|
||||
|
||||
// Note: cannot use dimless etc. since not guaranteed to be constructed
|
||||
defineDimensionedConstantWithDefault
|
||||
// Note: cannot use dimless etc. as they may not have been constructed yet
|
||||
|
||||
const Foam::dimensionedScalar atomic::alpha
|
||||
(
|
||||
atomic,
|
||||
alpha,
|
||||
dimensionedScalar
|
||||
dimensionedConstant
|
||||
(
|
||||
atomic::group,
|
||||
"alpha",
|
||||
sqr(electromagnetic::e)
|
||||
/(2*electromagnetic::epsilon0 *universal::h *universal::c)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
const Foam::dimensionedScalar atomic::Rinf
|
||||
(
|
||||
dimensionedConstant
|
||||
(
|
||||
atomic::group,
|
||||
"Rinf",
|
||||
sqr(atomic::alpha)*atomic::me*universal::c/(2*universal::h)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
const Foam::dimensionedScalar atomic::a0
|
||||
(
|
||||
dimensionedConstant
|
||||
(
|
||||
atomic::group,
|
||||
"a0",
|
||||
atomic::alpha/(4*mathematical::pi*atomic::Rinf)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
const Foam::dimensionedScalar atomic::re
|
||||
(
|
||||
dimensionedConstant
|
||||
(
|
||||
atomic::group,
|
||||
"re",
|
||||
sqr(electromagnetic::e)
|
||||
/(
|
||||
dimensionedScalar("C", dimensionSet(0, 0, 0, 0, 0), 2.0)
|
||||
*electromagnetic::epsilon0
|
||||
*universal::h
|
||||
*universal::c
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
defineDimensionedConstantWithDefault
|
||||
(
|
||||
atomic,
|
||||
Rinf,
|
||||
dimensionedScalar
|
||||
(
|
||||
sqr(atomic::alpha)
|
||||
*atomic::me
|
||||
*universal::c
|
||||
/(
|
||||
dimensionedScalar
|
||||
(
|
||||
"C",
|
||||
dimensionSet(0, 0, 0, 0, 0),
|
||||
2.0
|
||||
)
|
||||
*universal::h
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
defineDimensionedConstantWithDefault
|
||||
(
|
||||
atomic,
|
||||
a0,
|
||||
dimensionedScalar
|
||||
(
|
||||
atomic::alpha
|
||||
/(
|
||||
dimensionedScalar
|
||||
(
|
||||
"C",
|
||||
dimensionSet(0, 0, 0, 0, 0),
|
||||
4.0*mathematical::pi
|
||||
)
|
||||
*atomic::Rinf
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
defineDimensionedConstantWithDefault
|
||||
(
|
||||
atomic,
|
||||
re,
|
||||
dimensionedScalar
|
||||
(
|
||||
sqr(electromagnetic::e)
|
||||
/(
|
||||
dimensionedScalar
|
||||
(
|
||||
"C",
|
||||
dimensionSet(0, 0, 0, 0, 0),
|
||||
4.0*mathematical::pi
|
||||
)
|
||||
4*mathematical::pi
|
||||
*electromagnetic::epsilon0
|
||||
*atomic::me
|
||||
*sqr(universal::c)
|
||||
@ -122,14 +93,13 @@ defineDimensionedConstantWithDefault
|
||||
);
|
||||
|
||||
|
||||
defineDimensionedConstantWithDefault
|
||||
const Foam::dimensionedScalar atomic::Eh
|
||||
(
|
||||
atomic,
|
||||
Eh,
|
||||
dimensionedScalar
|
||||
dimensionedConstant
|
||||
(
|
||||
dimensionedScalar("C", dimensionSet(0, 0, 0, 0, 0), 2.0)
|
||||
*atomic::Rinf*universal::h*universal::c
|
||||
atomic::group,
|
||||
"Eh",
|
||||
2*atomic::Rinf*universal::h*universal::c
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -49,20 +49,19 @@ namespace atomic
|
||||
extern const char* const group;
|
||||
|
||||
//- Fine-structure constant: default SI units: []
|
||||
extern const dimensionedScalar& alpha;
|
||||
extern const dimensionedScalar alpha;
|
||||
|
||||
//- Rydberg constant: default SI units: [1/m]
|
||||
extern const dimensionedScalar& Rinf;
|
||||
extern const dimensionedScalar Rinf;
|
||||
|
||||
//- Bohr radius: default SI units: [m]
|
||||
extern const dimensionedScalar& a0;
|
||||
extern const dimensionedScalar a0;
|
||||
|
||||
//- Classical electron radius: default SI units: [m]
|
||||
extern const dimensionedScalar& re;
|
||||
extern const dimensionedScalar re;
|
||||
|
||||
//- Hartree energy: default SI units: [J]
|
||||
extern const dimensionedScalar& Eh;
|
||||
|
||||
extern const dimensionedScalar Eh;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -43,7 +43,12 @@ Foam::dictionary& Foam::dimensionedConstants()
|
||||
}
|
||||
|
||||
|
||||
void Foam::registerDimensionedConstant::lookup()
|
||||
Foam::dimensionedScalar Foam::dimensionedConstant
|
||||
(
|
||||
const char* const group,
|
||||
const char* name,
|
||||
const dimensionSet& dimensions
|
||||
)
|
||||
{
|
||||
dictionary& dict = dimensionedConstants();
|
||||
|
||||
@ -64,88 +69,52 @@ void Foam::registerDimensionedConstant::lookup()
|
||||
<< dict.name() << std::endl;
|
||||
}
|
||||
|
||||
dimensionedScalar::operator=
|
||||
return dimensionedScalar
|
||||
(
|
||||
dimensionedScalar
|
||||
(
|
||||
name(),
|
||||
dimensions(),
|
||||
dict.subDict(unitSetCoeffs).subDict(group_)
|
||||
)
|
||||
name,
|
||||
dimensions,
|
||||
dict.subDict(unitSetCoeffs).subDict(group)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void Foam::registerDimensionedConstantWithDefault::lookup()
|
||||
Foam::dimensionedScalar Foam::dimensionedConstant
|
||||
(
|
||||
const char* const group,
|
||||
const char* name,
|
||||
const dimensionedScalar& defaultValuee
|
||||
)
|
||||
{
|
||||
dictionary& dict = dimensionedConstants();
|
||||
|
||||
const word unitSet(dict.lookup("unitSet"));
|
||||
dictionary& unitDict(dict.subDict(unitSet + "Coeffs"));
|
||||
|
||||
const dimensionedScalar defaultValue(name(), defaultFunc_());
|
||||
const dimensionedScalar defaultValue(name, defaultValuee);
|
||||
|
||||
if (unitDict.found(group_))
|
||||
if (unitDict.found(group))
|
||||
{
|
||||
dictionary& groupDict = unitDict.subDict(group_);
|
||||
if (groupDict.found(name()))
|
||||
dictionary& groupDict = unitDict.subDict(group);
|
||||
if (groupDict.found(name))
|
||||
{
|
||||
dimensionedScalar::operator=
|
||||
return dimensionedScalar
|
||||
(
|
||||
dimensionedScalar
|
||||
(
|
||||
name(),
|
||||
defaultValue.dimensions(),
|
||||
groupDict.lookup(name())
|
||||
)
|
||||
name,
|
||||
defaultValue.dimensions(),
|
||||
groupDict.lookup(name)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
groupDict.add(name(), defaultValue);
|
||||
dimensionedScalar::operator=(defaultValue);
|
||||
groupDict.add(name, defaultValue);
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unitDict.add(group_, dictionary::null);
|
||||
unitDict.subDict(group_).add(name(), defaultValue);
|
||||
dimensionedScalar::operator=(defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::readDimensionedConstants(const dictionary& dict)
|
||||
{
|
||||
if (dict.found("DimensionedConstants"))
|
||||
{
|
||||
InfoHeader
|
||||
<< "Overriding DimensionedConstants according to "
|
||||
<< dict.name() << endl;
|
||||
|
||||
// Change dimensionedConstants dictionary in-memory
|
||||
dimensionedConstants().merge(dict.subDict("DimensionedConstants"));
|
||||
|
||||
simpleObjectRegistry& objects = debug::dimensionedConstantObjects();
|
||||
|
||||
IStringStream dummyIs("");
|
||||
|
||||
forAllConstIter(simpleObjectRegistry, objects, iter)
|
||||
{
|
||||
const List<simpleRegIOobject*>& objects = *iter;
|
||||
|
||||
forAll(objects, i)
|
||||
{
|
||||
objects[i]->readData(dummyIs);
|
||||
|
||||
if (writeInfoHeader)
|
||||
{
|
||||
Info<< " ";
|
||||
objects[i]->writeData(Info);
|
||||
Info<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
unitDict.add(group, dictionary::null);
|
||||
unitDict.subDict(group).add(name, defaultValue);
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -51,127 +51,19 @@ namespace Foam
|
||||
|
||||
dictionary& dimensionedConstants();
|
||||
|
||||
dimensionedScalar dimensionedConstant
|
||||
(
|
||||
const char* const group,
|
||||
const char* name,
|
||||
const dimensionSet& dimensions
|
||||
);
|
||||
|
||||
class registerDimensionedConstant
|
||||
:
|
||||
public simpleRegIOobject,
|
||||
public dimensionedScalar
|
||||
{
|
||||
const char* const group_;
|
||||
|
||||
//- Lookup the dimensionedConstant from the registry
|
||||
void lookup();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
registerDimensionedConstant
|
||||
(
|
||||
const char* const group,
|
||||
const char* name,
|
||||
const dimensionSet& dimensions
|
||||
)
|
||||
:
|
||||
simpleRegIOobject(debug::addDimensionedConstantObject, name),
|
||||
dimensionedScalar(name, dimensions, 0),
|
||||
group_(group)
|
||||
{
|
||||
lookup();
|
||||
}
|
||||
|
||||
virtual ~registerDimensionedConstant()
|
||||
{}
|
||||
|
||||
virtual void readData(Istream& is)
|
||||
{
|
||||
lookup();
|
||||
}
|
||||
|
||||
virtual void writeData(Ostream& os) const
|
||||
{
|
||||
os << static_cast<const dimensionedScalar&>(*this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//- Defined and register a dimensioned constant
|
||||
#define defineDimensionedConstant(Group, Name, Dimensions) \
|
||||
registerDimensionedConstant register##Name##DimensionedConstant_ \
|
||||
( \
|
||||
Group::group, \
|
||||
#Name, \
|
||||
Dimensions \
|
||||
); \
|
||||
const Foam::dimensionedScalar& Group::Name \
|
||||
( \
|
||||
register##Name##DimensionedConstant_ \
|
||||
);
|
||||
|
||||
|
||||
class registerDimensionedConstantWithDefault
|
||||
:
|
||||
public simpleRegIOobject,
|
||||
public dimensionedScalar
|
||||
{
|
||||
typedef dimensionedScalar (*defaultFuncPtr)();
|
||||
|
||||
const char* const group_;
|
||||
defaultFuncPtr defaultFunc_;
|
||||
|
||||
//- Lookup the dimensionedConstant from the registry
|
||||
void lookup();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
registerDimensionedConstantWithDefault
|
||||
(
|
||||
const char* const group,
|
||||
const char* name,
|
||||
defaultFuncPtr defaultFunc
|
||||
)
|
||||
:
|
||||
simpleRegIOobject(debug::addDimensionedConstantObject, name),
|
||||
dimensionedScalar(name, defaultFunc()),
|
||||
group_(group),
|
||||
defaultFunc_(defaultFunc)
|
||||
{
|
||||
lookup();
|
||||
}
|
||||
|
||||
virtual ~registerDimensionedConstantWithDefault()
|
||||
{}
|
||||
|
||||
virtual void readData(Istream& is)
|
||||
{
|
||||
lookup();
|
||||
}
|
||||
|
||||
virtual void writeData(Ostream& os) const
|
||||
{
|
||||
os << static_cast<const dimensionedScalar&>(*this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//- Read and update the dimensionedConstants specified in dict
|
||||
void readDimensionedConstants(const dictionary& dict);
|
||||
|
||||
|
||||
//- Defined and register a dimensioned constant with default
|
||||
#define defineDimensionedConstantWithDefault(Group, Name, DefaultExpr) \
|
||||
registerDimensionedConstantWithDefault \
|
||||
register##Name##DimensionedConstant_ \
|
||||
( \
|
||||
Group::group, \
|
||||
#Name, \
|
||||
[](){return DefaultExpr;} \
|
||||
); \
|
||||
\
|
||||
const Foam::dimensionedScalar& Group::Name \
|
||||
( \
|
||||
register##Name##DimensionedConstant_ \
|
||||
);
|
||||
dimensionedScalar dimensionedConstant
|
||||
(
|
||||
const char* const group,
|
||||
const char* name,
|
||||
const dimensionedScalar& defaultValue
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -27,7 +27,6 @@ License
|
||||
#include "universalConstants.H"
|
||||
#include "electromagneticConstants.H"
|
||||
#include "atomicConstants.H"
|
||||
|
||||
#include "dimensionedConstants.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -40,107 +39,97 @@ namespace constant
|
||||
const char* const electromagnetic::group = "electromagnetic";
|
||||
|
||||
|
||||
defineDimensionedConstantWithDefault
|
||||
(
|
||||
electromagnetic,
|
||||
mu0,
|
||||
dimensionedScalar
|
||||
(
|
||||
dimensionSet(1, 1, -2, 0, 0, -2, 0),
|
||||
4*mathematical::pi*1e-07
|
||||
)
|
||||
);
|
||||
// Note: cannot use dimless etc. as they may not have been constructed yet
|
||||
|
||||
|
||||
// Note: cannot use dimless etc. since not guaranteed to be constructed
|
||||
defineDimensionedConstantWithDefault
|
||||
const Foam::dimensionedScalar electromagnetic::mu0
|
||||
(
|
||||
electromagnetic,
|
||||
epsilon0,
|
||||
dimensionedScalar
|
||||
dimensionedConstant
|
||||
(
|
||||
electromagnetic::group,
|
||||
"mu0",
|
||||
dimensionedScalar
|
||||
(
|
||||
"C",
|
||||
dimensionSet(0, 0, 0, 0, 0),
|
||||
1
|
||||
)
|
||||
/(electromagnetic::mu0*sqr(universal::c))
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
defineDimensionedConstantWithDefault
|
||||
(
|
||||
electromagnetic,
|
||||
Z0,
|
||||
dimensionedScalar(electromagnetic::mu0*universal::c)
|
||||
);
|
||||
|
||||
|
||||
defineDimensionedConstantWithDefault
|
||||
(
|
||||
electromagnetic,
|
||||
kappa,
|
||||
dimensionedScalar
|
||||
(
|
||||
dimensionedScalar
|
||||
(
|
||||
"C",
|
||||
dimensionSet(0, 0, 0, 0, 0),
|
||||
1/(4*mathematical::pi)
|
||||
)
|
||||
/electromagnetic::epsilon0
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
defineDimensionedConstantWithDefault
|
||||
(
|
||||
electromagnetic,
|
||||
G0,
|
||||
dimensionedScalar
|
||||
(
|
||||
dimensionedScalar("C", dimensionSet(0, 0, 0, 0, 0), 2)
|
||||
*sqr(electromagnetic::e)
|
||||
/universal::h
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
defineDimensionedConstantWithDefault
|
||||
(
|
||||
electromagnetic,
|
||||
KJ,
|
||||
dimensionedScalar
|
||||
(
|
||||
dimensionedScalar("C", dimensionSet(0, 0, 0, 0, 0), 2)
|
||||
*electromagnetic::e
|
||||
/universal::h
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
defineDimensionedConstantWithDefault
|
||||
(
|
||||
electromagnetic,
|
||||
phi0,
|
||||
dimensionedScalar
|
||||
(
|
||||
universal::h
|
||||
/(
|
||||
dimensionedScalar("C", dimensionSet(0, 0, 0, 0, 0), 2)
|
||||
*electromagnetic::e
|
||||
dimensionSet(1, 1, -2, 0, 0, -2, 0),
|
||||
4*mathematical::pi*1e-07
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
defineDimensionedConstantWithDefault
|
||||
const Foam::dimensionedScalar electromagnetic::epsilon0
|
||||
(
|
||||
electromagnetic,
|
||||
RK,
|
||||
dimensionedScalar(universal::h/sqr(electromagnetic::e))
|
||||
dimensionedConstant
|
||||
(
|
||||
electromagnetic::group,
|
||||
"epsilon0",
|
||||
1/(electromagnetic::mu0*sqr(universal::c))
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
const Foam::dimensionedScalar electromagnetic::Z0
|
||||
(
|
||||
dimensionedConstant
|
||||
(
|
||||
electromagnetic::group,
|
||||
"Z0",
|
||||
electromagnetic::mu0*universal::c
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
const Foam::dimensionedScalar electromagnetic::kappa
|
||||
(
|
||||
dimensionedConstant
|
||||
(
|
||||
electromagnetic::group,
|
||||
"kappa",
|
||||
(1/(4*mathematical::pi))/electromagnetic::epsilon0
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
const Foam::dimensionedScalar electromagnetic::G0
|
||||
(
|
||||
dimensionedConstant
|
||||
(
|
||||
electromagnetic::group,
|
||||
"G0",
|
||||
2*sqr(electromagnetic::e)/universal::h
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
const Foam::dimensionedScalar electromagnetic::KJ
|
||||
(
|
||||
dimensionedConstant
|
||||
(
|
||||
electromagnetic::group,
|
||||
"KJ",
|
||||
2*electromagnetic::e/universal::h
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
const Foam::dimensionedScalar electromagnetic::phi0
|
||||
(
|
||||
dimensionedConstant
|
||||
(
|
||||
electromagnetic::group,
|
||||
"phi0",
|
||||
universal::h/(2*electromagnetic::e)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
const Foam::dimensionedScalar electromagnetic::RK
|
||||
(
|
||||
dimensionedConstant
|
||||
(
|
||||
electromagnetic::group,
|
||||
"RK",
|
||||
universal::h/sqr(electromagnetic::e)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -49,29 +49,28 @@ namespace electromagnetic
|
||||
extern const char* const group;
|
||||
|
||||
//- Magnetic constant/permeability of free space: default SI units: [H/m]
|
||||
extern const dimensionedScalar& mu0;
|
||||
extern const dimensionedScalar mu0;
|
||||
|
||||
//- Electric constant: default SI units: [F/m]
|
||||
extern const dimensionedScalar& epsilon0;
|
||||
extern const dimensionedScalar epsilon0;
|
||||
|
||||
//- Characteristic impedance of a vacuum: default SI units: [ohm]
|
||||
extern const dimensionedScalar& Z0;
|
||||
extern const dimensionedScalar Z0;
|
||||
|
||||
//- Coulomb constant: default SI units: [N.m2/C2]
|
||||
extern const dimensionedScalar& kappa;
|
||||
extern const dimensionedScalar kappa;
|
||||
|
||||
//- Conductance quantum: default SI units: [S]
|
||||
extern const dimensionedScalar& G0;
|
||||
extern const dimensionedScalar G0;
|
||||
|
||||
//- Josephson constant: default SI units: [Hz/V]
|
||||
extern const dimensionedScalar& KJ;
|
||||
extern const dimensionedScalar KJ;
|
||||
|
||||
//- Magnetic flux quantum: default SI units: [Wb]
|
||||
extern const dimensionedScalar& phi0;
|
||||
extern const dimensionedScalar phi0;
|
||||
|
||||
//- Von Klitzing constant: default SI units: [ohm]
|
||||
extern const dimensionedScalar& RK;
|
||||
|
||||
extern const dimensionedScalar RK;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -27,13 +27,11 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fundamentalConstants.H"
|
||||
|
||||
#include "universalConstants.H"
|
||||
#include "electromagneticConstants.H"
|
||||
#include "atomicConstants.H"
|
||||
#include "physicoChemicalConstants.H"
|
||||
#include "standardConstants.H"
|
||||
|
||||
#include "dimensionedConstants.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -47,42 +45,100 @@ namespace constant
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
defineDimensionedConstant(universal, c, dimensionSet(0, 1, -1, 0, 0));
|
||||
defineDimensionedConstant(universal, G, dimensionSet(-1, 3, -2, 0, 0));
|
||||
defineDimensionedConstant(universal, h, dimensionSet(1, 2, -1, 0, 0));
|
||||
// Note: cannot use dimless etc. as they may not have been constructed yet
|
||||
|
||||
// Electromagnetic
|
||||
defineDimensionedConstant
|
||||
|
||||
const Foam::dimensionedScalar universal::c
|
||||
(
|
||||
electromagnetic,
|
||||
e,
|
||||
dimensionSet(0, 0, 1, 0, 0, 1, 0)
|
||||
dimensionedConstant(universal::group, "c", dimensionSet(0, 1, -1, 0, 0))
|
||||
);
|
||||
|
||||
// Atomic
|
||||
defineDimensionedConstant(atomic, me, dimensionSet(1, 0, 0, 0, 0));
|
||||
defineDimensionedConstant(atomic, mp, dimensionSet(1, 0, 0, 0, 0));
|
||||
|
||||
// Physico-chemical
|
||||
defineDimensionedConstant(physicoChemical, mu, dimensionSet(1, 0, 0, 0, 0));
|
||||
|
||||
// Note: cannot use dimless etc since not guaranteed to be constructed
|
||||
defineDimensionedConstantWithDefault
|
||||
const Foam::dimensionedScalar universal::G
|
||||
(
|
||||
physicoChemical,
|
||||
NA,
|
||||
dimensionedScalar
|
||||
dimensionedConstant(universal::group, "G", dimensionSet(-1, 3, -2, 0, 0))
|
||||
);
|
||||
|
||||
const Foam::dimensionedScalar universal::h
|
||||
(
|
||||
dimensionedConstant(universal::group, "h", dimensionSet(1, 2, -1, 0, 0))
|
||||
);
|
||||
|
||||
|
||||
// Electromagnetic
|
||||
|
||||
const Foam::dimensionedScalar electromagnetic::e
|
||||
(
|
||||
dimensionedConstant
|
||||
(
|
||||
dimensionSet(0, 0, 0, 0, -1), // dimless/dimMoles,
|
||||
6.0221417930e+23
|
||||
electromagnetic::group,
|
||||
"e",
|
||||
dimensionSet(0, 0, 1, 0, 0, 1, 0)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// Atomic
|
||||
|
||||
const Foam::dimensionedScalar atomic::me
|
||||
(
|
||||
dimensionedConstant(atomic::group, "me", dimensionSet(1, 0, 0, 0, 0))
|
||||
);
|
||||
|
||||
const Foam::dimensionedScalar atomic::mp
|
||||
(
|
||||
dimensionedConstant(atomic::group, "mp", dimensionSet(1, 0, 0, 0, 0))
|
||||
);
|
||||
|
||||
|
||||
// Physico-chemical
|
||||
|
||||
const Foam::dimensionedScalar physicoChemical::mu
|
||||
(
|
||||
dimensionedConstant
|
||||
(
|
||||
physicoChemical::group,
|
||||
"mu",
|
||||
dimensionSet(1, 0, 0, 0, 0)
|
||||
)
|
||||
);
|
||||
|
||||
const Foam::dimensionedScalar physicoChemical::NA
|
||||
(
|
||||
dimensionedConstant
|
||||
(
|
||||
physicoChemical::group,
|
||||
"NA",
|
||||
dimensionedScalar
|
||||
(
|
||||
dimensionSet(0, 0, 0, 0, -1), // dimless/dimMoles,
|
||||
6.0221417930e+23
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
const Foam::dimensionedScalar physicoChemical::k
|
||||
(
|
||||
dimensionedConstant
|
||||
(
|
||||
physicoChemical::group,
|
||||
"k",
|
||||
dimensionSet(1, 2, -2, -1, 0)
|
||||
)
|
||||
);
|
||||
|
||||
defineDimensionedConstant(physicoChemical, k, dimensionSet(1, 2, -2, -1, 0));
|
||||
|
||||
// Standard
|
||||
defineDimensionedConstant(standard, Pstd, dimensionSet(1, -1, -2, 0, 0));
|
||||
defineDimensionedConstant(standard, Tstd, dimensionSet(0, 0, 0, 1, 0));
|
||||
|
||||
const Foam::dimensionedScalar standard::Pstd
|
||||
(
|
||||
dimensionedConstant(standard::group, "Pstd", dimensionSet(1, -1, -2, 0, 0))
|
||||
);
|
||||
|
||||
const Foam::dimensionedScalar standard::Tstd
|
||||
(
|
||||
dimensionedConstant(standard::group, "Tstd", dimensionSet(0, 0, 0, 1, 0))
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -43,49 +43,49 @@ namespace constant
|
||||
namespace universal
|
||||
{
|
||||
//- Speed of light in a vacuum
|
||||
extern const dimensionedScalar& c;
|
||||
extern const dimensionedScalar c;
|
||||
|
||||
//- Newtonian constant of gravitation
|
||||
extern const dimensionedScalar& G;
|
||||
extern const dimensionedScalar G;
|
||||
|
||||
//- Planck constant
|
||||
extern const dimensionedScalar& h;
|
||||
extern const dimensionedScalar h;
|
||||
}
|
||||
|
||||
namespace electromagnetic
|
||||
{
|
||||
//- Elementary charge
|
||||
extern const dimensionedScalar& e;
|
||||
extern const dimensionedScalar e;
|
||||
}
|
||||
|
||||
namespace atomic
|
||||
{
|
||||
//- Electron mass
|
||||
extern const dimensionedScalar& me;
|
||||
extern const dimensionedScalar me;
|
||||
|
||||
//- Proton mass
|
||||
extern const dimensionedScalar& mp;
|
||||
extern const dimensionedScalar mp;
|
||||
}
|
||||
|
||||
namespace physicoChemical
|
||||
{
|
||||
//- Atomic mass unit
|
||||
extern const dimensionedScalar& mu;
|
||||
extern const dimensionedScalar mu;
|
||||
|
||||
//- Avagadro number
|
||||
extern const dimensionedScalar& NA;
|
||||
extern const dimensionedScalar NA;
|
||||
|
||||
//- Boltzmann constant
|
||||
extern const dimensionedScalar& k;
|
||||
extern const dimensionedScalar k;
|
||||
}
|
||||
|
||||
namespace standard
|
||||
{
|
||||
//- Standard pressure
|
||||
extern const dimensionedScalar& Pstd;
|
||||
extern const dimensionedScalar Pstd;
|
||||
|
||||
//- Standard temperature
|
||||
extern const dimensionedScalar& Tstd;
|
||||
extern const dimensionedScalar Tstd;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -27,7 +27,6 @@ License
|
||||
#include "universalConstants.H"
|
||||
#include "electromagneticConstants.H"
|
||||
#include "physicoChemicalConstants.H"
|
||||
|
||||
#include "dimensionedConstants.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -39,11 +38,17 @@ namespace constant
|
||||
|
||||
const char* const physicoChemical::group = "physicoChemical";
|
||||
|
||||
defineDimensionedConstantWithDefault
|
||||
|
||||
// Note: cannot use dimless etc. as they may not have been constructed yet
|
||||
|
||||
const Foam::dimensionedScalar physicoChemical::R
|
||||
(
|
||||
physicoChemical,
|
||||
R,
|
||||
dimensionedScalar(physicoChemical::NA*physicoChemical::k)
|
||||
dimensionedConstant
|
||||
(
|
||||
physicoChemical::group,
|
||||
"R",
|
||||
physicoChemical::NA*physicoChemical::k
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@ -51,80 +56,70 @@ defineDimensionedConstantWithDefault
|
||||
// SI choice of kg rather than g for mass.
|
||||
// This is not appropriate for USCS and will be changed to an entry in
|
||||
// the DimensionedConstants dictionary in etc/controlDict
|
||||
defineDimensionedConstantWithDefault
|
||||
const Foam::dimensionedScalar physicoChemical::RR
|
||||
(
|
||||
physicoChemical,
|
||||
RR,
|
||||
dimensionedScalar(1000*physicoChemical::R)
|
||||
);
|
||||
|
||||
|
||||
defineDimensionedConstantWithDefault
|
||||
(
|
||||
physicoChemical,
|
||||
F,
|
||||
dimensionedScalar(physicoChemical::NA*electromagnetic::e)
|
||||
);
|
||||
|
||||
|
||||
// Note: cannot use dimless etc. since not guaranteed to be constructed
|
||||
defineDimensionedConstantWithDefault
|
||||
(
|
||||
physicoChemical,
|
||||
sigma,
|
||||
dimensionedScalar
|
||||
dimensionedConstant
|
||||
(
|
||||
dimensionedScalar
|
||||
(
|
||||
"C",
|
||||
dimensionSet(0, 0, 0, 0, 0),
|
||||
sqr(mathematical::pi)/60.0
|
||||
)
|
||||
*pow4(physicoChemical::k)
|
||||
/(pow3(universal::hr)*sqr(universal::c))
|
||||
physicoChemical::group,
|
||||
"RR",
|
||||
1000*physicoChemical::R
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
defineDimensionedConstantWithDefault
|
||||
const Foam::dimensionedScalar physicoChemical::F
|
||||
(
|
||||
physicoChemical,
|
||||
b,
|
||||
dimensionedScalar
|
||||
dimensionedConstant
|
||||
(
|
||||
(universal::h*universal::c/physicoChemical::k)
|
||||
/dimensionedScalar
|
||||
(
|
||||
"C",
|
||||
dimensionSet(0, 0, 0, 0, 0),
|
||||
4.965114231
|
||||
)
|
||||
physicoChemical::group,
|
||||
"F",
|
||||
physicoChemical::NA*electromagnetic::e
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
defineDimensionedConstantWithDefault
|
||||
const Foam::dimensionedScalar physicoChemical::sigma
|
||||
(
|
||||
physicoChemical,
|
||||
c1,
|
||||
dimensionedScalar
|
||||
dimensionedConstant
|
||||
(
|
||||
dimensionedScalar
|
||||
(
|
||||
"C",
|
||||
dimensionSet(0, 0, 0, 0, 0),
|
||||
mathematical::twoPi
|
||||
)
|
||||
*universal::h*sqr(universal::c)
|
||||
physicoChemical::group,
|
||||
"sigma",
|
||||
(sqr(mathematical::pi)/60.0)
|
||||
*pow4(physicoChemical::k)/(pow3(universal::hr)*sqr(universal::c))
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
defineDimensionedConstantWithDefault
|
||||
const Foam::dimensionedScalar physicoChemical::b
|
||||
(
|
||||
physicoChemical,
|
||||
c2,
|
||||
dimensionedScalar(universal::h*universal::c/physicoChemical::k)
|
||||
dimensionedConstant
|
||||
(
|
||||
physicoChemical::group,
|
||||
"b",
|
||||
(universal::h*universal::c/physicoChemical::k)/4.965114231
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
const Foam::dimensionedScalar physicoChemical::c1
|
||||
(
|
||||
dimensionedConstant
|
||||
(
|
||||
physicoChemical::group,
|
||||
"c1",
|
||||
mathematical::twoPi*universal::h*sqr(universal::c)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
const Foam::dimensionedScalar physicoChemical::c2
|
||||
(
|
||||
dimensionedConstant
|
||||
(
|
||||
physicoChemical::group,
|
||||
"c2",
|
||||
universal::h*universal::c/physicoChemical::k
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -49,25 +49,25 @@ namespace physicoChemical
|
||||
extern const char* const group;
|
||||
|
||||
//- Universal gas constant: default SI units: [J/mol/K]
|
||||
extern const dimensionedScalar& R;
|
||||
extern const dimensionedScalar R;
|
||||
|
||||
//- Universal gas constant: default SI units: [J/kmol/K]
|
||||
extern const dimensionedScalar& RR;
|
||||
extern const dimensionedScalar RR;
|
||||
|
||||
//- Faraday constant: default SI units: [C/mol]
|
||||
extern const dimensionedScalar& F;
|
||||
extern const dimensionedScalar F;
|
||||
|
||||
//- Stefan-Boltzmann constant: default SI units: [W/m^2/K^4]
|
||||
extern const dimensionedScalar& sigma;
|
||||
extern const dimensionedScalar sigma;
|
||||
|
||||
//- Wien displacement law constant: default SI units: [m K]
|
||||
extern const dimensionedScalar& b;
|
||||
extern const dimensionedScalar b;
|
||||
|
||||
//- First radiation constant: default SI units: [W/m^2]
|
||||
extern const dimensionedScalar& c1;
|
||||
extern const dimensionedScalar c1;
|
||||
|
||||
//- Second radiation constant: default SI units: [m K]
|
||||
extern const dimensionedScalar& c2;
|
||||
extern const dimensionedScalar c2;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,7 +25,6 @@ License
|
||||
|
||||
#include "universalConstants.H"
|
||||
#include "mathematicalConstants.H"
|
||||
|
||||
#include "dimensionedConstants.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -37,22 +36,16 @@ namespace constant
|
||||
|
||||
const char* const universal::group = "universal";
|
||||
|
||||
// Note: cannot use dimless etc. since not guaranteed to be constructed
|
||||
defineDimensionedConstantWithDefault
|
||||
|
||||
// Note: cannot use dimless etc. as they may not have been constructed yet
|
||||
|
||||
const Foam::dimensionedScalar universal::hr
|
||||
(
|
||||
universal,
|
||||
hr,
|
||||
dimensionedScalar
|
||||
dimensionedConstant
|
||||
(
|
||||
universal::h
|
||||
/(
|
||||
dimensionedScalar
|
||||
(
|
||||
"C",
|
||||
dimensionSet(0, 0, 0, 0, 0),
|
||||
mathematical::twoPi
|
||||
)
|
||||
)
|
||||
universal::group,
|
||||
"hr",
|
||||
universal::h/mathematical::twoPi
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -49,7 +49,7 @@ namespace universal
|
||||
extern const char* const group;
|
||||
|
||||
//- Reduced Planck constant: default SI units: [J/s]
|
||||
extern const dimensionedScalar& hr;
|
||||
extern const dimensionedScalar hr;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -32,7 +32,6 @@ Description
|
||||
#include "etcFiles.H"
|
||||
#include "Ostream.H"
|
||||
#include "demandDrivenData.H"
|
||||
#include "simpleObjectRegistry.H"
|
||||
#include "IOobject.H"
|
||||
#include "HashSet.H"
|
||||
|
||||
@ -86,12 +85,6 @@ dictionary& optimisationDefaultSwitches()
|
||||
return *optimisationDefaultSwitchesPtr_;
|
||||
}
|
||||
|
||||
// Debug switch read and write callback tables.
|
||||
simpleObjectRegistry* debugObjectsPtr_(nullptr);
|
||||
simpleObjectRegistry* infoObjectsPtr_(nullptr);
|
||||
simpleObjectRegistry* optimisationObjectsPtr_(nullptr);
|
||||
simpleObjectRegistry* dimensionSetObjectsPtr_(nullptr);
|
||||
simpleObjectRegistry* dimensionedConstantObjectsPtr_(nullptr);
|
||||
|
||||
// To ensure controlDictPtr_ is deleted at the end of the run
|
||||
class deleteControlDictPtr
|
||||
@ -103,12 +96,6 @@ public:
|
||||
|
||||
~deleteControlDictPtr()
|
||||
{
|
||||
deleteDemandDrivenData(debugObjectsPtr_);
|
||||
deleteDemandDrivenData(infoObjectsPtr_);
|
||||
deleteDemandDrivenData(optimisationObjectsPtr_);
|
||||
deleteDemandDrivenData(dimensionSetObjectsPtr_);
|
||||
deleteDemandDrivenData(dimensionedConstantObjectsPtr_);
|
||||
|
||||
deleteDemandDrivenData(debugDefaultSwitchesPtr_);
|
||||
deleteDemandDrivenData(infoDefaultSwitchesPtr_);
|
||||
deleteDemandDrivenData(optimisationDefaultSwitchesPtr_);
|
||||
@ -160,6 +147,13 @@ Foam::dictionary& Foam::debug::controlDict()
|
||||
controlDictPtr_->merge(dictionary(ifs));
|
||||
}
|
||||
}
|
||||
|
||||
IFstream ifs("system/controlDict");
|
||||
if (ifs.good())
|
||||
{
|
||||
entry::disableFunctionEntries = true;
|
||||
controlDictPtr_->merge(dictionary(ifs));
|
||||
}
|
||||
}
|
||||
|
||||
return *controlDictPtr_;
|
||||
@ -330,180 +324,7 @@ const Foam::word Foam::debug::wordOptimisationSwitch
|
||||
}
|
||||
|
||||
|
||||
void Foam::debug::addDebugObject(const char* name, simpleRegIOobject* obj)
|
||||
{
|
||||
simpleObjectRegistryEntry* ptr = debugObjects().lookupPtr(name);
|
||||
if (ptr)
|
||||
{
|
||||
ptr->append(obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
debugObjects().append
|
||||
(
|
||||
name,
|
||||
new simpleObjectRegistryEntry
|
||||
(
|
||||
List<simpleRegIOobject*>(1, obj)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::debug::addInfoObject(const char* name, simpleRegIOobject* obj)
|
||||
{
|
||||
simpleObjectRegistryEntry* ptr = infoObjects().lookupPtr(name);
|
||||
if (ptr)
|
||||
{
|
||||
ptr->append(obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
infoObjects().append
|
||||
(
|
||||
name,
|
||||
new simpleObjectRegistryEntry
|
||||
(
|
||||
List<simpleRegIOobject*>(1, obj)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::debug::addOptimisationObject
|
||||
(
|
||||
const char* name,
|
||||
simpleRegIOobject* obj
|
||||
)
|
||||
{
|
||||
simpleObjectRegistryEntry* ptr = optimisationObjects().lookupPtr(name);
|
||||
if (ptr)
|
||||
{
|
||||
ptr->append(obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
optimisationObjects().append
|
||||
(
|
||||
name,
|
||||
new simpleObjectRegistryEntry
|
||||
(
|
||||
List<simpleRegIOobject*>(1, obj)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::debug::addDimensionSetObject
|
||||
(
|
||||
const char* name,
|
||||
simpleRegIOobject* obj
|
||||
)
|
||||
{
|
||||
simpleObjectRegistryEntry* ptr = dimensionSetObjects().lookupPtr(name);
|
||||
if (ptr)
|
||||
{
|
||||
ptr->append(obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
dimensionSetObjects().append
|
||||
(
|
||||
name,
|
||||
new simpleObjectRegistryEntry
|
||||
(
|
||||
List<simpleRegIOobject*>(1, obj)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::debug::addDimensionedConstantObject
|
||||
(
|
||||
const char* name,
|
||||
simpleRegIOobject* obj
|
||||
)
|
||||
{
|
||||
simpleObjectRegistryEntry* ptr = dimensionedConstantObjects().lookupPtr
|
||||
(
|
||||
name
|
||||
);
|
||||
if (ptr)
|
||||
{
|
||||
ptr->append(obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
dimensionedConstantObjects().append
|
||||
(
|
||||
name,
|
||||
new simpleObjectRegistryEntry
|
||||
(
|
||||
List<simpleRegIOobject*>(1, obj)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::simpleObjectRegistry& Foam::debug::debugObjects()
|
||||
{
|
||||
if (!debugObjectsPtr_)
|
||||
{
|
||||
debugObjectsPtr_ = new simpleObjectRegistry(1000);
|
||||
}
|
||||
|
||||
return *debugObjectsPtr_;
|
||||
}
|
||||
|
||||
|
||||
Foam::simpleObjectRegistry& Foam::debug::infoObjects()
|
||||
{
|
||||
if (!infoObjectsPtr_)
|
||||
{
|
||||
infoObjectsPtr_ = new simpleObjectRegistry(100);
|
||||
}
|
||||
|
||||
return *infoObjectsPtr_;
|
||||
}
|
||||
|
||||
|
||||
Foam::simpleObjectRegistry& Foam::debug::optimisationObjects()
|
||||
{
|
||||
if (!optimisationObjectsPtr_)
|
||||
{
|
||||
optimisationObjectsPtr_ = new simpleObjectRegistry(100);
|
||||
}
|
||||
|
||||
return *optimisationObjectsPtr_;
|
||||
}
|
||||
|
||||
|
||||
Foam::simpleObjectRegistry& Foam::debug::dimensionSetObjects()
|
||||
{
|
||||
if (!dimensionSetObjectsPtr_)
|
||||
{
|
||||
dimensionSetObjectsPtr_ = new simpleObjectRegistry(100);
|
||||
}
|
||||
|
||||
return *dimensionSetObjectsPtr_;
|
||||
}
|
||||
|
||||
|
||||
Foam::simpleObjectRegistry& Foam::debug::dimensionedConstantObjects()
|
||||
{
|
||||
if (!dimensionedConstantObjectsPtr_)
|
||||
{
|
||||
dimensionedConstantObjectsPtr_ = new simpleObjectRegistry(100);
|
||||
}
|
||||
|
||||
return *dimensionedConstantObjectsPtr_;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
@ -565,18 +386,16 @@ void listSwitches
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void listSwitches
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& switches,
|
||||
const dictionary& defaultSwitches,
|
||||
const simpleObjectRegistry& registry
|
||||
const dictionary& defaultSwitches
|
||||
)
|
||||
{
|
||||
wordHashSet registeredDefaultSet;
|
||||
wordHashSet registeredNonDefaultSet;
|
||||
wordHashSet nonRegisteredDefaultSet;
|
||||
wordHashSet nonRegisteredNonDefaultSet;
|
||||
wordHashSet defaultSet;
|
||||
wordHashSet nonDefaultSet;
|
||||
wordHashSet noDefaultSet;
|
||||
|
||||
forAllConstIter(dictionary, switches, iter)
|
||||
@ -585,35 +404,19 @@ void listSwitches
|
||||
|
||||
const bool hasDefault = defaultSwitches.found(name);
|
||||
|
||||
const bool isRegistered = registry.found(name);
|
||||
|
||||
const bool isDefault =
|
||||
hasDefault
|
||||
&& defaultSwitches.lookupEntry(name, false, false) == iter();
|
||||
|
||||
if (hasDefault)
|
||||
{
|
||||
if (isRegistered)
|
||||
if (isDefault)
|
||||
{
|
||||
if (isDefault)
|
||||
{
|
||||
registeredDefaultSet.insert(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
registeredNonDefaultSet.insert(name);
|
||||
}
|
||||
defaultSet.insert(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isDefault)
|
||||
{
|
||||
nonRegisteredDefaultSet.insert(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
nonRegisteredNonDefaultSet.insert(name);
|
||||
}
|
||||
nonDefaultSet.insert(name);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -637,26 +440,14 @@ void listSwitches
|
||||
|
||||
print
|
||||
(
|
||||
"Registered switches with default values",
|
||||
registeredDefaultSet.sortedToc()
|
||||
"Switches with default values",
|
||||
defaultSet.sortedToc()
|
||||
);
|
||||
Info<< nl;
|
||||
print
|
||||
(
|
||||
"Registered switches with non default values",
|
||||
registeredNonDefaultSet.sortedToc()
|
||||
);
|
||||
Info<< nl;
|
||||
print
|
||||
(
|
||||
"Non-registered switches with default values",
|
||||
nonRegisteredDefaultSet.sortedToc()
|
||||
);
|
||||
Info<< nl;
|
||||
print
|
||||
(
|
||||
"Non-registered switches with non-default values",
|
||||
nonRegisteredNonDefaultSet.sortedToc()
|
||||
"Switches with non-default values",
|
||||
nonDefaultSet.sortedToc()
|
||||
);
|
||||
Info<< nl;
|
||||
print
|
||||
@ -668,17 +459,18 @@ void listSwitches
|
||||
Info<< decrIndent << token::END_BLOCK << endl;
|
||||
}
|
||||
|
||||
}
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::debug::listSwitches()
|
||||
{
|
||||
listSwitches
|
||||
(
|
||||
"DebugSwitches",
|
||||
debug::debugSwitches(),
|
||||
debug::debugDefaultSwitches(),
|
||||
debug::debugObjects()
|
||||
debug::debugDefaultSwitches()
|
||||
);
|
||||
Info<< endl;
|
||||
|
||||
@ -686,8 +478,7 @@ void Foam::debug::listSwitches()
|
||||
(
|
||||
"InfoSwitches",
|
||||
debug::infoSwitches(),
|
||||
debug::infoDefaultSwitches(),
|
||||
debug::infoObjects()
|
||||
debug::infoDefaultSwitches()
|
||||
);
|
||||
Info<< endl;
|
||||
|
||||
@ -695,60 +486,9 @@ void Foam::debug::listSwitches()
|
||||
(
|
||||
"OptimisationSwitches",
|
||||
debug::optimisationSwitches(),
|
||||
debug::optimisationDefaultSwitches(),
|
||||
debug::optimisationObjects()
|
||||
debug::optimisationDefaultSwitches()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void Foam::debug::readSwitches
|
||||
(
|
||||
const word& name,
|
||||
simpleObjectRegistry& objects,
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
if (dict.found(name + "Switches"))
|
||||
{
|
||||
InfoHeader
|
||||
<< "Overriding " << name << "Switches according to "
|
||||
<< dict.name()
|
||||
<< endl;
|
||||
|
||||
const dictionary& localSettings = dict.subDict(name + "Switches");
|
||||
forAllConstIter(dictionary, localSettings, iter)
|
||||
{
|
||||
const word& name = iter().keyword();
|
||||
simpleObjectRegistryEntry* objPtr = objects.lookupPtr(name);
|
||||
|
||||
if (objPtr)
|
||||
{
|
||||
InfoHeader << " " << iter() << endl;
|
||||
|
||||
const List<simpleRegIOobject*>& objects = *objPtr;
|
||||
|
||||
if (iter().isDict())
|
||||
{
|
||||
OStringStream os(IOstream::ASCII);
|
||||
os << iter().dict();
|
||||
IStringStream is(os.str());
|
||||
|
||||
forAll(objects, i)
|
||||
{
|
||||
objects[i]->readData(is.rewind());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(objects, i)
|
||||
{
|
||||
objects[i]->readData(iter().stream());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -44,8 +44,6 @@ namespace Foam
|
||||
class dictionary;
|
||||
class Istream;
|
||||
class Ostream;
|
||||
class simpleRegIOobject;
|
||||
class simpleObjectRegistry;
|
||||
class word;
|
||||
template<class Enum, unsigned int nEnum> class NamedEnum;
|
||||
|
||||
@ -115,49 +113,6 @@ namespace debug
|
||||
//- List debug switches
|
||||
void listSwitches();
|
||||
|
||||
//- Read and update the switches specified in dict
|
||||
void readSwitches
|
||||
(
|
||||
const word& name,
|
||||
simpleObjectRegistry& objects,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
// Registered debug switches
|
||||
|
||||
//- Register debug switch read/write object
|
||||
void addDebugObject(const char* name, simpleRegIOobject* obj);
|
||||
|
||||
//- Register info switch read/write object
|
||||
void addInfoObject(const char* name, simpleRegIOobject* obj);
|
||||
|
||||
//- Register optimisation switch read/write object
|
||||
void addOptimisationObject(const char* name, simpleRegIOobject* obj);
|
||||
|
||||
//- Register DimensionSets read/write object
|
||||
void addDimensionSetObject(const char* name, simpleRegIOobject* obj);
|
||||
|
||||
//- Register DimensionedConstant read/write object
|
||||
void addDimensionedConstantObject(const char* name, simpleRegIOobject*);
|
||||
|
||||
|
||||
//- Get access to registered debug switch objects
|
||||
simpleObjectRegistry& debugObjects();
|
||||
|
||||
//- Get access to registered info switch objects
|
||||
simpleObjectRegistry& infoObjects();
|
||||
|
||||
//- Get access to registered optimisation switch objects
|
||||
simpleObjectRegistry& optimisationObjects();
|
||||
|
||||
//- Get access to registered dimensionSets switch objects
|
||||
simpleObjectRegistry& dimensionSetObjects();
|
||||
|
||||
//- Get access to registered dimensionedConstant switch objects
|
||||
simpleObjectRegistry& dimensionedConstantObjects();
|
||||
|
||||
|
||||
} // End namespace debug
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -29,100 +29,28 @@ Description
|
||||
#ifndef defineDebugSwitch_H
|
||||
#define defineDebugSwitch_H
|
||||
|
||||
#include "simpleRegIOobject.H"
|
||||
#include "debug.H"
|
||||
#include "label.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
//- Define the debug information, lookup as \a Name
|
||||
template<class Type>
|
||||
class RegisterDebugSwitch
|
||||
:
|
||||
public ::Foam::simpleRegIOobject
|
||||
{
|
||||
public:
|
||||
|
||||
//- The unique RegisterDebugSwitch object
|
||||
static const RegisterDebugSwitch registerDebugSwitch;
|
||||
|
||||
RegisterDebugSwitch(const char* name)
|
||||
:
|
||||
::Foam::simpleRegIOobject(Foam::debug::addDebugObject, name)
|
||||
{}
|
||||
|
||||
virtual ~RegisterDebugSwitch()
|
||||
{}
|
||||
|
||||
virtual void readData(Foam::Istream& is)
|
||||
{
|
||||
Type::debug = readLabel(is);
|
||||
}
|
||||
|
||||
virtual void writeData(Foam::Ostream& os) const
|
||||
{
|
||||
os << Type::debug;
|
||||
}
|
||||
};
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define registerTemplateDebugSwitchWithName(Type,Name) \
|
||||
template<> \
|
||||
const Foam::RegisterDebugSwitch<Type> \
|
||||
Foam::RegisterDebugSwitch<Type>::registerDebugSwitch(Name)
|
||||
|
||||
|
||||
//- Define the debug information, lookup as \a Name
|
||||
#define registerDebugSwitchWithName(Type,Tag,Name) \
|
||||
class add##Tag##ToDebug \
|
||||
: \
|
||||
public ::Foam::simpleRegIOobject \
|
||||
{ \
|
||||
public: \
|
||||
add##Tag##ToDebug(const char* name) \
|
||||
: \
|
||||
::Foam::simpleRegIOobject(Foam::debug::addDebugObject, name) \
|
||||
{} \
|
||||
virtual ~add##Tag##ToDebug() \
|
||||
{} \
|
||||
virtual void readData(Foam::Istream& is) \
|
||||
{ \
|
||||
Type::debug = readLabel(is); \
|
||||
} \
|
||||
virtual void writeData(Foam::Ostream& os) const \
|
||||
{ \
|
||||
os << Type::debug; \
|
||||
} \
|
||||
}; \
|
||||
add##Tag##ToDebug add##Tag##ToDebug_(Name)
|
||||
|
||||
|
||||
//- Define the debug information, lookup as \a Name
|
||||
#define defineDebugSwitchWithName(Type, Name, DebugSwitch) \
|
||||
int Type::debug(::Foam::debug::debugSwitch(Name, DebugSwitch))
|
||||
|
||||
//- Define the debug information
|
||||
#define defineDebugSwitch(Type, DebugSwitch) \
|
||||
defineDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch); \
|
||||
registerDebugSwitchWithName(Type, Type, Type::typeName_())
|
||||
defineDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch);
|
||||
|
||||
//- Define the debug information for templates, lookup as \a Name
|
||||
#define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch) \
|
||||
template<> \
|
||||
defineDebugSwitchWithName(Type, Name, DebugSwitch); \
|
||||
registerTemplateDebugSwitchWithName(Type, Name)
|
||||
defineDebugSwitchWithName(Type, Name, DebugSwitch);
|
||||
|
||||
//- Define the debug information for templates sub-classes, lookup as \a Name
|
||||
#define defineTemplate2DebugSwitchWithName(Type, Name, DebugSwitch) \
|
||||
template<> \
|
||||
defineDebugSwitchWithName(Type, Name, DebugSwitch); \
|
||||
registerTemplateDebugSwitchWithName(Type, Name)
|
||||
defineDebugSwitchWithName(Type, Name, DebugSwitch);
|
||||
|
||||
//- Define the debug information for templates
|
||||
// Useful with typedefs
|
||||
@ -133,7 +61,6 @@ public:
|
||||
#define defineNamedTemplateDebugSwitch(Type, DebugSwitch) \
|
||||
defineTemplateDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch)
|
||||
|
||||
|
||||
//- Define the debug information for templates
|
||||
// Useful with typedefs
|
||||
#define defineTemplate2DebugSwitch(Type, DebugSwitch) \
|
||||
|
||||
@ -1,112 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2019-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::RegisterNamedEnum
|
||||
|
||||
Description
|
||||
Class and registration macros for info and optimisation named enumerations
|
||||
to support reading from system/controlDict and dynamic update.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef registerNamedEnum_H
|
||||
#define registerNamedEnum_H
|
||||
|
||||
#include "simpleRegIOobject.H"
|
||||
#include "macros.H"
|
||||
#include "NamedEnum.H"
|
||||
#include <type_traits>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class RegisterNamedEnum Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class NamedEnumType>
|
||||
class RegisterNamedEnum;
|
||||
|
||||
template<class Enum, unsigned int nEnum>
|
||||
class RegisterNamedEnum<NamedEnum<Enum, nEnum>>
|
||||
:
|
||||
public simpleRegIOobject
|
||||
{
|
||||
const NamedEnum<Enum, nEnum>& enumNames_;
|
||||
|
||||
Enum& enumRef_;
|
||||
|
||||
public:
|
||||
|
||||
RegisterNamedEnum
|
||||
(
|
||||
void (*registryFn)(const char* name, simpleRegIOobject*),
|
||||
const word& name,
|
||||
const NamedEnum<Enum, nEnum>& enumNames,
|
||||
Enum& enumRef
|
||||
)
|
||||
:
|
||||
::Foam::simpleRegIOobject(registryFn, name.c_str()),
|
||||
enumNames_(enumNames),
|
||||
enumRef_(enumRef)
|
||||
{}
|
||||
|
||||
virtual ~RegisterNamedEnum()
|
||||
{}
|
||||
|
||||
virtual void readData(Istream& is)
|
||||
{
|
||||
enumRef_ = enumNames_.read(is);
|
||||
}
|
||||
|
||||
virtual void writeData(Ostream& os) const
|
||||
{
|
||||
os << enumNames_[enumRef_];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define registerOptNamedEnum(Name, EnumNames, EnumRef) \
|
||||
static Foam::RegisterNamedEnum<std::remove_cv<decltype(EnumNames)>::type> \
|
||||
FILE_UNIQUE(_addToOpt_) \
|
||||
(Foam::debug::addOptimisationObject, Name, EnumNames, EnumRef)
|
||||
|
||||
#define registerInfoNamedEnum(Name, EnumNames, EnumRef) \
|
||||
static Foam::RegisterNamedEnum<std::remove_cv<decltype(EnumNames)>::type> \
|
||||
FILE_UNIQUE(_addToOpt_) \
|
||||
(Foam::debug::addInfoObject, Name, EnumNames, EnumRef)
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,103 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2015-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::RegisterSwitch
|
||||
|
||||
Description
|
||||
Class and registration macros for InfoSwitches and OptimisationSwitches
|
||||
to support reading from system/controlDict and dynamic update.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef registerSwitch_H
|
||||
#define registerSwitch_H
|
||||
|
||||
#include "simpleRegIOobject.H"
|
||||
#include "macros.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class RegisterSwitch Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class RegisterSwitch
|
||||
:
|
||||
public simpleRegIOobject
|
||||
{
|
||||
Type& optSwitch_;
|
||||
|
||||
public:
|
||||
|
||||
RegisterSwitch
|
||||
(
|
||||
void (*registryFn)(const char* name, simpleRegIOobject*),
|
||||
const char* name,
|
||||
Type& optSwitch
|
||||
)
|
||||
:
|
||||
simpleRegIOobject(registryFn, name),
|
||||
optSwitch_(optSwitch)
|
||||
{}
|
||||
|
||||
virtual ~RegisterSwitch()
|
||||
{}
|
||||
|
||||
virtual void readData(Foam::Istream& is)
|
||||
{
|
||||
is >> optSwitch_;
|
||||
}
|
||||
|
||||
virtual void writeData(Foam::Ostream& os) const
|
||||
{
|
||||
os << optSwitch_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define registerOptSwitch(Name, Type, Switch) \
|
||||
static Foam::RegisterSwitch<Type> FILE_UNIQUE(_addToOpt_) \
|
||||
(Foam::debug::addOptimisationObject, Name, Switch)
|
||||
|
||||
|
||||
#define registerInfoSwitch(Name, Type, Switch) \
|
||||
static Foam::RegisterSwitch<Type> FILE_UNIQUE(_addToOpt_) \
|
||||
(Foam::debug::addInfoObject, Name, Switch)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,91 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::simpleObjectRegistry
|
||||
|
||||
Description
|
||||
Object registry for simpleRegIOobject. Maintains ordering.
|
||||
|
||||
SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef simpleObjectRegistry_H
|
||||
#define simpleObjectRegistry_H
|
||||
|
||||
#include "Dictionary.H"
|
||||
#include "simpleRegIOobject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class simpleObjectRegistryEntry Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class simpleObjectRegistryEntry
|
||||
:
|
||||
public Dictionary<simpleObjectRegistryEntry>::link,
|
||||
public List<simpleRegIOobject*>
|
||||
{
|
||||
public:
|
||||
|
||||
simpleObjectRegistryEntry(const List<simpleRegIOobject*>& data)
|
||||
:
|
||||
List<simpleRegIOobject*>(data)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class simpleObjectRegistry Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class simpleObjectRegistry
|
||||
:
|
||||
public Dictionary<simpleObjectRegistryEntry>
|
||||
{
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct given initial table size
|
||||
simpleObjectRegistry(const label nIoObjects = 128)
|
||||
:
|
||||
Dictionary<simpleObjectRegistryEntry>(nIoObjects)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,92 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::simpleRegIOobject
|
||||
|
||||
Description
|
||||
Abstract base class for registered object with I/O. Used in debug symbol
|
||||
registration.
|
||||
|
||||
SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef simpleRegIOobject_H
|
||||
#define simpleRegIOobject_H
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class Istream;
|
||||
class Ostream;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class simpleRegIOobject Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class simpleRegIOobject
|
||||
{
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from objectregistry inserter and name
|
||||
simpleRegIOobject
|
||||
(
|
||||
void (*fn)(const char* name, simpleRegIOobject*),
|
||||
const char* name
|
||||
)
|
||||
{
|
||||
(*fn)(name, this);
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~simpleRegIOobject()
|
||||
{};
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read
|
||||
virtual void readData(Istream&) = 0;
|
||||
|
||||
//- Write
|
||||
virtual void writeData(Ostream&) const = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -27,7 +27,6 @@ License
|
||||
#include "Time.H"
|
||||
#include "threadedCollatedOFstream.H"
|
||||
#include "decomposedBlockData.H"
|
||||
#include "registerSwitch.H"
|
||||
#include "masterOFstream.H"
|
||||
#include "OFstream.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
@ -50,12 +49,6 @@ namespace fileOperations
|
||||
(
|
||||
debug::floatOptimisationSwitch("maxThreadFileBufferSize", 1e9)
|
||||
);
|
||||
registerOptSwitch
|
||||
(
|
||||
"maxThreadFileBufferSize",
|
||||
float,
|
||||
collatedFileOperation::maxThreadFileBufferSize
|
||||
);
|
||||
|
||||
// Mark as needing threaded mpi
|
||||
addNamedToRunTimeSelectionTable
|
||||
|
||||
@ -27,7 +27,6 @@ License
|
||||
#include "Time.H"
|
||||
#include "masterOFstream.H"
|
||||
#include "decomposedBlockData.H"
|
||||
#include "registerSwitch.H"
|
||||
#include "dummyISstream.H"
|
||||
#include "SubList.H"
|
||||
#include "PackedBoolList.H"
|
||||
@ -52,12 +51,6 @@ namespace fileOperations
|
||||
(
|
||||
Foam::debug::floatOptimisationSwitch("maxMasterFileBufferSize", 1e9)
|
||||
);
|
||||
registerOptSwitch
|
||||
(
|
||||
"maxMasterFileBufferSize",
|
||||
float,
|
||||
masterUncollatedFileOperation::maxMasterFileBufferSize
|
||||
);
|
||||
|
||||
// Mark as not needing threaded mpi
|
||||
addNamedToRunTimeSelectionTable
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -74,20 +74,12 @@ bool Foam::jobInfo::constructed(false);
|
||||
// Read file modification checking switches
|
||||
|
||||
#include "regIOobject.H"
|
||||
#include "registerSwitch.H"
|
||||
|
||||
float Foam::regIOobject::fileModificationSkew
|
||||
(
|
||||
Foam::debug::floatOptimisationSwitch("fileModificationSkew", 30)
|
||||
);
|
||||
|
||||
registerOptSwitch
|
||||
(
|
||||
"fileModificationSkew",
|
||||
float,
|
||||
Foam::regIOobject::fileModificationSkew
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Read parallel communication switches
|
||||
|
||||
|
||||
@ -36,25 +36,11 @@ bool Foam::jobInfo::writeJobControl
|
||||
Foam::debug::infoSwitch("writeJobControl", 0)
|
||||
);
|
||||
|
||||
registerInfoSwitch
|
||||
(
|
||||
"writeJobControl",
|
||||
bool,
|
||||
Foam::jobInfo::writeJobControl
|
||||
);
|
||||
|
||||
bool Foam::jobInfo::writeJobInfo
|
||||
(
|
||||
Foam::debug::infoSwitch("writeJobInfo", 0)
|
||||
);
|
||||
|
||||
registerInfoSwitch
|
||||
(
|
||||
"writeJobInfo",
|
||||
bool,
|
||||
Foam::jobInfo::writeJobInfo
|
||||
);
|
||||
|
||||
Foam::jobInfo Foam::jobInfo_;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user