const DoFHandler<dim> &
get_dof_handler(const unsigned int dof_handler_index = 0) const;
+ /**
+ * Return the AffineConstraints with the index as given to the
+ * respective `std::vector` argument in the reinit() function. Only available
+ * if the AffineConstraints objects have the same template parameter Number as
+ * MatrixFree. Throws an exception otherwise.
+ */
+ const AffineConstraints<Number> &
+ get_affine_constraints(const unsigned int dof_handler_index = 0) const;
+
/**
* Return the cell iterator in deal.II speak to a given cell batch
* (populating several lanes in a VectorizedArray) and the lane index within
*/
std::vector<SmartPointer<const DoFHandler<dim>>> dof_handlers;
+ /**
+ * Pointers to the AffineConstraints underlying the current problem. Only
+ * filled with an AffineConstraints object if objects of the same `Number`
+ * template parameter as the `Number` template of MatrixFree is passed to
+ * reinit(). Filled with nullptr otherwise.
+ */
+ std::vector<SmartPointer<const AffineConstraints<Number>>> affine_constraints;
+
/**
* Contains the information about degrees of freedom on the individual cells
* and constraints.
+template <int dim, typename Number, typename VectorizedArrayType>
+const AffineConstraints<Number> &
+MatrixFree<dim, Number, VectorizedArrayType>::get_affine_constraints(
+ const unsigned int dof_handler_index) const
+{
+ AssertIndexRange(dof_handler_index, n_components());
+
+ AssertThrow(affine_constraints[dof_handler_index] != nullptr,
+ ExcMessage(
+ "AffineConstraints are only accessible if its Number type "
+ "matches with Number type of MatrixFree!"));
+
+ return *(affine_constraints[dof_handler_index]);
+}
+
+
+
template <int dim, typename Number, typename VectorizedArrayType>
typename DoFHandler<dim>::cell_iterator
MatrixFree<dim, Number, VectorizedArrayType>::get_cell_iterator(
+namespace internal
+{
+ template <typename Number, typename Number2>
+ void
+ store_affine_constraints(
+ const dealii::AffineConstraints<Number2> *,
+ SmartPointer<const dealii::AffineConstraints<Number>> &stored_constraints)
+ {
+ stored_constraints = nullptr;
+ }
+
+ template <typename Number>
+ void
+ store_affine_constraints(
+ const dealii::AffineConstraints<Number> * affine_constraints,
+ SmartPointer<const dealii::AffineConstraints<Number>> &stored_constraints)
+ {
+ stored_constraints = affine_constraints;
+ }
+} // namespace internal
+
+
+
template <int dim, typename Number, typename VectorizedArrayType>
template <typename number2, int q_dim>
void
.reinit(quad[nq][q_no], dof_handler[no]->get_fe(fe_no), b);
}
+ // Store pointers to AffineConstraints objects if Number type matches
+ affine_constraints.resize(constraints.size());
+ for (unsigned int no = 0; no < constraints.size(); ++no)
+ internal::store_affine_constraints(constraints[no], affine_constraints[no]);
+
if (additional_data.initialize_indices == true)
{
clear();
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2019 - 2022 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 internal::store_affine_constraints() and get_affine_constraints()
+
+#include <deal.II/base/quadrature_lib.h>
+
+#include <deal.II/dofs/dof_handler.h>
+
+#include <deal.II/fe/fe_dgq.h>
+
+#include <deal.II/grid/grid_generator.h>
+
+#include <deal.II/matrix_free/matrix_free.h>
+
+#include "../tests.h"
+
+
+int
+main()
+{
+ initlog();
+
+ const unsigned int fe_degree = 1;
+ constexpr int dim = 2;
+
+ Triangulation<dim> tria;
+ GridGenerator::hyper_cube(tria, 0, 1, true);
+
+ FE_DGQ<dim> fe(fe_degree);
+ DoFHandler<dim> dof_handler(tria);
+ dof_handler.distribute_dofs(fe);
+
+ QGauss<1> quadrature(fe_degree + 1);
+
+ AffineConstraints<double> double_ac;
+ double_ac.close();
+
+ {
+ typename MatrixFree<dim, double>::AdditionalData additional_data_double;
+ MatrixFree<dim, double> matrix_free_double;
+ matrix_free_double.reinit(MappingQ1<dim>{},
+ dof_handler,
+ double_ac,
+ quadrature,
+ additional_data_double);
+
+ if (&matrix_free_double.get_affine_constraints() == &double_ac)
+ deallog << "OK" << std::endl;
+ }
+
+ {
+ typename MatrixFree<dim, float>::AdditionalData additional_data_float;
+ MatrixFree<dim, float> matrix_free_float;
+ matrix_free_float.reinit(MappingQ1<dim>{},
+ dof_handler,
+ double_ac,
+ quadrature,
+ additional_data_float);
+
+ try
+ {
+ matrix_free_float.get_affine_constraints();
+ }
+ catch (...)
+ {
+ deallog << "OK" << std::endl;
+ }
+ }
+}
--- /dev/null
+
+DEAL::OK
+DEAL::OK