From: Peter Munch Date: Tue, 25 Jul 2023 21:02:00 +0000 (+0200) Subject: Add MGLevelObject::clear() X-Git-Tag: relicensing~644^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f7b76b677216396343a458e53bd9b92bbc68874;p=dealii.git Add MGLevelObject::clear() --- diff --git a/include/deal.II/base/mg_level_object.h b/include/deal.II/base/mg_level_object.h index 20211a7301..3aec38ea92 100644 --- a/include/deal.II/base/mg_level_object.h +++ b/include/deal.II/base/mg_level_object.h @@ -131,6 +131,13 @@ public: MGLevelObject & operator=(const double d); + /** + * Clear all data fields and brings the class into a condition similar + * to after having called the default constructor. + */ + void + clear(); + /** * Call @p clear on all objects stored by this object. This function * is only implemented for some @p Object classes, e.g., matrix @@ -275,6 +282,15 @@ MGLevelObject::operator=(const double d) } +template +void +MGLevelObject::clear() +{ + minlevel = 0; + objects.clear(); +} + + template void MGLevelObject::clear_elements() diff --git a/tests/multigrid/mg_level_obj_02.cc b/tests/multigrid/mg_level_obj_02.cc new file mode 100644 index 0000000000..cecb3051e7 --- /dev/null +++ b/tests/multigrid/mg_level_obj_02.cc @@ -0,0 +1,42 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2023 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. +// +// --------------------------------------------------------------------- + + +// check MGLevelObject::clear() + +#include + +#include + +#include "../tests.h" + +int +main() +{ + initlog(); + + MGLevelObject o(2, 4); + + AssertDimension(o.min_level(), 2); + AssertDimension(o.max_level(), 4); + AssertDimension(o.n_levels(), 3); + + o.clear(); + + AssertDimension(o.min_level(), 0); + AssertDimension(o.n_levels(), 0); + + deallog << "OK!" << std::endl; +} diff --git a/tests/multigrid/mg_level_obj_02.output b/tests/multigrid/mg_level_obj_02.output new file mode 100644 index 0000000000..5cfb783b8f --- /dev/null +++ b/tests/multigrid/mg_level_obj_02.output @@ -0,0 +1,2 @@ + +DEAL::OK!