All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
flashprimaryvariables.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  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 2 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 
19  Consult the COPYING file in the top-level source directory of this
20  module for the precise wording of the license and the list of
21  copyright holders.
22 */
28 #ifndef EWOMS_FLASH_PRIMARY_VARIABLES_HH
29 #define EWOMS_FLASH_PRIMARY_VARIABLES_HH
30 
31 #include "flashindices.hh"
32 #include "flashproperties.hh"
33 
36 
37 #include <opm/material/constraintsolvers/NcpFlash.hpp>
38 #include <opm/material/fluidstates/CompositionalFluidState.hpp>
39 #include <opm/common/Valgrind.hpp>
40 #include <opm/common/Unused.hpp>
41 
42 #include <dune/common/fvector.hh>
43 
44 #include <iostream>
45 
46 namespace Ewoms {
47 
57 template <class TypeTag>
59 {
60  typedef FvBasePrimaryVariables<TypeTag> ParentType;
61 
62  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
63  typedef typename GET_PROP_TYPE(TypeTag, Evaluation) Evaluation;
64  typedef typename GET_PROP_TYPE(TypeTag, MaterialLawParams) MaterialLawParams;
65  typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
66  typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
67 
68  // primary variable indices
69  enum { cTot0Idx = Indices::cTot0Idx };
70 
71  enum { numPhases = GET_PROP_VALUE(TypeTag, NumPhases) };
72  enum { numComponents = GET_PROP_VALUE(TypeTag, NumComponents) };
73 
74  typedef typename Opm::MathToolbox<Evaluation> Toolbox;
76 
77 public:
78  FlashPrimaryVariables() : ParentType()
79  { Opm::Valgrind::SetDefined(*this); }
80 
84  FlashPrimaryVariables(Scalar value) : ParentType(value)
85  {
86  Opm::Valgrind::CheckDefined(value);
87  Opm::Valgrind::SetDefined(*this);
88  }
89 
94  FlashPrimaryVariables(const FlashPrimaryVariables& value) = default;
95  FlashPrimaryVariables& operator=(const FlashPrimaryVariables& value) = default;
96 
100  template <class FluidState>
101  void assignMassConservative(const FluidState& fluidState,
102  const MaterialLawParams& matParams OPM_UNUSED,
103  bool isInEquilibrium OPM_UNUSED= false)
104  {
105  // there is no difference between naive and mass conservative
106  // assignment in the flash model. (we only need the total
107  // concentrations.)
108  assignNaive(fluidState);
109  }
110 
114  template <class FluidState>
115  void assignNaive(const FluidState& fluidState)
116  {
117  // reset everything
118  (*this) = 0.0;
119 
120  // assign the phase temperatures. this is out-sourced to
121  // the energy module
122  EnergyModule::setPriVarTemperatures(*this, fluidState);
123 
124  // determine the phase presence.
125  for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
126  for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx) {
127  this->operator[](cTot0Idx + compIdx) +=
128  fluidState.molarity(phaseIdx, compIdx) * fluidState.saturation(phaseIdx);
129  }
130  }
131  }
132 
138  void print(std::ostream& os = std::cout) const
139  {
140  for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx) {
141  os << "(c_tot," << FluidSystem::componentName(compIdx) << " = "
142  << this->operator[](cTot0Idx + compIdx);
143  }
144  os << ")" << std::flush;
145  }
146 };
147 
148 } // namespace Ewoms
149 
150 #endif
Provides the auxiliary methods required for consideration of the energy equation. ...
Definition: energymodule.hh:59
#define GET_PROP_VALUE(TypeTag, PropTagName)
Access the value attribute of a property for a type tag.
Definition: propertysystem.hh:469
Contains the classes required to consider energy as a conservation quantity in a multi-phase module...
Declares the properties required by the compositional multi-phase model based on flash calculations...
void assignMassConservative(const FluidState &fluidState, const MaterialLawParams &matParams OPM_UNUSED, bool isInEquilibrium OPM_UNUSED=false)
Set the primary variables from an arbitrary fluid state in a mass conservative way.
Definition: flashprimaryvariables.hh:101
Represents the primary variables used by the a model.
Definition: fvbaseprimaryvariables.hh:48
Defines the primary variable and equation indices for the compositional multi-phase model based on fl...
Represents the primary variables used by the compositional flow model based on flash calculations...
Definition: flashprimaryvariables.hh:58
Represents the primary variables used by the a model.
FlashPrimaryVariables(Scalar value)
Constructor with assignment from scalar.
Definition: flashprimaryvariables.hh:84
void print(std::ostream &os=std::cout) const
Prints the names of the primary variables and their values.
Definition: flashprimaryvariables.hh:138
void assignNaive(const FluidState &fluidState)
Directly retrieve the primary variables from an arbitrary fluid state.
Definition: flashprimaryvariables.hh:115