From: David Wells Date: Tue, 7 May 2019 22:27:57 +0000 (-0400) Subject: Remove some unnecessary std::moves. X-Git-Tag: v9.1.0-rc1~84^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=19a1e6ce686baf6cb1bf5d390793b1e2c1d0fcc4;p=dealii.git Remove some unnecessary std::moves. GCC 9 and newer complain about this. Fix it by making the original pointer type correct. --- diff --git a/include/deal.II/fe/fe_face.h b/include/deal.II/fe/fe_face.h index c0238f6deb..6b5acf2002 100644 --- a/include/deal.II/fe/fe_face.h +++ b/include/deal.II/fe/fe_face.h @@ -357,22 +357,22 @@ protected: & /*output_data*/) const override { // generate a new data object and initialize some fields - auto data = std_cxx14::make_unique< + auto data_ptr = std_cxx14::make_unique< typename FiniteElement<1, spacedim>::InternalDataBase>(); - data->update_each = requires_update_flags(update_flags); + data_ptr->update_each = requires_update_flags(update_flags); const unsigned int n_q_points = quadrature.size(); AssertDimension(n_q_points, 1); (void)n_q_points; // No derivatives of this element are implemented. - if (data->update_each & update_gradients || - data->update_each & update_hessians) + if (data_ptr->update_each & update_gradients || + data_ptr->update_each & update_hessians) { Assert(false, ExcNotImplemented()); } - return std::move(data); + return data_ptr; } std::unique_ptr::InternalDataBase> diff --git a/include/deal.II/fe/fe_poly.h b/include/deal.II/fe/fe_poly.h index 35b01f74db..e184173ce4 100644 --- a/include/deal.II/fe/fe_poly.h +++ b/include/deal.II/fe/fe_poly.h @@ -243,8 +243,10 @@ protected: { // generate a new data object and // initialize some fields - auto data = std_cxx14::make_unique(); - data->update_each = requires_update_flags(update_flags); + std::unique_ptr::InternalDataBase> + data_ptr = std_cxx14::make_unique(); + auto &data = dynamic_cast(*data_ptr); + data.update_each = requires_update_flags(update_flags); const unsigned int n_q_points = quadrature.size(); @@ -281,16 +283,16 @@ protected: if ((update_flags & update_values) && !((output_data.shape_values.n_rows() > 0) && (output_data.shape_values.n_cols() == n_q_points))) - data->shape_values.reinit(this->dofs_per_cell, n_q_points); + data.shape_values.reinit(this->dofs_per_cell, n_q_points); if (update_flags & update_gradients) - data->shape_gradients.reinit(this->dofs_per_cell, n_q_points); + data.shape_gradients.reinit(this->dofs_per_cell, n_q_points); if (update_flags & update_hessians) - data->shape_hessians.reinit(this->dofs_per_cell, n_q_points); + data.shape_hessians.reinit(this->dofs_per_cell, n_q_points); if (update_flags & update_3rd_derivatives) - data->shape_3rd_derivatives.reinit(this->dofs_per_cell, n_q_points); + data.shape_3rd_derivatives.reinit(this->dofs_per_cell, n_q_points); // next already fill those fields of which we have information by // now. note that the shape gradients are only those on the unit @@ -321,7 +323,7 @@ protected: output_data.shape_values[k][i] = values[k]; else for (unsigned int k = 0; k < this->dofs_per_cell; ++k) - data->shape_values[k][i] = values[k]; + data.shape_values[k][i] = values[k]; } // for everything else, derivatives need to be transformed, @@ -329,17 +331,17 @@ protected: // copy stuff into where FEValues wants it if (update_flags & update_gradients) for (unsigned int k = 0; k < this->dofs_per_cell; ++k) - data->shape_gradients[k][i] = grads[k]; + data.shape_gradients[k][i] = grads[k]; if (update_flags & update_hessians) for (unsigned int k = 0; k < this->dofs_per_cell; ++k) - data->shape_hessians[k][i] = grad_grads[k]; + data.shape_hessians[k][i] = grad_grads[k]; if (update_flags & update_3rd_derivatives) for (unsigned int k = 0; k < this->dofs_per_cell; ++k) - data->shape_3rd_derivatives[k][i] = third_derivatives[k]; + data.shape_3rd_derivatives[k][i] = third_derivatives[k]; } - return std::move(data); + return data_ptr; } virtual void diff --git a/include/deal.II/fe/fe_poly_face.h b/include/deal.II/fe/fe_poly_face.h index 288f018bb9..c73705e2d8 100644 --- a/include/deal.II/fe/fe_poly_face.h +++ b/include/deal.II/fe/fe_poly_face.h @@ -109,8 +109,10 @@ protected: { // generate a new data object and // initialize some fields - auto data = std_cxx14::make_unique(); - data->update_each = requires_update_flags(update_flags); + std::unique_ptr::InternalDataBase> + data_ptr = std_cxx14::make_unique(); + auto &data = dynamic_cast(*data_ptr); + data.update_each = requires_update_flags(update_flags); const unsigned int n_q_points = quadrature.size(); @@ -124,11 +126,11 @@ protected: // initialize fields only if really // necessary. otherwise, don't // allocate memory - if (data->update_each & update_values) + if (data.update_each & update_values) { values.resize(poly_space.n()); - data->shape_values.resize(poly_space.n(), - std::vector(n_q_points)); + data.shape_values.resize(poly_space.n(), + std::vector(n_q_points)); for (unsigned int i = 0; i < n_q_points; ++i) { poly_space.compute(quadrature.point(i), @@ -139,18 +141,18 @@ protected: empty_vector_of_4th_order_tensors); for (unsigned int k = 0; k < poly_space.n(); ++k) - data->shape_values[k][i] = values[k]; + data.shape_values[k][i] = values[k]; } } // No derivatives of this element // are implemented. - if (data->update_each & update_gradients || - data->update_each & update_hessians) + if (data.update_each & update_gradients || + data.update_each & update_hessians) { Assert(false, ExcNotImplemented()); } - return std::move(data); + return data_ptr; } std::unique_ptr::InternalDataBase> diff --git a/include/deal.II/fe/fe_poly_tensor.h b/include/deal.II/fe/fe_poly_tensor.h index 582619dffa..1c99035623 100644 --- a/include/deal.II/fe/fe_poly_tensor.h +++ b/include/deal.II/fe/fe_poly_tensor.h @@ -227,8 +227,10 @@ protected: { // generate a new data object and // initialize some fields - auto data = std_cxx14::make_unique(); - data->update_each = requires_update_flags(update_flags); + std::unique_ptr::InternalDataBase> + data_ptr = std_cxx14::make_unique(); + auto &data = dynamic_cast(*data_ptr); + data.update_each = requires_update_flags(update_flags); const unsigned int n_q_points = quadrature.size(); @@ -240,7 +242,7 @@ protected: std::vector> fourth_derivatives(0); if (update_flags & (update_values | update_gradients | update_hessians)) - data->sign_change.resize(this->dofs_per_cell); + data.sign_change.resize(this->dofs_per_cell); // initialize fields only if really // necessary. otherwise, don't @@ -248,31 +250,31 @@ protected: if (update_flags & update_values) { values.resize(this->dofs_per_cell); - data->shape_values.reinit(this->dofs_per_cell, n_q_points); + data.shape_values.reinit(this->dofs_per_cell, n_q_points); if (mapping_type != mapping_none) - data->transformed_shape_values.resize(n_q_points); + data.transformed_shape_values.resize(n_q_points); } if (update_flags & update_gradients) { grads.resize(this->dofs_per_cell); - data->shape_grads.reinit(this->dofs_per_cell, n_q_points); - data->transformed_shape_grads.resize(n_q_points); + data.shape_grads.reinit(this->dofs_per_cell, n_q_points); + data.transformed_shape_grads.resize(n_q_points); if ((mapping_type == mapping_raviart_thomas) || (mapping_type == mapping_piola) || (mapping_type == mapping_nedelec) || (mapping_type == mapping_contravariant)) - data->untransformed_shape_grads.resize(n_q_points); + data.untransformed_shape_grads.resize(n_q_points); } if (update_flags & update_hessians) { grad_grads.resize(this->dofs_per_cell); - data->shape_grad_grads.reinit(this->dofs_per_cell, n_q_points); - data->transformed_shape_hessians.resize(n_q_points); + data.shape_grad_grads.reinit(this->dofs_per_cell, n_q_points); + data.transformed_shape_hessians.resize(n_q_points); if (mapping_type != mapping_none) - data->untransformed_shape_hessian_tensors.resize(n_q_points); + data.untransformed_shape_hessian_tensors.resize(n_q_points); } // Compute shape function values @@ -296,14 +298,14 @@ protected: { if (inverse_node_matrix.n_cols() == 0) for (unsigned int i = 0; i < this->dofs_per_cell; ++i) - data->shape_values[i][k] = values[i]; + data.shape_values[i][k] = values[i]; else for (unsigned int i = 0; i < this->dofs_per_cell; ++i) { Tensor<1, dim> add_values; for (unsigned int j = 0; j < this->dofs_per_cell; ++j) add_values += inverse_node_matrix(j, i) * values[j]; - data->shape_values[i][k] = add_values; + data.shape_values[i][k] = add_values; } } @@ -311,14 +313,14 @@ protected: { if (inverse_node_matrix.n_cols() == 0) for (unsigned int i = 0; i < this->dofs_per_cell; ++i) - data->shape_grads[i][k] = grads[i]; + data.shape_grads[i][k] = grads[i]; else for (unsigned int i = 0; i < this->dofs_per_cell; ++i) { Tensor<2, dim> add_grads; for (unsigned int j = 0; j < this->dofs_per_cell; ++j) add_grads += inverse_node_matrix(j, i) * grads[j]; - data->shape_grads[i][k] = add_grads; + data.shape_grads[i][k] = add_grads; } } @@ -326,7 +328,7 @@ protected: { if (inverse_node_matrix.n_cols() == 0) for (unsigned int i = 0; i < this->dofs_per_cell; ++i) - data->shape_grad_grads[i][k] = grad_grads[i]; + data.shape_grad_grads[i][k] = grad_grads[i]; else for (unsigned int i = 0; i < this->dofs_per_cell; ++i) { @@ -334,11 +336,11 @@ protected: for (unsigned int j = 0; j < this->dofs_per_cell; ++j) add_grad_grads += inverse_node_matrix(j, i) * grad_grads[j]; - data->shape_grad_grads[i][k] = add_grad_grads; + data.shape_grad_grads[i][k] = add_grad_grads; } } } - return std::move(data); + return data_ptr; } virtual void diff --git a/source/fe/fe_dgp_nonparametric.cc b/source/fe/fe_dgp_nonparametric.cc index 140a11c524..73be55da64 100644 --- a/source/fe/fe_dgp_nonparametric.cc +++ b/source/fe/fe_dgp_nonparametric.cc @@ -283,14 +283,14 @@ FE_DGPNonparametric::get_data( & /*output_data*/) const { // generate a new data object - auto data = std_cxx14::make_unique< + auto data_ptr = std_cxx14::make_unique< typename FiniteElement::InternalDataBase>(); - data->update_each = requires_update_flags(update_flags); + data_ptr->update_each = requires_update_flags(update_flags); // other than that, there is nothing we can add here as discussed // in the general documentation of this class - return std::move(data); + return data_ptr; } diff --git a/source/fe/fe_enriched.cc b/source/fe/fe_enriched.cc index ec5368122c..8c18e281c5 100644 --- a/source/fe/fe_enriched.cc +++ b/source/fe/fe_enriched.cc @@ -331,33 +331,35 @@ FE_Enriched::setup_data( // Pass ownership of the FiniteElement::InternalDataBase object // that fes_data points to, to the new InternalData object. auto update_each_flags = fes_data->update_each; - auto data = std_cxx14::make_unique(std::move(fes_data)); + std::unique_ptr::InternalDataBase> + data_ptr = std_cxx14::make_unique(std::move(fes_data)); + auto &data = dynamic_cast(*data_ptr); // copy update_each from FESystem data: - data->update_each = update_each_flags; + data.update_each = update_each_flags; // resize cache array according to requested flags - data->enrichment.resize(this->n_base_elements()); + data.enrichment.resize(this->n_base_elements()); const unsigned int n_q_points = quadrature.size(); for (unsigned int base = 0; base < this->n_base_elements(); ++base) { - data->enrichment[base].resize(this->element_multiplicity(base)); + data.enrichment[base].resize(this->element_multiplicity(base)); for (unsigned int m = 0; m < this->element_multiplicity(base); ++m) { if (flags & update_values) - data->enrichment[base][m].values.resize(n_q_points); + data.enrichment[base][m].values.resize(n_q_points); if (flags & update_gradients) - data->enrichment[base][m].gradients.resize(n_q_points); + data.enrichment[base][m].gradients.resize(n_q_points); if (flags & update_hessians) - data->enrichment[base][m].hessians.resize(n_q_points); + data.enrichment[base][m].hessians.resize(n_q_points); } } - return std::move(data); + return data_ptr; } diff --git a/source/fe/fe_nedelec_sz.cc b/source/fe/fe_nedelec_sz.cc index 9e3eebb637..9788479b1d 100644 --- a/source/fe/fe_nedelec_sz.cc +++ b/source/fe/fe_nedelec_sz.cc @@ -131,8 +131,11 @@ FE_NedelecSZ::get_data( spacedim> & /*output_data*/) const { - auto data = std_cxx14::make_unique(); - data->update_each = update_each(update_flags) | update_once(update_flags); + std::unique_ptr< + typename dealii::FiniteElement::InternalDataBase> + data_ptr = std_cxx14::make_unique(); + auto &data = dynamic_cast(*data_ptr); + data.update_each = update_each(update_flags) | update_once(update_flags); // Useful quantities: const unsigned int degree(this->degree - 1); // Note: FE holds input degree+1 @@ -144,31 +147,31 @@ FE_NedelecSZ::get_data( const unsigned int n_line_dofs = this->dofs_per_line * lines_per_cell; const unsigned int n_face_dofs = this->dofs_per_quad * faces_per_cell; - const UpdateFlags flags(data->update_each); + const UpdateFlags flags(data.update_each); const unsigned int n_q_points = quadrature.size(); // Resize the internal data storage: - data->sigma_imj_values.resize( + data.sigma_imj_values.resize( n_q_points, std::vector>(vertices_per_cell, std::vector(vertices_per_cell))); - data->sigma_imj_grads.resize(vertices_per_cell, - std::vector>( - vertices_per_cell, std::vector(dim))); + data.sigma_imj_grads.resize(vertices_per_cell, + std::vector>( + vertices_per_cell, std::vector(dim))); // Resize shape function arrays according to update flags: if (flags & update_values) { - data->shape_values.resize(this->dofs_per_cell, - std::vector>(n_q_points)); + data.shape_values.resize(this->dofs_per_cell, + std::vector>(n_q_points)); } if (flags & update_gradients) { - data->shape_grads.resize(this->dofs_per_cell, - std::vector>( - n_q_points)); + data.shape_grads.resize(this->dofs_per_cell, + std::vector>( + n_q_points)); } // Not implementing second derivatives yet: if (flags & update_hessians) @@ -206,7 +209,7 @@ FE_NedelecSZ::get_data( { for (unsigned int j = 0; j < vertices_per_cell; ++j) { - data->sigma_imj_values[q][i][j] = + data.sigma_imj_values[q][i][j] = sigma[q][i] - sigma[q][j]; } } @@ -255,7 +258,7 @@ FE_NedelecSZ::get_data( // Can now calculate the gradient, only non-zero in the // component given: Note some i,j combinations will be // incorrect, but only on invalid edges. - data->sigma_imj_grads[i][j][sigma_imj_component[i][j]] = + data.sigma_imj_grads[i][j][sigma_imj_component[i][j]] = 2.0 * sigma_imj_sign[i][j]; } } @@ -264,14 +267,14 @@ FE_NedelecSZ::get_data( // with global numbering matching that of the reference element: // Resize the edge parameterisations - data->edge_sigma_values.resize(lines_per_cell); - data->edge_sigma_grads.resize(lines_per_cell); + data.edge_sigma_values.resize(lines_per_cell); + data.edge_sigma_grads.resize(lines_per_cell); for (unsigned int m = 0; m < lines_per_cell; ++m) { - data->edge_sigma_values[m].resize(n_q_points); + data.edge_sigma_values[m].resize(n_q_points); // sigma grads are constant in a cell (no need for quad points) - data->edge_sigma_grads[m].resize(dim); + data.edge_sigma_grads[m].resize(dim); } // Fill the values for edge lambda and edge sigma: @@ -281,10 +284,10 @@ FE_NedelecSZ::get_data( 0, 0}; - data->edge_lambda_values.resize(lines_per_cell, - std::vector(n_q_points)); - data->edge_lambda_grads_2d.resize(lines_per_cell, - std::vector(dim)); + data.edge_lambda_values.resize(lines_per_cell, + std::vector(n_q_points)); + data.edge_lambda_grads_2d.resize(lines_per_cell, + std::vector(dim)); for (unsigned int m = 0; m < lines_per_cell; ++m) { // e1=max(reference vertex numbering on this edge) @@ -296,18 +299,17 @@ FE_NedelecSZ::get_data( GeometryInfo::line_to_cell_vertices(m, 0)); for (unsigned int q = 0; q < n_q_points; ++q) { - data->edge_sigma_values[m][q] = - data->sigma_imj_values[q][e2][e1]; - data->edge_lambda_values[m][q] = - lambda[q][e1] + lambda[q][e2]; + data.edge_sigma_values[m][q] = + data.sigma_imj_values[q][e2][e1]; + data.edge_lambda_values[m][q] = lambda[q][e1] + lambda[q][e2]; } - data->edge_sigma_grads[m][edge_sigma_direction[m]] = -2.0; + data.edge_sigma_grads[m][edge_sigma_direction[m]] = -2.0; } - data->edge_lambda_grads_2d[0] = {-1.0, 0.0}; - data->edge_lambda_grads_2d[1] = {1.0, 0.0}; - data->edge_lambda_grads_2d[2] = {0.0, -1.0}; - data->edge_lambda_grads_2d[3] = {0.0, 1.0}; + data.edge_lambda_grads_2d[0] = {-1.0, 0.0}; + data.edge_lambda_grads_2d[1] = {1.0, 0.0}; + data.edge_lambda_grads_2d[2] = {0.0, -1.0}; + data.edge_lambda_grads_2d[3] = {0.0, 1.0}; // If the polynomial order is 0, then no more work to do: if (degree < 1) @@ -452,29 +454,29 @@ FE_NedelecSZ::get_data( // Type 1: const unsigned int dof_index1(cell_type1_offset + shift_ij); - data->shape_values[dof_index1][q][0] = + data.shape_values[dof_index1][q][0] = 2.0 * polyx[i][1] * polyy[j][0]; - data->shape_values[dof_index1][q][1] = + data.shape_values[dof_index1][q][1] = 2.0 * polyx[i][0] * polyy[j][1]; // Type 2: const unsigned int dof_index2(cell_type2_offset + shift_ij); - data->shape_values[dof_index2][q][0] = - data->shape_values[dof_index1][q][0]; - data->shape_values[dof_index2][q][1] = - -1.0 * data->shape_values[dof_index1][q][1]; + data.shape_values[dof_index2][q][0] = + data.shape_values[dof_index1][q][0]; + data.shape_values[dof_index2][q][1] = + -1.0 * data.shape_values[dof_index1][q][1]; } // Type 3: const unsigned int dof_index3_1(cell_type3_offset1 + j); - data->shape_values[dof_index3_1][q][0] = polyy[j][0]; - data->shape_values[dof_index3_1][q][1] = 0.0; + data.shape_values[dof_index3_1][q][0] = polyy[j][0]; + data.shape_values[dof_index3_1][q][1] = 0.0; const unsigned int dof_index3_2(cell_type3_offset2 + j); - data->shape_values[dof_index3_2][q][0] = 0.0; - data->shape_values[dof_index3_2][q][1] = polyx[j][0]; + data.shape_values[dof_index3_2][q][0] = 0.0; + data.shape_values[dof_index3_2][q][1] = polyx[j][0]; } } if (flags & update_gradients) @@ -489,43 +491,43 @@ FE_NedelecSZ::get_data( // Type 1: const unsigned int dof_index1(cell_type1_offset + shift_ij); - data->shape_grads[dof_index1][q][0][0] = + data.shape_grads[dof_index1][q][0][0] = 4.0 * polyx[i][2] * polyy[j][0]; - data->shape_grads[dof_index1][q][0][1] = + data.shape_grads[dof_index1][q][0][1] = 4.0 * polyx[i][1] * polyy[j][1]; - data->shape_grads[dof_index1][q][1][0] = - data->shape_grads[dof_index1][q][0][1]; - data->shape_grads[dof_index1][q][1][1] = + data.shape_grads[dof_index1][q][1][0] = + data.shape_grads[dof_index1][q][0][1]; + data.shape_grads[dof_index1][q][1][1] = 4.0 * polyx[i][0] * polyy[j][2]; // Type 2: const unsigned int dof_index2(cell_type2_offset + shift_ij); - data->shape_grads[dof_index2][q][0][0] = - data->shape_grads[dof_index1][q][0][0]; - data->shape_grads[dof_index2][q][0][1] = - data->shape_grads[dof_index1][q][0][1]; - data->shape_grads[dof_index2][q][1][0] = - -1.0 * data->shape_grads[dof_index1][q][1][0]; - data->shape_grads[dof_index2][q][1][1] = - -1.0 * data->shape_grads[dof_index1][q][1][1]; + data.shape_grads[dof_index2][q][0][0] = + data.shape_grads[dof_index1][q][0][0]; + data.shape_grads[dof_index2][q][0][1] = + data.shape_grads[dof_index1][q][0][1]; + data.shape_grads[dof_index2][q][1][0] = + -1.0 * data.shape_grads[dof_index1][q][1][0]; + data.shape_grads[dof_index2][q][1][1] = + -1.0 * data.shape_grads[dof_index1][q][1][1]; } // Type 3: const unsigned int dof_index3_1(cell_type3_offset1 + j); - data->shape_grads[dof_index3_1][q][0][0] = 0.0; - data->shape_grads[dof_index3_1][q][0][1] = + data.shape_grads[dof_index3_1][q][0][0] = 0.0; + data.shape_grads[dof_index3_1][q][0][1] = 2.0 * polyy[j][1]; - data->shape_grads[dof_index3_1][q][1][0] = 0.0; - data->shape_grads[dof_index3_1][q][1][1] = 0.0; + data.shape_grads[dof_index3_1][q][1][0] = 0.0; + data.shape_grads[dof_index3_1][q][1][1] = 0.0; const unsigned int dof_index3_2(cell_type3_offset2 + j); - data->shape_grads[dof_index3_2][q][0][0] = 0.0; - data->shape_grads[dof_index3_2][q][0][1] = 0.0; - data->shape_grads[dof_index3_2][q][1][0] = + data.shape_grads[dof_index3_2][q][0][0] = 0.0; + data.shape_grads[dof_index3_2][q][0][1] = 0.0; + data.shape_grads[dof_index3_2][q][1][0] = 2.0 * polyx[j][1]; - data->shape_grads[dof_index3_2][q][1][1] = 0.0; + data.shape_grads[dof_index3_2][q][1][1] = 0.0; } } } @@ -574,7 +576,7 @@ FE_NedelecSZ::get_data( { for (unsigned int j = 0; j < vertices_per_cell; ++j) { - data->sigma_imj_values[q][i][j] = + data.sigma_imj_values[q][i][j] = sigma[q][i] - sigma[q][j]; } } @@ -642,7 +644,7 @@ FE_NedelecSZ::get_data( // Can now calculate the gradient, only non-zero in the // component given: Note some i,j combinations will be // incorrect, but only on invalid edges. - data->sigma_imj_grads[i][j][sigma_imj_component[i][j]] = + data.sigma_imj_grads[i][j][sigma_imj_component[i][j]] = 2.0 * sigma_imj_sign[i][j]; } } @@ -650,30 +652,30 @@ FE_NedelecSZ::get_data( // with global numbering matching that of the reference element: // resize the edge parameterisations - data->edge_sigma_values.resize(lines_per_cell); - data->edge_lambda_values.resize(lines_per_cell); - data->edge_sigma_grads.resize(lines_per_cell); - data->edge_lambda_grads_3d.resize(lines_per_cell); - data->edge_lambda_gradgrads_3d.resize(lines_per_cell); + data.edge_sigma_values.resize(lines_per_cell); + data.edge_lambda_values.resize(lines_per_cell); + data.edge_sigma_grads.resize(lines_per_cell); + data.edge_lambda_grads_3d.resize(lines_per_cell); + data.edge_lambda_gradgrads_3d.resize(lines_per_cell); for (unsigned int m = 0; m < lines_per_cell; ++m) { - data->edge_sigma_values[m].resize(n_q_points); - data->edge_lambda_values[m].resize(n_q_points); + data.edge_sigma_values[m].resize(n_q_points); + data.edge_lambda_values[m].resize(n_q_points); // sigma grads are constant in a cell (no need for quad points) - data->edge_sigma_grads[m].resize(dim); + data.edge_sigma_grads[m].resize(dim); - data->edge_lambda_grads_3d[m].resize(n_q_points); + data.edge_lambda_grads_3d[m].resize(n_q_points); for (unsigned int q = 0; q < n_q_points; ++q) { - data->edge_lambda_grads_3d[m][q].resize(dim); + data.edge_lambda_grads_3d[m][q].resize(dim); } // lambda_gradgrads are constant in a cell (no need for quad // points) - data->edge_lambda_gradgrads_3d[m].resize(dim); + data.edge_lambda_gradgrads_3d[m].resize(dim); for (unsigned int d = 0; d < dim; ++d) { - data->edge_lambda_gradgrads_3d[m][d].resize(dim); + data.edge_lambda_gradgrads_3d[m][d].resize(dim); } } @@ -694,13 +696,12 @@ FE_NedelecSZ::get_data( for (unsigned int q = 0; q < n_q_points; ++q) { - data->edge_sigma_values[m][q] = - data->sigma_imj_values[q][e2][e1]; - data->edge_lambda_values[m][q] = - lambda[q][e1] + lambda[q][e2]; + data.edge_sigma_values[m][q] = + data.sigma_imj_values[q][e2][e1]; + data.edge_lambda_values[m][q] = lambda[q][e1] + lambda[q][e2]; } - data->edge_sigma_grads[m][edge_sigma_direction[m]] = -2.0; + data.edge_sigma_grads[m][edge_sigma_direction[m]] = -2.0; } // edge_lambda_grads for (unsigned int q = 0; q < n_q_points; ++q) @@ -708,18 +709,18 @@ FE_NedelecSZ::get_data( double x(p_list[q][0]); double y(p_list[q][1]); double z(p_list[q][2]); - data->edge_lambda_grads_3d[0][q] = {z - 1.0, 0.0, x - 1.0}; - data->edge_lambda_grads_3d[1][q] = {1.0 - z, 0.0, -x}; - data->edge_lambda_grads_3d[2][q] = {0.0, z - 1.0, y - 1.0}; - data->edge_lambda_grads_3d[3][q] = {0.0, 1.0 - z, -y}; - data->edge_lambda_grads_3d[4][q] = {-z, 0.0, 1.0 - x}; - data->edge_lambda_grads_3d[5][q] = {z, 0.0, x}; - data->edge_lambda_grads_3d[6][q] = {0.0, -z, 1.0 - y}; - data->edge_lambda_grads_3d[7][q] = {0.0, z, y}; - data->edge_lambda_grads_3d[8][q] = {y - 1.0, x - 1.0, 0.0}; - data->edge_lambda_grads_3d[9][q] = {1.0 - y, -x, 0.0}; - data->edge_lambda_grads_3d[10][q] = {-y, 1.0 - x, 0.0}; - data->edge_lambda_grads_3d[11][q] = {y, x, 0.0}; + data.edge_lambda_grads_3d[0][q] = {z - 1.0, 0.0, x - 1.0}; + data.edge_lambda_grads_3d[1][q] = {1.0 - z, 0.0, -x}; + data.edge_lambda_grads_3d[2][q] = {0.0, z - 1.0, y - 1.0}; + data.edge_lambda_grads_3d[3][q] = {0.0, 1.0 - z, -y}; + data.edge_lambda_grads_3d[4][q] = {-z, 0.0, 1.0 - x}; + data.edge_lambda_grads_3d[5][q] = {z, 0.0, x}; + data.edge_lambda_grads_3d[6][q] = {0.0, -z, 1.0 - y}; + data.edge_lambda_grads_3d[7][q] = {0.0, z, y}; + data.edge_lambda_grads_3d[8][q] = {y - 1.0, x - 1.0, 0.0}; + data.edge_lambda_grads_3d[9][q] = {1.0 - y, -x, 0.0}; + data.edge_lambda_grads_3d[10][q] = {-y, 1.0 - x, 0.0}; + data.edge_lambda_grads_3d[11][q] = {y, x, 0.0}; } // edge_lambda gradgrads: const int edge_lambda_sign[GeometryInfo<3>::lines_per_cell] = { @@ -751,11 +752,11 @@ FE_NedelecSZ::get_data( {0, 1}}; // component which edge_lambda[m] depends on. for (unsigned int m = 0; m < lines_per_cell; ++m) { - data->edge_lambda_gradgrads_3d[m][edge_lambda_directions[m][0]] - [edge_lambda_directions[m][1]] = + data.edge_lambda_gradgrads_3d[m][edge_lambda_directions[m][0]] + [edge_lambda_directions[m][1]] = edge_lambda_sign[m]; - data->edge_lambda_gradgrads_3d[m][edge_lambda_directions[m][1]] - [edge_lambda_directions[m][0]] = + data.edge_lambda_gradgrads_3d[m][edge_lambda_directions[m][1]] + [edge_lambda_directions[m][0]] = edge_lambda_sign[m]; } // Precomputation for higher order shape functions, @@ -763,13 +764,13 @@ FE_NedelecSZ::get_data( if (degree > 0) { // resize required data: - data->face_lambda_values.resize(faces_per_cell); - data->face_lambda_grads.resize(faces_per_cell); + data.face_lambda_values.resize(faces_per_cell); + data.face_lambda_grads.resize(faces_per_cell); // for face-based shape functions: for (unsigned int m = 0; m < faces_per_cell; ++m) { - data->face_lambda_values[m].resize(n_q_points); - data->face_lambda_grads[m].resize(3); + data.face_lambda_values[m].resize(n_q_points); + data.face_lambda_grads[m].resize(3); } // Fill in the values (these don't change between cells). for (unsigned int q = 0; q < n_q_points; ++q) @@ -777,20 +778,20 @@ FE_NedelecSZ::get_data( double x(p_list[q][0]); double y(p_list[q][1]); double z(p_list[q][2]); - data->face_lambda_values[0][q] = 1.0 - x; - data->face_lambda_values[1][q] = x; - data->face_lambda_values[2][q] = 1.0 - y; - data->face_lambda_values[3][q] = y; - data->face_lambda_values[4][q] = 1.0 - z; - data->face_lambda_values[5][q] = z; + data.face_lambda_values[0][q] = 1.0 - x; + data.face_lambda_values[1][q] = x; + data.face_lambda_values[2][q] = 1.0 - y; + data.face_lambda_values[3][q] = y; + data.face_lambda_values[4][q] = 1.0 - z; + data.face_lambda_values[5][q] = z; } // gradients are constant: - data->face_lambda_grads[0] = {-1.0, 0.0, 0.0}; - data->face_lambda_grads[1] = {1.0, 0.0, 0.0}; - data->face_lambda_grads[2] = {0.0, -1.0, 0.0}; - data->face_lambda_grads[3] = {0.0, 1.0, 0.0}; - data->face_lambda_grads[4] = {0.0, 0.0, -1.0}; - data->face_lambda_grads[5] = {0.0, 0.0, 1.0}; + data.face_lambda_grads[0] = {-1.0, 0.0, 0.0}; + data.face_lambda_grads[1] = {1.0, 0.0, 0.0}; + data.face_lambda_grads[2] = {0.0, -1.0, 0.0}; + data.face_lambda_grads[3] = {0.0, 1.0, 0.0}; + data.face_lambda_grads[4] = {0.0, 0.0, -1.0}; + data.face_lambda_grads[5] = {0.0, 0.0, 1.0}; // for cell-based shape functions: // these don't depend on the cell, so can precompute all here: @@ -898,13 +899,13 @@ FE_NedelecSZ::get_data( const unsigned int dof_index1( cell_type1_offset + shift_ijk); - data->shape_values[dof_index1][q][0] = + data.shape_values[dof_index1][q][0] = 2.0 * polyx[i][1] * polyy[j][0] * polyz[k][0]; - data->shape_values[dof_index1][q][1] = + data.shape_values[dof_index1][q][1] = 2.0 * polyx[i][0] * polyy[j][1] * polyz[k][0]; - data->shape_values[dof_index1][q][2] = + data.shape_values[dof_index1][q][2] = 2.0 * polyx[i][0] * polyy[j][0] * polyz[k][1]; @@ -914,22 +915,22 @@ FE_NedelecSZ::get_data( const unsigned int dof_index2_2( cell_type2_offset2 + shift_ijk); - data->shape_values[dof_index2_1][q][0] = - data->shape_values[dof_index1][q][0]; - data->shape_values[dof_index2_1][q][1] = + data.shape_values[dof_index2_1][q][0] = + data.shape_values[dof_index1][q][0]; + data.shape_values[dof_index2_1][q][1] = -1.0 * - data->shape_values[dof_index1][q][1]; - data->shape_values[dof_index2_1][q][2] = - data->shape_values[dof_index1][q][2]; + data.shape_values[dof_index1][q][1]; + data.shape_values[dof_index2_1][q][2] = + data.shape_values[dof_index1][q][2]; - data->shape_values[dof_index2_2][q][0] = - data->shape_values[dof_index1][q][0]; - data->shape_values[dof_index2_2][q][1] = + data.shape_values[dof_index2_2][q][0] = + data.shape_values[dof_index1][q][0]; + data.shape_values[dof_index2_2][q][1] = -1.0 * - data->shape_values[dof_index1][q][1]; - data->shape_values[dof_index2_2][q][2] = + data.shape_values[dof_index1][q][1]; + data.shape_values[dof_index2_2][q][2] = -1.0 * - data->shape_values[dof_index1][q][2]; + data.shape_values[dof_index1][q][2]; } // Type 3: (note we re-use k and j for // convenience): @@ -943,19 +944,19 @@ FE_NedelecSZ::get_data( const unsigned int dof_index3_3( cell_type3_offset3 + shift_ij); - data->shape_values[dof_index3_1][q][0] = + data.shape_values[dof_index3_1][q][0] = polyy[j][0] * polyz[k][0]; - data->shape_values[dof_index3_1][q][1] = 0.0; - data->shape_values[dof_index3_1][q][2] = 0.0; + data.shape_values[dof_index3_1][q][1] = 0.0; + data.shape_values[dof_index3_1][q][2] = 0.0; - data->shape_values[dof_index3_2][q][0] = 0.0; - data->shape_values[dof_index3_2][q][1] = + data.shape_values[dof_index3_2][q][0] = 0.0; + data.shape_values[dof_index3_2][q][1] = polyx[j][0] * polyz[k][0]; - data->shape_values[dof_index3_2][q][2] = 0.0; + data.shape_values[dof_index3_2][q][2] = 0.0; - data->shape_values[dof_index3_3][q][0] = 0.0; - data->shape_values[dof_index3_3][q][1] = 0.0; - data->shape_values[dof_index3_3][q][2] = + data.shape_values[dof_index3_3][q][0] = 0.0; + data.shape_values[dof_index3_3][q][1] = 0.0; + data.shape_values[dof_index3_3][q][2] = polyx[j][0] * polyy[k][0]; } } @@ -981,30 +982,30 @@ FE_NedelecSZ::get_data( const unsigned int dof_index1( cell_type1_offset + shift_ijk); - data->shape_grads[dof_index1][q][0][0] = + data.shape_grads[dof_index1][q][0][0] = 4.0 * polyx[i][2] * polyy[j][0] * polyz[k][0]; - data->shape_grads[dof_index1][q][0][1] = + data.shape_grads[dof_index1][q][0][1] = 4.0 * polyx[i][1] * polyy[j][1] * polyz[k][0]; - data->shape_grads[dof_index1][q][0][2] = + data.shape_grads[dof_index1][q][0][2] = 4.0 * polyx[i][1] * polyy[j][0] * polyz[k][1]; - data->shape_grads[dof_index1][q][1][0] = - data->shape_grads[dof_index1][q][0][1]; - data->shape_grads[dof_index1][q][1][1] = + data.shape_grads[dof_index1][q][1][0] = + data.shape_grads[dof_index1][q][0][1]; + data.shape_grads[dof_index1][q][1][1] = 4.0 * polyx[i][0] * polyy[j][2] * polyz[k][0]; - data->shape_grads[dof_index1][q][1][2] = + data.shape_grads[dof_index1][q][1][2] = 4.0 * polyx[i][0] * polyy[j][1] * polyz[k][1]; - data->shape_grads[dof_index1][q][2][0] = - data->shape_grads[dof_index1][q][0][2]; - data->shape_grads[dof_index1][q][2][1] = - data->shape_grads[dof_index1][q][1][2]; - data->shape_grads[dof_index1][q][2][2] = + data.shape_grads[dof_index1][q][2][0] = + data.shape_grads[dof_index1][q][0][2]; + data.shape_grads[dof_index1][q][2][1] = + data.shape_grads[dof_index1][q][1][2]; + data.shape_grads[dof_index1][q][2][2] = 4.0 * polyx[i][0] * polyy[j][0] * polyz[k][2]; @@ -1016,31 +1017,34 @@ FE_NedelecSZ::get_data( for (unsigned int d = 0; d < dim; ++d) { - data->shape_grads[dof_index2_1][q][0] - [d] = - data->shape_grads[dof_index1][q][0] - [d]; - data->shape_grads[dof_index2_1][q][1] - [d] = - -1.0 * data->shape_grads[dof_index1] - [q][1][d]; - data->shape_grads[dof_index2_1][q][2] - [d] = - data->shape_grads[dof_index1][q][2] - [d]; - - data->shape_grads[dof_index2_2][q][0] - [d] = - data->shape_grads[dof_index1][q][0] - [d]; - data->shape_grads[dof_index2_2][q][1] - [d] = - -1.0 * data->shape_grads[dof_index1] - [q][1][d]; - data->shape_grads[dof_index2_2][q][2] - [d] = - -1.0 * data->shape_grads[dof_index1] - [q][2][d]; + data.shape_grads[dof_index2_1][q][0] + [d] = + data + .shape_grads[dof_index1][q][0][d]; + data.shape_grads[dof_index2_1][q][1] + [d] = + -1.0 * + data + .shape_grads[dof_index1][q][1][d]; + data.shape_grads[dof_index2_1][q][2] + [d] = + data + .shape_grads[dof_index1][q][2][d]; + + data.shape_grads[dof_index2_2][q][0] + [d] = + data + .shape_grads[dof_index1][q][0][d]; + data.shape_grads[dof_index2_2][q][1] + [d] = + -1.0 * + data + .shape_grads[dof_index1][q][1][d]; + data.shape_grads[dof_index2_2][q][2] + [d] = + -1.0 * + data + .shape_grads[dof_index1][q][2][d]; } } // Type 3: (note we re-use k and j for @@ -1058,27 +1062,27 @@ FE_NedelecSZ::get_data( { for (unsigned int d2 = 0; d2 < dim; ++d2) { - data->shape_grads[dof_index3_1][q][d1] - [d2] = 0.0; - data->shape_grads[dof_index3_2][q][d1] - [d2] = 0.0; - data->shape_grads[dof_index3_3][q][d1] - [d2] = 0.0; + data.shape_grads[dof_index3_1][q][d1] + [d2] = 0.0; + data.shape_grads[dof_index3_2][q][d1] + [d2] = 0.0; + data.shape_grads[dof_index3_3][q][d1] + [d2] = 0.0; } } - data->shape_grads[dof_index3_1][q][0][1] = + data.shape_grads[dof_index3_1][q][0][1] = 2.0 * polyy[j][1] * polyz[k][0]; - data->shape_grads[dof_index3_1][q][0][2] = + data.shape_grads[dof_index3_1][q][0][2] = 2.0 * polyy[j][0] * polyz[k][1]; - data->shape_grads[dof_index3_2][q][1][0] = + data.shape_grads[dof_index3_2][q][1][0] = 2.0 * polyx[j][1] * polyz[k][0]; - data->shape_grads[dof_index3_2][q][1][2] = + data.shape_grads[dof_index3_2][q][1][2] = 2.0 * polyx[j][0] * polyz[k][1]; - data->shape_grads[dof_index3_3][q][2][0] = + data.shape_grads[dof_index3_3][q][2][0] = 2.0 * polyx[j][1] * polyy[k][0]; - data->shape_grads[dof_index3_3][q][2][1] = + data.shape_grads[dof_index3_3][q][2][1] = 2.0 * polyx[j][0] * polyy[k][1]; } } @@ -1093,7 +1097,7 @@ FE_NedelecSZ::get_data( Assert(false, ExcNotImplemented()); } } - return std::move(data); + return data_ptr; } template diff --git a/source/fe/fe_p1nc.cc b/source/fe/fe_p1nc.cc index f681aece31..1f81305bff 100644 --- a/source/fe/fe_p1nc.cc +++ b/source/fe/fe_p1nc.cc @@ -140,18 +140,19 @@ FE_P1NC::get_data( dealii::internal::FEValuesImplementation::FiniteElementRelatedData<2, 2> &output_data) const { - auto data = std_cxx14::make_unique::InternalDataBase>(); + auto data_ptr = + std_cxx14::make_unique::InternalDataBase>(); - data->update_each = requires_update_flags(update_flags); + data_ptr->update_each = requires_update_flags(update_flags); const unsigned int n_q_points = quadrature.size(); - output_data.initialize(n_q_points, FE_P1NC(), data->update_each); + output_data.initialize(n_q_points, FE_P1NC(), data_ptr->update_each); // this is a linear element, so its second derivatives are zero - if (data->update_each & update_hessians) + if (data_ptr->update_each & update_hessians) output_data.shape_hessians.fill(Tensor<2, 2>()); - return data; + return data_ptr; } @@ -164,18 +165,19 @@ FE_P1NC::get_face_data( dealii::internal::FEValuesImplementation::FiniteElementRelatedData<2, 2> &output_data) const { - auto data = std_cxx14::make_unique::InternalDataBase>(); + auto data_ptr = + std_cxx14::make_unique::InternalDataBase>(); - data->update_each = requires_update_flags(update_flags); + data_ptr->update_each = requires_update_flags(update_flags); const unsigned int n_q_points = quadrature.size(); - output_data.initialize(n_q_points, FE_P1NC(), data->update_each); + output_data.initialize(n_q_points, FE_P1NC(), data_ptr->update_each); // this is a linear element, so its second derivatives are zero - if (data->update_each & update_hessians) + if (data_ptr->update_each & update_hessians) output_data.shape_hessians.fill(Tensor<2, 2>()); - return data; + return data_ptr; } @@ -188,18 +190,19 @@ FE_P1NC::get_subface_data( dealii::internal::FEValuesImplementation::FiniteElementRelatedData<2, 2> &output_data) const { - auto data = std_cxx14::make_unique::InternalDataBase>(); + auto data_ptr = + std_cxx14::make_unique::InternalDataBase>(); - data->update_each = requires_update_flags(update_flags); + data_ptr->update_each = requires_update_flags(update_flags); const unsigned int n_q_points = quadrature.size(); - output_data.initialize(n_q_points, FE_P1NC(), data->update_each); + output_data.initialize(n_q_points, FE_P1NC(), data_ptr->update_each); // this is a linear element, so its second derivatives are zero - if (data->update_each & update_hessians) + if (data_ptr->update_each & update_hessians) output_data.shape_hessians.fill(Tensor<2, 2>()); - return data; + return data_ptr; } diff --git a/source/fe/fe_system.cc b/source/fe/fe_system.cc index 7477fa495c..fbc334f182 100644 --- a/source/fe/fe_system.cc +++ b/source/fe/fe_system.cc @@ -940,8 +940,10 @@ FESystem::get_data( // and so the current object's update_each flag needs to be // correct in case the current FESystem is a base element for another, // higher-level FESystem itself. - auto data = std_cxx14::make_unique(this->n_base_elements()); - data->update_each = requires_update_flags(flags); + std::unique_ptr::InternalDataBase> + data_ptr = std_cxx14::make_unique(this->n_base_elements()); + auto &data = dynamic_cast(*data_ptr); + data.update_each = requires_update_flags(flags); // get data objects from each of the base elements and store // them. one might think that doing this in parallel (over the @@ -958,7 +960,7 @@ FESystem::get_data( for (unsigned int base_no = 0; base_no < this->n_base_elements(); ++base_no) { internal::FEValuesImplementation::FiniteElementRelatedData - &base_fe_output_object = data->get_fe_output_object(base_no); + &base_fe_output_object = data.get_fe_output_object(base_no); base_fe_output_object.initialize( quadrature.size(), base_element(base_no), @@ -975,10 +977,10 @@ FESystem::get_data( quadrature, base_fe_output_object); - data->set_fe_data(base_no, std::move(base_fe_data)); + data.set_fe_data(base_no, std::move(base_fe_data)); } - return std::move(data); + return data_ptr; } // The following function is a clone of get_data, with the exception @@ -1001,8 +1003,10 @@ FESystem::get_face_data( // and so the current object's update_each flag needs to be // correct in case the current FESystem is a base element for another, // higher-level FESystem itself. - auto data = std_cxx14::make_unique(this->n_base_elements()); - data->update_each = requires_update_flags(flags); + std::unique_ptr::InternalDataBase> + data_ptr = std_cxx14::make_unique(this->n_base_elements()); + auto &data = dynamic_cast(*data_ptr); + data.update_each = requires_update_flags(flags); // get data objects from each of the base elements and store // them. one might think that doing this in parallel (over the @@ -1019,7 +1023,7 @@ FESystem::get_face_data( for (unsigned int base_no = 0; base_no < this->n_base_elements(); ++base_no) { internal::FEValuesImplementation::FiniteElementRelatedData - &base_fe_output_object = data->get_fe_output_object(base_no); + &base_fe_output_object = data.get_fe_output_object(base_no); base_fe_output_object.initialize( quadrature.size(), base_element(base_no), @@ -1034,10 +1038,10 @@ FESystem::get_face_data( auto base_fe_data = base_element(base_no).get_face_data( flags, mapping, quadrature, base_fe_output_object); - data->set_fe_data(base_no, std::move(base_fe_data)); + data.set_fe_data(base_no, std::move(base_fe_data)); } - return std::move(data); + return data_ptr; } @@ -1062,8 +1066,11 @@ FESystem::get_subface_data( // and so the current object's update_each flag needs to be // correct in case the current FESystem is a base element for another, // higher-level FESystem itself. - auto data = std_cxx14::make_unique(this->n_base_elements()); - data->update_each = requires_update_flags(flags); + std::unique_ptr::InternalDataBase> + data_ptr = std_cxx14::make_unique(this->n_base_elements()); + auto &data = dynamic_cast(*data_ptr); + + data.update_each = requires_update_flags(flags); // get data objects from each of the base elements and store // them. one might think that doing this in parallel (over the @@ -1080,7 +1087,7 @@ FESystem::get_subface_data( for (unsigned int base_no = 0; base_no < this->n_base_elements(); ++base_no) { internal::FEValuesImplementation::FiniteElementRelatedData - &base_fe_output_object = data->get_fe_output_object(base_no); + &base_fe_output_object = data.get_fe_output_object(base_no); base_fe_output_object.initialize( quadrature.size(), base_element(base_no), @@ -1095,10 +1102,10 @@ FESystem::get_subface_data( auto base_fe_data = base_element(base_no).get_subface_data( flags, mapping, quadrature, base_fe_output_object); - data->set_fe_data(base_no, std::move(base_fe_data)); + data.set_fe_data(base_no, std::move(base_fe_data)); } - return std::move(data); + return data_ptr; } diff --git a/source/fe/mapping_cartesian.cc b/source/fe/mapping_cartesian.cc index aad2315648..fa4d762321 100644 --- a/source/fe/mapping_cartesian.cc +++ b/source/fe/mapping_cartesian.cc @@ -98,14 +98,16 @@ std::unique_ptr::InternalDataBase> MappingCartesian::get_data(const UpdateFlags update_flags, const Quadrature &q) const { - auto data = std_cxx14::make_unique(q); + std::unique_ptr::InternalDataBase> data_ptr = + std_cxx14::make_unique(q); + auto &data = dynamic_cast(*data_ptr); // store the flags in the internal data object so we can access them // in fill_fe_*_values(). use the transitive hull of the required // flags - data->update_each = requires_update_flags(update_flags); + data.update_each = requires_update_flags(update_flags); - return std::move(data); + return data_ptr; } @@ -116,8 +118,10 @@ MappingCartesian::get_face_data( const UpdateFlags update_flags, const Quadrature &quadrature) const { - auto data = std_cxx14::make_unique( - QProjector::project_to_all_faces(quadrature)); + std::unique_ptr::InternalDataBase> data_ptr = + std_cxx14::make_unique( + QProjector::project_to_all_faces(quadrature)); + auto &data = dynamic_cast(*data_ptr); // verify that we have computed the transitive hull of the required // flags and that FEValues has faithfully passed them on to us @@ -126,9 +130,9 @@ MappingCartesian::get_face_data( // store the flags in the internal data object so we can access them // in fill_fe_*_values() - data->update_each = update_flags; + data.update_each = update_flags; - return std::move(data); + return data_ptr; } @@ -139,8 +143,10 @@ MappingCartesian::get_subface_data( const UpdateFlags update_flags, const Quadrature &quadrature) const { - auto data = std_cxx14::make_unique( - QProjector::project_to_all_subfaces(quadrature)); + std::unique_ptr::InternalDataBase> data_ptr = + std_cxx14::make_unique( + QProjector::project_to_all_subfaces(quadrature)); + auto &data = dynamic_cast(*data_ptr); // verify that we have computed the transitive hull of the required // flags and that FEValues has faithfully passed them on to us @@ -149,9 +155,9 @@ MappingCartesian::get_subface_data( // store the flags in the internal data object so we can access them // in fill_fe_*_values() - data->update_each = update_flags; + data.update_each = update_flags; - return std::move(data); + return data_ptr; } diff --git a/source/fe/mapping_fe_field.cc b/source/fe/mapping_fe_field.cc index 1659ccfb3a..a7eb6f30a4 100644 --- a/source/fe/mapping_fe_field.cc +++ b/source/fe/mapping_fe_field.cc @@ -566,10 +566,12 @@ MappingFEField::get_data( const UpdateFlags update_flags, const Quadrature &quadrature) const { - auto data = + std::unique_ptr::InternalDataBase> data_ptr = std_cxx14::make_unique(euler_dof_handler->get_fe(), fe_mask); - this->compute_data(update_flags, quadrature, quadrature.size(), *data); - return std::move(data); + auto &data = dynamic_cast(*data_ptr); + this->compute_data(update_flags, quadrature, quadrature.size(), data); + + return data_ptr; } @@ -580,12 +582,13 @@ MappingFEField::get_face_data( const UpdateFlags update_flags, const Quadrature &quadrature) const { - auto data = + std::unique_ptr::InternalDataBase> data_ptr = std_cxx14::make_unique(euler_dof_handler->get_fe(), fe_mask); + auto & data = dynamic_cast(*data_ptr); const Quadrature q(QProjector::project_to_all_faces(quadrature)); - this->compute_face_data(update_flags, q, quadrature.size(), *data); + this->compute_face_data(update_flags, q, quadrature.size(), data); - return std::move(data); + return data_ptr; } @@ -595,12 +598,13 @@ MappingFEField::get_subface_data( const UpdateFlags update_flags, const Quadrature &quadrature) const { - auto data = + std::unique_ptr::InternalDataBase> data_ptr = std_cxx14::make_unique(euler_dof_handler->get_fe(), fe_mask); + auto & data = dynamic_cast(*data_ptr); const Quadrature q(QProjector::project_to_all_subfaces(quadrature)); - this->compute_face_data(update_flags, q, quadrature.size(), *data); + this->compute_face_data(update_flags, q, quadrature.size(), data); - return std::move(data); + return data_ptr; } diff --git a/source/fe/mapping_manifold.cc b/source/fe/mapping_manifold.cc index b31dc9ed80..3895e55443 100644 --- a/source/fe/mapping_manifold.cc +++ b/source/fe/mapping_manifold.cc @@ -314,10 +314,12 @@ std::unique_ptr::InternalDataBase> MappingManifold::get_data(const UpdateFlags update_flags, const Quadrature &q) const { - auto data = std_cxx14::make_unique(); - data->initialize(this->requires_update_flags(update_flags), q, q.size()); + std::unique_ptr::InternalDataBase> data_ptr = + std_cxx14::make_unique(); + auto &data = dynamic_cast(*data_ptr); + data.initialize(this->requires_update_flags(update_flags), q, q.size()); - return std::move(data); + return data_ptr; } @@ -328,12 +330,14 @@ MappingManifold::get_face_data( const UpdateFlags update_flags, const Quadrature &quadrature) const { - auto data = std_cxx14::make_unique(); - data->initialize_face(this->requires_update_flags(update_flags), - QProjector::project_to_all_faces(quadrature), - quadrature.size()); - - return std::move(data); + std::unique_ptr::InternalDataBase> data_ptr = + std_cxx14::make_unique(); + auto &data = dynamic_cast(*data_ptr); + data.initialize_face(this->requires_update_flags(update_flags), + QProjector::project_to_all_faces(quadrature), + quadrature.size()); + + return data_ptr; } @@ -344,12 +348,14 @@ MappingManifold::get_subface_data( const UpdateFlags update_flags, const Quadrature &quadrature) const { - auto data = std_cxx14::make_unique(); - data->initialize_face(this->requires_update_flags(update_flags), - QProjector::project_to_all_subfaces(quadrature), - quadrature.size()); - - return std::move(data); + std::unique_ptr::InternalDataBase> data_ptr = + std_cxx14::make_unique(); + auto &data = dynamic_cast(*data_ptr); + data.initialize_face(this->requires_update_flags(update_flags), + QProjector::project_to_all_subfaces(quadrature), + quadrature.size()); + + return data_ptr; } diff --git a/source/fe/mapping_q.cc b/source/fe/mapping_q.cc index 661c7286f2..8d012d3e23 100644 --- a/source/fe/mapping_q.cc +++ b/source/fe/mapping_q.cc @@ -151,7 +151,9 @@ std::unique_ptr::InternalDataBase> MappingQ::get_data(const UpdateFlags update_flags, const Quadrature &quadrature) const { - auto data = std_cxx14::make_unique(); + std::unique_ptr::InternalDataBase> data_ptr = + std_cxx14::make_unique(); + auto &data = dynamic_cast(*data_ptr); // build the Q1 and Qp internal data objects in parallel Threads::Task< @@ -162,15 +164,15 @@ MappingQ::get_data(const UpdateFlags update_flags, quadrature); if (!use_mapping_q_on_all_cells) - data->mapping_q1_data = Utilities::dynamic_unique_cast< + data.mapping_q1_data = Utilities::dynamic_unique_cast< typename MappingQGeneric::InternalData>( std::move(q1_mapping->get_data(update_flags, quadrature))); // wait for the task above to finish and use returned value - data->mapping_qp_data = Utilities::dynamic_unique_cast< + data.mapping_qp_data = Utilities::dynamic_unique_cast< typename MappingQGeneric::InternalData>( std::move(do_get_data.return_value())); - return std::move(data); + return data_ptr; } @@ -181,7 +183,9 @@ MappingQ::get_face_data( const UpdateFlags update_flags, const Quadrature &quadrature) const { - auto data = std_cxx14::make_unique(); + std::unique_ptr::InternalDataBase> data_ptr = + std_cxx14::make_unique(); + auto &data = dynamic_cast(*data_ptr); // build the Q1 and Qp internal data objects in parallel Threads::Task< @@ -193,15 +197,15 @@ MappingQ::get_face_data( quadrature); if (!use_mapping_q_on_all_cells) - data->mapping_q1_data = Utilities::dynamic_unique_cast< + data.mapping_q1_data = Utilities::dynamic_unique_cast< typename MappingQGeneric::InternalData>( std::move(q1_mapping->get_face_data(update_flags, quadrature))); // wait for the task above to finish and use returned value - data->mapping_qp_data = Utilities::dynamic_unique_cast< + data.mapping_qp_data = Utilities::dynamic_unique_cast< typename MappingQGeneric::InternalData>( std::move(do_get_data.return_value())); - return std::move(data); + return data_ptr; } @@ -212,7 +216,9 @@ MappingQ::get_subface_data( const UpdateFlags update_flags, const Quadrature &quadrature) const { - auto data = std_cxx14::make_unique(); + std::unique_ptr::InternalDataBase> data_ptr = + std_cxx14::make_unique(); + auto &data = dynamic_cast(*data_ptr); // build the Q1 and Qp internal data objects in parallel Threads::Task< @@ -224,15 +230,15 @@ MappingQ::get_subface_data( quadrature); if (!use_mapping_q_on_all_cells) - data->mapping_q1_data = Utilities::dynamic_unique_cast< + data.mapping_q1_data = Utilities::dynamic_unique_cast< typename MappingQGeneric::InternalData>( std::move(q1_mapping->get_subface_data(update_flags, quadrature))); // wait for the task above to finish and use returned value - data->mapping_qp_data = Utilities::dynamic_unique_cast< + data.mapping_qp_data = Utilities::dynamic_unique_cast< typename MappingQGeneric::InternalData>( std::move(do_get_data.return_value())); - return std::move(data); + return data_ptr; } diff --git a/source/fe/mapping_q_generic.cc b/source/fe/mapping_q_generic.cc index d7d8e96d88..252a391aec 100644 --- a/source/fe/mapping_q_generic.cc +++ b/source/fe/mapping_q_generic.cc @@ -2724,10 +2724,12 @@ std::unique_ptr::InternalDataBase> MappingQGeneric::get_data(const UpdateFlags update_flags, const Quadrature &q) const { - auto data = std_cxx14::make_unique(polynomial_degree); - data->initialize(this->requires_update_flags(update_flags), q, q.size()); + std::unique_ptr::InternalDataBase> data_ptr = + std_cxx14::make_unique(polynomial_degree); + auto &data = dynamic_cast(*data_ptr); + data.initialize(this->requires_update_flags(update_flags), q, q.size()); - return std::move(data); + return data_ptr; } @@ -2738,12 +2740,14 @@ MappingQGeneric::get_face_data( const UpdateFlags update_flags, const Quadrature &quadrature) const { - auto data = std_cxx14::make_unique(polynomial_degree); - data->initialize_face(this->requires_update_flags(update_flags), - QProjector::project_to_all_faces(quadrature), - quadrature.size()); - - return std::move(data); + std::unique_ptr::InternalDataBase> data_ptr = + std_cxx14::make_unique(polynomial_degree); + auto &data = dynamic_cast(*data_ptr); + data.initialize_face(this->requires_update_flags(update_flags), + QProjector::project_to_all_faces(quadrature), + quadrature.size()); + + return data_ptr; } @@ -2754,12 +2758,14 @@ MappingQGeneric::get_subface_data( const UpdateFlags update_flags, const Quadrature &quadrature) const { - auto data = std_cxx14::make_unique(polynomial_degree); - data->initialize_face(this->requires_update_flags(update_flags), - QProjector::project_to_all_subfaces(quadrature), - quadrature.size()); - - return std::move(data); + std::unique_ptr::InternalDataBase> data_ptr = + std_cxx14::make_unique(polynomial_degree); + auto &data = dynamic_cast(*data_ptr); + data.initialize_face(this->requires_update_flags(update_flags), + QProjector::project_to_all_subfaces(quadrature), + quadrature.size()); + + return data_ptr; }