version 0.4.4
loadcontrol.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
13#include <dune/common/hybridutilities.hh>
14
19
20namespace Ikarus {
21
22template <typename NLS>
23class LoadControl;
24
30{
31 int loadSteps{};
32 double tbegin{};
33 double tEnd{};
34};
35
44template <typename NLS>
45auto createControlRoutine(const LoadControlConfig& config, NLS&& nonlinearSolver) {
46 return LoadControl(std::forward<NLS>(nonlinearSolver), config.loadSteps, std::array{config.tbegin, config.tEnd});
47}
48
58template <typename NLS>
59class LoadControl : public ControlRoutineBase<typename NLS::DifferentiableFunction>
60{
61public:
63 constexpr std::string name() const { return "Load Control Method"; }
64
72 LoadControl(const std::shared_ptr<NLS>& nonLinearSolver, int loadSteps, const std::array<double, 2>& tbeginEnd)
73 : nonLinearSolver_{nonLinearSolver},
74 loadSteps_{loadSteps},
75 parameterBegin_{tbeginEnd[0]},
76 parameterEnd_{tbeginEnd[1]},
77 stepSize_{(parameterEnd_ - parameterBegin_) / loadSteps_} {
78 if (loadSteps_ <= 0)
79 DUNE_THROW(Dune::InvalidStateException, "Number of load steps should be greater than zero.");
80 }
81
87 ControlInformation run(typename NLS::Domain& x);
88
94 void predictor(typename NLS::Domain& x) const;
95
96 /* \brief returns the nonlinear solver */
97 NLS& nonLinearSolver() { return *nonLinearSolver_; }
98
99private:
100 std::shared_ptr<NLS> nonLinearSolver_;
101 int loadSteps_;
102 double parameterBegin_;
103 double parameterEnd_;
104 double stepSize_;
105
106 void updateAndNotifyControlInfo(ControlInformation& info, const NonLinearSolverInformation& solverInfo,
107 const typename LoadControl::State& state) {
108 info.solverInfos.push_back(solverInfo);
109 info.totalIterations += solverInfo.iterations;
112 }
113};
114
115} // namespace Ikarus
116
Implementation of the observer design pattern with broadcasters.
Defines the ControlInformation structure for storing control results.
Base for all control routines.
Implementation of the run function.
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 control routines.
Definition: controlroutinestate.hh:23
The LoadControl control routine increases the parameter of the fe requirements given in run function ...
Definition: loadcontrol.hh:60
LoadControl(const std::shared_ptr< NLS > &nonLinearSolver, int loadSteps, const std::array< double, 2 > &tbeginEnd)
Constructor for LoadControl.
Definition: loadcontrol.hh:72
constexpr std::string name() const
The name of the LoadControl method.
Definition: loadcontrol.hh:63
NLS & nonLinearSolver()
Definition: loadcontrol.hh:97
void predictor(typename NLS::Domain &x) const
Performs the prediction for every load increment.
Definition: loadcontrol.inl:55
ControlInformation run(typename NLS::Domain &x)
Executes the LoadControl routine.
Definition: loadcontrol.inl:21
Config for the Load-Control control routine.
Definition: loadcontrol.hh:30
double tEnd
Definition: loadcontrol.hh:33
int loadSteps
Definition: loadcontrol.hh:31
double tbegin
Definition: loadcontrol.hh:32
Information about the result of a non-linear solver.
Definition: solverinfos.hh:21
int iterations
Definition: solverinfos.hh:31
void notify(ControlMessages message, const State &data)
This calls all the registered functions.
Definition: broadcaster.hh:61