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.
nonlocal_damage_utilities.hpp
Go to the documentation of this file.
1 
2 // | / |
3 // ' / __| _` | __| _ \ __|
4 // . \ | ( | | ( |\__ `
5 // _|\_\_| \__,_|\__|\___/ ____/
6 // Multi-Physics
7 //
8 // License: BSD License
9 // Kratos default license: kratos/license.txt
10 //
11 // Main authors: Ignasi de Pouplana
12 //
13 
14 
15 #if !defined(KRATOS_NONLOCAL_DAMAGE_UTILITIES )
16 #define KRATOS_NONLOCAL_DAMAGE_UTILITIES
17 
18 // System includes
19 #include <cmath>
20 
21 // Project includes
22 #include "geometries/geometry.h"
23 #include "includes/define.h"
24 #include "includes/model_part.h"
26 #include "utilities/openmp_utils.h"
28 
29 // Application includes
31 
32 namespace Kratos
33 {
34 
36 {
37 
38 protected:
39 
40  struct GaussPoint
41  {
42  // Default Constructor
44 
45  // Constructor 1
46  GaussPoint (ConstitutiveLaw::Pointer pConstitutiveLawPointer,
47  const array_1d<double,3>& Coords,
48  const double& IntegrationWeight)
49  {
50  pConstitutiveLaw = pConstitutiveLawPointer;
51  noalias(Coordinates) = Coords;
52  Weight = IntegrationWeight;
53  }
54 
55  // Member variables
56  ConstitutiveLaw::Pointer pConstitutiveLaw;
58  double Weight;
59  std::vector<GaussPoint*> NeighbourPoints;
60  };
61 
63 
64 public:
65 
67 
70 
72 
75  {
76  for (unsigned int i = 0; i < mGaussPointList.size(); i++)
77  delete mGaussPointList[i];
78  }
79 
81 
82  virtual void SearchGaussPointsNeighbours (Parameters* pParameters, ModelPart& rModelPart)
83  {
84  KRATOS_ERROR << "Calling the default SearchGaussPointsNeighbours method" << std::endl;
85  }
86 
88 
89  void CalculateNonlocalEquivalentStrain (Parameters* pParameters, const ProcessInfo& CurrentProcessInfo)
90  {
91  int NGPoints = static_cast<int>(mGaussPointList.size());
92  double CharacteristicLength = (*pParameters)["characteristic_length"].GetDouble();
93 
94  // Loop through all Gauss Points
95  #pragma omp parallel for
96  for(int i = 0; i < NGPoints; i++)
97  {
98  const GaussPoint& ReceiverPoint = *(mGaussPointList[i]);
99  double LocalEquivalentStrain;
100  LocalEquivalentStrain = ReceiverPoint.pConstitutiveLaw->GetValue(LOCAL_EQUIVALENT_STRAIN,LocalEquivalentStrain);;
101  double Numerator = ReceiverPoint.Weight*LocalEquivalentStrain;
102  double WeightingFunctionDenominator = ReceiverPoint.Weight;
103 
104  //Loop through neighbours
105  for(unsigned int j = 0; j < ReceiverPoint.NeighbourPoints.size(); j++)
106  {
107  const GaussPoint& SourcePoint = *(ReceiverPoint.NeighbourPoints[j]);
108  double Distance;
109  this->ComputeNeighbourDistance(Distance,ReceiverPoint,SourcePoint);
110  LocalEquivalentStrain = SourcePoint.pConstitutiveLaw->GetValue(LOCAL_EQUIVALENT_STRAIN,LocalEquivalentStrain);
111 
112  Numerator += SourcePoint.Weight*exp(-4.0*Distance*Distance/(CharacteristicLength*CharacteristicLength))*LocalEquivalentStrain;
113  WeightingFunctionDenominator += SourcePoint.Weight*exp(-4.0*Distance*Distance/(CharacteristicLength*CharacteristicLength));
114  }
115  double NonlocalEquivalentStrain = Numerator/WeightingFunctionDenominator;
116  ReceiverPoint.pConstitutiveLaw->SetValue(NONLOCAL_EQUIVALENT_STRAIN,NonlocalEquivalentStrain,CurrentProcessInfo);
117  }
118  }
119 
121 
122 protected:
123 
125  std::vector<GaussPoint*> mGaussPointList;
126 
128 
130  double& rDistance,
131  const GaussPoint& ReceiverPoint,
132  const GaussPoint& SourcePoint)
133  {
134  KRATOS_ERROR << "Calling the default ComputeNeighbourDistance method" << std::endl;
135  }
136 
138 
139 }; // Class NonlocalDamageUtilities
140 
141 } // namespace Kratos.
142 
143 #endif /* KRATOS_NONLOCAL_DAMAGE_UTILITIES defined */
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
Definition: nonlocal_damage_utilities.hpp:36
virtual void ComputeNeighbourDistance(double &rDistance, const GaussPoint &ReceiverPoint, const GaussPoint &SourcePoint)
Definition: nonlocal_damage_utilities.hpp:129
NonlocalDamageUtilities()
Default Constructor.
Definition: nonlocal_damage_utilities.hpp:69
virtual void SearchGaussPointsNeighbours(Parameters *pParameters, ModelPart &rModelPart)
Definition: nonlocal_damage_utilities.hpp:82
virtual ~NonlocalDamageUtilities()
Destructor.
Definition: nonlocal_damage_utilities.hpp:74
KRATOS_CLASS_POINTER_DEFINITION(NonlocalDamageUtilities)
std::vector< GaussPoint * > mGaussPointList
Member Variables.
Definition: nonlocal_damage_utilities.hpp:125
void CalculateNonlocalEquivalentStrain(Parameters *pParameters, const ProcessInfo &CurrentProcessInfo)
Definition: nonlocal_damage_utilities.hpp:89
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
#define KRATOS_ERROR
Definition: exception.h:161
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
int j
Definition: quadrature.py:648
integer i
Definition: TensorModule.f:17
Definition: nonlocal_damage_utilities.hpp:41
ConstitutiveLaw::Pointer pConstitutiveLaw
Definition: nonlocal_damage_utilities.hpp:56
double Weight
Definition: nonlocal_damage_utilities.hpp:58
std::vector< GaussPoint * > NeighbourPoints
Definition: nonlocal_damage_utilities.hpp:59
GaussPoint()
Definition: nonlocal_damage_utilities.hpp:43
array_1d< double, 3 > Coordinates
Definition: nonlocal_damage_utilities.hpp:57
GaussPoint(ConstitutiveLaw::Pointer pConstitutiveLawPointer, const array_1d< double, 3 > &Coords, const double &IntegrationWeight)
Definition: nonlocal_damage_utilities.hpp:46