From: David Wells Date: Sun, 2 Jul 2023 15:12:07 +0000 (-0400) Subject: Fix the step-36 tests. X-Git-Tag: relicensing~801^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a850464123e106569379a8ea575a17178d6eee9b;p=dealii.git Fix the step-36 tests. These were broken by the ReadVector patch because std::vector cannot be converted to std::vector. While we are here I changed things to use ArrayView. --- diff --git a/doc/news/changes/incompatibilities/20230702DavidWells b/doc/news/changes/incompatibilities/20230702DavidWells new file mode 100644 index 0000000000..1c4caba63a --- /dev/null +++ b/doc/news/changes/incompatibilities/20230702DavidWells @@ -0,0 +1,6 @@ +Changed: The overloads of KellyErrorEstimator::estimate() which compute +multiple vector error estimates at once now require that vectors be passed +in ArrayView objects of pointers to ReadVector instead of std::vector objects +of pointers to VectorType objects. +
+(David Wells, 2023/07/02) diff --git a/include/deal.II/numerics/error_estimator.h b/include/deal.II/numerics/error_estimator.h index 92c67404d8..5e63a78327 100644 --- a/include/deal.II/numerics/error_estimator.h +++ b/include/deal.II/numerics/error_estimator.h @@ -379,7 +379,7 @@ public: * existence of this function, see the general documentation of this class. * * Since we do not want to force the user of this function to copy around - * their solution vectors, the vector of solution vectors takes pointers to + * their solution vectors, the ArrayView of solution vectors takes pointers to * the solutions, rather than being a vector of vectors. This makes it * simpler to have the solution vectors somewhere in memory, rather than to * have them collected somewhere special. (Note that it is not possible to @@ -393,9 +393,9 @@ public: const DoFHandler &dof, const Quadrature & quadrature, const std::map *> - & neumann_bc, - const std::vector *> &solutions, - std::vector *> & errors, + & neumann_bc, + const ArrayView *> &solutions, + ArrayView *> & errors, const ComponentMask & component_mask = ComponentMask(), const Function *coefficients = nullptr, const unsigned int n_threads = numbers::invalid_unsigned_int, @@ -413,9 +413,9 @@ public: const DoFHandler &dof, const Quadrature & quadrature, const std::map *> - & neumann_bc, - const std::vector *> &solutions, - std::vector *> & errors, + & neumann_bc, + const ArrayView *> &solutions, + ArrayView *> & errors, const ComponentMask & component_mask = ComponentMask(), const Function *coefficients = nullptr, const unsigned int n_threads = numbers::invalid_unsigned_int, @@ -478,9 +478,9 @@ public: const DoFHandler &dof, const hp::QCollection & quadrature, const std::map *> - & neumann_bc, - const std::vector *> &solutions, - std::vector *> & errors, + & neumann_bc, + const ArrayView *> &solutions, + ArrayView *> & errors, const ComponentMask & component_mask = ComponentMask(), const Function *coefficients = nullptr, const unsigned int n_threads = numbers::invalid_unsigned_int, @@ -499,9 +499,9 @@ public: const DoFHandler &dof, const hp::QCollection & quadrature, const std::map *> - & neumann_bc, - const std::vector *> &solutions, - std::vector *> & errors, + & neumann_bc, + const ArrayView *> &solutions, + ArrayView *> & errors, const ComponentMask & component_mask = ComponentMask(), const Function *coefficients = nullptr, const unsigned int n_threads = numbers::invalid_unsigned_int, @@ -677,9 +677,9 @@ public: const DoFHandler<1, spacedim> &dof, const Quadrature<0> & quadrature, const std::map *> - & neumann_bc, - const std::vector *> &solutions, - std::vector *> & errors, + & neumann_bc, + const ArrayView *> &solutions, + ArrayView *> & errors, const ComponentMask & component_mask = ComponentMask(), const Function *coefficients = nullptr, const unsigned int n_threads = numbers::invalid_unsigned_int, @@ -699,9 +699,9 @@ public: const DoFHandler<1, spacedim> &dof, const Quadrature<0> & quadrature, const std::map *> - & neumann_bc, - const std::vector *> &solutions, - std::vector *> & errors, + & neumann_bc, + const ArrayView *> &solutions, + ArrayView *> & errors, const ComponentMask & component_mask = ComponentMask(), const Function *coefficients = nullptr, const unsigned int n_threads = numbers::invalid_unsigned_int, @@ -767,9 +767,9 @@ public: const DoFHandler<1, spacedim> &dof, const hp::QCollection<0> & quadrature, const std::map *> - & neumann_bc, - const std::vector *> &solutions, - std::vector *> & errors, + & neumann_bc, + const ArrayView *> &solutions, + ArrayView *> & errors, const ComponentMask & component_mask = ComponentMask(), const Function *coefficients = nullptr, const unsigned int n_threads = numbers::invalid_unsigned_int, @@ -789,9 +789,9 @@ public: const DoFHandler<1, spacedim> &dof, const hp::QCollection<0> & quadrature, const std::map *> - & neumann_bc, - const std::vector *> &solutions, - std::vector *> & errors, + & neumann_bc, + const ArrayView *> &solutions, + ArrayView *> & errors, const ComponentMask & component_mask = ComponentMask(), const Function *coefficients = nullptr, const unsigned int n_threads = numbers::invalid_unsigned_int, diff --git a/include/deal.II/numerics/error_estimator.templates.h b/include/deal.II/numerics/error_estimator.templates.h index 7a059b6e73..5e00839ce9 100644 --- a/include/deal.II/numerics/error_estimator.templates.h +++ b/include/deal.II/numerics/error_estimator.templates.h @@ -655,10 +655,10 @@ namespace internal template void integrate_over_regular_face( - const std::vector *> &solutions, - ParallelData & parallel_data, + const ArrayView *> &solutions, + ParallelData & parallel_data, std::map::face_iterator, - std::vector> & local_face_integrals, + std::vector> & local_face_integrals, const typename DoFHandler::active_cell_iterator &cell, const unsigned int face_no, dealii::hp::FEFaceValues &fe_face_values_cell, @@ -748,10 +748,10 @@ namespace internal template void integrate_over_irregular_face( - const std::vector *> &solutions, - ParallelData & parallel_data, + const ArrayView *> &solutions, + ParallelData & parallel_data, std::map::face_iterator, - std::vector> & local_face_integrals, + std::vector> & local_face_integrals, const typename DoFHandler::active_cell_iterator &cell, const unsigned int face_no, dealii::hp::FEFaceValues & fe_face_values, @@ -863,10 +863,10 @@ namespace internal void estimate_one_cell( const typename DoFHandler::active_cell_iterator &cell, - ParallelData & parallel_data, + ParallelData & parallel_data, std::map::face_iterator, - std::vector> & local_face_integrals, - const std::vector *> &solutions, + std::vector> & local_face_integrals, + const ArrayView *> &solutions, const typename KellyErrorEstimator::Strategy strategy) { const unsigned int n_solution_vectors = solutions.size(); @@ -1016,14 +1016,15 @@ KellyErrorEstimator::estimate( const Strategy strategy) { // just pass on to the other function - const std::vector *> solutions(1, &solution); - std::vector *> errors(1, &error); + std::vector *> solutions(1, &solution); + std::vector *> errors(1, &error); + ArrayView *> error_view = make_array_view(errors); estimate(mapping, dof_handler, quadrature, neumann_bc, - solutions, - errors, + make_array_view(solutions), + error_view, component_mask, coefficients, n_threads, @@ -1084,14 +1085,15 @@ KellyErrorEstimator::estimate( const Strategy strategy) { // just pass on to the other function - const std::vector *> solutions(1, &solution); - std::vector *> errors(1, &error); + std::vector *> solutions(1, &solution); + std::vector *> errors(1, &error); + ArrayView *> error_view = make_array_view(errors); estimate(mapping, dof_handler, quadrature, neumann_bc, - solutions, - errors, + make_array_view(solutions), + error_view, component_mask, coefficients, n_threads, @@ -1142,11 +1144,11 @@ KellyErrorEstimator::estimate( const DoFHandler &dof_handler, const hp::QCollection & face_quadratures, const std::map *> - & neumann_bc, - const std::vector *> &solutions, - std::vector *> & errors, - const ComponentMask & component_mask, - const Function * coefficients, + & neumann_bc, + const ArrayView *> &solutions, + ArrayView *> & errors, + const ComponentMask & component_mask, + const Function * coefficients, const unsigned int, const types::subdomain_id subdomain_id_, const types::material_id material_id, @@ -1309,15 +1311,15 @@ KellyErrorEstimator::estimate( const DoFHandler &dof_handler, const Quadrature & quadrature, const std::map *> - & neumann_bc, - const std::vector *> &solutions, - std::vector *> & errors, - const ComponentMask & component_mask, - const Function * coefficients, - const unsigned int n_threads, - const types::subdomain_id subdomain_id, - const types::material_id material_id, - const Strategy strategy) + & neumann_bc, + const ArrayView *> &solutions, + ArrayView *> & errors, + const ComponentMask & component_mask, + const Function * coefficients, + const unsigned int n_threads, + const types::subdomain_id subdomain_id, + const types::material_id material_id, + const Strategy strategy) { // forward to the function with the QCollection estimate(mapping, @@ -1342,15 +1344,15 @@ KellyErrorEstimator::estimate( const DoFHandler &dof_handler, const Quadrature & quadrature, const std::map *> - & neumann_bc, - const std::vector *> &solutions, - std::vector *> & errors, - const ComponentMask & component_mask, - const Function * coefficients, - const unsigned int n_threads, - const types::subdomain_id subdomain_id, - const types::material_id material_id, - const Strategy strategy) + & neumann_bc, + const ArrayView *> &solutions, + ArrayView *> & errors, + const ComponentMask & component_mask, + const Function * coefficients, + const unsigned int n_threads, + const types::subdomain_id subdomain_id, + const types::material_id material_id, + const Strategy strategy) { estimate(get_default_linear_mapping(dof_handler.get_triangulation()), dof_handler, @@ -1375,15 +1377,15 @@ KellyErrorEstimator::estimate( const DoFHandler &dof_handler, const hp::QCollection & quadrature, const std::map *> - & neumann_bc, - const std::vector *> &solutions, - std::vector *> & errors, - const ComponentMask & component_mask, - const Function * coefficients, - const unsigned int n_threads, - const types::subdomain_id subdomain_id, - const types::material_id material_id, - const Strategy strategy) + & neumann_bc, + const ArrayView *> &solutions, + ArrayView *> & errors, + const ComponentMask & component_mask, + const Function * coefficients, + const unsigned int n_threads, + const types::subdomain_id subdomain_id, + const types::material_id material_id, + const Strategy strategy) { estimate(get_default_linear_mapping(dof_handler.get_triangulation()), dof_handler, diff --git a/source/numerics/error_estimator.inst.in b/source/numerics/error_estimator.inst.in index 211ffe29f9..74c2cf4009 100644 --- a/source/numerics/error_estimator.inst.in +++ b/source/numerics/error_estimator.inst.in @@ -67,8 +67,8 @@ for (S : REAL_AND_COMPLEX_SCALARS; deal_II_dimension : DIMENSIONS; const Quadrature &, const std::map *> &, - const std::vector *> &, - std::vector *> &, + const ArrayView *> &, + ArrayView *> &, const ComponentMask &, const Function *, const unsigned int, @@ -83,8 +83,8 @@ for (S : REAL_AND_COMPLEX_SCALARS; deal_II_dimension : DIMENSIONS; const Quadrature &, const std::map *> &, - const std::vector *> &, - std::vector *> &, + const ArrayView *> &, + ArrayView *> &, const ComponentMask &, const Function *, const unsigned int, @@ -133,8 +133,8 @@ for (S : REAL_AND_COMPLEX_SCALARS; deal_II_dimension : DIMENSIONS; const hp::QCollection &, const std::map *> &, - const std::vector *> &, - std::vector *> &, + const ArrayView *> &, + ArrayView *> &, const ComponentMask &, const Function *, const unsigned int, @@ -149,8 +149,8 @@ for (S : REAL_AND_COMPLEX_SCALARS; deal_II_dimension : DIMENSIONS; const hp::QCollection &, const std::map *> &, - const std::vector *> &, - std::vector *> &, + const ArrayView *> &, + ArrayView *> &, const ComponentMask &, const Function *, const unsigned int, diff --git a/source/numerics/error_estimator_1d.cc b/source/numerics/error_estimator_1d.cc index 4ad0d8302a..ef13297851 100644 --- a/source/numerics/error_estimator_1d.cc +++ b/source/numerics/error_estimator_1d.cc @@ -74,14 +74,15 @@ KellyErrorEstimator<1, spacedim>::estimate( const Strategy strategy) { // just pass on to the other function - const std::vector *> solutions(1, &solution); - std::vector *> errors(1, &error); + std::vector *> solutions(1, &solution); + std::vector *> errors(1, &error); + ArrayView *> error_view = make_array_view(errors); estimate(mapping, dof_handler, quadrature, neumann_bc, - solutions, - errors, + make_array_view(solutions), + error_view, component_mask, coefficients, n_threads, @@ -133,15 +134,15 @@ KellyErrorEstimator<1, spacedim>::estimate( const DoFHandler<1, spacedim> &dof_handler, const Quadrature<0> & quadrature, const std::map *> - & neumann_bc, - const std::vector *> &solutions, - std::vector *> & errors, - const ComponentMask & component_mask, - const Function * coefficients, - const unsigned int n_threads, - const types::subdomain_id subdomain_id, - const types::material_id material_id, - const Strategy strategy) + & neumann_bc, + const ArrayView *> &solutions, + ArrayView *> & errors, + const ComponentMask & component_mask, + const Function * coefficients, + const unsigned int n_threads, + const types::subdomain_id subdomain_id, + const types::material_id material_id, + const Strategy strategy) { const auto reference_cell = ReferenceCells::Line; estimate(reference_cell.template get_default_linear_mapping<1, spacedim>(), @@ -179,14 +180,15 @@ KellyErrorEstimator<1, spacedim>::estimate( const Strategy strategy) { // just pass on to the other function - const std::vector *> solutions(1, &solution); - std::vector *> errors(1, &error); + std::vector *> solutions(1, &solution); + std::vector *> errors(1, &error); + ArrayView *> error_view = make_array_view(errors); estimate(mapping, dof_handler, quadrature, neumann_bc, - solutions, - errors, + make_array_view(solutions), + error_view, component_mask, coefficients, n_threads, @@ -238,15 +240,15 @@ KellyErrorEstimator<1, spacedim>::estimate( const DoFHandler<1, spacedim> &dof_handler, const hp::QCollection<0> & quadrature, const std::map *> - & neumann_bc, - const std::vector *> &solutions, - std::vector *> & errors, - const ComponentMask & component_mask, - const Function * coefficients, - const unsigned int n_threads, - const types::subdomain_id subdomain_id, - const types::material_id material_id, - const Strategy strategy) + & neumann_bc, + const ArrayView *> &solutions, + ArrayView *> & errors, + const ComponentMask & component_mask, + const Function * coefficients, + const unsigned int n_threads, + const types::subdomain_id subdomain_id, + const types::material_id material_id, + const Strategy strategy) { const auto reference_cell = ReferenceCells::Line; estimate(reference_cell.template get_default_linear_mapping<1, spacedim>(), @@ -273,11 +275,11 @@ KellyErrorEstimator<1, spacedim>::estimate( const DoFHandler<1, spacedim> &dof_handler, const hp::QCollection<0> &, const std::map *> - & neumann_bc, - const std::vector *> &solutions, - std::vector *> & errors, - const ComponentMask & component_mask, - const Function * coefficient, + & neumann_bc, + const ArrayView *> &solutions, + ArrayView *> & errors, + const ComponentMask & component_mask, + const Function * coefficient, const unsigned int, const types::subdomain_id subdomain_id_, const types::material_id material_id, @@ -530,15 +532,15 @@ KellyErrorEstimator<1, spacedim>::estimate( const DoFHandler<1, spacedim> &dof_handler, const Quadrature<0> & quadrature, const std::map *> - & neumann_bc, - const std::vector *> &solutions, - std::vector *> & errors, - const ComponentMask & component_mask, - const Function * coefficients, - const unsigned int n_threads, - const types::subdomain_id subdomain_id, - const types::material_id material_id, - const Strategy strategy) + & neumann_bc, + const ArrayView *> &solutions, + ArrayView *> & errors, + const ComponentMask & component_mask, + const Function * coefficients, + const unsigned int n_threads, + const types::subdomain_id subdomain_id, + const types::material_id material_id, + const Strategy strategy) { const hp::QCollection<0> quadrature_collection(quadrature); estimate(mapping, diff --git a/source/numerics/error_estimator_1d.inst.in b/source/numerics/error_estimator_1d.inst.in index ea3f510579..c01a378e8e 100644 --- a/source/numerics/error_estimator_1d.inst.in +++ b/source/numerics/error_estimator_1d.inst.in @@ -57,8 +57,8 @@ for (S : REAL_AND_COMPLEX_SCALARS; deal_II_dimension : DIMENSIONS; const Quadrature &, const std::map *> &, - const std::vector *> &, - std::vector *> &, + const ArrayView *> &, + ArrayView *> &, const ComponentMask &, const Function *, const unsigned int, @@ -72,8 +72,8 @@ for (S : REAL_AND_COMPLEX_SCALARS; deal_II_dimension : DIMENSIONS; const Quadrature &, const std::map *> &, - const std::vector *> &, - std::vector *> &, + const ArrayView *> &, + ArrayView *> &, const ComponentMask &, const Function *, const unsigned int, @@ -119,8 +119,8 @@ for (S : REAL_AND_COMPLEX_SCALARS; deal_II_dimension : DIMENSIONS; const hp::QCollection &, const std::map *> &, - const std::vector *> &, - std::vector *> &, + const ArrayView *> &, + ArrayView *> &, const ComponentMask &, const Function *, const unsigned int, @@ -134,8 +134,8 @@ for (S : REAL_AND_COMPLEX_SCALARS; deal_II_dimension : DIMENSIONS; const hp::QCollection &, const std::map *> &, - const std::vector *> &, - std::vector *> &, + const ArrayView *> &, + ArrayView *> &, const ComponentMask &, const Function *, const unsigned int, diff --git a/tests/fe/fe_enriched_step-36.cc b/tests/fe/fe_enriched_step-36.cc index 189221484c..ecbff3aae7 100644 --- a/tests/fe/fe_enriched_step-36.cc +++ b/tests/fe/fe_enriched_step-36.cc @@ -488,9 +488,8 @@ namespace Step36 EigenvalueProblem::estimate_error() { { - std::vector sol( - number_of_eigenvalues); - std::vector *> error(number_of_eigenvalues); + std::vector *> sol(number_of_eigenvalues); + std::vector *> error(number_of_eigenvalues); for (unsigned int i = 0; i < number_of_eigenvalues; ++i) { @@ -502,12 +501,15 @@ namespace Step36 face_quadrature_formula.push_back(QGauss(3)); face_quadrature_formula.push_back(QGauss(3)); + ArrayView *> sol_view = + make_array_view(sol); + ArrayView *> error_view = make_array_view(error); KellyErrorEstimator::estimate( dof_handler, face_quadrature_formula, std::map *>(), - sol, - error); + sol_view, + error_view); } // sum up for a global: diff --git a/tests/fe/fe_enriched_step-36b.cc b/tests/fe/fe_enriched_step-36b.cc index dcd77b4fdf..9b8cdabcc4 100644 --- a/tests/fe/fe_enriched_step-36b.cc +++ b/tests/fe/fe_enriched_step-36b.cc @@ -694,9 +694,8 @@ namespace Step36 EigenvalueProblem::estimate_error() { { - std::vector sol( - number_of_eigenvalues); - std::vector *> error(number_of_eigenvalues); + std::vector *> sol(number_of_eigenvalues); + std::vector *> error(number_of_eigenvalues); for (unsigned int i = 0; i < number_of_eigenvalues; ++i) { @@ -708,12 +707,15 @@ namespace Step36 face_quadrature_formula.push_back(dealii::QGauss(3)); face_quadrature_formula.push_back(dealii::QGauss(3)); + ArrayView *> sol_view = + make_array_view(sol); + ArrayView *> error_view = make_array_view(error); KellyErrorEstimator::estimate( dof_handler, face_quadrature_formula, std::map *>(), - sol, - error); + sol_view, + error_view); } // sum up for a global: