Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dumux-repositories
dumux
Commits
d9d14beb
Commit
d9d14beb
authored
Jul 11, 2018
by
Dennis Gläser
Committed by
Timo Koch
Jul 12, 2018
Browse files
[multidomain][facet] pull out embedment data of grid manager
parent
121bba76
Changes
15
Hide whitespace changes
Inline
Side-by-side
dumux/multidomain/facet/box/couplingmapper.hh
View file @
d9d14beb
...
...
@@ -69,16 +69,16 @@ public:
*
* \param bulkFvGridGeometry The finite-volume grid geometry of the bulk grid
* \param lowDimFvGridGeometry The finite-volume grid geometry of the lower-dimensional grid
* \param
gridManager
Class that contains the embedments a
nd allows obtaining
entity insertion indices
* \param
embeddings
Class that contains the embedments a
mong the grids and
entity insertion indices
*/
template
<
class
GridManager
>
template
<
class
Embeddings
>
void
update
(
const
BulkFVG
&
bulkFvGridGeometry
,
const
LowDimFVG
&
lowDimFvGridGeometry
,
const
GridManager
&
gridManager
)
std
::
shared_ptr
<
const
Embeddings
>
embeddings
)
{
// forward to update function with instantiated vertex adapter
using
GridAdapter
=
CodimOneGridAdapter
<
GridManager
,
bulkGridId
,
facetGridId
>
;
update
(
bulkFvGridGeometry
,
lowDimFvGridGeometry
,
gridManager
,
GridAdapter
{
gridManager
}
);
using
GridAdapter
=
CodimOneGridAdapter
<
Embeddings
,
bulkGridId
,
facetGridId
>
;
update
(
bulkFvGridGeometry
,
lowDimFvGridGeometry
,
embeddings
,
GridAdapter
(
embeddings
)
);
}
/*!
* \brief Update coupling maps. This is the standard
...
...
@@ -86,20 +86,20 @@ public:
*
* \param bulkFvGridGeometry The finite-volume grid geometry of the bulk grid
* \param lowDimFvGridGeometry The finite-volume grid geometry of the lower-dimensional grid
* \param
gridManager
Class that contains the embedments a
nd allows obtaining
entity insertion indices
* \param
embeddings
Class that contains the embedments a
mong the grids and
entity insertion indices
* \param codimOneGridAdapter Allows direct access to data on the bulk grid for lowdim grid entities
*/
template
<
class
GridManager
,
class
CodimOneGridAdapter
>
template
<
class
Embeddings
,
class
CodimOneGridAdapter
>
void
update
(
const
BulkFVG
&
bulkFvGridGeometry
,
const
LowDimFVG
&
lowDimFvGridGeometry
,
const
GridManager
&
gridManager
,
std
::
shared_ptr
<
const
Embeddings
>
embeddings
,
const
CodimOneGridAdapter
&
codimOneGridAdapter
)
{
// define the
execution
policy how to add map entries f
rom an emb
ed
m
ent
auto
add
Embedment
Policy
=
[
&
]
(
auto
&&
embedment
s
,
const
LowDimElement
&
lowDimElement
,
const
LowDimFVG
&
lowDimFvGridGeometry
,
const
BulkFVG
&
bulkFvGridGeometry
)
// define the policy how to add map entries f
or given lowdim element and adjoin
ed
ent
ity indices
auto
add
CouplingEntry
Policy
=
[
&
]
(
auto
&&
adjoinedEntityIndice
s
,
const
LowDimElement
&
lowDimElement
,
const
LowDimFVG
&
lowDimFvGridGeometry
,
const
BulkFVG
&
bulkFvGridGeometry
)
{
using
LowDimIndexType
=
typename
LowDimGridView
::
IndexSet
::
IndexType
;
using
BulkIndexType
=
typename
BulkGridView
::
IndexSet
::
IndexType
;
...
...
@@ -115,10 +115,10 @@ public:
for
(
int
i
=
0
;
i
<
numElementCorners
;
++
i
)
elementCorners
[
i
]
=
codimOneGridAdapter
.
bulkGridVertexIndex
(
lowDimElement
.
template
subEntity
<
lowDimDim
>(
i
));
// save unsorted set of corner indices and search scvfs in
emb
ed
m
ents
// save unsorted set of corner indices and search scvfs in
adjoin
ed
ent
itie
s
const
auto
unsortedElemCorners
=
elementCorners
;
std
::
sort
(
elementCorners
.
begin
(),
elementCorners
.
end
());
for
(
auto
bulkElemIdx
:
embedment
s
)
for
(
auto
bulkElemIdx
:
adjoinedEntityIndice
s
)
{
const
auto
bulkElement
=
bulkFvGridGeometry
.
element
(
bulkElemIdx
);
const
auto
bulkRefElem
=
BulkReferenceElements
::
general
(
bulkElement
.
geometry
().
type
());
...
...
@@ -204,7 +204,7 @@ public:
};
// let the parent do the update subject to the execution policy defined above
ParentType
::
update_
(
bulkFvGridGeometry
,
lowDimFvGridGeometry
,
gridManager
,
addEmbedment
Policy
);
ParentType
::
update_
(
bulkFvGridGeometry
,
lowDimFvGridGeometry
,
embeddings
,
addCouplingEntry
Policy
);
// coupling stencils might not be unique with the policy above
auto
makeStencilUnique
=
[]
(
auto
&
data
)
...
...
dumux/multidomain/facet/cellcentered/tpfa/couplingmapper.hh
View file @
d9d14beb
...
...
@@ -62,18 +62,18 @@ public:
*
* \param bulkFvGridGeometry The finite-volume grid geometry of the bulk grid
* \param lowDimFvGridGeometry The finite-volume grid geometry of the lower-dimensional grid
* \param
gridManager
Class that contains the embedments a
nd allows obtaining
entity insertion indices
* \param
embeddings
Class that contains the embedments a
mong the grids and
entity insertion indices
*/
template
<
class
GridManager
>
template
<
class
Embeddings
>
void
update
(
const
BulkFVG
&
bulkFvGridGeometry
,
const
LowDimFVG
&
lowDimFvGridGeometry
,
const
GridManager
&
gridManager
)
std
::
shared_ptr
<
const
Embeddings
>
embeddings
)
{
// define the
execution
policy how to add map entries f
rom an emb
ed
m
ent
auto
add
Embedment
Policy
=
[
&
]
(
auto
&&
embedment
s
,
const
LowDimElement
&
lowDimElement
,
const
LowDimFVG
&
lowDimFvGridGeometry
,
const
BulkFVG
&
bulkFvGridGeometry
)
// define the policy how to add map entries f
or given lowdim element and adjoin
ed
ent
ity indices
auto
add
CouplingEntry
Policy
=
[
&
]
(
auto
&&
adjoinedEntityIndice
s
,
const
LowDimElement
&
lowDimElement
,
const
LowDimFVG
&
lowDimFvGridGeometry
,
const
BulkFVG
&
bulkFvGridGeometry
)
{
using
LowDimIndexType
=
typename
LowDimFVG
::
GridView
::
IndexSet
::
IndexType
;
using
BulkIndexType
=
typename
BulkFVG
::
GridView
::
IndexSet
::
IndexType
;
...
...
@@ -81,9 +81,9 @@ public:
const
auto
lowDimElemIdx
=
lowDimFvGridGeometry
.
elementMapper
().
index
(
lowDimElement
);
auto
&
lowDimData
=
this
->
couplingMap_
(
facetGridId
,
bulkGridId
)[
lowDimElemIdx
];
// find the scvfs in the
emb
ed
m
ents coinciding with the low dim element
// find the scvfs in the
adjoin
ed
ent
itie
s coinciding with the low dim element
// since the bulk domain uses tpfa, there is always only going to be one scvf
for
(
auto
bulkElemIdx
:
embedment
s
)
for
(
auto
bulkElemIdx
:
adjoinedEntityIndice
s
)
{
const
auto
bulkElement
=
bulkFvGridGeometry
.
element
(
bulkElemIdx
);
...
...
@@ -98,7 +98,9 @@ public:
// of the outside scv indices is in the set of embedments
if
(
!
scvf
.
boundary
())
{
if
(
std
::
find
(
embedments
.
begin
(),
embedments
.
end
(),
scvf
.
outsideScvIdx
())
!=
embedments
.
end
())
if
(
std
::
find
(
adjoinedEntityIndices
.
begin
(),
adjoinedEntityIndices
.
end
(),
scvf
.
outsideScvIdx
())
!=
adjoinedEntityIndices
.
end
()
)
{
embeddedScvfIdx
=
scvf
.
index
();
found
=
true
;
break
;
...
...
@@ -145,12 +147,12 @@ public:
lowDimData
.
embedments
.
emplace_back
(
bulkElemIdx
,
std
::
vector
<
BulkIndexType
>
({
embeddedScvfIdx
})
);
}
//
embedment
s = coupling stencil for tpfa
lowDimData
.
couplingStencil
=
std
::
move
(
embedment
s
);
//
adjoint entity indice
s = coupling stencil for tpfa
lowDimData
.
couplingStencil
=
std
::
move
(
adjoinedEntityIndice
s
);
};
// let the parent do the update subject to the execution policy defined above
ParentType
::
update_
(
bulkFvGridGeometry
,
lowDimFvGridGeometry
,
gridManager
,
addEmbedment
Policy
);
ParentType
::
update_
(
bulkFvGridGeometry
,
lowDimFvGridGeometry
,
embeddings
,
addCouplingEntry
Policy
);
// coupling stencils might not be unique if box is used in lowdim domain
if
(
LowDimFVG
::
discMethod
==
DiscretizationMethod
::
box
)
...
...
dumux/multidomain/facet/codimonegridadapter.hh
View file @
d9d14beb
...
...
@@ -34,77 +34,73 @@ namespace Dumux {
/*!
* \ingroup MultiDomain
* \ingroup FacetCoupling
* \brief Adapter t
o be plugged on top of a grid creator that allows for obtaining
*
information
o
n
a
d
-dimensional grid
for entities of a (d-1)
-dimensional
*
grid. This lower-dimensional grid is
assumed to be facet-conforming to the
*
d-dimensional grid. This class
can be used in the context of models where
*
a sub-domain lives on the
facets of a bulk grid.
* \brief Adapter t
hat allows retrieving information on a d-dimensional grid for
*
entities
o
f
a
(d-1)
-dimensional grid
. This lower
-dimensional
grid is
* assumed to be facet-conforming to the
d-dimensional grid. This class
* can be used in the context of models where
a sub-domain lives on the
* facets of a bulk grid.
*
* \tparam
GridManager A grid manager containing a hierarchy of facet-conforming grids.
* \tparam
Embeddings Class containing the embedments of entites between grids of codim 1
* \tparam bulkGridId The grid id of the d-dimensional grid within the hierarchy
* \tparam facetGridId The grid id of the (d-1)-dimensional grid within the hierarchy
*/
template
<
class
GridManager
,
int
bulkGridId
=
0
,
int
facetGridId
=
1
>
template
<
class
Embeddings
,
int
bulkGridId
=
0
,
int
facetGridId
=
1
>
class
CodimOneGridAdapter
{
// Extract some types of the facet-conforming grid of codimension one
using
FacetGrid
=
typename
GridManager
::
template
Grid
<
facetGridId
>;
using
FacetGridView
=
typename
FacetGrid
::
LeafGridView
;
using
FacetGridVertex
=
typename
FacetGridView
::
template
Codim
<
FacetGrid
::
dimension
>
::
Entity
;
using
FacetGridView
=
typename
Embeddings
::
template
GridView
<
facetGridId
>;
using
FacetGridVertex
=
typename
FacetGridView
::
template
Codim
<
FacetGridView
::
dimension
>
::
Entity
;
using
FacetGridElement
=
typename
FacetGridView
::
template
Codim
<
0
>
::
Entity
;
using
FacetGridIndexType
=
typename
FacetGridView
::
IndexSet
::
IndexType
;
// Extract some types of the bulk grid
using
BulkGrid
=
typename
GridManager
::
template
Grid
<
bulkGridId
>;
using
BulkGridView
=
typename
BulkGrid
::
LeafGridView
;
using
BulkGridView
=
typename
Embeddings
::
template
GridView
<
bulkGridId
>;
using
BulkMapper
=
Dune
::
MultipleCodimMultipleGeomTypeMapper
<
BulkGridView
>
;
using
BulkReferenceElements
=
typename
Dune
::
ReferenceElements
<
typename
BulkGridView
::
ctype
,
BulkGrid
::
dimension
>
;
using
BulkReferenceElements
=
typename
Dune
::
ReferenceElements
<
typename
BulkGridView
::
ctype
,
BulkGrid
View
::
dimension
>
;
using
BulkGridElement
=
typename
BulkGridView
::
template
Codim
<
0
>
::
Entity
;
using
BulkGridIntersection
=
typename
BulkGridView
::
Intersection
;
using
BulkGridVertex
=
typename
BulkGridView
::
template
Codim
<
BulkGrid
::
dimension
>
::
Entity
;
using
BulkGridVertex
=
typename
BulkGridView
::
template
Codim
<
BulkGrid
View
::
dimension
>
::
Entity
;
using
BulkIndexType
=
typename
BulkGridView
::
IndexSet
::
IndexType
;
// Find out if the given bulk grid is the one with highest dimensionality among the created grids
static
constexpr
bool
bulkHasHighestDimension
=
(
int
(
BulkGrid
::
dimension
)
==
GridManager
::
bulkDim
);
static
constexpr
bool
bulkHasHighestDimension
=
(
int
(
BulkGrid
View
::
dimension
)
==
Embeddings
::
bulkDim
);
// check if provided id combination makes sense
static_assert
(
int
(
FacetGrid
::
dimension
)
==
int
(
BulkGrid
::
dimension
)
-
1
,
static_assert
(
int
(
FacetGrid
View
::
dimension
)
==
int
(
BulkGrid
View
::
dimension
)
-
1
,
"Grid dimension mismatch! Please check the provided domain ids!"
);
static_assert
(
int
(
FacetGrid
::
dimensionworld
)
==
int
(
BulkGrid
::
dimensionworld
),
static_assert
(
int
(
FacetGrid
View
::
dimensionworld
)
==
int
(
BulkGrid
View
::
dimensionworld
),
"Grid world dimension mismatch! All grids must have the same world dimension"
);
public:
//! The constructor
CodimOneGridAdapter
(
const
GridManager
&
gridManager
)
:
gridManagerPtr_
(
&
gridManager
)
,
bulkVertexMapper_
(
gridManager
.
template
grid
<
bulkGridId
>()
.
leafGridView
()
,
Dune
::
mcmgVertexLayout
())
CodimOneGridAdapter
(
std
::
shared_ptr
<
const
Embeddings
>
embeddings
)
:
embeddingsPtr_
(
embeddings
)
,
bulkVertexMapper_
(
embeddings
->
template
grid
View
<
bulkGridId
>(),
Dune
::
mcmgVertexLayout
())
{
// bulk insertion to grid index map
const
auto
&
bulkGridView
=
gridManager
.
template
grid
<
bulkGridId
>().
leafGridView
();
const
auto
&
bulkGridFactory
=
gridManagerPtr_
->
template
gridFactory
<
bulkGridId
>();
bulkInsertionToGridVIdx_
.
resize
(
bulkGridView
.
size
(
BulkGrid
::
dimension
));
const
auto
&
bulkGridView
=
embeddings
->
template
gridView
<
bulkGridId
>();
bulkInsertionToGridVIdx_
.
resize
(
bulkGridView
.
size
(
BulkGridView
::
dimension
));
for
(
const
auto
&
v
:
vertices
(
bulkGridView
))
bulkInsertionToGridVIdx_
[
bulkGridFactory
.
insertionIndex
(
v
)
]
=
bulkVertexMapper_
.
index
(
v
);
bulkInsertionToGridVIdx_
[
embeddings
->
template
insertionIndex
<
bulkGridId
>
(
v
)]
=
bulkVertexMapper_
.
index
(
v
);
// maybe set up index map from hierachy insertion to bulk insertion indices
makeBulkIndexMap_
(
gridManager
);
makeBulkIndexMap_
();
// determine which bulk vertices lie on facet elements
bulkVertexIsOnFacetGrid_
.
resize
(
bulkGridView
.
size
(
BulkGrid
::
dimension
),
false
);
const
auto
&
facetGridView
=
gridManager
.
template
grid
<
facetGridId
>().
leafGridView
();
const
auto
&
facetGridFactory
=
gridManager
.
template
gridFactory
<
facetGridId
>();
bulkVertexIsOnFacetGrid_
.
resize
(
bulkGridView
.
size
(
BulkGridView
::
dimension
),
false
);
const
auto
&
facetGridView
=
embeddings
->
template
gridView
<
facetGridId
>();
for
(
const
auto
&
v
:
vertices
(
facetGridView
))
{
const
auto
insIdx
=
facetGridFactory
.
insertionIndex
(
v
);
const
auto
highestLevelInsIdx
=
gridManager
.
lowDimVertexIndices
(
facetGridId
)[
insIdx
];
const
auto
insIdx
=
embeddings
->
template
insertionIndex
<
facetGridId
>
(
v
);
const
auto
highestLevelInsIdx
=
embeddings
->
lowDimVertexIndices
(
facetGridId
)[
insIdx
];
const
auto
bulkGridIdx
=
getBulkGridVertexIndex_
(
highestLevelInsIdx
);
bulkVertexIsOnFacetGrid_
[
bulkGridIdx
]
=
true
;
}
// determine the bulk vertex indices that make up facet elements & connectivity
facetElementCorners_
.
resize
(
facetGridView
.
size
(
0
));
facetElementsAtBulkVertex_
.
resize
(
bulkGridView
.
size
(
BulkGrid
::
dimension
));
facetElementsAtBulkVertex_
.
resize
(
bulkGridView
.
size
(
BulkGrid
View
::
dimension
));
std
::
size_t
facetElementCounter
=
0
;
for
(
const
auto
&
element
:
elements
(
facetGridView
))
...
...
@@ -112,10 +108,10 @@ public:
if
(
isEmbedded
(
element
))
{
// obtain the bulk vertex indices of the corners of this element
const
auto
numCorners
=
element
.
subEntities
(
FacetGrid
::
dimension
);
const
auto
numCorners
=
element
.
subEntities
(
FacetGrid
View
::
dimension
);
std
::
vector
<
BulkIndexType
>
cornerIndices
(
numCorners
);
for
(
int
i
=
0
;
i
<
numCorners
;
++
i
)
cornerIndices
[
i
]
=
bulkGridVertexIndex
(
element
.
template
subEntity
<
FacetGrid
::
dimension
>(
i
));
cornerIndices
[
i
]
=
bulkGridVertexIndex
(
element
.
template
subEntity
<
FacetGrid
View
::
dimension
>(
i
));
// update connectivity map facetVertex -> facetElements
for
(
auto
bulkVIdx
:
cornerIndices
)
...
...
@@ -138,8 +134,8 @@ public:
*/
BulkIndexType
bulkGridVertexIndex
(
const
FacetGridVertex
&
v
)
const
{
const
auto
insIdx
=
gridManager
Ptr_
->
template
gridFactory
<
facetGridId
>().
insertionIndex
(
v
);
const
auto
highestLevelInsIdx
=
gridManager
Ptr_
->
lowDimVertexIndices
(
facetGridId
)[
insIdx
];
const
auto
insIdx
=
embeddings
Ptr_
->
template
insertionIndex
<
facetGridId
>
(
v
);
const
auto
highestLevelInsIdx
=
embeddings
Ptr_
->
lowDimVertexIndices
(
facetGridId
)[
insIdx
];
return
getBulkGridVertexIndex_
(
highestLevelInsIdx
);
}
...
...
@@ -149,7 +145,7 @@ public:
*/
bool
isOnFacetGrid
(
const
BulkGridVertex
&
v
)
const
{
const
auto
bulkInsIdx
=
gridManager
Ptr_
->
template
gridFactory
<
bulkGridId
>().
insertionIndex
(
v
);
const
auto
bulkInsIdx
=
embeddings
Ptr_
->
template
insertionIndex
<
bulkGridId
>
(
v
);
const
auto
bulkVIdx
=
bulkInsertionToGridVIdx_
[
bulkInsIdx
];
return
bulkVertexIsOnFacetGrid_
[
bulkVIdx
];
}
...
...
@@ -170,8 +166,8 @@ public:
std
::
vector
<
BulkIndexType
>
cornerIndices
(
numCorners
);
for
(
int
i
=
0
;
i
<
numCorners
;
++
i
)
cornerIndices
[
i
]
=
bulkVertexMapper_
.
subIndex
(
element
,
refElement
.
subEntity
(
facetIdx
,
1
,
i
,
BulkGrid
::
dimension
),
BulkGrid
::
dimension
);
refElement
.
subEntity
(
facetIdx
,
1
,
i
,
BulkGrid
View
::
dimension
),
BulkGrid
View
::
dimension
);
return
composeFacetElement
(
cornerIndices
);
}
...
...
@@ -230,29 +226,29 @@ public:
* given (d-1)-dimensional element is embedded in
*/
std
::
size_t
numEmbedments
(
const
FacetGridElement
&
e
)
const
{
return
gridManager
Ptr_
->
template
embedment
EntityIndices
<
facetGridId
>(
e
).
size
();
}
{
return
embeddings
Ptr_
->
template
adjoined
EntityIndices
<
facetGridId
>(
e
).
size
();
}
private:
//! Determine map from the insertion idx of the highest-dimensional grid to bulk insertion idx
template
<
bool
isHighest
=
bulkHasHighestDimension
,
std
::
enable_if_t
<!
isHighest
,
int
>
=
0
>
void
makeBulkIndexMap_
(
const
GridManager
&
gridManager
)
void
makeBulkIndexMap_
()
{
// obtain highest-dimensional grid using the bulkId from grid creator
const
auto
&
highestLevelGridView
=
gridManager
.
template
grid
<
GridManager
::
bulkGridId
>().
leafGridView
();
highestLevelInsertionToBulkInsertionIdx_
.
resize
(
highestLevelGridView
.
size
(
GridManager
::
bulkDim
));
const
auto
&
highestLevelGridView
=
embeddingsPtr_
->
template
gridView
<
Embeddings
::
bulkGridId
>
();
highestLevelInsertionToBulkInsertionIdx_
.
resize
(
highestLevelGridView
.
size
(
Embeddings
::
bulkDim
));
// indices in grid creator stem from the grid file, which has one set of vertices
// for the entire hierarchy. Thus, the vertex indices we obtain from the grid creator
// that make up this bulk grid (lower-dimensional within the hierarchy), correspond to
// the highest-dimensional grid's insertion indices.
const
auto
&
vertexInsIndices
=
gridManager
.
lowDimVertexIndices
(
bulkGridId
);
const
auto
&
vertexInsIndices
=
embeddingsPtr_
->
lowDimVertexIndices
(
bulkGridId
);
for
(
std
::
size_t
insIdx
=
0
;
insIdx
<
vertexInsIndices
.
size
();
++
insIdx
)
highestLevelInsertionToBulkInsertionIdx_
[
vertexInsIndices
[
insIdx
]
]
=
insIdx
;
}
//! If the given bulk grid is on the highest level of grid creation, we do not need the map
template
<
bool
isHighest
=
bulkHasHighestDimension
,
std
::
enable_if_t
<
isHighest
,
int
>
=
0
>
void
makeBulkIndexMap_
(
const
GridManager
&
gridManager
)
void
makeBulkIndexMap_
()
{}
//! Obtains the bulk grid vertex index from a given insertion index on the hierarchy
...
...
@@ -263,8 +259,8 @@ private:
:
bulkInsertionToGridVIdx_
[
highestLevelInsertionToBulkInsertionIdx_
[
highestLevelInsertionIdx
]
];
}
// pointer to the
grid creator
const
GridManager
*
gridManager
Ptr_
;
//
shared
pointer to the
embedment data
std
::
shared_ptr
<
const
Embeddings
>
embeddings
Ptr_
;
// vertex mapper of the bulk grid
BulkMapper
bulkVertexMapper_
;
...
...
dumux/multidomain/facet/couplingmapper.hh
View file @
d9d14beb
...
...
@@ -113,16 +113,16 @@ public:
* \param bulkFvGridGeometry The finite-volume grid geometry of the bulk grid
* \param facetFvGridGeometry The finite-volume grid geometry of the codimension-one grid
* \param edgeFvGridGeometry The finite-volume grid geometry of the codimension-two grid
* \param
gridManager
Class that contains the embedments a
nd allows obtaining
entity insertion indices
* \param
embeddings
Class that contains the embedments a
mong the grids and
entity insertion indices
*/
template
<
class
GridManager
>
template
<
class
Embeddings
>
void
update
(
const
BulkFVG
&
bulkFvGridGeometry
,
const
FacetFVG
&
facetFvGridGeometry
,
const
EdgeFVG
&
edgeFvGridGeometry
,
const
GridManager
&
gridManager
)
std
::
shared_ptr
<
const
Embeddings
>
embeddings
)
{
BulkFacetMapper
::
update
(
bulkFvGridGeometry
,
facetFvGridGeometry
,
gridManager
);
FacetEdgeMapper
::
update
(
facetFvGridGeometry
,
edgeFvGridGeometry
,
gridManager
);
BulkFacetMapper
::
update
(
bulkFvGridGeometry
,
facetFvGridGeometry
,
embeddings
);
FacetEdgeMapper
::
update
(
facetFvGridGeometry
,
edgeFvGridGeometry
,
embeddings
);
}
//! Pull up the parents' access operators to allow for individual updates
...
...
dumux/multidomain/facet/couplingmapperbase.hh
View file @
d9d14beb
...
...
@@ -64,11 +64,11 @@ class FacetCouplingMapperBase
static
constexpr
auto
bulkDiscMethod
=
BulkFVG
::
discMethod
;
// helper struct to check validity of the given domain id offset
template
<
class
GridManager
>
class
IsValid
GridManager
template
<
class
Embeddings
>
class
IsValid
DomainId
{
using
GCBulkGridView
=
typename
GridManager
::
template
Grid
<
bulkId
>
::
LeafGridView
;
using
GCLowDimGridView
=
typename
GridManager
::
template
Grid
<
lowDimId
>
::
LeafGridView
;
using
GCBulkGridView
=
typename
Embeddings
::
template
Grid
View
<
bulkId
>;
using
GCLowDimGridView
=
typename
Embeddings
::
template
Grid
View
<
lowDimId
>;
static
constexpr
bool
bulkMatch
=
std
::
is_same
<
GCBulkGridView
,
BulkGridView
>::
value
;
static
constexpr
bool
lowDimMatch
=
std
::
is_same
<
GCLowDimGridView
,
LowDimGridView
>::
value
;
static_assert
(
bulkMatch
,
"The bulk domain id does not match the provided bulk grid geometry"
);
...
...
@@ -145,10 +145,10 @@ public:
* \brief Update coupling maps. This is the standard interface
* and has to be overloaded by the implementation.
*/
template
<
class
GridManager
>
template
<
class
Embeddings
>
void
update
(
const
BulkFVG
&
bulkFvGridGeometry
,
const
LowDimFVG
&
lowDimFvGridGeometry
,
const
GridManager
&
gridManager
)
std
::
shared_ptr
<
const
Embeddings
>
embeddings
)
{
DUNE_THROW
(
Dune
::
NotImplemented
,
"Implementation does not provide an update() function."
);
}
//! returns coupling data for bulk -> lowDim
...
...
@@ -166,40 +166,40 @@ protected:
*
* \param bulkFvGridGeometry The finite-volume grid geometry of the bulk grid
* \param lowDimFvGridGeometry The finite-volume grid geometry of the lower-dimensional grid
* \param gridManager Class that contains the embedments and allows obtaining entity insertion indices
* \param EmbedmentExecutionPolicy Policy for adding coupling entries for embedments
* \param embeddings Class that contains the embedments and allows obtaining entity insertion indices
* \param AddCouplingEntryPolicy Policy for adding coupling entries starting from a lower-dimensional
* element and corresponding adjoined higher-dimensional entity indices
*/
template
<
class
GridManager
,
typename
EmbedmentExecution
Policy
>
template
<
class
Embeddings
,
typename
AddCouplingEntry
Policy
>
void
update_
(
const
BulkFVG
&
bulkFvGridGeometry
,
const
LowDimFVG
&
lowDimFvGridGeometry
,
const
GridManager
&
gridManager
,
EmbedmentExecutionPolicy
&&
embedment
Policy
)
std
::
shared_ptr
<
const
Embeddings
>
embeddings
,
AddCouplingEntryPolicy
&&
addCouplingEntry
Policy
)
{
// some static assertions on the grid creator
static_assert
(
IsValid
GridManager
<
GridManager
>::
value
,
"Grid type mismatch. Please review the provided domain id offset."
);
static_assert
(
IsValid
DomainId
<
Embeddings
>::
value
,
"Grid type mismatch. Please review the provided domain id offset."
);
// clear data
bulkCouplingData_
.
clear
();
lowDimCouplingData_
.
clear
();
// set up maps between element indices and insertion indices
const
auto
&
bulkGridFactory
=
gridManager
.
template
gridFactory
<
bulkId
>();
const
auto
bulkInsertionToElemIdxMap
=
makeInsertionToGridIndexMap_
(
bulkGridFactory
,
bulkFvGridGeometry
);
const
auto
bulkInsertionToElemIdxMap
=
makeInsertionToGridIndexMap_
(
embeddings
,
bulkFvGridGeometry
);
// set up coupling maps coming from the low dim domain
for
(
const
auto
&
element
:
elements
(
lowDimFvGridGeometry
.
gridView
()))
{
auto
embedments
=
gridManager
.
template
embedment
EntityIndices
<
lowDimId
>(
element
);
auto
adjoinedEntities
=
embeddings
->
template
adjoined
EntityIndices
<
lowDimId
>(
element
);
// proceed only if e
mbedments were foun
d
if
(
embedment
s
.
size
()
==
0
)
// proceed only if e
lement is embedde
d
if
(
adjoinedEntitie
s
.
size
()
==
0
)
continue
;
// turn
embedment
s into actual grid element indices ...
std
::
for_each
(
embedments
.
begin
(),
embedment
s
.
end
(),
[
&
]
(
auto
&
idx
)
{
idx
=
bulkInsertionToElemIdxMap
[
idx
];
});
// turn
(insertion) indice
s into actual grid element indices ...
std
::
for_each
(
adjoinedEntities
.
begin
(),
adjoinedEntitie
s
.
end
(),
[
&
]
(
auto
&
idx
)
{
idx
=
bulkInsertionToElemIdxMap
[
idx
];
});
// ... and add them
embedment
Policy
(
std
::
move
(
embedment
s
),
element
,
lowDimFvGridGeometry
,
bulkFvGridGeometry
);
addCouplingEntry
Policy
(
std
::
move
(
adjoinedEntitie
s
),
element
,
lowDimFvGridGeometry
,
bulkFvGridGeometry
);
}
}
...
...
@@ -231,15 +231,15 @@ protected:
private:
//! Creates the map from element insertion index to grid element index
template
<
class
GridFactory
,
class
FVGridGeometry
>
template
<
class
Embeddings
,
class
FVGridGeometry
>
std
::
vector
<
typename
FVGridGeometry
::
GridView
::
IndexSet
::
IndexType
>
makeInsertionToGridIndexMap_
(
const
GridFactory
&
gridFactory
,
const
FVGridGeometry
&
fvGridGeometry
)
const
makeInsertionToGridIndexMap_
(
std
::
shared_ptr
<
const
Embeddings
>
embeddings
,
const
FVGridGeometry
&
fvGridGeometry
)
const
{
using
IndexType
=
typename
FVGridGeometry
::
GridView
::
IndexSet
::
IndexType
;
std
::
vector
<
IndexType
>
map
(
fvGridGeometry
.
gridView
().
size
(
0
));
for
(
const
auto
&
e
:
elements
(
fvGridGeometry
.
gridView
()))
map
[
gridFactory
.
insertionIndex
(
e
)
]
=
fvGridGeometry
.
elementMapper
().
index
(
e
);
map
[
embeddings
->
template
insertionIndex
<
bulkId
>
(
e
)
]
=
fvGridGeometry
.
elementMapper
().
index
(
e
);
return
map
;
}
...
...
dumux/multidomain/facet/gmshreader.hh
View file @
d9d14beb
...
...
@@ -53,16 +53,16 @@ namespace Dumux {
* indexing in your grid file in that case.
*
* \tparam BulkGrid The type of the highest-dimensional grid in the hierachy
* \tparam IndexType The index type to be used
* \tparam numGrids The number of grids to be considered in the hierarchy
*/
template
<
class
BulkGrid
,
class
IndexType
,
int
numGrids
>
template
<
class
BulkGrid
,
int
numGrids
>
class
FacetCouplingGmshReader
{
// extract some necessary info from bulk grid
static
constexpr
int
bulkDim
=
BulkGrid
::
dimension
;
static
constexpr
int
bulkDimWorld
=
BulkGrid
::
dimensionworld
;
using
ctype
=
typename
BulkGrid
::
ctype
;
using
IndexType
=
typename
BulkGrid
::
LeafGridView
::
IndexSet
::
IndexType
;
using
GlobalPosition
=
Dune
::
FieldVector
<
ctype
,
bulkDimWorld
>
;
// determine minimum dimension for which a grid is created
...
...
@@ -322,10 +322,10 @@ public:
}
//! Returns the maps of the embedments
std
::
unordered_map
<
IndexType
,
std
::
vector
<
IndexType
>
>&
embedment
Map
(
std
::
size_t
id
)
std
::
unordered_map
<
IndexType
,
std
::
vector
<
IndexType
>
>&
adjoinedEntity
Map
(
std
::
size_t
id
)
{
assert
(
id
<
numGrids
&&
"Index exceeds number of grids provided"
);
return
embedment
Maps_
[
id
];
return
adjoinedEntity
Maps_
[
id
];
}
private:
...
...
@@ -398,7 +398,7 @@ private:
if
(
std
::
all_of
(
e
.
cornerIndices
.
begin
(),
e
.
cornerIndices
.
end
(),
vertIsContained
)
)
{
embeddedEntityMaps_
[
gridIdx
][
curElemIdx
].
push_back
(
i
);
embedment
Maps_
[
embeddedGridIdx
][
i
].
push_back
(
curElemIdx
);
adjoinedEntity
Maps_
[
embeddedGridIdx
][
i
].
push_back
(
curElemIdx
);
}
}
...
...
@@ -415,7 +415,7 @@ private:
//! data on connectivity between the grids
std
::
array
<
std
::
unordered_map
<
IndexType
,
std
::
vector
<
IndexType
>
>
,
numGrids
>
embeddedEntityMaps_
;
std
::
array
<
std
::
unordered_map
<
IndexType
,
std
::
vector
<
IndexType
>
>
,
numGrids
>
embedment
Maps_
;
std
::
array
<
std
::
unordered_map
<
IndexType
,
std
::
vector
<
IndexType
>
>
,
numGrids
>
adjoinedEntity
Maps_
;
//! data on domain and boundary markers
std
::
array
<
std
::
vector
<
int
>
,
numGrids
>
elementMarkerMaps_
;
...
...
dumux/multidomain/facet/gridmanager.hh
View file @
d9d14beb
...
...
@@ -16,8 +16,8 @@
*****************************************************************************/
/*!
* \file
* \ingroup M
ixedDimensio
n
* \ingroup
MixedDimensionFacet
* \ingroup M
ultiDomai
n
* \ingroup
FacetCoupling
* \brief Contains the grid manager class that creates the grids in the context
* of hybrid-dimensional coupled models, where the (n-1)-dimensional
* domains live on the element facets of the n-dimensional domains.
...
...
@@ -73,8 +73,8 @@ namespace Detail {
}
/*!
* \ingroup M
ixedDimensio
n
* \ingroup
MixedDimensionFacet
* \ingroup M
ultiDomai
n
* \ingroup
FacetCoupling
* \brief Grid data object to store element and boundary segment markers
* for all grids of the hierarchy.
*
...
...
@@ -135,33 +135,38 @@ private:
};
/*!
* \ingroup MixedDimension
* \ingroup MixedDimensionFacet
* \brief Creates the grids in the context of hybrid-dimensional coupled models,
* where the (n-1)-dimensional domains live on the element facets of the
* n-dimensional domains.
* \ingroup MultiDomain
* \ingroup FacetCoupling
* \brief Contains the embeddings between grids with codimension one
* among the grid hierarchy. All these embedments are given in
* insertion indices as they are read directly from the grid.
* Therefore, this class furthermore allows access to the insertion
* indices of entities. Additionally, it gives access to the grid
* views of the different grids on the hierarchy.
*
* \tparam Grids the types of the grid hierarchy
* \note Grids must be ordered in descending grid dimension
*/
template
<
typename
...
Grids
>
class
FacetCoupling
GridManager
class
FacetCoupling
Embeddings
{
// make sure all grids have the same world dimension and are ordered in descending dimension
static_assert
(
Detail
::
FulfillConditions
<
false
,
Grids
...
>::
value
,
"All grids must have the same world dimension!"
);
static_assert
(
Detail
::
FulfillConditions
<
true
,
Grids
...
>::
value
,
"Grids must be ordered w.r.t the dimension in descending order!"
);
// we use a wrapper class for the grid data containing the data on all grids
using
GridDataWrapper
=
FacetCouplingGridDataWrapper
<
Grids
...
>
;
public:
//! export the i-th grid type
//! the i-th grid type
template
<
std
::
size_t
id
>
using
Grid
=
typename
std
::
tuple_element_t
<
id
,
std
::
tuple
<
Grids
...
>>
;
//! export the i-th grid pointer type
template
<
std
::
size_t
id
>
using
GridPtr
=
typename
std
::
shared_ptr
<
Grid
<
id
>
>
;
//! export the i-th Dune::GridFactory type
template
<
std
::
size_t
id
>
using
GridFactory
=
Dune
::
GridFactory
<
Grid
<
id
>
>
;
//! export the i-th Dune::GridFactory type
template
<
std
::
size_t
id
>
using
GridFactoryPtr
=
std
::
shared_ptr
<
Dune
::
GridFactory
<
Grid
<
id
>>
>
;
//! the i-th grid factory type
template
<
std
::
size_t
id
>
using
GridFactory
=
typename
Dune
::
GridFactory
<
Grid
<
id
>>
;
//! we use the bulk grid's index type here
using
IT
=
typename
Grid
<
0
>::
LeafGridView
::
IndexSet
::
IndexType
;