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);
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");
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() );
167 std::for_each(bulkCouplingData.begin(), bulkCouplingData.end(), makeStencilUnique);