From eb3250074eaa59ba669f00f154cebca2ea0d6304 Mon Sep 17 00:00:00 2001 From: Luca Heltai Date: Sun, 12 Apr 2015 19:18:26 +0200 Subject: [PATCH] Added test for 2,3. --- tests/grid/grid_generator_08.cc | 105 ++++++++++++++++++++++++++++ tests/grid/grid_generator_08.output | 82 ++++++++++++++++++++++ 2 files changed, 187 insertions(+) create mode 100644 tests/grid/grid_generator_08.cc create mode 100644 tests/grid/grid_generator_08.output diff --git a/tests/grid/grid_generator_08.cc b/tests/grid/grid_generator_08.cc new file mode 100644 index 0000000000..740b483ea5 --- /dev/null +++ b/tests/grid/grid_generator_08.cc @@ -0,0 +1,105 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2005 - 2015 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 at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + + +// Test grid generation functions in GridGenerator for spacedim>dim + +#include "../tests.h" +#include +#include +#include +#include +#include + +#include +#include + + +template +void test(std::ostream &out) +{ + Point p1; + p1[0] = 2.; + if (dim>1) p1[1] = -1.; + if (dim>2) p1[2] = 0.; + Point p2; + p2[0] = 3.; + if (dim>1) p2[1] = 2.; + if (dim>2) p2[2] = 4.; + Point p3; + p3[0] = 2.; + if (dim>1) p3[1] = 1.; + if (dim>2) p3[2] = 4.; + + GridOut go; + GridOut::OutputFormat format = GridOut::msh; + + if (true) + { + deallog << "hyper_cube" << std::endl; + Triangulation tr; + GridGenerator::hyper_cube(tr, 3., 7.); + if (tr.n_cells() > 0) + go.write(tr, out, format); + } + if (true) + { + deallog << "subdivided_hyper_cube" << std::endl; + Triangulation tr; + GridGenerator::subdivided_hyper_cube(tr, 3, 1., 7.); + if (tr.n_cells() > 0) + go.write(tr, out, format); + } + if (true) + { + deallog << "hyper_rectangle" << std::endl; + Triangulation tr; + GridGenerator::hyper_rectangle(tr, p1, p2, true); + if (tr.n_cells() > 0) + go.write(tr, out, format); + } + if (true) + { + deallog << "subdivided_hyper_rectangle" << std::endl; + Triangulation tr; + std::vector sub(dim); + sub[0] = 2; + if (dim>1) sub[1] = 3; + if (dim>2) sub[2] = 4; + GridGenerator::subdivided_hyper_rectangle(tr, sub, p1, p2, true); + if (tr.n_cells() > 0) + go.write(tr, out, format); + } +} + + +int main() +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + +// deallog.push("1d"); +// test<1,2>(logfile); +// deallog.pop(); +// deallog.push("2d"); +// test<1,3>(logfile); +// deallog.pop(); + deallog.push("2-3"); + test<2,3>(logfile); + deallog.pop(); +} diff --git a/tests/grid/grid_generator_08.output b/tests/grid/grid_generator_08.output new file mode 100644 index 0000000000..455c752ba9 --- /dev/null +++ b/tests/grid/grid_generator_08.output @@ -0,0 +1,82 @@ + +DEAL:2-3::hyper_cube +$NOD +4 +1 3.00000 3.00000 0.00000 +2 7.00000 3.00000 0.00000 +3 3.00000 7.00000 0.00000 +4 7.00000 7.00000 0.00000 +$ENDNOD +$ELM +1 +1 3 0 0 4 1 2 4 3 +$ENDELM +DEAL:2-3::subdivided_hyper_cube +$NOD +16 +1 1.00000 1.00000 0.00000 +2 3.00000 1.00000 0.00000 +3 5.00000 1.00000 0.00000 +4 7.00000 1.00000 0.00000 +5 1.00000 3.00000 0.00000 +6 3.00000 3.00000 0.00000 +7 5.00000 3.00000 0.00000 +8 7.00000 3.00000 0.00000 +9 1.00000 5.00000 0.00000 +10 3.00000 5.00000 0.00000 +11 5.00000 5.00000 0.00000 +12 7.00000 5.00000 0.00000 +13 1.00000 7.00000 0.00000 +14 3.00000 7.00000 0.00000 +15 5.00000 7.00000 0.00000 +16 7.00000 7.00000 0.00000 +$ENDNOD +$ELM +9 +1 3 0 0 4 1 2 6 5 +2 3 0 0 4 2 3 7 6 +3 3 0 0 4 3 4 8 7 +4 3 0 0 4 5 6 10 9 +5 3 0 0 4 6 7 11 10 +6 3 0 0 4 7 8 12 11 +7 3 0 0 4 9 10 14 13 +8 3 0 0 4 10 11 15 14 +9 3 0 0 4 11 12 16 15 +$ENDELM +DEAL:2-3::hyper_rectangle +$NOD +4 +1 2.00000 -1.00000 0.00000 +2 3.00000 -1.00000 0.00000 +3 2.00000 2.00000 0.00000 +4 3.00000 2.00000 0.00000 +$ENDNOD +$ELM +1 +1 3 0 0 4 1 2 4 3 +$ENDELM +DEAL:2-3::subdivided_hyper_rectangle +$NOD +12 +1 2.00000 -1.00000 0.00000 +2 2.50000 -1.00000 0.00000 +3 3.00000 -1.00000 0.00000 +4 2.00000 0.00000 0.00000 +5 2.50000 0.00000 0.00000 +6 3.00000 0.00000 0.00000 +7 2.00000 1.00000 0.00000 +8 2.50000 1.00000 0.00000 +9 3.00000 1.00000 0.00000 +10 2.00000 2.00000 0.00000 +11 2.50000 2.00000 0.00000 +12 3.00000 2.00000 0.00000 +$ENDNOD +$ELM +6 +1 3 1 0 4 1 2 5 4 +2 3 1 0 4 2 3 6 5 +3 3 3 0 4 4 5 8 7 +4 3 3 0 4 5 6 9 8 +5 3 3 0 4 7 8 11 10 +6 3 3 0 4 8 9 12 11 +$ENDELM -- 2.39.5