From: Ce Qin Date: Wed, 6 Jan 2021 12:09:15 +0000 (+0800) Subject: Fix bug in distribute_dofs X-Git-Tag: v9.3.0-rc1~663^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F11486%2Fhead;p=dealii.git Fix bug in distribute_dofs --- diff --git a/source/dofs/dof_handler.cc b/source/dofs/dof_handler.cc index f6becc1322..d0b2a6661b 100644 --- a/source/dofs/dof_handler.cc +++ b/source/dofs/dof_handler.cc @@ -2056,6 +2056,9 @@ DoFHandler::reinit(const Triangulation &tria) DoFHandler::clear(); this->policy.reset(); + // reset the finite element collection + this->fe_collection = hp::FECollection(); + // // call constructor // diff --git a/tests/dofs/distribute_dofs_01.cc b/tests/dofs/distribute_dofs_01.cc new file mode 100644 index 0000000000..337a9a6f4b --- /dev/null +++ b/tests/dofs/distribute_dofs_01.cc @@ -0,0 +1,58 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2010 - 2021 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.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + +#include + +#include + +#include +#include + +#include "../tests.h" + +// Check DoFHandler::distribute_dofs with multiple calls to reinit + +void +test() +{ + dealii::Triangulation<3> tria; + dealii::GridGenerator::hyper_cube(tria, -1, 1); + + dealii::FE_Nedelec<3> fe_nedelec(0); + + dealii::DoFHandler<3> dh_nedelec; + + dh_nedelec.reinit(tria); + dh_nedelec.distribute_dofs(fe_nedelec); + + dh_nedelec.reinit(tria); + dh_nedelec.distribute_dofs(fe_nedelec); + + for (const auto &cell : dh_nedelec.active_cell_iterators()) + for (unsigned int i = 0; i < dealii::GeometryInfo<3>::lines_per_cell; ++i) + cell->line(i)->dof_index(0); + + deallog << "ok" << std::endl; +} + +int +main() +{ + initlog(); + + test(); + + return 0; +} diff --git a/tests/dofs/distribute_dofs_01.debug.output b/tests/dofs/distribute_dofs_01.debug.output new file mode 100644 index 0000000000..0de35217a9 --- /dev/null +++ b/tests/dofs/distribute_dofs_01.debug.output @@ -0,0 +1,2 @@ + +DEAL::ok