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.
pfem2_utilities.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: Author Julio Marti.
11 //
12 
13 #if !defined(KRATOS_ULF_UTILITIES_INCLUDED )
14 #define KRATOS_ULF_UTILITIES_INCLUDED
15 
16 
17 
18 
19 
20 
21 // System includes
22 #include <string>
23 #include <iostream>
24 #include <algorithm>
25 
26 // External includes
27 
28 
29 // Project includes
30 #include "includes/define.h"
31 #include "includes/model_part.h"
32 #include "includes/node.h"
33 #include "utilities/geometry_utilities.h"
36 #include "boost/smart_ptr.hpp"
37 #include "includes/cfd_variables.h"
39 
40 #include "processes/process.h"
41 #include "includes/condition.h"
43 //#include "incompressible_fluid_application.h"
44 
45 
46 
47 namespace Kratos
48 {
50 {
51 public:
52  typedef Node NodeType;
53  //**********************************************************************************************
54  //**********************************************************************************************
55 
56  //functions to apply the boundary conditions
57 
58  void ApplyBoundaryConditions(ModelPart& ThisModelPart, int laplacian_type)
59  {
60  KRATOS_TRY;
61 
62  if(laplacian_type == 1)
63  {
64  //identify fluid nodes and mark as boundary the free ones
65  for(ModelPart::NodesContainerType::const_iterator in = ThisModelPart.NodesBegin(); in!=ThisModelPart.NodesEnd(); in++)
66  {
67  //marking wet nodes
68  if(in->FastGetSolutionStepValue(IS_STRUCTURE) )
69  if( (in->GetValue(NEIGHBOUR_ELEMENTS)).size() != 0)
70  in->FastGetSolutionStepValue(IS_FLUID) = 1.0;
71  else //it is not anymore of fluid
72  in->FastGetSolutionStepValue(IS_FLUID) = 0.0;
73  //marking as free surface the lonely nodes
74  else if( (in->GetValue(NEIGHBOUR_ELEMENTS)).size() == 0)
75  in->FastGetSolutionStepValue(IS_BOUNDARY) = 1.0;
76  }
77 
78  //identify the free surface
79  for(ModelPart::NodeIterator i = ThisModelPart.NodesBegin() ;
80  i != ThisModelPart.NodesEnd() ; ++i)
81  {
82  //reset the free surface
83  i->FastGetSolutionStepValue(IS_FREE_SURFACE) = 0;
84  i->Free(PRESSURE);
85 
86  //identify the free surface and fix the pressure accordingly
87  if( i->FastGetSolutionStepValue(IS_BOUNDARY) != 0
88  &&
89  i->FastGetSolutionStepValue(IS_STRUCTURE) == 0)
90  {
91  i->FastGetSolutionStepValue(IS_FREE_SURFACE) = 1;
92  i->FastGetSolutionStepValue(PRESSURE) = 0.00;
93  i->Fix(PRESSURE);
94  }
95  }
96 
97 
98  }
99  else //case of discrete laplacian
100  {
101  //identify fluid nodes and mark as boundary the free ones
102  for(ModelPart::NodesContainerType::const_iterator in = ThisModelPart.NodesBegin(); in!=ThisModelPart.NodesEnd(); in++)
103  {
104  //marking wet nodes
105  if(in->FastGetSolutionStepValue(IS_STRUCTURE) )
106  if( (in->GetValue(NEIGHBOUR_ELEMENTS)).size() != 0)
107  in->FastGetSolutionStepValue(IS_FLUID) = 1.0;
108  else //it is not anymore of fluid
109  in->FastGetSolutionStepValue(IS_FLUID) = 0.0;
110  //marking as free surface the lonely nodes
111  else if( (in->GetValue(NEIGHBOUR_ELEMENTS)).size() == 0)
112  in->FastGetSolutionStepValue(IS_BOUNDARY) = 1.0;
113 
114  if( (in->GetValue(NEIGHBOUR_ELEMENTS)).size() == 0)
115  in->FastGetSolutionStepValue(PRESSURE) = 0.0;
116  }
117 
118  //identify the free surface
119  for(ModelPart::NodeIterator i = ThisModelPart.NodesBegin() ;
120  i != ThisModelPart.NodesEnd() ; ++i)
121  {
122  //reset the free surface
123  i->FastGetSolutionStepValue(IS_FREE_SURFACE) = 0;
124 
125  //identify the free surface and fix the pressure accordingly
126  if( i->FastGetSolutionStepValue(IS_BOUNDARY) != 0
127  &&
128  i->FastGetSolutionStepValue(IS_STRUCTURE) == 0)
129  {
130  i->FastGetSolutionStepValue(IS_FREE_SURFACE) = 1;
131  }
132  }
133 
134 
135 
136  }
137 
138  KRATOS_CATCH("");
139  }
140  //**********************************************************************************************
141  //**********************************************************************************************
142  void IdentifyFluidNodes(ModelPart& ThisModelPart)
143  {
144  KRATOS_TRY;
145 
146  for(ModelPart::ElementsContainerType::iterator i = ThisModelPart.ElementsBegin();
147  i!=ThisModelPart.ElementsEnd(); i++)
148  {
149  //calculating shape functions values
150  Geometry< Node >& geom = i->GetGeometry();
151 
152  for(unsigned int i = 0; i<geom.size(); i++)
153  geom[i].FastGetSolutionStepValue(IS_FLUID) = 1;
154 
155  }
156  KRATOS_CATCH("");
157  }
158 
159  //**********************************************************************************************
160  //**********************************************************************************************
161  void ApplyMinimalPressureConditions(std::vector< GlobalPointersVector< Node > >& connected_components)
162  {
163  KRATOS_TRY;
164 
165  //verify that the minimal conditions for pressure are applied
166  std::vector<bool> to_be_prescribed(connected_components.size());
167  array_1d<double,3> fixed_vel;
168  for(unsigned int i = 0; i<connected_components.size(); i++)
169  {
170  int boundary_nodes = 0;
171  int prescribed_vel_nodes = 0;
172  GlobalPointersVector< Node >& node_list = connected_components[i];
174  in != node_list.end(); in++)
175  {
176  //free the pressure
177  in->Free(PRESSURE);
178 
179  //cound boundary and fixed velocity nodes
180  if(in->FastGetSolutionStepValue(IS_BOUNDARY) == 1)
181  {
182  //count the nodes added
183  boundary_nodes += 1;
184 
185  //if it is structure add it to the fixed nodes
186  if(in->FastGetSolutionStepValue(IS_STRUCTURE) == 1)
187  prescribed_vel_nodes += 1;
188 
189  }
190  }
191 
192  //if all the boundary nodes have the velocity prescribed => it is needed to
193  //prescribe the pressure on 1 node
194  if(boundary_nodes == prescribed_vel_nodes)
195  {
196  bool one_is_prescribed = false;
198  in != node_list.end(); in++)
199  {
200  if( one_is_prescribed == false &&
201  in->FastGetSolutionStepValue(IS_BOUNDARY) == 1 )
202  {
203  std::cout << "fixed pressure on node " << in->Id() << std::endl;
204  one_is_prescribed = true;
205  in->Fix(PRESSURE);
206  }
207  }
208  }
209  }
210  KRATOS_CATCH("");
211  }
212 
213  //**********************************************************************************************
214  //**********************************************************************************************
215  double EstimateDeltaTime(double dt_min, double dt_max, ModelPart& ThisModelPart)
216  {
217  KRATOS_TRY
218 
219  array_1d<double,3> dx, dv;
220  double deltatime = dt_max;
221  double dvside, lside;
222 
223  for(ModelPart::ElementsContainerType::iterator i = ThisModelPart.ElementsBegin();
224  i!=ThisModelPart.ElementsEnd(); i++)
225  {
226  //calculating shape functions values
227  Geometry< Node >& geom = i->GetGeometry();
228 
229  for(unsigned int i1 = 0; i1 < geom.size()-1; i1++)
230  {
231  for(unsigned int i2 = i1 + 1; i2 < geom.size(); i2++)
232  {
233  dx[0] = geom[i2].X() - geom[i1].X();
234  dx[1] = geom[i2].Y() - geom[i1].Y();
235  dx[2] = geom[i2].Z() - geom[i1].Z();
236 
237  lside = inner_prod(dx,dx);
238 
239  noalias(dv) = geom[i2].FastGetSolutionStepValue(VELOCITY);
240  noalias(dv) -= geom[i1].FastGetSolutionStepValue(VELOCITY);
241 
242  dvside = inner_prod(dx,dv);
243 
244  double dt;
245  if(dvside < 0.0) //otherwise the side is "getting bigger" so the time step has not to be diminished
246  {
247  dt = fabs( lside/dvside );
248  if(dt < deltatime) deltatime = dt;
249  }
250 
251  }
252  }
253  }
254 
255  if(deltatime < dt_min)
256  {
257  std::cout << "ATTENTION dt_min is being used" << std::endl;
258  deltatime = dt_min;
259  }
260 
261 
262  return deltatime;
263 
264  KRATOS_CATCH("")
265  }
266  //**********************************************************************************************
267  //**********************************************************************************************
268  void MarkOuterNodes(const array_1d<double,3>& corner1, const array_1d<double,3>& corner2,
270  {
271  KRATOS_TRY;
272 
273  //add a big number to the id of the nodes to be erased
274  int n_erased = 0;
275  double xmax, xmin, ymax,ymin, zmax, zmin;
276 
277 
278 
279  if(corner1[0] > corner2[0])
280  {
281  xmax = corner1[0];
282  xmin = corner2[0];
283  }
284  else
285  {
286  xmax = corner2[0];
287  xmin = corner1[0];
288  }
289 
290  if(corner1[1] > corner2[1])
291  {
292  ymax = corner1[1];
293  ymin = corner2[1];
294  }
295  else
296  {
297  ymax = corner2[1];
298  ymin = corner1[1];
299  }
300 
301  if(corner1[2] > corner2[2])
302  {
303  zmax = corner1[2];
304  zmin = corner2[2];
305  }
306  else
307  {
308  zmax = corner2[2];
309  zmin = corner1[2];
310  }
311 
312 
313 
314  for(ModelPart::NodesContainerType::iterator in = rNodes.begin(); in!=rNodes.end(); in++)
315  {
316  bool erase = false;
317  double& x = in->X();
318  double& y = in->Y();
319  double& z = in->Z();
320 
321  if(x<xmin || x>xmax) erase = true;
322  else if(y<ymin || y>ymax) erase = true;
323  else if(z<zmin || z>zmax) erase = true;
324 
325  if(erase == true)
326  {
327  n_erased += 1;
328  in->Set(TO_ERASE, true);
329  }
330  }
331 
332  KRATOS_CATCH("")
333  }
334 
335  //**********************************************************************************************
336  //**********************************************************************************************
337  void MarkExcessivelyCloseNodes(ModelPart::NodesContainerType& rNodes, const double admissible_distance_factor)
338  {
339  KRATOS_TRY;
340  KRATOS_WATCH("ENTERD Mark close nodes")
341  double fact2 = admissible_distance_factor*admissible_distance_factor;
342 
343 
344  for(ModelPart::NodesContainerType::iterator in = rNodes.begin(); in!=rNodes.end(); in++)
345  {
346  if(in->FastGetSolutionStepValue(IS_STRUCTURE) == 0) //if it is not a wall node i can erase
347  {
348  double hnode2 = in->FastGetSolutionStepValue(NODAL_H);
349  hnode2 *= hnode2; //take the square
350 
351  //loop on neighbours and erase if they are too close
352  for( GlobalPointersVector< Node >::iterator i = in->GetValue(NEIGHBOUR_NODES).begin();
353  i != in->GetValue(NEIGHBOUR_NODES).end(); i++)
354  {
355  if( bool(i->Is(TO_ERASE)) == false) //we can erase the current node only if the neighb is not to be erased
356  {
357  double dx = i->X() - in->X();
358  double dy = i->Y() - in->Y();
359  double dz = i->Z() - in->Z();
360 
361  double dist2 = dx*dx + dy*dy + dz*dz;
362 
363  if(dist2 < fact2 * hnode2)
364  in->Set(TO_ERASE, true);
365  }
366  }
367  }
368  }
369 
370  KRATOS_CATCH("")
371  }
372 
373 
374  //**********************************************************************************************
375  //* //**********************************************************************************************
378  {
379  //KRATOS_WATCH("length calculation")
380  return sqrt((Point1[0]-Point2[0])*(Point1[0]-Point2[0]) + (Point1[1]-Point2[1])*(Point1[1]-Point2[1]) +(Point1[2]-Point2[2])*(Point1[2]-Point2[2]));
381  }
383  {
384  //Heron's formula
385  double a=Length(Point1, Point2);//sqrt((Point1[0]-Point2[0])*(Point1[0]-Point2[0]) + (Point1[1]-Point2[1])*(Point1[1]-Point2[1]) +(Point1[2]-Point2[2])*(Point1[2]-Point2[2]));
386  double b=Length(Point1, Point3);//sqrt((Point3[0]-Point2[0])*(Point3[0]-Point2[0]) + (Point3[1]-Point2[1])*(Point3[1]-Point2[1]) +(Point3[2]-Point2[2])*(Point3[2]-Point2[2]));
387  double c=Length(Point2, Point3);//sqrt((Point1[0]-Point3[0])*(Point1[0]-Point3[0]) + (Point1[1]-Point3[1])*(Point1[1]-Point3[1]) +(Point1[2]-Point3[2])*(Point1[2]-Point3[2]));
388  double p=0.5*(a+b+c);
389  return sqrt(p*(p-a)*(p-b)*(p-c));
390  }
391 
393 
395  void CalculateNodalArea(ModelPart& ThisModelPart, int domain_size)
396  {
397 
398  KRATOS_TRY
399 
400  //set to zero the nodal area
401  for(ModelPart::NodesContainerType::iterator in = ThisModelPart.NodesBegin();
402  in!=ThisModelPart.NodesEnd(); in++)
403  {
404  in->FastGetSolutionStepValue(NODAL_AREA) = 0.00;
405  }
406 
407  if(domain_size == 2)
408  {
409  double area = 0.0;
410  for(ModelPart::ElementsContainerType::iterator i = ThisModelPart.ElementsBegin();
411  i!=ThisModelPart.ElementsEnd(); i++)
412  {
413  //calculating shape functions values
414  Geometry< Node >& geom = i->GetGeometry();
415 
417  area *= 0.333333333333333333333333333;
418 
419 
420  geom[0].FastGetSolutionStepValue(NODAL_AREA) += area;
421  geom[1].FastGetSolutionStepValue(NODAL_AREA) += area;
422  geom[2].FastGetSolutionStepValue(NODAL_AREA) += area;
423 
424  }
425  }
426  else if(domain_size == 3)
427  {
428  for(ModelPart::ElementsContainerType::iterator i = ThisModelPart.ElementsBegin();
429  i!=ThisModelPart.ElementsEnd(); i++)
430  {
431  double vol;
432  //calculating shape functions values
433  Geometry< Node >& geom = i->GetGeometry();
434  //counting number of structural nodes
435 
436  if (geom.size()==4) //not to calculate the nodal area of the membrane which is a 2d element in 3d
437  {
438 
440  vol *= 0.25;
441 
442  geom[0].FastGetSolutionStepValue(NODAL_AREA) += vol;
443  geom[1].FastGetSolutionStepValue(NODAL_AREA) += vol;
444  geom[2].FastGetSolutionStepValue(NODAL_AREA) += vol;
445  geom[3].FastGetSolutionStepValue(NODAL_AREA) += vol;
446 
447 
448 
449 
450  }
451  }
452  }
453  //r
454 
455 
456  KRATOS_CATCH("")
457  }
459  void MarkNodesCloseToFS(ModelPart& ThisModelPart, int domain_size)
460  {
461  if (domain_size==2)
462  {
463 
464  for(ModelPart::ElementsContainerType::iterator i = ThisModelPart.ElementsBegin();
465  i!=ThisModelPart.ElementsEnd(); i++)
466  {
467  int n_fs=0;
468 
469  //counting number on nodes at the wall
470  Geometry< Node >& geom = i->GetGeometry();
471  n_fs = int(geom[0].FastGetSolutionStepValue(IS_FREE_SURFACE));
472  n_fs+= int(geom[1].FastGetSolutionStepValue(IS_FREE_SURFACE));
473  n_fs+= int(geom[2].FastGetSolutionStepValue(IS_FREE_SURFACE));
474  //if two walls are of freee surface, we check if the third node is close to it or not by passing the alpha-shape
475  if (n_fs==2)
476  {
477  //if alpha shape tells to preserve
478  if (AlphaShape(1.4, geom)==false)
479  {
480  for (int i=0; i<3; i++)
481  {
482  //if thats not the wall node, remove it
483  if (geom[i].FastGetSolutionStepValue(IS_FREE_SURFACE)==0.0 && geom[i].FastGetSolutionStepValue(IS_FLUID)==1.0 && geom[i].FastGetSolutionStepValue(IS_STRUCTURE)==0.0)
484  {
485  geom[i].Set(TO_ERASE,true);
486  KRATOS_WATCH("NODE CLOSE TO THE FS - WILL BE ERASED!!!!")
487  }
488  }
489  }
490  }
491 
492  }
493  }
494  if (domain_size==3)
495  {
496  KRATOS_WATCH("NOT IMPLEMENTED IN 3D")
497 
498  }
499  }
500 
501  void MarkNodesCloseToWallForBladder(ModelPart& ThisModelPart, const double& crit_distance)
502 
503  {
504  for(ModelPart::NodesContainerType::iterator in = ThisModelPart.NodesBegin();
505  in!=ThisModelPart.NodesEnd(); in++)
506  {
507  if (in->FastGetSolutionStepValue(DISTANCE)>0.00 && in->FastGetSolutionStepValue(DISTANCE)<crit_distance && in->FastGetSolutionStepValue(IS_STRUCTURE)==0)
508  {
509  in->Set(TO_ERASE,true);
510  KRATOS_WATCH("NODE EXCESSIVELY CLOSE TO WALL!!!!! BLADDER FUNCTION!!!!!!!!!!!!!!!!!!!!!!!!!!111")
511  }
512  }
513  }
514  //this is a function originally written by Antonia. It seems to work better then the MarkNodesCloseToWall (its given below)
515  void MarkNodesTouchingWall(ModelPart& ThisModelPart, int domain_size, double factor)
516  {
517  KRATOS_TRY;
518 
519  if (domain_size==2)
520  {
521 
522  for(ModelPart::ElementsContainerType::iterator i = ThisModelPart.ElementsBegin();
523  i!=ThisModelPart.ElementsEnd(); i++)
524  {
525  double n_str=0;
526 
527  //counting number on nodes at the wall
528  Geometry< Node >& geom = i->GetGeometry();
529  n_str = geom[0].FastGetSolutionStepValue(IS_BOUNDARY);
530  n_str+= geom[1].FastGetSolutionStepValue(IS_BOUNDARY);
531  n_str+= geom[2].FastGetSolutionStepValue(IS_BOUNDARY);
532  //if two walls are at the wall, we check if the third node is close to it or not by passing the alpha-shape
533  if (n_str==2.0)
534  {
535  BoundedMatrix<double,3,2> sort_coord = ZeroMatrix(3,2);
536  int cnt=1;
537  for (int i=0; i<3; ++i)
538  if(geom[i].FastGetSolutionStepValue(IS_BOUNDARY)==0.0)
539  {
540  sort_coord(0,0) = geom[i].X();
541  sort_coord(0,1) = geom[i].Y();
542  }
543  else
544  {
545  sort_coord(cnt,0) = geom[i].X();
546  sort_coord(cnt,1) = geom[i].Y();
547  cnt++;
548  }
549 
550  array_1d<double,2> vec1 = ZeroVector(2);
551  array_1d<double,2> vec2 = ZeroVector(2);
552 
553  vec1[0] = sort_coord(0,0) - sort_coord(1,0);
554  vec1[1] = sort_coord(0,1) - sort_coord(1,1);
555 
556  vec2[0] = sort_coord(2,0) - sort_coord(1,0);
557  vec2[1] = sort_coord(2,1) - sort_coord(1,1);
558 
559  double outer_prod = 0.0;
560  outer_prod = vec2[1]*vec1[0]-vec1[1]*vec2[0];
561 
562  double length_measure =0.0;
563  length_measure = vec2[0]*vec2[0] + vec2[1]*vec2[1];
564  length_measure = sqrt(length_measure);
565  outer_prod/=length_measure;
566 
567  //KRATOS_WATCH(fabs(outer_prod));
568  // RATOS_WATCH(factor*length_measure);
569 
570  if (fabs(outer_prod)<factor*length_measure)
571  {
572  for (int i=0; i<3; i++)
573  {
574  //if thats not the wall node, remove it
575  if (geom[i].FastGetSolutionStepValue(IS_BOUNDARY)==0.0)
576  {
577  geom[i].Set(TO_ERASE,true);
578  //KRATOS_WATCH("NODE TOUCHING THE WALL - WILL BE ERASED!!!!")
579  }
580  }
581  }
582  }
583 
584  }
585  }
586  else
587  {
588  for(ModelPart::ElementsContainerType::iterator i = ThisModelPart.ElementsBegin();
589  i!=ThisModelPart.ElementsEnd(); i++)
590  {
591  double n_str=0;
592  //the n_int is just for the bladder example.. otherwise the function works just with is_STR flag
593  double n_int=0;
594 
595  //counting number on nodes at the wall
596  Geometry< Node >& geom = i->GetGeometry();
597  if(geom.size() == 4)
598  {
599  for(int ii = 0; ii <= domain_size ; ++ii)
600  {
601  n_str += geom[ii].FastGetSolutionStepValue(IS_STRUCTURE);
602  n_int += geom[ii].FastGetSolutionStepValue(IS_INTERFACE);
603  }
604  //if two walls are at the wall, we check if the third node is close to it or not by passing the alpha-shape
605  if (n_str==3.0 && n_int==3.0)
606  {
607  BoundedMatrix<double,4,3> sort_coord = ZeroMatrix(4,3);
608  int cnt=1;
609  for (int i=0; i<4; ++i)
610  {
611  if(geom[i].FastGetSolutionStepValue(IS_STRUCTURE)==0.0)
612  {
613  sort_coord(0,0) = geom[i].X();
614  sort_coord(0,1) = geom[i].Y();
615  sort_coord(0,2) = geom[i].Z();
616  }
617  else
618  {
619  sort_coord(cnt,0) = geom[i].X();
620  sort_coord(cnt,1) = geom[i].Y();
621  sort_coord(cnt,2) = geom[i].Z();
622  cnt++;
623  }
624  }
625  array_1d<double,3> vec1 = ZeroVector(3);
626  array_1d<double,3> vec2 = ZeroVector(3);
627  array_1d<double,3> vec3 = ZeroVector(3);
628 
629 
630  vec1[0] = sort_coord(0,0) - sort_coord(1,0);
631  vec1[1] = sort_coord(0,1) - sort_coord(1,1);
632  vec1[2] = sort_coord(0,2) - sort_coord(1,2);
633 
634  vec2[0] = sort_coord(2,0) - sort_coord(1,0);
635  vec2[1] = sort_coord(2,1) - sort_coord(1,1);
636  vec2[2] = sort_coord(2,2) - sort_coord(1,2);
637 
638  vec3[0] = sort_coord(3,0) - sort_coord(1,0);
639  vec3[1] = sort_coord(3,1) - sort_coord(1,1);
640  vec3[2] = sort_coord(3,2) - sort_coord(1,2);
641 
642  //Control the hight of the thetraedral element
643  //Volume of the tethraedra
644  double vol = (vec2[0]*vec3[1]*vec1[2]-vec2[0]*vec3[2]*vec1[1]+
645  vec2[1]*vec3[2]*vec1[0]-vec2[1]*vec3[0]*vec1[2]+
646  vec2[2]*vec3[0]*vec1[1]-vec2[2]*vec3[1]*vec1[0])*0.1666666666667;
647  //Area of the basis
649  outer_prod[0] = vec2[1]*vec3[2]-vec2[2]*vec3[1];
650  outer_prod[1] = vec2[2]*vec3[0]-vec2[0]*vec3[2];
651  outer_prod[2] = vec2[0]*vec3[1]-vec2[1]*vec3[0];
652  double area_base = norm_2(outer_prod);
653  area_base *= 0.5;
654  //height
655 
656  if(area_base >0.0000000001)
657  vol/= area_base;
658  else
659  KRATOS_ERROR<<"error: BAse element has zero area";
660 
661  //vol/=area_base;
662  double length_measure1 = norm_2(vec2);
663  double length_measure = norm_2(vec3);
664  if(length_measure1 < length_measure)
665  {
666  length_measure = length_measure1;
667  }
668 
669  if (fabs(vol)<factor*length_measure)
670  {
671  for (int i=0; i<4; i++)
672  {
673  //if thats not the wall node, remove it
674  //never remove a Lagrangian inlet node
675  if (geom[i].FastGetSolutionStepValue(IS_STRUCTURE)==0.0 && geom[i].FastGetSolutionStepValue(IS_LAGRANGIAN_INLET)==0.0)
676  {
677  geom[i].Set(TO_ERASE,true);
678  KRATOS_WATCH("NODE TOUCHING THE WALL - WILL BE ERASED!!!!")
679  }
680  }
681  }
682  }//interface elements
683  }//non_shell
684  }//all elements loop
685  }//domain_size==3
686  KRATOS_CATCH("")
687  }
688 
689  void MarkNodesCloseToWall(ModelPart& ThisModelPart, int domain_size, double alpha_shape)
690  {
691  if (domain_size==2)
692  {
693 
694  for(ModelPart::ElementsContainerType::iterator i = ThisModelPart.ElementsBegin();
695  i!=ThisModelPart.ElementsEnd(); i++)
696  {
697  int n_str=0;
698 
699  //counting number on nodes at the wall
700  Geometry< Node >& geom = i->GetGeometry();
701  n_str = int(geom[0].FastGetSolutionStepValue(IS_STRUCTURE));
702  n_str+= int(geom[1].FastGetSolutionStepValue(IS_STRUCTURE));
703  n_str+= int(geom[2].FastGetSolutionStepValue(IS_STRUCTURE));
704  //if two walls are at the wall, we check if the third node is close to it or not by passing the alpha-shape
705  if (n_str==2)
706  {
707  //if alpha shape tells to preserve
708  if (AlphaShape(alpha_shape, geom)==false)
709  {
710  for (int i=0; i<3; i++)
711  {
712  //if thats not the wall node, remove it
713  if (geom[i].FastGetSolutionStepValue(IS_STRUCTURE)==0.0)
714  {
715  geom[i].Set(TO_ERASE,true);
716  //KRATOS_WATCH("NODE CLOSE TO THE WALL - WILL BE ERASED!!!!")
717  }
718  }
719  }
720  }
721 
722  }
723  }
724  if (domain_size==3)
725  {
726  KRATOS_WATCH("Inside mark nodes close to wall process")
727  for(ModelPart::ElementsContainerType::iterator i = ThisModelPart.ElementsBegin();
728  i!=ThisModelPart.ElementsEnd(); i++)
729  {
730  int n_str=0;
731  int n_fl=0;
732  int n_lag=0;
733  int n_interf=0;
734  //counting number on nodes at the wall
735  Geometry< Node >& geom = i->GetGeometry();
736  for (unsigned int iii=0; iii<geom.size(); iii++)
737  {
738  n_lag += int(geom[iii].FastGetSolutionStepValue(IS_LAGRANGIAN_INLET));
739  n_str += int(geom[iii].FastGetSolutionStepValue(IS_STRUCTURE));
740  n_fl += int(geom[iii].FastGetSolutionStepValue(IS_FLUID));
741  n_interf += int(geom[iii].FastGetSolutionStepValue(IS_INTERFACE));
742  }
743 
744 
745  //if three nodes are at the wall, we check if the fourth node is close to it or not by passing the alpha-shape
746  //if (geom.size()==4.0 && n_str==3.0 && n_fl==4.0)
747  if (geom.size()==4 && n_interf==3 && n_lag==0)
748  {
749  //if alpha shape tells to preserve
750  if (AlphaShape3D(alpha_shape, geom)==false)
751  {
752  for (unsigned int iii=0; iii<geom.size(); iii++)
753  {
754  //if thats not the wall node, remove it
755  if (geom[iii].FastGetSolutionStepValue(IS_STRUCTURE)==0.0)
756  {
757  geom[iii].Set(TO_ERASE,true);
758  KRATOS_WATCH("NODE CLOSE TO THE WALL - WILL BE ERASED!!!!")
759  }
760  }
761  }
762  }
763 
764 
765  }
766  }
767 
768 
769 
770  }
771 
772 
773 
775  {
776 
777 //delete lonely nodes //just to try: 19/07/2010
778  /*
779  for(ModelPart::NodesContainerType::iterator in = ThisModelPart.NodesBegin();
780  in!=ThisModelPart.NodesEnd(); in++)
781  {
782  in->Set(TO_ERASE,false);
783 
784  }
785  */
786 
787  for(ModelPart::NodesContainerType::iterator in = ThisModelPart.NodesBegin();
788  in!=ThisModelPart.NodesEnd(); in++)
789  {
790  if((in->GetValue(NEIGHBOUR_ELEMENTS)).size() == 0 && in->FastGetSolutionStepValue(IS_STRUCTURE)==0.0 && in->FastGetSolutionStepValue(IS_LAGRANGIAN_INLET)!=1 && in->FastGetSolutionStepValue(IS_LAGRANGIAN_INLET,1)!=1.0)
791  {
792  in->Set(TO_ERASE,true);
793  KRATOS_WATCH("Marking lonelynodes!!!")
794  }
795 
796  }
797  /*
798  for(ModelPart::NodesContainerType::iterator in = ThisModelPart.NodesBegin();
799  in!=ThisModelPart.NodesEnd(); in++)
800  {
801  if((in->GetValue(NEIGHBOUR_ELEMENTS)).size() == 0 && in->FastGetSolutionStepValue(IS_STRUCTURE)==1.0)
802  {
803  in->FastGetSolutionStepValue(PRESSURE)==0;
804  if ((in)->GetDof(DISPLACEMENT_X).IsFixed())
805  in->FastGetSolutionStepValue(VELOCITY_X)==0;
806 
807  if ((in)->GetDof(DISPLACEMENT_Y).IsFixed())
808  in->FastGetSolutionStepValue(VELOCITY_Y)==0;
809 
810  if ((in)->GetDof(DISPLACEMENT_Z).IsFixed())
811  in->FastGetSolutionStepValue(VELOCITY_Z)==0;
812 
813 
814  }
815 
816  }
817  */
818  }
819 
820  bool AlphaShape(double alpha_param, Geometry<Node >& pgeom)
821  //bool AlphaShape(double alpha_param, Triangle2D<Node >& pgeom)
822  {
823  KRATOS_TRY
824  BoundedMatrix<double,2,2> J; //local jacobian
825  BoundedMatrix<double,2,2> Jinv; //local jacobian
826  static array_1d<double,2> c; //center pos
827  static array_1d<double,2> rhs; //center pos
828 
829  double x0 = pgeom[0].X();
830  double x1 = pgeom[1].X();
831  double x2 = pgeom[2].X();
832 
833  double y0 = pgeom[0].Y();
834  double y1 = pgeom[1].Y();
835  double y2 = pgeom[2].Y();
836 
837  J(0,0)=2.0*(x1-x0);
838  J(0,1)=2.0*(y1-y0);
839  J(1,0)=2.0*(x2-x0);
840  J(1,1)=2.0*(y2-y0);
841 
842 
843  double detJ = J(0,0)*J(1,1)-J(0,1)*J(1,0);
844 
845  Jinv(0,0) = J(1,1);
846  Jinv(0,1) = -J(0,1);
847  Jinv(1,0) = -J(1,0);
848  Jinv(1,1) = J(0,0);
849 
850  bounded_matrix<double,2,2> check;
851 
852 
853  if(detJ < 1e-12)
854  {
855  //std::cout << "detJ = " << detJ << std::endl;
857  pgeom[0].GetSolutionStepValue(IS_BOUNDARY) = 1;
858  pgeom[1].GetSolutionStepValue(IS_BOUNDARY) = 1;
859  pgeom[2].GetSolutionStepValue(IS_BOUNDARY) = 1;
860  return false;
861  }
862 
863  else
864  {
865 
866  double x0_2 = x0*x0 + y0*y0;
867  double x1_2 = x1*x1 + y1*y1;
868  double x2_2 = x2*x2 + y2*y2;
869 
870  //finalizing the calculation of the inverted matrix
871  //std::cout<<"MATR INV"<<MatrixInverse(msJ)<<std::endl;
872  Jinv /= detJ;
873  //calculating the RHS
874  rhs[0] = (x1_2 - x0_2);
875  rhs[1] = (x2_2 - x0_2);
876 
877  //calculate position of the center
878  noalias(c) = prod(Jinv,rhs);
879 
880  double radius = sqrt(pow(c[0]-x0,2)+pow(c[1]-y0,2));
881 
882  //calculate average h
883  double h;
884  h = pgeom[0].FastGetSolutionStepValue(NODAL_H);
885  h += pgeom[1].FastGetSolutionStepValue(NODAL_H);
886  h += pgeom[2].FastGetSolutionStepValue(NODAL_H);
887  h *= 0.333333333;
888  if (radius < h*alpha_param)
889  {
890  return true;
891  }
892  else
893  {
894  return false;
895  }
896  }
897 
898 
899  KRATOS_CATCH("")
900  }
901  bool AlphaShape3D( double alpha_param, Geometry<Node >& geom )
902  {
903  KRATOS_TRY
904 
905  BoundedMatrix<double,3,3> J; //local jacobian
906  BoundedMatrix<double,3,3> Jinv; //local jacobian
907  array_1d<double,3> Rhs; //rhs
909  double radius=0.0;
910 
911  const double x0 = geom[0].X();
912  const double y0 = geom[0].Y();
913  const double z0 = geom[0].Z();
914  const double x1 = geom[1].X();
915  const double y1 = geom[1].Y();
916  const double z1 = geom[1].Z();
917  const double x2 = geom[2].X();
918  const double y2 = geom[2].Y();
919  const double z2 = geom[2].Z();
920  const double x3 = geom[3].X();
921  const double y3 = geom[3].Y();
922  const double z3 = geom[3].Z();
923 
924  //calculation of the jacobian
925  J(0,0) = x1-x0;
926  J(0,1) = y1-y0;
927  J(0,2) = z1-z0;
928  J(1,0) = x2-x0;
929  J(1,1) = y2-y0;
930  J(1,2) = z2-z0;
931  J(2,0) = x3-x0;
932  J(2,1) = y3-y0;
933  J(2,2) = z3-z0;
934 // KRATOS_WATCH("33333333333333333333333");
935 
936  //inverse of the jacobian
937  //first column
938  Jinv(0,0) = J(1,1)*J(2,2) - J(1,2)*J(2,1);
939  Jinv(1,0) = -J(1,0)*J(2,2) + J(1,2)*J(2,0);
940  Jinv(2,0) = J(1,0)*J(2,1) - J(1,1)*J(2,0);
941  //second column
942  Jinv(0,1) = -J(0,1)*J(2,2) + J(0,2)*J(2,1);
943  Jinv(1,1) = J(0,0)*J(2,2) - J(0,2)*J(2,0);
944  Jinv(2,1) = -J(0,0)*J(2,1) + J(0,1)*J(2,0);
945  //third column
946  Jinv(0,2) = J(0,1)*J(1,2) - J(0,2)*J(1,1);
947  Jinv(1,2) = -J(0,0)*J(1,2) + J(0,2)*J(1,0);
948  Jinv(2,2) = J(0,0)*J(1,1) - J(0,1)*J(1,0);
949  //calculation of determinant (of the input matrix)
950 
951 // KRATOS_WATCH("44444444444444444444444444");
952  double detJ = J(0,0)*Jinv(0,0)
953  + J(0,1)*Jinv(1,0)
954  + J(0,2)*Jinv(2,0);
955 
956  //volume = detJ * 0.16666666667;
957 // KRATOS_WATCH("55555555555555555555555");
958 
959 
960  double x0_2 = x0*x0 + y0*y0 + z0*z0;
961  double x1_2 = x1*x1 + y1*y1 + z1*z1;
962  double x2_2 = x2*x2 + y2*y2 + z2*z2;
963  double x3_2 = x3*x3 + y3*y3 + z3*z3;
964 
965  //finalizing the calculation of the inverted matrix
966  Jinv /= detJ;
967 
968  //calculating the RHS
969  //calculating the RHS
970  Rhs[0] = 0.5*(x1_2 - x0_2);
971  Rhs[1] = 0.5*(x2_2 - x0_2);
972  Rhs[2] = 0.5*(x3_2 - x0_2);
973 
974  //calculate position of the center
975  noalias(xc) = prod(Jinv,Rhs);
976  //calculate radius
977  radius = pow(xc[0] - x0,2);
978  radius += pow(xc[1] - y0,2);
979  radius += pow(xc[2] - z0,2);
980  radius = sqrt(radius);
981 
982  double h;
983  h = geom[0].FastGetSolutionStepValue(NODAL_H);
984  h += geom[1].FastGetSolutionStepValue(NODAL_H);
985  h += geom[2].FastGetSolutionStepValue(NODAL_H);
986  h += geom[3].FastGetSolutionStepValue(NODAL_H);
987  h *= 0.250;
988 
989  if (radius < h*alpha_param)
990  {
991  return true;
992  }
993  else
994  {
995  return false;
996  }
997 
998  KRATOS_CATCH("")
999  }
1000 
1001 
1002  //**********************************************************************************************
1003  //**********************************************************************************************
1004  //imposes the velocity that corresponds to a
1005  void MoveLonelyNodes(ModelPart& ThisModelPart)
1006  {
1007  KRATOS_TRY;
1008  //KRATOS_WATCH("MOVING LONELY NODES")
1009  double Dt = ThisModelPart.GetProcessInfo()[DELTA_TIME];
1010 
1011  array_1d<double,3> DeltaDisp, acc;
1012 
1013  //const array_1d<double,3> body_force = ThisModelPart.ElementsBegin()->GetProperties()[BODY_FORCE];
1014  for(ModelPart::NodeIterator i = ThisModelPart.NodesBegin() ;
1015  i != ThisModelPart.NodesEnd() ; ++i)
1016  {
1017  if(
1018  (i)->FastGetSolutionStepValue(IS_STRUCTURE) == 0 && //if it is not a wall node
1019  (i)->GetValue(NEIGHBOUR_ELEMENTS).size() == 0 &&//and it is lonely
1020  ((i)->GetDof(DISPLACEMENT_X).IsFixed() == false || (i)->GetDof(DISPLACEMENT_Y).IsFixed() == false || (i)->GetDof(DISPLACEMENT_Z).IsFixed() == false) //and not the node of the wall, where the 0-displ is prescribed
1021 
1022  )
1023  {
1024  //i->Set(TO_ERASE,true);
1025  //set to zero the pressure
1026  (i)->FastGetSolutionStepValue(PRESSURE) = 0;
1027 
1028  const array_1d<double,3>& old_vel = (i)->FastGetSolutionStepValue(VELOCITY,1);
1029  array_1d<double,3>& vel = (i)->FastGetSolutionStepValue(VELOCITY);
1030  //array_1d<double,3>& acc = (i)->FastGetSolutionStepValue(ACCELERATION);
1031 
1032  noalias(acc) = (i)->FastGetSolutionStepValue(BODY_FORCE);
1033 
1034  noalias(vel) = old_vel;
1035  noalias(vel) += Dt * acc ;
1036 
1037  //calculate displacements
1038  noalias(DeltaDisp) = Dt * vel;
1039 
1040  array_1d<double,3>& disp = i->FastGetSolutionStepValue(DISPLACEMENT);
1041  noalias(disp) = i->FastGetSolutionStepValue(DISPLACEMENT,1);
1042  noalias(disp) += DeltaDisp;
1043 
1044 
1045  }
1046 
1047  }
1048 
1049  KRATOS_CATCH("")
1050  }
1052  /*
1053  void MarkLonelyNodesForErasing(ModelPart& ThisModelPart)
1054  {
1055  KRATOS_TRY;
1056 
1057  for(ModelPart::NodeIterator i = ThisModelPart.NodesBegin() ;
1058  i != ThisModelPart.NodesEnd() ; ++i)
1059  {
1060  if(
1061  (i)->FastGetSolutionStepValue(IS_STRUCTURE) == 0 && //if it is not a wall node
1062  (i)->GetValue(NEIGHBOUR_ELEMENTS).size() == 0 &&//and it is lonely
1063  ((i)->GetDof(DISPLACEMENT_X).IsFixed() == false || (i)->GetDof(DISPLACEMENT_Y).IsFixed() == false || (i)->GetDof(DISPLACEMENT_Z).IsFixed() == false) //and not the node of the wall, where the 0-displ is prescribed
1064 
1065  )
1066  {
1067 
1068  i->Set(TO_ERASE,true);
1069 
1070 
1071 
1072  }
1073 
1074  }
1075 
1076  KRATOS_CATCH("")
1077  }
1078  */
1079 
1080 
1081 
1082  //**********************************************************************************************
1083  //**********************************************************************************************
1084  //ATTENTION:: returns a negative volume if inverted elements appear
1085  double CalculateVolume(ModelPart& ThisModelPart, int domain_size)
1086  {
1087  KRATOS_TRY;
1088  KRATOS_WATCH("ENTERED calc vol")
1089  bool inverted_elements = false;
1090  //auxiliary vectors
1091  double Atot = 0.00;
1092  double Ael;
1093  //line added on 28th August in order to be able to use membrane elements, i.e. 3 noded elements in 3D
1094  unsigned int nstruct=0;
1095 
1096  if(domain_size == 2)
1097  {
1098  for(ModelPart::ElementsContainerType::iterator i = ThisModelPart.ElementsBegin();
1099  i!=ThisModelPart.ElementsEnd(); i++)
1100  {
1101  //calculating shape functions values
1102  Geometry< Node >& geom = i->GetGeometry();
1103  for (unsigned int kkk=0; kkk<(i->GetGeometry()).size(); kkk++)
1104  {
1105  //n_struct += int( im->GetGeometry()[i].FastGetSolutionStepValue(IS_STRUCTURE) );
1106  nstruct+= int(i->GetGeometry()[kkk].FastGetSolutionStepValue(IS_STRUCTURE));
1107  }
1108 
1109  if ( nstruct!= ( i->GetGeometry()).size() )
1110  {
1112  Atot += Ael;
1113  if(Ael <= 0)
1114  {
1115  inverted_elements = true;
1116  }
1117  }
1118  nstruct=0;
1119  }
1120 
1121  }
1122  else if (domain_size == 3)
1123  {
1124  for(ModelPart::ElementsContainerType::iterator i = ThisModelPart.ElementsBegin();
1125  i!=ThisModelPart.ElementsEnd(); i++)
1126  {
1127  //calculating shape functions values
1128  Geometry< Node >& geom = i->GetGeometry();
1129  for (unsigned int kkk=0; kkk<(i->GetGeometry()).size(); kkk++)
1130  {
1131  //n_struct += int( im->GetGeometry()[i].FastGetSolutionStepValue(IS_STRUCTURE) );
1132  nstruct+= int(i->GetGeometry()[kkk].FastGetSolutionStepValue(IS_STRUCTURE));
1133  }
1134 
1135 
1136  //if ( (i->GetGeometry()).size()==4 )
1137  if ( nstruct!= ( i->GetGeometry()).size() )
1138  {
1140  Atot += Ael;
1141  if(Ael <= 0) inverted_elements = true;
1142  }
1143  nstruct=0;
1144  }
1145 
1146  }
1147 
1148  //set to negative the volume if inverted elements appear
1149  if( inverted_elements == true)
1150  Atot = -Atot;
1151  //return the total area
1152  KRATOS_WATCH("FINISHED calc vol LAST!!!!!!!! ")
1153  KRATOS_WATCH(Atot)
1154  return Atot;
1155 
1156  KRATOS_CATCH("");
1157  }
1158 
1159  //**********************************************************************************************
1160  //**********************************************************************************************
1161  void ReduceTimeStep(ModelPart& ThisModelPart, const double reduction_factor)
1162  {
1163  KRATOS_TRY;
1164  KRATOS_WATCH("INSIDE -REDUCE TIME STEP- process")
1165  double old_dt = ThisModelPart.GetProcessInfo()[DELTA_TIME];
1166  double new_dt = reduction_factor * old_dt;
1167  double time = ThisModelPart.GetProcessInfo()[TIME];
1168 
1169  double new_time = time - old_dt + new_dt;
1170  KRATOS_WATCH(time);
1171  KRATOS_WATCH(new_time);
1172  (ThisModelPart.GetProcessInfo()).SetCurrentTime(new_time);
1173  //and now we set the data values to the ones of the previous time
1174 
1175  unsigned int step_data_size = ThisModelPart.GetNodalSolutionStepDataSize();
1176  KRATOS_WATCH(step_data_size)
1177  for(ModelPart::NodesContainerType::iterator i = ThisModelPart.NodesBegin();
1178  i!=ThisModelPart.NodesEnd(); i++)
1179  {
1180  //unsigned int buffer_size = i->GetBufferSize();
1181 
1182 
1183  //getting the data of the solution step
1184  double* step_data = i->SolutionStepData().Data(0);
1185  double* prev_step_data = i->SolutionStepData().Data(1);
1186 
1187 
1188  //setting it to the old one (we will intend solve the problem now with the reduced step), for every nodal variable
1189  for(unsigned int j= 0; j<step_data_size; j++)
1190  {
1191  step_data[j] = prev_step_data[j];
1192  }
1193 
1194  }
1195 
1196  KRATOS_CATCH("");
1197  }
1198 
1199  //**********************************************************************************************
1200  //**********************************************************************************************
1201  void SaveNodalArea(ModelPart& ThisModelPart)
1202  {
1203  KRATOS_TRY;
1204 
1205  for(ModelPart::NodesContainerType::iterator i = ThisModelPart.NodesBegin();
1206  i!=ThisModelPart.NodesEnd(); i++)
1207  {
1208  i->FastGetSolutionStepValue(NODAL_AREA,1) = i->FastGetSolutionStepValue(NODAL_AREA);
1209  }
1210 
1211  KRATOS_CATCH("");
1212  }
1213 
1214  //**********************************************************************************************
1215  //**********************************************************************************************
1216 
1217  void SaveReducedPart(ModelPart& full_model_part, ModelPart& reduced_model_part)
1218  {
1219  KRATOS_TRY
1220 
1222  //clear reduced_model_part
1223  reduced_model_part.Conditions().clear();
1224  reduced_model_part.Elements().clear();
1225  reduced_model_part.Nodes().clear();
1226  // unsigned int NumberOfProperties = full_model_part.NumberOfProperties();
1227 
1228  //change the name of the var to another one - otherwise confusing
1229  for(ModelPart::NodesContainerType::iterator in = full_model_part.NodesBegin() ; in != full_model_part.NodesEnd() ; ++in)
1230  {
1231  in->FastGetSolutionStepValue(ACTIVATION_LEVEL)=false;
1232  in->FastGetSolutionStepValue(MATERIAL_VARIABLE)=false;
1233  }
1234 
1235  int n_nodes=0;
1236 
1237  for(ModelPart::ElementsContainerType::iterator im = full_model_part.ElementsBegin() ; im != full_model_part.ElementsEnd() ; ++im)
1238  {
1239  int n_int=0;
1240  int n_nodes=im->GetGeometry().size();
1241 
1242  for (int i=0; i<n_nodes; i++)
1243  {
1244 
1245  if(im->GetGeometry()[i].FastGetSolutionStepValue(IS_INTERFACE)==1) n_int+=1.0;//im->GetGeometry()[i].FastGetSolutionStepValue(IS_INTERFACE);
1246  }
1247  if (n_int==n_nodes)
1248  {
1249 
1250  if(n_nodes==4)
1251  {
1252  im->GetGeometry()[0].FastGetSolutionStepValue(MATERIAL_VARIABLE)=true;
1253  im->GetGeometry()[1].FastGetSolutionStepValue(MATERIAL_VARIABLE)=true;
1254  im->GetGeometry()[2].FastGetSolutionStepValue(MATERIAL_VARIABLE)=true;
1255  im->GetGeometry()[3].FastGetSolutionStepValue(MATERIAL_VARIABLE)=true;
1256  }
1257  else
1258  {
1259  im->GetGeometry()[0].FastGetSolutionStepValue(MATERIAL_VARIABLE)=true;
1260  im->GetGeometry()[1].FastGetSolutionStepValue(MATERIAL_VARIABLE)=true;
1261  im->GetGeometry()[2].FastGetSolutionStepValue(MATERIAL_VARIABLE)=true;
1262  //im->GetGeometry()[3].FastGetSolutionStepValue(MATERIAL_VARIABLE)=true;
1263 
1264  }
1265 
1266  }
1267 
1268  if (n_int<n_nodes)
1269  {
1270  reduced_model_part.Elements().push_back(*(im.base()));
1271 
1272  for (int i=0;i<n_nodes;i++)
1273  {
1274  im->GetGeometry()[i].FastGetSolutionStepValue(ACTIVATION_LEVEL)=true;
1275  }
1276  }
1277 
1278  if (n_int>n_nodes)
1279  KRATOS_ERROR<<"Number of DISABLE flags cant exceed number of the element nodes.... ";
1280 
1281  }
1282 
1283 
1284 
1285  for(ModelPart::NodesContainerType::iterator in = full_model_part.NodesBegin() ; in != full_model_part.NodesEnd() ; ++in)
1286  {
1287  int n_disabled=in->FastGetSolutionStepValue(ACTIVATION_LEVEL);
1288  if (n_disabled==1)
1289  {
1290  reduced_model_part.Nodes().push_back(*(in.base()));
1291  }
1292 
1293  }
1294 
1295  for(ModelPart::PropertiesContainerType::iterator i_properties = full_model_part.PropertiesBegin() ;
1296  i_properties != full_model_part.PropertiesEnd() ; ++i_properties)
1297  {
1298  reduced_model_part.AddProperties(*(i_properties.base()));
1299 
1300  }
1301 
1302 
1303 
1304 
1305 
1306  //find neighbors within reduced model part
1307  if (n_nodes==3)
1308  {
1309  FindNodalNeighboursProcess N_FINDER(reduced_model_part);
1310  N_FINDER.Execute();
1311  }
1312  else if (n_nodes==4)
1313  {
1314  FindNodalNeighboursProcess N_FINDER(reduced_model_part);
1315  N_FINDER.Execute();
1316  }
1317 
1318 
1319 
1320  KRATOS_CATCH("")
1321  }
1322 
1323 
1324 
1325 
1326 private:
1327 
1328  //aux vars
1329  static BoundedMatrix<double,3,3> msJ; //local jacobian
1330  static BoundedMatrix<double,3,3> msJinv; //inverse jacobian
1331  static array_1d<double,3> msc; //center pos
1332  static array_1d<double,3> ms_rhs; //center pos
1333 
1334 
1335 };
1336 
1337 } // namespace Kratos.
1338 
1339 #endif // KRATOS_ULF_UTILITIES_INCLUDED defined
This method allows to look for neighbours in a triangular or tetrahedral mesh.
Definition: find_nodal_neighbours_process.h:59
void Execute() override
This method esxecutes the neighbour search.
Definition: find_nodal_neighbours_process.cpp:49
Geometry base class.
Definition: geometry.h:71
SizeType size() const
Definition: geometry.h:518
static double CalculateVolume2D(const GeometryType &rGeometry)
This function computes the element's volume (with sign)
Definition: geometry_utilities.h:292
static double CalculateVolume3D(const GeometryType &rGeometry)
This function computes the element's volume (with sign)
Definition: geometry_utilities.h:226
This class is a vector which stores global pointers.
Definition: global_pointers_vector.h:61
boost::indirect_iterator< typename TContainerType::iterator > iterator
Definition: global_pointers_vector.h:79
Definition: amatrix_interface.h:41
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ElementIterator ElementsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1169
SizeType GetNodalSolutionStepDataSize()
Definition: model_part.h:571
PropertiesIterator PropertiesBegin(IndexType ThisIndex=0)
Definition: model_part.h:978
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
void AddProperties(PropertiesType::Pointer pNewProperties, IndexType ThisIndex=0)
Inserts a properties in the current mesh.
Definition: model_part.cpp:582
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
MeshType::NodeIterator NodeIterator
Definition: model_part.h:134
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
ElementIterator ElementsEnd(IndexType ThisIndex=0)
Definition: model_part.h:1179
NodeIterator NodesEnd(IndexType ThisIndex=0)
Definition: model_part.h:497
PropertiesIterator PropertiesEnd(IndexType ThisIndex=0)
Definition: model_part.h:988
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
This class defines the node.
Definition: node.h:65
Definition: pfem2_utilities.h:50
void MarkNodesTouchingWall(ModelPart &ThisModelPart, int domain_size, double factor)
Definition: pfem2_utilities.h:515
void MarkLonelyNodesForErasing(ModelPart &ThisModelPart)
Definition: pfem2_utilities.h:774
void SaveNodalArea(ModelPart &ThisModelPart)
Definition: pfem2_utilities.h:1201
void IdentifyFluidNodes(ModelPart &ThisModelPart)
Definition: pfem2_utilities.h:142
double CalculateTriangleArea3D(array_1d< double, 3 > &Point1, array_1d< double, 3 > &Point2, array_1d< double, 3 > &Point3)
Definition: pfem2_utilities.h:382
double Length(array_1d< double, 3 > &Point1, array_1d< double, 3 > &Point2)
Definition: pfem2_utilities.h:377
void MarkOuterNodes(const array_1d< double, 3 > &corner1, const array_1d< double, 3 > &corner2, ModelPart::NodesContainerType &rNodes)
Definition: pfem2_utilities.h:268
void MarkNodesCloseToWall(ModelPart &ThisModelPart, int domain_size, double alpha_shape)
Definition: pfem2_utilities.h:689
double EstimateDeltaTime(double dt_min, double dt_max, ModelPart &ThisModelPart)
Definition: pfem2_utilities.h:215
void MarkNodesCloseToWallForBladder(ModelPart &ThisModelPart, const double &crit_distance)
Definition: pfem2_utilities.h:501
void ReduceTimeStep(ModelPart &ThisModelPart, const double reduction_factor)
Definition: pfem2_utilities.h:1161
void SaveReducedPart(ModelPart &full_model_part, ModelPart &reduced_model_part)
Definition: pfem2_utilities.h:1217
void MarkExcessivelyCloseNodes(ModelPart::NodesContainerType &rNodes, const double admissible_distance_factor)
Definition: pfem2_utilities.h:337
bool AlphaShape(double alpha_param, Geometry< Node > &pgeom)
Definition: pfem2_utilities.h:820
void ApplyBoundaryConditions(ModelPart &ThisModelPart, int laplacian_type)
Definition: pfem2_utilities.h:58
void ApplyMinimalPressureConditions(std::vector< GlobalPointersVector< Node > > &connected_components)
Definition: pfem2_utilities.h:161
void MarkNodesCloseToFS(ModelPart &ThisModelPart, int domain_size)
Definition: pfem2_utilities.h:459
void MoveLonelyNodes(ModelPart &ThisModelPart)
Definition: pfem2_utilities.h:1005
bool AlphaShape3D(double alpha_param, Geometry< Node > &geom)
Definition: pfem2_utilities.h:901
void CalculateNodalArea(ModelPart &ThisModelPart, int domain_size)
Definition: pfem2_utilities.h:395
Node NodeType
Definition: pfem2_utilities.h:52
double CalculateVolume(ModelPart &ThisModelPart, int domain_size)
Definition: pfem2_utilities.h:1085
boost::indirect_iterator< typename TContainerType::iterator > iterator
Definition: pointer_vector_set.h:95
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_WATCH(variable)
Definition: define.h:806
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR
Definition: exception.h:161
dt
Definition: DEM_benchmarks.py:173
im
Definition: GenerateCN.py:100
z
Definition: GenerateWind.py:163
Parameters GetValue(Parameters &rParameters, const std::string &rEntry)
Definition: add_kratos_parameters_to_python.cpp:53
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
TExpressionType::data_type norm_2(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:625
KratosZeroMatrix< double > ZeroMatrix
Definition: amatrix_interface.h:559
AMatrix::MatrixProductExpression< TExpression1Type, TExpression2Type > prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:568
TExpression1Type::data_type inner_prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:592
AMatrix::VectorOuterProductExpression< TExpression1Type, TExpression2Type > outer_prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:582
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
REACTION_CHECK_STIFFNESS_FACTOR int
Definition: contact_structural_mechanics_application_variables.h:75
float zmax
Definition: cube_mesher.py:747
float xmax
Definition: cube_mesher.py:743
float ymax
Definition: cube_mesher.py:745
float xmin
Definition: cube_mesher.py:742
float zmin
Definition: cube_mesher.py:746
float ymin
Definition: cube_mesher.py:744
int domain_size
Definition: face_heat.py:4
time
Definition: face_heat.py:85
Dt
Definition: face_heat.py:78
y
Other simbols definition.
Definition: generate_axisymmetric_navier_stokes_element.py:54
h
Definition: generate_droplet_dynamics.py:91
x2
Definition: generate_frictional_mortar_condition.py:122
rhs
Definition: generate_frictional_mortar_condition.py:297
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
int n_nodes
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:15
c
Definition: generate_weakly_compressible_navier_stokes_element.py:108
list node_list
Definition: mesh_to_mdpa_converter.py:39
float radius
Definition: mesh_to_mdpa_converter.py:18
vel
Definition: pure_conduction.py:76
int j
Definition: quadrature.py:648
float xc
Definition: rotating_cone.py:77
alpha_shape
Definition: script.py:120
J
Definition: sensitivityMatrix.py:58
p
Definition: sensitivityMatrix.py:52
x
Definition: sensitivityMatrix.py:49
integer i
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31
float factor
for node in (self.combined_model_part).Nodes: pold = node.GetSolutionStepValue(PRESSURE,...
Definition: ulf_PGLASS.py:254