Dune-Fufem 2.11-git
Loading...
Searching...
No Matches
continuityconstraints.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3
4// SPDX-FileCopyrightText: Copyright © DUNE-FUFEM Project contributors, see file AUTHORS.md
5// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
6
7#ifndef DUNE_FUFEM_CONSTRAINTS_CONTINUITYCONSTRAINTS_HH
8#define DUNE_FUFEM_CONSTRAINTS_CONTINUITYCONSTRAINTS_HH
9
10#include <type_traits>
11#include <variant>
12
14
17
20
21
22
23namespace Dune::Fufem {
24
25
26
48template<class BV, class V, class MI, class C, class Basis>
50{
51 using Constraints = AffineConstraints<BV, V, MI, C>;
52
54
55 auto&& isInterpolated = Dune::Functions::istlVectorBackend(constraints.isConstrained());
56
57 auto localIndices = [](const auto& tree) {
58 if (tree.size()==0)
59 return Dune::range(std::size_t(0), std::size_t(0));
60 return Dune::range(tree.localIndex(0), tree.localIndex(0)+tree.size());
61 };
62
63 auto localView = basis.localView();
64 auto neighborLocalView = basis.localView();
65 auto intersectionDOFs = Dune::Functions::subEntityDOFs(basis);
66
67 for(const auto& element : elements(basis.gridView()))
68 {
69 localView.bind(element);
70 auto level = element.level();
71
72 bool allDofsConstrained = true;
73 for(auto i : localIndices(localView.tree()))
74 allDofsConstrained = allDofsConstrained and isInterpolated[localView.index(i)];
75 if (allDofsConstrained)
76 continue;
77
78 for(const auto& intersection : intersections(basis.gridView(), element))
79 {
80 if (not(intersection.neighbor()))
81 continue;
82
83 const auto& neighborElement = intersection.outside();
84
85 if (neighborElement.level()>=level)
86 continue;
87
88 intersectionDOFs.bind(localView, intersection);
89
90 neighborLocalView.bind(neighborElement);
91
92 auto secondaryToPrimary = [&](const auto& x) {
93 auto globalPosition = element.geometry().global(x);
94 return neighborElement.geometry().local(globalPosition);
95 };
96
97 computeLocalInterpolationConstraints(neighborLocalView, localView, secondaryToPrimary, intersectionDOFs, constraints);
98 }
99 }
100 constraints.resolveDependencies();
101}
102
103
104
132template<class BitVector=std::monostate, class Vector=std::monostate, class Basis>
133auto makeContinuityConstraints(const Basis& basis)
134{
135 auto constraints = makeAffineConstraints<BitVector, Vector>(basis);
136 computeContinuityConstraints(constraints, basis);
137 return constraints;
138}
139
140} // namespace Dune::Fufem
141
142
143
144#endif // DUNE_FUFEM_CONSTRAINTS_CONTINUITYCONSTRAINTS_HH
auto subEntityDOFs(const T &)
auto istlVectorBackend(Vector &v)
static constexpr IntegralRange< std::decay_t< T > > range(T &&from, U &&to) noexcept
auto makeContinuityConstraints(const Basis &basis)
Compute constraints for a conforming basis on a grid with hanging nodes.
Definition continuityconstraints.hh:133
void computeLocalInterpolationConstraints(const PrimaryLocalView &primaryLocalView, const SecondaryLocalView &secondaryLocalView, const SecondaryToPrimary &localSecondaryToPrimary, const SecondaryDOFs &secondaryDOFs, Constraints &constraints)
Compute local constraints from interpolating between local views.
Definition localinterpolationconstraints.hh:61
void computeContinuityConstraints(AffineConstraints< BV, V, MI, C > &constraints, const Basis &basis)
Compute constraints for a conforming basis on a grid with hanging nodes.
Definition continuityconstraints.hh:49
Definition dunefunctionsboundaryfunctionalassembler.hh:29
Class to handle affine constraints on a subset of DOFs.
Definition affineconstraints.hh:201
void resolveDependencies()
Resolve dependencies of constrained DOFs on other constrained DOFs.
Definition affineconstraints.hh:756
bool isConstrained(const MultiIndexType &i) const
Check if i-th DOF is constrained.
Definition affineconstraints.hh:315
T forward(T... args)