12#ifndef DUMUX_CCTPFA_FACETCOUPLING_MAPPER_HH
13#define DUMUX_CCTPFA_FACETCOUPLING_MAPPER_HH
15#include <dune/common/indices.hh>
16#include <dune/common/float_cmp.hh>
37template<
class BulkFVG,
class LowDimFVG, std::
size_t bulkId, std::
size_t lowDimId>
42 using LowDimElement =
typename LowDimFVG::GridView::template Codim<0>::Entity;
43 using GlobalPosition =
typename LowDimElement::Geometry::GlobalCoordinate;
47 using ParentType::bulkGridId;
48 using ParentType::facetGridId;
58 template<
class Embeddings >
59 void update(
const BulkFVG& bulkFvGridGeometry,
60 const LowDimFVG& lowDimFvGridGeometry,
61 std::shared_ptr<const Embeddings> embeddings)
64 auto addCouplingEntryPolicy = [&] (
auto&& adjoinedEntityIndices,
65 const LowDimElement& lowDimElement,
66 const LowDimFVG& lowDimFvGridGeometry,
67 const BulkFVG& bulkFvGridGeometry)
72 const auto lowDimGeometry = lowDimElement.geometry();
73 const auto lowDimElemIdx = lowDimFvGridGeometry.elementMapper().index(lowDimElement);
74 auto& lowDimData = this->couplingMap_(facetGridId, bulkGridId)[lowDimElemIdx];
76 auto fvGeometry =
localView(bulkFvGridGeometry);
79 for (
auto bulkElemIdx : adjoinedEntityIndices)
81 const auto bulkElement = bulkFvGridGeometry.element(bulkElemIdx);
82 fvGeometry.bindElement(bulkElement);
85 BulkIndexType embeddedScvfIdx;
86 for (
const auto& scvf : scvfs(fvGeometry))
92 if ( std::find(adjoinedEntityIndices.begin(),
93 adjoinedEntityIndices.end(),
94 scvf.outsideScvIdx()) != adjoinedEntityIndices.end() )
96 embeddedScvfIdx = scvf.index();
104 const auto eps = lowDimGeometry.volume()*1e-8;
105 const auto diffVec = lowDimGeometry.center()-scvf.center();
107 if ( Dune::FloatCmp::eq<GlobalPosition, Dune::FloatCmp::CmpStyle::absolute>(diffVec, GlobalPosition(0.0), eps) )
109 embeddedScvfIdx = scvf.index();
117 DUNE_THROW(Dune::InvalidStateException,
"Could not find coupling scvf in embedment");
120 auto& bulkData = this->couplingMap_(bulkGridId, facetGridId)[bulkElemIdx];
122 ? this->extractNodalDofs_(lowDimElement, lowDimFvGridGeometry)
123 : std::vector<LowDimIndexType>( {lowDimElemIdx} );
125 for (
auto dofIdx : lowDimElementDofs)
127 bulkData.couplingStencil.push_back( dofIdx );
128 bulkData.dofToCouplingScvfMap[dofIdx].push_back( embeddedScvfIdx );
132 bulkData.couplingElementStencil.push_back(lowDimElemIdx);
133 bulkData.elementToScvfMap[lowDimElemIdx].push_back( embeddedScvfIdx );
136 lowDimData.embedments.emplace_back( bulkElemIdx, std::vector<BulkIndexType>({embeddedScvfIdx}) );
140 lowDimData.couplingStencil = std::move(adjoinedEntityIndices);
144 ParentType::update_(bulkFvGridGeometry, lowDimFvGridGeometry, embeddings, addCouplingEntryPolicy);
149 auto makeStencilUnique = [] (
auto& data)
151 auto& cs = data.second.couplingStencil;
152 std::sort(cs.begin(), cs.end());
153 cs.erase( std::unique(cs.begin(), cs.end()), cs.end() );
156 auto& bulkCouplingData = this->couplingMap_(bulkGridId, facetGridId);
157 std::for_each(bulkCouplingData.begin(), bulkCouplingData.end(), makeStencilUnique);
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:59
Base class for the coupling mapper that sets up and stores the coupling maps between two domains of d...
Definition: couplingmapperbase.hh:41
Implementation for the coupling mapper that sets up and stores the coupling maps between two domains ...
Definition: facet/couplingmapper.hh:42
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:26
The available discretization methods in Dumux.
constexpr Box box
Definition: method.hh:147
typename GridView::IndexSet::IndexType GridIndex
Definition: indextraits.hh:27