From 136ca6f72e5a056c107ead85c293770bc1bf82f4 Mon Sep 17 00:00:00 2001 From: heltai Date: Fri, 18 Jul 2014 15:59:55 +0000 Subject: [PATCH] Added template to function, and made GridOut::write work also in codimension one. git-svn-id: https://svn.dealii.org/trunk@33197 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/doc/news/changes.h | 14 + deal.II/include/deal.II/base/function.h | 226 ++++++------- deal.II/include/deal.II/base/function_time.h | 16 +- .../include/deal.II/base/tensor_function.h | 46 +-- deal.II/include/deal.II/dofs/dof_tools.h | 2 +- deal.II/include/deal.II/dofs/function_map.h | 6 +- deal.II/include/deal.II/grid/grid_out.h | 20 +- deal.II/include/deal.II/grid/grid_tools.h | 2 +- .../deal.II/multigrid/mg_constrained_dofs.h | 2 +- .../include/deal.II/numerics/matrix_tools.h | 1 + .../include/deal.II/numerics/vector_tools.h | 70 ++-- deal.II/source/base/function.cc | 316 +++++++++--------- deal.II/source/base/function_time.cc | 17 +- deal.II/source/base/tensor_function.cc | 72 ++-- deal.II/source/grid/grid_out.cc | 91 +++-- deal.II/source/grid/grid_out.inst.in | 9 + 16 files changed, 488 insertions(+), 422 deletions(-) diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index d9020e8a12..4969a34529 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -190,6 +190,20 @@ inconvenience this causes.

