mirror of
https://github.com/OpenFOAM/OpenFOAM-6.git
synced 2025-12-08 06:57:46 +00:00
registerSwitch: rationalization of info and optimization switch registration
plus support for other than integer types
This commit is contained in:
@ -25,7 +25,7 @@ License
|
|||||||
|
|
||||||
#include "UPstream.H"
|
#include "UPstream.H"
|
||||||
#include "debug.H"
|
#include "debug.H"
|
||||||
#include "registerOptSwitch.H"
|
#include "registerSwitch.H"
|
||||||
#include "dictionary.H"
|
#include "dictionary.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
|
|
||||||
@ -424,32 +424,32 @@ Foam::UPstream::communicator serialComm
|
|||||||
// in accuracy
|
// in accuracy
|
||||||
bool Foam::UPstream::floatTransfer
|
bool Foam::UPstream::floatTransfer
|
||||||
(
|
(
|
||||||
debug::optimisationSwitch("floatTransfer", 0)
|
Foam::debug::optimisationSwitch("floatTransfer", 0)
|
||||||
);
|
);
|
||||||
registerOptSwitchWithName
|
registerOptSwitch
|
||||||
(
|
(
|
||||||
Foam::UPstream::floatTransfer,
|
"floatTransfer",
|
||||||
floatTransfer,
|
bool,
|
||||||
"floatTransfer"
|
Foam::UPstream::floatTransfer
|
||||||
);
|
);
|
||||||
|
|
||||||
// Number of processors at which the reduce algorithm changes from linear to
|
// Number of processors at which the reduce algorithm changes from linear to
|
||||||
// tree
|
// tree
|
||||||
int Foam::UPstream::nProcsSimpleSum
|
int Foam::UPstream::nProcsSimpleSum
|
||||||
(
|
(
|
||||||
debug::optimisationSwitch("nProcsSimpleSum", 16)
|
Foam::debug::optimisationSwitch("nProcsSimpleSum", 16)
|
||||||
);
|
);
|
||||||
registerOptSwitchWithName
|
registerOptSwitch
|
||||||
(
|
(
|
||||||
Foam::UPstream::nProcsSimpleSum,
|
"nProcsSimpleSum",
|
||||||
nProcsSimpleSum,
|
int,
|
||||||
"nProcsSimpleSum"
|
Foam::UPstream::nProcsSimpleSum
|
||||||
);
|
);
|
||||||
|
|
||||||
// Default commsType
|
// Default commsType
|
||||||
Foam::UPstream::commsTypes Foam::UPstream::defaultCommsType
|
Foam::UPstream::commsTypes Foam::UPstream::defaultCommsType
|
||||||
(
|
(
|
||||||
commsTypeNames.read(debug::optimisationSwitches().lookup("commsType"))
|
commsTypeNames.read(Foam::debug::optimisationSwitches().lookup("commsType"))
|
||||||
);
|
);
|
||||||
// Register re-reader
|
// Register re-reader
|
||||||
class addcommsTypeToOpt
|
class addcommsTypeToOpt
|
||||||
@ -489,13 +489,14 @@ Foam::label Foam::UPstream::warnComm(-1);
|
|||||||
// Number of polling cycles in processor updates
|
// Number of polling cycles in processor updates
|
||||||
int Foam::UPstream::nPollProcInterfaces
|
int Foam::UPstream::nPollProcInterfaces
|
||||||
(
|
(
|
||||||
debug::optimisationSwitch("nPollProcInterfaces", 0)
|
Foam::debug::optimisationSwitch("nPollProcInterfaces", 0)
|
||||||
);
|
);
|
||||||
registerOptSwitchWithName
|
registerOptSwitch
|
||||||
(
|
(
|
||||||
Foam::UPstream::nPollProcInterfaces,
|
"nPollProcInterfaces",
|
||||||
nPollProcInterfaces,
|
int,
|
||||||
"nPollProcInterfaces"
|
Foam::UPstream::nPollProcInterfaces
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -26,7 +26,7 @@ License
|
|||||||
#include "regIOobject.H"
|
#include "regIOobject.H"
|
||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
#include "polyMesh.H"
|
#include "polyMesh.H"
|
||||||
#include "registerOptSwitch.H"
|
#include "registerSwitch.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -34,18 +34,6 @@ namespace Foam
|
|||||||
{
|
{
|
||||||
defineTypeNameAndDebug(regIOobject, 0);
|
defineTypeNameAndDebug(regIOobject, 0);
|
||||||
|
|
||||||
int regIOobject::fileModificationSkew
|
|
||||||
(
|
|
||||||
debug::optimisationSwitch("fileModificationSkew", 30)
|
|
||||||
);
|
|
||||||
registerOptSwitchWithName
|
|
||||||
(
|
|
||||||
Foam::regIOobject::fileModificationSkew,
|
|
||||||
fileModificationSkew,
|
|
||||||
"fileModificationSkew"
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
const char* NamedEnum
|
const char* NamedEnum
|
||||||
<
|
<
|
||||||
@ -60,6 +48,17 @@ namespace Foam
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Foam::regIOobject::fileModificationSkew
|
||||||
|
(
|
||||||
|
Foam::debug::optimisationSwitch("fileModificationSkew", 30)
|
||||||
|
);
|
||||||
|
registerOptSwitch
|
||||||
|
(
|
||||||
|
"fileModificationSkew",
|
||||||
|
int,
|
||||||
|
Foam::regIOobject::fileModificationSkew
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
const Foam::NamedEnum<Foam::regIOobject::fileCheckTypes, 4>
|
const Foam::NamedEnum<Foam::regIOobject::fileCheckTypes, 4>
|
||||||
Foam::regIOobject::fileCheckTypesNames;
|
Foam::regIOobject::fileCheckTypesNames;
|
||||||
|
|||||||
@ -1,65 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2012-2015 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 info switches.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifndef registerInfoSwitch_H
|
|
||||||
#define registerInfoSwitch_H
|
|
||||||
|
|
||||||
#include "simpleRegIOobject.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
//- 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)
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,65 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2012-2015 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 optimization switches.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifndef registerOptSwitch_H
|
|
||||||
#define registerOptSwitch_H
|
|
||||||
|
|
||||||
#include "simpleRegIOobject.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
//- 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)
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
90
src/OpenFOAM/global/debug/registerSwitch.H
Normal file
90
src/OpenFOAM/global/debug/registerSwitch.H
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2015 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
|
||||||
|
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"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
class RegisterSwitch
|
||||||
|
:
|
||||||
|
public ::Foam::simpleRegIOobject
|
||||||
|
{
|
||||||
|
Type& optSwitch_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
RegisterSwitch
|
||||||
|
(
|
||||||
|
void (*registryFn)(const char* name, simpleRegIOobject*),
|
||||||
|
const char* name,
|
||||||
|
Type& optSwitch
|
||||||
|
)
|
||||||
|
:
|
||||||
|
::Foam::simpleRegIOobject(registryFn, name),
|
||||||
|
optSwitch_(optSwitch)
|
||||||
|
{}
|
||||||
|
|
||||||
|
virtual ~RegisterSwitch()
|
||||||
|
{}
|
||||||
|
|
||||||
|
virtual void readData(Foam::Istream& is)
|
||||||
|
{
|
||||||
|
is >> optSwitch_;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void writeData(Foam::Ostream& os) const
|
||||||
|
{
|
||||||
|
os << optSwitch_;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#define CONCAT(x, y) x ## y
|
||||||
|
#define CONCAT2(x, y) CONCAT(x, y)
|
||||||
|
#define FILE_UNIQUE(x) CONCAT2(x, __LINE__)
|
||||||
|
|
||||||
|
#define registerOptSwitch(Name, Type, Switch) \
|
||||||
|
static RegisterSwitch<Type> FILE_UNIQUE(_addToOpt_) \
|
||||||
|
(Foam::debug::addOptimisationObject, Name, Switch)
|
||||||
|
|
||||||
|
|
||||||
|
#define registerInfoSwitch(Name, Type, Switch) \
|
||||||
|
static RegisterSwitch<Type> FILE_UNIQUE(_addToOpt_) \
|
||||||
|
(Foam::debug::addInfoObject, Name, Switch)
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
Reference in New Issue
Block a user