fixed: fix debug printing with quad
std::to_string(__float128) is not defined we need to instance the evaluation formatter for __float128
This commit is contained in:
parent
27ecbe5c98
commit
509a018ae7
@ -155,6 +155,7 @@ macro (sources_hook)
|
||||
get_target_property(qm_defs QuadMath::QuadMath INTERFACE_COMPILE_DEFINITIONS)
|
||||
get_target_property(qm_options QuadMath::QuadMath INTERFACE_COMPILE_OPTIONS)
|
||||
set_source_files_properties(src/opm/material/components/CO2.cpp
|
||||
src/opm/material/densead/Evaluation.cpp
|
||||
PROPERTIES COMPILE_DEFINITIONS "${qm_defs}"
|
||||
COMPILE_OPTIONS "${qm_options}")
|
||||
endif()
|
||||
|
@ -981,13 +981,24 @@ private:
|
||||
const Evaluation& temperature,
|
||||
const Evaluation& pressure)
|
||||
{
|
||||
auto tostring = [](const auto& val) -> std::string
|
||||
auto cast = [](const auto d)
|
||||
{
|
||||
if constexpr (DenseAd::is_evaluation<Evaluation>::value)
|
||||
return std::to_string(getValue(val.value()));
|
||||
#if HAVE_QUAD
|
||||
if constexpr (std::is_same_v<decltype(d), const quad>)
|
||||
return static_cast<double>(d);
|
||||
else
|
||||
return std::to_string(getValue(val));
|
||||
#endif
|
||||
return d;
|
||||
};
|
||||
auto tostring = [cast](const auto& val) -> std::string
|
||||
{
|
||||
if constexpr (DenseAd::is_evaluation<Evaluation>::value) {
|
||||
return std::to_string(cast(getValue(val.value())));
|
||||
}
|
||||
else
|
||||
return std::to_string(cast(getValue(val)));
|
||||
};
|
||||
|
||||
return type + " is only implemented for temperatures "
|
||||
"below 623.15K and pressures below 100MPa. (T = " +
|
||||
tostring(temperature) + ", p=" + tostring(pressure);
|
||||
|
@ -166,17 +166,27 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
auto cast = [](const auto d)
|
||||
{
|
||||
#if HAVE_QUAD
|
||||
if constexpr (std::is_same_v<decltype(d), const quad>)
|
||||
return static_cast<double>(d);
|
||||
else
|
||||
#endif
|
||||
return d;
|
||||
};
|
||||
|
||||
std::string msg =
|
||||
std::string("Calculating the ")
|
||||
+ FluidSystem::phaseName(phaseIdx)
|
||||
+ "Phase composition failed. Initial {x} = {";
|
||||
for (const auto& v : xInit)
|
||||
msg += " " + std::to_string(getValue(v));
|
||||
msg += " " + std::to_string(cast(getValue(v)));
|
||||
msg += " }, {fug_t} = {";
|
||||
for (const auto& v : targetFug)
|
||||
msg += " " + std::to_string(getValue(v));
|
||||
msg += " }, p = " + std::to_string(getValue(fluidState.pressure(phaseIdx)))
|
||||
+ ", T = " + std::to_string(getValue(fluidState.temperature(phaseIdx)));
|
||||
msg += " " + std::to_string(cast(getValue(v)));
|
||||
msg += " }, p = " + std::to_string(cast(getValue(fluidState.pressure(phaseIdx))))
|
||||
+ ", T = " + std::to_string(cast(getValue(fluidState.temperature(phaseIdx))));
|
||||
throw NumericalProblem(msg);
|
||||
}
|
||||
|
||||
|
@ -232,12 +232,22 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
auto cast = [](const auto d)
|
||||
{
|
||||
#if HAVE_QUAD
|
||||
if constexpr (std::is_same_v<decltype(d), const quad>)
|
||||
return static_cast<double>(d);
|
||||
else
|
||||
#endif
|
||||
return d;
|
||||
};
|
||||
|
||||
std::string msg = "NcpFlash solver failed: "
|
||||
"{c_alpha^kappa} = {";
|
||||
for (const auto& v : globalMolarities)
|
||||
msg += " " + std::to_string(getValue(v));
|
||||
msg += " " + std::to_string(cast(getValue(v)));
|
||||
msg += " }, T = ";
|
||||
msg += std::to_string(getValue(fluidState.temperature(/*phaseIdx=*/0)));
|
||||
msg += std::to_string(cast(getValue(fluidState.temperature(/*phaseIdx=*/0))));
|
||||
throw NumericalProblem(msg);
|
||||
}
|
||||
|
||||
|
@ -490,12 +490,22 @@ private:
|
||||
Valgrind::CheckDefined(xlH2O);
|
||||
Valgrind::CheckDefined(xlCO2);
|
||||
|
||||
auto tostring = [](const auto& val) -> std::string
|
||||
auto cast = [](const auto d)
|
||||
{
|
||||
#if HAVE_QUAD
|
||||
if constexpr (std::is_same_v<decltype(d), const quad>)
|
||||
return static_cast<double>(d);
|
||||
else
|
||||
#endif
|
||||
return d;
|
||||
};
|
||||
|
||||
auto tostring = [cast](const auto& val) -> std::string
|
||||
{
|
||||
if constexpr (DenseAd::is_evaluation<LhsEval>::value) {
|
||||
return std::to_string(getValue(val.value()));
|
||||
return std::to_string(cast(getValue(val.value())));
|
||||
} else {
|
||||
return std::to_string(val);
|
||||
return std::to_string(cast(val));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -24,6 +24,10 @@
|
||||
#include <config.h>
|
||||
#include <opm/material/densead/Evaluation.hpp>
|
||||
|
||||
#if HAVE_QUAD
|
||||
#include <opm/material/common/quad.hpp>
|
||||
#endif
|
||||
|
||||
#include <ostream>
|
||||
|
||||
namespace Opm {
|
||||
@ -52,13 +56,27 @@ void printEvaluation(std::ostream& os,
|
||||
const Evaluation<T,size1,size2>&, \
|
||||
bool);
|
||||
|
||||
#if HAVE_QUAD
|
||||
#define INSTANCE(size) \
|
||||
INSTANCE_IMPL(double,size,0u) \
|
||||
INSTANCE_IMPL(quad,size,0u) \
|
||||
INSTANCE_IMPL(float,size,0u)
|
||||
#else
|
||||
#define INSTANCE(size) \
|
||||
INSTANCE_IMPL(double,size,0u) \
|
||||
INSTANCE_IMPL(float,size,0u)
|
||||
#endif
|
||||
|
||||
#if HAVE_QUAD
|
||||
#define INSTANCE_DYN(size) \
|
||||
INSTANCE_IMPL(double,-1,size) \
|
||||
INSTANCE_IMPL(quad,-1,size) \
|
||||
INSTANCE_IMPL(float,-1,size)
|
||||
#else
|
||||
#define INSTANCE_DYN(size) \
|
||||
INSTANCE_IMPL(double,-1,size) \
|
||||
INSTANCE_IMPL(float,-1,size)
|
||||
#endif
|
||||
|
||||
INSTANCE(1)
|
||||
INSTANCE(2)
|
||||
|
Loading…
Reference in New Issue
Block a user