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.
control_module_2d_process.hpp
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: Ignasi de Pouplana
11 //
12 
13 
14 #if !defined(KRATOS_CONTROL_MODULE_2D_PROCESS )
15 #define KRATOS_CONTROL_MODULE_2D_PROCESS
16 
17 // Project includes
18 #include "includes/table.h"
20 #include "processes/process.h"
21 
22 // Application includes
24 
26 
27 namespace Kratos
28 {
29 
31 {
32 
33 public:
34 
36 
39 
41 
44  ModelPart& rModelPart,
45  Parameters rParameters
46  ) : Process() ,
47  mrModelPart(rModelPart)
48  {
50 
51  Parameters default_parameters( R"(
52  {
53  "model_part_name":"MODEL_PART_NAME",
54  "imposed_direction" : 0,
55  "alternate_axis_loading": false,
56  "control_module_time_step": 1.0e-5,
57  "target_stress_table_id" : 0,
58  "initial_velocity" : 0.0,
59  "limit_velocity" : 0.1,
60  "velocity_factor" : 1.0,
61  "compression_length" : 1.0,
62  "young_modulus" : 1.0e9,
63  "stress_increment_tolerance": 100.0,
64  "update_stiffness": true,
65  "stiffness_alpha": 1.0,
66  "start_time" : 0.0,
67  "stress_averaging_time": 1e-7
68  } )" );
69 
70  // Now validate agains defaults -- this also ensures no type mismatch
71  rParameters.ValidateAndAssignDefaults(default_parameters);
72 
73  mImposedDirection = rParameters["imposed_direction"].GetInt();
74  mTargetStressTableId = rParameters["target_stress_table_id"].GetInt();
75  mVelocity = rParameters["initial_velocity"].GetDouble();
76  mLimitVelocity = rParameters["limit_velocity"].GetDouble();
77  mVelocityFactor = rParameters["velocity_factor"].GetDouble();
78  mCompressionLength = rParameters["compression_length"].GetDouble();
79  mStartTime = rParameters["start_time"].GetDouble();
80  mStressIncrementTolerance = rParameters["stress_increment_tolerance"].GetDouble();
81  mUpdateStiffness = rParameters["update_stiffness"].GetBool();
82  mReactionStressOld = 0.0;
83  mStiffness = rParameters["young_modulus"].GetDouble()/mCompressionLength; // mStiffness is actually a stiffness over an area
84  mStiffnessAlpha = rParameters["stiffness_alpha"].GetDouble();
85  mStressAveragingTime = rParameters["stress_averaging_time"].GetDouble();
86  mVectorOfLastStresses.resize(0);
87 
88  // NOTE: Alternate axis loading only works for X,Y,Z loading. Radial loading is always applied.
89  mAlternateAxisLoading = rParameters["alternate_axis_loading"].GetBool();
90  mCMTimeStep = rParameters["control_module_time_step"].GetDouble();
91  mStep = 0;
92 
93  // Initialize Variables
94  mrModelPart.GetProcessInfo().SetValue(TARGET_STRESS_Z,0.0);
95  const int NNodes = static_cast<int>(mrModelPart.Nodes().size());
96  ModelPart::NodesContainerType::iterator it_begin = mrModelPart.NodesBegin();
97  array_1d<double,3> zero_vector = ZeroVector(3);
98  #pragma omp parallel for
99  for(int i = 0; i<NNodes; i++) {
100  ModelPart::NodesContainerType::iterator it = it_begin + i;
101  it->SetValue(TARGET_STRESS,zero_vector);
102  it->SetValue(REACTION_STRESS,zero_vector);
103  it->SetValue(LOADING_VELOCITY,zero_vector);
104  }
105 
106  KRATOS_CATCH("");
107  }
108 
110 
113 
115 
117  void Execute() override
118  {
119  }
120 
123  void ExecuteInitialize() override
124  {
125  KRATOS_TRY;
126 
127  const int NNodes = static_cast<int>(mrModelPart.Nodes().size());
128  ModelPart::NodesContainerType::iterator it_begin = mrModelPart.NodesBegin();
129 
130  if (mImposedDirection == 0) {
131  // X direction
132  #pragma omp parallel for
133  for(int i = 0; i<NNodes; i++) {
134  ModelPart::NodesContainerType::iterator it = it_begin + i;
135  it->FastGetSolutionStepValue(DISPLACEMENT_X) = 0.0;
136  it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_X) = 0.0;
137  it->FastGetSolutionStepValue(VELOCITY_X) = mVelocity;
138  it->FastGetSolutionStepValue(DISPLACEMENT_Z) = 0.0;
139  it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_Z) = 0.0;
140  it->FastGetSolutionStepValue(VELOCITY_Z) = 0.0;
141  }
142  } else if (mImposedDirection == 1) {
143  // Y direction
144  #pragma omp parallel for
145  for(int i = 0; i<NNodes; i++) {
146  ModelPart::NodesContainerType::iterator it = it_begin + i;
147  it->FastGetSolutionStepValue(DISPLACEMENT_Y) = 0.0;
148  it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_Y) = 0.0;
149  it->FastGetSolutionStepValue(VELOCITY_Y) = mVelocity;
150  it->FastGetSolutionStepValue(DISPLACEMENT_Z) = 0.0;
151  it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_Z) = 0.0;
152  it->FastGetSolutionStepValue(VELOCITY_Z) = 0.0;
153  }
154  } else if (mImposedDirection == 2) {
155  // Z direction
156  mrModelPart.GetProcessInfo()[IMPOSED_Z_STRAIN_VALUE] = 0.0;
157  } else {
158  // Radial direction
159  #pragma omp parallel for
160  for(int i = 0; i<NNodes; i++) {
161  ModelPart::NodesContainerType::iterator it = it_begin + i;
162  const double external_radius = std::sqrt(it->X()*it->X() + it->Y()*it->Y());
163  const double cos_theta = it->X()/external_radius;
164  const double sin_theta = it->Y()/external_radius;
165  it->FastGetSolutionStepValue(DISPLACEMENT_X) = 0.0;
166  it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_X) = 0.0;
167  it->FastGetSolutionStepValue(VELOCITY_X) = mVelocity * cos_theta;
168  it->FastGetSolutionStepValue(DISPLACEMENT_Y) = 0.0;
169  it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_Y) = 0.0;
170  it->FastGetSolutionStepValue(VELOCITY_Y) = mVelocity * sin_theta;
171  it->FastGetSolutionStepValue(DISPLACEMENT_Z) = 0.0;
172  it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_Z) = 0.0;
173  it->FastGetSolutionStepValue(VELOCITY_Z) = 0.0;
174  }
175  }
176 
177  KRATOS_CATCH("");
178  }
179 
182  {
183  KRATOS_TRY;
184 
185  const double CurrentTime = mrModelPart.GetProcessInfo()[TIME];
186  TableType::Pointer pTargetStressTable = mrModelPart.pGetTable(mTargetStressTableId);
187 
188  mStep += 1;
189  if (mStep == 1) {
190  unsigned int cm_num_super_steps = (int)(mCMTimeStep / mrModelPart.GetProcessInfo()[DELTA_TIME]);
191  if(cm_num_super_steps < 1) {cm_num_super_steps = 1;}
192  mXStartStep = 1;
193  mXEndStep = mXStartStep + cm_num_super_steps - 1;
194  mYStartStep = mXEndStep + 1;
195  mYEndStep = mYStartStep + cm_num_super_steps - 1;
196  mZStartStep = mYEndStep + 1;
197  mZEndStep = mZStartStep + cm_num_super_steps - 1;
198  }
199 
200  double ReactionStress = CalculateReactionStress();
201  ReactionStress = UpdateVectorOfHistoricalStressesAndComputeNewAverage(ReactionStress);
202 
203  // Check whether this is a loading step for the current axis
204  IsTimeToApplyCM();
205 
206  if (mApplyCM == true) {
207 
208  // Update K if required
209  double delta_time;
210  if (mAlternateAxisLoading == false) {
211  delta_time = mrModelPart.GetProcessInfo()[DELTA_TIME];
212  if(mUpdateStiffness == true) {
213  double K_estimated = EstimateStiffness(ReactionStress,delta_time);
214  mStiffness = mStiffnessAlpha * K_estimated + (1.0 - mStiffnessAlpha) * mStiffness;
215  }
216  } else {
218  // delta_time = 3.0*mCMTimeStep;
219  }
220 
221  // Update velocity
222  const double NextTargetStress = pTargetStressTable->GetValue(CurrentTime+delta_time);
223  const double df_target = NextTargetStress - ReactionStress;
224  double delta_velocity = df_target/(mStiffness * delta_time) - mVelocity;
225  if(std::abs(df_target) < mStressIncrementTolerance) { delta_velocity = -mVelocity; }
226  if (mAlternateAxisLoading == false) {
227  mReactionStressOld = ReactionStress;
228  // v_new = vf*v_new + (1-vf)*v_old
229  mVelocity += mVelocityFactor * delta_velocity;
230  if(std::abs(mVelocity) > std::abs(mLimitVelocity)) {
231  if(mVelocity >= 0.0) { mVelocity = std::abs(mLimitVelocity); }
232  else { mVelocity = - std::abs(mLimitVelocity); }
233  }
234  } else if (mIsStartStep == true) {
235  mReactionStressOld = ReactionStress;
236  mVelocity += mVelocityFactor * delta_velocity;
237  if(std::abs(mVelocity) > std::abs(mLimitVelocity)) {
238  if(mVelocity >= 0.0) { mVelocity = std::abs(mLimitVelocity); }
239  else { mVelocity = - std::abs(mLimitVelocity); }
240  }
241  }
242 
243  UpdateMotionAndSaveVariablesToPrint(mVelocity, pTargetStressTable->GetValue(CurrentTime), ReactionStress);
244  }
245  else {
246  UpdateMotionAndSaveVariablesToPrint(0.0, pTargetStressTable->GetValue(CurrentTime), ReactionStress);
247  }
248 
249  // UpdateMotionAndSaveVariablesToPrint(mVelocity, pTargetStressTable->GetValue(CurrentTime), ReactionStress);
250 
251  KRATOS_CATCH("");
252  }
253 
258  {
259  // Update K with latest ReactionStress after the axis has been loaded
260  if (mAlternateAxisLoading == true && mApplyCM == true && mIsEndStep == true) {
261  double ReactionStress = CalculateReactionStress();
262  if(mUpdateStiffness == true) {
263  double K_estimated = EstimateStiffness(ReactionStress,mCMTimeStep);
264  mStiffness = mStiffnessAlpha * K_estimated + (1.0 - mStiffnessAlpha) * mStiffness;
265  }
266  }
267  }
268 
270  std::string Info() const override
271  {
272  return "ControlModule2DProcess";
273  }
274 
276  void PrintInfo(std::ostream& rOStream) const override
277  {
278  rOStream << "ControlModule2DProcess";
279  }
280 
282  void PrintData(std::ostream& rOStream) const override
283  {
284  }
285 
287 
288 protected:
289 
291 
293  unsigned int mImposedDirection;
294  unsigned int mTargetStressTableId;
295  double mVelocity;
299  double mStartTime;
302  double mStiffness;
304  std::vector<double> mVectorOfLastStresses;
307  unsigned int mXStartStep;
308  unsigned int mXEndStep;
309  unsigned int mYStartStep;
310  unsigned int mYEndStep;
311  unsigned int mZStartStep;
312  unsigned int mZEndStep;
313  bool mApplyCM;
316  unsigned int mStep;
317  double mCMTimeStep;
319 
321 
322 private:
323 
325  ControlModule2DProcess& operator=(ControlModule2DProcess const& rOther);
326 
328  //ControlModule2DProcess(ControlModule2DProcess const& rOther);
329 
330  double UpdateVectorOfHistoricalStressesAndComputeNewAverage(const double& last_reaction) {
331  KRATOS_TRY;
332  int length_of_vector = mVectorOfLastStresses.size();
333  if (length_of_vector == 0) { //only the first time
334  int number_of_steps_for_stress_averaging = (int) (mStressAveragingTime / mrModelPart.GetProcessInfo()[DELTA_TIME]);
335  if(number_of_steps_for_stress_averaging < 1) number_of_steps_for_stress_averaging = 1;
336  mVectorOfLastStresses.resize(number_of_steps_for_stress_averaging);
337  KRATOS_INFO("DEM") << " 'number_of_steps_for_stress_averaging' is "<< number_of_steps_for_stress_averaging << std::endl;
338  }
339 
340  length_of_vector = mVectorOfLastStresses.size();
341 
342  if(length_of_vector > 1) {
343  for(int i=1; i<length_of_vector; i++) {
345  }
346  }
347  mVectorOfLastStresses[length_of_vector-1] = last_reaction;
348 
349  double average = 0.0;
350  for(int i=0; i<length_of_vector; i++) {
351  average += mVectorOfLastStresses[i];
352  }
353  average /= (double) length_of_vector;
354  return average;
355 
356  KRATOS_CATCH("");
357  }
358 
359  void IsTimeToApplyCM(){
360  const double current_time = mrModelPart.GetProcessInfo()[TIME];
361  mApplyCM = false;
362  mIsStartStep = false;
363  mIsEndStep = false;
364  // TODO
365  // double r = (double)(rand()/(RAND_MAX)) - 0.5;
366  // unsigned int cm_num_super_steps = (int)(r + mCMTimeStep / mrModelPart.GetProcessInfo()[DELTA_TIME]);
367  unsigned int cm_num_super_steps = (int)(mCMTimeStep / mrModelPart.GetProcessInfo()[DELTA_TIME]);
368 
369  if(current_time >= mStartTime) {
370  if (mAlternateAxisLoading == true) {
371  if (mImposedDirection == 0) {
372  if (mStep >= mXStartStep && mStep <= mXEndStep) {
373  mApplyCM = true;
374  if(mStep == mXStartStep){
375  mIsStartStep = true;
376  } else if (mStep == mXEndStep) {
377  mIsEndStep = true;
378  }
379  if (mIsEndStep == true) {
380  mXStartStep += 3*cm_num_super_steps;
381  mXEndStep += 3*cm_num_super_steps;
382  }
383  }
384  } else if (mImposedDirection == 1) {
385  if (mStep >= mYStartStep && mStep <= mYEndStep) {
386  mApplyCM = true;
387  if(mStep == mYStartStep){
388  mIsStartStep = true;
389  } else if (mStep == mYEndStep) {
390  mIsEndStep = true;
391  }
392  if (mIsEndStep == true) {
393  mYStartStep += 3*cm_num_super_steps;
394  mYEndStep += 3*cm_num_super_steps;
395  }
396  }
397  } else if (mImposedDirection == 2) {
398  if (mStep >= mZStartStep && mStep <= mZEndStep) {
399  mApplyCM = true;
400  if(mStep == mZStartStep){
401  mIsStartStep = true;
402  } else if (mStep == mZEndStep) {
403  mIsEndStep = true;
404  }
405  if (mIsEndStep == true) {
406  mZStartStep += 3*cm_num_super_steps;
407  mZEndStep += 3*cm_num_super_steps;
408  }
409  }
410  } else {
411  mApplyCM = true;
412  mIsStartStep = true;
413  mIsEndStep = true;
414  }
415  } else {
416  mApplyCM = true;
417  mIsStartStep = true;
418  mIsEndStep = true;
419  }
420  }
421  }
422 
423  double CalculateReactionStress() {
424  const int NNodes = static_cast<int>(mrModelPart.Nodes().size());
425  ModelPart::NodesContainerType::iterator it_begin = mrModelPart.NodesBegin();
426 
427  // Calculate face_area
428  double face_area = 0.0;
429  if (mImposedDirection == 2) { // Z direction
431 
432  #pragma omp parallel for reduction(+:face_area)
433  for (int i = 0; i < (int)rElements.size(); i++) {
434  ModelPart::ElementsContainerType::ptr_iterator ptr_itElem = rElements.ptr_begin() + i;
435  Element* p_element = ptr_itElem->get();
436  SphericContinuumParticle* pDemElem = dynamic_cast<SphericContinuumParticle*>(p_element);
437  const double radius = pDemElem->GetRadius();
438  face_area += Globals::Pi*radius*radius;
439  }
440  } else { // X and Y directions
441  const int NCons = static_cast<int>(mrModelPart.Conditions().size());
442  ModelPart::ConditionsContainerType::iterator con_begin = mrModelPart.ConditionsBegin();
443  #pragma omp parallel for reduction(+:face_area)
444  for(int i = 0; i < NCons; i++) {
445  ModelPart::ConditionsContainerType::iterator itCond = con_begin + i;
446  face_area += itCond->GetGeometry().Area();
447  }
448  }
449 
450  // Calculate ReactionStress
451  double FaceReaction = 0.0;
452  if (mImposedDirection == 0) { // X direction
453  #pragma omp parallel for reduction(+:FaceReaction)
454  for(int i = 0; i<NNodes; i++) {
455  ModelPart::NodesContainerType::iterator it = it_begin + i;
456  FaceReaction -= it->FastGetSolutionStepValue(CONTACT_FORCES_X);
457  }
458  } else if (mImposedDirection == 1) { // Y direction
459  #pragma omp parallel for reduction(+:FaceReaction)
460  for(int i = 0; i<NNodes; i++) {
461  ModelPart::NodesContainerType::iterator it = it_begin + i;
462  FaceReaction -= it->FastGetSolutionStepValue(CONTACT_FORCES_Y);
463  }
464  } else if (mImposedDirection == 2) { // Z direction
466 
467  #pragma omp parallel for reduction(+:FaceReaction)
468  for (int i = 0; i < (int)rElements.size(); i++) {
469  ModelPart::ElementsContainerType::ptr_iterator ptr_itElem = rElements.ptr_begin() + i;
470  Element* p_element = ptr_itElem->get();
471  SphericContinuumParticle* pDemElem = dynamic_cast<SphericContinuumParticle*>(p_element);
472  BoundedMatrix<double, 3, 3> stress_tensor = ZeroMatrix(3,3);
473  noalias(stress_tensor) = (*(pDemElem->mSymmStressTensor));
474  const double radius = pDemElem->GetRadius();
475  FaceReaction += stress_tensor(2,2) * Globals::Pi*radius*radius;
476  }
477  } else { // Radial direction
478  #pragma omp parallel for reduction(+:FaceReaction)
479  for(int i = 0; i<NNodes; i++) {
480  ModelPart::NodesContainerType::iterator it = it_begin + i;
481  // Unit normal vector pointing outwards
482  array_1d<double,2> n;
483  n[0] = it->X();
484  n[1] = it->Y();
485  double inv_norm = 1.0/norm_2(n);
486  n[0] *= inv_norm;
487  n[1] *= inv_norm;
488  // Scalar product between reaction and normal
489  double n_dot_r = n[0] * it->FastGetSolutionStepValue(CONTACT_FORCES_X) + n[1] * it->FastGetSolutionStepValue(CONTACT_FORCES_Y);
490  FaceReaction -= n_dot_r;
491  }
492  // FaceReaction = 0.0;
493  // for(int i = 0; i<NNodes; i++) {
494  // ModelPart::NodesContainerType::iterator it = it_begin + i;
495  // // Unit normal vector pointing outwards
496  // array_1d<double,2> n;
497  // n[0] = it->X();
498  // n[1] = it->Y();
499  // double inv_norm = 1.0/norm_2(n);
500  // n[0] *= inv_norm;
501  // n[1] *= inv_norm;
502  // // Scalar product between reaction and normal
503  // double n_dot_r = n[0] * it->FastGetSolutionStepValue(CONTACT_FORCES_X) + n[1] * it->FastGetSolutionStepValue(CONTACT_FORCES_Y);
504  // FaceReaction -= n_dot_r;
505  // }
506  }
507 
508  double ReactionStress;
509  if (std::abs(face_area) > 1.0e-12) {
510  ReactionStress = FaceReaction/face_area;
511  } else {
512  ReactionStress = 0.0;
513  }
514 
515  return ReactionStress;
516  }
517 
518  double EstimateStiffness(const double& rReactionStress, const double& rDeltaTime) {
519  double K_estimated = mStiffness;
520  if(std::abs(mVelocity) > 1.0e-12 && std::abs(rReactionStress-mReactionStressOld) > mStressIncrementTolerance) {
521  K_estimated = std::abs((rReactionStress-mReactionStressOld)/(mVelocity * rDeltaTime));
522  }
523  return K_estimated;
524  }
525 
526  void UpdateMotionAndSaveVariablesToPrint(const double rVelocity, const double& rTargetStress, const double& rReactionStress) {
527 
528  const int NNodes = static_cast<int>(mrModelPart.Nodes().size());
529  ModelPart::NodesContainerType::iterator it_begin = mrModelPart.NodesBegin();
530 
531  // Update Imposed displacement
532  if (mImposedDirection == 0) { // X direction
533  #pragma omp parallel for
534  for(int i = 0; i<NNodes; i++) {
535  ModelPart::NodesContainerType::iterator it = it_begin + i;
536  it->FastGetSolutionStepValue(VELOCITY_X) = rVelocity;
537  it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_X) = it->FastGetSolutionStepValue(VELOCITY_X) * mrModelPart.GetProcessInfo()[DELTA_TIME];
538  it->FastGetSolutionStepValue(DISPLACEMENT_X) += it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_X);
539  it->X() = it->X0() + it->FastGetSolutionStepValue(DISPLACEMENT_X);
540  // Save calculated velocity and reaction for print
541  // TODO: print errors:
542  // max_relative
543  // max_absolute
544  // average_relative
545  // average_absolute
546  it->GetValue(TARGET_STRESS_X) = rTargetStress;
547  it->GetValue(REACTION_STRESS_X) = rReactionStress;
548  it->GetValue(LOADING_VELOCITY_X) = rVelocity;
549  }
550  } else if (mImposedDirection == 1) { // Y direction
551  #pragma omp parallel for
552  for(int i = 0; i<NNodes; i++) {
553  ModelPart::NodesContainerType::iterator it = it_begin + i;
554  it->FastGetSolutionStepValue(VELOCITY_Y) = rVelocity;
555  it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_Y) = it->FastGetSolutionStepValue(VELOCITY_Y) * mrModelPart.GetProcessInfo()[DELTA_TIME];
556  it->FastGetSolutionStepValue(DISPLACEMENT_Y) += it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_Y);
557  it->Y() = it->Y0() + it->FastGetSolutionStepValue(DISPLACEMENT_Y);
558  // Save calculated velocity and reaction for print
559  it->GetValue(TARGET_STRESS_Y) = rTargetStress;
560  it->GetValue(REACTION_STRESS_Y) = rReactionStress;
561  it->GetValue(LOADING_VELOCITY_Y) = rVelocity;
562  }
563  } else if (mImposedDirection == 2) { // Z direction
564  mrModelPart.GetProcessInfo()[IMPOSED_Z_STRAIN_VALUE] += rVelocity*mrModelPart.GetProcessInfo()[DELTA_TIME]/mCompressionLength;
565  #pragma omp parallel for
566  for(int i = 0; i<NNodes; i++) {
567  ModelPart::NodesContainerType::iterator it = it_begin + i;
568  // Save calculated velocity and reaction for print
569  it->GetValue(TARGET_STRESS_Z) = rTargetStress;
570  it->GetValue(REACTION_STRESS_Z) = rReactionStress;
571  it->GetValue(LOADING_VELOCITY_Z) = rVelocity;
572  }
573  mrModelPart.GetProcessInfo()[TARGET_STRESS_Z] = std::abs(rTargetStress);
574  } else { // Radial direction
575  #pragma omp parallel for
576  for(int i = 0; i<NNodes; i++) {
577  ModelPart::NodesContainerType::iterator it = it_begin + i;
578  const double external_radius = std::sqrt(it->X()*it->X() + it->Y()*it->Y());
579  const double cos_theta = it->X()/external_radius;
580  const double sin_theta = it->Y()/external_radius;
581  it->FastGetSolutionStepValue(VELOCITY_X) = rVelocity * cos_theta;
582  it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_X) = it->FastGetSolutionStepValue(VELOCITY_X) * mrModelPart.GetProcessInfo()[DELTA_TIME];
583  it->FastGetSolutionStepValue(DISPLACEMENT_X) += it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_X);
584  it->X() = it->X0() + it->FastGetSolutionStepValue(DISPLACEMENT_X);
585  it->FastGetSolutionStepValue(VELOCITY_Y) = rVelocity * sin_theta;
586  it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_Y) = it->FastGetSolutionStepValue(VELOCITY_Y) * mrModelPart.GetProcessInfo()[DELTA_TIME];
587  it->FastGetSolutionStepValue(DISPLACEMENT_Y) += it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_Y);
588  it->Y() = it->Y0() + it->FastGetSolutionStepValue(DISPLACEMENT_Y);
589  // Save calculated velocity and reaction for print
590  it->GetValue(TARGET_STRESS_X) = rTargetStress * cos_theta;
591  it->GetValue(TARGET_STRESS_Y) = rTargetStress * sin_theta;
592  it->GetValue(REACTION_STRESS_X) = rReactionStress * cos_theta;
593  it->GetValue(REACTION_STRESS_Y) = rReactionStress * sin_theta;
594  it->GetValue(LOADING_VELOCITY_X) = rVelocity * cos_theta;
595  it->GetValue(LOADING_VELOCITY_Y) = rVelocity * sin_theta;
596  }
597  }
598  }
599 
600 
601 }; // Class ControlModule2DProcess
602 
604 inline std::istream& operator >> (std::istream& rIStream,
605  ControlModule2DProcess& rThis);
606 
608 inline std::ostream& operator << (std::ostream& rOStream,
609  const ControlModule2DProcess& rThis)
610 {
611  rThis.PrintInfo(rOStream);
612  rOStream << std::endl;
613  rThis.PrintData(rOStream);
614 
615  return rOStream;
616 }
617 
618 } // namespace Kratos.
619 
620 #endif /* KRATOS_CONTROL_MODULE_2D_PROCESS defined */
MeshType & LocalMesh()
Returns the reference to the mesh storing all local entities.
Definition: communicator.cpp:245
Definition: control_module_2d_process.hpp:31
Table< double, double > TableType
Defining a table with double argument and result type as table type.
Definition: control_module_2d_process.hpp:38
unsigned int mXEndStep
Definition: control_module_2d_process.hpp:308
void ExecuteFinalizeSolutionStep() override
This function will be executed at every time step AFTER performing the solve phase.
Definition: control_module_2d_process.hpp:257
double mVelocity
Definition: control_module_2d_process.hpp:295
void Execute() override
Execute method is used to execute the ControlModule2DProcess algorithms.
Definition: control_module_2d_process.hpp:117
double mStiffness
Definition: control_module_2d_process.hpp:302
ControlModule2DProcess(ModelPart &rModelPart, Parameters rParameters)
Constructor.
Definition: control_module_2d_process.hpp:43
double mCompressionLength
Definition: control_module_2d_process.hpp:298
bool mApplyCM
Definition: control_module_2d_process.hpp:313
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: control_module_2d_process.hpp:282
double mLimitVelocity
Definition: control_module_2d_process.hpp:296
unsigned int mXStartStep
Definition: control_module_2d_process.hpp:307
ModelPart & mrModelPart
Member Variables.
Definition: control_module_2d_process.hpp:292
void ExecuteInitializeSolutionStep() override
this function will be executed at every time step BEFORE performing the solve phase
Definition: control_module_2d_process.hpp:181
unsigned int mStep
Definition: control_module_2d_process.hpp:316
double mStiffnessAlpha
Definition: control_module_2d_process.hpp:318
unsigned int mYStartStep
Definition: control_module_2d_process.hpp:309
double mStressAveragingTime
Definition: control_module_2d_process.hpp:305
bool mUpdateStiffness
Definition: control_module_2d_process.hpp:303
std::vector< double > mVectorOfLastStresses
Definition: control_module_2d_process.hpp:304
bool mIsStartStep
Definition: control_module_2d_process.hpp:314
double mCMTimeStep
Definition: control_module_2d_process.hpp:317
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: control_module_2d_process.hpp:276
double mVelocityFactor
Definition: control_module_2d_process.hpp:297
double mStartTime
Definition: control_module_2d_process.hpp:299
double mStressIncrementTolerance
Definition: control_module_2d_process.hpp:301
unsigned int mZEndStep
Definition: control_module_2d_process.hpp:312
unsigned int mZStartStep
Definition: control_module_2d_process.hpp:311
unsigned int mTargetStressTableId
Definition: control_module_2d_process.hpp:294
KRATOS_CLASS_POINTER_DEFINITION(ControlModule2DProcess)
bool mAlternateAxisLoading
Definition: control_module_2d_process.hpp:306
unsigned int mYEndStep
Definition: control_module_2d_process.hpp:310
unsigned int mImposedDirection
Definition: control_module_2d_process.hpp:293
bool mIsEndStep
Definition: control_module_2d_process.hpp:315
double mReactionStressOld
Definition: control_module_2d_process.hpp:300
~ControlModule2DProcess() override
Destructor.
Definition: control_module_2d_process.hpp:112
std::string Info() const override
Turn back information as a string.
Definition: control_module_2d_process.hpp:270
void ExecuteInitialize() override
Definition: control_module_2d_process.hpp:123
void SetValue(const Variable< TDataType > &rThisVariable, TDataType const &rValue)
Sets the value for a given variable.
Definition: data_value_container.h:320
TDataType & GetValue(const Variable< TDataType > &rThisVariable)
Gets the value associated with a given variable.
Definition: data_value_container.h:268
ElementsContainerType & Elements()
Definition: mesh.h:568
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ConditionIterator ConditionsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1361
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
Communicator & GetCommunicator()
Definition: model_part.h:1821
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
TableType::Pointer pGetTable(IndexType TableId)
Definition: model_part.h:595
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
double GetDouble() const
This method returns the double contained in the current Parameter.
Definition: kratos_parameters.cpp:657
int GetInt() const
This method returns the integer contained in the current Parameter.
Definition: kratos_parameters.cpp:666
void ValidateAndAssignDefaults(const Parameters &rDefaultParameters)
This function is designed to verify that the parameters under testing match the form prescribed by th...
Definition: kratos_parameters.cpp:1306
bool GetBool() const
This method returns the boolean contained in the current Parameter.
Definition: kratos_parameters.cpp:675
ptr_iterator ptr_begin()
Returns an iterator pointing to the beginning of the underlying data container.
Definition: pointer_vector_set.h:386
The base class for all processes in Kratos.
Definition: process.h:49
Definition: table.h:435
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_INFO(label)
Definition: logger.h:250
constexpr double Pi
Definition: global_variables.h:25
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
TExpressionType::data_type norm_2(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:625
KratosZeroMatrix< double > ZeroMatrix
Definition: amatrix_interface.h:559
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
REACTION_CHECK_STIFFNESS_FACTOR int
Definition: contact_structural_mechanics_application_variables.h:75
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
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
delta_time
Definition: generate_frictional_mortar_condition.py:130
float radius
Definition: mesh_to_mdpa_converter.py:18
float external_radius
Definition: mesh_to_mdpa_converter.py:24
int n
manufactured solution and derivatives (u=0 at z=0 dudz=0 at z=domain_height)
Definition: ode_solve.py:402
integer i
Definition: TensorModule.f:17