version 0.4.4
pathfollowing.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2021-2025 The Ikarus Developers ikarus@ibb.uni-stuttgart.de
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
9#pragma once
10
11#include <memory>
12
22
23namespace Ikarus {
24
30template <typename D>
32{
33 using Domain = D;
34
35 const Domain& domain;
38
39 int loadStep{-1};
40 double stepSize{};
41};
42
43namespace Impl {
56 template <typename NLS, typename PF = ArcLength, typename ASS>
57 consteval bool checkPathFollowingTemplates() {
58 return Concepts::PathFollowingStrategy<PF, std::remove_cvref_t<NLS>, SubsidiaryArgs> and
59 Concepts::AdaptiveStepSizingStrategy<ASS, NonLinearSolverInformation, SubsidiaryArgs,
60 std::remove_cvref_t<typename NLS::DifferentiableFunction>> and
61 Concepts::NonLinearSolverCheckForPathFollowing<NLS>;
62 }
63
64 template <typename F>
65 struct PathFollowingStateFactory
66 {
67 private:
68 using SignatureTraits = typename F::Traits;
69 using Domain = typename SignatureTraits::Domain;
70
71 public:
72 using type = PathFollowingState<Domain>;
73 };
74
75} // namespace Impl
76
82template <typename F>
84
85template <typename NLS, typename PF, typename ASS>
86requires(Impl::checkPathFollowingTemplates<NLS, PF, ASS>())
87class PathFollowing;
88
96template <typename PF_ = ArcLength, typename ASS_ = AdaptiveStepSizing::NoOp>
98{
99 using PF = PF_;
100 using ASS = ASS_;
101
102 int steps{};
103 double stepSize{};
106};
107
108#ifndef DOXYGEN
109PathFollowingConfig(int, double) -> PathFollowingConfig<>;
110
111template <typename PF>
112PathFollowingConfig(int, double, PF) -> PathFollowingConfig<PF>;
113
114template <typename PF, typename ASS>
115PathFollowingConfig(int, double, PF, ASS) -> PathFollowingConfig<PF, ASS>;
116
117template <typename ASS>
118PathFollowingConfig(int, double, ArcLength, ASS) -> PathFollowingConfig<ArcLength, ASS>;
119#endif
120
130template <typename NLS, typename PFConfig>
131requires traits::isSpecialization<PathFollowingConfig, std::remove_cvref_t<PFConfig>>::value
132auto createControlRoutine(PFConfig&& config, NLS&& nonlinearSolver) {
133 return PathFollowing<typename std::remove_cvref_t<NLS>::element_type, typename PFConfig::PF, typename PFConfig::ASS>(
134 std::forward<NLS>(nonlinearSolver), config.steps, config.stepSize, config.pathFollowingFunction,
135 config.adaptiveStepSizingFunction);
136}
137
167template <typename NLS, typename PF = ArcLength, typename ASS = AdaptiveStepSizing::NoOp>
168requires(Impl::checkPathFollowingTemplates<NLS, PF, ASS>())
169class PathFollowing : public ControlRoutineBase<typename NLS::DifferentiableFunction,
171
172{
173public:
175 constexpr auto name() const { return std::string("Path following with " + pathFollowingType_.name()); }
176
185 PathFollowing(const std::shared_ptr<NLS>& nls, int steps, double stepSize, PF pathFollowingType = ArcLength{},
186 ASS adaptiveStepSizing = {})
187 : nonLinearSolver_{nls},
188 steps_{steps},
189 stepSize_{stepSize},
190 pathFollowingType_{pathFollowingType},
191 adaptiveStepSizing_{adaptiveStepSizing} {
192 if (steps_ <= 0)
193 DUNE_THROW(Dune::InvalidStateException, "Number of steps should be greater than zero.");
194 }
195
203 [[nodiscard]] ControlInformation run(typename NLS::Domain& d);
204
205 /* \brief returns the nonlinear solver */
206 NLS& nonLinearSolver() { return *nonLinearSolver_; }
207
208private:
209 std::shared_ptr<NLS> nonLinearSolver_;
210
211 int steps_;
212 double stepSize_;
213 PF pathFollowingType_;
214 ASS adaptiveStepSizing_;
215 SubsidiaryArgs subsidiaryArgs_;
216
217 void updateAndNotifyControlInfo(ControlInformation& info, const NonLinearSolverInformation& solverInfo,
218 const typename PathFollowing::State& state) {
219 info.solverInfos.push_back(solverInfo);
220 info.totalIterations += solverInfo.iterations;
221 this->notify(ControlMessages::SOLUTION_CHANGED, state);
222 this->notify(ControlMessages::STEP_ENDED, state);
223 }
224};
225
226} // namespace Ikarus
227
Contains the generic DifferentiableFunctionFactory class.
Enums for observer messages.
Contains the generic NonlinearSolverFactory class.
Defines the ControlInformation structure for storing control results.
Base for all control routines.
Implementation of the run function.
Contains the AdaptiveStepSizing namespace with strategies for adaptive step sizing.
Defines structures and methods related to subsidiary functions for control routines.
Factory for controlroutines.
Definition: assemblermanipulatorbuildingblocks.hh:22
auto createControlRoutine(const LoadControlConfig &config, NLS &&nonlinearSolver)
Function to create a load control instance.
Definition: loadcontrol.hh:45
Structure containing information about the control results.
Definition: controlinfos.hh:23
int totalIterations
Total number of iterations performed.
Definition: controlinfos.hh:30
std::vector< Ikarus::NonLinearSolverInformation > solverInfos
Vector containing information from nonlinear solvers.
Definition: controlinfos.hh:29
Base for all control routines. Defines the message interface that can be broadcasted to listeners.
Definition: controlroutinebase.hh:24
State for path following control routine.
Definition: pathfollowing.hh:32
double stepSize
Definition: pathfollowing.hh:40
const ControlInformation & information
Definition: pathfollowing.hh:36
const Domain & domain
Definition: pathfollowing.hh:35
int loadStep
Definition: pathfollowing.hh:39
D Domain
Definition: pathfollowing.hh:33
const SubsidiaryArgs & subsidiaryArgs
Definition: pathfollowing.hh:37
The PathFollowing control routine for path-following analysis.
Definition: pathfollowing.hh:172
constexpr auto name() const
The name of the PathFollowing method.
Definition: pathfollowing.hh:175
NLS & nonLinearSolver()
Definition: pathfollowing.hh:206
PathFollowing(const std::shared_ptr< NLS > &nls, int steps, double stepSize, PF pathFollowingType=ArcLength{}, ASS adaptiveStepSizing={})
Constructor for PathFollowing.
Definition: pathfollowing.hh:185
Config for the Path-Following control routine.
Definition: pathfollowing.hh:98
ASS adaptiveStepSizingFunction
Definition: pathfollowing.hh:105
double stepSize
Definition: pathfollowing.hh:103
PF pathFollowingFunction
Definition: pathfollowing.hh:104
ASS_ ASS
Definition: pathfollowing.hh:100
PF_ PF
Definition: pathfollowing.hh:99
int steps
Definition: pathfollowing.hh:102
Structure containing arguments for subsidiary functions.
Definition: pathfollowingfunctions.hh:49
Structure representing the subsidiary function for the standard arc-length method.
Definition: pathfollowingfunctions.hh:89
Information about the result of a non-linear solver.
Definition: solverinfos.hh:21
int iterations
Definition: solverinfos.hh:31