version 3.11-dev
dirichletconstraints.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3//
4// SPDX-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_DIRICHLET_CONSTRAINTS_HH
13#define DUMUX_DIRICHLET_CONSTRAINTS_HH
14
15#include <concepts>
16#include <unordered_map>
17
19
20namespace Dumux {
21
22template<class Info, class Values>
24{
25 using ConstraintInfo = Info;
26 using ConstraintValues = Values;
27
29 { return info_; }
30
31 const ConstraintValues& values() const
32 { return values_; }
33
36};
37
38template<class DirichletConstraintInfo, class DirichletValues, class IndexType>
39struct DirichletConstraintData : public ConstraintData<DirichletConstraintInfo, DirichletValues>
40{
41 using GridIndexType = IndexType;
42
44 { return dofIdx_; }
45
47};
48
49} // end namespace Dumux
50
51
53
54template <typename C>
56 C& c,
57 typename C::value_type v,
58 typename C::value_type::ConstraintInfo info,
59 typename C::value_type::ConstraintValues vals,
60 typename C::value_type::GridIndexType idx
61){
62 c.push_back(v);
63 { typename C::value_type{info, vals, idx} };
64};
65
66} // end namespace Dumux::CVFE::Detail
67
68
69namespace Dumux::CVFE {
70
78template<class Problem, class DirichletFunction, Detail::DirichletConstraintContainer Constraints>
79void appendDirichletConstraints(const Problem& problem,
80 const DirichletFunction& dirichletFunction,
81 Constraints& constraints)
82{
83 using Data = typename Constraints::value_type;
84 using ConstraintInfo = typename Data::ConstraintInfo;
85 using DirichletValues = typename Data::ConstraintValues;
86
87 auto fvGeometry = localView(problem.gridGeometry());
88 for (const auto& element : elements(problem.gridGeometry().gridView()))
89 {
90 fvGeometry.bind(element);
91 for (const auto& intersection : intersections(problem.gridGeometry().gridView(), element))
92 {
93 if(!intersection.boundary() || intersection.neighbor())
94 continue;
95
96 const auto& bcTypes = problem.boundaryTypes(fvGeometry, intersection);
97 if (bcTypes.hasDirichlet())
98 {
99 for (const auto& localDof : localDofs(fvGeometry, intersection))
100 {
101 ConstraintInfo info;
102 // set the Dirichlet constraints
103 for (int eqIdx = 0; eqIdx < DirichletValues::size(); ++eqIdx)
104 if (bcTypes.isDirichlet(eqIdx))
105 info.set(bcTypes.eqToDirichletIndex(eqIdx), eqIdx);
106
107 auto dirichletValues = dirichletFunction(fvGeometry, intersection, localDof);
108 constraints.push_back(Data{std::move(info), std::move(dirichletValues), localDof.dofIndex()});
109 }
110 }
111 }
112 }
113}
114
115} // end namespace Dumux::CVFE
116
117#endif
Class to specify information related to constraints.
Definition: constraintinfo.hh:26
void set(int eqIdx)
Set a constraint condition for a single equation.
Definition: constraintinfo.hh:64
Definition: dirichletconstraints.hh:55
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:26
Defines the index types used for grid and local indices.
Definition: dirichletconstraints.hh:52
Definition: cvfe/interpolationpointdata.hh:17
void appendDirichletConstraints(const Problem &problem, const DirichletFunction &dirichletFunction, Constraints &constraints)
Append constraints for Dirichlet boundaries.
Definition: dirichletconstraints.hh:79
Definition: adapt.hh:17
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