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
6020d45d
Commit
6020d45d
authored
6 years ago
by
Timo Koch
Browse files
Options
Downloads
Patches
Plain Diff
[test][multitypeblockvector] Test construction of MultiTypeBlockVector of references of Vectors
parent
d1abd2df
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!241
MultiTypeBlockVector: Inherit tuple constructors
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/istl/test/multitypeblockvectortest.cc
+60
-42
60 additions, 42 deletions
dune/istl/test/multitypeblockvectortest.cc
with
60 additions
and
42 deletions
dune/istl/test/multitypeblockvectortest.cc
+
60
−
42
View file @
6020d45d
...
...
@@ -14,74 +14,92 @@
#include
<dune/common/exceptions.hh>
#include
<dune/common/fvector.hh>
#include
<dune/common/indices.hh>
#include
<dune/common/float_cmp.hh>
#include
<dune/istl/bvector.hh>
#include
<dune/istl/multitypeblockvector.hh>
using
namespace
Dune
;
int
main
(
int
argc
,
char
**
argv
)
try
template
<
typename
...
Args
>
void
testMultiVector
(
const
MultiTypeBlockVector
<
Args
...
>&
multiVector
)
{
using
namespace
Indices
;
// test operator<<
std
::
cout
<<
multiVector
<<
std
::
endl
;
MultiTypeBlockVector
<
BlockVector
<
FieldVector
<
double
,
3
>
>
,
BlockVector
<
FieldVector
<
double
,
1
>
>
>
multiVector
;
// test method 'count'
std
::
cout
<<
"multi vector has "
<<
multiVector
.
count
()
<<
" first level blocks"
<<
std
::
endl
;
multiVector
[
_0
]
=
{{
1
,
0
,
0
},
{
0
,
1
,
0
},
{
0
,
0
,
1
}};
static_assert
(
MultiTypeBlockVector
<
Args
...
>::
size
()
==
2
,
"Method MultiTypeBlockVector::size() returned wrong value!"
);
multiVector
[
_1
]
=
{
3.14
,
42
};
if
(
multiVector
.
count
()
!=
2
)
DUNE_THROW
(
Exception
,
"Method MultiTypeBlockVector::count returned wrong value!"
);
// Test copy construction
auto
multiVector2
=
multiVector
;
//
tes
t operator
<<
std
::
cout
<<
multiVector
<<
std
::
endl
;
//
Test assignmen
t operator
multiVector2
=
multiVector
;
//
t
est
method 'count'
std
::
cout
<<
"
multi
v
ector
has "
<<
multiVector
.
count
()
<<
" first level blocks"
<<
std
::
endl
;
//
T
est
operator+=
multi
V
ector
2
+=
multiVector
;
static_assert
(
multiVector
.
size
()
==
2
,
"Method MultiTypeBlockVector::size() returned wrong value!"
);
// Test operator-=
multiVector2
-=
multiVector
;
if
(
multiVector
.
count
()
!=
2
)
DUNE_THROW
(
Exception
,
"Method MultiTypeBlockVector::count returned wrong value!"
);
// Test multiplication with scalar
multiVector2
*=
(
double
)
0.5
;
multiVector2
*=
(
int
)
2
;
multiVector2
*=
(
float
)
0.5
;
// Test copy construction
auto
multiVector2
=
multiVector
;
// Test assignment from scalar
multiVector2
=
(
double
)
0.5
;
multiVector2
=
(
int
)
2
;
multiVector2
=
(
float
)
0.5
;
// Test a
ssignment operator
multiVector2
=
multiVector
;
// Test a
xpy
multiVector2
.
axpy
(
-
1
,
multiVector
)
;
// Test
operator+=
multi
V
ector2
+=
multiVector
;
// Test
two_norm
std
::
cout
<<
"
multi
v
ector2
has two_norm: "
<<
multiVector2
.
two_norm
()
<<
std
::
endl
;
// Test
operator-=
multi
V
ector2
-=
multiVector
;
// Test
two_norm2
std
::
cout
<<
"
multi
v
ector2
has two_norm2: "
<<
multiVector2
.
two_norm2
()
<<
std
::
endl
;
// Test multiplication with scalar
multiVector2
*=
(
double
)
0.5
;
multiVector2
*=
(
int
)
2
;
multiVector2
*=
(
float
)
0.5
;
// Test infinity_norm
std
::
cout
<<
"multivector2 has infinity_norm: "
<<
multiVector2
.
infinity_norm
()
<<
std
::
endl
;
// Test assignment from scalar
multiVector2
=
(
double
)
0.5
;
multiVector2
=
(
int
)
2
;
multiVector2
=
(
float
)
0.5
;
// Test operator*
std
::
cout
<<
multiVector
*
multiVector2
<<
std
::
endl
;
// Test axpy
multiVector2
.
axpy
(
-
1
,
multiVector
);
// Test method 'dot'
std
::
cout
<<
multiVector
.
dot
(
multiVector2
)
<<
std
::
endl
;
}
int
main
(
int
argc
,
char
**
argv
)
try
{
using
namespace
Indices
;
MultiTypeBlockVector
<
BlockVector
<
FieldVector
<
double
,
3
>
>
,
BlockVector
<
FieldVector
<
double
,
1
>
>
>
multiVector
;
multiVector
[
_0
]
=
{{
1
,
0
,
0
},
{
0
,
1
,
0
},
{
0
,
0
,
1
}};
multiVector
[
_1
]
=
{
3.14
,
42
};
// Test two_norm
std
::
cout
<<
"multivector2 has two_norm: "
<<
multiVector2
.
two_norm
()
<<
std
::
endl
;
testMultiVector
(
multiVector
);
// Test two_norm2
std
::
cout
<<
"multivector2 has two_norm2: "
<<
multiVector2
.
two_norm2
()
<<
std
::
endl
;
// create a "shallow" copy
MultiTypeBlockVector
<
BlockVector
<
FieldVector
<
double
,
3
>
>&
,
BlockVector
<
FieldVector
<
double
,
1
>
>&
>
multiVectorRef
(
multiVector
[
_0
],
multiVector
[
_1
]);
// Test infinity_norm
std
::
cout
<<
"multivector2 has infinity_norm: "
<<
multiVector2
.
infinity_norm
()
<<
std
::
endl
;
multiVectorRef
[
_0
][
0
][
0
]
=
5.0
;
// Test operator*
std
::
cout
<<
multiVector
*
multiVector2
<<
std
::
endl
;
if
(
!
FloatCmp
::
eq
(
multiVectorRef
[
_0
][
0
][
0
],
multiVector
[
_0
][
0
][
0
]))
DUNE_THROW
(
Exception
,
"Modifying an entry of the referencing vector failed!"
)
;
// Test method 'dot'
std
::
cout
<<
multiVector
.
dot
(
multiVector2
)
<<
std
::
endl
;
testMultiVector
(
multiVectorRef
);
return
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