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.
dam_uplift_circular_condition_load_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: Lorenzo Gracia
11 //
12 //
13 
14 #if !defined(KRATOS_DAM_UPLIFT_CIRCULAR_CONDITION_LOAD_PROCESS)
15 #define KRATOS_DAM_UPLIFT_CIRCULAR_CONDITION_LOAD_PROCESS
16 
17 #include <cmath>
18 
19 // Project includes
20 #include "includes/kratos_flags.h"
22 #include "processes/process.h"
23 
24 // Application include
26 
27 namespace Kratos
28 {
29 
31 {
32 
33  public:
35 
37 
38  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
39 
42  ModelPart &rJointModelPart,
43  Parameters &rParameters) : Process(Flags()), mrModelPart(rModelPart), mrJointModelPart(rJointModelPart)
44  {
46 
47  //only include validation with c++11 since raw_literals do not exist in c++03
48  Parameters default_parameters(R"(
49  {
50  "model_part_name":"PLEASE_CHOOSE_MODEL_PART_NAME",
51  "variable_name": "PLEASE_PRESCRIBE_VARIABLE_NAME",
52  "Modify" : true,
53  "joint_group_name" : "PLEASE_CHOOSE_JOINT_GROUP_NAME",
54  "Gravity_Direction" : "Y",
55  "Reservoir_Bottom_Coordinate_in_Gravity_Direction" : 0.0,
56  "Upstream_Coordinate_first_bracket" : [0.0,0.0,0.0],
57  "Downstream_Coordinate_first_bracket" : [0.0,0.0,0.0],
58  "Focus" : [0.0,0.0,0.0],
59  "Spe_weight" : 10000,
60  "Water_level" : 0.0,
61  "Drains" : false,
62  "Height_drain" : 0.0,
63  "Distance" : 0.0,
64  "Effectiveness" : 0.0,
65  "table" : 0,
66  "interval":[
67  0.0,
68  0.0
69  ]
70  } )");
71 
72  // Some values need to be mandatorily prescribed since no meaningful default value exist. For this reason try accessing to them
73  // So that an error is thrown if they don't exist
74  rParameters["Focus"];
75 
76  // Now validate agains defaults -- this also ensures no type mismatch
77  rParameters.ValidateAndAssignDefaults(default_parameters);
78 
79  mVariableName = rParameters["variable_name"].GetString();
80  mGravityDirection = rParameters["Gravity_Direction"].GetString();
81  mReferenceCoordinate = rParameters["Reservoir_Bottom_Coordinate_in_Gravity_Direction"].GetDouble();
82  mSpecific = rParameters["Spe_weight"].GetDouble();
83 
84  // Getting the values of the coordinates at first bracket (reference value)
85  mUpstream.resize(3, false);
86  mUpstream[0] = rParameters["Upstream_Coordinate_first_bracket"][0].GetDouble();
87  mUpstream[1] = rParameters["Upstream_Coordinate_first_bracket"][1].GetDouble();
88  mUpstream[2] = rParameters["Upstream_Coordinate_first_bracket"][2].GetDouble();
89 
90  mDownstream.resize(3, false);
91  mDownstream[0] = rParameters["Downstream_Coordinate_first_bracket"][0].GetDouble();
92  mDownstream[1] = rParameters["Downstream_Coordinate_first_bracket"][1].GetDouble();
93  mDownstream[2] = rParameters["Downstream_Coordinate_first_bracket"][2].GetDouble();
94 
95  // Getting the coordinates of the focus (reference value)
96  mFocus.resize(3, false);
97  mFocus[0] = rParameters["Focus"][0].GetDouble();
98  mFocus[1] = rParameters["Focus"][1].GetDouble();
99  mFocus[2] = rParameters["Focus"][2].GetDouble();
100 
101  // Drains
102  mDrain = rParameters["Drains"].GetBool();
103  mHeightDrain = rParameters["Height_drain"].GetDouble();
104  mDistanceDrain = rParameters["Distance"].GetDouble();
105  mEffectivenessDrain = rParameters["Effectiveness"].GetDouble();
106  mWaterLevel = rParameters["Water_level"].GetInt();
107 
108  mTimeUnitConverter = mrModelPart.GetProcessInfo()[TIME_UNIT_CONVERTER];
109  mTableId = rParameters["table"].GetInt();
110 
111  if (mTableId != 0)
113 
114  KRATOS_CATCH("");
115  }
116 
118 
121 
122  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
123  void Execute() override
124  {
125  }
126 
127  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
128 
129  void ExecuteInitialize() override
130  {
131 
132  KRATOS_TRY;
133 
134  //Defining necessary variables
136  const int nnodes = mrModelPart.GetMesh(0).Nodes().size();
137  array_1d<double, 3> auxiliar_vector;
138 
139  // Gravity direction for computing the hydrostatic pressure
140  int direction;
141  int radius_comp_1;
142  int radius_comp_2;
143 
144  if (mGravityDirection == "X")
145  {
146  direction = 0;
147  radius_comp_1 = 1;
148  radius_comp_2 = 2;
149  }
150  else if (mGravityDirection == "Y")
151  {
152  direction = 1;
153  radius_comp_1 = 0;
154  radius_comp_2 = 2;
155  }
156  else
157  {
158  direction = 2;
159  radius_comp_1 = 0;
160  radius_comp_2 = 1;
161  }
162 
163  // Computation of the angle in radians for each bracket
164  //double tetha = (mangle*2*pi)/(mnum_brackets*360);
165 
166  // Computation of radius for Upstream and Downstream
167  double up_radius = norm_2(mFocus - mUpstream);
168  double down_radius = norm_2(mFocus - mDownstream);
169  double width_dam = up_radius - down_radius;
170 
171  if (nnodes != 0)
172  {
173  ModelPart::NodesContainerType::iterator it_begin = mrModelPart.GetMesh(0).NodesBegin();
174 
175  if (mDrain == true)
176  {
177  double coefficient_effectiveness = 1.0 - mEffectivenessDrain;
178  double aux_drain = coefficient_effectiveness * ((mWaterLevel - mReferenceCoordinate) - mHeightDrain) * ((width_dam - mDistanceDrain) / width_dam) + mHeightDrain;
179 
180 #pragma omp parallel for
181  for (int i = 0; i < nnodes; i++)
182  {
183  ModelPart::NodesContainerType::iterator it = it_begin + i;
184 
185  auxiliar_vector.resize(3, false);
186  const array_1d<double,3>& r_coordinates = it->Coordinates();
187  noalias(auxiliar_vector) = mFocus - r_coordinates;
188 
190  double current_radius = sqrt(auxiliar_vector[radius_comp_1] * auxiliar_vector[radius_comp_1] + auxiliar_vector[radius_comp_2] * auxiliar_vector[radius_comp_2]);
191 
193  mUpliftPressure = mSpecific * ((mWaterLevel - aux_drain) - (r_coordinates[direction])) * (1.0 - ((1.0 / mDistanceDrain) * (fabs(current_radius - up_radius)))) + (mSpecific * aux_drain);
194 
196  if (mUpliftPressure <= mSpecific * aux_drain)
197  {
198  mUpliftPressure = (mSpecific * ((mReferenceCoordinate + aux_drain) - (r_coordinates[direction]))) * (1.0 - ((1.0 / (width_dam - mDistanceDrain)) * (fabs(current_radius - (up_radius - mDistanceDrain)))));
199  }
200 
201  if (mUpliftPressure < 0.0)
202  {
203  it->FastGetSolutionStepValue(var) = 0.0;
204  }
205  else
206  {
207  it->FastGetSolutionStepValue(var) = mUpliftPressure;
208  }
209  }
210  }
211  else
212  {
213 #pragma omp parallel for
214  for (int i = 0; i < nnodes; i++)
215  {
216  ModelPart::NodesContainerType::iterator it = it_begin + i;
217 
218  auxiliar_vector.resize(3, false);
219  const array_1d<double,3>& r_coordinates = it->Coordinates();
220  noalias(auxiliar_vector) = mFocus - r_coordinates;
221 
222  // Computing the current distance to the focus.
223  double current_radius = sqrt(auxiliar_vector[radius_comp_1] * auxiliar_vector[radius_comp_1] + auxiliar_vector[radius_comp_2] * auxiliar_vector[radius_comp_2]);
224 
225  mUpliftPressure = mSpecific * (mWaterLevel - (r_coordinates[direction])) * (1.0 - (1.0 / width_dam) * (fabs(current_radius - up_radius)));
226 
227  if (mUpliftPressure < 0.0)
228  {
229  it->FastGetSolutionStepValue(var) = 0.0;
230  }
231  else
232  {
233  it->FastGetSolutionStepValue(var) = mUpliftPressure;
234  }
235  }
236  }
237  }
238 
239  KRATOS_CATCH("");
240  }
241 
242  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
243 
245  {
246 
247  KRATOS_TRY;
248 
249  //Defining necessary variables
251  const int nnodes = mrModelPart.GetMesh(0).Nodes().size();
252  array_1d<double, 3> auxiliar_vector;
253 
254  // Getting the values of table in case that it exist
255  if (mTableId != 0)
256  {
257  double time = mrModelPart.GetProcessInfo()[TIME];
259  mWaterLevel = mpTable->GetValue(time);
260  }
261 
262  // Gravity direction for computing the hydrostatic pressure
263  int direction;
264  int radius_comp_1;
265  int radius_comp_2;
266 
267  if (mGravityDirection == "X")
268  {
269  direction = 0;
270  radius_comp_1 = 1;
271  radius_comp_2 = 2;
272  }
273  else if (mGravityDirection == "Y")
274  {
275  direction = 1;
276  radius_comp_1 = 0;
277  radius_comp_2 = 2;
278  }
279  else
280  {
281  direction = 2;
282  radius_comp_1 = 0;
283  radius_comp_2 = 1;
284  }
285 
286  // Computation of the angle in radians for each bracket
287  //double tetha = (mangle*2*pi)/(mnum_brackets*360);
288 
289  // Computation of radius for Upstream and Downstream
290  double up_radius = norm_2(mFocus - mUpstream);
291  double down_radius = norm_2(mFocus - mDownstream);
292  double width_dam = up_radius - down_radius;
293 
294  if (nnodes != 0)
295  {
296  ModelPart::NodesContainerType::iterator it_begin = mrModelPart.GetMesh(0).NodesBegin();
297 
298  if (mDrain == true)
299  {
300  double coefficient_effectiveness = 1.0 - mEffectivenessDrain;
301  double aux_drain = coefficient_effectiveness * ((mWaterLevel - mReferenceCoordinate) - mHeightDrain) * ((width_dam - mDistanceDrain) / width_dam) + mHeightDrain;
302 
303 #pragma omp parallel for
304  for (int i = 0; i < nnodes; i++)
305  {
306  ModelPart::NodesContainerType::iterator it = it_begin + i;
307 
308  auxiliar_vector.resize(3, false);
309  const array_1d<double,3>& r_coordinates = it->Coordinates();
310  noalias(auxiliar_vector) = mFocus - r_coordinates;
311 
313  double current_radius = sqrt(auxiliar_vector[radius_comp_1] * auxiliar_vector[radius_comp_1] + auxiliar_vector[radius_comp_2] * auxiliar_vector[radius_comp_2]);
314 
316  mUpliftPressure = mSpecific * ((mWaterLevel - aux_drain) - (r_coordinates[direction])) * (1.0 - ((1.0 / mDistanceDrain) * (fabs(current_radius - up_radius)))) + (mSpecific * aux_drain);
317 
319  if (mUpliftPressure <= mSpecific * aux_drain)
320  {
321  mUpliftPressure = (mSpecific * ((mReferenceCoordinate + aux_drain) - (r_coordinates[direction]))) * (1.0 - ((1.0 / (width_dam - mDistanceDrain)) * (fabs(current_radius - (up_radius - mDistanceDrain)))));
322  }
323 
324  if (mUpliftPressure < 0.0)
325  {
326  it->FastGetSolutionStepValue(var) = 0.0;
327  }
328  else
329  {
330  it->FastGetSolutionStepValue(var) = mUpliftPressure;
331  }
332  }
333  }
334  else
335  {
336 #pragma omp parallel for
337  for (int i = 0; i < nnodes; i++)
338  {
339  ModelPart::NodesContainerType::iterator it = it_begin + i;
340 
341  auxiliar_vector.resize(3, false);
342  const array_1d<double,3>& r_coordinates = it->Coordinates();
343  noalias(auxiliar_vector) = mFocus - r_coordinates;
344 
345  // Computing the current distance to the focus.
346  double current_radius = sqrt(auxiliar_vector[radius_comp_1] * auxiliar_vector[radius_comp_1] + auxiliar_vector[radius_comp_2] * auxiliar_vector[radius_comp_2]);
347 
348  mUpliftPressure = mSpecific * (mWaterLevel - (r_coordinates[direction])) * (1.0 - (1.0 / width_dam) * (fabs(current_radius - up_radius)));
349 
350  if (mUpliftPressure < 0.0)
351  {
352  it->FastGetSolutionStepValue(var) = 0.0;
353  }
354  else
355  {
356  it->FastGetSolutionStepValue(var) = mUpliftPressure;
357  }
358  }
359  }
360  }
361 
362  KRATOS_CATCH("");
363  }
364 
366  std::string Info() const override
367  {
368  return "DamUpliftCircularConditionLoadProcess";
369  }
370 
372  void PrintInfo(std::ostream &rOStream) const override
373  {
374  rOStream << "DamUpliftCircularConditionLoadProcess";
375  }
376 
378  void PrintData(std::ostream &rOStream) const override
379  {
380  }
381 
383 
384  protected:
386 
389  std::string mVariableName;
390  std::string mGravityDirection;
392  double mSpecific;
393  double mWaterLevel;
394  bool mDrain;
395  double mHeightDrain;
403  TableType::Pointer mpTable;
404  int mTableId;
405 
406  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
407 
408  private:
411 
412 }; //Class
413 
415 inline std::istream &operator>>(std::istream &rIStream,
417 
419 inline std::ostream &operator<<(std::ostream &rOStream,
421 {
422  rThis.PrintInfo(rOStream);
423  rOStream << std::endl;
424  rThis.PrintData(rOStream);
425 
426  return rOStream;
427 }
428 
429 } /* namespace Kratos.*/
430 
431 #endif /* KRATOS_DAM_UPLIFT_CIRCULAR_CONDITION_LOAD_PROCESS defined */
Definition: dam_uplift_circular_condition_load_process.hpp:31
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: dam_uplift_circular_condition_load_process.hpp:372
double mHeightDrain
Definition: dam_uplift_circular_condition_load_process.hpp:395
double mWaterLevel
Definition: dam_uplift_circular_condition_load_process.hpp:393
double mSpecific
Definition: dam_uplift_circular_condition_load_process.hpp:392
double mDistanceDrain
Definition: dam_uplift_circular_condition_load_process.hpp:396
bool mDrain
Definition: dam_uplift_circular_condition_load_process.hpp:394
double mReferenceCoordinate
Definition: dam_uplift_circular_condition_load_process.hpp:391
void Execute() override
Execute method is used to execute the Process algorithms.
Definition: dam_uplift_circular_condition_load_process.hpp:123
KRATOS_CLASS_POINTER_DEFINITION(DamUpliftCircularConditionLoadProcess)
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: dam_uplift_circular_condition_load_process.hpp:378
TableType::Pointer mpTable
Definition: dam_uplift_circular_condition_load_process.hpp:403
Vector mFocus
Definition: dam_uplift_circular_condition_load_process.hpp:401
double mEffectivenessDrain
Definition: dam_uplift_circular_condition_load_process.hpp:397
std::string mVariableName
Definition: dam_uplift_circular_condition_load_process.hpp:389
Vector mUpstream
Definition: dam_uplift_circular_condition_load_process.hpp:399
std::string Info() const override
Turn back information as a string.
Definition: dam_uplift_circular_condition_load_process.hpp:366
virtual ~DamUpliftCircularConditionLoadProcess()
Destructor.
Definition: dam_uplift_circular_condition_load_process.hpp:120
DamUpliftCircularConditionLoadProcess(ModelPart &rModelPart, ModelPart &rJointModelPart, Parameters &rParameters)
Constructor.
Definition: dam_uplift_circular_condition_load_process.hpp:41
Vector mDownstream
Definition: dam_uplift_circular_condition_load_process.hpp:400
std::string mGravityDirection
Definition: dam_uplift_circular_condition_load_process.hpp:390
double mUpliftPressure
Definition: dam_uplift_circular_condition_load_process.hpp:398
double mTimeUnitConverter
Definition: dam_uplift_circular_condition_load_process.hpp:402
ModelPart & mrJointModelPart
Definition: dam_uplift_circular_condition_load_process.hpp:388
Table< double, double > TableType
Definition: dam_uplift_circular_condition_load_process.hpp:36
void ExecuteInitialize() override
This function is designed for being called at the beginning of the computations right after reading t...
Definition: dam_uplift_circular_condition_load_process.hpp:129
int mTableId
Definition: dam_uplift_circular_condition_load_process.hpp:404
void ExecuteInitializeSolutionStep() override
This function will be executed at every time step BEFORE performing the solve phase.
Definition: dam_uplift_circular_condition_load_process.hpp:244
ModelPart & mrModelPart
Member Variables.
Definition: dam_uplift_circular_condition_load_process.hpp:387
Definition: flags.h:58
void resize(std::size_t NewSize1, std::size_t NewSize2, bool preserve=0)
Definition: amatrix_interface.h:224
KratosComponents class encapsulates a lookup table for a family of classes in a generic way.
Definition: kratos_components.h:49
NodesContainerType & Nodes()
Definition: mesh.h:346
NodeIterator NodesBegin()
Definition: mesh.h:326
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
TableType::Pointer pGetTable(IndexType TableId)
Definition: model_part.h:595
MeshType & GetMesh(IndexType ThisIndex=0)
Definition: model_part.h:1791
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
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
The base class for all processes in Kratos.
Definition: process.h:49
Definition: table.h:435
BOOST_UBLAS_INLINE void resize(size_type array_size, bool preserve=true)
Definition: array_1d.h:242
#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
TExpressionType::data_type norm_2(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:625
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
time
Definition: face_heat.py:85
int nnodes
Definition: sensitivityMatrix.py:24
integer i
Definition: TensorModule.f:17