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.
isotropic_damage_utilities.hpp
Go to the documentation of this file.
1 //
2 // Project Name: KratosPoromechanicsApplication $
3 // Created by: $Author: IPouplana $
4 // Last modified by: $Co-Author: $
5 // Date: $Date: July 2015 $
6 // Revision: $Revision: 0.0 $
7 //
8 //
9 
10 #if !defined(KRATOS_ISOTROPIC_DAMAGE_UTILITIES_H_INCLUDED)
11 #define KRATOS_ISOTROPIC_DAMAGE_UTILITIES_H_INCLUDED
12 
13 
14 /* System includes */
15 #include <cmath>
16 
17 namespace Kratos
18 {
19 
21 {
22 public:
36  static inline void ComputePerturbationVector( Vector& rPerturbationVector, const Vector& InputVector )
37  {
38  const unsigned int VSize = InputVector.size();
39  if(rPerturbationVector.size() != VSize)
40  rPerturbationVector.resize(VSize,false);
41 
42  const double MinTol = 1.0e-10;
43  const double MaxTol = 1.0e-5;
44 
45  //Maximum and minimum vector components
46  double max_component = fabs(InputVector[0]) , min_component = fabs(InputVector[0]);
47 
48  for( unsigned int i=1; i<VSize; i++ )
49  {
50  if( fabs(InputVector[i]) < min_component )
51  {
52  min_component = fabs(InputVector[i]);
53  }
54  else if( fabs(InputVector[i]) > max_component )
55  {
56  max_component = fabs(InputVector[i]);
57  }
58  }
59 
60  double aux = min_component*MaxTol;
61 
62  if( aux < (max_component*MinTol) )
63  {
64  aux = max_component*MinTol;
65  }
66 
67  //PerturbationVector
68  for( unsigned int i=0; i<VSize; i++ )
69  {
70  if( fabs(InputVector[i]) > 1.0e-20 ) // different from zero
71  {
72  rPerturbationVector[i] = InputVector[i]*MaxTol;
73  }
74  else if( InputVector[i] >= 0.0 )
75  {
76  rPerturbationVector[i] = aux;
77  }
78  else
79  {
80  rPerturbationVector[i] = -aux;
81  }
82  }
83  }
84 
85 
86 }; /* Class IsotropicDamageUtilities */
87 } /* namespace Kratos.*/
88 
89 #endif /* KRATOS_ISOTROPIC_DAMAGE_UTILITIES_H_INCLUDED defined */
void resize(std::size_t NewSize1, std::size_t NewSize2, bool preserve=0)
Definition: amatrix_interface.h:224
Definition: isotropic_damage_utilities.hpp:21
static void ComputePerturbationVector(Vector &rPerturbationVector, const Vector &InputVector)
Definition: isotropic_damage_utilities.hpp:36
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
integer i
Definition: TensorModule.f:17