mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-12-27 01:31:00 -06:00
add some fluid state classes
namely BlackoilStateToFluidState which takes a BlackoilState object and exposes it as a opm-material like fluid state object. Similar for ExplicitArraysFluidState, which takes raw arrays. since fluid states are a local API, the index of the cell to be used for these two classes must be set externally. The advantage of this concept is that it is possible to make "saturation functions" which not only depend on saturations but also on arbitrary other quanties (like temperature or phase composition) without having to change the API of the "saturation" functions.
This commit is contained in:
parent
55786028fd
commit
5af89a0e55
94
opm/core/simulator/BlackoilStateToFluidState.hpp
Normal file
94
opm/core/simulator/BlackoilStateToFluidState.hpp
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2015 Andreas Lauser
|
||||||
|
|
||||||
|
This file is part of the Open Porous Media project (OPM).
|
||||||
|
|
||||||
|
OPM is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OPM is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef OPM_BLACKOIL_STATE_TO_FLUID_STATE_HEADER_INCLUDED
|
||||||
|
#define OPM_BLACKOIL_STATE_TO_FLUID_STATE_HEADER_INCLUDED
|
||||||
|
|
||||||
|
#include <opm/core/simulator/BlackoilState.hpp>
|
||||||
|
|
||||||
|
namespace Opm
|
||||||
|
{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief This is an light weight "impedance adaption" class with a well defined API for
|
||||||
|
* saturation and PVT functions.
|
||||||
|
*
|
||||||
|
* It uses a stripped down version of opm-material's FluidState API and takes an
|
||||||
|
* Opm::BlackoilState plus a cell index.
|
||||||
|
*
|
||||||
|
* Note that this class requires that is underlying BlackoilState must valid for at least
|
||||||
|
* as long as an object of BlackoilStateToFluidState is used.
|
||||||
|
*/
|
||||||
|
class BlackoilStateToFluidState
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef double Scalar;
|
||||||
|
|
||||||
|
enum { numPhases = 3 };
|
||||||
|
enum { numComponents = 3 };
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Create a BlackoilState to Fluid state wrapper object.
|
||||||
|
*
|
||||||
|
* Note that this class requires that is underlying BlackoilState must valid for at least
|
||||||
|
* as long as an object of BlackoilStateToFluidState is used.
|
||||||
|
*/
|
||||||
|
BlackoilStateToFluidState(const BlackoilState& blackoilState)
|
||||||
|
: blackoilState_(blackoilState)
|
||||||
|
{
|
||||||
|
if (blackoilState_.numPhases() != numPhases) {
|
||||||
|
OPM_THROW(std::runtime_error,
|
||||||
|
"Only " << numPhases << " are supported, but the deck specifies " << blackoilState_.numPhases());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Sets the index of the currently used cell.
|
||||||
|
*
|
||||||
|
* After calling this, the values returned by the other methods are specific for this
|
||||||
|
* cell.
|
||||||
|
*/
|
||||||
|
void setCurrentCellIndex(unsigned cellIdx)
|
||||||
|
{ cellIdx_ = cellIdx; }
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Returns the saturation of a phase for the current cell index.
|
||||||
|
*/
|
||||||
|
Scalar saturation(int phaseIdx) const
|
||||||
|
{ return blackoilState_.saturation()[numPhases*cellIdx_ + phaseIdx]; }
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Returns the temperature [K] of a phase for the current cell index.
|
||||||
|
*/
|
||||||
|
Scalar temperature(int phaseIdx) const
|
||||||
|
{ return blackoilState_.temperature()[cellIdx_]; }
|
||||||
|
|
||||||
|
// TODO (?) pressure, composition, etc
|
||||||
|
|
||||||
|
private:
|
||||||
|
size_t numCells() const
|
||||||
|
{ return blackoilState_.pressure().size(); }
|
||||||
|
|
||||||
|
const BlackoilState& blackoilState_;
|
||||||
|
unsigned cellIdx_;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Opm
|
||||||
|
|
||||||
|
#endif // OPM_SIMULATORTIMER_HEADER_INCLUDED
|
97
opm/core/simulator/ExplicitArraysFluidState.hpp
Normal file
97
opm/core/simulator/ExplicitArraysFluidState.hpp
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2015 Andreas Lauser
|
||||||
|
|
||||||
|
This file is part of the Open Porous Media project (OPM).
|
||||||
|
|
||||||
|
OPM is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OPM is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef OPM_EXPLICIT_ARRAYS_FLUID_STATE_HEADER_INCLUDED
|
||||||
|
#define OPM_EXPLICIT_ARRAYS_FLUID_STATE_HEADER_INCLUDED
|
||||||
|
|
||||||
|
#include <opm/core/simulator/BlackoilState.hpp>
|
||||||
|
|
||||||
|
namespace Opm
|
||||||
|
{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief This is a fluid state which translates global arrays and translates them to a
|
||||||
|
* subset of the fluid state API.
|
||||||
|
*
|
||||||
|
* This class is similar to Opm::BlackoilStateToFluidState.
|
||||||
|
*/
|
||||||
|
class ExplicitArraysFluidState
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef double Scalar;
|
||||||
|
|
||||||
|
enum { numPhases = 3 };
|
||||||
|
enum { numComponents = 3 };
|
||||||
|
|
||||||
|
ExplicitArraysFluidState()
|
||||||
|
{}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Sets the currently used array index.
|
||||||
|
*
|
||||||
|
* After calling this, the values returned by the other methods are specific for this
|
||||||
|
* index.
|
||||||
|
*/
|
||||||
|
void setIndex(unsigned arrayIdx)
|
||||||
|
{ arrayIdx_ = arrayIdx; }
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Set the array containing the phase saturations.
|
||||||
|
*
|
||||||
|
* This array is supposed to be of size numPhases*size and is not allowed to be
|
||||||
|
* deleted while the ExplicitArraysFluidState object is alive. This class assumes
|
||||||
|
* that the saturations of all phase saturations for a point are consequtive, i.e.,
|
||||||
|
* in the array the saturations cycle fastest.
|
||||||
|
*/
|
||||||
|
void setSaturationArray(const double* saturations)
|
||||||
|
{ saturations_ = saturations; }
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Set the array containing the phase temperatures.
|
||||||
|
*
|
||||||
|
* This array is supposed to be of size 'size' and is not allowed to be
|
||||||
|
* deleted while the ExplicitArraysFluidState object is alive.
|
||||||
|
*/
|
||||||
|
void setTemperatureArray(const double* temperature)
|
||||||
|
{ temperature_ = temperature; }
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Returns the saturation of a phase for the current cell index.
|
||||||
|
*/
|
||||||
|
Scalar saturation(int phaseIdx) const
|
||||||
|
{ return saturations_[numPhases*arrayIdx_ + phaseIdx]; }
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Returns the temperature [K] of a phase for the current cell index.
|
||||||
|
*/
|
||||||
|
Scalar temperature(int phaseIdx) const
|
||||||
|
{ return temperature_[arrayIdx_]; }
|
||||||
|
|
||||||
|
// TODO (?) pressure, composition, etc
|
||||||
|
|
||||||
|
private:
|
||||||
|
const double* saturations_;
|
||||||
|
const double* temperature_;
|
||||||
|
|
||||||
|
unsigned arrayIdx_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Opm
|
||||||
|
|
||||||
|
#endif // OPM_SIMULATORTIMER_HEADER_INCLUDED
|
Loading…
Reference in New Issue
Block a user