Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-xt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
ag-ohlberger
dune-community
dune-xt
Commits
77b658f8
Commit
77b658f8
authored
4 years ago
by
Tobias Leibner
Browse files
Options
Downloads
Patches
Plain Diff
[test.la] fix undefined behavior
parent
a67c9a52
No related branches found
No related tags found
1 merge request
!44
ccache and clang sanitizer flags for CI
Pipeline
#65234
failed
4 years ago
Stage: images
Stage: cpp
Stage: python
Stage: headercheck
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dune/xt/la/solver/istl/schurcomplement.hh
+14
-5
14 additions, 5 deletions
dune/xt/la/solver/istl/schurcomplement.hh
dune/xt/test/la/solver.tpl
+4
-0
4 additions, 0 deletions
dune/xt/test/la/solver.tpl
with
18 additions
and
5 deletions
dune/xt/la/solver/istl/schurcomplement.hh
+
14
−
5
View file @
77b658f8
...
...
@@ -15,8 +15,10 @@
#include
<dune/istl/operators.hh>
#include
<dune/istl/solvers.hh>
#include
<dune/xt/common/exceptions.hh>
#include
<dune/xt/common/configuration.hh>
#include
<dune/xt/common/exceptions.hh>
#include
<dune/xt/common/math.hh>
#include
<dune/xt/la/container/istl.hh>
#include
<dune/xt/la/solver.hh>
...
...
@@ -82,10 +84,17 @@ public:
auto
&
B1x
=
m_vec_1_
;
B1_
.
mv
(
x
,
B1x
);
// calculate A^{-1} B1 x
auto
&
AinvB1x
=
m_vec_2_
;
A_inv_
.
apply
(
B1x
,
AinvB1x
,
solver_opts_
);
// apply B2^T
B2_
.
mtv
(
AinvB1x
,
y
);
if
(
XT
::
Common
::
is_zero
(
B1x
.
two_norm
()))
{
// if B1x is zero, y will also be zero
// this special case is here to avoid calling the dune-istl CG solver with an
// initial defect of 0 which causes undefined behavior (division-by-zero)
y
*=
0.
;
}
else
{
auto
&
AinvB1x
=
m_vec_2_
;
A_inv_
.
apply
(
B1x
,
AinvB1x
,
solver_opts_
);
// apply B2^T
B2_
.
mtv
(
AinvB1x
,
y
);
}
// calculate Cx
auto
&
Cx
=
n_vec_1_
;
C_
.
mv
(
x
,
Cx
);
...
...
This diff is collapsed.
Click to expand it.
dune/xt/test/la/solver.tpl
+
4
−
0
View file @
77b658f8
...
...
@@ -64,6 +64,10 @@ struct SolverTest_{{T_NAME}} : public ::testing::Test
options.report(out, " ");
// dynamic tests
// Matrix is the identity matrix, solution and rhs are initially filled with ones
// Multiply by 2 to avoid calling the istl iterative solver with an
// initial defect of 0 which results in undefined behavior (division-by-zero)
solution *= 2.;
solver.apply(rhs, solution, type);
EXPECT_TRUE(XT::Common::FloatCmp::eq(solution, rhs));
solution *= 0.;
...
...
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