From 849243271a39a64f7bc2e10ebc1119494fbfc83d Mon Sep 17 00:00:00 2001 From: David Wells Date: Sat, 1 Jul 2023 16:43:10 -0400 Subject: [PATCH] Use ReferenceCell::closest_point() in more places. --- include/deal.II/grid/grid_tools.h | 2 +- .../vector_tools_point_gradient.templates.h | 4 +-- .../vector_tools_point_value.templates.h | 30 +++++++++---------- source/fe/mapping_fe_field.cc | 6 +--- source/grid/grid_tools.cc | 8 ++--- source/grid/manifold_lib.cc | 3 +- 6 files changed, 22 insertions(+), 31 deletions(-) diff --git a/include/deal.II/grid/grid_tools.h b/include/deal.II/grid/grid_tools.h index dcf52d9ccf..cbfa05a523 100644 --- a/include/deal.II/grid/grid_tools.h +++ b/include/deal.II/grid/grid_tools.h @@ -1637,7 +1637,7 @@ namespace GridTools * local position might be located slightly outside an actual unit cell, * due to numerical roundoff. Therefore, the point returned by this function * should be projected onto the unit cell, using - * GeometryInfo::project_to_unit_cell(). This is not automatically performed + * ReferenceCell::closest_point(). This is not automatically performed * by the algorithm. The returned cell can be a locally-owned cell or a * ghost cell (but not an artificial cell). The returned cell might be a * ghost cell even if the given point is a vertex of a locally owned cell. diff --git a/include/deal.II/numerics/vector_tools_point_gradient.templates.h b/include/deal.II/numerics/vector_tools_point_gradient.templates.h index a709d20f1c..361c77f13c 100644 --- a/include/deal.II/numerics/vector_tools_point_gradient.templates.h +++ b/include/deal.II/numerics/vector_tools_point_gradient.templates.h @@ -113,7 +113,7 @@ namespace VectorTools ExcInternalError()); const Quadrature quadrature( - GeometryInfo::project_to_unit_cell(cell_point.second)); + cell_point.first->reference_cell().closest_point(cell_point.second)); FEValues fe_values(mapping, fe, quadrature, update_gradients); fe_values.reinit(cell_point.first); @@ -159,7 +159,7 @@ namespace VectorTools ExcInternalError()); const Quadrature quadrature( - GeometryInfo::project_to_unit_cell(cell_point.second)); + cell_point.first->reference_cell().closest_point(cell_point.second)); hp::FEValues hp_fe_values(mapping, fe, hp::QCollection(quadrature), diff --git a/include/deal.II/numerics/vector_tools_point_value.templates.h b/include/deal.II/numerics/vector_tools_point_value.templates.h index a53792ed8b..f2049e6616 100644 --- a/include/deal.II/numerics/vector_tools_point_value.templates.h +++ b/include/deal.II/numerics/vector_tools_point_value.templates.h @@ -112,7 +112,7 @@ namespace VectorTools ExcInternalError()); const Quadrature quadrature( - GeometryInfo::project_to_unit_cell(cell_point.second)); + cell_point.first->reference_cell().closest_point(cell_point.second)); FEValues fe_values(mapping, fe, quadrature, update_values); fe_values.reinit(cell_point.first); @@ -155,7 +155,7 @@ namespace VectorTools ExcInternalError()); const Quadrature quadrature( - GeometryInfo::project_to_unit_cell(cell_point.second)); + cell_point.first->reference_cell().closest_point(cell_point.second)); hp::FEValues hp_fe_values(mapping, fe, hp::QCollection(quadrature), @@ -260,7 +260,7 @@ namespace VectorTools ExcInternalError()); const Quadrature quadrature( - GeometryInfo::project_to_unit_cell(cell_point.second)); + cell_point.first->reference_cell().closest_point(cell_point.second)); FEValues fe_values(mapping, fe, quadrature, update_values); fe_values.reinit(cell_point.first); @@ -300,12 +300,12 @@ namespace VectorTools AssertThrow(cell_point.first.state() == IteratorState::valid, ExcPointNotAvailableHere()); - Quadrature q( - GeometryInfo::project_to_unit_cell(cell_point.second)); + const Quadrature quadrature( + cell_point.first->reference_cell().closest_point(cell_point.second)); FEValues fe_values(mapping, dof_handler.get_fe(), - q, + quadrature, UpdateFlags(update_values)); fe_values.reinit(cell_point.first); @@ -364,12 +364,12 @@ namespace VectorTools AssertThrow(cell_point.first.state() == IteratorState::valid, ExcPointNotAvailableHere()); - Quadrature q( - GeometryInfo::project_to_unit_cell(cell_point.second)); + const Quadrature quadrature( + cell_point.first->reference_cell().closest_point(cell_point.second)); FEValues fe_values(mapping[cell_point.first->active_fe_index()], cell_point.first->get_fe(), - q, + quadrature, UpdateFlags(update_values)); fe_values.reinit(cell_point.first); @@ -409,13 +409,13 @@ namespace VectorTools AssertThrow(cell_point.first.state() == IteratorState::valid, ExcPointNotAvailableHere()); - const Quadrature q( - GeometryInfo::project_to_unit_cell(cell_point.second)); + const Quadrature quadrature( + cell_point.first->reference_cell().closest_point(cell_point.second)); const FEValuesExtractors::Vector vec(0); FEValues fe_values(mapping, dof_handler.get_fe(), - q, + quadrature, UpdateFlags(update_values)); fe_values.reinit(cell_point.first); @@ -480,13 +480,13 @@ namespace VectorTools AssertThrow(cell_point.first.state() == IteratorState::valid, ExcPointNotAvailableHere()); - Quadrature q( - GeometryInfo::project_to_unit_cell(cell_point.second)); + const Quadrature quadrature( + cell_point.first->reference_cell().closest_point(cell_point.second)); const FEValuesExtractors::Vector vec(0); FEValues fe_values(mapping[cell_point.first->active_fe_index()], cell_point.first->get_fe(), - q, + quadrature, UpdateFlags(update_values)); fe_values.reinit(cell_point.first); diff --git a/source/fe/mapping_fe_field.cc b/source/fe/mapping_fe_field.cc index 87d142c7d2..2de9bf96e8 100644 --- a/source/fe/mapping_fe_field.cc +++ b/source/fe/mapping_fe_field.cc @@ -2252,11 +2252,7 @@ MappingFEField::transform_real_to_unit_cell( initial_p_unit[d] = 0.5; } - // TODO - initial_p_unit = GeometryInfo::project_to_unit_cell(initial_p_unit); - - // for (unsigned int d=0; dreference_cell().closest_point(initial_p_unit); const Quadrature point_quadrature(initial_p_unit); diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc index 3162580712..b8680497ea 100644 --- a/source/grid/grid_tools.cc +++ b/source/grid/grid_tools.cc @@ -6281,12 +6281,8 @@ namespace GridTools auto reference_position = cell_and_reference_position.second; - // TODO: we need to implement - // ReferenceCell::project_to_unit_cell() - if (cell->reference_cell().is_hyper_cube()) - reference_position = - GeometryInfo::project_to_unit_cell( - reference_position); + reference_position = + cell->reference_cell().closest_point(reference_position); send_components.emplace_back( std::pair(cell->level(), cell->index()), diff --git a/source/grid/manifold_lib.cc b/source/grid/manifold_lib.cc index 7c0ab122d4..e4c3880f99 100644 --- a/source/grid/manifold_lib.cc +++ b/source/grid/manifold_lib.cc @@ -2093,8 +2093,7 @@ TransfiniteInterpolationManifold::pull_back( outside[d] = internal::invalid_pull_back_coordinate; // project the user-given input to unit cell - Point chart_point = - GeometryInfo::project_to_unit_cell(initial_guess); + Point chart_point = cell->reference_cell().closest_point(initial_guess); // run quasi-Newton iteration with a combination of finite differences for // the exact Jacobian and "Broyden's good method". As opposed to the various -- 2.39.5