G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsALMRiks.hpp
Go to the documentation of this file.
1 
14 #pragma once
15 
16 #include <typeinfo>
17 #include <gsStructuralAnalysis/src/gsALMSolvers/gsALMHelper.h>
18 
19 namespace gismo
20 {
21 
22 template <class T>
24 {
25  m_numDof = m_forcing.size();
26  m_DeltaU = m_U = gsVector<T>::Zero(m_numDof);
27  m_DeltaL = m_L = 0.0;
28 
29  m_Uprev = gsVector<T>::Zero(m_numDof);
30  m_Lprev = 0.0;
31 }
32 
33 // ------------------------------------------------------------------------------------------------------------
34 // ---------------------------------------Riks's method--------------------------------------------------------
35 // ------------------------------------------------------------------------------------------------------------
36 
37 template <class T>
39 {
40  m_jacMat = computeJacobian();
41  this->factorizeMatrix(m_jacMat);
42  computeUt(); // rhs does not depend on solution
43  computeUbar(); // rhs contains residual and should be computed every time
44 
45 }
46 
47 template <class T>
49 {
50  m_jacMat = computeJacobian();
51  this->factorizeMatrix(m_jacMat);
52  computeUt(); // rhs does not depend on solution
53 }
54 
55 // template <class T>
56 // void gsALMRiks<T>::iteration()
57 // {
58 // m_deltaUbar = this->solveSystem(-m_resVec);
59 // m_deltaUt = this->solveSystem(m_forcing); // note the minus!!
60 
61 // m_deltaL = - ( (m_DeltaU).dot(m_deltaUbar) ) / ( (m_DeltaL)*m_forcing.dot(m_forcing) + (m_DeltaU).dot(m_deltaUt) );
62 // m_deltaU = m_deltaUbar + m_deltaL*m_deltaUt;
63 
64 // m_DeltaU += m_deltaU;
65 // m_DeltaL += m_deltaL;
66 // }
67 
68 template <class T>
70 {
71  computeUbar(); // rhs contains residual and should be computed every time
72 
73  // Compute next solution
74  //
75  // Residual function
76  // r = m_phi * m_DeltaU.dot(m_DeltaU) + (1.0-m_phi) * m_DeltaL*m_DeltaL - m_arcLength*m_arcLength;
77  T r = m_phi*(m_U + m_DeltaU - m_U).dot(m_U + m_DeltaU - m_U) + (1-m_phi)*math::pow(m_L + m_DeltaL - m_L,2.0) - m_arcLength*m_arcLength;
78 
79  m_deltaL = - ( r + 2*m_phi*(m_DeltaU).dot(m_deltaUbar) ) / ( 2*(1-m_phi)*(m_DeltaL) + 2*m_phi*(m_DeltaU).dot(m_deltaUt) );
80  m_deltaU = m_deltaUbar + m_deltaL*m_deltaUt;
81 
82  m_DeltaU += m_deltaU;
83  m_DeltaL += m_deltaL;
84 }
85 
86 template <class T>
88 {
89  // (m_U,m_L) is the present solution (iteratively updated)
90  // (m_Uprev,m_Lprev) is the previously converged solution before (m_Lprev,m_Uprev)
91 
92  // Reset step
93  m_DeltaU = m_deltaU = gsVector<T>::Zero(m_numDof);
94  m_DeltaL = m_deltaL = 0.0;
95 }
96 
97 template <class T>
99 {
100  m_jacMat = computeJacobian();
101  this->factorizeMatrix(m_jacMat);
102 
103  // Define scaling
104  if (m_numDof ==1)
105  m_phi = 0.99999999999;
106  else
107  m_phi = 1./m_numDof;
108 
109  // Check if the solution on start and prev are similar.
110  // Then compute predictor of the method
111  T tol = 1e-10;
112 
113  if ( ((m_U-m_Uprev).norm() < tol) && ((m_L - m_Lprev) * (m_L - m_Lprev) < tol ) )
114  {
115  m_note+= "predictor\t";
116  T DL = 1.;
117  m_deltaUt = this->solveSystem(m_forcing);
118  m_deltaU = m_deltaUt / math::sqrt( m_deltaUt.dot(m_deltaUt) + m_DeltaL*DL );
119  m_deltaL = DL / math::sqrt( m_deltaUt.dot(m_deltaUt) + m_DeltaL*DL );
120  }
121  else
122  {
123  m_deltaL = 1./m_arcLength_prev*(m_L - m_Lprev);
124  m_deltaU = 1./m_arcLength_prev*(m_U - m_Uprev);
125  }
126 
127  // Update iterative step
128  m_deltaL *= m_arcLength;
129  m_deltaU *= m_arcLength;
130 
131  // Update load step
132  m_DeltaU += m_deltaU;
133  m_DeltaL += m_deltaL;
134 }
135 
136 template <class T>
138 {
139  GISMO_ASSERT(m_Uguess.rows()!=0 && m_Uguess.cols()!=0,"Guess is empty");
140 
141  m_jacMat = computeJacobian();
142  this->factorizeMatrix(m_jacMat);
143 
144  m_deltaUt = this->solveSystem(m_forcing);
145 
146  T tol = 1e-10;
147 
148  if ( ((m_Uguess-m_U).norm() < tol) && ((m_Lguess - m_L) * (m_Lguess - m_L) < tol ) )
149  {
150  m_note+= "predictor\t";
151  T DL = 1.;
152  m_deltaUt = this->solveSystem(m_forcing);
153  m_deltaU = m_deltaUt / math::sqrt( m_deltaUt.dot(m_deltaUt) + m_DeltaL*DL );
154  m_deltaL = DL / math::sqrt( m_deltaUt.dot(m_deltaUt) + m_DeltaL*DL );
155  }
156  else
157  {
158  m_deltaL = 1./m_arcLength_prev*(m_Lguess - m_L);
159  m_deltaU = 1./m_arcLength_prev*(m_Uguess - m_U);
160  }
161 
162  // Update iterative step
163  m_deltaL *= m_arcLength;
164  m_deltaU *= m_arcLength;
165 
166  m_DeltaU = m_deltaU;
167  m_DeltaL = m_deltaL;
168 
169  m_Uguess.resize(0);
170 }
171 
172 // template <class T>
173 // void gsALMRiks<T>::predictor()
174 // {
175 // // Check if the solution on start and prev are similar.
176 // // Then compute predictor of the method
177 // T tol = 1e-10;
178 
179 // if ( ((m_U-m_Uprev).norm() < tol) && ((m_L - m_Lprev) * (m_L - m_Lprev) < tol ) )
180 // {
181 // m_note+= "predictor\t";
182 // T DL = 1.;
183 // m_jacMat = computeJacobian();
184 // this->factorizeMatrix(m_jacMat);
185 // m_deltaUt = this->solveSystem(m_forcing);
186 // m_deltaU = m_deltaUt / math::sqrt( m_deltaUt.dot(m_deltaUt) + m_DeltaL*DL );
187 // m_deltaL = DL / math::sqrt( m_deltaUt.dot(m_deltaUt) + m_DeltaL*DL );
188 // }
189 // else
190 // {
191 // m_deltaL = 1./m_arcLength*(m_L - m_Lprev);
192 // m_deltaU = 1./m_arcLength*(m_U - m_Uprev);
193 // }
194 
195 // // Update iterative step
196 // m_deltaL *= m_arcLength;
197 // m_deltaU *= m_arcLength;
198 
199 // // Update load step
200 // m_DeltaU += m_deltaU;
201 // m_DeltaL += m_deltaL;
202 // }
203 
204 template <class T>
206 {
207  m_converged = true;
208  m_Uprev = m_U;
209  m_Lprev = m_L;
210  m_U += m_DeltaU;
211  m_L += m_DeltaL;
212 }
213 
214 // ------------------------------------------------------------------------------------------------------------
215 // ---------------------------------------Output functions-----------------------------------------------------
216 // ------------------------------------------------------------------------------------------------------------
217 
218 template <class T>
220 {
221  gsInfo<<"\t";
222  gsInfo<<std::setw(4)<<std::left<<"It.";
223  gsInfo<<std::setw(17)<<std::left<<"Res. F";
224  gsInfo<<std::setw(17)<<std::left<<"|dU|/|Du|";
225  gsInfo<<std::setw(17)<<std::left<<"dL/DL";
226  gsInfo<<std::setw(17)<<std::left<<"|U|";
227  gsInfo<<std::setw(17)<<std::left<<"L";
228  gsInfo<<std::setw(17)<<std::left<<"|DU|";
229  gsInfo<<std::setw(17)<<std::left<<"DL";
230  gsInfo<<std::setw(17)<<std::left<<"|dU|";
231  gsInfo<<std::setw(17)<<std::left<<"dL";
232  gsInfo<<std::setw(17)<<std::left<<"ds²";
233  gsInfo<<std::setw(17)<<std::left<<"|dU|²";
234  gsInfo<<std::setw(17)<<std::left<<"dL²";
235  gsInfo<<std::setw(17)<<std::left<<"Dmin";
236  gsInfo<<std::setw(17)<<std::left<<"m_note";
237  gsInfo<<"\n";
238 
239  m_note = "";
240 }
241 
242 template <class T>
244 {
245  computeStability(false);
246 
247  gsInfo<<"\t";
248  gsInfo<<std::setw(4)<<std::left<<m_numIterations;
249  gsInfo<<std::setw(17)<<std::left<<m_residueF;
250  gsInfo<<std::setw(17)<<std::left<<m_residueU;
251  gsInfo<<std::setw(17)<<std::left<<m_residueL;
252  gsInfo<<std::setw(17)<<std::left<<(m_U+m_DeltaU).norm();
253  gsInfo<<std::setw(17)<<std::left<<(m_L + m_DeltaL);
254  gsInfo<<std::setw(17)<<std::left<<m_DeltaU.norm();
255  gsInfo<<std::setw(17)<<std::left<<m_DeltaL;
256  gsInfo<<std::setw(17)<<std::left<<m_deltaU.norm();
257  gsInfo<<std::setw(17)<<std::left<<m_deltaL;
258  gsInfo<<std::setw(17)<<std::left<<m_phi * math::pow(m_DeltaU.norm(),2.0) + (1.0-m_phi) * math::pow(m_DeltaL,2.0);
259  gsInfo<<std::setw(17)<<std::left<<m_phi * math::pow(m_DeltaU.norm(),2.0);
260  gsInfo<<std::setw(17)<<std::left<<(1-m_phi) * math::pow(m_DeltaL,2.0);
261  gsInfo<<std::setw(17)<<std::left<<m_indicator;
262  gsInfo<<std::setw(17)<<std::left<<m_note;
263  gsInfo<<"\n";
264 
265  m_note = "";
266 }
267 
268 } // namespace gismo
Performs the Riks arc length method to solve a nonlinear equation system.
Definition: gsALMRiks.h:29
void iterationFinish()
See gsALMBase.
Definition: gsALMRiks.hpp:205
void initMethods()
See gsALMBase.
Definition: gsALMRiks.hpp:23
void quasiNewtonIteration()
See gsALMBase.
Definition: gsALMRiks.hpp:48
void initiateStep()
See gsALMBase.
Definition: gsALMRiks.hpp:87
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition: gsVector.h:35
#define gsInfo
Definition: gsDebug.h:43
void iteration()
See gsALMBase.
Definition: gsALMRiks.hpp:69
void stepOutput()
See gsALMBase.
Definition: gsALMRiks.hpp:243
void initOutput()
See gsALMBase.
Definition: gsALMRiks.hpp:219
void predictor()
See gsALMBase.
Definition: gsALMRiks.hpp:98
void quasiNewtonPredictor()
See gsALMBase.
Definition: gsALMRiks.hpp:38