Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-istl
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
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Core Modules
dune-istl
Commits
85ce7736
Commit
85ce7736
authored
6 years ago
by
Lasse Hinrichsen-Bischoff
Browse files
Options
Downloads
Patches
Plain Diff
[BlockVectorWindow] Demonstrate behaviour of copying blocks
parent
43faf1be
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!215
Allow autoCopy() for blocks of VariableBlockVector
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/istl/test/vbvectortest.cc
+24
-1
24 additions, 1 deletion
dune/istl/test/vbvectortest.cc
with
24 additions
and
1 deletion
dune/istl/test/vbvectortest.cc
+
24
−
1
View file @
85ce7736
...
...
@@ -3,6 +3,8 @@
#include
"config.h"
#include
<dune/istl/vbvector.hh>
#include
<dune/common/fvector.hh>
#include
<dune/common/typetraits.hh>
#include
<dune/common/test/testsuite.hh>
#include
<dune/istl/test/vectortest.hh>
...
...
@@ -10,6 +12,8 @@ using namespace Dune;
int
main
()
{
TestSuite
suite
;
VariableBlockVector
<
FieldVector
<
double
,
1
>
>
v1
;
VariableBlockVector
<
FieldVector
<
double
,
1
>
>
v2
=
v1
;
VariableBlockVector
<
FieldVector
<
double
,
1
>
>
v3
(
10
);
...
...
@@ -25,11 +29,30 @@ int main()
v3
=
1.0
;
/* Copy-ing specific blocks with `auto` from a VariableBlockVector is tricky, because
* the returned object will be a reference:
*/
auto
block0_copy_reference
=
v3
[
0
];
block0_copy_reference
[
0
]
=
4.2
;
// change first entry in the copy which has reference semantics. This also changes v3!
suite
.
check
(
v3
[
0
][
0
]
!=
1.0
,
"Show auto x = v3[0] has reference semantics"
)
<<
"Unexpected behaviour: v3[0][0] is "
<<
v3
[
0
][
0
];
v3
[
0
][
0
]
=
1.0
;
// reset v3
// For an actual copy, use the Dune::autoCopy() mechanism
// This will give a BlockVector with the contents of v3[0].
auto
block0_autoCopy
=
Dune
::
autoCopy
(
v3
[
0
]);
block0_autoCopy
[
0
]
=
4.2
;
suite
.
check
(
v3
[
0
][
0
]
==
1.0
,
"Show that v3 was not modified when copying via autoCopy"
)
<<
"Unexpected behaviour: v3[0][0] is "
<<
v3
[
0
][
0
];
// Perform more general vector tests:
testHomogeneousRandomAccessContainer
(
v3
);
Dune
::
testConstructibility
<
VariableBlockVector
<
FieldVector
<
double
,
1
>
>
>
();
testNorms
(
v3
);
testVectorSpaceOperations
(
v3
);
testScalarProduct
(
v3
);
return
0
;
return
suite
.
exit
()
;
}
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