From: Wolfgang Bangerth Date: Tue, 2 Nov 2021 23:33:13 +0000 (-0600) Subject: Add a test for pyramid output with gnuplot. X-Git-Tag: v9.4.0-rc1~862^2~4 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65cbeb2ea3598b274868c26f49bc1930ff69a397;p=dealii.git Add a test for pyramid output with gnuplot. --- diff --git a/tests/simplex/data_out_write_gnuplot_02.cc b/tests/simplex/data_out_write_gnuplot_02.cc new file mode 100644 index 0000000000..47f5969360 --- /dev/null +++ b/tests/simplex/data_out_write_gnuplot_02.cc @@ -0,0 +1,111 @@ +// --------------------------------------------------------------------- +// +// 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_gnuplot() for a pyramid mesh + +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include "../tests.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) +{ + Triangulation tria; + GridGenerator::reference_cell(tria, ReferenceCells::Pyramid); + + DoFHandler dof_handler(tria); + + dof_handler.distribute_dofs(fe); + + Vector solution(dof_handler.n_dofs()); + + MappingFE mapping(FE_PyramidP(1)); + + AffineConstraints dummy; + dummy.close(); + + VectorTools::project(mapping, + dof_handler, + dummy, + QGaussPyramid(fe.tensor_degree() + 1), + RightHandSideFunction(1), + solution); + + + DataOut data_out; + + data_out.attach_dof_handler(dof_handler); + data_out.add_data_vector(solution, "solution"); + + + data_out.build_patches(mapping, 1); + +#if false + static unsigned int counter = 0; + std::ofstream output("test." + std::to_string(dim) + "." + + std::to_string(counter++) + ".gnuplot"); + data_out.write_gnuplot(output); +#else + data_out.write_gnuplot(deallog.get_file_stream()); +#endif +} + +int +main() +{ + initlog(); + + const int dim = 3; + test(FE_PyramidP(1)); +} diff --git a/tests/simplex/data_out_write_gnuplot_02.output b/tests/simplex/data_out_write_gnuplot_02.output new file mode 100644 index 0000000000..a627d9d89e --- /dev/null +++ b/tests/simplex/data_out_write_gnuplot_02.output @@ -0,0 +1,20 @@ + +# This file was generated by the deal.II library. + + +# +# For a description of the GNUPLOT format see the GNUPLOT manual. +# +# +-1.00000 -1.00000 0.00000 0.311111 +1.00000 -1.00000 0.00000 0.311111 +1.00000 1.00000 0.00000 0.311111 +-1.00000 1.00000 0.00000 0.311111 +-1.00000 -1.00000 0.00000 0.311111 +0.00000 0.00000 1.00000 -0.133333 +1.00000 -1.00000 0.00000 0.311111 + +1.00000 1.00000 0.00000 0.311111 +0.00000 0.00000 1.00000 -0.133333 +-1.00000 1.00000 0.00000 0.311111 +