From cd3dd79c0e3c9fe633d4358ba4ae818541d119d2 Mon Sep 17 00:00:00 2001 From: Luca Heltai Date: Thu, 11 Jan 2018 10:18:09 +0100 Subject: [PATCH] Removed smart pointer to dh.get_fe() --- include/deal.II/fe/mapping_fe_field.h | 10 ---- source/fe/mapping_fe_field.cc | 37 ++++++------ tests/mappings/mapping_fe_field_02.cc | 69 +++++++++++++++++++++++ tests/mappings/mapping_fe_field_02.output | 21 +++++++ 4 files changed, 108 insertions(+), 29 deletions(-) create mode 100644 tests/mappings/mapping_fe_field_02.cc create mode 100644 tests/mappings/mapping_fe_field_02.output diff --git a/include/deal.II/fe/mapping_fe_field.h b/include/deal.II/fe/mapping_fe_field.h index 95fb0938ec..6067d80f65 100644 --- a/include/deal.II/fe/mapping_fe_field.h +++ b/include/deal.II/fe/mapping_fe_field.h @@ -496,16 +496,6 @@ private: */ SmartPointer > euler_vector; - /** - * A FiniteElement object which is only needed in 3D, since it knows how to - * reorder shape functions/DoFs on non-standard faces. This is used to - * reorder support points in the same way. We could make this a pointer to - * prevent construction in 1D and 2D, but since memory and time requirements - * are not particularly high this seems unnecessary at the moment. - */ - SmartPointer, MappingFEField > fe; - - /** * Pointer to the DoFHandler to which the mapping vector is associated. */ diff --git a/source/fe/mapping_fe_field.cc b/source/fe/mapping_fe_field.cc index 1f2e35e624..a06dcf75c6 100644 --- a/source/fe/mapping_fe_field.cc +++ b/source/fe/mapping_fe_field.cc @@ -207,10 +207,9 @@ MappingFEField::MappingFEField const ComponentMask &mask) : euler_vector(&euler_vector), - fe(&euler_dof_handler.get_fe()), euler_dof_handler(&euler_dof_handler), fe_mask(mask.size() ? mask : - ComponentMask(fe->get_nonzero_components(0).size(), true)), + ComponentMask(euler_dof_handler.get_fe().get_nonzero_components(0).size(), true)), fe_to_real(fe_mask.size(), numbers::invalid_unsigned_int) { unsigned int size = 0; @@ -228,7 +227,6 @@ MappingFEField::MappingFEField (const MappingFEField &mapping) : euler_vector(mapping.euler_vector), - fe(mapping.fe), euler_dof_handler(mapping.euler_dof_handler), fe_mask(mapping.fe_mask), fe_to_real(mapping.fe_to_real) @@ -266,6 +264,7 @@ MappingFEField:: compute_shapes_virtual (const std::vector > &unit_points, typename MappingFEField::InternalData &data) const { + const auto fe = &euler_dof_handler->get_fe(); const unsigned int n_points=unit_points.size(); for (unsigned int point=0; point::InternalData * MappingFEField::get_data (const UpdateFlags update_flags, const Quadrature &quadrature) const { - InternalData *data = new InternalData(*fe, fe_mask); + InternalData *data = new InternalData(euler_dof_handler->get_fe(), fe_mask); this->compute_data (update_flags, quadrature, quadrature.size(), *data); return data; @@ -494,7 +493,7 @@ MappingFEField::get_face_data (const UpdateFlags update_flags, const Quadrature &quadrature) const { - InternalData *data = new InternalData(*fe, fe_mask); + InternalData *data = new InternalData(euler_dof_handler->get_fe(), fe_mask); const Quadrature q (QProjector::project_to_all_faces(quadrature)); this->compute_face_data (update_flags, q, quadrature.size(), *data); @@ -509,7 +508,7 @@ MappingFEField::get_subface_data (const UpdateFlags update_flags, const Quadrature &quadrature) const { - InternalData *data = new InternalData(*fe, fe_mask); + InternalData *data = new InternalData(euler_dof_handler->get_fe(), fe_mask); const Quadrature q (QProjector::project_to_all_subfaces(quadrature)); this->compute_face_data (update_flags, q, quadrature.size(), *data); @@ -1324,13 +1323,13 @@ fill_fe_values (const typename Triangulation::cell_iterator &cell, internal::MappingFEField::maybe_compute_q_points (QProjector::DataSetDescriptor::cell (), - data, *fe, fe_mask, fe_to_real, + data, euler_dof_handler->get_fe(), fe_mask, fe_to_real, output_data.quadrature_points); internal::MappingFEField::maybe_update_Jacobians (cell_similarity, QProjector::DataSetDescriptor::cell (), - data, *fe, fe_mask, fe_to_real); + data, euler_dof_handler->get_fe(), fe_mask, fe_to_real); const UpdateFlags update_flags = data.update_each; const std::vector &weights=quadrature.get_weights(); @@ -1434,35 +1433,35 @@ fill_fe_values (const typename Triangulation::cell_iterator &cell, internal::MappingFEField::maybe_update_jacobian_grads (cell_similarity, QProjector::DataSetDescriptor::cell(), - data, *fe, fe_mask, fe_to_real, + data, euler_dof_handler->get_fe(), fe_mask, fe_to_real, output_data.jacobian_grads); // calculate derivatives of the Jacobians pushed forward to real cell coordinates internal::MappingFEField::maybe_update_jacobian_pushed_forward_grads (cell_similarity, QProjector::DataSetDescriptor::cell(), - data, *fe, fe_mask, fe_to_real, + data, euler_dof_handler->get_fe(), fe_mask, fe_to_real, output_data.jacobian_pushed_forward_grads); // calculate hessians of the Jacobians internal::MappingFEField::maybe_update_jacobian_2nd_derivatives (cell_similarity, QProjector::DataSetDescriptor::cell(), - data, *fe, fe_mask, fe_to_real, + data, euler_dof_handler->get_fe(), fe_mask, fe_to_real, output_data.jacobian_2nd_derivatives); // calculate hessians of the Jacobians pushed forward to real cell coordinates internal::MappingFEField::maybe_update_jacobian_pushed_forward_2nd_derivatives (cell_similarity, QProjector::DataSetDescriptor::cell(), - data, *fe, fe_mask, fe_to_real, + data, euler_dof_handler->get_fe(), fe_mask, fe_to_real, output_data.jacobian_pushed_forward_2nd_derivatives); // calculate gradients of the hessians of the Jacobians internal::MappingFEField::maybe_update_jacobian_3rd_derivatives (cell_similarity, QProjector::DataSetDescriptor::cell(), - data, *fe, fe_mask, fe_to_real, + data, euler_dof_handler->get_fe(), fe_mask, fe_to_real, output_data.jacobian_3rd_derivatives); // calculate gradients of the hessians of the Jacobians pushed forward to real @@ -1470,7 +1469,7 @@ fill_fe_values (const typename Triangulation::cell_iterator &cell, internal::MappingFEField::maybe_update_jacobian_pushed_forward_3rd_derivatives (cell_similarity, QProjector::DataSetDescriptor::cell(), - data, *fe, fe_mask, fe_to_real, + data, euler_dof_handler->get_fe(), fe_mask, fe_to_real, output_data.jacobian_pushed_forward_3rd_derivatives); return updated_cell_similarity; @@ -1506,7 +1505,7 @@ fill_fe_face_values (const typename Triangulation::cell_iterator & quadrature.size()), quadrature, data, - *fe, fe_mask, fe_to_real, + euler_dof_handler->get_fe(), fe_mask, fe_to_real, output_data); } @@ -1541,7 +1540,7 @@ fill_fe_subface_values (const typename Triangulation::cell_iterato cell->subface_case(face_no)), quadrature, data, - *fe, fe_mask, fe_to_real, + euler_dof_handler->get_fe(), fe_mask, fe_to_real, output_data); } @@ -1797,7 +1796,7 @@ do_transform_unit_to_real_cell (const InternalData &data) const for (unsigned int i=0; isystem_to_component_index(i).first; + unsigned int comp_i = euler_dof_handler->get_fe().system_to_component_index(i).first; if (fe_mask[comp_i]) p_real[fe_to_real[comp_i]] += data.local_dof_values[i] * data.shape(0,i); } @@ -1890,7 +1889,7 @@ do_transform_real_to_unit_cell for (unsigned int k=0; k &grad_k = mdata.derivative(0,k); - unsigned int comp_k = fe->system_to_component_index(k).first; + unsigned int comp_k = euler_dof_handler->get_fe().system_to_component_index(k).first; if (fe_mask[comp_k]) for (unsigned int j=0; j unsigned int MappingFEField::get_degree() const { - return fe->degree; + return euler_dof_handler->get_fe().degree; } diff --git a/tests/mappings/mapping_fe_field_02.cc b/tests/mappings/mapping_fe_field_02.cc new file mode 100644 index 0000000000..b7a159920e --- /dev/null +++ b/tests/mappings/mapping_fe_field_02.cc @@ -0,0 +1,69 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2001 - 2016 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +template +void test() +{ + Triangulation tria; + GridGenerator::hyper_cube (tria); + + FESystem fe(FE_Q(1), spacedim); + DoFHandler dh(tria); + + dh.distribute_dofs(fe); + + deallog << "dim, spacedim: " << dim << ", " << spacedim << std::endl + << "cells: " << tria.n_active_cells() << ", dofs: " + << dh.n_dofs() < map_vector(dh.n_dofs()); + VectorTools::get_position_vector(dh, map_vector); + MappingFEField mapping(dh, map_vector); + + tria.refine_global (1); + + dh.distribute_dofs(fe); + + deallog << "After refine:" << std::endl + << "cells: " << tria.n_active_cells() << ", dofs: " + << dh.n_dofs() <(); + test<1,2>(); + test<2,2>(); + test<2,3>(); + test<3,3>(); +} diff --git a/tests/mappings/mapping_fe_field_02.output b/tests/mappings/mapping_fe_field_02.output new file mode 100644 index 0000000000..562627c06e --- /dev/null +++ b/tests/mappings/mapping_fe_field_02.output @@ -0,0 +1,21 @@ + +DEAL::dim, spacedim: 1, 1 +DEAL::cells: 1, dofs: 2 +DEAL::After refine: +DEAL::cells: 2, dofs: 3 +DEAL::dim, spacedim: 1, 2 +DEAL::cells: 1, dofs: 4 +DEAL::After refine: +DEAL::cells: 2, dofs: 6 +DEAL::dim, spacedim: 2, 2 +DEAL::cells: 1, dofs: 8 +DEAL::After refine: +DEAL::cells: 4, dofs: 18 +DEAL::dim, spacedim: 2, 3 +DEAL::cells: 1, dofs: 12 +DEAL::After refine: +DEAL::cells: 4, dofs: 27 +DEAL::dim, spacedim: 3, 3 +DEAL::cells: 1, dofs: 24 +DEAL::After refine: +DEAL::cells: 8, dofs: 81 -- 2.39.5