Skip to content
GitLab
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
cf41b398
Commit
cf41b398
authored
Dec 16, 2019
by
Praetorius, Simon
Browse files
Merge branch 'issue/cleanup_concepts' into 'master'
Issue/cleanup concepts See merge request
!128
parents
224f40e9
720a8837
Changes
12
Hide whitespace changes
Inline
Side-by-side
src/amdis/AdaptionInterface.hpp
View file @
cf41b398
...
...
@@ -16,7 +16,7 @@ namespace AMDiS
struct
InterpolateData
{
template
<
class
Data
>
auto
require
s_
(
Data
const
&
data
)
->
decltype
(
auto
require
(
Data
const
&
data
)
->
decltype
(
const_cast
<
Data
&>
(
data
).
preAdapt
(
true
),
const_cast
<
Data
&>
(
data
).
postAdapt
(
true
)
);
...
...
@@ -25,7 +25,7 @@ namespace AMDiS
struct
UpdateData
{
template
<
class
Basis
>
auto
require
s_
(
Basis
const
&
basis
)
->
decltype
(
auto
require
(
Basis
const
&
basis
)
->
decltype
(
const_cast
<
Basis
&>
(
basis
).
update
(
basis
.
gridView
())
);
};
...
...
@@ -35,9 +35,16 @@ namespace AMDiS
template
<
class
Data
>
constexpr
bool
InterpolateData
=
models
<
Definition
::
InterpolateData
(
Data
)
>
;
template
<
class
Data
>
using
InterpolateData_t
=
models_t
<
Definition
::
InterpolateData
(
Data
)
>
;
template
<
class
Basis
>
constexpr
bool
UpdateData
=
models
<
Definition
::
UpdateData
(
Basis
)
>
;
template
<
class
Basis
>
using
UpdateData_t
=
models_t
<
Definition
::
UpdateData
(
Basis
)
>
;
}
// end namespace Concepts
/// @}
...
...
src/amdis/common/Access.hpp
View file @
cf41b398
...
...
@@ -15,30 +15,30 @@ namespace AMDiS
struct
HasVectorAccess
{
template
<
class
V
,
class
I
>
auto
require
s_
(
V
&&
v
,
I
&&
i
,
Dune
::
PriorityTag
<
2
>
)
->
decltype
(
v
[
i
]
);
auto
require
(
V
&&
v
,
I
&&
i
,
Dune
::
PriorityTag
<
2
>
)
->
decltype
(
v
[
i
]
);
template
<
class
V
,
class
I
>
auto
require
s_
(
V
&&
v
,
I
&&
i
,
Dune
::
PriorityTag
<
1
>
)
->
decltype
(
v
(
i
)
);
auto
require
(
V
&&
v
,
I
&&
i
,
Dune
::
PriorityTag
<
1
>
)
->
decltype
(
v
(
i
)
);
};
struct
HasMatrixAccess
{
template
<
class
M
,
class
I
,
class
J
>
auto
require
s_
(
M
&&
m
,
I
&&
i
,
J
&&
j
,
Dune
::
PriorityTag
<
2
>
)
->
decltype
(
m
[
i
][
j
]
);
auto
require
(
M
&&
m
,
I
&&
i
,
J
&&
j
,
Dune
::
PriorityTag
<
2
>
)
->
decltype
(
m
[
i
][
j
]
);
template
<
class
M
,
class
I
,
class
J
>
auto
require
s_
(
M
&&
m
,
I
&&
i
,
J
&&
j
,
Dune
::
PriorityTag
<
1
>
)
->
decltype
(
m
(
i
,
j
)
);
auto
require
(
M
&&
m
,
I
&&
i
,
J
&&
j
,
Dune
::
PriorityTag
<
1
>
)
->
decltype
(
m
(
i
,
j
)
);
};
}
// end namespace Definition
/// Vector component can be accessed either with [.] or (.)
template
<
class
V
,
class
I
>
using
VectorAccessible_t
=
bool_t
<
models
<
Definition
::
HasVectorAccess
(
V
,
I
,
Dune
::
PriorityTag
<
42
>
)
>
>
;
using
VectorAccessible_t
=
models
_t
<
Definition
::
HasVectorAccess
(
V
,
I
,
Dune
::
PriorityTag
<
42
>
)
>
;
/// Matrix component can be accessed either with [.][.] or (.,.)
template
<
class
M
,
class
I
,
class
J
>
using
MatrixAccessible_t
=
bool_t
<
models
<
Definition
::
HasMatrixAccess
(
M
,
I
,
J
,
Dune
::
PriorityTag
<
42
>
)
>
>
;
using
MatrixAccessible_t
=
models
_t
<
Definition
::
HasMatrixAccess
(
M
,
I
,
J
,
Dune
::
PriorityTag
<
42
>
)
>
;
}
// end namespace Concepts
...
...
src/amdis/common/Concepts.hpp
View file @
cf41b398
...
...
@@ -53,19 +53,9 @@ namespace AMDiS
struct
IsReferenceWrapper
<
std
::
reference_wrapper
<
T
>>
:
std
::
true_type
{};
template
<
class
,
class
=
void
>
struct
IsDefined
:
std
::
false_type
{};
template
<
class
T
>
struct
IsDefined
<
T
,
std
::
enable_if_t
<
std
::
is_object
<
T
>::
value
&&
!
std
::
is_pointer
<
T
>::
value
&&
(
sizeof
(
T
)
>
0
)
>
>
:
std
::
true_type
{};
}
// end namespace Traits
namespace
Concepts
{
#ifndef DOXYGEN
...
...
@@ -75,33 +65,42 @@ namespace AMDiS
struct
Callable
{
template
<
class
F
,
class
...
Args
>
auto
requires_
(
F
&&
f
,
Args
&&
...
args
)
->
decltype
(
f
(
FWD
(
args
)...));
auto
require
(
F
&&
f
,
Args
&&
...
args
)
->
decltype
(
f
(
FWD
(
args
)...)
);
};
// idx[0]
struct
MultiIndex
{
template
<
class
MI
>
auto
requires_
(
MI
&&
idx
)
->
decltype
(
Concepts
::
valid_expr
(
idx
[
0
],
idx
.
size
(),
idx
.
max_size
()
/* ,idx.resize() */
));
auto
require
(
MI
&&
idx
)
->
decltype
(
idx
[
0
],
idx
.
size
(),
idx
.
max_size
()
);
};
}
// end namespace Definition
#endif // DOXYGEN
/// Types are the same
template
<
class
...
Ts
>
constexpr
bool
Same
=
Traits
::
IsSame
<
Ts
...
>::
value
;
template
<
class
...
Ts
>
using
Same_t
=
Traits
::
IsSame
<
Ts
...
>
;
/// Types are the same, up to decay of qualifiers
template
<
class
A
,
class
B
>
constexpr
bool
Similar
=
Traits
::
IsSimilar
<
A
,
B
>::
value
;
template
<
class
A
,
class
B
>
using
Similar_t
=
Traits
::
IsSimilar
<
A
,
B
>
;
/// \brief A Collable is a function `F` that can be called with arguments of type `Args...`.
/**
* To be used as follows: `Concepts::Collable<F, Args...>`. Returns true, if
...
...
@@ -111,6 +110,9 @@ namespace AMDiS
template
<
class
F
,
class
...
Args
>
constexpr
bool
Callable
=
models
<
Definition
::
Callable
(
F
,
Args
...)
>
;
template
<
class
F
,
class
...
Args
>
using
Callable_t
=
models_t
<
Definition
::
Callable
(
F
,
Args
...)
>
;
/// \brief A Functor is a function `F` with signature `Signature`.
/**
...
...
@@ -121,18 +123,26 @@ namespace AMDiS
template
<
class
F
,
class
Signature
>
// F, Signature=Return(Arg)
constexpr
bool
Functor
=
Dune
::
Functions
::
Concept
::
isFunction
<
F
,
Signature
>
();
template
<
class
F
,
class
Signature
>
// F, Signature=Return(Arg)
using
Functor_t
=
bool_t
<
Functor
<
F
,
Signature
>>
;
/// A predicate is a function that returns a boolean.
template
<
class
F
,
class
...
Args
>
constexpr
bool
Predicate
=
Functor
<
F
,
bool
(
Args
...)
>
;
template
<
class
F
,
class
...
Args
>
using
Predicate_t
=
Functor_t
<
F
,
bool
(
Args
...)
>
;
/// A multi-index type
template
<
class
MI
>
constexpr
bool
MultiIndex
=
models
<
Definition
::
MultiIndex
(
MI
)
>
;
template
<
class
T
>
constexpr
bool
Defined
=
Traits
::
IsDefined
<
T
>::
value
;
template
<
class
MI
>
using
MultiIndex_t
=
models_t
<
Definition
::
MultiIndex
(
MI
)
>
;
/** @} **/
}
// end namespace Concepts
}
// end namespace AMDiS
src/amdis/common/ConceptsBase.hpp
View file @
cf41b398
...
...
@@ -32,21 +32,10 @@ namespace AMDiS
{};
template
<
class
Concept
,
class
...
Ts
>
struct
models
<
Concept
(
Ts
...),
void_t
<
decltype
(
std
::
declval
<
Concept
>
().
require
s_
(
std
::
declval
<
Ts
>
()...))
>>
struct
models
<
Concept
(
Ts
...),
void_t
<
decltype
(
std
::
declval
<
Concept
>
().
require
(
std
::
declval
<
Ts
>
()...))
>>
:
std
::
true_type
{};
struct
valid_expr
{
template
<
class
...
Ts
>
void
operator
()(
Ts
&&
...)
const
;
#if defined(__GNUC__) && !defined(__clang__)
template
<
class
...
Ts
>
void
operator
()(
Ts
const
&
...)
const
;
#endif
};
}
// end namespace Impl_
...
...
@@ -54,9 +43,9 @@ namespace AMDiS
template
<
class
Concept
>
constexpr
bool
models
=
Impl_
::
models
<
Concept
>::
value
;
constexpr
Impl_
::
valid_expr
valid_expr
=
{};
template
<
class
Concept
>
using
models_t
=
Impl_
::
models
<
Concept
>
;
#endif // DOXYGEN
}
// end namespace Concepts
}
// end namespace AMDiS
src/amdis/common/Resize.hpp
View file @
cf41b398
...
...
@@ -14,32 +14,32 @@ namespace AMDiS
struct
VectorResizable
{
template
<
class
V
>
auto
require
s_
(
V
const
&
vec
,
Dune
::
PriorityTag
<
2
>
)
->
decltype
(
const_cast
<
V
&>
(
vec
).
resize
(
0u
),
0
);
auto
require
(
V
const
&
vec
,
Dune
::
PriorityTag
<
2
>
)
->
decltype
(
const_cast
<
V
&>
(
vec
).
resize
(
0u
),
0
);
template
<
class
V
>
auto
require
s_
(
V
const
&
vec
,
Dune
::
PriorityTag
<
1
>
)
->
decltype
(
const_cast
<
V
&>
(
vec
).
change_dim
(
0u
),
0
);
auto
require
(
V
const
&
vec
,
Dune
::
PriorityTag
<
1
>
)
->
decltype
(
const_cast
<
V
&>
(
vec
).
change_dim
(
0u
),
0
);
};
struct
MatrixResizable
{
template
<
class
M
>
auto
require
s_
(
M
const
&
mat
,
Dune
::
PriorityTag
<
3
>
)
->
decltype
(
const_cast
<
M
&>
(
mat
).
resize
(
0u
,
0u
),
0
);
auto
require
(
M
const
&
mat
,
Dune
::
PriorityTag
<
3
>
)
->
decltype
(
const_cast
<
M
&>
(
mat
).
resize
(
0u
,
0u
),
0
);
template
<
class
M
>
auto
require
s_
(
M
const
&
mat
,
Dune
::
PriorityTag
<
2
>
)
->
decltype
(
const_cast
<
M
&>
(
mat
).
change_dim
(
0u
,
0u
),
0
);
auto
require
(
M
const
&
mat
,
Dune
::
PriorityTag
<
2
>
)
->
decltype
(
const_cast
<
M
&>
(
mat
).
change_dim
(
0u
,
0u
),
0
);
template
<
class
M
>
auto
require
s_
(
M
const
&
mat
,
Dune
::
PriorityTag
<
1
>
)
->
decltype
(
const_cast
<
M
&>
(
mat
).
setSize
(
0u
,
0u
),
0
);
auto
require
(
M
const
&
mat
,
Dune
::
PriorityTag
<
1
>
)
->
decltype
(
const_cast
<
M
&>
(
mat
).
setSize
(
0u
,
0u
),
0
);
};
}
/// Checks whether a vector can be resized by various resize methods
template
<
class
Vector
>
using
VectorResizable_t
=
bool_t
<
models
<
Definition
::
VectorResizable
(
Vector
,
Dune
::
PriorityTag
<
42
>
)
>
>
;
using
VectorResizable_t
=
models
_t
<
Definition
::
VectorResizable
(
Vector
,
Dune
::
PriorityTag
<
42
>
)
>
;
/// Checks whether a matrix can be resized by various resize methods
template
<
class
Matrix
>
using
MatrixResizable_t
=
bool_t
<
models
<
Definition
::
MatrixResizable
(
Matrix
,
Dune
::
PriorityTag
<
42
>
)
>
>
;
using
MatrixResizable_t
=
models
_t
<
Definition
::
MatrixResizable
(
Matrix
,
Dune
::
PriorityTag
<
42
>
)
>
;
}
// end namespace Concepts
...
...
src/amdis/gridfunctions/AnalyticGridFunction.hpp
View file @
cf41b398
...
...
@@ -193,6 +193,9 @@ namespace AMDiS
Definition
::
CallableDow
<
F
,
WORLDDIM
>
;
#endif
template
<
class
F
>
using
CallableDomain_t
=
bool_t
<
CallableDomain
<
F
>>
;
}
// end namespace Concepts
...
...
src/amdis/gridfunctions/Derivative.hpp
View file @
cf41b398
...
...
@@ -28,19 +28,19 @@ namespace AMDiS
struct
HasDerivative
{
template
<
class
F
,
class
T
>
auto
require
s_
(
F
&&
f
,
T
&&
t
)
->
decltype
(
derivative
(
f
,
t
)
);
auto
require
(
F
&&
f
,
T
&&
t
)
->
decltype
(
derivative
(
f
,
t
)
);
};
struct
HasLocalFunctionDerivative
{
template
<
class
F
,
class
T
>
auto
require
s_
(
F
&&
f
,
T
&&
t
)
->
decltype
(
derivative
(
localFunction
(
f
),
t
)
);
auto
require
(
F
&&
f
,
T
&&
t
)
->
decltype
(
derivative
(
localFunction
(
f
),
t
)
);
};
struct
HasPartial
{
template
<
class
F
,
class
I
>
auto
require
s_
(
F
&&
f
,
I
&&
i
)
->
decltype
(
partial
(
f
,
i
)
);
auto
require
(
F
&&
f
,
I
&&
i
)
->
decltype
(
partial
(
f
,
i
)
);
};
}
// end namespace Definition
...
...
@@ -50,14 +50,25 @@ namespace AMDiS
template
<
class
GF
,
class
Type
>
constexpr
bool
HasDerivative
=
models
<
Definition
::
HasDerivative
(
GF
,
Type
)
>
;
template
<
class
GF
,
class
Type
>
using
HasDerivative_t
=
models_t
<
Definition
::
HasDerivative
(
GF
,
Type
)
>
;
/// \brief GridFunction GF has free function `derivative(localFunction(F))`
template
<
class
GF
,
class
Type
>
constexpr
bool
HasLocalFunctionDerivative
=
models
<
Definition
::
HasLocalFunctionDerivative
(
GF
,
Type
)
>
;
template
<
class
GF
,
class
Type
>
using
HasLocalFunctionDerivative_t
=
models_t
<
Definition
::
HasLocalFunctionDerivative
(
GF
,
Type
)
>
;
/// \brief Functor F has free function `partial(F,_0)`
template
<
class
F
>
constexpr
bool
HasPartial
=
models
<
Definition
::
HasPartial
(
F
,
index_t
<
0
>
)
>
;
template
<
class
F
>
using
HasPartial_t
=
models_t
<
Definition
::
HasPartial
(
F
,
index_t
<
0
>
)
>
;
/** @} **/
}
// end namespace Concepts
...
...
src/amdis/gridfunctions/FunctorGridFunction.hpp
View file @
cf41b398
...
...
@@ -20,16 +20,12 @@ namespace AMDiS
struct
DomainType
{
using
type
=
typename
T0
::
Domain
;
// static_assert( all_of_v< std::is_same<type, typename DomainType<Ts>::type>::value... >,
// "All GridFunctions must have the same Domain." );
};
template
<
class
T0
,
class
...
Ts
>
struct
EntitySetType
{
using
type
=
typename
T0
::
EntitySet
;
// static_assert( all_of_v< std::is_same<type, typename EntitySetType<Ts>::type>::value... >,
// "All GridFunctions must have the same EntitySet." );
};
}
// end namespace Impl
...
...
src/amdis/gridfunctions/GridFunction.hpp
View file @
cf41b398
...
...
@@ -38,16 +38,19 @@ namespace AMDiS
struct
HasLocalFunction
{
template
<
class
F
>
auto
requires_
(
F
&&
f
)
->
decltype
(
localFunction
(
f
)
);
auto
require
(
F
&&
f
)
->
decltype
(
localFunction
(
f
)
);
};
struct
HasGridFunctionTypes
{
template
<
class
GF
>
auto
require
s_
(
GF
const
&
/*gf*/
)
->
void_t
<
auto
require
(
GF
const
&
/*gf*/
)
->
void_t
<
typename
GF
::
Range
,
typename
GF
::
Domain
,
typename
GF
::
EntitySet
>
;
typename
GF
::
EntitySet
>
;
};
}
// end namespace Definition
...
...
@@ -57,12 +60,20 @@ namespace AMDiS
template
<
class
GF
>
constexpr
bool
HasLocalFunction
=
models
<
Definition
::
HasLocalFunction
(
GF
)
>
;
template
<
class
GF
>
using
HasLocalFunction_t
=
models_t
<
Definition
::
HasLocalFunction
(
GF
)
>
;
/// \brief GridFunction GF is a Type that has LocalFunction and provides some
/// typedefs for `Domain`, `Range`, and `EntitySet`.
template
<
class
GF
>
constexpr
bool
GridFunction
=
HasLocalFunction
<
GF
>
&&
models
<
Definition
::
HasGridFunctionTypes
(
GF
)
>
;
template
<
class
GF
>
using
GridFunction_t
=
bool_t
<
GridFunction
<
GF
>>
;
/// \brief Concept is fulfilled, if at least one of the massed Expressions
/// can be converted to a GridFunction, or is already a GridFunction.
template
<
class
...
GFs
>
...
...
@@ -70,6 +81,9 @@ namespace AMDiS
any_of_v
<
GridFunction
<
remove_cvref_t
<
GFs
>>
...
>
||
any_of_v
<
Traits
::
IsPreGridFunction
<
remove_cvref_t
<
GFs
>>::
value
...
>
;
template
<
class
...
GFs
>
using
AnyGridFunction_t
=
bool_t
<
AnyGridFunction
<
GFs
...
>>
;
/** @} **/
}
// end namespace Concepts
...
...
@@ -137,7 +151,7 @@ namespace AMDiS
template
<
class
PreGridFct
,
class
GridView
>
decltype
(
auto
)
makeGridFunction
(
PreGridFct
const
&
preGridFct
,
GridView
const
&
gridView
)
{
using
isGridFct
=
bool_t
<
Concepts
::
GridFunction
<
PreGridFct
>
>
;
using
isGridFct
=
Concepts
::
GridFunction
_t
<
PreGridFct
>
;
return
Impl
::
makeGridFunctionImpl
(
preGridFct
,
gridView
,
isGridFct
{});
}
...
...
src/amdis/gridfunctions/Order.hpp
View file @
cf41b398
...
...
@@ -24,13 +24,17 @@ namespace AMDiS
struct
HasLocalFunctionOrder
{
template
<
class
F
>
auto
requires_
(
F
&&
f
)
->
decltype
(
order
(
localFunction
(
f
))
);
auto
require
(
F
&&
f
)
->
decltype
(
order
(
localFunction
(
f
))
);
};
struct
HasOrder
{
template
<
class
F
>
auto
requires_
(
F
&&
f
)
->
decltype
(
order
(
f
)
);
auto
require
(
F
&&
f
)
->
decltype
(
order
(
f
)
);
};
}
// end namespace Definition
...
...
@@ -40,10 +44,17 @@ namespace AMDiS
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
)
>
;
template
<
class
LF
>
using
HasOrder_t
=
models_t
<
Definition
::
HasOrder
(
LF
)
>
;
/** @} **/
}
// end namespace Concepts
...
...
src/amdis/operations/Basic.hpp
View file @
cf41b398
...
...
@@ -15,12 +15,15 @@ namespace AMDiS
struct
HasFunctorOrder
{
template
<
class
F
,
int
...
I
>
auto
require
s_
(
F
&&
f
,
std
::
integer_sequence
<
int
,
I
...
>
)
->
decltype
(
order
(
f
,
I
...)
);
auto
require
(
F
&&
f
,
std
::
integer_sequence
<
int
,
I
...
>
)
->
decltype
(
order
(
f
,
I
...)
);
};
}
template
<
class
F
,
int
N
>
constexpr
bool
HasFunctorOrder
=
models
<
Definition
::
HasFunctorOrder
(
F
,
std
::
make_integer_sequence
<
int
,
N
>
)
>
;
template
<
class
F
,
int
N
>
using
HasFunctorOrder_t
=
bool_t
<
HasFunctorOrder
<
F
,
N
>>
;
}
namespace
Operation
...
...
src/amdis/typetree/TreePath.hpp
View file @
cf41b398
...
...
@@ -8,6 +8,8 @@
#include
<dune/typetree/treepath.hh>
#include
<dune/typetree/typetraits.hh>
#include
<amdis/common/Logical.hpp>
namespace
AMDiS
{
struct
RootTreePath
{};
...
...
@@ -55,6 +57,9 @@ namespace AMDiS
template
<
class
TP
>
constexpr
bool
PreTreePath
=
Dune
::
TypeTree
::
IsTreePath
<
TP
>::
value
||
Definition
::
IsPreTreePath
<
TP
>::
value
;
template
<
class
TP
>
using
PreTreePath_t
=
bool_t
<
PreTreePath
<
TP
>>
;
/** @} **/
}
// end namespace Concepts
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment