14 #ifndef KRATOS_CONTROL_MODULE_FEM_DEM_UTILITIES
15 #define KRATOS_CONTROL_MODULE_FEM_DEM_UTILITIES
72 "imposed_direction" : 2,
73 "alternate_axis_loading": false,
74 "target_stress_table_id" : 0,
75 "initial_velocity" : 0.0,
76 "limit_velocity" : 1.0,
77 "velocity_factor" : 1.0,
78 "compression_length" : 1.0,
79 "young_modulus" : 1.0e7,
80 "stress_increment_tolerance": 100.0,
81 "update_stiffness": true,
83 "stress_averaging_time": 1.0e-5
122 #pragma omp parallel for
123 for(
int i = 0;
i<NNodes;
i++) {
124 ModelPart::NodesContainerType::iterator it = it_begin +
i;
125 it->SetValue(TARGET_STRESS,zero_vector);
126 it->SetValue(REACTION_STRESS,zero_vector);
127 it->SetValue(LOADING_VELOCITY,zero_vector);
131 #pragma omp parallel for
132 for(
int i = 0;
i<NNodes;
i++) {
133 ModelPart::NodesContainerType::iterator it = it_begin +
i;
134 it->SetValue(TARGET_STRESS,zero_vector);
135 it->SetValue(REACTION_STRESS,zero_vector);
136 it->SetValue(LOADING_VELOCITY,zero_vector);
161 #pragma omp parallel for
162 for(
int i = 0;
i<NNodes;
i++) {
163 ModelPart::NodesContainerType::iterator it = it_begin +
i;
164 it->Fix(DISPLACEMENT_X);
165 it->FastGetSolutionStepValue(DISPLACEMENT_X) = 0.0;
169 #pragma omp parallel for
170 for(
int i = 0;
i<NNodes;
i++) {
171 ModelPart::NodesContainerType::iterator it = it_begin +
i;
172 it->Fix(DISPLACEMENT_Y);
173 it->FastGetSolutionStepValue(DISPLACEMENT_Y) = 0.0;
177 #pragma omp parallel for
178 for(
int i = 0;
i<NNodes;
i++) {
179 ModelPart::NodesContainerType::iterator it = it_begin +
i;
180 it->Fix(DISPLACEMENT_Z);
181 it->FastGetSolutionStepValue(DISPLACEMENT_Z) = 0.0;
197 double ReactionStress = CalculateReactionStress();
198 ReactionStress = UpdateVectorOfHistoricalStressesAndComputeNewAverage(ReactionStress);
208 mStiffness = EstimateStiffness(ReactionStress,DeltaTime);
214 const double NextTargetStress = pTargetStressTable->GetValue(CurrentTime+DeltaTime);
215 const double df_target = NextTargetStress - ReactionStress;
237 #pragma omp parallel for
238 for(
int i = 0;
i<NNodes;
i++) {
239 ModelPart::NodesContainerType::iterator it = it_begin +
i;
240 it->FastGetSolutionStepValue(DISPLACEMENT_X) +=
mVelocity * DeltaTime;
242 it->GetValue(TARGET_STRESS_X) = pTargetStressTable->GetValue(CurrentTime);
243 it->GetValue(REACTION_STRESS_X) = ReactionStress;
244 it->GetValue(LOADING_VELOCITY_X) =
mVelocity;
250 #pragma omp parallel for
251 for(
int i = 0;
i<NNodes;
i++) {
252 ModelPart::NodesContainerType::iterator it = it_begin +
i;
253 it->FastGetSolutionStepValue(DISPLACEMENT_Y) +=
mVelocity * DeltaTime;
255 it->GetValue(TARGET_STRESS_Y) = pTargetStressTable->GetValue(CurrentTime);
256 it->GetValue(REACTION_STRESS_Y) = ReactionStress;
257 it->GetValue(LOADING_VELOCITY_Y) =
mVelocity;
263 #pragma omp parallel for
264 for(
int i = 0;
i<NNodes;
i++) {
265 ModelPart::NodesContainerType::iterator it = it_begin +
i;
266 it->FastGetSolutionStepValue(DISPLACEMENT_Z) +=
mVelocity * DeltaTime;
268 it->GetValue(TARGET_STRESS_Z) = pTargetStressTable->GetValue(CurrentTime);
269 it->GetValue(REACTION_STRESS_Z) = ReactionStress;
270 it->GetValue(LOADING_VELOCITY_Z) =
mVelocity;
280 #pragma omp parallel for
281 for(
int i = 0;
i<NNodes;
i++) {
282 ModelPart::NodesContainerType::iterator it = it_begin +
i;
283 it->GetValue(TARGET_STRESS_X) = pTargetStressTable->GetValue(CurrentTime);
284 it->GetValue(REACTION_STRESS_X) = ReactionStress;
285 it->GetValue(LOADING_VELOCITY_X) = 0.0;
291 #pragma omp parallel for
292 for(
int i = 0;
i<NNodes;
i++) {
293 ModelPart::NodesContainerType::iterator it = it_begin +
i;
294 it->GetValue(TARGET_STRESS_Y) = pTargetStressTable->GetValue(CurrentTime);
295 it->GetValue(REACTION_STRESS_Y) = ReactionStress;
296 it->GetValue(LOADING_VELOCITY_Y) = 0.0;
302 #pragma omp parallel for
303 for(
int i = 0;
i<NNodes;
i++) {
304 ModelPart::NodesContainerType::iterator it = it_begin +
i;
305 it->GetValue(TARGET_STRESS_Z) = pTargetStressTable->GetValue(CurrentTime);
306 it->GetValue(REACTION_STRESS_Z) = ReactionStress;
307 it->GetValue(LOADING_VELOCITY_Z) = 0.0;
321 double ReactionStress = CalculateReactionStress();
343 virtual std::string
Info()
const
439 double UpdateVectorOfHistoricalStressesAndComputeNewAverage(
const double& last_reaction) {
442 if (length_of_vector == 0) {
444 if(number_of_steps_for_stress_averaging < 1) number_of_steps_for_stress_averaging = 1;
446 KRATOS_INFO(
"DEM") <<
" 'number_of_steps_for_stress_averaging' is "<< number_of_steps_for_stress_averaging << std::endl;
451 if(length_of_vector > 1) {
452 for(
int i=1;
i<length_of_vector;
i++) {
458 double average = 0.0;
459 for(
int i=0;
i<length_of_vector;
i++) {
462 average /= (
double) length_of_vector;
468 void IsTimeToApplyCM(){
497 double CalculateReactionStress() {
506 double face_area = 0.0;
508 #pragma omp parallel for reduction(+:face_area)
509 for (
int i = 0;
i < (
int)rElements.size();
i++) {
510 ModelPart::ElementsContainerType::ptr_iterator ptr_itElem = rElements.ptr_begin() +
i;
511 Element* p_element = ptr_itElem->get();
512 SphericContinuumParticle* pDemElem =
dynamic_cast<SphericContinuumParticle*
>(p_element);
513 const double radius = pDemElem->GetRadius();
519 #pragma omp parallel for reduction(+:face_area)
520 for(
int i = 0;
i < NCons;
i++)
522 ModelPart::ConditionsContainerType::iterator itCond = con_begin +
i;
523 face_area += itCond->GetGeometry().Area();
527 double FaceReaction = 0.0;
530 #pragma omp parallel for reduction(+:FaceReaction)
531 for(
int i = 0;
i<NNodes;
i++){
532 ModelPart::NodesContainerType::iterator it = it_begin +
i;
533 FaceReaction += it->FastGetSolutionStepValue(REACTION_X);
536 #pragma omp parallel for reduction(+:FaceReaction)
537 for(
int i = 0;
i<NNodes;
i++){
538 ModelPart::NodesContainerType::iterator it = it_begin +
i;
539 FaceReaction += it->FastGetSolutionStepValue(REACTION_Y);
542 #pragma omp parallel for reduction(+:FaceReaction)
543 for(
int i = 0;
i<NNodes;
i++){
544 ModelPart::NodesContainerType::iterator it = it_begin +
i;
545 FaceReaction += it->FastGetSolutionStepValue(REACTION_Z);
554 #pragma omp parallel for reduction(-:FaceReaction)
555 for(
int i = 0;
i<NDemNodes;
i++) {
556 ModelPart::NodesContainerType::iterator it = it_dem_begin +
i;
557 FaceReaction -= it->FastGetSolutionStepValue(TOTAL_FORCES_X);
560 #pragma omp parallel for reduction(-:FaceReaction)
561 for(
int i = 0;
i<NDemNodes;
i++) {
562 ModelPart::NodesContainerType::iterator it = it_dem_begin +
i;
563 FaceReaction -= it->FastGetSolutionStepValue(TOTAL_FORCES_Y);
566 #pragma omp parallel for reduction(-:FaceReaction)
567 for(
int i = 0;
i<NDemNodes;
i++) {
568 ModelPart::NodesContainerType::iterator it = it_dem_begin +
i;
569 FaceReaction -= it->FastGetSolutionStepValue(TOTAL_FORCES_Z);
573 double reaction_stress;
574 if (std::abs(face_area) > 1.0e-12) {
575 reaction_stress = FaceReaction / face_area;
577 reaction_stress = 0.0;
580 return reaction_stress;
583 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_utilities.hpp:51
double mStiffness
Definition: control_module_fem_dem_utilities.hpp:381
void ExecuteInitialize()
Definition: control_module_fem_dem_utilities.hpp:152
KRATOS_CLASS_POINTER_DEFINITION(ControlModuleFemDemUtilities)
bool mApplyCM
Definition: control_module_fem_dem_utilities.hpp:389
virtual ~ControlModuleFemDemUtilities()
Destructor.
Definition: control_module_fem_dem_utilities.hpp:146
ModelPart & mrFemModelPart
Definition: control_module_fem_dem_utilities.hpp:371
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: control_module_fem_dem_utilities.hpp:350
unsigned int mXCounter
Definition: control_module_fem_dem_utilities.hpp:386
bool mUpdateStiffness
Definition: control_module_fem_dem_utilities.hpp:382
double mStressAveragingTime
Definition: control_module_fem_dem_utilities.hpp:384
bool mAlternateAxisLoading
Definition: control_module_fem_dem_utilities.hpp:385
double mReactionStressOld
Definition: control_module_fem_dem_utilities.hpp:379
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: control_module_fem_dem_utilities.hpp:356
void ExecuteFinalizeSolutionStep()
Definition: control_module_fem_dem_utilities.hpp:315
void ExecuteInitializeSolutionStep()
Definition: control_module_fem_dem_utilities.hpp:189
unsigned int mYCounter
Definition: control_module_fem_dem_utilities.hpp:387
ControlModuleFemDemUtilities(ModelPart &rFemModelPart, ModelPart &rDemModelPart, Parameters &rParameters)
Default constructor.
Definition: control_module_fem_dem_utilities.hpp:61
double mStartTime
Definition: control_module_fem_dem_utilities.hpp:378
double mLimitVelocity
Definition: control_module_fem_dem_utilities.hpp:376
ModelPart & mrDemModelPart
Definition: control_module_fem_dem_utilities.hpp:372
double mStressIncrementTolerance
Definition: control_module_fem_dem_utilities.hpp:380
unsigned int mImposedDirection
Definition: control_module_fem_dem_utilities.hpp:373
double mVelocity
Definition: control_module_fem_dem_utilities.hpp:375
double mVelocityFactor
Definition: control_module_fem_dem_utilities.hpp:377
std::vector< double > mVectorOfLastStresses
Definition: control_module_fem_dem_utilities.hpp:383
unsigned int mZCounter
Definition: control_module_fem_dem_utilities.hpp:388
Table< double, double > TableType
Defining a table with double argument and result type as table type.
Definition: control_module_fem_dem_utilities.hpp:57
unsigned int mTargetStressTableId
Definition: control_module_fem_dem_utilities.hpp:374
virtual std::string Info() const
Turn back information as a stemplate<class T, std::size_t dim> tring.
Definition: control_module_fem_dem_utilities.hpp:343
void SetValue(const Variable< TDataType > &rThisVariable, TDataType const &rValue)
Sets the value for a given variable.
Definition: data_value_container.h:320
KratosComponents class encapsulates a lookup table for a family of classes in a generic way.
Definition: kratos_components.h:49
ElementsContainerType & Elements()
Definition: mesh.h:568
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ConditionIterator ConditionsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1361
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
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
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
#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
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
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