Skip to content
Snippets Groups Projects
Commit 6860c44c authored by Carsten Gräser's avatar Carsten Gräser
Browse files

Add utility function markBoundaryDOfs

If we have `markBoundaryPatchDofs()` there should also be
`markBoundaryDofs()` to avoid having to construct a `BoundaryPatch`
in the trivial cases.
parent 427126ed
Branches
No related tags found
1 merge request!258Add constraints support for dune-functions basis
......@@ -50,6 +50,39 @@ void markBoundaryPatchDofs(const BoundaryPatch<GridView>& boundaryPatch,
});
}
/**
* \brief For a given basis determine all degrees of freedom on the boundary.
*
* Set each entry of the vector to true, that corresponds to a DOF
* associated to an intersection (or a subentity) contained in the
* boundary. If the passed vector does not implement
* the VectorBackend concept, it is automatically wrapped in a
* Dune::Functions::ISTLVectorBackend.
*
* \param basis Mark DOFS of this basis
* \param vector A bit vector corresponding to the basis DOFs
*/
template <class Basis, class Vector>
void markBoundaryDofs(const Basis& basis,
Vector& vector)
{
auto&& toVectorBackend = [&](auto& v) -> decltype(auto) {
if constexpr (Dune::models<Dune::Functions::Concept::VectorBackend<Basis>, decltype(v)>()) {
return v;
} else {
return Dune::Functions::istlVectorBackend(v);
}
};
auto&& vectorBackend = toVectorBackend(vector);
vectorBackend.resize(basis);
vectorBackend = false;
Dune::Functions::forEachBoundaryDOF(basis, [&] (auto&& index) {
vectorBackend[index] = true;
});
}
} // namespace Dune::Fufem
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment