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.
trigen_pfem_refine_segment.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: Riccardo Rossi
11 //
12 
13 
14 #if !defined(KRATOS_TRIGEN_PFEM_REFINE_SEGMENT_H_INCLUDED )
15 #define KRATOS_TRIGEN_PFEM_REFINE_SEGMENT_H_INCLUDED
16 
17 // System includes
18 
19 // External includes
20 #include "triangle.h"
21 
22 // Project includes
23 #include "includes/define.h"
24 #include "includes/model_part.h"
27 #include "utilities/timer.h"
31 
32 namespace Kratos
33 {
34 extern "C" {
35  void triangulate(char *, struct triangulateio *, struct triangulateio *,struct triangulateio *);
36  //void trifree();
37 }
38 
39 
42 
46 
50 
54 
58 
60 
63 
64 {
65 public:
68 
71 
75 
78  mJ(ZeroMatrix(2,2)), //local jacobian
79  mJinv(ZeroMatrix(2,2)), //inverse jacobian
80  mC(ZeroVector(2)), //dimension = number of nodes
81  mRhs(ZeroVector(2)) {}
82  //mpNodeEraseProcess(NULL){} //dimension = number of nodes
83 
85  virtual ~TriGenPFEMRefineSegment() = default;
86 
87 
91 
92 
96 
97 
98  //*******************************************************************************************
99  //*******************************************************************************************
101  ModelPart& ThisModelPart ,
102  Element const& rReferenceElement,
103  Condition const& rReferenceBoundaryCondition,
104  EntitiesEraseProcess<Node>& node_erase, bool rem_nodes = true, bool add_nodes=true,
105  double my_alpha = 1.4, double h_factor=0.5)
106  {
107 
108  KRATOS_TRY
109  if (ThisModelPart.NodesBegin()->SolutionStepsDataHas(IS_FREE_SURFACE)==false )
110  KRATOS_THROW_ERROR(std::logic_error,"Add ----IS_FREE_SURFACE---- variable!!!!!! ERROR","");
111  if (ThisModelPart.NodesBegin()->SolutionStepsDataHas(IS_STRUCTURE)==false )
112  KRATOS_THROW_ERROR(std::logic_error,"Add ----IS_STRUCTURE---- variable!!!!!! ERROR","");
113  if (ThisModelPart.NodesBegin()->SolutionStepsDataHas(IS_BOUNDARY)==false )
114  KRATOS_THROW_ERROR(std::logic_error,"Add ----IS_BOUNDARY---- variable!!!!!! ERROR","");
115  if (ThisModelPart.NodesBegin()->SolutionStepsDataHas(IS_FLUID)==false )
116  KRATOS_THROW_ERROR(std::logic_error,"Add ----IS_FLUID---- variable!!!!!! ERROR","");
117  if (ThisModelPart.NodesBegin()->SolutionStepsDataHas(IS_WATER)==false )
118  KRATOS_THROW_ERROR(std::logic_error,"Add ----IS_WATER---- variable!!!!!! ERROR","");
119  if (ThisModelPart.NodesBegin()->SolutionStepsDataHas(IS_INTERFACE)==false )
120  KRATOS_THROW_ERROR(std::logic_error,"Add ----IS_INTERFACE---- variable!!!!!! ERROR","");
121 
122  KRATOS_WATCH("Trigen PFEM Refining Segment Mesher")
123  const auto inital_time = std::chrono::steady_clock::now();
124 
125 
126 //clearing elements
127  KRATOS_WATCH(ThisModelPart.Elements().size());
128 //KRATOS_WATCH("TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT");
129  //****************************************************
130  //filling the interface list before removing the elements and nodes
131  //****************************************************
132  std::vector <int> mid_seg_list;
133  int seg_num = 0;
134  int num_interface = 0;
135  SegmentDetecting(ThisModelPart, mid_seg_list, seg_num, num_interface, h_factor);
136 
137 
138  ThisModelPart.Elements().clear();
139  ThisModelPart.Conditions().clear();
140 
142  typedef Node PointType;
143  typedef Node::Pointer PointPointerType;
144  typedef std::vector<PointType::Pointer> PointVector;
145  typedef PointVector::iterator PointIterator;
146  typedef std::vector<double> DistanceVector;
147  typedef std::vector<double>::iterator DistanceIterator;
148 
149  int step_data_size = ThisModelPart.GetNodalSolutionStepDataSize();
150  KRATOS_WATCH(step_data_size);
151  // bucket types
152 // typedef Bucket<3, PointType, ModelPart::NodesContainerType, PointPointerType, PointIterator, DistanceIterator > BucketType;
154  // bucket types
155  //typedef Bucket<3, PointType, PointVector, PointPointerType, PointIterator, DistanceIterator > BucketType;//commented
156 
157 
158  //*************
159  // DynamicBins;
160  //typedef Tree< KDTreePartition<BucketType> > kd_tree; //Kdtree;
161  typedef Tree< StaticBins > kd_tree; //Binstree;
162  unsigned int bucket_size = 64;
163 
164  //performing the interpolation - all of the nodes in this list will be preserved
165  unsigned int max_results = 500;
166  //PointerVector<PointType> res(max_results);
167  //NodeIterator res(max_results);
168  PointVector res(max_results);
169  DistanceVector res_distances(max_results);
170  Node work_point(0,0.0,0.0,0.0);
171 
172  //****************************************************
173  //filling the interface list before removing the nodes
174  //****************************************************
175  /* for(ModelPart::NodesContainerType::const_iterator in = ThisModelPart.NodesBegin();
176  in != ThisModelPart.NodesEnd(); in++)
177  {
178  in->FastGetSolutionStepValue(IS_VISITED) = 0.0;
179  in->FastGetSolutionStepValue(AUX_INDEX) = 0.0;
180  }
181  std::vector <int> mid_seg_list;
182  //list_of_nodes.reserve(ThisModelPart.Nodes().size());
183  int seg_num = 0;
184 
185 
186  for(ModelPart::NodesContainerType::const_iterator in = ThisModelPart.NodesBegin();
187  in != ThisModelPart.NodesEnd(); in++)
188  {
189  if(in->FastGetSolutionStepValue(IS_INTERFACE) == 1.0)
190  {
191 
192  GlobalPointersVector< Node >& neighb = in->GetValue(NEIGHBOUR_NODES);
193  int num_of_intr_neigh = 0;
194  //KRATOS_WATCH(neighb.size());
195  for( GlobalPointersVector< Node >::iterator ngh_ind = neighb.begin(); ngh_ind!=neighb.end(); ngh_ind++)
196  {
197  if(ngh_ind->FastGetSolutionStepValue(IS_INTERFACE) == 1.0) num_of_intr_neigh++;
198  }
199 
200  if(num_of_intr_neigh <= 2)
201  {
202  for( GlobalPointersVector< Node >::iterator ngh_ind = neighb.begin(); ngh_ind!=neighb.end(); ngh_ind++)
203  {
204 
205  if(ngh_ind->FastGetSolutionStepValue(IS_INTERFACE) == 1.0)
206  {
207  if(ngh_ind->FastGetSolutionStepValue(IS_VISITED) != 10.0)
208  {
209  //KRATOS_WATCH(ngh_ind->Id());
210  mid_seg_list.push_back(in->Id());
211  mid_seg_list.push_back(ngh_ind->Id());
212  seg_num++;
213  //row += 2;
214  }
215  ngh_ind->FastGetSolutionStepValue(AUX_INDEX) += 1.0;
216  }
217  }
218  in->FastGetSolutionStepValue(IS_VISITED) = 10.0;
219  }
220  else
221  {
222  in->FastGetSolutionStepValue(IS_VISITED) = 5.0;
223  }
224  //KRATOS_WATCH("(((((((((after neighbour loop))))))))))))))))");
225 
226  }
227  }
228 
229  //conecting remaining interface nodes( those which have more than two interface neighbors)
230  for(ModelPart::NodesContainerType::const_iterator in = ThisModelPart.NodesBegin();
231  in != ThisModelPart.NodesEnd(); in++)
232  {
233  if(in->FastGetSolutionStepValue(IS_INTERFACE) == 1.0 && in->FastGetSolutionStepValue(IS_VISITED) == 5.0)
234  {
235  if(in->FastGetSolutionStepValue(AUX_INDEX) < 2.0)
236  {
237  GlobalPointersVector< Node >& neighb = in->GetValue(NEIGHBOUR_NODES);
238  for( GlobalPointersVector< Node >::iterator ngh_ind = neighb.begin(); ngh_ind!=neighb.end(); ngh_ind++)
239  {
240  if(ngh_ind->FastGetSolutionStepValue(IS_INTERFACE) == 1.0 && ngh_ind->FastGetSolutionStepValue(IS_VISITED) != 10.0 && ngh_ind->FastGetSolutionStepValue(AUX_INDEX) < 2.0)
241  {
242  mid_seg_list.push_back(in->Id());
243  mid_seg_list.push_back(ngh_ind->Id());
244  seg_num++;
245  KRATOS_WATCH("**** A COMPLEX BOUNDARY IS DETECTED *******");
246  }
247  ngh_ind->FastGetSolutionStepValue(AUX_INDEX) += 1.0;
248  }
249 
250  }
251  in->FastGetSolutionStepValue(IS_VISITED) = 10.0;
252  }
253  }*/
254 
255  //if the remove_node switch is activated, we check if the nodes got too close
256  if (rem_nodes==true)
257  {
258 
259  PointVector list_of_nodes;
260  list_of_nodes.reserve(ThisModelPart.Nodes().size());
261  for(ModelPart::NodesContainerType::iterator i_node = ThisModelPart.NodesBegin() ; i_node != ThisModelPart.NodesEnd() ; i_node++)
262  {
263  (list_of_nodes).push_back(*(i_node.base()));
264  }
265 
266  kd_tree nodes_tree1(list_of_nodes.begin(),list_of_nodes.end(), bucket_size);
267 
268  unsigned int n_points_in_radius;
269  //radius means the distance, closer than which no node shall be allowd. if closer -> mark for erasing
270  double radius;
271 
272  for(ModelPart::NodesContainerType::const_iterator in = ThisModelPart.NodesBegin();
273  in != ThisModelPart.NodesEnd(); in++)
274  {
275  radius=h_factor*in->FastGetSolutionStepValue(NODAL_H);
276 
277  work_point[0]=in->X();
278  work_point[1]=in->Y();
279  work_point[2]=in->Z();
280 
281  n_points_in_radius = nodes_tree1.SearchInRadius(work_point, radius, res.begin(),res_distances.begin(), max_results);
282  if (n_points_in_radius>1)
283  {
284  if (in->FastGetSolutionStepValue(IS_BOUNDARY)==0.0 && in->FastGetSolutionStepValue(IS_STRUCTURE)==0.0 && in->FastGetSolutionStepValue(IS_INTERFACE)==0.0)
285  {
286  //look if we are already erasing any of the other nodes
287  double erased_nodes = 0;
288  for(auto i=res.begin(); i!=res.begin() + n_points_in_radius ; i++)
289  erased_nodes += (*i)->Is(TO_ERASE);
290 
291  /*
292  //to avoid remove of near boundary nodes
293  double center_flag=in->FastGetSolutionStepValue(IS_WATER);
294  for(PointIterator i=res.begin(); i!=res.begin() + n_points_in_radius ; i++)
295  {
296  double ngh_flag = (*i)->FastGetSolutionStepValue(IS_WATER);
297  if(center_flag != ngh_flag)
298  erased_nodes++;
299  }
300  */
301  if( erased_nodes < 1.0) //we cancel the node if no other nodes are being erased
302  in->Set(TO_ERASE,true);
303 
304 
305  }
306  else if ( (in)->FastGetSolutionStepValue(IS_STRUCTURE)!=1.0) //boundary nodes will be removed if they get REALLY close to another boundary node (0.2 * h_factor)
307  {
308  //here we loop over the neighbouring nodes and if there are nodes
309  //with IS_BOUNDARY=1 which are closer than 0.2*nodal_h from our we remove the node we are considering
310  unsigned int k = 0;
311  unsigned int counter = 0;
312  for(auto i=res.begin(); i!=res.begin() + n_points_in_radius ; i++)
313  {
314  if ( (*i)->FastGetSolutionStepValue(IS_BOUNDARY,1)==1.0 && res_distances[k] < 0.2*radius && res_distances[k] > 0.0 )
315  {
316  // KRATOS_WATCH( res_distances[k] );
317  counter += 1;
318  }
319  k++;
320  }
321  if(counter > 0)
322  in->Set(TO_ERASE,true);
323  }
324  }
325 
326  }
327  //not erase INTERFACE node
328  for(ModelPart::NodesContainerType::const_iterator in = ThisModelPart.NodesBegin();
329  in != ThisModelPart.NodesEnd(); in++)
330  {
331  if((in)->FastGetSolutionStepValue(IS_INTERFACE) == 1.0)
332  in->Set(TO_ERASE, false);
333 
334  }
335 
336  node_erase.Execute();
337 
338  KRATOS_WATCH("Number of nodes after erasing")
339  KRATOS_WATCH(ThisModelPart.Nodes().size())
340  }
341 
343  // //
344  // Now we shall pass the Alpha Shape for the second time, having the "bad nodes" removed //
346  //creating the containers for the input and output
347  struct triangulateio in_mid;
348  struct triangulateio out_mid;
349  struct triangulateio vorout_mid;
350 
351  initialize_triangulateio(in_mid);
352  initialize_triangulateio(out_mid);
353  initialize_triangulateio(vorout_mid);
354 
355  //assigning the size of the input containers
356 
357  in_mid.numberofpoints = ThisModelPart.Nodes().size();
358  in_mid.pointlist = (REAL *) malloc(in_mid.numberofpoints * 2 * sizeof(REAL));
359 
360  //reorder the id's and give the coordinates to the mesher
361  ModelPart::NodesContainerType::iterator nodes_begin = ThisModelPart.NodesBegin();
362  std::vector <int> reorder_mid_seg_list;
363  if(seg_num != 0)
364  reorder_mid_seg_list.resize(seg_num*2,false);
365 
366  for(unsigned int i = 0; i<ThisModelPart.Nodes().size(); i++)
367  {
368  int base = i*2;
369  //int base = ((nodes_begin + i)->Id() - 1 ) * 2;
370 
371  //from now on it is consecutive
372  int pr_id = (nodes_begin + i)->Id();
373 
374  (nodes_begin + i)->SetId(i+1);
375 // (nodes_begin + i)->Id() = i+1;
376 
377  in_mid.pointlist[base] = (nodes_begin + i)->X();
378  in_mid.pointlist[base+1] = (nodes_begin + i)->Y();
379 
380  auto& node_dofs = (nodes_begin + i)->GetDofs();
381  for(auto iii = node_dofs.begin(); iii != node_dofs.end(); iii++)
382  {
383  (**iii).SetEquationId(i+1);
384  }
385  //reordering segment list
386  if(seg_num != 0)
387  {
388  if( (nodes_begin + i)->FastGetSolutionStepValue(IS_INTERFACE) == 1.0 )
389  {
390  for(int jj = 0; jj < seg_num*2; ++jj)
391  if( mid_seg_list[jj] == pr_id)
392  reorder_mid_seg_list[jj] = (nodes_begin + i)->Id();
393 
394  }
395  }
396  }
397 //(for(int ii = 0; ii<seg_num*2; ii++){
398 //KRATOS_WATCH(mid_seg_list[ii])
399 //KRATOS_WATCH(reorder_mid_seg_list[ii])}
400  //in_mid.numberoftriangles = ThisModelPart.Elements().size();
401  //in_mid.trianglelist = (int*) malloc(in_mid.numberoftriangles * 3 * sizeof(int));
402 
403  //***********preserving the list of interface segments
404 
405 
406  if(seg_num != 0)
407  {
408  in_mid.numberofsegments = seg_num;
409  in_mid.segmentlist = (int*) malloc(in_mid.numberofsegments * 2 * sizeof(int));
410  in_mid.segmentmarkerlist = (int*) malloc(in_mid.numberofsegments * sizeof(int));
411  //in2.segmentlist = seg_list;
412  for( int ii = 0; ii < seg_num*2; ++ii)
413  in_mid.segmentlist[ii] = reorder_mid_seg_list[ii];
414 
415  for( int jj = 0; jj < seg_num ; ++jj)
416  in_mid.segmentmarkerlist[jj] = 5;
417 
418  }
419  //***********end ofsegments
420  KRATOS_WATCH(seg_num);
421  //********************************REGIONAL ATTRIBUTE
422  /*int num_water_node= 0;
423  for(unsigned int i = 0; i<ThisModelPart.Nodes().size(); i++)
424  {
425  if((nodes_begin + i)->FastGetSolutionStepValue(IS_WATER) == 1.0)
426  num_water_node++;
427 
428  }
429  in_mid.numberofregions = num_water_node;
430  in_mid.regionlist = (REAL *) malloc(in_mid.numberofregions * 3 * sizeof(REAL));
431 
432  int base = 0;
433  for(unsigned int i = 0; i<ThisModelPart.Nodes().size(); i++)
434  {
435 
436  if((nodes_begin + i)->FastGetSolutionStepValue(IS_WATER) == 1.0)
437  {
438  in_mid.regionlist[base] = (nodes_begin + i)->X();
439  in_mid.regionlist[base + 1] = (nodes_begin + i)->Y();
440  in_mid.regionlist[base + 2] = 14.0;
441  base+=3;
442  }
443  }*/
444 
445  /*for(unsigned int i = 0; i<ThisModelPart.Nodes().size() ; i++)
446  {
447  if( (nodes_begin + i)->FastGetSolutionStepValue(IS_INTERFACE) != 1.0)
448  {
449  if((nodes_begin + i)->FastGetSolutionStepValue(IS_WATER) == 0.0)
450  in_mid.regionlist[i] = 7.0;
451  else
452  in_mid.regionlist[i] = 14.0;
453  }
454  else
455  in_mid.regionlist[i] = 0.0;
456 
457  }*/
458  //********************************end of REGIONAL ATTRIBUTE
459  //for(unsigned int ii=0;ii<mid_seg_list.size(); ++ii)
460  // KRATOS_WATCH(in_mid.segmentlist[ii]);
461 
462  // "P" suppresses the output .poly file. Saves disk space, but you
463  //lose the ability to maintain constraining segments on later refinements of the mesh.
464  // "B" Suppresses boundary markers in the output .node, .poly, and .edge output files
465  // "n" outputs a list of triangles neighboring each triangle.
466  // "e" outputs edge list (i.e. all the "connectivities")
467  //char options1[] = "Pne";
468  char options1[] = "pcne";
469  KRATOS_WATCH(ThisModelPart.Nodes().size());
470 
471  triangulate(options1, &in_mid, &out_mid, &vorout_mid);
472  //print out the mesh generation time
473  std::cout << "mesh generation time = " << Timer::ElapsedSeconds(inital_time) << std::endl;
474  //number of newly generated triangles
475  unsigned int el_number=out_mid.numberoftriangles;
476  KRATOS_WATCH("*********NUMBER OF ELEMENTS***********");
477  KRATOS_WATCH(el_number);
478 
479  //prepairing for alpha shape passing : creating necessary arrays
480  //list of preserved elements is created: at max el_number can be preserved (all elements)
481  std::vector<int> preserved_list1(el_number);
482  preserved_list1.resize(el_number);
483 
487  //region flag check
488  /* for(unsigned int i = 0; i<num_water_node*3 ; i++)
489  {
490  KRATOS_WATCH(in_mid.regionlist[i]);
491  }
492  for(unsigned int el = 0; el< el_number; el++)
493  {
494  KRATOS_WATCH("*""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""*");
495 
496  KRATOS_WATCH(out_mid.triangleattributelist[el]);
497  } */
498  //end of region flag check
501  //int number_of_preserved_elems=0;
502  int number_of_preserved_elems=0;
503  int point_base;
504  //loop for passing alpha shape
505  for(unsigned int el = 0; el< el_number; el++)
506  {
507  int base = el * 3;
508 
509  //coordinates
510  point_base = (out_mid.trianglelist[base] - 1)*2;
511  x1[0] = out_mid.pointlist[point_base];
512  x1[1] = out_mid.pointlist[point_base+1];
513 
514  point_base = (out_mid.trianglelist[base+1] - 1)*2;
515  x2[0] = out_mid.pointlist[point_base];
516  x2[1] = out_mid.pointlist[point_base+1];
517 
518  point_base = (out_mid.trianglelist[base+2] - 1)*2;
519  x3[0] = out_mid.pointlist[point_base];
520  x3[1] = out_mid.pointlist[point_base+1];
521 
522  //here we shall temporarily save the elements and pass them afterwards to the alpha shape
524 
525  temp.push_back( *((ThisModelPart.Nodes()).find( out_mid.trianglelist[base]).base() ) );
526  temp.push_back( *((ThisModelPart.Nodes()).find( out_mid.trianglelist[base+1]).base() ) );
527  temp.push_back( *((ThisModelPart.Nodes()).find( out_mid.trianglelist[base+2]).base() ) );
528 
529  int number_of_structure_nodes = int( temp[0].FastGetSolutionStepValue(IS_STRUCTURE) );
530  number_of_structure_nodes += int( temp[1].FastGetSolutionStepValue(IS_STRUCTURE) );
531  number_of_structure_nodes += int( temp[2].FastGetSolutionStepValue(IS_STRUCTURE) );
532 
533  //check the number of nodes of boundary
534  int nfs = int( temp[0].FastGetSolutionStepValue(IS_FREE_SURFACE) );
535  nfs += int( temp[1].FastGetSolutionStepValue(IS_FREE_SURFACE) );
536  nfs += int( temp[2].FastGetSolutionStepValue(IS_FREE_SURFACE) );
537 
538  //check the number of nodes of boundary
539  int nfluid = int( temp[0].FastGetSolutionStepValue(IS_FLUID) );
540  nfluid += int( temp[1].FastGetSolutionStepValue(IS_FLUID) );
541  nfluid += int( temp[2].FastGetSolutionStepValue(IS_FLUID) );
542 
543  //check a three nodede interface element
544  int num_interface = 0;
545  for( int ii = 0; ii<3; ++ii)
546  if(temp[ii].FastGetSolutionStepValue(IS_INTERFACE) == 1.0)
547  num_interface++;
548 
549  /*if(num_interface == 3)
550  {
551  KRATOS_WATCH("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO inside mesher w 3 interface");
552  // KRATOS_WATCH(out_mid.triangleattributelist[el]);
553  }
554  */
555 
556  //first check that we are working with fluid elements, otherwise throw an error
557  //if (nfluid!=3)
558  // KRATOS_THROW_ERROR(std::logic_error,"THATS NOT FLUID or NOT TRIANGLE!!!!!! ERROR","");
559  //otherwise perform alpha shape check
560 
561 
562  if(number_of_structure_nodes!=3) //if it is = 3 it is a completely fixed element -> do not add it
563  {
564  if (nfs != 0 || nfluid != 3) //in this case it is close to the surface so i should use alpha shape
565  {
566 
567  if( AlphaShape(my_alpha,temp) && number_of_structure_nodes!=3) //if alpha shape says to preserve
568  {
569  preserved_list1[el] = true;
570  number_of_preserved_elems += 1;
571 
572  }
573  }
574  else //internal triangle --- should be ALWAYS preserved
575  {
576  double bigger_alpha = my_alpha*5.0;
577  if( AlphaShape(bigger_alpha,temp) && number_of_structure_nodes!=3)
578  {
579  preserved_list1[el] = true;
580  number_of_preserved_elems += 1;
581  }
582  }
583  }
584  else
585  preserved_list1[el] = false;
586  }
587  //freeing memory
588 
589 
590  //NOW WE SHALL PERFORM ADAPTIVE REMESHING, i.e. insert and remove nodes based upon mesh quality
591  // and prescribed sizes
592  struct triangulateio in2;
593  struct triangulateio out2;
594  struct triangulateio vorout2;
595 
596  initialize_triangulateio(in2);
597  initialize_triangulateio(out2);
598  initialize_triangulateio(vorout2);
599 
600 // in2.firstnumber = 1;
601  in2.numberofpoints = ThisModelPart.Nodes().size();
602  in2.pointlist = (REAL *) malloc(in2.numberofpoints * 2 * sizeof(REAL));
603 
604  //writing the input point list
605  for(unsigned int i = 0; i<ThisModelPart.Nodes().size(); i++)
606  {
607  int base = i*2;
608  in2.pointlist[base] = (nodes_begin + i)->X();
609  in2.pointlist[base+1] = (nodes_begin + i)->Y();
610  }
611  in2.numberoftriangles=number_of_preserved_elems;
612 
613  in2.trianglelist = (int *) malloc(in2.numberoftriangles * 3 * sizeof(int));
614  in2.trianglearealist = (REAL *) malloc(in2.numberoftriangles * sizeof(REAL));
615 // in2.trianglelist = new int[in2.numberoftriangles * 3];
616 // in2.trianglearealist = new double[in2.numberoftriangles];
617 
618 
619  int counter = 0;
620  for (unsigned int el=0; el<el_number; el++)
621  {
622  if( preserved_list1[el] )
623  {
624  //saving the list of ONLY preserved triangles, the ones that passed alpha-shape check
625  int new_base = counter*3;
626  int old_base = el*3;
627  //copying in case it is preserved
628  in2.trianglelist[new_base] = out_mid.trianglelist[old_base];
629  in2.trianglelist[new_base+1] = out_mid.trianglelist[old_base+1];
630  in2.trianglelist[new_base+2] = out_mid.trianglelist[old_base+2];
631 
632  //calculate the prescribed h
633  double prescribed_h = (nodes_begin + out_mid.trianglelist[old_base]-1)->FastGetSolutionStepValue(NODAL_H);
634  prescribed_h += (nodes_begin + out_mid.trianglelist[old_base+1]-1)->FastGetSolutionStepValue(NODAL_H);
635  prescribed_h += (nodes_begin + out_mid.trianglelist[old_base+2]-1)->FastGetSolutionStepValue(NODAL_H);
636  prescribed_h *= 0.3333;
637  //if h is the height of a equilateral triangle, the area is 1/2*h*h
638  in2.trianglearealist[counter] = 0.5*(1.5*prescribed_h*1.5*prescribed_h);
639  counter += 1;
640  }
641 
642  }
643  //***********preserving the list of interface segments
644  /*std::vector <int> seg_list;
645  //list_of_nodes.reserve(ThisModelPart.Nodes().size());
646  seg_num = 0;
647  //int row = 0;
648  // FindNodalNeighboursProcess(ThisModelPart).Execute();
649  for(ModelPart::NodesContainerType::const_iterator in = ThisModelPart.NodesBegin();
650  in != ThisModelPart.NodesEnd(); in++)
651  {
652  in->FastGetSolutionStepValue(IS_VISITED) = 0.0;
653  }
654 
655  for(ModelPart::NodesContainerType::const_iterator in = ThisModelPart.NodesBegin();
656  in != ThisModelPart.NodesEnd(); in++)
657  {
658  //KRATOS_WATCH("&&&&&&&&&&&&&&&&& inside node loops&&&&&&&&&&&&&&&&&&&&&&&&&");
659  if(in->FastGetSolutionStepValue(IS_INTERFACE) == 1.0)
660  {
661  //KRATOS_WATCH("@@@@@@@@@@@@@@@@2 an interface is detected@@@@@@@@@@@@@@@");
662 
663  GlobalPointersVector< Node >& neighb = in->GetValue(NEIGHBOUR_NODES);
664 
665  for( GlobalPointersVector< Node >::iterator ngh_ind = neighb.begin(); ngh_ind!=neighb.end(); ngh_ind++)
666  {
667 
668  if(ngh_ind->FastGetSolutionStepValue(IS_INTERFACE) == 1.0 && ngh_ind->FastGetSolutionStepValue(IS_VISITED) != 10.0)
669  {
670  seg_list.push_back(in->Id());
671  seg_list.push_back(ngh_ind->Id());
672  seg_num++;
673  //row += 2;
674  }
675  }
676  in->FastGetSolutionStepValue(IS_VISITED) = 10.0;
677  }
678  }
679 
680  */
681  if(seg_num)
682  {
683  in2.numberofsegments = seg_num;
684  in2.segmentlist = (int*) malloc(in2.numberofsegments * 2 * sizeof(int));
685  in2.segmentmarkerlist = (int*) malloc(in2.numberofsegments * sizeof(int));
686  //in2.segmentlist = seg_list;
687  for( int ii = 0; ii < seg_num*2; ++ii)
688  //in2.segmentlist[ii] = seg_list[ii];
689  in2.segmentlist[ii] = reorder_mid_seg_list[ii];
690 
691  for( int jj = 0; jj < seg_num ; ++jj)
692  in2.segmentmarkerlist[jj] = 5;
693 
694  }
695  //***********end ofsegments
696  KRATOS_WATCH(seg_num);
697  //for(unsigned int ii=0;ii<reorder_mid_seg_list.size(); ++ii)
698  // KRATOS_WATCH(in2.segmentlist[ii]);
699  //here we generate a new mesh adding/removing nodes, by initializing "q"-quality mesh and "a"-area constraint switches
700  //
701  // MOST IMPORTANT IS "r" switch, that refines previously generated mesh!!!!!!!!!!(that is the one given inside in2)
702  //char mesh_regen_opts[] = "YYJaqrn";
703  //char mesh_regen_opts[] = "YJq1.4arn";Yjaqrpcn
704  //Y means dont insert node in boundary
705  //YY meand no node on edges (inside)
706 
707  if (add_nodes==true)
708  {
709  char mesh_regen_opts[] = "Yjaqrpcn";
710  triangulate(mesh_regen_opts, &in2, &out2, &vorout2);
711  KRATOS_WATCH("Adaptive remeshing with segment executed")
712  }
713  else
714  {
715  char mesh_regen_opts[] = "YJrn";
716  triangulate(mesh_regen_opts, &in2, &out2, &vorout2);
717  KRATOS_WATCH("Non-Adaptive remeshing executed")
718  }
719 
720  //segment check
721  /*unsigned int input_num_of_marker = in2.numberofsegments;
722  unsigned int output_num_of_marker = out2.numberofsegments;
723  unsigned int in_point_attr = in2.numberofpointattributes;
724  unsigned int out_point_attr = out2.numberofpointattributes;*/
725 
726  /*for( int ii = 0; ii<num_of_marker; ii++)
727  KRATOS_WATCH(out_mid.segmentmarkerlist[ii]);*/
728  /*KRATOS_WATCH(input_num_of_marker);
729  KRATOS_WATCH(output_num_of_marker);
730  KRATOS_WATCH(in_point_attr);
731  KRATOS_WATCH(out_point_attr);
732 
733 
734  for(int ii = 0; ii<out2.numberofpoints; ii++)
735  {
736  KRATOS_WATCH("********* new pointr ***********")
737  KRATOS_WATCH(out2.pointmarkerlist[ii])
738  KRATOS_WATCH(out2.pointlist[ii*2])
739  KRATOS_WATCH(out2.pointlist[ii*2 + 1])
740 
741  }
742 
743  */
744 
745  //end of segment check
746 
747 
748 
749 
750 
751  //and now we shall find out where the new nodes belong to
752  //defintions for spatial search
753  typedef Node PointType;
754  typedef Node::Pointer PointPointerType;
755  typedef std::vector<PointType::Pointer> PointVector;
756  //typedef std::vector<PointType::Pointer>::iterator PointIterator;
757  typedef PointVector::iterator PointIterator;
758  typedef std::vector<double> DistanceVector;
759  typedef std::vector<double>::iterator DistanceIterator;
760 
761 
762  //typedef Bucket<3, PointType, PointVector, PointPointerType, PointIterator, DistanceIterator > BucketType;//commented
763 
764  //typedef Tree< KDTreePartition<BucketType> > kd_tree; //Kdtree;//comented
765 
766  //int step_data_size = ThisModelPart.GetNodalSolutionStepDataSize();
767 
768  //creating an auxiliary list for the new nodes
769  PointVector list_of_new_nodes;
770 
771  //node to get the DOFs from
772  Node::DofsContainerType& reference_dofs = (ThisModelPart.NodesBegin())->GetDofs();
773 
774  double z = 0.0;
775  int n_points_before_refinement = in2.numberofpoints;
776  //if points were added, we add them as nodes to the ModelPart
777  if (out2.numberofpoints > n_points_before_refinement )
778  {
779  for(int i = n_points_before_refinement; i<out2.numberofpoints; i++)
780  {
781  int id=i+1;
782  int base = i*2;
783  double& x= out2.pointlist[base];
784  double& y= out2.pointlist[base+1];
785 
786  Node::Pointer pnode = ThisModelPart.CreateNewNode(id,x,y,z);
787 
788  pnode->SetBufferSize(ThisModelPart.NodesBegin()->GetBufferSize() );
789 
790  list_of_new_nodes.push_back( pnode );
791 
792  //assigning interface flag of segment
793  //segment are assigned to 5 so every new node on them have also flag 5
794  if(out2.pointmarkerlist[i] == 5)
795  {
796  pnode->FastGetSolutionStepValue(IS_INTERFACE) = 1.0;
797  KRATOS_WATCH("NEW INTERFACE ON SEGMEMNT is DETECTED");
798  //KRATOS_WATCH(pnode->Id());
799  }
800  else
801  pnode->FastGetSolutionStepValue(IS_INTERFACE) = 0.0;
802 
803  //KRATOS_WATCH(pnode->FastGetSolutionStepValue(IS_INTERFACE));
804  //std::cout << "new node id = " << pnode->Id() << std::endl;
805  //generating the dofs
806  for(Node::DofsContainerType::iterator iii = reference_dofs.begin(); iii != reference_dofs.end(); iii++)
807  {
808  Node::DofType& rDof = **iii;
809  Node::DofType::Pointer p_new_dof = pnode->pAddDof( rDof );
810 
811  (p_new_dof)->FreeDof();
812 // (p_new_dof)->EquationId() = -1;
813 
814  }
815 
816  }
817  }
818 
819  std::cout << "During refinement we added " << out2.numberofpoints-n_points_before_refinement<< " nodes " <<std::endl;
820  //unsigned int bucket_size = 20;
821  //performing the interpolation - all of the nodes in this list will be preserved
822  //unsigned int max_results = 50;
823  //PointVector results(max_results);
824  //DistanceVector results_distances(max_results);
826 
827  //WHAT ARE THOSE????
828 // Node work_point(0,0.0,0.0,0.0);
829  unsigned int MaximumNumberOfResults = list_of_new_nodes.size();
830  PointVector Results(MaximumNumberOfResults);
831  DistanceVector ResultsDistances(MaximumNumberOfResults);
832 
833  step_data_size = ThisModelPart.GetNodalSolutionStepDataSize();
834 
835 
836  if(out2.numberofpoints-n_points_before_refinement > 0) //if we added points
837  {
838 
839  kd_tree nodes_tree2(list_of_new_nodes.begin(),list_of_new_nodes.end(),bucket_size);
840  nodes_begin = ThisModelPart.NodesBegin();
841 
842  for(int el = 0; el< in2.numberoftriangles; el++)
843  {
844  int base = el * 3;
845  //coordinates
846  point_base = (in2.trianglelist[base] - 1)*2;
847  x1[0] = in2.pointlist[point_base];
848  x1[1] = in2.pointlist[point_base+1];
849 
850  point_base = (in2.trianglelist[base+1] - 1)*2;
851  x2[0] = in2.pointlist[point_base];
852  x2[1] = in2.pointlist[point_base+1];
853 
854  point_base = (in2.trianglelist[base+2] - 1)*2;
855  x3[0] = in2.pointlist[point_base];
856  x3[1] = in2.pointlist[point_base+1];
857 
858 
859  //find the center and "radius" of the element
860  double xc, yc, radius;
861  CalculateCenterAndSearchRadius( x1[0], x1[1],
862  x2[0], x2[1],
863  x3[0], x3[1],
864  xc,yc,radius);
865 
866  //find all of the new nodes within the radius
867  int number_of_points_in_radius;
868  work_point.X() = xc;
869  work_point.Y() = yc;
870  work_point.Z() = 0.0;
871 
872  number_of_points_in_radius = nodes_tree2.SearchInRadius(work_point, radius, Results.begin(),
873  ResultsDistances.begin(), MaximumNumberOfResults);
874 
875  Triangle2D3<Node > geom(
876  *( (nodes_begin + in2.trianglelist[base]-1).base() ),
877  *( (nodes_begin + in2.trianglelist[base+1]-1).base() ),
878  *( (nodes_begin + in2.trianglelist[base+2]-1).base() )
879  );
880 
881  //check if inside and eventually interpolate
882  for( auto it_found = Results.begin(); it_found != Results.begin() + number_of_points_in_radius; it_found++)
883  {
884  bool is_inside = false;
885  is_inside = CalculatePosition(x1[0], x1[1],
886  x2[0], x2[1],
887  x3[0], x3[1],
888  (*it_found)->X(),(*it_found)->Y(),N);
889 
890 
891  if(is_inside == true)
892  {
893  double regionflag = 0.0;
894  //regionflag = out_mid.triangleattributelist[el];
895  Interpolate( geom, N, step_data_size, *(it_found ), regionflag);
896 
897  }
898  }
899  }
900  }
901 
902  ThisModelPart.Elements().clear();
903 
904  //set the coordinates to the original value
905  for(auto & list_of_new_node : list_of_new_nodes)
906  {
907  const array_1d<double,3>& disp = list_of_new_node->FastGetSolutionStepValue(DISPLACEMENT);
908  list_of_new_node->X0() = list_of_new_node->X() - disp[0];
909  list_of_new_node->Y0() = list_of_new_node->Y() - disp[1];
910  list_of_new_node->Z0() = 0.0;
911  }
912  //cleaning unnecessary data
913  //in2.deinitialize();
914  //in2.initialize();
915  //free( in2.pointlist );
916 
917  //add preserved elements to the kratos
918  Properties::Pointer properties = ThisModelPart.GetMesh().pGetProperties(1);
919  nodes_begin = ThisModelPart.NodesBegin();
920  (ThisModelPart.Elements()).reserve(out2.numberoftriangles);
921 
922  for(int iii = 0; iii< out2.numberoftriangles; iii++)
923  {
924  int id = iii + 1;
925  int base = iii * 3;
926  Triangle2D3<Node > geom(
927  *( (nodes_begin + out2.trianglelist[base]-1).base() ),
928  *( (nodes_begin + out2.trianglelist[base+1]-1).base() ),
929  *( (nodes_begin + out2.trianglelist[base+2]-1).base() )
930  );
931 
932 
933 #ifdef _DEBUG
934  ModelPart::NodesContainerType& ModelNodes = ThisModelPart.Nodes();
935  if( *(ModelNodes).find( out2.trianglelist[base]).base() == *(ThisModelPart.Nodes().end()).base() )
936  KRATOS_THROW_ERROR(std::logic_error,"trying to use an inexisting node","");
937  if( *(ModelNodes).find( out2.trianglelist[base+1]).base() == *(ThisModelPart.Nodes().end()).base() )
938  KRATOS_THROW_ERROR(std::logic_error,"trying to use an inexisting node","");
939  if( *(ModelNodes).find( out2.trianglelist[base+2]).base() == *(ThisModelPart.Nodes().end()).base() )
940  KRATOS_THROW_ERROR(std::logic_error,"trying to use an inexisting node","");
941 
942 #endif
943 
944  Element::Pointer p_element = rReferenceElement.Create(id, geom, properties);
945  (ThisModelPart.Elements()).push_back(p_element);
946 
947  }
948  ThisModelPart.Elements().Sort();
949 
950  //filling the neighbour list
951  ModelPart::ElementsContainerType::const_iterator el_begin = ThisModelPart.ElementsBegin();
952  for(ModelPart::ElementsContainerType::const_iterator iii = ThisModelPart.ElementsBegin();
953  iii != ThisModelPart.ElementsEnd(); iii++)
954  {
955  //Geometry< Node >& geom = iii->GetGeometry();
956  int base = ( iii->Id() - 1 )*3;
957 
958  (iii->GetValue(NEIGHBOUR_ELEMENTS)).resize(3);
959  GlobalPointersVector< Element >& neighb = iii->GetValue(NEIGHBOUR_ELEMENTS);
960  for(int i = 0; i<3; i++)
961  {
962  int index = out2.neighborlist[base+i];
963  if(index > 0)
964  neighb(i) = GlobalPointer<Element>(&*(el_begin + index-1));
965  else
966  neighb(i) = Element::WeakPointer();
967  }
968  }
969 
970  //reset the boundary flag
971  for(ModelPart::NodesContainerType::const_iterator in = ThisModelPart.NodesBegin(); in!=ThisModelPart.NodesEnd(); in++)
972  {
973  in->FastGetSolutionStepValue(IS_BOUNDARY) = 0;
974  }
975  //filling the elemental neighbours list (from now on the elements list can not change)
976  ModelPart::ElementsContainerType::iterator elements_end = ThisModelPart.Elements().end();
977 
978  ThisModelPart.Elements().Unique();
979 
980  //now the boundary faces
981  for(ModelPart::ElementsContainerType::iterator iii = ThisModelPart.ElementsBegin(); iii != ThisModelPart.ElementsEnd(); iii++)
982  {
983  int base = ( iii->Id() - 1 )*3;
984 
985  ModelPart::ElementsContainerType::iterator el_neighb;
986  /*each face is opposite to the corresponding node number so
987  0 ----- 2 1
988  1 ----- 0 2
989  2 ----- 1 0
990  */
991 
993  //
994  //********************************************************************
995  //first face
996  el_neighb = (ThisModelPart.Elements()).find( out2.neighborlist[base] );
997  if( el_neighb == elements_end )
998  {
999  //std::cout << "node0" << std::endl;
1000  //if no neighnour is present => the face is free surface
1001  iii->GetGeometry()[1].FastGetSolutionStepValue(IS_BOUNDARY) = 1;
1002  iii->GetGeometry()[2].FastGetSolutionStepValue(IS_BOUNDARY) = 1;
1003 
1004  //Generate condition
1006  temp.reserve(2);
1007  temp.push_back(iii->GetGeometry()(2));
1008  temp.push_back(iii->GetGeometry()(1));
1009 
1012  int id = (iii->Id()-1)*3;
1013 
1014  //Condition::Pointer p_cond =
1015  // Condition::Pointer(new Condition(id, cond, properties) );
1016 
1017  Condition::Pointer p_cond = rReferenceBoundaryCondition.Create(id, temp, properties);
1018  (ThisModelPart.Conditions()).push_back(p_cond);
1019 
1020 
1021  }
1022 
1023  //********************************************************************
1024  //second face
1025  el_neighb = (ThisModelPart.Elements()).find( out2.neighborlist[base+1] );
1026  //if( el != ThisModelPart.Elements().end() )
1027  if( el_neighb == elements_end )
1028  {
1029  //if no neighnour is present => the face is free surface
1030  iii->GetGeometry()[2].FastGetSolutionStepValue(IS_BOUNDARY) = 1;
1031  iii->GetGeometry()[0].FastGetSolutionStepValue(IS_BOUNDARY) = 1;
1032 
1033  //Generate condition
1035  temp.reserve(2);
1036  temp.push_back(iii->GetGeometry()(0));
1037  temp.push_back(iii->GetGeometry()(2));
1038 
1041  int id = (iii->Id()-1)*3+1;
1042  //
1043  //Condition::Pointer p_cond =
1044  // Condition::Pointer(new Condition(id, cond, properties) );
1045 
1046  Condition::Pointer p_cond = rReferenceBoundaryCondition.Create(id, temp, properties);
1047  (ThisModelPart.Conditions()).push_back(p_cond);
1048 
1049 
1050  }
1051 
1052  //********************************************************************
1053  //third face
1054  el_neighb = (ThisModelPart.Elements()).find( out2.neighborlist[base+2] );
1055  if( el_neighb == elements_end )
1056  {
1057  //if no neighnour is present => the face is free surface
1058  iii->GetGeometry()[0].FastGetSolutionStepValue(IS_BOUNDARY) = 1;
1059  iii->GetGeometry()[1].FastGetSolutionStepValue(IS_BOUNDARY) = 1;
1060 
1061 // Generate condition
1063  temp.reserve(2);
1064  temp.push_back(iii->GetGeometry()(1));
1065  temp.push_back(iii->GetGeometry()(0));
1068  int id = (iii->Id()-1)*3+2;
1069 
1070  //Condition::Pointer p_cond =
1071  // Condition::Pointer(new Condition(id, cond, properties) );
1072 
1073  Condition::Pointer p_cond = rReferenceBoundaryCondition.Create(id, temp, properties);
1074  (ThisModelPart.Conditions()).push_back(p_cond);
1075 
1076 
1077 
1078  }
1079 
1080 
1081  }
1082 
1083 
1084 
1085  clean_triangulateio(in2);
1086 
1087  clean_triangulateio(out2);
1088 
1089  clean_triangulateio(vorout2);
1090  KRATOS_WATCH("Finished remeshing with Trigen_PFEM_Refine_segment")
1091 
1092  KRATOS_CATCH("")
1093  }
1094 
1095 
1099 
1100 
1104 
1105 
1109 
1111  virtual std::string Info() const
1112  {
1113  return "";
1114  }
1115 
1117  virtual void PrintInfo(std::ostream& rOStream) const {}
1118 
1120  virtual void PrintData(std::ostream& rOStream) const {}
1121 
1122 
1126 
1127 
1129 
1130 protected:
1133 
1134 
1138 
1139 
1143 
1144 
1148 
1149 
1153 
1154 
1158 
1159 
1163 
1164 
1166 
1167 private:
1170 
1171 
1175  boost::numeric::ublas::bounded_matrix<double,2,2> mJ; //local jacobian
1176  boost::numeric::ublas::bounded_matrix<double,2,2> mJinv; //inverse jacobian
1177  array_1d<double,2> mC; //center pos
1178  array_1d<double,2> mRhs; //center pos
1179  //EntitiesEraseProcess<Node>* mpNodeEraseProcess;
1180 
1181 
1185  //returns false if it should be removed
1186  bool AlphaShape(double alpha_param, Geometry<Node >& pgeom)
1187  //bool AlphaShape(double alpha_param, Triangle2D<Node >& pgeom)
1188  {
1189  KRATOS_TRY
1190 
1191 
1192  double x0 = pgeom[0].X();
1193  double x1 = pgeom[1].X();
1194  double x2 = pgeom[2].X();
1195 
1196  double y0 = pgeom[0].Y();
1197  double y1 = pgeom[1].Y();
1198  double y2 = pgeom[2].Y();
1199 
1200  mJ(0,0)=2.0*(x1-x0);
1201  mJ(0,1)=2.0*(y1-y0);
1202  mJ(1,0)=2.0*(x2-x0);
1203  mJ(1,1)=2.0*(y2-y0);
1204 
1205 
1206  double detJ = mJ(0,0)*mJ(1,1)-mJ(0,1)*mJ(1,0);
1207 
1208  mJinv(0,0) = mJ(1,1);
1209  mJinv(0,1) = -mJ(0,1);
1210  mJinv(1,0) = -mJ(1,0);
1211  mJinv(1,1) = mJ(0,0);
1212 
1213  bounded_matrix<double,2,2> check;
1214 
1215 //calculate average h
1216  double h;
1217  h = pgeom[0].FastGetSolutionStepValue(NODAL_H);
1218  h += pgeom[1].FastGetSolutionStepValue(NODAL_H);
1219  h += pgeom[2].FastGetSolutionStepValue(NODAL_H);
1220  h *= 0.333333333;
1221 
1222 
1223  if(detJ < 5e-3*h*h)
1224  {
1225  //std::cout << "detJ = " << detJ << std::endl;
1227  pgeom[0].GetSolutionStepValue(IS_BOUNDARY) = 1;
1228  pgeom[1].GetSolutionStepValue(IS_BOUNDARY) = 1;
1229  pgeom[2].GetSolutionStepValue(IS_BOUNDARY) = 1;
1230  return false;
1231  }
1232 
1233  else
1234  {
1235 
1236  double x0_2 = x0*x0 + y0*y0;
1237  double x1_2 = x1*x1 + y1*y1;
1238  double x2_2 = x2*x2 + y2*y2;
1239 
1240  //finalizing the calculation of the inverted matrix
1241  //std::cout<<"MATR INV"<<MatrixInverse(mJ)<<std::endl;
1242  mJinv /= detJ;
1243  //calculating the RHS
1244  mRhs[0] = (x1_2 - x0_2);
1245  mRhs[1] = (x2_2 - x0_2);
1246 
1247  //calculate position of the center
1248  noalias(mC) = prod(mJinv,mRhs);
1249 
1250  double radius = sqrt(pow(mC[0]-x0,2)+pow(mC[1]-y0,2));
1251 
1252 
1253  if (radius < h*alpha_param)
1254  {
1255  return true;
1256  }
1257  else
1258  {
1259  return false;
1260  }
1261  }
1262 
1263 
1264  KRATOS_CATCH("")
1265  }
1266  //AUXILLIARY FCTNS
1267  inline void CalculateCenterAndSearchRadius(const double x0, const double y0,
1268  const double x1, const double y1,
1269  const double x2, const double y2,
1270  double& xc, double& yc, double& R
1271  )
1272  {
1273  xc = 0.3333333333333333333*(x0+x1+x2);
1274  yc = 0.3333333333333333333*(y0+y1+y2);
1275 
1276  double R1 = (xc-x0)*(xc-x0) + (yc-y0)*(yc-y0);
1277  double R2 = (xc-x1)*(xc-x1) + (yc-y1)*(yc-y1);
1278  double R3 = (xc-x2)*(xc-x2) + (yc-y2)*(yc-y2);
1279 
1280  R = R1;
1281  if(R2 > R) R = R2;
1282  if(R3 > R) R = R3;
1283 
1284  R = sqrt(R);
1285  }
1286 
1287  inline double CalculateVol( const double x0, const double y0,
1288  const double x1, const double y1,
1289  const double x2, const double y2
1290  )
1291  {
1292  return 0.5*( (x1-x0)*(y2-y0)- (y1-y0)*(x2-x0) );
1293  }
1294 
1295  inline bool CalculatePosition( const double x0, const double y0,
1296  const double x1, const double y1,
1297  const double x2, const double y2,
1298  const double xc, const double yc,
1299  array_1d<double,3>& N
1300  )
1301  {
1302  double area = CalculateVol(x0,y0,x1,y1,x2,y2);
1303  double inv_area = 0.0;
1304  if(area < 0.0000000000000001)
1305  {
1306  KRATOS_THROW_ERROR(std::logic_error,"element with zero area found","");
1307  }
1308  else
1309  {
1310  inv_area = 1.0 / area;
1311  }
1312 
1313 
1314  N[0] = CalculateVol(x1,y1,x2,y2,xc,yc) * inv_area;
1315  N[1] = CalculateVol(x2,y2,x0,y0,xc,yc) * inv_area;
1316  N[2] = CalculateVol(x0,y0,x1,y1,xc,yc) * inv_area;
1317 
1318  /* N[0] = CalculateVol(x0,y0,x1,y1,xc,yc) * inv_area;
1319  N[1] = CalculateVol(x1,y1,x2,y2,xc,yc) * inv_area;
1320  N[2] = CalculateVol(x2,y2,x0,y0,xc,yc) * inv_area;*/
1321 
1322  if(N[0] >= 0.0 && N[1] >= 0.0 && N[2] >= 0.0 && N[0] <= 1.0 && N[1] <= 1.0 && N[2] <= 1.0) //if the xc yc is inside the triangle
1323  //if(N[0] >= 0.0 && N[1] >= 0.0 && N[2] >= 0.0 && N[0] <= 1.0 && N[1] <= 1.0 && N[2] <= 1.0) //if the xc yc is inside the triangle return true
1324  return true;
1325 
1326  return false;
1327  }
1328  //**********************************************************************************************
1329  //**********************************************************************************************
1330  void Interpolate( Triangle2D3<Node >& geom, const array_1d<double,3>& N,
1331  unsigned int step_data_size,
1332  Node::Pointer pnode, double region_flag)
1333  {
1334  unsigned int buffer_size = pnode->GetBufferSize();
1335  //KRATOS_WATCH("Buffer size")
1336  //KRATOS_WATCH(buffer_size)
1337 //KRATOS_WATCH(pnode->FastGetSolutionStepValue(IS_INTERFACE));
1338  //here we want to keep the flag of aaded segment node and not interpolate it
1339  double aux_interface = pnode->FastGetSolutionStepValue(IS_INTERFACE);
1340 
1341  for(unsigned int step = 0; step<buffer_size; step++)
1342  {
1343 
1344  //getting the data of the solution step
1345  double* step_data = (pnode)->SolutionStepData().Data(step);
1346 
1347 
1348  double* node0_data = geom[0].SolutionStepData().Data(step);
1349  double* node1_data = geom[1].SolutionStepData().Data(step);
1350  double* node2_data = geom[2].SolutionStepData().Data(step);
1351 
1352  //copying this data in the position of the vector we are interested in
1353  for(unsigned int j= 0; j<step_data_size; j++)
1354  {
1355 
1356  step_data[j] = N[0]*node0_data[j] + N[1]*node1_data[j] + N[2]*node2_data[j];
1357 
1358 
1359  }
1360  }
1361  if (N[0]==0.0 && N[1]==0.0 && N[2]==0.0)
1362  KRATOS_THROW_ERROR(std::logic_error,"SOMETHING's wrong with the added nodes!!!!!! ERROR","");
1363 
1364  //if ( pnode->FastGetSolutionStepValue(BULK_MODULUS)==0.0)
1365  // KRATOS_THROW_ERROR(std::logic_error,"SOMETHING's wrong with the added nodes!!!!!! ERROR","");
1366 
1367  //now we assure that the flag variables are set coorect!! since we add nodes inside of the fluid volume only
1368  //we manually reset the IS_BOUNDARY, IS_FLUID, IS_STRUCTURE, IS_FREE_SURFACE values in a right way
1369  //not to have values, like 0.33 0.66 resulting if we would have been interpolating them in the same way
1370  //as the normal variables, like Velocity etc
1371 
1372 
1373  pnode->FastGetSolutionStepValue(IS_BOUNDARY)=0.0;
1374  pnode->FastGetSolutionStepValue(IS_STRUCTURE)=0.0;
1375  pnode->Set(TO_ERASE,false);
1376  pnode->FastGetSolutionStepValue(IS_FREE_SURFACE)=0.0;
1377  pnode->FastGetSolutionStepValue(IS_FLUID)=1.0;
1378 
1379  pnode->FastGetSolutionStepValue(IS_BOUNDARY,1)=0.0;
1380  pnode->FastGetSolutionStepValue(IS_STRUCTURE,1)=0.0;
1381  pnode->Set(TO_ERASE,false);
1382  pnode->FastGetSolutionStepValue(IS_FREE_SURFACE,1)=0.0;
1383  pnode->FastGetSolutionStepValue(IS_FLUID,1)=1.0;
1384  //pnode->FastGetSolutionStepValue(IS_VISITED)=0.0;
1385 
1386  //pnode->FastGetSolutionStepValue(IS_INTERFACE)=1.0;
1387  pnode->FastGetSolutionStepValue(IS_INTERFACE) = aux_interface;
1388  pnode->FastGetSolutionStepValue(IS_INTERFACE,1) = aux_interface;
1389 
1390  double same_colour = 0.0;
1391  for(int ii= 0; ii<= 2; ++ii)
1392  if(geom[ii].FastGetSolutionStepValue(IS_WATER) == 0.0)
1393  same_colour++;
1394  if(same_colour == 3.0)
1395  {
1396  pnode->FastGetSolutionStepValue(IS_WATER) = 0.0;
1397  pnode->FastGetSolutionStepValue(IS_WATER,1) = 0.0;
1398 
1399  }
1400  else
1401  {
1402  pnode->FastGetSolutionStepValue(IS_WATER) = 1.0;
1403  pnode->FastGetSolutionStepValue(IS_WATER) = 1.0;
1404  }
1405 
1406  /*if(region_flag == 14.0)
1407  {
1408  pnode->FastGetSolutionStepValue(IS_WATER) = 1.0;
1409  KRATOS_WATCH("RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR");
1410  KRATOS_WATCH(region_flag);
1411  }*/
1412  /*if(pnode->FastGetSolutionStepValue(IS_WATER)!= 1.0 && pnode->FastGetSolutionStepValue(IS_WATER)!= 0.0 &&
1413  pnode->FastGetSolutionStepValue(IS_WATER)!=-1.0)
1414  {
1415  pnode->FastGetSolutionStepValue(IS_WATER) = 1.0;
1416  KRATOS_WATCH("$$$$$$$$$$$$$$$ A NEAR BOUNDARY NODE IS INSERTED $$$$$$$$$$$$$$$$$$$$$$");
1417  }*/
1418  /*if(pnode->FastGetSolutionStepValue(DISTANCE) <= 0.0)
1419  {pnode->FastGetSolutionStepValue(IS_WATER) = 0.0;}
1420  else
1421  {pnode->FastGetSolutionStepValue(IS_WATER) = 1.0;}*/
1422 
1423  if(aux_interface)
1424  {
1425  pnode->FastGetSolutionStepValue(IS_WATER) = 0.0;
1426  pnode->FastGetSolutionStepValue(IS_WATER,1) = 0.0;
1427 
1428  }
1429 //KRATOS_WATCH(pnode->FastGetSolutionStepValue(IS_INTERFACE));
1430 
1431 
1432  }
1433 
1434  //**********************************************************************************************
1435  //**********************************************************************************************
1436  void SegmentDetecting(ModelPart& ThisModelPart, std::vector <int>& seg_list, int& seg_num, int& num_interface, double h_factor)
1437  {
1438  KRATOS_TRY;
1439  int Tdim = 2;
1440  seg_list.clear();
1441  num_interface = 0;
1442  std::vector <int> nodes_of_bad_segments;
1443  //PointVector nodes_of_bad_segments
1444  std::vector <int> raw_seg_list;
1445 
1446  if(h_factor > 0.1)
1447  h_factor = 0.5;
1448 
1449  //delete interface flag
1450  for(ModelPart::NodeIterator ind = ThisModelPart.NodesBegin(); ind != ThisModelPart.NodesEnd(); ++ind)
1451  ind->FastGetSolutionStepValue(IS_INTERFACE) = 0.0;
1452 
1453 
1454 
1455  for(ModelPart::ElementsContainerType::iterator elem = ThisModelPart.ElementsBegin();
1456  elem!=ThisModelPart.ElementsEnd(); elem++)
1457  {
1458 
1459  if(elem->GetValue(IS_WATER_ELEMENT) == 0)
1460  {
1461 
1462  GlobalPointersVector< Element >& neighbor_els = elem->GetValue(NEIGHBOUR_ELEMENTS);
1463  Geometry< Node >& geom = elem->GetGeometry();
1464 
1465  for(int ii=0; ii<(Tdim+1); ++ii)
1466  {
1467 
1468  if(neighbor_els[ii].GetValue(IS_WATER_ELEMENT) == 1 && neighbor_els[ii].Id() != elem->Id())
1469  {
1470 
1471  if(ii == 0) // 2,1
1472  {
1473  if(geom[1].FastGetSolutionStepValue(IS_STRUCTURE) == 0.0 && geom[2].FastGetSolutionStepValue(IS_STRUCTURE) == 0.0)
1474  {
1475 
1476  //check for bad segments
1477  double length = 0.0;
1478  length = pow(geom[1].X()-geom[2].X(),2) + pow(geom[1].Y()-geom[2].Y(),2) +pow(geom[1].Z()-geom[2].Z(),2);
1479  length = sqrt(length);
1480 
1481  if(length < h_factor*geom[2].FastGetSolutionStepValue(NODAL_H))
1482  {
1483  //detect bad segment and mark to earase first node
1484  nodes_of_bad_segments.push_back(geom[2].Id());
1485  nodes_of_bad_segments.push_back(geom[1].Id());
1486  //nodes_of_bad_segments.push_back(geom[2]);
1487  //nodes_of_bad_segments.push_back(geom[1]);
1488 
1489 
1490  //earse bad node
1491  geom[2].FastGetSolutionStepValue(IS_INTERFACE) = 0.0;
1492  geom[2].Set(TO_ERASE, true);
1493  }
1494  else
1495  {
1496  //one segment is detected
1497  ++seg_num;
1498  raw_seg_list.push_back(geom[2].Id());
1499  raw_seg_list.push_back(geom[1].Id());
1500  geom[2].FastGetSolutionStepValue(IS_INTERFACE) = 1.0;
1501  geom[1].FastGetSolutionStepValue(IS_INTERFACE) = 1.0;
1502  }
1503  }
1504  }
1505  if(ii == 1) // 0,2
1506  {
1507  if(geom[0].FastGetSolutionStepValue(IS_STRUCTURE) == 0.0 && geom[2].FastGetSolutionStepValue(IS_STRUCTURE) == 0.0)
1508  {
1509  //check for bad segments
1510  double length = 0.0;
1511  length = pow(geom[0].X()-geom[2].X(),2) + pow(geom[0].Y()-geom[2].Y(),2) +pow(geom[0].Z()-geom[2].Z(),2);
1512  length = sqrt(length);
1513 
1514  if(length < h_factor*geom[0].FastGetSolutionStepValue(NODAL_H))
1515  {
1516  //detect bad segment and mark to earase first node
1517  nodes_of_bad_segments.push_back(geom[0].Id());
1518  nodes_of_bad_segments.push_back(geom[2].Id());
1519  //nodes_of_bad_segments.push_back(geom[0]);
1520  //nodes_of_bad_segments.push_back(geom[2]);
1521 
1522  //earse bad node
1523  geom[0].FastGetSolutionStepValue(IS_INTERFACE) = 0.0;
1524  geom[0].Set(TO_ERASE, true);
1525  }
1526  else
1527  {
1528  //one segment is detected
1529  ++seg_num;
1530  raw_seg_list.push_back(geom[0].Id());
1531  raw_seg_list.push_back(geom[2].Id());
1532  geom[0].FastGetSolutionStepValue(IS_INTERFACE) = 1.0;
1533  geom[2].FastGetSolutionStepValue(IS_INTERFACE) = 1.0;
1534  }
1535  }
1536  }
1537  if(ii == 2) // 1,0
1538  {
1539  if(geom[0].FastGetSolutionStepValue(IS_STRUCTURE) == 0.0 && geom[1].FastGetSolutionStepValue(IS_STRUCTURE) == 0.0)
1540  {
1541  //check for bad segments
1542  double length = 0.0;
1543  length = pow(geom[0].X()-geom[1].X(),2) + pow(geom[0].Y()-geom[1].Y(),2) +pow(geom[0].Z()-geom[1].Z(),2);
1544  length = sqrt(length);
1545 
1546  if(length < h_factor*geom[1].FastGetSolutionStepValue(NODAL_H))
1547  {
1548  //detect bad segment and mark to earase first node
1549  nodes_of_bad_segments.push_back(geom[1].Id());
1550  nodes_of_bad_segments.push_back(geom[0].Id());
1551  //nodes_of_bad_segments.push_back(geom[1]);
1552  //nodes_of_bad_segments.push_back(geom[0]);
1553 
1554  //earse bad node
1555  geom[1].FastGetSolutionStepValue(IS_INTERFACE) = 0.0;
1556  geom[1].Set(TO_ERASE, true);
1557  }
1558  else
1559  {
1560  //one segment is detected
1561  ++seg_num;
1562  raw_seg_list.push_back(geom[1].Id());
1563  raw_seg_list.push_back(geom[0].Id());
1564  geom[1].FastGetSolutionStepValue(IS_INTERFACE) = 1.0;
1565  geom[0].FastGetSolutionStepValue(IS_INTERFACE) = 1.0;
1566  }
1567  }
1568  }
1569 
1570  }
1571  }
1572 
1573  }
1574  }
1575 
1576  //count interface nodes
1577  for(ModelPart::NodeIterator ind = ThisModelPart.NodesBegin(); ind != ThisModelPart.NodesEnd(); ++ind)
1578  if(ind->FastGetSolutionStepValue(IS_INTERFACE) == 1.0)
1579  num_interface++;
1580 
1581  /* for(unsigned int seg=0; seg < raw_seg_list.size(); seg+=2)
1582  {
1583  seg_list.push_back(raw_seg_list[seg]);
1584  seg_list.push_back(raw_seg_list[seg + 1]);
1585 
1586  }
1587 
1588 
1589  */
1590 
1591 
1592  //merge for mark to erase node (the node marked for erase is relpaced byanother node of deleted segment on remaining segment)
1593  for(unsigned int ii=0; ii<nodes_of_bad_segments.size(); ii+=2)
1594  {
1595  KRATOS_WATCH("!!!!!!!!!!!!!!!!!!! BAD NODES !!!!!!!!!!!!!!!!!!!!!!");
1596 
1597  int bad_node = nodes_of_bad_segments[ii];
1598 
1599 //COORDINTAES of bad node
1600  KRATOS_WATCH(ThisModelPart.Nodes()[bad_node].X());
1601  KRATOS_WATCH(ThisModelPart.Nodes()[bad_node].Y());
1602 //ens of COORDINTAES
1603 
1604  for(int & jj : raw_seg_list)
1605  {
1606  //merge in segment list
1607  if(jj == bad_node )
1608  {
1609  jj = nodes_of_bad_segments[ii + 1];
1610  KRATOS_WATCH("OOOOOOOOOOOOOOOOOO MERGE IS DONE OOOOOOOOOOOOOOOOOOOOOO");
1611  }
1612  }
1613  //possible replace in nodes_of_bad_segments for adjacent bad segments
1614  for(unsigned int kk=0; kk<nodes_of_bad_segments.size(); kk+=2)
1615  {
1616  if(nodes_of_bad_segments[kk + 1] == bad_node )
1617  {
1618  nodes_of_bad_segments[kk + 1] = nodes_of_bad_segments[ii + 1];
1619  KRATOS_WATCH("HHHHHHHHHHHHHHHHHH BAD_SEGMENT LIST UPDATED HHHHHHHHHHHHHHHHHHHHHHHH");
1620  }
1621  }
1622 
1623 
1624  }
1625 
1626 
1627  //fill de final list
1628  seg_num = 0 ;
1629  for(unsigned int seg=0; seg < raw_seg_list.size(); seg+=2)
1630  {
1631  if(raw_seg_list[seg] != raw_seg_list[seg + 1])
1632  {
1633  seg_list.push_back(raw_seg_list[seg]);
1634  seg_list.push_back(raw_seg_list[seg + 1]);
1635  seg_num++;
1636 
1637  ModelPart::NodesContainerType::iterator inode = ThisModelPart.Nodes().find(raw_seg_list[seg]);
1638  inode->FastGetSolutionStepValue(IS_INTERFACE) = 1.0;
1639  inode->Set(TO_ERASE, false);
1640 
1641  ModelPart::NodesContainerType::iterator iinode = ThisModelPart.Nodes().find(raw_seg_list[seg+1]);
1642  iinode->FastGetSolutionStepValue(IS_INTERFACE) = 1.0;
1643  iinode->Set(TO_ERASE, false);
1644 
1645  //ThisModelPart.Nodes()[raw_seg_list[seg]].Set(TO_ERASE, false);
1646  //ThisModelPart.Nodes()[raw_seg_list[seg + 1]].Set(TO_ERASE, false);
1647  }
1648  }
1649 
1650 
1651 
1652 
1653  KRATOS_CATCH("");
1654  }
1655  //**********************************************************************************************
1656  //**********************************************************************************************
1657  void initialize_triangulateio( triangulateio& tr )
1658  {
1659  tr.pointlist = (REAL*) nullptr;
1660  tr.pointattributelist = (REAL*) nullptr;
1661  tr.pointmarkerlist = (int*) nullptr;
1662  tr.numberofpoints = 0;
1663  tr.numberofpointattributes = 0;
1664  tr.trianglelist = (int*) nullptr;
1665  tr.triangleattributelist = (REAL*) nullptr;
1666  tr.trianglearealist = (REAL*) nullptr;
1667  tr.neighborlist = (int*) nullptr;
1668  tr.numberoftriangles = 0;
1669  tr.numberofcorners = 3;
1670  tr.numberoftriangleattributes = 0;
1671  tr.segmentlist = (int*) nullptr;
1672  tr.segmentmarkerlist = (int*) nullptr;
1673  tr.numberofsegments = 0;
1674  tr.holelist = (REAL*) nullptr;
1675  tr.numberofholes = 0;
1676  tr.regionlist = (REAL*) nullptr;
1677  tr.numberofregions = 0;
1678  tr.edgelist = (int*) nullptr;
1679  tr.edgemarkerlist = (int*) nullptr;
1680  tr.normlist = (REAL*) nullptr;
1681  tr.numberofedges = 0;
1682  };
1683 
1684  void clean_triangulateio( triangulateio& tr )
1685  {
1686  if(tr.pointlist != nullptr) free(tr.pointlist );
1687  if(tr.pointattributelist != nullptr) free(tr.pointattributelist );
1688  if(tr.pointmarkerlist != nullptr) free(tr.pointmarkerlist );
1689  if(tr.trianglelist != nullptr) free(tr.trianglelist );
1690  if(tr.triangleattributelist != nullptr) free(tr.triangleattributelist );
1691  if(tr.trianglearealist != nullptr) free(tr.trianglearealist );
1692  if(tr.neighborlist != nullptr) free(tr.neighborlist );
1693  if(tr.segmentlist != nullptr) free(tr.segmentlist );
1694  if(tr.segmentmarkerlist != nullptr) free(tr.segmentmarkerlist );
1695  if(tr.holelist != nullptr) free(tr.holelist );
1696  if(tr.regionlist != nullptr) free(tr.regionlist );
1697  if(tr.edgelist != nullptr) free(tr.edgelist );
1698  if(tr.edgemarkerlist != nullptr) free(tr.edgemarkerlist );
1699  if(tr.normlist != nullptr) free(tr.normlist );
1700  };
1704 
1705 
1709 
1710 
1714 
1715 
1719 
1722 
1723 
1725 
1726 }; // Class TriGenPFEMRefineSegment
1727 
1729 
1732 
1733 
1737 
1738 
1740 inline std::istream& operator >> (std::istream& rIStream,
1741  TriGenPFEMRefineSegment& rThis);
1742 
1744 inline std::ostream& operator << (std::ostream& rOStream,
1745  const TriGenPFEMRefineSegment& rThis)
1746 {
1747  rThis.PrintInfo(rOStream);
1748  rOStream << std::endl;
1749  rThis.PrintData(rOStream);
1750 
1751  return rOStream;
1752 }
1754 
1755 
1756 } // namespace Kratos.
1757 
1758 #endif // KRATOS_TRIGEN_PFEM_MODELER_H_INCLUDED defined
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
Definition: bins_static.h:35
Base class for all Conditions.
Definition: condition.h:59
virtual Pointer Create(IndexType NewId, NodesArrayType const &ThisNodes, PropertiesType::Pointer pProperties) const
It creates a new condition pointer.
Definition: condition.h:205
Dof represents a degree of freedom (DoF).
Definition: dof.h:86
Base class for all Elements.
Definition: element.h:60
virtual Pointer Create(IndexType NewId, NodesArrayType const &ThisNodes, PropertiesType::Pointer pProperties) const
It creates a new element pointer.
Definition: element.h:202
This process removes the entities from a model part with the flag TO_ERASE.
Definition: entity_erase_process.h:70
void Execute() override
Execute method is used to execute the Process algorithms.
Geometry base class.
Definition: geometry.h:71
This class is a wrapper for a pointer to a data that is located in a different rank.
Definition: global_pointer.h:44
Definition: amatrix_interface.h:497
Definition: amatrix_interface.h:530
PropertiesType::Pointer pGetProperties(IndexType PropertiesId)
Definition: mesh.h:394
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
NodeType::Pointer CreateNewNode(int Id, double x, double y, double z, VariablesList::Pointer pNewVariablesList, IndexType ThisIndex=0)
Definition: model_part.cpp:270
SizeType GetNodalSolutionStepDataSize()
Definition: model_part.h:571
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
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
MeshType & GetMesh(IndexType ThisIndex=0)
Definition: model_part.h:1791
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
This class defines the node.
Definition: node.h:65
std::vector< std::unique_ptr< Dof< double > >> DofsContainerType
The DoF container type definition.
Definition: node.h:92
double Y() const
Definition: point.h:187
double Z() const
Definition: point.h:193
double X() const
Definition: point.h:181
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
static double ElapsedSeconds(const std::chrono::steady_clock::time_point StartTime)
This method returns the resulting time.
Definition: timer.h:179
A generic tree data structure for spatial partitioning.
Definition: tree.h:190
Short class definition.
Definition: trigen_pfem_refine_segment.h:64
void ReGenerateMesh(ModelPart &ThisModelPart, Element const &rReferenceElement, Condition const &rReferenceBoundaryCondition, EntitiesEraseProcess< Node > &node_erase, bool rem_nodes=true, bool add_nodes=true, double my_alpha=1.4, double h_factor=0.5)
Definition: trigen_pfem_refine_segment.h:100
KRATOS_CLASS_POINTER_DEFINITION(TriGenPFEMRefineSegment)
Pointer definition of TriGenModeler.
virtual ~TriGenPFEMRefineSegment()=default
Destructor.
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: trigen_pfem_refine_segment.h:1117
virtual std::string Info() const
Turn back information as a string.
Definition: trigen_pfem_refine_segment.h:1111
TriGenPFEMRefineSegment()
Default constructor.
Definition: trigen_pfem_refine_segment.h:77
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: trigen_pfem_refine_segment.h:1120
A three node 2D triangle geometry with linear shape functions.
Definition: triangle_2d_3.h:74
#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
#define REAL
Definition: delaunator_utilities.cpp:16
Kratos::ModelPart ModelPart
Definition: kratos_wrapper.h:31
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
bool CalculatePosition(Geometry< Node > &geom, const double xc, const double yc, const double zc, array_1d< double, 3 > &N)
Definition: transfer_utility.h:343
double CalculateVol(const double x0, const double y0, const double x1, const double y1, const double x2, const double y2)
Definition: transfer_utility.h:424
AMatrix::MatrixProductExpression< TExpression1Type, TExpression2Type > prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:568
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
DistanceVector::iterator DistanceIterator
Definition: internal_variables_interpolation_process.h:56
std::vector< PointTypePointer > PointVector
Definition: internal_variables_interpolation_process.h:53
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
void triangulate(char *, struct triangulateio *, struct triangulateio *, struct triangulateio *)
REACTION_CHECK_STIFFNESS_FACTOR int
Definition: contact_structural_mechanics_application_variables.h:75
PointVector::iterator PointIterator
Definition: internal_variables_interpolation_process.h:54
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
std::vector< double > DistanceVector
Definition: internal_variables_interpolation_process.h:55
Point PointType
Geometric definitions.
Definition: mortar_classes.h:36
int step
Definition: face_heat.py:88
y
Other simbols definition.
Definition: generate_axisymmetric_navier_stokes_element.py:54
res
Definition: generate_convection_diffusion_explicit_element.py:211
h
Definition: generate_droplet_dynamics.py:91
x2
Definition: generate_frictional_mortar_condition.py:122
x1
Definition: generate_frictional_mortar_condition.py:121
R
Definition: isotropic_damage_automatic_differentiation.py:172
float radius
Definition: mesh_to_mdpa_converter.py:18
def Interpolate(variable, entity, sf_values, historical_value)
Definition: point_output_process.py:231
int k
Definition: quadrature.py:595
int j
Definition: quadrature.py:648
el
Definition: read_stl.py:25
float temp
Definition: rotating_cone.py:85
float xc
Definition: rotating_cone.py:77
float yc
Definition: rotating_cone.py:78
int counter
Definition: script_THERMAL_CORRECT.py:218
add_nodes
Definition: script.py:96
N
Definition: sensitivityMatrix.py:29
x
Definition: sensitivityMatrix.py:49
integer i
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31