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.
construction_utility.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: Lorenzo Gracia
11 //
12 //
13 
14 #if !defined(KRATOS_CONSTRUCTION_UTILITIES)
15 #define KRATOS_CONSTRUCTION_UTILITIES
16 
17 // System includes
18 #include <cmath>
19 
20 // Project includes
21 #include "includes/model_part.h"
23 #include "utilities/openmp_utils.h"
24 #include "utilities/math_utils.h"
26 #include "includes/element.h"
27 
28 // Application includes
30 
31 namespace Kratos
32 {
33 
35 {
36 
37  public:
38  typedef std::size_t IndexType;
40 
41  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
42 
44  ConstructionUtility(ModelPart &rMechanicalModelPart, ModelPart &rThermalModelPart,
45  TableType &rTableAmbientTemp, Parameters &rParameters) : mrMechanicalModelPart(rMechanicalModelPart), mrThermalModelPart(rThermalModelPart), mrTableAmbientTemp(rTableAmbientTemp)
46  {
48 
49  // Getting values
50  mGravityDirection = rParameters["gravity_direction"].GetString();
51  mReferenceCoordinate = mHighestBlockHeight = rParameters["reservoir_bottom_coordinate_in_gravity_direction"].GetDouble();
52  mLiftHeight = rParameters["lift_height"].GetDouble();
53  mSourceType = rParameters["source_type"].GetString();
54  mAging = rParameters["aging"].GetBool();
55  mH0 = rParameters["h_0"].GetDouble();
56  mActivateSoilPart = rParameters["activate_soil_part"].GetBool();
57  mActivateExistingPart = rParameters["activate_existing_part"].GetBool();
59 
60  if (mActivateSoilPart == true)
61  {
62  mMechanicalSoilPart = rParameters["mechanical_soil_part"].GetString();
63  mThermalSoilPart = rParameters["thermal_soil_part"].GetString();
64  }
65  if (mActivateExistingPart == true)
66  {
67  mMechanicalExistingPart = rParameters["mechanical_existing_part"].GetString();
68  mThermalExistingPart = rParameters["thermal_existing_part"].GetString();
69  }
70 
71  if (mSourceType == "NonAdiabatic")
72  mAlphaInitial = rParameters["alpha_initial"].GetDouble();
73 
74  if (mAging == true)
75  mYoungInf = rParameters["young_inf"].GetDouble();
76 
77  KRATOS_CATCH("");
78  }
79 
81 
84 
85  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
86 
87  void Initialize()
88  {
89  KRATOS_TRY;
90 
91  const int nelements = mrMechanicalModelPart.GetMesh(0).Elements().size();
92 
95 
96  const ProcessInfo& r_current_process_info = mrMechanicalModelPart.GetProcessInfo();
97 
98  if (nelements != 0)
99  {
100  ModelPart::ElementsContainerType::iterator el_begin = mrMechanicalModelPart.ElementsBegin();
101  mNumNode = el_begin->GetGeometry().PointsNumber();
102 
103  // Deactivate all elements of both thermal and mechanical model parts
104  VariableUtils().SetFlag(ACTIVE, false, mrThermalModelPart.Elements());
106 
107  // Deactivate all nodes of one of the model parts (thermal) as both model parts share the same nodes
108  VariableUtils().SetFlag(ACTIVE, false, mrThermalModelPart.Nodes());
109  VariableUtils().SetFlag(SOLID, false, mrThermalModelPart.Nodes());
110 
111  block_for_each(mrMechanicalModelPart.Elements(), [&](auto& rMechanicalElement){
112  // Initialize non-active elements of the mechanical model part (to avoid segmentation fault)
113  rMechanicalElement.Initialize(r_current_process_info);
114  });
115  }
116 
117  // Activation of the existing parts, either the soil or the already built dam ( User must specify each part through the interface)
118  if (mActivateSoilPart == true)
119  {
120  const int soil_nelements = mrMechanicalModelPart.GetSubModelPart(mMechanicalSoilPart).Elements().size();
121 
122  if (soil_nelements != 0)
123  {
124  // Activate elements of the soil part of both model parts
127 
128  // Activate nodes of the soil part of one of the model parts (thermal) as both model parts share the same nodes
131  }
132  }
133 
134  if (mActivateExistingPart == true)
135  {
136  const int existing_nelements = mrMechanicalModelPart.GetSubModelPart(mMechanicalExistingPart).Elements().size();
137 
138  if (existing_nelements != 0)
139  {
140  // Activate elements of the existing part of both model parts
143 
144  // Activate nodes of the existing part of one of the model parts (thermal) as both model parts share the same nodes
147  }
148  }
149 
150  // Mechanical Conditions
151  const int nconditions_mech = mrMechanicalModelPart.GetMesh(0).Conditions().size();
152 
153  if (nconditions_mech != 0)
154  {
155  ModelPart::ConditionsContainerType::iterator cond_begin_mech = mrMechanicalModelPart.ConditionsBegin();
156 
157  for (int k = 0; k < nconditions_mech; ++k)
158  {
159  ModelPart::ConditionsContainerType::iterator it_cond_mech = cond_begin_mech + k;
160  const unsigned int number_of_points = (*it_cond_mech).GetGeometry().PointsNumber();
161  bool active_condition = true;
162 
163  for (unsigned int i_node = 0; i_node < number_of_points; ++i_node)
164  {
165  if ((*it_cond_mech).GetGeometry()[i_node].IsNot(ACTIVE))
166  {
167  active_condition = false;
168  break;
169  }
170  }
171  if (active_condition) it_cond_mech->Set(ACTIVE, true);
172  else it_cond_mech->Set(ACTIVE, false);
173  }
174  }
175 
176  // Thermal Conditions
177  const int nconditions_thermal = mrThermalModelPart.GetMesh(0).Conditions().size();
178 
179  if (nconditions_thermal != 0)
180  {
181  ModelPart::ConditionsContainerType::iterator cond_begin_thermal = mrThermalModelPart.ConditionsBegin();
182 
183  for (int k = 0; k < nconditions_thermal; ++k)
184  {
185  ModelPart::ConditionsContainerType::iterator it_cond_thermal = cond_begin_thermal + k;
186  const unsigned int number_of_points = (*it_cond_thermal).GetGeometry().PointsNumber();
187  bool active_condition = true;
188 
189  for (unsigned int i_node = 0; i_node < number_of_points; ++i_node)
190  {
191  if ((*it_cond_thermal).GetGeometry()[i_node].IsNot(ACTIVE))
192  {
193  active_condition = false;
194  break;
195  }
196  }
197  if (active_condition) it_cond_thermal->Set(ACTIVE, true);
198  else it_cond_thermal->Set(ACTIVE, false);
199  }
200  }
201 
202  // Assign Alpha Initial in case of using Azenha Formulation
203  if (mSourceType == "NonAdiabatic")
204  {
205  if (mAging == false)
206  {
208  }
209  else
210  {
212  VariableUtils().SetVariable(NODAL_YOUNG_MODULUS, sqrt(mAlphaInitial) * mYoungInf, mrThermalModelPart.Nodes());
213  }
214  }
215 
216  KRATOS_CATCH("");
217  }
218 
219  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
220 
221  void AssignTimeActivation(std::string ThermalSubModelPartName, int phase, double time_activation, double initial_temperature)
222  {
223  KRATOS_TRY;
224 
225  const int nelements = mrThermalModelPart.GetSubModelPart(ThermalSubModelPartName).Elements().size();
226  int direction;
227  if (mGravityDirection == "X")
228  direction = 0;
229  else if (mGravityDirection == "Y")
230  direction = 1;
231  else
232  direction = 2;
233 
234  if (nelements != 0)
235  {
236  double current_height = mReferenceCoordinate + mLiftHeight * (phase);
237  double previous_height = mReferenceCoordinate + mLiftHeight * (phase - 1);
238 
239  block_for_each(mrThermalModelPart.GetSubModelPart(ThermalSubModelPartName).Elements(), [&](auto& rThermalElement){
240  array_1d<double, 3> central_position = rThermalElement.GetGeometry().Center();
241  if ((central_position(direction) >= previous_height) && (central_position(direction) <= current_height))
242  {
243  const unsigned int number_of_points = rThermalElement.GetGeometry().PointsNumber();
244  for (unsigned int i = 0; i < number_of_points; ++i)
245  {
246  if (rThermalElement.GetGeometry()[i].FastGetSolutionStepValue(TIME_ACTIVATION)==0)
247  {
248  rThermalElement.GetGeometry()[i].FastGetSolutionStepValue(TIME_ACTIVATION) = time_activation * mTimeUnitConverter;
249  rThermalElement.GetGeometry()[i].FastGetSolutionStepValue(TEMPERATURE) = rThermalElement.GetGeometry()[i].FastGetSolutionStepValue(PLACEMENT_TEMPERATURE) = initial_temperature;
250  }
251  }
252  }
253  });
254  }
255 
256  KRATOS_CATCH("");
257  }
258 
259  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
260 
261  void InitializeSolutionStep(std::string ThermalSubModelPartName, std::string MechanicalSubModelPartName, std::string HeatFluxSubModelPartName, std::string HydraulicPressureSubModelPartName, bool thermal_conditions, bool mechanical_conditions, int current_number_of_phase)
262  {
263  KRATOS_TRY;
264 
265  const int nelements_thermal = mrThermalModelPart.GetSubModelPart(ThermalSubModelPartName).Elements().size();
266  const int nelements_mech = mrMechanicalModelPart.GetSubModelPart(MechanicalSubModelPartName).Elements().size();
267 
268  int nconditions_thermal = 0;
269  int nconditions_mech = 0;
270  if (thermal_conditions) nconditions_thermal = mrThermalModelPart.GetSubModelPart(HeatFluxSubModelPartName).Conditions().size();
271  if (mechanical_conditions) nconditions_mech = mrMechanicalModelPart.GetSubModelPart(HydraulicPressureSubModelPartName).Conditions().size();
272 
273  int direction;
274 
275  if (mGravityDirection == "X")
276  direction = 0;
277  else if (mGravityDirection == "Y")
278  direction = 1;
279  else
280  direction = 2;
281 
282  // Getting the value of the table and computing the current height
283  double current_height = mReferenceCoordinate + mLiftHeight * current_number_of_phase;
284 
285  if (current_height > mHighestBlockHeight) mHighestBlockHeight = current_height;
286 
287  if (nelements_thermal != 0)
288  {
289  // Thermal Elements
290  block_for_each(mrThermalModelPart.GetSubModelPart(ThermalSubModelPartName).Elements(), [&](auto& rThermalElement){
291  array_1d<double, 3> central_position = rThermalElement.GetGeometry().Center();
292  if ((central_position(direction) >= (mReferenceCoordinate - mLiftHeight)) && (central_position(direction) <= current_height))
293  {
294  rThermalElement.Set(ACTIVE, true);
295  }
296  });
297  }
298 
299  if (nelements_mech != 0)
300  {
301  // Mechanical Elements
302  block_for_each(mrMechanicalModelPart.GetSubModelPart(MechanicalSubModelPartName).Elements(), [&](auto& rMechanicalElement){
303  array_1d<double, 3> central_position = rMechanicalElement.GetGeometry().Center();
304  if ((central_position(direction) >= (mReferenceCoordinate - mLiftHeight)) && (central_position(direction) <= current_height))
305  {
306  rMechanicalElement.Set(ACTIVE, true);
307 
308  const unsigned int number_of_points = rMechanicalElement.GetGeometry().PointsNumber();
309  for (unsigned int i = 0; i < number_of_points; i++)
310  {
311  rMechanicalElement.GetGeometry()[i].Set(ACTIVE, true);
312  rMechanicalElement.GetGeometry()[i].Set(SOLID, false);
313  }
314  }
315  });
316  }
317 
318  if (thermal_conditions && nconditions_thermal != 0)
319  {
320  // Thermal Conditions
321  block_for_each(mrThermalModelPart.GetSubModelPart(HeatFluxSubModelPartName).Conditions(), [&](auto& rThermalCondition){
322  array_1d<double, 3> central_position = rThermalCondition.GetGeometry().Center();
323  if ((central_position(direction) >= (mReferenceCoordinate - mLiftHeight)) && (central_position(direction) <= current_height))
324  {
325  if (rThermalCondition.IsNot(ACTIVE)) rThermalCondition.Set(ACTIVE, true);
326  }
327  });
328  }
329 
330  if (mechanical_conditions && nconditions_mech != 0)
331  {
332  // Mechanical Conditions
333  block_for_each(mrMechanicalModelPart.GetSubModelPart(HydraulicPressureSubModelPartName).Conditions(), [&](auto& rMechanicalCondition){
334  array_1d<double, 3> central_position = rMechanicalCondition.GetGeometry().Center();
335  if ((central_position(direction) >= (mReferenceCoordinate - mLiftHeight)) && (central_position(direction) <= current_height))
336  {
337  if (rMechanicalCondition.IsNot(ACTIVE)) rMechanicalCondition.Set(ACTIVE, true);
338  }
339  });
340  }
341 
342  KRATOS_CATCH("");
343  }
344 
345  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
346 
347  void CheckTemperature(Parameters &CheckTemperatureParameters)
348  {
349  KRATOS_TRY;
350 
351  // Getting CheckTemperature Values
352  const double maximum_temperature_increment = CheckTemperatureParameters["maximum_temperature_increment"].GetDouble();
353  const double maximum_temperature_aux = CheckTemperatureParameters["maximum_temperature"].GetDouble();
354  const double minimum_temperature_aux = CheckTemperatureParameters["minimum_temperature"].GetDouble();
355 
356  block_for_each(mrThermalModelPart.Nodes(), [&](auto& rNode){
357  if (rNode.Is(ACTIVE) && rNode.IsNot(SOLID))
358  {
359  double maximum_temperature = std::max(rNode.FastGetSolutionStepValue(PLACEMENT_TEMPERATURE) + maximum_temperature_increment, maximum_temperature_aux);
360  double minimum_temperature = std::min(rNode.FastGetSolutionStepValue(PLACEMENT_TEMPERATURE), minimum_temperature_aux);
361  double current_temperature = rNode.FastGetSolutionStepValue(TEMPERATURE);
362 
363  if (current_temperature > maximum_temperature)
364  {
365  rNode.FastGetSolutionStepValue(TEMPERATURE) = maximum_temperature;
366  }
367  else if (current_temperature < minimum_temperature)
368  {
369  rNode.FastGetSolutionStepValue(TEMPERATURE) = minimum_temperature;
370  }
371  }
372  else if (rNode.Is(ACTIVE) && rNode.Is(SOLID))
373  {
374  double maximum_temperature = maximum_temperature_aux;
375  double minimum_temperature = minimum_temperature_aux;
376  double current_temperature = rNode.FastGetSolutionStepValue(TEMPERATURE);
377 
378  if (current_temperature > maximum_temperature)
379  {
380  rNode.FastGetSolutionStepValue(TEMPERATURE) = maximum_temperature;
381  }
382  else if (current_temperature < minimum_temperature)
383  {
384  rNode.FastGetSolutionStepValue(TEMPERATURE) = minimum_temperature;
385  }
386  }
387  });
388 
389  KRATOS_CATCH("");
390  }
391 
393 
395  {
396  KRATOS_TRY;
397 
398  const int nelements = mrThermalModelPart.GetMesh(0).Elements().size();
399  const unsigned int Dim = mrMechanicalModelPart.GetProcessInfo()[DOMAIN_SIZE];
400  std::vector<std::size_t> ConditionNodeIds(Dim);
401  if (mNumNode == 8)
402  ConditionNodeIds.resize(Dim + 1);
403 
404  int last_condition_id = mMechanicalLastCondition + mThermalLastCondition;
405  int direction;
406 
407  if (mGravityDirection == "X")
408  direction = 0;
409  else if (mGravityDirection == "Y")
410  direction = 1;
411  else
412  direction = 2;
413 
414  if (nelements != 0)
415  {
416  ModelPart::ElementsContainerType::iterator el_begin_thermal = mrThermalModelPart.ElementsBegin();
417 
418  if (Dim == 2)
419  {
420  for (int k = 0; k < nelements; ++k)
421  {
422  ModelPart::ElementsContainerType::iterator it_thermal = el_begin_thermal + k;
423  array_1d<double, 3> central_position = it_thermal->GetGeometry().Center();
424 
425  // Elements
426  if ((it_thermal)->IsNot(ACTIVE))
427  {
428  if (central_position(direction) <= mHighestBlockHeight + mLiftHeight)
429  {
430  for (unsigned int i_edge = 0; i_edge < (*it_thermal).GetGeometry().EdgesNumber(); ++i_edge)
431  {
432  const unsigned int number_of_points = (*it_thermal).GetGeometry().GenerateEdges()[i_edge].PointsNumber();
433  bool active_edge = true;
434 
435  for (unsigned int i_node = 0; i_node < number_of_points; ++i_node)
436  {
437  if ((*it_thermal).GetGeometry().GenerateEdges()[i_edge][i_node].IsNot(ACTIVE))
438  {
439  active_edge = false;
440  break;
441  }
442  }
443  if (active_edge)
444  {
445  for (unsigned int m = 0; m < number_of_points; ++m)
446  {
447  ConditionNodeIds[m] = (*it_thermal).GetGeometry().GenerateEdges()[i_edge][m].Id();
448  }
449  this->DeactiveFaceHeatFluxStep(ConditionNodeIds);
450 
451  mrThermalModelPart.RemoveConditionFromAllLevels(last_condition_id + 1, 0);
452  last_condition_id++;
453  }
454  }
455  }
456  }
457  }
458  }
459  else
460  {
461  for (int k = 0; k < nelements; ++k)
462  {
463  ModelPart::ElementsContainerType::iterator it_thermal = el_begin_thermal + k;
464  array_1d<double, 3> central_position = it_thermal->GetGeometry().Center();
465 
466  // Elements
467  if ((it_thermal)->IsNot(ACTIVE))
468  {
469  if (central_position(direction) <= mHighestBlockHeight + mLiftHeight)
470  {
471  for (unsigned int i_face = 0; i_face < (*it_thermal).GetGeometry().FacesNumber(); ++i_face)
472  {
473  const unsigned int number_of_points = (*it_thermal).GetGeometry().GenerateFaces()[i_face].PointsNumber();
474  bool active_face = true;
475 
476  for (unsigned int i_node = 0; i_node < number_of_points; ++i_node)
477  {
478  if ((*it_thermal).GetGeometry().GenerateFaces()[i_face][i_node].IsNot(ACTIVE))
479  {
480  active_face = false;
481  break;
482  }
483  }
484  if (active_face)
485  {
486  for (unsigned int m = 0; m < number_of_points; ++m)
487  {
488  ConditionNodeIds[m] = (*it_thermal).GetGeometry().GenerateFaces()[i_face][m].Id();
489  }
490  this->DeactiveFaceHeatFluxStep(ConditionNodeIds);
491 
492  mrThermalModelPart.RemoveConditionFromAllLevels(last_condition_id + 1, 0);
493  last_condition_id++;
494  }
495  }
496  }
497  }
498  }
499  }
500  }
501 
502  KRATOS_CATCH("");
503  }
504 
506 
508  {
509  KRATOS_TRY;
510 
511  const int nelements = mrMechanicalModelPart.GetMesh(0).Elements().size();
512  const unsigned int Dim = mrMechanicalModelPart.GetProcessInfo()[DOMAIN_SIZE];
513  std::vector<std::size_t> ConditionNodeIds(Dim);
514  if (mNumNode == 8)
515  ConditionNodeIds.resize(Dim + 1);
516 
517  int last_condition_id = mMechanicalLastCondition + mThermalLastCondition;
518  int direction;
519 
520  if (mGravityDirection == "X")
521  direction = 0;
522  else if (mGravityDirection == "Y")
523  direction = 1;
524  else
525  direction = 2;
526 
527  if (nelements != 0)
528  {
529  ModelPart::ElementsContainerType::iterator el_begin_thermal = mrThermalModelPart.ElementsBegin();
530 
531  if (Dim == 2)
532  {
533  // Searching for thermal boundary conditions Edges
534  for (int k = 0; k < nelements; ++k)
535  {
536  ModelPart::ElementsContainerType::iterator it_thermal = el_begin_thermal + k;
537  array_1d<double, 3> central_position = it_thermal->GetGeometry().Center();
538 
539  // Elements
540  if ((it_thermal)->IsNot(ACTIVE))
541  {
542  if (central_position(direction) <= mHighestBlockHeight + mLiftHeight)
543  {
544  for (unsigned int i_edge = 0; i_edge < (*it_thermal).GetGeometry().EdgesNumber(); ++i_edge)
545  {
546  const unsigned int number_of_points = (*it_thermal).GetGeometry().GenerateEdges()[i_edge].PointsNumber();
547  bool active_edge = true;
548 
549  for (unsigned int i_node = 0; i_node < number_of_points; ++i_node)
550  {
551  if ((*it_thermal).GetGeometry().GenerateEdges()[i_edge][i_node].IsNot(ACTIVE))
552  {
553  active_edge = false;
554  break;
555  }
556  }
557  if (active_edge)
558  {
559  for (unsigned int m = 0; m < number_of_points; ++m)
560  {
561  ConditionNodeIds[m] = (*it_thermal).GetGeometry().GenerateEdges()[i_edge][m].Id();
562  }
563  this->ActiveFaceHeatFluxStep(ConditionNodeIds);
564 
565  mrThermalModelPart.CreateNewCondition("FluxCondition2D2N", last_condition_id + 1, ConditionNodeIds, 0);
566  last_condition_id++;
567  }
568  }
569  }
570  }
571  }
572  }
573  else
574  {
575  // Searching for thermal boundary conditions
576  for (int k = 0; k < nelements; ++k)
577  {
578  ModelPart::ElementsContainerType::iterator it_thermal = el_begin_thermal + k;
579  array_1d<double, 3> central_position = it_thermal->GetGeometry().Center();
580 
581  // Elements
582  if ((it_thermal)->IsNot(ACTIVE))
583  {
584  if (central_position(direction) <= mHighestBlockHeight + mLiftHeight)
585  {
586  for (unsigned int i_face = 0; i_face < (*it_thermal).GetGeometry().FacesNumber(); ++i_face)
587  {
588  const unsigned int number_of_points = (*it_thermal).GetGeometry().GenerateFaces()[i_face].PointsNumber();
589  bool active_face = true;
590 
591  for (unsigned int i_node = 0; i_node < number_of_points; ++i_node)
592  {
593  if ((*it_thermal).GetGeometry().GenerateFaces()[i_face][i_node].IsNot(ACTIVE))
594  {
595  active_face = false;
596  break;
597  }
598  }
599  if (active_face)
600  {
601  for (unsigned int m = 0; m < number_of_points; ++m)
602  {
603  ConditionNodeIds[m] = (*it_thermal).GetGeometry().GenerateFaces()[i_face][m].Id();
604  }
605  this->ActiveFaceHeatFluxStep(ConditionNodeIds);
606 
607  if (number_of_points == 3)
608  {
609  mrThermalModelPart.CreateNewCondition("FluxCondition3D3N", last_condition_id + 1, ConditionNodeIds, 0);
610  last_condition_id++;
611  }
612  else
613  {
614  mrThermalModelPart.CreateNewCondition("FluxCondition3D4N", last_condition_id + 1, ConditionNodeIds, 0);
615  last_condition_id++;
616  }
617  }
618  }
619  }
620  }
621  }
622  }
623  }
624 
625  KRATOS_CATCH("");
626  }
627 
629 
630  void ActiveHeatFluxNoorzai(Parameters &NoorzaiParameters)
631  {
632  KRATOS_TRY;
633 
634  // Getting Noorzai Values
635  const double density = NoorzaiParameters["density"].GetDouble();
636  const double specific_heat = NoorzaiParameters["specific_heat"].GetDouble();
637  const double alpha = NoorzaiParameters["alpha"].GetDouble();
638  const double t_max = NoorzaiParameters["t_max"].GetDouble();
639  const double time = mrThermalModelPart.GetProcessInfo()[TIME];
640  const double delta_time = mrThermalModelPart.GetProcessInfo()[DELTA_TIME];
641 
642  block_for_each(mrThermalModelPart.Nodes(), [&](auto& rNode){
643  double current_activation_time = time - (rNode.FastGetSolutionStepValue(TIME_ACTIVATION));
644  if (current_activation_time >= 0.0 && (rNode.Is(SOLID) == false))
645  {
646  // Computing the value of heat flux according the time
647  double value = density * specific_heat * alpha * t_max * (exp(-alpha * (current_activation_time + 0.5 * delta_time)));
648  rNode.FastGetSolutionStepValue(HEAT_FLUX) = value;
649  }
650  });
651  KRATOS_CATCH("");
652  }
653 
655 
656  void ActiveHeatFluxAzenha(Parameters &AzenhaParameters)
657  {
658  KRATOS_TRY;
659 
660  if (mAging == false)
661  {
662  // Getting Azenha Values
663  const double activation_energy = AzenhaParameters["activation_energy"].GetDouble();
664  const double gas_constant = AzenhaParameters["gas_constant"].GetDouble();
665  const double constant_rate = AzenhaParameters["constant_rate"].GetDouble();
666  const double q_total = AzenhaParameters["q_total"].GetDouble();
667  const double a_coef = AzenhaParameters["A"].GetDouble();
668  const double b_coef = AzenhaParameters["B"].GetDouble();
669  const double c_coef = AzenhaParameters["C"].GetDouble();
670  const double d_coef = AzenhaParameters["D"].GetDouble();
671 
672  // Temporal variables
673  const double time = mrThermalModelPart.GetProcessInfo()[TIME];
674  const double delta_time = mrThermalModelPart.GetProcessInfo()[DELTA_TIME];
675 
676  block_for_each(mrThermalModelPart.Nodes(), [&](auto& rNode){
677  double current_activation_time = time - (rNode.FastGetSolutionStepValue(TIME_ACTIVATION));
678  if (current_activation_time >= 0.0 && (rNode.Is(SOLID) == false))
679  {
680  // Computing the current alpha according las step.
681  double current_alpha = ((rNode.FastGetSolutionStepValue(HEAT_FLUX, 1)) / q_total) * delta_time + (rNode.FastGetSolutionStepValue(ALPHA_HEAT_SOURCE));
682  double f_alpha = a_coef * (pow(current_alpha, 2)) * exp(-b_coef * pow(current_alpha, 3)) + c_coef * current_alpha * exp(-d_coef * current_alpha);
683 
684  // This is neccesary for stopping the addition to the system once the process finish.
685  if (current_alpha >= 1.0)
686  {
687  f_alpha = 0.0;
688  current_alpha = 1.0;
689  }
690 
691  // Transformation degress to Kelvins, it is necessary since gas constant is in Kelvins.
692  const double temp_current = rNode.FastGetSolutionStepValue(TEMPERATURE) + 273.0;
693  const double heat_flux = constant_rate * f_alpha * exp((-activation_energy) / (gas_constant * temp_current));
694 
695  // Updating values according the computations
696  rNode.FastGetSolutionStepValue(HEAT_FLUX) = heat_flux;
697  rNode.FastGetSolutionStepValue(ALPHA_HEAT_SOURCE) = current_alpha;
698  }
699  });
700  }
701  else
702  {
703  this->ActiveHeatFluxAzenhaAging(AzenhaParameters);
704  }
705 
706  KRATOS_CATCH("");
707  }
708 
710 
711  protected:
713 
716  int mNumNode;
717  std::string mGravityDirection;
718  std::string mMechanicalSoilPart;
719  std::string mThermalSoilPart;
721  std::string mThermalExistingPart;
722  std::string mSourceType;
727  double mLiftHeight;
728  double mH0;
731  bool mAging;
732  double mYoungInf;
734  unsigned int mThermalLastCondition;
736 
737  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
738 
739  void ActiveHeatFluxAzenhaAging(Parameters &AzenhaParameters)
740  {
741  KRATOS_TRY;
742 
743  // Getting Azenha Values
744  double activation_energy = AzenhaParameters["activation_energy"].GetDouble();
745  double gas_constant = AzenhaParameters["gas_constant"].GetDouble();
746  double constant_rate = AzenhaParameters["constant_rate"].GetDouble();
747  double q_total = AzenhaParameters["q_total"].GetDouble();
748  double a_coef = AzenhaParameters["A"].GetDouble();
749  double b_coef = AzenhaParameters["B"].GetDouble();
750  double c_coef = AzenhaParameters["C"].GetDouble();
751  double d_coef = AzenhaParameters["D"].GetDouble();
752 
753  // Tempotal variables
754  double time = mrThermalModelPart.GetProcessInfo()[TIME];
755  double delta_time = mrThermalModelPart.GetProcessInfo()[DELTA_TIME];
756 
757  block_for_each(mrThermalModelPart.Nodes(), [&](auto& rNode){
758  double current_activation_time = time - (rNode.FastGetSolutionStepValue(TIME_ACTIVATION));
759  if (current_activation_time >= 0.0 && (rNode.Is(SOLID) == false))
760  {
761  // Computing the current alpha according las step.
762  double current_alpha = ((rNode.FastGetSolutionStepValue(HEAT_FLUX, 1)) / q_total) * delta_time + (rNode.FastGetSolutionStepValue(ALPHA_HEAT_SOURCE));
763  double f_alpha = a_coef * (pow(current_alpha, 2)) * exp(-b_coef * pow(current_alpha, 3)) + c_coef * current_alpha * exp(-d_coef * current_alpha);
764 
765  // This is neccesary for stopping the addition to the system once the process finish.
766  if (current_alpha >= 1.0)
767  {
768  f_alpha = 0.0;
769  current_alpha = 1.0;
770  }
771 
772  // Transformation degress to Kelvins, it is necessary since gas constant is in Kelvins.
773  const double temp_current = rNode.FastGetSolutionStepValue(TEMPERATURE) + 273.0;
774  const double heat_flux = constant_rate * f_alpha * exp((-activation_energy) / (gas_constant * temp_current));
775 
776  // Updating values according the computations
777  rNode.FastGetSolutionStepValue(HEAT_FLUX) = heat_flux;
778  rNode.FastGetSolutionStepValue(ALPHA_HEAT_SOURCE) = current_alpha;
779  rNode.FastGetSolutionStepValue(NODAL_YOUNG_MODULUS) = sqrt(current_alpha) * mYoungInf;
780  }
781  });
782 
783  KRATOS_CATCH("");
784  }
785 
787 
788  void ActiveFaceHeatFluxStep(std::vector<IndexType> ConditionNodeIds)
789  {
790  KRATOS_TRY;
791 
792  const unsigned int size = ConditionNodeIds.size();
793  const unsigned int nnodes = mrThermalModelPart.GetMesh(0).Nodes().size();
794  ModelPart::NodesContainerType::iterator it_begin_thermal = mrThermalModelPart.GetMesh(0).NodesBegin();
795 
796  double time = mrThermalModelPart.GetProcessInfo()[TIME];
797  time = time / mTimeUnitConverter;
798  double ambient_temp = mrTableAmbientTemp.GetValue(time);
799 
800  if (size != 0)
801  {
802  for (unsigned int j = 0; j < size; ++j)
803  {
804  for (unsigned int i = 0; i < nnodes; ++i)
805  {
806  ModelPart::NodesContainerType::iterator it_thermal = it_begin_thermal + i;
807 
808  if (it_thermal->Id() == ConditionNodeIds[j])
809  {
810  const double temp_current = it_thermal->FastGetSolutionStepValue(TEMPERATURE);
811  const double heat_flux = mH0 * (ambient_temp - temp_current);
812  it_thermal->FastGetSolutionStepValue(FACE_HEAT_FLUX) = heat_flux;
813  }
814  }
815  }
816  }
817 
818  KRATOS_CATCH("");
819  }
820 
821  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
822 
823  void DeactiveFaceHeatFluxStep(std::vector<IndexType> ConditionNodeIds)
824  {
825  KRATOS_TRY;
826 
827  const unsigned int size = ConditionNodeIds.size();
828  const unsigned int nnodes = mrThermalModelPart.GetMesh(0).Nodes().size();
829  ModelPart::NodesContainerType::iterator it_begin_thermal = mrThermalModelPart.GetMesh(0).NodesBegin();
830 
831  if (size != 0)
832  {
833  for (unsigned int j = 0; j < size; ++j)
834  {
835  for (unsigned int i = 0; i < nnodes; ++i)
836  {
837  ModelPart::NodesContainerType::iterator it_thermal = it_begin_thermal + i;
838 
839  if (it_thermal->Id() == ConditionNodeIds[j])
840  {
841  //Setting to 0 the fluxes since in the next step
842  it_thermal->FastGetSolutionStepValue(FACE_HEAT_FLUX) = 0.0;
843  }
844  }
845  }
846  }
847 
848  KRATOS_CATCH("");
849  }
850 
851  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
852 
853 }; //Class
854 
855 } /* namespace Kratos.*/
856 
857 #endif /* KRATOS_CONSTRUCTION_UTILITIES defined */
Definition: construction_utility.hpp:35
Table< double, double > TableType
Definition: construction_utility.hpp:39
ModelPart & mrThermalModelPart
Definition: construction_utility.hpp:715
bool mAging
Definition: construction_utility.hpp:731
void ActiveHeatFluxAzenha(Parameters &AzenhaParameters)
Definition: construction_utility.hpp:656
bool mActivateSoilPart
Definition: construction_utility.hpp:723
std::string mMechanicalSoilPart
Definition: construction_utility.hpp:718
void Initialize()
Definition: construction_utility.hpp:87
std::size_t IndexType
Definition: construction_utility.hpp:38
double mLiftHeight
Definition: construction_utility.hpp:727
int mNumNode
Definition: construction_utility.hpp:716
double mTimeUnitConverter
Definition: construction_utility.hpp:729
unsigned int mThermalLastCondition
Definition: construction_utility.hpp:734
std::string mThermalExistingPart
Definition: construction_utility.hpp:721
void ActiveHeatFluxNoorzai(Parameters &NoorzaiParameters)
Definition: construction_utility.hpp:630
void DeactiveFaceHeatFluxStep(std::vector< IndexType > ConditionNodeIds)
Definition: construction_utility.hpp:823
void AfterOutputStep()
Definition: construction_utility.hpp:394
ConstructionUtility(ModelPart &rMechanicalModelPart, ModelPart &rThermalModelPart, TableType &rTableAmbientTemp, Parameters &rParameters)
Constructor.
Definition: construction_utility.hpp:44
double mAlphaInitial
Definition: construction_utility.hpp:730
std::string mThermalSoilPart
Definition: construction_utility.hpp:719
TableType & mrTableAmbientTemp
Definition: construction_utility.hpp:735
void ActiveHeatFluxAzenhaAging(Parameters &AzenhaParameters)
Definition: construction_utility.hpp:739
double mH0
Definition: construction_utility.hpp:728
void InitializeSolutionStep(std::string ThermalSubModelPartName, std::string MechanicalSubModelPartName, std::string HeatFluxSubModelPartName, std::string HydraulicPressureSubModelPartName, bool thermal_conditions, bool mechanical_conditions, int current_number_of_phase)
Definition: construction_utility.hpp:261
void SearchingFluxes()
Definition: construction_utility.hpp:507
~ConstructionUtility()
Destructor.
Definition: construction_utility.hpp:83
double mYoungInf
Definition: construction_utility.hpp:732
std::string mMechanicalExistingPart
Definition: construction_utility.hpp:720
ModelPart & mrMechanicalModelPart
Member Variables.
Definition: construction_utility.hpp:714
void CheckTemperature(Parameters &CheckTemperatureParameters)
Definition: construction_utility.hpp:347
void ActiveFaceHeatFluxStep(std::vector< IndexType > ConditionNodeIds)
Definition: construction_utility.hpp:788
std::string mGravityDirection
Definition: construction_utility.hpp:717
void AssignTimeActivation(std::string ThermalSubModelPartName, int phase, double time_activation, double initial_temperature)
Definition: construction_utility.hpp:221
double mHighestBlockHeight
Definition: construction_utility.hpp:726
unsigned int mMechanicalLastCondition
Definition: construction_utility.hpp:733
double mReferenceCoordinate
Definition: construction_utility.hpp:725
std::string mSourceType
Definition: construction_utility.hpp:722
bool mActivateExistingPart
Definition: construction_utility.hpp:724
ConditionsContainerType & Conditions()
Definition: mesh.h:691
NodesContainerType & Nodes()
Definition: mesh.h:346
NodeIterator NodesBegin()
Definition: mesh.h:326
ElementsContainerType & Elements()
Definition: mesh.h:568
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ElementIterator ElementsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1169
ConditionIterator ConditionsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1361
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
ModelPart & GetSubModelPart(std::string const &SubModelPartName)
Definition: model_part.cpp:2029
MeshType & GetMesh(IndexType ThisIndex=0)
Definition: model_part.h:1791
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
std::string GetString() const
This method returns the string contained in the current Parameter.
Definition: kratos_parameters.cpp:684
bool GetBool() const
This method returns the boolean contained in the current Parameter.
Definition: kratos_parameters.cpp:675
size_type size() const
Returns the number of elements in the container.
Definition: pointer_vector_set.h:502
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
Definition: table.h:435
TResultType GetValue(TArgumentType const &X) const
Definition: table.h:502
This class implements a set of auxiliar, already parallelized, methods to perform some common tasks r...
Definition: variable_utils.h:63
void SetVariable(const TVarType &rVariable, const TDataType &rValue, NodesContainerType &rNodes, const unsigned int Step=0)
Sets the nodal value of a scalar variable.
Definition: variable_utils.h:675
void SetFlag(const Flags &rFlag, const bool FlagValue, TContainerType &rContainer)
Sets a flag according to a given status over a given container.
Definition: variable_utils.h:900
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
void block_for_each(TIterator itBegin, TIterator itEnd, TFunction &&rFunction)
Execute a functor on all items of a range in parallel.
Definition: parallel_utilities.h:299
float specific_heat
Definition: face_heat.py:57
time
Definition: face_heat.py:85
float density
Definition: face_heat.py:56
alpha
Definition: generate_convection_diffusion_explicit_element.py:113
delta_time
Definition: generate_frictional_mortar_condition.py:130
int k
Definition: quadrature.py:595
int j
Definition: quadrature.py:648
int m
Definition: run_marine_rain_substepping.py:8
int nnodes
Definition: sensitivityMatrix.py:24
integer i
Definition: TensorModule.f:17