From: Alexander Grayver Date: Mon, 18 Jan 2021 20:44:02 +0000 (+0100) Subject: Add changelog X-Git-Tag: v9.3.0-rc1~581^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e51df1d17e2c2da577ead11c0ea8391595254f07;p=dealii.git Add changelog --- diff --git a/contrib/python-bindings/include/reference_cell_wrapper.h b/contrib/python-bindings/include/reference_cell_wrapper.h new file mode 100644 index 0000000000..1a8b755f58 --- /dev/null +++ b/contrib/python-bindings/include/reference_cell_wrapper.h @@ -0,0 +1,68 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 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. +// +// --------------------------------------------------------------------- + +#ifndef dealii_reference_cell_wrapper_h +#define dealii_reference_cell_wrapper_h + +#include + +#include + +#include + +DEAL_II_NAMESPACE_OPEN + +namespace python +{ + class CellTypeWrapper + { + public: + /** + * Copy constructor. + */ + CellTypeWrapper(const CellTypeWrapper &other); + + /** + * Constructor. Takes a CellKinds enum field and creates a Type class. + */ + CellTypeWrapper(const ReferenceCell::Type::CellKinds &kind); + + /** + * Constructor. Takes a CellKinds enum field and creates a Type class. + */ + CellTypeWrapper(const ReferenceCell::Type &cell_type_in); + + /** + * Constructor for an empty object. + */ + CellTypeWrapper(); + + /** + * Destructor. + */ + ~CellTypeWrapper(); + + ReferenceCell::Type::CellKinds + cell_kind() const; + + private: + ReferenceCell::Type cell_type; + }; + +} // namespace python + +DEAL_II_NAMESPACE_CLOSE + +#endif diff --git a/contrib/python-bindings/source/cell_accessor_wrapper.cc b/contrib/python-bindings/source/cell_accessor_wrapper.cc index 50ce261f39..016e678ad2 100644 --- a/contrib/python-bindings/source/cell_accessor_wrapper.cc +++ b/contrib/python-bindings/source/cell_accessor_wrapper.cc @@ -796,6 +796,8 @@ namespace python return internal::cell_cast<3, 3>(cell_accessor)->n_faces(); } + + CellTypeWrapper CellAccessorWrapper::reference_cell_type() const { diff --git a/contrib/python-bindings/source/export_reference_cell.cc b/contrib/python-bindings/source/export_reference_cell.cc new file mode 100644 index 0000000000..7ad3d0ffb8 --- /dev/null +++ b/contrib/python-bindings/source/export_reference_cell.cc @@ -0,0 +1,50 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2016 - 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 + +DEAL_II_NAMESPACE_OPEN + +namespace python +{ + const char cell_kind_docstring[] = + "Return geometric type of the corresponding reference cell. \n"; + + + void + export_reference_cell() + { + boost::python::enum_("CellKinds") + .value("Vertex", ReferenceCell::Type::Vertex) + .value("Line", ReferenceCell::Type::Line) + .value("Tri", ReferenceCell::Type::Tri) + .value("Quad", ReferenceCell::Type::Quad) + .value("Tet", ReferenceCell::Type::Tet) + .value("Pyramid", ReferenceCell::Type::Pyramid) + .value("Wedge", ReferenceCell::Type::Wedge) + .value("Hex", ReferenceCell::Type::Hex) + .value("Invalid", ReferenceCell::Type::Invalid); + + boost::python::class_( + "CellType", + boost::python::init( + boost::python::args("kind"))) + .add_property("kind", &CellTypeWrapper::cell_kind, cell_kind_docstring); + } +} // namespace python + +DEAL_II_NAMESPACE_CLOSE diff --git a/contrib/python-bindings/source/reference_cell_wrapper.cc b/contrib/python-bindings/source/reference_cell_wrapper.cc new file mode 100644 index 0000000000..b87e29ddc5 --- /dev/null +++ b/contrib/python-bindings/source/reference_cell_wrapper.cc @@ -0,0 +1,64 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 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 + +DEAL_II_NAMESPACE_OPEN + +namespace python +{ + CellTypeWrapper::CellTypeWrapper() + {} + + + + CellTypeWrapper::CellTypeWrapper(const CellTypeWrapper &other) + { + cell_type = other.cell_type; + } + + + + CellTypeWrapper::CellTypeWrapper(const ReferenceCell::Type::CellKinds &kind) + { + cell_type = kind; + } + + + + CellTypeWrapper::CellTypeWrapper(const ReferenceCell::Type &cell_type_in) + { + cell_type = cell_type_in; + } + + + + CellTypeWrapper::~CellTypeWrapper() + {} + + + + ReferenceCell::Type::CellKinds + CellTypeWrapper::cell_kind() const + { + std::uint8_t kind = (std::uint8_t)cell_type; + return static_cast(kind); + } + +} // namespace python + +DEAL_II_NAMESPACE_CLOSE diff --git a/contrib/python-bindings/source/tria_accessor_wrapper.cc b/contrib/python-bindings/source/tria_accessor_wrapper.cc index eebd472ff4..37c442e13c 100644 --- a/contrib/python-bindings/source/tria_accessor_wrapper.cc +++ b/contrib/python-bindings/source/tria_accessor_wrapper.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2016 - 2020 by the deal.II authors +// Copyright (C) 2021 by the deal.II authors // // This file is part of the deal.II library. // @@ -417,8 +417,18 @@ namespace python return internal::tria_accessor_cast<1, 2, 2>(tria_accessor)->n_vertices(); else if ((dim == 2) && (spacedim == 3) && (structdim == 1)) return internal::tria_accessor_cast<1, 2, 3>(tria_accessor)->n_vertices(); - else + else if ((dim == 3) && (spacedim == 3) && (structdim == 1)) + return internal::tria_accessor_cast<1, 3, 3>(tria_accessor)->n_vertices(); + else if ((dim == 3) && (spacedim == 3) && (structdim == 2)) return internal::tria_accessor_cast<2, 3, 3>(tria_accessor)->n_vertices(); + else if ((dim == 3) && (spacedim == 3) && (structdim == 3)) + return internal::tria_accessor_cast<3, 3, 3>(tria_accessor)->n_vertices(); + else + { + AssertThrow(false, + ExcMessage("Wrong structdim-dim-spacedim combination.")); + return -1; + } } @@ -430,8 +440,18 @@ namespace python return internal::tria_accessor_cast<1, 2, 2>(tria_accessor)->n_lines(); else if ((dim == 2) && (spacedim == 3) && (structdim == 1)) return internal::tria_accessor_cast<1, 2, 3>(tria_accessor)->n_lines(); - else + else if ((dim == 3) && (spacedim == 3) && (structdim == 1)) + return internal::tria_accessor_cast<1, 3, 3>(tria_accessor)->n_lines(); + else if ((dim == 3) && (spacedim == 3) && (structdim == 2)) return internal::tria_accessor_cast<2, 3, 3>(tria_accessor)->n_lines(); + else if ((dim == 3) && (spacedim == 3) && (structdim == 3)) + return internal::tria_accessor_cast<3, 3, 3>(tria_accessor)->n_lines(); + else + { + AssertThrow(false, + ExcMessage("Wrong structdim-dim-spacedim combination.")); + return -1; + } } @@ -441,10 +461,16 @@ namespace python { if ((dim == 2) && (spacedim == 2) && (structdim == 1)) return internal::tria_accessor_cast<1, 2, 2>(tria_accessor)->n_faces(); - else if ((dim == 2) && (spacedim == 3) && (structdim == 1)) - return internal::tria_accessor_cast<1, 2, 3>(tria_accessor)->n_faces(); - else + else if ((dim == 3) && (spacedim == 3) && (structdim == 2)) return internal::tria_accessor_cast<2, 3, 3>(tria_accessor)->n_faces(); + else if ((dim == 3) && (spacedim == 3) && (structdim == 3)) + return internal::tria_accessor_cast<3, 3, 3>(tria_accessor)->n_faces(); + else + { + AssertThrow(false, + ExcMessage("Wrong structdim-dim-spacedim combination.")); + return -1; + } } } // namespace python diff --git a/contrib/python-bindings/source/triangulation_wrapper.cc b/contrib/python-bindings/source/triangulation_wrapper.cc index 511df8b736..5d5cb5e7dc 100644 --- a/contrib/python-bindings/source/triangulation_wrapper.cc +++ b/contrib/python-bindings/source/triangulation_wrapper.cc @@ -1549,6 +1549,7 @@ namespace python } + void TriangulationWrapper::convert_hypercube_to_simplex_mesh( TriangulationWrapper &tria_out) @@ -1569,6 +1570,7 @@ namespace python } + void TriangulationWrapper::extrude_triangulation( const unsigned int n_slices, diff --git a/contrib/python-bindings/tests/triangulation_wrapper.py b/contrib/python-bindings/tests/triangulation_wrapper.py index 09445d2f4a..e6eb29ab59 100644 --- a/contrib/python-bindings/tests/triangulation_wrapper.py +++ b/contrib/python-bindings/tests/triangulation_wrapper.py @@ -438,6 +438,18 @@ class TestTriangulationWrapper(unittest.TestCase): self.assertTrue(cell.center().distance(cell_ret.center()) < 1e-8) + def test_simplex(self): + for dim in self.dim: + triangulation_hex = self.build_hyper_cube_triangulation(dim) + triangulation_simplex = Triangulation(dim[0], dim[1]) + triangulation_hex.convert_hypercube_to_simplex_mesh(triangulation_simplex) + + if dim[0] == '3D': + self.assertTrue(triangulation_simplex.n_active_cells() == 24) + else: + self.assertTrue(triangulation_simplex.n_active_cells() == 8) + + def test_save_load(self): for dim in self.dim: triangulation_1 = self.build_hyper_cube_triangulation(dim) diff --git a/doc/news/changes/minor/20210118AlexanderGrayver b/doc/news/changes/minor/20210118AlexanderGrayver new file mode 100644 index 0000000000..927449f483 --- /dev/null +++ b/doc/news/changes/minor/20210118AlexanderGrayver @@ -0,0 +1,3 @@ +New: Added python wrappers to enable support for simplex and mixed meshes. +
+(Alexander Grayver, 2021/01/18)