Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
amdis
amdis-core
Commits
5c9749d2
Commit
5c9749d2
authored
Feb 08, 2020
by
Praetorius, Simon
Browse files
merged issue/solver_info
parents
91b1d5ab
a99f9670
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/amdis/ProblemStat.inc.hpp
View file @
5c9749d2
...
...
@@ -396,16 +396,7 @@ solve(AdaptInfo& adaptInfo, bool createMatrixData, bool storeMatrixData)
}
}
if
(
solverInfo
.
doBreak
())
{
std
::
stringstream
tol_str
;
if
(
solverInfo
.
absTolerance
()
>
0
&&
solverInfo
.
absResidual
()
>
solverInfo
.
absTolerance
())
tol_str
<<
"absTol = "
<<
solverInfo
.
absTolerance
()
<<
" "
;
if
(
solverInfo
.
relTolerance
()
>
0
&&
solverInfo
.
relResidual
()
>
solverInfo
.
relTolerance
())
tol_str
<<
"relTol = "
<<
solverInfo
.
relTolerance
()
<<
" "
;
error_exit
(
"Tolerance {} could not be reached!"
,
tol_str
.
str
());
}
test_exit
(
!
solverInfo
.
doBreak
()
&&
!
solverInfo
.
error
(),
"Could not solver the linear system!"
);
}
...
...
src/amdis/linearalgebra/SolverInfo.hpp
View file @
5c9749d2
...
...
@@ -14,16 +14,12 @@ namespace AMDiS
/// The constructor reads needed parameters and sets solver \p prefix.
/**
* Reads parameters for a solver with name 'NAME':
* NAME->absolute tolerance \ref aTol_
* NAME->relative tolerance \ref rTol_
* NAME->info \ref info_
* NAME->break if tolerance not reached \ref breakTolNotReached_
**/
explicit
SolverInfo
(
std
::
string
const
&
prefix
)
:
prefix_
(
prefix
)
{
Parameters
::
get
(
prefix
+
"->absolute tolerance"
,
aTol_
);
Parameters
::
get
(
prefix
+
"->relative tolerance"
,
rTol_
);
Parameters
::
get
(
prefix
+
"->info"
,
info_
);
Parameters
::
get
(
prefix
+
"->break if tolerance not reached"
,
breakTolNotReached_
);
}
...
...
@@ -32,20 +28,8 @@ namespace AMDiS
* \{
*/
/// Returns \ref aTol_
double
absTolerance
()
const
{
return
aTol_
;
}
/// Returns \ref rTol_
double
relTolerance
()
const
{
return
rTol_
;
}
/// Returns error code in last run of an iterative solver
int
error
Code
()
const
int
error
()
const
{
return
error_
;
}
...
...
@@ -68,12 +52,6 @@ namespace AMDiS
return
relResidual_
;
}
/// Returns the initfile \ref prefix_
std
::
string
const
&
prefix
()
const
{
return
prefix_
;
}
/// Returns \ref createMatrixData
bool
doCreateMatrixData
()
const
{
...
...
@@ -88,9 +66,7 @@ namespace AMDiS
bool
doBreak
()
const
{
return
breakTolNotReached_
&&
(
(
aTol_
>
1.e-30
&&
absResidual_
>
aTol_
)
||
(
rTol_
>
1.e-30
&&
relResidual_
>
rTol_
)
);
return
breakTolNotReached_
;
}
/** \} */
...
...
@@ -100,25 +76,13 @@ namespace AMDiS
* \{
*/
/// Sets \ref aTol_
void
setAbsTolerance
(
double
tol
)
{
aTol_
=
tol
;
}
/// Sets \ref rTol_
void
setRelTolerance
(
double
tol
)
{
rTol_
=
tol
;
}
/// Sets \ref aTol_
/// Sets \ref absResidual_
void
setAbsResidual
(
double
r
)
{
absResidual_
=
r
;
}
/// Sets \ref r
To
l_
/// Sets \ref r
elResidua
l_
void
setRelResidual
(
double
r
)
{
relResidual_
=
r
;
...
...
@@ -154,12 +118,6 @@ namespace AMDiS
/// The initfile prefix to read parameters
std
::
string
prefix_
;
/// The abolute tolerance
double
aTol_
=
0
;
/// The relative tolerance
double
rTol_
=
1.e-6
;
/// Throw an error if tolerance could not be reached
bool
breakTolNotReached_
=
false
;
...
...
src/amdis/linearalgebra/eigen/IterativeRunner.hpp
View file @
5c9749d2
...
...
@@ -51,7 +51,8 @@ namespace AMDiS
/// Implements \ref RunnerInterface::solve()
int
solve
(
M
const
&
A
,
X
&
x
,
Y
const
&
b
,
SolverInfo
&
solverInfo
)
override
{
solver_
.
setTolerance
(
solverInfo
.
relTolerance
());
DUNE_UNUSED_PARAMETER
(
A
);
x
=
solver_
.
solveWithGuess
(
b
,
x
);
Y
r
=
b
;
...
...
src/amdis/linearalgebra/eigen/SolverConfig.hpp
View file @
5c9749d2
...
...
@@ -15,6 +15,11 @@ namespace AMDiS
template
<
class
D
>
static
void
init
(
std
::
string
const
&
prefix
,
Eigen
::
IterativeSolverBase
<
D
>&
solver
)
{
using
RealScalar
=
typename
Eigen
::
IterativeSolverBase
<
D
>::
RealScalar
;
auto
rtol
=
Parameters
::
get
<
RealScalar
>
(
prefix
+
"->relative tolerance"
);
if
(
rtol
)
solver
.
setTolerance
(
rtol
.
value
());
int
maxIter
=
500
;
Parameters
::
get
(
prefix
+
"->max iteration"
,
maxIter
);
solver
.
setMaxIterations
(
maxIter
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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