--- /dev/null
+// ---------------------------------------------------------------------
+//
+// 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 <deal.II/base/config.h>
+
+#include <deal.II/grid/reference_cell.h>
+
+#include <boost/python.hpp>
+
+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
return internal::cell_cast<3, 3>(cell_accessor)->n_faces();
}
+
+
CellTypeWrapper
CellAccessorWrapper::reference_cell_type() const
{
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// 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 <boost/python.hpp>
+
+#include <reference_cell_wrapper.h>
+
+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_<ReferenceCell::Type::CellKinds>("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_<CellTypeWrapper>(
+ "CellType",
+ boost::python::init<ReferenceCell::Type::CellKinds>(
+ boost::python::args("kind")))
+ .add_property("kind", &CellTypeWrapper::cell_kind, cell_kind_docstring);
+ }
+} // namespace python
+
+DEAL_II_NAMESPACE_CLOSE
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// 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 <deal.II/grid/reference_cell.h>
+
+#include <reference_cell_wrapper.h>
+
+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<ReferenceCell::Type::CellKinds>(kind);
+ }
+
+} // namespace python
+
+DEAL_II_NAMESPACE_CLOSE
// ---------------------------------------------------------------------
//
-// 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.
//
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;
+ }
}
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;
+ }
}
{
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
}
+
void
TriangulationWrapper::convert_hypercube_to_simplex_mesh(
TriangulationWrapper &tria_out)
}
+
void
TriangulationWrapper::extrude_triangulation(
const unsigned int n_slices,
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)
--- /dev/null
+New: Added python wrappers to enable support for simplex and mixed meshes.
+<br>
+(Alexander Grayver, 2021/01/18)