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
76e58b6e
Commit
76e58b6e
authored
12 years ago
by
Dr. Felix Tobias Schindler
Browse files
Options
Downloads
Patches
Plain Diff
[test.function_expression] update
parent
b34b1bb2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/stuff/test/function_expression.cc
+24
-10
24 additions, 10 deletions
dune/stuff/test/function_expression.cc
with
24 additions
and
10 deletions
dune/stuff/test/function_expression.cc
+
24
−
10
View file @
76e58b6e
...
...
@@ -21,8 +21,10 @@
// #include <dune/stuff/fem/customprojection.hh>
//#endif
#include
<dune/stuff/grid/provider.hh>
#include
<dune/stuff/function/nonparametric/expression.hh>
#include
<dune/stuff/function/expression.hh>
#include
<dune/stuff/function/parametric/separable/coefficient.hh>
#if HAVE_EIGEN
#include
<Eigen/Core>
...
...
@@ -33,9 +35,9 @@ int main(int argc, char** argv)
try
{
Dune
::
MPIHelper
::
instance
(
argc
,
argv
);
typedef
Dune
::
Stuff
::
Function
::
Nonparametric
Expression
<
double
,
2
,
double
,
1
>
ScalarFunctionType
;
typename
ScalarFunctionType
::
DomainType
scalar_x
;
typename
ScalarFunctionType
::
RangeType
scalar_value
;
typedef
Dune
::
Stuff
::
Function
::
Expression
<
double
,
2
,
double
,
1
>
ScalarFunctionType
;
typename
Dune
::
FieldVector
<
double
,
2
>
scalar_x
;
typename
Dune
::
FieldVector
<
double
,
1
>
scalar_value
;
scalar_x
[
0
]
=
1.0
;
scalar_x
[
1
]
=
2.0
;
ScalarFunctionType
scalar_f_from_single_expression
(
"x"
,
"x[0] + x[1]"
);
...
...
@@ -60,7 +62,7 @@ int main(int argc, char** argv)
scalar_paramTree_single_expression
[
"order"
]
=
"5"
;
scalar_paramTree_single_expression
[
"name"
]
=
"scalar_f_from_paramtree_with_expressions"
;
ScalarFunctionType
scalar_f_from_paramtree_with_single_expression
=
ScalarFunctionType
::
createFrom
ParamTree
(
scalar_paramTree_single_expression
);
ScalarFunctionType
::
createFrom
Description
(
scalar_paramTree_single_expression
);
scalar_f_from_paramtree_with_single_expression
.
report
(
"scalar_f_from_paramtree_with_single_expression"
);
scalar_f_from_paramtree_with_single_expression
.
evaluate
(
scalar_x
,
scalar_value
);
std
::
cout
<<
"scalar_f_from_paramtree_with_single_expression("
<<
scalar_x
<<
") = "
<<
scalar_value
...
...
@@ -73,7 +75,7 @@ int main(int argc, char** argv)
scalar_paramTree_expressions
[
"name"
]
=
"scalar_f_from_paramtree_with_expressions"
;
scalar_paramTree_expressions
[
"expression"
]
=
"[x[0] + x[1]*sin(pi/2)]"
;
ScalarFunctionType
scalar_f_from_paramtree_with_expressions
=
ScalarFunctionType
::
createFrom
ParamTree
(
scalar_paramTree_expressions
);
ScalarFunctionType
::
createFrom
Description
(
scalar_paramTree_expressions
);
scalar_f_from_paramtree_with_expressions
.
report
(
"scalar_f_from_paramtree_with_expressions"
);
scalar_f_from_paramtree_with_expressions
.
evaluate
(
scalar_x
,
scalar_value
);
std
::
cout
<<
"scalar_f_from_paramtree_with_expressions("
<<
scalar_x
<<
") = "
<<
scalar_value
<<
" (should be 3)"
...
...
@@ -81,9 +83,9 @@ int main(int argc, char** argv)
std
::
cout
<<
std
::
endl
;
std
::
cout
<<
std
::
endl
;
typedef
Dune
::
Stuff
::
Function
::
Nonparametric
Expression
<
double
,
2
,
double
,
2
>
VectorFunctionType
;
typename
VectorFunctionType
::
DomainType
vector_x
;
typename
VectorFunctionType
::
RangeType
vector_value
;
typedef
Dune
::
Stuff
::
Function
::
Expression
<
double
,
2
,
double
,
2
>
VectorFunctionType
;
typename
Dune
::
FieldVector
<
double
,
2
>
vector_x
;
typename
Dune
::
FieldVector
<
double
,
2
>
vector_value
;
vector_x
[
0
]
=
1.0
;
vector_x
[
1
]
=
2.0
;
std
::
string
vector_variable
=
"x"
;
...
...
@@ -100,11 +102,23 @@ int main(int argc, char** argv)
vector_paramTree_expressions
[
"variable"
]
=
"x"
;
vector_paramTree_expressions
[
"expression"
]
=
"[x[0] + x[1]*sin(pi/2); -1*(x[0] + x[1]*sin(pi/2))]"
;
VectorFunctionType
vector_f_from_paramtree_with_expressions
=
VectorFunctionType
::
createFrom
ParamTree
(
vector_paramTree_expressions
);
VectorFunctionType
::
createFrom
Description
(
vector_paramTree_expressions
);
vector_f_from_paramtree_with_expressions
.
report
(
"vector_f_from_paramtree_with_expressions"
);
vector_f_from_paramtree_with_expressions
.
evaluate
(
vector_x
,
vector_value
);
std
::
cout
<<
"vector_f_from_paramtree_with_expressions("
<<
vector_x
<<
") = "
<<
vector_value
<<
" (should be 3 -3)"
<<
std
::
endl
;
std
::
cout
<<
std
::
endl
;
typedef
Dune
::
Stuff
::
Function
::
Parametric
::
Separable
::
Coefficient
<
double
>
CoefficientFunctionType
;
const
CoefficientFunctionType
coefficientFunction
(
"2*mu[0] + sin(mu[1])"
);
typedef
CoefficientFunctionType
::
ParamType
ParamType
;
ParamType
mu
(
2
),
coefficient_value
;
mu
[
0
]
=
1.0
;
mu
[
1
]
=
0.0
;
coefficientFunction
.
report
(
"coefficientFunction"
);
coefficientFunction
.
evaluate
(
mu
,
coefficient_value
);
std
::
cout
<<
"coefficientFunction("
<<
mu
<<
") = "
<<
coefficient_value
<<
" (should be 2)"
<<
std
::
endl
;
std
::
cout
<<
std
::
endl
;
//#if HAVE_EIGEN
// std::cout << std::endl;
...
...
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