14 #ifndef KRATOS_CONTROL_MODULE_FEM_DEM_2D_UTILITIES
15 #define KRATOS_CONTROL_MODULE_FEM_DEM_2D_UTILITIES
72 "alternate_axis_loading": false,
73 "target_stress_table_id" : 0,
74 "initial_velocity" : 0.0,
75 "limit_velocity" : 1.0,
76 "velocity_factor" : 1.0,
77 "compression_length" : 1.0,
78 "young_modulus" : 1.0e7,
79 "stress_increment_tolerance": 100.0,
80 "update_stiffness": true,
82 "stress_averaging_time": 1.0e-5
110 #pragma omp parallel for
111 for(
int i = 0;
i<NNodes;
i++) {
112 ModelPart::NodesContainerType::iterator it = it_begin +
i;
113 it->SetValue(TARGET_STRESS,zero_vector);
114 it->SetValue(REACTION_STRESS,zero_vector);
115 it->SetValue(LOADING_VELOCITY,zero_vector);
119 #pragma omp parallel for
120 for(
int i = 0;
i<NNodes;
i++) {
121 ModelPart::NodesContainerType::iterator it = it_begin +
i;
122 it->SetValue(TARGET_STRESS,zero_vector);
123 it->SetValue(REACTION_STRESS,zero_vector);
124 it->SetValue(LOADING_VELOCITY,zero_vector);
165 double reaction_stress = CalculateReactionStress();
166 reaction_stress = UpdateVectorOfHistoricalStressesAndComputeNewAverage(reaction_stress);
182 const double NextTargetStress = pTargetStressTable->GetValue(CurrentTime+
delta_time);
183 const double df_target = NextTargetStress - reaction_stress;
200 #pragma omp parallel for
201 for(
int i = 0;
i < NElems;
i++)
203 ModelPart::ElementsContainerType::iterator itElem = elem_begin +
i;
207 unsigned int NumGPoints = IntegrationPoints.size();
208 std::vector<double> imposed_z_strain_vector(NumGPoints);
210 for (
unsigned int GPoint = 0; GPoint < NumGPoints; GPoint++ )
212 imposed_z_strain_vector[GPoint] = imposed_z_strain;
214 itElem->SetValuesOnIntegrationPoints( IMPOSED_Z_STRAIN_VALUE, imposed_z_strain_vector, CurrentProcessInfo );
217 #pragma omp parallel for
218 for(
int i = 0;
i<NNodes;
i++) {
219 ModelPart::NodesContainerType::iterator it = it_begin +
i;
220 it->GetValue(TARGET_STRESS_Z) = pTargetStressTable->GetValue(CurrentTime);
221 it->GetValue(REACTION_STRESS_Z) = reaction_stress;
222 it->GetValue(LOADING_VELOCITY_Z) =
mVelocity;
226 #pragma omp parallel for
227 for(
int i = 0;
i<NNodes;
i++) {
228 ModelPart::NodesContainerType::iterator it = it_begin +
i;
229 it->GetValue(TARGET_STRESS_Z) = pTargetStressTable->GetValue(CurrentTime);
230 it->GetValue(REACTION_STRESS_Z) = reaction_stress;
231 it->GetValue(LOADING_VELOCITY_Z) = 0.0;
247 double ReactionStress = CalculateReactionStress();
269 virtual std::string
Info()
const
363 double UpdateVectorOfHistoricalStressesAndComputeNewAverage(
const double& last_reaction) {
366 if (length_of_vector == 0) {
368 if(number_of_steps_for_stress_averaging < 1) number_of_steps_for_stress_averaging = 1;
370 KRATOS_INFO(
"DEM") <<
" 'number_of_steps_for_stress_averaging' is "<< number_of_steps_for_stress_averaging << std::endl;
375 if(length_of_vector > 1) {
376 for(
int i=1;
i<length_of_vector;
i++) {
382 double average = 0.0;
383 for(
int i=0;
i<length_of_vector;
i++) {
386 average /= (
double) length_of_vector;
392 void IsTimeToApplyCM(){
409 double CalculateReactionStress() {
418 double face_area = 0.0;
420 #pragma omp parallel for reduction(+:face_area)
421 for (
int i = 0;
i < (
int)rElements.size();
i++) {
422 ModelPart::ElementsContainerType::ptr_iterator ptr_itElem = rElements.ptr_begin() +
i;
423 Element* p_element = ptr_itElem->get();
424 SphericContinuumParticle* pDemElem =
dynamic_cast<SphericContinuumParticle*
>(p_element);
425 const double radius = pDemElem->GetRadius();
429 #pragma omp parallel for reduction(+:face_area)
430 for(
int i = 0;
i < NElems;
i++) {
431 ModelPart::ElementsContainerType::iterator itElem = elem_begin +
i;
432 face_area += itElem->GetGeometry().Area();
436 double face_reaction = 0.0;
438 #pragma omp parallel for reduction(+:face_reaction)
439 for (
int i = 0;
i < (
int)rElements.size();
i++) {
440 ModelPart::ElementsContainerType::ptr_iterator ptr_itElem = rElements.ptr_begin() +
i;
441 Element* p_element = ptr_itElem->get();
442 SphericContinuumParticle* pDemElem =
dynamic_cast<SphericContinuumParticle*
>(p_element);
443 BoundedMatrix<double, 3, 3> stress_tensor =
ZeroMatrix(3,3);
444 noalias(stress_tensor) = (*(pDemElem->mSymmStressTensor));
445 const double radius = pDemElem->GetRadius();
449 #pragma omp parallel for reduction(+:face_reaction)
450 for(
int i = 0;
i < NElems;
i++)
452 ModelPart::ElementsContainerType::iterator itElem = elem_begin +
i;
456 unsigned int NumGPoints = IntegrationPoints.size();
457 std::vector<Vector> stress_vector(NumGPoints);
458 itElem->CalculateOnIntegrationPoints( CAUCHY_STRESS_VECTOR, stress_vector, CurrentProcessInfo );
459 const double area_over_gp = rGeom.Area()/NumGPoints;
461 for (
unsigned int GPoint = 0; GPoint < NumGPoints; GPoint++ )
463 face_reaction += stress_vector[GPoint][2] * area_over_gp;
467 double reaction_stress;
468 if (std::abs(face_area) > 1.0e-12) {
469 reaction_stress = face_reaction / face_area;
471 reaction_stress = 0.0;
474 return reaction_stress;
477 double EstimateStiffness(
const double& rReactionStress,
const double& rDeltaTime) {
MeshType & LocalMesh()
Returns the reference to the mesh storing all local entities.
Definition: communicator.cpp:245
Definition: control_module_fem_dem_2d_utilities.hpp:51
double mStiffness
Definition: control_module_fem_dem_2d_utilities.hpp:307
bool mApplyCM
Definition: control_module_fem_dem_2d_utilities.hpp:313
KRATOS_CLASS_POINTER_DEFINITION(ControlModuleFemDem2DUtilities)
double mStressAveragingTime
Definition: control_module_fem_dem_2d_utilities.hpp:310
virtual std::string Info() const
Turn back information as a stemplate<class T, std::size_t dim> tring.
Definition: control_module_fem_dem_2d_utilities.hpp:269
unsigned int mZCounter
Definition: control_module_fem_dem_2d_utilities.hpp:312
unsigned int mTargetStressTableId
Definition: control_module_fem_dem_2d_utilities.hpp:299
double mVelocityFactor
Definition: control_module_fem_dem_2d_utilities.hpp:302
ControlModuleFemDem2DUtilities(ModelPart &rFemModelPart, ModelPart &rDemModelPart, Parameters &rParameters)
Default constructor.
Definition: control_module_fem_dem_2d_utilities.hpp:61
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: control_module_fem_dem_2d_utilities.hpp:282
std::vector< double > mVectorOfLastStresses
Definition: control_module_fem_dem_2d_utilities.hpp:309
ModelPart & mrFemModelPart
Definition: control_module_fem_dem_2d_utilities.hpp:297
double mReactionStressOld
Definition: control_module_fem_dem_2d_utilities.hpp:305
double mStressIncrementTolerance
Definition: control_module_fem_dem_2d_utilities.hpp:306
double mStartTime
Definition: control_module_fem_dem_2d_utilities.hpp:304
void ExecuteFinalizeSolutionStep()
Definition: control_module_fem_dem_2d_utilities.hpp:241
void ExecuteInitialize()
Definition: control_module_fem_dem_2d_utilities.hpp:140
double mCompressionLength
Definition: control_module_fem_dem_2d_utilities.hpp:303
virtual ~ControlModuleFemDem2DUtilities()
Destructor.
Definition: control_module_fem_dem_2d_utilities.hpp:134
void ExecuteInitializeSolutionStep()
Definition: control_module_fem_dem_2d_utilities.hpp:152
Table< double, double > TableType
Defining a table with double argument and result type as table type.
Definition: control_module_fem_dem_2d_utilities.hpp:57
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: control_module_fem_dem_2d_utilities.hpp:276
ModelPart & mrDemModelPart
Definition: control_module_fem_dem_2d_utilities.hpp:298
double mLimitVelocity
Definition: control_module_fem_dem_2d_utilities.hpp:301
bool mAlternateAxisLoading
Definition: control_module_fem_dem_2d_utilities.hpp:311
double mVelocity
Definition: control_module_fem_dem_2d_utilities.hpp:300
bool mUpdateStiffness
Definition: control_module_fem_dem_2d_utilities.hpp:308
void SetValue(const Variable< TDataType > &rThisVariable, TDataType const &rValue)
Sets the value for a given variable.
Definition: data_value_container.h:320
TDataType & GetValue(const Variable< TDataType > &rThisVariable)
Gets the value associated with a given variable.
Definition: data_value_container.h:268
Geometry< NodeType > GeometryType
definition of the geometry type with given NodeType
Definition: element.h:83
IntegrationMethod
Definition: geometry_data.h:76
Geometry base class.
Definition: geometry.h:71
std::vector< IntegrationPointType > IntegrationPointsArrayType
Definition: geometry.h:161
const IntegrationPointsArrayType & IntegrationPoints() const
Definition: geometry.h:2284
ElementsContainerType & Elements()
Definition: mesh.h:568
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ElementIterator ElementsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1169
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
Communicator & GetCommunicator()
Definition: model_part.h:1821
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
TableType::Pointer pGetTable(IndexType TableId)
Definition: model_part.h:595
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
double GetDouble() const
This method returns the double contained in the current Parameter.
Definition: kratos_parameters.cpp:657
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
bool GetBool() const
This method returns the boolean contained in the current Parameter.
Definition: kratos_parameters.cpp:675
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_INFO(label)
Definition: logger.h:250
constexpr double Pi
Definition: global_variables.h:25
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
KratosZeroMatrix< double > ZeroMatrix
Definition: amatrix_interface.h:559
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
REACTION_CHECK_STIFFNESS_FACTOR int
Definition: contact_structural_mechanics_application_variables.h:75
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
ProcessInfo
Definition: edgebased_PureConvection.py:116
int step
Definition: face_heat.py:88
delta_time
Definition: generate_frictional_mortar_condition.py:130
float radius
Definition: mesh_to_mdpa_converter.py:18
integer i
Definition: TensorModule.f:17