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_westergaard_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 #if !defined(KRATOS_DAM_WESTERGAARD_CONDITION_LOAD_PROCESS)
14 #define KRATOS_DAM_WESTERGAARD_CONDITION_LOAD_PROCESS
15 
16 #include <cmath>
17 
18 // Project includes
19 #include "includes/kratos_flags.h"
21 #include "processes/process.h"
22 
23 // Application include
25 
26 namespace Kratos
27 {
28 
30 {
31 
32  public:
34 
36 
37  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
38 
41  Parameters &rParameters) : Process(Flags()), mrModelPart(rModelPart)
42  {
44 
45  //only include validation with c++11 since raw_literals do not exist in c++03
46  Parameters default_parameters(R"(
47  {
48  "model_part_name":"PLEASE_CHOOSE_MODEL_PART_NAME",
49  "variable_name": "PLEASE_PRESCRIBE_VARIABLE_NAME",
50  "Modify" : true,
51  "Gravity_Direction" : "Y",
52  "Reservoir_Bottom_Coordinate_in_Gravity_Direction" : 0.0,
53  "Spe_weight" : 0.0,
54  "Water_level" : 0.0,
55  "Water_Table" : 0,
56  "Aceleration" : 0.0,
57  "Aceleration_Table" : 0,
58  "interval":[
59  0.0,
60  0.0
61  ]
62  } )");
63 
64  // Some values need to be mandatorily prescribed since no meaningful default value exist. For this reason try accessing to them
65  // So that an error is thrown if they don't exist
66  rParameters["Reservoir_Bottom_Coordinate_in_Gravity_Direction"];
67  rParameters["variable_name"];
68  rParameters["model_part_name"];
69 
70  // Now validate agains defaults -- this also ensures no type mismatch
71  rParameters.ValidateAndAssignDefaults(default_parameters);
72 
73  mVariableName = rParameters["variable_name"].GetString();
74  mGravityDirection = rParameters["Gravity_Direction"].GetString();
75  mReferenceCoordinate = rParameters["Reservoir_Bottom_Coordinate_in_Gravity_Direction"].GetDouble();
76  mSpecific = rParameters["Spe_weight"].GetDouble();
77  mWaterLevel = rParameters["Water_level"].GetDouble();
78  mAcceleration = rParameters["Aceleration"].GetDouble();
79 
80  mTimeUnitConverter = mrModelPart.GetProcessInfo()[TIME_UNIT_CONVERTER];
81  mTableIdWater = rParameters["Water_Table"].GetInt();
82  mTableIdAcceleration = rParameters["Aceleration_Table"].GetInt();
83 
84  if (mTableIdWater != 0)
86 
87  if (mTableIdAcceleration != 0)
89 
90  KRATOS_CATCH("");
91  }
92 
94 
97 
98  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
99 
100  void Execute() override
101  {
102  }
103 
104  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
105 
106  void ExecuteInitialize() override
107  {
108  KRATOS_TRY;
109 
111  const int nnodes = mrModelPart.GetMesh(0).Nodes().size();
112  int direction;
113  double pressure;
114 
115  if (mGravityDirection == "X")
116  direction = 0;
117  else if (mGravityDirection == "Y")
118  direction = 1;
119  else
120  direction = 2;
121 
122  double unit_acceleration = mAcceleration / 9.81;
123 
124  if (nnodes != 0)
125  {
126  ModelPart::NodesContainerType::iterator it_begin = mrModelPart.GetMesh(0).NodesBegin();
127 
128 #pragma omp parallel for
129  for (int i = 0; i < nnodes; i++)
130  {
131  ModelPart::NodesContainerType::iterator it = it_begin + i;
132 
133  double y_water = mWaterLevel - (it->Coordinates()[direction]);
134 
135  if (y_water < 0.0)
136  {
137  y_water = 0.0;
138  }
139 
140  pressure = (mSpecific * (y_water)) + 0.875 * (unit_acceleration)*mSpecific * sqrt(y_water * (mWaterLevel - mReferenceCoordinate));
141  it->FastGetSolutionStepValue(var) = pressure;
142  }
143  }
144 
145  KRATOS_CATCH("");
146  }
147 
148  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
149 
151  {
152 
153  KRATOS_TRY;
154 
156 
157  // Getting the values of table in case that it exist
158  if (mTableIdWater != 0)
159  {
160  double time = mrModelPart.GetProcessInfo()[TIME];
162  mWaterLevel = mpTableWater->GetValue(time);
163  }
164 
165  if (mTableIdAcceleration != 0)
166  {
167  double time = mrModelPart.GetProcessInfo()[TIME];
170  }
171 
172  const int nnodes = mrModelPart.GetMesh(0).Nodes().size();
173  int direction;
174  double pressure;
175 
176  if (mGravityDirection == "X")
177  direction = 0;
178  else if (mGravityDirection == "Y")
179  direction = 1;
180  else
181  direction = 2;
182 
183  double unit_acceleration = mAcceleration / 9.81;
184 
185  if (nnodes != 0)
186  {
187  ModelPart::NodesContainerType::iterator it_begin = mrModelPart.GetMesh(0).NodesBegin();
188 
189 #pragma omp parallel for
190  for (int i = 0; i < nnodes; i++)
191  {
192  ModelPart::NodesContainerType::iterator it = it_begin + i;
193 
194  double y_water = mWaterLevel - (it->Coordinates()[direction]);
195 
196  if (y_water < 0.0)
197  {
198  y_water = 0.0;
199  }
200 
201  // Hydrodynamics Westergaard effects just contribute when the acceleration goes in the upstream direction
202  if (unit_acceleration < 0.0)
203  {
204  pressure = (mSpecific * (y_water)) + 0.875 * (-1.0 * unit_acceleration) * mSpecific * sqrt(y_water * (mWaterLevel - mReferenceCoordinate));
205  }
206  else
207  {
208  pressure = (mSpecific * (y_water));
209  }
210 
211  if (pressure > 0.0)
212  {
213  it->FastGetSolutionStepValue(var) = pressure;
214  }
215  else
216  {
217  it->FastGetSolutionStepValue(var) = 0.0;
218  }
219  }
220  }
221 
222  KRATOS_CATCH("");
223  }
224 
226  std::string Info() const override
227  {
228  return "DamWestergaardConditionLoadProcess";
229  }
230 
232  void PrintInfo(std::ostream &rOStream) const override
233  {
234  rOStream << "DamWestergaardConditionLoadProcess";
235  }
236 
238  void PrintData(std::ostream &rOStream) const override
239  {
240  }
241 
243 
244  protected:
246 
248  std::string mVariableName;
249  std::string mGravityDirection;
251  double mSpecific;
252  double mWaterLevel;
255  TableType::Pointer mpTableWater;
256  TableType::Pointer mpTableAcceleration;
259 
260  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
261 
262  private:
265 
266 }; //Class
267 
269 inline std::istream &operator>>(std::istream &rIStream,
271 
273 inline std::ostream &operator<<(std::ostream &rOStream,
275 {
276  rThis.PrintInfo(rOStream);
277  rOStream << std::endl;
278  rThis.PrintData(rOStream);
279 
280  return rOStream;
281 }
282 
283 } /* namespace Kratos.*/
284 
285 #endif /* KRATOS_DAM_WESTERGAARD_CONDITION_LOAD_PROCESS defined */
Definition: dam_westergaard_condition_load_process.hpp:30
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: dam_westergaard_condition_load_process.hpp:232
double mReferenceCoordinate
Definition: dam_westergaard_condition_load_process.hpp:250
KRATOS_CLASS_POINTER_DEFINITION(DamWestergaardConditionLoadProcess)
double mAcceleration
Definition: dam_westergaard_condition_load_process.hpp:253
ModelPart & mrModelPart
Member Variables.
Definition: dam_westergaard_condition_load_process.hpp:247
void ExecuteInitializeSolutionStep() override
This function will be executed at every time step BEFORE performing the solve phase.
Definition: dam_westergaard_condition_load_process.hpp:150
void ExecuteInitialize() override
This function is designed for being called at the beginning of the computations right after reading t...
Definition: dam_westergaard_condition_load_process.hpp:106
virtual ~DamWestergaardConditionLoadProcess()
Destructor.
Definition: dam_westergaard_condition_load_process.hpp:96
Table< double, double > TableType
Definition: dam_westergaard_condition_load_process.hpp:35
int mTableIdWater
Definition: dam_westergaard_condition_load_process.hpp:257
double mWaterLevel
Definition: dam_westergaard_condition_load_process.hpp:252
double mTimeUnitConverter
Definition: dam_westergaard_condition_load_process.hpp:254
std::string mVariableName
Definition: dam_westergaard_condition_load_process.hpp:248
std::string Info() const override
Turn back information as a string.
Definition: dam_westergaard_condition_load_process.hpp:226
void Execute() override
Execute method is used to execute the Process algorithms.
Definition: dam_westergaard_condition_load_process.hpp:100
TableType::Pointer mpTableAcceleration
Definition: dam_westergaard_condition_load_process.hpp:256
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: dam_westergaard_condition_load_process.hpp:238
double mSpecific
Definition: dam_westergaard_condition_load_process.hpp:251
std::string mGravityDirection
Definition: dam_westergaard_condition_load_process.hpp:249
int mTableIdAcceleration
Definition: dam_westergaard_condition_load_process.hpp:258
TableType::Pointer mpTableWater
Definition: dam_westergaard_condition_load_process.hpp:255
DamWestergaardConditionLoadProcess(ModelPart &rModelPart, Parameters &rParameters)
Constructor.
Definition: dam_westergaard_condition_load_process.hpp:40
Definition: flags.h:58
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
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
#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
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
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
float pressure
Definition: test_pureconvectionsolver_benchmarking.py:101