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
2da26120
Commit
2da26120
authored
6 years ago
by
Tobias Leibner
Browse files
Options
Downloads
Patches
Plain Diff
[constant] add tests, fix ambiguous constructor
parent
12be9234
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitsuper
+4
-4
4 additions, 4 deletions
.gitsuper
dune/xt/functions/constant.hh
+4
-14
4 additions, 14 deletions
dune/xt/functions/constant.hh
dune/xt/functions/test/constant.tpl
+112
-7
112 additions, 7 deletions
dune/xt/functions/test/constant.tpl
with
120 additions
and
25 deletions
.gitsuper
+
4
−
4
View file @
2da26120
...
@@ -15,9 +15,9 @@ status = 1a3bcab04b011a5d6e44f9983cae6ff89fa695e8 bin (heads/master)
...
@@ -15,9 +15,9 @@ status = 1a3bcab04b011a5d6e44f9983cae6ff89fa695e8 bin (heads/master)
07f9700459c616186737a9a34277f2edee76f475 dune-uggrid (v2.6.0-1-g07f97004)
07f9700459c616186737a9a34277f2edee76f475 dune-uggrid (v2.6.0-1-g07f97004)
+ef03286d66302d2af5a38b8047da47ee16214006 dune-xt-common (heads/master)
+ef03286d66302d2af5a38b8047da47ee16214006 dune-xt-common (heads/master)
+376e88d14fd23ea12c3e23befc3fc967d4833751 dune-xt-data (heads/master)
+376e88d14fd23ea12c3e23befc3fc967d4833751 dune-xt-data (heads/master)
+
45c5f0f9950010560c78266012a2208a812c2d0c
dune-xt-functions (heads/dailywork_tleibner)
+
1d740654e31f32cd19cfa5610bf4d6d4743189fb
dune-xt-functions (heads/dailywork_tleibner)
+654c823f698418b67a696618342b54324f2cc151 dune-xt-grid (heads/master)
+654c823f698418b67a696618342b54324f2cc151 dune-xt-grid (heads/master)
+
40a051d255e05a84191726b515d43779f2a89b1b
dune-xt-la (heads/master)
+
a42e4d9449f4a20c692805fce018ec23a19680dc
dune-xt-la (heads/master)
09d0378f616b94d68bcdd9fc6114813181849ec0 scripts (heads/master)
09d0378f616b94d68bcdd9fc6114813181849ec0 scripts (heads/master)
commit = fbf04258130187925b17e8c0482d280e9ae111e2
commit = fbf04258130187925b17e8c0482d280e9ae111e2
...
@@ -99,7 +99,7 @@ commit = 376e88d14fd23ea12c3e23befc3fc967d4833751
...
@@ -99,7 +99,7 @@ commit = 376e88d14fd23ea12c3e23befc3fc967d4833751
[submodule.dune-xt-functions]
[submodule.dune-xt-functions]
remote = git@github.com:dune-community/dune-xt-functions.git
remote = git@github.com:dune-community/dune-xt-functions.git
status = cc1bbdac283f4b9323c64345030f1b8f634b88d5 .vcsetup (heads/master)
status = cc1bbdac283f4b9323c64345030f1b8f634b88d5 .vcsetup (heads/master)
commit =
45c5f0f9950010560c78266012a2208a812c2d0c
commit =
1d740654e31f32cd19cfa5610bf4d6d4743189fb
[submodule.dune-xt-grid]
[submodule.dune-xt-grid]
remote = git@github.com:dune-community/dune-xt-grid.git
remote = git@github.com:dune-community/dune-xt-grid.git
...
@@ -109,7 +109,7 @@ commit = 654c823f698418b67a696618342b54324f2cc151
...
@@ -109,7 +109,7 @@ commit = 654c823f698418b67a696618342b54324f2cc151
[submodule.dune-xt-la]
[submodule.dune-xt-la]
remote = git@github.com:dune-community/dune-xt-la.git
remote = git@github.com:dune-community/dune-xt-la.git
status = cc1bbdac283f4b9323c64345030f1b8f634b88d5 .vcsetup (heads/master)
status = cc1bbdac283f4b9323c64345030f1b8f634b88d5 .vcsetup (heads/master)
commit =
40a051d255e05a84191726b515d43779f2a89b1b
commit =
a42e4d9449f4a20c692805fce018ec23a19680dc
[submodule.scripts]
[submodule.scripts]
remote = https://github.com/wwu-numerik/scripts.git
remote = https://github.com/wwu-numerik/scripts.git
...
...
This diff is collapsed.
Click to expand it.
dune/xt/functions/constant.hh
+
4
−
14
View file @
2da26120
...
@@ -51,12 +51,7 @@ public:
...
@@ -51,12 +51,7 @@ public:
return
config
;
return
config
;
}
// ... defaults(...)
}
// ... defaults(...)
explicit
ConstantFunction
(
const
RangeReturnType
&
constant
,
const
std
::
string
name_in
=
static_id
())
ConstantFunction
(
const
RangeReturnType
constant
,
const
std
::
string
name_in
=
static_id
())
:
constant_
(
constant
)
,
name_
(
name_in
)
{}
explicit
ConstantFunction
(
const
RangeField
&
constant
,
const
std
::
string
name_in
=
static_id
())
:
constant_
(
constant
)
:
constant_
(
constant
)
,
name_
(
name_in
)
,
name_
(
name_in
)
{}
{}
...
@@ -100,13 +95,8 @@ class ConstantGridFunction : public GridFunctionInterface<Element, rangeDim, ran
...
@@ -100,13 +95,8 @@ class ConstantGridFunction : public GridFunctionInterface<Element, rangeDim, ran
public:
public:
using
typename
BaseType
::
LocalFunctionType
;
using
typename
BaseType
::
LocalFunctionType
;
explicit
ConstantGridFunction
(
const
typename
LocalFunctionType
::
RangeType
&
constant
,
ConstantGridFunction
(
const
typename
LocalFunctionType
::
RangeReturnType
constant
,
const
std
::
string
name_in
=
static_id
())
const
std
::
string
name_in
=
static_id
())
:
constant_function_
(
constant
,
name_in
)
,
constant_grid_function_
(
constant_function_
)
{}
explicit
ConstantGridFunction
(
const
RangeField
&
constant
,
const
std
::
string
name_in
=
static_id
())
:
constant_function_
(
constant
,
name_in
)
:
constant_function_
(
constant
,
name_in
)
,
constant_grid_function_
(
constant_function_
)
,
constant_grid_function_
(
constant_function_
)
{}
{}
...
@@ -121,7 +111,7 @@ public:
...
@@ -121,7 +111,7 @@ public:
return
constant_grid_function_
.
local_function
();
return
constant_grid_function_
.
local_function
();
}
}
virtual
std
::
string
name
()
const
virtual
std
::
string
name
()
const
override
final
{
{
return
constant_function_
.
name
();
return
constant_function_
.
name
();
}
}
...
...
This diff is collapsed.
Click to expand it.
dune/xt/functions/test/constant.tpl
+
112
−
7
View file @
2da26120
...
@@ -35,7 +35,12 @@ struct ConstantFunction_from_{{GRIDNAME}}_to_{{r}}_times_{{rC}} : public ::testi
...
@@ -35,7 +35,12 @@ struct ConstantFunction_from_{{GRIDNAME}}_to_{{r}}_times_{{rC}} : public ::testi
TEST_F(ConstantFunction_from_{
{
GRIDNAME
}
}_to_{
{
r
}
}_times_{
{
rC
}
}, is_constructible)
TEST_F(ConstantFunction_from_{
{
GRIDNAME
}
}_to_{
{
r
}
}_times_{
{
rC
}
}, is_constructible)
{
{
FunctionType function(0.);
// constructor taking FieldType
FunctionType function1(0.);
FunctionType function2(0., "name");
// constructor taking RangeType
FunctionType function3(RangeReturnType(0.));
FunctionType function4(RangeReturnType(0.), "name");
}
}
TEST_F(ConstantFunction_from_{
{
GRIDNAME
}
}_to_{
{
r
}
}_times_{
{
rC
}
}, has_default_config)
TEST_F(ConstantFunction_from_{
{
GRIDNAME
}
}_to_{
{
r
}
}_times_{
{
rC
}
}, has_default_config)
...
@@ -44,12 +49,6 @@ TEST_F(ConstantFunction_from_{{GRIDNAME}}_to_{{r}}_times_{{rC}}, has_default_con
...
@@ -44,12 +49,6 @@ TEST_F(ConstantFunction_from_{{GRIDNAME}}_to_{{r}}_times_{{rC}}, has_default_con
EXPECT_EQ(cfg.get
<std::string>
("name"), FunctionType::static_id());
EXPECT_EQ(cfg.get
<std::string>
("name"), FunctionType::static_id());
}
}
TEST_F(ConstantFunction_from_{
{
GRIDNAME
}
}_to_{
{
r
}
}_times_{
{
rC
}
}, is_creatable)
{
//auto default_function = FunctionType::create();
//EXPECT_EQ(default_function->order(), 0);
}
TEST_F(ConstantFunction_from_{
{
GRIDNAME
}
}_to_{
{
r
}
}_times_{
{
rC
}
}, is_visualizable)
TEST_F(ConstantFunction_from_{
{
GRIDNAME
}
}_to_{
{
r
}
}_times_{
{
rC
}
}, is_visualizable)
{
{
const auto leaf_view = grid_.leaf_view();
const auto leaf_view = grid_.leaf_view();
...
@@ -165,4 +164,110 @@ TEST_F(ConstantFunction_from_{{GRIDNAME}}_to_{{r}}_times_{{rC}}, local_jacobian)
...
@@ -165,4 +164,110 @@ TEST_F(ConstantFunction_from_{{GRIDNAME}}_to_{{r}}_times_{{rC}}, local_jacobian)
}
}
struct ConstantGridFunction_from_{
{
GRIDNAME
}
}_to_{
{
r
}
}_times_{
{
rC
}
} : public ::testing::Test
{
using GridType = {
{
GRID
}
};
using ElementType = typename GridType::template Codim
<
0
>
::Entity;
static const constexpr size_t d = GridType::dimension;
static const size_t r = {
{
r
}
};
static const size_t rC = {
{
rC
}
};
using FunctionType = Functions::ConstantGridFunction
<ElementType
,
r
,
rC
>
;
using RangeReturnType = typename FunctionType::LocalFunctionType::RangeReturnType;
using DomainType = typename FunctionType::LocalFunctionType::DomainType;
using DerivativeRangeReturnType = typename FunctionType::LocalFunctionType::DerivativeRangeReturnType;
ConstantGridFunction_from_{
{
GRIDNAME
}
}_to_{
{
r
}
}_times_{
{
rC
}
}()
: grid_(Grid::make_cube_grid
<GridType>
(-1., 1., 4))
{
}
const Grid::GridProvider
<GridType>
grid_;
};
TEST_F(ConstantGridFunction_from_{
{
GRIDNAME
}
}_to_{
{
r
}
}_times_{
{
rC
}
}, is_constructible)
{
// passing FieldType
FunctionType function1(0.);
FunctionType function2(0., "name");
// passing RangeType
FunctionType function3(RangeReturnType(0.));
FunctionType function4(RangeReturnType(0.), "name");
}
TEST_F(ConstantGridFunction_from_{
{
GRIDNAME
}
}_to_{
{
r
}
}_times_{
{
rC
}
}, is_visualizable)
{
const auto leaf_view = grid_.leaf_view();
FunctionType function(1.);
function.visualize(leaf_view, "test__ConstantFunction_from_{
{
GRIDNAME
}
}_to_{
{
r
}
}_times_{
{
rC
}
}__is_visualizable");
}
TEST_F(ConstantGridFunction_from_{
{
GRIDNAME
}
}_to_{
{
r
}
}_times_{
{
rC
}
}, is_bindable)
{
FunctionType function(1.);
auto local_f = function.local_function();
const auto leaf_view = grid_.leaf_view();
for (auto
&&
element : Dune::elements(leaf_view)) {
local_f->bind(element);
}
}
TEST_F(ConstantGridFunction_from_{
{
GRIDNAME
}
}_to_{
{
r
}
}_times_{
{
rC
}
}, local_order)
{
const int expected_order = 0;
for (auto vv : {-10., 3., 17., 41.}) {
const RangeReturnType value(vv);
FunctionType function(value);
auto local_f = function.local_function();
const auto leaf_view = grid_.leaf_view();
for (auto
&&
element : Dune::elements(leaf_view)) {
local_f->bind(element);
const auto actual_order = local_f->order();
EXPECT_EQ(expected_order, actual_order);
}
}
}
TEST_F(ConstantGridFunction_from_{
{
GRIDNAME
}
}_to_{
{
r
}
}_times_{
{
rC
}
}, local_evaluate)
{
for (auto value : {-10., 3., 17., 41.}) {
const RangeReturnType expected_value(value);
FunctionType function(expected_value);
auto local_f = function.local_function();
const auto leaf_view = grid_.leaf_view();
for (auto
&&
element : Dune::elements(leaf_view)) {
local_f->bind(element);
for (const auto
&
quadrature_point : Dune::QuadratureRules
<double
,
d
>
::rule(element.type(), 3)) {
const auto local_x = quadrature_point.position();
const auto actual_value = local_f->evaluate(local_x);
EXPECT_EQ(expected_value, actual_value);
}
}
}
}
TEST_F(ConstantGridFunction_from_{
{
GRIDNAME
}
}_to_{
{
r
}
}_times_{
{
rC
}
}, local_jacobian)
{
for (auto vv : {-10., 3., 17., 41.}) {
RangeReturnType value(vv);
DerivativeRangeReturnType expected_jacobian;
//expected_jacobian *= 0;
FunctionType function(value);
auto local_f = function.local_function();
const auto leaf_view = grid_.leaf_view();
for (auto
&&
element : Dune::elements(leaf_view)) {
local_f->bind(element);
for (const auto
&
quadrature_point : Dune::QuadratureRules
<double
,
d
>
::rule(element.type(), 3)) {
const auto local_x = quadrature_point.position();
const auto actual_jacobian = local_f->jacobian(local_x);
EXPECT_EQ(expected_jacobian, actual_jacobian);
}
}
}
}
{% endfor %}
{% endfor %}
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