From: Maximilian Bergbauer Date: Wed, 4 Oct 2023 08:06:00 +0000 (+0200) Subject: Add test and changelog X-Git-Tag: relicensing~436^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b709f7ef4d6c9cd7c5c86b713de36023b1bdca9c;p=dealii.git Add test and changelog --- diff --git a/doc/news/changes/minor/20231004Bergbauer b/doc/news/changes/minor/20231004Bergbauer new file mode 100644 index 0000000000..e2bb26e0cf --- /dev/null +++ b/doc/news/changes/minor/20231004Bergbauer @@ -0,0 +1,3 @@ +Added: An output operator was added to DerivativeForm. +
+(Maximilian Bergbauer, 2023/10/04) diff --git a/include/deal.II/base/derivative_form.h b/include/deal.II/base/derivative_form.h index bf49bdd770..7cfae69b27 100644 --- a/include/deal.II/base/derivative_form.h +++ b/include/deal.II/base/derivative_form.h @@ -444,7 +444,8 @@ operator<<(std::ostream &out, { out << df[i]; if (i != spacedim - 1) - out << ' '; + for (unsigned int j = 0; j < order + 1; ++j) + out << ' '; } return out; diff --git a/include/deal.II/base/tensor.h b/include/deal.II/base/tensor.h index 942bb19dd4..467ad896b0 100644 --- a/include/deal.II/base/tensor.h +++ b/include/deal.II/base/tensor.h @@ -1929,7 +1929,8 @@ operator<<(std::ostream &out, const Tensor &p) { out << p[i]; if (i != dim - 1) - out << ' '; + for (unsigned int j = 0; j < rank_; ++j) + out << ' '; } return out; diff --git a/tests/base/derivative_forms_05.cc b/tests/base/derivative_forms_05.cc new file mode 100644 index 0000000000..0159d43e31 --- /dev/null +++ b/tests/base/derivative_forms_05.cc @@ -0,0 +1,58 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2023 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 operator<< for DerivativeForm + + +#include + +#include "../tests.h" + + +template +void +test() +{ + DerivativeForm<1, dim, spacedim> dF; + double dF_norm_sqr = 0; + for (unsigned int i = 0; i < spacedim; ++i) + for (unsigned int j = 0; j < dim; ++j) + dF[i][j] = (i + 2 * j + 1); + + + DerivativeForm<2, dim, spacedim> ddF; + double ddF_norm_sqr = 0; + for (unsigned int i = 0; i < spacedim; ++i) + for (unsigned int j = 0; j < dim; ++j) + for (unsigned int k = 0; k < dim; ++k) + ddF[i][j][k] = (i + 2 * j + 3 * k + 1); + + + // output the norms of these objects + deallog << "dF : " << dF << std::endl; + deallog << "ddF: " << ddF << std::endl; +} + +int +main() +{ + initlog(); + test<1, 1>(); + test<1, 2>(); + test<1, 3>(); + test<2, 2>(); + test<2, 3>(); + test<3, 3>(); +} diff --git a/tests/base/derivative_forms_05.output b/tests/base/derivative_forms_05.output new file mode 100644 index 0000000000..252c2ce0c1 --- /dev/null +++ b/tests/base/derivative_forms_05.output @@ -0,0 +1,13 @@ + +DEAL::dF : 1.00000 +DEAL::ddF: 1.00000 +DEAL::dF : 1.00000 2.00000 +DEAL::ddF: 1.00000 2.00000 +DEAL::dF : 1.00000 2.00000 3.00000 +DEAL::ddF: 1.00000 2.00000 3.00000 +DEAL::dF : 1.00000 3.00000 2.00000 4.00000 +DEAL::ddF: 1.00000 4.00000 3.00000 6.00000 2.00000 5.00000 4.00000 7.00000 +DEAL::dF : 1.00000 3.00000 2.00000 4.00000 3.00000 5.00000 +DEAL::ddF: 1.00000 4.00000 3.00000 6.00000 2.00000 5.00000 4.00000 7.00000 3.00000 6.00000 5.00000 8.00000 +DEAL::dF : 1.00000 3.00000 5.00000 2.00000 4.00000 6.00000 3.00000 5.00000 7.00000 +DEAL::ddF: 1.00000 4.00000 7.00000 3.00000 6.00000 9.00000 5.00000 8.00000 11.0000 2.00000 5.00000 8.00000 4.00000 7.00000 10.0000 6.00000 9.00000 12.0000 3.00000 6.00000 9.00000 5.00000 8.00000 11.0000 7.00000 10.0000 13.0000