Commit d9d14beb authored by Dennis Gläser's avatar Dennis Gläser Committed by Timo Koch
Browse files

[multidomain][facet] pull out embedment data of grid manager

parent 121bba76
......@@ -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 and allows obtaining entity insertion indices
* \param embeddings Class that contains the embedments among 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 and allows obtaining entity insertion indices
* \param embeddings Class that contains the embedments among 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 from an embedment
auto addEmbedmentPolicy = [&] (auto&& embedments,
const LowDimElement& lowDimElement,
const LowDimFVG& lowDimFvGridGeometry,
const BulkFVG& bulkFvGridGeometry)
// define the policy how to add map entries for given lowdim element and adjoined entity indices
auto addCouplingEntryPolicy = [&] (auto&& adjoinedEntityIndices,
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 embedments
// save unsorted set of corner indices and search scvfs in adjoined entities
const auto unsortedElemCorners = elementCorners;
std::sort(elementCorners.begin(), elementCorners.end());
for (auto bulkElemIdx : embedments)
for (auto bulkElemIdx : adjoinedEntityIndices)
{
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, addEmbedmentPolicy);
ParentType::update_(bulkFvGridGeometry, lowDimFvGridGeometry, embeddings, addCouplingEntryPolicy);
// coupling stencils might not be unique with the policy above
auto makeStencilUnique = [] (auto& data)
......
......@@ -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 and allows obtaining entity insertion indices
* \param embeddings Class that contains the embedments among 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 from an embedment
auto addEmbedmentPolicy = [&] (auto&& embedments,
const LowDimElement& lowDimElement,
const LowDimFVG& lowDimFvGridGeometry,
const BulkFVG& bulkFvGridGeometry)
// define the policy how to add map entries for given lowdim element and adjoined entity indices
auto addCouplingEntryPolicy = [&] (auto&& adjoinedEntityIndices,
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 embedments coinciding with the low dim element
// find the scvfs in the adjoined entities coinciding with the low dim element
// since the bulk domain uses tpfa, there is always only going to be one scvf
for (auto bulkElemIdx : embedments)
for (auto bulkElemIdx : adjoinedEntityIndices)
{
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}) );
}
// embedments = coupling stencil for tpfa
lowDimData.couplingStencil = std::move(embedments);
// adjoint entity indices = coupling stencil for tpfa
lowDimData.couplingStencil = std::move(adjoinedEntityIndices);
};
// let the parent do the update subject to the execution policy defined above
ParentType::update_(bulkFvGridGeometry, lowDimFvGridGeometry, gridManager, addEmbedmentPolicy);
ParentType::update_(bulkFvGridGeometry, lowDimFvGridGeometry, embeddings, addCouplingEntryPolicy);
// coupling stencils might not be unique if box is used in lowdim domain
if (LowDimFVG::discMethod == DiscretizationMethod::box)
......
......@@ -34,77 +34,73 @@ namespace Dumux {
/*!
* \ingroup MultiDomain
* \ingroup FacetCoupling
* \brief Adapter to be plugged on top of a grid creator that allows for obtaining
* information on 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 that allows retrieving information on 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.
*
* \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, BulkGridView::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<BulkGridView::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(BulkGridView::dimension) == Embeddings::bulkDim);
// check if provided id combination makes sense
static_assert( int(FacetGrid::dimension) == int(BulkGrid::dimension) - 1,
static_assert( int(FacetGridView::dimension) == int(BulkGridView::dimension) - 1,
"Grid dimension mismatch! Please check the provided domain ids!" );
static_assert( int(FacetGrid::dimensionworld) == int(BulkGrid::dimensionworld),
static_assert( int(FacetGridView::dimensionworld) == int(BulkGridView::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 gridView<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(BulkGridView::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(FacetGridView::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<FacetGridView::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 = gridManagerPtr_->template gridFactory<facetGridId>().insertionIndex(v);
const auto highestLevelInsIdx = gridManagerPtr_->lowDimVertexIndices(facetGridId)[insIdx];
const auto insIdx = embeddingsPtr_->template insertionIndex<facetGridId>(v);
const auto highestLevelInsIdx = embeddingsPtr_->lowDimVertexIndices(facetGridId)[insIdx];
return getBulkGridVertexIndex_(highestLevelInsIdx);
}
......@@ -149,7 +145,7 @@ public:
*/
bool isOnFacetGrid(const BulkGridVertex& v) const
{
const auto bulkInsIdx = gridManagerPtr_->template gridFactory<bulkGridId>().insertionIndex(v);
const auto bulkInsIdx = embeddingsPtr_->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, BulkGridView::dimension),
BulkGridView::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 gridManagerPtr_->template embedmentEntityIndices<facetGridId>(e).size(); }
{ return embeddingsPtr_->template adjoinedEntityIndices<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* gridManagerPtr_;
// shared pointer to the embedment data
std::shared_ptr<const Embeddings> embeddingsPtr_;
// vertex mapper of the bulk grid
BulkMapper bulkVertexMapper_;
......
......@@ -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 and allows obtaining entity insertion indices
* \param embeddings Class that contains the embedments among 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
......
......@@ -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 IsValidGridManager
template< class Embeddings >
class IsValidDomainId
{
using GCBulkGridView = typename GridManager::template Grid<bulkId>::LeafGridView;
using GCLowDimGridView = typename GridManager::template Grid<lowDimId>::LeafGridView;
using GCBulkGridView = typename Embeddings::template GridView<bulkId>;
using GCLowDimGridView = typename Embeddings::template GridView<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 EmbedmentExecutionPolicy >
template< class Embeddings, typename AddCouplingEntryPolicy >
void update_(const BulkFVG& bulkFvGridGeometry,
const LowDimFVG& lowDimFvGridGeometry,
const GridManager& gridManager,
EmbedmentExecutionPolicy&& embedmentPolicy)
std::shared_ptr<const Embeddings> embeddings,
AddCouplingEntryPolicy&& addCouplingEntryPolicy)
{
// some static assertions on the grid creator
static_assert(IsValidGridManager< GridManager >::value, "Grid type mismatch. Please review the provided domain id offset.");
static_assert(IsValidDomainId<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 embedmentEntityIndices<lowDimId>(element);
auto adjoinedEntities = embeddings->template adjoinedEntityIndices<lowDimId>(element);
// proceed only if embedments were found
if (embedments.size() == 0)
// proceed only if element is embedded
if (adjoinedEntities.size() == 0)
continue;
// turn embedments into actual grid element indices ...
std::for_each(embedments.begin(), embedments.end(), [&] (auto& idx) { idx = bulkInsertionToElemIdxMap[idx]; });
// turn (insertion) indices into actual grid element indices ...
std::for_each(adjoinedEntities.begin(), adjoinedEntities.end(), [&] (auto& idx) { idx = bulkInsertionToElemIdxMap[idx]; });
// ... and add them
embedmentPolicy(std::move(embedments), element, lowDimFvGridGeometry, bulkFvGridGeometry);
addCouplingEntryPolicy(std::move(adjoinedEntities), 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;
}
......
......@@ -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> >& embedmentMap(std::size_t id)
std::unordered_map< IndexType, std::vector<IndexType> >& adjoinedEntityMap(std::size_t id)
{
assert(id < numGrids && "Index exceeds number of grids provided");
return embedmentMaps_[id];
return adjoinedEntityMaps_[id];
}
private:
......@@ -398,7 +398,7 @@ private:
if ( std::all_of(e.cornerIndices.begin(), e.cornerIndices.end(), vertIsContained) )
{
embeddedEntityMaps_[gridIdx][curElemIdx].push_back(i);
embedmentMaps_[embeddedGridIdx][i].push_back(curElemIdx);
adjoinedEntityMaps_[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 > embedmentMaps_;
std::array< std::unordered_map< IndexType, std::vector<IndexType> >, numGrids > adjoinedEntityMaps_;
//! data on domain and boundary markers
std::array< std::vector<int>, numGrids > elementMarkerMaps_;
......
......@@ -16,8 +16,8 @@
*****************************************************************************/
/*!
* \file
* \ingroup MixedDimension
* \ingroup MixedDimensionFacet
* \ingroup MultiDomain
* \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 MixedDimension
* \ingroup MixedDimensionFacet
* \ingroup MultiDomain
* \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 FacetCouplingGridManager
class FacetCouplingEmbeddings
{
// 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;