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_vms.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 #if !defined(KRATOS_TRIGEN_PFEM_MODELER_VMS_H_INCLUDED )
14 #define KRATOS_TRIGEN_PFEM_MODELER_VMS_H_INCLUDED
15 
16 // System includes
17 
18 // External includes
19 #include "triangle.h"
20 
21 // Project includes
22 #include "includes/define.h"
23 #include "includes/model_part.h"
25 #include "utilities/timer.h"
30 #include "trigen_pfem_refine.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 public:
67 
70  typedef Node PointType;
71  typedef Node::Pointer PointPointerType;
72  typedef std::vector<PointType::Pointer> PointVector;
73  typedef PointVector::iterator PointIterator;
74  typedef std::vector<double> DistanceVector;
75  typedef std::vector<double>::iterator DistanceIterator;
78 
82 
85  mJ(ZeroMatrix(2,2)), //local jacobian
86  mJinv(ZeroMatrix(2,2)), //inverse jacobian
87  mC(ZeroVector(2)), //dimension = number of nodes
88  mRhs(ZeroVector(2)) {}
89  //mpNodeEraseProcess(NULL){} //dimension = number of nodes
90 
92  ~TriGenPFEMModelerVMS() override = default;
93 
94 
98 
99 
103 
104 
105  //*******************************************************************************************
106  //*******************************************************************************************
108  ModelPart& ThisModelPart ,
109  Element const& rReferenceElement,
110  Condition const& rReferenceBoundaryCondition,
111  EntitiesEraseProcess<Node>& node_erase, bool rem_nodes = true, bool add_nodes=true,
112  double my_alpha = 1.4, double h_factor=0.5)
113  {
114 
115  KRATOS_TRY
116  if (ThisModelPart.NodesBegin()->SolutionStepsDataHas(IS_FREE_SURFACE)==false )
117  KRATOS_THROW_ERROR(std::logic_error,"Add ----IS_FREE_SURFACE---- variable!!!!!! ERROR","");
118  if (ThisModelPart.NodesBegin()->SolutionStepsDataHas(IS_STRUCTURE)==false )
119  KRATOS_THROW_ERROR(std::logic_error,"Add ----IS_STRUCTURE---- variable!!!!!! ERROR","");
120  if (ThisModelPart.NodesBegin()->SolutionStepsDataHas(IS_BOUNDARY)==false )
121  KRATOS_THROW_ERROR(std::logic_error,"Add ----IS_BOUNDARY---- variable!!!!!! ERROR","");
122  if (ThisModelPart.NodesBegin()->SolutionStepsDataHas(IS_FLUID)==false )
123  KRATOS_THROW_ERROR(std::logic_error,"Add ----IS_FLUID---- variable!!!!!! ERROR","");
124 
125  KRATOS_WATCH("Trigen PFEM Refining Mesher")
126  const auto inital_time = std::chrono::steady_clock::now();
127 
128 
129 //clearing elements
130 
131  ThisModelPart.Elements().clear();
132  ThisModelPart.Conditions().clear();
133 
135 
136 
137  int step_data_size = ThisModelPart.GetNodalSolutionStepDataSize();
138 
139  // bucket types
140  //typedef Bucket<3, PointType, ModelPart::NodesContainerType, PointPointerType, PointIterator, DistanceIterator > BucketType;
141  //typedef Bins< 3, PointType, PointVector, PointPointerType, PointIterator, DistanceIterator > StaticBins;
142  // bucket types
143 
144  //typedef Tree< StaticBins > Bin; //Binstree;
145  unsigned int bucket_size = 20;
146 
147  //performing the interpolation - all of the nodes in this list will be preserved
148  unsigned int max_results = 100;
149  //PointerVector<PointType> res(max_results);
150  //NodeIterator res(max_results);
151  PointVector res(max_results);
152  DistanceVector res_distances(max_results);
153  Node work_point(0,0.0,0.0,0.0);
154  //if the remove_node switch is activated, we check if the nodes got too close
155 
156  if (rem_nodes==true)
157  {
158  PointVector list_of_nodes;
159  list_of_nodes.reserve(ThisModelPart.Nodes().size());
160  for(ModelPart::NodesContainerType::iterator i_node = ThisModelPart.NodesBegin() ; i_node != ThisModelPart.NodesEnd() ; i_node++)
161  {
162  (list_of_nodes).push_back(*(i_node.base()));
163  }
164 
165  KdtreeType nodes_tree1(list_of_nodes.begin(),list_of_nodes.end(), bucket_size);
166 
167  RemoveCloseNodes(ThisModelPart, nodes_tree1, node_erase, h_factor);
168  }
169 
171  // //
172  // Now we shall pass the Alpha Shape for the second time, having the "bad nodes" removed //
174  //creating the containers for the input and output
175  struct triangulateio in_mid;
176  struct triangulateio out_mid;
177  struct triangulateio vorout_mid;
178 
179  initialize_triangulateio(in_mid);
180  initialize_triangulateio(out_mid);
181  initialize_triangulateio(vorout_mid);
182 
183  //assigning the size of the input containers
184 
185  in_mid.numberofpoints = ThisModelPart.Nodes().size();
186  in_mid.pointlist = (REAL *) malloc(in_mid.numberofpoints * 2 * sizeof(REAL));
187 
188  //reorder the id's and give the coordinates to the mesher
189  ModelPart::NodesContainerType::iterator nodes_begin = ThisModelPart.NodesBegin();
190  for(unsigned int i = 0; i<ThisModelPart.Nodes().size(); i++)
191  {
192  int base = i*2;
193  //int base = ((nodes_begin + i)->Id() - 1 ) * 2;
194 
195  //from now on it is consecutive
196  (nodes_begin + i)->SetId(i+1);
197 // (nodes_begin + i)->Id() = i+1;
198 
199  in_mid.pointlist[base] = (nodes_begin + i)->X();
200  in_mid.pointlist[base+1] = (nodes_begin + i)->Y();
201 
202  auto& node_dofs = (nodes_begin + i)->GetDofs();
203  for(auto iii = node_dofs.begin(); iii != node_dofs.end(); iii++)
204  {
205  (**iii).SetEquationId(i+1);
206  }
207  }
208  //in_mid.numberoftriangles = ThisModelPart.Elements().size();
209  //in_mid.trianglelist = (int*) malloc(in_mid.numberoftriangles * 3 * sizeof(int));
210 
211  // "P" suppresses the output .poly file. Saves disk space, but you
212  //lose the ability to maintain constraining segments on later refinements of the mesh.
213  // "B" Suppresses boundary markers in the output .node, .poly, and .edge output files
214  // "n" outputs a list of triangles neighboring each triangle.
215  // "e" outputs edge list (i.e. all the "connectivities")
216  char options1[] = "Pne";
217  triangulate(options1, &in_mid, &out_mid, &vorout_mid);
218  //print out the mesh generation time
219  std::cout<<"mesh generation time = " << Timer::ElapsedSeconds(inital_time) << std::endl;
220  //number of newly generated triangles
221  unsigned int el_number=out_mid.numberoftriangles;
222 
223  //PASSING THE CREATED ELEMENTS TO THE ALPHA-SHAPE
224  std::vector<int> preserved_list1(el_number);
225  preserved_list1.resize(el_number);
226 
227  int number_of_preserved_elems= PassAlphaShape(ThisModelPart, preserved_list1, el_number, my_alpha, out_mid);
228 
229  //freeing memory
230 
231  clean_triangulateio(in_mid);
232  clean_triangulateio(vorout_mid);
233  KRATOS_WATCH("ln367");
234  //NOW WE SHALL PERFORM ADAPTIVE REMESHING, i.e. insert and remove nodes based upon mesh quality
235  // and prescribed sizes
236  struct triangulateio in2;
237  struct triangulateio out2;
238  struct triangulateio vorout2;
239 
240  initialize_triangulateio(in2);
241  initialize_triangulateio(out2);
242  initialize_triangulateio(vorout2);
243 
244 // in2.firstnumber = 1;
245  in2.numberofpoints = ThisModelPart.Nodes().size();
246  in2.pointlist = (REAL *) malloc(in2.numberofpoints * 2 * sizeof(REAL));
247 
248  //writing the input point list
249  for(unsigned int i = 0; i<ThisModelPart.Nodes().size(); i++)
250  {
251  int base = i*2;
252  in2.pointlist[base] = (nodes_begin + i)->X();
253  in2.pointlist[base+1] = (nodes_begin + i)->Y();
254  }
255  in2.numberoftriangles=number_of_preserved_elems;
256 
257  in2.trianglelist = (int *) malloc(in2.numberoftriangles * 3 * sizeof(int));
258  in2.trianglearealist = (REAL *) malloc(in2.numberoftriangles * sizeof(REAL));
259 // in2.trianglelist = new int[in2.numberoftriangles * 3];
260 // in2.trianglearealist = new double[in2.numberoftriangles];
261 
262  KRATOS_WATCH(el_number);
263  int counter = 0;
264  //here I will assign a huge number of NODAL_H to the free surface nodes, so that there no nodes will be added
265  for(ModelPart::NodesContainerType::iterator i_node = ThisModelPart.NodesBegin() ; i_node != ThisModelPart.NodesEnd() ; i_node++)
266  {
267  if (i_node->FastGetSolutionStepValue(IS_FREE_SURFACE)!=0)
268  {
269 
270  double& val=i_node->FastGetSolutionStepValue(NODAL_H);
271  val*=2.0;
272  //i_node->FastGetSolutionStepValue(NODAL_H,1)=val;
273  //KRATOS_WATCH("AAAAAAAAAAAAAAAAAAAAAAAA!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
274  }
275  }
276 
277 
278  for (unsigned int el=0; el<el_number; el++)
279  {
280  if( static_cast<bool>(preserved_list1[el]) == true )
281  {
282  //saving the list of ONLY preserved triangles, the ones that passed alpha-shape check
283  int new_base = counter*3;
284  int old_base = el*3;
285  //copying in case it is preserved
286  in2.trianglelist[new_base] = out_mid.trianglelist[old_base];
287  in2.trianglelist[new_base+1] = out_mid.trianglelist[old_base+1];
288  in2.trianglelist[new_base+2] = out_mid.trianglelist[old_base+2];
289 
290  //calculate the prescribed h
291  double prescribed_h = (nodes_begin + out_mid.trianglelist[old_base]-1)->FastGetSolutionStepValue(NODAL_H);
292  prescribed_h += (nodes_begin + out_mid.trianglelist[old_base+1]-1)->FastGetSolutionStepValue(NODAL_H);
293  prescribed_h += (nodes_begin + out_mid.trianglelist[old_base+2]-1)->FastGetSolutionStepValue(NODAL_H);
294  prescribed_h *= 0.3333;
295  //if h is the height of a equilateral triangle, the area is 1/2*h*h
296  in2.trianglearealist[counter] = 0.5*(1.5*prescribed_h*1.5*prescribed_h);
297  counter += 1;
298  }
299 
300  }
301  //now I set back the nodal_h
302  for(ModelPart::NodesContainerType::iterator i_node = ThisModelPart.NodesBegin() ; i_node != ThisModelPart.NodesEnd() ; i_node++)
303  {
304  if (i_node->FastGetSolutionStepValue(IS_FREE_SURFACE)!=0)
305  {
306  double& nodal_h=i_node->FastGetSolutionStepValue(NODAL_H);
307  nodal_h/=2.0;
308  }
309  }
310 
311 
312  clean_triangulateio(out_mid);
313  KRATOS_WATCH("ln420");
314  //here we generate a new mesh adding/removing nodes, by initializing "q"-quality mesh and "a"-area constraint switches
315  //
316  // MOST IMPORTANT IS "r" switch, that refines previously generated mesh!!!!!!!!!!(that is the one given inside in2)
317  //char mesh_regen_opts[] = "YYJaqrn";
318  //char mesh_regen_opts[] = "YJq1.4arn";
319  if (add_nodes==true)
320  {
321  char mesh_regen_opts[] = "YJq1.4arn";
322  triangulate(mesh_regen_opts, &in2, &out2, &vorout2);
323  KRATOS_WATCH("Adaptive remeshing executed")
324  }
325  else
326  {
327  char mesh_regen_opts[] = "YJrn";
328  triangulate(mesh_regen_opts, &in2, &out2, &vorout2);
329  KRATOS_WATCH("Non-Adaptive remeshing executed")
330  }
331 
332  //and now we shall find out where the new nodes belong to
333  //defintions for spatial search
334  typedef Node PointType;
335  typedef Node::Pointer PointPointerType;
336  typedef std::vector<PointType::Pointer> PointVector;
337  //typedef std::vector<PointType::Pointer>::iterator PointIterator;
338  typedef PointVector::iterator PointIterator;
339  typedef std::vector<double> DistanceVector;
340  typedef std::vector<double>::iterator DistanceIterator;
341  KRATOS_WATCH("ln449");
342 
344 
345  typedef Tree< KDTreePartition<BucketType> > kd_tree; //Kdtree;
346 
347  //int step_data_size = ThisModelPart.GetNodalSolutionStepDataSize();
348 
349  //creating an auxiliary list for the new nodes
350  PointVector list_of_new_nodes;
351 
352  //node to get the DOFs from
353  Node::DofsContainerType& reference_dofs = (ThisModelPart.NodesBegin())->GetDofs();
354 
355  double z = 0.0;
356  int n_points_before_refinement = in2.numberofpoints;
357  //if points were added, we add them as nodes to the ModelPart
358  if (out2.numberofpoints > n_points_before_refinement )
359  {
360  for(int i = n_points_before_refinement; i<out2.numberofpoints; i++)
361  {
362  int id=i+1;
363  int base = i*2;
364  double& x= out2.pointlist[base];
365  double& y= out2.pointlist[base+1];
366 
367  Node::Pointer pnode = ThisModelPart.CreateNewNode(id,x,y,z);
368 
369  pnode->SetBufferSize(ThisModelPart.NodesBegin()->GetBufferSize() );
370 
371  list_of_new_nodes.push_back( pnode );
372 
373  //std::cout << "new node id = " << pnode->Id() << std::endl;
374  //generating the dofs
375  for(Node::DofsContainerType::iterator iii = reference_dofs.begin(); iii != reference_dofs.end(); iii++)
376  {
377  Node::DofType& rDof = **iii;
378  Node::DofType::Pointer p_new_dof = pnode->pAddDof( rDof );
379 
380  (p_new_dof)->FreeDof();
381 // (p_new_dof)->EquationId() = -1;
382 
383  }
384 
385  }
386  }
387 
388  std::cout << "During refinement we added " << out2.numberofpoints-n_points_before_refinement<< " nodes " <<std::endl;
389  //unsigned int bucket_size = 20;
390  //performing the interpolation - all of the nodes in this list will be preserved
391  //unsigned int max_results = 50;
392  //PointVector results(max_results);
393  //DistanceVector results_distances(max_results);
395 
397 
398  //int number_of_preserved_elems=0;
399 
400  int point_base;
401  //WHAT ARE THOSE????
402 // Node work_point(0,0.0,0.0,0.0);
403  unsigned int MaximumNumberOfResults = list_of_new_nodes.size();
404  PointVector Results(MaximumNumberOfResults);
405  DistanceVector ResultsDistances(MaximumNumberOfResults);
406 
407  step_data_size = ThisModelPart.GetNodalSolutionStepDataSize();
408 
409  if(out2.numberofpoints-n_points_before_refinement > 0) //if we added points
410  {
411 
412  kd_tree nodes_tree2(list_of_new_nodes.begin(),list_of_new_nodes.end(),bucket_size);
413  nodes_begin = ThisModelPart.NodesBegin();
414 
415  for(int el = 0; el< in2.numberoftriangles; el++)
416  {
417  int base = el * 3;
418  //coordinates
419  point_base = (in2.trianglelist[base] - 1)*2;
420  x1[0] = in2.pointlist[point_base];
421  x1[1] = in2.pointlist[point_base+1];
422 
423  point_base = (in2.trianglelist[base+1] - 1)*2;
424  x2[0] = in2.pointlist[point_base];
425  x2[1] = in2.pointlist[point_base+1];
426 
427  point_base = (in2.trianglelist[base+2] - 1)*2;
428  x3[0] = in2.pointlist[point_base];
429  x3[1] = in2.pointlist[point_base+1];
430 
431 
432  //find the center and "radius" of the element
433  double xc, yc, radius;
434  CalculateCenterAndSearchRadius( x1[0], x1[1],
435  x2[0], x2[1],
436  x3[0], x3[1],
437  xc,yc,radius);
438 
439  //find all of the new nodes within the radius
440  int number_of_points_in_radius;
441  work_point.X() = xc;
442  work_point.Y() = yc;
443  work_point.Z() = 0.0;
444 
445  number_of_points_in_radius = nodes_tree2.SearchInRadius(work_point, radius*1.01, Results.begin(),
446  ResultsDistances.begin(), MaximumNumberOfResults);
447 
448  Triangle2D3<Node > geom(
449  *( (nodes_begin + in2.trianglelist[base]-1).base() ),
450  *( (nodes_begin + in2.trianglelist[base+1]-1).base() ),
451  *( (nodes_begin + in2.trianglelist[base+2]-1).base() )
452  );
453 
454  //check if inside and eventually interpolate
455  for( auto it_found = Results.begin(); it_found != Results.begin() + number_of_points_in_radius; it_found++)
456  {
457  bool is_inside = false;
458  is_inside = CalculatePosition(x1[0], x1[1],
459  x2[0], x2[1],
460  x3[0], x3[1],
461  (*it_found)->X(),(*it_found)->Y(),N);
462 
463 
464  if(is_inside == true)
465  {
466  Interpolate( geom, N, step_data_size, *(it_found ) );
467 
468  }
469  }
470  }
471  }
472 
473  ThisModelPart.Elements().clear();
474 
475  //set the coordinates to the original value
476  for(auto & list_of_new_node : list_of_new_nodes)
477  {
478  const array_1d<double,3>& disp = list_of_new_node->FastGetSolutionStepValue(DISPLACEMENT);
479  list_of_new_node->X0() = list_of_new_node->X() - disp[0];
480  list_of_new_node->Y0() = list_of_new_node->Y() - disp[1];
481  list_of_new_node->Z0() = 0.0;
482  }
483  //cleaning unnecessary data
484  //in2.deinitialize();
485  //in2.initialize();
486  //free( in2.pointlist );
487 
488  //add preserved elements to the kratos
489  Properties::Pointer properties = ThisModelPart.GetMesh().pGetProperties(1);
490  nodes_begin = ThisModelPart.NodesBegin();
491  (ThisModelPart.Elements()).reserve(out2.numberoftriangles);
492 
493  for(int iii = 0; iii< out2.numberoftriangles; iii++)
494  {
495  int id = iii + 1;
496  int base = iii * 3;
497  Triangle2D3<Node > geom(
498  *( (nodes_begin + out2.trianglelist[base]-1).base() ),
499  *( (nodes_begin + out2.trianglelist[base+1]-1).base() ),
500  *( (nodes_begin + out2.trianglelist[base+2]-1).base() )
501  );
502 
503 
504 #ifdef _DEBUG
505  ModelPart::NodesContainerType& ModelNodes = ThisModelPart.Nodes();
506  if( *(ModelNodes).find( out2.trianglelist[base]).base() == *(ThisModelPart.Nodes().end()).base() )
507  KRATOS_THROW_ERROR(std::logic_error,"trying to use an inexisting node","");
508  if( *(ModelNodes).find( out2.trianglelist[base+1]).base() == *(ThisModelPart.Nodes().end()).base() )
509  KRATOS_THROW_ERROR(std::logic_error,"trying to use an inexisting node","");
510  if( *(ModelNodes).find( out2.trianglelist[base+2]).base() == *(ThisModelPart.Nodes().end()).base() )
511  KRATOS_THROW_ERROR(std::logic_error,"trying to use an inexisting node","");
512 
513 #endif
514 
515  Element::Pointer p_element = rReferenceElement.Create(id, geom, properties);
516  (ThisModelPart.Elements()).push_back(p_element);
517 
518  }
519  ThisModelPart.Elements().Sort();
520 
521  //filling the neighbour list
522  ModelPart::ElementsContainerType::const_iterator el_begin = ThisModelPart.ElementsBegin();
523  for(ModelPart::ElementsContainerType::const_iterator iii = ThisModelPart.ElementsBegin();
524  iii != ThisModelPart.ElementsEnd(); iii++)
525  {
526  //Geometry< Node >& geom = iii->GetGeometry();
527  int base = ( iii->Id() - 1 )*3;
528 
529  (iii->GetValue(NEIGHBOUR_ELEMENTS)).resize(3);
530  GlobalPointersVector< Element >& neighb = iii->GetValue(NEIGHBOUR_ELEMENTS);
531  for(int i = 0; i<3; i++)
532  {
533  int index = out2.neighborlist[base+i];
534  if(index > 0)
535  neighb(i) = GlobalPointer<Element>(&*(el_begin + index-1));
536  else
537  neighb(i) = Element::WeakPointer();
538  }
539  }
540  //identifying boundary, creating skin
541  IdentifyBoundary(ThisModelPart, rReferenceBoundaryCondition, properties, out2);
542 
543  KRATOS_WATCH("ln749");
544 
545  clean_triangulateio(in2);
546  KRATOS_WATCH("ln752");
547  clean_triangulateio(out2);
548  KRATOS_WATCH("ln754");
549  clean_triangulateio(vorout2);
550  KRATOS_WATCH("Finished remeshing with Trigen_PFEM_Refine")
551 
552  KRATOS_CATCH("")
553  }
554 
555 
559 
560 
564 
565 
569 
571  std::string Info() const override
572  {
573  return "";
574  }
575 
577  void PrintInfo(std::ostream& rOStream) const override {}
578 
580  void PrintData(std::ostream& rOStream) const override {}
581 
582 
586 
587 
589 
590 protected:
593 
594 
598  //KdtreeType mKdtree;
599 
603 
604 
608 
609 
613 
614 
618 
619 
623 
624 
626 
627 private:
630 
631 
635  boost::numeric::ublas::bounded_matrix<double,2,2> mJ; //local jacobian
636  boost::numeric::ublas::bounded_matrix<double,2,2> mJinv; //inverse jacobian
637  array_1d<double,2> mC; //center pos
638  array_1d<double,2> mRhs; //center pos
639  //EntitiesEraseProcess<Node>* mpNodeEraseProcess;
640 
641 
645  void RemoveCloseNodes(ModelPart& ThisModelPart, KdtreeType& nodes_tree1, EntitiesEraseProcess<Node>& node_erase, double& h_factor)
646  {
647  //unsigned int bucket_size = 20;
648 
649  //performing the interpolation - all of the nodes in this list will be preserved
650  unsigned int max_results = 100;
651  //PointerVector<PointType> res(max_results);
652  //NodeIterator res(max_results);
653  PointVector res(max_results);
654  DistanceVector res_distances(max_results);
655  Node work_point(0,0.0,0.0,0.0);
656 
657  unsigned int n_points_in_radius;
658  //radius means the distance, closer than which no node shall be allowd. if closer -> mark for erasing
659  double radius;
660 
661  for(ModelPart::NodesContainerType::const_iterator in = ThisModelPart.NodesBegin(); in != ThisModelPart.NodesEnd(); in++)
662  {
663  radius=h_factor*in->FastGetSolutionStepValue(NODAL_H);
664 
665  work_point[0]=in->X();
666  work_point[1]=in->Y();
667  work_point[2]=in->Z();
668 
669  n_points_in_radius = nodes_tree1.SearchInRadius(work_point, radius, res.begin(),res_distances.begin(), max_results);
670  if (n_points_in_radius>1)
671  {
672  if (in->FastGetSolutionStepValue(IS_BOUNDARY)==0.0 && in->FastGetSolutionStepValue(IS_STRUCTURE)==0.0)
673  {
674  //look if we are already erasing any of the other nodes
675  double erased_nodes = 0;
676  for(auto i=res.begin(); i!=res.begin() + n_points_in_radius ; i++)
677  erased_nodes += in->Is(TO_ERASE);
678 
679  if( erased_nodes < 1) //we cancel the node if no other nodes are being erased
680  in->Set(TO_ERASE,true);
681 
682  }
683  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)
684  {
685  //here we loop over the neighbouring nodes and if there are nodes
686  //with IS_BOUNDARY=1 which are closer than 0.2*nodal_h from our we remove the node we are considering
687  unsigned int k = 0;
688  unsigned int counter = 0;
689  for(auto i=res.begin(); i!=res.begin() + n_points_in_radius ; i++)
690  {
691  if ( (*i)->FastGetSolutionStepValue(IS_BOUNDARY,1)==1.0 && res_distances[k] < 0.2*radius && res_distances[k] > 0.0 )
692  {
693  // KRATOS_WATCH( res_distances[k] );
694  counter += 1;
695  }
696  k++;
697  }
698  if(counter > 0)
699  in->Set(TO_ERASE,true);
700  }
701  }
702 
703  }
704 
705 
706  node_erase.Execute();
707 
708  KRATOS_WATCH("Number of nodes after erasing")
709  KRATOS_WATCH(ThisModelPart.Nodes().size())
710  }
711 
712 
713  int PassAlphaShape(ModelPart& ThisModelPart, std::vector<int>& preserved_list1, unsigned int & el_number, double& my_alpha, struct triangulateio& out_mid)
714  {
715  //NOTE THAT preserved_list1 will be overwritten, only the elements that passed alpha-shaoe check will enter it
716 
717  //prepairing for alpha shape passing : creating necessary arrays
718  //list of preserved elements is created: at max el_number can be preserved (all elements)
719 
720 
721  array_1d<double,3> x1,x2,x3,xc;
722 
723  //int number_of_preserved_elems=0;
724  int number_of_preserved_elems=0;
725  int point_base;
726  //loop for passing alpha shape
727  for(unsigned int el = 0; el< el_number; el++)
728  {
729  int base = el * 3;
730 
731  //coordinates
732  point_base = (out_mid.trianglelist[base] - 1)*2;
733  x1[0] = out_mid.pointlist[point_base];
734  x1[1] = out_mid.pointlist[point_base+1];
735 
736  point_base = (out_mid.trianglelist[base+1] - 1)*2;
737  x2[0] = out_mid.pointlist[point_base];
738  x2[1] = out_mid.pointlist[point_base+1];
739 
740  point_base = (out_mid.trianglelist[base+2] - 1)*2;
741  x3[0] = out_mid.pointlist[point_base];
742  x3[1] = out_mid.pointlist[point_base+1];
743 
744  //here we shall temporarily save the elements and pass them afterwards to the alpha shape
745  Geometry<Node > temp;
746 
747  temp.push_back( *((ThisModelPart.Nodes()).find( out_mid.trianglelist[base]).base() ) );
748  temp.push_back( *((ThisModelPart.Nodes()).find( out_mid.trianglelist[base+1]).base() ) );
749  temp.push_back( *((ThisModelPart.Nodes()).find( out_mid.trianglelist[base+2]).base() ) );
750 
751  int number_of_structure_nodes = int( temp[0].FastGetSolutionStepValue(IS_STRUCTURE) );
752  number_of_structure_nodes += int( temp[1].FastGetSolutionStepValue(IS_STRUCTURE) );
753  number_of_structure_nodes += int( temp[2].FastGetSolutionStepValue(IS_STRUCTURE) );
754 
755  //check the number of nodes of boundary
756  int nfs = int( temp[0].FastGetSolutionStepValue(IS_FREE_SURFACE) );
757  nfs += int( temp[1].FastGetSolutionStepValue(IS_FREE_SURFACE) );
758  nfs += int( temp[2].FastGetSolutionStepValue(IS_FREE_SURFACE) );
759 
760  //check the number of nodes of boundary
761  int nfluid = int( temp[0].FastGetSolutionStepValue(IS_FLUID) );
762  nfluid += int( temp[1].FastGetSolutionStepValue(IS_FLUID) );
763  nfluid += int( temp[2].FastGetSolutionStepValue(IS_FLUID) );
764 
765  //check the number of nodes of boundary
766  // int nboundary = int( temp[0].FastGetSolutionStepValue(IS_BOUNDARY) );
767  // nboundary += int( temp[1].FastGetSolutionStepValue(IS_BOUNDARY) );
768  // nboundary += int( temp[2].FastGetSolutionStepValue(IS_BOUNDARY) );
769  //first check that we are working with fluid elements, otherwise throw an error
770  //if (nfluid!=3)
771  // KRATOS_THROW_ERROR(std::logic_error,"THATS NOT FLUID or NOT TRIANGLE!!!!!! ERROR","");
772  //otherwise perform alpha shape check
773 
774 
775  if(number_of_structure_nodes!=3) //if it is = 3 it is a completely fixed element -> do not add it
776  {
777  preserved_list1[el] = false;
778  if (nfs != 0 || nfluid != 3 ) //in this case it is close to the surface so i should use alpha shape
779  {
780 
781  if( AlphaShape(my_alpha,temp) && number_of_structure_nodes!=3) //if alpha shape says to preserve
782  {
783 // if(nboundary==3 && number_of_structure_nodes > 1 && nfs > 0) //if it is = 3 pressure problems -> do not add it
784 // {
785 // preserved_list1[el] = false;
786 // }
787 // else
788 // {
789  preserved_list1[el] = true;
790  number_of_preserved_elems += 1;
791 // }
792  }
793  }
794  else //internal triangle --- should be ALWAYS preserved
795  {
796  double bigger_alpha = my_alpha*10.0;
797  if( AlphaShape(bigger_alpha,temp) && number_of_structure_nodes!=3)
798  {
799 // if(nboundary==3 && number_of_structure_nodes > 1 && nfs > 0) //if it is = 3 pressure problems -> do not add it
800 // {
801 // preserved_list1[el] = false;
802 // }
803 // else
804 // {
805  preserved_list1[el] = true;
806  number_of_preserved_elems += 1;
807 // }
808  }
809  }
810 //qua inizia la parte cambiata
811 
812  if ( preserved_list1[el] == false && number_of_structure_nodes == 1 )
813  {
814  int noFSEdge = 0;
815  int Vertexiter[4] = {0,1,2,0};
816  for (int iVertex = 0 ; iVertex < 3 ; iVertex++ )
817  {
818  if ( ( temp[Vertexiter[iVertex]].FastGetSolutionStepValue(IS_FREE_SURFACE) && temp[Vertexiter[iVertex + 1]].FastGetSolutionStepValue(IS_FREE_SURFACE) )
819  || ( temp[Vertexiter[iVertex]].FastGetSolutionStepValue(IS_FREE_SURFACE) && temp[Vertexiter[iVertex + 1]].FastGetSolutionStepValue(IS_STRUCTURE) )
820  || ( temp[Vertexiter[iVertex]].FastGetSolutionStepValue(IS_STRUCTURE) && temp[Vertexiter[iVertex + 1]].FastGetSolutionStepValue(IS_FREE_SURFACE) )
821  )
822  {
823  noFSEdge++;
824  }
825  }
826  if (noFSEdge == 3)
827  {
828  double bigger_alpha = my_alpha*1.23;
829  if( AlphaShape(bigger_alpha,temp) && number_of_structure_nodes!=3)
830  {
831  // if(nboundary==3 && number_of_structure_nodes > 1 && nfs > 0) //if it is = 3 pressure problems -> do not add it
832  // {
833  // preserved_list1[el] = false;
834  // }
835  // else
836  // {
837  preserved_list1[el] = true;
838  number_of_preserved_elems += 1;
839  // }
840  }
841  }
842  }
843 
844 // fine della parte cambiata
845 
846  }
847  else
848  preserved_list1[el] = false;
849 
850  }
851  return number_of_preserved_elems;
852  }
853 
854 
855 
856 
857 
858  void IdentifyBoundary(ModelPart& ThisModelPart, Condition const& rReferenceBoundaryCondition, Properties::Pointer& properties, struct triangulateio& out2)
859  {
860 
861  //reset the boundary flag
862  for(ModelPart::NodesContainerType::const_iterator in = ThisModelPart.NodesBegin(); in!=ThisModelPart.NodesEnd(); in++)
863  {
864  in->FastGetSolutionStepValue(IS_BOUNDARY) = 0;
865  }
866  //filling the elemental neighbours list (from now on the elements list can not change)
867  ModelPart::ElementsContainerType::iterator elements_end = ThisModelPart.Elements().end();
868 
869  ThisModelPart.Elements().Unique();
870 
871  //now the boundary faces
872  for(ModelPart::ElementsContainerType::iterator iii = ThisModelPart.ElementsBegin(); iii != ThisModelPart.ElementsEnd(); iii++)
873  {
874  int base = ( iii->Id() - 1 )*3;
875 
876  ModelPart::ElementsContainerType::iterator el_neighb;
877  /*each face is opposite to the corresponding node number so
878  0 ----- 1 2
879  1 ----- 2 0
880  2 ----- 0 1
881  */
882 
884  //
885  //********************************************************************
886  //first face
887  el_neighb = (ThisModelPart.Elements()).find( out2.neighborlist[base] );
888  if( el_neighb == elements_end )
889  {
890  //std::cout << "node0" << std::endl;
891  //if no neighnour is present => the face is free surface
892  iii->GetGeometry()[1].FastGetSolutionStepValue(IS_BOUNDARY) = 1;
893  iii->GetGeometry()[2].FastGetSolutionStepValue(IS_BOUNDARY) = 1;
894 
895  //Generate condition
897  temp1.reserve(2);
898  temp1.push_back(iii->GetGeometry()(1));
899  temp1.push_back(iii->GetGeometry()(2));
900 
901  Geometry< Node >::Pointer cond = Geometry< Node >::Pointer(new Geometry< Node >(temp1) );
902  int id = (iii->Id()-1)*3;
903  Condition::Pointer p_cond = rReferenceBoundaryCondition.Create(id, temp1, properties);
904  ThisModelPart.Conditions().push_back(p_cond);
905 
906  }
907 
908  //********************************************************************
909  //second face
910  el_neighb = (ThisModelPart.Elements()).find( out2.neighborlist[base+1] );
911  //if( el != ThisModelPart.Elements().end() )
912  if( el_neighb == elements_end )
913  {
914  //if no neighnour is present => the face is free surface
915  iii->GetGeometry()[2].FastGetSolutionStepValue(IS_BOUNDARY) = 1;
916  iii->GetGeometry()[0].FastGetSolutionStepValue(IS_BOUNDARY) = 1;
917 
918  //Generate condition
920  temp1.reserve(2);
921  temp1.push_back(iii->GetGeometry()(2));
922  temp1.push_back(iii->GetGeometry()(0));
923 
924  Geometry< Node >::Pointer cond = Geometry< Node >::Pointer(new Geometry< Node >(temp1) );
925  int id = (iii->Id()-1)*3+1;
926  Condition::Pointer p_cond = rReferenceBoundaryCondition.Create(id, temp1, properties);
927  ThisModelPart.Conditions().push_back(p_cond);
928 
929 
930  }
931 
932  //********************************************************************
933  //third face
934  el_neighb = (ThisModelPart.Elements()).find( out2.neighborlist[base+2] );
935  if( el_neighb == elements_end )
936  {
937  //if no neighnour is present => the face is free surface
938  iii->GetGeometry()[0].FastGetSolutionStepValue(IS_BOUNDARY) = 1;
939  iii->GetGeometry()[1].FastGetSolutionStepValue(IS_BOUNDARY) = 1;
940 
941 // Generate condition
943  temp1.reserve(2);
944  temp1.push_back(iii->GetGeometry()(0));
945  temp1.push_back(iii->GetGeometry()(1));
946 
947  Geometry< Node >::Pointer cond = Geometry< Node >::Pointer(new Geometry< Node >(temp1) );
948  int id = (iii->Id()-1)*3+2;
949  Condition::Pointer p_cond = rReferenceBoundaryCondition.Create(id, temp1, properties);
950  ThisModelPart.Conditions().push_back(p_cond);
951 
952  }
953 
954 
955  }
956  }
957 
958 
959  //returns false if it should be removed
960  bool AlphaShape(double alpha_param, Geometry<Node >& pgeom)
961  //bool AlphaShape(double alpha_param, Triangle2D<Node >& pgeom)
962  {
963  KRATOS_TRY
964 
965 
966  double x0 = pgeom[0].X();
967  double x1 = pgeom[1].X();
968  double x2 = pgeom[2].X();
969 
970  double y0 = pgeom[0].Y();
971  double y1 = pgeom[1].Y();
972  double y2 = pgeom[2].Y();
973 
974  mJ(0,0)=2.0*(x1-x0);
975  mJ(0,1)=2.0*(y1-y0);
976  mJ(1,0)=2.0*(x2-x0);
977  mJ(1,1)=2.0*(y2-y0);
978 
979 
980  double detJ = mJ(0,0)*mJ(1,1)-mJ(0,1)*mJ(1,0);
981 
982  mJinv(0,0) = mJ(1,1);
983  mJinv(0,1) = -mJ(0,1);
984  mJinv(1,0) = -mJ(1,0);
985  mJinv(1,1) = mJ(0,0);
986 
987  bounded_matrix<double,2,2> check;
988 
989 //calculate average h
990  double h;
991  h = pgeom[0].FastGetSolutionStepValue(NODAL_H);
992  h += pgeom[1].FastGetSolutionStepValue(NODAL_H);
993  h += pgeom[2].FastGetSolutionStepValue(NODAL_H);
994  h *= 0.333333333;
995 
996 
997  if(detJ < 5e-3*h*h)
998  {
999  //std::cout << "detJ = " << detJ << std::endl;
1001  pgeom[0].GetSolutionStepValue(IS_BOUNDARY) = 1;
1002  pgeom[1].GetSolutionStepValue(IS_BOUNDARY) = 1;
1003  pgeom[2].GetSolutionStepValue(IS_BOUNDARY) = 1;
1004  return false;
1005  }
1006 
1007  else
1008  {
1009 
1010  double x0_2 = x0*x0 + y0*y0;
1011  double x1_2 = x1*x1 + y1*y1;
1012  double x2_2 = x2*x2 + y2*y2;
1013 
1014  //finalizing the calculation of the inverted matrix
1015  //std::cout<<"MATR INV"<<MatrixInverse(mJ)<<std::endl;
1016  mJinv /= detJ;
1017  //calculating the RHS
1018  mRhs[0] = (x1_2 - x0_2);
1019  mRhs[1] = (x2_2 - x0_2);
1020 
1021  //calculate position of the center
1022  noalias(mC) = prod(mJinv,mRhs);
1023 
1024  double radius = sqrt(pow(mC[0]-x0,2)+pow(mC[1]-y0,2));
1025 
1026 
1027  if (radius < h*alpha_param)
1028  {
1029  return true;
1030  }
1031  else
1032  {
1033  return false;
1034  }
1035  }
1036 
1037 
1038  KRATOS_CATCH("")
1039  }
1040  //AUXILLIARY FCTNS
1041  inline void CalculateCenterAndSearchRadius(const double x0, const double y0,
1042  const double x1, const double y1,
1043  const double x2, const double y2,
1044  double& xc, double& yc, double& R
1045  )
1046  {
1047  xc = 0.3333333333333333333*(x0+x1+x2);
1048  yc = 0.3333333333333333333*(y0+y1+y2);
1049 
1050  double R1 = (xc-x0)*(xc-x0) + (yc-y0)*(yc-y0);
1051  double R2 = (xc-x1)*(xc-x1) + (yc-y1)*(yc-y1);
1052  double R3 = (xc-x2)*(xc-x2) + (yc-y2)*(yc-y2);
1053 
1054  R = R1;
1055  if(R2 > R) R = R2;
1056  if(R3 > R) R = R3;
1057 
1058  R = sqrt(R);
1059  }
1060 
1061  inline double CalculateVol( const double x0, const double y0,
1062  const double x1, const double y1,
1063  const double x2, const double y2
1064  )
1065  {
1066  return 0.5*( (x1-x0)*(y2-y0)- (y1-y0)*(x2-x0) );
1067  }
1068 
1069  inline bool CalculatePosition( const double x0, const double y0,
1070  const double x1, const double y1,
1071  const double x2, const double y2,
1072  const double xc, const double yc,
1073  array_1d<double,3>& N
1074  )
1075  {
1076  double area = CalculateVol(x0,y0,x1,y1,x2,y2);
1077 
1078  if(area < 0.000000000001)
1079  {
1080  KRATOS_THROW_ERROR(std::logic_error,"element with zero area found","");
1081  }
1082 
1083 
1084 
1085  N[0] = CalculateVol(x1,y1,x2,y2,xc,yc) / area;
1086  N[1] = CalculateVol(x2,y2,x0,y0,xc,yc) / area;
1087  N[2] = CalculateVol(x0,y0,x1,y1,xc,yc) / area;
1088 
1089  /* N[0] = CalculateVol(x0,y0,x1,y1,xc,yc) * inv_area;
1090  N[1] = CalculateVol(x1,y1,x2,y2,xc,yc) * inv_area;
1091  N[2] = CalculateVol(x2,y2,x0,y0,xc,yc) * inv_area;*/
1092  double tol = 1e-4;
1093  double upper_limit = 1.0+tol;
1094  double lower_limit = -tol;
1095 
1096  if(N[0] >= lower_limit && N[1] >= lower_limit && N[2] >= lower_limit && N[0] <= upper_limit && N[1] <= upper_limit && N[2] <= upper_limit) //if the xc yc is inside the triangle
1097  //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
1098  return true;
1099 
1100  return false;
1101  }
1102 
1103  void Interpolate( Triangle2D3<Node >& geom, const array_1d<double,3>& N,
1104  unsigned int step_data_size,
1105  Node::Pointer pnode)
1106  {
1107  unsigned int buffer_size = pnode->GetBufferSize();
1108  //KRATOS_WATCH("Buffer size")
1109  //KRATOS_WATCH(buffer_size)
1110 
1111  for(unsigned int step = 0; step<buffer_size; step++)
1112  {
1113 
1114  //getting the data of the solution step
1115  double* step_data = (pnode)->SolutionStepData().Data(step);
1116 
1117 
1118  double* node0_data = geom[0].SolutionStepData().Data(step);
1119  double* node1_data = geom[1].SolutionStepData().Data(step);
1120  double* node2_data = geom[2].SolutionStepData().Data(step);
1121 
1122  //copying this data in the position of the vector we are interested in
1123  for(unsigned int j= 0; j<step_data_size; j++)
1124  {
1125 
1126  step_data[j] = N[0]*node0_data[j] + N[1]*node1_data[j] + N[2]*node2_data[j];
1127 
1128 
1129  }
1130  }
1131  if (N[0]==0.0 && N[1]==0.0 && N[2]==0.0)
1132  KRATOS_THROW_ERROR(std::logic_error,"SOMETHING's wrong with the added nodes!!!!!! ERROR","");
1133 
1134  //if ( pnode->FastGetSolutionStepValue(BULK_MODULUS)==0.0)
1135  // KRATOS_THROW_ERROR(std::logic_error,"SOMETHING's wrong with the added nodes!!!!!! ERROR","");
1136 
1137  //now we assure that the flag variables are set coorect!! since we add nodes inside of the fluid volume only
1138  //we manually reset the IS_BOUNDARY, IS_FLUID, IS_STRUCTURE, IS_FREE_SURFACE values in a right way
1139  //not to have values, like 0.33 0.66 resulting if we would have been interpolating them in the same way
1140  //as the normal variables, like Velocity etc
1141 
1142 
1143  pnode->FastGetSolutionStepValue(IS_BOUNDARY)=0.0;
1144  pnode->FastGetSolutionStepValue(IS_STRUCTURE)=0.0;
1145  pnode->FastGetSolutionStepValue(IS_INTERFACE)=0.0;
1146  pnode->Set(TO_ERASE,false);
1147  pnode->FastGetSolutionStepValue(IS_FREE_SURFACE)=0.0;
1148  pnode->FastGetSolutionStepValue(IS_FLUID)=1.0;
1149  }
1150 
1151  void initialize_triangulateio( triangulateio& tr )
1152  {
1153  tr.pointlist = (REAL*) nullptr;
1154  tr.pointattributelist = (REAL*) nullptr;
1155  tr.pointmarkerlist = (int*) nullptr;
1156  tr.numberofpoints = 0;
1157  tr.numberofpointattributes = 0;
1158  tr.trianglelist = (int*) nullptr;
1159  tr.triangleattributelist = (REAL*) nullptr;
1160  tr.trianglearealist = (REAL*) nullptr;
1161  tr.neighborlist = (int*) nullptr;
1162  tr.numberoftriangles = 0;
1163  tr.numberofcorners = 3;
1164  tr.numberoftriangleattributes = 0;
1165  tr.segmentlist = (int*) nullptr;
1166  tr.segmentmarkerlist = (int*) nullptr;
1167  tr.numberofsegments = 0;
1168  tr.holelist = (REAL*) nullptr;
1169  tr.numberofholes = 0;
1170  tr.regionlist = (REAL*) nullptr;
1171  tr.numberofregions = 0;
1172  tr.edgelist = (int*) nullptr;
1173  tr.edgemarkerlist = (int*) nullptr;
1174  tr.normlist = (REAL*) nullptr;
1175  tr.numberofedges = 0;
1176  };
1177 
1178  void clean_triangulateio( triangulateio& tr )
1179  {
1180  if(tr.pointlist != nullptr) free(tr.pointlist );
1181  if(tr.pointattributelist != nullptr) free(tr.pointattributelist );
1182  if(tr.pointmarkerlist != nullptr) free(tr.pointmarkerlist );
1183  if(tr.trianglelist != nullptr) free(tr.trianglelist );
1184  if(tr.triangleattributelist != nullptr) free(tr.triangleattributelist );
1185  if(tr.trianglearealist != nullptr) free(tr.trianglearealist );
1186  if(tr.neighborlist != nullptr) free(tr.neighborlist );
1187  if(tr.segmentlist != nullptr) free(tr.segmentlist );
1188  if(tr.segmentmarkerlist != nullptr) free(tr.segmentmarkerlist );
1189  if(tr.holelist != nullptr) free(tr.holelist );
1190  if(tr.regionlist != nullptr) free(tr.regionlist );
1191  if(tr.edgelist != nullptr) free(tr.edgelist );
1192  if(tr.edgemarkerlist != nullptr) free(tr.edgemarkerlist );
1193  if(tr.normlist != nullptr) free(tr.normlist );
1194  };
1198 
1199 
1203 
1204 
1208 
1209 
1213 
1216 
1217 
1219 
1220 }; // Class TriGenPFEMModelerVMS
1221 
1223 
1226 
1227 
1231 
1232 
1234 inline std::istream& operator >> (std::istream& rIStream,
1235  TriGenPFEMModelerVMS& rThis);
1236 
1238 inline std::ostream& operator << (std::ostream& rOStream,
1239  const TriGenPFEMModelerVMS& rThis)
1240 {
1241  rThis.PrintInfo(rOStream);
1242  rOStream << std::endl;
1243  rThis.PrintData(rOStream);
1244 
1245  return rOStream;
1246 }
1248 
1249 
1250 } // namespace Kratos.
1251 
1252 #endif // KRATOS_TRIGEN_PFEM_MODELER_VMS_H_INCLUDED defined
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
Short class definition.
Definition: bucket.h:57
Base class for all Conditions.
Definition: condition.h:59
Geometry< NodeType >::PointsArrayType NodesArrayType
definition of nodes container type, redefined from GeometryType
Definition: condition.h:86
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.
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
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
void reserve(size_type dim)
Definition: pointer_vector.h:319
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.h:64
std::vector< double > DistanceVector
Definition: trigen_pfem_refine.h:75
std::vector< PointType::Pointer > PointVector
Definition: trigen_pfem_refine.h:73
Short class definition.
Definition: trigen_pfem_refine_vms.h:63
~TriGenPFEMModelerVMS() override=default
Destructor.
std::vector< double > DistanceVector
Definition: trigen_pfem_refine_vms.h:74
PointVector::iterator PointIterator
Definition: trigen_pfem_refine_vms.h:73
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: trigen_pfem_refine_vms.h:577
std::string Info() const override
Turn back information as a string.
Definition: trigen_pfem_refine_vms.h:571
KRATOS_CLASS_POINTER_DEFINITION(TriGenPFEMModelerVMS)
Pointer definition of TriGenModeler.
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_vms.h:107
Node::Pointer PointPointerType
Definition: trigen_pfem_refine_vms.h:71
std::vector< double >::iterator DistanceIterator
Definition: trigen_pfem_refine_vms.h:75
TriGenPFEMModelerVMS()
Default constructor.
Definition: trigen_pfem_refine_vms.h:84
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: trigen_pfem_refine_vms.h:580
Tree< KDTreePartition< BucketType > > KdtreeType
Definition: trigen_pfem_refine_vms.h:77
std::vector< PointType::Pointer > PointVector
Definition: trigen_pfem_refine_vms.h:72
Bucket< 3, PointType, PointVector, PointPointerType, PointIterator, DistanceIterator > BucketType
Definition: trigen_pfem_refine_vms.h:76
Node PointType
Definition: trigen_pfem_refine_vms.h:70
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
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
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
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
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
int tol
Definition: hinsberg_optimization.py:138
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
namespace
Definition: array_1d.h:793
integer i
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31