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.
tetgen_pfem_refine_face.h
Go to the documentation of this file.
1 //
2 // Project Name: Kratos
3 // Last Modified by: $Author: kazem $
4 // Date: $Date: 2009-01-15 14:50:34 $
5 // Revision: $Revision: 1.8 $
6 //
7 
8 
9 
10 
11 #if !defined(KRATOS_TETGEN_PFEM_REFINE_FACE_H_INCLUDED )
12 #define KRATOS_TETGEN_PFEM_REFINE_FACE_H_INCLUDED
13 
14 
15 
16 // System includes
17 #include <string>
18 #include <iostream>
19 #include <cstdlib>
20 #include <boost/timer.hpp>
21 
22 
23 
24 #include "tetgen.h" // Defined tetgenio, tetrahedralize().
25 
26 // Project includes
27 #include "includes/define.h"
28 #include "utilities/geometry_utilities.h"
29 #include "includes/model_part.h"
34 
36 //#include "containers/bucket.h"
37 //#include "containers/kd_tree.h"
38 //#include "external_includes/trigen_refine.h"
39 namespace Kratos
40 {
41 
42 
45 
49 
53 
57 
61 
63 
66 {
67 public:
70 
73 
77 
80  mJ(ZeroMatrix(3,3)), //local jacobian
81  mJinv(ZeroMatrix(3,3)), //inverse jacobian
82  mc(ZeroVector(3)), //dimension = number of nodes
83  mRhs(ZeroVector(3)) {} //dimension = number of nodes
84 
86  virtual ~TetGenPfemRefineFace() = default;
87 
88 
92 
93 
97 
98 
99  //*******************************************************************************************
100  //*******************************************************************************************
102  ModelPart& ThisModelPart , ModelPart::ElementsContainerType& rElements,
103  Element const& rReferenceElement,
104  Condition const& rReferenceBoundaryCondition,
105  EntitiesEraseProcess<Node>& node_erase, bool rem_nodes = true, bool add_nodes=true,
106  double alpha_param = 1.4, double h_factor=0.5)
107  {
108 
109  KRATOS_TRY
110 //KRATOS_WATCH(ThisModelPart);
111 //KRATOS_WATCH(ThisModelPart.NodesBegin()->Id());
112 //KRATOS_WATCH(ThisModelPart.NodesBegin()->GetSolutionStepValue(IS_FREE_SURFACE));
113  if (ThisModelPart.NodesBegin()->SolutionStepsDataHas(IS_FREE_SURFACE)==false )
114  KRATOS_THROW_ERROR(std::logic_error,"Add ----IS_FREE_SURFACE---- variable!!!!!! ERROR","");
115  if (ThisModelPart.NodesBegin()->SolutionStepsDataHas(IS_STRUCTURE)==false )
116  KRATOS_THROW_ERROR(std::logic_error,"Add ----IS_STRUCTURE---- variable!!!!!! ERROR","");
117  if (ThisModelPart.NodesBegin()->SolutionStepsDataHas(IS_BOUNDARY)==false )
118  KRATOS_THROW_ERROR(std::logic_error,"Add ----IS_BOUNDARY---- variable!!!!!! ERROR","");
119  if (ThisModelPart.NodesBegin()->SolutionStepsDataHas(IS_FLUID)==false )
120  KRATOS_THROW_ERROR(std::logic_error,"Add ----IS_FLUID---- variable!!!!!! ERROR","");
121  if (ThisModelPart.NodesBegin()->SolutionStepsDataHas(IS_WATER)==false )
122  KRATOS_THROW_ERROR(std::logic_error,"Add ----IS_WATER---- variable!!!!!! ERROR","");
123  if (ThisModelPart.NodesBegin()->SolutionStepsDataHas(IS_INTERFACE)==false )
124  KRATOS_THROW_ERROR(std::logic_error,"Add ----IS_INTERFACE---- variable!!!!!! ERROR","");
125 
126  KRATOS_WATCH(" HELLO TETGEN PFEM REFINE FACE")
127 
128 //KRATOS_WATCH("TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT");
129  //****************************************************
130  //filling the interface list before removing the elements and nodes
131  //****************************************************
132  std::vector <int> mid_face_list;
133  int face_num = 0;
134  FaceDetecting(ThisModelPart, rElements, mid_face_list, face_num, h_factor);
135 // KRATOS_WATCH("AFTER FACEDETECTING");
136 
137  //ContactMesh(rElements);
138 // KRATOS_WATCH("AFTER contact mesh");
139  //KRATOS_WATCH(face_num);
140  //KRATOS_WATCH(rElements.size());
141  int str_size = rElements.size();
142  /*for(int ii=0; ii<face_num; ++ii)
143  {
144  int cnt = 3*ii;
145  KRATOS_WATCH(mid_face_list[cnt]);
146  KRATOS_WATCH(mid_face_list[cnt+1]);
147  KRATOS_WATCH(mid_face_list[cnt+2]);
148  }*/
150  //clearing elements
151 
152  ThisModelPart.Elements().clear();
153  ThisModelPart.Conditions().clear();
154 
155  boost::timer auxiliary;
157  typedef Node PointType;
158  typedef Node::Pointer PointPointerType;
159  //typedef PointerVector<PointType> PointVector;
160  typedef std::vector<PointType::Pointer> PointVector;
161  typedef PointVector::iterator PointIterator;
162  typedef std::vector<double> DistanceVector;
163  typedef std::vector<double>::iterator DistanceIterator;
164 
165  int step_data_size = ThisModelPart.GetNodalSolutionStepDataSize();
166 
167  // bucket types
168  //typedef Bucket<3, PointType, ModelPart::NodesContainerType, PointPointerType, PointIterator, DistanceIterator > BucketType;
170  // bucket types
171 // typedef Bucket<3, PointType, PointVector, PointPointerType, PointIterator, DistanceIterator > BucketType;
172 
173 
174  //*************
175  // DynamicBins;
176  //typedef Tree< KDTreePartition<BucketType> > kd_tree; //Kdtree;
177  typedef Tree< StaticBins > kd_tree; //Binstree;
178  unsigned int bucket_size = 64;
179 
180  //performing the interpolation - all of the nodes in this list will be preserved
181  unsigned int max_results = 8000;
182  //PointerVector<PointType> res(max_results);
183  //NodeIterator res(max_results);
184  PointVector res(max_results);
185  DistanceVector res_distances(max_results);
186  Node work_point(0,0.0,0.0,0.0);
187  //if the remove_node switch is activated, we check if the nodes got too close
188  if (rem_nodes==true)
189  {
190 
191  PointVector list_of_nodes;
192  list_of_nodes.reserve(ThisModelPart.Nodes().size());
193  for(ModelPart::NodesContainerType::iterator i_node = ThisModelPart.NodesBegin() ; i_node != ThisModelPart.NodesEnd() ; i_node++)
194  {
195  (list_of_nodes).push_back(*(i_node.base()));
196  //(list_of_nodes).push_back(i_node.base());
197  }
198 
199  kd_tree nodes_tree1(list_of_nodes.begin(),list_of_nodes.end(), bucket_size);
200  //std::cout<<nodes_tree2<<std::endl;
201 
202  unsigned int n_points_in_radius;
203  //radius means the distance, closer than which no node shall be allowd. if closer -> mark for erasing
204  double radius;
205 
206  for(ModelPart::NodesContainerType::const_iterator in = ThisModelPart.NodesBegin();
207  in != ThisModelPart.NodesEnd(); in++)
208  {
209  radius=h_factor*in->FastGetSolutionStepValue(NODAL_H);
210 
211  work_point[0]=in->X();
212  work_point[1]=in->Y();
213  work_point[2]=in->Z();
214 
215  n_points_in_radius = nodes_tree1.SearchInRadius(work_point, radius, res.begin(),res_distances.begin(), max_results);
216  if (n_points_in_radius>1)
217  {
218  if (in->FastGetSolutionStepValue(IS_BOUNDARY)==0.0 && in->FastGetSolutionStepValue(IS_STRUCTURE)==0.0&& in->FastGetSolutionStepValue(IS_INTERFACE)==0.0)
219  {
220 
221  double erased_nodes = 0;
222  for(auto i=res.begin(); i!=res.begin() + n_points_in_radius ; i++)
223  erased_nodes += (*i)->Is(TO_ERASE);
224 
225 
226  if( erased_nodes < 1.0) //we cancel the node if no other nodes are being erased
227  in->Set(TO_ERASE,true);
228 
229  }
230  }
231  /*
232  if (in->Is(TO_ERASE)!=1.0)
233  {
234  for(PointIterator i=res.begin(); i!=res.begin() + n_points_in_radius; i++)
235  {
236  // not to remove the boundary nodes
237  if ( (*i)->FastGetSolutionStepValue(IS_BOUNDARY)!=1.0 )
238  {
239  (*i)->Set(TO_ERASE,false);
240  KRATOS_WATCH("ERASING NODE!!!!!!!!!!!")
241  }
242  }
243  }
244  */
245  }
246  //not erase INTERFACE node // flag_variable == 5.= arre sensors
247  for(ModelPart::NodesContainerType::const_iterator in = ThisModelPart.NodesBegin();
248  in != ThisModelPart.NodesEnd(); in++)
249  {
250  if((in)->FastGetSolutionStepValue(IS_INTERFACE) == 1.0 || (in)->FastGetSolutionStepValue(IS_STRUCTURE) == 1.0 || (in)->FastGetSolutionStepValue(FLAG_VARIABLE) == 5.0 )
251  in->Set(TO_ERASE, false);
252 
253  }
254 
255 
256  node_erase.Execute();
257 
258  // KRATOS_WATCH("Number of nodes after erasing")
259  //KRATOS_WATCH(ThisModelPart.Nodes().size())
260  }
264 
265 
266  tetgenio in, out, in2, outnew;
267 //in.initialize();
268  tetgenio::facet *f;
269  tetgenio::polygon *p;
270 
271 
272  // All indices start from 1.
273  in.firstnumber = 1;
274  in.numberofpoints = ThisModelPart.Nodes().size();
275  in.pointlist = new REAL[in.numberofpoints * 3];
276 
277  //writing the point coordinates in a vector
278  ModelPart::NodesContainerType::iterator nodes_begin = ThisModelPart.NodesBegin();
279 
280  std::vector <int> reorder_mid_face_list;
281  if(face_num != 0)
282  reorder_mid_face_list.resize(face_num*3,false);
283 
284 
285  //reorder node Ids
286  for(unsigned int i = 0; i<ThisModelPart.Nodes().size(); i++)
287  {
288  int pr_id = (nodes_begin + i)->Id();
289 
290  (nodes_begin + i)->SetId(i+1);
291 // (nodes_begin + i)->Id() = i+1;
292 
293  //reorder face list
294  if(face_num != 0)
295  {
296  if( (nodes_begin + i)->FastGetSolutionStepValue(IS_INTERFACE) == 1.0 || (nodes_begin + i)->FastGetSolutionStepValue(IS_STRUCTURE) == 1.0 )
297  {
298  for(int jj = 0; jj < face_num*3; ++jj)
299  if( mid_face_list[jj] == pr_id)
300  reorder_mid_face_list[jj] = (nodes_begin + i)->Id();
301 
302  }
303  }
304 
305 
306  }
307 
308  //give the corrdinates to the mesher
309  for(unsigned int i = 0; i<ThisModelPart.Nodes().size(); i++)
310  {
311  int base = i*3;
312  in.pointlist[base] = (nodes_begin + i)->X();
313  in.pointlist[base+1] = (nodes_begin + i)->Y();
314  in.pointlist[base+2] = (nodes_begin + i)->Z();
315  }
316 
317  //***********preserving the list of facets for
318  //surface mesh file .smesh
319 
320  /* if(face_num != 0){
321  in.numberoftrifaces = face_num;
322  in.trifacelist = new int[in.numberoftrifaces * 3 ];
323  in.trifacemarkerlist = new int[in.numberoftrifaces ];
324  //in2.segmentlist = seg_list;
325  for( int ii = 0; ii < face_num*3; ++ii)
326  in.trifacelist[ii] = reorder_mid_face_list[ii];
327 
328  for( int jj = 0; jj < face_num ; ++jj)
329  in.trifacemarkerlist[jj] = 1;
330 
331  }*/
332  /* in.numberoffacets = 0;
333  in.facetlist = NULL;
334  in.numberofholes = 0;
335  in.holelist = NULL;*/
336 
337  if(face_num != 0)
338  {
339  int cnt = 0;
340  in.numberoffacets = face_num;
341  in.facetmarkerlist = new int[in.numberoffacets];
342  in.facetlist = new tetgenio::facet[in.numberoffacets];
343  for(int ii=0; ii<face_num; ++ii)
344  {
345  f = &in.facetlist[ii];
346  f->numberofpolygons = 1;
347  f->polygonlist = new tetgenio::polygon[f->numberofpolygons];
348  f->numberofholes = 0;
349  f->holelist = nullptr;
350 
351 
352  p = &f->polygonlist[0];
353  p->numberofvertices = 3;
354  p->vertexlist = new int[p->numberofvertices];
355  p->vertexlist[0] = reorder_mid_face_list[cnt];
356  p->vertexlist[1] = reorder_mid_face_list[cnt + 1];
357  p->vertexlist[2] = reorder_mid_face_list[cnt + 2];
358  cnt +=3;
359 
360  if( ii < str_size)
361  in.facetmarkerlist[ii] = 5;
362  else
363  in.facetmarkerlist[ii] = 10;
364  }
365 
366 
367 
368  //holes
369  in.numberofholes = 0;
370  in.holelist = nullptr;
371 
372  //regions
373  in.numberofregions = 1;
374  in.regionlist = new REAL[in.numberofregions * 5];
375 
376  in.regionlist[0] = 0.0;
377  in.regionlist[1] = 0.137;//0.137
378  in.regionlist[2] = 0.0;
379 
380  in.regionlist[3] = -20;
381  in.regionlist[4] = -1;
382 
383 
384 
385  }
386 
387  //***********end of facets
388 // KRATOS_WATCH(in.numberoffacets);
389  /* int cnt = 0;
390  for(int ii=0; ii<face_num; ii++)
391 
392  {
393  KRATOS_WATCH("begin");
394  KRATOS_WATCH(ii);
395  KRATOS_WATCH(reorder_mid_face_list[cnt]);
396  KRATOS_WATCH(reorder_mid_face_list[cnt + 1]);
397  KRATOS_WATCH(reorder_mid_face_list[cnt + 2]);
398  KRATOS_WATCH("end");
399  cnt +=3;
400  }*/
401  //in.save_nodes("first_mesh_in");
402  //in.save_poly("first_mesh_in");
403  //char tetgen_options[] = "VMYYJ";pA
404  char tetgen_options[] = "pAYYjQ";
405 
406 //KRATOS_WATCH(in.numberofpoints);
407 
408  tetrahedralize(tetgen_options, &in, &out); //with option to remove slivers
409 
410  //out.save_nodes("first_mesh_out");
411  //out.save_elements("first_mesh_out");
412 // out.save_faces("first_mesh_out");
413 
414 // KRATOS_WATCH(out.numberofpoints);
415 // KRATOS_WATCH(out.numberoftetrahedra);
416  KRATOS_WATCH("FINISH FIRST MESH GENERATION");
417  double first_part_time = auxiliary.elapsed();
418  std::cout << "mesh generation time = " << first_part_time << std::endl;
419 
420  //generate Kratos Tetrahedra3D4
421  int el_number = out.numberoftetrahedra;
422 
423  boost::timer alpha_shape_time;
424  //calculate r , center for all of the elements
425  std::vector<int> preserved_list(el_number);
426  array_1d<double,3> x1,x2,x3,x4, xc;
427  int point_base;
428  int number_of_preserved_elems = 0;
429  int num_of_input = in.numberofpoints;
430 
431 
432  for(int el = 0; el< el_number; el++)
433  {
434  int base = el * 4;
435  if(out.tetrahedronlist[base] > num_of_input ||
436  out.tetrahedronlist[base + 1] > num_of_input ||
437  out.tetrahedronlist[base + 2] > num_of_input ||
438  out.tetrahedronlist[base + 3] > num_of_input)
439  preserved_list[el] = false; //not preseve element with Steiner point!!
440  else
441  {
442  preserved_list[el] = true; //preserve!!
443  number_of_preserved_elems += 1;
444  }
445  /* preserved_list[el] = true; //preserve!!
446  number_of_preserved_elems += 1;*/
447  }
448 
449 
450  std::cout << "time for passing alpha shape" << alpha_shape_time.elapsed() << std::endl;
451 
452 //KRATOS_WATCH(number_of_preserved_elems);
453  in2.firstnumber = 1;
454  in2.numberofpoints = ThisModelPart.Nodes().size();
455  in2.pointlist = new REAL[in2.numberofpoints * 3];
456 
457  for(unsigned int i = 0; i<ThisModelPart.Nodes().size(); i++)
458  {
459  int base = i*3;
460  in2.pointlist[base] = (nodes_begin + i)->X();
461  in2.pointlist[base+1] = (nodes_begin + i)->Y();
462  in2.pointlist[base+2] = (nodes_begin + i)->Z();
463  }
464  std::cout << "qui" << std::endl;
465  in2.numberoftetrahedra = number_of_preserved_elems;
466  in2.tetrahedronlist = new int[in2.numberoftetrahedra * 4];
467  in2.tetrahedronvolumelist = new double[in2.numberoftetrahedra];
468 
469  in2.numberoftetrahedronattributes = 1;
470  in2.tetrahedronattributelist = new REAL[in2.numberoftetrahedra * in2.numberoftetrahedronattributes ];
471 
472 
473  int counter = 0;
474  for(int el = 0; el< el_number; el++)
475  {
476  if( preserved_list[el] )
477  {
478 
479  //saving the compact element list
480 
481  int new_base = counter*4;
482  int old_base = el*4;
483  in2.tetrahedronlist[new_base] = out.tetrahedronlist[old_base];
484  in2.tetrahedronlist[new_base+1] = out.tetrahedronlist[old_base+1];
485  in2.tetrahedronlist[new_base+2] = out.tetrahedronlist[old_base+2];
486  in2.tetrahedronlist[new_base+3] = out.tetrahedronlist[old_base+3];
487 
488 
489 
490  //calculate the prescribed h
491  double prescribed_h = (nodes_begin + out.tetrahedronlist[old_base]-1)->FastGetSolutionStepValue(NODAL_H);
492  prescribed_h += (nodes_begin + out.tetrahedronlist[old_base+1]-1)->FastGetSolutionStepValue(NODAL_H);
493  prescribed_h += (nodes_begin + out.tetrahedronlist[old_base+2]-1)->FastGetSolutionStepValue(NODAL_H);
494  prescribed_h += (nodes_begin + out.tetrahedronlist[old_base+3]-1)->FastGetSolutionStepValue(NODAL_H);
495  prescribed_h *= 0.25;
496  //if h is the height of a perfect tetrahedra, the edge size is edge = sqrt(3/2) h
497  //filling in the list of "IDEAL" tetrahedron volumes=1/12 * (edge)^3 * sqrt(2)~0.11785* h^3=
498  //0.2165063509*h^3
499 
500  in2.tetrahedronvolumelist[counter] = 0.217*prescribed_h*prescribed_h*prescribed_h;
501  //in2.tetrahedronvolumelist[counter] = 0.0004;
502  //KRATOS_WATCH(in2.tetrahedronvolumelist[counter])
503 
504  in2.tetrahedronattributelist[counter] = out.tetrahedronattributelist[el];
505 
506 
507 
508 
509 
510  counter += 1;
511 
512 
513 
514  }
515 
516  }
517 
518 //KRATOS_WATCH("RIGHT BEFORE DEINITIALIZE");
519  //freeing unnecessary memory
520  //clean_tetgenio(in);
521  in.deinitialize();
522  // out.deinitialize();
523 
524  in.initialize();
525 
526  //setting the new new ids in a aux vector
527 // tetgenio in2;
528 
529 
530  //creating a new mesh
531  boost::timer mesh_recreation_time;
532 
533 
534  //freeing unnecessary memory
535  out.deinitialize();
536  out.initialize();
537 
538 // in2.save_nodes("second_mesh_in2");
539 // in2.save_elements("second_mesh_in2");
540  KRATOS_WATCH("RIGHT BEFORE ADAPTIVE MESHER");
541  //HERE WE ADD THE VOLUME CONSTRAINT -the desired volume of the equidistant tertrahedra
542  //based upon average nodal_h (that is the "a" switch
543  //char regeneration_options[] = "rQJYq1.8anS";
544  if (add_nodes==true)
545  {
546  char mesh_regen_opts[] = "rMfjYYaq2.5nQ";//a
547  tetrahedralize(mesh_regen_opts, &in2, &outnew);
548  KRATOS_WATCH("Adaptive remeshing executed")
549  }
550  else
551  {
552  char mesh_regen_opts[] = "rjYYnS";
553  tetrahedralize(mesh_regen_opts, &in2, &outnew);
554  KRATOS_WATCH("Non-Adaptive remeshing executed")
555  }
556 
557  //q - creates quality mesh, with the default radius-edge ratio set to 2.0
558 // outnew.save_nodes("second_mesh_outnew");
559 // outnew.save_elements("second_mesh_outnew");
560 // outnew.save_faces("second_mesh_outnew");
561 // outnew.save_neighbors("second_mesh_outnew");
562 
563  std::cout << "mesh recreation time" << mesh_recreation_time.elapsed() << std::endl;
564 
565 
566  //PAVEL
567 
568  //putting the new nodes in a spatial container
569  //PointerVector< Element >& neighb
570 
571  /*
572  typedef Node PointType;
573  typedef Node::Pointer PointPointerType;
574  typedef std::vector<PointType::Pointer> PointVector;
575  typedef PointVector::iterator PointIterator;
576  typedef std::vector<double> DistanceVector;
577  typedef std::vector<double>::iterator DistanceIterator;
578 
579  int step_data_size = ThisModelPart.GetNodalSolutionStepDataSize();
580 
581  // bucket types
582  typedef Bucket<3, PointType, PointVector, PointPointerType, PointIterator, DistanceIterator > BucketType;
583  typedef Bins< 3, PointType, PointVector, PointPointerType, PointIterator, DistanceIterator > StaticBins;
584 
585  // DynamicBins;
586  typedef Tree< KDTreePartition<BucketType> > kd_tree; //Kdtree;
587  //typedef Tree< StaticBins > Bin; //Binstree;
588  */
589  PointVector list_of_new_nodes;
590 
591  Node::DofsContainerType& reference_dofs = (ThisModelPart.NodesBegin())->GetDofs();
592 
593  int n_points_before_refinement = in2.numberofpoints;
594  //if the refinement was performed, we need to add it to the model part.
595  if (outnew.numberofpoints>n_points_before_refinement)
596  {
597  for(int i = n_points_before_refinement; i<outnew.numberofpoints; i++)
598  {
599  int id=i+1;
600  int base = i*3;
601  double& x= outnew.pointlist[base];
602  double& y= outnew.pointlist[base+1];
603  double& z= outnew.pointlist[base+2];
604 
605  Node::Pointer pnode = ThisModelPart.CreateNewNode(id,x,y,z);
606 
607  //putting the new node also in an auxiliary list
608  //KRATOS_WATCH("adding nodes to list")
609  list_of_new_nodes.push_back( pnode );
610 
611  //std::cout << "new node id = " << pnode->Id() << std::endl;
612  //generating the dofs
613  for(Node::DofsContainerType::iterator iii = reference_dofs.begin(); iii != reference_dofs.end(); iii++)
614  {
615  Node::DofType &rDof = **iii;
616  Node::DofType::Pointer p_new_dof = pnode->pAddDof( rDof );
617 
618  (p_new_dof)->FreeDof();
619  }
620  //assigning interface flag of segment
621  //segment are assigned to 5 so every new node on them have also flag 5
622  /* KRATOS_WATCH("INSIDE NEW NODE");
623  if(outnew.pointmarkerlist[i] == 5)
624  {
625  KRATOS_WATCH("INSIDE NEW NODE INTERFACE");
626  pnode->FastGetSolutionStepValue(IS_INTERFACE) = 1.0;
627  KRATOS_WATCH("new interface on FACE is detected");
628  //KRATOS_WATCH(pnode->Id());
629  }
630  else
631  pnode->FastGetSolutionStepValue(IS_INTERFACE) = 0.0;*/
632 
633  }
634  }
635 
636  std::cout << "During refinement we added " << outnew.numberofpoints-n_points_before_refinement<< "nodes " <<std::endl;
637 
638 
639  bucket_size = 64;//20;
640 
641  //performing the interpolation - all of the nodes in this list will be preserved
642  max_results = list_of_new_nodes.size();//800;
643  PointVector results(max_results);
644  DistanceVector results_distances(max_results);
646  //int data_size = ThisModelPart.GetNodalSolutionStepTotalDataSize();
647 
648 
649  //double* work_array;
650  //Node work_point(0,0.0,0.0,0.0);
651 
652 
653 
654  //NOW WE SHALL IDENTIFY LONELY BUT NOT FLYING NODES (compare with the flying nodes identification above (after first remeshing step))
655  /*
656  std::vector<double> aux_after_ref(outnew.numberofpoints);
657 
658  for (unsigned int i=0; i<aux_after_ref.size();i++)
659  {
660  aux_after_ref[i]=0.0;
661  }
662  int el_number_ref= outnew.numberoftetrahedra;
663 
664  for(int el = 0; el< el_number_ref; el++)
665  {
666  int base=el*4;
667 
668 
669  //we add a non-zero value for the node of the element that has a non-zero value
670  aux_after_ref[outnew.tetrahedronlist[base]-1]+=1;
671  aux_after_ref[outnew.tetrahedronlist[base+1]-1]+=1;
672  aux_after_ref[outnew.tetrahedronlist[base+2]-1]+=1;
673  aux_after_ref[outnew.tetrahedronlist[base+3]-1]+=1;
674 
675  }
676  */
677  unsigned int fined_node_counter = 0;
678  if(outnew.numberofpoints-n_points_before_refinement > 0) //if we added points
679  {
680  kd_tree nodes_tree2(list_of_new_nodes.begin(),list_of_new_nodes.end(),bucket_size);
681  //std::cout<<nodes_tree2<<std::endl;
682  nodes_begin = ThisModelPart.NodesBegin();
683 
684  for(int el = 0; el< in2.numberoftetrahedra; el++)
685  //for(unsigned int el = 0; el< outnew.numberoftetrahedra; el++)
686  {
687 
688  int base = el * 4;
689  //coordinates
690 
691  point_base = (in2.tetrahedronlist[base] - 1)*3;
692  x1[0] = in2.pointlist[point_base];
693  x1[1] = in2.pointlist[point_base+1];
694  x1[2] = in2.pointlist[point_base+2];
695 
696  point_base = (in2.tetrahedronlist[base+1] - 1)*3;
697  x2[0] = in2.pointlist[point_base];
698  x2[1] = in2.pointlist[point_base+1];
699  x2[2] = in2.pointlist[point_base+2];
700 
701  point_base = (in2.tetrahedronlist[base+2] - 1)*3;
702  x3[0] = in2.pointlist[point_base];
703  x3[1] = in2.pointlist[point_base+1];
704  x3[2] = in2.pointlist[point_base+2];
705 
706  point_base = (in2.tetrahedronlist[base+3] - 1)*3;
707  x4[0] = in2.pointlist[point_base];
708  x4[1] = in2.pointlist[point_base+1];
709  x4[2] = in2.pointlist[point_base+2];
710 
711  //calculate the geometrical data
712  //degenerate elements are given a very high radius
713  double geometrical_hmin, geometrical_hmax;
714  double radius;
715  double vol;
716  int in2_tet_attr;
717  in2_tet_attr = in2.tetrahedronattributelist[el];
718 
720 
721  //it calculates the data necessary to perfom the search, like the element center etc., search radius
722  //and writes it to radius, xc etc etc
723 
724  CalculateElementData(x1,x2,x3,x4,vol,xc,radius,geometrical_hmin,geometrical_hmax);
725 
726  //find all of the nodes in a radius centered in xc
727 
728  std::size_t number_of_points_in_radius;
729  work_point.X() = xc[0];
730  work_point.Y() = xc[1];
731  work_point.Z() = xc[2];
732 
733  number_of_points_in_radius = nodes_tree2.SearchInRadius(work_point, radius, results.begin(),results_distances.begin(), max_results);
734 
735  if(number_of_points_in_radius == max_results)
736  KRATOS_WATCH("HHHHHHHHHHHH number_of_points_in_radius == max_results HHHHHHHHHH ");
737  //for each of the nodes in radius find if it is inside the element or not
738  //if inside interpolate
739 
740 
742  *( (nodes_begin + in2.tetrahedronlist[base]-1).base() ),
743  *( (nodes_begin + in2.tetrahedronlist[base+1]-1).base() ),
744  *( (nodes_begin + in2.tetrahedronlist[base+2]-1).base() ),
745  *( (nodes_begin + in2.tetrahedronlist[base+3]-1).base() )
746  );
747 
748 
749  //KRATOS_WATCH(results.size())
750  for(auto it=results.begin(); it!=results.begin() + number_of_points_in_radius; it++)
751  {
752  bool is_inside=false;
753 // KRATOS_WATCH((*it)->Id());
754  is_inside = CalculatePosition(x1[0],x1[1],x1[2],
755  x2[0],x2[1],x2[2],
756  x3[0],x3[1],x3[2],
757  x4[0],x4[1],x4[2],
758  (*it)->X(),(*it)->Y(), (*it)->Z(),N);
759 // KRATOS_WATCH(is_inside);
760  if(is_inside == true)
761  {
762 
763  Interpolate( geom, N, step_data_size, *(it), in2_tet_attr );
764  fined_node_counter++;
765  }
766 
767  }
768  }
769  }
770  KRATOS_WATCH("DDDDDDDDDDDDDDDDDDDD AFTER INTERPOLATING ZZZZZZZZZZZZZZZZZZZZZZ");
771  if(list_of_new_nodes.size() > fined_node_counter)
772  {
773  KRATOS_WATCH(list_of_new_nodes.size());
774  KRATOS_WATCH(fined_node_counter);
775  // KRATOS_THROW_ERROR(std::logic_error,"Definitly some nodes are not interpolated","");
776  KRATOS_WATCH("Definitly some nodes are not interpolated");
777 
778  }
779 
780  ThisModelPart.Elements().clear();
781  ThisModelPart.Conditions().clear();
782 
783  //set the coordinates to the original value
784  for(auto & list_of_new_node : list_of_new_nodes)
785  {
786  const array_1d<double,3>& disp = list_of_new_node->FastGetSolutionStepValue(DISPLACEMENT);
787  list_of_new_node->X0() = list_of_new_node->X() - disp[0];
788  list_of_new_node->Y0() = list_of_new_node->Y() - disp[1];
789  list_of_new_node->Z0() = list_of_new_node->Z() - disp[2];
790 
791  if(list_of_new_node->FastGetSolutionStepValue(IS_WATER) != 0.0 && list_of_new_node->FastGetSolutionStepValue(IS_WATER) != 1.0)
792  KRATOS_WATCH("SSSSSSSSSSSSSSSSSSS a non_interpolated node SSSSSSSSSSSSSSSSSSSSS");
793  }
794  //cleaning unnecessary data
795 
796 
797  //***********************************************************************************
798  //***********************************************************************************
799  boost::timer adding_elems;
800  //add preserved elements to the kratos
801  Properties::Pointer properties = ThisModelPart.GetMesh().pGetProperties(1);
802  //KRATOS_WATCH("!!!!!!!!!!!!!!! properties !!!!!!!!!");
803  // KRATOS_WATCH(properties);
804  nodes_begin = ThisModelPart.NodesBegin();
805  (ThisModelPart.Elements()).reserve(outnew.numberoftetrahedra);
806 
807  for(int iii = 0; iii< outnew.numberoftetrahedra; iii++)
808  {
809 
810  int id = iii + 1;
811  int base = iii * 4;
813  *( (nodes_begin + outnew.tetrahedronlist[base]-1).base() ),
814  *( (nodes_begin + outnew.tetrahedronlist[base+1]-1).base() ),
815  *( (nodes_begin + outnew.tetrahedronlist[base+2]-1).base() ),
816  *( (nodes_begin + outnew.tetrahedronlist[base+3]-1).base() )
817  );
818 
819 #ifdef _DEBUG
820  ModelPart::NodesContainerType& ModelNodes = ThisModelPart.Nodes();
821  if( *(ModelNodes).find( outnew.tetrahedronlist[base]).base() == *(ThisModelPart.Nodes().end()).base() )
822  KRATOS_THROW_ERROR(std::logic_error,"trying to use an inexisting node","");
823  if( *(ModelNodes).find( outnew.tetrahedronlist[base+1]).base() == *(ThisModelPart.Nodes().end()).base() )
824  KRATOS_THROW_ERROR(std::logic_error,"trying to use an inexisting node","");
825  if( *(ModelNodes).find( outnew.tetrahedronlist[base+2]).base() == *(ThisModelPart.Nodes().end()).base() )
826  KRATOS_THROW_ERROR(std::logic_error,"trying to use an inexisting node","");
827  if( *(ModelNodes).find( outnew.tetrahedronlist[base+3]).base() == *(ThisModelPart.Nodes().end()).base() )
828  KRATOS_THROW_ERROR(std::logic_error,"trying to use an inexisting node","");
829 #endif
830 
831  Element::Pointer p_element = rReferenceElement.Create(id, geom, properties);
832  (ThisModelPart.Elements()).push_back(p_element);
833 
834  if(outnew.tetrahedronattributelist[iii] == -20)
835  p_element->GetValue(IS_WATER_ELEMENT) = 0.0;
836  else
837  p_element->GetValue(IS_WATER_ELEMENT) = 1.0;
838 
839  }
840 
841  std::cout << "time for adding elems" << adding_elems.elapsed() << std::endl;;
842  ThisModelPart.Elements().Sort();
843  /*
844  boost::timer adding_neighb;
845  // //filling the neighbour list
846  ModelPart::ElementsContainerType::const_iterator el_begin = ThisModelPart.ElementsBegin();
847  for(ModelPart::ElementsContainerType::const_iterator iii = ThisModelPart.ElementsBegin();
848  iii != ThisModelPart.ElementsEnd(); iii++)
849  {
850  //Geometry< Node >& geom = iii->GetGeometry();
851  int base = ( iii->Id() - 1 )*4;
852 
853  (iii->GetValue(NEIGHBOUR_ELEMENTS)).resize(4);
854  GlobalPointersVector< Element >& neighb = iii->GetValue(NEIGHBOUR_ELEMENTS);
855 
856  for(int i = 0; i<4; i++)
857  {
858  int index = outnew.neighborlist[base+i];
859  if(index > 0)
860  neighb(i) = *((el_begin + index-1).base());
861  else
862  neighb(i) = Element::WeakPointer();
863  }
864  }
865  std::cout << "time for adding neigbours" << adding_neighb.elapsed() << std::endl;;
866  */
867 
868  std::cout << "time for adding neigbours is zero because n neighbor added"<<std::endl;;
869 
870 
871  //***********************************************************************************
872  //***********************************************************************************
873  //mark boundary nodes
874  //reset the boundary flag
875  for(ModelPart::NodesContainerType::const_iterator in = ThisModelPart.NodesBegin(); in!=ThisModelPart.NodesEnd(); in++)
876  {
877  in->FastGetSolutionStepValue(IS_BOUNDARY) = 0;
878  }
879 
880 
881  //***********************************************************************************
882  //***********************************************************************************
883  boost::timer adding_faces;
884 
885  (ThisModelPart.Conditions()).reserve(outnew.numberoftrifaces );
886 
887  //creating the faces
888  for(ModelPart::ElementsContainerType::const_iterator iii = ThisModelPart.ElementsBegin();
889  iii != ThisModelPart.ElementsEnd(); iii++)
890  {
891 
892  int base = ( iii->Id() - 1 )*4;
893 
894  //create boundary faces and mark the boundary nodes
895  //each face is opposite to the corresponding node number so
896  // 0 ----- 1 2 3
897  // 1 ----- 0 3 2
898  // 2 ----- 0 1 3
899  // 3 ----- 0 2 1
900 
901  //node 1
902 
903  //if( neighb(0).expired() );
904  if( outnew.neighborlist[base] == -1)
905  {
906  CreateBoundaryFace(1, 2, 3, ThisModelPart, 0, *(iii.base()), properties,rReferenceBoundaryCondition );
907  }
908  //if(neighb(1).expired() );
909  if( outnew.neighborlist[base+1] == -1)
910  {
911  CreateBoundaryFace(0,3,2, ThisModelPart, 1, *(iii.base()), properties, rReferenceBoundaryCondition );
912  }
913  if( outnew.neighborlist[base+2] == -1)
914  //if(neighb(2).expired() );
915  {
916  CreateBoundaryFace(0,1,3, ThisModelPart, 2, *(iii.base()), properties, rReferenceBoundaryCondition );
917  }
918  if( outnew.neighborlist[base+3] == -1)
919  //if(neighb(3).expired() );
920  {
921  CreateBoundaryFace(0,2,1, ThisModelPart, 3, *(iii.base()), properties, rReferenceBoundaryCondition );
922  }
923 
924  }
925 
926 // //after assigning face condition clear 4 structure element
927 // ModelPart::ElementsContainerType GoodElements;
928 // for(ModelPart::ElementsContainerType::const_iterator iii = ThisModelPart.ElementsBegin();
929 // iii != ThisModelPart.ElementsEnd(); iii++)
930 // {
931 // Geometry< Node >& geom = iii->GetGeometry();
932 // int number_of_structure_nodes = int( geom[0].FastGetSolutionStepValue(IS_STRUCTURE) );
933 // number_of_structure_nodes += int( geom[1].FastGetSolutionStepValue(IS_STRUCTURE) );
934 // number_of_structure_nodes += int( geom[2].FastGetSolutionStepValue(IS_STRUCTURE) );
935 // number_of_structure_nodes += int( geom[3].FastGetSolutionStepValue(IS_STRUCTURE) );
936 //
937 // if(number_of_structure_nodes != 4)//if they have at least one node out of structure
938 // {
939 // GoodElements.push_back(*(iii.base()));
940 // }
941 //
942 // }
943 // ThisModelPart.Elements().clear();
944 // ThisModelPart.Elements() = GoodElements;
945 // ThisModelPart.Elements().Sort();
946  //KRATOS_WATCH("deinitialize outnew");
947  outnew.deinitialize();
948  outnew.initialize();
949  // KRATOS_WATCH("deinitialize first in2");
950  in2.deinitialize();
951  //KRATOS_WATCH("deinitialize middle in2");
952  in2.initialize();
953  //KRATOS_WATCH("deinitialize last in2");
954  std::cout << "time for adding faces" << adding_faces.elapsed() << std::endl;;
955 
956 
957 
958  //here we remove lonely nodes that are not teh flying nodes, but are the lonely nodes inside water vol
959  /*
960  for(ModelPart::NodesContainerType::const_iterator in = ThisModelPart.NodesBegin(); in!=ThisModelPart.NodesEnd(); in++)
961  {
962  //if this is a node added during refinement, but isnt contained in any element
963  if (aux_after_ref[in->GetId()]==0 && in->GetId()>aux_before_ref.size() && in->GetId()<aux_after_ref.size())
964  {
965  in->Set(TO_ERASE,true);
966  KRATOS_WATCH("This is that ugly ugly lonely interior node a666a. IT SHALL BE TERRRRMINATED!!!!!!")
967  KRATOS_WATCH(in->GetId())
968  }
969  //if this was an interior node after first step and became single due to derefinement - erase it
970  if (aux_after_ref[in->GetId()]==0 && in->GetId()<aux_before_ref.size() && aux_before_ref[in->GetId()]!=0)
971  {
972  in->Set(TO_ERASE,true);
973  KRATOS_WATCH("This is that ugly ugly lonely interior node. IT SHALL BE TERRRRMINATED!!!!!!")
974  }
975  }
976  */
977 
978 
979  double second_part_time = auxiliary.elapsed();
980  std::cout << "second part time = " << second_part_time - first_part_time << std::endl;
981 
982 
983  KRATOS_CATCH("")
984  }
985 
989 
990 
994 
995 
999 
1001  virtual std::string Info() const
1002  {
1003  return "";
1004  }
1005 
1007  virtual void PrintInfo(std::ostream& rOStream) const {}
1008 
1010  virtual void PrintData(std::ostream& rOStream) const {}
1011 
1012 
1016 
1017 
1019 
1020 protected:
1023 
1024 
1028 
1029 
1033 
1034 
1038 
1039 
1043 
1044 
1048 
1049 
1053 
1054 
1056 
1057 private:
1060 
1061 
1065  boost::numeric::ublas::bounded_matrix<double,3,3> mJ; //local jacobian
1066  boost::numeric::ublas::bounded_matrix<double,3,3> mJinv; //inverse jacobian
1067  array_1d<double,3> mc; //center pos
1068  array_1d<double,3> mRhs; //center pos
1069 
1070 
1071  void CreateBoundaryFace(const int& i1, const int& i2, const int& i3, ModelPart& ThisModelPart, const int& outer_node_id, Element::Pointer origin_element, Properties::Pointer properties,Condition const& rReferenceBoundaryCondition)
1072  {
1073  KRATOS_TRY
1074 
1075  Geometry<Node >& geom = origin_element->GetGeometry();
1076  //mark the nodes as free surface
1077  geom[i1].FastGetSolutionStepValue(IS_BOUNDARY) = 1;
1078  geom[i2].FastGetSolutionStepValue(IS_BOUNDARY) = 1;
1079  geom[i3].FastGetSolutionStepValue(IS_BOUNDARY) = 1;
1080 
1081  //generate a face condition
1083  temp.reserve(3);
1084  temp.push_back(geom(i1));
1085  temp.push_back(geom(i2));
1086  temp.push_back(geom(i3));
1088  //Geometry< Node >::Pointer cond = Geometry< Node >::Pointer(new Triangle3D< Node >(temp) );
1089  int id = (origin_element->Id()-1)*4;
1090  //Condition::Pointer p_cond = Condition::Pointer(new Condition(id, cond, properties) );
1091  //Condition::Pointer p_cond = rReferenceBoundaryCondition::Pointer(new Condition(id, cond, properties) );
1092  Condition::Pointer p_cond = rReferenceBoundaryCondition.Create(id, temp, properties);
1093  //assigning the neighbour node
1094  (p_cond->GetValue(NEIGHBOUR_NODES)).clear();
1095  (p_cond->GetValue(NEIGHBOUR_NODES)).push_back( Node::WeakPointer( geom(outer_node_id) ) );
1096  (p_cond->GetValue(NEIGHBOUR_ELEMENTS)).clear();
1097  (p_cond->GetValue(NEIGHBOUR_ELEMENTS)).push_back( Element::WeakPointer( origin_element ) );
1098  ThisModelPart.Conditions().push_back(p_cond);
1099  KRATOS_CATCH("")
1100 
1101  }
1102 
1105  void Interpolate( Tetrahedra3D4<Node >& geom, const array_1d<double,4>& N,
1106  unsigned int step_data_size,
1107  Node::Pointer pnode, int tet_attr)
1108  {
1109  unsigned int buffer_size = pnode->GetBufferSize();
1110 
1111  //here we want to keep the flag of aaded Faces node and not interpolate it
1112 // double aux_interface = pnode->FastGetSolutionStepValue(IS_INTERFACE);
1113 
1114  for(unsigned int step = 0; step<buffer_size; step++)
1115  {
1116 
1117  //getting the data of the solution step
1118  double* step_data = (pnode)->SolutionStepData().Data(step);
1119 
1120 
1121  double* node0_data = geom[0].SolutionStepData().Data(step);
1122  double* node1_data = geom[1].SolutionStepData().Data(step);
1123  double* node2_data = geom[2].SolutionStepData().Data(step);
1124  double* node3_data = geom[3].SolutionStepData().Data(step);
1125 
1126  //copying this data in the position of the vector we are interested in
1127  for(unsigned int j= 0; j<step_data_size; j++)
1128  {
1129 
1130  step_data[j] = N[0]*node0_data[j] + N[1]*node1_data[j] + N[2]*node2_data[j] + N[3]*node3_data[j];
1131 
1132 
1133  }
1134  }
1135  //now we assure that the flag variables are set coorect!! since we add nodes inside of the fluid volume only
1136  //we manually reset the IS_BOUNDARY, IS_FLUID, IS_STRUCTURE, IS_FREE_SURFACE values in a right way
1137  //not to have values, like 0.33 0.66 resulting if we would have been interpolating them in the same way
1138  //as the normal variables, like Velocity etc
1139 
1140  pnode->FastGetSolutionStepValue(IS_BOUNDARY)=0.0;
1141  pnode->FastGetSolutionStepValue(IS_STRUCTURE)=0.0;
1142  pnode->FastGetSolutionStepValue(IS_FREE_SURFACE)=0.0;
1143  pnode->FastGetSolutionStepValue(IS_FLUID)=1.0;
1144  pnode->FastGetSolutionStepValue(IS_INTERFACE)=0.0;
1145  pnode->Set(TO_ERASE,false);
1146 
1147  pnode->FastGetSolutionStepValue(IS_BOUNDARY,1)=0.0;
1148  pnode->FastGetSolutionStepValue(IS_STRUCTURE,1)=0.0;
1149  pnode->FastGetSolutionStepValue(IS_FREE_SURFACE,1)=0.0;
1150  pnode->FastGetSolutionStepValue(IS_FLUID,1)=1.0;
1151  pnode->FastGetSolutionStepValue(IS_INTERFACE,1)=0.0;
1152 
1153 // pnode->FastGetSolutionStepValue(WATER_PRESSURE,1) = pnode->FastGetSolutionStepValue(WATER_PRESSURE);
1154 // pnode->FastGetSolutionStepValue(AIR_PRESSURE,1) = pnode->FastGetSolutionStepValue(AIR_PRESSURE);
1155 
1156  if(pnode->FastGetSolutionStepValue(NODAL_H) == 0.0)
1157  {
1158  double mean_h =0.0;
1159  mean_h += geom[0].FastGetSolutionStepValue(NODAL_H);
1160  mean_h += geom[1].FastGetSolutionStepValue(NODAL_H);
1161  mean_h += geom[2].FastGetSolutionStepValue(NODAL_H);
1162  mean_h += geom[3].FastGetSolutionStepValue(NODAL_H);
1163 
1164  pnode->FastGetSolutionStepValue(NODAL_H) = mean_h/4.0;
1165  pnode->FastGetSolutionStepValue(NODAL_H,1) = mean_h/4.0;
1166  }
1167 
1168  //pnode->FastGetSolutionStepValue(IS_INTERFACE)=1.0;
1169  //pnode->FastGetSolutionStepValue(IS_INTERFACE) = aux_interface;
1170 
1171  /* double same_colour = 0.0;
1172  for(int ii= 0; ii<= 3; ++ii)
1173  if(geom[ii].FastGetSolutionStepValue(IS_WATER) == 0.0)
1174  same_colour++;
1175  if(same_colour == 4.0)
1176  pnode->FastGetSolutionStepValue(IS_WATER) = 0.0;
1177  else
1178  pnode->FastGetSolutionStepValue(IS_WATER) = 1.0;
1179  */
1180  //interface nodes are always air
1181  if(tet_attr == -20)
1182  {
1183  pnode->FastGetSolutionStepValue(IS_WATER) = 0.0;
1184  pnode->FastGetSolutionStepValue(IS_WATER,1) = 0.0;
1185  //KRATOS_WATCH(">>>>>>>>>>>>>>>>>inside interpolate AIR added<<<<<<<<<<<<<<<<<");
1186 // KRATOS_WATCH(pnode->FastGetSolutionStepValue(WATER_PRESSURE));
1187 // KRATOS_WATCH(pnode->Id());
1188  }
1189  else
1190  {
1191  pnode->FastGetSolutionStepValue(IS_WATER) = 1.0;
1192  pnode->FastGetSolutionStepValue(IS_WATER,1) = 1.0;
1193  //KRATOS_WATCH(">>>>>>>>>>>>>>>>>inside interpolate WATER added<<<<<<<<<<<<<<<<<");
1194 // KRATOS_WATCH(pnode->FastGetSolutionStepValue(AIR_PRESSURE));
1195 // KRATOS_WATCH(pnode->Id());
1196  }
1197  }
1200 
1201  inline double CalculateVol( const double x0, const double y0, const double z0,
1202  const double x1, const double y1, const double z1,
1203  const double x2, const double y2, const double z2,
1204  const double x3, const double y3, const double z3
1205  )
1206  {
1207  double x10 = x1 - x0;
1208  double y10 = y1 - y0;
1209  double z10 = z1 - z0;
1210 
1211  double x20 = x2 - x0;
1212  double y20 = y2 - y0;
1213  double z20 = z2 - z0;
1214 
1215  double x30 = x3 - x0;
1216  double y30 = y3 - y0;
1217  double z30 = z3 - z0;
1218 
1219  double detJ = x10 * y20 * z30 - x10 * y30 * z20 + y10 * z20 * x30 - y10 * x20 * z30 + z10 * x20 * y30 - z10 * y20 * x30;
1220  return detJ*0.1666666666666666666667;
1221 
1222  //return 0.5*( (x1-x0)*(y2-y0)- (y1-y0)*(x2-x0) );
1223  }
1224 
1225  inline bool CalculatePosition( const double x0, const double y0, const double z0,
1226  const double x1, const double y1, const double z1,
1227  const double x2, const double y2, const double z2,
1228  const double x3, const double y3, const double z3,
1229  const double xc, const double yc, const double zc,
1230  array_1d<double,4>& N
1231  )
1232  {
1233 
1234 
1235  double vol = CalculateVol(x0,y0,z0,x1,y1,z1,x2,y2,z2,x3,y3,z3);
1236 
1237  double inv_vol = 0.0;
1238  if(vol < 0.0000000000000000000000000000000000000000000001)
1239  {
1240  KRATOS_WATCH(vol);
1241 
1242  KRATOS_THROW_ERROR(std::logic_error,"element with zero vol found","");
1243  }
1244  else
1245  {
1246  inv_vol = 1.0 / vol;
1247  }
1248 
1249  N[0] = CalculateVol(x1,y1,z1,x3,y3,z3,x2,y2,z2,xc,yc,zc) * inv_vol;
1250  N[1] = CalculateVol(x3,y3,z3,x0,y0,z0,x2,y2,z2,xc,yc,zc) * inv_vol;
1251  N[2] = CalculateVol(x3,y3,z3,x1,y1,z1,x0,y0,z0,xc,yc,zc) * inv_vol;
1252  N[3] = CalculateVol(x0,y0,z0,x1,y1,z1,x2,y2,z2,xc,yc,zc) * inv_vol;
1253 
1254 
1255  if(N[0] >= 0.0 && N[1] >= 0.0 && N[2] >= 0.0 && N[3] >=0.0 &&
1256  N[0] <= 1.0 && N[1] <= 1.0 && N[2] <= 1.0 && N[3] <=1.0)
1257  //if the xc yc zc is inside the tetrahedron return true
1258  return true;
1259 
1260  return false;
1261  }
1262  //***************************************
1263  //***************************************
1264  inline void CalculateCenterAndSearchRadius(const double x0, const double y0, const double z0,
1265  const double x1, const double y1, const double z1,
1266  const double x2, const double y2, const double z2,
1267  const double x3, const double y3, const double z3,
1268  double& xc, double& yc, double& zc, double& R
1269  )
1270  {
1271  xc = 0.25*(x0+x1+x2+x3);
1272  yc = 0.25*(y0+y1+y2+y3);
1273  zc = 0.25*(z0+z1+z2+z3);
1274 
1275  double R1 = (xc-x0)*(xc-x0) + (yc-y0)*(yc-y0) + (zc-z0)*(zc-z0);
1276  double R2 = (xc-x1)*(xc-x1) + (yc-y1)*(yc-y1) + (zc-z1)*(zc-z1);
1277  double R3 = (xc-x2)*(xc-x2) + (yc-y2)*(yc-y2) + (zc-z2)*(zc-z2);
1278  double R4 = (xc-x3)*(xc-x3) + (yc-y3)*(yc-y3) + (zc-z3)*(zc-z3);
1279 
1280  R = R1;
1281  if(R2 > R) R = R2;
1282  if(R3 > R) R = R3;
1283  if(R4 > R) R = R4;
1284 
1285  R = sqrt(R);
1286  }
1287  //*****************************************************************************************
1288  //*****************************************************************************************
1289  void CalculateElementData(const array_1d<double,3>& c1,
1290  const array_1d<double,3>& c2,
1291  const array_1d<double,3>& c3,
1292  const array_1d<double,3>& c4,
1293  double& volume,
1294  array_1d<double,3>& xc,
1295  double& radius,
1296  double& hmin,
1297  double& hmax
1298  )
1299  {
1300  KRATOS_TRY
1301  const double x0 = c1[0];
1302  const double y0 = c1[1];
1303  const double z0 = c1[2];
1304  const double x1 = c2[0];
1305  const double y1 = c2[1];
1306  const double z1 = c2[2];
1307  const double x2 = c3[0];
1308  const double y2 = c3[1];
1309  const double z2 = c3[2];
1310  const double x3 = c4[0];
1311  const double y3 = c4[1];
1312  const double z3 = c4[2];
1313 
1314 // KRATOS_WATCH("111111111111111111111");
1315  //calculate min side lenght
1316  //(use xc as a auxiliary vector) !!!!!!!!!!!!
1317  double aux;
1318  noalias(xc) = c4;
1319  noalias(xc)-=c1;
1320  aux = inner_prod(xc,xc);
1321  hmin = aux;
1322  hmax = aux;
1323  noalias(xc) = c3;
1324  noalias(xc)-=c1;
1325  aux = inner_prod(xc,xc);
1326  if(aux<hmin) hmin = aux;
1327  else if(aux>hmax) hmax = aux;
1328  noalias(xc) = c2;
1329  noalias(xc)-=c1;
1330  aux = inner_prod(xc,xc);
1331  if(aux<hmin) hmin = aux;
1332  else if(aux>hmax) hmax = aux;
1333  noalias(xc) = c4;
1334  noalias(xc)-=c2;
1335  aux = inner_prod(xc,xc);
1336  if(aux<hmin) hmin = aux;
1337  else if(aux>hmax) hmax = aux;
1338  noalias(xc) = c3;
1339  noalias(xc)-=c2;
1340  aux = inner_prod(xc,xc);
1341  if(aux<hmin) hmin = aux;
1342  else if(aux>hmax) hmax = aux;
1343  noalias(xc) = c4;
1344  noalias(xc)-=c3;
1345  aux = inner_prod(xc,xc);
1346  if(aux<hmin) hmin = aux;
1347  else if(aux>hmax) hmax = aux;
1348  hmin = sqrt(hmin);
1349  hmax = sqrt(hmax);
1350 
1351  //calculation of the jacobian
1352  mJ(0,0) = x1-x0;
1353  mJ(0,1) = y1-y0;
1354  mJ(0,2) = z1-z0;
1355  mJ(1,0) = x2-x0;
1356  mJ(1,1) = y2-y0;
1357  mJ(1,2) = z2-z0;
1358  mJ(2,0) = x3-x0;
1359  mJ(2,1) = y3-y0;
1360  mJ(2,2) = z3-z0;
1361 // KRATOS_WATCH("33333333333333333333333");
1362 
1363  //inverse of the jacobian
1364  //first column
1365  mJinv(0,0) = mJ(1,1)*mJ(2,2) - mJ(1,2)*mJ(2,1);
1366  mJinv(1,0) = -mJ(1,0)*mJ(2,2) + mJ(1,2)*mJ(2,0);
1367  mJinv(2,0) = mJ(1,0)*mJ(2,1) - mJ(1,1)*mJ(2,0);
1368  //second column
1369  mJinv(0,1) = -mJ(0,1)*mJ(2,2) + mJ(0,2)*mJ(2,1);
1370  mJinv(1,1) = mJ(0,0)*mJ(2,2) - mJ(0,2)*mJ(2,0);
1371  mJinv(2,1) = -mJ(0,0)*mJ(2,1) + mJ(0,1)*mJ(2,0);
1372  //third column
1373  mJinv(0,2) = mJ(0,1)*mJ(1,2) - mJ(0,2)*mJ(1,1);
1374  mJinv(1,2) = -mJ(0,0)*mJ(1,2) + mJ(0,2)*mJ(1,0);
1375  mJinv(2,2) = mJ(0,0)*mJ(1,1) - mJ(0,1)*mJ(1,0);
1376  //calculation of determinant (of the input matrix)
1377 
1378 // KRATOS_WATCH("44444444444444444444444444");
1379  double detJ = mJ(0,0)*mJinv(0,0)
1380  + mJ(0,1)*mJinv(1,0)
1381  + mJ(0,2)*mJinv(2,0);
1382 
1383  volume = detJ * 0.16666666667;
1384 // KRATOS_WATCH("55555555555555555555555");
1385 
1386  if(volume < 1e-13 * hmax*hmax*hmax) //this is a sliver and we will remove it
1387  {
1388  //KRATOS_WATCH("666666666666666666666666666");
1389  //very bad element // ser a very high center for it to be eliminated
1390  xc[0]=0.0;
1391  xc[1]=0.0;
1392  xc[2]=0.0;
1393  radius = 10000000;
1394  KRATOS_WATCH("777777777777777777777777");
1395  }
1396  else
1397  {
1398 
1399 // KRATOS_WATCH("888888888888888888888888");
1400  double x0_2 = x0*x0 + y0*y0 + z0*z0;
1401  double x1_2 = x1*x1 + y1*y1 + z1*z1;
1402  double x2_2 = x2*x2 + y2*y2 + z2*z2;
1403  double x3_2 = x3*x3 + y3*y3 + z3*z3;
1404 
1405  //finalizing the calculation of the inverted matrix
1406  mJinv /= detJ;
1407 
1408  //calculating the RHS
1409  //calculating the RHS
1410  mRhs[0] = 0.5*(x1_2 - x0_2);
1411  mRhs[1] = 0.5*(x2_2 - x0_2);
1412  mRhs[2] = 0.5*(x3_2 - x0_2);
1413 
1414  //calculate position of the center
1415 // noalias(xc) = prod(mJinv,mRhs);
1416  xc(0) = 0.25*(x0 + x1 + x2 + x3);
1417  xc(1) = 0.25*(y0 + y1 + y2 + y3);
1418  xc(2) = 0.25*(z0 + z1 + z2 + z3);
1419 
1420  //calculate radius
1421  array_1d<double,4> radii;
1422 
1423  radii(0) = pow(xc[0] - x0,2) + pow(xc[1] - y0,2) + pow(xc[2] - z0,2);
1424  radii(1) = pow(xc[0] - x1,2) + pow(xc[1] - y1,2) + pow(xc[2] - z1,2);
1425  radii(2) = pow(xc[0] - x2,2) + pow(xc[1] - y2,2) + pow(xc[2] - z2,2);
1426  radii(3) = pow(xc[0] - x3,2) + pow(xc[1] - y3,2) + pow(xc[2] - z3,2);
1427 
1428  radius = sqrt(radii(0));
1429  for(int ii=1; ii<4; ++ii)
1430  {
1431  double candid = sqrt(radii(ii));
1432  if(candid > radius)
1433  radius = candid;
1434  }
1435  radius *=2.0;
1436 // radius = 10000000000000000000;
1437 // radius = pow(xc[0] - x0,2);
1438 // radius += pow(xc[1] - y0,2);
1439 // radius += pow(xc[2] - z0,2);
1440 // radius = sqrt(radius);
1441 // KRATOS_WATCH("999999999999999999999999999");
1442  }
1443  KRATOS_CATCH("")
1444  }
1445 
1446  template< class T, std::size_t dim >
1447  class PointDistance
1448  {
1449  public:
1450  double operator()( T const& p1, T const& p2 )
1451  {
1452  double dist = 0.0;
1453  for( std::size_t i = 0 ; i < dim ; i++)
1454  {
1455  double tmp = p1[i] - p2[i];
1456  dist += tmp*tmp;
1457  }
1458  return sqrt(dist);
1459  }
1460  };
1461 
1462  template< class T, std::size_t dim >
1463  class DistanceCalculator
1464  {
1465  public:
1466  double operator()( T const& p1, T const& p2 )
1467  {
1468  double dist = 0.0;
1469  for( std::size_t i = 0 ; i < dim ; i++)
1470  {
1471  double tmp = p1[i] - p2[i];
1472  dist += tmp*tmp;
1473  }
1474  return dist;
1475  }
1476  };
1477 
1481 
1485  //**********************************************************************************************
1486  //**********************************************************************************************
1487  void FaceDetecting(ModelPart& ThisModelPart,ModelPart::ElementsContainerType& rElements, std::vector <int>& face_list, int& face_num, double h_factor)
1488  {
1489  KRATOS_TRY;
1490 // int Tdim = 3;
1491  face_list.clear();
1492  face_num = 0;
1493 
1494  //std::vector <int> nodes_of_bad_segments;
1495  //std::vector <int> raw_seg_list;
1496  // 0 ----- 1 2 3
1497  // 1 ----- 0 3 2
1498  // 2 ----- 0 1 3
1499  // 3 ----- 0 2 1
1500  //if(h_factor > 0.1)
1501  // h_factor = 0.5;
1502  KRATOS_WATCH("INSIDE FACE");
1503  //Fill structure interface
1504 // elenum = neighbor_els.begin(); elenum!=neighbor_els.end(); elenum++)
1505  for(ModelPart::ElementsContainerType::iterator elem = rElements.begin();
1506  elem!=rElements.end(); elem++)
1507  {
1508  Geometry< Node >& geom = elem->GetGeometry();
1509 
1510 
1511  //one segment is detected
1512  ++face_num;
1513  face_list.push_back(geom[0].Id());
1514  face_list.push_back(geom[1].Id());
1515  face_list.push_back(geom[2].Id());
1516  geom[0].FastGetSolutionStepValue(IS_INTERFACE) = 1.0;
1517  geom[1].FastGetSolutionStepValue(IS_INTERFACE) = 1.0;
1518  geom[2].FastGetSolutionStepValue(IS_INTERFACE) = 1.0;
1519  }
1520 
1521  for(ModelPart::ElementsContainerType::iterator elem = ThisModelPart.ElementsBegin();
1522  elem!=ThisModelPart.ElementsEnd(); elem++)
1523  {
1524 
1525  if(elem->GetValue(IS_WATER_ELEMENT) == 1.0)
1526  {
1527  Geometry< Node >& geom = elem->GetGeometry();
1528  array_1d<int,3> str_pts = ZeroVector(3);
1529 // int str_num = 0;
1530 // int cnt = 0;
1531  GlobalPointersVector< Element >& neighbor_els = elem->GetValue(NEIGHBOUR_ELEMENTS);
1532  for(int ii=0; ii<4; ++ii)
1533  {
1534  if(neighbor_els[ii].Id() == elem->Id())
1535  {
1536  //FLAG_VARIABLE == 5 is used to detect just exterior boundary
1537  //interior one is shell
1538  int is_bdr_five = 0;
1539  for(int jj=0; jj<4; ++jj)
1540  if(geom[jj].FastGetSolutionStepValue(FLAG_VARIABLE) == 5.0)
1541  is_bdr_five++;
1542 
1543  if(is_bdr_five >= 3.0)
1544  {
1545 //KRATOS_WATCH("HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH");
1546  if( ii == 0 )
1547  {
1548  face_list.push_back(geom[1].Id());
1549  face_list.push_back(geom[2].Id());
1550  face_list.push_back(geom[3].Id());
1551  ++face_num;
1552 // geom[1].FastGetSolutionStepValue(IS_STRUCTURE) = 1.0;
1553 // geom[2].FastGetSolutionStepValue(IS_STRUCTURE) = 1.0;
1554 // geom[3].FastGetSolutionStepValue(IS_STRUCTURE) = 1.0;
1555  }
1556  if( ii == 1 )
1557  {
1558  face_list.push_back(geom[0].Id());
1559  face_list.push_back(geom[2].Id());
1560  face_list.push_back(geom[3].Id());
1561  ++face_num;
1562  /*
1563  geom[0].FastGetSolutionStepValue(IS_STRUCTURE) = 1.0;
1564  geom[2].FastGetSolutionStepValue(IS_STRUCTURE) = 1.0;
1565  geom[3].FastGetSolutionStepValue(IS_STRUCTURE) = 1.0;*/
1566  }
1567  if( ii == 2 )
1568  {
1569  face_list.push_back(geom[0].Id());
1570  face_list.push_back(geom[1].Id());
1571  face_list.push_back(geom[3].Id());
1572  ++face_num;
1573 
1574 // geom[0].FastGetSolutionStepValue(IS_STRUCTURE) = 1.0;
1575 // geom[1].FastGetSolutionStepValue(IS_STRUCTURE) = 1.0;
1576 // geom[3].FastGetSolutionStepValue(IS_STRUCTURE) = 1.0;
1577  }
1578  if( ii == 3 )
1579  {
1580  face_list.push_back(geom[0].Id());
1581  face_list.push_back(geom[1].Id());
1582  face_list.push_back(geom[2].Id());
1583  ++face_num;
1584 
1585 // geom[0].FastGetSolutionStepValue(IS_STRUCTURE) = 1.0;
1586 // geom[1].FastGetSolutionStepValue(IS_STRUCTURE) = 1.0;
1587 // geom[2].FastGetSolutionStepValue(IS_STRUCTURE) = 1.0;
1588  }
1589  }
1590  }
1591  }
1592  }
1593  }//end of structure boundary
1594  KRATOS_CATCH("");
1595  }
1596  //**********************************************************************************************
1597  //**********************************************************************************************
1598  void ContactMesh(ModelPart::ElementsContainerType& rElements)
1599  {
1600  std::vector <int> shell_list;
1601  shell_list.clear();
1602  int shell_num = 0;
1603  ModelPart::NodesContainerType shell_nodes;
1604 
1605  for(ModelPart::ElementsContainerType::iterator elem = rElements.begin();
1606  elem!=rElements.end(); elem++)
1607  {
1608  Geometry< Node >& geom = elem->GetGeometry();
1609 
1610  shell_nodes.push_back(geom(0));
1611  shell_nodes.push_back(geom(1));
1612  shell_nodes.push_back(geom(2));
1613 
1614  }
1615  KRATOS_WATCH(shell_nodes.size());
1616  shell_nodes.Unique();
1617  KRATOS_WATCH("AFTER SHELL_UNIQUE");
1618  ModelPart::NodesContainerType::iterator nodes_begin = shell_nodes.begin();
1619  for(unsigned int ii=0; ii < shell_nodes.size(); ii++)
1620  ( nodes_begin + ii ) ->SetId( ii + 1 );
1621  KRATOS_WATCH("AFTER set id");
1622  for(ModelPart::ElementsContainerType::iterator elem = rElements.begin();
1623  elem!=rElements.end(); elem++)
1624  {
1625  ++shell_num;
1626  Geometry< Node >& geom = elem->GetGeometry();
1627  shell_list.push_back(geom[0].Id());
1628  shell_list.push_back(geom[1].Id());
1629  shell_list.push_back(geom[2].Id());
1630  }
1631  KRATOS_WATCH("AFTER filling shell list");
1632  //mesh generation
1633  tetgenio in_shell, out_shell;
1634 
1635  in_shell.firstnumber = 1;
1636  in_shell.numberofpoints = shell_nodes.size();
1637  in_shell.pointlist = new REAL[in_shell.numberofpoints * 3];
1638 
1639 
1640  tetgenio::facet *f;
1641  tetgenio::polygon *p;
1642  //give the corrdinates to the mesher
1643  for(unsigned int i = 0; i<shell_nodes.size(); i++)
1644  {
1645  int base = i*3;
1646  in_shell.pointlist[base] = (nodes_begin + i)->X();
1647  in_shell.pointlist[base+1] = (nodes_begin + i)->Y();
1648  in_shell.pointlist[base+2] = (nodes_begin + i)->Z();
1649  }
1650 
1651  KRATOS_WATCH("AFTER fill node_input");
1652  if(shell_num != 0)
1653  {
1654  int cnt = 0;
1655  in_shell.numberoffacets = shell_num;
1656  in_shell.facetmarkerlist = new int[in_shell.numberoffacets];
1657  in_shell.facetlist = new tetgenio::facet[in_shell.numberoffacets];
1658  for(int ii=0; ii<shell_num; ++ii)
1659  {
1660  f = &in_shell.facetlist[ii];
1661  f->numberofpolygons = 1;
1662  f->polygonlist = new tetgenio::polygon[f->numberofpolygons];
1663  f->numberofholes = 0;
1664  f->holelist = nullptr;
1665 
1666 
1667  p = &f->polygonlist[0];
1668  p->numberofvertices = 3;
1669  p->vertexlist = new int[p->numberofvertices];
1670  p->vertexlist[0] = shell_list[cnt];
1671  p->vertexlist[1] = shell_list[cnt + 1];
1672  p->vertexlist[2] = shell_list[cnt + 2];
1673  cnt +=3;
1674 
1675  in_shell.facetmarkerlist[ii] = 5;
1676  }
1677 
1678  //holes
1679  in_shell.numberofholes = 0;
1680  in_shell.holelist = nullptr;
1681 
1682  }
1683  KRATOS_WATCH("Bofere mesh generation");
1684  //in_shell.save_nodes("shell_mesh_in");
1685  //in_shell.save_poly("shell_mesh_in");
1686  //char tetgen_options[] = "VMYYJ";pA
1687  char tetgen_options[] = "CCVpYYJ";
1688 
1689  KRATOS_WATCH(in_shell.numberofpoints);
1690 
1691  tetrahedralize(tetgen_options, &in_shell, &out_shell); //with option to remove slivers
1692 
1693  //out_shell.save_nodes("shell_mesh_out");
1694  //out_shell.save_elements("shell_mesh_out");
1695  //out_shell.save_faces("shell_mesh_out");
1696 
1697  in_shell.deinitialize();
1698  // out.deinitialize();
1699 
1700  in_shell.initialize();
1701  out_shell.deinitialize();
1702  // out.deinitialize();
1703 
1704  out_shell.initialize();
1705 
1706 
1707  }
1708  //**********************************************************************************************
1709  //**********************************************************************************************
1710 
1714 
1715 
1719 
1720 
1724 
1726  TetGenPfemRefineFace& operator=(TetGenPfemRefineFace const& rOther);
1727 
1728 
1730 
1731 }; // Class TetGenPfemModeler
1732 
1734 
1737 
1738 
1742 
1743 
1745 inline std::istream& operator >> (std::istream& rIStream,
1746  TetGenPfemRefineFace& rThis);
1747 
1749 inline std::ostream& operator << (std::ostream& rOStream,
1750  const TetGenPfemRefineFace& rThis)
1751 {
1752  rThis.PrintInfo(rOStream);
1753  rOStream << std::endl;
1754  rThis.PrintData(rOStream);
1755 
1756  return rOStream;
1757 }
1759 
1760 
1761 } // namespace Kratos.
1762 
1763 #endif // KRATOS_TETGEN_PFEM_MODELER_H_INCLUDED defined
1764 
1765 
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
void push_back(TPointerType x)
Definition: global_pointers_vector.h:322
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
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
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
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
void push_back(TPointerType x)
Adds a pointer to the end of the set.
Definition: pointer_vector_set.h:544
Short class definition.
Definition: tetgen_pfem_refine_face.h:66
TetGenPfemRefineFace()
Default constructor.
Definition: tetgen_pfem_refine_face.h:79
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: tetgen_pfem_refine_face.h:1010
void ReGenerateMesh(ModelPart &ThisModelPart, ModelPart::ElementsContainerType &rElements, Element const &rReferenceElement, Condition const &rReferenceBoundaryCondition, EntitiesEraseProcess< Node > &node_erase, bool rem_nodes=true, bool add_nodes=true, double alpha_param=1.4, double h_factor=0.5)
Definition: tetgen_pfem_refine_face.h:101
virtual std::string Info() const
Turn back information as a string.
Definition: tetgen_pfem_refine_face.h:1001
KRATOS_CLASS_POINTER_DEFINITION(TetGenPfemRefineFace)
Pointer definition of TetGenPfemRefineFace.
virtual ~TetGenPfemRefineFace()=default
Destructor.
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: tetgen_pfem_refine_face.h:1007
A four node tetrahedra geometry with linear shape functions.
Definition: tetrahedra_3d_4.h:59
A generic tree data structure for spatial partitioning.
Definition: tree.h:190
A three node 3D triangle geometry with linear shape functions.
Definition: triangle_3d_3.h:77
#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
z
Definition: GenerateWind.py:163
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
TExpression1Type::data_type inner_prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:592
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
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
float dist
Definition: edgebased_PureConvection.py:89
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
f
Definition: generate_convection_diffusion_explicit_element.py:112
x2
Definition: generate_frictional_mortar_condition.py:122
x1
Definition: generate_frictional_mortar_condition.py:121
tuple tmp
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:98
out
Definition: isotropic_damage_automatic_differentiation.py:200
R
Definition: isotropic_damage_automatic_differentiation.py:172
float radius
Definition: mesh_to_mdpa_converter.py:18
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
p
Definition: sensitivityMatrix.py:52
N
Definition: sensitivityMatrix.py:29
x
Definition: sensitivityMatrix.py:49
int dim
Definition: sensitivityMatrix.py:25
volume
Definition: sp_statistics.py:15
integer i
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31