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.
spheric_continuum_particle.h
Go to the documentation of this file.
1 //
2 // Author: Miquel Santasusana msantasusana@cimne.upc.edu
3 //
4 
5 #if !defined(KRATOS_SPHERIC_CONTINUUM_PARTICLE_H_INCLUDED )
6 #define KRATOS_SPHERIC_CONTINUUM_PARTICLE_H_INCLUDED
7 
8 // System includes
9 #include <string>
10 #include <iostream>
11 #include <iomanip> // to improve std::cout precision
12 
13 // Project includes
14 #include "includes/define.h"
15 #include "spheric_particle.h"
17 #include "custom_utilities/AuxiliaryFunctions.h"
18 #include "utilities/openmp_utils.h"
19 #include "utilities/timer.h"
22 
23 namespace Kratos
24 {
25  class KRATOS_API(DEM_APPLICATION) SphericContinuumParticle : public SphericParticle
26  {
27  public:
28 
31 
35 
37  SphericContinuumParticle(IndexType NewId, GeometryType::Pointer pGeometry);
38  SphericContinuumParticle(IndexType NewId, NodesArrayType const& ThisNodes);
39  SphericContinuumParticle(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties);
40 
41  Element::Pointer Create(IndexType NewId, NodesArrayType const& ThisNodes, PropertiesType::Pointer pProperties) const override;
42 
44  virtual ~SphericContinuumParticle();
45 
46 
48  {
49  public:
51 
52  virtual ~ParticleDataBuffer(){}
53 
54  bool SetNextNeighbourOrExit(int& i) override
55  {
56  while (i < int(mpThisParticle->mNeighbourElements.size()) && (mpThisParticle->mNeighbourElements[i]==NULL)){
57  i++;
58  }
59 
60  if (i < int(mpThisParticle->mNeighbourElements.size())) {
61  SetCurrentNeighbour(mpThisParticle->mNeighbourElements[i]);
62  mpOtherParticleNode = &(mpOtherParticle->GetGeometry()[0]);
63  return true;
64  }
65 
66  else { // other_neighbour is nullified upon exiting loop
67  mpOtherParticle = NULL;
68  mpOtherParticleNode = NULL;
69  return false;
70  }
71  }
72  };
73 
74  std::unique_ptr<SphericParticle::ParticleDataBuffer> CreateParticleDataBuffer(SphericParticle* p_this_particle) override
75  {
76  return std::unique_ptr<SphericParticle::ParticleDataBuffer>(new ParticleDataBuffer(p_this_particle));
77  }
78 
79  virtual void SetInitialSphereContacts(const ProcessInfo& r_process_info);
80  void SetInitialFemContacts();
81  virtual void CreateContinuumConstitutiveLaws();
82  void FinalizeSolutionStep(const ProcessInfo& r_process_info) override;
83  void GetStressTensorFromNeighbourStep1();
84  void GetStressTensorFromNeighbourStep2();
85  void GetStressTensorFromNeighbourStep3();
86 
87  void Calculate(const Variable<double>& rVariable, double& Output, const ProcessInfo& r_process_info) override;
88 
89  void ReorderAndRecoverInitialPositionsAndFilter(std::vector<SphericParticle*>& mTempNeighbourElements);
90  virtual void UpdateContinuumNeighboursVector(const ProcessInfo& r_process_info);
91  virtual void ReorderFEMneighbours();
92  virtual void ComputeForceWithNeighbourFinalOperations();
93 
94  virtual double CalculateMaxSearchDistance(const bool has_mpi, const ProcessInfo& r_process_info);
95  virtual bool OverlappedParticleRemoval();
96  virtual void CalculateMeanContactArea(const bool has_mpi, const ProcessInfo& r_process_info);
97  virtual void CalculateOnContinuumContactElements(size_t i_neighbour_count, double LocalElasticContactForce[3], double ElasticLocalRotationalMoment[3],
98  double contact_sigma, double contact_tau, double failure_criterion_state, double acumulated_damage, int time_steps, double calculation_area);
99 
100 
101  virtual void FilterNonSignificantDisplacements(double DeltDisp[3], //IN GLOBAL AXES
102  double RelVel[3], //IN GLOBAL AXES
103  double& indentation);
104 
105 
106 
107  virtual void ContactAreaWeighting();
108  virtual double EffectiveVolumeRadius();
109  virtual double GetInitialDelta(int index);
110  virtual bool IsSkin() { return (bool)*mSkinSphere; }
111  void MarkNewSkinParticlesDueToBreakage();
112 
114  virtual std::string Info() const override
115  {
116  std::stringstream buffer;
117  buffer << "SphericCosntinuumParticle" ;
118  return buffer.str();
119  }
120 
122  virtual void PrintInfo(std::ostream& rOStream) const override {rOStream << "SphericContinuumParticle";}
123 
125  virtual void PrintData(std::ostream& rOStream) const override {}
126 
127  //member variables DEM_CONTINUUM
129  std::vector<int> mIniNeighbourIds;
130  std::vector<int> mIniNeighbourFailureId;
131  std::vector<double> mIniNeighbourDelta;
132 
134  unsigned int mInitialNeighborsSize;
135  std::vector<Kratos::DEMContinuumConstitutiveLaw::Pointer> mContinuumConstitutiveLawArray;
136  double mLocalRadiusAmplificationFactor = 1.0;
137  double mLocalJointNormal[3];
138 
139  protected:
140 
142 
143  void Initialize(const ProcessInfo& r_process_info) override;
144  virtual double GetInitialDeltaWithFEM(int index) override;
145  virtual void ComputeBallToBallContactForceAndMoment(SphericParticle::ParticleDataBuffer &,
146  const ProcessInfo& r_process_info,
147  array_1d<double, 3>& rElasticForce,
148  array_1d<double, 3>& rContactForce) override;
149  virtual void ComputeBrokenBondsRatio();
150  virtual void AddContributionToRepresentativeVolume(const double distance,
151  const double radius_sum,
152  const double contact_area);
153 
154  double* mSkinSphere;
155  std::vector<int> mFemIniNeighbourIds;
156  std::vector<double> mFemIniNeighbourDelta;
157 
158  private:
159 
160  friend class Serializer;
161 
162  virtual void save(Serializer& rSerializer) const override
163  {
165  //rSerializer.save("mContinuumGroup",mContinuumGroup);
166  //rSerializer.save("mIniNeighbourIds",mIniNeighbourIds);
167  //rSerializer.save("mSymmStressTensor",mSymmStressTensor);
168  rSerializer.save("mContinuumInitialNeighborsSize",mContinuumInitialNeighborsSize);
169  }
170 
171  virtual void load(Serializer& rSerializer) override
172  {
174  //rSerializer.load("mContinuumGroup",mContinuumGroup);
175  //rSerializer.load("mIniNeighbourIds",mIniNeighbourIds);
176  //rSerializer.load("mSymmStressTensor",mSymmStressTensor);
177  rSerializer.load("mContinuumInitialNeighborsSize",mContinuumInitialNeighborsSize);
178  mContinuumGroup = this->GetGeometry()[0].FastGetSolutionStepValue(COHESIVE_GROUP);
179  mSkinSphere = &(this->GetGeometry()[0].FastGetSolutionStepValue(SKIN_SPHERE));
180  }
181 
182  /* Assignment operator
183  SphericContinuumParticle& operator=(SphericContinuumParticle const& rOther) { return *this; }
184  Copy constructor
185  SphericContinuumParticle(SphericContinuumParticle const& rOther) { *this = rOther; }
186  */
187 
188  }; // Class SphericContinuumParticle
189 
191  inline std::istream& operator >> (std::istream& rIStream, SphericContinuumParticle& rThis) {return rIStream;}
192 
194  inline std::ostream& operator << (std::ostream& rOStream, const SphericContinuumParticle& rThis) {
195  rThis.PrintInfo(rOStream);
196  rOStream << std::endl;
197  rThis.PrintData(rOStream);
198  return rOStream;
199  }
200 } // namespace Kratos
201 
202 #endif // KRATOS_SPHERIC_CONTINUUM_PARTICLE_H_INCLUDED defined
std::size_t IndexType
Definition: flags.h:74
typename TContainerType::iterator ptr_iterator
Definition: global_pointers_vector.h:85
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
void load(std::string const &rTag, TDataType &rObject)
Definition: serializer.h:207
void save(std::string const &rTag, std::array< TDataType, TDataSize > const &rObject)
Definition: serializer.h:545
Definition: spheric_continuum_particle.h:48
ParticleDataBuffer(SphericParticle *p_this_particle)
Definition: spheric_continuum_particle.h:50
bool SetNextNeighbourOrExit(int &i) override
Definition: spheric_continuum_particle.h:54
virtual ~ParticleDataBuffer()
Definition: spheric_continuum_particle.h:52
Definition: spheric_continuum_particle.h:26
std::vector< double > mIniNeighbourDelta
Definition: spheric_continuum_particle.h:131
GlobalPointersVector< Element > ParticleWeakVectorType
Definition: spheric_continuum_particle.h:32
int mContinuumGroup
Definition: spheric_continuum_particle.h:128
std::unique_ptr< SphericParticle::ParticleDataBuffer > CreateParticleDataBuffer(SphericParticle *p_this_particle) override
Definition: spheric_continuum_particle.h:74
double * mSkinSphere
Definition: spheric_continuum_particle.h:154
ParticleWeakVectorType::ptr_iterator ParticleWeakIteratorType_ptr
Definition: spheric_continuum_particle.h:33
GlobalPointersVector< Element >::iterator ParticleWeakIteratorType
Definition: spheric_continuum_particle.h:34
std::vector< Kratos::DEMContinuumConstitutiveLaw::Pointer > mContinuumConstitutiveLawArray
Definition: spheric_continuum_particle.h:135
virtual void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: spheric_continuum_particle.h:122
virtual void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: spheric_continuum_particle.h:125
unsigned int mInitialNeighborsSize
Definition: spheric_continuum_particle.h:134
std::vector< int > mIniNeighbourIds
Definition: spheric_continuum_particle.h:129
KRATOS_CLASS_INTRUSIVE_POINTER_DEFINITION(SphericContinuumParticle)
Pointer definition of SphericContinuumParticle.
virtual std::string Info() const override
Turn back information as a string.
Definition: spheric_continuum_particle.h:114
std::vector< double > mFemIniNeighbourDelta
Definition: spheric_continuum_particle.h:156
unsigned int mContinuumInitialNeighborsSize
Definition: spheric_continuum_particle.h:133
std::vector< int > mIniNeighbourFailureId
Definition: spheric_continuum_particle.h:130
std::vector< int > mFemIniNeighbourIds
Definition: spheric_continuum_particle.h:155
virtual bool IsSkin()
Definition: spheric_continuum_particle.h:110
Definition: spheric_particle.h:59
Definition: spheric_particle.h:31
#define KRATOS_SERIALIZE_SAVE_BASE_CLASS(Serializer, BaseType)
Definition: define.h:812
#define KRATOS_SERIALIZE_LOAD_BASE_CLASS(Serializer, BaseType)
Definition: define.h:815
Modeler::Pointer Create(const std::string &ModelerName, Model &rModel, const Parameters ModelParameters)
Checks if the modeler is registered.
Definition: modeler_factory.cpp:30
TDataType Calculate(GeometryType &dummy, const Variable< TDataType > &rVariable)
Definition: add_geometries_to_python.cpp:103
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
def load(f)
Definition: ode_solve.py:307
integer i
Definition: TensorModule.f:17