KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
residualbased_incremental_aitken_static_scheme.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main authors: Riccardo Rossi
11 //
12 
13 #if !defined( KRATOS_RESIDUALBASED_INCREMENTAL_AITKEN_STATIC_SCHEME_H_INCLUDED )
14 #define KRATOS_RESIDUALBASED_INCREMENTAL_AITKEN_STATIC_SCHEME_H_INCLUDED
15 
16 // System includes
17 #include <string>
18 #include <iostream>
19 
20 // External includes
21 
22 // Project includes
23 #include "includes/define.h"
25 
26 namespace Kratos
27 {
30 
33 
37 
41 
45 
49 
51 
53 template< class TSparseSpace,class TDenseSpace >
55 {
56 public:
59 
62 
64 
66 
68 
69  typedef typename BaseType::TDataType TDataType;
70 
72 
74 
76 
80 
85  {
86  }
87 
93  ResidualBasedIncrementalAitkenStaticScheme([](Parameters x) -> double {x.ValidateAndAssignDefaults(StaticGetDefaultParameters()); return x["default_omega"].GetDouble(); }(ThisParameters))
94  {
95  }
96 
101  explicit ResidualBasedIncrementalAitkenStaticScheme(double DefaultOmega):
102  mDefaultOmega(DefaultOmega),
103  mOldOmega(DefaultOmega)
104  {}
105 
108 
109 
113 
114 
118 
123  typename BaseSchemeType::Pointer Create(Parameters ThisParameters) const override
124  {
125  return Kratos::make_shared<ClassType>(ThisParameters);
126  }
127 
129 
135  void InitializeSolutionStep(ModelPart &r_model_part,
137  TSystemVectorType &Dx,
138  TSystemVectorType &b) override
139  {
140  BaseType::InitializeSolutionStep(r_model_part,A,Dx,b);
141  if (TSparseSpace::Size(mPreviousDx) != TSparseSpace::Size(Dx)) {
142  TSparseSpace::Resize(mPreviousDx, TSparseSpace::Size(Dx));
143  }
144  TSparseSpace::SetToZero(mPreviousDx);
145  mIterationCounter = 0;
146  }
147 
148 
150 
156  void Update(ModelPart &r_model_part,
157  DofsArrayType &rDofSet,
159  TSystemVectorType &Dx,
160  TSystemVectorType &b) override
161  {
162  mIterationCounter++;
163 
164  // Compute relaxation factor
165  double Omega;
166 
167  if (mIterationCounter > 1)
168  {
169  double Num = 0.0;
170  double Den = 0.0;
171 
172  for (unsigned int i = 0; i < Dx.size(); i++)
173  {
174  double Diff = Dx[i] - mPreviousDx[i];
175  Num += mPreviousDx[i] * Diff;
176  Den += Diff * Diff;
177  }
178 
179  Omega = - mOldOmega * Num / Den;
180  }
181  else
182  {
183  // Initialize the process using min(DefaultOmega,Omega_from_last_step)
184  if (mOldOmega < mDefaultOmega)
185  Omega = mOldOmega;
186  else
187  Omega = mDefaultOmega;
188  }
189 
190  //KRATOS_WATCH(Omega);
191 
192  // Update using relaxation factor
193  for(typename DofsArrayType::iterator i_dof = rDofSet.begin() ; i_dof != rDofSet.end() ; ++i_dof)
194  {
195  if(i_dof->IsFree())
196  {
197  i_dof->GetSolutionStepValue() += Omega * Dx[i_dof->EquationId()];
198  }
199  }
200 
201  // Store results for next iteration
202  boost::numeric::ublas::noalias(mPreviousDx) = Dx;
203  mOldOmega = Omega;
204  }
205 
207  {
208  Parameters default_parameters = Parameters(R"(
209  {
210  "name" : "ResidualBasedIncrementalAitkenStaticScheme",
211  "default_omega" : 0.1
212  })");
213 
214  return default_parameters;
215  }
216 
221  {
222  return StaticGetDefaultParameters();
223  }
224 
228 
229 
233 
237 
239  std::string Info() const override
240  {
241  return "ResidualBasedIncrementalAitkenStaticScheme";
242  }
243 
245  void PrintInfo(std::ostream& rOStream) const override
246  {
247  rOStream << Info();
248  }
249 
251  void PrintData(std::ostream& rOStream) const override
252  {
253  rOStream << Info();
254  }
255 
259 
260 
262 
263 protected:
266 
267 
271 
272 
276 
277 
281 
282 
286 
287 
291 
292 
296 
297 
299 
300 private:
303 
304 
308 
310  unsigned int mIterationCounter;
311 
313 
316  const double mDefaultOmega;
317 
319  double mOldOmega;
320 
322  TSystemVectorType mPreviousDx;
323 
327 
328 
332 
333 
337 
338 
342 
343 
347 
350 
352  ResidualBasedIncrementalAitkenStaticScheme(ResidualBasedIncrementalAitkenStaticScheme const& rOther) {}
353 
354 
356 
357 }; // Class ResidualBasedIncrementalAitkenStaticScheme
358 
360 
363 
364 
368 
369 
371 
373 
374 } // namespace Kratos.
375 
376 #endif // KRATOS_RESIDUALBASED_INCREMENTAL_AITKEN_STATIC_SCHEME_H_INCLUDED defined
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
std::string Info() const override
Turn back information as a string.
Definition: periodic_interface_process.hpp:93
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
A sorted associative container similar to an STL set, but uses a vector to store pointers to its data...
Definition: pointer_vector_set.h:72
boost::indirect_iterator< typename TContainerType::iterator > iterator
Definition: pointer_vector_set.h:95
iterator begin()
Returns an iterator pointing to the beginning of the container.
Definition: pointer_vector_set.h:278
iterator end()
Returns an iterator pointing to the end of the container.
Definition: pointer_vector_set.h:314
A scheme for the solution of a problem using Aitken iterations.
Definition: residualbased_incremental_aitken_static_scheme.h:55
ResidualBasedIncrementalAitkenStaticScheme(Parameters ThisParameters)
Default constructor. (with parameters)
Definition: residualbased_incremental_aitken_static_scheme.h:92
ResidualBasedIncrementalUpdateStaticScheme< TSparseSpace, TDenseSpace > BaseType
Definition: residualbased_incremental_aitken_static_scheme.h:65
Scheme< TSparseSpace, TDenseSpace > BaseSchemeType
Definition: residualbased_incremental_aitken_static_scheme.h:63
static Parameters StaticGetDefaultParameters()
Definition: residualbased_incremental_aitken_static_scheme.h:206
void InitializeSolutionStep(ModelPart &r_model_part, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Initialize the iteration counter at the beginning of each solution step.
Definition: residualbased_incremental_aitken_static_scheme.h:135
ResidualBasedIncrementalAitkenStaticScheme()
Default constructor.
Definition: residualbased_incremental_aitken_static_scheme.h:84
BaseSchemeType::Pointer Create(Parameters ThisParameters) const override
Create method.
Definition: residualbased_incremental_aitken_static_scheme.h:123
BaseType::TSystemVectorType TSystemVectorType
Definition: residualbased_incremental_aitken_static_scheme.h:75
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: residualbased_incremental_aitken_static_scheme.h:251
BaseType::DofsArrayType DofsArrayType
Definition: residualbased_incremental_aitken_static_scheme.h:71
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: residualbased_incremental_aitken_static_scheme.h:245
Parameters GetDefaultParameters() const override
This method provides the defaults parameters to avoid conflicts between the different constructors.
Definition: residualbased_incremental_aitken_static_scheme.h:220
BaseType::TDataType TDataType
Definition: residualbased_incremental_aitken_static_scheme.h:69
ResidualBasedIncrementalAitkenStaticScheme< TSparseSpace, TDenseSpace > ClassType
Definition: residualbased_incremental_aitken_static_scheme.h:67
KRATOS_CLASS_POINTER_DEFINITION(ResidualBasedIncrementalAitkenStaticScheme)
Pointer definition of ResidualBasedIncrementalAitkenStaticScheme.
BaseType::TSystemMatrixType TSystemMatrixType
Definition: residualbased_incremental_aitken_static_scheme.h:73
std::string Info() const override
Turn back information as a string.
Definition: residualbased_incremental_aitken_static_scheme.h:239
ResidualBasedIncrementalAitkenStaticScheme(double DefaultOmega)
Default constructor.
Definition: residualbased_incremental_aitken_static_scheme.h:101
void Update(ModelPart &r_model_part, DofsArrayType &rDofSet, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Update the degrees of freedom of the problem using Aitken's accelerator.
Definition: residualbased_incremental_aitken_static_scheme.h:156
~ResidualBasedIncrementalAitkenStaticScheme() override
Destructor.
Definition: residualbased_incremental_aitken_static_scheme.h:107
This class provides the implementation of a static scheme.
Definition: residualbased_incrementalupdate_static_scheme.h:57
BaseType::TDataType TDataType
Data type definition.
Definition: residualbased_incrementalupdate_static_scheme.h:76
BaseType::TSystemMatrixType TSystemMatrixType
Matrix type definition.
Definition: residualbased_incrementalupdate_static_scheme.h:78
BaseType::TSystemVectorType TSystemVectorType
Vector type definition.
Definition: residualbased_incrementalupdate_static_scheme.h:80
This class provides the implementation of the basic tasks that are needed by the solution strategy.
Definition: scheme.h:56
void InitializeSolutionStep(ConstructionUtility &rThisUtil, std::string ThermalSubModelPartName, std::string MechanicalSubModelPartName, std::string HeatFluxSubModelPartName, std::string HydraulicPressureSubModelPartName, bool thermal_conditions, bool mechanical_conditions, int phase)
Definition: add_custom_utilities_to_python.cpp:45
TSpaceType::IndexType Size(TSpaceType &dummy, typename TSpaceType::VectorType const &rV)
Definition: add_strategies_to_python.cpp:111
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
TABLE_NUMBER_ANGULAR_VELOCITY TABLE_NUMBER_MOMENT I33 BEAM_INERTIA_ROT_UNIT_LENGHT_Y KRATOS_DEFINE_APPLICATION_VARIABLE(DEM_APPLICATION, double, BEAM_INERTIA_ROT_UNIT_LENGHT_Z) typedef std double
Definition: DEM_application_variables.h:182
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
A
Definition: sensitivityMatrix.py:70
x
Definition: sensitivityMatrix.py:49
def ValidateAndAssignDefaults(defaults, settings, recursive=False)
Definition: sdof_solver.py:252
integer i
Definition: TensorModule.f:17