From ebf6dcd6ad0debb08568b04ade987fabe75a40d4 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 18 Jun 2025 18:18:25 -0600 Subject: [PATCH] Add a test. --- tests/base/functions_16.cc | 79 ++++++++++++++++++++++++++++++++++ tests/base/functions_16.output | 4 ++ 2 files changed, 83 insertions(+) create mode 100644 tests/base/functions_16.cc create mode 100644 tests/base/functions_16.output diff --git a/tests/base/functions_16.cc b/tests/base/functions_16.cc new file mode 100644 index 0000000000..23ea12b404 --- /dev/null +++ b/tests/base/functions_16.cc @@ -0,0 +1,79 @@ +// ------------------------------------------------------------------------ +// +// SPDX-License-Identifier: LGPL-2.1-or-later +// Copyright (C) 2011 - 2018 by the deal.II authors +// +// This file is part of the deal.II library. +// +// Part of the source code is dual licensed under Apache-2.0 WITH +// LLVM-exception OR LGPL-2.1-or-later. Detailed license information +// governing the source code and code contributions can be found in +// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II. +// +// ------------------------------------------------------------------------ + + +// Test VectorFunctionFromTensorFunctionObject + +#include +#include + +#include + +#include "../tests.h" + + + +template +void +check1() +{ + const auto x = [](const Point &p) -> Tensor<1, dim> { return p; }; + + VectorFunctionFromTensorFunctionObject object(x, 1, dim + 2); + + AssertThrow(object.n_components == dim + 2, ExcInternalError()); + + for (unsigned int i = 0; i < 10; ++i) + { + Point p; + for (unsigned int d = 0; d < dim; ++d) + p[d] = i + d; + + for (unsigned int c = 0; c < dim + 2; ++c) + if (c == 0 || c == dim + 1) + { + AssertThrow(object.value(p, c) == 0, ExcInternalError()); + } + else + { + AssertThrow(object.value(p, c) == p[c - 1], ExcInternalError()); + } + + Vector v(dim + 2); + object.vector_value(p, v); + for (unsigned int c = 0; c < dim + 2; ++c) + if (c == 0 || c == dim + 1) + { + AssertThrow(v(c) == 0, ExcInternalError()); + } + else + { + AssertThrow(v(c) == p[c - 1], ExcInternalError()); + } + } + + deallog << "OK" << std::endl; +} + + + +int +main() +{ + initlog(); + + check1<1>(); + check1<2>(); + check1<3>(); +} diff --git a/tests/base/functions_16.output b/tests/base/functions_16.output new file mode 100644 index 0000000000..fb71de2867 --- /dev/null +++ b/tests/base/functions_16.output @@ -0,0 +1,4 @@ + +DEAL::OK +DEAL::OK +DEAL::OK -- 2.39.5