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.
volume_shaping_process.hpp
Go to the documentation of this file.
1 //
2 // Project Name: KratosPfemApplication $
3 // Created by: $Author: JMCarbonell $
4 // Last modified by: $Co-Author: $
5 // Date: $Date: August 2018 $
6 // Revision: $Revision: 0.0 $
7 //
8 //
9 
10 
11 #if !defined(KRATOS_VOLUME_SHAPING_PROCESS_H_INCLUDED )
12 #define KRATOS_VOLUME_SHAPING_PROCESS_H_INCLUDED
13 
14 // External includes
15 
16 // System includes
17 
18 // Project includes
19 #include "includes/model_part.h"
21 #include "processes/process.h"
22 
23 namespace Kratos
24 {
25 
28 
30 
34 {
35  public:
38 
41 
46 
50 
52  VolumeShapingProcess(ModelPart& rModelPart, Parameters rParameters)
53  : Process(Flags()), mrModelPart(rModelPart)
54  {
55 
56  Parameters default_parameters( R"(
57  {
58  "variable_name": "VOLUME_WEAR",
59  "flags_list": [],
60  "properties": {}
61  } )" );
62 
63 
64  // Validate against defaults -- this ensures no type mismatch
65  rParameters.ValidateAndAssignDefaults(default_parameters);
66 
67  mVariableName = rParameters["variable_name"].GetString();
68 
69  // check variable to store volume shaping magnitude
70  if( rModelPart.GetNodalSolutionStepVariablesList().Has( KratosComponents< Variable<double> >::Get( mVariableName ) ) == false )
71  {
72  KRATOS_ERROR << "trying to set a variable that is not in the model_part - variable name is " << mVariableName << std::endl;
73  }
74 
75  // set properties
76  Parameters variables = rParameters["properties"];
77  for(auto iter = variables.begin(); iter != variables.end(); ++iter) {
78 
79  std::string variable_name = iter.name();
80  const Parameters value = variables.GetValue(variable_name);
81 
82  if(KratosComponents<Variable<double> >::Has(variable_name)) {
83  const Variable<double>& variable = KratosComponents<Variable<double>>().Get(variable_name);
84  mProperties.SetValue(variable, value.GetDouble());
85  } else if(KratosComponents<Variable<bool> >::Has(variable_name)) {
86  const Variable<bool>& variable = KratosComponents<Variable<bool>>().Get(variable_name);
87  mProperties.SetValue(variable, value.GetBool());
88  } else if(KratosComponents<Variable<int> >::Has(variable_name)) {
89  const Variable<int>& variable = KratosComponents<Variable<int>>().Get(variable_name);
90  mProperties.SetValue(variable, value.GetInt());
91  } else if(KratosComponents<Variable<std::string> >::Has(variable_name)) {
92  const Variable<std::string>& variable = KratosComponents<Variable<std::string>>().Get(variable_name);
93  mProperties.SetValue(variable, value.GetString());
94  } else {
95  KRATOS_ERROR << "Value type for Variable: "<<variable_name<<" not defined";
96  }
97  }
98 
99  for(unsigned int i=0; i<rParameters["flags_list"].size(); ++i)
100  {
101  mControlFlags.push_back(KratosComponents< Flags >::Get( rParameters["flags_list"][i].GetString() ));
102  }
103 
104  }
105 
106 
109 
110 
114 
116  void operator()()
117  {
118  Execute();
119  }
120 
124 
126  void Execute() override
127  {
128  }
129 
132  void ExecuteInitialize() override
133  {
134  }
135 
139  {
140  }
141 
144  {
145  }
146 
149  {
150  KRATOS_TRY
151 
152  //shape volume
153  this->ShapeVolume(mrModelPart);
154 
155  KRATOS_CATCH("")
156  }
157 
158 
160  void ExecuteBeforeOutputStep() override
161  {
162  }
163 
164 
166  void ExecuteAfterOutputStep() override
167  {
168  }
169 
170 
173  void ExecuteFinalize() override
174  {
175  }
176 
177 
187 
189  std::string Info() const override
190  {
191  return "VolumeShapingProcess";
192  }
193 
195  void PrintInfo(std::ostream& rOStream) const override
196  {
197  rOStream << "VolumeShapingProcess";
198  }
199 
201  void PrintData(std::ostream& rOStream) const override
202  {
203  }
204 
209 
210  protected:
211 
233 
234  private:
235 
241 
242  ModelPart& mrModelPart;
243 
244  std::vector<Flags> mControlFlags;
245 
246  Properties mProperties;
247 
248  std::string mVariableName;
249 
250  struct ShapingVariables{
251 
252  double TotalVolume;
253  double TotalVolumeLoss;
254  double TotalSurface;
255  double OffsetFactor;
256 
257  std::vector<unsigned int> VisitedNodesIds;
258  std::vector<double> NodalSurface;
259  std::vector<double> NodalVolume;
260  std::vector<double> NodalVolumeLoss;
261  };
262 
269 
270  //*******************************************************************************************
271  //*******************************************************************************************
272 
273  void ShapeVolume(ModelPart& rModelPart)
274  {
275 
276  KRATOS_TRY
277 
278  double Tolerance = 1e-14;
279  unsigned int NumberOfIterations = 5;
280  unsigned int iteration = -1;
281 
282  this->SetVisitedEntities(rModelPart);
283 
284  ShapingVariables Variables;
285 
286  Variables.TotalVolume = this->ComputeTotalVolume(rModelPart);
287  Variables.TotalSurface = this->ComputeTotalSurface(rModelPart);
288 
289  this->ComputeNodalVolumeAndSurface(rModelPart,Variables);
290 
291  Variables.TotalVolumeLoss = this->ComputeVolumeLosses(rModelPart,Variables);
292 
293  Variables.OffsetFactor = 1;
294 
295  double VolumeIncrement = 0;
296 
297  double Ratio = fabs(Variables.TotalVolume-VolumeIncrement/(Variables.TotalVolume-Variables.TotalVolumeLoss));
298  double Error = 1;
299 
300  while(++iteration < NumberOfIterations && ( Ratio < 0.9 || Ratio > 1 ) && Error > Tolerance)
301  {
302 
303  this->MoveSurface(rModelPart,Variables);
304 
305  VolumeIncrement = Variables.TotalVolume - this->ComputeTotalVolume(rModelPart);
306 
307  if( VolumeIncrement > 0 )
308  Variables.OffsetFactor*=(1.0-(Variables.TotalVolumeLoss/VolumeIncrement));
309 
310  if( (VolumeIncrement-Variables.TotalVolumeLoss) * Variables.OffsetFactor > 0 )
311  Variables.OffsetFactor*=(-1);
312 
313  Ratio = fabs(Variables.TotalVolume-VolumeIncrement/(Variables.TotalVolume-Variables.TotalVolumeLoss));
314 
315  Error = fabs(Variables.TotalVolumeLoss-VolumeIncrement);
316  //std::cout<<" Iteration: "<<iteration<<" Ratio in Volume "<<Ratio<<" Volume Increment "<<VolumeIncrement<<std::endl;
317  }
318 
319 
320  this->ResetVisitedEntities(rModelPart);
321 
322  std::cout<<" Surface shaping perfomed in "<<iteration<<" iterations : Error "<<Error<<std::endl;
323  std::cout<<" TotalVolume "<<Variables.TotalVolume<<" TotalVolumeLoss "<<Variables.TotalVolumeLoss<<" VolumeIncrement "<<VolumeIncrement<<std::endl;
324 
325  KRATOS_CATCH("")
326  }
327 
328 
329  //*******************************************************************************************
330  //*******************************************************************************************
331 
332  void MoveSurface(ModelPart& rModelPart, const ShapingVariables& rVariables)
333  {
334  KRATOS_TRY
335 
336  ModelPart::NodesContainerType::iterator it_begin = rModelPart.NodesBegin();
337  int NumberOfNodes = rModelPart.NumberOfNodes();
338 
339  #pragma omp parallel for
340  for (int i=0; i<NumberOfNodes; ++i)
341  {
342  ModelPart::NodesContainerType::iterator i_node = it_begin + i;
343  if(i_node->Is(VISITED)){
344  unsigned int id = rVariables.VisitedNodesIds[i_node->Id()];
345  const array_1d<double,3>& rNormal = i_node->FastGetSolutionStepValue(NORMAL);
346  double& rShrinkFactor = i_node->FastGetSolutionStepValue(SHRINK_FACTOR);
347  double rOffset = -rVariables.OffsetFactor * rShrinkFactor * rVariables.NodalVolumeLoss[id] * rVariables.NodalSurface[id] / (100 * rVariables.TotalVolume * rVariables.TotalSurface);
348  //std::cout<<" rOffset "<<rOffset<<" "<<rShrinkFactor<<" "<<rVariables.NodalVolumeLoss[id]<<" "<<rVariables.NodalSurface[id]<<" "<<rVariables.TotalSurface<<std::endl;
349 
350  i_node->Coordinates() += rOffset * rNormal;
351  i_node->FastGetSolutionStepValue(DISPLACEMENT) += rOffset * rNormal;
352  i_node->FastGetSolutionStepValue(DISPLACEMENT,1) += rOffset * rNormal;
353  }
354  }
355 
356  KRATOS_CATCH("")
357  }
358 
359  //*******************************************************************************************
360  //*******************************************************************************************
361 
362  void SetVisitedEntities(ModelPart& rModelPart)
363  {
364  KRATOS_TRY
365 
366  this->SetVisitedNodes(rModelPart);
367  this->SetVisitedElements(rModelPart);
368 
369  KRATOS_CATCH("")
370  }
371 
372 
373  //*******************************************************************************************
374  //*******************************************************************************************
375 
376  void ResetVisitedEntities(ModelPart& rModelPart)
377  {
378  KRATOS_TRY
379 
380  this->ResetVisitedNodes(rModelPart);
381  this->ResetVisitedElements(rModelPart);
382 
383  KRATOS_CATCH("")
384  }
385 
386  //*******************************************************************************************
387  //*******************************************************************************************
388 
389  void SetVisitedNodes(ModelPart& rModelPart)
390  {
391  KRATOS_TRY
392 
393  for(ModelPart::NodesContainerType::iterator i_node = rModelPart.NodesBegin() ; i_node != rModelPart.NodesEnd() ; ++i_node)
394  {
395  if(this->MatchControlFlags(*(i_node.base()))){
396  i_node->Set(VISITED,true);
397  }
398  }
399 
400  KRATOS_CATCH("")
401  }
402 
403 
404  //*******************************************************************************************
405  //*******************************************************************************************
406 
407  void ResetVisitedNodes(ModelPart& rModelPart)
408  {
409  KRATOS_TRY
410 
411  for(ModelPart::NodesContainerType::iterator i_node = rModelPart.NodesBegin() ; i_node != rModelPart.NodesEnd() ; ++i_node)
412  {
413  i_node->Set(VISITED,false);
414  }
415 
416  KRATOS_CATCH("")
417  }
418 
419 
420  //*******************************************************************************************
421  //*******************************************************************************************
422 
423  void SetVisitedElements(ModelPart& rModelPart)
424  {
425  KRATOS_TRY
426 
427  for(ModelPart::ElementsContainerType::iterator i_elem = rModelPart.ElementsBegin() ; i_elem != rModelPart.ElementsEnd() ; ++i_elem)
428  {
429  for(unsigned int i=0; i<i_elem->GetGeometry().size(); ++i)
430  {
431  if(this->MatchControlFlags(i_elem->GetGeometry()(i))){
432  i_elem->Set(VISITED,true);
433  break;
434  }
435  }
436  }
437 
438  KRATOS_CATCH("")
439  }
440 
441 
442  //*******************************************************************************************
443  //*******************************************************************************************
444 
445  void ResetVisitedElements(ModelPart& rModelPart)
446  {
447  KRATOS_TRY
448 
449  for(ModelPart::ElementsContainerType::iterator i_elem = rModelPart.ElementsBegin() ; i_elem != rModelPart.ElementsEnd() ; ++i_elem)
450  {
451  i_elem->Set(VISITED,false);
452  }
453 
454  KRATOS_CATCH("")
455  }
456 
457  //*******************************************************************************************
458  //*******************************************************************************************
459 
460  double ComputeTotalVolume(ModelPart& rModelPart)
461  {
462  KRATOS_TRY
463 
464  const unsigned int dimension = rModelPart.GetProcessInfo()[SPACE_DIMENSION];
465  double TotalVolume = 0;
466 
467  if( dimension == 2 ){
468 
469  ModelPart::ElementsContainerType::iterator it_begin = rModelPart.ElementsBegin();
470  int NumberOfElements = rModelPart.NumberOfElements();
471 
472  #pragma omp parallel for reduction(+:TotalVolume)
473  for (int i=0; i<NumberOfElements; ++i)
474  {
475  ModelPart::ElementsContainerType::iterator i_elem = it_begin + i;
476  if( i_elem->GetGeometry().Dimension() == 2 && i_elem->Is(VISITED) )
477  TotalVolume += i_elem->GetGeometry().Area();
478  }
479  }
480  else{ //dimension == 3
481 
482  ModelPart::ElementsContainerType::iterator it_begin = rModelPart.ElementsBegin();
483  int NumberOfElements = rModelPart.NumberOfElements();
484 
485  #pragma omp parallel for reduction(+:TotalVolume)
486  for (int i=0; i<NumberOfElements; ++i)
487  {
488  ModelPart::ElementsContainerType::iterator i_elem = it_begin + i;
489  if( i_elem->GetGeometry().Dimension() == 3 && i_elem->Is(VISITED) )
490  TotalVolume += i_elem->GetGeometry().Volume();
491  }
492  }
493 
494  return TotalVolume;
495 
496  KRATOS_CATCH("")
497 
498  }
499 
500 
501  //*******************************************************************************************
502  //*******************************************************************************************
503 
504  double ComputeTotalSurface(ModelPart& rModelPart)
505  {
506  KRATOS_TRY
507 
508  const unsigned int dimension = rModelPart.GetProcessInfo()[SPACE_DIMENSION];
509  double TotalSurface = 0;
510 
511  if( dimension == 2 ){
512 
513  ModelPart::ElementsContainerType::iterator it_begin = rModelPart.ElementsBegin();
514  int NumberOfElements = rModelPart.NumberOfElements();
515 
516  #pragma omp parallel for reduction(+:TotalSurface)
517  for (int i=0; i<NumberOfElements; ++i)
518  {
519  ModelPart::ElementsContainerType::iterator i_elem = it_begin + i;
520  GeometryType& rGeometry = i_elem->GetGeometry();
521  if( rGeometry.Dimension() == 2 && i_elem->Is(VISITED) ){
522  for(unsigned int j=0; j<rGeometry.size()-1; ++j)
523  {
524  if(rGeometry[j].Is(VISITED)){
525  for(unsigned int k=j+1; k<rGeometry.size(); ++k)
526  {
527  if(rGeometry[k].Is(VISITED)){
528  TotalSurface += norm_2( rGeometry[k].Coordinates() - rGeometry[j].Coordinates() );
529  }
530  }
531 
532  }
533  }
534  }
535  }
536  }
537  else{ //dimension == 3
538 
539  DenseMatrix<unsigned int> lpofa; //connectivities of points defining faces
540  DenseVector<unsigned int> lnofa; //number of points defining faces
541 
542  ModelPart::ElementsContainerType::iterator it_begin = rModelPart.ElementsBegin();
543  int NumberOfElements = rModelPart.NumberOfElements();
544 
545  #pragma omp parallel for private(lpofa,lnofa) reduction(+:TotalSurface)
546  for (int i=0; i<NumberOfElements; ++i)
547  {
548  ModelPart::ElementsContainerType::iterator i_elem = it_begin + i;
549 
550  GeometryType& rGeometry = i_elem->GetGeometry();
551 
552  if( rGeometry.Dimension() == 3 && i_elem->Is(VISITED) ){
553 
554  rGeometry.NodesInFaces(lpofa);
555  rGeometry.NumberNodesInFaces(lnofa);
556 
557  for(unsigned int iface=0; iface<rGeometry.FacesNumber(); ++iface)
558  {
559  unsigned int free_surface = 0;
560  for(unsigned int j=1; j<=lnofa[iface]; ++j)
561  if(rGeometry[j].Is(VISITED))
562  ++free_surface;
563 
564  if(free_surface==lnofa[iface])
565  TotalSurface+=Compute3DArea(rGeometry[lpofa(1,iface)].Coordinates(),
566  rGeometry[lpofa(2,iface)].Coordinates(),
567  rGeometry[lpofa(3,iface)].Coordinates());
568  }
569  }
570  }
571  }
572 
573  return TotalSurface;
574 
575  KRATOS_CATCH("")
576 
577  }
578 
579 
580  //*******************************************************************************************
581  //*******************************************************************************************
582 
583  void ComputeNodalVolumeAndSurface(ModelPart& rModelPart, ShapingVariables& rVariables)
584  {
585  KRATOS_TRY
586 
587  unsigned int MaxNodeId = MesherUtilities::GetMaxNodeId(rModelPart);
588  rVariables.VisitedNodesIds.resize(MaxNodeId+1);
589  std::fill( rVariables.VisitedNodesIds.begin(), rVariables.VisitedNodesIds.end(), 0 );
590 
591  std::vector<GlobalPointersVector<Element> > Neighbours(rModelPart.NumberOfNodes()+1);
592  unsigned int id = 1;
593  for(ModelPart::ElementsContainerType::iterator i_elem = rModelPart.ElementsBegin(); i_elem!=rModelPart.ElementsEnd(); ++i_elem)
594  {
595  if(i_elem->Is(VISITED)){
596 
597  Element::GeometryType& pGeometry = i_elem->GetGeometry();
598 
599  for(unsigned int i = 0; i < pGeometry.size(); ++i)
600  {
601  if( pGeometry[i].Is(VISITED) ){
602 
603  if(rVariables.VisitedNodesIds[pGeometry[i].Id()]==0){
604  rVariables.VisitedNodesIds[pGeometry[i].Id()]=id;
605  Neighbours[id].push_back( Element::WeakPointer( *(i_elem.base()) ) );
606  ++id;
607  }
608  else{
609  Neighbours[rVariables.VisitedNodesIds[pGeometry[i].Id()]].push_back( Element::WeakPointer( *(i_elem.base()) ) );
610  }
611 
612  }
613  }
614  }
615  }
616 
617  rVariables.NodalSurface.resize(id);
618  std::fill( rVariables.NodalSurface.begin(), rVariables.NodalSurface.end(), 0 );
619 
620  rVariables.NodalVolume.resize(id);
621  std::fill( rVariables.NodalVolume.begin(), rVariables.NodalVolume.end(), 0 );
622 
623  const unsigned int dimension = rModelPart.GetProcessInfo()[SPACE_DIMENSION];
624 
625  if( dimension == 2 ){
626 
627  ModelPart::NodesContainerType::iterator it_begin = rModelPart.NodesBegin();
628  int NumberOfNodes = rModelPart.NumberOfNodes();
629 
630  #pragma omp parallel for
631  for (int i=0; i<NumberOfNodes; ++i)
632  {
633  ModelPart::NodesContainerType::iterator i_node = it_begin + i;
634 
635  if( i_node->Is(VISITED) ){
636  unsigned int id = rVariables.VisitedNodesIds[i_node->Id()];
637  GlobalPointersVector<Element>& rE = Neighbours[id];
638  for(GlobalPointersVector<Element >::iterator ie= rE.begin(); ie!=rE.end(); ++ie)
639  {
640  GeometryType& rGeometry = ie->GetGeometry();
641 
642  rVariables.NodalVolume[id] += ie->GetGeometry().Area() / double(ie->GetGeometry().size());
643 
644  if( rGeometry.Dimension() == 2 ){
645  for(unsigned int j=0; j<rGeometry.size()-1; ++j)
646  {
647  if(rGeometry[j].Is(VISITED)){
648  for(unsigned int k=j+1; k<rGeometry.size(); ++k)
649  {
650  if(rGeometry[k].Is(VISITED) && (rGeometry[j].Id() == i_node->Id() || rGeometry[k].Id() == i_node->Id()) ){
651  rVariables.NodalSurface[id] += 0.5 * norm_2( rGeometry[k].Coordinates() - rGeometry[j].Coordinates() ); //linear elements 2 noded sides
652  }
653  }
654  }
655  }
656  }
657  }
658  }
659  }
660  }
661  else{ //dimension == 3
662 
663  DenseMatrix<unsigned int> lpofa; //connectivities of points defining faces
664  DenseVector<unsigned int> lnofa; //number of points defining faces
665 
666  ModelPart::NodesContainerType::iterator it_begin = rModelPart.NodesBegin();
667  int NumberOfNodes = rModelPart.NumberOfNodes();
668 
669  double athird = 1.0/3.0;
670 
671  #pragma omp parallel for private(lpofa,lnofa)
672  for (int i=0; i<NumberOfNodes; ++i)
673  {
674  ModelPart::NodesContainerType::iterator i_node = it_begin + i;
675 
676  if( i_node->Is(VISITED) ){
677  unsigned int id = rVariables.VisitedNodesIds[i_node->Id()];
678  GlobalPointersVector<Element>& rE = Neighbours[id];
679  for(GlobalPointersVector<Element >::iterator ie= rE.begin(); ie!=rE.end(); ++ie)
680  {
681  GeometryType& rGeometry = ie->GetGeometry();
682 
683  rVariables.NodalVolume[id] += ie->GetGeometry().Volume() / double(ie->GetGeometry().size());
684 
685  if( rGeometry.Dimension() == 3 ){
686 
687  rGeometry.NodesInFaces(lpofa);
688  rGeometry.NumberNodesInFaces(lnofa);
689 
690  for(unsigned int iface=0; iface<rGeometry.FacesNumber(); ++iface)
691  {
692  unsigned int visited = 0;
693  bool selected = false;
694  for(unsigned int j=1; j<=lnofa[iface]; ++j){
695  if(rGeometry[j].Is(VISITED))
696  ++visited;
697  if(rGeometry[i].Id() == i_node->Id())
698  selected = true;
699  }
700 
701  if(visited==lnofa[iface] && selected)
702  rVariables.NodalSurface[id]+= athird * Compute3DArea(rGeometry[lpofa(1,iface)].Coordinates(),
703  rGeometry[lpofa(2,iface)].Coordinates(),
704  rGeometry[lpofa(3,iface)].Coordinates());
705  }
706 
707  }
708  }
709  }
710  }
711 
712  }
713 
714  KRATOS_CATCH("")
715 
716  }
717 
718  //*******************************************************************************************
719  //*******************************************************************************************
720 
721  double ComputeVolumeLosses(ModelPart& rModelPart, ShapingVariables& rVariables)
722  {
723  KRATOS_TRY
724 
725  double TotalVolumeLoss = 0;
726 
727  const Variable<double>& VolumeLossVariable = KratosComponents< Variable<double> >::Get(mVariableName);
728 
729  double ArchardCoefficient = 0;
730  if( mProperties.Has(WEAR_COEFFICIENT) && mProperties.Has(INDENTATION_HARDNESS) ){
731  ArchardCoefficient = mProperties[WEAR_COEFFICIENT] / mProperties[INDENTATION_HARDNESS];
732  }
733  else{
734  KRATOS_WARNING("Wear calculation not possible") << " WEAR_COEFFICIENT and INDENTATION_HARDNESS variables not DEFINED " << std::endl;
735  }
736 
737  ModelPart::NodesContainerType::iterator it_begin = rModelPart.NodesBegin();
738  int NumberOfNodes = rModelPart.NumberOfNodes();
739 
740  rVariables.NodalVolumeLoss.resize(rVariables.NodalVolume.size());
741  std::fill( rVariables.NodalVolumeLoss.begin(), rVariables.NodalVolumeLoss.end(), 0 );
742 
743  #pragma omp parallel for reduction(+:TotalVolumeLoss)
744  for (int i=0; i<NumberOfNodes; ++i)
745  {
746  ModelPart::NodesContainerType::iterator i_node = it_begin + i;
747 
748  unsigned int id = rVariables.VisitedNodesIds[i_node->Id()];
749  if( i_node->Is(VISITED) && id != 0 ){
750 
751  const array_1d<double,3>& Normal = i_node->FastGetSolutionStepValue(NORMAL);
752  const array_1d<double,3>& ContactForce = i_node->FastGetSolutionStepValue(CONTACT_FORCE);
753 
754  array_1d<double,3> DeltaDisplacement = i_node->FastGetSolutionStepValue(DISPLACEMENT) - i_node->FastGetSolutionStepValue(DISPLACEMENT,1);
755 
756  rVariables.NodalVolumeLoss[id] = ArchardCoefficient * fabs(inner_prod(ContactForce,Normal)) * norm_2( DeltaDisplacement - inner_prod(DeltaDisplacement,Normal) * Normal);
757 
758  i_node->FastGetSolutionStepValue(VolumeLossVariable) += rVariables.NodalVolumeLoss[id];
759 
760  if( rVariables.NodalVolumeLoss[id] > rVariables.NodalVolume[id] )
761  rVariables.NodalVolumeLoss[id] = rVariables.NodalVolume[id];
762 
763  TotalVolumeLoss += rVariables.NodalVolumeLoss[id];
764 
765  }
766  }
767 
768  return TotalVolumeLoss;
769 
770  KRATOS_CATCH("")
771  }
772 
773 
774  //*******************************************************************************************
775  //*******************************************************************************************
776 
777 
778  bool MatchControlFlags(const Node::Pointer& pNode)
779  {
780 
781  for(unsigned int i = 0; i<mControlFlags.size(); i++)
782  {
783  if( pNode->IsNot(mControlFlags[i]) )
784  return false;
785  }
786 
787  return true;
788 
789  }
790 
791 
792  double Compute3DArea(array_1d<double,3> PointA, array_1d<double,3> PointB, array_1d<double,3> PointC){
793  double a = MathUtils<double>::Norm3(PointA - PointB);
794  double b = MathUtils<double>::Norm3(PointB - PointC);
795  double c = MathUtils<double>::Norm3(PointC - PointA);
796  double s = (a+b+c) / 2.0;
797  double Area=std::sqrt(s*(s-a)*(s-b)*(s-c));
798  return Area;
799  }
800 
804 
805 
809 
810 
814 
815 
817  VolumeShapingProcess& operator=(VolumeShapingProcess const& rOther);
818 
819 
821 
822 
824  //Process(Process const& rOther);
825 
826 
828 
829 }; // Class Process
830 
832 
835 
836 
840 
841 
843 inline std::istream& operator >> (std::istream& rIStream,
844  VolumeShapingProcess& rThis);
845 
847 inline std::ostream& operator << (std::ostream& rOStream,
848  const VolumeShapingProcess& rThis)
849 {
850  rThis.PrintInfo(rOStream);
851  rOStream << std::endl;
852  rThis.PrintData(rOStream);
853 
854  return rOStream;
855 }
857 
858 
859 } // namespace Kratos.
860 
861 #endif // KRATOS_VOLUME_SHAPING_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
Definition: flags.h:58
bool Is(Flags const &rOther) const
Definition: flags.h:274
Geometry base class.
Definition: geometry.h:71
virtual void NodesInFaces(DenseMatrix< unsigned int > &rNodesInFaces) const
Definition: geometry.h:2195
virtual double Volume() const
This method calculate and return volume of this geometry.
Definition: geometry.h:1358
virtual double Area() const
This method calculate and return area or surface area of this geometry depending to it's dimension.
Definition: geometry.h:1345
boost::indirect_iterator< typename TContainerType::iterator > iterator
Definition: global_pointers_vector.h:79
KratosComponents class encapsulates a lookup table for a family of classes in a generic way.
Definition: kratos_components.h:49
static double Norm3(const TVectorType &a)
Calculates the norm of vector "a" which is assumed to be of size 3.
Definition: math_utils.h:691
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
VariablesList & GetNodalSolutionStepVariablesList()
Definition: model_part.h:549
This class defines the node.
Definition: node.h:65
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
Parameters GetValue(const std::string &rEntry)
This method returns the Parameter corresponding to a certain entry.
Definition: kratos_parameters.cpp:423
iterator begin()
This returns the begin iterator.
Definition: kratos_parameters.cpp:961
double GetDouble() const
This method returns the double contained in the current Parameter.
Definition: kratos_parameters.cpp:657
iterator end()
This returns the end iterator.
Definition: kratos_parameters.cpp:969
int GetInt() const
This method returns the integer contained in the current Parameter.
Definition: kratos_parameters.cpp:666
void ValidateAndAssignDefaults(const Parameters &rDefaultParameters)
This function is designed to verify that the parameters under testing match the form prescribed by th...
Definition: kratos_parameters.cpp:1306
SizeType size() const
This method returns the total size of the current array parameter.
Definition: kratos_parameters.cpp:993
std::string GetString() const
This method returns the string contained in the current Parameter.
Definition: kratos_parameters.cpp:684
bool GetBool() const
This method returns the boolean contained in the current Parameter.
Definition: kratos_parameters.cpp:675
The base class for all processes in Kratos.
Definition: process.h:49
Properties encapsulates data shared by different Elements or Conditions. It can store any type of dat...
Definition: properties.h:69
bool Has(TVariableType const &rThisVariable) const
Definition: properties.h:578
void SetValue(TVariableType const &rV, typename TVariableType::Type const &rValue)
Definition: properties.h:287
bool Has(const VariableData &rThisVariable) const
Definition: variables_list.h:372
Move free surface to restore volume losses.
Definition: volume_shaping_process.hpp:34
void ExecuteBeforeOutputStep() override
this function will be executed at every time step BEFORE writing the output
Definition: volume_shaping_process.hpp:160
void ExecuteFinalizeSolutionStep() override
this function will be executed at every time step AFTER performing the solve phase
Definition: volume_shaping_process.hpp:148
void ExecuteAfterOutputStep() override
this function will be executed at every time step AFTER writing the output
Definition: volume_shaping_process.hpp:166
ConditionType::GeometryType GeometryType
Definition: volume_shaping_process.hpp:45
void ExecuteInitialize() override
Definition: volume_shaping_process.hpp:132
ModelPart::ConditionType ConditionType
Definition: volume_shaping_process.hpp:43
ModelPart::PropertiesType PropertiesType
Definition: volume_shaping_process.hpp:44
std::string Info() const override
Turn back information as a string.
Definition: volume_shaping_process.hpp:189
void ExecuteFinalize() override
Definition: volume_shaping_process.hpp:173
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: volume_shaping_process.hpp:195
VolumeShapingProcess(ModelPart &rModelPart, Parameters rParameters)
Default constructor.
Definition: volume_shaping_process.hpp:52
void ExecuteBeforeSolutionLoop() override
Definition: volume_shaping_process.hpp:138
void Execute() override
Execute method is used to execute the AssignPropertiesToNodesProcess algorithms.
Definition: volume_shaping_process.hpp:126
void ExecuteInitializeSolutionStep() override
this function will be executed at every time step BEFORE performing the solve phase
Definition: volume_shaping_process.hpp:143
virtual ~VolumeShapingProcess()
Destructor.
Definition: volume_shaping_process.hpp:108
KRATOS_CLASS_POINTER_DEFINITION(VolumeShapingProcess)
Pointer definition of Process.
ModelPart::NodeType NodeType
Definition: volume_shaping_process.hpp:42
void PrintData(std::ostream &rOStream) const override
Print object's data.s.
Definition: volume_shaping_process.hpp:201
void operator()()
This operator is provided to call the process as a function and simply calls the Execute method.
Definition: volume_shaping_process.hpp:116
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR
Definition: exception.h:161
#define KRATOS_WARNING(label)
Definition: logger.h:265
iteration
Definition: DEM_benchmarks.py:172
bool Has(const std::string &ModelerName)
Checks if the modeler is registered.
Definition: modeler_factory.cpp:24
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
TExpressionType::data_type norm_2(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:625
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
TABLE_NUMBER_ANGULAR_VELOCITY TABLE_NUMBER_MOMENT I33 BEAM_INERTIA_ROT_UNIT_LENGHT_Y KRATOS_DEFINE_APPLICATION_VARIABLE(DEM_APPLICATION, double, BEAM_INERTIA_ROT_UNIT_LENGHT_Z) typedef std double
Definition: DEM_application_variables.h:182
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
a
Definition: generate_stokes_twofluid_element.py:77
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
c
Definition: generate_weakly_compressible_navier_stokes_element.py:108
int dimension
Definition: isotropic_damage_automatic_differentiation.py:123
int k
Definition: quadrature.py:595
int j
Definition: quadrature.py:648
integer i
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31