mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
VFPInjProperties: template Scalar type
This commit is contained in:
parent
8a4e78e7c4
commit
099322b0f0
@ -17,45 +17,47 @@
|
|||||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <opm/simulators/wells/VFPInjProperties.hpp>
|
#include <opm/simulators/wells/VFPInjProperties.hpp>
|
||||||
|
|
||||||
|
#include <opm/input/eclipse/Schedule/VFPInjTable.hpp>
|
||||||
|
|
||||||
#include <opm/material/densead/Math.hpp>
|
#include <opm/material/densead/Math.hpp>
|
||||||
#include <opm/material/densead/Evaluation.hpp>
|
#include <opm/material/densead/Evaluation.hpp>
|
||||||
|
|
||||||
#include <opm/input/eclipse/Schedule/VFPInjTable.hpp>
|
|
||||||
|
|
||||||
#include <opm/simulators/wells/VFPHelpers.hpp>
|
#include <opm/simulators/wells/VFPHelpers.hpp>
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
|
|
||||||
double VFPInjProperties::bhp(int table_id,
|
template<class Scalar>
|
||||||
const double& aqua,
|
Scalar VFPInjProperties<Scalar>::
|
||||||
const double& liquid,
|
bhp(const int table_id,
|
||||||
const double& vapour,
|
const Scalar aqua,
|
||||||
const double& thp_arg) const {
|
const Scalar liquid,
|
||||||
|
const Scalar vapour,
|
||||||
|
const Scalar thp_arg) const
|
||||||
|
{
|
||||||
const VFPInjTable& table = detail::getTable(m_tables, table_id);
|
const VFPInjTable& table = detail::getTable(m_tables, table_id);
|
||||||
|
|
||||||
detail::VFPEvaluation retval = detail::bhp(table, aqua, liquid, vapour, thp_arg);
|
detail::VFPEvaluation retval = detail::bhp(table, aqua, liquid, vapour, thp_arg);
|
||||||
return retval.value;
|
return retval.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
double VFPInjProperties::thp(int table_id,
|
template<class Scalar>
|
||||||
const double& aqua,
|
Scalar VFPInjProperties<Scalar>::
|
||||||
const double& liquid,
|
thp(const int table_id,
|
||||||
const double& vapour,
|
const Scalar aqua,
|
||||||
const double& bhp_arg) const {
|
const Scalar liquid,
|
||||||
|
const Scalar vapour,
|
||||||
|
const Scalar bhp_arg) const
|
||||||
|
{
|
||||||
const VFPInjTable& table = detail::getTable(m_tables, table_id);
|
const VFPInjTable& table = detail::getTable(m_tables, table_id);
|
||||||
|
|
||||||
//Find interpolation variables
|
//Find interpolation variables
|
||||||
const double flo = detail::getFlo(table, aqua, liquid, vapour);
|
const Scalar flo = detail::getFlo(table, aqua, liquid, vapour);
|
||||||
if (std::abs(flo) < std::numeric_limits<double>::epsilon()) {
|
if (std::abs(flo) < std::numeric_limits<Scalar>::epsilon()) {
|
||||||
return 0.;
|
return 0.;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,34 +70,41 @@ double VFPInjProperties::thp(int table_id,
|
|||||||
* expensive, but let us assome that nthp is small
|
* expensive, but let us assome that nthp is small
|
||||||
*/
|
*/
|
||||||
auto flo_i = detail::findInterpData(flo, table.getFloAxis());
|
auto flo_i = detail::findInterpData(flo, table.getFloAxis());
|
||||||
std::vector<double> bhp_array(nthp);
|
std::vector<Scalar> bhp_array(nthp);
|
||||||
for (int i=0; i<nthp; ++i) {
|
for (int i = 0; i < nthp; ++i) {
|
||||||
auto thp_i = detail::findInterpData(thp_array[i], thp_array);
|
auto thp_i = detail::findInterpData(thp_array[i], thp_array);
|
||||||
bhp_array[i] = detail::interpolate(table, flo_i, thp_i).value;
|
bhp_array[i] = detail::interpolate(table, flo_i, thp_i).value;
|
||||||
}
|
}
|
||||||
|
|
||||||
double retval = detail::findTHP(bhp_array, thp_array, bhp_arg);
|
return detail::findTHP(bhp_array, thp_array, bhp_arg);
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const VFPInjTable& VFPInjProperties::getTable(const int table_id) const {
|
template<class Scalar>
|
||||||
|
const VFPInjTable&
|
||||||
|
VFPInjProperties<Scalar>::getTable(const int table_id) const
|
||||||
|
{
|
||||||
return detail::getTable(m_tables, table_id);
|
return detail::getTable(m_tables, table_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VFPInjProperties::hasTable(const int table_id) const {
|
template<class Scalar>
|
||||||
|
bool VFPInjProperties<Scalar>::hasTable(const int table_id) const
|
||||||
|
{
|
||||||
return detail::hasTable(m_tables, table_id);
|
return detail::hasTable(m_tables, table_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VFPInjProperties::addTable(const VFPInjTable& new_table) {
|
template<class Scalar>
|
||||||
|
void VFPInjProperties<Scalar>::addTable(const VFPInjTable& new_table)
|
||||||
|
{
|
||||||
this->m_tables.emplace( new_table.getTableNum(), new_table );
|
this->m_tables.emplace( new_table.getTableNum(), new_table );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class Scalar>
|
||||||
template <class EvalWell>
|
template <class EvalWell>
|
||||||
EvalWell VFPInjProperties::bhp(const int table_id,
|
EvalWell VFPInjProperties<Scalar>::bhp(const int table_id,
|
||||||
const EvalWell& aqua,
|
const EvalWell& aqua,
|
||||||
const EvalWell& liquid,
|
const EvalWell& liquid,
|
||||||
const EvalWell& vapour,
|
const EvalWell& vapour,
|
||||||
const double& thp) const
|
const Scalar thp) const
|
||||||
{
|
{
|
||||||
//Get the table
|
//Get the table
|
||||||
const VFPInjTable& table = detail::getTable(m_tables, table_id);
|
const VFPInjTable& table = detail::getTable(m_tables, table_id);
|
||||||
@ -116,12 +125,14 @@ EvalWell VFPInjProperties::bhp(const int table_id,
|
|||||||
return bhp;
|
return bhp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template class VFPInjProperties<double>;
|
||||||
|
|
||||||
#define INSTANCE(...) \
|
#define INSTANCE(...) \
|
||||||
template __VA_ARGS__ VFPInjProperties::bhp<__VA_ARGS__>(const int, \
|
template __VA_ARGS__ VFPInjProperties<double>::bhp<__VA_ARGS__>(const int, \
|
||||||
const __VA_ARGS__&, \
|
const __VA_ARGS__&, \
|
||||||
const __VA_ARGS__&, \
|
const __VA_ARGS__&, \
|
||||||
const __VA_ARGS__&, \
|
const __VA_ARGS__&, \
|
||||||
const double&) const;
|
const double) const;
|
||||||
|
|
||||||
INSTANCE(DenseAd::Evaluation<double, -1, 4u>)
|
INSTANCE(DenseAd::Evaluation<double, -1, 4u>)
|
||||||
INSTANCE(DenseAd::Evaluation<double, -1, 5u>)
|
INSTANCE(DenseAd::Evaluation<double, -1, 5u>)
|
||||||
@ -139,4 +150,5 @@ INSTANCE(DenseAd::Evaluation<double, 7, 0u>)
|
|||||||
INSTANCE(DenseAd::Evaluation<double, 8, 0u>)
|
INSTANCE(DenseAd::Evaluation<double, 8, 0u>)
|
||||||
INSTANCE(DenseAd::Evaluation<double, 9, 0u>)
|
INSTANCE(DenseAd::Evaluation<double, 9, 0u>)
|
||||||
INSTANCE(DenseAd::Evaluation<double, 10, 0u>)
|
INSTANCE(DenseAd::Evaluation<double, 10, 0u>)
|
||||||
|
|
||||||
} //Namespace Opm
|
} //Namespace Opm
|
||||||
|
@ -30,9 +30,9 @@ namespace Opm {
|
|||||||
|
|
||||||
class VFPInjTable;
|
class VFPInjTable;
|
||||||
|
|
||||||
|
template<class Scalar>
|
||||||
class VFPInjProperties {
|
class VFPInjProperties {
|
||||||
public:
|
public:
|
||||||
VFPInjProperties() = default;
|
|
||||||
/**
|
/**
|
||||||
* Takes *no* ownership of data.
|
* Takes *no* ownership of data.
|
||||||
*/
|
*/
|
||||||
@ -55,11 +55,11 @@ public:
|
|||||||
* input ADB objects.
|
* input ADB objects.
|
||||||
*/
|
*/
|
||||||
template <class EvalWell>
|
template <class EvalWell>
|
||||||
EvalWell bhp(const int table_id,
|
EvalWell bhp(const int table_id,
|
||||||
const EvalWell& aqua,
|
const EvalWell& aqua,
|
||||||
const EvalWell& liquid,
|
const EvalWell& liquid,
|
||||||
const EvalWell& vapour,
|
const EvalWell& vapour,
|
||||||
const double& thp) const;
|
const Scalar thp) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the table associated with the ID, or throws an exception if
|
* Returns the table associated with the ID, or throws an exception if
|
||||||
@ -75,7 +75,8 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Returns true if no vfp tables are in the current map
|
* Returns true if no vfp tables are in the current map
|
||||||
*/
|
*/
|
||||||
bool empty() const {
|
bool empty() const
|
||||||
|
{
|
||||||
return m_tables.empty();
|
return m_tables.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,11 +91,11 @@ public:
|
|||||||
* @return The bottom hole pressure, interpolated/extrapolated linearly using
|
* @return The bottom hole pressure, interpolated/extrapolated linearly using
|
||||||
* the above parameters from the values in the input table.
|
* the above parameters from the values in the input table.
|
||||||
*/
|
*/
|
||||||
double bhp(int table_id,
|
Scalar bhp(const int table_id,
|
||||||
const double& aqua,
|
const Scalar aqua,
|
||||||
const double& liquid,
|
const Scalar liquid,
|
||||||
const double& vapour,
|
const Scalar vapour,
|
||||||
const double& thp) const;
|
const Scalar thp) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Linear interpolation of thp as a function of the input parameters
|
* Linear interpolation of thp as a function of the input parameters
|
||||||
@ -107,19 +108,17 @@ public:
|
|||||||
* @return The tubing hole pressure, interpolated/extrapolated linearly using
|
* @return The tubing hole pressure, interpolated/extrapolated linearly using
|
||||||
* the above parameters from the values in the input table.
|
* the above parameters from the values in the input table.
|
||||||
*/
|
*/
|
||||||
double thp(int table_id,
|
Scalar thp(const int table_id,
|
||||||
const double& aqua,
|
const Scalar aqua,
|
||||||
const double& liquid,
|
const Scalar liquid,
|
||||||
const double& vapour,
|
const Scalar vapour,
|
||||||
const double& bhp) const;
|
const Scalar bhp) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Map which connects the table number with the table itself
|
// Map which connects the table number with the table itself
|
||||||
std::map<int, std::reference_wrapper<const VFPInjTable>> m_tables;
|
std::map<int, std::reference_wrapper<const VFPInjTable>> m_tables;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} //namespace
|
} //namespace
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
#include <opm/simulators/wells/VFPHelpers.hpp>
|
#include <opm/simulators/wells/VFPHelpers.hpp>
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <map>
|
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
|
|
||||||
@ -61,7 +60,8 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Returns the VFP properties for injection wells
|
* Returns the VFP properties for injection wells
|
||||||
*/
|
*/
|
||||||
const VFPInjProperties* getInj() const {
|
const VFPInjProperties<double>* getInj() const
|
||||||
|
{
|
||||||
return &m_inj;
|
return &m_inj;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,13 +93,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VFPInjProperties m_inj;
|
VFPInjProperties<double> m_inj;
|
||||||
VFPProdProperties m_prod;
|
VFPProdProperties m_prod;
|
||||||
const WellState<double>& well_state_;
|
const WellState<double>& well_state_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace Opm
|
||||||
} //Namespace
|
|
||||||
|
|
||||||
#endif /* OPM_AUTODIFF_VFPPROPERTIES_HPP_ */
|
#endif /* OPM_AUTODIFF_VFPPROPERTIES_HPP_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user