24#ifndef DUMUX_CCTPFA_FACETCOUPLING_MAPPER_HH
25#define DUMUX_CCTPFA_FACETCOUPLING_MAPPER_HH
27#include <dune/common/indices.hh>
28#include <dune/common/float_cmp.hh>
49template<
class BulkFVG,
class LowDimFVG, std::
size_t bulkId, std::
size_t lowDimId>
54 using LowDimElement =
typename LowDimFVG::GridView::template Codim<0>::Entity;
55 using GlobalPosition =
typename LowDimElement::Geometry::GlobalCoordinate;
59 using ParentType::bulkGridId;
60 using ParentType::facetGridId;
70 template<
class Embeddings >
71 void update(
const BulkFVG& bulkFvGridGeometry,
72 const LowDimFVG& lowDimFvGridGeometry,
73 std::shared_ptr<const Embeddings> embeddings)
76 auto addCouplingEntryPolicy = [&] (
auto&& adjoinedEntityIndices,
77 const LowDimElement& lowDimElement,
78 const LowDimFVG& lowDimFvGridGeometry,
79 const BulkFVG& bulkFvGridGeometry)
84 const auto lowDimGeometry = lowDimElement.geometry();
85 const auto lowDimElemIdx = lowDimFvGridGeometry.elementMapper().index(lowDimElement);
86 auto& lowDimData = this->couplingMap_(facetGridId, bulkGridId)[lowDimElemIdx];
88 auto fvGeometry =
localView(bulkFvGridGeometry);
91 for (
auto bulkElemIdx : adjoinedEntityIndices)
93 const auto bulkElement = bulkFvGridGeometry.element(bulkElemIdx);
94 fvGeometry.bindElement(bulkElement);
97 BulkIndexType embeddedScvfIdx;
98 for (
const auto& scvf : scvfs(fvGeometry))
102 if (!scvf.boundary())
104 if ( std::find(adjoinedEntityIndices.begin(),
105 adjoinedEntityIndices.end(),
106 scvf.outsideScvIdx()) != adjoinedEntityIndices.end() )
108 embeddedScvfIdx = scvf.index();
116 const auto eps = lowDimGeometry.volume()*1e-8;
117 const auto diffVec = lowDimGeometry.center()-scvf.center();
119 if ( Dune::FloatCmp::eq<GlobalPosition, Dune::FloatCmp::CmpStyle::absolute>(diffVec, GlobalPosition(0.0), eps) )
121 embeddedScvfIdx = scvf.index();
129 DUNE_THROW(Dune::InvalidStateException,
"Could not find coupling scvf in embedment");
132 auto& bulkData = this->couplingMap_(bulkGridId, facetGridId)[bulkElemIdx];
134 ? this->extractNodalDofs_(lowDimElement, lowDimFvGridGeometry)
135 : std::vector<LowDimIndexType>( {lowDimElemIdx} );
137 for (
auto dofIdx : lowDimElementDofs)
139 bulkData.couplingStencil.push_back( dofIdx );
140 bulkData.dofToCouplingScvfMap[dofIdx].push_back( embeddedScvfIdx );
144 bulkData.couplingElementStencil.push_back(lowDimElemIdx);
145 bulkData.elementToScvfMap[lowDimElemIdx].push_back( embeddedScvfIdx );
148 lowDimData.embedments.emplace_back( bulkElemIdx, std::vector<BulkIndexType>({embeddedScvfIdx}) );
152 lowDimData.couplingStencil = std::move(adjoinedEntityIndices);
156 ParentType::update_(bulkFvGridGeometry, lowDimFvGridGeometry, embeddings, addCouplingEntryPolicy);
161 auto makeStencilUnique = [] (
auto& data)
163 auto& cs = data.second.couplingStencil;
164 std::sort(cs.begin(), cs.end());
165 cs.erase( std::unique(cs.begin(), cs.end()), cs.end() );
168 auto& bulkCouplingData = this->couplingMap_(bulkGridId, facetGridId);
169 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
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
constexpr Box box
Definition: method.hh:136
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:71
Implementation for the coupling mapper that sets up and stores the coupling maps between two domains ...
Definition: facet/couplingmapper.hh:54
Base class for the coupling mapper that sets up and stores the coupling maps between two domains of d...
Definition: couplingmapperbase.hh:53