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-FileCopyrightInfo: 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 TwoPNCTests | ||
10 | * \brief Problem of a diffusion | ||
11 | * problem which uses the isothermal 2p2c box model. | ||
12 | */ | ||
13 | #ifndef DUMUX_TWOPNC_DIFFUSION_PROBLEM_HH | ||
14 | #define DUMUX_TWOPNC_DIFFUSION_PROBLEM_HH | ||
15 | |||
16 | #include <dumux/common/properties.hh> | ||
17 | #include <dumux/common/parameters.hh> | ||
18 | #include <dumux/common/boundarytypes.hh> | ||
19 | #include <dumux/common/numeqvector.hh> | ||
20 | |||
21 | #include <dumux/porousmediumflow/problem.hh> | ||
22 | |||
23 | namespace Dumux { | ||
24 | |||
25 | /*! | ||
26 | * \ingroup TwoPNCTests | ||
27 | * \brief Problem of a diffusion | ||
28 | * problem which uses the isothermal 2p2c box model. | ||
29 | */ | ||
30 | template <class TypeTag> | ||
31 | class TwoPNCDiffusionProblem : public PorousMediumFlowProblem<TypeTag> | ||
32 | { | ||
33 | using ParentType = PorousMediumFlowProblem<TypeTag>; | ||
34 | using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView; | ||
35 | using Scalar = GetPropType<TypeTag, Properties::Scalar>; | ||
36 | using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>; | ||
37 | |||
38 | enum { | ||
39 | // Grid and world dimension | ||
40 | dim = GridView::dimension, | ||
41 | dimWorld = GridView::dimensionworld | ||
42 | }; | ||
43 | |||
44 | using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices; | ||
45 | using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>; | ||
46 | using NumEqVector = Dumux::NumEqVector<PrimaryVariables>; | ||
47 | using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>; | ||
48 | using Element = typename GridView::template Codim<0>::Entity; | ||
49 | using GlobalPosition = typename Element::Geometry::GlobalCoordinate; | ||
50 | using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>; | ||
51 | |||
52 | //! Property that defines whether mole or mass fractions are used | ||
53 | static constexpr bool useMoles = getPropValue<TypeTag, Properties::UseMoles>(); | ||
54 | |||
55 | public: | ||
56 | 2 | TwoPNCDiffusionProblem(std::shared_ptr<const GridGeometry> gridGeometry) | |
57 |
7/20✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✓ Branch 15 taken 2 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 2 times.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
6 | : ParentType(gridGeometry) |
58 | { | ||
59 | // initialize the tables of the fluid system | ||
60 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | FluidSystem::init(); |
61 | |||
62 |
2/4✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
|
2 | name_ = getParam<std::string>("Problem.Name"); |
63 | |||
64 | // stating in the console whether mole or mass fractions are used | ||
65 | if(useMoles) | ||
66 | { | ||
67 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
4 | std::cout<<"problem uses mole-fractions"<<std::endl; |
68 | } | ||
69 | else | ||
70 | { | ||
71 | std::cout<<"problem uses mass-fractions"<<std::endl; | ||
72 | } | ||
73 | 2 | } | |
74 | |||
75 | /*! | ||
76 | * \brief Returns the problem name | ||
77 | * | ||
78 | * This is used as a prefix for files generated by the simulation. | ||
79 | */ | ||
80 | const std::string& name() const | ||
81 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | { return name_; } |
82 | |||
83 | /*! | ||
84 | * \brief Specifies which kind of boundary condition should be | ||
85 | * used for which equation on a given boundary segment | ||
86 | * | ||
87 | * \param globalPos The global position | ||
88 | */ | ||
89 | ✗ | BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const | |
90 | { | ||
91 | 67760 | BoundaryTypes bcTypes; | |
92 |
2/8✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 16940 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 50820 times.
✗ Branch 7 not taken.
|
67760 | bcTypes.setAllDirichlet(); |
93 | ✗ | return bcTypes; | |
94 | } | ||
95 | |||
96 | /*! | ||
97 | * \brief Evaluates the boundary conditions for a Dirichlet boundary segment. | ||
98 | * | ||
99 | * \param globalPos The global position | ||
100 | */ | ||
101 | PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const | ||
102 | { | ||
103 |
2/4✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
✓ Branch 3 taken 16170 times.
|
16940 | PrimaryVariables priVars; |
104 |
2/4✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
✓ Branch 3 taken 16170 times.
|
16940 | priVars.setState(Indices::firstPhaseOnly); |
105 |
2/4✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
✓ Branch 3 taken 16170 times.
|
16940 | priVars[Indices::pressureIdx] = 1e5; |
106 |
2/4✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
✓ Branch 3 taken 16170 times.
|
16940 | priVars[Indices::switchIdx] = 1e-5 ; |
107 | |||
108 |
10/20✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 770 times.
✓ Branch 11 taken 16170 times.
✓ Branch 12 taken 770 times.
✓ Branch 13 taken 16170 times.
✓ Branch 14 taken 770 times.
✓ Branch 15 taken 16170 times.
✓ Branch 16 taken 770 times.
✓ Branch 17 taken 16170 times.
✓ Branch 18 taken 770 times.
✓ Branch 19 taken 16170 times.
|
84700 | if (globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_) |
109 | 1540 | priVars[Indices::switchIdx] = 1e-3; | |
110 | |||
111 | return priVars; | ||
112 | } | ||
113 | |||
114 | /*! | ||
115 | * \brief Evaluates the boundary conditions for a Neumann boundary segment. | ||
116 | * | ||
117 | * For this method, the \a priVars parameter stores the mass flux | ||
118 | * in normal direction of each component. Negative values mean influx. | ||
119 | * \param globalPos The global position | ||
120 | * | ||
121 | * \note The units must be according to either using mole or mass fractions (mole/(m^2*s) or kg/(m^2*s)). | ||
122 | */ | ||
123 | ✗ | NumEqVector neumannAtPos(const GlobalPosition& globalPos) const | |
124 | { | ||
125 | ✗ | NumEqVector values(0.0); | |
126 | ✗ | return values; | |
127 | } | ||
128 | |||
129 | /*! | ||
130 | * \brief Evaluates the initial values for a control volume. | ||
131 | * | ||
132 | * \param globalPos The global position | ||
133 | */ | ||
134 | ✗ | PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const | |
135 | { | ||
136 | 1000 | return initial_(globalPos); | |
137 | } | ||
138 | |||
139 | |||
140 | private: | ||
141 | /*! | ||
142 | * \brief Evaluates the initial values for a control volume. | ||
143 | * | ||
144 | * The internal method for the initial condition | ||
145 | * | ||
146 | * \param globalPos The global position | ||
147 | */ | ||
148 | ✗ | PrimaryVariables initial_(const GlobalPosition &globalPos) const | |
149 | { | ||
150 | 500 | PrimaryVariables priVars(0.0); | |
151 | 500 | priVars.setState(Indices::firstPhaseOnly); | |
152 | |||
153 | //mole-fraction formulation | ||
154 | 500 | priVars[Indices::switchIdx] = 1e-5; | |
155 | 1000 | priVars[Indices::pressureIdx] = 1e5; | |
156 | ✗ | return priVars; | |
157 | } | ||
158 | |||
159 | static constexpr Scalar eps_ = 1e-6; | ||
160 | |||
161 | std::string name_ ; | ||
162 | }; | ||
163 | |||
164 | } // end namespace Dumux | ||
165 | |||
166 | #endif | ||
167 |