WellTest: optionally instantiate for float

WellInterfaceGeneric: optionally instantiate for float
WellBhpThpCalculator: optionally instantiate for float
WellHelpers: optionally instantiate for float

these need to go together due to circular dependencies
This commit is contained in:
Arne Morten Kvarving 2024-04-12 13:11:09 +02:00
parent 6a71f139b9
commit 9d0670a62d
4 changed files with 81 additions and 58 deletions

View File

@ -1009,11 +1009,11 @@ template<class Scalar>
bool
WellBhpThpCalculator<Scalar>::
bruteForceBracketCommonTHP(const std::function<Scalar(const Scalar)>& eq,
const std::array<Scalar, 2>& range,
Scalar& low, Scalar& high,
std::optional<Scalar>& approximate_solution,
const Scalar& limit,
DeferredLogger& deferred_logger)
const std::array<Scalar, 2>& range,
Scalar& low, Scalar& high,
std::optional<Scalar>& approximate_solution,
const Scalar& limit,
DeferredLogger& deferred_logger)
{
bool bracket_found = false;
low = range[0];
@ -1025,7 +1025,7 @@ bruteForceBracketCommonTHP(const std::function<Scalar(const Scalar)>& eq,
for (int i = 0; i < sample_number + 1; ++i) {
high = range[0] + interval * i;
eq_high = eq(high);
if ( (std::fabs(eq_high) < limit)) {
if ((std::fabs(eq_high) < limit)) {
approximate_solution = high;
break;
}
@ -1049,7 +1049,7 @@ template<class Scalar>
bool
WellBhpThpCalculator<Scalar>::
bruteForceBracketCommonTHP(const std::function<Scalar(const Scalar)>& eq,
Scalar& min_thp, Scalar& max_thp)
Scalar& min_thp, Scalar& max_thp)
{
bool bracket_found = false;
constexpr int sample_number = 1000;
@ -1069,33 +1069,40 @@ bruteForceBracketCommonTHP(const std::function<Scalar(const Scalar)>& eq,
return bracket_found;
}
template class WellBhpThpCalculator<double>;
#define INSTANTIATE(T,...) \
template __VA_ARGS__ \
WellBhpThpCalculator<T>:: \
calculateBhpFromThp(const WellState<T>&, \
const std::vector<__VA_ARGS__>&, \
const Well&, \
const SummaryState&, \
const T, \
DeferredLogger&) const;
#define INSTANCE(...) \
template __VA_ARGS__ WellBhpThpCalculator<double>:: \
calculateBhpFromThp<__VA_ARGS__>(const WellState<double>&, \
const std::vector<__VA_ARGS__>&, \
const Well&, \
const SummaryState&, \
const double, \
DeferredLogger&) const;
#define INSTANTIATE_TYPE(T) \
template class WellBhpThpCalculator<T>; \
INSTANTIATE(T,T) \
INSTANTIATE(T,DenseAd::Evaluation<T,3,0u>) \
INSTANTIATE(T,DenseAd::Evaluation<T,4,0u>) \
INSTANTIATE(T,DenseAd::Evaluation<T,5,0u>) \
INSTANTIATE(T,DenseAd::Evaluation<T,6,0u>) \
INSTANTIATE(T,DenseAd::Evaluation<T,7,0u>) \
INSTANTIATE(T,DenseAd::Evaluation<T,8,0u>) \
INSTANTIATE(T,DenseAd::Evaluation<T,9,0u>) \
INSTANTIATE(T,DenseAd::Evaluation<T,10,0u>) \
INSTANTIATE(T,DenseAd::Evaluation<T,-1,4u>) \
INSTANTIATE(T,DenseAd::Evaluation<T,-1,5u>) \
INSTANTIATE(T,DenseAd::Evaluation<T,-1,6u>) \
INSTANTIATE(T,DenseAd::Evaluation<T,-1,7u>) \
INSTANTIATE(T,DenseAd::Evaluation<T,-1,8u>) \
INSTANTIATE(T,DenseAd::Evaluation<T,-1,9u>) \
INSTANTIATE(T,DenseAd::Evaluation<T,-1,10u>) \
INSTANTIATE(T,DenseAd::Evaluation<T,-1,11u>)
INSTANCE(double)
INSTANCE(DenseAd::Evaluation<double,3,0u>)
INSTANCE(DenseAd::Evaluation<double,4,0u>)
INSTANCE(DenseAd::Evaluation<double,5,0u>)
INSTANCE(DenseAd::Evaluation<double,6,0u>)
INSTANCE(DenseAd::Evaluation<double,7,0u>)
INSTANCE(DenseAd::Evaluation<double,8,0u>)
INSTANCE(DenseAd::Evaluation<double,9,0u>)
INSTANCE(DenseAd::Evaluation<double,10,0u>)
INSTANCE(DenseAd::Evaluation<double,-1,4u>)
INSTANCE(DenseAd::Evaluation<double,-1,5u>)
INSTANCE(DenseAd::Evaluation<double,-1,6u>)
INSTANCE(DenseAd::Evaluation<double,-1,7u>)
INSTANCE(DenseAd::Evaluation<double,-1,8u>)
INSTANCE(DenseAd::Evaluation<double,-1,9u>)
INSTANCE(DenseAd::Evaluation<double,-1,10u>)
INSTANCE(DenseAd::Evaluation<double,-1,11u>)
INSTANTIATE_TYPE(double)
#if FLOW_INSTANTIATE_FLOAT
INSTANTIATE_TYPE(float)
#endif
} // namespace Opm

View File

@ -215,34 +215,42 @@ bool rateControlWithZeroInjTarget(const WellInjectionControls& controls,
}
}
template class ParallelStandardWellB<double>;
template<int Dim> using Vec = Dune::BlockVector<Dune::FieldVector<double,Dim>>;
using DynVec = Dune::BlockVector<Dune::DynamicVector<double>>;
#define INSTANCE(Dim) \
template void ParallelStandardWellB<double>::mv<Vec<Dim>,DynVec>(const Vec<Dim>&,DynVec&) const; \
template void ParallelStandardWellB<double>::mmv<Vec<Dim>,DynVec>(const Vec<Dim>&,DynVec&) const;
INSTANCE(1)
INSTANCE(2)
INSTANCE(3)
INSTANCE(4)
INSTANCE(5)
INSTANCE(6)
template<class Scalar, int Dim>
using Vec = Dune::BlockVector<Dune::FieldVector<Scalar,Dim>>;
template<class Scalar>
using DynVec = Dune::BlockVector<Dune::DynamicVector<Scalar>>;
template<class Scalar>
using DMatrix = Dune::DynamicMatrix<Scalar>;
using Comm = Parallel::Communication;
template void sumDistributedWellEntries<double,Comm>(Dune::DynamicMatrix<double>& mat,
Dune::DynamicVector<double>& vec,
const Comm& comm);
using DMatrix = Dune::DynamicMatrix<double>;
template DMatrix transposeDenseDynMatrix<DMatrix>(const DMatrix&);
#define INSTANTIATE(T,Dim) \
template void ParallelStandardWellB<T>:: \
mv(const Vec<T,Dim>&,DynVec<T>&) const; \
template void ParallelStandardWellB<T>:: \
mmv(const Vec<T,Dim>&,DynVec<T>&) const;
template double computeHydrostaticCorrection<double>(const double,
const double,
const double,
const double);
#define INSTANTIATE_TYPE(T) \
template class ParallelStandardWellB<T>; \
template void sumDistributedWellEntries(Dune::DynamicMatrix<T>& mat, \
Dune::DynamicVector<T>& vec, \
const Comm& comm); \
template DMatrix<T> transposeDenseDynMatrix(const DMatrix<T>&); \
template T computeHydrostaticCorrection(const T, \
const T, \
const T, \
const T); \
INSTANTIATE(T,1) \
INSTANTIATE(T,2) \
INSTANTIATE(T,3) \
INSTANTIATE(T,4) \
INSTANTIATE(T,5) \
INSTANTIATE(T,6)
INSTANTIATE_TYPE(double)
#if FLOW_INSTANTIATE_FLOAT
INSTANTIATE_TYPE(float)
#endif
} // namespace wellhelpers
} // namespace Opm

View File

@ -869,4 +869,8 @@ prepareForPotentialCalculations(const SummaryState& summary_state,
template class WellInterfaceGeneric<double>;
#if FLOW_INSTANTIATE_FLOAT
template class WellInterfaceGeneric<float>;
#endif
} // namespace Opm

View File

@ -481,4 +481,8 @@ updateWellTestStatePhysical(const double simulation_time,
template class WellTest<double>;
#if FLOW_INSTANTIATE_FLOAT
template class WellTest<float>;
#endif
} // namespace Opm