Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Praetorius, Simon
dune-multimesh
Commits
d6b07d78
Commit
d6b07d78
authored
Jun 28, 2018
by
Praetorius, Simon
Browse files
Options
Browse Files
Download
Plain Diff
resolved a merge conflict
parents
42349adf
f1028dc2
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
625 additions
and
80 deletions
+625
-80
cmake/modules/CMakeLists.txt
cmake/modules/CMakeLists.txt
+4
-3
cmake/modules/CXXFeatures.cmake
cmake/modules/CXXFeatures.cmake
+13
-0
cmake/modules/DuneMultimeshMacros.cmake
cmake/modules/DuneMultimeshMacros.cmake
+2
-0
config.h.cmake
config.h.cmake
+3
-0
dune/multimesh/mmentity.hh
dune/multimesh/mmentity.hh
+10
-13
dune/multimesh/mmgeometry.hh
dune/multimesh/mmgeometry.hh
+7
-7
dune/multimesh/mmiterator.hh
dune/multimesh/mmiterator.hh
+114
-34
dune/multimesh/multigridview.hh
dune/multimesh/multigridview.hh
+208
-0
dune/multimesh/multiindexset.hh
dune/multimesh/multiindexset.hh
+113
-0
dune/multimesh/multimesh.hh
dune/multimesh/multimesh.hh
+6
-6
dune/multimesh/utility/structuredgridbuilder.hh
dune/multimesh/utility/structuredgridbuilder.hh
+6
-10
src/CMakeLists.txt
src/CMakeLists.txt
+2
-0
src/localrefinement.cc
src/localrefinement.cc
+2
-2
src/multigridview.cc
src/multigridview.cc
+75
-0
src/testiterator.cc
src/testiterator.cc
+2
-2
src/uggrid.cc
src/uggrid.cc
+2
-1
test/CMakeLists.txt
test/CMakeLists.txt
+2
-1
test/testgridviews.cc
test/testgridviews.cc
+53
-0
test/testvolume.cc
test/testvolume.cc
+1
-1
No files found.
cmake/modules/CMakeLists.txt
View file @
d6b07d78
set
(
modules
"DuneMultimeshMacros.cmake"
)
install
(
FILES
DuneMultimeshMacros.cmake
install
(
FILES
${
modules
}
DESTINATION
${
DUNE_INSTALL_MODULEDIR
}
)
CXXFeatures.cmake
DESTINATION
${
DUNE_INSTALL_MODULEDIR
}
)
cmake/modules/CXXFeatures.cmake
0 → 100644
View file @
d6b07d78
include
(
CheckCXXSourceCompiles
)
# support for C++17's variant implementation
check_cxx_source_compiles
(
"
#include <variant>
int main()
{
std::variant<int,double> a;
a = 1;
a = 2.0;
bool positive = std::visit([](auto&& x) { return x > 0; }, a);
}
"
DUNE_HAVE_CXX_VARIANT
)
cmake/modules/DuneMultimeshMacros.cmake
View file @
d6b07d78
# File for module specific CMake tests.
# File for module specific CMake tests.
include
(
CXXFeatures
)
config.h.cmake
View file @
d6b07d78
...
@@ -40,6 +40,9 @@
...
@@ -40,6 +40,9 @@
/* Define to the revision of dune-multimesh */
/* Define to the revision of dune-multimesh */
#define DUNE_MULTIMESH_VERSION_REVISION @DUNE_MULTIMESH_VERSION_REVISION@
#define DUNE_MULTIMESH_VERSION_REVISION @DUNE_MULTIMESH_VERSION_REVISION@
/* some detected compiler features may be used in this module */
#cmakedefine DUNE_HAVE_CXX_VARIANT 1
/* end dune-multimesh
/* end dune-multimesh
Everything below here will be overwritten
Everything below here will be overwritten
*/
*/
dune/multimesh/mmentity.hh
View file @
d6b07d78
...
@@ -12,23 +12,23 @@
...
@@ -12,23 +12,23 @@
namespace
Dune
namespace
Dune
{
{
template
<
class
Grid
Imp
>
template
<
class
Host
Grid
>
class
MultiEntity
class
MultiEntity
:
public
std
::
vector
<
typename
GridImp
::
HostGrid
Type
::
Traits
::
template
Codim
<
0
>
::
Entity
>
:
public
std
::
vector
<
typename
HostGrid
::
Traits
::
template
Codim
<
0
>
::
Entity
>
{
{
private:
private:
using
ctype
=
typename
Grid
Imp
::
ctype
;
using
ctype
=
typename
Host
Grid
::
ctype
;
public:
public:
enum
{
dimension
=
Grid
Imp
::
dimension
};
enum
{
dimension
=
Host
Grid
::
dimension
};
/// The type of a local geometry
/// The type of a local geometry
using
LocalGeometry
=
Dune
::
Geometry
<
dimension
,
dimension
,
con
st
Grid
Imp
,
MultiMeshLocalGeometry
>
;
using
LocalGeometry
=
MultiMeshLocal
Geometry
<
dimension
,
dimension
,
Ho
stGrid
>
;
using
EntitySeed
=
typename
GridImp
::
Traits
::
template
Codim
<
0
>
::
EntitySeed
;
using
EntitySeed
=
MultiMeshEntitySeed
<
0
,
HostGrid
>
;
/// Entity in the host grid
/// Entity in the host grid
using
HostGridEntity
=
typename
GridImp
::
HostGrid
Type
::
Traits
::
template
Codim
<
0
>
::
Entity
;
using
HostGridEntity
=
typename
HostGrid
::
Traits
::
template
Codim
<
0
>
::
Entity
;
/// Containertype
/// Containertype
using
Super
=
std
::
vector
<
HostGridEntity
>
;
using
Super
=
std
::
vector
<
HostGridEntity
>
;
...
@@ -39,15 +39,13 @@ namespace Dune
...
@@ -39,15 +39,13 @@ namespace Dune
/// Return a local geometry of source in target
/// Return a local geometry of source in target
static
LocalGeometry
localGeometry
(
HostGridEntity
const
&
source
,
HostGridEntity
const
&
target
)
static
LocalGeometry
localGeometry
(
HostGridEntity
const
&
source
,
HostGridEntity
const
&
target
)
{
{
using
LocalGeometryImp
=
MultiMeshLocalGeometry
<
dimension
,
dimension
,
const
GridImp
>
;
return
{
source
,
target
};
return
LocalGeometry
{
LocalGeometryImp
{
source
,
target
}};
}
}
/// Return a local geometry of source_i'th entity in target_t'th entity
/// Return a local geometry of source_i'th entity in target_t'th entity
LocalGeometry
localGeometry
(
std
::
size_t
source_i
,
std
::
size_t
target_i
)
const
LocalGeometry
localGeometry
(
std
::
size_t
source_i
,
std
::
size_t
target_i
)
const
{
{
using
LocalGeometryImp
=
MultiMeshLocalGeometry
<
dimension
,
dimension
,
const
GridImp
>
;
return
{(
*
this
)[
source_i
],
(
*
this
)[
target_i
]};
return
LocalGeometry
{
LocalGeometryImp
{(
*
this
)[
source_i
],
(
*
this
)[
target_i
]}};
}
}
/// Return coordinate `sourceLocal` in coordinates of target entity
/// Return coordinate `sourceLocal` in coordinates of target entity
...
@@ -73,8 +71,7 @@ namespace Dune
...
@@ -73,8 +71,7 @@ namespace Dune
**/
**/
EntitySeed
seed
(
std
::
size_t
entity_i
)
const
EntitySeed
seed
(
std
::
size_t
entity_i
)
const
{
{
using
EntitySeedImp
=
MultiMeshEntitySeed
<
0
,
const
GridImp
>
;
return
{(
*
this
)[
entity_i
],
entity_i
};
return
EntitySeedImp
{(
*
this
)[
entity_i
],
entity_i
};
}
}
/// Return the entity with maximal level
/// Return the entity with maximal level
...
...
dune/multimesh/mmgeometry.hh
View file @
d6b07d78
...
@@ -9,23 +9,23 @@
...
@@ -9,23 +9,23 @@
namespace
Dune
namespace
Dune
{
{
template
<
int
mydim
,
int
coorddim
,
class
Grid
Imp
>
template
<
int
mydim
,
int
coorddim
,
class
Host
Grid
>
class
MultiMeshLocalGeometry
class
MultiMeshLocalGeometry
:
public
GeometryDefaultImplementation
<
mydim
,
coorddim
,
Grid
Imp
,
MultiMeshLocalGeometry
>
:
public
GeometryDefaultImplementation
<
mydim
,
coorddim
,
Host
Grid
,
MultiMeshLocalGeometry
>
{
{
private:
private:
using
ctype
=
typename
Grid
Imp
::
ctype
;
using
ctype
=
typename
Host
Grid
::
ctype
;
public:
public:
// The codimension of this entitypointer wrt the host grid
// The codimension of this entitypointer wrt the host grid
enum
{
codimension
=
GridImp
::
HostGrid
Type
::
dimension
-
mydim
};
enum
{
codimension
=
HostGrid
::
dimension
-
mydim
};
enum
{
dimensionworld
=
GridImp
::
HostGrid
Type
::
dimensionworld
};
enum
{
dimensionworld
=
HostGrid
::
dimensionworld
};
// select appropriate hostgrid geometry via typeswitch
// select appropriate hostgrid geometry via typeswitch
using
HostLocalGeometry
=
typename
GridImp
::
HostGrid
Type
::
Traits
::
template
Codim
<
codimension
>
::
LocalGeometry
;
using
HostLocalGeometry
=
typename
HostGrid
::
Traits
::
template
Codim
<
codimension
>
::
LocalGeometry
;
/// entity in the host grid
/// entity in the host grid
using
HostGridEntity
=
typename
GridImp
::
HostGrid
Type
::
Traits
::
template
Codim
<
codimension
>
::
Entity
;
using
HostGridEntity
=
typename
HostGrid
::
Traits
::
template
Codim
<
codimension
>
::
Entity
;
//! type of jacobian transposed
//! type of jacobian transposed
using
JacobianInverseTransposed
=
typename
HostLocalGeometry
::
JacobianInverseTransposed
;
using
JacobianInverseTransposed
=
typename
HostLocalGeometry
::
JacobianInverseTransposed
;
...
...
dune/multimesh/mmiterator.hh
View file @
d6b07d78
...
@@ -5,8 +5,10 @@
...
@@ -5,8 +5,10 @@
#include <numeric>
#include <numeric>
#include <stack>
#include <stack>
#include <variant>
#include <dune/common/iteratorfacades.hh>
#include <dune/common/iteratorfacades.hh>
#include <dune/common/std/type_traits.hh>
#include <dune/grid/common/exceptions.hh>
#include <dune/grid/common/exceptions.hh>
#include <dune/grid/common/gridenums.hh>
#include <dune/grid/common/gridenums.hh>
...
@@ -14,10 +16,15 @@
...
@@ -14,10 +16,15 @@
namespace
Dune
namespace
Dune
{
{
namespace
tag
{
struct
with_gridview
{};
}
/** \brief Iterator over all entities of a given codimension and level of a grid.
/** \brief Iterator over all entities of a given codimension and level of a grid.
* \ingroup MultiMesh
* \ingroup MultiMesh
*/
*/
template
<
int
codim
,
PartitionIteratorType
pitype
,
class
Grid
Imp
>
template
<
int
codim
,
PartitionIteratorType
pitype
,
class
Host
Grid
>
class
MultiMeshIterator
class
MultiMeshIterator
{
{
public:
public:
...
@@ -35,18 +42,20 @@ namespace Dune
...
@@ -35,18 +42,20 @@ namespace Dune
// Implemented for codim 0 entities only
// Implemented for codim 0 entities only
template
<
PartitionIteratorType
pitype
,
class
Grid
Imp
>
template
<
PartitionIteratorType
pitype
,
class
Host
Grid
>
class
MultiMeshIterator
<
0
,
pitype
,
Grid
Imp
>
class
MultiMeshIterator
<
0
,
pitype
,
Host
Grid
>
:
public
ForwardIteratorFacade
<
MultiMeshIterator
<
0
,
pitype
,
Grid
Imp
>
,
:
public
ForwardIteratorFacade
<
MultiMeshIterator
<
0
,
pitype
,
Host
Grid
>
,
MultiEntity
<
Grid
Imp
>
,
MultiEntity
<
Host
Grid
>
,
MultiEntity
<
Grid
Imp
>
const
&>
MultiEntity
<
Host
Grid
>
const
&>
{
{
private:
private:
// LevelIterator to the equivalent entity in the host grid
// LevelIterator to the equivalent entity in the host grid
using
HostGridLevelIterator
=
using
HostGridLevelIterator
=
typename
GridImp
::
HostGrid
Type
::
template
Codim
<
0
>
::
template
Partition
<
pitype
>
::
LevelIterator
;
typename
HostGrid
::
template
Codim
<
0
>
::
template
Partition
<
pitype
>
::
LevelIterator
;
using
HostEntity
=
typename
GridImp
::
HostGridType
::
template
Codim
<
0
>
::
Entity
;
using
HostEntity
=
typename
HostGrid
::
template
Codim
<
0
>
::
Entity
;
using
EntityTest
=
std
::
function
<
bool
(
HostEntity
)
>
;
struct
EntityStackEntry
struct
EntityStackEntry
{
{
...
@@ -88,21 +97,23 @@ namespace Dune
...
@@ -88,21 +97,23 @@ namespace Dune
public:
public:
/// Constructor. Stores a pointer to the grid
/// Constructor. Stores a pointer to the grid
explicit
MultiMeshIterator
(
const
GridImp
*
multiMesh
,
int
level
)
template
<
class
GridImp
>
:
multiMesh_
(
multiMesh
)
MultiMeshIterator
(
const
GridImp
*
multiMesh
,
int
level
)
,
incrementAllowed_
(
multiMesh
->
size
(),
true
)
:
incrementAllowed_
(
multiMesh
->
size
(),
true
)
,
level_
(
level
)
,
contains_
(
multiMesh
->
size
(),
EntityTest
{[
level
](
const
HostEntity
&
entity
)
{
return
entity
.
level
()
==
level
;
}})
,
maxLevel_
(
multiMesh
->
size
(),
level
)
,
multiEntity_
(
multiMesh
->
size
())
,
multiEntity_
(
multiMesh
->
size
())
{
{
for
(
auto
const
&
grid
:
multiMesh
_
->
grids_
)
{
for
(
auto
const
&
grid
:
multiMesh
->
grids_
)
{
macroIterators_
.
push_back
(
grid
->
levelGridView
(
0
).
template
begin
<
0
,
pitype
>());
macroIterators_
.
push_back
(
grid
->
levelGridView
(
0
).
template
begin
<
0
,
pitype
>());
macroEndIterators_
.
push_back
(
grid
->
levelGridView
(
0
).
template
end
<
0
,
pitype
>());
macroEndIterators_
.
push_back
(
grid
->
levelGridView
(
0
).
template
end
<
0
,
pitype
>());
}
}
// go to first leaf entity on all grids
// go to first leaf entity on all grids
entityStacks_
.
reserve
(
multiMesh_
->
size
());
entityStacks_
.
reserve
(
multiMesh
->
size
());
for
(
std
::
size_t
i
=
0
;
i
<
multiMesh_
->
size
();
++
i
)
{
for
(
std
::
size_t
i
=
0
;
i
<
multiMesh
->
size
();
++
i
)
{
entityStacks_
.
emplace_back
((
*
multiMesh_
)[
i
].
maxLevel
());
maxLevel_
[
i
]
=
(
*
multiMesh
)[
i
].
maxLevel
();
entityStacks_
.
emplace_back
((
*
multiMesh
)[
i
].
maxLevel
());
initialIncrement
(
i
);
initialIncrement
(
i
);
}
}
}
}
...
@@ -112,26 +123,84 @@ namespace Dune
...
@@ -112,26 +123,84 @@ namespace Dune
* \param multiMesh Pointer to grid instance
* \param multiMesh Pointer to grid instance
* \param endDummy Here only to distinguish it from the other constructor
* \param endDummy Here only to distinguish it from the other constructor
*/
*/
template
<
class
GridImp
>
MultiMeshIterator
(
const
GridImp
*
multiMesh
,
int
level
,
bool
endDummy
)
MultiMeshIterator
(
const
GridImp
*
multiMesh
,
int
level
,
bool
endDummy
)
:
multiMesh_
(
multiMesh
)
,
level_
(
level
)
{
{
for
(
auto
const
&
grid
:
multiMesh
_
->
grids_
)
{
for
(
auto
const
&
grid
:
multiMesh
->
grids_
)
macroIterators_
.
push_back
(
grid
->
levelGridView
(
0
).
template
end
<
0
,
pitype
>());
macroIterators_
.
push_back
(
grid
->
levelGridView
(
0
).
template
end
<
0
,
pitype
>());
macroEndIterators_
.
push_back
(
grid
->
levelGridView
(
0
).
template
end
<
0
,
pitype
>());
}
}
}
/// Constructor which create the leaf-iterator
/// Constructor which create the leaf-iterator
template
<
class
GridImp
>
MultiMeshIterator
(
const
GridImp
*
multiMesh
)
MultiMeshIterator
(
const
GridImp
*
multiMesh
)
:
MultiMeshIterator
{
multiMesh
,
-
1
}
:
MultiMeshIterator
{
multiMesh
,
-
1
}
{}
{}
/// Constructor which create the end leaf-iterator
/// Constructor which create the end leaf-iterator
template
<
class
GridImp
>
MultiMeshIterator
(
const
GridImp
*
multiMesh
,
bool
endDummy
)
MultiMeshIterator
(
const
GridImp
*
multiMesh
,
bool
endDummy
)
:
MultiMeshIterator
{
multiMesh
,
-
1
,
endDummy
}
:
MultiMeshIterator
{
multiMesh
,
-
1
,
endDummy
}
{}
{}
template
<
class
...
GridViews
,
std
::
enable_if_t
<
not
Std
::
disjunction
<
std
::
is_same
<
GridViews
,
bool
>...
>::
value
,
int
>
=
0
>
MultiMeshIterator
(
tag
::
with_gridview
,
GridViews
const
&
...
gridViews
)
:
incrementAllowed_
(
sizeof
...(
GridViews
),
true
)
,
maxLevel_
{
gridViews
.
grid
().
maxLevel
()...}
,
multiEntity_
(
sizeof
...(
GridViews
))
,
macroIterators_
{
gridViews
.
grid
().
levelGridView
(
0
).
template
begin
<
0
,
pitype
>()...}
,
macroEndIterators_
{
gridViews
.
grid
().
levelGridView
(
0
).
template
end
<
0
,
pitype
>()...}
,
entityStacks_
{
EntityStack
{
gridViews
.
grid
().
maxLevel
()}...}
{
contains_
.
reserve
(
sizeof
...(
GridViews
));
Hybrid
::
forEach
(
std
::
forward_as_tuple
(
gridViews
...),
[
this
](
auto
const
&
gv
)
{
contains_
.
emplace_back
([
gv
](
const
HostEntity
&
entity
)
{
return
gv
.
contains
(
entity
);
});
});
for
(
std
::
size_t
i
=
0
;
i
<
sizeof
...(
GridViews
);
++
i
)
initialIncrement
(
i
);
}
template
<
class
...
GridViews
>
MultiMeshIterator
(
tag
::
with_gridview
,
bool
endDummy
,
GridViews
const
&
...
gridViews
)
:
macroIterators_
{
gridViews
.
grid
().
levelGridView
(
0
).
template
end
<
0
,
pitype
>()...}
{}
#if DUNE_HAVE_CXX_VARIANT
template
<
class
...
GV
>
MultiMeshIterator
(
const
std
::
vector
<
std
::
variant
<
GV
...
>>&
gridViews
)
:
incrementAllowed_
(
gridViews
.
size
(),
true
)
,
multiEntity_
(
gridViews
.
size
())
{
contains_
.
reserve
(
gridViews
.
size
());
entityStacks_
.
reserve
(
gridViews
.
size
());
maxLevel_
.
reserve
(
gridViews
.
size
());
for
(
auto
const
&
gvs
:
gridViews
)
{
macroIterators_
.
push_back
(
std
::
visit
([](
auto
const
&
gv
)
{
return
gv
.
grid
().
levelGridView
(
0
).
template
begin
<
0
,
pitype
>();
},
gvs
));
macroEndIterators_
.
push_back
(
std
::
visit
([](
auto
const
&
gv
)
{
return
gv
.
grid
().
levelGridView
(
0
).
template
end
<
0
,
pitype
>();
},
gvs
));
contains_
.
emplace_back
(
std
::
visit
([](
auto
const
&
gv
)
{
return
EntityTest
{[
gv
](
const
HostEntity
&
entity
)
{
return
gv
.
contains
(
entity
);
}};
},
gvs
));
maxLevel_
.
push_back
(
std
::
visit
([](
auto
const
&
gv
)
{
return
gv
.
grid
().
maxLevel
();
},
gvs
));
entityStacks_
.
emplace_back
(
std
::
visit
([](
auto
const
&
gv
)
{
return
gv
.
grid
().
maxLevel
();
},
gvs
));
}
// go to first leaf entity on all grids
for
(
std
::
size_t
i
=
0
;
i
<
entityStacks_
.
size
();
++
i
)
initialIncrement
(
i
);
}
template
<
class
...
GV
>
MultiMeshIterator
(
const
std
::
vector
<
std
::
variant
<
GV
...
>>&
gridViews
,
bool
endDummy
)
{
for
(
auto
const
&
gvs
:
gridViews
)
{
macroIterators_
.
push_back
(
std
::
visit
([](
auto
const
&
gv
)
{
return
gv
.
grid
().
levelGridView
(
0
).
template
end
<
0
,
pitype
>();
},
gvs
));
}
}
#endif
/// prefix increment
/// prefix increment
void
increment
()
void
increment
()
...
@@ -146,7 +215,7 @@ namespace Dune
...
@@ -146,7 +215,7 @@ namespace Dune
}
}
/// dereferencing
/// dereferencing
MultiEntity
<
Grid
Imp
>
const
&
dereference
()
const
MultiEntity
<
Host
Grid
>
const
&
dereference
()
const
{
{
// update entries in multiEntity that have changed
// update entries in multiEntity that have changed
for
(
std
::
size_t
i
=
0
;
i
<
entityStacks_
.
size
();
++
i
)
{
for
(
std
::
size_t
i
=
0
;
i
<
entityStacks_
.
size
();
++
i
)
{
...
@@ -189,10 +258,10 @@ namespace Dune
...
@@ -189,10 +258,10 @@ namespace Dune
}
}
// 3. go down in tree until leaf entity
// 3. go down in tree until leaf entity
for
(
auto
child
=
dereference
(
i
);
!
entityTest
(
child
);
for
(
auto
child
=
dereference
(
i
);
!
entityTest
(
i
,
child
);
child
=
dereference
(
i
))
{
child
=
dereference
(
i
))
{
entityStack
.
emplace
(
child
);
entityStack
.
emplace
(
child
);
assert
(
entityStack
.
size
()
<=
(
*
multiMesh_
)[
i
].
maxLevel
()
);
assert
(
entityStack
.
size
()
<=
maxLevel
_
[
i
]
);
}
}
}
}
...
@@ -218,10 +287,10 @@ namespace Dune
...
@@ -218,10 +287,10 @@ namespace Dune
return
;
return
;
// 2. go down in tree until leaf entity
// 2. go down in tree until leaf entity
for
(
auto
child
=
dereference
(
i
);
!
entityTest
(
child
);
for
(
auto
child
=
dereference
(
i
);
!
entityTest
(
i
,
child
);
child
=
dereference
(
i
))
{
child
=
dereference
(
i
))
{
entityStack
.
emplace
(
child
);
entityStack
.
emplace
(
child
);
assert
(
entityStack
.
size
()
<=
(
*
multiMesh_
)[
i
].
maxLevel
()
);
assert
(
entityStack
.
size
()
<=
maxLevel
_
[
i
]
);
}
}
}
}
...
@@ -236,24 +305,35 @@ namespace Dune
...
@@ -236,24 +305,35 @@ namespace Dune
}
}
}
}
bool
entityTest
(
HostEntity
const
&
entity
)
bool
entityTest
(
std
::
size_t
i
,
HostEntity
const
&
entity
)
const
{
{
return
entity
.
level
()
==
level_
||
entity
.
isLeaf
()
||
!
entity
.
isRegular
();
return
contains_
[
i
](
entity
)
||
entity
.
isLeaf
()
||
!
entity
.
isRegular
();
}
}
private:
private:
const
GridImp
*
multiMesh_
;
std
::
vector
<
bool
>
incrementAllowed_
;
std
::
vector
<
EntityTest
>
contains_
;
std
::
vector
<
int
>
maxLevel_
;
mutable
MultiEntity
<
HostGrid
>
multiEntity_
;
std
::
vector
<
HostGridLevelIterator
>
macroIterators_
;
std
::
vector
<
HostGridLevelIterator
>
macroIterators_
;
std
::
vector
<
HostGridLevelIterator
>
macroEndIterators_
;
std
::
vector
<
HostGridLevelIterator
>
macroEndIterators_
;
std
::
vector
<
EntityStack
>
entityStacks_
;
std
::
vector
<
EntityStack
>
entityStacks_
;
std
::
vector
<
bool
>
incrementAllowed_
;
int
level_
=
-
1
;
mutable
MultiEntity
<
GridImp
>
multiEntity_
;
};
};
template
<
class
>
class
MultiMesh
;
template
<
class
...
GridViews
>
inline
auto
multi_elements
(
GridViews
const
&
...
gridViews
)
{
using
GridView0
=
std
::
tuple_element_t
<
0
,
std
::
tuple
<
GridViews
...
>>
;
using
Iterator
=
MultiMeshIterator
<
0
,
All_Partition
,
typename
GridView0
::
Grid
>
;
using
Range
=
IteratorRange
<
Iterator
>
;
return
Range
{
Iterator
{
tag
::
with_gridview
{},
gridViews
...},
Iterator
{
tag
::
with_gridview
{},
true
,
gridViews
...}
};
}
}
// end namespace Dune
}
// end namespace Dune
#endif // DUNE_MULTIMESH_ITERATOR_HH
#endif // DUNE_MULTIMESH_ITERATOR_HH
dune/multimesh/multigridview.hh
0 → 100644
View file @
d6b07d78
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_MULTI_GRIDVIEW_HH
#define DUNE_MULTI_GRIDVIEW_HH
#if ! DUNE_HAVE_CXX_VARIANT
#error "Require C++17 variant!"
#endif
#include <variant>
#include <dune/common/typetraits.hh>
#include <dune/common/exceptions.hh>
#include <dune/common/std/type_traits.hh>
#include <dune/grid/common/capabilities.hh>
#include <dune/grid/common/gridview.hh>
#include "mmiterator.hh"
#include "multiindexset.hh"
namespace
Dune
{
// forward declaration
template
<
class
HostGrid
>
class
MultiGridView
;
template
<
class
HostGrid
>
struct
MultiGridViewTraits
{
using
Grid
=
typename
std
::
remove_const
<
HostGrid
>::
type
;
using
IndexSet
=
MultiIndexSet
<
HostGrid
>
;
using
Intersection
=
std
::
variant
<
typename
HostGrid
::
Traits
::
LeafIntersection
,
typename
HostGrid
::
Traits
::
LevelIntersection
>
;
using
IntersectionIterator
=
std
::
variant
<
typename
HostGrid
::
Traits
::
LeafIntersectionIterator
,
typename
HostGrid
::
Traits
::
LevelIntersectionIterator
>
;
using
CollectiveCommunication
=
typename
HostGrid
::
Traits
::
CollectiveCommunication
;
template
<
int
cd
>
struct
Codim
{
using
Entity
=
typename
Grid
::
Traits
::
template
Codim
<
cd
>
::
Entity
;
using
Geometry
=
typename
Grid
::
template
Codim
<
cd
>
::
Geometry
;
using
LocalGeometry
=
typename
Grid
::
template
Codim
<
cd
>
::
LocalGeometry
;
template
<
PartitionIteratorType
pit
>
struct
Partition
{
using
Iterator
=
MultiMeshIterator
<
cd
,
pit
,
HostGrid
>
;
};
};
enum
{
conforming
=
Capabilities
::
isLevelwiseConforming
<
HostGrid
>::
v
};
};
template
<
class
HostGrid
>
class
MultiGridView
{
public:
using
Traits
=
MultiGridViewTraits
<
HostGrid
>
;
/// The MultiMesh GridType
using
Grid
=
typename
Traits
::
Grid
;
using
GridViewTypes
=
std
::
variant
<
typename
HostGrid
::
LeafGridView
,
typename
HostGrid
::
LevelGridView
>
;
using
IndexSet
=
typename
Traits
::
IndexSet
;
using
IndexSetTypes
=
typename
IndexSet
::
IndexSetTypes
;
using
IntersectionIterator
=
typename
Traits
::
IntersectionIterator
;
using
CollectiveCommunication
=
typename
Traits
::
CollectiveCommunication
;
template
<
class
GV
>
using
IsGridView
=
Std
::
disjunction
<
std
::
is_same
<
std
::
decay_t
<
GV
>
,
typename
HostGrid
::
LeafGridView
>
,
std
::
is_same
<
std
::
decay_t
<
GV
>
,
typename
HostGrid
::
LevelGridView
>
>
;
template
<
int
cd
>
struct
Codim
:
public
Traits
::
template
Codim
<
cd
>
{};
enum
{
dimension
=
HostGrid
::
dimension
};
enum
{
dimensionworld
=
HostGrid
::
dimensionworld
};
enum
{
conforming
=
Traits
::
conforming
};
public:
/// Constructor.
template
<
class
...
GridViews
,
std
::
enable_if_t
<
Std
::
conjunction
<
IsGridView
<
GridViews
>...
>::
value
,
int
>
=
0
>
MultiGridView
(
GridViews
&&
...
gridViews
)
:
gridViews_
{
std
::
forward
<
GridViews
>
(
gridViews
)...}
{}
template
<
class
GridView
,
std
::
enable_if_t
<
IsGridView
<
GridView
>
::
value
,
int
>
=
0
>
MultiGridView
(
const
std
::
vector
<
GridView
>&
gridViews
)
:
gridViews_
(
gridViews
.
begin
(),
gridViews
.
end
())
{}
template
<
class
Iter
,
std
::
enable_if_t
<
IsGridView
<
typename
std
::
iterator_traits
<
Iter
>
::
value_type
>::