From: Wolfgang Bangerth Date: Tue, 7 Feb 2023 16:59:05 +0000 (-0700) Subject: Add test. X-Git-Tag: v9.5.0-rc1~567^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F14754%2Fhead;p=dealii.git Add test. --- diff --git a/tests/base/derivative_form_initialization.cc b/tests/base/derivative_form_initialization.cc new file mode 100644 index 0000000000..be3a40960a --- /dev/null +++ b/tests/base/derivative_form_initialization.cc @@ -0,0 +1,60 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2017 - 2018 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. +// +// --------------------------------------------------------------------- + + +// Verify that DerivativeForm can be initialized from a +// Tensor<1,dim,Tensor. We used to have a bug where the +// copy constructor offered Tensor instead, +// but that was just wrong. + +#include + +#include + +#include + +#include "../tests.h" + +template +void +test() +{ + // Choose orders and dimensions so that they are all not equal: + constexpr int order = 2; + constexpr int dim = 1; + constexpr int spacedim = 3; + + + Tensor inner; + inner[0][0] = 1; + Tensor<1, spacedim, Tensor> t; + t[0] = t[1] = t[2] = inner; + + const DerivativeForm d(t); + + deallog << "norm: " << d.norm() << std::endl; +} + +int +main() +{ + initlog(); + + deallog << "testing float" << std::endl; + test(); + + deallog << "testing double" << std::endl; + test(); +} diff --git a/tests/base/derivative_form_initialization.output b/tests/base/derivative_form_initialization.output new file mode 100644 index 0000000000..5a0d6b83f3 --- /dev/null +++ b/tests/base/derivative_form_initialization.output @@ -0,0 +1,5 @@ + +DEAL::testing float +DEAL::norm: 1.73205 +DEAL::testing double +DEAL::norm: 1.73205