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.
calculate_adhesion_force.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 author: Alex Jarauta
11 // Co-author : Elaf Mahrous
12 
13 
14 #if !defined(CALCULATE_ADHESION_FORCE_INCLUDED )
15 #define CALCULATE_ADHESION_FORCE_INCLUDED
16 
17 
18 
19 // System includes
20 #include <string>
21 #include <iostream>
22 #include <algorithm>
23 
24 // External includes
25 
26 
27 // Project includes
28 #include <pybind11/pybind11.h>
29 #include "includes/define.h"
30 #include "includes/define_python.h"
31 
32 #include "includes/model_part.h"
33 #include "includes/node.h"
34 #include "utilities/math_utils.h"
35 #include "utilities/geometry_utilities.h"
36 #include "processes/process.h"
37 #include "includes/condition.h"
38 #include "includes/element.h"
39 #include "ULF_application.h"
40 
41 
42 
43 namespace Kratos
44 {
45 
46 
49 
53 
54 
58 
62 
66 
68 
76  : public Process
77  {
78  public:
79 
82 
85 
89 
92  {
93  }
94 
97  {
98  }
99 
100 
104 
105  // void operator()()
106  // {
107  // MergeParts();
108  // }
109 
110 
114 
115 
116  void CalculateAdhesionForce3D(ModelPart& ThisModelPart)
117  {
118  KRATOS_TRY
119 
120  double gamma = ThisModelPart.GetProcessInfo()[SURFACE_TENSION_COEF]; //Surface tension coefficient [N m-1]
121  double pi = 3.14159265359;
123  double theta, sign_force, theta_rad, cos_t;
126  array_1d<double,2> n_tp = ZeroVector(2);
127 
128  for(ModelPart::NodesContainerType::iterator im = ThisModelPart.NodesBegin() ;
129  im != ThisModelPart.NodesEnd() ; ++im)
130  {
131  //Find the neighbours of TRIPLE_POINT at the boundary
132  if ((im->FastGetSolutionStepValue(TRIPLE_POINT))*1000 != 0.0)
133  {
134  nu0[0] = im->FastGetSolutionStepValue( NORMAL_TRIPLE_POINT_X);
135  nu0[1] = im->FastGetSolutionStepValue( NORMAL_TRIPLE_POINT_Y);
136  NormalizeVec2D(nu0);
137  theta = im->FastGetSolutionStepValue(CONTACT_ANGLE);
138  theta_rad = (theta)*pi/180.0;
139  cos_t = cos(theta_rad);
140  cos_t = sqrt(cos_t*cos_t);
141  vel[0] = im->FastGetSolutionStepValue(VELOCITY_X);
142  vel[1] = im->FastGetSolutionStepValue(VELOCITY_Y);
143  if (vel[0] != 0.0 && vel[1] != 0.0)
144  {
145 // sign_force = fsign(theta,theta_eq);
146  sign_force = DotProduct2D(nu0,vel);
147  }
148  else
149  {
150  n_tp[0] = im->FastGetSolutionStepValue( NORMAL_TRIPLE_POINT_X);
151  n_tp[1] = im->FastGetSolutionStepValue( NORMAL_TRIPLE_POINT_Y);
152  sign_force = DotProduct2D(nu0,n_tp);
153  }
154  im->FastGetSolutionStepValue(ADHESION_FORCE_X) = -sign_force*gamma*cos_t*(im->FastGetSolutionStepValue(NODAL_LENGTH))*nu0[0];
155  im->FastGetSolutionStepValue(ADHESION_FORCE_Y) = -sign_force*gamma*cos_t*(im->FastGetSolutionStepValue(NODAL_LENGTH))*nu0[1];
156  im->FastGetSolutionStepValue(ADHESION_FORCE_Z) = 0.0;
157  }
158  else
159  {
160  im->FastGetSolutionStepValue(ADHESION_FORCE_X) = 0.0;
161  im->FastGetSolutionStepValue(ADHESION_FORCE_Y) = 0.0;
162  im->FastGetSolutionStepValue(ADHESION_FORCE_Z) = 0.0;
163  }
164 
165  }
166  KRATOS_CATCH("")
167  }
168 
169  void Vector2D(const double x0, const double y0, const double x1, const double y1, array_1d<double,2>& r01)
170  {
171  r01[0] = x1 - x0;
172  r01[1] = y1 - y0;
173  }
174 
175  void Vector3D(const double x0, const double y0, const double z0,
176  const double x1, const double y1, const double z1, array_1d<double,3>& r01)
177  {
178  r01[0] = x1 - x0;
179  r01[1] = y1 - y0;
180  r01[2] = z1 - z0;
181  }
182 
183  double Norm2D(const array_1d<double,2>& a)
184  {
185  return sqrt(a[0]*a[0] + a[1]*a[1]);
186  }
187 
188  double Norm3D(const array_1d<double,3>& a)
189  {
190  return sqrt(a[0]*a[0] + a[1]*a[1] + a[2]*a[2]);
191  }
192 
194  {
195  double norm = Norm2D(input);
196  if (norm != 0.0)
197  {
198  input[0] /= norm;
199  input[1] /= norm;
200  }
201  return input;
202  }
203 
205  {
206  double norm = Norm3D(input);
207  if (norm != 0.0)
208  {
209  input[0] /= norm;
210  input[1] /= norm;
211  input[2] /= norm;
212  }
213  return input;
214  }
215 
217  {
218  for (unsigned int i = 0; i < 3; i++)
219  {
220  c[i] = a[i] + b[i];
221  }
222  }
223 
225  {
226  return (a[0]*b[0] + a[1]*b[1]);
227  }
228 
229  double fsign(const double& a, const double& b)
230  {
231  double c = a - b;
232  if(c*c < 0.00000000000000001)
233  return 0;
234  else
235  return c/sqrt(c*c);
236  }
237 
238 
242 
243 
247 
248 
252 
254  std::string Info() const override
255  {
256  return "CalculateAdhesionForce";
257  }
258 
260  void PrintInfo(std::ostream& rOStream) const override
261  {
262  rOStream << "CalculateAdhesionForce";
263  }
264 
266  void PrintData(std::ostream& rOStream) const override
267  {
268  }
269 
270 
274 
275 
277 
278 protected:
281 
282 
286 
287 
291 
292 
296 
297 
301 
302 
306 
307 
311 
312 
314 
315 private:
318 
319 
323 
324 
328 
329 
333 
334 
338 
339 
343 
344 
348 
350 // CalculateAdhesionForce& operator=(CalculateAdhesionForce const& rOther);
351 
353 // CalculateAdhesionForce(CalculateAdhesionForce& rOther);
354 
355 
357 
358 }; // Class CalculateAdhesionForce
359 
361 
364 
365 
369 
370 
372 inline std::istream& operator >> (std::istream& rIStream,
373  CalculateAdhesionForce& rThis);
374 
376 inline std::ostream& operator << (std::ostream& rOStream,
377  const CalculateAdhesionForce& rThis)
378 {
379  rThis.PrintInfo(rOStream);
380  rOStream << std::endl;
381  rThis.PrintData(rOStream);
382 
383  return rOStream;
384 }
386 
387 
388 
389 } // namespace Kratos.
390 
391 
392 
393 #endif // KRATOS_CALCULATE_ADHESION_FORCE_INCLUDED defined
394 
395 
Short class definition.
Definition: calculate_adhesion_force.h:77
std::string Info() const override
Turn back information as a string.
Definition: calculate_adhesion_force.h:254
CalculateAdhesionForce()
Default constructor.
Definition: calculate_adhesion_force.h:91
double DotProduct2D(const array_1d< double, 2 > &a, const array_1d< double, 2 > &b)
Definition: calculate_adhesion_force.h:224
void CalculateAdhesionForce3D(ModelPart &ThisModelPart)
Definition: calculate_adhesion_force.h:116
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: calculate_adhesion_force.h:260
void Vector2D(const double x0, const double y0, const double x1, const double y1, array_1d< double, 2 > &r01)
Definition: calculate_adhesion_force.h:169
double SumVecs3D(const array_1d< double, 3 > &a, const array_1d< double, 3 > &b, array_1d< double, 3 > &c)
Definition: calculate_adhesion_force.h:216
KRATOS_CLASS_POINTER_DEFINITION(CalculateAdhesionForce)
Pointer definition of PushStructureProcess.
void Vector3D(const double x0, const double y0, const double z0, const double x1, const double y1, const double z1, array_1d< double, 3 > &r01)
Definition: calculate_adhesion_force.h:175
double Norm2D(const array_1d< double, 2 > &a)
Definition: calculate_adhesion_force.h:183
double Norm3D(const array_1d< double, 3 > &a)
Definition: calculate_adhesion_force.h:188
~CalculateAdhesionForce() override
Destructor.
Definition: calculate_adhesion_force.h:96
array_1d< double, 3 > NormalizeVec3D(array_1d< double, 3 > &input)
Definition: calculate_adhesion_force.h:204
array_1d< double, 2 > NormalizeVec2D(array_1d< double, 2 > &input)
Definition: calculate_adhesion_force.h:193
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: calculate_adhesion_force.h:266
double fsign(const double &a, const double &b)
Definition: calculate_adhesion_force.h:229
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
NodeIterator NodesEnd(IndexType ThisIndex=0)
Definition: model_part.h:497
The base class for all processes in Kratos.
Definition: process.h:49
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
im
Definition: GenerateCN.py:100
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
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
input
Definition: generate_frictional_mortar_condition.py:435
x1
Definition: generate_frictional_mortar_condition.py:121
a
Definition: generate_stokes_twofluid_element.py:77
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
float gamma
Definition: generate_two_fluid_navier_stokes.py:131
c
Definition: generate_weakly_compressible_navier_stokes_element.py:108
vel
Definition: pure_conduction.py:76
integer i
Definition: TensorModule.f:17
double precision, public pi
Definition: TensorModule.f:16