mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: debug: register debug names
This commit is contained in:
@ -240,6 +240,12 @@ bool Foam::UPstream::floatTransfer
|
||||
(
|
||||
debug::optimisationSwitch("floatTransfer", 0)
|
||||
);
|
||||
registerOptSwitchWithName
|
||||
(
|
||||
Foam::UPstream::floatTransfer,
|
||||
floatTransfer,
|
||||
"floatTransfer"
|
||||
);
|
||||
|
||||
// Number of processors at which the reduce algorithm changes from linear to
|
||||
// tree
|
||||
@ -247,18 +253,55 @@ int Foam::UPstream::nProcsSimpleSum
|
||||
(
|
||||
debug::optimisationSwitch("nProcsSimpleSum", 16)
|
||||
);
|
||||
registerOptSwitchWithName
|
||||
(
|
||||
Foam::UPstream::nProcsSimpleSum,
|
||||
nProcsSimpleSum,
|
||||
"nProcsSimpleSum"
|
||||
);
|
||||
|
||||
// Default commsType
|
||||
Foam::UPstream::commsTypes Foam::UPstream::defaultCommsType
|
||||
(
|
||||
commsTypeNames.read(debug::optimisationSwitches().lookup("commsType"))
|
||||
);
|
||||
// Register re-reader
|
||||
class addcommsTypeToOpt
|
||||
:
|
||||
public ::Foam::simpleRegIOobject
|
||||
{
|
||||
public:
|
||||
addcommsTypeToOpt(const char* name)
|
||||
:
|
||||
::Foam::simpleRegIOobject(Foam::debug::addOptimisationObject, name)
|
||||
{}
|
||||
virtual ~addcommsTypeToOpt()
|
||||
{}
|
||||
virtual void readData(Foam::Istream& is)
|
||||
{
|
||||
Foam::UPstream::defaultCommsType = Foam::UPstream::commsTypeNames.read
|
||||
(
|
||||
is
|
||||
);
|
||||
}
|
||||
virtual void writeData(Foam::Ostream& os) const
|
||||
{
|
||||
os << Foam::UPstream::commsTypeNames[Foam::UPstream::defaultCommsType];
|
||||
}
|
||||
};
|
||||
addcommsTypeToOpt addcommsTypeToOpt_("commsType");
|
||||
|
||||
|
||||
// Number of polling cycles in processor updates
|
||||
int Foam::UPstream::nPollProcInterfaces
|
||||
(
|
||||
debug::optimisationSwitch("nPollProcInterfaces", 0)
|
||||
);
|
||||
|
||||
registerOptSwitchWithName
|
||||
(
|
||||
Foam::UPstream::nPollProcInterfaces,
|
||||
nPollProcInterfaces,
|
||||
"nPollProcInterfaces"
|
||||
);
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -32,8 +32,9 @@ namespace Foam
|
||||
const char* const token::typeName = "token";
|
||||
token token::undefinedToken;
|
||||
|
||||
defineTypeNameAndDebug(token::compound, 0);
|
||||
defineRunTimeSelectionTable(token::compound, Istream);
|
||||
typedef token::compound tokenCompound;
|
||||
defineTypeNameAndDebug(tokenCompound, 0);
|
||||
defineRunTimeSelectionTable(tokenCompound, Istream);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -51,7 +51,7 @@ void Foam::Time::readDict()
|
||||
if (fnd != objects.end())
|
||||
{
|
||||
Info<< controlDict_.name() << " : overriding debug switch "
|
||||
<< name << endl;
|
||||
<< name << " to " << fnd() << endl;
|
||||
|
||||
if (iter().isDict())
|
||||
{
|
||||
@ -99,7 +99,7 @@ void Foam::Time::readDict()
|
||||
{
|
||||
Info<< controlDict_.name()
|
||||
<< " : overriding optimisation switch "
|
||||
<< name << endl;
|
||||
<< name << " to " << fnd() << endl;
|
||||
|
||||
if (iter().isDict())
|
||||
{
|
||||
|
||||
@ -37,6 +37,13 @@ namespace Foam
|
||||
(
|
||||
debug::optimisationSwitch("fileModificationSkew", 30)
|
||||
);
|
||||
registerOptSwitchWithName
|
||||
(
|
||||
Foam::regIOobject::fileModificationSkew,
|
||||
fileModificationSkew,
|
||||
"fileModificationSkew"
|
||||
);
|
||||
|
||||
|
||||
template<>
|
||||
const char* NamedEnum
|
||||
@ -67,6 +74,35 @@ Foam::regIOobject::fileCheckTypes Foam::regIOobject::fileModificationChecking
|
||||
)
|
||||
)
|
||||
);
|
||||
// Register re-reader
|
||||
class addfileModificationCheckingToOpt
|
||||
:
|
||||
public ::Foam::simpleRegIOobject
|
||||
{
|
||||
public:
|
||||
addfileModificationCheckingToOpt(const char* name)
|
||||
:
|
||||
::Foam::simpleRegIOobject(Foam::debug::addOptimisationObject, name)
|
||||
{}
|
||||
virtual ~addfileModificationCheckingToOpt()
|
||||
{}
|
||||
virtual void readData(Foam::Istream& is)
|
||||
{
|
||||
Foam::regIOobject::fileModificationChecking =
|
||||
Foam::regIOobject::fileCheckTypesNames.read(is);
|
||||
}
|
||||
virtual void writeData(Foam::Ostream& os) const
|
||||
{
|
||||
os << Foam::regIOobject::fileCheckTypesNames
|
||||
[
|
||||
Foam::regIOobject::fileModificationChecking
|
||||
];
|
||||
}
|
||||
};
|
||||
addfileModificationCheckingToOpt addfileModificationCheckingToOpt_
|
||||
(
|
||||
"fileModificationChecking"
|
||||
);
|
||||
|
||||
|
||||
bool Foam::regIOobject::masterOnlyReading = false;
|
||||
|
||||
@ -31,6 +31,7 @@ Description
|
||||
|
||||
#include "word.H"
|
||||
#include "debug.H"
|
||||
#include "debugName.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -133,84 +134,6 @@ public: \
|
||||
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// definitions (debug information only)
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
//- 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)
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
//- Define the debug information for templates, lookup as \a Name
|
||||
# define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch) \
|
||||
defineDebugSwitchWithName(Type, Name, DebugSwitch)
|
||||
//- Define the debug information for templates sub-classes, lookup as \a Name
|
||||
# define defineTemplate2DebugSwitchWithName(Type, Name, DebugSwitch) \
|
||||
defineDebugSwitchWithName(Type, Name, DebugSwitch)
|
||||
#else
|
||||
//- Define the debug information for templates, lookup as \a Name
|
||||
# define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch) \
|
||||
template<> \
|
||||
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)
|
||||
#endif
|
||||
|
||||
//- Define the debug information for templates
|
||||
// Useful with typedefs
|
||||
#define defineTemplateDebugSwitch(Type, DebugSwitch) \
|
||||
defineTemplateDebugSwitchWithName(Type, #Type, DebugSwitch)
|
||||
|
||||
//- Define the debug information directly for templates
|
||||
#define defineNamedTemplateDebugSwitch(Type, DebugSwitch) \
|
||||
defineTemplateDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch)
|
||||
|
||||
|
||||
// for templated sub-classes
|
||||
|
||||
//- Define the debug information for templates
|
||||
// Useful with typedefs
|
||||
#define defineTemplate2DebugSwitch(Type, DebugSwitch) \
|
||||
defineTemplate2DebugSwitchWithName(Type, #Type, DebugSwitch)
|
||||
|
||||
//- Define the debug information directly for templates
|
||||
#define defineNamedTemplate2DebugSwitch(Type, DebugSwitch) \
|
||||
defineTemplate2DebugSwitchWithName(Type, Type::typeName_(), DebugSwitch)
|
||||
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// definitions (with debug information)
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
171
src/OpenFOAM/db/typeInfo/debugName.H
Normal file
171
src/OpenFOAM/db/typeInfo/debugName.H
Normal file
@ -0,0 +1,171 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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/>.
|
||||
|
||||
Description
|
||||
Macro definitions for debug symbols etc.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef debugName_H
|
||||
#define debugName_H
|
||||
|
||||
#include "simpleRegIOobject.H"
|
||||
#include "word.H"
|
||||
#include "debug.H"
|
||||
#include "label.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// definitions (debug information only)
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
//- 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)
|
||||
|
||||
|
||||
//- Register info switch (if int), lookup as \a Name
|
||||
#define registerInfoSwitchWithName(Switch,Tag,Name) \
|
||||
class add##Tag##ToInfo \
|
||||
: \
|
||||
public ::Foam::simpleRegIOobject \
|
||||
{ \
|
||||
public: \
|
||||
add##Tag##ToInfo(const char* name) \
|
||||
: \
|
||||
::Foam::simpleRegIOobject(Foam::debug::addInfoObject, name) \
|
||||
{} \
|
||||
virtual ~add##Tag##ToInfo() \
|
||||
{} \
|
||||
virtual void readData(Foam::Istream& is) \
|
||||
{ \
|
||||
Switch = readLabel(is); \
|
||||
} \
|
||||
virtual void writeData(Foam::Ostream& os) const \
|
||||
{ \
|
||||
os << Switch; \
|
||||
} \
|
||||
}; \
|
||||
add##Tag##ToInfo add##Tag##ToInfo_(Name)
|
||||
|
||||
//- Register optimisation switch (if int), lookup as \a Name
|
||||
#define registerOptSwitchWithName(Switch,Tag,Name) \
|
||||
class add##Tag##ToOpt \
|
||||
: \
|
||||
public ::Foam::simpleRegIOobject \
|
||||
{ \
|
||||
public: \
|
||||
add##Tag##ToOpt(const char* name) \
|
||||
: \
|
||||
::Foam::simpleRegIOobject(Foam::debug::addOptimisationObject,name)\
|
||||
{} \
|
||||
virtual ~add##Tag##ToOpt() \
|
||||
{} \
|
||||
virtual void readData(Foam::Istream& is) \
|
||||
{ \
|
||||
Switch = readLabel(is); \
|
||||
} \
|
||||
virtual void writeData(Foam::Ostream& os) const \
|
||||
{ \
|
||||
os << Switch; \
|
||||
} \
|
||||
}; \
|
||||
add##Tag##ToOpt add##Tag##ToOpt_(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_())
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
//- Define the debug information for templates, lookup as \a Name
|
||||
# define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch) \
|
||||
defineDebugSwitchWithName(Type, Name, DebugSwitch)
|
||||
//- Define the debug information for templates sub-classes, lookup as \a Name
|
||||
# define defineTemplate2DebugSwitchWithName(Type, Name, DebugSwitch) \
|
||||
defineDebugSwitchWithName(Type, Name, DebugSwitch)
|
||||
#else
|
||||
//- Define the debug information for templates, lookup as \a Name
|
||||
# define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch) \
|
||||
template<> \
|
||||
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)
|
||||
#endif
|
||||
|
||||
//- Define the debug information for templates
|
||||
// Useful with typedefs
|
||||
#define defineTemplateDebugSwitch(Type, DebugSwitch) \
|
||||
defineTemplateDebugSwitchWithName(Type, #Type, DebugSwitch)
|
||||
|
||||
//- Define the debug information directly for templates
|
||||
#define defineNamedTemplateDebugSwitch(Type, DebugSwitch) \
|
||||
defineTemplateDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch)
|
||||
|
||||
|
||||
// for templated sub-classes
|
||||
|
||||
//- Define the debug information for templates
|
||||
// Useful with typedefs
|
||||
#define defineTemplate2DebugSwitch(Type, DebugSwitch) \
|
||||
defineTemplate2DebugSwitchWithName(Type, #Type, DebugSwitch)
|
||||
|
||||
//- Define the debug information directly for templates
|
||||
#define defineNamedTemplate2DebugSwitch(Type, DebugSwitch) \
|
||||
defineTemplate2DebugSwitchWithName(Type, Type::typeName_(), DebugSwitch)
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -190,13 +190,25 @@ int Foam::debug::optimisationSwitch(const char* name, const int defaultValue)
|
||||
|
||||
void Foam::debug::addDebugObject(const char* name, simpleRegIOobject* obj)
|
||||
{
|
||||
debugObjects().insert(name, obj);
|
||||
if (!debugObjects().insert(name, obj))
|
||||
{
|
||||
//std::cerr<< "debug::addDebugObject : Duplicate entry " << name
|
||||
// << " in runtime selection table"
|
||||
// << std::endl;
|
||||
//error::safePrintStack(std::cerr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::debug::addInfoObject(const char* name, simpleRegIOobject* obj)
|
||||
{
|
||||
infoObjects().insert(name, obj);
|
||||
if (!infoObjects().insert(name, obj))
|
||||
{
|
||||
//std::cerr<< "debug::addInfoObject : Duplicate entry " << name
|
||||
// << " in runtime selection table"
|
||||
// << std::endl;
|
||||
//error::safePrintStack(std::cerr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -206,7 +218,13 @@ void Foam::debug::addOptimisationObject
|
||||
simpleRegIOobject* obj
|
||||
)
|
||||
{
|
||||
optimisationObjects().insert(name, obj);
|
||||
if (!optimisationObjects().insert(name, obj))
|
||||
{
|
||||
//std::cerr<< "debug::addOptimisationObject : Duplicate entry " << name
|
||||
// << " in runtime selection table"
|
||||
// << std::endl;
|
||||
//error::safePrintStack(std::cerr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -216,7 +234,13 @@ void Foam::debug::addDimensionSetObject
|
||||
simpleRegIOobject* obj
|
||||
)
|
||||
{
|
||||
dimensionSetObjects().insert(name, obj);
|
||||
if (!dimensionSetObjects().insert(name, obj))
|
||||
{
|
||||
//std::cerr<< "debug::addDimensionSetObject : Duplicate entry " << name
|
||||
// << " in runtime selection table"
|
||||
// << std::endl;
|
||||
//error::safePrintStack(std::cerr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -33,8 +33,9 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(graph::writer, 0);
|
||||
defineRunTimeSelectionTable(graph::writer, word);
|
||||
typedef graph::writer graphWriter;
|
||||
defineTypeNameAndDebug(graphWriter, 0);
|
||||
defineRunTimeSelectionTable(graphWriter, word);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -47,12 +47,6 @@ License
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(polyMesh, 0);
|
||||
registerDebugSwitchWithName
|
||||
(
|
||||
polyMesh,
|
||||
polyMesh,
|
||||
polyMesh::typeName_()
|
||||
);
|
||||
|
||||
word polyMesh::defaultRegion = "region0";
|
||||
word polyMesh::meshSubDir = "polyMesh";
|
||||
|
||||
Reference in New Issue
Block a user