14 #if !defined(KRATOS_CONTROL_MODULE_2D_PROCESS )
15 #define KRATOS_CONTROL_MODULE_2D_PROCESS
53 "model_part_name":"MODEL_PART_NAME",
54 "imposed_direction" : 0,
55 "alternate_axis_loading": false,
56 "control_module_time_step": 1.0e-5,
57 "target_stress_table_id" : 0,
58 "initial_velocity" : 0.0,
59 "limit_velocity" : 0.1,
60 "velocity_factor" : 1.0,
61 "compression_length" : 1.0,
62 "young_modulus" : 1.0e9,
63 "stress_increment_tolerance": 100.0,
64 "update_stiffness": true,
65 "stiffness_alpha": 1.0,
67 "stress_averaging_time": 1e-7
98 #pragma omp parallel for
99 for(
int i = 0;
i<NNodes;
i++) {
100 ModelPart::NodesContainerType::iterator it = it_begin +
i;
101 it->SetValue(TARGET_STRESS,zero_vector);
102 it->SetValue(REACTION_STRESS,zero_vector);
103 it->SetValue(LOADING_VELOCITY,zero_vector);
132 #pragma omp parallel for
133 for(
int i = 0;
i<NNodes;
i++) {
134 ModelPart::NodesContainerType::iterator it = it_begin +
i;
135 it->FastGetSolutionStepValue(DISPLACEMENT_X) = 0.0;
136 it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_X) = 0.0;
137 it->FastGetSolutionStepValue(VELOCITY_X) =
mVelocity;
138 it->FastGetSolutionStepValue(DISPLACEMENT_Z) = 0.0;
139 it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_Z) = 0.0;
140 it->FastGetSolutionStepValue(VELOCITY_Z) = 0.0;
144 #pragma omp parallel for
145 for(
int i = 0;
i<NNodes;
i++) {
146 ModelPart::NodesContainerType::iterator it = it_begin +
i;
147 it->FastGetSolutionStepValue(DISPLACEMENT_Y) = 0.0;
148 it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_Y) = 0.0;
149 it->FastGetSolutionStepValue(VELOCITY_Y) =
mVelocity;
150 it->FastGetSolutionStepValue(DISPLACEMENT_Z) = 0.0;
151 it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_Z) = 0.0;
152 it->FastGetSolutionStepValue(VELOCITY_Z) = 0.0;
159 #pragma omp parallel for
160 for(
int i = 0;
i<NNodes;
i++) {
161 ModelPart::NodesContainerType::iterator it = it_begin +
i;
162 const double external_radius = std::sqrt(it->X()*it->X() + it->Y()*it->Y());
165 it->FastGetSolutionStepValue(DISPLACEMENT_X) = 0.0;
166 it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_X) = 0.0;
167 it->FastGetSolutionStepValue(VELOCITY_X) =
mVelocity * cos_theta;
168 it->FastGetSolutionStepValue(DISPLACEMENT_Y) = 0.0;
169 it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_Y) = 0.0;
170 it->FastGetSolutionStepValue(VELOCITY_Y) =
mVelocity * sin_theta;
171 it->FastGetSolutionStepValue(DISPLACEMENT_Z) = 0.0;
172 it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_Z) = 0.0;
173 it->FastGetSolutionStepValue(VELOCITY_Z) = 0.0;
191 if(cm_num_super_steps < 1) {cm_num_super_steps = 1;}
200 double ReactionStress = CalculateReactionStress();
201 ReactionStress = UpdateVectorOfHistoricalStressesAndComputeNewAverage(ReactionStress);
213 double K_estimated = EstimateStiffness(ReactionStress,
delta_time);
222 const double NextTargetStress = pTargetStressTable->GetValue(CurrentTime+
delta_time);
223 const double df_target = NextTargetStress - ReactionStress;
243 UpdateMotionAndSaveVariablesToPrint(
mVelocity, pTargetStressTable->GetValue(CurrentTime), ReactionStress);
246 UpdateMotionAndSaveVariablesToPrint(0.0, pTargetStressTable->GetValue(CurrentTime), ReactionStress);
261 double ReactionStress = CalculateReactionStress();
263 double K_estimated = EstimateStiffness(ReactionStress,
mCMTimeStep);
270 std::string
Info()
const override
272 return "ControlModule2DProcess";
278 rOStream <<
"ControlModule2DProcess";
330 double UpdateVectorOfHistoricalStressesAndComputeNewAverage(
const double& last_reaction) {
333 if (length_of_vector == 0) {
335 if(number_of_steps_for_stress_averaging < 1) number_of_steps_for_stress_averaging = 1;
337 KRATOS_INFO(
"DEM") <<
" 'number_of_steps_for_stress_averaging' is "<< number_of_steps_for_stress_averaging << std::endl;
342 if(length_of_vector > 1) {
343 for(
int i=1;
i<length_of_vector;
i++) {
349 double average = 0.0;
350 for(
int i=0;
i<length_of_vector;
i++) {
353 average /= (
double) length_of_vector;
359 void IsTimeToApplyCM(){
423 double CalculateReactionStress() {
428 double face_area = 0.0;
432 #pragma omp parallel for reduction(+:face_area)
433 for (
int i = 0;
i < (
int)rElements.size();
i++) {
434 ModelPart::ElementsContainerType::ptr_iterator ptr_itElem = rElements.
ptr_begin() +
i;
435 Element* p_element = ptr_itElem->get();
436 SphericContinuumParticle* pDemElem =
dynamic_cast<SphericContinuumParticle*
>(p_element);
437 const double radius = pDemElem->GetRadius();
443 #pragma omp parallel for reduction(+:face_area)
444 for(
int i = 0;
i < NCons;
i++) {
445 ModelPart::ConditionsContainerType::iterator itCond = con_begin +
i;
446 face_area += itCond->GetGeometry().Area();
451 double FaceReaction = 0.0;
453 #pragma omp parallel for reduction(+:FaceReaction)
454 for(
int i = 0;
i<NNodes;
i++) {
455 ModelPart::NodesContainerType::iterator it = it_begin +
i;
456 FaceReaction -= it->FastGetSolutionStepValue(CONTACT_FORCES_X);
459 #pragma omp parallel for reduction(+:FaceReaction)
460 for(
int i = 0;
i<NNodes;
i++) {
461 ModelPart::NodesContainerType::iterator it = it_begin +
i;
462 FaceReaction -= it->FastGetSolutionStepValue(CONTACT_FORCES_Y);
467 #pragma omp parallel for reduction(+:FaceReaction)
468 for (
int i = 0;
i < (
int)rElements.size();
i++) {
469 ModelPart::ElementsContainerType::ptr_iterator ptr_itElem = rElements.
ptr_begin() +
i;
470 Element* p_element = ptr_itElem->get();
471 SphericContinuumParticle* pDemElem =
dynamic_cast<SphericContinuumParticle*
>(p_element);
472 BoundedMatrix<double, 3, 3> stress_tensor =
ZeroMatrix(3,3);
473 noalias(stress_tensor) = (*(pDemElem->mSymmStressTensor));
474 const double radius = pDemElem->GetRadius();
478 #pragma omp parallel for reduction(+:FaceReaction)
479 for(
int i = 0;
i<NNodes;
i++) {
480 ModelPart::NodesContainerType::iterator it = it_begin +
i;
482 array_1d<double,2>
n;
485 double inv_norm = 1.0/
norm_2(
n);
489 double n_dot_r =
n[0] * it->FastGetSolutionStepValue(CONTACT_FORCES_X) +
n[1] * it->FastGetSolutionStepValue(CONTACT_FORCES_Y);
490 FaceReaction -= n_dot_r;
508 double ReactionStress;
509 if (std::abs(face_area) > 1.0e-12) {
510 ReactionStress = FaceReaction/face_area;
512 ReactionStress = 0.0;
515 return ReactionStress;
518 double EstimateStiffness(
const double& rReactionStress,
const double& rDeltaTime) {
526 void UpdateMotionAndSaveVariablesToPrint(
const double rVelocity,
const double& rTargetStress,
const double& rReactionStress) {
533 #pragma omp parallel for
534 for(
int i = 0;
i<NNodes;
i++) {
535 ModelPart::NodesContainerType::iterator it = it_begin +
i;
536 it->FastGetSolutionStepValue(VELOCITY_X) = rVelocity;
537 it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_X) = it->FastGetSolutionStepValue(VELOCITY_X) *
mrModelPart.
GetProcessInfo()[DELTA_TIME];
538 it->FastGetSolutionStepValue(DISPLACEMENT_X) += it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_X);
539 it->X() = it->X0() + it->FastGetSolutionStepValue(DISPLACEMENT_X);
546 it->
GetValue(TARGET_STRESS_X) = rTargetStress;
547 it->GetValue(REACTION_STRESS_X) = rReactionStress;
548 it->GetValue(LOADING_VELOCITY_X) = rVelocity;
551 #pragma omp parallel for
552 for(
int i = 0;
i<NNodes;
i++) {
553 ModelPart::NodesContainerType::iterator it = it_begin +
i;
554 it->FastGetSolutionStepValue(VELOCITY_Y) = rVelocity;
555 it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_Y) = it->FastGetSolutionStepValue(VELOCITY_Y) *
mrModelPart.
GetProcessInfo()[DELTA_TIME];
556 it->FastGetSolutionStepValue(DISPLACEMENT_Y) += it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_Y);
557 it->Y() = it->Y0() + it->FastGetSolutionStepValue(DISPLACEMENT_Y);
559 it->
GetValue(TARGET_STRESS_Y) = rTargetStress;
560 it->GetValue(REACTION_STRESS_Y) = rReactionStress;
561 it->GetValue(LOADING_VELOCITY_Y) = rVelocity;
565 #pragma omp parallel for
566 for(
int i = 0;
i<NNodes;
i++) {
567 ModelPart::NodesContainerType::iterator it = it_begin +
i;
569 it->GetValue(TARGET_STRESS_Z) = rTargetStress;
570 it->GetValue(REACTION_STRESS_Z) = rReactionStress;
571 it->GetValue(LOADING_VELOCITY_Z) = rVelocity;
575 #pragma omp parallel for
576 for(
int i = 0;
i<NNodes;
i++) {
577 ModelPart::NodesContainerType::iterator it = it_begin +
i;
578 const double external_radius = std::sqrt(it->X()*it->X() + it->Y()*it->Y());
581 it->FastGetSolutionStepValue(VELOCITY_X) = rVelocity * cos_theta;
582 it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_X) = it->FastGetSolutionStepValue(VELOCITY_X) *
mrModelPart.
GetProcessInfo()[DELTA_TIME];
583 it->FastGetSolutionStepValue(DISPLACEMENT_X) += it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_X);
584 it->X() = it->X0() + it->FastGetSolutionStepValue(DISPLACEMENT_X);
585 it->FastGetSolutionStepValue(VELOCITY_Y) = rVelocity * sin_theta;
586 it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_Y) = it->FastGetSolutionStepValue(VELOCITY_Y) *
mrModelPart.
GetProcessInfo()[DELTA_TIME];
587 it->FastGetSolutionStepValue(DISPLACEMENT_Y) += it->FastGetSolutionStepValue(DELTA_DISPLACEMENT_Y);
588 it->Y() = it->Y0() + it->FastGetSolutionStepValue(DISPLACEMENT_Y);
590 it->
GetValue(TARGET_STRESS_X) = rTargetStress * cos_theta;
591 it->GetValue(TARGET_STRESS_Y) = rTargetStress * sin_theta;
592 it->GetValue(REACTION_STRESS_X) = rReactionStress * cos_theta;
593 it->GetValue(REACTION_STRESS_Y) = rReactionStress * sin_theta;
594 it->GetValue(LOADING_VELOCITY_X) = rVelocity * cos_theta;
595 it->GetValue(LOADING_VELOCITY_Y) = rVelocity * sin_theta;
612 rOStream << std::endl;
MeshType & LocalMesh()
Returns the reference to the mesh storing all local entities.
Definition: communicator.cpp:245
Definition: control_module_2d_process.hpp:31
Table< double, double > TableType
Defining a table with double argument and result type as table type.
Definition: control_module_2d_process.hpp:38
unsigned int mXEndStep
Definition: control_module_2d_process.hpp:308
void ExecuteFinalizeSolutionStep() override
This function will be executed at every time step AFTER performing the solve phase.
Definition: control_module_2d_process.hpp:257
double mVelocity
Definition: control_module_2d_process.hpp:295
void Execute() override
Execute method is used to execute the ControlModule2DProcess algorithms.
Definition: control_module_2d_process.hpp:117
double mStiffness
Definition: control_module_2d_process.hpp:302
ControlModule2DProcess(ModelPart &rModelPart, Parameters rParameters)
Constructor.
Definition: control_module_2d_process.hpp:43
double mCompressionLength
Definition: control_module_2d_process.hpp:298
bool mApplyCM
Definition: control_module_2d_process.hpp:313
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: control_module_2d_process.hpp:282
double mLimitVelocity
Definition: control_module_2d_process.hpp:296
unsigned int mXStartStep
Definition: control_module_2d_process.hpp:307
ModelPart & mrModelPart
Member Variables.
Definition: control_module_2d_process.hpp:292
void ExecuteInitializeSolutionStep() override
this function will be executed at every time step BEFORE performing the solve phase
Definition: control_module_2d_process.hpp:181
unsigned int mStep
Definition: control_module_2d_process.hpp:316
double mStiffnessAlpha
Definition: control_module_2d_process.hpp:318
unsigned int mYStartStep
Definition: control_module_2d_process.hpp:309
double mStressAveragingTime
Definition: control_module_2d_process.hpp:305
bool mUpdateStiffness
Definition: control_module_2d_process.hpp:303
std::vector< double > mVectorOfLastStresses
Definition: control_module_2d_process.hpp:304
bool mIsStartStep
Definition: control_module_2d_process.hpp:314
double mCMTimeStep
Definition: control_module_2d_process.hpp:317
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: control_module_2d_process.hpp:276
double mVelocityFactor
Definition: control_module_2d_process.hpp:297
double mStartTime
Definition: control_module_2d_process.hpp:299
double mStressIncrementTolerance
Definition: control_module_2d_process.hpp:301
unsigned int mZEndStep
Definition: control_module_2d_process.hpp:312
unsigned int mZStartStep
Definition: control_module_2d_process.hpp:311
unsigned int mTargetStressTableId
Definition: control_module_2d_process.hpp:294
KRATOS_CLASS_POINTER_DEFINITION(ControlModule2DProcess)
bool mAlternateAxisLoading
Definition: control_module_2d_process.hpp:306
unsigned int mYEndStep
Definition: control_module_2d_process.hpp:310
unsigned int mImposedDirection
Definition: control_module_2d_process.hpp:293
bool mIsEndStep
Definition: control_module_2d_process.hpp:315
double mReactionStressOld
Definition: control_module_2d_process.hpp:300
~ControlModule2DProcess() override
Destructor.
Definition: control_module_2d_process.hpp:112
std::string Info() const override
Turn back information as a string.
Definition: control_module_2d_process.hpp:270
void ExecuteInitialize() override
Definition: control_module_2d_process.hpp:123
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
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
ptr_iterator ptr_begin()
Returns an iterator pointing to the beginning of the underlying data container.
Definition: pointer_vector_set.h:386
The base class for all processes in Kratos.
Definition: process.h:49
#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
TExpressionType::data_type norm_2(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:625
KratosZeroMatrix< double > ZeroMatrix
Definition: amatrix_interface.h:559
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
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
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
delta_time
Definition: generate_frictional_mortar_condition.py:130
float radius
Definition: mesh_to_mdpa_converter.py:18
float external_radius
Definition: mesh_to_mdpa_converter.py:24
int n
manufactured solution and derivatives (u=0 at z=0 dudz=0 at z=domain_height)
Definition: ode_solve.py:402
integer i
Definition: TensorModule.f:17