version 3.11-dev
Loading...
Searching...
No Matches
freeflow/navierstokes/mass/1p/variables.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_NAVIERSTOKES_MASS_ONEP_VARIABLES_HH
13#define DUMUX_NAVIERSTOKES_MASS_ONEP_VARIABLES_HH
14
15#include <dumux/common/concepts/ipdata_.hh>
16
17namespace Dumux {
18
26template <class Traits>
28{
29 using Scalar = typename Traits::PrimaryVariables::value_type;
30
31 static_assert(!Traits::ModelTraits::enableEnergyBalance(),
32 "The energy balance is currently not implemented for variables defined per local dof");
33
34public:
36 using PrimaryVariables = typename Traits::PrimaryVariables;
38 using Indices = typename Traits::ModelTraits::Indices;
40 using FluidSystem = typename Traits::FluidSystem;
42 using FluidState = typename Traits::FluidState;
43
45 static constexpr int numFluidPhases() { return Traits::ModelTraits::numFluidPhases(); }
47 static constexpr int numFluidComponents() { return Traits::ModelTraits::numFluidComponents(); }
48
58 template<class ElementSolution, class Problem, class ElementDiscretization, Concept::LocalDofIpData IpData>
59 void update(const ElementSolution& elemSol,
60 const Problem& problem,
61 const ElementDiscretization& elemDisc,
62 const IpData& ipData)
63 {
64 priVars_ = elemSol[ipData.localDofIndex()];
65 extrusionFactor_ = problem.spatialParams().extrusionFactor(elemDisc, ipData, elemSol);
66
67 completeFluidState(elemSol, problem, elemDisc, ipData, fluidState_);
68 }
69
80 template<class ElementSolution, class Problem, class ElementDiscretization, Concept::LocalDofIpData IpData>
81 void completeFluidState(const ElementSolution& elemSol,
82 const Problem& problem,
83 const ElementDiscretization& elemDisc,
84 const IpData& ipData,
86 {
87 fluidState.setTemperature(/*phaseIdx=*/0, problem.spatialParams().temperature(elemDisc, ipData, elemSol));
88 fluidState.setPressure(/*phaseIdx=*/0, elemSol[ipData.localDofIndex()][Indices::pressureIdx]);
89
90 // saturation in a single phase is always 1 and thus redundant to set. But since we use
91 // the fluid state shared by the immiscible multi-phase models, we have to set it here
92 fluidState.setSaturation(/*phaseIdx=*/0, 1.0);
93
94 typename FluidSystem::ParameterCache paramCache;
95 paramCache.updatePhase(fluidState, /*phaseIdx=*/0);
96
97 Scalar value = FluidSystem::density(fluidState, paramCache, /*phaseIdx=*/0);
98 fluidState.setDensity(/*phaseIdx=*/0, value);
99
100 value = FluidSystem::viscosity(fluidState, paramCache, /*phaseIdx=*/0);
101 fluidState.setViscosity(/*phaseIdx=*/0, value);
102
103 // the enthalpy is zero for isothermal models
104 fluidState.setEnthalpy(/*phaseIdx=*/0, 0.0);
105 }
106
110 Scalar extrusionFactor() const
111 { return extrusionFactor_; }
112
117 Scalar pressure(int phaseIdx = 0) const
118 { return fluidState_.pressure(phaseIdx); }
119
123 Scalar saturation(int phaseIdx = 0) const
124 { return 1.0; }
125
129 Scalar density(int phaseIdx = 0) const
130 { return fluidState_.density(phaseIdx); }
131
135 Scalar molarDensity(int phaseIdx = 0) const
136 { return fluidState_.molarDensity(phaseIdx); }
137
141 Scalar viscosity(int phaseIdx = 0) const
142 { return fluidState_.viscosity(phaseIdx); }
143
147 Scalar temperature() const
148 { return fluidState_.temperature(); }
149
153 const FluidState& fluidState() const
154 { return fluidState_; }
155
160 Scalar priVar(const int pvIdx) const
161 { return priVars_[pvIdx]; }
162
167 { return priVars_; }
168
169private:
170 PrimaryVariables priVars_;
171 FluidState fluidState_;
172 Scalar extrusionFactor_;
173};
174
175} // end namespace Dumux
176
177#endif
Variables for the single-phase Navier-Stokes mass model.
Definition freeflow/navierstokes/mass/1p/variables.hh:28
Scalar viscosity(int phaseIdx=0) const
Returns the dynamic viscosity of the fluid.
Definition freeflow/navierstokes/mass/1p/variables.hh:141
typename Traits::ModelTraits::Indices Indices
export the indices type
Definition freeflow/navierstokes/mass/1p/variables.hh:38
typename Traits::FluidSystem FluidSystem
Export the underlying fluid system.
Definition freeflow/navierstokes/mass/1p/variables.hh:40
static constexpr int numFluidComponents()
Return number of components considered by the model.
Definition freeflow/navierstokes/mass/1p/variables.hh:47
Scalar extrusionFactor() const
Return how much the localDof is extruded.
Definition freeflow/navierstokes/mass/1p/variables.hh:110
Scalar temperature() const
Returns the temperature inside the control volume.
Definition freeflow/navierstokes/mass/1p/variables.hh:147
static constexpr int numFluidPhases()
Return number of phases considered by the model.
Definition freeflow/navierstokes/mass/1p/variables.hh:45
void update(const ElementSolution &elemSol, const Problem &problem, const ElementDiscretization &elemDisc, const IpData &ipData)
Update all quantities for a local dof.
Definition freeflow/navierstokes/mass/1p/variables.hh:59
typename Traits::PrimaryVariables PrimaryVariables
export the type used for the primary variables
Definition freeflow/navierstokes/mass/1p/variables.hh:36
typename Traits::FluidState FluidState
Export the fluid state type.
Definition freeflow/navierstokes/mass/1p/variables.hh:42
Scalar molarDensity(int phaseIdx=0) const
Returns the molar density of a given phase.
Definition freeflow/navierstokes/mass/1p/variables.hh:135
const FluidState & fluidState() const
Returns the fluid state of the control volume.
Definition freeflow/navierstokes/mass/1p/variables.hh:153
Scalar priVar(const int pvIdx) const
Return a component of the primary variable vector.
Definition freeflow/navierstokes/mass/1p/variables.hh:160
void completeFluidState(const ElementSolution &elemSol, const Problem &problem, const ElementDiscretization &elemDisc, const IpData &ipData, FluidState &fluidState) const
Sets the complete fluid state.
Definition freeflow/navierstokes/mass/1p/variables.hh:81
Scalar saturation(int phaseIdx=0) const
Returns the saturation.
Definition freeflow/navierstokes/mass/1p/variables.hh:123
Scalar pressure(int phaseIdx=0) const
Returns the effective pressure of a given phase within the control volume.
Definition freeflow/navierstokes/mass/1p/variables.hh:117
Scalar density(int phaseIdx=0) const
Returns the mass density of a given phase.
Definition freeflow/navierstokes/mass/1p/variables.hh:129
const PrimaryVariables & priVars() const
Return the primary variable vector.
Definition freeflow/navierstokes/mass/1p/variables.hh:166
Definition adapt.hh:17