My Project
EclSpecrockLawParams.hpp
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 */
27 #ifndef OPM_ECL_SPECROCK_LAW_PARAMS_HPP
28 #define OPM_ECL_SPECROCK_LAW_PARAMS_HPP
29 
31 
33 
34 namespace Opm {
35 
40 template <class ScalarT>
42 {
44 
45 public:
46  typedef ScalarT Scalar;
47 
49 
51  { }
52 
56  template <class Container>
57  void setHeatCapacities(const Container& temperature,
58  const Container& heatCapacity)
59  {
60  assert(temperature.size() == heatCapacity.size());
61 
62  // integrate the heat capacity to compute the internal energy
63  Scalar curU = temperature[0]*heatCapacity[0];
64  unsigned n = temperature.size();
65  std::vector<Scalar> T(n);
66  std::vector<Scalar> u(n);
67  for (unsigned i = 0; i < temperature.size(); ++ i) {
68  T[i] = temperature[i];
69  u[i] = curU;
70 
71  if (i >= temperature.size() - 1)
72  break;
73 
74  // integrate to the heat capacity from the current sampling point to the next
75  // one. this leads to a quadratic polynomial.
76  Scalar c_v0 = heatCapacity[i];
77  Scalar c_v1 = heatCapacity[i + 1];
78  Scalar T0 = temperature[i];
79  Scalar T1 = temperature[i + 1];
80  curU += 0.5*(c_v0 + c_v1)*(T1 - T0);
81  }
82 
83  internalEnergyFunction_.setXYContainers(T, u);
84  }
85 
95  { EnsureFinalized::check(); return internalEnergyFunction_; }
96 
97 private:
98  InternalEnergyFunction internalEnergyFunction_;
99 };
100 
101 } // namespace Opm
102 
103 #endif
Default implementation for asserting finalization of parameter objects.
Implements a linearly interpolated scalar function that depends on one variable.
The default implementation of a parameter object for the ECL thermal law based on SPECROCK.
Definition: EclSpecrockLawParams.hpp:42
const InternalEnergyFunction & internalEnergyFunction() const
Return the function which maps temparature to the rock's volumetric internal energy.
Definition: EclSpecrockLawParams.hpp:94
void setHeatCapacities(const Container &temperature, const Container &heatCapacity)
Specify the volumetric internal energy of rock via heat capacities.
Definition: EclSpecrockLawParams.hpp:57
Default implementation for asserting finalization of parameter objects.
Definition: EnsureFinalized.hpp:47
void setXYContainers(const ScalarContainerX &x, const ScalarContainerY &y, bool sortInputs=true)
Set the sampling points for the piecewise linear function.
Definition: Tabulated1DFunction.hpp:127