21#include <dune/common/exceptions.hh>
41 Eigen::VectorX<double>
DD;
78 const auto root = sqrt(args.
DD.squaredNorm() + psi.value() * psi.value() * args.
Dlambda * args.
Dlambda);
83 DUNE_THROW(Dune::InvalidStateException,
"You have to call initialPrediction first. Otherwise psi is not defined");
98 template <
typename NLO>
101 using JacobianType = std::remove_cvref_t<typename NLO::DerivativeType>;
102 static_assert((traits::isSpecializationTypeAndNonTypes<Eigen::Matrix, JacobianType>::value) or
103 (traits::isSpecializationTypeNonTypeAndType<Eigen::SparseMatrix, JacobianType>::value),
104 "Linear solver not implemented for the chosen derivative type of the non-linear operator");
106 if constexpr (traits::isSpecializationTypeAndNonTypes<Eigen::Matrix, JacobianType>::value)
111 nonLinearOperator.lastParameter() = 1.0;
112 nonLinearOperator.template update<0>();
113 const auto& R = nonLinearOperator.value();
114 const auto& K = nonLinearOperator.derivative();
116 static constexpr bool isLinearSolver =
118 typename NLO::ValueType>;
119 static_assert(isLinearSolver,
120 "Initial predictor step in the standard arc-length method doesn't have a linear solver");
123 linearSolver.analyzePattern(K);
124 linearSolver.factorize(K);
125 linearSolver.solve(args.
DD, -R);
127 const auto DD2 = args.
DD.squaredNorm();
130 auto s = sqrt(psi.value() * psi.value() + DD2);
135 nonLinearOperator.firstParameter() = args.
DD;
136 nonLinearOperator.lastParameter() = args.
Dlambda;
148 template <
typename NLO>
150 nonLinearOperator.firstParameter() += args.
DD;
151 nonLinearOperator.lastParameter() += args.
Dlambda;
155 constexpr auto name()
const {
return std::string(
"Arc length"); }
158 std::optional<double> psi;
184 args.
dfdDD.setZero();
197 template <
typename NLO>
200 nonLinearOperator.lastParameter() = args.
Dlambda;
212 template <
typename NLO>
214 nonLinearOperator.lastParameter() += args.
Dlambda;
218 constexpr auto name()
const {
return std::string(
"Load Control"); }
241 : controlledIndices{
std::move(p_controlledIndices)} {}
251 const auto controlledDOFsNorm = args.
DD(controlledIndices).norm();
252 args.
f = controlledDOFsNorm - args.
stepSize;
254 args.
dfdDD.setZero();
255 args.
dfdDD(controlledIndices) = args.
DD(controlledIndices) / controlledDOFsNorm;
267 template <
typename NLO>
269 args.
DD(controlledIndices).array() = args.
stepSize;
270 nonLinearOperator.firstParameter() = args.
DD;
282 template <
typename NLO>
284 nonLinearOperator.firstParameter() += args.
DD;
288 constexpr auto name()
const {
return std::string(
"Displacement Control"); }
291 std::vector<int> controlledIndices;
Contains stl-like type traits.
Collection of fallback default functions.
Type-erased linear solver with templated scalar type.
void initialPrediction(NLO &nonLinearOperator, SubsidiaryArgs &args)
Performs the initial prediction for the standard arc-length method.
Definition: pathfollowingfunctions.hh:99
Definition: assemblermanipulatorbuildingblocks.hh:22
LinearSolverTemplate< double > LinearSolver
Definition: linearsolver.hh:235
SolverTypeTag
Enumeration representing different solver types.
Definition: linearsolver.hh:31
Structure containing arguments for subsidiary functions.
Definition: pathfollowingfunctions.hh:39
double Dlambda
The increment in the load factor.
Definition: pathfollowingfunctions.hh:42
double dfdDlambda
The derivative of the subsidiary function with respect to Dlambda.
Definition: pathfollowingfunctions.hh:45
int currentStep
The current step index in the control routine.
Definition: pathfollowingfunctions.hh:46
double f
The value of the subsidiary function.
Definition: pathfollowingfunctions.hh:43
double stepSize
The step size in the control routine.
Definition: pathfollowingfunctions.hh:40
Eigen::VectorX< double > dfdDD
The derivative of the subsidiary function with respect to DD.
Definition: pathfollowingfunctions.hh:44
Eigen::VectorX< double > DD
The vector representing the solution increment.
Definition: pathfollowingfunctions.hh:41
Structure representing the subsidiary function for the standard arc-length method.
Definition: pathfollowingfunctions.hh:67
void operator()(SubsidiaryArgs &args) const
Evaluates the subsidiary function for the standard arc-length method.
Definition: pathfollowingfunctions.hh:76
void intermediatePrediction(NLO &nonLinearOperator, SubsidiaryArgs &args)
Performs intermediate prediction for the standard arc-length method.
Definition: pathfollowingfunctions.hh:149
constexpr auto name() const
The name of the PathFollowing method.
Definition: pathfollowingfunctions.hh:155
Structure representing the subsidiary function for the load control method.
Definition: pathfollowingfunctions.hh:174
void initialPrediction(NLO &nonLinearOperator, SubsidiaryArgs &args)
Performs initial prediction for the load control method.
Definition: pathfollowingfunctions.hh:198
constexpr auto name() const
The name of the PathFollowing method.
Definition: pathfollowingfunctions.hh:218
void intermediatePrediction(NLO &nonLinearOperator, SubsidiaryArgs &args)
Performs intermediate prediction for the load control method.
Definition: pathfollowingfunctions.hh:213
void operator()(SubsidiaryArgs &args) const
Evaluates the subsidiary function for the load control method.
Definition: pathfollowingfunctions.hh:182
Structure representing the subsidiary function for the displacement control method.
Definition: pathfollowingfunctions.hh:234
constexpr auto name() const
The name of the PathFollowing method.
Definition: pathfollowingfunctions.hh:288
void operator()(SubsidiaryArgs &args) const
Evaluates the subsidiary function for the displacement control method.
Definition: pathfollowingfunctions.hh:250
void intermediatePrediction(NLO &nonLinearOperator, SubsidiaryArgs &args)
Performs intermediate prediction for the displacement control method.
Definition: pathfollowingfunctions.hh:283
DisplacementControl(std::vector< int > p_controlledIndices)
Constructor for DisplacementControl.
Definition: pathfollowingfunctions.hh:240
void initialPrediction(NLO &nonLinearOperator, SubsidiaryArgs &args)
Performs initial prediction for the displacement control method.
Definition: pathfollowingfunctions.hh:268
Concept to check if a linear solver implements all the needed functions for given vector and matrix t...
Definition: concepts.hh:215