--- /dev/null
+//-----------------------------------------------------------------------------
+// $Id$
+// Version: $Name$
+//
+// Copyright (C) 2013 by the deal.II authors
+//
+// This file is subject to QPL and may not be distributed
+// without copyright and license information. Please refer
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//-----------------------------------------------------------------------------
+
+// Test ConstantTensorFunction
+
+#include "../tests.h"
+#include <deal.II/base/tensor_function.h>
+
+
+
+// Fill a tensor with values:
+template<int rank, int dim>
+struct FillTensor
+{
+ static void fill_tensor(Tensor<rank, dim> &tensor, int base)
+ {
+ for(int i = 0; i < dim; ++i)
+ FillTensor<rank-1,dim>::fill_tensor(tensor[i], 10 * base + i);
+ }
+};
+
+template<int dim>
+struct FillTensor<1, dim>
+{
+ static void fill_tensor(Tensor<1, dim> &tensor, int base)
+ {
+ for(int i = 0; i < dim; ++i)
+ tensor[i] = 10 * base + i;
+ }
+};
+
+
+
+// Print a tensor of arbitrary rank to the console:
+template<int rank, int dim>
+struct PrintTensor
+{
+ static void print_tensor(const Tensor<rank, dim> &tensor)
+ {
+ for(int i = 0; i < dim; ++i)
+ {
+ PrintTensor<rank-1,dim>::print_tensor(tensor[i]);
+ deallog << " ";
+ }
+ }
+};
+
+template<int dim>
+struct PrintTensor<1, dim>
+{
+ static void print_tensor(const Tensor<1, dim> &tensor)
+ {
+ for(int i = 0; i < dim; ++i)
+ deallog << tensor[i] << " ";
+ }
+};
+
+
+
+template <int rank, int dim>
+void check ()
+{
+ deallog << "ConstantTensorFunction<"
+ << rank << ", " << dim << ">:" << std::endl;
+
+ Tensor<rank, dim> value;
+ FillTensor<rank, dim>::fill_tensor(value, 0);
+
+ ConstantTensorFunction<rank, dim> tensor_function(value);
+ TensorFunction<rank, dim> *foo = &tensor_function;
+
+
+ Point<dim> point;
+ for (int i = 0; i < dim; ++i)
+ point(i) = i;
+
+ deallog << "->value:" << std::endl;
+ PrintTensor<rank, dim>::print_tensor( foo->value(point) );
+ deallog << std::endl;
+
+ deallog << "->gradient:" << std::endl;
+ PrintTensor<rank+1, dim>::print_tensor( foo->gradient(point) );
+ deallog << std::endl;
+
+
+ std::vector<Point<dim> > points;
+ points.push_back(point);
+
+ for (int i = 0; i < dim; ++i)
+ point(i) = dim-i;
+ points.push_back(point);
+
+ std::vector<Tensor<rank, dim> > tensors;
+ std::vector<Tensor<rank + 1, dim> > gradients;
+ tensors.resize(2);
+ gradients.resize(2);
+
+ deallog << "->value_list:" << std::endl;
+ foo->value_list(points, tensors);
+ PrintTensor<rank, dim>::print_tensor(tensors[0]);
+ deallog << std::endl;
+ PrintTensor<rank, dim>::print_tensor(tensors[1]);
+ deallog << std::endl;
+
+ deallog << "->gradient_list:" << std::endl;
+ foo->gradient_list(points, gradients);
+ PrintTensor<rank + 1, dim>::print_tensor(gradients[0]);
+ deallog << std::endl;
+ PrintTensor<rank + 1, dim>::print_tensor(gradients[1]);
+ deallog << std::endl;
+}
+
+
+
+int main()
+{
+ std::string logname = JobIdentifier::base_name(__FILE__) + std::string("/output");
+ std::ofstream logfile(logname.c_str());
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ check<1,1>();
+ check<2,1>();
+ check<3,1>();
+ check<4,1>();
+
+ check<1,2>();
+ check<2,2>();
+ check<3,2>();
+ check<4,2>();
+
+ check<1,3>();
+ check<2,3>();
+ check<3,3>();
+ check<4,3>();
+}
+
--- /dev/null
+
+DEAL::ConstantTensorFunction<1, 1>:
+DEAL::->value:
+DEAL::0
+DEAL::->gradient:
+DEAL::0
+DEAL::->value_list:
+DEAL::0
+DEAL::0
+DEAL::->gradient_list:
+DEAL::0
+DEAL::0
+DEAL::ConstantTensorFunction<2, 1>:
+DEAL::->value:
+DEAL::0
+DEAL::->gradient:
+DEAL::0
+DEAL::->value_list:
+DEAL::0
+DEAL::0
+DEAL::->gradient_list:
+DEAL::0
+DEAL::0
+DEAL::ConstantTensorFunction<3, 1>:
+DEAL::->value:
+DEAL::0
+DEAL::->gradient:
+DEAL::0
+DEAL::->value_list:
+DEAL::0
+DEAL::0
+DEAL::->gradient_list:
+DEAL::0
+DEAL::0
+DEAL::ConstantTensorFunction<4, 1>:
+DEAL::->value:
+DEAL::0
+DEAL::->gradient:
+DEAL::0
+DEAL::->value_list:
+DEAL::0
+DEAL::0
+DEAL::->gradient_list:
+DEAL::0
+DEAL::0
+DEAL::ConstantTensorFunction<1, 2>:
+DEAL::->value:
+DEAL::0 1.00000
+DEAL::->gradient:
+DEAL::0 0 0 0
+DEAL::->value_list:
+DEAL::0 1.00000
+DEAL::0 1.00000
+DEAL::->gradient_list:
+DEAL::0 0 0 0
+DEAL::0 0 0 0
+DEAL::ConstantTensorFunction<2, 2>:
+DEAL::->value:
+DEAL::0 1.00000 10.0000 11.0000
+DEAL::->gradient:
+DEAL::0 0 0 0 0 0 0 0
+DEAL::->value_list:
+DEAL::0 1.00000 10.0000 11.0000
+DEAL::0 1.00000 10.0000 11.0000
+DEAL::->gradient_list:
+DEAL::0 0 0 0 0 0 0 0
+DEAL::0 0 0 0 0 0 0 0
+DEAL::ConstantTensorFunction<3, 2>:
+DEAL::->value:
+DEAL::0 1.00000 10.0000 11.0000 100.000 101.000 110.000 111.000
+DEAL::->gradient:
+DEAL::0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+DEAL::->value_list:
+DEAL::0 1.00000 10.0000 11.0000 100.000 101.000 110.000 111.000
+DEAL::0 1.00000 10.0000 11.0000 100.000 101.000 110.000 111.000
+DEAL::->gradient_list:
+DEAL::0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+DEAL::0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+DEAL::ConstantTensorFunction<4, 2>:
+DEAL::->value:
+DEAL::0 1.00000 10.0000 11.0000 100.000 101.000 110.000 111.000 1000.00 1001.00 1010.00 1011.00 1100.00 1101.00 1110.00 1111.00
+DEAL::->gradient:
+DEAL::0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+DEAL::->value_list:
+DEAL::0 1.00000 10.0000 11.0000 100.000 101.000 110.000 111.000 1000.00 1001.00 1010.00 1011.00 1100.00 1101.00 1110.00 1111.00
+DEAL::0 1.00000 10.0000 11.0000 100.000 101.000 110.000 111.000 1000.00 1001.00 1010.00 1011.00 1100.00 1101.00 1110.00 1111.00
+DEAL::->gradient_list:
+DEAL::0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+DEAL::0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+DEAL::ConstantTensorFunction<1, 3>:
+DEAL::->value:
+DEAL::0 1.00000 2.00000
+DEAL::->gradient:
+DEAL::0 0 0 0 0 0 0 0 0
+DEAL::->value_list:
+DEAL::0 1.00000 2.00000
+DEAL::0 1.00000 2.00000
+DEAL::->gradient_list:
+DEAL::0 0 0 0 0 0 0 0 0
+DEAL::0 0 0 0 0 0 0 0 0
+DEAL::ConstantTensorFunction<2, 3>:
+DEAL::->value:
+DEAL::0 1.00000 2.00000 10.0000 11.0000 12.0000 20.0000 21.0000 22.0000
+DEAL::->gradient:
+DEAL::0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+DEAL::->value_list:
+DEAL::0 1.00000 2.00000 10.0000 11.0000 12.0000 20.0000 21.0000 22.0000
+DEAL::0 1.00000 2.00000 10.0000 11.0000 12.0000 20.0000 21.0000 22.0000
+DEAL::->gradient_list:
+DEAL::0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+DEAL::0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+DEAL::ConstantTensorFunction<3, 3>:
+DEAL::->value:
+DEAL::0 1.00000 2.00000 10.0000 11.0000 12.0000 20.0000 21.0000 22.0000 100.000 101.000 102.000 110.000 111.000 112.000 120.000 121.000 122.000 200.000 201.000 202.000 210.000 211.000 212.000 220.000 221.000 222.000
+DEAL::->gradient:
+DEAL::0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+DEAL::->value_list:
+DEAL::0 1.00000 2.00000 10.0000 11.0000 12.0000 20.0000 21.0000 22.0000 100.000 101.000 102.000 110.000 111.000 112.000 120.000 121.000 122.000 200.000 201.000 202.000 210.000 211.000 212.000 220.000 221.000 222.000
+DEAL::0 1.00000 2.00000 10.0000 11.0000 12.0000 20.0000 21.0000 22.0000 100.000 101.000 102.000 110.000 111.000 112.000 120.000 121.000 122.000 200.000 201.000 202.000 210.000 211.000 212.000 220.000 221.000 222.000
+DEAL::->gradient_list:
+DEAL::0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+DEAL::0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+DEAL::ConstantTensorFunction<4, 3>:
+DEAL::->value:
+DEAL::0 1.00000 2.00000 10.0000 11.0000 12.0000 20.0000 21.0000 22.0000 100.000 101.000 102.000 110.000 111.000 112.000 120.000 121.000 122.000 200.000 201.000 202.000 210.000 211.000 212.000 220.000 221.000 222.000 1000.00 1001.00 1002.00 1010.00 1011.00 1012.00 1020.00 1021.00 1022.00 1100.00 1101.00 1102.00 1110.00 1111.00 1112.00 1120.00 1121.00 1122.00 1200.00 1201.00 1202.00 1210.00 1211.00 1212.00 1220.00 1221.00 1222.00 2000.00 2001.00 2002.00 2010.00 2011.00 2012.00 2020.00 2021.00 2022.00 2100.00 2101.00 2102.00 2110.00 2111.00 2112.00 2120.00 2121.00 2122.00 2200.00 2201.00 2202.00 2210.00 2211.00 2212.00 2220.00 2221.00 2222.00
+DEAL::->gradient:
+DEAL::0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+DEAL::->value_list:
+DEAL::0 1.00000 2.00000 10.0000 11.0000 12.0000 20.0000 21.0000 22.0000 100.000 101.000 102.000 110.000 111.000 112.000 120.000 121.000 122.000 200.000 201.000 202.000 210.000 211.000 212.000 220.000 221.000 222.000 1000.00 1001.00 1002.00 1010.00 1011.00 1012.00 1020.00 1021.00 1022.00 1100.00 1101.00 1102.00 1110.00 1111.00 1112.00 1120.00 1121.00 1122.00 1200.00 1201.00 1202.00 1210.00 1211.00 1212.00 1220.00 1221.00 1222.00 2000.00 2001.00 2002.00 2010.00 2011.00 2012.00 2020.00 2021.00 2022.00 2100.00 2101.00 2102.00 2110.00 2111.00 2112.00 2120.00 2121.00 2122.00 2200.00 2201.00 2202.00 2210.00 2211.00 2212.00 2220.00 2221.00 2222.00
+DEAL::0 1.00000 2.00000 10.0000 11.0000 12.0000 20.0000 21.0000 22.0000 100.000 101.000 102.000 110.000 111.000 112.000 120.000 121.000 122.000 200.000 201.000 202.000 210.000 211.000 212.000 220.000 221.000 222.000 1000.00 1001.00 1002.00 1010.00 1011.00 1012.00 1020.00 1021.00 1022.00 1100.00 1101.00 1102.00 1110.00 1111.00 1112.00 1120.00 1121.00 1122.00 1200.00 1201.00 1202.00 1210.00 1211.00 1212.00 1220.00 1221.00 1222.00 2000.00 2001.00 2002.00 2010.00 2011.00 2012.00 2020.00 2021.00 2022.00 2100.00 2101.00 2102.00 2110.00 2111.00 2112.00 2120.00 2121.00 2122.00 2200.00 2201.00 2202.00 2210.00 2211.00 2212.00 2220.00 2221.00 2222.00
+DEAL::->gradient_list:
+DEAL::0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+DEAL::0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0