Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
amdis
amdis-core
Commits
59f986f2
Commit
59f986f2
authored
Jul 29, 2020
by
Praetorius, Simon
Browse files
resolved merge conlicts
parents
8dcda52e
661a7e84
Changes
12
Hide whitespace changes
Inline
Side-by-side
amdis/Integrate.hpp
View file @
59f986f2
...
...
@@ -32,15 +32,6 @@ namespace AMDiS
return
gridView
.
comm
().
sum
(
result
);
}
template
<
class
GF
,
class
GV
,
class
QP
>
auto
integrateImpl
(
GF
&&
gf
,
GV
const
&
gv
,
QP
makeQuad
,
std
::
true_type
)
{
return
integrateImpl
(
FWD
(
gf
),
gv
,
makeQuad
);
}
template
<
class
GF
,
class
GV
,
class
QP
>
auto
integrateImpl
(
GF
&&
,
GV
&&
,
QP
&&
,
std
::
false_type
)
{
return
0.0
;
}
}
// end namespace Impl
...
...
@@ -58,16 +49,9 @@ namespace AMDiS
{
auto
&&
gridFct
=
makeGridFunction
(
FWD
(
expr
),
gridView
);
// test whether the gridFct model `Concepts::HasLocalFunctionOrder`
using
GF
=
TYPEOF
(
gridFct
);
static
const
bool
expr_has_order
=
Concepts
::
HasLocalFunctionOrder
<
GF
>
;
static_assert
(
expr_has_order
,
"Polynomial degree of expression can not be deduced. You need to provide an explicit value for the quadrature degree or a quadrature rule in `integrate()`."
);
using
Rules
=
Dune
::
QuadratureRules
<
typename
GridView
::
ctype
,
GridView
::
dimension
>
;
auto
makeQuad
=
[](
auto
&&
t
,
auto
&&
lf
)
{
return
Rules
::
rule
(
t
,
order
(
lf
));
};
return
Impl
::
integrateImpl
(
FWD
(
gridFct
),
gridView
,
makeQuad
,
bool_
<
expr_has_order
>
);
return
Impl
::
integrateImpl
(
FWD
(
gridFct
),
gridView
,
[](
auto
&&
t
,
auto
&&
lf
)
{
return
Rules
::
rule
(
t
,
polynomialDegree
(
lf
).
value
());
});
}
...
...
@@ -84,7 +68,8 @@ namespace AMDiS
auto
integrate
(
Expr
&&
expr
,
GridView
const
&
gridView
,
QuadratureRule
const
&
quad
)
{
auto
&&
gridFct
=
makeGridFunction
(
FWD
(
expr
),
gridView
);
return
Impl
::
integrateImpl
(
FWD
(
gridFct
),
gridView
,
[
&
](
auto
&&
,
auto
&&
)
{
return
quad
;
});
return
Impl
::
integrateImpl
(
FWD
(
gridFct
),
gridView
,
[
&
](
auto
&&
,
auto
&&
)
{
return
quad
;
});
}
...
...
amdis/common/CMakeLists.txt
View file @
59f986f2
...
...
@@ -23,6 +23,7 @@ install(FILES
Literals.hpp
Logical.hpp
Math.hpp
PolynomialDegree.hpp
Range.hpp
QuadMath.hpp
SharedPtr.hpp
...
...
amdis/common/PolynomialDegree.hpp
0 → 100644
View file @
59f986f2
#pragma once
#include
<optional>
#include
<type_traits>
#include
<dune/common/std/type_traits.hh>
namespace
AMDiS
{
namespace
Traits
{
template
<
class
T
>
using
OrderFreeFunction
=
decltype
(
order
(
std
::
declval
<
T
>
()));
template
<
class
T
>
using
OrderMemberFunction
=
decltype
(
std
::
declval
<
T
>
().
order
());
}
// end namespace Traits
/// Polynomial degree of a local function or a finite-element space or anything
/// else that defines an order function.
/**
* Return the derived or defined polynomial degree of a function `f`
* If no order is defined, return an empty optional.
**/
template
<
class
F
>
std
::
optional
<
int
>
polynomialDegree
(
F
const
&
f
)
{
if
constexpr
(
Dune
::
Std
::
is_detected_v
<
Traits
::
OrderFreeFunction
,
F
>
)
return
order
(
f
);
else
if
constexpr
(
Dune
::
Std
::
is_detected_v
<
Traits
::
OrderMemberFunction
,
F
>
)
return
f
.
order
();
else
return
std
::
nullopt
;
}
}
// end namespace AMDiS
\ No newline at end of file
amdis/functions/CMakeLists.txt
View file @
59f986f2
...
...
@@ -5,5 +5,6 @@ install(FILES
Interpolate.hpp
NodeIndices.hpp
Nodes.hpp
Order.hpp
ParallelGlobalBasis.hpp
DESTINATION
${
CMAKE_INSTALL_INCLUDEDIR
}
/amdis/functions
)
amdis/functions/Order.hpp
0 → 100644
View file @
59f986f2
#pragma once
#include
<cmath>
#include
<type_traits>
#include
<dune/typetree/nodetags.hh>
#include
<amdis/common/ConceptsBase.hpp>
#include
<amdis/common/ForEach.hpp>
namespace
AMDiS
{
template
<
class
Node
>
auto
order
(
Node
const
&
node
)
->
decltype
(
node
.
finiteElement
().
localBasis
().
order
())
{
return
node
.
finiteElement
().
localBasis
().
order
();
}
template
<
class
Node
,
REQUIRES
(
std
::
is_same_v
<
typename
Node
::
NodeTag
,
Dune
::
TypeTree
::
PowerNodeTag
>)
>
int
order
(
Node
const
&
node
)
{
return
order
(
node
.
child
(
0u
));
}
template
<
class
Node
,
REQUIRES
(
std
::
is_same_v
<
typename
Node
::
NodeTag
,
Dune
::
TypeTree
::
CompositeNodeTag
>)
>
int
order
(
Node
const
&
node
)
{
int
degree
=
0
;
Tools
::
for_range
<
0
,
Node
::
CHILDREN
>
([
&
](
auto
const
_i
)
{
degree
=
std
::
max
(
degree
,
int
(
order
(
node
.
child
(
_i
))));
});
return
degree
;
}
}
// end namespace AMDiS
amdis/gridfunctions/DiscreteLocalFunction.inc.hpp
View file @
59f986f2
...
...
@@ -3,6 +3,7 @@
#include
<amdis/Output.hpp>
#include
<amdis/common/DerivativeTraits.hpp>
#include
<amdis/common/FieldMatVec.hpp>
#include
<amdis/common/Math.hpp>
#include
<amdis/functions/NodeIndices.hpp>
#include
<amdis/typetree/FiniteElementType.hpp>
#include
<amdis/utility/LocalBasisCache.hpp>
...
...
@@ -131,7 +132,7 @@ public:
return
PartialLocalFunction
{
globalFunction_
,
type
};
}
/// \brief The
\ref order()
of the LocalFunctions
/// \brief The
polynomial degree
of the LocalFunctions
basis-functions
int
order
()
const
{
using
AMDiS
::
order
;
...
...
@@ -209,7 +210,8 @@ public:
bound_
=
false
;
}
int
order
()
const
auto
order
()
const
->
decltype
(
order
(
std
::
declval
<
SubTree
>
()))
{
using
AMDiS
::
order
;
assert
(
bound_
);
...
...
amdis/gridfunctions/FunctorGridFunction.hpp
View file @
59f986f2
...
...
@@ -152,11 +152,11 @@ namespace AMDiS
/**
* **Requirements:**
* - The functor `F` must model `Concepts::HasFunctorOrder`
* - All localFunctions `LFs...` must model `Concepts::
HasOrder
`
* - All localFunctions `LFs...` must model `Concepts::
Polynomial
`
**/
template
<
class
Sig
,
class
F
,
class
...
LFs
,
REQUIRES
(
Concepts
::
HasFunctorOrder
<
F
,
sizeof
...(
LFs
)>
&&
(
Concepts
::
HasOrder
<
LFs
>
&&
...))
>
&&
(
Concepts
::
Polynomial
<
LFs
>
&&
...))
>
int
order
(
FunctorLocalFunction
<
Sig
,
F
,
LFs
...
>
const
&
lf
)
{
return
Tools
::
apply
([
&
lf
](
auto
const
&
...
lgfs
)
{
...
...
amdis/gridfunctions/Order.hpp
View file @
59f986f2
...
...
@@ -2,7 +2,7 @@
#include
<type_traits>
#include
<amdis/common/Concepts.hpp>
#include
<amdis/common/Concepts
Base
.hpp>
namespace
AMDiS
{
...
...
@@ -14,7 +14,6 @@ namespace AMDiS
return
lf
.
order
();
}
namespace
Concepts
{
/** \addtogroup Concepts
...
...
@@ -23,15 +22,7 @@ namespace AMDiS
namespace
Definition
{
struct
HasLocalFunctionOrder
{
template
<
class
F
>
auto
require
(
F
&&
f
)
->
decltype
(
order
(
localFunction
(
f
))
);
};
struct
HasOrder
struct
Polynomial
{
template
<
class
F
>
auto
require
(
F
&&
f
)
->
decltype
(
...
...
@@ -41,24 +32,14 @@ namespace AMDiS
}
// end namespace Definition
/// \brief GridFunction GF has free function `order(localFunction(F))`
template
<
class
GF
>
constexpr
bool
HasLocalFunctionOrder
=
models
<
Definition
::
HasLocalFunctionOrder
(
GF
)
>
;
template
<
class
GF
>
using
HasLocalFunctionOrder_t
=
models_t
<
Definition
::
HasLocalFunctionOrder
(
GF
)
>
;
/// \brief LocalFuncion LF has free function `order(F)`
template
<
class
LF
>
constexpr
bool
HasOrder
=
models
<
Definition
::
HasOrder
(
LF
)
>
;
constexpr
bool
Polynomial
=
models
<
Definition
::
Polynomial
(
LF
)
>
;
template
<
class
LF
>
using
HasOrder
_t
=
models_t
<
Definition
::
HasOrder
(
LF
)
>
;
using
Polynomial
_t
=
models_t
<
Definition
::
Polynomial
(
LF
)
>
;
/** @} **/
}
// end namespace Concepts
}
// end namespace AMDiS
amdis/localoperators/ConvectionDiffusionOperator.hpp
View file @
59f986f2
...
...
@@ -176,16 +176,10 @@ namespace AMDiS
private:
template
<
class
LF
>
using
HasLocalFunctionOrder
=
decltype
(
order
(
std
::
declval
<
LF
>
())
);
template
<
class
LocalFct
>
int
coeffOrder
(
LocalFct
const
&
localFct
)
{
if
constexpr
(
Dune
::
Std
::
is_detected
<
HasLocalFunctionOrder
,
LocalFct
>::
value
)
return
order
(
localFct
);
else
return
0
;
return
polynomialDegree
(
localFct
).
value_or
(
0
);
}
template
<
class
T
,
int
N
>
...
...
amdis/typetree/FiniteElementType.hpp
View file @
59f986f2
...
...
@@ -46,11 +46,6 @@ namespace AMDiS
struct
FiniteElementTypeImpl
<
Node
,
Dune
::
TypeTree
::
LeafNodeTag
>
{
using
type
=
typename
Node
::
FiniteElement
;
static
int
order
(
Node
const
&
node
)
{
return
node
.
finiteElement
().
localBasis
().
order
();
}
};
// Power node
...
...
amdis/utility/QuadratureFactory.hpp
View file @
59f986f2
...
...
@@ -5,6 +5,7 @@
#include
<dune/geometry/quadraturerules.hh>
#include
<dune/geometry/type.hh>
#include
<amdis/common/PolynomialDegree.hpp>
#include
<amdis/gridfunctions/Order.hpp>
namespace
AMDiS
...
...
@@ -39,27 +40,16 @@ namespace AMDiS
};
template
<
class
LF
>
using
HasLocalFunctionOrder
=
decltype
(
order
(
std
::
declval
<
LF
>
())
);
/// \brief Factory for quadrature rule, that calculates the coefficient order from
/// a localFunction passed to the bind method.
template
<
class
ctype
,
int
dim
,
class
LocalFunction
>
class
QuadFactoryFromLocalFunction
:
public
QuadratureFactory
<
ctype
,
dim
,
LocalFunction
>
{
using
Concept
=
Dune
::
Std
::
is_detected
<
HasLocalFunctionOrder
,
LocalFunction
>
;
static_assert
(
Concept
::
value
,
"Polynomial order of GridFunction can not be extracted. Provide an explicit order parameter instead."
);
public:
void
bind
(
LocalFunction
const
&
localFct
)
final
{
if
constexpr
(
Concept
::
value
)
order_
=
AMDiS
::
order
(
localFct
);
else
order_
=
-
1
;
order_
=
polynomialDegree
(
localFct
).
value
();
}
int
order
()
const
final
{
return
order_
;
}
...
...
test/FiniteElementTypeTest.cpp
View file @
59f986f2
...
...
@@ -4,6 +4,8 @@
#include
<dune/functions/functionspacebases/powerbasis.hh>
#include
<dune/functions/functionspacebases/lagrangebasis.hh>
#include
<amdis/common/PolynomialDegree.hpp>
#include
<amdis/functions/Order.hpp>
#include
<amdis/typetree/FiniteElementType.hpp>
#include
"Tests.hpp"
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment