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
debd7f32
Commit
debd7f32
authored
6 years ago
by
Tobias Leibner
Committed by
Tobias Leibner
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[test.affine] actually test something
parent
ecf3bc96
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dune/xt/functions/test/affine.cc
+36
-5
36 additions, 5 deletions
dune/xt/functions/test/affine.cc
dune/xt/functions/test/affine_flux.cc
+35
-6
35 additions, 6 deletions
dune/xt/functions/test/affine_flux.cc
with
71 additions
and
11 deletions
dune/xt/functions/test/affine.cc
+
36
−
5
View file @
debd7f32
...
...
@@ -14,10 +14,15 @@
#include
<memory>
#include
<dune/xt/common/exceptions.hh>
#include
<dune/xt/grid/grids.hh>
#include
<dune/xt/grid/gridprovider/cube.hh>
#include
<dune/xt/functions/affine.hh>
#if HAVE_DUNE_XT_LA
#include
<dune/xt/la/container/eye-matrix.hh>
#endif // HAVE_DUNE_XT_LA
#include
<dune/xt/functions/affine.hh>
#include
<dune/xt/functions/test/functions.hh>
using
namespace
Dune
;
...
...
@@ -25,18 +30,44 @@ using namespace Dune::XT;
using
namespace
Dune
::
XT
::
Functions
;
#if HAVE_DUNE_XT_LA
struct
Function
s
Test
:
public
FunctionTest
<
TESTFUNCTIONTYPE
>
struct
Affine
FunctionTest
:
public
FunctionTest
<
TESTFUNCTIONTYPE
>
{
void
check
()
{
using
MatrixType
=
typename
TESTFUNCTIONTYPE
::
FieldMatrixType
;
static
constexpr
size_t
dimDomain
=
TESTFUNCTIONTYPE
::
dimDomain
;
static
constexpr
size_t
dimRange
=
TESTFUNCTIONTYPE
::
dimRange
;
static
constexpr
size_t
dimRangeCols
=
TESTFUNCTIONTYPE
::
dimRangeCols
;
auto
grid
=
XT
::
Grid
::
make_cube_grid
<
GRIDTYPE
>
();
const
auto
testfunction
=
TESTFUNCTIONTYPE
::
create
();
auto
unit_matrix
=
XT
::
LA
::
eye_matrix
<
MatrixType
>
(
dimRange
,
dimDomain
);
auto
matrices
=
FieldVector
<
MatrixType
,
dimRangeCols
>
(
unit_matrix
);
for
(
size_t
rC
=
0
;
rC
<
dimRangeCols
;
++
rC
)
matrices
[
rC
]
*=
rC
+
1
;
const
auto
testfunction
=
TESTFUNCTIONTYPE
(
matrices
);
for
(
auto
&&
entity
:
elements
(
grid
.
leaf_view
()))
{
auto
xx_global
=
entity
.
geometry
().
center
();
auto
xx_local
=
entity
.
geometry
().
local
(
xx_global
);
TESTFUNCTIONTYPE
::
JacobianRangeType
jacobian
;
testfunction
->
local_function
(
entity
)
->
jacobian
(
xx_local
);
FieldVector
<
MatrixType
,
dimRangeCols
>
jacobian
;
auto
ret
=
testfunction
.
local_function
(
entity
)
->
evaluate
(
xx_local
);
for
(
size_t
ii
=
0
;
ii
<
std
::
min
(
dimRange
,
dimDomain
);
++
ii
)
{
FieldVector
<
double
,
dimRangeCols
>
ret_row
(
ret
[
ii
]);
for
(
size_t
rC
=
0
;
rC
<
dimRangeCols
;
++
rC
)
EXPECT_DOUBLE_EQ
(
xx_global
[
ii
]
*
(
rC
+
1
),
ret_row
[
rC
]);
}
for
(
size_t
ii
=
std
::
min
(
dimRange
,
dimDomain
)
+
1
;
ii
<
dimRange
;
++
ii
)
{
FieldVector
<
double
,
dimRangeCols
>
ret_row
(
ret
[
ii
]);
for
(
size_t
rC
=
0
;
rC
<
dimRangeCols
;
++
rC
)
EXPECT_DOUBLE_EQ
(
0.
,
ret_row
[
rC
]);
}
testfunction
.
local_function
(
entity
)
->
jacobian
(
xx_local
,
jacobian
);
for
(
size_t
rC
=
0
;
rC
<
dimRangeCols
;
++
rC
)
ASSERT_TRUE
(
XT
::
Common
::
FloatCmp
::
eq
(
jacobian
[
rC
],
matrices
[
rC
]));
}
}
};
TEST_F
(
AffineFunctionTest
,
creation_and_evalution
)
{
this
->
check
();
}
#endif // HAVE_DUNE_XT_LA
This diff is collapsed.
Click to expand it.
dune/xt/functions/test/affine_flux.cc
+
35
−
6
View file @
debd7f32
...
...
@@ -14,10 +14,15 @@
#include
<memory>
#include
<dune/xt/common/exceptions.hh>
#include
<dune/xt/grid/grids.hh>
#include
<dune/xt/grid/gridprovider/cube.hh>
#include
<dune/xt/functions/affine.hh>
#if HAVE_DUNE_XT_LA
#include
<dune/xt/la/container/eye-matrix.hh>
#endif // HAVE_DUNE_XT_LA
#include
<dune/xt/functions/affine.hh>
#include
<dune/xt/functions/test/functions.hh>
using
namespace
Dune
;
...
...
@@ -25,19 +30,43 @@ using namespace Dune::XT;
using
namespace
Dune
::
XT
::
Functions
;
#if HAVE_DUNE_XT_LA
struct
Function
s
Test
:
public
FunctionTest
<
TESTFUNCTIONTYPE
>
struct
AffineFlux
FunctionTest
:
public
FunctionTest
<
TESTFUNCTIONTYPE
>
{
void
check
()
{
using
MatrixType
=
typename
TESTFUNCTIONTYPE
::
FieldMatrixType
;
static
constexpr
size_t
dimRange
=
TESTFUNCTIONTYPE
::
dimRange
;
static
constexpr
size_t
dimRangeCols
=
TESTFUNCTIONTYPE
::
dimRangeCols
;
static
constexpr
size_t
stateDimRange
=
TESTFUNCTIONTYPE
::
StateType
::
dimRange
;
auto
grid
=
XT
::
Grid
::
make_cube_grid
<
GRIDTYPE
>
();
const
auto
testfunction
=
TESTFUNCTIONTYPE
::
create
();
auto
unit_matrix
=
XT
::
LA
::
eye_matrix
<
MatrixType
>
(
dimRange
,
stateDimRange
);
auto
matrices
=
FieldVector
<
MatrixType
,
dimRangeCols
>
(
unit_matrix
);
for
(
size_t
rC
=
0
;
rC
<
dimRangeCols
;
++
rC
)
matrices
[
rC
]
*=
rC
+
1
;
const
auto
testfunction
=
TESTFUNCTIONTYPE
(
matrices
);
for
(
auto
&&
entity
:
elements
(
grid
.
leaf_view
()))
{
auto
xx_global
=
entity
.
geometry
().
center
();
auto
xx_local
=
entity
.
geometry
().
local
(
xx_global
);
TESTFUNCTIONTYPE
::
PartialURangeType
partial_u
;
TESTFUNCTIONTYPE
::
StateRangeType
u
(
0.
);
testfunction
->
local_function
(
entity
)
->
partial_u
(
xx_local
,
u
);
FieldVector
<
MatrixType
,
dimRangeCols
>
partial_u
;
TESTFUNCTIONTYPE
::
StateRangeType
u
(
1.
);
auto
ret
=
testfunction
.
local_function
(
entity
)
->
evaluate
(
xx_local
,
u
);
for
(
size_t
ii
=
0
;
ii
<
std
::
min
(
dimRange
,
stateDimRange
);
++
ii
)
{
FieldVector
<
double
,
dimRangeCols
>
ret_row
(
ret
[
ii
]);
for
(
size_t
rC
=
0
;
rC
<
dimRangeCols
;
++
rC
)
EXPECT_DOUBLE_EQ
((
rC
+
1
),
ret_row
[
rC
]);
}
for
(
size_t
ii
=
std
::
min
(
dimRange
,
stateDimRange
)
+
1
;
ii
<
dimRange
;
++
ii
)
{
FieldVector
<
double
,
dimRangeCols
>
ret_row
(
ret
[
ii
]);
for
(
size_t
rC
=
0
;
rC
<
dimRangeCols
;
++
rC
)
EXPECT_DOUBLE_EQ
(
0.
,
ret_row
[
rC
]);
}
}
}
};
TEST_F
(
AffineFluxFunctionTest
,
creation_and_evalution
)
{
this
->
check
();
}
#endif // HAVE_DUNE_XT_LA
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