--- /dev/null
+Changed: Time is described by a real-valued scalar in Function, TensorFunction,
+ConstantTensorFunction and ZeroTensorFunction, i.e. all of them derive from
+FunctionTime with a real-valued scalar template parameter.
+<br>
+(Daniel Arndt, 2018/10/26)
* @author Wolfgang Bangerth, 1998, 1999, Luca Heltai 2014
*/
template <int dim, typename RangeNumberType = double>
-class Function : public FunctionTime<RangeNumberType>, public Subscriptor
+class Function : public FunctionTime<
+ typename numbers::NumberTraits<RangeNumberType>::real_type>,
+ public Subscriptor
{
public:
/**
* (which defaults to one, i.e. a scalar function), and the time variable,
* which defaults to zero.
*/
- Function(const unsigned int n_components = 1,
- const RangeNumberType initial_time = 0.0);
+ Function(const unsigned int n_components = 1,
+ const typename numbers::NumberTraits<RangeNumberType>::real_type
+ initial_time = 0.0);
/**
* Virtual destructor; absolutely necessary in this case.
template <int dim, typename RangeNumberType>
-Function<dim, RangeNumberType>::Function(const unsigned int n_components,
- const RangeNumberType initial_time)
- : FunctionTime<RangeNumberType>(initial_time)
+Function<dim, RangeNumberType>::Function(
+ const unsigned int n_components,
+ const typename numbers::NumberTraits<RangeNumberType>::real_type initial_time)
+ : FunctionTime<typename numbers::NumberTraits<RangeNumberType>::real_type>(
+ initial_time)
, n_components(n_components)
{
// avoid the construction of function objects that don't return any
* @author Guido Kanschat, 1999
*/
template <int rank, int dim, typename Number = double>
-class TensorFunction : public FunctionTime<Number>, public Subscriptor
+class TensorFunction
+ : public FunctionTime<typename numbers::NumberTraits<Number>::real_type>,
+ public Subscriptor
{
public:
/**
* Constructor. May take an initial value for the time variable, which
* defaults to zero.
*/
- TensorFunction(const Number initial_time = Number(0.0));
+ TensorFunction(
+ const typename numbers::NumberTraits<Number>::real_type initial_time =
+ typename numbers::NumberTraits<Number>::real_type(0.0));
/**
* Virtual destructor; absolutely necessary in this case, as classes are
* An initial value for the time variable may be specified, otherwise it
* defaults to zero.
*/
- ConstantTensorFunction(const dealii::Tensor<rank, dim, Number> &value,
- const Number initial_time = 0.0);
+ ConstantTensorFunction(
+ const dealii::Tensor<rank, dim, Number> & value,
+ const typename numbers::NumberTraits<Number>::real_type initial_time = 0.0);
virtual ~ConstantTensorFunction() override = default;
* An initial value for the time variable may be specified, otherwise it
* defaults to zero.
*/
- ZeroTensorFunction(const Number initial_time = 0.0);
+ ZeroTensorFunction(
+ const typename numbers::NumberTraits<Number>::real_type initial_time = 0.0);
};
template <int rank, int dim, typename Number>
-TensorFunction<rank, dim, Number>::TensorFunction(const Number initial_time)
- : FunctionTime<Number>(initial_time)
+TensorFunction<rank, dim, Number>::TensorFunction(
+ const typename numbers::NumberTraits<Number>::real_type initial_time)
+ : FunctionTime<typename numbers::NumberTraits<Number>::real_type>(
+ initial_time)
{}
template <int rank, int dim, typename Number>
ConstantTensorFunction<rank, dim, Number>::ConstantTensorFunction(
- const Tensor<rank, dim, Number> &value,
- const Number initial_time)
+ const Tensor<rank, dim, Number> & value,
+ const typename numbers::NumberTraits<Number>::real_type initial_time)
: TensorFunction<rank, dim, Number>(initial_time)
, _value(value)
{}
template <int rank, int dim, typename Number>
ZeroTensorFunction<rank, dim, Number>::ZeroTensorFunction(
- const Number initial_time)
+ const typename numbers::NumberTraits<Number>::real_type initial_time)
: ConstantTensorFunction<rank, dim, Number>(
dealii::Tensor<rank, dim, Number>(),
initial_time)
#include "../tests.h"
-using namespace dealii;
-
template <typename Number>
-class MyFunctionTime : dealii::FunctionTime<Number>
+class MyFunctionTime : public dealii::FunctionTime<Number>
{};
template <int dim, typename Number>
-class MyFunction : dealii::Function<dim, Number>
+class MyFunction : public dealii::Function<dim, Number>
{};
template <int rank, int dim, typename Number>
-class MyTensorFunction : dealii::TensorFunction<rank, dim, Number>
+class MyTensorFunction : public dealii::TensorFunction<rank, dim, Number>
{};
int
{
initlog();
+ MyFunctionTime<std::complex<double>> function_time_1;
+ static_assert(std::is_same<decltype(function_time_1.get_time()),
+ std::complex<double>>::value,
+ "Wrong return type for FunctionTime<double>::get_time().");
+ MyFunctionTime<std::complex<float>> function_time_2;
+ static_assert(std::is_same<decltype(function_time_2.get_time()),
+ std::complex<float>>::value,
+ "Wrong return type for FunctionTime<float>::get_time().");
+
MyFunction<1, std::complex<double>> function_1;
- MyFunction<2, std::complex<float>> function_2;
+ static_assert(std::is_same<decltype(function_1.get_time()), double>::value,
+ "Wrong return type for Function<double>::get_time().");
+ MyFunction<2, std::complex<float>> function_2;
+ static_assert(std::is_same<decltype(function_2.get_time()), float>::value,
+ "Wrong return type for Function<float>::get_time().");
MyTensorFunction<1, 1, std::complex<double>> tensor_function_1;
- MyTensorFunction<2, 2, std::complex<float>> tensor_function_2;
+ static_assert(
+ std::is_same<decltype(tensor_function_1.get_time()), double>::value,
+ "Wrong return type for TensorFunction<double>::get_time().");
+ MyTensorFunction<2, 2, std::complex<float>> tensor_function_2;
+ static_assert(
+ std::is_same<decltype(tensor_function_2.get_time()), float>::value,
+ "Wrong return type for TensorFunction<float>::get_time().");
deallog << "OK" << std::endl;
}