From 7923c84448cf3463fa9206d3fea85b4513aeea38 Mon Sep 17 00:00:00 2001 From: Alejandro Date: Sun, 17 Sep 2023 12:52:27 +0400 Subject: [PATCH 1/4] some maintenance in Maxwell cl --- .../viscous/viscous_generalized_maxwell.cpp | 39 +++---------------- .../viscous/viscous_generalized_maxwell.h | 27 ------------- 2 files changed, 6 insertions(+), 60 deletions(-) diff --git a/applications/ConstitutiveLawsApplication/custom_constitutive/small_strains/viscous/viscous_generalized_maxwell.cpp b/applications/ConstitutiveLawsApplication/custom_constitutive/small_strains/viscous/viscous_generalized_maxwell.cpp index 245fb4cf03ec..67dac7302eaa 100644 --- a/applications/ConstitutiveLawsApplication/custom_constitutive/small_strains/viscous/viscous_generalized_maxwell.cpp +++ b/applications/ConstitutiveLawsApplication/custom_constitutive/small_strains/viscous/viscous_generalized_maxwell.cpp @@ -101,19 +101,6 @@ void ViscousGeneralizedMaxwell::CalculateMaterialResponseC /***********************************************************************************/ /***********************************************************************************/ -template -void ViscousGeneralizedMaxwell::FinalizeSolutionStep( - const Properties &rMaterialProperties, - const GeometryType &rElementGeometry, - const Vector& rShapeFunctionsValues, - const ProcessInfo &rCurrentProcessInfo) -{ - // Deprecated -} - -/***********************************************************************************/ -/***********************************************************************************/ - template void ViscousGeneralizedMaxwell::ComputeViscoElasticity(ConstitutiveLaw::Parameters& rValues) { @@ -124,9 +111,9 @@ void ViscousGeneralizedMaxwell::ComputeViscoElasticity(Con const Flags& r_flags = rValues.GetOptions(); // We compute the strain in case not provided + Vector& r_strain_vector = rValues.GetStrainVector(); if (r_flags.IsNot( ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN)) { - Vector& r_strain_vector = rValues.GetStrainVector(); - this->CalculateValue(rValues, STRAIN, r_strain_vector); + BaseType::CalculateValue(rValues, STRAIN, r_strain_vector); } // We compute the stress @@ -136,9 +123,8 @@ void ViscousGeneralizedMaxwell::ComputeViscoElasticity(Con // Elastic Matrix Matrix constitutive_matrix; - this->CalculateValue(rValues, CONSTITUTIVE_MATRIX, constitutive_matrix); + BaseType::CalculateValue(rValues, CONSTITUTIVE_MATRIX, constitutive_matrix); - const Vector& r_strain_vector = rValues.GetStrainVector(); const Vector& r_previous_strain = this->GetPreviousStrainVector(); const Vector& r_previous_stress = this->GetPreviousStressVector(); const Vector& r_strain_increment = r_strain_vector - r_previous_strain; @@ -155,7 +141,7 @@ void ViscousGeneralizedMaxwell::ComputeViscoElasticity(Con // Elastic Matrix if( r_flags.Is( ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR ) ) { Matrix& r_constitutive_matrix = rValues.GetConstitutiveMatrix(); - this->CalculateValue(rValues, CONSTITUTIVE_MATRIX, r_constitutive_matrix); + BaseType::CalculateValue(rValues, CONSTITUTIVE_MATRIX, r_constitutive_matrix); } } } @@ -205,7 +191,7 @@ void ViscousGeneralizedMaxwell::FinalizeMaterialResponseCa // We compute the strain in case not provided if (r_flags.IsNot( ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN)) { Vector& r_strain_vector = rValues.GetStrainVector(); - this->CalculateValue(rValues, STRAIN, r_strain_vector); + BaseType::CalculateValue(rValues, STRAIN, r_strain_vector); } @@ -214,7 +200,7 @@ void ViscousGeneralizedMaxwell::FinalizeMaterialResponseCa // Elastic Matrix Matrix constitutive_matrix; - this->CalculateValue(rValues, CONSTITUTIVE_MATRIX, constitutive_matrix); + BaseType::CalculateValue(rValues, CONSTITUTIVE_MATRIX, constitutive_matrix); const Vector& r_strain_vector = rValues.GetStrainVector(); const Vector& r_previous_strain = this->GetPreviousStrainVector(); @@ -233,19 +219,6 @@ void ViscousGeneralizedMaxwell::FinalizeMaterialResponseCa /***********************************************************************************/ /***********************************************************************************/ -template -Vector& ViscousGeneralizedMaxwell::CalculateValue( - ConstitutiveLaw::Parameters& rParameterValues, - const Variable& rThisVariable, - Vector& rValue - ) -{ - return BaseType::CalculateValue(rParameterValues, rThisVariable, rValue); -} - -/***********************************************************************************/ -/***********************************************************************************/ - template Matrix& ViscousGeneralizedMaxwell::CalculateValue( ConstitutiveLaw::Parameters& rParameterValues, diff --git a/applications/ConstitutiveLawsApplication/custom_constitutive/small_strains/viscous/viscous_generalized_maxwell.h b/applications/ConstitutiveLawsApplication/custom_constitutive/small_strains/viscous/viscous_generalized_maxwell.h index bafb22149f63..52514cc2fd4d 100644 --- a/applications/ConstitutiveLawsApplication/custom_constitutive/small_strains/viscous/viscous_generalized_maxwell.h +++ b/applications/ConstitutiveLawsApplication/custom_constitutive/small_strains/viscous/viscous_generalized_maxwell.h @@ -150,20 +150,6 @@ class KRATOS_API(CONSTITUTIVE_LAWS_APPLICATION) ViscousGeneralizedMaxwell */ void CalculateMaterialResponseCauchy(ConstitutiveLaw::Parameters& rValues) override; - /** - * to be called at the end of each solution step - * (e.g. from Element::FinalizeSolutionStep) - * @param rMaterialProperties the Properties instance of the current element - * @param rElementGeometry the geometry of the current element - * @param rShapeFunctionsValues the shape functions values in the current integration point - * @param the current ProcessInfo instance - */ - void FinalizeSolutionStep( - const Properties &rMaterialProperties, - const GeometryType &rElementGeometry, - const Vector &rShapeFunctionsValues, - const ProcessInfo &rCurrentProcessInfo) override; - /** * Finalize the material response in terms of 1st Piola-Kirchhoff stresses * @see Parameters @@ -188,19 +174,6 @@ class KRATOS_API(CONSTITUTIVE_LAWS_APPLICATION) ViscousGeneralizedMaxwell */ void FinalizeMaterialResponseCauchy(ConstitutiveLaw::Parameters& rValues) override; - /** - * @brief Calculates the value of a specified variable (Vector) - * @param rParameterValues the needed parameters for the CL calculation - * @param rThisVariable the variable to be returned - * @param rValue a reference to the returned value - * @param rValue output: the value of the specified variable - */ - Vector& CalculateValue( - ConstitutiveLaw::Parameters& rParameterValues, - const Variable& rThisVariable, - Vector& rValue - ) override; - /** * @brief Calculates the value of a specified variable (Matrix) * @param rParameterValues the needed parameters for the CL calculation From d7422d160bfc7062a4f5cc1c08d599bc12167de9 Mon Sep 17 00:00:00 2001 From: Alejandro Date: Sun, 17 Sep 2023 12:59:26 +0400 Subject: [PATCH 2/4] solving seg fault --- .../small_strains/viscous/viscous_generalized_maxwell.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/applications/ConstitutiveLawsApplication/custom_constitutive/small_strains/viscous/viscous_generalized_maxwell.cpp b/applications/ConstitutiveLawsApplication/custom_constitutive/small_strains/viscous/viscous_generalized_maxwell.cpp index 67dac7302eaa..8bbef072fd04 100644 --- a/applications/ConstitutiveLawsApplication/custom_constitutive/small_strains/viscous/viscous_generalized_maxwell.cpp +++ b/applications/ConstitutiveLawsApplication/custom_constitutive/small_strains/viscous/viscous_generalized_maxwell.cpp @@ -135,7 +135,8 @@ void ViscousGeneralizedMaxwell::ComputeViscoElasticity(Con noalias(integrated_stress_vector) = r_previous_stress * std::exp(-time_step / delay_time) + prod(constitutive_matrix, r_auxiliary_strain); if (r_flags.Is(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR)) { - rValues.SetConstitutiveMatrix(constitutive_matrix); + Matrix& r_constitutive_matrix = rValues.GetConstitutiveMatrix(); + noalias(r_constitutive_matrix) = constitutive_matrix; } } else { // Elastic Matrix From 0593656dcfae60e06482cb8592b48c0dca55ca04 Mon Sep 17 00:00:00 2001 From: Alejandro Date: Sun, 17 Sep 2023 20:01:58 +0400 Subject: [PATCH 3/4] more cleaning --- .../viscous/viscous_generalized_kelvin.cpp | 13 ++++++------- .../viscous/viscous_generalized_maxwell.cpp | 10 ++++------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/applications/ConstitutiveLawsApplication/custom_constitutive/small_strains/viscous/viscous_generalized_kelvin.cpp b/applications/ConstitutiveLawsApplication/custom_constitutive/small_strains/viscous/viscous_generalized_kelvin.cpp index 6a0af8f3f05b..fa626e1528f0 100644 --- a/applications/ConstitutiveLawsApplication/custom_constitutive/small_strains/viscous/viscous_generalized_kelvin.cpp +++ b/applications/ConstitutiveLawsApplication/custom_constitutive/small_strains/viscous/viscous_generalized_kelvin.cpp @@ -121,8 +121,8 @@ void ViscousGeneralizedKelvin::ComputeViscoElasticity(Cons const Flags& r_flags = rValues.GetOptions(); // We compute the strain in case not provided + Vector& r_strain_vector = rValues.GetStrainVector(); if (r_flags.IsNot( ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN)) { - Vector& r_strain_vector = rValues.GetStrainVector(); this->CalculateValue(rValues, STRAIN, r_strain_vector); } @@ -146,7 +146,6 @@ void ViscousGeneralizedKelvin::ComputeViscoElasticity(Cons Vector elastic_strain(VoigtSize); // Apply increments - const Vector& r_strain_vector = rValues.GetStrainVector(); for (IndexType i = 0; i < number_sub_increments; ++i) { noalias(aux) = (std::exp(-dt / delay_time) * prod(inverse_constitutive_matrix, aux_stress_vector)) / delay_time; noalias(inelastic_strain) = std::exp(-dt / delay_time) * inelastic_strain + aux; @@ -158,7 +157,8 @@ void ViscousGeneralizedKelvin::ComputeViscoElasticity(Cons noalias(integrated_stress_vector) = aux_stress_vector; if (r_flags.Is(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR)) { - rValues.SetConstitutiveMatrix(constitutive_matrix); + Matrix& r_constitutive_matrix = rValues.GetConstitutiveMatrix(); + noalias(r_constitutive_matrix) = constitutive_matrix; } } else { // Elastic Matrix @@ -210,8 +210,8 @@ void ViscousGeneralizedKelvin::FinalizeMaterialResponseCau const Flags& r_flags = rValues.GetOptions(); // We compute the strain in case not provided + Vector& r_strain_vector = rValues.GetStrainVector(); if (r_flags.IsNot( ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN)) { - Vector& r_strain_vector = rValues.GetStrainVector(); this->CalculateValue(rValues, STRAIN, r_strain_vector); } @@ -233,7 +233,6 @@ void ViscousGeneralizedKelvin::FinalizeMaterialResponseCau Vector elastic_strain(VoigtSize); // Apply increments - const Vector& r_strain_vector = rValues.GetStrainVector(); for (IndexType i = 0; i < number_sub_increments; ++i) { noalias(aux) = (std::exp(-dt / delay_time) * prod(inverse_constitutive_matrix, aux_stress_vector)) / delay_time; noalias(inelastic_strain) = std::exp(-dt / delay_time) * inelastic_strain + aux; @@ -241,8 +240,8 @@ void ViscousGeneralizedKelvin::FinalizeMaterialResponseCau noalias(aux_stress_vector) = prod(constitutive_matrix, elastic_strain); } - mPrevInelasticStrainVector = inelastic_strain; - mPrevStressVector = aux_stress_vector; + noalias(mPrevInelasticStrainVector) = inelastic_strain; + noalias(mPrevStressVector) = aux_stress_vector; } /***********************************************************************************/ diff --git a/applications/ConstitutiveLawsApplication/custom_constitutive/small_strains/viscous/viscous_generalized_maxwell.cpp b/applications/ConstitutiveLawsApplication/custom_constitutive/small_strains/viscous/viscous_generalized_maxwell.cpp index 8bbef072fd04..6a0bd44faf02 100644 --- a/applications/ConstitutiveLawsApplication/custom_constitutive/small_strains/viscous/viscous_generalized_maxwell.cpp +++ b/applications/ConstitutiveLawsApplication/custom_constitutive/small_strains/viscous/viscous_generalized_maxwell.cpp @@ -106,8 +106,7 @@ void ViscousGeneralizedMaxwell::ComputeViscoElasticity(Con { const Properties& material_props = rValues.GetMaterialProperties(); Vector& integrated_stress_vector = rValues.GetStressVector(); // To be updated - const ProcessInfo& process_info = rValues.GetProcessInfo(); - const double time_step = process_info[DELTA_TIME]; + const double time_step = rValues.GetProcessInfo()[DELTA_TIME]; const Flags& r_flags = rValues.GetOptions(); // We compute the strain in case not provided @@ -190,8 +189,8 @@ void ViscousGeneralizedMaxwell::FinalizeMaterialResponseCa const Flags& r_flags = rValues.GetOptions(); // We compute the strain in case not provided + Vector& r_strain_vector = rValues.GetStrainVector(); if (r_flags.IsNot( ConstitutiveLaw::USE_ELEMENT_PROVIDED_STRAIN)) { - Vector& r_strain_vector = rValues.GetStrainVector(); BaseType::CalculateValue(rValues, STRAIN, r_strain_vector); } @@ -203,7 +202,6 @@ void ViscousGeneralizedMaxwell::FinalizeMaterialResponseCa Matrix constitutive_matrix; BaseType::CalculateValue(rValues, CONSTITUTIVE_MATRIX, constitutive_matrix); - const Vector& r_strain_vector = rValues.GetStrainVector(); const Vector& r_previous_strain = this->GetPreviousStrainVector(); const Vector& r_previous_stress = this->GetPreviousStressVector(); const Vector& r_strain_increment = r_strain_vector - r_previous_strain; @@ -213,8 +211,8 @@ void ViscousGeneralizedMaxwell::FinalizeMaterialResponseCa noalias(integrated_stress_vector) = r_previous_stress * std::exp(-time_step / delay_time) + prod(constitutive_matrix, r_auxiliary_strain); - mPrevStressVector = integrated_stress_vector; - mPrevStrainVector = r_strain_vector; + noaias(mPrevStressVector) = integrated_stress_vector; + noaias(mPrevStrainVector) = r_strain_vector; } /***********************************************************************************/ From 85c2c8845c0bca6a6fffafde22a5c56848e93c27 Mon Sep 17 00:00:00 2001 From: Alejandro Date: Sun, 17 Sep 2023 20:04:08 +0400 Subject: [PATCH 4/4] typo --- .../small_strains/viscous/viscous_generalized_maxwell.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/ConstitutiveLawsApplication/custom_constitutive/small_strains/viscous/viscous_generalized_maxwell.cpp b/applications/ConstitutiveLawsApplication/custom_constitutive/small_strains/viscous/viscous_generalized_maxwell.cpp index 6a0bd44faf02..168c6793da60 100644 --- a/applications/ConstitutiveLawsApplication/custom_constitutive/small_strains/viscous/viscous_generalized_maxwell.cpp +++ b/applications/ConstitutiveLawsApplication/custom_constitutive/small_strains/viscous/viscous_generalized_maxwell.cpp @@ -211,8 +211,8 @@ void ViscousGeneralizedMaxwell::FinalizeMaterialResponseCa noalias(integrated_stress_vector) = r_previous_stress * std::exp(-time_step / delay_time) + prod(constitutive_matrix, r_auxiliary_strain); - noaias(mPrevStressVector) = integrated_stress_vector; - noaias(mPrevStrainVector) = r_strain_vector; + noalias(mPrevStressVector) = integrated_stress_vector; + noalias(mPrevStrainVector) = r_strain_vector; } /***********************************************************************************/