From ccac0e2af831c8902ea3cc3ba23f5115ba44a07c Mon Sep 17 00:00:00 2001 From: Simon Sticko Date: Sat, 7 Sep 2024 14:50:42 +0200 Subject: [PATCH] Make it possible to include nonlinear.h when no external libs are enabled The file nonlinear.h can not be included when none of SUNDIALS, TRILINOS, or PETSC are enabled. Fix this. --- include/deal.II/numerics/nonlinear.h | 8 ++-- .../numerics/nonlinear_solver_selector_04.cc | 37 +++++++++++++++++++ .../nonlinear_solver_selector_04.output | 2 + 3 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 tests/numerics/nonlinear_solver_selector_04.cc create mode 100644 tests/numerics/nonlinear_solver_selector_04.output diff --git a/include/deal.II/numerics/nonlinear.h b/include/deal.II/numerics/nonlinear.h index bde8ee41b6..712db8b5c7 100644 --- a/include/deal.II/numerics/nonlinear.h +++ b/include/deal.II/numerics/nonlinear.h @@ -689,15 +689,15 @@ NonlinearSolverSelector::solve( } else { - const std::string solvers = + const std::string solvers = "" #ifdef DEAL_II_WITH_SUNDIALS - "kinsol\n" + "kinsol\n" #endif #ifdef DEAL_II_TRILINOS_WITH_NOX - "NOX\n" + "NOX\n" #endif #ifdef DEAL_II_WITH_PETSC - "SNES\n" + "SNES\n" #endif ; diff --git a/tests/numerics/nonlinear_solver_selector_04.cc b/tests/numerics/nonlinear_solver_selector_04.cc new file mode 100644 index 0000000000..2ce8c47828 --- /dev/null +++ b/tests/numerics/nonlinear_solver_selector_04.cc @@ -0,0 +1,37 @@ +// ------------------------------------------------------------------------ +// +// SPDX-License-Identifier: LGPL-2.1-or-later +// Copyright (C) 2022 - 2024 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. +// +// ------------------------------------------------------------------------ + + + +// Tests that nonlinear.h can be included and that an object of +// NonlinearSolverSelector can be created, even when none of SUNDIALS, +// TRILINOS, or PETSC are enabled. Test added to trigger the bug, that this was +// not possibles. + +#include + +#include + +#include "../tests.h" + + +int +main() +{ + initlog(); + + NonlinearSolverSelector solver; + + deallog << "OK" << std::endl; +} diff --git a/tests/numerics/nonlinear_solver_selector_04.output b/tests/numerics/nonlinear_solver_selector_04.output new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/numerics/nonlinear_solver_selector_04.output @@ -0,0 +1,2 @@ + +DEAL::OK -- 2.39.5