21#include <dune/common/exceptions.hh>
40 Eigen::VectorX<double>
DD;
76 const auto root = sqrt(args.
DD.squaredNorm() + psi.value() * psi.value() * args.
Dlambda * args.
Dlambda);
81 DUNE_THROW(Dune::InvalidStateException,
82 "You have to call initialPrediction first. Otherwise psi is not defined");
97 template <
typename NonLinearOperator>
100 using JacobianType = std::remove_cvref_t<typename NonLinearOperator::DerivativeType>;
101 static_assert((traits::isSpecializationTypeAndNonTypes<Eigen::Matrix, JacobianType>::value)
102 or (traits::isSpecializationTypeNonTypeAndType<Eigen::SparseMatrix, JacobianType>::value),
103 "Linear solver not implemented for the chosen derivative type of the non-linear operator");
105 if constexpr (traits::isSpecializationTypeAndNonTypes<Eigen::Matrix, JacobianType>::value)
110 nonLinearOperator.lastParameter() = 1.0;
111 nonLinearOperator.template update<0>();
112 const auto& R = nonLinearOperator.value();
113 const auto& K = nonLinearOperator.derivative();
115 static constexpr bool isLinearSolver
117 typename NonLinearOperator::DerivativeType,
118 typename NonLinearOperator::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 NonLinearOperator>
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;
183 args.
dfdDD.setZero();
196 template <
typename NonLinearOperator>
199 nonLinearOperator.lastParameter() = args.
Dlambda;
211 template <
typename NonLinearOperator>
213 nonLinearOperator.lastParameter() += args.
Dlambda;
217 constexpr auto name()
const {
return std::string(
"Load Control"); }
239 : controlledIndices{std::move(p_controlledIndices)} {}
249 const auto controlledDOFsNorm = args.
DD(controlledIndices).norm();
250 args.
f = controlledDOFsNorm - args.
stepSize;
252 args.
dfdDD.setZero();
253 args.
dfdDD(controlledIndices) = args.
DD(controlledIndices) / controlledDOFsNorm;
265 template <
typename NonLinearOperator>
267 args.
DD(controlledIndices).array() = args.
stepSize;
268 nonLinearOperator.firstParameter() = args.
DD;
280 template <
typename NonLinearOperator>
282 nonLinearOperator.firstParameter() += args.
DD;
286 constexpr auto name()
const {
return std::string(
"Displacement Control"); }
289 std::vector<int> controlledIndices;
Collection of fallback default functions.
Contains stl-like type traits.
Type-erased linear solver with templated scalar type.
void initialPrediction(NonLinearOperator &nonLinearOperator, SubsidiaryArgs &args)
Performs the initial prediction for the standard arc-length method.
Definition: pathfollowingfunctions.hh:98
Definition: simpleassemblers.hh:21
SolverTypeTag
Enumeration representing different solver types.
Definition: linearsolver.hh:27
LinearSolverTemplate< double > LinearSolver
Definition: linearsolver.hh:234
Structure containing arguments for subsidiary functions.
Definition: pathfollowingfunctions.hh:38
double Dlambda
The increment in the load factor.
Definition: pathfollowingfunctions.hh:41
double dfdDlambda
The derivative of the subsidiary function with respect to Dlambda.
Definition: pathfollowingfunctions.hh:44
int currentStep
The current step index in the control routine.
Definition: pathfollowingfunctions.hh:45
double f
The value of the subsidiary function.
Definition: pathfollowingfunctions.hh:42
double stepSize
The step size in the control routine.
Definition: pathfollowingfunctions.hh:39
Eigen::VectorX< double > dfdDD
The derivative of the subsidiary function with respect to DD.
Definition: pathfollowingfunctions.hh:43
Eigen::VectorX< double > DD
The vector representing the solution increment.
Definition: pathfollowingfunctions.hh:40
Structure representing the subsidiary function for the standard arc-length method.
Definition: pathfollowingfunctions.hh:65
void operator()(SubsidiaryArgs &args) const
Evaluates the subsidiary function for the standard arc-length method.
Definition: pathfollowingfunctions.hh:74
void intermediatePrediction(NonLinearOperator &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:173
void initialPrediction(NonLinearOperator &nonLinearOperator, SubsidiaryArgs &args)
Performs initial prediction for the load control method.
Definition: pathfollowingfunctions.hh:197
void intermediatePrediction(NonLinearOperator &nonLinearOperator, SubsidiaryArgs &args)
Performs intermediate prediction for the load control method.
Definition: pathfollowingfunctions.hh:212
constexpr auto name() const
The name of the PathFollowing method.
Definition: pathfollowingfunctions.hh:217
void operator()(SubsidiaryArgs &args) const
Evaluates the subsidiary function for the load control method.
Definition: pathfollowingfunctions.hh:181
Structure representing the subsidiary function for the displacement control method.
Definition: pathfollowingfunctions.hh:232
void intermediatePrediction(NonLinearOperator &nonLinearOperator, SubsidiaryArgs &args)
Performs intermediate prediction for the displacement control method.
Definition: pathfollowingfunctions.hh:281
constexpr auto name() const
The name of the PathFollowing method.
Definition: pathfollowingfunctions.hh:286
void initialPrediction(NonLinearOperator &nonLinearOperator, SubsidiaryArgs &args)
Performs initial prediction for the displacement control method.
Definition: pathfollowingfunctions.hh:266
void operator()(SubsidiaryArgs &args) const
Evaluates the subsidiary function for the displacement control method.
Definition: pathfollowingfunctions.hh:248
DisplacementControl(std::vector< int > p_controlledIndices)
Constructor for DisplacementControl.
Definition: pathfollowingfunctions.hh:238
Represents a NonLinearOperator class for handling nonlinear operators.
Definition: nonlinearoperator.hh:154
Concept to check if a linear solver implements all the needed functions for given vector and matrix t...
Definition: concepts.hh:218