Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
e0adf45e
Commit
e0adf45e
authored
Feb 05, 2015
by
Henry
Browse files
registerSwitch: rationalization of info and optimization switch registration
plus support for other than integer types
parent
e58ff9d3
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C
View file @
e0adf45e
...
...
@@ -25,7 +25,7 @@ License
#include
"UPstream.H"
#include
"debug.H"
#include
"register
Opt
Switch.H"
#include
"registerSwitch.H"
#include
"dictionary.H"
#include
"IOstreams.H"
...
...
@@ -424,32 +424,32 @@ Foam::UPstream::communicator serialComm
// in accuracy
bool
Foam
::
UPstream
::
floatTransfer
(
debug
::
optimisationSwitch
(
"floatTransfer"
,
0
)
Foam
::
debug
::
optimisationSwitch
(
"floatTransfer"
,
0
)
);
registerOptSwitch
WithName
registerOptSwitch
(
Foam
::
UPstream
::
floatTransfer
,
floatTransfer
,
"
floatTransfer
"
"
floatTransfer
"
,
bool
,
Foam
::
UPstream
::
floatTransfer
);
// Number of processors at which the reduce algorithm changes from linear to
// tree
int
Foam
::
UPstream
::
nProcsSimpleSum
(
debug
::
optimisationSwitch
(
"nProcsSimpleSum"
,
16
)
Foam
::
debug
::
optimisationSwitch
(
"nProcsSimpleSum"
,
16
)
);
registerOptSwitch
WithName
registerOptSwitch
(
Foam
::
UPstream
::
nProcsSimpleSum
,
nProcsSimpleSum
,
"
nProcsSimpleSum
"
"
nProcsSimpleSum
"
,
int
,
Foam
::
UPstream
::
nProcsSimpleSum
);
// Default commsType
Foam
::
UPstream
::
commsTypes
Foam
::
UPstream
::
defaultCommsType
(
commsTypeNames
.
read
(
debug
::
optimisationSwitches
().
lookup
(
"commsType"
))
commsTypeNames
.
read
(
Foam
::
debug
::
optimisationSwitches
().
lookup
(
"commsType"
))
);
// Register re-reader
class
addcommsTypeToOpt
...
...
@@ -489,13 +489,14 @@ Foam::label Foam::UPstream::warnComm(-1);
// Number of polling cycles in processor updates
int
Foam
::
UPstream
::
nPollProcInterfaces
(
debug
::
optimisationSwitch
(
"nPollProcInterfaces"
,
0
)
Foam
::
debug
::
optimisationSwitch
(
"nPollProcInterfaces"
,
0
)
);
registerOptSwitch
WithName
registerOptSwitch
(
Foam
::
UPstream
::
nPollProcInterfaces
,
nPollProcInterfaces
,
"
nPollProcInterfaces
"
"
nPollProcInterfaces
"
,
int
,
Foam
::
UPstream
::
nPollProcInterfaces
);
// ************************************************************************* //
src/OpenFOAM/db/regIOobject/regIOobject.C
View file @
e0adf45e
...
...
@@ -26,7 +26,7 @@ License
#include
"regIOobject.H"
#include
"Time.H"
#include
"polyMesh.H"
#include
"register
Opt
Switch.H"
#include
"registerSwitch.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
...
...
@@ -34,18 +34,6 @@ namespace Foam
{
defineTypeNameAndDebug
(
regIOobject
,
0
);
int
regIOobject
::
fileModificationSkew
(
debug
::
optimisationSwitch
(
"fileModificationSkew"
,
30
)
);
registerOptSwitchWithName
(
Foam
::
regIOobject
::
fileModificationSkew
,
fileModificationSkew
,
"fileModificationSkew"
);
template
<>
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
>
Foam
::
regIOobject
::
fileCheckTypesNames
;
...
...
src/OpenFOAM/global/debug/registerOptSwitch.H
deleted
100644 → 0
View file @
e58ff9d3
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //
src/OpenFOAM/global/debug/register
Info
Switch.H
→
src/OpenFOAM/global/debug/registerSwitch.H
View file @
e0adf45e
...
...
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C)
2012-
2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
...
...
@@ -22,40 +22,65 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Macro definitions for info switches.
Class and registration macros for InfoSwitches and OptimisationSwitches
to support reading from system/controlDict and dynamic update.
\*---------------------------------------------------------------------------*/
#ifndef register
Info
Switch_H
#define register
Info
Switch_H
#ifndef registerSwitch_H
#define registerSwitch_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)
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)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment