version 0.4.4
common.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2021-2025 The Ikarus Developers mueller@ibb.uni-stuttgart.de
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
9#pragma once
10
11#include <concepts>
12
16
17namespace Ikarus {
18
19namespace Concepts {
25 template <typename NLS>
26 concept HasValidIDBCForceFunction = not std::same_as<typename NLS::IDBCForceFunction, utils::IDBCForceDefault>;
27} // namespace Concepts
28
39template <typename NLS>
41 using JacobianType = std::remove_cvref_t<typename NLS::JacobianType>;
42 static_assert((traits::isSpecializationTypeAndNonTypes<Eigen::Matrix, JacobianType>::value) or
43 (traits::isSpecializationTypeNonTypeAndType<Eigen::SparseMatrix, JacobianType>::value),
44 "Linear solver not implemented for the chosen derivative type of the non-linear operator");
45 SolverTypeTag solverTag;
46
47 auto&& residual = nls.residual();
48
49 if constexpr (traits::isSpecializationTypeAndNonTypes<Eigen::Matrix, JacobianType>::value)
50 solverTag = SolverTypeTag::d_LDLT;
51 else
53 return LinearSolver(solverTag);
54}
55
63template <typename NLS>
64typename NLS::Domain::SolutionVectorType idbcIncrement(typename NLS::Domain& x, const NLS& nls, double Dlambda) {
66 auto y = x;
67 y.parameter() += Dlambda;
68 y.syncParameterAndGlobalSolution(nls.updateFunction());
69 const auto delta = (y.globalSolution() - x.globalSolution()).eval();
70 return delta;
71 } else {
72 Eigen::VectorXd v;
73 v.setZero(x.globalSolution().size());
74 return v;
75 }
76}
77} // namespace Ikarus
Contains stl-like type traits.
Collection of fallback default functions.
Type-erased linear solver with templated scalar type.
Definition: assemblermanipulatorbuildingblocks.hh:22
LinearSolverTemplate< double > LinearSolver
Definition: linearsolver.hh:235
auto createSPDLinearSolverFromNonLinearSolver(const NLS &nls)
A helper function that returns a linear solver suitable for symmetric, positive-definite sparse or de...
Definition: common.hh:40
SolverTypeTag
Enumeration representing different solver types.
Definition: linearsolver.hh:31
NLS::Domain::SolutionVectorType idbcIncrement(typename NLS::Domain &x, const NLS &nls, double Dlambda)
A helper function to calculate the increment in the solution vector based on inhomogeneous Dirichlet ...
Definition: common.hh:64
A concept to check if the underlying solver has a valid function to handle inhomogeneous Dirichlet BC...
Definition: common.hh:26