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
90ffe5c0
Commit
90ffe5c0
authored
8 years ago
by
Elias Pipping
Browse files
Options
Downloads
Patches
Plain Diff
Tests: Clean up output and add benchmarking
parent
6fa42ab1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/solvers/test/cgsteptest.cc
+46
-38
46 additions, 38 deletions
dune/solvers/test/cgsteptest.cc
with
46 additions
and
38 deletions
dune/solvers/test/cgsteptest.cc
+
46
−
38
View file @
90ffe5c0
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
#include
<iostream>
#include
<iostream>
#include
<dune/common/parallel/mpihelper.hh>
#include
<dune/common/parallel/mpihelper.hh>
#include
<dune/common/timer.hh>
#include
<dune/solvers/solvers/loopsolver.hh>
#include
<dune/solvers/solvers/loopsolver.hh>
#include
<dune/solvers/iterationsteps/blockgssteps.hh>
#include
<dune/solvers/iterationsteps/blockgssteps.hh>
...
@@ -22,10 +23,11 @@ public:
...
@@ -22,10 +23,11 @@ public:
{}
{}
bool
bool
analyse
(
typename
Problem
::
Vector
const
&
candidate
,
std
::
string
testCase
)
{
analyse
(
typename
Problem
::
Vector
const
&
candidate
,
SolverResult
solverResult
,
double
t
,
std
::
string
testCase
)
{
const
auto
twoNormDiff
=
p_
.
twoNorm
.
diff
(
p_
.
u_ex
,
candidate
);
const
auto
twoNormDiff
=
p_
.
twoNorm
.
diff
(
p_
.
u_ex
,
candidate
);
std
::
cout
<<
"Defect two norm |u-u_n| for solver
\"
"
<<
testCase
printf
(
"%f | %3zu | %11g | %11g | %s
\n
"
,
t
,
solverResult
.
iterations
,
<<
"
\"
: "
<<
twoNormDiff
<<
std
::
endl
;
solverResult
.
conv_rate
,
twoNormDiff
,
testCase
.
c_str
())
;
if
(
twoNormDiff
>
tolerance_
)
{
if
(
twoNormDiff
>
tolerance_
)
{
std
::
cerr
<<
"### Error too large for solver
\"
"
<<
testCase
<<
"
\"
."
std
::
cerr
<<
"### Error too large for solver
\"
"
<<
testCase
<<
"
\"
."
<<
std
::
endl
;
<<
std
::
endl
;
...
@@ -59,12 +61,44 @@ struct CGTestSuite
...
@@ -59,12 +61,44 @@ struct CGTestSuite
SymmetricSampleProblem
<
1
,
typename
GridType
::
LevelGridView
>
;
SymmetricSampleProblem
<
1
,
typename
GridType
::
LevelGridView
>
;
Problem
p
(
grid
.
levelGridView
(
grid
.
maxLevel
()));
Problem
p
(
grid
.
levelGridView
(
grid
.
maxLevel
()));
const
auto
verbosity
=
Solver
::
REDUCED
;
const
auto
verbosity
=
Solver
::
QUIET
;
const
bool
relativeErrors
=
false
;
const
bool
relativeErrors
=
false
;
// Test that ignoreNodes are honoured.
{
typename
Problem
::
Vector
u_copy
=
p
.
u
;
for
(
size_t
i
=
0
;
i
<
p
.
u
.
size
();
++
i
)
if
(
p
.
ignore
[
i
].
any
())
u_copy
[
i
]
+=
1.0
;
typename
Problem
::
Vector
rhs_copy
=
p
.
rhs
;
Dune
::
Solvers
::
CGStep
<
typename
Problem
::
Matrix
,
typename
Problem
::
Vector
>
cgStep
(
p
.
A
,
u_copy
,
rhs_copy
);
cgStep
.
setIgnore
(
p
.
ignore
);
::
LoopSolver
<
typename
Problem
::
Vector
>
solver
(
&
cgStep
,
maxIterations
,
stepTol
,
&
p
.
twoNorm
,
Solver
::
QUIET
,
relativeErrors
);
solver
.
check
();
solver
.
preprocess
();
solver
.
solve
();
for
(
size_t
i
=
0
;
i
<
p
.
u
.
size
();
++
i
)
if
(
p
.
ignore
[
i
].
any
())
if
(
std
::
abs
(
u_copy
[
i
]
-
1.0
-
p
.
u_ex
[
i
])
>
solveTol
)
{
std
::
cerr
<<
"### error: ignoredNodes not respected!"
<<
std
::
endl
;
passed
=
false
;
break
;
}
}
// Test if we get the right solution and benchmark
Analyser
<
Problem
>
analyser
(
p
,
solveTol
);
Analyser
<
Problem
>
analyser
(
p
,
solveTol
);
Dune
::
Timer
timer
;
printf
(
"time [s] | #it | conv. rate | abs. error | preconditioner
\n
"
);
{
{
std
::
string
const
testCase
=
"
Dune::Solvers::CGStep
"
;
std
::
string
const
testCase
=
"
none
"
;
typename
Problem
::
Vector
u_copy
=
p
.
u
;
typename
Problem
::
Vector
u_copy
=
p
.
u
;
typename
Problem
::
Vector
rhs_copy
=
p
.
rhs
;
typename
Problem
::
Vector
rhs_copy
=
p
.
rhs
;
...
@@ -77,13 +111,15 @@ struct CGTestSuite
...
@@ -77,13 +111,15 @@ struct CGTestSuite
&
cgStep
,
maxIterations
,
stepTol
,
&
p
.
twoNorm
,
verbosity
,
&
cgStep
,
maxIterations
,
stepTol
,
&
p
.
twoNorm
,
verbosity
,
relativeErrors
);
relativeErrors
);
solver
.
check
();
solver
.
check
();
timer
.
reset
();
solver
.
preprocess
();
solver
.
preprocess
();
solver
.
solve
();
solver
.
solve
();
passed
&=
analyser
.
analyse
(
u_copy
,
testCase
);
passed
&=
analyser
.
analyse
(
u_copy
,
solver
.
getResult
(),
timer
.
elapsed
(),
testCase
);
}
}
{
{
std
::
string
const
testCase
=
"
Dune::Solvers::CGStep, preconditioned
"
;
std
::
string
const
testCase
=
"
BlockGS
"
;
typename
Problem
::
Vector
u_copy
=
p
.
u
;
typename
Problem
::
Vector
u_copy
=
p
.
u
;
typename
Problem
::
Vector
rhs_copy
=
p
.
rhs
;
typename
Problem
::
Vector
rhs_copy
=
p
.
rhs
;
...
@@ -102,41 +138,13 @@ struct CGTestSuite
...
@@ -102,41 +138,13 @@ struct CGTestSuite
&
cgStep
,
maxIterations
,
stepTol
,
&
p
.
twoNorm
,
verbosity
,
&
cgStep
,
maxIterations
,
stepTol
,
&
p
.
twoNorm
,
verbosity
,
relativeErrors
);
relativeErrors
);
solver
.
check
();
solver
.
check
();
timer
.
reset
();
solver
.
preprocess
();
solver
.
preprocess
();
solver
.
solve
();
solver
.
solve
();
passed
&=
analyser
.
analyse
(
u_copy
,
testCase
);
passed
&=
analyser
.
analyse
(
u_copy
,
solver
.
getResult
(),
timer
.
elapsed
(),
testCase
);
}
}
// Test that ignoreNodes are honoured.
{
typename
Problem
::
Vector
u_copy
=
p
.
u
;
for
(
size_t
i
=
0
;
i
<
p
.
u
.
size
();
++
i
)
if
(
p
.
ignore
[
i
].
any
())
u_copy
[
i
]
+=
1.0
;
typename
Problem
::
Vector
rhs_copy
=
p
.
rhs
;
Dune
::
Solvers
::
CGStep
<
typename
Problem
::
Matrix
,
typename
Problem
::
Vector
>
cgStep
(
p
.
A
,
u_copy
,
rhs_copy
);
cgStep
.
setIgnore
(
p
.
ignore
);
::
LoopSolver
<
typename
Problem
::
Vector
>
solver
(
&
cgStep
,
maxIterations
,
stepTol
,
&
p
.
twoNorm
,
Solver
::
QUIET
,
relativeErrors
);
solver
.
check
();
solver
.
preprocess
();
solver
.
solve
();
for
(
size_t
i
=
0
;
i
<
p
.
u
.
size
();
++
i
)
if
(
p
.
ignore
[
i
].
any
())
if
(
std
::
abs
(
u_copy
[
i
]
-
1.0
-
p
.
u_ex
[
i
])
>
solveTol
)
{
std
::
cerr
<<
"### error: ignoredNodes not respected!"
<<
std
::
endl
;
passed
=
false
;
break
;
}
}
return
passed
;
return
passed
;
}
}
};
};
...
...
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