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
144b36ba
Commit
144b36ba
authored
6 years ago
by
Praetorius, Simon
Browse files
Options
Downloads
Patches
Plain Diff
added examples to integrate methods
parent
c27b2e73
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/amdis/gridfunctions/Integrate.hpp
+29
-7
29 additions, 7 deletions
src/amdis/gridfunctions/Integrate.hpp
with
29 additions
and
7 deletions
src/amdis/gridfunctions/Integrate.hpp
+
29
−
7
View file @
144b36ba
...
...
@@ -8,12 +8,13 @@ namespace AMDiS
{
namespace
Impl
{
template
<
class
G
ridFct
,
class
GridView
,
class
QuadProvider
>
auto
integrateImpl
(
G
ridFct
&&
gridFct
,
GridView
const
&
gridView
,
QuadProvider
makeQuad
)
template
<
class
G
F
,
class
GridView
,
class
QuadProvider
>
auto
integrateImpl
(
G
F
&&
gf
,
GridView
const
&
gridView
,
QuadProvider
makeQuad
)
{
auto
localFct
=
localFunction
(
gridFct
);
auto
localFct
=
localFunction
(
std
::
forward
<
GF
>
(
gf
)
);
using
Range
=
typename
std
::
decay_t
<
GridFct
>::
Range
;
using
GridFct
=
std
::
decay_t
<
GF
>
;
using
Range
=
typename
GridFct
::
Range
;
Range
result
(
0
);
for
(
auto
const
&
element
:
elements
(
gridView
))
{
...
...
@@ -33,7 +34,15 @@ namespace AMDiS
}
// end namespace Impl
/// Integrate expression with quadrature rule determined by polynomial order of expression
/// \brief Integrate expression with quadrature rule determined by polynomial order of expression
/**
* **Example:**
* ```
* double i1 = integrate(prob.solution(0), prob.gridView());
* double i2 = integrate(X(0) + X(1), prob.gridView());
* double i3 = integrate([](auto const& x) { return x[0] + x[1]; }, prob.gridView()); // ERROR
* ```
**/
template
<
class
Expr
,
class
GridView
>
auto
integrate
(
Expr
&&
expr
,
GridView
const
&
gridView
)
{
...
...
@@ -47,17 +56,24 @@ namespace AMDiS
#if AMDIS_HAS_CXX_CONSTEXPR_IF
if
constexpr
(
expr_has_order
)
return
Impl
::
integrateImpl
(
gridFct
,
gridView
,
makeQuad
);
return
Impl
::
integrateImpl
(
std
::
forward
<
decltype
(
gridFct
)
>
(
gridFct
)
,
gridView
,
makeQuad
);
else
return
0.0
;
#else
return
Dune
::
Hybrid
::
ifElse
(
bool_
<
expr_has_order
>
,
[
&
](
auto
)
{
return
Impl
::
integrateImpl
(
gridFct
,
gridView
,
makeQuad
);
},
[
&
](
auto
)
{
return
Impl
::
integrateImpl
(
std
::
forward
<
decltype
(
gridFct
)
>
(
gridFct
)
,
gridView
,
makeQuad
);
},
[
](
auto
)
{
return
0.0
;
});
#endif
}
/// Integrate expression with quadrature rule provided
/**
* **Example:**
* ```
* auto quad = Dune::QuadratureRules<double,DIM>::rule(Dune::GeometryTypes::triangle, 1);
* double i4 = integrate([](auto const& x) { return x[0]; }, prob.gridView(), quad); // OK
* ```
**/
template
<
class
Expr
,
class
GridView
,
class
QuadratureRule
=
Dune
::
QuadratureRule
<
typename
GridView
::
ctype
,
GridView
::
dimension
>
>
auto
integrate
(
Expr
&&
expr
,
GridView
const
&
gridView
,
QuadratureRule
const
&
quad
)
...
...
@@ -68,6 +84,12 @@ namespace AMDiS
}
/// Integrate expression with quadrature rule determined by provided polynomial `degree`
/**
* **Example:**
* ```
* double i5 = integrate([](auto const& x) { return x[0]; }, prob.gridView(), 1); // OK
* ```
**/
template
<
class
Expr
,
class
GridView
>
auto
integrate
(
Expr
&&
expr
,
GridView
const
&
gridView
,
int
degree
,
Dune
::
QuadratureType
::
Enum
qt
=
Dune
::
QuadratureType
::
GaussLegendre
)
...
...
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