From: Matthias Maier Date: Thu, 27 Aug 2015 03:46:18 +0000 (-0500) Subject: Refactor template definitions into tensor_function.templates.h X-Git-Tag: v8.4.0-rc2~541^2~5 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=422f91f70fdc17094400d60d9fbc1ecf04e9f920;p=dealii.git Refactor template definitions into tensor_function.templates.h --- diff --git a/include/deal.II/base/tensor_function.templates.h b/include/deal.II/base/tensor_function.templates.h new file mode 100644 index 0000000000..6e1981e6b9 --- /dev/null +++ b/include/deal.II/base/tensor_function.templates.h @@ -0,0 +1,164 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 1999 - 2015 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + +#ifndef dealii__tensor_function_templates_h +#define dealii__tensor_function_templates_h + +#include +#include +#include + +#include +#include + +DEAL_II_NAMESPACE_OPEN + + +template +TensorFunction::TensorFunction (const Number initial_time) + : + FunctionTime (initial_time) +{} + + +template +TensorFunction::~TensorFunction () +{} + + +template +typename TensorFunction::value_type +TensorFunction::value (const Point &) const +{ + Assert (false, ExcPureFunctionCalled()); + return Tensor(); +} + + +template +void +TensorFunction::value_list ( + const std::vector > &points, + std::vector &values) const +{ + Assert (values.size() == points.size(), + ExcDimensionMismatch(values.size(), points.size())); + + for (unsigned int i=0; ivalue (points[i]); +} + + +template +typename TensorFunction::gradient_type +TensorFunction::gradient (const Point &) const +{ + Assert (false, ExcPureFunctionCalled()); + return Tensor(); +} + + +template +void +TensorFunction::gradient_list ( + const std::vector > &points, + std::vector &gradients) const +{ + Assert (gradients.size() == points.size(), + ExcDimensionMismatch(gradients.size(), points.size())); + + for (unsigned int i=0; i +ConstantTensorFunction::ConstantTensorFunction ( + const Tensor &value, + const Number initial_time) + : + TensorFunction (initial_time), + _value(value) +{} + + +template +ConstantTensorFunction::~ConstantTensorFunction () +{} + + +template +typename TensorFunction::value_type +ConstantTensorFunction::value ( + const Point &/*point*/) const +{ + return _value; +} + + +template +void +ConstantTensorFunction::value_list ( + const std::vector > &points, + std::vector::value_type> &values) const +{ + (void)points; + Assert (values.size() == points.size(), + ExcDimensionMismatch(values.size(), points.size())); + + for (unsigned int i=0; i +typename TensorFunction::gradient_type +ConstantTensorFunction::gradient (const Point &) const +{ + static const Tensor zero; + + return zero; +} + + +template +void +ConstantTensorFunction::gradient_list ( + const std::vector > &points, + std::vector::gradient_type> &gradients) const +{ + (void)points; + Assert (gradients.size() == points.size(), + ExcDimensionMismatch(gradients.size(), points.size())); + + static const Tensor zero; + + for (unsigned int i=0; i +ZeroTensorFunction::ZeroTensorFunction (const Number initial_time) + : + ConstantTensorFunction (dealii::Tensor(), initial_time) +{} + + +DEAL_II_NAMESPACE_CLOSE + +#endif /* dealii__tensor_function_templates_h */ diff --git a/source/base/tensor_function.cc b/source/base/tensor_function.cc index 28d2618c66..f976e6eabb 100644 --- a/source/base/tensor_function.cc +++ b/source/base/tensor_function.cc @@ -13,162 +13,11 @@ // // --------------------------------------------------------------------- -#include -#include -#include -#include -#include +#include DEAL_II_NAMESPACE_OPEN - - -////////////////////////////////////////////////////////////////////// -// TensorFunction -////////////////////////////////////////////////////////////////////// - -template -TensorFunction::TensorFunction (const Number initial_time) - : - FunctionTime (initial_time) -{} - - - -template -TensorFunction::~TensorFunction () -{} - - -template -typename TensorFunction::value_type -TensorFunction::value (const Point &) const -{ - Assert (false, ExcPureFunctionCalled()); - return Tensor(); -} - - -template -void -TensorFunction::value_list (const std::vector > &points, - std::vector &values) const -{ - Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - - for (unsigned int i=0; ivalue (points[i]); -} - - -template -typename TensorFunction::gradient_type -TensorFunction::gradient (const Point &) const -{ - Assert (false, ExcPureFunctionCalled()); - return Tensor(); -} - - -template -void -TensorFunction::gradient_list (const std::vector > &points, - std::vector &gradients) const -{ - Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); - - for (unsigned int i=0; i -ConstantTensorFunction::ConstantTensorFunction (const Tensor &value, - const Number initial_time) - : - TensorFunction (initial_time), - _value(value) -{} - - -template -ConstantTensorFunction::~ConstantTensorFunction () -{} - - -template -typename TensorFunction::value_type -ConstantTensorFunction::value (const Point &/*point*/) const -{ - return _value; -} - - -template -void -ConstantTensorFunction::value_list (const std::vector > &points, - std::vector::value_type> &values) const -{ - (void)points; - Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - - for (unsigned int i=0; i -typename TensorFunction::gradient_type -ConstantTensorFunction::gradient (const Point &) const -{ - static const Tensor zero; - - return zero; -} - - -template -void -ConstantTensorFunction::gradient_list (const std::vector > &points, - std::vector::gradient_type> &gradients) const -{ - (void)points; - Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); - - static const Tensor zero; - - for (unsigned int i=0; i -ZeroTensorFunction::ZeroTensorFunction (const Number initial_time) - : - ConstantTensorFunction (dealii::Tensor(), initial_time) -{} - - - -////////////////////////////////////////////////////////////////////// // Explicit instantiations: -////////////////////////////////////////////////////////////////////// template class TensorFunction<1,1>; template class TensorFunction<2,1>;