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<typename NLS::DifferentiableFunction>,
59 SubsidiaryArgs> and
60 Concepts::AdaptiveStepSizingStrategy<ASS, NonLinearSolverInformation, SubsidiaryArgs,
61 std::remove_cvref_t<typename NLS::DifferentiableFunction>> and
62 Concepts::NonLinearSolverCheckForPathFollowing<NLS>;
63 }
64
65 template <typename F>
66 struct PathFollowingStateFactory
67 {
68 private:
69 using SignatureTraits = typename F::Traits;
70 using Domain = typename SignatureTraits::Domain;
71
72 public:
73 using type = PathFollowingState<Domain>;
74 };
75
76} // namespace Impl
77
83template <typename F>
85
86template <typename NLS, typename PF, typename ASS>
87requires(Impl::checkPathFollowingTemplates<NLS, PF, ASS>())
88class PathFollowing;
89
97template <typename PF_ = ArcLength, typename ASS_ = AdaptiveStepSizing::NoOp>
99{
100 using PF = PF_;
101 using ASS = ASS_;
102
103 int steps{};
104 double stepSize{};
107};
108
109#ifndef DOXYGEN
110PathFollowingConfig(int, double) -> PathFollowingConfig<>;
111
112template <typename PF>
113PathFollowingConfig(int, double, PF) -> PathFollowingConfig<PF>;
114
115template <typename PF, typename ASS>
116PathFollowingConfig(int, double, PF, ASS) -> PathFollowingConfig<PF, ASS>;
117
118template <typename ASS>
119PathFollowingConfig(int, double, ArcLength, ASS) -> PathFollowingConfig<ArcLength, ASS>;
120#endif
121
131template <typename NLS, typename PFConfig>
132requires traits::isSpecialization<PathFollowingConfig, std::remove_cvref_t<PFConfig>>::value
133auto createControlRoutine(PFConfig&& config, NLS&& nonlinearSolver) {
134 return PathFollowing<typename std::remove_cvref_t<NLS>::element_type, typename PFConfig::PF, typename PFConfig::ASS>(
135 std::forward<NLS>(nonlinearSolver), config.steps, config.stepSize, config.pathFollowingFunction,
136 config.adaptiveStepSizingFunction);
137}
138
168template <typename NLS, typename PF = ArcLength, typename ASS = AdaptiveStepSizing::NoOp>
169requires(Impl::checkPathFollowingTemplates<NLS, PF, ASS>())
170class PathFollowing : public ControlRoutineBase<typename NLS::DifferentiableFunction,
172
173{
174public:
176 constexpr auto name() const { return std::string("Path following with " + pathFollowingType_.name()); }
177
186 PathFollowing(const std::shared_ptr<NLS>& nls, int steps, double stepSize, PF pathFollowingType = ArcLength{},
187 ASS adaptiveStepSizing = {})
188 : nonLinearSolver_{nls},
189 steps_{steps},
190 stepSize_{stepSize},
191 pathFollowingType_{pathFollowingType},
192 adaptiveStepSizing_{adaptiveStepSizing} {
193 if (steps_ <= 0)
194 DUNE_THROW(Dune::InvalidStateException, "Number of steps should be greater than zero.");
195 }
196
204 [[nodiscard]] ControlInformation run(typename NLS::Domain& d);
205
206 /* \brief returns the nonlinear solver */
207 NLS& nonLinearSolver() { return *nonLinearSolver_; }
208
209private:
210 std::shared_ptr<NLS> nonLinearSolver_;
211
212 int steps_;
213 double stepSize_;
214 PF pathFollowingType_;
215 ASS adaptiveStepSizing_;
216 SubsidiaryArgs subsidiaryArgs_;
217
218 void updateAndNotifyControlInfo(ControlInformation& info, const NonLinearSolverInformation& solverInfo,
219 const typename PathFollowing::State& state) {
220 info.solverInfos.push_back(solverInfo);
221 info.totalIterations += solverInfo.iterations;
222 this->notify(ControlMessages::SOLUTION_CHANGED, state);
223 this->notify(ControlMessages::STEP_ENDED, state);
224 }
225};
226
227} // namespace Ikarus
228
Contains the generic DifferentiableFunctionFactory class.
Contains the generic NonlinearSolverFactory class.
Enums for observer messages.
Factory for controlroutines.
Contains the AdaptiveStepSizing namespace with strategies for adaptive step sizing.
Implementation of the run function.
Base for all control routines.
Defines the ControlInformation structure for storing control results.
Defines structures and methods related to subsidiary functions for control routines.
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:173
constexpr auto name() const
The name of the PathFollowing method.
Definition: pathfollowing.hh:176
NLS & nonLinearSolver()
Definition: pathfollowing.hh:207
PathFollowing(const std::shared_ptr< NLS > &nls, int steps, double stepSize, PF pathFollowingType=ArcLength{}, ASS adaptiveStepSizing={})
Constructor for PathFollowing.
Definition: pathfollowing.hh:186
Config for the Path-Following control routine.
Definition: pathfollowing.hh:99
ASS adaptiveStepSizingFunction
Definition: pathfollowing.hh:106
double stepSize
Definition: pathfollowing.hh:104
PF pathFollowingFunction
Definition: pathfollowing.hh:105
ASS_ ASS
Definition: pathfollowing.hh:101
PF_ PF
Definition: pathfollowing.hh:100
int steps
Definition: pathfollowing.hh:103
Structure containing arguments for subsidiary functions.
Definition: pathfollowingfunctions.hh:40
Structure representing the subsidiary function for the standard arc-length method.
Definition: pathfollowingfunctions.hh:80
Information about the result of a non-linear solver.
Definition: solverinfos.hh:21
int iterations
Definition: solverinfos.hh:31