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.
tetrahedra_reconnect_utility.h
Go to the documentation of this file.
1 //
2 //
3 // Project Name: Kratos
4 // Last Modified by: $Author: pooyan $
5 // Date: $Date: 2006-11-27 16:07:33 $
6 // Revision: $Revision: 1.1.1.1 $
7 //
8 //
9 
10 #if !defined(KRATOS_TETRAHEDRA_RECONNECT_H_INCLUDED )
11 #define KRATOS_TETRAHEDRA_RECONNECT_H_INCLUDED
12 
13 
14 
15 // System includes
16 #include <string>
17 #include <iostream>
18 #include "utilities/openmp_utils.h"
19 // External includes
20 
21 
22 // Project includes
23 #include "includes/define.h"
24 #include "includes/model_part.h"
26 
28 
29 #include "u_qualityMetrics.h"
30 #include "Math3D.h"
31 #include "u_Types.h"
32 #include "u_TetraFunctions.h"
33 #include "u_ShowMetrics.h"
34 #include "u_ParallelFunctions.h"
35 #include "u_MeshLoaders.h"
36 #include "u_elementCluster.h"
37 #include "u_ProcessTime.h"
38 #include "u_TetGenInterface.h"
39 
40 #ifdef _OPENMP
41 #include <omp.h>
42 #endif
43 
44 
45 namespace Kratos
46 {
49 
52 
56 
60 
64 
68 
70 
73 {
74 public:
78  int blockSize ;
79  bool debugMode;
82 
86  // inner Mesh
87  TVolumeMesh *m ;
88 
90 
93  refMP(r_model_part)
94  {
95  std::cout << "Creating mesh" << "\n";
96  m = new TVolumeMesh();
97  // Convert to inner format
98  innerConvertFromKratos(r_model_part , m );
99  //refMP = r_model_part;
100 
101  maxNumThreads = 0;
102  blockSize = 2048;
103 
104  }
105 
107  virtual ~TetrahedraReconnectUtility() = default;
108 
109 
113 
114 
117 
122  void innerConvertFromKratos(ModelPart& r_model_part, TVolumeMesh *m)
123  {
124  if (debugMode) std::cout << "Reading nodes"<< "\n";
125  //reorder node Ids consecutively
126  unsigned int id=1;
127  for (ModelPart::NodesContainerType::iterator i_node = r_model_part.NodesBegin() ; i_node != r_model_part.NodesEnd() ; i_node++)
128  i_node->SetId(id++);
129 
130  //loop on nodes
131  for (ModelPart::NodesContainerType::iterator it=r_model_part.NodesBegin(); it!=r_model_part.NodesEnd(); it++)
132  {
133  float4 fPos ;
134  fPos.x = it->X();
135  fPos.y = it->Y();
136  fPos.z = it->Z();
137  auto v = new TVertex(fPos);
138  v->setID( it->Id() );
139  v->blockID = true;
140  m->vertexes->Add(v);
141  }
142  if (debugMode) std::cout << "Reading elements"<< "\n";
143 
144  for (ModelPart::ElementsContainerType::iterator el_it=r_model_part.ElementsBegin(); el_it!=r_model_part.ElementsEnd(); el_it++)
145  {
146  Geometry< Node >& geom = el_it->GetGeometry();
147  if (geom.size() != 4)
148  {
149  std::cout << "Invalid element size" << el_it->Id();
150  continue;
151  }
152  TVertex *v0 = m->findVertexById(geom[0].Id());
153  if ( v0 == nullptr )
154  {
155  std::cout << "Invalid element reference" << el_it->Id();
156  continue;
157  }
158  TVertex *v1 = m->findVertexById(geom[1].Id());
159  if ( v1 == nullptr )
160  {
161  std::cout << "Invalid element reference" << el_it->Id();
162  continue;
163  }
164  TVertex *v2 = m->findVertexById(geom[2].Id());
165  if ( v2 == nullptr )
166  {
167  std::cout << "Invalid element reference" << el_it->Id();
168  continue;
169  }
170  TVertex *v3 = m->findVertexById(geom[3].Id());
171  if ( v3 == nullptr )
172  {
173  std::cout << "Invalid element reference" << el_it->Id();
174  continue;
175  }
176 
177  auto t = new TTetra(nullptr, v0,v1,v2,v3);
178  m->elements->Add(t);
179  }
180 
181  if (debugMode) std::cout << " Number of vertexes read :"<< m->vertexes->Count() <<"\n";
182  if (debugMode) std::cout << " Number of elements read :"<< m->elements->Count() << "\n";
183  m->updateIndexes(GENERATE_SURFACE | KEEP_ORIG_IDS);
184  if (debugMode) std::cout << " Number of faces read :"<< m->fFaces->Count() << "\n";
185 
186  }
187 
193  void innerConvertToKratos(ModelPart& mrModelPart , TVolumeMesh *m, bool removeFreeVertexes)
194  {
195  if (debugMode) std::cout << "-------------Generating for Kratos----------------" << "\n";
196  m->vertexes->Sort(sortByID);
197  Element::Pointer pReferenceElement = *(mrModelPart.Elements().begin()).base();
198 
199  // Mark elements to delete
200  // 0 Not remove
201  // 1 Remove
202  for (int i=0; i< m->vertexes->Count(); i++)
203  {
204  if (m->vertexes->structure[i]->elementsList->Count() == 0)
205  m->vertexes->elementAt(i)->flag = 1;
206  else
207  m->vertexes->elementAt(i)->flag = 0;
208  }
209  if (debugMode) std::cout << " Nodes : Mark elements to remove : " << "\n";
210  bool shownMessage = false;
211  /* Control de Indices
212  int indexv = 0;
213  TMeshLoader* ml2 = new TVMWLoader();
214  std::string s("d:/MeshKratos_innerConvertion.vwm");
215  ml2->save( s, m);
216  delete ml2;
217  */
218  // Create new Nodes
219  for (ModelPart::NodesContainerType::iterator i_node = mrModelPart.Nodes().begin() ; i_node != mrModelPart.Nodes().end() ; i_node++)
220  {
221  TVertex* v = m->findVertexById(i_node->Id());
222  if (v == nullptr)
223  {
224  if (!shownMessage)
225  std::cout << "Error at id "<<i_node->Id() << "\n";
226  shownMessage = true;
227  continue;
228  }
229  i_node->Set(TO_ERASE ,v->flag == 1);
230  }
231  if (debugMode) std::cout << " Generating Elements for Kratos " << "\n";
232  //generate new nodes
233  mrModelPart.Elements().clear();
234  //add preserved elements to the kratos
235  Properties::Pointer properties = mrModelPart.GetMesh().pGetProperties(1);
236  (mrModelPart.Elements()).reserve(m->elements->Count());
237  bool messageShown = false;
238 
239  for (int i=0; i< m->elements->Count() ; i++)
240  {
241 
242  TTetra* t = (TTetra*)(m->elements->elementAt(i));
243  Node::Pointer v0 = mrModelPart.pGetNode(t->vertexes[0]->getID());
244  Node::Pointer v1 = mrModelPart.pGetNode(t->vertexes[1]->getID());
245  Node::Pointer v2 = mrModelPart.pGetNode(t->vertexes[2]->getID());
246  Node::Pointer v3 = mrModelPart.pGetNode(t->vertexes[3]->getID());
247  if ((v0.get() == nullptr) || (v1.get()==nullptr) || (v2.get() == nullptr) || (v3.get() == nullptr))
248 
249  {
250  if (!messageShown)
251  std::cout << "Invalid vertex access " << t->getID() <<"\n";
252  messageShown = true;
253  continue ;
254  }
256  v0,v1,v2,v3
257  );
258 
259  Element::Pointer p_element = pReferenceElement->Create(i+1, geom, properties);
260  (mrModelPart.Elements()).push_back(p_element);
261  //KRATOS_WATCH(*p_element);
262  }
263  if (debugMode) std::cout << "Generation OK " << "\n";
264  mrModelPart.Elements().Sort();
265 
266  if (removeFreeVertexes )
267  {
268  std::cout << "Removing free vertexes " << "\n";
269  (EntitiesEraseProcess<Node>(mrModelPart)).Execute();
270  }
271  if (debugMode) std::cout << "-----------------Generation Finished OK-------------------" << "\n";
272 
273  // TVolumeMesh *testM = new TVolumeMesh();
274  // innerConvertFromKratos( mrModelPart , testM);
275 
276  }
277 
279  {
280  auto qt = new TetQuality(m) ;
281  qt->refresh();
282  qt->print();
283  int numNegElements = qt->nonPositive;
284  delete qt;
285  return numNegElements == 0;
286  }
287 
292  {
293  for (int i=0 ; i<100 ; i++)
294  {
295  m->elementsToRemove->Add( m->elements->elementAt(i));
296  }
297  m->updateRefs();
298  }
299 
303  void updateNodesPositions(ModelPart& r_model_part)
304  {
305  std::cout << "Updating nodes"<< "\n";
306  //loop on nodes
307  for (ModelPart::NodesContainerType::iterator it=r_model_part.NodesBegin(); it!=r_model_part.NodesEnd(); it++)
308  {
309  float4 fPos ;
310  fPos.x = it->X();
311  fPos.y = it->Y();
312  fPos.z = it->Z();
313  fPos.w = 1.0f;
314 
315  int id = it->Id();
316  TVertex *v = m->findVertexById(id);
317  if (v == nullptr)
318  v->fPos = fPos;
319  }
320  }
331 
332  void setMaxNumThreads(int mxTh)
333  {
334  maxNumThreads = mxTh;
335  }
336 
337  void setBlockSize(int bs)
338  {
339  blockSize = bs;
340  }
341 
343  {
344  auto qt = new TetQuality(m) ;
345  qt->refresh();
346  int numNegElements = qt->nonPositive;
347  delete qt;
348  return numNegElements == 0;
349  }
350 
351  void InterpolateAndAddNewNodes(ModelPart& rModelPart, TVolumeMesh* m, BinBasedFastPointLocator<3>& element_finder)
352  {
353  unsigned int n_points_before_refinement = rModelPart.Nodes().size();
354 
355  //if the refinement was performed, we need to add it to the model part.
356  if (m->vertexes->Count()>(int)n_points_before_refinement)
357  {
358  //defintions for spatial search
359 // typedef Node PointType;
360 // typedef Node ::Pointer PointTypePointer;
362  const int max_results = 10000;
364 
365  Node::DofsContainerType& reference_dofs = (rModelPart.NodesBegin())->GetDofs();
366 
367  int step_data_size = rModelPart.GetNodalSolutionStepDataSize();
368  std::cout <<"...Adding Nodes :"<< m->vertexes->Count() - n_points_before_refinement<<"\n";
369  //TODO: parallelize this loop
370  for (int i = n_points_before_refinement; i<m->vertexes->Count(); i++)
371  {
372  int id=i+1;
373 
374  TVertex *v = m->vertexes->elementAt(i);
375  double x= (float)(v->fPos.x);
376  double y= (float)(v->fPos.y);
377  double z= (float)(v->fPos.z);
378 
379  Node::Pointer pnode = rModelPart.CreateNewNode(id,x,y,z);
380 
381  //putting the new node also in an auxiliary list
382  //KRATOS_WATCH("adding nodes to list")
383  //list_of_new_nodes.push_back( pnode );
384 
385  //std::cout << "new node id = " << pnode->Id() << std::endl;
386  //generating the dofs
387  for (Node::DofsContainerType::iterator iii = reference_dofs.begin(); iii != reference_dofs.end(); iii++)
388  {
389  Node::DofType &rDof = **iii;
390  Node::DofType::Pointer p_new_dof = pnode->pAddDof( rDof );
391 
392  (p_new_dof)->FreeDof();
393  }
394 
395  //do interpolation
396  auto result_begin = results.begin();
397  Element::Pointer pelement;
398 
399  bool is_found = element_finder.FindPointOnMesh(pnode->Coordinates(), N, pelement, result_begin, max_results);
400 
401  if (is_found == true)
402  {
403  Geometry<Node >& geom = pelement->GetGeometry();
404 
405  Interpolate( geom, N, step_data_size, pnode);
406  }
407 
408 
409  }
410  }
411  // std::cout << "During refinement we added " << tet.numberofpoints-n_points_before_refinement<< "nodes " <<std::endl;
412  }
413 
414  void setVertexExpectedSize(ModelPart& rModelPart, TVolumeMesh* m )
415  {
416  for (int el = 0; el< m->elements->Count(); el++)
417  {
418 
419  //calculate the prescribed h
420  /* double prescribed_h = (nodes_begin + out.tetrahedronlist[old_base]-1)->FastGetSolutionStepValue(NODAL_H);
421  prescribed_h += (nodes_begin + out.tetrahedronlist[old_base+1]-1)->FastGetSolutionStepValue(NODAL_H);
422  prescribed_h += (nodes_begin + out.tetrahedronlist[old_base+2]-1)->FastGetSolutionStepValue(NODAL_H);
423  prescribed_h += (nodes_begin + out.tetrahedronlist[old_base+3]-1)->FastGetSolutionStepValue(NODAL_H);
424  prescribed_h *= 0.25;*/
425  TTetra *t = (TTetra*)(m->elements->elementAt(el));
426  ModelPart::NodesContainerType& rNodes = rModelPart.Nodes();
427  ModelPart::NodesContainerType::iterator it1 = (rNodes).find( t->vertexes[0]->getID());
428  ModelPart::NodesContainerType::iterator it2 = (rNodes).find( t->vertexes[1]->getID());
429  ModelPart::NodesContainerType::iterator it3 = (rNodes).find( t->vertexes[2]->getID());
430  ModelPart::NodesContainerType::iterator it4 = (rNodes).find( t->vertexes[3]->getID());
431 
432  if ( it1 == rModelPart.Nodes().end() )
433  KRATOS_THROW_ERROR(std::logic_error,"trying to use an inexisting node with id ",it1->Id());
434  if ( it2 == rModelPart.Nodes().end() )
435  KRATOS_THROW_ERROR(std::logic_error,"trying to use an inexisting node with id ",it2->Id());
436  if ( it3 == rModelPart.Nodes().end() )
437  KRATOS_THROW_ERROR(std::logic_error,"trying to use an inexisting node with id ",it3->Id());
438  if ( it4 == rModelPart.Nodes().end() )
439  KRATOS_THROW_ERROR(std::logic_error,"trying to use an inexisting node with id ",it4->Id());
440 
441  Node::Pointer pn1 = *it1.base();
442  Node::Pointer pn2 = *it2.base();
443  Node::Pointer pn3 = *it3.base();
444  Node::Pointer pn4 = *it4.base();
445 
446  t->vertexes[0]->expectedSize = (pn1)->FastGetSolutionStepValue(NODAL_H);
447  t->vertexes[1]->expectedSize = (pn2)->FastGetSolutionStepValue(NODAL_H);
448  t->vertexes[2]->expectedSize = (pn3)->FastGetSolutionStepValue(NODAL_H);
449  t->vertexes[3]->expectedSize = (pn4)->FastGetSolutionStepValue(NODAL_H);
450 
451  //if h is the height of a perfect tetrahedra, the edge size is edge = sqrt(3/2) h
452  //filling in the list of "IDEAL" tetrahedron volumes=1/12 * (edge)^3 * sqrt(2)~0.11785* h^3=
453  //0.2165063509*h^3
454 // double prescribed_h = (t->vertexes[0]->expectedSize + t->vertexes[1]->expectedSize +
455 // t->vertexes[2]->expectedSize +t->vertexes[3]->expectedSize) * 0.25;
456 //
457  //out.tetrahedronvolumelist[counter] = 0.217*prescribed_h*prescribed_h*prescribed_h;
458 
459 
460  }
461  }
465  unsigned int step_data_size,
466  Node::Pointer pnode)
467  {
468  unsigned int buffer_size = pnode->GetBufferSize();
469 
470 
471  for (unsigned int step = 0; step<buffer_size; step++)
472  {
473 
474  //getting the data of the solution step
475  double* step_data = (pnode)->SolutionStepData().Data(step);
476 
477 
478  double* node0_data = geom[0].SolutionStepData().Data(step);
479  double* node1_data = geom[1].SolutionStepData().Data(step);
480  double* node2_data = geom[2].SolutionStepData().Data(step);
481  double* node3_data = geom[3].SolutionStepData().Data(step);
482 
483  //copying this data in the position of the vector we are interested in
484  for (unsigned int j= 0; j<step_data_size; j++)
485  {
486 
487  step_data[j] = N[0]*node0_data[j] + N[1]*node1_data[j] + N[2]*node2_data[j] + N[3]*node3_data[j];
488 
489 
490  }
491  }
492  pnode->FastGetSolutionStepValue(IS_BOUNDARY)=0.0;
493  }
494 
495  void OptimizeQuality(ModelPart& r_model_part,int simIter, int iterations ,
496  bool processByNode, bool processByFace, bool processByEdge,
497  bool saveToFile, bool removeFreeVertexes ,
498  bool evaluateInParallel , bool reinsertNodes , bool debugMode, int minAngle)
499  {
500  this->debugMode = debugMode;
501  m->vertexes->Sort(sortByID);
502 
503 
504  // Save the mesh as generated from Kratos
505  if (saveToFile)
506  {
507  TMeshLoader* ml2 = new TVMWLoader();
508  std::string s("out_MeshFromKratos.vwm");
509  ml2->save( s, m);
510  delete ml2;
511  }
512  if (debugMode && saveToFile)
513  {
514  EvaluateQuality();
515  setVertexExpectedSize(r_model_part , m);
516  std::cout <<"...Start Optimization..." <<"\n";
517  auto ml2 = new TVMWLoader();
518  std::string s("");
519  s = "../out_MeshFromKratos" + intToString(simIter)+".vwm";
520 
521  ml2->save( s.data(), m);
522  delete ml2;
523 
524  return ;
525  }
526 
527  if (debugMode) std::cout <<"...Start Optimization..." <<"\n";
528  // maxNumThreads works as a FLAG
529  // when equals to 0, take "max available threads"
530  // in other case, take "set num threads"
531 
532  if ( maxNumThreads == 0)
533  {
534 #ifdef _OPENMP
535  OpenMPUtils::SetNumThreads(omp_get_max_threads());
536 #endif
537  }
538  else
539  OpenMPUtils::SetNumThreads(maxNumThreads);
540 
541  if (debugMode)
542  {
543  std::cout <<"Number of active threads"<< OpenMPUtils::GetNumThreads() <<"\n";
544  std::cout <<"Debug mode is Active" <<"\n";
545  startTimers();
546  }
547  else
548  {
549  stopTimers();
550  }
551  std::cout <<"...Trying to allocate memory\n";
552  preparePool();
553  std::cout <<"...Allocate memory OK\n";
554 
555  for (int iter = 0 ; iter< iterations ; iter ++)
556  {
557  //ParallelEvaluateClusterByNode(m,vrelaxQuality);
558  if (processByNode)
559  {
560 
561  if (evaluateInParallel )
562  {
563  if (debugMode) std::cout <<"...Parallel optimizing by Node. Iteration : "<< iter <<"\n";
564  ParallelEvaluateClusterByNode((TVolumeMesh*)(m),vrelaxQuality,minAngle);
565  }
566  else
567  {
568  if (debugMode) std::cout <<"...Optimizing by Node. Iteration : "<< iter <<"\n";
569  evaluateClusterByNode( (TVolumeMesh*)(m),minAngle,vrelaxQuality);
570  }
571  if (debugMode)
572  m->updateIndexes(GENERATE_SURFACE | KEEP_ORIG_IDS);
573  }
574 
575  if (processByFace)
576  {
577  if (evaluateInParallel )
578  {
579  if (debugMode) std::cout <<"...Parallel optimizing by Face. Iteration : "<< iter <<"\n";
580  ParallelEvaluateClusterByFace((TVolumeMesh*)(m),vrelaxQuality,minAngle);
581  if (debugMode) std::cout <<"...End. Iteration : "<< iter <<"\n";
582  }
583  else
584  {
585  if (debugMode) std::cout <<"...Optimizing by Face. Iteration : "<< iter <<"\n";
586  evaluateClusterByFace(m,minAngle,vrelaxQuality);
587  if (debugMode) std::cout <<"...End. Iteration : "<< iter <<"\n";
588  }
589  if (debugMode)
590  m->updateIndexes(GENERATE_SURFACE | KEEP_ORIG_IDS);
591  }
592 
593  if (processByEdge)
594  {
595 
596  if (evaluateInParallel )
597  {
598  if (debugMode) std::cout <<"...Parallel optimizing by Edge. Iteration : "<< iter <<"\n";
599  ParallelEvaluateClusterByEdge((TVolumeMesh*)(m),vrelaxQuality,minAngle);
600  if (debugMode) std::cout <<"...End. Iteration : "<< iter <<"\n";
601  }
602  else
603  {
604  if (debugMode) std::cout <<"...Optimizing by Edge. Iteration : "<< iter <<"\n";
605  evaluateClusterByEdge( (TVolumeMesh*)(m),minAngle,vrelaxQuality);
606  }
607  if (debugMode)
608  m->updateIndexes(GENERATE_SURFACE | KEEP_ORIG_IDS);
609  }
610 
611  if (debugMode)
612  {
613  std :: cout<< "Number of faces:" << m->fFaces->Count() << "\n";
614  EvaluateQuality();
615  m->updateIndexes(GENERATE_SURFACE | KEEP_ORIG_IDS);
616  m->validate(true);
617  std :: cout<< "Number of faces:" << m->fFaces->Count() << "\n";
618  showProcessTime();
619  }
620  // Save the mesh as generated from Kratos
621  if (saveToFile)
622  {
623  TMeshLoader* ml2 = new TVMWLoader();
624  std::string s("");
625  s = "out_MeshFromKratos" + intToString(iter)+".vwm";
626  // BUG Linux/Windows
627  ml2->save(s , m);
628  delete ml2;
629  }
630  }
631 
632  if (saveToFile)
633  {
634  TMeshLoader* ml2 = new TVMWLoader();
635  std::string s("out_MeshC.vwm");
636  ml2->save(s, m);
637  delete ml2;
638  }
639 
640  if (reinsertNodes)
641  {
642  if (debugMode) std::cout <<"...Trying to reinsert nodes..." <<"\n";
644  }
645 
646  // Sino pudo mejorar la malla
647  /*
648  TVolumeMesh* m2 = (TVolumeMesh*)(GenerateMesh(m));
649  m= m2;
650  */
652  //construct spatial structure with an auxiliary model part
653 
654  std::cout <<"...Interpolating and adding new Nodes..." <<"\n";
655  BinBasedFastPointLocator<3> element_finder(r_model_part);
656  element_finder.UpdateSearchDatabase();
657  InterpolateAndAddNewNodes(r_model_part, m,element_finder);
658 
659  }
663  {
664  int vToR =m->vertexesToRemove->Count();
665  int ri = vertexTetraReInsertion(m , m->vertexesToRemove);
666  m->updateIndexes(GENERATE_SURFACE | KEEP_ORIG_IDS);
667  std :: cout<< " Reinsert vertexes " << ri << " of " << vToR <<"\n";
668  EvaluateQuality();
669  m->validate(true);
670  std :: cout<< "........................................"<<"\n";
671  }
674  void FinalizeOptimization(bool removeFreeVertexes )
675  {
676  if (m == nullptr ) return ;
677  if (debugMode) std::cout <<"...Output to Kratos Format" <<"\n";
678  // Get back in Kratos
679  innerConvertToKratos(refMP , m , removeFreeVertexes);
680  delete m;
681  m = nullptr;
682  std::cout <<"...Trying to release memory\n";
683  clearPool();
684  std::cout <<"...Release memory OK\n";
685 
686  }
687 
688 
692 
693 
697 
698 
702 
704  virtual std::string Info() const
705  {
706  std::stringstream buffer;
707  buffer << "TetrahedraReconnectUtility" ;
708  return buffer.str();
709  }
710 
712  virtual void PrintInfo(std::ostream& rOStream) const
713  {
714  rOStream << "TetrahedraReconnectUtility";
715  }
716 
718  virtual void PrintData(std::ostream& rOStream) const {}
719 
720 
724 
725 
727 
728 protected:
731 
732 
736 
737 
741 
742 
746 
747 
751 
752 
756 
757 
761 
762 
764 
765 private:
768 
769 
773 
774 
778 
779 
783 
784 
788 
789 
793 
794 
798 
801  {
802  return *this;
803  }
804 
807 
808 
810 
811 }; // Class TetrahedraReconnectUtility
812 
814 
817 
818 
822 
823 
825 inline std::istream& operator >> (std::istream& rIStream,
827 {
828  return rIStream;
829 }
830 
832 inline std::ostream& operator << (std::ostream& rOStream,
833  const TetrahedraReconnectUtility& rThis)
834 {
835  rThis.PrintInfo(rOStream);
836  rOStream << std::endl;
837  rThis.PrintData(rOStream);
838 
839  return rOStream;
840 }
842 
844 
845 } // namespace Kratos.
846 
847 #endif // KRATOS_TETRAHEDRA_RECONNECT_H_INCLUDED defined
848 
849 
This class is designed to allow the fast location of MANY points on the top of a 3D mesh.
Definition: binbased_fast_point_locator.h:68
void UpdateSearchDatabase()
Function to construct or update the search database.
Definition: binbased_fast_point_locator.h:139
ConfigureType::ResultContainerType ResultContainerType
Definition: binbased_fast_point_locator.h:81
Dof represents a degree of freedom (DoF).
Definition: dof.h:86
This process removes the entities from a model part with the flag TO_ERASE.
Definition: entity_erase_process.h:70
Geometry base class.
Definition: geometry.h:71
SizeType size() const
Definition: geometry.h:518
IndexType const & Id() const
Id of this Geometry.
Definition: geometry.h:964
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
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
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
std::vector< std::unique_ptr< Dof< double > >> DofsContainerType
The DoF container type definition.
Definition: node.h:92
A four node tetrahedra geometry with linear shape functions.
Definition: tetrahedra_3d_4.h:59
Short class definition.
Definition: tetrahedra_reconnect_utility.h:73
bool debugMode
Definition: tetrahedra_reconnect_utility.h:79
void updateNodesPositions(ModelPart &r_model_part)
function updateNodesPositions Update only nodes positions without regenerating the structure
Definition: tetrahedra_reconnect_utility.h:303
int maxNumThreads
Definition: tetrahedra_reconnect_utility.h:77
void innerConvertToKratos(ModelPart &mrModelPart, TVolumeMesh *m, bool removeFreeVertexes)
function innerConvertToKratos This function converts back to Kratos format
Definition: tetrahedra_reconnect_utility.h:193
void setMaxNumThreads(int mxTh)
function OptimizeQuality
Definition: tetrahedra_reconnect_utility.h:332
TVolumeMesh * m
Definition: tetrahedra_reconnect_utility.h:87
KRATOS_CLASS_POINTER_DEFINITION(TetrahedraReconnectUtility)
Pointer definition of TetrahedraReconnectUtility.
virtual std::string Info() const
Turn back information as a string.
Definition: tetrahedra_reconnect_utility.h:704
void OptimizeQuality(ModelPart &r_model_part, int simIter, int iterations, bool processByNode, bool processByFace, bool processByEdge, bool saveToFile, bool removeFreeVertexes, bool evaluateInParallel, bool reinsertNodes, bool debugMode, int minAngle)
Definition: tetrahedra_reconnect_utility.h:495
void setBlockSize(int bs)
Definition: tetrahedra_reconnect_utility.h:337
void setVertexExpectedSize(ModelPart &rModelPart, TVolumeMesh *m)
Definition: tetrahedra_reconnect_utility.h:414
virtual ~TetrahedraReconnectUtility()=default
Destructor.
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: tetrahedra_reconnect_utility.h:712
void FinalizeOptimization(bool removeFreeVertexes)
function FinalizeOptimization Destroy the structure
Definition: tetrahedra_reconnect_utility.h:674
void TestRemovingElements()
Definition: tetrahedra_reconnect_utility.h:291
TetrahedraReconnectUtility(ModelPart &r_model_part)
Default constructor.
Definition: tetrahedra_reconnect_utility.h:92
bool isaValidMesh()
Definition: tetrahedra_reconnect_utility.h:342
int blockSize
Definition: tetrahedra_reconnect_utility.h:78
ModelPart & refMP
Definition: tetrahedra_reconnect_utility.h:89
bool EvaluateQuality()
Definition: tetrahedra_reconnect_utility.h:278
void Interpolate(Geometry< Node > &geom, const array_1d< double, 4 > &N, unsigned int step_data_size, Node::Pointer pnode)
Definition: tetrahedra_reconnect_utility.h:464
void InterpolateAndAddNewNodes(ModelPart &rModelPart, TVolumeMesh *m, BinBasedFastPointLocator< 3 > &element_finder)
Definition: tetrahedra_reconnect_utility.h:351
void tryToReinsertNodes()
function tryToReinsertNodes Reinsert removed nodes into the structure
Definition: tetrahedra_reconnect_utility.h:662
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: tetrahedra_reconnect_utility.h:718
void innerConvertFromKratos(ModelPart &r_model_part, TVolumeMesh *m)
function innerConvertFromKratos This function converts from Kratos format, to the inner structure
Definition: tetrahedra_reconnect_utility.h:122
#define KRATOS_THROW_ERROR(ExceptionType, ErrorMessage, MoreInfo)
Definition: define.h:77
z
Definition: GenerateWind.py:163
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
int step
Definition: face_heat.py:88
y
Other simbols definition.
Definition: generate_axisymmetric_navier_stokes_element.py:54
v
Definition: generate_convection_diffusion_explicit_element.py:114
int t
Definition: ode_solve.py:392
int j
Definition: quadrature.py:648
el
Definition: read_stl.py:25
N
Definition: sensitivityMatrix.py:29
x
Definition: sensitivityMatrix.py:49
integer i
Definition: TensorModule.f:17