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];
86 auto fvGeometry =
localView(bulkFvGridGeometry);
89 for (
auto bulkElemIdx : adjoinedEntityIndices)
91 const auto bulkElement = bulkFvGridGeometry.element(bulkElemIdx);
92 fvGeometry.bindElement(bulkElement);
95 BulkIndexType embeddedScvfIdx;
96 for (
const auto& scvf : scvfs(fvGeometry))
100 if (!scvf.boundary())
102 if ( std::find(adjoinedEntityIndices.begin(),
103 adjoinedEntityIndices.end(),
104 scvf.outsideScvIdx()) != adjoinedEntityIndices.end() )
106 embeddedScvfIdx = scvf.index();
114 const auto eps = lowDimGeometry.volume()*1e-8;
115 const auto diffVec = lowDimGeometry.center()-scvf.center();
117 if ( Dune::FloatCmp::eq<GlobalPosition, Dune::FloatCmp::CmpStyle::absolute>(diffVec, GlobalPosition(0.0), eps) )
119 embeddedScvfIdx = scvf.index();
127 DUNE_THROW(Dune::InvalidStateException,
"Could not find coupling scvf in embedment");
130 auto& bulkData = this->couplingMap_(bulkGridId, facetGridId)[bulkElemIdx];
132 ? this->extractNodalDofs_(lowDimElement, lowDimFvGridGeometry)
133 : std::vector<LowDimIndexType>( {lowDimElemIdx} );
135 for (
auto dofIdx : lowDimElementDofs)
137 bulkData.couplingStencil.push_back( dofIdx );
138 bulkData.dofToCouplingScvfMap[dofIdx].push_back( embeddedScvfIdx );
142 bulkData.couplingElementStencil.push_back(lowDimElemIdx);
143 bulkData.elementToScvfMap[lowDimElemIdx].push_back( embeddedScvfIdx );
146 lowDimData.embedments.emplace_back( bulkElemIdx, std::vector<BulkIndexType>({embeddedScvfIdx}) );
150 lowDimData.couplingStencil = std::move(adjoinedEntityIndices);
154 ParentType::update_(bulkFvGridGeometry, lowDimFvGridGeometry, embeddings, addCouplingEntryPolicy);
159 auto makeStencilUnique = [] (
auto& data)
161 auto& cs = data.second.couplingStencil;
162 std::sort(cs.begin(), cs.end());
163 cs.erase( std::unique(cs.begin(), cs.end()), cs.end() );
166 auto& bulkCouplingData = this->couplingMap_(bulkGridId, facetGridId);
167 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
constexpr Box box
Definition: method.hh:139
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