From 8859f618ba3eb15efbe05caf7ab3b543d9c54f13 Mon Sep 17 00:00:00 2001 From: Maximilian Bergbauer Date: Mon, 2 Oct 2023 22:11:15 +0200 Subject: [PATCH] Print function for DerivativeForm --- include/deal.II/base/derivative_form.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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 -- 2.39.5