mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: debug: add run-time debug switch modification
This commit is contained in:
@ -25,6 +25,7 @@ License
|
||||
|
||||
#include "Time.H"
|
||||
#include "Pstream.H"
|
||||
#include "simpleObjectRegistry.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
@ -37,6 +38,86 @@ void Foam::Time::readDict()
|
||||
setEnv("FOAM_APPLICATION", application, false);
|
||||
}
|
||||
|
||||
|
||||
// Check for local switches and settings
|
||||
if (controlDict_.found("DebugSwitches"))
|
||||
{
|
||||
simpleObjectRegistry& objects = debug::debugObjects();
|
||||
const dictionary& localSettings = controlDict_.subDict("DebugSwitches");
|
||||
forAllConstIter(dictionary, localSettings, iter)
|
||||
{
|
||||
const word& name = iter().keyword();
|
||||
simpleObjectRegistry::iterator fnd = objects.find(name);
|
||||
if (fnd != objects.end())
|
||||
{
|
||||
Info<< controlDict_.name() << " : overriding debug switch "
|
||||
<< name << endl;
|
||||
|
||||
if (iter().isDict())
|
||||
{
|
||||
OStringStream os(IOstream::ASCII);
|
||||
os << iter().dict();
|
||||
IStringStream is(os.str());
|
||||
fnd()->readData(is);
|
||||
}
|
||||
else
|
||||
{
|
||||
fnd()->readData(iter().stream());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (controlDict_.found("DimensionSets"))
|
||||
{
|
||||
dictionary dict(Foam::dimensionSystems());
|
||||
dict.merge(controlDict_.subDict("DimensionSets"));
|
||||
|
||||
simpleObjectRegistry& objects = debug::dimensionSetObjects();
|
||||
simpleObjectRegistry::iterator fnd = objects.find("DimensionSets");
|
||||
if (fnd != objects.end())
|
||||
{
|
||||
Info<< controlDict_.name() << " : overriding DimensionSets" << endl;
|
||||
|
||||
OStringStream os(IOstream::ASCII);
|
||||
os << dict;
|
||||
IStringStream is(os.str());
|
||||
fnd()->readData(is);
|
||||
}
|
||||
}
|
||||
if (controlDict_.found("OptimisationSwitches"))
|
||||
{
|
||||
simpleObjectRegistry& objects = debug::optimisationObjects();
|
||||
const dictionary& localSettings = controlDict_.subDict
|
||||
(
|
||||
"OptimisationSwitches"
|
||||
);
|
||||
forAllConstIter(dictionary, localSettings, iter)
|
||||
{
|
||||
const word& name = iter().keyword();
|
||||
simpleObjectRegistry::iterator fnd = objects.find(name);
|
||||
if (fnd != objects.end())
|
||||
{
|
||||
Info<< controlDict_.name()
|
||||
<< " : overriding optimisation switch "
|
||||
<< name << endl;
|
||||
|
||||
if (iter().isDict())
|
||||
{
|
||||
OStringStream os(IOstream::ASCII);
|
||||
os << iter().dict();
|
||||
IStringStream is(os.str());
|
||||
fnd()->readData(is);
|
||||
}
|
||||
else
|
||||
{
|
||||
fnd()->readData(iter().stream());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!deltaTchanged_)
|
||||
{
|
||||
deltaT_ = readScalar(controlDict_.lookup("deltaT"));
|
||||
|
||||
@ -25,13 +25,15 @@ License
|
||||
|
||||
#include "dimensionSet.H"
|
||||
#include "dimensionedScalar.H"
|
||||
#include "simpleRegIOobject.H"
|
||||
#include "demandDrivenData.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
|
||||
|
||||
dictionary* dimensionSystemsPtr_(NULL);
|
||||
|
||||
@ -45,11 +47,35 @@ dictionary& dimensionSystems()
|
||||
}
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
|
||||
|
||||
autoPtr<HashTable<dimensionedScalar> > unitSetPtr_;
|
||||
autoPtr<dimensionSets> writeUnitSetPtr_;
|
||||
|
||||
class addDimensionSetsToDebug
|
||||
:
|
||||
public ::Foam::simpleRegIOobject
|
||||
{
|
||||
public:
|
||||
addDimensionSetsToDebug(const char* name)
|
||||
:
|
||||
::Foam::simpleRegIOobject(Foam::debug::addDimensionSetObject, name)
|
||||
{}
|
||||
virtual ~addDimensionSetsToDebug()
|
||||
{}
|
||||
virtual void readData(Foam::Istream& is)
|
||||
{
|
||||
deleteDemandDrivenData(dimensionSystemsPtr_);
|
||||
unitSetPtr_.clear();
|
||||
writeUnitSetPtr_.clear();
|
||||
dimensionSystemsPtr_ = new dictionary(is);
|
||||
}
|
||||
virtual void writeData(Foam::Ostream& os) const
|
||||
{
|
||||
os << dimensionSystems();
|
||||
}
|
||||
};
|
||||
addDimensionSetsToDebug addDimensionSetsToDebug_("DimensionSets");
|
||||
|
||||
|
||||
|
||||
const HashTable<dimensionedScalar>& unitSet()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user