12#ifndef DUMUX_DIRICHLET_CONSTRAINTS_HH
13#define DUMUX_DIRICHLET_CONSTRAINTS_HH
16#include <unordered_map>
22template<
class Info,
class Values>
38template<
class DirichletConstra
intInfo,
class DirichletValues,
class IndexType>
58 using GridIndexType =
typename Data::GridIndexType;
59 using DirichletConstraintInfo =
typename Data::ConstraintInfo;
60 using DirichletValues =
typename Data::ConstraintValues;
69 template<
class Problem,
typename DirichletFunction>
70 void update(
const Problem& problem,
const DirichletFunction& dirichletFunction)
74 auto fvGeometry =
localView(problem.gridGeometry());
75 for (
const auto& element : elements(problem.gridGeometry().gridView()))
77 fvGeometry.bind(element);
78 for (
const auto& intersection : intersections(problem.gridGeometry().gridView(), element))
80 if(!intersection.boundary() || intersection.neighbor())
83 const auto& bcTypes = problem.boundaryTypes(fvGeometry, intersection);
84 if (bcTypes.hasDirichlet())
86 for (
const auto& localDof :
localDofs(fvGeometry, intersection))
88 DirichletConstraintInfo info;
90 for (
int eqIdx = 0; eqIdx < DirichletValues::size(); ++eqIdx)
91 if (bcTypes.isDirichlet(eqIdx))
92 info.set(bcTypes.eqToDirichletIndex(eqIdx), eqIdx);
94 auto dirichletValues = dirichletFunction(fvGeometry, intersection, localDof);
95 constraints_.push_back(Data{std::move(info), std::move(dirichletValues), localDof.dofIndex()});
103 {
return constraints_.cbegin(); }
106 {
return constraints_.cend(); }
109 std::vector<Data> constraints_;
112static_assert(std::ranges::range<DirichletConstraints<DirichletConstraintData<int, int, int>>>);
Constraints related to Dirichlet boundaries. This class generates global constraints based on Dirichl...
Definition: dirichletconstraints.hh:57
auto end() const
Definition: dirichletconstraints.hh:105
auto begin() const
Definition: dirichletconstraints.hh:102
void update(const Problem &problem, const DirichletFunction &dirichletFunction)
Update the boundary types for all element intersections.
Definition: dirichletconstraints.hh:70
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:26
auto localDofs(const FVElementGeometry &fvGeometry)
range over local dofs
Definition: localdof.hh:50
Definition: dirichletconstraints.hh:24
Info ConstraintInfo
Definition: dirichletconstraints.hh:25
const ConstraintValues & values() const
Definition: dirichletconstraints.hh:31
ConstraintValues values_
Definition: dirichletconstraints.hh:35
ConstraintInfo info_
Definition: dirichletconstraints.hh:34
Values ConstraintValues
Definition: dirichletconstraints.hh:26
const ConstraintInfo & constraintInfo() const
Definition: dirichletconstraints.hh:28
Definition: dirichletconstraints.hh:40
IndexType GridIndexType
Definition: dirichletconstraints.hh:41
GridIndexType dofIndex() const
Definition: dirichletconstraints.hh:43
GridIndexType dofIdx_
Definition: dirichletconstraints.hh:46