Line | Branch | Exec | Source |
---|---|---|---|
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 | // | ||
7 | /*! | ||
8 | * \file | ||
9 | * \ingroup OnePTests | ||
10 | * \brief A test for internal Dirichlet constraints | ||
11 | */ | ||
12 | |||
13 | #ifndef DUMUX_INCOMPRESSIBLE_ONEP_TEST_PROBLEM_INTERNAL_DIRICHLET_HH | ||
14 | #define DUMUX_INCOMPRESSIBLE_ONEP_TEST_PROBLEM_INTERNAL_DIRICHLET_HH | ||
15 | |||
16 | #include <dumux/common/boundarytypes.hh> | ||
17 | #include <dumux/common/numeqvector.hh> | ||
18 | |||
19 | #include <test/porousmediumflow/1p/incompressible/problem.hh> | ||
20 | |||
21 | namespace Dumux { | ||
22 | /*! | ||
23 | * \ingroup OnePTests | ||
24 | * \brief A test for internal Dirichlet constraints | ||
25 | */ | ||
26 | template<class TypeTag> | ||
27 | 6 | class OnePTestProblemInternalDirichlet : public OnePTestProblem<TypeTag> | |
28 | { | ||
29 | using ParentType = OnePTestProblem<TypeTag>; | ||
30 | using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView; | ||
31 | using Element = typename GridView::template Codim<0>::Entity; | ||
32 | using Scalar = GetPropType<TypeTag, Properties::Scalar>; | ||
33 | using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>; | ||
34 | using NeumannValues = Dumux::NumEqVector<PrimaryVariables>; | ||
35 | using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>; | ||
36 | using BoundaryTypes = Dumux::BoundaryTypes<ModelTraits::numEq()>; | ||
37 | using Indices = typename ModelTraits::Indices; | ||
38 | using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>; | ||
39 | using SubControlVolume = typename GridGeometry::SubControlVolume; | ||
40 | using GlobalPosition = typename Element::Geometry::GlobalCoordinate; | ||
41 | |||
42 | static constexpr auto numEq = ModelTraits::numEq(); | ||
43 | |||
44 | public: | ||
45 | 2 | OnePTestProblemInternalDirichlet(std::shared_ptr<const GridGeometry> gridGeometry) | |
46 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | : ParentType(gridGeometry) |
47 | 2 | {} | |
48 | |||
49 | /*! | ||
50 | * \brief Specifies which kind of boundary condition should be | ||
51 | * used for which equation on a given boundary control volume. | ||
52 | * | ||
53 | * \param globalPos The position of the center of the finite volume | ||
54 | */ | ||
55 |
4/10✓ Branch 0 taken 228 times.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 120 times.
|
508 | BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const |
56 | { | ||
57 |
4/10✓ Branch 0 taken 228 times.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 120 times.
|
508 | BoundaryTypes values; |
58 | values.setAllNeumann(); | ||
59 | return values; | ||
60 | } | ||
61 | |||
62 | /*! | ||
63 | * \brief Evaluate the boundary conditions for a neumann | ||
64 | * boundary segment. | ||
65 | * | ||
66 | * \param globalPos The position of the boundary face's integration point in global coordinates | ||
67 | * | ||
68 | * Negative values mean influx. | ||
69 | * E.g. for the mass balance that would be the mass flux in \f$ [ kg / (m^2 \cdot s)] \f$. | ||
70 | */ | ||
71 | 360 | NeumannValues neumannAtPos(const GlobalPosition& globalPos) const | |
72 | { | ||
73 |
2/4✓ Branch 0 taken 270 times.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
360 | const auto& gg = this->gridGeometry(); |
74 |
2/4✓ Branch 0 taken 270 times.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
360 | if (globalPos[0] < gg.bBoxMin()[0] + eps_) |
75 | return NeumannValues(1e3); | ||
76 |
2/4✓ Branch 0 taken 180 times.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
270 | else if (globalPos[1] < gg.bBoxMin()[1] + eps_) |
77 | return NeumannValues(-1e3); | ||
78 | else | ||
79 | return NeumannValues(0.0); | ||
80 | } | ||
81 | |||
82 | //! Enable internal Dirichlet constraints | ||
83 | static constexpr bool enableInternalDirichletConstraints() | ||
84 | { return true; } | ||
85 | |||
86 | /*! | ||
87 | * \brief Tag a degree of freedom to carry internal Dirichlet constraints. | ||
88 | * If true is returned for a dof, the equation for this dof is replaced | ||
89 | * by the constraint that its primary variable values must match the | ||
90 | * user-defined values obtained from the function internalDirichlet(), | ||
91 | * which must be defined in the problem. | ||
92 | * | ||
93 | * \param element The finite element | ||
94 | * \param scv The sub-control volume | ||
95 | */ | ||
96 | 1500 | std::bitset<numEq> hasInternalDirichletConstraint(const Element& element, | |
97 | const SubControlVolume& scv) const | ||
98 | { | ||
99 | // the pure Neumann problem is only defined up to a constant | ||
100 | // we create a well-posed problem by fixing the pressure at one dof in the middle of the domain | ||
101 |
4/4✓ Branch 0 taken 8 times.
✓ Branch 1 taken 792 times.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 396 times.
|
1500 | std::bitset<numEq> values; |
102 |
7/8✓ Branch 1 taken 794 times.
✓ Branch 2 taken 202 times.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 99 times.
✓ Branch 0 taken 8 times.
✓ Branch 3 taken 396 times.
|
1500 | if (scv.dofIndex() == static_cast<std::size_t>(this->gridGeometry().numDofs()/2)) |
103 | 15 | values.set(Indices::pressureIdx); | |
104 | return values; | ||
105 | } | ||
106 | |||
107 | /*! | ||
108 | * \brief Define the values of internal Dirichlet constraints for a degree of freedom. | ||
109 | * \param element The finite element | ||
110 | * \param scv The sub-control volume | ||
111 | */ | ||
112 | 106 | PrimaryVariables internalDirichlet(const Element& element, const SubControlVolume& scv) const | |
113 | { return PrimaryVariables(1e5); } | ||
114 | |||
115 | private: | ||
116 | static constexpr Scalar eps_ = 1.5e-7; | ||
117 | }; | ||
118 | |||
119 | } // end namespace Dumux | ||
120 | |||
121 | #endif | ||
122 |