Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-solvers
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
agnumpde
dune-solvers
Commits
2ae7a612
Commit
2ae7a612
authored
7 years ago
by
Jonathan Youett
Browse files
Options
Downloads
Patches
Plain Diff
Make iterationStep and errorNorm protected and store it as shared_ptr
parent
ff877be7
No related branches found
No related tags found
1 merge request
!15
Reduce raw pointer
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/solvers/solvers/iterativesolver.hh
+60
-6
60 additions, 6 deletions
dune/solvers/solvers/iterativesolver.hh
with
60 additions
and
6 deletions
dune/solvers/solvers/iterativesolver.hh
+
60
−
6
View file @
2ae7a612
...
...
@@ -6,6 +6,7 @@
#include
<dune/common/ftraits.hh>
#include
<dune/solvers/common/defaultbitvector.hh>
#include
<dune/solvers/common/wrapownshare.hh>
#include
<dune/solvers/solvers/solver.hh>
#include
<dune/solvers/iterationsteps/iterationstep.hh>
#include
<dune/solvers/norms/norm.hh>
...
...
@@ -19,7 +20,9 @@ namespace Dune {
class
IterativeSolver
:
public
Solver
{
// For norms and convergence rates
typedef
typename
Dune
::
FieldTraits
<
VectorType
>::
real_type
real_type
;
using
real_type
=
typename
Dune
::
FieldTraits
<
VectorType
>::
real_type
;
using
ItStep
=
IterationStep
<
VectorType
,
BitVectorType
>
;
using
ErrorNorm
=
Norm
<
VectorType
>
;
public:
...
...
@@ -30,12 +33,13 @@ namespace Dune {
bool
useRelativeError
=
true
)
:
Solver
(
verbosity
),
tolerance_
(
tolerance
),
maxIterations_
(
maxIterations
),
errorNorm_
(
NULL
),
maxIterations_
(
maxIterations
),
errorNorm_
(
nullptr
),
historyBuffer_
(
""
),
useRelativeError_
(
useRelativeError
)
{}
/** \brief Constructor taking all relevant data */
DUNE_DEPRECATED_MSG
(
"Handing over raw pointer in the constructor is deprecated!"
)
IterativeSolver
(
int
maxIterations
,
double
tolerance
,
const
Norm
<
VectorType
>*
errorNorm
,
...
...
@@ -43,7 +47,23 @@ namespace Dune {
bool
useRelativeError
=
true
)
:
Solver
(
verbosity
),
tolerance_
(
tolerance
),
maxIterations_
(
maxIterations
),
errorNorm_
(
errorNorm
),
maxIterations_
(
maxIterations
),
errorNorm_
(
Dune
::
stackobject_to_shared_ptr
(
*
errorNorm
)),
historyBuffer_
(
""
),
useRelativeError_
(
useRelativeError
)
{}
/** \brief Constructor taking all relevant data */
template
<
class
NormT
,
class
Enable
=
std
::
enable_if_t
<
not
std
::
is_pointer
<
NormT
>
::
value
>
>
IterativeSolver
(
int
maxIterations
,
double
tolerance
,
NormT
&&
errorNorm
,
VerbosityMode
verbosity
,
bool
useRelativeError
=
true
)
:
Solver
(
verbosity
),
tolerance_
(
tolerance
),
maxIterations_
(
maxIterations
),
errorNorm_
(
wrap_own_share
<
const
ErrorNorm
>
(
std
::
forward
<
NormT
>
(
errorNorm
))),
historyBuffer_
(
""
),
useRelativeError_
(
useRelativeError
)
{}
...
...
@@ -59,8 +79,37 @@ namespace Dune {
/** \brief Write the current iterate to disk (for convergence measurements) */
void
writeIterate
(
const
VectorType
&
iterate
,
int
iterationNumber
)
const
;
//! The iteration step used by the algorithm
IterationStep
<
VectorType
,
BitVectorType
>*
iterationStep_
;
/** \brief Set iteration step */
template
<
class
Step
>
void
setIterationStep
(
Step
&&
iterationStep
)
{
iterationStep_
=
wrap_own_share
<
ItStep
>
(
std
::
forward
<
Step
>
(
iterationStep
));
}
/** \brief Get iteration step */
const
ItStep
&
getIterationStep
()
const
{
return
*
iterationStep_
;
}
/** \brief Get iteration step */
ItStep
&
getIterationStep
()
{
return
*
iterationStep_
;
}
/** \brief Set the error norm */
template
<
class
NormT
>
void
setErrorNorm
(
NormT
&&
errorNorm
)
{
errorNorm_
=
wrap_own_share
<
ErrorNorm
>
(
std
::
forward
<
NormT
>
(
errorNorm
));
}
/** \brief Get error norm */
const
ItStep
&
getErrorNorm
()
const
{
return
*
errorNorm_
;
}
/** \brief The requested tolerance of the solver */
double
tolerance_
;
...
...
@@ -68,9 +117,14 @@ namespace Dune {
//! The maximum number of iterations
int
maxIterations_
;
protected
:
//! The iteration step used by the algorithm
std
::
shared_ptr
<
IterationStep
<
VectorType
,
BitVectorType
>
>
iterationStep_
;
//! The norm used to measure convergence
const
Norm
<
VectorType
>
*
errorNorm_
;
std
::
shared_ptr
<
const
Norm
<
VectorType
>
>
errorNorm_
;
public
:
/** \brief If this string is nonempty it is expected to contain a valid
directory name. All intermediate iterates are then written there. */
std
::
string
historyBuffer_
;
...
...
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