--- /dev/null
+New: The type alias FEValuesViews::View now allows one to infer the correct FEValuesViews type
+that would be returned by FEValuesBase::operator[]() when called with a specified extractor type from the
+FEValuesExtractors namespace.
+<br>
+(Luca Heltai, 2019/03/20)
{
namespace FEValuesViews
{
+ /**
+ * A class whose specialization is used to define what FEValuesViews
+ * object corresponds to the given FEValuesExtractors object.
+ *
+ * @author Luca Heltai, 2019.
+ */
+ template <int dim, int spacedim, typename Extractor>
+ struct ViewType
+ {};
+
+ /**
+ * A class whose specialization is used to define what FEValuesViews
+ * object corresponds to the given FEValuesExtractors object.
+ *
+ * When using FEValuesExtractors::Scalar, the corresponding view is an
+ * FEValuesViews::Scalar<dim, spacedim>.
+ */
+ template <int dim, int spacedim>
+ struct ViewType<dim, spacedim, FEValuesExtractors::Scalar>
+ {
+ using type = typename dealii::FEValuesViews::Scalar<dim, spacedim>;
+ };
+
+ /**
+ * A class whose specialization is used to define what FEValuesViews
+ * object corresponds to the given FEValuesExtractors object.
+ *
+ * When using FEValuesExtractors::Vector, the corresponding view is an
+ * FEValuesViews::Vector<dim, spacedim>.
+ */
+ template <int dim, int spacedim>
+ struct ViewType<dim, spacedim, FEValuesExtractors::Vector>
+ {
+ using type = typename dealii::FEValuesViews::Vector<dim, spacedim>;
+ };
+
+ /**
+ * A class whose specialization is used to define what FEValuesViews
+ * object corresponds to the given FEValuesExtractors object.
+ *
+ * When using FEValuesExtractors::Tensor<rank>, the corresponding view is an
+ * FEValuesViews::Tensor<rank, dim, spacedim>.
+ */
+ template <int dim, int spacedim, int rank>
+ struct ViewType<dim, spacedim, FEValuesExtractors::Tensor<rank>>
+ {
+ using type = typename dealii::FEValuesViews::Tensor<rank, dim, spacedim>;
+ };
+
+ /**
+ * A class whose specialization is used to define what FEValuesViews
+ * object corresponds to the given FEValuesExtractors object.
+ *
+ * When using FEValuesExtractors::SymmetricTensor<rank>, the corresponding
+ * view is an FEValuesViews::SymmetricTensor<rank, dim, spacedim>.
+ */
+ template <int dim, int spacedim, int rank>
+ struct ViewType<dim, spacedim, FEValuesExtractors::SymmetricTensor<rank>>
+ {
+ using type =
+ typename dealii::FEValuesViews::SymmetricTensor<rank, dim, spacedim>;
+ };
+
/**
* A class objects of which store a collection of FEValuesViews::Scalar,
* FEValuesViews::Vector, etc object. The FEValuesBase class uses it to
} // namespace FEValuesViews
} // namespace internal
+namespace FEValuesViews
+{
+ /**
+ * A templated alias that associates to a given Extractor class
+ * the corresponding view in FEValuesViews.
+ *
+ * @author Luca Heltai, 2019.
+ */
+ template <int dim, int spacedim, typename Extractor>
+ using View =
+ typename internal::FEValuesViews::ViewType<dim, spacedim, Extractor>::type;
+} // namespace FEValuesViews
/**
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2019 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.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+// Test FEValuesViews::View<dim,spacedim,Extractor>
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/fe/fe_values.h>
+
+#include "../tests.h"
+
+template <int dim, int spacedim, typename Extractor>
+void
+test(const Extractor &)
+{
+ typename FEValuesViews::View<dim, spacedim, Extractor>::template OutputType<
+ double>::value_type t1;
+
+ typename FEValuesViews::View<dim, spacedim, Extractor>::template OutputType<
+ double>::gradient_type t2;
+
+ deallog << "Test<" << Utilities::dim_string(dim, spacedim) << ">" << std::endl
+ << Utilities::type_to_string(t1) << std::endl
+ << Utilities::type_to_string(t2) << std::endl;
+}
+
+int
+main()
+{
+ initlog();
+
+ FEValuesExtractors::Scalar scalar(0);
+ FEValuesExtractors::Vector vector(1);
+ FEValuesExtractors::Tensor<2> tensor(2);
+
+ test<1, 1>(scalar);
+ test<1, 1>(vector);
+ test<1, 1>(tensor);
+
+ test<1, 2>(scalar);
+ test<1, 2>(vector);
+ test<1, 2>(tensor);
+
+ test<2, 2>(scalar);
+ test<2, 2>(vector);
+ test<2, 2>(tensor);
+
+ test<2, 3>(scalar);
+ test<2, 3>(vector);
+ test<2, 3>(tensor);
+
+ test<3, 3>(scalar);
+ test<3, 3>(vector);
+ test<3, 3>(tensor);
+}
--- /dev/null
+
+DEAL::Test<1>
+DEAL::double
+DEAL::dealii::Tensor<1, 1, double>
+DEAL::Test<1>
+DEAL::dealii::Tensor<1, 1, double>
+DEAL::dealii::Tensor<2, 1, double>
+DEAL::Test<1>
+DEAL::dealii::Tensor<2, 1, double>
+DEAL::dealii::Tensor<3, 1, double>
+DEAL::Test<1,2>
+DEAL::double
+DEAL::dealii::Tensor<1, 2, double>
+DEAL::Test<1,2>
+DEAL::dealii::Tensor<1, 2, double>
+DEAL::dealii::Tensor<2, 2, double>
+DEAL::Test<1,2>
+DEAL::dealii::Tensor<2, 2, double>
+DEAL::dealii::Tensor<3, 2, double>
+DEAL::Test<2>
+DEAL::double
+DEAL::dealii::Tensor<1, 2, double>
+DEAL::Test<2>
+DEAL::dealii::Tensor<1, 2, double>
+DEAL::dealii::Tensor<2, 2, double>
+DEAL::Test<2>
+DEAL::dealii::Tensor<2, 2, double>
+DEAL::dealii::Tensor<3, 2, double>
+DEAL::Test<2,3>
+DEAL::double
+DEAL::dealii::Tensor<1, 3, double>
+DEAL::Test<2,3>
+DEAL::dealii::Tensor<1, 3, double>
+DEAL::dealii::Tensor<2, 3, double>
+DEAL::Test<2,3>
+DEAL::dealii::Tensor<2, 3, double>
+DEAL::dealii::Tensor<3, 3, double>
+DEAL::Test<3>
+DEAL::double
+DEAL::dealii::Tensor<1, 3, double>
+DEAL::Test<3>
+DEAL::dealii::Tensor<1, 3, double>
+DEAL::dealii::Tensor<2, 3, double>
+DEAL::Test<3>
+DEAL::dealii::Tensor<2, 3, double>
+DEAL::dealii::Tensor<3, 3, double>