From: Peter Munch Date: Tue, 19 Oct 2021 21:40:20 +0000 (+0200) Subject: DataOut: add wedge/pyramid test X-Git-Tag: v9.4.0-rc1~914^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=943f78b71330709ced851935148ed0d938879517;p=dealii.git DataOut: add wedge/pyramid test --- diff --git a/tests/simplex/data_out_write_vtk_04.cc b/tests/simplex/data_out_write_vtk_04.cc new file mode 100644 index 0000000000..8437faf328 --- /dev/null +++ b/tests/simplex/data_out_write_vtk_04.cc @@ -0,0 +1,118 @@ +// --------------------------------------------------------------------- +// +// 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. +// +// --------------------------------------------------------------------- + + + +// Test DataOut::write_vtk() for wedge and pyramid meshes. + +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include "../tests.h" + +#include "simplex_grids.h" + +using namespace dealii; + +template +class RightHandSideFunction : public Function +{ +public: + RightHandSideFunction(const unsigned int n_components) + : Function(n_components) + {} + + virtual double + value(const Point &p, const unsigned int component = 0) const + { + return p[component % dim] * p[component % dim]; + } +}; + +template +void +test(const FiniteElement & fe, + const std::function &)> &fu) +{ + Triangulation tria; + fu(tria); + + DoFHandler dof_handler(tria); + dof_handler.distribute_dofs(fe); + + Vector solution(dof_handler.n_dofs()); + VectorTools::interpolate(dof_handler, + RightHandSideFunction(fe.n_components()), + solution); + + static unsigned int counter = 0; + + for (unsigned int i = 0; i <= 1; ++i) + { + DataOut data_out; + + if (i == 0) + { + data_out.attach_dof_handler(dof_handler); + data_out.add_data_vector(solution, "solution"); + } + else + { + data_out.attach_triangulation(tria); + } + + data_out.build_patches(); + +#if 0 + std::ofstream output("test." + std::to_string(dim) + "." + + std::to_string(counter++) + ".vtk"); + data_out.write_vtk(output); +#else + data_out.write_vtk(deallog.get_file_stream()); +#endif + } +} + +int +main() +{ + initlog(); + + // test wedges + test<3, 3>(FE_WedgeP<3>(1), [](auto &tria) { + GridGenerator::subdivided_hyper_cube_with_wedges(tria, 1); + }); + + // test pyramids + test<3, 3>(FE_PyramidP<3>(1), [](auto &tria) { + GridGenerator::subdivided_hyper_cube_with_pyramids(tria, 1); + }); +} diff --git a/tests/simplex/data_out_write_vtk_04.output b/tests/simplex/data_out_write_vtk_04.output new file mode 100644 index 0000000000..f65b314b34 --- /dev/null +++ b/tests/simplex/data_out_write_vtk_04.output @@ -0,0 +1,155 @@ + +# vtk DataFile Version 3.0 +#This file was generated +ASCII +DATASET UNSTRUCTURED_GRID + +POINTS 12 double +0.00000 0.00000 0.00000 +1.00000 0.00000 0.00000 +0.00000 1.00000 0.00000 +0.00000 0.00000 1.00000 +1.00000 0.00000 1.00000 +0.00000 1.00000 1.00000 +1.00000 1.00000 0.00000 +0.00000 1.00000 0.00000 +1.00000 0.00000 0.00000 +1.00000 1.00000 1.00000 +0.00000 1.00000 1.00000 +1.00000 0.00000 1.00000 + +CELLS 2 14 + 6 0 1 2 3 4 5 + 6 6 7 8 9 10 11 + +CELL_TYPES 2 + 13 13 +POINT_DATA 12 +SCALARS solution double 1 +LOOKUP_TABLE default +0.00000 1.00000 0.00000 0.00000 1.00000 0.00000 1.00000 0.00000 1.00000 1.00000 0.00000 1.00000 +# vtk DataFile Version 3.0 +#This file was generated +ASCII +DATASET UNSTRUCTURED_GRID + +POINTS 12 double +0.00000 0.00000 0.00000 +1.00000 0.00000 0.00000 +0.00000 1.00000 0.00000 +0.00000 0.00000 1.00000 +1.00000 0.00000 1.00000 +0.00000 1.00000 1.00000 +1.00000 1.00000 0.00000 +0.00000 1.00000 0.00000 +1.00000 0.00000 0.00000 +1.00000 1.00000 1.00000 +0.00000 1.00000 1.00000 +1.00000 0.00000 1.00000 + +CELLS 2 14 + 6 0 1 2 3 4 5 + 6 6 7 8 9 10 11 + +CELL_TYPES 2 + 13 13 +POINT_DATA 12 +# vtk DataFile Version 3.0 +#This file was generated +ASCII +DATASET UNSTRUCTURED_GRID + +POINTS 30 double +0.00000 0.00000 0.00000 +0.00000 1.00000 0.00000 +0.00000 1.00000 1.00000 +0.00000 0.00000 1.00000 +0.500000 0.500000 0.500000 +0.00000 1.00000 0.00000 +1.00000 1.00000 0.00000 +1.00000 1.00000 1.00000 +0.00000 1.00000 1.00000 +0.500000 0.500000 0.500000 +0.00000 1.00000 1.00000 +1.00000 1.00000 1.00000 +1.00000 0.00000 1.00000 +0.00000 0.00000 1.00000 +0.500000 0.500000 0.500000 +1.00000 0.00000 0.00000 +1.00000 0.00000 1.00000 +1.00000 1.00000 1.00000 +1.00000 1.00000 0.00000 +0.500000 0.500000 0.500000 +0.00000 0.00000 0.00000 +1.00000 0.00000 0.00000 +1.00000 1.00000 0.00000 +0.00000 1.00000 0.00000 +0.500000 0.500000 0.500000 +0.00000 0.00000 0.00000 +0.00000 0.00000 1.00000 +1.00000 0.00000 1.00000 +1.00000 0.00000 0.00000 +0.500000 0.500000 0.500000 + +CELLS 6 36 + 5 0 1 2 3 4 + 5 5 6 7 8 9 + 5 10 11 12 13 14 + 5 15 16 17 18 19 + 5 20 21 22 23 24 + 5 25 26 27 28 29 + +CELL_TYPES 6 + 14 14 14 14 14 14 +POINT_DATA 30 +SCALARS solution double 1 +LOOKUP_TABLE default +0.00000 0.00000 0.00000 0.00000 0.250000 0.00000 1.00000 1.00000 0.00000 0.250000 0.00000 1.00000 1.00000 0.00000 0.250000 1.00000 1.00000 1.00000 1.00000 0.250000 0.00000 1.00000 1.00000 0.00000 0.250000 0.00000 0.00000 1.00000 1.00000 0.250000 +# vtk DataFile Version 3.0 +#This file was generated +ASCII +DATASET UNSTRUCTURED_GRID + +POINTS 30 double +0.00000 0.00000 0.00000 +0.00000 1.00000 0.00000 +0.00000 1.00000 1.00000 +0.00000 0.00000 1.00000 +0.500000 0.500000 0.500000 +0.00000 1.00000 0.00000 +1.00000 1.00000 0.00000 +1.00000 1.00000 1.00000 +0.00000 1.00000 1.00000 +0.500000 0.500000 0.500000 +0.00000 1.00000 1.00000 +1.00000 1.00000 1.00000 +1.00000 0.00000 1.00000 +0.00000 0.00000 1.00000 +0.500000 0.500000 0.500000 +1.00000 0.00000 0.00000 +1.00000 0.00000 1.00000 +1.00000 1.00000 1.00000 +1.00000 1.00000 0.00000 +0.500000 0.500000 0.500000 +0.00000 0.00000 0.00000 +1.00000 0.00000 0.00000 +1.00000 1.00000 0.00000 +0.00000 1.00000 0.00000 +0.500000 0.500000 0.500000 +0.00000 0.00000 0.00000 +0.00000 0.00000 1.00000 +1.00000 0.00000 1.00000 +1.00000 0.00000 0.00000 +0.500000 0.500000 0.500000 + +CELLS 6 36 + 5 0 1 2 3 4 + 5 5 6 7 8 9 + 5 10 11 12 13 14 + 5 15 16 17 18 19 + 5 20 21 22 23 24 + 5 25 26 27 28 29 + +CELL_TYPES 6 + 14 14 14 14 14 14 +POINT_DATA 30