22#ifndef DUMUX_CCTPFA_FACETCOUPLING_MAPPER_HH
23#define DUMUX_CCTPFA_FACETCOUPLING_MAPPER_HH
25#include <dune/common/indices.hh>
26#include <dune/common/float_cmp.hh>
47template<
class BulkFVG,
class LowDimFVG, std::
size_t bulkId, std::
size_t lowDimId>
52 using LowDimElement =
typename LowDimFVG::GridView::template Codim<0>::Entity;
53 using GlobalPosition =
typename LowDimElement::Geometry::GlobalCoordinate;
57 using ParentType::bulkGridId;
58 using ParentType::facetGridId;
68 template<
class Embeddings >
69 void update(
const BulkFVG& bulkFvGridGeometry,
70 const LowDimFVG& lowDimFvGridGeometry,
71 std::shared_ptr<const Embeddings> embeddings)
74 auto addCouplingEntryPolicy = [&] (
auto&& adjoinedEntityIndices,
75 const LowDimElement& lowDimElement,
76 const LowDimFVG& lowDimFvGridGeometry,
77 const BulkFVG& bulkFvGridGeometry)
82 const auto lowDimGeometry = lowDimElement.geometry();
83 const auto lowDimElemIdx = lowDimFvGridGeometry.elementMapper().index(lowDimElement);
84 auto& lowDimData = this->couplingMap_(facetGridId, bulkGridId)[lowDimElemIdx];
88 for (
auto bulkElemIdx : adjoinedEntityIndices)
90 const auto bulkElement = bulkFvGridGeometry.element(bulkElemIdx);
92 auto fvGeometry =
localView(bulkFvGridGeometry);
93 fvGeometry.bindElement(bulkElement);
96 BulkIndexType embeddedScvfIdx;
97 for (
const auto& scvf : scvfs(fvGeometry))
101 if (!scvf.boundary())
103 if ( std::find(adjoinedEntityIndices.begin(),
104 adjoinedEntityIndices.end(),
105 scvf.outsideScvIdx()) != adjoinedEntityIndices.end() )
107 embeddedScvfIdx = scvf.index();
115 const auto eps = lowDimGeometry.volume()*1e-8;
116 const auto diffVec = lowDimGeometry.center()-scvf.center();
118 if ( Dune::FloatCmp::eq<GlobalPosition, Dune::FloatCmp::CmpStyle::absolute>(diffVec, GlobalPosition(0.0), eps) )
120 embeddedScvfIdx = scvf.index();
128 DUNE_THROW(Dune::InvalidStateException,
"Could not find coupling scvf in embedment");
131 auto& bulkData = this->couplingMap_(bulkGridId, facetGridId)[bulkElemIdx];
133 ? this->extractNodalDofs_(lowDimElement, lowDimFvGridGeometry)
134 : std::vector<LowDimIndexType>( {lowDimElemIdx} );
136 for (
auto dofIdx : lowDimElementDofs)
138 bulkData.couplingStencil.push_back( dofIdx );
139 bulkData.dofToCouplingScvfMap[dofIdx].push_back( embeddedScvfIdx );
143 bulkData.couplingElementStencil.push_back(lowDimElemIdx);
144 bulkData.elementToScvfMap[lowDimElemIdx].push_back( embeddedScvfIdx );
147 lowDimData.embedments.emplace_back( bulkElemIdx, std::vector<BulkIndexType>({embeddedScvfIdx}) );
151 lowDimData.couplingStencil = std::move(adjoinedEntityIndices);
155 ParentType::update_(bulkFvGridGeometry, lowDimFvGridGeometry, embeddings, addCouplingEntryPolicy);
160 auto makeStencilUnique = [] (
auto& data)
162 auto& cs = data.second.couplingStencil;
163 std::sort(cs.begin(), cs.end());
164 cs.erase( std::unique(cs.begin(), cs.end()), cs.end() );
167 auto& bulkCouplingData = this->couplingMap_(bulkGridId, facetGridId);
168 std::for_each(bulkCouplingData.begin(), bulkCouplingData.end(), makeStencilUnique);
Defines the index types used for grid and local indices.
The available discretization methods in Dumux.
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:38
DiscretizationMethod
The available discretization methods in Dumux.
Definition: method.hh:37
typename GridView::IndexSet::IndexType GridIndex
Definition: indextraits.hh:39
void update(const BulkFVG &bulkFvGridGeometry, const LowDimFVG &lowDimFvGridGeometry, std::shared_ptr< const Embeddings > embeddings)
Update coupling maps. This is the standard interface required by any mapper implementation.
Definition: facet/cellcentered/tpfa/couplingmapper.hh:69
Implementation for the coupling mapper that sets up and stores the coupling maps between two domains ...
Definition: facet/couplingmapper.hh:52
Base class for the coupling mapper that sets up and stores the coupling maps between two domains of d...
Definition: couplingmapperbase.hh:51