/home/runner/work/kynema/kynema/kynema/src/step/step.hpp Source File

Kynema API: /home/runner/work/kynema/kynema/kynema/src/step/step.hpp Source File
Kynema API
A flexible multibody structural dynamics code for wind turbines
Loading...
Searching...
No Matches
step.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Kokkos_Core.hpp>
4#include <Kokkos_Profiling_ScopedRegion.hpp>
5
13#include "elements/elements.hpp"
15#include "reset_constraints.hpp"
16#include "reset_solver.hpp"
17#include "solve_system.hpp"
18#include "solver/solver.hpp"
19#include "state/state.hpp"
22#include "step_parameters.hpp"
28
29namespace kynema {
30
42template <typename DeviceType>
43inline bool Step(
44 StepParameters& parameters, Solver<DeviceType>& solver, Elements<DeviceType>& elements,
46) {
47 auto region = Kokkos::Profiling::ScopedRegion("Step");
48
49 step::PredictNextState(parameters, state);
50 step::ResetConstraints(constraints);
51
52 solver.convergence_err.clear();
53 double err{1000.};
54 for (auto iter = 0U; err > 1.; ++iter) {
55 if (iter >= parameters.max_iter) {
56 return false;
57 }
58 step::ResetSolver(solver);
59
60 step::UpdateTangentOperator(parameters, state);
61
62 step::UpdateSystemVariables(parameters, elements, state);
63
64 step::AssembleSystemResidual(solver, elements, state);
65
66 step::AssembleSystemMatrix(parameters, solver, elements);
67
68 step::UpdateConstraintVariables(state, constraints);
69
70 step::AssembleConstraintsMatrix(solver, constraints);
71
72 step::AssembleConstraintsResidual(solver, constraints);
73
74 step::SolveSystem(parameters, solver);
75
76 err = step::CalculateConvergenceError(parameters, solver, state, constraints);
77
78 solver.convergence_err.push_back(err);
79
80 step::UpdateStatePrediction(parameters, solver, state);
81
82 step::UpdateConstraintPrediction(solver, constraints);
83 }
84
85 using RangePolicy = Kokkos::RangePolicy<typename DeviceType::execution_space>;
86
87 auto system_range = RangePolicy(0, solver.num_system_nodes);
88 Kokkos::parallel_for(
89 "UpdateAlgorithmicAcceleration", system_range,
91 state.a,
92 state.vd,
93 parameters.alpha_f,
94 parameters.alpha_m,
95 }
96 );
97
98 Kokkos::parallel_for(
99 "UpdateGlobalPosition", system_range,
101 state.q,
102 state.x0,
103 state.x,
104 }
105 );
106
107 auto constraints_range = RangePolicy(0, constraints.num_constraints);
108 Kokkos::parallel_for(
109 "CalculateConstraintOutput", constraints_range,
111 constraints.type,
112 constraints.target_node_index,
113 constraints.axes,
114 state.x0,
115 state.q,
116 state.v,
117 state.vd,
118 constraints.output,
119 }
120 );
121 Kokkos::deep_copy(constraints.host_output, constraints.output);
122
123 return true;
124}
125
126} // namespace kynema
void ResetSolver(Solver< DeviceType > &solver)
Definition reset_solver.hpp:11
void UpdateTangentOperator(StepParameters &parameters, State< DeviceType > &state)
Definition update_tangent_operator.hpp:13
void AssembleSystemMatrix(StepParameters &parameters, Solver< DeviceType > &solver, Elements< DeviceType > &elements)
Definition assemble_system_matrix.hpp:16
void UpdateConstraintVariables(State< DeviceType > &state, Constraints< DeviceType > &constraints)
Definition update_constraint_variables.hpp:13
double CalculateConvergenceError(const StepParameters &parameters, const Solver< DeviceType > &solver, const State< DeviceType > &state, const Constraints< DeviceType > &constraints)
Calculation based on Table 1 of DOI: 10.1115/1.4033441.
Definition calculate_convergence_error.hpp:16
void AssembleConstraintsResidual(Solver< DeviceType > &solver, Constraints< DeviceType > &constraints)
Definition assemble_constraints_residual.hpp:15
void SolveSystem(StepParameters &parameters, Solver< DeviceType > &solver)
Definition solve_system.hpp:15
void ResetConstraints(Constraints< DeviceType > &constraints)
Definition reset_constraints.hpp:11
void AssembleSystemResidual(Solver< DeviceType > &solver, Elements< DeviceType > &elements, State< DeviceType > &state)
Definition assemble_system_residual.hpp:17
void AssembleConstraintsMatrix(Solver< DeviceType > &solver, Constraints< DeviceType > &constraints)
Definition assemble_constraints_matrix.hpp:13
void PredictNextState(StepParameters &parameters, State< DeviceType > &state)
Definition predict_next_state.hpp:14
void UpdateConstraintPrediction(Solver< DeviceType > &solver, Constraints< DeviceType > &constraints)
Definition update_constraint_prediction.hpp:13
void UpdateStatePrediction(StepParameters &parameters, const Solver< DeviceType > &solver, State< DeviceType > &state)
Updates the predicted next state values, based on computed solver solution, solver....
Definition update_state_prediction.hpp:25
void UpdateSystemVariables(StepParameters &parameters, const Elements< DeviceType > &elements, State< DeviceType > &state)
Definition update_system_variables.hpp:15
Definition calculate_constraint_output.hpp:8
bool Step(StepParameters &parameters, Solver< DeviceType > &solver, Elements< DeviceType > &elements, State< DeviceType > &state, Constraints< DeviceType > &constraints)
Attempts to complete a single time step in the dynamic FEA simulation.
Definition step.hpp:43
Container class for managing multiple constraints in a simulation.
Definition constraints.hpp:29
View< double *[3]> output
Definition constraints.hpp:59
View< size_t * > target_node_index
Definition constraints.hpp:42
View< double *[3][3]> axes
Definition constraints.hpp:55
size_t num_constraints
Definition constraints.hpp:35
View< constraints::ConstraintType * > type
Definition constraints.hpp:39
View< double *[3]>::HostMirror host_output
Definition constraints.hpp:64
A container providing handle to all structural elements present in the model.
Definition elements.hpp:20
This object manages the assembly and solution of linear system arising from the generalized-alpha bas...
Definition solver.hpp:21
size_t num_system_nodes
Definition solver.hpp:73
std::vector< double > convergence_err
Definition solver.hpp:83
Container for storing the complete system state of the simulation at a given time increment.
Definition state.hpp:18
View< double *[7]> x0
Definition state.hpp:29
View< double *[6]> v
Definition state.hpp:34
View< double *[6]> a
Definition state.hpp:36
View< double *[7]> x
Definition state.hpp:30
View< double *[7]> q
Definition state.hpp:33
View< double *[6]> vd
Definition state.hpp:35
A Struct containing the paramters used to control the time stepping process.
Definition step_parameters.hpp:12
double alpha_m
Definition step_parameters.hpp:16
size_t max_iter
Definition step_parameters.hpp:14
double alpha_f
Definition step_parameters.hpp:17
Kernel that calculates the output for a constraints, for use as feedback to controllers.
Definition calculate_constraint_output.hpp:15
A Kernel to update the algorithmic acceleration based on the acceleration and generalized alpha solve...
Definition update_algorithmic_acceleration.hpp:12
A Kernel to update the absolute position of each node based on the solver's current state and the ini...
Definition update_global_position.hpp:14