From: Wolfgang Bangerth Date: Tue, 10 Jan 2023 17:03:09 +0000 (-0700) Subject: Test output of a simplex cell with n_subdivisions=2. X-Git-Tag: v9.5.0-rc1~651^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=332a0a1e5abbf5df5e2af9f67b28351514665ab9;p=dealii.git Test output of a simplex cell with n_subdivisions=2. --- diff --git a/tests/data_out/write_subdivided_simplex_vtu.cc b/tests/data_out/write_subdivided_simplex_vtu.cc new file mode 100644 index 0000000000..f05b089036 --- /dev/null +++ b/tests/data_out/write_subdivided_simplex_vtu.cc @@ -0,0 +1,91 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2020 - 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_vtu() for a single simplex subdivided more than once. + +#include + +#include +#include + +#include +#include + +#include +#include + +#include "../tests.h" + +using namespace dealii; + +template +class RightHandSideFunction : public Function +{ +public: + virtual double + value(const Point &p, const unsigned int component = 0) const + { + return p * p; + } +}; + + +template +void +test() +{ + Triangulation tria; + GridGenerator::reference_cell(tria, ReferenceCells::get_simplex()); + + // Use a quadratic element; this can correctly represent the + // quadratic function we are interpolating + FE_SimplexP fe(2); + DoFHandler dof_handler(tria); + + dof_handler.distribute_dofs(fe); + + Vector solution(dof_handler.n_dofs()); + + MappingFE mapping(FE_SimplexP(1)); + + VectorTools::interpolate(mapping, + dof_handler, + RightHandSideFunction(), + solution); + + // Switch off compression to make the resulting file easier to read + // as a human + DataOutBase::VtkFlags flags; + flags.compression_level = DataOutBase::CompressionLevel::plain_text; + + DataOut data_out; + data_out.attach_dof_handler(dof_handler); + data_out.add_data_vector(solution, "solution"); + data_out.build_patches(mapping, 2); + + data_out.set_flags(flags); + data_out.write_vtu(deallog.get_file_stream()); +} + +int +main() +{ + initlog(); + + test<2>(); + test<3>(); +} diff --git a/tests/data_out/write_subdivided_simplex_vtu.output b/tests/data_out/write_subdivided_simplex_vtu.output new file mode 100644 index 0000000000..da841b36ba --- /dev/null +++ b/tests/data_out/write_subdivided_simplex_vtu.output @@ -0,0 +1,67 @@ + + + + + + + + +0 0 0 1 0 0 0 1 0 0.5 0 0 0.5 0.5 0 0 0.5 0 + + + + + + 0 1 2 3 4 5 + + +6 + + +22 + + + + +0 1 1 0.25 0.5 0.25 + + + + + + + + + + + + +0 0 0 1 0 0 0 1 0 0 0 1 0.5 0 0 0.5 0.5 0 0 0.5 0 0 0 0.5 0.5 0 0.5 0 0.5 0.5 + + + + + + 0 1 2 3 4 5 6 7 8 9 + + +10 + + +24 + + + + +0 1 1 1 0.25 0.5 0.25 0.25 0.5 0.5 + + + + +