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
90c3d73b
Commit
90c3d73b
authored
Dec 28, 2017
by
Praetorius, Simon
Browse files
improved error messages, added quadrature degree parameter
parent
e4baaf0f
Changes
38
Show whitespace changes
Inline
Side-by-side
dune/amdis/GridFunctionOperator.hpp
View file @
90c3d73b
...
...
@@ -3,7 +3,8 @@
#include
<cassert>
#include
<type_traits>
#include
<dune/amdis/gridfunctions/GridFunctionConcepts.hpp>
#include
<dune/amdis/GridFunctions.hpp>
#include
<dune/amdis/common/Utility.hpp>
#include
<dune/amdis/utility/GetDegree.hpp>
namespace
AMDiS
...
...
@@ -24,10 +25,11 @@ namespace AMDiS
* \ref ExpressionBase, and stores a copy. Additionally, it gets the
* differentiation order, to calculate the quadrature degree in \ref getDegree.
**/
GridFunctionOperatorBase
(
GridFunction
const
&
gridFct
,
int
order
)
GridFunctionOperatorBase
(
GridFunction
const
&
gridFct
,
int
order
,
int
degree
=
-
1
)
:
gridFct_
(
gridFct
)
,
localFct_
(
localFunction
(
gridFct_
))
,
order_
(
order
)
,
degree_
(
degree
)
{}
/// \brief Binds operator to `element` and `geometry`.
...
...
@@ -75,7 +77,7 @@ namespace AMDiS
assert
(
bound_
);
int
psiDegree
=
getPolynomialDegree
(
node
);
int
coeffDegree
=
order
(
localFct_
);
int
coeffDegree
=
getGridFctDegree
(
localFct_
);
int
degree
=
psiDegree
+
coeffDegree
;
if
(
isSimplex_
)
...
...
@@ -100,7 +102,7 @@ namespace AMDiS
int
psiDegree
=
getPolynomialDegree
(
rowNode
);
int
phiDegree
=
getPolynomialDegree
(
colNode
);
int
coeffDegree
=
order
(
localFct_
);
int
coeffDegree
=
getGridFctDegree
(
localFct_
);
int
degree
=
psiDegree
+
phiDegree
+
coeffDegree
;
if
(
isSimplex_
)
...
...
@@ -111,11 +113,27 @@ namespace AMDiS
return
degree
;
}
protected:
template
<
class
LocalFct
,
REQUIRES
(
Concepts
::
HasOrder
<
LocalFct
>)
>
int
getGridFctDegree
(
LocalFct
const
&
localFct
)
const
{
return
degree_
>=
0
?
degree_
:
order
(
localFct_
);
}
template
<
class
LocalFct
,
REQUIRES
(
not
Concepts
::
HasOrder
<
LocalFct
>)
>
int
getGridFctDegree
(
LocalFct
const
&
localFct
)
const
{
return
degree_
;
}
private:
GridFunction
gridFct_
;
LocalFunction
localFct_
;
int
order_
;
//< the derivative order of this operator
int
degree_
;
//< the polynomial order of the gridFunction
bool
isSimplex_
=
false
;
//< the bound element is a simplex
bool
isAffine_
=
false
;
//< the bound geometry is affine
...
...
@@ -166,50 +184,84 @@ namespace AMDiS
}
};
namespace
Concepts
{
namespace
Definition
{
struct
HasGridFunctionOrder
{
template
<
class
F
,
class
GridView
>
auto
requires_
(
F
&&
f
,
GridView
const
&
gridView
)
->
decltype
(
order
(
localFunction
(
makeGridFunction
(
f
,
gridView
)))
);
};
}
template
<
class
F
,
class
GridView
=
Dune
::
YaspGrid
<
2
>
::
LeafGridView
>
constexpr
bool
HasGridFunctionOrder
=
models
<
Definition
::
HasGridFunctionOrder
(
F
,
GridView
)
>
;
}
// end namespace Concepts
template
<
class
Tag
,
class
Expr
>
struct
ExpressionPreOperator
{
Tag
tag
;
Expr
expr
;
int
order
=
-
1
;
};
/// Store tag and expression in struct
template
<
class
Tag
,
class
Expr
>
auto
makeOperator
(
Tag
t
,
Expr
const
&
expr
)
{
using
RawExpr
=
Underlying_t
<
Expr
>
;
static_assert
(
Concepts
::
HasGridFunctionOrder
<
RawExpr
>
,
"Polynomial degree of expression can not be deduced. You need to provide an explicit value for polynomial order in `makeOperator()`."
);
return
ExpressionPreOperator
<
Tag
,
Expr
>
{
t
,
expr
};
}
template
<
class
Tag
,
class
Expr
>
auto
makeOperator
(
Tag
t
,
Expr
const
&
expr
,
int
order
)
{
return
ExpressionPreOperator
<
Tag
,
Expr
>
{
t
,
expr
,
order
};
}
/// Generate an \ref GridFunctionOperator from a PreOperator (tag, expr).
/// @{
template
<
class
Tag
,
class
Expr
,
class
GridView
>
auto
makeGridOperator
(
ExpressionPreOperator
<
Tag
,
Expr
>
const
&
op
,
GridView
const
&
gridView
)
{
auto
gridFct
=
makeGridFunction
(
op
.
expr
,
gridView
,
Dune
::
PriorityTag
<
42
>
{}
);
return
GridFunctionOperator
<
Tag
,
decltype
(
gridFct
)
>
{
op
.
tag
,
gridFct
};
auto
gridFct
=
makeGridFunction
(
op
.
expr
,
gridView
);
return
GridFunctionOperator
<
Tag
,
decltype
(
gridFct
)
>
{
op
.
tag
,
gridFct
,
op
.
order
};
}
template
<
class
Tag
,
class
Expr
,
class
GridView
>
auto
makeGridOperator
(
std
::
reference_wrapper
<
ExpressionPreOperator
<
Tag
,
Expr
>>
op
,
GridView
const
&
gridView
)
{
ExpressionPreOperator
<
Tag
,
Expr
>
const
&
op_ref
=
op
;
auto
gridFct
=
makeGridFunction
(
std
::
ref
(
op_ref
.
expr
),
gridView
,
Dune
::
PriorityTag
<
42
>
{}
);
return
GridFunctionOperator
<
Tag
,
decltype
(
gridFct
)
>
{
op_ref
.
tag
,
gridFct
};
auto
gridFct
=
makeGridFunction
(
std
::
ref
(
op_ref
.
expr
),
gridView
);
return
GridFunctionOperator
<
Tag
,
decltype
(
gridFct
)
>
{
op_ref
.
tag
,
gridFct
,
op_ref
.
order
};
}
/// @}
/// Generate a shared_ptr to \ref GridFunctionOperator from a PreOperator (tag, expr).
/// @{
template
<
class
Tag
,
class
Expr
,
class
GridView
>
auto
makeGridOperatorPtr
(
ExpressionPreOperator
<
Tag
,
Expr
>
const
&
op
,
GridView
const
&
gridView
)
{
auto
gridFct
=
makeGridFunction
(
op
.
expr
,
gridView
,
Dune
::
PriorityTag
<
42
>
{}
);
return
std
::
make_shared
<
GridFunctionOperator
<
Tag
,
decltype
(
gridFct
)
>>
(
op
.
tag
,
gridFct
);
auto
gridFct
=
makeGridFunction
(
op
.
expr
,
gridView
);
return
std
::
make_shared
<
GridFunctionOperator
<
Tag
,
decltype
(
gridFct
)
>>
(
op
.
tag
,
gridFct
,
op
.
order
);
}
template
<
class
Tag
,
class
Expr
,
class
GridView
>
auto
makeGridOperatorPtr
(
std
::
reference_wrapper
<
ExpressionPreOperator
<
Tag
,
Expr
>>
op
,
GridView
const
&
gridView
)
{
ExpressionPreOperator
<
Tag
,
Expr
>
const
&
op_ref
=
op
;
auto
gridFct
=
makeGridFunction
(
std
::
ref
(
op_ref
.
expr
),
gridView
,
Dune
::
PriorityTag
<
42
>
{}
);
return
std
::
make_shared
<
GridFunctionOperator
<
Tag
,
decltype
(
gridFct
)
>>
(
op_ref
.
tag
,
gridFct
);
auto
gridFct
=
makeGridFunction
(
std
::
ref
(
op_ref
.
expr
),
gridView
);
return
std
::
make_shared
<
GridFunctionOperator
<
Tag
,
decltype
(
gridFct
)
>>
(
op_ref
.
tag
,
gridFct
,
op_ref
.
order
);
}
/// @}
}
// end namespace AMDiS
dune/amdis/GridFunctions.hpp
View file @
90c3d73b
...
...
@@ -6,3 +6,14 @@
#include
<dune/amdis/gridfunctions/DerivativeGridFunction.hpp>
#include
<dune/amdis/gridfunctions/FunctorGridFunction.hpp>
#include
<dune/amdis/gridfunctions/OperationsGridFunction.hpp>
namespace
AMDiS
{
// Generator for Gridfunctions from Pre-Gridfunctions
template
<
class
PreGridFct
,
class
GridView
>
decltype
(
auto
)
makeGridFunction
(
PreGridFct
&&
preGridFct
,
GridView
const
&
gridView
)
{
return
Impl
::
makeGridFunctionImpl
(
std
::
forward
<
PreGridFct
>
(
preGridFct
),
gridView
,
Dune
::
PriorityTag
<
10
>
{});
}
}
// end namespace AMDiS
dune/amdis/ProblemStat.hpp
View file @
90c3d73b
...
...
@@ -31,6 +31,7 @@
#include
<dune/amdis/common/TypeDefs.hpp>
#include
<dune/amdis/common/Utility.hpp>
#include
<dune/amdis/GridFunctions.hpp>
#include
<dune/amdis/gridfunctions/DOFVectorView.hpp>
#include
<dune/amdis/io/FileWriterInterface.hpp>
...
...
dune/amdis/ProblemStat.inc.hpp
View file @
90c3d73b
...
...
@@ -216,7 +216,7 @@ addDirichletBC(Predicate const& predicate, RowTreePath row, ColTreePath col, Val
auto
i
=
child
(
globalBasis
->
localView
().
tree
(),
makeTreePath
(
row
));
auto
j
=
child
(
globalBasis
->
localView
().
tree
(),
makeTreePath
(
col
));
auto
valueGridFct
=
makeGridFunction
(
values
,
globalBasis
->
gridView
()
,
Dune
::
PriorityTag
<
42
>
{}
);
auto
valueGridFct
=
makeGridFunction
(
values
,
globalBasis
->
gridView
());
using
Range
=
typename
decltype
(
valueGridFct
)
::
Range
;
using
BcType
=
DirichletBC
<
WorldVector
,
Range
>
;
...
...
dune/amdis/assembler/FirstOrderDivTestvecTrial.hpp
View file @
90c3d73b
...
...
@@ -20,8 +20,8 @@ namespace AMDiS
using
Transposed
=
GridFunctionOperator
<
tag
::
test_divtrialvec
,
GridFct
>
;
public:
GridFunctionOperator
(
tag
::
divtestvec_trial
,
GridFct
const
&
expr
)
:
Transposed
(
tag
::
test_divtrialvec
{},
expr
)
GridFunctionOperator
(
tag
::
divtestvec_trial
,
GridFct
const
&
expr
,
int
degree
)
:
Transposed
(
tag
::
test_divtrialvec
{},
expr
,
degree
)
{}
template
<
class
Context
,
class
QuadratureRule
,
...
...
dune/amdis/assembler/FirstOrderGradTestTrial.hpp
View file @
90c3d73b
...
...
@@ -20,8 +20,8 @@ namespace AMDiS
using
Transposed
=
GridFunctionOperator
<
tag
::
test_gradtrial
,
GridFct
>
;
public:
GridFunctionOperator
(
tag
::
gradtest_trial
,
GridFct
const
&
expr
)
:
Transposed
(
tag
::
test_gradtrial
{},
expr
)
GridFunctionOperator
(
tag
::
gradtest_trial
,
GridFct
const
&
expr
,
int
degree
)
:
Transposed
(
tag
::
test_gradtrial
{},
expr
,
degree
)
{}
template
<
class
Context
,
class
QuadratureRule
,
...
...
dune/amdis/assembler/FirstOrderGradTestTrialvec.hpp
View file @
90c3d73b
...
...
@@ -20,8 +20,8 @@ namespace AMDiS
using
Transposed
=
GridFunctionOperator
<
tag
::
testvec_gradtrial
,
GridFct
>
;
public:
GridFunctionOperator
(
tag
::
gradtest_trialvec
,
GridFct
const
&
expr
)
:
Transposed
(
tag
::
testvec_gradtrial
{},
expr
)
GridFunctionOperator
(
tag
::
gradtest_trialvec
,
GridFct
const
&
expr
,
int
degree
)
:
Transposed
(
tag
::
testvec_gradtrial
{},
expr
,
degree
)
{}
template
<
class
Context
,
class
QuadratureRule
,
...
...
dune/amdis/assembler/FirstOrderPartialTestTrial.hpp
View file @
90c3d73b
...
...
@@ -23,8 +23,8 @@ namespace AMDiS
using
Transposed
=
GridFunctionOperator
<
tag
::
test_partialtrial
,
GridFct
>
;
public:
GridFunctionOperator
(
tag
::
partialtest_trial
tag
,
GridFct
const
&
expr
)
:
Transposed
(
tag
::
test_partialtrial
{
tag
.
comp
},
expr
)
GridFunctionOperator
(
tag
::
partialtest_trial
tag
,
GridFct
const
&
expr
,
int
degree
)
:
Transposed
(
tag
::
test_partialtrial
{
tag
.
comp
},
expr
,
degree
)
{}
template
<
class
Context
,
class
QuadratureRule
,
...
...
dune/amdis/assembler/FirstOrderTestDivTrialvec.hpp
View file @
90c3d73b
...
...
@@ -24,8 +24,8 @@ namespace AMDiS
static_assert
(
Category
::
Scalar
<
typename
GridFct
::
Range
>
,
"Expression must be of scalar type."
);
public:
GridFunctionOperator
(
tag
::
test_divtrialvec
,
GridFct
const
&
expr
)
:
Super
(
expr
,
1
)
GridFunctionOperator
(
tag
::
test_divtrialvec
,
GridFct
const
&
expr
,
int
degree
)
:
Super
(
expr
,
1
,
degree
)
{}
template
<
class
Context
,
class
QuadratureRule
,
...
...
dune/amdis/assembler/FirstOrderTestGradTrial.hpp
View file @
90c3d73b
...
...
@@ -24,8 +24,8 @@ namespace AMDiS
static_assert
(
Category
::
Vector
<
typename
GridFct
::
Range
>
,
"Expression must be of vector type."
);
public:
GridFunctionOperator
(
tag
::
test_gradtrial
,
GridFct
const
&
expr
)
:
Super
(
expr
,
1
)
GridFunctionOperator
(
tag
::
test_gradtrial
,
GridFct
const
&
expr
,
int
degree
)
:
Super
(
expr
,
1
,
degree
)
{}
template
<
class
Context
,
class
QuadratureRule
,
...
...
dune/amdis/assembler/FirstOrderTestPartialTrial.hpp
View file @
90c3d73b
...
...
@@ -27,8 +27,8 @@ namespace AMDiS
static_assert
(
Category
::
Scalar
<
typename
GridFct
::
Range
>
,
"Expression must be of scalar type."
);
public:
GridFunctionOperator
(
tag
::
test_partialtrial
tag
,
GridFct
const
&
expr
)
:
Super
(
expr
,
1
)
GridFunctionOperator
(
tag
::
test_partialtrial
tag
,
GridFct
const
&
expr
,
int
degree
)
:
Super
(
expr
,
1
,
degree
)
,
comp_
(
tag
.
comp
)
{}
...
...
dune/amdis/assembler/FirstOrderTestvecGradTrial.hpp
View file @
90c3d73b
...
...
@@ -24,8 +24,8 @@ namespace AMDiS
static_assert
(
Category
::
Scalar
<
typename
GridFct
::
Range
>
,
"Expression must be of scalar type."
);
public:
GridFunctionOperator
(
tag
::
testvec_gradtrial
,
GridFct
const
&
expr
)
:
Super
(
expr
,
1
)
GridFunctionOperator
(
tag
::
testvec_gradtrial
,
GridFct
const
&
expr
,
int
degree
)
:
Super
(
expr
,
1
,
degree
)
{}
template
<
class
Context
,
class
QuadratureRule
,
...
...
dune/amdis/assembler/SecondOrderDivTestvecDivTrialvec.hpp
View file @
90c3d73b
...
...
@@ -24,8 +24,8 @@ namespace AMDiS
static_assert
(
Category
::
Scalar
<
typename
GridFct
::
Range
>
,
"Expression must be of scalar type."
);
public:
GridFunctionOperator
(
tag
::
divtestvec_divtrialvec
,
GridFct
const
&
expr
)
:
Super
(
expr
,
2
)
GridFunctionOperator
(
tag
::
divtestvec_divtrialvec
,
GridFct
const
&
expr
,
int
degree
)
:
Super
(
expr
,
2
,
degree
)
{}
template
<
class
Context
,
class
QuadratureRule
,
...
...
dune/amdis/assembler/SecondOrderGradTestGradTrial.hpp
View file @
90c3d73b
...
...
@@ -26,8 +26,8 @@ namespace AMDiS
"Expression must be of scalar or matrix type."
);
public:
GridFunctionOperator
(
tag
::
gradtest_gradtrial
,
GridFct
const
&
expr
)
:
Super
(
expr
,
2
)
GridFunctionOperator
(
tag
::
gradtest_gradtrial
,
GridFct
const
&
expr
,
int
degree
)
:
Super
(
expr
,
2
,
degree
)
{}
template
<
class
Context
,
class
QuadratureRule
,
...
...
dune/amdis/assembler/SecondOrderPartialTestPartialTrial.hpp
View file @
90c3d73b
...
...
@@ -28,8 +28,8 @@ namespace AMDiS
static_assert
(
Category
::
Scalar
<
typename
GridFct
::
Range
>
,
"Expression must be of scalar type."
);
public:
GridFunctionOperator
(
tag
::
partialtest_partialtrial
tag
,
GridFct
const
&
expr
)
:
Super
(
expr
,
2
)
GridFunctionOperator
(
tag
::
partialtest_partialtrial
tag
,
GridFct
const
&
expr
,
int
degree
)
:
Super
(
expr
,
2
,
degree
)
,
compTest_
(
tag
.
comp_test
)
,
compTrial_
(
tag
.
comp_trial
)
{}
...
...
dune/amdis/assembler/ZeroOrderTest.hpp
View file @
90c3d73b
...
...
@@ -23,8 +23,8 @@ namespace AMDiS
static_assert
(
Category
::
Scalar
<
typename
GridFct
::
Range
>
,
"Expression must be of scalar type."
);
public:
GridFunctionOperator
(
tag
::
test
,
GridFct
const
&
expr
)
:
Super
(
expr
,
0
)
GridFunctionOperator
(
tag
::
test
,
GridFct
const
&
expr
,
int
degree
)
:
Super
(
expr
,
0
,
degree
)
{}
template
<
class
Context
,
class
QuadratureRule
,
...
...
dune/amdis/assembler/ZeroOrderTestTrial.hpp
View file @
90c3d73b
...
...
@@ -23,8 +23,8 @@ namespace AMDiS
static_assert
(
Category
::
Scalar
<
typename
GridFct
::
Range
>
,
"Expression must be of scalar type."
);
public:
GridFunctionOperator
(
tag
::
test_trial
,
GridFct
const
&
expr
)
:
Super
(
expr
,
0
)
GridFunctionOperator
(
tag
::
test_trial
,
GridFct
const
&
expr
,
int
degree
)
:
Super
(
expr
,
0
,
degree
)
{}
template
<
class
Context
,
class
QuadratureRule
,
...
...
dune/amdis/assembler/ZeroOrderTestTrialvec.hpp
View file @
90c3d73b
...
...
@@ -23,8 +23,8 @@ namespace AMDiS
static_assert
(
Category
::
Vector
<
typename
GridFct
::
Range
>
,
"Expression must be of vector type."
);
public:
GridFunctionOperator
(
tag
::
test_trialvec
,
GridFct
const
&
expr
)
:
Super
(
expr
,
0
)
GridFunctionOperator
(
tag
::
test_trialvec
,
GridFct
const
&
expr
,
int
degree
)
:
Super
(
expr
,
0
,
degree
)
{}
template
<
class
Context
,
class
QuadratureRule
,
...
...
dune/amdis/assembler/ZeroOrderTestvec.hpp
View file @
90c3d73b
...
...
@@ -23,8 +23,8 @@ namespace AMDiS
static_assert
(
Category
::
Vector
<
typename
GridFct
::
Range
>
,
"Expression must be of vector type."
);
public:
GridFunctionOperator
(
tag
::
testvec
,
GridFct
const
&
expr
)
:
Super
(
expr
,
0
)
GridFunctionOperator
(
tag
::
testvec
,
GridFct
const
&
expr
,
int
degree
)
:
Super
(
expr
,
0
,
degree
)
{}
template
<
class
Context
,
class
QuadratureRule
,
...
...
dune/amdis/assembler/ZeroOrderTestvecTrial.hpp
View file @
90c3d73b
...
...
@@ -20,8 +20,8 @@ namespace AMDiS
using
Transposed
=
GridFunctionOperator
<
tag
::
test_trialvec
,
GridFct
>
;
public:
GridFunctionOperator
(
tag
::
testvec_trial
,
GridFct
const
&
expr
)
:
Transposed
(
tag
::
test_trialvec
{},
expr
)
GridFunctionOperator
(
tag
::
testvec_trial
,
GridFct
const
&
expr
,
int
degree
)
:
Transposed
(
tag
::
test_trialvec
{},
expr
,
degree
)
{}
template
<
class
Context
,
class
QuadratureRule
,
...
...
Prev
1
2
Next
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