--- /dev/null
+Changed: When calling Triangulation::get_manifold(manifold_id) for
+a non-existing manifold_id, the function returned a flat manifold.
+This behaviour has been changed and an assert is thrown in this case.
+Furthermore, the functions Triangulation::reset_manifold() and
+Triangulation::reset_all_manifolds() do not actually remove the manifolds
+but make them flat.
+<br>
+(Peter Munch, 2022/12/09)
* assignment of a different Manifold object by the function
* Triangulation::set_manifold().
*
+ * @note Geometric objects with the manifold ID @p manifold_number will
+ * still have the same ID after calling this function so that the function
+ * get_manifold_ids() will still return the same set of IDs.
+ *
* @ingroup manifold
*
* @see
* of all Manifold objects by the function
* Triangulation::set_manifold().
*
+ * @note Geometric objects not having numbers::flat_manifold_id as manifold ID
+ * will after calling this function still have the same IDs. Their IDs are
+ * not replaced by numbers::flat_manifold_id so that the function
+ * get_manifold_ids() will still return the same set of IDs.
+ *
* @ingroup manifold
*
* @see
tria.set_manifold(2,
CylindricalManifold<3>(Tensor<1, 3>({0., 1., 0.}),
Point<3>()));
+
+ tria.set_manifold(0, FlatManifold<3>());
TransfiniteInterpolationManifold<3> transfinite;
transfinite.initialize(tria);
tria.set_manifold(0, transfinite);
PolarManifold<2> polar_manifold(new_center);
tria.set_manifold(polar_manifold_id, polar_manifold);
+ tria.set_manifold(tfi_manifold_id, FlatManifold<2>());
TransfiniteInterpolationManifold<2> inner_manifold;
inner_manifold.initialize(tria);
tria.set_manifold(tfi_manifold_id, inner_manifold);
const CylindricalManifold<3> cylindrical_manifold(
direction,
/*axial_point*/ new_center);
+ tria.set_manifold(polar_manifold_id, FlatManifold<3>());
+ tria.set_manifold(tfi_manifold_id, FlatManifold<3>());
TransfiniteInterpolationManifold<3> inner_manifold;
inner_manifold.initialize(tria);
+
tria.set_manifold(polar_manifold_id, cylindrical_manifold);
tria.set_manifold(tfi_manifold_id, inner_manifold);
}
// attach manifolds
PolarManifold<2> polar_manifold(Point<2>(0.2, 0.2));
tria.set_manifold(polar_manifold_id, polar_manifold);
+
+ tria.set_manifold(tfi_manifold_id, FlatManifold<2>());
TransfiniteInterpolationManifold<2> inner_manifold;
inner_manifold.initialize(tria);
tria.set_manifold(tfi_manifold_id, inner_manifold);
const Point<3> axial_point(m_ptr->center[0], m_ptr->center[1], 0.0);
const Tensor<1, 3> direction{{0.0, 0.0, 1.0}};
+ tria.set_manifold(cylindrical_manifold_id, FlatManifold<3>());
+ tria.set_manifold(tfi_manifold_id, FlatManifold<3>());
const CylindricalManifold<3> cylindrical_manifold(direction, axial_point);
TransfiniteInterpolationManifold<3> inner_manifold;
inner_manifold.initialize(tria);
tria.set_manifold(0, SphericalManifold<2>(p));
if (internal_manifolds)
tria.set_manifold(1, SphericalManifold<2>(p));
+ else
+ tria.set_manifold(1, FlatManifold<2>());
}
SphericalManifold<dim> inner_manifold(inner_center);
SphericalManifold<dim> outer_manifold(outer_center);
+ tria.set_manifold(0, FlatManifold<dim>());
+ tria.set_manifold(1, FlatManifold<dim>());
+ tria.set_manifold(2, FlatManifold<dim>());
TransfiniteInterpolationManifold<dim> transfinite;
transfinite.initialize(tria);
tria.set_manifold(0, SphericalManifold<3>(p));
if (internal_manifold)
tria.set_manifold(1, SphericalManifold<3>(p));
+ else
+ tria.set_manifold(1, FlatManifold<3>());
}
cell->set_all_manifold_ids(numbers::flat_manifold_id);
GridTools::shift(p, tria);
+ tria.set_manifold(1, FlatManifold<dim>());
+
tria.set_all_manifold_ids_on_boundary(0);
tria.set_manifold(0, SphericalManifold<dim>(p));
}
}
out_tria.create_triangulation(v, cells, subcelldata);
+
+ for (const auto i : out_tria.get_manifold_ids())
+ if (i != numbers::flat_manifold_id)
+ out_tria.set_manifold(i, FlatManifold<dim, spacedim2>());
}
}
}
+ out_tria.clear();
out_tria.create_triangulation(vertices, cells, subcell_data);
+
+ for (const auto i : out_tria.get_manifold_ids())
+ if (i != numbers::flat_manifold_id)
+ out_tria.set_manifold(i, FlatManifold<dim, spacedim>());
}
surface_to_volume_mapping[temporary_map_boundary_cell_face[i].first] =
temporary_map_boundary_cell_face[i].second.first;
+ // TODO: we attach flat manifolds here; one should attach submanifolds here
+ const auto attached_mids =
+ surface_mesh.get_triangulation().get_manifold_ids();
+ for (const auto i : volume_mesh.get_triangulation().get_manifold_ids())
+ if (i != numbers::flat_manifold_id &&
+ std::find(attached_mids.begin(), attached_mids.end(), i) ==
+ attached_mids.end())
+ const_cast<Triangulation<dim - 1, spacedim> &>(
+ surface_mesh.get_triangulation())
+ .set_manifold(i, FlatManifold<dim - 1, spacedim>());
+
return surface_to_volume_mapping;
}
for (unsigned int p = 0; p < n_pipes; ++p)
tria.set_manifold(p, manifolds[p]);
+ tria.set_manifold(n_pipes, FlatManifold<3>());
// Since GridGenerator::merge_triangulations() does not copy boundary IDs
// either, we need to set them after the final geometry is created. Luckily,
AssertIndexRange(m_number, numbers::flat_manifold_id);
// delete the entry located at number.
- manifolds.erase(m_number);
+ manifolds[m_number] =
+ internal::TriangulationImplementation::get_default_flat_manifold<dim,
+ spacedim>()
+ .clone();
}
DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim<dim, spacedim>))
void Triangulation<dim, spacedim>::reset_all_manifolds()
{
- manifolds.clear();
+ for (auto &m : manifolds)
+ m.second = internal::TriangulationImplementation::
+ get_default_flat_manifold<dim, spacedim>()
+ .clone();
}
const Manifold<dim, spacedim> &Triangulation<dim, spacedim>::get_manifold(
const types::manifold_id m_number) const
{
+ // check if flat manifold has been queried
+ if (m_number == numbers::flat_manifold_id)
+ return internal::TriangulationImplementation::
+ get_default_flat_manifold<dim, spacedim>();
+
// look, if there is a manifold stored at
// manifold_id number.
const auto it = manifolds.find(m_number);
return *(it->second);
}
- // if we have not found an entry connected with number, we return
- // the default (flat) manifold
+ Assert(
+ false,
+ ExcMessage(
+ "No manifold of the manifold id " + std::to_string(m_number) +
+ " has been attached to the triangulation. "
+ "Please attach the right manifold with Triangulation::set_manifold()."));
+
return internal::TriangulationImplementation::
- get_default_flat_manifold<dim, spacedim>();
+ get_default_flat_manifold<dim, spacedim>(); // never reached
}
GridGenerator::extract_boundary_mesh(volume_mesh,
boundary_mesh,
boundary_ids);
+ boundary_mesh.set_manifold(1, FlatManifold<dim - 1, dim>());
deallog << volume_mesh.n_active_cells() << std::endl;
deallog << boundary_mesh.n_active_cells() << std::endl;
#include <deal.II/grid/grid_generator.h>
#include <deal.II/grid/grid_out.h>
#include <deal.II/grid/grid_tools.h>
+#include <deal.II/grid/manifold.h>
#include <deal.II/grid/manifold_lib.h>
#include <deal.II/grid/tria.h>
Triangulation<dim - 1, dim> boundary_mesh;
+ for (const auto bid : volume_mesh.get_manifold_ids())
+ if (bid != numbers::flat_manifold_id)
+ boundary_mesh.set_manifold(bid, FlatManifold<2, 3>());
+
surface_to_volume_mapping =
GridGenerator::extract_boundary_mesh(volume_mesh, boundary_mesh);
#include <deal.II/grid/grid_generator.h>
#include <deal.II/grid/grid_out.h>
+#include <deal.II/grid/manifold.h>
#include <deal.II/grid/tria.h>
#include "../tests.h"
GridOut().write_gnuplot(triangulation, deallog.get_file_stream());
Triangulation<dim - 1, dim> triangulation_surface;
+
+ for (const auto bid : triangulation.get_manifold_ids())
+ if (bid != numbers::flat_manifold_id)
+ triangulation_surface.set_manifold(bid, FlatManifold<2, 3>());
+
GridGenerator::extract_boundary_mesh(triangulation, triangulation_surface);
triangulation_surface.refine_global(2);
// now extract the surface mesh
Triangulation<dim - 1, dim> triangulation_surface;
+ for (const auto bid : triangulation.get_manifold_ids())
+ if (bid != numbers::flat_manifold_id)
+ triangulation_surface.set_manifold(bid, FlatManifold<2, 3>());
+
static const CylindricalManifold<dim - 1, dim> surface_cyl(0);
triangulation_surface.set_manifold(0, surface_cyl);
// now extract the surface mesh
Triangulation<dim - 1, dim> triangulation_surface;
+ for (const auto bid : triangulation.get_manifold_ids())
+ if (bid != numbers::flat_manifold_id)
+ triangulation_surface.set_manifold(bid, FlatManifold<2, 3>());
+
static const CylindricalManifold<dim - 1, dim> surface_cyl(0);
triangulation_surface.set_manifold(0, surface_cyl);
#include <deal.II/grid/grid_generator.h>
#include <deal.II/grid/grid_out.h>
#include <deal.II/grid/grid_tools.h>
+#include <deal.II/grid/manifold.h>
#include <deal.II/grid/manifold_lib.h>
#include <deal.II/grid/tria.h>
cell->face(f)->set_manifold_id(cell->face(f)->boundary_id());
}
+ for (const auto bid : triangulation.get_manifold_ids())
+ if (bid != numbers::flat_manifold_id)
+ triangulation.set_manifold(bid, FlatManifold<3>());
+
static const CylindricalManifold<dim> outer_cylinder(0);
triangulation.set_manifold(0, outer_cylinder);
// now extract the surface mesh
Triangulation<dim - 1, dim> triangulation_surface;
+ for (const auto bid : triangulation.get_manifold_ids())
+ if (bid != numbers::flat_manifold_id)
+ triangulation_surface.set_manifold(bid, FlatManifold<2, 3>());
+
static const CylindricalManifold<dim - 1, dim> surface_cyl(0);
triangulation_surface.set_manifold(0, surface_cyl);
GridGenerator::subdivided_hyper_rectangle(tr, subdivisions, p1, p2);
GridTools::copy_boundary_to_manifold_id(tr);
+ for (const auto bid : tr.get_boundary_ids())
+ tr.set_manifold(bid, FlatManifold<dim>());
+
static const SphericalManifold<dim> boundary(tr.begin_active()->center());
tr.set_manifold(1, boundary);
#include <deal.II/grid/grid_generator.h>
#include <deal.II/grid/grid_out.h>
+#include <deal.II/grid/manifold.h>
#include <deal.II/grid/manifold_lib.h>
#include <deal.II/grid/tria.h>
Triangulation<3> triangulation_3;
GridGenerator::extrude_triangulation(
triangulation_2, 3, 1.0, triangulation_3, true);
+ triangulation_3.set_manifold(0, FlatManifold<3>());
+ triangulation_3.set_manifold(1, FlatManifold<3>());
TransfiniteInterpolationManifold<3> tfi_manifold;
tfi_manifold.initialize(triangulation_3);
CylindricalManifold<3> cylinder_manifold(2);
#include <deal.II/grid/grid_generator.h>
#include <deal.II/grid/grid_out.h>
#include <deal.II/grid/grid_tools.h>
+#include <deal.II/grid/manifold.h>
#include <deal.II/grid/tria.h>
#include "../tests.h"
static_cast<types::material_id>(10.0 * (3.0 + cell->center()[0])));
for (auto face : tria.active_face_iterators())
if (0.5 < face->center()[0])
- face->set_all_manifold_ids(42);
+ {
+ face->set_all_manifold_ids(42);
+ tria.set_manifold(42, FlatManifold<1>());
+ }
for (auto &cell : tria.active_cell_iterators())
- cell->set_manifold_id(
- static_cast<types::material_id>(10.0 * (2.0 + cell->center()[0])));
+ {
+ const auto bid =
+ static_cast<types::material_id>(10.0 * (2.0 + cell->center()[0]));
+ cell->set_manifold_id(bid);
+ tria.set_manifold(bid, FlatManifold<1>());
+ }
}
// detail that unassigned manifolds are flat.
for (auto face : tria.active_face_iterators())
if (-0.1 < face->center()[0])
- face->set_all_manifold_ids(42);
+ {
+ face->set_all_manifold_ids(42);
+ tria.set_manifold(42, FlatManifold<dim>());
+ }
for (auto &cell : tria.active_cell_iterators())
if (cell->center() != Point<dim>())
{
const double angle = std::atan2(cell->center()[0], cell->center()[1]);
- cell->set_manifold_id(
- static_cast<types::material_id>(361 - angle * 180.0 / numbers::PI));
+
+ const auto bid =
+ static_cast<types::material_id>(361 - angle * 180.0 / numbers::PI);
+ cell->set_manifold_id(bid);
+ tria.set_manifold(bid, FlatManifold<dim>());
}
}
tria_2.create_triangulation(vertices, cells, subcell_data);
Assert(GridTools::have_same_coarse_mesh(tria, tria_2), ExcInternalError());
+ for (const auto bid : tria_2.get_manifold_ids())
+ if (bid != numbers::flat_manifold_id)
+ tria_2.set_manifold(bid, FlatManifold<dim>());
+
GridOut grid_out;
deallog << "Original Triangulation:" << std::endl;
grid_out.write_vtk(tria, deallog.get_file_stream());
tria.reset_manifold(0);
tria.set_all_manifold_ids(numbers::flat_manifold_id);
GridTools::copy_boundary_to_manifold_id(tria);
+
+ for (const auto bid : tria.get_boundary_ids())
+ tria.set_manifold(bid, FlatManifold<dim>());
+
if (dim == 3)
for (typename Triangulation<dim>::active_cell_iterator c =
tria.begin_active();
GridTools::copy_boundary_to_manifold_id(tria);
+ for (const auto bid : tria.get_boundary_ids())
+ tria.set_manifold(bid, FlatManifold<2>());
+
tria.set_manifold(0, m0);
tria.set_manifold(1, m1);
PolarManifold<2> polar_manifold(Point<2>(0.2, 0.2));
result_2.set_manifold(polar_id, polar_manifold);
+ result_2.set_manifold(tfi_id, FlatManifold<2>());
TransfiniteInterpolationManifold<2> inner_manifold;
inner_manifold.initialize(result_2);
result_2.set_manifold(tfi_id, inner_manifold);
void
print_tria_info(const Triangulation<dim> &tria)
{
+ const std::vector<types::manifold_id> bids =
+ tria.n_active_cells() == 0 ? std::vector<types::manifold_id>() :
+ tria.get_manifold_ids();
+
const bool manifold_0_is_flat =
+ (std::find(bids.begin(), bids.end(), 0) == bids.end()) ||
dynamic_cast<const FlatManifold<dim> *>(&tria.get_manifold(0)) != nullptr;
+
deallog << (tria.n_active_cells() != 0) << ", " << (tria.n_active_hexs() != 0)
<< ", " << (tria.n_active_quads() != 0) << ", "
<< (tria.n_active_lines() != 0) << ", " << (tria.n_levels() != 0)
GridGenerator::hyper_ball(triangulation, center, radius);
triangulation.set_all_manifold_ids(circular_manifold_id);
triangulation.set_manifold(circular_manifold_id, *boundary);
+ triangulation.set_manifold(straight_manifold_id, FlatManifold<dim>());
const double core_radius = 1.0 / 4.8 * radius;
const double inner_radius = 1.0 / 2.4 * radius;
typename Triangulation<dim, spacedim>::active_cell_iterator cell;
tria.begin_active()->set_all_manifold_ids(1);
+ tria.set_manifold(1, FlatManifold<dim, spacedim>());
+
tria.refine_global(ref);
for (cell = tria.begin_active(); cell != tria.end(); ++cell)
tria.begin_active()->set_manifold_id(1);
+ tria.set_manifold(1, FlatManifold<dim, spacedim>());
tria.refine_global(1);
for (const unsigned int f : GeometryInfo<dim>::face_indices())
tria.begin_active()->face(f)->set_manifold_id(2);
+ tria.set_manifold(1, FlatManifold<dim, spacedim>());
+ tria.set_manifold(2, FlatManifold<dim, spacedim>());
+ tria.set_manifold(3, FlatManifold<dim, spacedim>());
+
tria.refine_global(1);
for (cell = tria.begin_active(); cell != tria.end(); ++cell)
// Make sure that Triangulation::get_manifold_ids() work correctly
#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/manifold_lib.h>
#include <deal.II/grid/tria.h>
#include "../tests.h"
tria.begin_active()->line(0)->set_manifold_id(3);
+ tria.set_manifold(1, FlatManifold<dim>());
+ tria.set_manifold(2, FlatManifold<dim>());
+ tria.set_manifold(3, FlatManifold<dim>());
+
tria.refine_global(ref);
for (cell = tria.begin_active(); cell != tria.end(); ++cell)
cell->set_all_manifold_ids(0);
}
+ tria.set_manifold(0, FlatManifold<dim, spacedim>());
tria.set_manifold(1, manifold);
tria.refine_global(2);
if (Point<2>(X_C, Y_C).distance(cell->center()) <= R_2)
cell->set_all_manifold_ids(MANIFOLD_ID);
}
+ tria.set_manifold(MANIFOLD_ID, FlatManifold<2>());
}
void
if (Point<3>(X_C, Y_C, cell->center()[2]).distance(cell->center()) <= R_2)
cell->set_all_manifold_ids(MANIFOLD_ID);
}
+ tria.set_manifold(0, FlatManifold<3>());
+ tria.set_manifold(MANIFOLD_ID, FlatManifold<3>());
}
template <int dim>
#include <deal.II/grid/grid_generator.h>
#include <deal.II/grid/grid_tools.h>
+#include <deal.II/grid/manifold.h>
#include <deal.II/grid/manifold_lib.h>
#include <deal.II/lac/affine_constraints.h>
triangulation.set_all_manifold_ids(numbers::flat_manifold_id);
GridTools::copy_boundary_to_manifold_id(triangulation);
+ for (const auto bid : triangulation.get_boundary_ids())
+ triangulation.set_manifold(bid, FlatManifold<dim>());
+
#ifdef PERIODIC
std::vector<GridTools::PeriodicFacePair<
typename parallel::distributed::Triangulation<dim>::cell_iterator>>
#include <deal.II/grid/grid_generator.h>
#include <deal.II/grid/grid_out.h>
#include <deal.II/grid/grid_tools.h>
+#include <deal.II/grid/manifold.h>
#include <deal.II/grid/manifold_lib.h>
#include <deal.II/grid/tria.h>
sixty_deg_hyper_shell(triangulation, Point<dim>(), 0.5, 1.0);
GridTools::copy_boundary_to_manifold_id(triangulation);
+ for (unsigned int d = 0; d < 2 * dim; ++d)
+ triangulation.set_manifold(d, FlatManifold<dim>());
+
static SphericalManifold<dim> boundary((Point<dim>()));
triangulation.set_manifold(0, boundary);
// points created in the interior
// of the face.
tria.begin()->set_manifold_id(1);
+ tria.set_manifold(1, FlatManifold<2, 3>());
// We refine twice, and expect the
// outer points to end up on the
// This is here to ignore the points created in the interior of the
// face.
tria.begin()->set_manifold_id(1);
+ tria.set_manifold(1, FlatManifold<2, 3>());
// We refine twice, and expect the outer points to end up on a
// smooth curve interpolating the square vertices.
// This is here to ignore the points created in the interior of the
// face.
tria.begin()->set_manifold_id(1);
+ tria.set_manifold(1, FlatManifold<2, 3>());
// We refine twice, and expect the outer points to end up on a
// smooth curve interpolating the square vertices.
// of the face.
tria.begin()->set_all_manifold_ids(1);
tria.begin()->set_manifold_id(0);
+ tria.set_manifold(0, FlatManifold<3>());
tria.refine_global(2);
#include <deal.II/fe/mapping_fe.h>
#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/manifold_lib.h>
#include <deal.II/grid/tria.h>
#include <deal.II/grid/tria_accessor.h>
#include <deal.II/grid/tria_iterator.h>
GridGenerator::convert_hypercube_to_simplex_mesh(triangulation_temp,
triangulation);
+ triangulation.set_manifold(0, FlatManifold<2>());
}
int
GridGenerator::convert_hypercube_to_simplex_mesh(triangulation_temp,
triangulation);
+ for (const auto i : triangulation_temp.get_manifold_ids())
+ if (i != numbers::flat_manifold_id)
+ triangulation.set_manifold(i, triangulation_temp.get_manifold(i));
triangulation.refine_global(); // WARNING: no local refinement is performed
}
GridGenerator::convert_hypercube_to_simplex_mesh(
temporary_quad_particle_triangulation,
temporary_tri_particle_triangulation);
+ temporary_tri_particle_triangulation.set_manifold(0, FlatManifold<dim>());
// extract relevant information from distributed triangulation
parallel::fullydistributed::Triangulation<dim> particle_triangulation(
mpi_communicator);
particle_triangulation.create_triangulation(particle_construction_data);
+ particle_triangulation.set_manifold(0, FlatManifold<dim>());
// We generate the necessary bounding boxes for the particles generator.
// These bounding boxes are required to quickly identify in which