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
89 /* \brief returns the nonlinear solver */
90 NLS& nonLinearSolver() { return *nonLinearSolver_; }
91
92private:
93 std::shared_ptr<NLS> nonLinearSolver_;
94 int loadSteps_;
95 double parameterBegin_;
96 double parameterEnd_;
97 double stepSize_;
98
99 void updateAndNotifyControlInfo(ControlInformation& info, const NonLinearSolverInformation& solverInfo,
100 const typename LoadControl::State& state) {
101 info.solverInfos.push_back(solverInfo);
102 info.totalIterations += solverInfo.iterations;
105 }
106};
107
108} // namespace Ikarus
109
Implementation of the observer design pattern with broadcasters.
Factory for controlroutines.
Implementation of the run function.
Base for all control routines.
Defines the ControlInformation structure for storing control results.
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:90
ControlInformation run(typename NLS::Domain &x)
Executes the LoadControl routine.
Definition: loadcontrol.inl:19
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