Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Praetorius, Simon
dune-amdis
Commits
947d788f
Commit
947d788f
authored
Mar 02, 2019
by
Praetorius, Simon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
split Mpl.hpp into Index, Logical, Range
parent
138c15d3
Pipeline
#1779
passed with stage
in 25 minutes and 44 seconds
Changes
22
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
366 additions
and
101 deletions
+366
-101
src/amdis/ProblemStat.inc.hpp
src/amdis/ProblemStat.inc.hpp
+1
-1
src/amdis/ProblemStatTraits.hpp
src/amdis/ProblemStatTraits.hpp
+1
-1
src/amdis/common/Apply.hpp
src/amdis/common/Apply.hpp
+17
-15
src/amdis/common/CMakeLists.txt
src/amdis/common/CMakeLists.txt
+4
-1
src/amdis/common/Concepts.hpp
src/amdis/common/Concepts.hpp
+16
-1
src/amdis/common/ForEach.hpp
src/amdis/common/ForEach.hpp
+50
-0
src/amdis/common/Index.hpp
src/amdis/common/Index.hpp
+45
-0
src/amdis/common/Logical.hpp
src/amdis/common/Logical.hpp
+97
-0
src/amdis/common/Loops.hpp
src/amdis/common/Loops.hpp
+0
-10
src/amdis/common/MultiTypeMatrix.hpp
src/amdis/common/MultiTypeMatrix.hpp
+19
-7
src/amdis/common/MultiTypeVector.hpp
src/amdis/common/MultiTypeVector.hpp
+15
-7
src/amdis/common/Range.hpp
src/amdis/common/Range.hpp
+69
-0
src/amdis/common/StaticSize.hpp
src/amdis/common/StaticSize.hpp
+2
-20
src/amdis/common/TypeTraits.hpp
src/amdis/common/TypeTraits.hpp
+0
-7
src/amdis/gridfunctions/FunctorGridFunction.hpp
src/amdis/gridfunctions/FunctorGridFunction.hpp
+12
-19
src/amdis/gridfunctions/GridFunctionConcepts.hpp
src/amdis/gridfunctions/GridFunctionConcepts.hpp
+1
-1
src/amdis/linearalgebra/eigen/Constraints.hpp
src/amdis/linearalgebra/eigen/Constraints.hpp
+1
-1
src/amdis/localoperators/ConvectionDiffusionOperator.hpp
src/amdis/localoperators/ConvectionDiffusionOperator.hpp
+3
-1
src/amdis/operations/Basic.hpp
src/amdis/operations/Basic.hpp
+1
-1
src/amdis/operations/Composer.hpp
src/amdis/operations/Composer.hpp
+4
-3
src/amdis/typetree/FiniteElementType.hpp
src/amdis/typetree/FiniteElementType.hpp
+3
-3
src/amdis/typetree/Traversal.hpp
src/amdis/typetree/Traversal.hpp
+5
-2
No files found.
src/amdis/ProblemStat.inc.hpp
View file @
947d788f
...
...
@@ -4,6 +4,7 @@
#include <string>
#include <utility>
#include <dune/common/hybridutilities.hh>
#include <dune/common/timer.hh>
#include <dune/typetree/childextraction.hh>
...
...
@@ -12,7 +13,6 @@
#include <amdis/Assembler.hpp>
#include <amdis/GridFunctionOperator.hpp>
#include <amdis/GridTransferManager.hpp>
#include <amdis/common/Loops.hpp>
namespace
AMDiS
{
...
...
src/amdis/ProblemStatTraits.hpp
View file @
947d788f
...
...
@@ -7,7 +7,7 @@
#include <dune/functions/functionspacebases/pqknodalbasis.hh>
#include <dune/grid/yaspgrid.hh>
#include <amdis/common/
Mp
l.hpp>
#include <amdis/common/
Logica
l.hpp>
namespace
AMDiS
{
...
...
src/amdis/common/Apply.hpp
View file @
947d788f
...
...
@@ -4,7 +4,8 @@
#include <type_traits>
#include <utility>
#include <amdis/common/Mpl.hpp>
#include <amdis/common/Index.hpp>
#include <amdis/common/StaticSize.hpp>
#include <amdis/common/TypeTraits.hpp>
namespace
AMDiS
...
...
@@ -13,14 +14,15 @@ namespace AMDiS
{
namespace
Impl_
{
template
<
class
F
,
class
Tuple
,
std
::
size_t
...
I
>
constexpr
decltype
(
auto
)
apply_impl
(
F
&&
f
,
Tuple
&&
t
,
std
::
index_sequence
<
I
...
>
)
template
<
class
F
unctor
,
class
Tuple
,
std
::
size_t
...
I
>
constexpr
decltype
(
auto
)
apply_impl
(
F
unctor
&&
f
,
Tuple
&&
t
,
std
::
index_sequence
<
I
...
>
)
{
return
f
(
std
::
get
<
I
>
(
FWD
(
t
))...);
using
std
::
get
;
return
f
(
get
<
I
>
(
FWD
(
t
))...);
}
template
<
class
F
,
std
::
size_t
I0
,
std
::
size_t
...
I
>
constexpr
decltype
(
auto
)
apply_indices_impl
(
F
&&
f
,
index_t
<
I0
>
,
std
::
index_sequence
<
I
...
>
)
template
<
class
F
unctor
,
std
::
size_t
I0
,
std
::
size_t
...
I
>
constexpr
decltype
(
auto
)
apply_indices_impl
(
F
unctor
&&
f
,
index_t
<
I0
>
,
std
::
index_sequence
<
I
...
>
)
{
return
f
(
index_t
<
I0
+
I
>
{}...);
}
...
...
@@ -29,25 +31,25 @@ namespace AMDiS
template
<
class
F
,
class
Tuple
>
constexpr
decltype
(
auto
)
apply
(
F
&&
f
,
Tuple
&&
t
)
{
return
Impl_
::
apply_impl
(
FWD
(
f
),
FWD
(
t
),
std
::
make_index_sequence
<
std
::
tuple_s
ize
<
std
::
remove_reference_t
<
Tuple
>>
::
value
>
{});
return
Impl_
::
apply_impl
(
FWD
(
f
),
FWD
(
t
),
std
::
make_index_sequence
<
S
ize
_v
<
std
::
remove_reference_t
<
Tuple
>>>
{});
}
template
<
class
F
,
class
...
Args
>
constexpr
decltype
(
auto
)
apply_variadic
(
F
&&
f
,
Args
&&
...
args
)
template
<
class
F
unctor
,
class
...
Args
>
constexpr
decltype
(
auto
)
apply_variadic
(
F
unctor
&&
f
,
Args
&&
...
args
)
{
return
apply
(
FWD
(
f
),
std
::
forward_as_tuple
(
args
...));
return
apply
(
FWD
(
f
),
std
::
forward_as_tuple
(
args
...));
}
template
<
class
F
,
std
::
size_t
N
>
constexpr
decltype
(
auto
)
apply_indices
(
F
&&
f
,
index_t
<
N
>
)
template
<
class
F
unctor
,
std
::
size_t
N
>
constexpr
decltype
(
auto
)
apply_indices
(
F
unctor
&&
f
,
index_t
<
N
>
)
{
return
Impl_
::
apply_indices_impl
(
FWD
(
f
),
index_t
<
0
>
{},
std
::
make_index_sequence
<
N
>
{});
}
template
<
class
F
,
std
::
size_t
I0
,
std
::
size_t
I1
>
constexpr
decltype
(
auto
)
apply_indices
(
F
&&
f
,
index_t
<
I0
>
,
index_t
<
I1
>
)
template
<
class
F
unctor
,
std
::
size_t
I0
,
std
::
size_t
I1
>
constexpr
decltype
(
auto
)
apply_indices
(
F
unctor
&&
f
,
index_t
<
I0
>
,
index_t
<
I1
>
)
{
return
Impl_
::
apply_indices_impl
(
FWD
(
f
),
index_t
<
I0
>
{},
std
::
make_index_sequence
<
I1
-
I0
>
{});
...
...
src/amdis/common/CMakeLists.txt
View file @
947d788f
...
...
@@ -12,12 +12,15 @@ install(FILES
FieldMatVec.hpp
FieldMatVec.inc.hpp
Filesystem.hpp
ForEach.hpp
Index.hpp
Literals.hpp
Logical.hpp
Loops.hpp
Math.hpp
Mpl.hpp
MultiTypeMatrix.hpp
MultiTypeVector.hpp
Range.hpp
StaticSize.hpp
String.hpp
Tags.hpp
...
...
src/amdis/common/Concepts.hpp
View file @
947d788f
...
...
@@ -5,7 +5,7 @@
#include <dune/functions/common/functionconcepts.hh>
#include <amdis/common/ConceptsBase.hpp>
#include <amdis/common/
Mp
l.hpp>
#include <amdis/common/
Logica
l.hpp>
#include <amdis/common/TypeTraits.hpp>
namespace
AMDiS
...
...
@@ -33,6 +33,18 @@ namespace AMDiS
struct
IsSimilar
<
Types
<
A0
,
As
...
>
,
Types
<
B0
,
Bs
...
>>
:
and_t
<
IsSimilar
<
A0
,
B0
>::
value
,
IsSimilar
<
Types
<
As
...
>
,
Types
<
Bs
...
>>::
value
>
{};
template
<
class
...
Ts
>
struct
IsSame
;
template
<
class
T0
,
class
...
Ts
>
struct
IsSame
<
T0
,
Ts
...
>
:
std
::
is_same
<
Types
<
T0
,
Ts
...
>
,
Types
<
Ts
...,
T0
>>
{};
template
<
>
struct
IsSame
<>
:
std
::
true_type
{};
template
<
class
T
>
struct
IsReferenceWrapper
:
std
::
false_type
{};
...
...
@@ -71,6 +83,9 @@ namespace AMDiS
}
// end namespace Definition
#endif // DOXYGEN
/// Types are the same
template
<
class
...
Ts
>
constexpr
bool
Same
=
Traits
::
IsSame
<
Ts
...
>::
value
;
/// Types are the same, up to decay of qualifiers
template
<
class
A
,
class
B
>
...
...
src/amdis/common/ForEach.hpp
0 → 100644
View file @
947d788f
#pragma once
#include <initializer_list>
#include <amdis/common/Apply.hpp>
#include <amdis/common/Index.hpp>
#include <amdis/common/Range.hpp>
namespace
AMDiS
{
namespace
Tools
{
namespace
Impl_
{
template
<
class
T
>
void
ignored_evaluation
(
std
::
initializer_list
<
T
>&&
)
{
/* do nothing */
}
}
template
<
class
Tuple
,
class
Functor
>
constexpr
void
for_each
(
Tuple
&&
tuple
,
Functor
&&
f
)
{
#if AMDIS_HAS_CXX_FOLD_EXPRESSIONS
Tools
::
apply
([
f
=
std
::
move
(
f
)](
auto
&&
...
t
)
{
(
f
(
FWD
(
t
)),...);
},
tuple
);
#else
Tools
::
apply
([
f
=
std
::
move
(
f
)](
auto
&&
...
t
)
{
Impl_
::
ignored_evaluation
<
int
>
({
0
,
(
f
(
FWD
(
t
)),
0
)...});
},
tuple
);
#endif
}
template
<
std
::
size_t
I0
,
std
::
size_t
I1
,
class
Functor
>
constexpr
void
for_range
(
index_t
<
I0
>
i0
,
index_t
<
I1
>
i1
,
Functor
&&
f
)
{
Tools
::
for_each
(
range_t
<
I0
,
I1
>
{},
FWD
(
f
));
}
template
<
std
::
size_t
N
,
class
Functor
>
constexpr
void
for_range
(
index_t
<
N
>
,
Functor
&&
f
)
{
Tools
::
for_each
(
range_t
<
0
,
N
>
{},
FWD
(
f
));
}
template
<
std
::
size_t
I0
,
std
::
size_t
I1
,
class
Functor
>
constexpr
void
for_range
(
Functor
&&
f
)
{
Tools
::
for_each
(
range_t
<
I0
,
I1
>
{},
FWD
(
f
));
}
}
// end namespace Tools
}
// end namespace AMDiS
src/amdis/common/Index.hpp
0 → 100644
View file @
947d788f
#pragma once
// std c++ headers
#include <tuple>
#include <type_traits>
#include <utility>
namespace
AMDiS
{
// introduce some shortcuts for integral constants
// ---------------------------------------------------------------------------
/// A wrapper for int type
template
<
int
I
>
using
int_t
=
std
::
integral_constant
<
int
,
I
>
;
/// Variable template to generate int-type
template
<
int
I
>
constexpr
int_t
<
I
>
int_
=
{};
/// class that represents a sequence of integers
template
<
int
...
I
>
using
Ints
=
std
::
integer_sequence
<
int
,
I
...
>
;
template
<
std
::
size_t
I
,
int
...
J
>
auto
get
(
Ints
<
J
...
>
)
{
return
std
::
get
<
I
>
(
std
::
make_tuple
(
int_
<
J
>
...));
}
/// A wrapper for std::size_t type
template
<
std
::
size_t
I
>
using
index_t
=
std
::
integral_constant
<
std
::
size_t
,
I
>
;
/// Variable template to generate std::size_t-type
template
<
std
::
size_t
I
>
constexpr
index_t
<
I
>
index_
=
{};
/// class that represents a sequence of indices
template
<
std
::
size_t
...
I
>
using
Indices
=
std
::
index_sequence
<
I
...
>
;
template
<
std
::
size_t
I
,
std
::
size_t
...
J
>
auto
get
(
Indices
<
J
...
>
)
{
return
std
::
get
<
I
>
(
std
::
make_tuple
(
index_
<
J
>
...));
}
}
// end namespace AMDiS
src/amdis/common/
Mp
l.hpp
→
src/amdis/common/
Logica
l.hpp
View file @
947d788f
...
...
@@ -7,42 +7,6 @@
namespace
AMDiS
{
// introduce some shortcuts for integral constants
// ---------------------------------------------------------------------------
/// A wrapper for int type
template
<
int
I
>
using
int_t
=
std
::
integral_constant
<
int
,
I
>
;
/// Variable template to generate int-type
template
<
int
I
>
constexpr
int_t
<
I
>
int_
=
{};
/// class that represents a sequence of integers
template
<
int
...
I
>
using
Ints
=
std
::
integer_sequence
<
int
,
I
...
>
;
template
<
std
::
size_t
I
,
int
...
J
>
auto
get
(
Ints
<
J
...
>
)
{
return
std
::
get
<
I
>
(
std
::
make_tuple
(
int_
<
J
>
...));
}
/// A wrapper for std::size_t type
template
<
std
::
size_t
I
>
using
index_t
=
std
::
integral_constant
<
std
::
size_t
,
I
>
;
/// Variable template to generate std::size_t-type
template
<
std
::
size_t
I
>
constexpr
index_t
<
I
>
index_
=
{};
/// class that represents a sequence of indices
template
<
std
::
size_t
...
I
>
using
Indices
=
std
::
index_sequence
<
I
...
>
;
template
<
std
::
size_t
I
,
std
::
size_t
...
J
>
auto
get
(
Indices
<
J
...
>
)
{
return
std
::
get
<
I
>
(
std
::
make_tuple
(
index_
<
J
>
...));
}
/// A wrapper for bool types
template
<
bool
B
>
using
bool_t
=
std
::
integral_constant
<
bool
,
B
>
;
...
...
@@ -51,47 +15,6 @@ namespace AMDiS
template
<
bool
B
>
constexpr
bool_t
<
B
>
bool_
=
{};
namespace
Impl
{
/// A range of indices [I,J)
template
<
class
Int
,
Int
I
,
Int
J
>
struct
range_impl
{
using
type
=
range_impl
;
/// Return the first element in the range
static
constexpr
auto
begin
()
{
return
std
::
integral_constant
<
Int
,
I
>
{};
}
/// Returns the element after the last element in the range
static
constexpr
auto
end
()
{
return
std
::
integral_constant
<
Int
,
J
>
{};
}
/// Returns the ith index in the range as integral constant
template
<
std
::
size_t
i
>
constexpr
auto
operator
[](
index_t
<
i
>
)
const
{
return
std
::
integral_constant
<
Int
,
I
+
Int
(
i
)
>
{};
}
/// Return whether the range is empty
static
constexpr
bool
empty
()
{
return
I
>=
J
;
}
/// Returns the size of the range
static
constexpr
auto
size
()
{
return
std
::
integral_constant
<
Int
,
J
-
I
>
{};
}
};
/// Extracts the Ith element element from the range
template
<
std
::
size_t
I
,
class
Int
,
Int
begin
,
Int
end
>
constexpr
auto
get
(
range_impl
<
Int
,
begin
,
end
>
const
&
r
)
{
return
r
[
index_
<
I
>
];
}
}
// end namespace Impl
template
<
std
::
size_t
I
,
std
::
size_t
J
>
using
range_t
=
Impl
::
range_impl
<
std
::
size_t
,
I
,
J
>
;
template
<
std
::
size_t
I
,
std
::
size_t
J
>
constexpr
range_t
<
I
,
J
>
range_
=
{};
// some boolean operations
// ---------------------------------------------------------------------------
...
...
@@ -163,17 +86,6 @@ namespace AMDiS
template
<
class
T
>
struct
IsEqualImpl
<
T
>
{
enum
{
value
=
true
};
};
template
<
class
...
Ts
>
struct
IsSameImpl
;
template
<
class
T0
,
class
...
Ts
>
struct
IsSameImpl
<
T0
,
Ts
...
>
:
public
std
::
is_same
<
std
::
tuple
<
T0
,
Ts
...
>
,
std
::
tuple
<
Ts
...,
T0
>>
{};
template
<
>
struct
IsSameImpl
<>
{
enum
{
value
=
true
};
};
}
// end namespace Impl
template
<
class
T
,
T
...
values
>
...
...
@@ -182,7 +94,4 @@ namespace AMDiS
template
<
class
T
,
class
...
Ts
>
using
is_one_of
=
or_t
<
std
::
is_same
<
T
,
Ts
>::
value
...
>
;
template
<
class
...
Ts
>
using
IsSame
=
Impl
::
IsSameImpl
<
Ts
...
>
;
}
// end namespace AMDiS
src/amdis/common/Loops.hpp
deleted
100644 → 0
View file @
138c15d3
#pragma once
#include <dune/common/hybridutilities.hh>
#include <dune/common/rangeutilities.hh>
namespace
AMDiS
{
using
Dune
::
Hybrid
::
forEach
;
}
// end namespace AMDiS
src/amdis/common/MultiTypeMatrix.hpp
View file @
947d788f
...
...
@@ -6,10 +6,11 @@
#include <dune/common/ftraits.hh>
#include <amdis/common/Concepts.hpp>
#include <amdis/common/Loops.hpp>
#include <amdis/common/ForEach.hpp>
#include <amdis/common/Index.hpp>
#include <amdis/common/Math.hpp>
#include <amdis/common/Mpl.hpp>
#include <amdis/common/MultiTypeVector.hpp>
#include <amdis/common/Range.hpp>
#include <amdis/common/StaticSize.hpp>
#include <amdis/common/TypeTraits.hpp>
#include <amdis/typetree/MultiIndex.hpp>
...
...
@@ -71,35 +72,35 @@ namespace AMDiS
/// Assignment of real number to all tuple elements
MultiTypeMatrix
&
operator
=
(
real_type
value
)
{
for
E
ach
(
*
this
,
[
value
](
auto
&
fv
)
{
fv
=
value
;
});
Tools
::
for
_e
ach
(
*
this
,
[
value
](
auto
&
fv
)
{
fv
=
value
;
});
return
*
this
;
}
// Compound assignment operator +=
MultiTypeMatrix
&
operator
+=
(
MultiTypeMatrix
const
&
that
)
{
forEach
(
range
_
<
0
,
rows
>
,
[
&
that
,
this
](
auto
const
_i
)
{
(
*
this
)[
_i
]
+=
that
[
_i
];
});
Tools
::
for_
range
<
0
,
rows
>
(
[
&
that
,
this
](
auto
const
_i
)
{
(
*
this
)[
_i
]
+=
that
[
_i
];
});
return
*
this
;
}
// Compound assignment operator -=
MultiTypeMatrix
&
operator
-=
(
MultiTypeMatrix
const
&
that
)
{
forEach
(
range
_
<
0
,
rows
>
,
[
&
that
,
this
](
auto
const
_i
)
{
(
*
this
)[
_i
]
-=
that
[
_i
];
});
Tools
::
for_
range
<
0
,
rows
>
(
[
&
that
,
this
](
auto
const
_i
)
{
(
*
this
)[
_i
]
-=
that
[
_i
];
});
return
*
this
;
}
// Scaling of all tuple elements by a constant value
MultiTypeMatrix
&
operator
*=
(
real_type
value
)
{
for
E
ach
(
*
this
,
[
value
](
auto
&
fv
)
{
fv
*=
value
;
});
Tools
::
for
_e
ach
(
*
this
,
[
value
](
auto
&
fv
)
{
fv
*=
value
;
});
return
*
this
;
}
// Scaling of all tuple elements by the inverse of a constant value
MultiTypeMatrix
&
operator
/=
(
real_type
value
)
{
for
E
ach
(
*
this
,
[
value
](
auto
&
fv
)
{
fv
/=
value
;
});
Tools
::
for
_e
ach
(
*
this
,
[
value
](
auto
&
fv
)
{
fv
/=
value
;
});
return
*
this
;
}
...
...
@@ -150,4 +151,15 @@ namespace AMDiS
}
};
namespace
Impl
{
template
<
class
...
Rows
>
struct
RowsImpl
<
MultiTypeMatrix
<
Rows
...
>>
:
std
::
integral_constant
<
std
::
size_t
,
sizeof
...(
Rows
)
>
{};
template
<
class
Row0
,
class
...
Rows
>
struct
ColsImpl
<
MultiTypeMatrix
<
Row0
,
Rows
...
>>
:
SizeImpl
<
Row0
>
{};
}
}
// end namespace AMDiS
src/amdis/common/MultiTypeVector.hpp
View file @
947d788f
...
...
@@ -7,8 +7,9 @@
#include <dune/functions/common/indexaccess.hh>
#include <amdis/common/Concepts.hpp>
#include <amdis/common/Loops.hpp>
#include <amdis/common/Mpl.hpp>
#include <amdis/common/ForEach.hpp>
#include <amdis/common/Index.hpp>
#include <amdis/common/Range.hpp>
#include <amdis/common/StaticSize.hpp>
#include <amdis/common/TypeTraits.hpp>
...
...
@@ -64,35 +65,35 @@ namespace AMDiS
/// Assignment of real number to all tuple elements
MultiTypeVector
&
operator
=
(
real_type
value
)
{
for
E
ach
(
*
this
,
[
value
](
auto
&
fv
)
{
fv
=
value
;
});
Tools
::
for
_e
ach
(
*
this
,
[
value
](
auto
&
fv
)
{
fv
=
value
;
});
return
*
this
;
}
// Compound assignment operator +=
MultiTypeVector
&
operator
+=
(
MultiTypeVector
const
&
that
)
{
forEach
(
range
_
<
0
,
dimension
>
,
[
&
that
,
this
](
auto
const
_i
)
{
(
*
this
)[
_i
]
+=
that
[
_i
];
});
Tools
::
for_
range
<
0
,
dimension
>
(
[
&
that
,
this
](
auto
const
_i
)
{
(
*
this
)[
_i
]
+=
that
[
_i
];
});
return
*
this
;
}
// Compound assignment operator -=
MultiTypeVector
&
operator
-=
(
MultiTypeVector
const
&
that
)
{
forEach
(
range
_
<
0
,
dimension
>
,
[
&
that
,
this
](
auto
const
_i
)
{
(
*
this
)[
_i
]
-=
that
[
_i
];
});
Tools
::
for_
range
<
0
,
dimension
>
(
[
&
that
,
this
](
auto
const
_i
)
{
(
*
this
)[
_i
]
-=
that
[
_i
];
});
return
*
this
;
}
// Scaling of all tuple elements by a constant value
MultiTypeVector
&
operator
*=
(
real_type
value
)
{
for
E
ach
(
*
this
,
[
value
](
auto
&
fv
)
{
fv
*=
value
;
});
Tools
::
for
_e
ach
(
*
this
,
[
value
](
auto
&
fv
)
{
fv
*=
value
;
});
return
*
this
;
}
// Scaling of all tuple elements by the inverse of a constant value
MultiTypeVector
&
operator
/=
(
real_type
value
)
{
for
E
ach
(
*
this
,
[
value
](
auto
&
fv
)
{
fv
/=
value
;
});
Tools
::
for
_e
ach
(
*
this
,
[
value
](
auto
&
fv
)
{
fv
/=
value
;
});
return
*
this
;
}
...
...
@@ -133,4 +134,11 @@ namespace AMDiS
}
};
namespace
Impl
{
template
<
class
...
Ts
>
struct
SizeImpl
<
MultiTypeVector
<
Ts
...
>>
:
std
::
integral_constant
<
std
::
size_t
,
sizeof
...(
Ts
)
>
{};
}
}
// end namespace AMDiS
src/amdis/common/Range.hpp
0 → 100644
View file @
947d788f
#pragma once
#include <type_traits>
#include <amdis/common/Index.hpp>
#include <amdis/common/StaticSize.hpp>
namespace
AMDiS
{
namespace
Impl
{
/// A range of indices [I,J)
template
<
class
Int
,
Int
I
,
Int
J
>
struct
range_impl
{
using
type
=
range_impl
;
/// Return the first element in the range
static
constexpr
auto
begin
()
{
return
std
::
integral_constant
<
Int
,
I
>
{};
}
/// Returns the element after the last element in the range
static
constexpr
auto
end
()
{
return
std
::
integral_constant
<
Int
,
J
>
{};
}
/// Returns the ith index in the range as integral constant
template
<
std
::
size_t
i
>
constexpr
auto
operator
[](
index_t
<
i
>
)
const
{
return
std
::
integral_constant
<
Int
,
I
+
Int
(
i
)
>
{};
}
/// Return whether the range is empty
static
constexpr
bool
empty
()
{
return
I
>=
J
;
}
/// Returns the size of the range
static
constexpr
auto
size
()
{
return
std
::
integral_constant
<
Int
,
J
-
I
>
{};
}
};
/// Extracts the Ith element element from the range
template
<
std
::
size_t
I
,
class
Int
,
Int
begin
,
Int
end
>
constexpr
auto
get
(
range_impl
<
Int
,
begin
,
end
>
const
&
r
)
{
return
r
[
index_
<
I
>
];
}
/// Return the size of the range
template
<
class
Int
,
Int
I
,
Int
J
>
struct
SizeImpl
<
range_impl
<
Int
,
I
,
J
>>
:
std
::
integral_constant
<
std
::
size_t
,
std
::
size_t
(
J
-
I
)
>
{};
}
// end namespace Impl
template
<
std
::
size_t
I
,
std
::
size_t
J
>
using
range_t
=
Impl
::
range_impl
<
std
::
size_t
,
I
,
J
>
;
template
<
std
::
size_t
I
,
std
::
size_t
J
>
constexpr
range_t
<
I
,
J
>
range_
=
{};
}
// end namespace AMDiS
namespace
std
{
template
<
class
Int
,
Int
I0
,
Int
I1
>
struct
tuple_size
<
AMDiS
::
Impl
::
range_impl
<
Int
,
I0
,
I1
>>
:
std
::
integral_constant
<
std
::
size_t
,
std
::
size_t
(
I1
-
I0
)
>
{};
template
<
std
::
size_t
I
,
class
Int
,
Int
I0
,
Int
I1
>
struct
tuple_element
<
I
,
AMDiS
::
Impl
::
range_impl
<
Int
,
I0
,
I1
>>
{
using
type
=
Int
;
};
}
// end namespace std
src/amdis/common/StaticSize.hpp
View file @
947d788f
...
...
@@ -4,6 +4,8 @@
#include <tuple>
#include <type_traits>
#include <amdis/common/TypeTraits.hpp>
namespace
Dune
{
// forward declarations
...
...
@@ -25,14 +27,6 @@ namespace Dune
namespace
AMDiS
{
// forward declarations
template
<
class
...
Rows
>
class
MultiTypeMatrix
;
template
<
class
...
Ts
>
class
MultiTypeVector
;
namespace
Impl
{
template
<
class
Tuple
,
class
=
void
>
...
...
@@ -58,10 +52,6 @@ namespace AMDiS
struct
SizeImpl
<
Dune
::
FieldMatrix
<
T
,
N
,
M
>>
:
std
::
integral_constant
<
std
::
size_t
,
N
*
M
>
{};