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  Copyright (C) 2011-2013 by Andreas Lauser
5 
6  This file is part of the Open Porous Media project (OPM).
7 
8  OPM is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 2 of the License, or
11  (at your option) any later version.
12 
13  OPM is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with OPM. If not, see <http://www.gnu.org/licenses/>.
20 */
26 #ifndef EWOMS_FLASH_PRIMARY_VARIABLES_HH
27 #define EWOMS_FLASH_PRIMARY_VARIABLES_HH
28 
29 #include "flashindices.hh"
30 #include "flashproperties.hh"
31 
34 
35 #include <opm/material/constraintsolvers/NcpFlash.hpp>
36 #include <opm/material/fluidstates/CompositionalFluidState.hpp>
37 
38 #include <dune/common/fvector.hh>
39 
40 #include <iostream>
41 
42 namespace Ewoms {
43 
53 template <class TypeTag>
55 {
56  typedef FvBasePrimaryVariables<TypeTag> ParentType;
57 
58  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
59  typedef typename GET_PROP_TYPE(TypeTag, Evaluation) Evaluation;
60  typedef typename GET_PROP_TYPE(TypeTag, MaterialLawParams) MaterialLawParams;
61  typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
62  typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
63 
64  // primary variable indices
65  enum { cTot0Idx = Indices::cTot0Idx };
66 
67  enum { numPhases = GET_PROP_VALUE(TypeTag, NumPhases) };
68  enum { numComponents = GET_PROP_VALUE(TypeTag, NumComponents) };
69 
70  typedef typename Opm::MathToolbox<Evaluation> Toolbox;
72 
73 public:
74  FlashPrimaryVariables() : ParentType()
75  { Valgrind::SetDefined(*this); }
76 
80  FlashPrimaryVariables(Scalar value) : ParentType(value)
81  {
82  Valgrind::CheckDefined(value);
83  Valgrind::SetDefined(*this);
84  }
85 
91  : ParentType(value)
92  { Valgrind::SetDefined(*this); }
93 
97  template <class FluidState>
98  void assignMassConservative(const FluidState &fluidState,
99  const MaterialLawParams &matParams,
100  bool isInEquilibrium = false)
101  {
102  // there is no difference between naive and mass conservative
103  // assignment in the flash model. (we only need the total
104  // concentrations.)
105  assignNaive(fluidState);
106  }
107 
111  template <class FluidState>
112  void assignNaive(const FluidState &fluidState)
113  {
114  // reset everything
115  (*this) = 0.0;
116 
117  // assign the phase temperatures. this is out-sourced to
118  // the energy module
119  EnergyModule::setPriVarTemperatures(*this, fluidState);
120 
121  // determine the phase presence.
122  for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
123  for (int compIdx = 0; compIdx < numComponents; ++compIdx) {
124  this->operator[](cTot0Idx + compIdx) +=
125  fluidState.molarity(phaseIdx, compIdx) * fluidState.saturation(phaseIdx);
126  }
127  }
128  }
129 
135  void print(std::ostream &os = std::cout) const
136  {
137  for (int compIdx = 0; compIdx < numComponents; ++compIdx) {
138  os << "(c_tot," << FluidSystem::componentName(compIdx) << " = "
139  << this->operator[](cTot0Idx + compIdx);
140  }
141  os << ")" << std::flush;
142  }
143 };
144 
145 } // namespace Ewoms
146 
147 #endif
Represents the primary variables used by the a model.
void assignMassConservative(const FluidState &fluidState, const MaterialLawParams &matParams, bool isInEquilibrium=false)
Set the primary variables from an arbitrary fluid state in a mass conservative way.
Definition: flashprimaryvariables.hh:98
void print(std::ostream &os=std::cout) const
Prints the names of the primary variables and their values.
Definition: flashprimaryvariables.hh:135
#define GET_PROP_VALUE(TypeTag, PropTagName)
Access the value attribute of a property for a type tag.
Definition: propertysystem.hh:468
Represents the primary variables used by the a model.
Definition: fvbaseprimaryvariables.hh:41
Provides the auxiliary methods required for consideration of the energy equation. ...
Definition: energymodule.hh:54
Definition: baseauxiliarymodule.hh:35
FlashPrimaryVariables(Scalar value)
Constructor with assignment from scalar.
Definition: flashprimaryvariables.hh:80
void assignNaive(const FluidState &fluidState)
Directly retrieve the primary variables from an arbitrary fluid state.
Definition: flashprimaryvariables.hh:112
FlashPrimaryVariables(const FlashPrimaryVariables &value)
Default constructor.
Definition: flashprimaryvariables.hh:90
FlashPrimaryVariables()
Definition: flashprimaryvariables.hh:74
Defines the primary variable and equation indices for the compositional multi-phase model based on fl...
Declares the properties required by the compositional multi-phase model based on flash calculations...
Represents the primary variables used by the compositional flow model based on flash calculations...
Definition: flashprimaryvariables.hh:54
Contains the classes required to consider energy as a conservation quantity in a multi-phase module...