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.
insert_fluid_nodes_mesher_process.hpp
Go to the documentation of this file.
1 //
2 // Project Name: KratosPfemApplication $
3 // Created by: $Author: AFranci $
4 // Last modified by: $Co-Author: $
5 // Date: $Date: July 2018 $
6 // Revision: $Revision: 0.0 $
7 //
8 //
9 
10 
11 #if !defined(KRATOS_INSERT_FLUID_NODES_MESHER_PROCESS_H_INCLUDED )
12 #define KRATOS_INSERT_FLUID_NODES_MESHER_PROCESS_H_INCLUDED
13 
14 
15 // External includes
16 
17 // System includes
18 
19 // Project includes
22 
23 #include "includes/model_part.h"
27 
28 
29 namespace Kratos
30 {
31 
34 
36 
41  : public MesherProcess
42 {
43  public:
46 
49 
54 
58 
61  MesherUtilities::MeshingParameters& rRemeshingParameters,
62  int EchoLevel)
63  : mrModelPart(rModelPart),
64  mrRemesh(rRemeshingParameters)
65  {
66  mEchoLevel = EchoLevel;
67  }
68 
69 
72 
73 
77 
79  void operator()()
80  {
81  Execute();
82  }
83 
84 
88 
90  void Execute() override
91  {
93 
94  if( mEchoLevel > 1 )
95  std::cout<<" [ INSERT NEW NODES for homomgeneous mesh: "<<std::endl;
96 
97  if( mrModelPart.Name() != mrRemesh.SubModelPartName )
98  std::cout<<" ModelPart Supplied do not corresponds to the Meshing Domain: ("<<mrModelPart.Name()<<" != "<<mrRemesh.SubModelPartName<<")"<<std::endl;
99 
100  unsigned int ElementsToRefine = mrRemesh.Info->RemovedNodes;
101 
102  if( ElementsToRefine > 0 )
103  {
104  std::vector<array_1d<double,3> > NewPositions(ElementsToRefine);
105  std::vector<array_1d< unsigned int,4 > > NodeIdsToInterpolate(ElementsToRefine);
106  std::vector<Node::DofsContainerType > NewDofs(ElementsToRefine);
107  std::vector<double > LargestVolumes(ElementsToRefine);
108  std::fill(LargestVolumes.begin(), LargestVolumes.end(), -1 );
109 
110  unsigned int NodesToRefine=0;
111 
112  for(ModelPart::ElementsContainerType::const_iterator i_elem = mrModelPart.ElementsBegin(); i_elem != mrModelPart.ElementsEnd(); ++i_elem)
113  {
114 
115  const unsigned int dimension = i_elem->GetGeometry().WorkingSpaceDimension();
116 
117  if(dimension==2){
118  if( i_elem->GetGeometry().size() > 2 ) //not boundary elements
119  SelectEdgeToRefine2D(i_elem->GetGeometry(),NewPositions,LargestVolumes,NodeIdsToInterpolate,NewDofs,NodesToRefine,ElementsToRefine);
120  } else if(dimension==3){
121  if( i_elem->GetGeometry().size() > 3 ) //not boundary elements
122  SelectEdgeToRefine3D(i_elem->GetGeometry(),NewPositions,LargestVolumes,NodeIdsToInterpolate,NewDofs,NodesToRefine,ElementsToRefine);
123  }
124 
125  }
126 
127  mrRemesh.Info->InsertedNodes = NodesToRefine;
128 
129  // Here only splits as vertices as removed nodes ( without cheking the longest vertices )
130  this->CreateAndAddNewNodes(NewPositions,NodeIdsToInterpolate,NewDofs,ElementsToRefine);
131 
132  }
133 
134  if( mEchoLevel > 1 )
135  std::cout<<" INSERT NEW NODES ]; ("<<mrRemesh.Info->InsertedNodes<<")"<<std::endl;
136 
137 
138  KRATOS_CATCH(" ")
139  }
140 
141 
145 
146 
150 
151 
155 
157  std::string Info() const override
158  {
159  return "InsertFluidNodesMesherProcess";
160  }
161 
163  void PrintInfo(std::ostream& rOStream) const override
164  {
165  rOStream << "InsertFluidNodesMesherProcess";
166  }
167 
169  void PrintData(std::ostream& rOStream) const override
170  {
171  }
172 
173 
177 
179 
180 
181  private:
184 
188 
189  ModelPart& mrModelPart;
190 
192 
193  MesherUtilities mMesherUtilities;
194 
195  int mEchoLevel;
196 
200 
201 
205 
206  //**************************************************************************
207  //**************************************************************************
208 
209  void FlagsCounter(GeometryType& rGeometry, unsigned int& rigid_nodes,unsigned int& freesurface_nodes,unsigned int& inlet_nodes,unsigned int& nodes_to_split, unsigned int& nodes_to_erase)
210  {
211  const unsigned int NumberOfNodes = rGeometry.size();
212  for(unsigned int i=0; i<NumberOfNodes; ++i)
213  {
214  if(rGeometry[i].Is(RIGID)){
215  ++rigid_nodes;
216  }
217  if(rGeometry[i].Is(FREE_SURFACE)){
218  ++freesurface_nodes;
219  }
220  if(rGeometry[i].Is(INLET)){
221  ++inlet_nodes;
222  }
223  if(rGeometry[i].Is(TO_SPLIT)){
224  ++nodes_to_split;
225  }
226  if(rGeometry[i].Is(TO_ERASE)){
227  ++nodes_to_erase;
228  }
229 
230  }
231 
232  }
233 
234  void CopyDofs(Node::DofsContainerType const& From, Node::DofsContainerType& To){
235  for(auto& p_dof : From){
236  To.push_back(Kratos::unique_ptr<Dof<double>>(new Dof<double>(*p_dof)));
237  }
238  }
239 
240  //**************************************************************************
241  //**************************************************************************
242 
243  void SelectEdgeToRefine2D( Element::GeometryType& rGeometry,
244  std::vector<array_1d<double,3> >& rNewPositions,
245  std::vector<double >& rLargestVolumes,
246  std::vector<array_1d< unsigned int,4 > >& rNodeIdsToInterpolate,
247  std::vector<Node::DofsContainerType >& rNewDofs,
248  unsigned int& rNodesToRefine,
249  const unsigned int& rElementsToRefine)
250  {
251  KRATOS_TRY
252 
253  const unsigned int NumberOfNodes = rGeometry.size();
254 
255  unsigned int rigid_nodes=0;
256  unsigned int freesurface_nodes=0;
257  unsigned int inlet_nodes=0;
258  unsigned int nodes_to_split=0;
259  unsigned int nodes_to_erase=0;
260 
261  this->FlagsCounter(rGeometry, rigid_nodes, freesurface_nodes, inlet_nodes, nodes_to_split, nodes_to_erase);
262 
263  bool any_node_to_erase=false;
264  if( nodes_to_erase > 0 )
265  any_node_to_erase = true;
266 
267  double critical_edge_length=5.0*mrRemesh.Refine->CriticalRadius;
268 
269  double length_tolerance=1.5;
270  double penalization=1.0;
271 
272  if(rigid_nodes>1){
273  // penalization=0.7;
274  penalization=0.8;
275  if(inlet_nodes>0){
276  penalization=0.9;
277  }
278  }
279 
280  double ElementalVolume = rGeometry.Area();
281 
282  array_1d<double,3> Edges(3,0.0);
283  array_1d<unsigned int,3> FirstEdgeNode(3,0);
284  array_1d<unsigned int,3> SecondEdgeNode(3,0);
285 
286  double WallCharacteristicDistance=0;
287  array_1d<double,3> CoorDifference;
288  noalias(CoorDifference) = rGeometry[1].Coordinates() - rGeometry[0].Coordinates();
289 
290  double SquaredLength = CoorDifference[0]*CoorDifference[0] + CoorDifference[1]*CoorDifference[1];
291  Edges[0]=sqrt(SquaredLength);
292  FirstEdgeNode[0]=0;
293  SecondEdgeNode[0]=1;
294  if(rGeometry[0].Is(RIGID) && rGeometry[1].Is(RIGID)){
295  WallCharacteristicDistance=Edges[0];
296  }
297  unsigned int Counter=0;
298  for (unsigned int i = 2; i < NumberOfNodes; ++i)
299  {
300  for(unsigned int j = 0; j < i; ++j)
301  {
302  noalias(CoorDifference) = rGeometry[i].Coordinates() - rGeometry[j].Coordinates();
303  SquaredLength = CoorDifference[0]*CoorDifference[0] + CoorDifference[1]*CoorDifference[1];
304  Counter+=1;
305  Edges[Counter]=sqrt(SquaredLength);
306  FirstEdgeNode[Counter]=j;
307  SecondEdgeNode[Counter]=i;
308  if(rGeometry[i].Is(RIGID) && rGeometry[j].Is(RIGID) && Edges[Counter]>WallCharacteristicDistance ){
309  WallCharacteristicDistance=Edges[Counter];
310  }
311  }
312 
313  }
314 
315  bool dangerousElement=false;
316 
317  if(rigid_nodes>1){
318 
319  for (unsigned int i = 0; i < 3; ++i)
320  {
321  if((Edges[i]<WallCharacteristicDistance*length_tolerance && (rGeometry[FirstEdgeNode[i]].Is(RIGID) || rGeometry[SecondEdgeNode[i]].Is(RIGID))) ||
322  (rGeometry[FirstEdgeNode[i]].Is(RIGID) && rGeometry[SecondEdgeNode[i]].Is(RIGID) )){
323  Edges[i]=0;
324 
325  }
326  if((rGeometry[FirstEdgeNode[i]].Is(FREE_SURFACE) || rGeometry[FirstEdgeNode[i]].Is(RIGID)) &&
327  (rGeometry[SecondEdgeNode[i]].Is(FREE_SURFACE)|| rGeometry[SecondEdgeNode[i]].Is(RIGID))){
328  Edges[i]=0;
329  }
330  }
331 
332  }
333 
334  if((Edges[0]==0 && Edges[1]==0 && Edges[2]==0) || rigid_nodes==3){
335  dangerousElement=true;
336  }
337 
338  if(dangerousElement==false && any_node_to_erase==false && nodes_to_split<2){
339 
340  unsigned int maxCount=2;
341  double LargestEdge=0;
342 
343  for(unsigned int i=0; i<3; ++i)
344  {
345  if(Edges[i]>LargestEdge){
346  maxCount=i;
347  LargestEdge=Edges[i];
348  }
349  }
350 
351  if(rNodesToRefine<rElementsToRefine && LargestEdge>critical_edge_length){
352 
353  array_1d<double,3> NewPosition;
354  noalias(NewPosition)= 0.5*(rGeometry[FirstEdgeNode[maxCount]].Coordinates()+rGeometry[SecondEdgeNode[maxCount]].Coordinates());
355 
356  rNodeIdsToInterpolate[rNodesToRefine][0]=rGeometry[FirstEdgeNode[maxCount]].GetId();
357  rNodeIdsToInterpolate[rNodesToRefine][1]=rGeometry[SecondEdgeNode[maxCount]].GetId();
358 
359  rGeometry[FirstEdgeNode[maxCount]].Set(TO_SPLIT);
360  rGeometry[SecondEdgeNode[maxCount]].Set(TO_SPLIT);
361 
362  if(rGeometry[SecondEdgeNode[maxCount]].IsNot(RIGID)){
363  CopyDofs(rGeometry[SecondEdgeNode[maxCount]].GetDofs(), rNewDofs[rNodesToRefine]);
364  }else if(rGeometry[FirstEdgeNode[maxCount]].IsNot(RIGID)){
365  CopyDofs(rGeometry[FirstEdgeNode[maxCount]].GetDofs(), rNewDofs[rNodesToRefine]);
366  }else{
367  std::cout<<"CAUTION! THIS IS A WALL EDGE"<<std::endl;
368  }
369 
370  std::cout<<" NewPosition" <<NewPosition<<" maxCount "<<maxCount<<" LargestEdge "<<LargestEdge<<std::endl;
371 
372  rLargestVolumes[rNodesToRefine]=ElementalVolume;
373  rNewPositions[rNodesToRefine]=NewPosition;
374  rNodesToRefine++;
375 
376  }
377  else if( freesurface_nodes<3 && rigid_nodes<3 ){
378 
379  ElementalVolume*=penalization;
380  for(unsigned int nn= 0; nn< rElementsToRefine; ++nn)
381  {
382  if(ElementalVolume>rLargestVolumes[nn]){
383 
384  bool suitableElement=true;
385  if(maxCount<3 && LargestEdge>critical_edge_length){
386  array_1d<double,3> NewPosition;
387  noalias(NewPosition) = 0.5*(rGeometry[FirstEdgeNode[maxCount]].Coordinates()+rGeometry[SecondEdgeNode[maxCount]].Coordinates());
388 
389  for(unsigned int j= 0; j< rElementsToRefine; ++j)
390  {
391  if(rNewPositions[j][0]==NewPosition[0] && rNewPositions[j][1]==NewPosition[1]){
392  suitableElement=false;
393  }
394  }
395 
396  if(suitableElement==true){
397  rNodeIdsToInterpolate[nn][0]=rGeometry[FirstEdgeNode[maxCount]].GetId();
398  rNodeIdsToInterpolate[nn][1]=rGeometry[SecondEdgeNode[maxCount]].GetId();
399 
400  rGeometry[FirstEdgeNode[maxCount]].Set(TO_SPLIT);
401  rGeometry[SecondEdgeNode[maxCount]].Set(TO_SPLIT);
402 
403  if(rGeometry[SecondEdgeNode[maxCount]].IsNot(RIGID)){
404  CopyDofs(rGeometry[SecondEdgeNode[maxCount]].GetDofs(), rNewDofs[nn]);
405  }else if(rGeometry[FirstEdgeNode[maxCount]].IsNot(RIGID)){
406  CopyDofs(rGeometry[FirstEdgeNode[maxCount]].GetDofs(), rNewDofs[nn]);
407  }else{
408  std::cout<<"CAUTION! THIS IS A WALL EDGE"<<std::endl;
409  }
410  rLargestVolumes[nn]=ElementalVolume;
411  rNewPositions[nn]=NewPosition;
412  }
413 
414  }
415 
416  break;
417  }
418  }
419 
420  }
421  }
422 
423  // reset TO_SPLIT
424  for(ModelPart::NodesContainerType::const_iterator in = mrModelPart.NodesBegin(); in != mrModelPart.NodesEnd(); ++in)
425  {
426  if(in->Is(TO_SPLIT))
427  in->Set(TO_SPLIT,false);
428  }
429 
430  KRATOS_CATCH( "" )
431  }
432 
433  //**************************************************************************
434  //**************************************************************************
435 
436 
437  void SelectEdgeToRefine3D( GeometryType& rGeometry,
438  std::vector<array_1d<double,3> >& rNewPositions,
439  std::vector<double >& rLargestVolumes,
440  std::vector<array_1d< unsigned int,4 > >& rNodeIdsToInterpolate,
441  std::vector<Node::DofsContainerType >& rNewDofs,
442  unsigned int& rNodesToRefine,
443  const unsigned int& rElementsToRefine)
444  {
445  KRATOS_TRY
446 
447  const unsigned int NumberOfNodes = rGeometry.size();
448 
449  unsigned int rigid_nodes=0;
450  unsigned int freesurface_nodes=0;
451  unsigned int inlet_nodes=0;
452  unsigned int nodes_to_split=0;
453  unsigned int nodes_to_erase=0;
454 
455  this->FlagsCounter(rGeometry, rigid_nodes, freesurface_nodes, inlet_nodes, nodes_to_split, nodes_to_erase);
456 
457  bool any_node_to_erase=false;
458  if( nodes_to_erase > 0 )
459  any_node_to_erase = true;
460 
461  double critical_edge_length=5.0*mrRemesh.Refine->CriticalRadius;
462  double length_tolerance=1.6;
463  double penalization=1.0;
464 
465  if(rigid_nodes>2){
466  penalization=0.7;
467  if(inlet_nodes>0){
468  penalization=0.9;
469  }
470  }
471 
472 
473  double ElementalVolume = rGeometry.Volume();
474 
475  array_1d<double,6> Edges(6,0.0);
476  array_1d<unsigned int,6> FirstEdgeNode(6,0);
477  array_1d<unsigned int,6> SecondEdgeNode(6,0);
478  double WallCharacteristicDistance=0;
479  array_1d<double,3> CoorDifference;
480  noalias(CoorDifference) = rGeometry[1].Coordinates() - rGeometry[0].Coordinates();
481 
482  double SquaredLength = CoorDifference[0]*CoorDifference[0] + CoorDifference[1]*CoorDifference[1] + CoorDifference[2]*CoorDifference[2];
483  Edges[0]=sqrt(SquaredLength);
484  FirstEdgeNode[0]=0;
485  SecondEdgeNode[0]=1;
486 
487  if(rGeometry[0].Is(RIGID) && rGeometry[1].Is(RIGID)){
488  WallCharacteristicDistance=Edges[0];
489  }
490 
491  unsigned int Counter=0;
492  for (unsigned int i = 2; i < NumberOfNodes; ++i)
493  {
494  for(unsigned int j = 0; j < i; ++j)
495  {
496  noalias(CoorDifference) = rGeometry[i].Coordinates() - rGeometry[j].Coordinates();
497  SquaredLength = CoorDifference[0]*CoorDifference[0] + CoorDifference[1]*CoorDifference[1] + CoorDifference[2]*CoorDifference[2];
498  Counter+=1;
499  Edges[Counter]=sqrt(SquaredLength);
500  FirstEdgeNode[Counter]=j;
501  SecondEdgeNode[Counter]=i;
502  if(rGeometry[i].Is(RIGID) && rGeometry[j].Is(RIGID) && Edges[Counter]>WallCharacteristicDistance ){
503  WallCharacteristicDistance=Edges[Counter];
504  }
505  }
506 
507  }
508  //Edges connectivity: Edges[0]=d01, Edges[1]=d20, Edges[2]=d21, Edges[3]=d30, Edges[4]=d31, Edges[5]=d32
509  bool dangerousElement=false;
510 
511  if(rigid_nodes>1){
512 
513  for (unsigned int i = 0; i < 6; ++i)
514  {
515  if((Edges[i]<WallCharacteristicDistance*length_tolerance && (rGeometry[FirstEdgeNode[i]].Is(RIGID) || rGeometry[SecondEdgeNode[i]].Is(RIGID))) ||
516  (rGeometry[FirstEdgeNode[i]].Is(RIGID) && rGeometry[SecondEdgeNode[i]].Is(RIGID) )){
517  Edges[i]=0;
518  }
519 
520  if((rGeometry[FirstEdgeNode[i]].Is(FREE_SURFACE) || rGeometry[FirstEdgeNode[i]].Is(RIGID)) &&
521  (rGeometry[SecondEdgeNode[i]].Is(FREE_SURFACE)|| rGeometry[SecondEdgeNode[i]].Is(RIGID))){
522  Edges[i]=0;
523  }
524  }
525 
526  }
527  else if(rigid_nodes==1){
528 
529  if(rGeometry[0].Is(RIGID)){
530  Edges[0]=0;
531  Edges[1]=0;
532  Edges[3]=0;
533  }
534  if(rGeometry[1].Is(RIGID)){
535  Edges[0]=0;
536  Edges[2]=0;
537  Edges[4]=0;
538  }
539  if(rGeometry[2].Is(RIGID)){
540  Edges[1]=0;
541  Edges[2]=0;
542  Edges[5]=0;
543  }
544  if(rGeometry[3].Is(RIGID)){
545  Edges[3]=0;
546  Edges[4]=0;
547  Edges[5]=0;
548  }
549  }
550 
551  if((Edges[0]==0 && Edges[1]==0 && Edges[2]==0 && Edges[3]==0 && Edges[4]==0 && Edges[5]==0) || rigid_nodes>2){
552  dangerousElement=true;
553  }
554 
555  //just to fill the vector
556  if(dangerousElement==false && any_node_to_erase==false && nodes_to_split<2){
557 
558  unsigned int maxCount=6;
559  double LargestEdge=0;
560 
561  for(unsigned int i=0; i<6; ++i)
562  {
563  if(Edges[i]>LargestEdge){
564  maxCount=i;
565  LargestEdge=Edges[i];
566  }
567  }
568 
569  if(rNodesToRefine<rElementsToRefine && LargestEdge>critical_edge_length){
570  array_1d<double,3> NewPosition;
571  noalias(NewPosition) = 0.5*(rGeometry[FirstEdgeNode[maxCount]].Coordinates()+rGeometry[SecondEdgeNode[maxCount]].Coordinates());
572 
573  rNodeIdsToInterpolate[rNodesToRefine][0]=rGeometry[FirstEdgeNode[maxCount]].GetId();
574  rNodeIdsToInterpolate[rNodesToRefine][1]=rGeometry[SecondEdgeNode[maxCount]].GetId();
575 
576  rGeometry[FirstEdgeNode[maxCount]].Set(TO_SPLIT);
577  rGeometry[SecondEdgeNode[maxCount]].Set(TO_SPLIT);
578 
579  if(rGeometry[SecondEdgeNode[maxCount]].IsNot(RIGID)){
580  CopyDofs(rGeometry[SecondEdgeNode[maxCount]].GetDofs(), rNewDofs[rNodesToRefine]);
581  }else if(rGeometry[FirstEdgeNode[maxCount]].IsNot(RIGID)){
582  CopyDofs(rGeometry[FirstEdgeNode[maxCount]].GetDofs(), rNewDofs[rNodesToRefine]);
583  }else{
584  std::cout<<"CAUTION! THIS IS A WALL EDGE"<<std::endl;
585  }
586  rLargestVolumes[rNodesToRefine]=ElementalVolume;
587  rNewPositions[rNodesToRefine]=NewPosition;
588  rNodesToRefine++;
589 
590  }
591  else if(freesurface_nodes<4 && rigid_nodes<4){
592 
593  ElementalVolume*=penalization;
594  for(unsigned int nn= 0; nn< rElementsToRefine; ++nn)
595  {
596  if(ElementalVolume>rLargestVolumes[nn]){
597 
598 
599  bool suitableElement=true;
600 
601  if(maxCount<6 && LargestEdge>critical_edge_length){
602  array_1d<double,3> NewPosition;
603  noalias(NewPosition) = 0.5 * (rGeometry[FirstEdgeNode[maxCount]].Coordinates()+rGeometry[SecondEdgeNode[maxCount]].Coordinates());
604 
605  for(unsigned int j= 0; j< rElementsToRefine; ++j)
606  {
607  if(rNewPositions[j][0]==NewPosition[0] && rNewPositions[j][1]==NewPosition[1] && rNewPositions[j][2]==NewPosition[2]){
608  suitableElement=false; //this is a repeated node, I have already choose this from another element
609  }
610  }
611 
612  if(suitableElement==true){
613 
614  rNodeIdsToInterpolate[nn][0]=rGeometry[FirstEdgeNode[maxCount]].GetId();
615  rNodeIdsToInterpolate[nn][1]=rGeometry[SecondEdgeNode[maxCount]].GetId();
616 
617  rGeometry[FirstEdgeNode[maxCount]].Set(TO_SPLIT);
618  rGeometry[SecondEdgeNode[maxCount]].Set(TO_SPLIT);
619 
620  if(rGeometry[SecondEdgeNode[maxCount]].IsNot(RIGID)){
621  CopyDofs(rGeometry[SecondEdgeNode[maxCount]].GetDofs(), rNewDofs[nn]);
622  }else if(rGeometry[FirstEdgeNode[maxCount]].IsNot(RIGID)){
623  CopyDofs(rGeometry[FirstEdgeNode[maxCount]].GetDofs(), rNewDofs[nn]);
624  }else{
625  std::cout<<"CAUTION! THIS IS A WALL EDGE"<<std::endl;
626  }
627  rLargestVolumes[nn]=ElementalVolume;
628  rNewPositions[nn]=NewPosition;
629  }
630 
631  }
632 
633  break;
634  }
635  }
636  }
637  }
638 
639  // reset TO_SPLIT
640  for(ModelPart::NodesContainerType::const_iterator in = mrModelPart.NodesBegin(); in != mrModelPart.NodesEnd(); ++in)
641  {
642  if(in->Is(TO_SPLIT))
643  in->Set(TO_SPLIT,false);
644  }
645 
646  KRATOS_CATCH( "" )
647  }
648 
649 
650  void CreateAndAddNewNodes(std::vector<array_1d<double,3> >& rNewPositions,
651  std::vector<array_1d< unsigned int,4 > >& rNodeIdsToInterpolate,
652  std::vector<Node::DofsContainerType >& rNewDofs,
653  const unsigned int& rElementsToRefine)
654  {
655  KRATOS_TRY
656 
657  const unsigned int dimension = mrModelPart.ElementsBegin()->GetGeometry().WorkingSpaceDimension();
658 
659  std::vector<Node::Pointer > list_of_new_nodes;
660  const unsigned int NodeIdParent = MesherUtilities::GetMaxNodeId( mrModelPart.GetParentModelPart() );
661  const unsigned int NodeId = MesherUtilities::GetMaxNodeId(mrModelPart);
662 
663  unsigned int Id = NodeIdParent + 1; //total model part node size
664 
665  if(NodeId>NodeIdParent){
666  Id = NodeId + 1;
667  std::cout<<"initial_node_size "<<Id<<std::endl;
668  }
669 
670  //assign data to dofs
671  VariablesList& rVariablesList = mrModelPart.GetNodalSolutionStepVariablesList();
672 
673  for(unsigned int nn= 0; nn< rNewPositions.size(); ++nn)
674  {
675 
676  double x = rNewPositions[nn][0];
677  double y = rNewPositions[nn][1];
678  double z = 0;
679  if(dimension==3)
680  z=rNewPositions[nn][2];
681 
682  //create a new node
683  Node::Pointer pnode = mrModelPart.CreateNewNode(Id,x,y,z);
684  ++Id;
685 
686  //to control the inserted nodes
687  // pnode->Set(MODIFIED);
688  std::cout<<" Insert new node "<<pnode->Id()<<"["<<x<<","<<y<<","<<z<<"]"<<std::endl;
689 
690 
691  pnode->Set(NEW_ENTITY,true); //not boundary
692  list_of_new_nodes.push_back( pnode );
693 
694  // commented JMC august 15-18
695  // if(mrRemesh.InputInitializedFlag){
696  // mrRemesh.NodalPreIds.push_back( pnode->Id() );
697  // pnode->SetId(Id);
698  // }
699 
700  //giving model part variables list to the node
701  pnode->SetSolutionStepVariablesList(&rVariablesList);
702 
703  //set buffer size
704  pnode->SetBufferSize(mrModelPart.GetBufferSize());
705 
706  Node::DofsContainerType& Reference_dofs = rNewDofs[nn];
707 
708  //generating the dofs
709  // for(Node::DofsContainerType::iterator iii = Reference_dofs.begin(); iii != Reference_dofs.end(); ++iii)
710  // {
711  // Node::DofType& rDof = **iii;
712  // Node::DofType::Pointer p_new_dof = pnode->pAddDof( rDof );
713 
714  // //(p_new_dof)->FreeDof();
715  // }
716 
718  PointsArray.push_back( mrModelPart.pGetNode(rNodeIdsToInterpolate[nn][0]) );
719  PointsArray.push_back( mrModelPart.pGetNode(rNodeIdsToInterpolate[nn][1]) );
720 
721  Geometry<Node > LineGeometry( PointsArray );
722 
723  std::vector<double> ShapeFunctionsN(2);
724  std::fill( ShapeFunctionsN.begin(), ShapeFunctionsN.end(), 0.0 );
725  ShapeFunctionsN[0] = 0.5;
726  ShapeFunctionsN[1] = 0.5;
727 
728  MeshDataTransferUtilities DataTransferUtilities;
729  DataTransferUtilities.Interpolate(LineGeometry, ShapeFunctionsN, rVariablesList, pnode);
730 
731  if( PointsArray[0].Is(FREE_SURFACE) && PointsArray[1].Is(FREE_SURFACE) )
732  pnode->Set(FREE_SURFACE);
733 
734  if( PointsArray[0].Is(BOUNDARY) && PointsArray[1].Is(BOUNDARY) )
735  pnode->Set(BOUNDARY);
736 
737  }
738 
739 
740  //set the coordinates to the original value
741  const array_1d<double,3> ZeroNormal(3,0.0);
742  for(std::vector<Node::Pointer>::iterator it = list_of_new_nodes.begin(); it!=list_of_new_nodes.end(); ++it)
743  {
744  const array_1d<double,3>& displacement = (*it)->FastGetSolutionStepValue(DISPLACEMENT);
745  (*it)->X0() = (*it)->X() - displacement[0];
746  (*it)->Y0() = (*it)->Y() - displacement[1];
747  (*it)->Z0() = (*it)->Z() - displacement[2];
748 
749  (*it)->Set(FLUID);
750  (*it)->Set(ACTIVE);
751 
752  // std::cout<<" New Node [ "<<(*it)->Id()<<"]: Displacement "<<(*it)->FastGetSolutionStepValue(DISPLACEMENT)<<" Position "<<(*it)->Coordinates()<<std::endl;
753 
754  //correct contact_normal interpolation
755  if( (*it)->SolutionStepsDataHas(CONTACT_FORCE) )
756  noalias((*it)->GetSolutionStepValue(CONTACT_FORCE)) = ZeroNormal;
757 
758  }
759 
760 
761  KRATOS_CATCH( "" )
762 
763  }
764 
765 
769 
770 
774 
775 
779 
780 
783 
784 
786 
787 
789  //Process(Process const& rOther);
790 
791 
793 
794 }; // Class Process
795 
797 
800 
801 
805 
806 
808 inline std::istream& operator >> (std::istream& rIStream,
810 
812 inline std::ostream& operator << (std::ostream& rOStream,
813  const InsertFluidNodesMesherProcess& rThis)
814 {
815  rThis.PrintInfo(rOStream);
816  rOStream << std::endl;
817  rThis.PrintData(rOStream);
818 
819  return rOStream;
820 }
822 
823 
824 } // namespace Kratos.
825 
826 #endif // KRATOS_INSERT_FLUID_NODES_MESHER_PROCESS_H_INCLUDED defined
Base class for all Conditions.
Definition: condition.h:59
Geometry< NodeType > GeometryType
definition of the geometry type with given NodeType
Definition: element.h:83
bool Is(Flags const &rOther) const
Definition: flags.h:274
bool IsNot(Flags const &rOther) const
Definition: flags.h:291
Geometry base class.
Definition: geometry.h:71
SizeType size() const
Definition: geometry.h:518
PointerVector< TPointType > PointsArrayType
Definition: geometry.h:118
Refine Mesh Elements Process 2D and 3D.
Definition: insert_fluid_nodes_mesher_process.hpp:42
ModelPart::ConditionType ConditionType
Definition: insert_fluid_nodes_mesher_process.hpp:51
ConditionType::GeometryType GeometryType
Definition: insert_fluid_nodes_mesher_process.hpp:53
void Execute() override
Execute method is used to execute the Process algorithms.
Definition: insert_fluid_nodes_mesher_process.hpp:90
void PrintData(std::ostream &rOStream) const override
Print object's data.s.
Definition: insert_fluid_nodes_mesher_process.hpp:169
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: insert_fluid_nodes_mesher_process.hpp:163
ModelPart::PropertiesType PropertiesType
Definition: insert_fluid_nodes_mesher_process.hpp:52
InsertFluidNodesMesherProcess(ModelPart &rModelPart, MesherUtilities::MeshingParameters &rRemeshingParameters, int EchoLevel)
Default constructor.
Definition: insert_fluid_nodes_mesher_process.hpp:60
virtual ~InsertFluidNodesMesherProcess()
Destructor.
Definition: insert_fluid_nodes_mesher_process.hpp:71
std::string Info() const override
Turn back information as a string.
Definition: insert_fluid_nodes_mesher_process.hpp:157
void operator()()
This operator is provided to call the process as a function and simply calls the Execute method.
Definition: insert_fluid_nodes_mesher_process.hpp:79
KRATOS_CLASS_POINTER_DEFINITION(InsertFluidNodesMesherProcess)
Pointer definition of Process.
ModelPart::NodeType NodeType
Definition: insert_fluid_nodes_mesher_process.hpp:50
The base class for processes passed to the solution scheme.
Definition: mesher_process.hpp:37
Short class definition.
Definition: mesher_utilities.hpp:49
static unsigned int GetMaxNodeId(ModelPart &rModelPart)
Definition: mesher_utilities.hpp:1408
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
std::string & Name()
Definition: model_part.h:1811
ElementIterator ElementsEnd(IndexType ThisIndex=0)
Definition: model_part.h:1179
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
void push_back(const TPointerType &x)
Definition: pointer_vector.h:270
Properties encapsulates data shared by different Elements or Conditions. It can store any type of dat...
Definition: properties.h:69
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
static int EchoLevel
Definition: co_sim_EMPIRE_API.h:42
z
Definition: GenerateWind.py:163
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::unique_ptr< T > unique_ptr
Definition: smart_pointers.h:33
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
y
Other simbols definition.
Definition: generate_axisymmetric_navier_stokes_element.py:54
int dimension
Definition: isotropic_damage_automatic_differentiation.py:123
int j
Definition: quadrature.py:648
x
Definition: sensitivityMatrix.py:49
integer i
Definition: TensorModule.f:17
Definition: mesher_utilities.hpp:631
MeshingInfoParameters::Pointer Info
Definition: mesher_utilities.hpp:681
RefiningParameters::Pointer Refine
Definition: mesher_utilities.hpp:684
std::string SubModelPartName
Definition: mesher_utilities.hpp:642