Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
amdis-core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
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
amdis
amdis-core
Commits
7474c377
Commit
7474c377
authored
3 months ago
by
Praetorius, Simon
Browse files
Options
Downloads
Patches
Plain Diff
Add a test for the VectorSpaceOperations
parent
4730a0bd
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/CMakeLists.txt
+3
-0
3 additions, 0 deletions
test/CMakeLists.txt
test/VectorFacadeTest.cpp
+69
-0
69 additions, 0 deletions
test/VectorFacadeTest.cpp
with
72 additions
and
0 deletions
test/CMakeLists.txt
+
3
−
0
View file @
7474c377
...
...
@@ -179,3 +179,6 @@ dune_add_test(SOURCES UniqueBorderPartitionTest.cpp
dune_add_test
(
SOURCES ValidTreePathTest.cpp
LINK_LIBRARIES amdis
)
dune_add_test
(
SOURCES VectorFacadeTest.cpp
LINK_LIBRARIES amdis
)
This diff is collapsed.
Click to expand it.
test/VectorFacadeTest.cpp
0 → 100644
+
69
−
0
View file @
7474c377
#include
<amdis/AMDiS.hpp>
#include
<amdis/DOFVector.hpp>
#include
<dune/common/test/testsuite.hh>
#include
<dune/grid/yaspgrid.hh>
#include
<dune/functions/functionspacebases/lagrangebasis.hh>
using
namespace
AMDiS
;
int
main
(
int
argc
,
char
**
argv
)
{
Environment
env
(
argc
,
argv
);
using
namespace
Dune
::
Functions
::
BasisFactory
;
Dune
::
YaspGrid
<
2
>
grid
({
1.0
,
1.0
},
{
1
,
1
});
auto
dv
=
DOFVector
{
grid
.
leafGridView
(),
lagrange
<
1
>
()};
auto
&
basis
=
dv
.
basis
();
// extract the pure vector facade
auto
&
v
=
dv
.
coefficients
();
Dune
::
TestSuite
test
;
// check the size of the vector
test
.
check
(
v
.
localSize
()
<=
v
.
globalSize
());
test
.
check
(
v
.
localSize
()
==
basis
.
dimension
());
// check that the resize has no effect
auto
ls
=
v
.
localSize
();
auto
gs
=
v
.
globalSize
();
v
.
resize
(
basis
);
test
.
check
(
v
.
localSize
()
==
ls
);
test
.
check
(
v
.
globalSize
()
==
gs
);
// check that resize with zeroing out gives components with value 0
v
.
resizeZero
(
basis
);
auto
lv
=
basis
.
localView
();
lv
.
bind
(
*
basis
.
gridView
().
begin
<
0
>
());
test
.
check
(
v
.
get
(
lv
.
index
(
0
))
==
0.0
);
test
.
check
(
v
.
state
()
==
VectorState
::
synchronized
);
v
.
init
(
basis
,
true
);
test
.
check
(
v
.
state
()
==
VectorState
::
synchronized
);
v
.
finish
();
// create a copy
auto
v2
=
v
;
v
=
0.0
;
v2
=
1.0
;
test
.
check
(
v
.
get
(
lv
.
index
(
0
))
==
0.0
);
test
.
check
(
v2
.
get
(
lv
.
index
(
0
))
==
1.0
);
// call linear algebra operations
v
.
axpy
(
2.0
,
v2
);
// v += 2.0 * v2
test
.
check
(
v
.
get
(
lv
.
index
(
0
))
==
2.0
);
v
.
aypx
(
1.5
,
v2
);
// v = 1.0 * v + v2
test
.
check
(
v
.
get
(
lv
.
index
(
0
))
==
4.0
);
v
+=
v2
;
test
.
check
(
v
.
get
(
lv
.
index
(
0
))
==
5.0
);
v
-=
v2
;
test
.
check
(
v
.
get
(
lv
.
index
(
0
))
==
4.0
);
return
test
.
exit
();
}
\ No newline at end of file
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