From: Wolfgang Bangerth Date: Tue, 2 Nov 2021 23:32:59 +0000 (-0600) Subject: Add a test for wedge output with gnuplot. X-Git-Tag: v9.4.0-rc1~862^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3dc8dda6c51ea6279d9b315c9c3973fd11d40277;p=dealii.git Add a test for wedge output with gnuplot. --- diff --git a/tests/simplex/data_out_write_gnuplot_03.cc b/tests/simplex/data_out_write_gnuplot_03.cc new file mode 100644 index 0000000000..5c08845e16 --- /dev/null +++ b/tests/simplex/data_out_write_gnuplot_03.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 wedge 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::Wedge); + + DoFHandler dof_handler(tria); + + dof_handler.distribute_dofs(fe); + + Vector solution(dof_handler.n_dofs()); + + MappingFE mapping(FE_WedgeP(1)); + + AffineConstraints dummy; + dummy.close(); + + VectorTools::project(mapping, + dof_handler, + dummy, + QGaussWedge(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_WedgeP(1)); +} diff --git a/tests/simplex/data_out_write_gnuplot_03.output b/tests/simplex/data_out_write_gnuplot_03.output new file mode 100644 index 0000000000..8e2282a5cd --- /dev/null +++ b/tests/simplex/data_out_write_gnuplot_03.output @@ -0,0 +1,23 @@ + +# This file was generated by the deal.II library. + + +# +# For a description of the GNUPLOT format see the GNUPLOT manual. +# +# +0.00000 0.00000 0.00000 -0.100000 +1.00000 0.00000 0.00000 0.700000 +0.00000 1.00000 0.00000 -0.100000 +0.00000 0.00000 0.00000 -0.100000 +0.00000 0.00000 1.00000 -0.100000 +1.00000 0.00000 1.00000 0.700000 +0.00000 1.00000 1.00000 -0.100000 +0.00000 0.00000 1.00000 -0.100000 + +1.00000 0.00000 0.00000 0.700000 +1.00000 0.00000 1.00000 0.700000 + +0.00000 1.00000 0.00000 -0.100000 +0.00000 1.00000 1.00000 -0.100000 +