From: Luca Heltai Date: Mon, 23 Apr 2018 15:28:41 +0000 (+0200) Subject: Added test. X-Git-Tag: v9.0.0-rc1~129^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d536df1e89dde09fe640f84eaadfd281d922f0c;p=dealii.git Added test. --- diff --git a/tests/grid/grid_tools_min_max_diameter_01.cc b/tests/grid/grid_tools_min_max_diameter_01.cc new file mode 100644 index 0000000000..5cfbdfb8ec --- /dev/null +++ b/tests/grid/grid_tools_min_max_diameter_01.cc @@ -0,0 +1,87 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2018 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. +// +// --------------------------------------------------------------------- + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define PRECISION 2 + +template +void test(const unsigned int degree) +{ + deallog << "dim = " << dim << ", spacedim = " << spacedim << std::endl; + deallog << "degree = " << degree << std::endl; + + Triangulation tria; + GridGenerator::hyper_cube(tria, 0., 1.); + tria.refine_global (1); + tria.begin_active()->set_refine_flag(); + tria.execute_coarsening_and_refinement(); + + FE_Q fe(degree); + FESystem fe_sys(fe, spacedim); + + DoFHandler dof_sys(tria); + dof_sys.distribute_dofs(fe_sys); + + Vector euler; + euler.reinit(dof_sys.n_dofs()); + const ComponentMask mask(spacedim, true); + + VectorTools::get_position_vector(dof_sys, euler, mask); + + // By using MappingQEulerian with the position vector, we are making everything + // bigger by a factor 2. + MappingQEulerian, spacedim> map_fe(degree, dof_sys, euler); + + deallog << "Min diameter : " << GridTools::minimal_cell_diameter(tria) << std::endl + << "Max diameter : " << GridTools::maximal_cell_diameter(tria) << std::endl + << "Min mapped diameter : " << GridTools::minimal_cell_diameter(tria,map_fe) << std::endl + << "Max mapped diameter : " << GridTools::maximal_cell_diameter(tria,map_fe) << std::endl; +} + +int main() +{ + initlog(); + + for (unsigned int d=1; d<4; ++d) + { + test<2,2>(d); + test<2,3>(d); + test<3,3>(d); + } +} diff --git a/tests/grid/grid_tools_min_max_diameter_01.output b/tests/grid/grid_tools_min_max_diameter_01.output new file mode 100644 index 0000000000..102920769f --- /dev/null +++ b/tests/grid/grid_tools_min_max_diameter_01.output @@ -0,0 +1,55 @@ + +DEAL::dim = 2, spacedim = 2 +DEAL::degree = 1 +DEAL::Min diameter : 0.353553 +DEAL::Max diameter : 0.707107 +DEAL::Min mapped diameter : 0.707107 +DEAL::Max mapped diameter : 1.41421 +DEAL::dim = 2, spacedim = 3 +DEAL::degree = 1 +DEAL::Min diameter : 0.353553 +DEAL::Max diameter : 0.707107 +DEAL::Min mapped diameter : 0.707107 +DEAL::Max mapped diameter : 1.41421 +DEAL::dim = 3, spacedim = 3 +DEAL::degree = 1 +DEAL::Min diameter : 0.433013 +DEAL::Max diameter : 0.866025 +DEAL::Min mapped diameter : 0.866025 +DEAL::Max mapped diameter : 1.73205 +DEAL::dim = 2, spacedim = 2 +DEAL::degree = 2 +DEAL::Min diameter : 0.353553 +DEAL::Max diameter : 0.707107 +DEAL::Min mapped diameter : 0.707107 +DEAL::Max mapped diameter : 1.41421 +DEAL::dim = 2, spacedim = 3 +DEAL::degree = 2 +DEAL::Min diameter : 0.353553 +DEAL::Max diameter : 0.707107 +DEAL::Min mapped diameter : 0.707107 +DEAL::Max mapped diameter : 1.41421 +DEAL::dim = 3, spacedim = 3 +DEAL::degree = 2 +DEAL::Min diameter : 0.433013 +DEAL::Max diameter : 0.866025 +DEAL::Min mapped diameter : 0.866025 +DEAL::Max mapped diameter : 1.73205 +DEAL::dim = 2, spacedim = 2 +DEAL::degree = 3 +DEAL::Min diameter : 0.353553 +DEAL::Max diameter : 0.707107 +DEAL::Min mapped diameter : 0.707107 +DEAL::Max mapped diameter : 1.41421 +DEAL::dim = 2, spacedim = 3 +DEAL::degree = 3 +DEAL::Min diameter : 0.353553 +DEAL::Max diameter : 0.707107 +DEAL::Min mapped diameter : 0.707107 +DEAL::Max mapped diameter : 1.41421 +DEAL::dim = 3, spacedim = 3 +DEAL::degree = 3 +DEAL::Min diameter : 0.433013 +DEAL::Max diameter : 0.866025 +DEAL::Min mapped diameter : 0.866025 +DEAL::Max mapped diameter : 1.73205