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.
Boundary_Windkessel_model.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main authors: Eduardo Soudah
11 // Jordi Cotela
12 //
13 
14 #if !defined(KRATOS_WINDKESSEL_H_INCLUDED )
15 #define KRATOS_WINDKESSEL_H_INCLUDED
16 
17 
18 
19 // System includes
20 #include <string>
21 #include <iostream>
22 
23 
24 // External includes
25 
26 // Project includes
27 #include "includes/define.h"
28 #include "processes/process.h"
29 
30 
31 // Application includes
33 
34 namespace Kratos
35 {
38 
41 
45 
49 
53 
57 
59 
62 class WindkesselModel : public Process
63 {
64 public:
67 
70 
74 
76 
77  ModelPart& ThisModelPart
78  //typename TLinearSolver::Pointer pLinearSolver,
79  //unsigned int DomainSize,
80  //double NonLinearTol,
81  //unsigned int MaxIter,
82  //bool ReformDofSet,
83  //unsigned int TimeOrder
84  )
85  : mr_model_part(ThisModelPart)
86  //mmax_it(MaxIter), mtime_order(TimeOrder),madapt_for_fractional_step(false)
87  //, mdomain_size(DomainSize), mtol(NonLinearTol), mmax_it(MaxIter), mtime_order(TimeOrder),madapt_for_fractional_step(false)
88  {
89  }
90 
92 
93  ~WindkesselModel() override
94  {
95  }
96 
97 
101 
102 
106 
108  void Execute() override
109  {
110  KRATOS_TRY
111  double Flow_total=0.0;
112  double Resistence = 5e9;
113  if ((Resistence <=0.0)){
114  KRATOS_THROW_ERROR(std::logic_error, "Resistece must be higer than cero:", Resistence);
115  }
117  //1_Compute Flow in the outlew area
118  for(ModelPart::ConditionsContainerType::iterator i = rConditions.begin(); i!=rConditions.end(); i++){
119  //KRATOS_WATCH(i->GetProperties().Id())
120  if(i->GetProperties().Id() == 1001){
121  //i->NodesContainerType rNodes = mr_model_part.Nodes();
122  double Area = i->GetGeometry().Area();
123  //double Velocity_total_X=0.0;
124  //double Velocity_total_Y=0.0;
125  //double Velocity_total_Z=0.0;
126  double total_velocity=0.0;
127  double velocity =0.0;
128  double Flow_total_node=0.0;
129  for (unsigned int j = 0 ; j < i->GetGeometry().PointsNumber(); j++){
130  const double Velocity_node_X= i->GetGeometry()[j].FastGetSolutionStepValue(VELOCITY_X);
131  const double Velocity_node_Y= i->GetGeometry()[j].FastGetSolutionStepValue(VELOCITY_Y);
132  const double Velocity_node_Z= i->GetGeometry()[j].FastGetSolutionStepValue(VELOCITY_Z);
133  velocity=sqrt(pow(Velocity_node_X,2.0) + pow(Velocity_node_Y,2.0) + pow(Velocity_node_Z,2.0));
134  total_velocity += velocity;
135 // Velocity_total_X +=Velocity_node_X;
136 // Velocity_total_Y +=Velocity_node_Y;
137 // Velocity_total_Z +=Velocity_node_Z;
138  }
139  //Flow_total=((Velocity_total_X+Velocity_total_Y+Velocity_total_Z)/3);
140 
141  Flow_total_node=total_velocity/3;
142  Flow_total+= Flow_total_node*Area;
143  //KRATOS_WATCH(Area)
144  }
145  }
146  //2_Compute the Pressure according to the Windkessel Model
147  double Update_Pressure = Flow_total * Resistence;
148  //KRATOS_WATCH(Flow_total)
149  //3_Assign Pressure over the outlet area
151  for(ModelPart::NodesContainerType::iterator i = rNodes.begin(); i!=rNodes.end(); i++)
152  {
153  const int Flag = i->FastGetSolutionStepValue(FLAG_VARIABLE);
154  if(Flag == 1001)
155  {
156  i->FastGetSolutionStepValue(PRESSURE) = Update_Pressure;
157  //KRATOS_WATCH(Update_Pressure)
158  }
159  }
160  KRATOS_WATCH("Windkessel_Pressure")
161  KRATOS_CATCH("");
162  }
163 
164 
165 
169 
170 
174 
175 
179 
181 
182  std::string Info() const override
183  {
184  std::stringstream buffer;
185  buffer << "WindkesselModel";
186  return buffer.str();
187  }
188 
190 
191  void PrintInfo(std::ostream& rOStream) const override
192  {
193  rOStream << "WindkesselModel";
194  }
195 
197 
198  void PrintData(std::ostream& rOStream) const override
199  {
200  }
201 
202 
206 
207 
209 
210 protected:
213 
214 
218 
220  //ModelPart mspalart_model_part;
221 
222 
223 
224 
225 
226 
230 
231 
235 
236 
240 
241 
245 
246 
250 
252 
253 private:
256 
257 
261 
262 
266 
270 
271 
275 
276 
280 
281 
285 
287 
288  WindkesselModel & operator=(WindkesselModel const& rOther)
289  {
290  return *this;
291  }
292 
294 
295  WindkesselModel(WindkesselModel const& rOther)
296  : mr_model_part(rOther.mr_model_part)
297  {
298  }
299 
300 
302 
303 }; // Class WindkesselModel
304 
306 
309 
310 
314 
315 
317 
318 
319 inline std::istream & operator >>(std::istream& rIStream,
320  WindkesselModel& rThis)
321 {
322  return rIStream;
323 }
324 
326 
327 inline std::ostream & operator <<(std::ostream& rOStream,
328  const WindkesselModel& rThis)
329 {
330  rThis.PrintInfo(rOStream);
331  rOStream << std::endl;
332  rThis.PrintData(rOStream);
333 
334  return rOStream;
335 }
337 
339 
340 } // namespace Kratos.
341 
342 #endif // KRATOS_WINDKESSEL_H_INCLUDED defined
343 
344 
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
MeshType::ConditionsContainerType ConditionsContainerType
Condintions container. A vector set of Conditions with their Id's as key.
Definition: model_part.h:183
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
The base class for all processes in Kratos.
Definition: process.h:49
An impelementation of the Windkessel model for boundary condition of incompressible flows.
Definition: Boundary_Windkessel_model.h:63
std::string Info() const override
Turn back information as a string.
Definition: Boundary_Windkessel_model.h:182
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: Boundary_Windkessel_model.h:198
WindkesselModel(ModelPart &ThisModelPart)
Definition: Boundary_Windkessel_model.h:75
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: Boundary_Windkessel_model.h:191
~WindkesselModel() override
Destructor.
Definition: Boundary_Windkessel_model.h:93
void Execute() override
Solve an iteration of the turbulent viscosity.
Definition: Boundary_Windkessel_model.h:108
KRATOS_CLASS_POINTER_DEFINITION(WindkesselModel)
Pointer definition of WindkesselModel.
ModelPart & mr_model_part
Definition: Boundary_Windkessel_model.h:219
#define KRATOS_THROW_ERROR(ExceptionType, ErrorMessage, MoreInfo)
Definition: define.h:77
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_WATCH(variable)
Definition: define.h:806
#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
float velocity
Definition: PecletTest.py:54
int j
Definition: quadrature.py:648
integer i
Definition: TensorModule.f:17