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.
inlet.h
Go to the documentation of this file.
1 //
2 // Authors:
3 // Miguel Angel Celigueta maceli@cimne.upc.edu
4 //
5 
6 #if !defined(DEM_INLET_H)
7 #define DEM_INLET_H
8 
9 // System includes
10 #include <string>
11 #include <iostream>
12 #include <random>
13 
14 // Project includes
15 #include "includes/define.h"
16 #include "includes/variables.h"
17 #include "includes/node.h"
18 #include "includes/element.h"
19 #include "geometries/geometry.h"
20 #include "includes/properties.h"
21 #include "includes/process_info.h"
25 #include "includes/condition.h"
27 #include "custom_utilities/AuxiliaryFunctions.h"
33 
34 namespace Kratos {
35 
36  class ParticleCreatorDestructor;
37 
38  class KRATOS_API(DEM_APPLICATION) DEM_Inlet
39  {
40  public:
41 
45 
47 
49  DEM_Inlet(ModelPart& inlet_modelpart, const int seed=42);
50  DEM_Inlet(ModelPart& inlet_modelpart, const Parameters& r_inlet_settings, const int seed=42);
51 
53  virtual ~DEM_Inlet(){}
54 
55  DEM_Inlet(const DEM_Inlet&) = delete;
56  DEM_Inlet& operator=(const DEM_Inlet&) = delete;
57 
58  template<class TDataType> void CheckIfSubModelPartHasVariable(ModelPart& smp, const Variable<TDataType>& rThisVariable) {
59  if(!smp.Has(rThisVariable)) KRATOS_ERROR<<"The SubModelPart '"<<smp.Name()<<"' does not have the variable '"<<rThisVariable.Name()<<"'";
60  }
61  virtual void CheckSubModelPart(ModelPart& smp);
62  virtual void InitializeDEM_Inlet(ModelPart& r_modelpart, ParticleCreatorDestructor& creator, const bool using_strategy_for_continuum = false);
63  virtual void InitializeStep(ModelPart& r_modelpart);
64  void DettachElements(ModelPart& r_modelpart, unsigned int& max_Id);
65  void DettachClusters(ModelPart& r_clusters_modelpart, unsigned int& max_Id);
66  bool OneNeighbourInjectorIsInjecting(const Element::Pointer& element);
67  virtual void CreateElementsFromInletMesh(ModelPart& r_modelpart, ModelPart& r_clusters_modelpart, ParticleCreatorDestructor& creator);
68  ModelPart& GetInletModelPart();
69  void SetNormalizedMaxIndentationForRelease(const double value);
70  void SetNormalizedMaxIndentationForNewParticleCreation(const double value);
71  int GetPartialNumberOfParticlesInjectedSoFar(const int i);
72  int GetTotalNumberOfParticlesInjectedSoFar();
73  double GetPartialMassInjectedSoFar(const int i);
74  double GetTotalMassInjectedSoFar();
75  virtual double SetMaxDistributionRadius(ModelPart& mp);
76  virtual double SetDistributionMeanRadius(ModelPart& mp);
77  virtual double GetMaxRadius(ModelPart& mp);
78 
79  protected:
80  virtual void AddRandomPerpendicularComponentToGivenVector(array_1d<double, 3 >& vector, const double angle_in_degrees);
81  virtual void AddRandomPerpendicularComponentToGivenVector2D(array_1d<double, 3 >& vector, const double angle_in_degrees);
82 
83  private:
84 
85 
86  void UpdateInjectedParticleVelocity(Element &particle, Element &injector_element);
87  virtual void FixInjectorConditions(Element* p_element);
88  virtual void FixInjectionConditions(Element* p_element, Element* p_injector_element);
89  virtual void RemoveInjectionConditions(Element &element, const int dimension);
90  virtual void UpdateTotalThroughput(SphericParticle& r_spheric_particle);
91  virtual void UpdateTotalThroughput(Cluster3D& r_cluster);
92  virtual void UpdatePartialThroughput(SphericParticle& r_spheric_particle, const int i);
93  virtual void UpdatePartialThroughput(Cluster3D& r_cluster, const int i);
94  double GetInputNumberOfParticles(const ModelPart& mp);
95  virtual void CheckDistanceAndSetFlag(ModelPart& r_modelpart);
96 
97 
98  std::vector<double> mPartialParticleToInsert; //array of doubles, must be resized in the constructor to the number of meshes
99  std::vector<double> mLastInjectionTimes; //array of doubles, must be resized in the constructor to the number of meshes
100 
101  bool mFirstInjectionIsDone;
102  bool mBallsModelPartHasSphericity;
103  bool mBallsModelPartHasRotation;
104  bool mStrategyForContinuum;
105  int mTotalNumberOfParticlesInjected;
106  std::vector<int> mNumberOfParticlesInjected;
107  std::map<int, std::string> mOriginInletSubmodelPartIndexes;
108  double mTotalMassInjected;
109  //int mSeed;
110  std::vector<double> mMassInjected;
111  std::mt19937 mGenerator;
112  // The following two ratios mark the limit indentation (normalized by the radius) for releasing a particle
113  // and for allowing a new one to be injected. admissible_indentation_ratio_for_release should be smaller
114  // (more strict), since we want to make sure that the particle is taken far enough to avoid interferences
115  // with the newly created ones to come. Otherwise, an initial huge indentation could easily happen.
116  double mNormalizedMaxIndentationForRelease;
117  double mNormalizedMaxIndentationForNewParticleCreation;
118  std::vector<PropertiesProxy> mFastProperties;
119  std::vector<bool> mLayerRemoved;
120  //std::vector<int> mTotalNumberOfDetachedParticles;
121  ModelPart& mInletModelPart; //The model part used to insert elements
122 
123  bool mWarningTooSmallInlet;
124  bool mWarningTooSmallInletForMassFlow;
125  void ThrowWarningTooSmallInlet(const ModelPart& mp);
126  void ThrowWarningTooSmallInletForMassFlow(const ModelPart& mp);
127  std::vector<ModelPart*> mListOfSubModelParts;
128  std::map<std::string, std::unique_ptr<RandomVariable>> mInletsRandomVariables;
129  std::map<std::string, Parameters> mInletsRandomSettings;
130  Parameters mInletsSettings;
131  };
132 }// namespace Kratos.
133 
134 #endif // DEM_INLET_H defined
135 
Definition: cluster3D.h:29
Definition: inlet.h:39
DEM_Inlet & operator=(const DEM_Inlet &)=delete
ModelPart::ElementsContainerType ElementsArrayType
Definition: inlet.h:44
GlobalPointersVector< Element >::iterator ParticleWeakIteratorType
Definition: inlet.h:42
KRATOS_CLASS_POINTER_DEFINITION(DEM_Inlet)
virtual ~DEM_Inlet()
Destructor.
Definition: inlet.h:53
void CheckIfSubModelPartHasVariable(ModelPart &smp, const Variable< TDataType > &rThisVariable)
Definition: inlet.h:58
DEM_Inlet(const DEM_Inlet &)=delete
GlobalPointersVector< Element > ParticleWeakVectorType
Definition: inlet.h:43
bool Has(const Variable< TDataType > &rThisVariable) const
Checks if the data container has a value associated with a given variable.
Definition: data_value_container.h:382
Base class for all Elements.
Definition: element.h:60
This class is a vector which stores global pointers.
Definition: global_pointers_vector.h:61
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
std::string & Name()
Definition: model_part.h:1811
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
Definition: create_and_destroy.h:33
Definition: spheric_particle.h:31
const std::string & Name() const
Definition: variable_data.h:201
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
#define KRATOS_ERROR
Definition: exception.h:161
int seed
Definition: GenerateWind.py:138
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
int angle_in_degrees
Definition: angle_finder.py:23
int dimension
Definition: isotropic_damage_automatic_differentiation.py:123
integer i
Definition: TensorModule.f:17
Definition: mesh_converter.cpp:33