From: Maximilian Bergbauer Date: Mon, 2 Oct 2023 20:11:15 +0000 (+0200) Subject: Print function for DerivativeForm X-Git-Tag: relicensing~446^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8859f618ba3eb15efbe05caf7ab3b543d9c54f13;p=dealii.git Print function for DerivativeForm --- diff --git a/include/deal.II/base/derivative_form.h b/include/deal.II/base/derivative_form.h index 8c1e4710f6..bf49bdd770 100644 --- a/include/deal.II/base/derivative_form.h +++ b/include/deal.II/base/derivative_form.h @@ -428,6 +428,30 @@ DerivativeForm::memory_consumption() +/** + * Output operator for DerivativeForm. Print the elements consecutively, with a + * space in between, two spaces between rank 1 subtensors, three between rank 2 + * and so on. + * + * @relatesalso DerivativeForm + */ +template +inline std::ostream & +operator<<(std::ostream &out, + const DerivativeForm &df) +{ + for (unsigned int i = 0; i < spacedim; ++i) + { + out << df[i]; + if (i != spacedim - 1) + out << ' '; + } + + return out; +} + + + /** * One of the uses of DerivativeForm is to apply it as a linear transformation. * This function returns $\nabla \mathbf F(\mathbf x) \Delta \mathbf x$, which