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
09aba8bc
Commit
09aba8bc
authored
Sep 23, 2019
by
Praetorius, Simon
Browse files
Merge branch 'feature/alltruebitsetvector' into 'master'
Added extended AllTrueBitSetVector class See merge request
!100
parents
fda1afdb
aa317187
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/amdis/functions/Interpolate.hpp
View file @
09aba8bc
...
...
@@ -13,6 +13,7 @@
#include
<amdis/common/Logical.hpp>
#include
<amdis/functions/HierarchicNodeToRangeMap.hpp>
#include
<amdis/typetree/Traversal.hpp>
#include
<amdis/utility/AllTrueBitSetVector.hpp>
namespace
AMDiS
{
namespace
Impl
{
...
...
@@ -270,7 +271,7 @@ template <class B, class... I, class Vec, class C, class GF, class NTRE, bool av
void
interpolateTree
(
B
const
&
basis
,
Dune
::
TypeTree
::
HybridTreePath
<
I
...
>
const
&
treePath
,
Vec
&
vec
,
C
&
count
,
GF
const
&
gf
,
NTRE
const
&
nodeToRangeEntry
,
bool_t
<
average
>
)
{
auto
bitVec
=
Dune
::
Functions
::
Imp
::
AllTrueBitSetVector
()
;
auto
bitVec
=
AllTrueBitSetVector
{}
;
AMDiS
::
interpolateTreeSubset
(
basis
,
treePath
,
vec
,
count
,
bitVec
,
gf
,
nodeToRangeEntry
,
bool_t
<
average
>
{});
}
...
...
@@ -281,7 +282,7 @@ template <class B, class... I, class Vec, class C, class GF, bool average,
void
interpolateTree
(
B
const
&
basis
,
Dune
::
TypeTree
::
HybridTreePath
<
I
...
>
const
&
treePath
,
Vec
&
vec
,
C
&
count
,
GF
const
&
gf
,
bool_t
<
average
>
)
{
auto
bitVec
=
Dune
::
Functions
::
Imp
::
AllTrueBitSetVector
()
;
auto
bitVec
=
AllTrueBitSetVector
{}
;
auto
ntrm
=
AMDiS
::
HierarchicNodeToRangeMap
();
AMDiS
::
interpolateTreeSubset
(
basis
,
treePath
,
vec
,
count
,
bitVec
,
gf
,
ntrm
,
bool_t
<
average
>
{});
}
...
...
@@ -366,7 +367,7 @@ template <class B, class Vec, class C, class GF, bool average,
void
interpolate
(
B
const
&
basis
,
Vec
&
vec
,
C
&
count
,
GF
const
&
gf
,
bool_t
<
average
>
)
{
auto
root
=
Dune
::
TypeTree
::
hybridTreePath
();
auto
bitVec
=
Dune
::
Functions
::
Imp
::
AllTrueBitSetVector
()
;
auto
bitVec
=
AllTrueBitSetVector
{}
;
AMDiS
::
interpolateFiltered
(
basis
,
root
,
vec
,
count
,
bitVec
,
gf
,
bool_t
<
average
>
{});
}
...
...
@@ -377,7 +378,7 @@ template <class B, class... I, class Vec, class GF,
void
interpolate
(
B
const
&
basis
,
Vec
&
vec
,
GF
const
&
gf
)
{
auto
root
=
Dune
::
TypeTree
::
hybridTreePath
();
auto
bitVec
=
Dune
::
Functions
::
Imp
::
AllTrueBitSetVector
()
;
auto
bitVec
=
AllTrueBitSetVector
{}
;
auto
count
=
Impl
::
FakeCounter
();
AMDiS
::
interpolateFiltered
(
basis
,
root
,
vec
,
count
,
bitVec
,
gf
,
std
::
false_type
{});
}
...
...
@@ -405,7 +406,7 @@ template <class B, class... I, class Vec, class C, class GF, bool average,
void
interpolate
(
B
const
&
basis
,
Dune
::
TypeTree
::
HybridTreePath
<
I
...
>
const
&
treePath
,
Vec
&
vec
,
C
&
count
,
GF
const
&
gf
,
bool_t
<
average
>
)
{
auto
bitVec
=
Dune
::
Functions
::
Imp
::
AllTrueBitSetVector
()
;
auto
bitVec
=
AllTrueBitSetVector
{}
;
AMDiS
::
interpolateFiltered
(
basis
,
treePath
,
vec
,
count
,
bitVec
,
gf
,
bool_t
<
average
>
{});
}
...
...
@@ -414,7 +415,7 @@ template <class B, class... I, class Vec, class GF,
REQUIRES
(
Concepts
::
GridFunction
<
GF
>
)
>
void
interpolate
(
B
const
&
basis
,
Dune
::
TypeTree
::
HybridTreePath
<
I
...
>
const
&
treePath
,
Vec
&
vec
,
GF
const
&
gf
)
{
auto
bitVec
=
Dune
::
Functions
::
Imp
::
AllTrueBitSetVector
()
;
auto
bitVec
=
AllTrueBitSetVector
{}
;
auto
count
=
Impl
::
FakeCounter
();
AMDiS
::
interpolateFiltered
(
basis
,
treePath
,
vec
,
count
,
bitVec
,
gf
,
std
::
false_type
{});
}
...
...
src/amdis/utility/AllTrueBitSetVector.hpp
0 → 100644
View file @
09aba8bc
#pragma once
#include
<cstddef>
#include
<iterator>
namespace
AMDiS
{
/// \brief Vector-like container of bools returning always true.
/**
* Model of an infinite range of bools of value `true` with vector-like element
* access by `operator[]`.
**/
class
AllTrueBitSetVector
{
public:
using
value_type
=
bool
;
struct
const_iterator
{
using
value_type
=
bool
;
using
reference
=
bool
;
using
difference_type
=
std
::
ptrdiff_t
;
using
iterator_category
=
std
::
forward_iterator_tag
;
constexpr
bool
operator
*
()
const
noexcept
{
return
true
;
}
constexpr
const_iterator
&
operator
++
()
noexcept
{
return
*
this
;
}
constexpr
const_iterator
operator
++
(
int
)
noexcept
{
return
*
this
;
}
/// Comparison of the iterator is always true
constexpr
bool
operator
==
(
const_iterator
)
const
noexcept
{
return
true
;
}
constexpr
bool
operator
!=
(
const_iterator
)
const
noexcept
{
return
false
;
}
};
/// Constexpr default constructor
constexpr
AllTrueBitSetVector
()
noexcept
=
default
;
public:
// element access
/// Converting to true
constexpr
operator
bool
()
const
noexcept
{
return
true
;
}
/// Access to any element of the container returns always true.
template
<
class
Index
>
constexpr
AllTrueBitSetVector
const
&
at
(
Index
const
&
/*index*/
)
const
noexcept
{
return
*
this
;
}
/// Access to any element of the container returns always true.
template
<
class
Index
>
constexpr
AllTrueBitSetVector
const
&
operator
[](
Index
const
&
/*index*/
)
const
noexcept
{
return
*
this
;
}
/// Access the front element of the infinite range
constexpr
AllTrueBitSetVector
const
&
front
()
const
noexcept
{
return
*
this
;
}
public:
// iterators
/// Return iterator that always redirects to a bool true.
constexpr
const_iterator
begin
()
const
noexcept
{
return
const_iterator
{};
}
/// Return iterator that always redirects to a bool true.
constexpr
const_iterator
cbegin
()
const
noexcept
{
return
const_iterator
{};
}
public:
// capacity and modifier
/// Resize does nothing
template
<
class
Size
>
constexpr
void
resize
(
Size
const
&
/*size*/
)
const
noexcept
{
/* do nothing */
}
/// The container is always non-empty
constexpr
bool
empty
()
const
noexcept
{
return
false
;
}
};
}
// end namespace AMDiS
test/AllTrueBitSetVectorTest.cpp
0 → 100644
View file @
09aba8bc
#include
<type_traits>
#include
<amdis/utility/AllTrueBitSetVector.hpp>
#include
"Tests.hpp"
using
namespace
AMDiS
;
int
main
(
int
argc
,
char
**
argv
)
{
constexpr
auto
bitSet
=
AllTrueBitSetVector
{};
// The bitset is not empty
AMDIS_TEST
(
!
bitSet
.
empty
());
// All entries are true
std
::
size_t
i
=
0
;
for
(
auto
it
=
bitSet
.
begin
();
i
<
10
;
++
it
,
++
i
)
AMDIS_TEST
(
*
it
);
for
(
i
=
0
;
i
<
10
;
++
i
)
{
AMDIS_TEST
(
bitSet
[
i
]);
AMDIS_TEST
(
bitSet
.
at
(
i
));
}
// The front entry is true
AMDIS_TEST
(
bitSet
.
front
());
// resize has not effect
bitSet
.
resize
(
0
);
AMDIS_TEST
(
!
bitSet
.
empty
());
// use bitset element as template parameter
auto
iconst
=
std
::
integral_constant
<
bool
,
bitSet
[
0
]
>
{};
return
report_errors
();
}
test/CMakeLists.txt
View file @
09aba8bc
...
...
@@ -5,6 +5,9 @@ dune_add_test(SOURCES AccessTest.cpp
dune_add_test
(
SOURCES AdaptInfoTest.cpp
LINK_LIBRARIES amdis
)
dune_add_test
(
SOURCES AllTrueBitSetVectorTest.cpp
LINK_LIBRARIES amdis
)
foreach
(
_GRID RANGE 7
)
dune_add_test
(
NAME
"BackupRestoreTest_
${
_GRID
}
"
SOURCES BackupRestoreTest.cpp
...
...
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