Specific improvements

    +
  1. New: The function GridOut::write, can now be used also in + the codimension one case. +
    + (Luca Heltai, 2014/07/18) +
  2. + +
  3. New: The Function classes, now take an additional optional + template argument, specifying the type of number to use, which defaults + to double. +
    + (Luca Heltai, 2014/07/18) +
  4. + +
  5. New: The GridReordering::reorder_cells() function used a numbering format for the vertices in a cell that was last used in deal.II version 5.2. This format is still used internally, but diff --git a/deal.II/include/deal.II/base/function.h b/deal.II/include/deal.II/base/function.h index a48f4637d4..ace10a1c22 100644 --- a/deal.II/include/deal.II/base/function.h +++ b/deal.II/include/deal.II/base/function.h @@ -32,7 +32,7 @@ DEAL_II_NAMESPACE_OPEN template class Vector; -template class TensorFunction; +template class TensorFunction; /** * This class is a model for a general function that, given a point at which @@ -52,11 +52,11 @@ template class TensorFunction; * methods: * @code * // access to one component at one point - * double value (const Point &p, + * double value (const Point &p, * const unsigned int component = 0) const; * * // return all components at one point - * void vector_value (const Point &p, + * void vector_value (const Point &p, * Vector &value) const; * @endcode * @@ -64,12 +64,12 @@ template class TensorFunction; * components at a list of points at once: * @code * // access to one component at several points - * void value_list (const std::vector > &point_list, + * void value_list (const std::vector > &point_list, * std::vector &value_list, * const unsigned int component = 0) const; * * // return all components at several points - * void vector_value_list (const std::vector > &point_list, + * void vector_value_list (const std::vector > &point_list, * std::vector > &value_list) const; * @endcode * @@ -111,11 +111,11 @@ template class TensorFunction; * class to convert the former to the latter. * * @ingroup functions - * @author Wolfgang Bangerth, 1998, 1999 + * @author Wolfgang Bangerth, 1998, 1999, Luca Heltai 2014 */ -template -class Function : public FunctionTime, - public Subscriptor +template +class Function : public FunctionTime, + public Subscriptor { public: /** @@ -135,7 +135,7 @@ public: * variable, which defaults to zero. */ Function (const unsigned int n_components = 1, - const double initial_time = 0.0); + const Number initial_time = 0.0); /** * Virtual destructor; absolutely necessary in this case. @@ -175,7 +175,7 @@ public: * component you want to have evaluated; it defaults to zero, i.e. the * first component. */ - virtual double value (const Point &p, + virtual Number value (const Point &p, const unsigned int component = 0) const; /** @@ -186,8 +186,8 @@ public: * * The default implementation will call value() for each component. */ - virtual void vector_value (const Point &p, - Vector &values) const; + virtual void vector_value (const Point &p, + Vector &values) const; /** * Set values to the point values of the specified component of @@ -198,8 +198,8 @@ public: * By default, this function repeatedly calls value() for each point * separately, to fill the output array. */ - virtual void value_list (const std::vector > &points, - std::vector &values, + virtual void value_list (const std::vector > &points, + std::vector &values, const unsigned int component = 0) const; /** @@ -212,8 +212,8 @@ public: * By default, this function repeatedly calls vector_value() for each * point separately, to fill the output array. */ - virtual void vector_value_list (const std::vector > &points, - std::vector > &values) const; + virtual void vector_value_list (const std::vector > &points, + std::vector > &values) const; /** * For each component of the function, fill a vector of values, one for @@ -223,22 +223,22 @@ public: * value_list() for each component. In order to improve performance, this * can be reimplemented in derived classes to speed up performance. */ - virtual void vector_values (const std::vector > &points, - std::vector > &values) const; + virtual void vector_values (const std::vector > &points, + std::vector > &values) const; /** * Return the gradient of the specified component of the function at the * given point. */ - virtual Tensor<1,dim> gradient (const Point &p, + virtual Tensor<1,dim, Number> gradient (const Point &p, const unsigned int component = 0) const; /** * Return the gradient of all components of the function at the given * point. */ - virtual void vector_gradient (const Point &p, - std::vector > &gradients) const; + virtual void vector_gradient (const Point &p, + std::vector > &gradients) const; /** * Set gradients to the gradients of the specified component of @@ -246,8 +246,8 @@ public: * gradients already has the right size, i.e. the same size as * the points array. */ - virtual void gradient_list (const std::vector > &points, - std::vector > &gradients, + virtual void gradient_list (const std::vector > &points, + std::vector > &gradients, const unsigned int component = 0) const; /** @@ -258,8 +258,8 @@ public: * value_list() for each component. In order to improve performance, this * can be reimplemented in derived classes to speed up performance. */ - virtual void vector_gradients (const std::vector > &points, - std::vector > > &gradients) const; + virtual void vector_gradients (const std::vector > &points, + std::vector > > &gradients) const; /** * Set gradients to the gradients of the function at the @@ -270,34 +270,34 @@ public: * The outer loop over gradients is over the points in the list, * the inner loop over the different components of the function. */ - virtual void vector_gradient_list (const std::vector > &points, - std::vector > > &gradients) const; + virtual void vector_gradient_list (const std::vector > &points, + std::vector > > &gradients) const; /** * Compute the Laplacian of a given component at point p. */ - virtual double laplacian (const Point &p, + virtual Number laplacian (const Point &p, const unsigned int component = 0) const; /** * Compute the Laplacian of all components at point p and store * them in values. */ - virtual void vector_laplacian (const Point &p, - Vector &values) const; + virtual void vector_laplacian (const Point &p, + Vector &values) const; /** * Compute the Laplacian of one component at a set of points. */ - virtual void laplacian_list (const std::vector > &points, - std::vector &values, + virtual void laplacian_list (const std::vector > &points, + std::vector &values, const unsigned int component = 0) const; /** * Compute the Laplacians of all components at a set of points. */ - virtual void vector_laplacian_list (const std::vector > &points, - std::vector > &values) const; + virtual void vector_laplacian_list (const std::vector > &points, + std::vector > &values) const; /** * Determine an estimate for the memory consumption (in bytes) of this @@ -324,8 +324,8 @@ public: * @ingroup functions * @author Wolfgang Bangerth, 1998, 1999 */ -template -class ZeroFunction : public Function +template +class ZeroFunction : public Function { public: /** @@ -339,31 +339,31 @@ public: */ virtual ~ZeroFunction (); - virtual double value (const Point &p, + virtual Number value (const Point &p, const unsigned int component) const; - virtual void vector_value (const Point &p, - Vector &return_value) const; + virtual void vector_value (const Point &p, + Vector &return_value) const; - virtual void value_list (const std::vector > &points, - std::vector &values, + virtual void value_list (const std::vector > &points, + std::vector &values, const unsigned int component = 0) const; - virtual void vector_value_list (const std::vector > &points, - std::vector > &values) const; + virtual void vector_value_list (const std::vector > &points, + std::vector > &values) const; - virtual Tensor<1,dim> gradient (const Point &p, + virtual Tensor<1,dim, Number> gradient (const Point &p, const unsigned int component = 0) const; - virtual void vector_gradient (const Point &p, - std::vector > &gradients) const; + virtual void vector_gradient (const Point &p, + std::vector > &gradients) const; - virtual void gradient_list (const std::vector > &points, - std::vector > &gradients, + virtual void gradient_list (const std::vector > &points, + std::vector > &gradients, const unsigned int component = 0) const; - virtual void vector_gradient_list (const std::vector > &points, - std::vector > > &gradients) const; + virtual void vector_gradient_list (const std::vector > &points, + std::vector > > &gradients) const; }; @@ -391,15 +391,15 @@ public: * @ingroup functions * @author Wolfgang Bangerth, 1998, 1999 */ -template -class ConstantFunction : public ZeroFunction +template +class ConstantFunction : public ZeroFunction { public: /** * Constructor; takes the constant function value as an argument. The * number of components is preset to one. */ - ConstantFunction (const double value, + ConstantFunction (const Number value, const unsigned int n_components = 1); /** @@ -407,18 +407,18 @@ public: */ virtual ~ConstantFunction (); - virtual double value (const Point &p, + virtual Number value (const Point &p, const unsigned int component) const; - virtual void vector_value (const Point &p, - Vector &return_value) const; + virtual void vector_value (const Point &p, + Vector &return_value) const; - virtual void value_list (const std::vector > &points, - std::vector &values, + virtual void value_list (const std::vector > &points, + std::vector &values, const unsigned int component = 0) const; - virtual void vector_value_list (const std::vector > &points, - std::vector > &values) const; + virtual void vector_value_list (const std::vector > &points, + std::vector > &values) const; std::size_t memory_consumption () const; @@ -426,7 +426,7 @@ protected: /** * Store the constant function value. */ - const double function_value; + const Number function_value; }; @@ -445,8 +445,8 @@ protected: * @ingroup functions * @author Guido Kanschat, 2000, Wolfgang Bangerth 2006 */ -template -class ComponentSelectFunction : public ConstantFunction +template +class ComponentSelectFunction : public ConstantFunction { public: /** @@ -455,7 +455,7 @@ public: * total number of vector components. */ ComponentSelectFunction (const unsigned int selected, - const double value, + const Number value, const unsigned int n_components); /** @@ -479,8 +479,8 @@ public: * Return the value of the function at the given point for all * components. */ - virtual void vector_value (const Point &p, - Vector &return_value) const; + virtual void vector_value (const Point &p, + Vector &return_value) const; /** * Set values to the point values of the function at the @@ -488,8 +488,8 @@ public: * values already has the right size, i.e. the same size as the * points array. */ - virtual void vector_value_list (const std::vector > &points, - std::vector > &values) const; + virtual void vector_value_list (const std::vector > &points, + std::vector > &values) const; /** * Determine an estimate for the memory consumption (in bytes) of this @@ -512,7 +512,7 @@ protected: /** * This class provides a way to convert a scalar function of the kind * @code - * double foo (const Point &); + * Number foo (const Point &); * @endcode * into an object of type Function@. Since the argument returns a * scalar, the result is clearly a Function object for which @@ -537,10 +537,10 @@ protected: * argument. For example, if you need a Function object that returns the * norm of a point, you could write it like so: * @code - * template - * class Norm : public Function { + * template + * class Norm : public Function { * public: - * virtual double value (const Point &p, + * virtual Number value (const Point &p, * const unsigned int component) const { * Assert (component == 0, ExcMessage ("This object is scalar!")); * return p.norm(); @@ -552,23 +552,23 @@ protected: * and then pass the my_norm_object around, or you could write * it like so: * @code - * ScalarFunctionFromFunctionObject my_norm_object (&Point::norm); + * ScalarFunctionFromFunctionObject my_norm_object (&Point::norm); * @endcode * * Similarly, to generate an object that computes the distance to a point * q, we could do this: * @code - * template - * class DistanceTo : public Function { + * template + * class DistanceTo : public Function { * public: - * DistanceTo (const Point &q) : q(q) {} - * virtual double value (const Point &p, + * DistanceTo (const Point &q) : q(q) {} + * virtual Number value (const Point &p, * const unsigned int component) const { * Assert (component == 0, ExcMessage ("This object is scalar!")); * return q.distance(p); * } * private: - * const Point q; + * const Point q; * }; * * Point<2> q (2,3); @@ -576,8 +576,8 @@ protected: * @endcode * or we could write it like so: * @code - * ScalarFunctionFromFunctionObject - * my_distance_object (std_cxx1x::bind (&Point::distance, + * ScalarFunctionFromFunctionObject + * my_distance_object (std_cxx1x::bind (&Point::distance, * q, * std_cxx1x::_1)); * @endcode @@ -585,21 +585,21 @@ protected: * * @author Wolfgang Bangerth, 2011 */ -template -class ScalarFunctionFromFunctionObject : public Function +template +class ScalarFunctionFromFunctionObject : public Function { public: /** - * Given a function object that takes a Point and returns a double value, - * convert this into an object that matches the Function interface. + * Given a function object that takes a Point and returns a Number value, + * convert this into an object that matches the Function interface. */ - ScalarFunctionFromFunctionObject (const std_cxx1x::function &)> &function_object); + ScalarFunctionFromFunctionObject (const std_cxx1x::function &)> &function_object); /** * Return the value of the function at the given point. Returns the value * the function given to the constructor produces for this point. */ - virtual double value (const Point &p, + virtual Number value (const Point &p, const unsigned int component = 0) const; private: @@ -607,7 +607,7 @@ private: * The function object which we call when this class's value() or * value_list() functions are called. **/ - const std_cxx1x::function &)> function_object; + const std_cxx1x::function &)> function_object; }; @@ -633,7 +633,7 @@ private: * * To be more concrete, let us consider the following example: * @code - * double one (const Point<2> &p) { return 1; } + * Number one (const Point<2> &p) { return 1; } * VectorFunctionFromScalarFunctionObject<2> * component_mask (&one, 1, 3); * @endcode @@ -646,12 +646,12 @@ private: * * @author Wolfgang Bangerth, 2011 */ -template -class VectorFunctionFromScalarFunctionObject : public Function +template +class VectorFunctionFromScalarFunctionObject : public Function { public: /** - * Given a function object that takes a Point and returns a double + * Given a function object that takes a Point and returns a Number * value, convert this into an object that matches the Function@ * interface. * @@ -662,7 +662,7 @@ public: * @param selected_component The single component that should be * filled by the first argument. **/ - VectorFunctionFromScalarFunctionObject (const std_cxx1x::function &)> &function_object, + VectorFunctionFromScalarFunctionObject (const std_cxx1x::function &)> &function_object, const unsigned int selected_component, const unsigned int n_components); @@ -670,7 +670,7 @@ public: * Return the value of the function at the given point. Returns the value * the function given to the constructor produces for this point. */ - virtual double value (const Point &p, + virtual Number value (const Point &p, const unsigned int component = 0) const; /** @@ -679,15 +679,15 @@ public: * values shall have the right size beforehand, i.e. * #n_components. */ - virtual void vector_value (const Point &p, - Vector &values) const; + virtual void vector_value (const Point &p, + Vector &values) const; private: /** * The function object which we call when this class's value() or * value_list() functions are called. **/ - const std_cxx1x::function &)> function_object; + const std_cxx1x::function &)> function_object; /** * The vector component whose value is to be filled by the given scalar @@ -698,7 +698,7 @@ private: /** - * This class is built as a means of translating the Tensor<1,dim> + * This class is built as a means of translating the Tensor<1,dim, Number> * values produced by objects of type TensorFunction and returning * them as a multiple component version of the same thing as a Vector for * use in, for example, the VectorTools::interpolate or the many other @@ -709,11 +709,11 @@ private: * * For example: Say you created a class called * @code - * class RightHandSide : public TensorFunction + * class RightHandSide : public TensorFunction * @endcode * which extends the TensorFunction class and you have an object * @code - * RightHandSide<1,dim> rhs; + * RightHandSide<1,dim, Number> rhs; * @endcode * of that class which you want to interpolate onto your mesh using the * VectorTools::interpolate function, but the finite element you use for @@ -723,21 +723,21 @@ private: * that has 3*dim vector components. Creating such an object from the * existing rhs object is done using this piece of code: * @code - * RighHandSide<1,dim> rhs; - * VectorFunctionFromTensorFunction rhs_vector_function (rhs, 0, 3*dim); + * RighHandSide<1,dim, Number> rhs; + * VectorFunctionFromTensorFunction rhs_vector_function (rhs, 0, 3*dim); * @endcode * where the dim components of the tensor function are placed into * the first dim components of the function object. * * @author Spencer Patty, 2013 */ -template -class VectorFunctionFromTensorFunction : public Function +template +class VectorFunctionFromTensorFunction : public Function { public: /** * Given a TensorFunction object that takes a Point and returns - * a Tensor<1,dim> value, convert this into an object that + * a Tensor<1,dim, Number> value, convert this into an object that * matches the Function@ interface. * * By default, create a Vector object of the same size as @@ -752,7 +752,7 @@ public: * tensor_function fits inside the n_component length return * vector. */ - VectorFunctionFromTensorFunction (const TensorFunction<1,dim> &tensor_function, + VectorFunctionFromTensorFunction (const TensorFunction<1,dim, Number> &tensor_function, const unsigned int selected_component=0, const unsigned int n_components=dim); @@ -766,7 +766,7 @@ public: * Return a single component of a vector-valued function at a given * point. */ - virtual double value (const Point &p, + virtual Number value (const Point &p, const unsigned int component = 0) const; /** @@ -775,8 +775,8 @@ public: * values shall have the right size beforehand, i.e. * #n_components. */ - virtual void vector_value (const Point &p, - Vector &values) const; + virtual void vector_value (const Point &p, + Vector &values) const; /** * Return all components of a vector-valued function at a list of points. @@ -785,21 +785,21 @@ public: * element of the vector will be passed to vector_value() to evaluate the * function */ - virtual void vector_value_list (const std::vector > &points, - std::vector > &value_list) const; + virtual void vector_value_list (const std::vector > &points, + std::vector > &value_list) const; private: /** * The TensorFunction object which we call when this class's * vector_value() or vector_value_list() functions are called. **/ - const TensorFunction<1,dim> &tensor_function; + const TensorFunction<1,dim,Number> &tensor_function; /** * The first vector component whose value is to be filled by the given * TensorFunction. The values will be placed in components * selected_component to selected_component+dim-1 for a - * TensorFunction<1,dim> object. + * TensorFunction<1,dim, Number> object. */ const unsigned int selected_component; }; diff --git a/deal.II/include/deal.II/base/function_time.h b/deal.II/include/deal.II/base/function_time.h index 3615f51f73..4b8109be72 100644 --- a/deal.II/include/deal.II/base/function_time.h +++ b/deal.II/include/deal.II/base/function_time.h @@ -64,6 +64,7 @@ DEAL_II_NAMESPACE_OPEN * @ingroup functions * @author Wolfgang Bangerth, Guido Kanschat, 1998, 1999 */ +template class FunctionTime { public: @@ -72,7 +73,7 @@ public: * for the time variable, which defaults * to zero. */ - FunctionTime (const double initial_time = 0.0); + FunctionTime (const Number initial_time = Number(0.0)); /** * Virtual destructor. @@ -82,25 +83,25 @@ public: /** * Return the value of the time variable/ */ - double get_time () const; + Number get_time () const; /** * Set the time to new_time, overwriting * the old value. */ - virtual void set_time (const double new_time); + virtual void set_time (const Number new_time); /** * Advance the time by the given * time step delta_t. */ - virtual void advance_time (const double delta_t); + virtual void advance_time (const Number delta_t); private: /** * Store the present time. */ - double time; + Number time; }; @@ -109,8 +110,9 @@ private: #ifndef DOXYGEN -inline double -FunctionTime::get_time () const +template +inline Number +FunctionTime::get_time () const { return time; } diff --git a/deal.II/include/deal.II/base/tensor_function.h b/deal.II/include/deal.II/base/tensor_function.h index c6da7af3aa..d61290e0b5 100644 --- a/deal.II/include/deal.II/base/tensor_function.h +++ b/deal.II/include/deal.II/base/tensor_function.h @@ -56,23 +56,23 @@ DEAL_II_NAMESPACE_OPEN * @ingroup functions * @author Guido Kanschat, 1999 */ -template -class TensorFunction : public FunctionTime, +template +class TensorFunction : public FunctionTime, public Subscriptor { public: /** * Define typedefs for the return types of the value functions. */ - typedef Tensor value_type; + typedef Tensor value_type; - typedef Tensor gradient_type; + typedef Tensor gradient_type; /** * Constructor. May take an initial value for the time variable, which * defaults to zero. */ - TensorFunction (const double initial_time = 0.0); + TensorFunction (const Number initial_time = Number(0.0)); /** * Virtual destructor; absolutely necessary in this case, as classes are @@ -84,27 +84,27 @@ public: /** * Return the value of the function at the given point. */ - virtual value_type value (const Point &p) const; + virtual value_type value (const Point &p) const; /** * Set values to the point values of the function at the * points. It is assumed that values already has the * right size, i.e. the same size as the points array. */ - virtual void value_list (const std::vector > &points, + virtual void value_list (const std::vector > &points, std::vector &values) const; /** * Return the gradient of the function at the given point. */ - virtual gradient_type gradient (const Point &p) const; + virtual gradient_type gradient (const Point &p) const; /** * Set gradients to the gradients of the function at the * points. It is assumed that values already has the * right size, i.e. the same size as the points array. */ - virtual void gradient_list (const std::vector > &points, + virtual void gradient_list (const std::vector > &points, std::vector &gradients) const; /** @@ -130,8 +130,8 @@ public: * @ingroup functions * @author Matthias Maier, 2013 */ -template -class ConstantTensorFunction : public TensorFunction +template +class ConstantTensorFunction : public TensorFunction { public: /** @@ -141,23 +141,23 @@ public: * An initial value for the time variable may be specified, otherwise it * defaults to zero. */ - ConstantTensorFunction (const dealii::Tensor &value, - const double initial_time = 0.0); + ConstantTensorFunction (const dealii::Tensor &value, + const Number initial_time = 0.0); virtual ~ConstantTensorFunction (); - virtual typename dealii::TensorFunction::value_type value (const Point &p) const; + virtual typename dealii::TensorFunction::value_type value (const Point &p) const; - virtual void value_list (const std::vector > &points, - std::vector::value_type> &values) const; + virtual void value_list (const std::vector > &points, + std::vector::value_type> &values) const; - virtual typename dealii::TensorFunction::gradient_type gradient (const Point &p) const; + virtual typename dealii::TensorFunction::gradient_type gradient (const Point &p) const; - virtual void gradient_list (const std::vector > &points, - std::vector::gradient_type> &gradients) const; + virtual void gradient_list (const std::vector > &points, + std::vector::gradient_type> &gradients) const; private: - const dealii::Tensor _value; + const dealii::Tensor _value; }; @@ -169,8 +169,8 @@ private: * @ingroup functions * @author Matthias Maier, 2013 */ -template -class ZeroTensorFunction : public ConstantTensorFunction +template +class ZeroTensorFunction : public ConstantTensorFunction { public: /** @@ -179,7 +179,7 @@ public: * An initial value for the time variable may be specified, otherwise it * defaults to zero. */ - ZeroTensorFunction (const double initial_time = 0.0); + ZeroTensorFunction (const Number initial_time = 0.0); }; diff --git a/deal.II/include/deal.II/dofs/dof_tools.h b/deal.II/include/deal.II/dofs/dof_tools.h index 45f72ff92d..72a3791bfe 100644 --- a/deal.II/include/deal.II/dofs/dof_tools.h +++ b/deal.II/include/deal.II/dofs/dof_tools.h @@ -40,7 +40,7 @@ DEAL_II_NAMESPACE_OPEN template class Table; class SparsityPattern; template class Vector; -template class Function; +template class Function; template class FiniteElement; template class DoFHandler; namespace hp diff --git a/deal.II/include/deal.II/dofs/function_map.h b/deal.II/include/deal.II/dofs/function_map.h index 52e3495a0d..a436e0eea4 100644 --- a/deal.II/include/deal.II/dofs/function_map.h +++ b/deal.II/include/deal.II/dofs/function_map.h @@ -22,7 +22,7 @@ DEAL_II_NAMESPACE_OPEN -template class Function; +template class Function; @@ -65,7 +65,7 @@ template class Function; * @ingroup functions * @author Wolfgang Bangerth, Ralf Hartmann, 2001 */ -template +template struct FunctionMap { /** @@ -77,7 +77,7 @@ struct FunctionMap * name it in the fashion of the * STL local typedefs. */ - typedef std::map*> type; + typedef std::map*> type; }; DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/include/deal.II/grid/grid_out.h b/deal.II/include/deal.II/grid/grid_out.h index 308df13c5e..55b48caa58 100644 --- a/deal.II/include/deal.II/grid/grid_out.h +++ b/deal.II/include/deal.II/grid/grid_out.h @@ -895,8 +895,8 @@ public: * Not implemented for the * codimension one case. */ - template - void write_dx (const Triangulation &tria, + template + void write_dx (const Triangulation &tria, std::ostream &out) const; /** @@ -1044,10 +1044,10 @@ public: * * Not implemented for the codimension one case. */ - template - void write_eps (const Triangulation &tria, + template + void write_eps (const Triangulation &tria, std::ostream &out, - const Mapping *mapping=0) const; + const Mapping *mapping=0) const; /** * Write two-dimensional XFig-file. @@ -1067,10 +1067,10 @@ public: * * Not implemented for the codimension one case. */ - template - void write_xfig (const Triangulation &tria, + template + void write_xfig (const Triangulation &tria, std::ostream &out, - const Mapping *mapping=0) const; + const Mapping *mapping=0) const; /** * Write the triangulation in the SVG format. @@ -1122,8 +1122,8 @@ public: * * @note Not implemented for the codimension one case. */ - template - void write_mathgl (const Triangulation &tria, + template + void write_mathgl (const Triangulation &tria, std::ostream &out) const; /** diff --git a/deal.II/include/deal.II/grid/grid_tools.h b/deal.II/include/deal.II/grid/grid_tools.h index 8a6b6c6747..fb5eff8e65 100644 --- a/deal.II/include/deal.II/grid/grid_tools.h +++ b/deal.II/include/deal.II/grid/grid_tools.h @@ -312,7 +312,7 @@ namespace GridTools template void laplace_transform (const std::map > &new_points, Triangulation &tria, - const Function *coefficient = 0); + const Function *coefficient = 0); /** * Scale the entire triangulation diff --git a/deal.II/include/deal.II/multigrid/mg_constrained_dofs.h b/deal.II/include/deal.II/multigrid/mg_constrained_dofs.h index e30bfa3ae4..0547380d32 100644 --- a/deal.II/include/deal.II/multigrid/mg_constrained_dofs.h +++ b/deal.II/include/deal.II/multigrid/mg_constrained_dofs.h @@ -28,7 +28,7 @@ DEAL_II_NAMESPACE_OPEN template class DoFHandler; -template struct FunctionMap; +template struct FunctionMap; /** diff --git a/deal.II/include/deal.II/numerics/matrix_tools.h b/deal.II/include/deal.II/numerics/matrix_tools.h index 3d90ebe0fa..ab4b762277 100644 --- a/deal.II/include/deal.II/numerics/matrix_tools.h +++ b/deal.II/include/deal.II/numerics/matrix_tools.h @@ -19,6 +19,7 @@ #include +#include #include #include #include diff --git a/deal.II/include/deal.II/numerics/vector_tools.h b/deal.II/include/deal.II/numerics/vector_tools.h index 59c74cfccc..0f15f4c978 100644 --- a/deal.II/include/deal.II/numerics/vector_tools.h +++ b/deal.II/include/deal.II/numerics/vector_tools.h @@ -32,8 +32,8 @@ DEAL_II_NAMESPACE_OPEN -template class Function; -template struct FunctionMap; +template class Function; +template struct FunctionMap; template class Quadrature; template class QGauss; @@ -454,7 +454,7 @@ namespace VectorTools template class DH> void interpolate (const Mapping &mapping, const DH &dof, - const Function &function, + const Function &function, VECTOR &vec); /** @@ -464,7 +464,7 @@ namespace VectorTools */ template void interpolate (const DH &dof, - const Function &function, + const Function &function, VECTOR &vec); /** @@ -565,7 +565,7 @@ namespace VectorTools void interpolate_based_on_material_id(const Mapping& mapping, const DH& dof_handler, - const std::map< types::material_id, const Function* >& function_map, + const std::map< types::material_id, const Function* >& function_map, VECTOR& dst, const ComponentMask& component_mask = ComponentMask()); @@ -715,7 +715,7 @@ namespace VectorTools const DoFHandler &dof, const ConstraintMatrix &constraints, const Quadrature &quadrature, - const Function &function, + const Function &function, VECTOR &vec, const bool enforce_zero_boundary = false, const Quadrature &q_boundary = (dim > 1 ? @@ -732,7 +732,7 @@ namespace VectorTools void project (const DoFHandler &dof, const ConstraintMatrix &constraints, const Quadrature &quadrature, - const Function &function, + const Function &function, VECTOR &vec, const bool enforce_zero_boundary = false, const Quadrature &q_boundary = (dim > 1 ? @@ -749,7 +749,7 @@ namespace VectorTools const hp::DoFHandler &dof, const ConstraintMatrix &constraints, const hp::QCollection &quadrature, - const Function &function, + const Function &function, VECTOR &vec, const bool enforce_zero_boundary = false, const hp::QCollection &q_boundary = hp::QCollection(dim > 1 ? @@ -766,7 +766,7 @@ namespace VectorTools void project (const hp::DoFHandler &dof, const ConstraintMatrix &constraints, const hp::QCollection &quadrature, - const Function &function, + const Function &function, VECTOR &vec, const bool enforce_zero_boundary = false, const hp::QCollection &q_boundary = hp::QCollection(dim > 1 ? @@ -895,7 +895,7 @@ namespace VectorTools interpolate_boundary_values (const Mapping &mapping, const DH &dof, const types::boundary_id boundary_component, - const Function &boundary_function, + const Function &boundary_function, std::map &boundary_values, const ComponentMask &component_mask = ComponentMask()); @@ -914,7 +914,7 @@ namespace VectorTools void interpolate_boundary_values (const DH &dof, const types::boundary_id boundary_component, - const Function &boundary_function, + const Function &boundary_function, std::map &boundary_values, const ComponentMask &component_mask = ComponentMask()); @@ -1057,7 +1057,7 @@ namespace VectorTools interpolate_boundary_values (const Mapping &mapping, const DH &dof, const types::boundary_id boundary_component, - const Function &boundary_function, + const Function &boundary_function, ConstraintMatrix &constraints, const ComponentMask &component_mask = ComponentMask()); @@ -1078,7 +1078,7 @@ namespace VectorTools void interpolate_boundary_values (const DH &dof, const types::boundary_id boundary_component, - const Function &boundary_function, + const Function &boundary_function, ConstraintMatrix &constraints, const ComponentMask &component_mask = ComponentMask()); @@ -1359,7 +1359,7 @@ namespace VectorTools template void project_boundary_values_curl_conforming (const DoFHandler &dof_handler, const unsigned int first_vector_component, - const Function &boundary_function, + const Function &boundary_function, const types::boundary_id boundary_component, ConstraintMatrix &constraints, const Mapping &mapping = StaticMappingQ1::mapping); @@ -1374,7 +1374,7 @@ namespace VectorTools template void project_boundary_values_curl_conforming (const hp::DoFHandler &dof_handler, const unsigned int first_vector_component, - const Function &boundary_function, + const Function &boundary_function, const types::boundary_id boundary_component, ConstraintMatrix &constraints, const hp::MappingCollection &mapping_collection = hp::StaticMappingQ1::mapping_collection); @@ -1449,7 +1449,7 @@ namespace VectorTools template void project_boundary_values_div_conforming (const DoFHandler &dof_handler, const unsigned int first_vector_component, - const Function &boundary_function, + const Function &boundary_function, const types::boundary_id boundary_component, ConstraintMatrix &constraints, const Mapping &mapping = StaticMappingQ1::mapping); @@ -1464,7 +1464,7 @@ namespace VectorTools template void project_boundary_values_div_conforming (const hp::DoFHandler &dof_handler, const unsigned int first_vector_component, - const Function &boundary_function, + const Function &boundary_function, const types::boundary_id boundary_component, ConstraintMatrix &constraints, const hp::MappingCollection &mapping_collection = hp::StaticMappingQ1::mapping_collection); @@ -1752,7 +1752,7 @@ namespace VectorTools void create_right_hand_side (const Mapping &mapping, const DoFHandler &dof, const Quadrature &q, - const Function &rhs, + const Function &rhs, Vector &rhs_vector); /** @@ -1763,7 +1763,7 @@ namespace VectorTools template void create_right_hand_side (const DoFHandler &dof, const Quadrature &q, - const Function &rhs, + const Function &rhs, Vector &rhs_vector); /** @@ -1774,7 +1774,7 @@ namespace VectorTools void create_right_hand_side (const hp::MappingCollection &mapping, const hp::DoFHandler &dof, const hp::QCollection &q, - const Function &rhs, + const Function &rhs, Vector &rhs_vector); /** @@ -1784,7 +1784,7 @@ namespace VectorTools template void create_right_hand_side (const hp::DoFHandler &dof, const hp::QCollection &q, - const Function &rhs, + const Function &rhs, Vector &rhs_vector); /** @@ -1913,7 +1913,7 @@ namespace VectorTools void create_boundary_right_hand_side (const Mapping &mapping, const DoFHandler &dof, const Quadrature &q, - const Function &rhs, + const Function &rhs, Vector &rhs_vector, const std::set &boundary_indicators = std::set()); @@ -1928,7 +1928,7 @@ namespace VectorTools template void create_boundary_right_hand_side (const DoFHandler &dof, const Quadrature &q, - const Function &rhs, + const Function &rhs, Vector &rhs_vector, const std::set &boundary_indicators = std::set()); @@ -1942,7 +1942,7 @@ namespace VectorTools void create_boundary_right_hand_side (const hp::MappingCollection &mapping, const hp::DoFHandler &dof, const hp::QCollection &q, - const Function &rhs, + const Function &rhs, Vector &rhs_vector, const std::set &boundary_indicators = std::set()); @@ -1961,7 +1961,7 @@ namespace VectorTools template void create_boundary_right_hand_side (const hp::DoFHandler &dof, const hp::QCollection &q, - const Function &rhs, + const Function &rhs, Vector &rhs_vector, const std::set &boundary_indicators = std::set()); @@ -2085,11 +2085,11 @@ namespace VectorTools void integrate_difference (const Mapping &mapping, const DoFHandler &dof, const InVector &fe_function, - const Function &exact_solution, + const Function &exact_solution, OutVector &difference, const Quadrature &q, const NormType &norm, - const Function *weight = 0, + const Function *weight = 0, const double exponent = 2.); /** @@ -2100,11 +2100,11 @@ namespace VectorTools template void integrate_difference (const DoFHandler &dof, const InVector &fe_function, - const Function &exact_solution, + const Function &exact_solution, OutVector &difference, const Quadrature &q, const NormType &norm, - const Function *weight = 0, + const Function *weight = 0, const double exponent = 2.); /** @@ -2114,11 +2114,11 @@ namespace VectorTools void integrate_difference (const hp::MappingCollection &mapping, const hp::DoFHandler &dof, const InVector &fe_function, - const Function &exact_solution, + const Function &exact_solution, OutVector &difference, const hp::QCollection &q, const NormType &norm, - const Function *weight = 0, + const Function *weight = 0, const double exponent = 2.); /** @@ -2129,11 +2129,11 @@ namespace VectorTools template void integrate_difference (const hp::DoFHandler &dof, const InVector &fe_function, - const Function &exact_solution, + const Function &exact_solution, OutVector &difference, const hp::QCollection &q, const NormType &norm, - const Function *weight = 0, + const Function *weight = 0, const double exponent = 2.); /** @@ -2160,7 +2160,7 @@ namespace VectorTools template void point_difference (const DoFHandler &dof, const InVector &fe_function, - const Function &exact_solution, + const Function &exact_solution, Vector &difference, const Point &point); @@ -2190,7 +2190,7 @@ namespace VectorTools void point_difference (const Mapping &mapping, const DoFHandler &dof, const InVector &fe_function, - const Function &exact_solution, + const Function &exact_solution, Vector &difference, const Point &point); diff --git a/deal.II/source/base/function.cc b/deal.II/source/base/function.cc index 40c7f30af2..ce7fba508f 100644 --- a/deal.II/source/base/function.cc +++ b/deal.II/source/base/function.cc @@ -23,15 +23,15 @@ DEAL_II_NAMESPACE_OPEN -template -const unsigned int Function::dimension; +template +const unsigned int Function::dimension; -template -Function::Function (const unsigned int n_components, - const double initial_time) +template +Function::Function (const unsigned int n_components, + const Number initial_time) : - FunctionTime(initial_time), + FunctionTime(initial_time), n_components(n_components) { // avoid the construction of function @@ -45,22 +45,22 @@ Function::Function (const unsigned int n_components, } -template -Function::~Function () +template +Function::~Function () {} -template -Function &Function::operator= (const Function &f) +template +Function &Function::operator= (const Function &f) { AssertDimension (n_components, f.n_components); return *this; } -template -double Function::value (const Point &, +template +Number Function::value (const Point &, const unsigned int) const { Assert (false, ExcPureFunctionCalled()); @@ -68,9 +68,9 @@ double Function::value (const Point &, } -template -void Function::vector_value (const Point &p, - Vector &v) const +template +void Function::vector_value (const Point &p, + Vector &v) const { AssertDimension(v.size(), this->n_components); for (unsigned int i=0; in_components; ++i) @@ -78,9 +78,9 @@ void Function::vector_value (const Point &p, } -template -void Function::value_list (const std::vector > &points, - std::vector &values, +template +void Function::value_list (const std::vector > &points, + std::vector &values, const unsigned int component) const { // check whether component is in @@ -94,9 +94,9 @@ void Function::value_list (const std::vector > &points, } -template -void Function::vector_value_list (const std::vector > &points, - std::vector > &values) const +template +void Function::vector_value_list (const std::vector > &points, + std::vector > &values) const { // check whether component is in // the valid range is up to the @@ -109,10 +109,10 @@ void Function::vector_value_list (const std::vector > &points, } -template -void Function::vector_values ( - const std::vector > &points, - std::vector > &values) const +template +void Function::vector_values ( + const std::vector > &points, + std::vector > &values) const { const unsigned int n = this->n_components; AssertDimension (values.size(), n); @@ -121,19 +121,19 @@ void Function::vector_values ( } -template -Tensor<1,dim> Function::gradient (const Point &, - const unsigned int) const +template +Tensor<1,dim,Number> Function::gradient (const Point &, + const unsigned int) const { Assert (false, ExcPureFunctionCalled()); - return Point(); + return Point(); } -template -void Function::vector_gradient ( - const Point &p, - std::vector > &v) const +template +void Function::vector_gradient ( + const Point &p, + std::vector > &v) const { AssertDimension(v.size(), this->n_components); for (unsigned int i=0; in_components; ++i) @@ -141,10 +141,10 @@ void Function::vector_gradient ( } -template -void Function::gradient_list (const std::vector > &points, - std::vector > &gradients, - const unsigned int component) const +template +void Function::gradient_list (const std::vector > &points, + std::vector > &gradients, + const unsigned int component) const { Assert (gradients.size() == points.size(), ExcDimensionMismatch(gradients.size(), points.size())); @@ -154,9 +154,9 @@ void Function::gradient_list (const std::vector > &points, } -template -void Function::vector_gradient_list (const std::vector > &points, - std::vector > > &gradients) const +template +void Function::vector_gradient_list (const std::vector > &points, + std::vector > > &gradients) const { Assert (gradients.size() == points.size(), ExcDimensionMismatch(gradients.size(), points.size())); @@ -170,10 +170,10 @@ void Function::vector_gradient_list (const std::vector > } -template -void Function::vector_gradients ( - const std::vector > &points, - std::vector > > &values) const +template +void Function::vector_gradients ( + const std::vector > &points, + std::vector > > &values) const { const unsigned int n = this->n_components; AssertDimension (values.size(), n); @@ -183,8 +183,8 @@ void Function::vector_gradients ( -template -double Function::laplacian (const Point &, +template +Number Function::laplacian (const Point &, const unsigned int) const { Assert (false, ExcPureFunctionCalled()); @@ -192,18 +192,18 @@ double Function::laplacian (const Point &, } -template -void Function::vector_laplacian (const Point &, - Vector &) const +template +void Function::vector_laplacian (const Point &, + Vector &) const { Assert (false, ExcPureFunctionCalled()); } -template -void Function::laplacian_list (const std::vector > &points, - std::vector &laplacians, +template +void Function::laplacian_list (const std::vector > &points, + std::vector &laplacians, const unsigned int component) const { // check whether component is in @@ -217,9 +217,9 @@ void Function::laplacian_list (const std::vector > &points, } -template -void Function::vector_laplacian_list (const std::vector > &points, - std::vector > &laplacians) const +template +void Function::vector_laplacian_list (const std::vector > &points, + std::vector > &laplacians) const { // check whether component is in // the valid range is up to the @@ -233,9 +233,9 @@ void Function::vector_laplacian_list (const std::vector > &point -template +template std::size_t -Function::memory_consumption () const +Function::memory_consumption () const { // only simple data elements, so // use sizeof operator @@ -245,29 +245,29 @@ Function::memory_consumption () const //--------------------------------------------------------------------------- -template -ZeroFunction::ZeroFunction (const unsigned int n_components) +template +ZeroFunction::ZeroFunction (const unsigned int n_components) : - Function (n_components) + Function (n_components) {} -template -ZeroFunction::~ZeroFunction () +template +ZeroFunction::~ZeroFunction () {} -template -double ZeroFunction::value (const Point &, +template +Number ZeroFunction::value (const Point &, const unsigned int) const { return 0.; } -template -void ZeroFunction::vector_value (const Point &, - Vector &return_value) const +template +void ZeroFunction::vector_value (const Point &, + Vector &return_value) const { Assert (return_value.size() == this->n_components, ExcDimensionMismatch (return_value.size(), this->n_components)); @@ -276,9 +276,9 @@ void ZeroFunction::vector_value (const Point &, } -template -void ZeroFunction::value_list (const std::vector > &points, - std::vector &values, +template +void ZeroFunction::value_list (const std::vector > &points, + std::vector &values, const unsigned int /*component*/) const { Assert (values.size() == points.size(), @@ -288,9 +288,9 @@ void ZeroFunction::value_list (const std::vector > &points, } -template -void ZeroFunction::vector_value_list (const std::vector > &points, - std::vector > &values) const +template +void ZeroFunction::vector_value_list (const std::vector > &points, + std::vector > &values) const { Assert (values.size() == points.size(), ExcDimensionMismatch(values.size(), points.size())); @@ -304,17 +304,17 @@ void ZeroFunction::vector_value_list (const std::vector > &point } -template -Tensor<1,dim> ZeroFunction::gradient (const Point &, +template +Tensor<1,dim,Number> ZeroFunction::gradient (const Point &, const unsigned int) const { - return Tensor<1,dim>(); + return Tensor<1,dim,Number>(); } -template -void ZeroFunction::vector_gradient (const Point &, - std::vector > &gradients) const +template +void ZeroFunction::vector_gradient (const Point &, + std::vector > &gradients) const { Assert (gradients.size() == this->n_components, ExcDimensionMismatch(gradients.size(), this->n_components)); @@ -324,9 +324,9 @@ void ZeroFunction::vector_gradient (const Point &, } -template -void ZeroFunction::gradient_list (const std::vector > &points, - std::vector > &gradients, +template +void ZeroFunction::gradient_list (const std::vector > &points, + std::vector > &gradients, const unsigned int /*component*/) const { Assert (gradients.size() == points.size(), @@ -337,9 +337,9 @@ void ZeroFunction::gradient_list (const std::vector > &points, } -template -void ZeroFunction::vector_gradient_list (const std::vector > &points, - std::vector > > &gradients) const +template +void ZeroFunction::vector_gradient_list (const std::vector > &points, + std::vector > > &gradients) const { Assert (gradients.size() == points.size(), ExcDimensionMismatch(gradients.size(), points.size())); @@ -355,23 +355,23 @@ void ZeroFunction::vector_gradient_list (const std::vector > //--------------------------------------------------------------------------- -template -ConstantFunction::ConstantFunction (const double value, +template +ConstantFunction::ConstantFunction (const Number value, const unsigned int n_components) : - ZeroFunction (n_components), + ZeroFunction (n_components), function_value (value) {} -template -ConstantFunction::~ConstantFunction () {} +template +ConstantFunction::~ConstantFunction () {} -template -double ConstantFunction::value (const Point &, +template +Number ConstantFunction::value (const Point &, const unsigned int component) const { Assert (component < this->n_components, @@ -381,9 +381,9 @@ double ConstantFunction::value (const Point &, -template -void ConstantFunction::vector_value (const Point &, - Vector &return_value) const +template +void ConstantFunction::vector_value (const Point &, + Vector &return_value) const { Assert (return_value.size() == this->n_components, ExcDimensionMismatch (return_value.size(), this->n_components)); @@ -393,9 +393,9 @@ void ConstantFunction::vector_value (const Point &, -template -void ConstantFunction::value_list (const std::vector > &points, - std::vector &values, +template +void ConstantFunction::value_list (const std::vector > &points, + std::vector &values, const unsigned int component) const { Assert (component < this->n_components, @@ -408,9 +408,9 @@ void ConstantFunction::value_list (const std::vector > &points, -template -void ConstantFunction::vector_value_list (const std::vector > &points, - std::vector > &values) const +template +void ConstantFunction::vector_value_list (const std::vector > &points, + std::vector > &values) const { Assert (values.size() == points.size(), ExcDimensionMismatch(values.size(), points.size())); @@ -425,9 +425,9 @@ void ConstantFunction::vector_value_list (const std::vector > &p -template +template std::size_t -ConstantFunction::memory_consumption () const +ConstantFunction::memory_consumption () const { // only simple data elements, so // use sizeof operator @@ -436,24 +436,24 @@ ConstantFunction::memory_consumption () const //--------------------------------------------------------------------------- -template -ComponentSelectFunction:: +template +ComponentSelectFunction:: ComponentSelectFunction (const unsigned int selected, - const double value, + const Number value, const unsigned int n_components) : - ConstantFunction (value, n_components), + ConstantFunction (value, n_components), selected_components(std::make_pair(selected,selected+1)) {} -template -ComponentSelectFunction:: +template +ComponentSelectFunction:: ComponentSelectFunction (const unsigned int selected, const unsigned int n_components) : - ConstantFunction (1., n_components), + ConstantFunction (1., n_components), selected_components(std::make_pair(selected,selected+1)) { Assert (selected < n_components, @@ -462,12 +462,12 @@ ComponentSelectFunction (const unsigned int selected, -template -ComponentSelectFunction:: +template +ComponentSelectFunction:: ComponentSelectFunction (const std::pair &selected, const unsigned int n_components) : - ConstantFunction (1., n_components), + ConstantFunction (1., n_components), selected_components(selected) { Assert (selected_components.first < selected_components.second, @@ -480,9 +480,9 @@ ComponentSelectFunction (const std::pair &selected, -template -void ComponentSelectFunction::vector_value (const Point &, - Vector &return_value) const +template +void ComponentSelectFunction::vector_value (const Point &, + Vector &return_value) const { Assert (return_value.size() == this->n_components, ExcDimensionMismatch (return_value.size(), this->n_components)); @@ -495,23 +495,23 @@ void ComponentSelectFunction::vector_value (const Point &, -template -void ComponentSelectFunction::vector_value_list (const std::vector > &points, - std::vector > &values) const +template +void ComponentSelectFunction::vector_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; i::vector_value (points[i], + ComponentSelectFunction::vector_value (points[i], values[i]); } -template +template std::size_t -ComponentSelectFunction::memory_consumption () const +ComponentSelectFunction::memory_consumption () const { // only simple data elements, so // use sizeof operator @@ -519,19 +519,19 @@ ComponentSelectFunction::memory_consumption () const } -template -ScalarFunctionFromFunctionObject:: -ScalarFunctionFromFunctionObject (const std_cxx1x::function &)> &function_object) +template +ScalarFunctionFromFunctionObject:: +ScalarFunctionFromFunctionObject (const std_cxx1x::function &)> &function_object) : - Function(1), + Function(1), function_object (function_object) {} -template -double -ScalarFunctionFromFunctionObject::value (const Point &p, +template +Number +ScalarFunctionFromFunctionObject::value (const Point &p, const unsigned int component) const { Assert (component == 0, @@ -541,13 +541,13 @@ ScalarFunctionFromFunctionObject::value (const Point &p, -template -VectorFunctionFromScalarFunctionObject:: -VectorFunctionFromScalarFunctionObject (const std_cxx1x::function &)> &function_object, +template +VectorFunctionFromScalarFunctionObject:: +VectorFunctionFromScalarFunctionObject (const std_cxx1x::function &)> &function_object, const unsigned int selected_component, const unsigned int n_components) : - Function(n_components), + Function(n_components), function_object (function_object), selected_component (selected_component) { @@ -557,9 +557,9 @@ VectorFunctionFromScalarFunctionObject (const std_cxx1x::function -double -VectorFunctionFromScalarFunctionObject::value (const Point &p, +template +Number +VectorFunctionFromScalarFunctionObject::value (const Point &p, const unsigned int component) const { Assert (component < this->n_components, @@ -573,11 +573,11 @@ VectorFunctionFromScalarFunctionObject::value (const Point &p, -template +template void -VectorFunctionFromScalarFunctionObject:: -vector_value (const Point &p, - Vector &values) const +VectorFunctionFromScalarFunctionObject:: +vector_value (const Point &p, + Vector &values) const { AssertDimension(values.size(), this->n_components); @@ -592,31 +592,31 @@ vector_value (const Point &p, * The constructor for VectorFunctionFromTensorFunction which initiates the return vector * to be size n_components. */ -template -VectorFunctionFromTensorFunction::VectorFunctionFromTensorFunction (const TensorFunction<1,dim> &tensor_function, +template +VectorFunctionFromTensorFunction::VectorFunctionFromTensorFunction (const TensorFunction<1,dim,Number> &tensor_function, const unsigned int selected_component, const unsigned int n_components) : - Function (n_components), + Function (n_components), tensor_function (tensor_function), selected_component (selected_component) { - // Verify that the Tensor<1,dim> will fit in the given length selected_components + // Verify that the Tensor<1,dim,Number> will fit in the given length selected_components // and not hang over the end of the vector. Assert (selected_component + dim - 1 < this->n_components, ExcIndexRange (selected_component, 0, this->n_components)); } -template -VectorFunctionFromTensorFunction::~VectorFunctionFromTensorFunction () +template +VectorFunctionFromTensorFunction::~VectorFunctionFromTensorFunction () {} -template +template inline -double VectorFunctionFromTensorFunction::value (const Point &p, +Number VectorFunctionFromTensorFunction::value (const Point &p, const unsigned int component) const { Assert (componentn_components, @@ -632,16 +632,16 @@ double VectorFunctionFromTensorFunction::value (const Point &p, // otherwise retrieve the values from the tensor_function to be // placed at the selected_component to selected_component + dim - 1 // elements of the Vector values and pick the correct one - const Tensor<1,dim> tensor_value = tensor_function.value (p); + const Tensor<1,dim,Number> tensor_value = tensor_function.value (p); return tensor_value[component-selected_component]; } -template +template inline -void VectorFunctionFromTensorFunction::vector_value (const Point &p, - Vector &values) const +void VectorFunctionFromTensorFunction::vector_value (const Point &p, + Vector &values) const { Assert(values.size() == this->n_components, ExcDimensionMismatch(values.size(),this->n_components)); @@ -649,7 +649,7 @@ void VectorFunctionFromTensorFunction::vector_value (const Point &p, // Retrieve the values from the tensor_function to be // placed at the selected_component to selected_component + dim - 1 // elements of the Vector values. - const Tensor<1,dim> tensor_value = tensor_function.value (p); + const Tensor<1,dim,Number> tensor_value = tensor_function.value (p); // First we make all elements of values = 0 values = 0; @@ -661,13 +661,13 @@ void VectorFunctionFromTensorFunction::vector_value (const Point &p, /** Member function vector_value_list is the interface for giving a list of - * points (vector >) of which to evaluate using the vector_value + * points (vector >) of which to evaluate using the vector_value * member function. Again, this function is written so as to not replicate the function definition * but passes each point on to vector_value to be evaluated. */ -template -void VectorFunctionFromTensorFunction::vector_value_list (const std::vector > &points, - std::vector > &value_list) const +template +void VectorFunctionFromTensorFunction::vector_value_list (const std::vector > &points, + std::vector > &value_list) const { Assert (value_list.size() == points.size(), ExcDimensionMismatch (value_list.size(), points.size())); @@ -675,7 +675,7 @@ void VectorFunctionFromTensorFunction::vector_value_list (const std::vector const unsigned int n_points = points.size(); for (unsigned int p=0; p::vector_value (points[p], value_list[p]); + VectorFunctionFromTensorFunction::vector_value (points[p], value_list[p]); } diff --git a/deal.II/source/base/function_time.cc b/deal.II/source/base/function_time.cc index b726a6551e..2dc9fc6fbd 100644 --- a/deal.II/source/base/function_time.cc +++ b/deal.II/source/base/function_time.cc @@ -19,30 +19,37 @@ DEAL_II_NAMESPACE_OPEN -FunctionTime::FunctionTime(const double initial_time) +template +FunctionTime::FunctionTime(const Number initial_time) : time(initial_time) {} -FunctionTime::~FunctionTime() +template +FunctionTime::~FunctionTime() {} +template void -FunctionTime::set_time (const double new_time) +FunctionTime::set_time (const Number new_time) { time = new_time; } - +template void -FunctionTime::advance_time (const double delta_t) +FunctionTime::advance_time (const Number delta_t) { set_time (time+delta_t); } +// Explicit instantiation +template class FunctionTime; + DEAL_II_NAMESPACE_CLOSE + diff --git a/deal.II/source/base/tensor_function.cc b/deal.II/source/base/tensor_function.cc index 93c80d0eb2..f4b7415eff 100644 --- a/deal.II/source/base/tensor_function.cc +++ b/deal.II/source/base/tensor_function.cc @@ -28,31 +28,31 @@ DEAL_II_NAMESPACE_OPEN // TensorFunction ////////////////////////////////////////////////////////////////////// -template -TensorFunction::TensorFunction (const double initial_time) +template +TensorFunction::TensorFunction (const Number initial_time) : - FunctionTime (initial_time) + FunctionTime (initial_time) {} -template -TensorFunction::~TensorFunction () +template +TensorFunction::~TensorFunction () {} -template -typename TensorFunction::value_type -TensorFunction::value (const Point &) const +template +typename TensorFunction::value_type +TensorFunction::value (const Point &) const { Assert (false, ExcPureFunctionCalled()); return Tensor(); } -template +template void -TensorFunction::value_list (const std::vector > &points, +TensorFunction::value_list (const std::vector > &points, std::vector &values) const { Assert (values.size() == points.size(), @@ -63,18 +63,18 @@ TensorFunction::value_list (const std::vector > &points, } -template -typename TensorFunction::gradient_type -TensorFunction::gradient (const Point &) const +template +typename TensorFunction::gradient_type +TensorFunction::gradient (const Point &) const { Assert (false, ExcPureFunctionCalled()); return Tensor(); } -template +template void -TensorFunction::gradient_list (const std::vector > &points, +TensorFunction::gradient_list (const std::vector > &points, std::vector &gradients) const { Assert (gradients.size() == points.size(), @@ -91,32 +91,32 @@ TensorFunction::gradient_list (const std::vector > &poin ////////////////////////////////////////////////////////////////////// -template -ConstantTensorFunction::ConstantTensorFunction (const Tensor &value, - const double initial_time) +template +ConstantTensorFunction::ConstantTensorFunction (const Tensor &value, + const Number initial_time) : - TensorFunction (initial_time), + TensorFunction (initial_time), _value(value) {} -template -ConstantTensorFunction::~ConstantTensorFunction () +template +ConstantTensorFunction::~ConstantTensorFunction () {} -template -typename TensorFunction::value_type -ConstantTensorFunction::value (const Point &/*point*/) const +template +typename TensorFunction::value_type +ConstantTensorFunction::value (const Point &/*point*/) const { return _value; } -template +template void -ConstantTensorFunction::value_list (const std::vector > &points, - std::vector::value_type> &values) const +ConstantTensorFunction::value_list (const std::vector > &points, + std::vector::value_type> &values) const { Assert (values.size() == points.size(), ExcDimensionMismatch(values.size(), points.size())); @@ -126,9 +126,9 @@ ConstantTensorFunction::value_list (const std::vector > &p } -template -typename TensorFunction::gradient_type -ConstantTensorFunction::gradient (const Point &) const +template +typename TensorFunction::gradient_type +ConstantTensorFunction::gradient (const Point &) const { static const Tensor zero; @@ -136,10 +136,10 @@ ConstantTensorFunction::gradient (const Point &) const } -template +template void -ConstantTensorFunction::gradient_list (const std::vector > &points, - std::vector::gradient_type> &gradients) const +ConstantTensorFunction::gradient_list (const std::vector > &points, + std::vector::gradient_type> &gradients) const { Assert (gradients.size() == points.size(), ExcDimensionMismatch(gradients.size(), points.size())); @@ -157,10 +157,10 @@ ConstantTensorFunction::gradient_list (const std::vector > ////////////////////////////////////////////////////////////////////// -template -ZeroTensorFunction::ZeroTensorFunction (const double initial_time) +template +ZeroTensorFunction::ZeroTensorFunction (const Number initial_time) : - ConstantTensorFunction (dealii::Tensor(), initial_time) + ConstantTensorFunction (dealii::Tensor(), initial_time) {} diff --git a/deal.II/source/grid/grid_out.cc b/deal.II/source/grid/grid_out.cc index afd5647f65..6622f529ed 100644 --- a/deal.II/source/grid/grid_out.cc +++ b/deal.II/source/grid/grid_out.cc @@ -689,17 +689,31 @@ void GridOut::write_dx (const Triangulation<1> &, Assert (false, ExcNotImplemented()); } +template <> +void GridOut::write_dx (const Triangulation<1,2> &, + std::ostream &) const +{ + Assert (false, ExcNotImplemented()); +} + +template <> +void GridOut::write_dx (const Triangulation<1,3> &, + std::ostream &) const +{ + Assert (false, ExcNotImplemented()); +} + -template -void GridOut::write_dx (const Triangulation &tria, +template +void GridOut::write_dx (const Triangulation &tria, std::ostream &out) const { //TODO:[GK] allow for boundary faces only Assert(dx_flags.write_all_faces, ExcNotImplemented()); AssertThrow (out, ExcIO()); // Copied and adapted from write_ucd - const std::vector > &vertices = tria.get_vertices(); + const std::vector > &vertices = tria.get_vertices(); const std::vector &vertex_used = tria.get_used_vertices(); const unsigned int n_vertices = tria.n_used_vertices(); @@ -718,8 +732,8 @@ void GridOut::write_dx (const Triangulation &tria, renumber[i]=new_number++; Assert(new_number==n_vertices, ExcInternalError()); - typename Triangulation::active_cell_iterator cell; - const typename Triangulation::active_cell_iterator endc=tria.end(); + typename Triangulation::active_cell_iterator cell; + const typename Triangulation::active_cell_iterator endc=tria.end(); // write the vertices @@ -809,7 +823,7 @@ void GridOut::write_dx (const Triangulation &tria, { for (unsigned int f=0; f::faces_per_cell; ++f) { - typename Triangulation::face_iterator face = cell->face(f); + typename Triangulation::face_iterator face = cell->face(f); for (unsigned int v=0; v::vertices_per_face; ++v) out << '\t' << renumber[face->vertex_index(GeometryInfo::dx_to_deal[v])]; @@ -1192,11 +1206,11 @@ void GridOut::write_ucd (const Triangulation &tria, -template +template void GridOut::write_xfig ( - const Triangulation &, + const Triangulation &, std::ostream &, - const Mapping *) const + const Mapping *) const { Assert (false, ExcNotImplemented()); } @@ -1210,6 +1224,7 @@ void GridOut::write_xfig ( const Mapping<2> * /*mapping*/) const { const int dim = 2; + const int spacedim = 2; const unsigned int nv = GeometryInfo::vertices_per_cell; const unsigned int nf = GeometryInfo::faces_per_cell; @@ -1272,8 +1287,8 @@ void GridOut::write_xfig ( // on finer levels. Level 0 // corresponds to a depth of 900, // each level subtracting 1 - Triangulation::cell_iterator cell = tria.begin(); - const Triangulation::cell_iterator end = tria.end(); + Triangulation::cell_iterator cell = tria.begin(); + const Triangulation::cell_iterator end = tria.end(); for (; cell != end; ++cell) { @@ -1339,7 +1354,7 @@ void GridOut::write_xfig ( if (xfig_flags.draw_boundary) for (unsigned int f=0; f::face_iterator + Triangulation::face_iterator face = cell->face(face_reorder[f]); const types::boundary_id bi = face->boundary_indicator(); if (bi != numbers::internal_face_boundary_id) @@ -2264,8 +2279,8 @@ void GridOut::write_mathgl (const Triangulation<1> &, } -template -void GridOut::write_mathgl (const Triangulation &tria, +template +void GridOut::write_mathgl (const Triangulation &tria, std::ostream &out) const { AssertThrow (out, ExcIO ()); @@ -2356,7 +2371,7 @@ void GridOut::write_mathgl (const Triangulation &tria, // run over all active cells and write out a list of // xyz-coordinates that correspond to vertices - typename dealii::Triangulation::active_cell_iterator + typename dealii::Triangulation::active_cell_iterator cell=tria.begin_active (), endc=tria.end (); @@ -3345,12 +3360,30 @@ namespace internal Assert(false, ExcNotImplemented()); } + void write_eps (const dealii::Triangulation<1,2> &, + std::ostream &, + const Mapping<1,2> *, + const GridOutFlags::Eps<2> &, + const GridOutFlags::Eps<3> &) + { + Assert(false, ExcNotImplemented()); + } + void write_eps (const dealii::Triangulation<2,3> &, + std::ostream &, + const Mapping<2,3> *, + const GridOutFlags::Eps<2> &, + const GridOutFlags::Eps<3> &) + { + Assert(false, ExcNotImplemented()); + } - template - void write_eps (const dealii::Triangulation &tria, + + + template + void write_eps (const dealii::Triangulation &tria, std::ostream &out, - const Mapping *mapping, + const Mapping *mapping, const GridOutFlags::Eps<2> &eps_flags_2, const GridOutFlags::Eps<3> &eps_flags_3) { @@ -3394,13 +3427,13 @@ namespace internal case 2: { - for (typename dealii::Triangulation::active_cell_iterator + for (typename dealii::Triangulation::active_cell_iterator cell=tria.begin_active(); cell!=tria.end(); ++cell) for (unsigned int line_no=0; line_no::lines_per_cell; ++line_no) { - typename dealii::Triangulation::line_iterator + typename dealii::Triangulation::line_iterator line=cell->line(line_no); // first treat all @@ -3467,12 +3500,12 @@ namespace internal // boundary faces and // generate the info from // them - for (typename dealii::Triangulation::active_cell_iterator + for (typename dealii::Triangulation::active_cell_iterator cell=tria.begin_active(); cell!=tria.end(); ++cell) for (unsigned int face_no=0; face_no::faces_per_cell; ++face_no) { - const typename dealii::Triangulation::face_iterator + const typename dealii::Triangulation::face_iterator face = cell->face(face_no); if (face->at_boundary()) @@ -3517,7 +3550,7 @@ namespace internal // presently not supported Assert (mapping == 0, ExcNotImplemented()); - typename dealii::Triangulation::active_cell_iterator + typename dealii::Triangulation::active_cell_iterator cell=tria.begin_active(), endc=tria.end(); @@ -3568,7 +3601,7 @@ namespace internal for (unsigned int line_no=0; line_no::lines_per_cell; ++line_no) { - typename dealii::Triangulation::line_iterator + typename dealii::Triangulation::line_iterator line=cell->line(line_no); line_list.push_back (LineEntry(Point<2>(line->vertex(0) * unit_vector2, line->vertex(0) * unit_vector1), @@ -3734,7 +3767,7 @@ namespace internal out << "(Helvetica) findfont 140 scalefont setfont" << '\n'; - typename dealii::Triangulation::active_cell_iterator + typename dealii::Triangulation::active_cell_iterator cell = tria.begin_active (), endc = tria.end (); for (; cell!=endc; ++cell) @@ -3765,7 +3798,7 @@ namespace internal // already tracked, to avoid // doing this multiply std::set treated_vertices; - typename dealii::Triangulation::active_cell_iterator + typename dealii::Triangulation::active_cell_iterator cell = tria.begin_active (), endc = tria.end (); for (; cell!=endc; ++cell) @@ -3801,10 +3834,10 @@ namespace internal } -template -void GridOut::write_eps (const Triangulation &tria, +template +void GridOut::write_eps (const Triangulation &tria, std::ostream &out, - const Mapping *mapping) const + const Mapping *mapping) const { internal::write_eps (tria, out, mapping, eps_flags_2, eps_flags_3); diff --git a/deal.II/source/grid/grid_out.inst.in b/deal.II/source/grid/grid_out.inst.in index 160a8fd98f..c9cbe7f4bb 100644 --- a/deal.II/source/grid/grid_out.inst.in +++ b/deal.II/source/grid/grid_out.inst.in @@ -82,6 +82,15 @@ for (deal_II_dimension : DIMENSIONS) template void GridOut::write_vtu (const Triangulation&, std::ostream&) const; + + template void GridOut::write + (const Triangulation &, + std::ostream &, const OutputFormat, + const Mapping *) const; + template void GridOut::write + (const Triangulation &, + std::ostream &, const Mapping *) const; + #endif #if deal_II_dimension == 3 template void GridOut::write_ucd -- 2.39.5