From: Wolfgang Bangerth Date: Thu, 3 Dec 2020 22:10:46 +0000 (-0700) Subject: Avoid raw pointers in more places. X-Git-Tag: v9.3.0-rc1~786^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4546bdc0eb25eff82d153338fd7c89ec59239370;p=dealii.git Avoid raw pointers in more places. --- diff --git a/include/deal.II/matrix_free/shape_info.templates.h b/include/deal.II/matrix_free/shape_info.templates.h index 3ae57a53c5..403e25aceb 100644 --- a/include/deal.II/matrix_free/shape_info.templates.h +++ b/include/deal.II/matrix_free/shape_info.templates.h @@ -254,16 +254,16 @@ namespace internal AssertDimension(dim, dim_q); - const auto quad = Quadrature(quad_in); - const auto fe = &fe_in.base_element(base_element_number); + const auto quad = Quadrature(quad_in); + const auto &fe = fe_in.base_element(base_element_number); n_dimensions = dim; n_components = fe_in.n_components(); n_q_points = quad.size(); - dofs_per_component_on_cell = fe->n_dofs_per_cell(); + dofs_per_component_on_cell = fe.n_dofs_per_cell(); n_q_points_face = 0; // not implemented yet dofs_per_component_on_face = 0; // - Assert(fe->n_components() == 1, + Assert(fe.n_components() == 1, ExcMessage( "FEEvaluation only works for scalar finite elements.")); @@ -277,10 +277,10 @@ namespace internal // a 1D quadrature rule. However, in this case we are not able to // define that rule anyway so other code cannot use this information. - univariate_shape_data.fe_degree = fe->degree; + univariate_shape_data.fe_degree = fe.degree; univariate_shape_data.n_q_points_1d = quad.size(); - if ((fe->n_dofs_per_cell() == 0) || (quad.size() == 0)) + if ((fe.n_dofs_per_cell() == 0) || (quad.size() == 0)) return; // grant write access to common univariate shape data @@ -290,7 +290,7 @@ namespace internal auto &shape_gradients_face = univariate_shape_data.shape_gradients_face; - const unsigned int n_dofs = fe->n_dofs_per_cell(); + const unsigned int n_dofs = fe.n_dofs_per_cell(); const unsigned int array_size = n_dofs * n_q_points; @@ -301,9 +301,9 @@ namespace internal for (unsigned int q = 0; q < n_q_points; ++q) { shape_values[i * n_q_points + q] = - fe->shape_value(i, quad.point(q)); + fe.shape_value(i, quad.point(q)); - const auto grad = fe->shape_grad(i, quad.point(q)); + const auto grad = fe.shape_grad(i, quad.point(q)); for (int d = 0; d < dim; ++d) shape_gradients[d * n_dofs * n_q_points + i * n_q_points + @@ -351,9 +351,9 @@ namespace internal projected_quad_face.point(q + offset); shape_values_face(f, o, i * n_q_points_face + q) = - fe->shape_value(i, point); + fe.shape_value(i, point); - const auto grad = fe->shape_grad(i, point); + const auto grad = fe.shape_grad(i, point); for (int d = 0; d < dim; ++d) shape_gradients_face( @@ -380,7 +380,7 @@ namespace internal std::vector scalar_lexicographic; get_element_type_specific_information(fe_in, - *fe, + fe, base_element_number, element_type, scalar_lexicographic, @@ -401,11 +401,11 @@ namespace internal const auto quad = quad_in.get_tensor_basis()[0]; - const FiniteElement *fe = &fe_in.base_element(base_element_number); + const FiniteElement &fe = fe_in.base_element(base_element_number); n_dimensions = dim; n_components = fe_in.n_components(); - Assert(fe->n_components() == 1, + Assert(fe.n_components() == 1, ExcMessage("FEEvaluation only works for scalar finite elements.")); // assuming isotropy of dimensions and components @@ -414,10 +414,10 @@ namespace internal data_access.reinit(n_dimensions, n_components); data_access.fill(&univariate_shape_data); univariate_shape_data.quadrature = quad; - univariate_shape_data.fe_degree = fe->degree; + univariate_shape_data.fe_degree = fe.degree; univariate_shape_data.n_q_points_1d = quad.size(); - if ((fe->n_dofs_per_cell() == 0) || (quad.size() == 0)) + if ((fe.n_dofs_per_cell() == 0) || (quad.size() == 0)) return; // grant write access to common univariate shape data @@ -440,10 +440,10 @@ namespace internal auto &nodal_at_cell_boundaries = univariate_shape_data.nodal_at_cell_boundaries; - const unsigned int fe_degree = fe->degree; + const unsigned int fe_degree = fe.degree; const unsigned int n_q_points_1d = quad.size(); const unsigned int n_dofs_1d = - std::min(fe->n_dofs_per_cell(), fe_degree + 1); + std::min(fe.n_dofs_per_cell(), fe_degree + 1); // renumber (this is necessary for FE_Q, for example, since there the // vertex DoFs come first, which is incompatible with the lexicographic @@ -452,11 +452,10 @@ namespace internal Point unit_point; { // find numbering to lexicographic - Assert(fe->n_components() == 1, - ExcMessage("Expected a scalar element")); + Assert(fe.n_components() == 1, ExcMessage("Expected a scalar element")); get_element_type_specific_information(fe_in, - *fe, + fe, base_element_number, element_type, scalar_lexicographic, @@ -466,22 +465,22 @@ namespace internal // unit support point, assuming that fe.shape_value(0,unit_point) == // 1. otherwise, need other entry point (e.g. generating a 1D element // by reading the name, as done before r29356) - if (fe->has_support_points()) - unit_point = fe->get_unit_support_points()[scalar_lexicographic[0]]; - Assert(fe->n_dofs_per_cell() == 0 || - std::abs(fe->shape_value(scalar_lexicographic[0], unit_point) - + if (fe.has_support_points()) + unit_point = fe.get_unit_support_points()[scalar_lexicographic[0]]; + Assert(fe.n_dofs_per_cell() == 0 || + std::abs(fe.shape_value(scalar_lexicographic[0], unit_point) - 1) < 1e-13, ExcInternalError("Could not decode 1D shape functions for the " "element " + - fe->get_name())); + fe.get_name())); } n_q_points = Utilities::fixed_power(n_q_points_1d); n_q_points_face = - dim > 1 ? Utilities::fixed_power(n_q_points_1d) : 1; - dofs_per_component_on_cell = fe->n_dofs_per_cell(); + (dim > 1 ? Utilities::fixed_power(n_q_points_1d) : 1); + dofs_per_component_on_cell = fe.n_dofs_per_cell(); dofs_per_component_on_face = - dim > 1 ? Utilities::fixed_power(fe_degree + 1) : 1; + (dim > 1 ? Utilities::fixed_power(fe_degree + 1) : 1); const unsigned int array_size = n_dofs_1d * n_q_points_1d; shape_gradients.resize_fast(array_size); @@ -508,45 +507,45 @@ namespace internal q_point[0] = quad.get_points()[q][0]; shape_values[i * n_q_points_1d + q] = - fe->shape_value(my_i, q_point); + fe.shape_value(my_i, q_point); shape_gradients[i * n_q_points_1d + q] = - fe->shape_grad(my_i, q_point)[0]; + fe.shape_grad(my_i, q_point)[0]; shape_hessians[i * n_q_points_1d + q] = - fe->shape_grad_grad(my_i, q_point)[0][0]; + fe.shape_grad_grad(my_i, q_point)[0][0]; // evaluate basis functions on the two 1D subfaces (i.e., at the // positions divided by one half and shifted by one half, // respectively) q_point[0] *= 0.5; values_within_subface[0][i * n_q_points_1d + q] = - fe->shape_value(my_i, q_point); + fe.shape_value(my_i, q_point); gradients_within_subface[0][i * n_q_points_1d + q] = - fe->shape_grad(my_i, q_point)[0]; + fe.shape_grad(my_i, q_point)[0]; hessians_within_subface[0][i * n_q_points_1d + q] = - fe->shape_grad_grad(my_i, q_point)[0][0]; + fe.shape_grad_grad(my_i, q_point)[0][0]; q_point[0] += 0.5; values_within_subface[1][i * n_q_points_1d + q] = - fe->shape_value(my_i, q_point); + fe.shape_value(my_i, q_point); gradients_within_subface[1][i * n_q_points_1d + q] = - fe->shape_grad(my_i, q_point)[0]; + fe.shape_grad(my_i, q_point)[0]; hessians_within_subface[1][i * n_q_points_1d + q] = - fe->shape_grad_grad(my_i, q_point)[0][0]; + fe.shape_grad_grad(my_i, q_point)[0][0]; } // evaluate basis functions on the 1D faces, i.e., in zero and one Point q_point = unit_point; q_point[0] = 0; - shape_data_on_face[0][i] = fe->shape_value(my_i, q_point); + shape_data_on_face[0][i] = fe.shape_value(my_i, q_point); shape_data_on_face[0][i + n_dofs_1d] = - fe->shape_grad(my_i, q_point)[0]; + fe.shape_grad(my_i, q_point)[0]; shape_data_on_face[0][i + 2 * n_dofs_1d] = - fe->shape_grad_grad(my_i, q_point)[0][0]; + fe.shape_grad_grad(my_i, q_point)[0][0]; q_point[0] = 1; - shape_data_on_face[1][i] = fe->shape_value(my_i, q_point); + shape_data_on_face[1][i] = fe.shape_value(my_i, q_point); shape_data_on_face[1][i + n_dofs_1d] = - fe->shape_grad(my_i, q_point)[0]; + fe.shape_grad(my_i, q_point)[0]; shape_data_on_face[1][i + 2 * n_dofs_1d] = - fe->shape_grad_grad(my_i, q_point)[0][0]; + fe.shape_grad_grad(my_i, q_point)[0][0]; } if (n_q_points_1d < 200) @@ -641,15 +640,15 @@ namespace internal // errors low. inverse_shape_values.resize_fast(array_size); FullMatrix transform_from_gauss(n_dofs_1d, n_dofs_1d); - if (fe->has_support_points()) + if (fe.has_support_points()) { for (unsigned int i = 0; i < n_dofs_1d; ++i) for (unsigned int j = 0; j < n_dofs_1d; ++j) transform_from_gauss(i, j) = fe_project.shape_value( j, Point<1>( - fe->get_unit_support_points()[scalar_lexicographic[i]] - [0])); + fe.get_unit_support_points()[scalar_lexicographic[i]] + [0])); FullMatrix result(n_dofs_1d, n_q_points_1d); transform_from_gauss.mmult(result, project_to_dof_space); @@ -670,7 +669,7 @@ namespace internal q_point[0] = quad_project.point(i)[0]; transform_from_gauss(i, j) = - fe->shape_value(scalar_lexicographic[j], q_point); + fe.shape_value(scalar_lexicographic[j], q_point); } Householder H(transform_from_gauss); Vector in(n_dofs_1d), out(n_dofs_1d);