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_normal_eq.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 
15 #if !defined(CALCULATE_NORMAL_EQ_INCLUDED )
16 #define CALCULATE_NORMAL_EQ_INCLUDED
17 
18 
19 
20 // System includes
21 #include <string>
22 #include <iostream>
23 #include <algorithm>
24 
25 // External includes
26 
27 
28 // Project includes
29 #include <pybind11/pybind11.h>
30 #include "includes/define.h"
31 #include "includes/define_python.h"
32 
33 #include "includes/model_part.h"
34 #include "includes/node.h"
35 #include "utilities/math_utils.h"
36 #include "utilities/geometry_utilities.h"
37 #include "processes/process.h"
38 #include "includes/condition.h"
39 #include "includes/element.h"
40 #include "ULF_application.h"
41 
42 
43 
44 namespace Kratos
45 {
46 
49 
53 
54 
58 
62 
66 
68 
75  : public Process
76  {
77  public:
78 
81 
84 
88 
91  {
92  }
93 
95  ~CalculateNormalEq() override
96  {
97  }
98 
99 
103 
104  // void operator()()
105  // {
106  // MergeParts();
107  // }
108 
109 
113 
114 
115  void CalculateNormalEq3D(ModelPart& ThisModelPart)
116  {
117  KRATOS_TRY
118 
119  double pi = 3.14159265359;
120  double theta_eq = ThisModelPart.GetProcessInfo()[CONTACT_ANGLE_STATIC];
121  double theta_rad = theta_eq*pi/180.0;
123 
124  array_1d<double,3> normal_eq = ZeroVector(3);
125  array_1d<double,3> normal_xy = ZeroVector(3);
126  normal_xy[2] = 1.0;
128 
129  for(ModelPart::NodesContainerType::iterator im = ThisModelPart.NodesBegin() ; im != ThisModelPart.NodesEnd() ; ++im)
130  {
131  //Find the neighbours of TRIPLE_POINT at the boundary
132  if (im->FastGetSolutionStepValue(TRIPLE_POINT) != 0.0)
133  {
134  temp[0] = im->FastGetSolutionStepValue(NORMAL_TRIPLE_POINT_X);
135  temp[1] = im->FastGetSolutionStepValue(NORMAL_TRIPLE_POINT_Y);
137  normal_eq[0] = sin(theta_rad)*temp[0];
138  normal_eq[1] = sin(theta_rad)*temp[1];
139  normal_eq[2] = cos(theta_rad);
140  normal_eq = NormalizeVec3D(normal_eq);
141  im->FastGetSolutionStepValue(NORMAL_EQUILIBRIUM) = normal_eq;
142 
143  im->FastGetSolutionStepValue(NORMAL_CONTACT_LINE_EQUILIBRIUM_X) = -cos(theta_rad)*temp[0];
144  im->FastGetSolutionStepValue(NORMAL_CONTACT_LINE_EQUILIBRIUM_Y) = -cos(theta_rad)*temp[1];
145  im->FastGetSolutionStepValue(NORMAL_CONTACT_LINE_EQUILIBRIUM_Z) = sin(theta_rad);
146  im->FastGetSolutionStepValue(NORMAL_CONTACT_LINE_EQUILIBRIUM) = NormalizeVec3D(im->FastGetSolutionStepValue(NORMAL_CONTACT_LINE_EQUILIBRIUM));
147 
148  }
149  else
150  im->FastGetSolutionStepValue(NORMAL_CONTACT_LINE_EQUILIBRIUM) = ZeroVector(3);
151  }
152  KRATOS_CATCH("")
153  }
154 
155 
156 
157  array_1d<double,2> Vector2D(const double x0, const double y0, const double x1, const double y1)
158  {
159  array_1d<double,2> r01;
160  r01[0] = x1 - x0;
161  r01[1] = y1 - y0;
162  return r01;
163  }
164 
165  array_1d<double,3> Vector3D(const double x0, const double y0, const double z0,
166  const double x1, const double y1, const double z1)
167  {
168  array_1d<double,3> r01;
169  r01[0] = x1 - x0;
170  r01[1] = y1 - y0;
171  r01[2] = z1 - z0;
172  return r01;
173  }
174 
175  double Norm2D(const array_1d<double,2>& a)
176  {
177  return sqrt(a[0]*a[0] + a[1]*a[1]);
178  }
179 
180  double Norm3D(const array_1d<double,3>& a)
181  {
182  return sqrt(a[0]*a[0] + a[1]*a[1] + a[2]*a[2]);
183  }
184 
186  {
187  double norm = Norm2D(input);
188  if (norm != 0.0)
189  {
190  input[0] /= norm;
191  input[1] /= norm;
192  }
193  return input;
194  }
195 
197  {
198  double norm = Norm3D(input);
199  if (norm != 0.0)
200  {
201  input[0] /= norm;
202  input[1] /= norm;
203  input[2] /= norm;
204  }
205  return input;
206  }
207 
209  {
211  for (unsigned int i = 0; i < 3; i++)
212  {
213  c[i] = a[i] + b[i];
214  }
215  return c;
216  }
217 
219  {
220  double pi = 3.14159265359;
221  double norm_a = Norm3D(a);
222  double norm_b = Norm3D(b);
223  double temp = 0.0;
224  if (norm_a*norm_b > -0.00000001 && norm_a*norm_b < 0.00000001)
225  temp = 0.0;
226  else
227  temp = DotProduct3D(a,b)/(norm_a*norm_b);
228  return (acos(temp)*180.0/pi);
229  }
230 
232  {
233  return (a[0]*b[0] + a[1]*b[1] + a[2]*b[2]);
234  }
235 
239 
240 
244 
245 
249 
251  std::string Info() const override
252  {
253  return "AssignSurfaceTensionConditions";
254  }
255 
257  void PrintInfo(std::ostream& rOStream) const override
258  {
259  rOStream << "AssignSurfaceTensionConditions";
260  }
261 
263  void PrintData(std::ostream& rOStream) const override
264  {
265  }
266 
267 
271 
272 
274 
275 protected:
278 
279 
283 
284 
288 
289 
293 
294 
298 
299 
303 
304 
308 
309 
311 
312 private:
315 
316 
320 
321 
325 
326 
330 
331 
335 
336 
340 
341 
345 
347 // CalculateNormalEq& operator=(CalculateNormalEq const& rOther);
348 
350 // CalculateNormalEq(CalculateNormalEq const& rOther);
351 
352 
354 
355 }; // Class CalculateNormalEq
356 
358 
361 
362 
366 
367 
369 inline std::istream& operator >> (std::istream& rIStream,
370  CalculateNormalEq& rThis);
371 
373 inline std::ostream& operator << (std::ostream& rOStream,
374  const CalculateNormalEq& rThis)
375 {
376  rThis.PrintInfo(rOStream);
377  rOStream << std::endl;
378  rThis.PrintData(rOStream);
379 
380  return rOStream;
381 }
383 
384 
385 
386 } // namespace Kratos.
387 
388 
389 #endif // KRATOS_CALCULATE_NORMAL_EQ_INCLUDED defined
390 
391 
Short class definition.
Definition: calculate_normal_eq.h:76
CalculateNormalEq()
Default constructor.
Definition: calculate_normal_eq.h:90
KRATOS_CLASS_POINTER_DEFINITION(CalculateNormalEq)
Pointer definition of PushStructureProcess.
~CalculateNormalEq() override
Destructor.
Definition: calculate_normal_eq.h:95
std::string Info() const override
Turn back information as a string.
Definition: calculate_normal_eq.h:251
array_1d< double, 2 > NormalizeVec2D(array_1d< double, 2 > &input)
Definition: calculate_normal_eq.h:185
double Angle2vecs3D(const array_1d< double, 3 > &a, const array_1d< double, 3 > &b)
Definition: calculate_normal_eq.h:218
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: calculate_normal_eq.h:263
double Norm2D(const array_1d< double, 2 > &a)
Definition: calculate_normal_eq.h:175
double Norm3D(const array_1d< double, 3 > &a)
Definition: calculate_normal_eq.h:180
array_1d< double, 2 > Vector2D(const double x0, const double y0, const double x1, const double y1)
Definition: calculate_normal_eq.h:157
array_1d< double, 3 > Vector3D(const double x0, const double y0, const double z0, const double x1, const double y1, const double z1)
Definition: calculate_normal_eq.h:165
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: calculate_normal_eq.h:257
array_1d< double, 3 > NormalizeVec3D(array_1d< double, 3 > &input)
Definition: calculate_normal_eq.h:196
array_1d< double, 3 > SumVecs3D(const array_1d< double, 3 > &a, const array_1d< double, 3 > &b)
Definition: calculate_normal_eq.h:208
double DotProduct3D(const array_1d< double, 3 > &a, const array_1d< double, 3 > &b)
Definition: calculate_normal_eq.h:231
void CalculateNormalEq3D(ModelPart &ThisModelPart)
Definition: calculate_normal_eq.h:115
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
c
Definition: generate_weakly_compressible_navier_stokes_element.py:108
float temp
Definition: rotating_cone.py:85
integer i
Definition: TensorModule.f:17
double precision, public pi
Definition: TensorModule.f:16