first_selected_component);
}
+ namespace internal
+ {
+ /**
+ * If value type of matrix and constrains equals, return a reference
+ * to the given AffineConstraint instance.
+ */
+ template <typename MatrixType,
+ typename Number,
+ typename std::enable_if<std::is_same<
+ typename std::remove_const<typename std::remove_reference<
+ typename MatrixType::value_type>::type>::type,
+ typename std::remove_const<typename std::remove_reference<
+ Number>::type>::type>::value>::type * = nullptr>
+ const AffineConstraints<typename MatrixType::value_type> &
+ create_new_affine_constraints_if_needed(
+ const MatrixType &,
+ const AffineConstraints<Number> &constraints,
+ std::unique_ptr<AffineConstraints<typename MatrixType::value_type>> &)
+ {
+ return constraints;
+ }
+
+ /**
+ * If value type of matrix and constrains do not equal, a new
+ * AffineConstraint instance with the value type of the matrix is
+ * created and a reference to it is returned.
+ */
+ template <typename MatrixType,
+ typename Number,
+ typename std::enable_if<!std::is_same<
+ typename std::remove_const<typename std::remove_reference<
+ typename MatrixType::value_type>::type>::type,
+ typename std::remove_const<typename std::remove_reference<
+ Number>::type>::type>::value>::type * = nullptr>
+ const AffineConstraints<typename MatrixType::value_type> &
+ create_new_affine_constraints_if_needed(
+ const MatrixType &,
+ const AffineConstraints<Number> &constraints,
+ std::unique_ptr<AffineConstraints<typename MatrixType::value_type>>
+ &new_constraints)
+ {
+ new_constraints =
+ std::make_unique<AffineConstraints<typename MatrixType::value_type>>();
+ new_constraints->copy_from(constraints);
+
+ return *new_constraints;
+ }
+ } // namespace internal
+
template <int dim,
int fe_degree,
int n_q_points_1d,
typename MatrixType>
void
compute_matrix(
- const MatrixFree<dim, Number, VectorizedArrayType> & matrix_free,
- const AffineConstraints<Number> & constraints,
- MatrixType & matrix,
+ const MatrixFree<dim, Number, VectorizedArrayType> &matrix_free,
+ const AffineConstraints<Number> & constraints_in,
+ MatrixType & matrix,
const std::function<void(FEEvaluation<dim,
fe_degree,
n_q_points_1d,
const unsigned int quad_no,
const unsigned int first_selected_component)
{
+ std::unique_ptr<AffineConstraints<typename MatrixType::value_type>>
+ constraints_for_matrix;
+ const AffineConstraints<typename MatrixType::value_type> &constraints =
+ internal::create_new_affine_constraints_if_needed(matrix,
+ constraints_in,
+ constraints_for_matrix);
+
matrix_free.template cell_loop<MatrixType, MatrixType>(
[&](const auto &, auto &dst, const auto &, const auto range) {
FEEvaluation<dim,
AffineConstraints<Number> constraint;
DoFTools::make_hanging_node_constraints(dof_handler, constraint);
- VectorTools::interpolate_boundary_values(
- dof_handler, 0, Functions::ZeroFunction<dim>(n_components), constraint);
+ VectorTools::interpolate_boundary_values(dof_handler,
+ 0,
+ Functions::ZeroFunction<dim, Number>(
+ n_components),
+ constraint);
constraint.close();
test<2, 1, 2, 1>(); // scalar
test<2, 1, 2, 2>(); // vector
+
+ test<2, 1, 2, 1, float>(); // scalar
+ test<2, 1, 2, 2, float>(); // vector
}
Vector data:
0.000e+00 0.000e+00 0.000e+00 0.000e+00 3.000e+00 3.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 2.667e+00 2.667e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 2.667e+00 2.667e+00 0.000e+00 0.000e+00 2.667e+00 2.667e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00
DEAL:0::7.78888
+Process #0
+Local range: [0, 18), global size: 18
+Vector data:
+0.000e+00 0.000e+00 3.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 2.667e+00 0.000e+00 0.000e+00 2.667e+00 0.000e+00 2.667e+00 0.000e+00 0.000e+00 0.000e+00
+DEAL:0::5.50757
+Process #0
+Local range: [0, 18), global size: 18
+Vector data:
+0.000e+00 0.000e+00 3.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 2.667e+00 0.000e+00 0.000e+00 2.667e+00 0.000e+00 2.667e+00 0.000e+00 0.000e+00 0.000e+00
+DEAL:0::5.50757
+Process #0
+Local range: [0, 18), global size: 18
+Vector data:
+0.000e+00 0.000e+00 3.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 2.667e+00 0.000e+00 0.000e+00 2.667e+00 0.000e+00 2.667e+00 0.000e+00 0.000e+00 0.000e+00
+DEAL:0::5.50757
+Process #0
+Local range: [0, 36), global size: 36
+Vector data:
+0.000e+00 0.000e+00 0.000e+00 0.000e+00 3.000e+00 3.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 2.667e+00 2.667e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 2.667e+00 2.667e+00 0.000e+00 0.000e+00 2.667e+00 2.667e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00
+DEAL:0::7.78888
+Process #0
+Local range: [0, 36), global size: 36
+Vector data:
+0.000e+00 0.000e+00 0.000e+00 0.000e+00 3.000e+00 3.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 2.667e+00 2.667e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 2.667e+00 2.667e+00 0.000e+00 0.000e+00 2.667e+00 2.667e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00
+DEAL:0::7.78888
+Process #0
+Local range: [0, 36), global size: 36
+Vector data:
+0.000e+00 0.000e+00 0.000e+00 0.000e+00 3.000e+00 3.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 2.667e+00 2.667e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 2.667e+00 2.667e+00 0.000e+00 0.000e+00 2.667e+00 2.667e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00
+DEAL:0::7.78888
+Process #0
+Local range: [0, 9), global size: 18
+Vector data:
+0.000e+00 0.000e+00 0.000e+00 2.667e+00 0.000e+00 0.000e+00 0.000e+00 2.667e+00 3.000e+00
+DEAL:0::5.50757
+Process #0
+Local range: [0, 9), global size: 18
+Vector data:
+0.000e+00 0.000e+00 0.000e+00 2.667e+00 0.000e+00 0.000e+00 0.000e+00 2.667e+00 3.000e+00
+DEAL:0::5.50757
+Process #0
+Local range: [0, 9), global size: 18
+Vector data:
+0.000e+00 0.000e+00 0.000e+00 2.667e+00 0.000e+00 0.000e+00 0.000e+00 2.667e+00 3.000e+00
+DEAL:0::5.50757
+Process #0
+Local range: [0, 18), global size: 36
+Vector data:
+0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 2.667e+00 2.667e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 2.667e+00 2.667e+00 3.000e+00 3.000e+00
+DEAL:0::7.78888
+Process #0
+Local range: [0, 18), global size: 36
+Vector data:
+0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 2.667e+00 2.667e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 2.667e+00 2.667e+00 3.000e+00 3.000e+00
+DEAL:0::7.78888
+Process #0
+Local range: [0, 18), global size: 36
+Vector data:
+0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 2.667e+00 2.667e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 2.667e+00 2.667e+00 3.000e+00 3.000e+00
+DEAL:0::7.78888
Process #0
Local range: [0, 9), global size: 18
Vector data:
Vector data:
0.000e+00 0.000e+00 0.000e+00 0.000e+00
DEAL:1::7.78888
+Process #1
+Local range: [9, 11), global size: 18
+Vector data:
+0.000e+00 0.000e+00
+DEAL:1::5.50757
+Process #1
+Local range: [9, 11), global size: 18
+Vector data:
+0.000e+00 0.000e+00
+DEAL:1::5.50757
+Process #1
+Local range: [9, 11), global size: 18
+Vector data:
+0.000e+00 0.000e+00
+DEAL:1::5.50757
+Process #1
+Local range: [18, 22), global size: 36
+Vector data:
+0.000e+00 0.000e+00 0.000e+00 0.000e+00
+DEAL:1::7.78888
+Process #1
+Local range: [18, 22), global size: 36
+Vector data:
+0.000e+00 0.000e+00 0.000e+00 0.000e+00
+DEAL:1::7.78888
+Process #1
+Local range: [18, 22), global size: 36
+Vector data:
+0.000e+00 0.000e+00 0.000e+00 0.000e+00
+DEAL:1::7.78888
Process #2
Vector data:
0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 2.667e+00 2.667e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00
DEAL:2::7.78888
+Process #2
+Local range: [11, 18), global size: 18
+Vector data:
+0.000e+00 0.000e+00 0.000e+00 2.667e+00 0.000e+00 0.000e+00 0.000e+00
+DEAL:2::5.50757
+Process #2
+Local range: [11, 18), global size: 18
+Vector data:
+0.000e+00 0.000e+00 0.000e+00 2.667e+00 0.000e+00 0.000e+00 0.000e+00
+DEAL:2::5.50757
+Process #2
+Local range: [11, 18), global size: 18
+Vector data:
+0.000e+00 0.000e+00 0.000e+00 2.667e+00 0.000e+00 0.000e+00 0.000e+00
+DEAL:2::5.50757
+Process #2
+Local range: [22, 36), global size: 36
+Vector data:
+0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 2.667e+00 2.667e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00
+DEAL:2::7.78888
+Process #2
+Local range: [22, 36), global size: 36
+Vector data:
+0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 2.667e+00 2.667e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00
+DEAL:2::7.78888
+Process #2
+Local range: [22, 36), global size: 36
+Vector data:
+0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 2.667e+00 2.667e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00
+DEAL:2::7.78888