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