Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dumux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dumux-repositories
dumux
Commits
920dc578
Commit
920dc578
authored
5 years ago
by
Timo Koch
Browse files
Options
Downloads
Plain Diff
Merge branch 'fix/params' into 'master'
Fix/params See merge request
!1633
parents
075e46f9
1dfd9ab6
No related branches found
No related tags found
1 merge request
!1633
Fix/params
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dumux/common/parameters.hh
+53
-60
53 additions, 60 deletions
dumux/common/parameters.hh
with
53 additions
and
60 deletions
dumux/common/parameters.hh
+
53
−
60
View file @
920dc578
...
@@ -83,7 +83,7 @@ public:
...
@@ -83,7 +83,7 @@ public:
* \param parameterFileName the file name of the input file
* \param parameterFileName the file name of the input file
* \param usage the usage function to print if the help option was passed on the command line
* \param usage the usage function to print if the help option was passed on the command line
* \note the default parameter tree is initialized in the following way
* \note the default parameter tree is initialized in the following way
* 1) global defaults (see member function
g
lobalDefault
Parameter
s_)
* 1) global defaults (see member function
applyG
lobalDefaults_)
* 2) user provided defaults (overwrite global defaults)
* 2) user provided defaults (overwrite global defaults)
* the parameter tree is initialized in the following way
* the parameter tree is initialized in the following way
* 1) parameters from the input file
* 1) parameters from the input file
...
@@ -112,8 +112,8 @@ public:
...
@@ -112,8 +112,8 @@ public:
}
}
// apply the default parameters
// apply the default parameters
globalDefaultParameters_
(
defaultParamTree_
());
defaultParams
(
defaultParamTree_
());
defaultParams
(
defaultParamTree_
());
applyGlobalDefaults_
(
defaultParamTree_
());
// parse paramters from the command line
// parse paramters from the command line
const
auto
commandLineArgs
=
parseCommandLine
(
argc
,
argv
);
const
auto
commandLineArgs
=
parseCommandLine
(
argc
,
argv
);
...
@@ -184,8 +184,8 @@ public:
...
@@ -184,8 +184,8 @@ public:
// apply the parameters
// apply the parameters
params
(
paramTree_
());
params
(
paramTree_
());
// apply the default parameters
// apply the default parameters
globalDefaultParameters_
(
defaultParamTree_
());
defaultParams
(
defaultParamTree_
());
defaultParams
(
defaultParamTree_
());
applyGlobalDefaults_
(
defaultParamTree_
());
}
}
/*!
/*!
...
@@ -211,14 +211,14 @@ public:
...
@@ -211,14 +211,14 @@ public:
Dune
::
ParameterTreeParser
::
readINITree
(
parameterFileName
,
paramTree_
(),
inputFileOverwritesParams
);
Dune
::
ParameterTreeParser
::
readINITree
(
parameterFileName
,
paramTree_
(),
inputFileOverwritesParams
);
// apply the default parameters
// apply the default parameters
globalDefaultParameters_
(
defaultParamTree_
());
defaultParams
(
defaultParamTree_
());
defaultParams
(
defaultParamTree_
());
applyGlobalDefaults_
(
defaultParamTree_
());
}
}
//! prints all used and unused parameters
//! prints all used and unused parameters
static
void
print
()
static
void
print
()
{
{
getTree
_
().
reportAll
();
getTree
().
reportAll
();
}
}
//! Parse command line arguments into a parameter tree
//! Parse command line arguments into a parameter tree
...
@@ -303,25 +303,18 @@ public:
...
@@ -303,25 +303,18 @@ public:
return
parameterFileName
;
return
parameterFileName
;
}
}
DUNE_DEPRECATED_MSG
(
"getTree is deprecated and will be removed after 3.1"
)
static
const
LoggingParameterTree
&
getTree
()
{
return
getTree_
();
}
private
:
/*!
/*!
* \brief Get the parameter tree
* \brief Get the parameter tree
*
*
* The logging parameter tree recording which parameters are used during the simulation
* The logging parameter tree recording which parameters are used during the simulation
* \note Once this has been called the first time, you cannot modify the parameter tree anymore
*/
*/
static
const
LoggingParameterTree
&
getTree
_
()
static
const
LoggingParameterTree
&
getTree
()
{
{
static
LoggingParameterTree
tree
(
paramTree_
(),
defaultParamTree_
());
static
LoggingParameterTree
tree
(
paramTree_
(),
defaultParamTree_
());
return
tree
;
return
tree
;
}
}
private
:
//! the actual internal parameter tree storing all user-specfied runtime parameters
//! the actual internal parameter tree storing all user-specfied runtime parameters
static
Dune
::
ParameterTree
&
paramTree_
()
static
Dune
::
ParameterTree
&
paramTree_
()
{
{
...
@@ -338,53 +331,59 @@ private:
...
@@ -338,53 +331,59 @@ private:
//! This method puts all default arguments into the parameter tree
//! This method puts all default arguments into the parameter tree
//! we do this once per simulation on call to Parameters::init();
//! we do this once per simulation on call to Parameters::init();
static
void
g
lobalDefault
Parameter
s_
(
Dune
::
ParameterTree
&
params
)
static
void
applyG
lobalDefaults_
(
Dune
::
ParameterTree
&
params
)
{
{
// global defaults
Dune
::
ParameterTree
defaultParams
;
// parameters in the implicit group
// parameters in the implicit group
p
arams
[
"Flux.UpwindWeight"
]
=
"1.0"
;
defaultP
arams
[
"Flux.UpwindWeight"
]
=
"1.0"
;
p
arams
[
"Implicit.EnableJacobianRecycling"
]
=
"false"
;
defaultP
arams
[
"Implicit.EnableJacobianRecycling"
]
=
"false"
;
// parameters in the assembly group
// parameters in the assembly group
p
arams
[
"Assembly.NumericDifferenceMethod"
]
=
"1"
;
defaultP
arams
[
"Assembly.NumericDifferenceMethod"
]
=
"1"
;
// parameters in the linear solver group
// parameters in the linear solver group
p
arams
[
"LinearSolver.GMResRestart"
]
=
"10"
;
defaultP
arams
[
"LinearSolver.GMResRestart"
]
=
"10"
;
p
arams
[
"LinearSolver.MaxIterations"
]
=
"250"
;
defaultP
arams
[
"LinearSolver.MaxIterations"
]
=
"250"
;
p
arams
[
"LinearSolver.PreconditionerIterations"
]
=
"1"
;
defaultP
arams
[
"LinearSolver.PreconditionerIterations"
]
=
"1"
;
p
arams
[
"LinearSolver.PreconditionerRelaxation"
]
=
"1.0"
;
defaultP
arams
[
"LinearSolver.PreconditionerRelaxation"
]
=
"1.0"
;
p
arams
[
"LinearSolver.ResidualReduction"
]
=
"1e-13"
;
defaultP
arams
[
"LinearSolver.ResidualReduction"
]
=
"1e-13"
;
p
arams
[
"LinearSolver.Verbosity"
]
=
"0"
;
defaultP
arams
[
"LinearSolver.Verbosity"
]
=
"0"
;
// parameters in the problem group
// parameters in the problem group
p
arams
[
"Problem.EnableGravity"
]
=
"true"
;
defaultP
arams
[
"Problem.EnableGravity"
]
=
"true"
;
p
arams
[
"Problem.EnableInertiaTerms"
]
=
"true"
;
defaultP
arams
[
"Problem.EnableInertiaTerms"
]
=
"true"
;
// parameters in the Newton group
// parameters in the Newton group
// MinSteps = 2 makes Newton more robust if converge criterion is not perfect
// MinSteps = 2 makes Newton more robust if converge criterion is not perfect
p
arams
[
"Newton.MinSteps"
]
=
"2"
;
defaultP
arams
[
"Newton.MinSteps"
]
=
"2"
;
p
arams
[
"Newton.MaxSteps"
]
=
"18"
;
defaultP
arams
[
"Newton.MaxSteps"
]
=
"18"
;
p
arams
[
"Newton.TargetSteps"
]
=
"10"
;
defaultP
arams
[
"Newton.TargetSteps"
]
=
"10"
;
p
arams
[
"Newton.UseLineSearch"
]
=
"false"
;
defaultP
arams
[
"Newton.UseLineSearch"
]
=
"false"
;
p
arams
[
"Newton.EnableChop"
]
=
"false"
;
defaultP
arams
[
"Newton.EnableChop"
]
=
"false"
;
p
arams
[
"Newton.EnableShiftCriterion"
]
=
"true"
;
defaultP
arams
[
"Newton.EnableShiftCriterion"
]
=
"true"
;
p
arams
[
"Newton.MaxRelativeShift"
]
=
"1e-8"
;
defaultP
arams
[
"Newton.MaxRelativeShift"
]
=
"1e-8"
;
p
arams
[
"Newton.EnableResidualCriterion"
]
=
"false"
;
defaultP
arams
[
"Newton.EnableResidualCriterion"
]
=
"false"
;
p
arams
[
"Newton.ResidualReduction"
]
=
"1e-5"
;
defaultP
arams
[
"Newton.ResidualReduction"
]
=
"1e-5"
;
p
arams
[
"Newton.EnableAbsoluteResidualCriterion"
]
=
"false"
;
defaultP
arams
[
"Newton.EnableAbsoluteResidualCriterion"
]
=
"false"
;
p
arams
[
"Newton.MaxAbsoluteResidual"
]
=
"1e-5"
;
defaultP
arams
[
"Newton.MaxAbsoluteResidual"
]
=
"1e-5"
;
p
arams
[
"Newton.SatisfyResidualAndShiftCriterion"
]
=
"false"
;
defaultP
arams
[
"Newton.SatisfyResidualAndShiftCriterion"
]
=
"false"
;
p
arams
[
"Newton.EnablePartialReassembly"
]
=
"false"
;
defaultP
arams
[
"Newton.EnablePartialReassembly"
]
=
"false"
;
// parameters in the time loop group
// parameters in the time loop group
p
arams
[
"TimeLoop.MaxTimeStepSize"
]
=
"1e300"
;
defaultP
arams
[
"TimeLoop.MaxTimeStepSize"
]
=
"1e300"
;
p
arams
[
"TimeLoop.MaxTimeStepDivisions"
]
=
"10"
;
defaultP
arams
[
"TimeLoop.MaxTimeStepDivisions"
]
=
"10"
;
// parameters in the vtk group
// parameters in the vtk group
p
arams
[
"Vtk.AddVelocity"
]
=
"false"
;
defaultP
arams
[
"Vtk.AddVelocity"
]
=
"false"
;
p
arams
[
"Vtk.AddProcessRank"
]
=
"true"
;
defaultP
arams
[
"Vtk.AddProcessRank"
]
=
"true"
;
// parameters in the mpfa group
// parameters in the mpfa group
params
[
"Mpfa.Q"
]
=
"0.0"
;
defaultParams
[
"Mpfa.Q"
]
=
"0.0"
;
// merge the global default tree but do not overwrite if the parameter already exists
mergeTree_
(
params
,
defaultParams
,
false
);
}
}
//! merge source into target tree
//! merge source into target tree
...
@@ -392,22 +391,16 @@ private:
...
@@ -392,22 +391,16 @@ private:
{
mergeTreeImpl_
(
target
,
source
,
overwrite
,
""
);
}
{
mergeTreeImpl_
(
target
,
source
,
overwrite
,
""
);
}
//! recursively merge all elements
//! recursively merge all elements
static
void
mergeTreeImpl_
(
Dune
::
ParameterTree
&
target
,
const
Dune
::
ParameterTree
&
source
,
bool
overwrite
,
const
std
::
string
&
prefix
)
static
void
mergeTreeImpl_
(
Dune
::
ParameterTree
&
target
,
const
Dune
::
ParameterTree
&
source
,
bool
overwrite
,
const
std
::
string
&
group
)
{
{
const
auto
prefix
=
group
==
""
?
""
:
group
+
"."
;
for
(
const
auto
&
key
:
source
.
getValueKeys
())
for
(
const
auto
&
key
:
source
.
getValueKeys
())
if
(
overwrite
||
!
target
.
hasKey
(
key
))
if
(
overwrite
||
!
target
.
hasKey
(
key
))
target
[
prefix
+
"."
+
key
]
=
source
[
key
];
target
[
prefix
+
key
]
=
source
[
key
];
const
auto
nextPrefix
=
prefix
==
""
?
""
:
prefix
+
"."
;
for
(
const
auto
&
subKey
:
source
.
getSubKeys
())
for
(
const
auto
&
subKey
:
source
.
getSubKeys
())
mergeTreeImpl_
(
target
,
source
.
sub
(
subKey
),
overwrite
,
nextP
refix
+
subKey
);
mergeTreeImpl_
(
target
,
source
.
sub
(
subKey
),
overwrite
,
p
refix
+
subKey
);
}
}
// be friends with the accesors
template
<
typename
T
,
typename
...
Args
>
friend
T
getParam
(
Args
&&
...
args
);
template
<
typename
T
,
typename
...
Args
>
friend
T
getParamFromGroup
(
Args
&&
...
args
);
friend
bool
hasParam
(
const
std
::
string
&
param
);
friend
bool
hasParamInGroup
(
const
std
::
string
&
paramGroup
,
const
std
::
string
&
param
);
};
};
/*!
/*!
...
@@ -434,7 +427,7 @@ void setParam(Dune::ParameterTree& params,
...
@@ -434,7 +427,7 @@ void setParam(Dune::ParameterTree& params,
*/
*/
template
<
typename
T
,
typename
...
Args
>
template
<
typename
T
,
typename
...
Args
>
T
getParam
(
Args
&&
...
args
)
T
getParam
(
Args
&&
...
args
)
{
return
Parameters
::
getTree
_
().
template
get
<
T
>(
std
::
forward
<
Args
>
(
args
)...
);
}
{
return
Parameters
::
getTree
().
template
get
<
T
>(
std
::
forward
<
Args
>
(
args
)...
);
}
/*!
/*!
* \ingroup Common
* \ingroup Common
...
@@ -444,23 +437,23 @@ T getParam(Args&&... args)
...
@@ -444,23 +437,23 @@ T getParam(Args&&... args)
*/
*/
template
<
typename
T
,
typename
...
Args
>
template
<
typename
T
,
typename
...
Args
>
T
getParamFromGroup
(
Args
&&
...
args
)
T
getParamFromGroup
(
Args
&&
...
args
)
{
return
Parameters
::
getTree
_
().
template
getFromGroup
<
T
>(
std
::
forward
<
Args
>
(
args
)...
);
}
{
return
Parameters
::
getTree
().
template
getFromGroup
<
T
>(
std
::
forward
<
Args
>
(
args
)...
);
}
/*!
/*!
* \ingroup Common
* \ingroup Common
* \brief Check whether a key exists in the parameter tree
* \brief Check whether a key exists in the parameter tree
* \note Once this has been called the first time, you cannot modify the parameter tree anymore
* \note Once this has been called the first time, you cannot modify the parameter tree anymore
*/
*/
bool
hasParam
(
const
std
::
string
&
param
)
inline
bool
hasParam
(
const
std
::
string
&
param
)
{
return
Parameters
::
getTree
_
().
hasKey
(
param
);
}
{
return
Parameters
::
getTree
().
hasKey
(
param
);
}
/*!
/*!
* \ingroup Common
* \ingroup Common
* \brief Check whether a key exists in the parameter tree with a model group prefix
* \brief Check whether a key exists in the parameter tree with a model group prefix
* \note Once this has been called the first time, you cannot modify the parameter tree anymore
* \note Once this has been called the first time, you cannot modify the parameter tree anymore
*/
*/
bool
hasParamInGroup
(
const
std
::
string
&
paramGroup
,
const
std
::
string
&
param
)
inline
bool
hasParamInGroup
(
const
std
::
string
&
paramGroup
,
const
std
::
string
&
param
)
{
return
Parameters
::
getTree
_
().
hasKeyInGroup
(
param
,
paramGroup
);
}
{
return
Parameters
::
getTree
().
hasKeyInGroup
(
param
,
paramGroup
);
}
}
// namespace Dumux
}
// namespace Dumux
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment