From e4575d26d9f5fed7ef5ac30b46a2d5faefe86619 Mon Sep 17 00:00:00 2001 From: Elias Dejene Date: Sat, 2 Jan 2021 13:14:44 +0100 Subject: [PATCH] Add tutorial step-01 based on simplices. --- tests/simplex/step-01.cc | 110 +++ .../step-01.with_simplex_support=on.output | 643 ++++++++++++++++++ 2 files changed, 753 insertions(+) create mode 100644 tests/simplex/step-01.cc create mode 100644 tests/simplex/step-01.with_simplex_support=on.output diff --git a/tests/simplex/step-01.cc b/tests/simplex/step-01.cc new file mode 100644 index 0000000000..b9a41e2418 --- /dev/null +++ b/tests/simplex/step-01.cc @@ -0,0 +1,110 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2020 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. +// +// --------------------------------------------------------------------- + + +// Step-01 on a simplex mesh. Following incompatible modifications had to be +// made: +// - Replace or convert triangulation to a simplex based triangulation. +// - Copy manifolds after conversion to simplex based triangulation in order +// to execute refinement. + + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include "../tests.h" + +using namespace dealii; + +void +first_grid() +{ + Triangulation<2> triangulation; + GridGenerator::subdivided_hyper_cube_with_simplices(triangulation, 1); + triangulation.refine_global(2); + + GridOut grid_out; + grid_out.write_svg(triangulation, deallog.get_file_stream()); + deallog << "Grid written to grid-1.svg" << std::endl; +} + + + +void +second_grid() +{ + Triangulation<2> tria_temp, triangulation; + + const Point<2> center(1, 0); + const double inner_radius = 0.5, outer_radius = 1.0; + GridGenerator::hyper_shell(tria_temp, center, inner_radius, outer_radius, 10); + + // convert mesh to a simplex mesh and copy manually the attached manifolds + GridGenerator::convert_hypercube_to_simplex_mesh(tria_temp, triangulation); + for (const auto i : tria_temp.get_manifold_ids()) + if (i != numbers::flat_manifold_id) + triangulation.set_manifold(i, tria_temp.get_manifold(i)); + + for (unsigned int step = 0; step < 2; ++step) + { + for (auto &cell : triangulation.active_cell_iterators()) + { + for (const auto v : cell->vertex_indices()) + { + const double distance_from_center = + center.distance(cell->vertex(v)); + + if (std::fabs(distance_from_center - inner_radius) <= + 1e-6 * inner_radius) + { + cell->set_refine_flag(); + break; + } + } + } + + triangulation.execute_coarsening_and_refinement(); + } + + GridOut grid_out; +#if false + std::ofstream out("mesh.svg"); + grid_out.write_svg(triangulation, out); +#else + grid_out.write_svg(triangulation, deallog.get_file_stream()); +#endif + + deallog << "Grid written to grid-2.svg" << std::endl; +} + + + +int +main() +{ + initlog(); + + first_grid(); + second_grid(); +} diff --git a/tests/simplex/step-01.with_simplex_support=on.output b/tests/simplex/step-01.with_simplex_support=on.output new file mode 100644 index 0000000000..ce62528217 --- /dev/null +++ b/tests/simplex/step-01.with_simplex_support=on.output @@ -0,0 +1,643 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +DEAL::Grid written to grid-1.svg + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +DEAL::Grid written to grid-2.svg -- 2.39.5