32#ifndef OPM_MATERIAL_MATH_TOOLBOX_HPP
33#define OPM_MATERIAL_MATH_TOOLBOX_HPP
39#include <opm/common/utility/gpuDecorators.hpp>
49template <
class ScalarT>
52 static_assert(std::is_floating_point<ScalarT>::value,
53 "This class expects floating point scalars! (specialization missing?)");
125 if (numDerivatives != 0)
126 throw std::logic_error(
"Plain floating point objects cannot represent any derivatives");
149 {
throw std::logic_error(
"Plain floating point objects cannot represent variables"); }
160 {
throw std::logic_error(
"Plain floating point objects cannot represent variables"); }
173 template <
class LhsEval>
176 static_assert(std::is_floating_point<LhsEval>::value,
177 "The left-hand side must be a primitive floating point type!");
188 Scalar denom = std::max<Scalar>(1.0, std::abs(a + b));
190 return std::abs(valueDiff) < tolerance || std::abs(valueDiff)/denom < tolerance;
199 {
return std::max(arg1, arg2); }
203 {
return std::min(arg1, arg2); }
207 {
return std::abs(arg); }
211 {
return std::tan(arg); }
215 {
return std::atan(arg); }
219 {
return std::atan2(arg1, arg2); }
223 {
return std::sin(arg); }
227 {
return std::asin(arg); }
231 {
return std::sinh(arg); }
235 {
return std::asinh(arg); }
239 {
return std::cos(arg); }
243 {
return std::acos(arg); }
247 {
return std::cosh(arg); }
251 {
return std::acosh(arg); }
255 {
return std::sqrt(arg); }
259 {
return std::exp(arg); }
263 {
return std::log10(arg); }
267 {
return std::log(arg); }
271 {
return std::pow(base,
exp); }
275 {
return std::isfinite(arg); }
279 {
return std::isnan(arg); }
282template <
class Eval1,
class Eval2>
285 typedef typename std::remove_const< typename std::remove_reference<Eval1>::type >::type T;
286 typedef typename std::remove_const< typename std::remove_reference<Eval2>::type >::type U;
291 typedef typename std::conditional<std::is_constructible<T, U>::value,
297template <
class Evaluation>
298OPM_HOST_DEVICE Evaluation blank(
const Evaluation& x)
301template <
class Evaluation,
class Scalar>
302OPM_HOST_DEVICE Evaluation constant(
const Scalar& value)
305template <
class Evaluation,
class Scalar>
306OPM_HOST_DEVICE Evaluation constant(
unsigned numDeriv,
const Scalar& value)
309template <
class Evaluation,
class Scalar>
310OPM_HOST_DEVICE Evaluation constant(
const Evaluation& x,
const Scalar& value)
313template <
class Evaluation,
class Scalar>
314OPM_HOST_DEVICE Evaluation variable(
unsigned numDeriv,
const Scalar& value,
unsigned idx)
317template <
class Evaluation,
class Scalar>
318OPM_HOST_DEVICE Evaluation variable(
const Evaluation& x,
const Scalar& value,
unsigned idx)
321template <
class Evaluation,
class Scalar>
322OPM_HOST_DEVICE Evaluation variable(
const Scalar& value,
unsigned idx)
325template <
class ResultEval,
class Evaluation>
326OPM_HOST_DEVICE
auto decay(
const Evaluation& value)
327 ->
decltype(MathToolbox<Evaluation>::template decay<ResultEval>(value))
328{
return MathToolbox<Evaluation>::template decay<ResultEval>(value); }
330template <
class Evaluation>
331OPM_HOST_DEVICE
auto getValue(
const Evaluation& val)
335template <
class Evaluation>
336OPM_HOST_DEVICE
auto scalarValue(
const Evaluation& val)
340template <
class Evaluation1,
class Evaluation2>
341typename ReturnEval_<Evaluation1, Evaluation2>::type
342OPM_HOST_DEVICE max(
const Evaluation1& arg1,
const Evaluation2& arg2)
343{
return MathToolbox<typename ReturnEval_<Evaluation1, Evaluation2>::type>::max(arg1, arg2); }
345template <
class Evaluation1,
class Evaluation2>
346typename ReturnEval_<Evaluation1, Evaluation2>::type
347OPM_HOST_DEVICE min(
const Evaluation1& arg1,
const Evaluation2& arg2)
348{
return MathToolbox<typename ReturnEval_<Evaluation1, Evaluation2>::type>::min(arg1, arg2); }
350template <
class Evaluation>
351OPM_HOST_DEVICE Evaluation abs(
const Evaluation& value)
354template <
class Evaluation>
355OPM_HOST_DEVICE Evaluation tan(
const Evaluation& value)
358template <
class Evaluation>
359OPM_HOST_DEVICE Evaluation atan(
const Evaluation& value)
362template <
class Evaluation1,
class Evaluation2>
363typename ReturnEval_<Evaluation1, Evaluation2>::type
364OPM_HOST_DEVICE atan2(
const Evaluation1& value1,
const Evaluation2& value2)
365{
return MathToolbox<typename ReturnEval_<Evaluation1, Evaluation2>::type>::atan2(value1, value2); }
367template <
class Evaluation>
368OPM_HOST_DEVICE Evaluation sin(
const Evaluation& value)
371template <
class Evaluation>
372OPM_HOST_DEVICE Evaluation asin(
const Evaluation& value)
375template <
class Evaluation>
376OPM_HOST_DEVICE Evaluation sinh(
const Evaluation& value)
379template <
class Evaluation>
380OPM_HOST_DEVICE Evaluation asinh(
const Evaluation& value)
383template <
class Evaluation>
384OPM_HOST_DEVICE Evaluation cos(
const Evaluation& value)
387template <
class Evaluation>
388OPM_HOST_DEVICE Evaluation acos(
const Evaluation& value)
391template <
class Evaluation>
392OPM_HOST_DEVICE Evaluation cosh(
const Evaluation& value)
395template <
class Evaluation>
396OPM_HOST_DEVICE Evaluation acosh(
const Evaluation& value)
399template <
class Evaluation>
400OPM_HOST_DEVICE Evaluation sqrt(
const Evaluation& value)
403template <
class Evaluation>
404OPM_HOST_DEVICE Evaluation exp(
const Evaluation& value)
407template <
class Evaluation>
408OPM_HOST_DEVICE Evaluation log(
const Evaluation& value)
411template <
class Evaluation>
412OPM_HOST_DEVICE Evaluation log10(
const Evaluation& value)
415template <
class Evaluation1,
class Evaluation2>
416typename ReturnEval_<Evaluation1, Evaluation2>::type
417OPM_HOST_DEVICE pow(
const Evaluation1& base,
const Evaluation2& exp)
418{
return MathToolbox<typename ReturnEval_<Evaluation1, Evaluation2>::type>::pow(base, exp); }
420template <
class Evaluation>
421OPM_HOST_DEVICE
bool isfinite(
const Evaluation& value)
424template <
class Evaluation>
425OPM_HOST_DEVICE
bool isnan(
const Evaluation& value)
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Definition MathToolbox.hpp:284