From d9785396e4da0c381b44355044515d47fdfb6061 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Sun, 1 Mar 2020 17:24:35 +0100 Subject: [PATCH 01/47] cleanup - behaviour not changed (I) --- ..._lagrangian_V_P_implicit_fluid_element.cpp | 79 ------------------- 1 file changed, 79 deletions(-) diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp index 3e358c56646c..2aed0f868b9e 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp @@ -1532,8 +1532,6 @@ void TwoStepUpdatedLagrangianVPImplicitFluidElement<2>::CalcElasticPlasticCauchy { double CurrSecondLame = this->mMaterialDeviatoricCoefficient; - // double CurrBulkModulus = this->mMaterialVolumetricCoefficient; - // double CurrFirstLame = CurrBulkModulus - 2.0*CurrSecondLame/3.0; double DefX = rElementalVariables.SpatialDefRate[0]; double DefY = rElementalVariables.SpatialDefRate[1]; @@ -1544,26 +1542,10 @@ void TwoStepUpdatedLagrangianVPImplicitFluidElement<2>::CalcElasticPlasticCauchy double sigmaDev_yy = 2 * CurrSecondLame * (DefY - DefVol / 3.0); double sigmaDev_xy = 2 * CurrSecondLame * DefXY; - // double sigmaTot_xx= CurrFirstLame*DefVol + 2.0*CurrSecondLame*DefX; - // double sigmaTot_yy= CurrFirstLame*DefVol + 2.0*CurrSecondLame*DefY; - // double sigmaTot_xy= 2.0*CurrSecondLame*DefXY; - - // sigmaDev_xx=rElementalVariables.CurrentDeviatoricCauchyStress[0]; - // sigmaDev_yy=rElementalVariables.CurrentDeviatoricCauchyStress[1]; - // sigmaDev_xy=rElementalVariables.CurrentDeviatoricCauchyStress[2]; - - // sigmaTot_xx+=rElementalVariables.CurrentTotalCauchyStress[0]; - // sigmaTot_yy+=rElementalVariables.CurrentTotalCauchyStress[1]; - // sigmaTot_xy+=rElementalVariables.CurrentTotalCauchyStress[2]; - double sigmaTot_xx = sigmaDev_xx + rElementalVariables.MeanPressure; double sigmaTot_yy = sigmaDev_yy + rElementalVariables.MeanPressure; double sigmaTot_xy = sigmaDev_xy; - // sigmaDev_xx= sigmaTot_xx - rElementalVariables.MeanPressure; - // sigmaDev_yy= sigmaTot_yy - rElementalVariables.MeanPressure; - // sigmaDev_xy= sigmaTot_xy; - rElementalVariables.UpdatedDeviatoricCauchyStress[0] = sigmaDev_xx; rElementalVariables.UpdatedDeviatoricCauchyStress[1] = sigmaDev_yy; rElementalVariables.UpdatedDeviatoricCauchyStress[2] = sigmaDev_xy; @@ -1572,37 +1554,6 @@ void TwoStepUpdatedLagrangianVPImplicitFluidElement<2>::CalcElasticPlasticCauchy rElementalVariables.UpdatedTotalCauchyStress[1] = sigmaTot_yy; rElementalVariables.UpdatedTotalCauchyStress[2] = sigmaTot_xy; - // double TauNorm=sqrt((0.5*sigmaDev_xx*sigmaDev_xx + 0.5*sigmaDev_yy*sigmaDev_yy + sigmaDev_xy*sigmaDev_xy)); - // double FluidYieldShear=0; - // this->EvaluatePropertyFromANotRigidNode(FluidYieldShear,YIELD_SHEAR); - - // const SizeType NumNodes = this->GetGeometry().PointsNumber(); - // for (SizeType i = 0; i < NumNodes; ++i) - // { - // this->GetGeometry()[i].FastGetSolutionStepValue(ADAPTIVE_EXPONENT)=VolumetricCoeff; - // this->GetGeometry()[i].FastGetSolutionStepValue(ALPHA_PARAMETER)=DeviatoricCoeff; - // this->GetGeometry()[i].FastGetSolutionStepValue(FLOW_INDEX)=rElementalVariables.EquivalentStrainRate; - // } - - // if(TauNorm>FluidYieldShear){ - // this->SetValue(YIELDED,1.0); - - // for (SizeType i = 0; i < NumNodes; ++i){ - - // // rGeom[i].FastGetSolutionStepValue(FLOW_INDEX) = 1; - // rGeom[i].FastGetSolutionStepValue(FREESURFACE) = 1; - // } - // }else{ - - // this->SetValue(YIELDED,0.0); - // // std::vector rOutput; - // // this->GetElementalValueForOutput(YIELDED,rOutput); - - // for (SizeType i = 0; i < NumNodes; ++i){ - // // rGeom[i].FastGetSolutionStepValue(FLOW_INDEX) = 0; - // rGeom[i].FastGetSolutionStepValue(FREESURFACE) = 0; - // } - // } } template <> @@ -1610,8 +1561,6 @@ void TwoStepUpdatedLagrangianVPImplicitFluidElement<3>::CalcElasticPlasticCauchy { double CurrSecondLame = this->mMaterialDeviatoricCoefficient; - // double CurrBulkModulus = this->mMaterialVolumetricCoefficient; - // double CurrFirstLame = CurrBulkModulus - 2.0*CurrSecondLame/3.0; double DefX = rElementalVariables.SpatialDefRate[0]; double DefY = rElementalVariables.SpatialDefRate[1]; @@ -1629,20 +1578,6 @@ void TwoStepUpdatedLagrangianVPImplicitFluidElement<3>::CalcElasticPlasticCauchy double sigmaDev_xz = 2 * CurrSecondLame * DefXZ; double sigmaDev_yz = 2 * CurrSecondLame * DefYZ; - // double sigmaTot_xx= CurrFirstLame*DefVol + 2*CurrSecondLame*DefX; - // double sigmaTot_yy= CurrFirstLame*DefVol + 2*CurrSecondLame*DefY; - // double sigmaTot_zz= CurrFirstLame*DefVol + 2*CurrSecondLame*DefZ; - // double sigmaTot_xy= 2*CurrSecondLame*DefXY; - // double sigmaTot_xz= 2*CurrSecondLame*DefXZ; - // double sigmaTot_yz= 2*CurrSecondLame*DefYZ; - - // sigmaDev_xx+=rElementalVariables.CurrentDeviatoricCauchyStress[0]; - // sigmaDev_yy+=rElementalVariables.CurrentDeviatoricCauchyStress[1]; - // sigmaDev_zz+=rElementalVariables.CurrentDeviatoricCauchyStress[2]; - // sigmaDev_xy+=rElementalVariables.CurrentDeviatoricCauchyStress[3]; - // sigmaDev_xz+=rElementalVariables.CurrentDeviatoricCauchyStress[4]; - // sigmaDev_yz+=rElementalVariables.CurrentDeviatoricCauchyStress[5]; - double sigmaTot_xx = sigmaDev_xx + rElementalVariables.MeanPressure; double sigmaTot_yy = sigmaDev_yy + rElementalVariables.MeanPressure; double sigmaTot_zz = sigmaDev_zz + rElementalVariables.MeanPressure; @@ -1650,20 +1585,6 @@ void TwoStepUpdatedLagrangianVPImplicitFluidElement<3>::CalcElasticPlasticCauchy double sigmaTot_xz = sigmaDev_xz; double sigmaTot_yz = sigmaDev_yz; - // sigmaTot_xx+=rElementalVariables.CurrentTotalCauchyStress[0]; - // sigmaTot_yy+=rElementalVariables.CurrentTotalCauchyStress[1]; - // sigmaTot_zz+=rElementalVariables.CurrentTotalCauchyStress[2]; - // sigmaTot_xy+=rElementalVariables.CurrentTotalCauchyStress[3]; - // sigmaTot_xz+=rElementalVariables.CurrentTotalCauchyStress[4]; - // sigmaTot_yz+=rElementalVariables.CurrentTotalCauchyStress[5]; - - // sigmaDev_xx= sigmaTot_xx - rElementalVariables.MeanPressure; - // sigmaDev_yy= sigmaTot_yy - rElementalVariables.MeanPressure; - // sigmaDev_zz= sigmaTot_zz - rElementalVariables.MeanPressure; - // sigmaDev_xy= sigmaTot_xy; - // sigmaDev_xz= sigmaTot_xz; - // sigmaDev_yz= sigmaTot_yz; - rElementalVariables.UpdatedDeviatoricCauchyStress[0] = sigmaDev_xx; rElementalVariables.UpdatedDeviatoricCauchyStress[1] = sigmaDev_yy; rElementalVariables.UpdatedDeviatoricCauchyStress[2] = sigmaDev_zz; From c421ee1adfa349fa15705061253728def7245ad7 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Sun, 1 Mar 2020 17:26:21 +0100 Subject: [PATCH 02/47] cleanup - behaviour not changed (II) --- ..._lagrangian_V_P_implicit_fluid_element.cpp | 131 +++++++++--------- 1 file changed, 64 insertions(+), 67 deletions(-) diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp index 2aed0f868b9e..5d5c5277ddf4 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp @@ -1528,76 +1528,73 @@ void TwoStepUpdatedLagrangianVPImplicitFluidElement::InitializeElementalVa } template <> -void TwoStepUpdatedLagrangianVPImplicitFluidElement<2>::CalcElasticPlasticCauchySplitted(ElementalVariables &rElementalVariables, double TimeStep, unsigned int g) -{ - - double CurrSecondLame = this->mMaterialDeviatoricCoefficient; - - double DefX = rElementalVariables.SpatialDefRate[0]; - double DefY = rElementalVariables.SpatialDefRate[1]; - double DefXY = rElementalVariables.SpatialDefRate[2]; - - double DefVol = rElementalVariables.VolumetricDefRate; - double sigmaDev_xx = 2 * CurrSecondLame * (DefX - DefVol / 3.0); - double sigmaDev_yy = 2 * CurrSecondLame * (DefY - DefVol / 3.0); - double sigmaDev_xy = 2 * CurrSecondLame * DefXY; - - double sigmaTot_xx = sigmaDev_xx + rElementalVariables.MeanPressure; - double sigmaTot_yy = sigmaDev_yy + rElementalVariables.MeanPressure; - double sigmaTot_xy = sigmaDev_xy; - - rElementalVariables.UpdatedDeviatoricCauchyStress[0] = sigmaDev_xx; - rElementalVariables.UpdatedDeviatoricCauchyStress[1] = sigmaDev_yy; - rElementalVariables.UpdatedDeviatoricCauchyStress[2] = sigmaDev_xy; - - rElementalVariables.UpdatedTotalCauchyStress[0] = sigmaTot_xx; - rElementalVariables.UpdatedTotalCauchyStress[1] = sigmaTot_yy; - rElementalVariables.UpdatedTotalCauchyStress[2] = sigmaTot_xy; - +void TwoStepUpdatedLagrangianVPImplicitFluidElement<2>::CalcElasticPlasticCauchySplitted( + ElementalVariables &rElementalVariables, double TimeStep, unsigned int g) { + double CurrSecondLame = this->mMaterialDeviatoricCoefficient; + + double DefX = rElementalVariables.SpatialDefRate[0]; + double DefY = rElementalVariables.SpatialDefRate[1]; + double DefXY = rElementalVariables.SpatialDefRate[2]; + + double DefVol = rElementalVariables.VolumetricDefRate; + double sigmaDev_xx = 2 * CurrSecondLame * (DefX - DefVol / 3.0); + double sigmaDev_yy = 2 * CurrSecondLame * (DefY - DefVol / 3.0); + double sigmaDev_xy = 2 * CurrSecondLame * DefXY; + + double sigmaTot_xx = sigmaDev_xx + rElementalVariables.MeanPressure; + double sigmaTot_yy = sigmaDev_yy + rElementalVariables.MeanPressure; + double sigmaTot_xy = sigmaDev_xy; + + rElementalVariables.UpdatedDeviatoricCauchyStress[0] = sigmaDev_xx; + rElementalVariables.UpdatedDeviatoricCauchyStress[1] = sigmaDev_yy; + rElementalVariables.UpdatedDeviatoricCauchyStress[2] = sigmaDev_xy; + + rElementalVariables.UpdatedTotalCauchyStress[0] = sigmaTot_xx; + rElementalVariables.UpdatedTotalCauchyStress[1] = sigmaTot_yy; + rElementalVariables.UpdatedTotalCauchyStress[2] = sigmaTot_xy; } template <> -void TwoStepUpdatedLagrangianVPImplicitFluidElement<3>::CalcElasticPlasticCauchySplitted(ElementalVariables &rElementalVariables, double TimeStep, unsigned int g) -{ - - double CurrSecondLame = this->mMaterialDeviatoricCoefficient; - - double DefX = rElementalVariables.SpatialDefRate[0]; - double DefY = rElementalVariables.SpatialDefRate[1]; - double DefZ = rElementalVariables.SpatialDefRate[2]; - double DefXY = rElementalVariables.SpatialDefRate[3]; - double DefXZ = rElementalVariables.SpatialDefRate[4]; - double DefYZ = rElementalVariables.SpatialDefRate[5]; - - double DefVol = rElementalVariables.VolumetricDefRate; - - double sigmaDev_xx = 2 * CurrSecondLame * (DefX - DefVol / 3.0); - double sigmaDev_yy = 2 * CurrSecondLame * (DefY - DefVol / 3.0); - double sigmaDev_zz = 2 * CurrSecondLame * (DefZ - DefVol / 3.0); - double sigmaDev_xy = 2 * CurrSecondLame * DefXY; - double sigmaDev_xz = 2 * CurrSecondLame * DefXZ; - double sigmaDev_yz = 2 * CurrSecondLame * DefYZ; - - double sigmaTot_xx = sigmaDev_xx + rElementalVariables.MeanPressure; - double sigmaTot_yy = sigmaDev_yy + rElementalVariables.MeanPressure; - double sigmaTot_zz = sigmaDev_zz + rElementalVariables.MeanPressure; - double sigmaTot_xy = sigmaDev_xy; - double sigmaTot_xz = sigmaDev_xz; - double sigmaTot_yz = sigmaDev_yz; - - rElementalVariables.UpdatedDeviatoricCauchyStress[0] = sigmaDev_xx; - rElementalVariables.UpdatedDeviatoricCauchyStress[1] = sigmaDev_yy; - rElementalVariables.UpdatedDeviatoricCauchyStress[2] = sigmaDev_zz; - rElementalVariables.UpdatedDeviatoricCauchyStress[3] = sigmaDev_xy; - rElementalVariables.UpdatedDeviatoricCauchyStress[4] = sigmaDev_xz; - rElementalVariables.UpdatedDeviatoricCauchyStress[5] = sigmaDev_yz; - - rElementalVariables.UpdatedTotalCauchyStress[0] = sigmaTot_xx; - rElementalVariables.UpdatedTotalCauchyStress[1] = sigmaTot_yy; - rElementalVariables.UpdatedTotalCauchyStress[2] = sigmaTot_zz; - rElementalVariables.UpdatedTotalCauchyStress[3] = sigmaTot_xy; - rElementalVariables.UpdatedTotalCauchyStress[4] = sigmaTot_xz; - rElementalVariables.UpdatedTotalCauchyStress[5] = sigmaTot_yz; +void TwoStepUpdatedLagrangianVPImplicitFluidElement<3>::CalcElasticPlasticCauchySplitted( + ElementalVariables &rElementalVariables, double TimeStep, unsigned int g) { + double CurrSecondLame = this->mMaterialDeviatoricCoefficient; + + double DefX = rElementalVariables.SpatialDefRate[0]; + double DefY = rElementalVariables.SpatialDefRate[1]; + double DefZ = rElementalVariables.SpatialDefRate[2]; + double DefXY = rElementalVariables.SpatialDefRate[3]; + double DefXZ = rElementalVariables.SpatialDefRate[4]; + double DefYZ = rElementalVariables.SpatialDefRate[5]; + + double DefVol = rElementalVariables.VolumetricDefRate; + + double sigmaDev_xx = 2 * CurrSecondLame * (DefX - DefVol / 3.0); + double sigmaDev_yy = 2 * CurrSecondLame * (DefY - DefVol / 3.0); + double sigmaDev_zz = 2 * CurrSecondLame * (DefZ - DefVol / 3.0); + double sigmaDev_xy = 2 * CurrSecondLame * DefXY; + double sigmaDev_xz = 2 * CurrSecondLame * DefXZ; + double sigmaDev_yz = 2 * CurrSecondLame * DefYZ; + + double sigmaTot_xx = sigmaDev_xx + rElementalVariables.MeanPressure; + double sigmaTot_yy = sigmaDev_yy + rElementalVariables.MeanPressure; + double sigmaTot_zz = sigmaDev_zz + rElementalVariables.MeanPressure; + double sigmaTot_xy = sigmaDev_xy; + double sigmaTot_xz = sigmaDev_xz; + double sigmaTot_yz = sigmaDev_yz; + + rElementalVariables.UpdatedDeviatoricCauchyStress[0] = sigmaDev_xx; + rElementalVariables.UpdatedDeviatoricCauchyStress[1] = sigmaDev_yy; + rElementalVariables.UpdatedDeviatoricCauchyStress[2] = sigmaDev_zz; + rElementalVariables.UpdatedDeviatoricCauchyStress[3] = sigmaDev_xy; + rElementalVariables.UpdatedDeviatoricCauchyStress[4] = sigmaDev_xz; + rElementalVariables.UpdatedDeviatoricCauchyStress[5] = sigmaDev_yz; + + rElementalVariables.UpdatedTotalCauchyStress[0] = sigmaTot_xx; + rElementalVariables.UpdatedTotalCauchyStress[1] = sigmaTot_yy; + rElementalVariables.UpdatedTotalCauchyStress[2] = sigmaTot_zz; + rElementalVariables.UpdatedTotalCauchyStress[3] = sigmaTot_xy; + rElementalVariables.UpdatedTotalCauchyStress[4] = sigmaTot_xz; + rElementalVariables.UpdatedTotalCauchyStress[5] = sigmaTot_yz; } template From e037aa0cf3052067366cb6949bc80b1fe2b4e2ca Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Sun, 1 Mar 2020 17:29:28 +0100 Subject: [PATCH 03/47] cleanup - behaviour not changed (III) --- ..._lagrangian_V_P_implicit_fluid_element.cpp | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp index 5d5c5277ddf4..8a9e2bf970d3 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp @@ -83,17 +83,6 @@ void TwoStepUpdatedLagrangianVPImplicitFluidElement::ComputeMaterialParame else if (staticFrictionCoefficient != 0) { DeviatoricCoeff = this->ComputePapanastasiouMuIrheologyViscosity(rElementalVariables); - // if(regularizationCoefficient!=0 && inertialNumberThreshold==0){ - // // DeviatoricCoeff=this->ComputeBercovierMuIrheologyViscosity(rElementalVariables); - // DeviatoricCoeff=this->ComputePapanastasiouMuIrheologyViscosity(rElementalVariables); - // } - // else if(regularizationCoefficient==0 && inertialNumberThreshold!=0){ - // DeviatoricCoeff=this->ComputeBarkerMuIrheologyViscosity(rElementalVariables); - // }else if(regularizationCoefficient!=0 && inertialNumberThreshold!=0){ - // DeviatoricCoeff=this->ComputeBarkerBercovierMuIrheologyViscosity(rElementalVariables); - // }else{ - // DeviatoricCoeff=this->ComputeJopMuIrheologyViscosity(rElementalVariables); - // } } else { @@ -101,23 +90,10 @@ void TwoStepUpdatedLagrangianVPImplicitFluidElement::ComputeMaterialParame DeviatoricCoeff = this->GetProperties()[DYNAMIC_VISCOSITY]; } - // this->ComputeMaterialParametersGranularGas(rElementalVariables,VolumetricCoeff,DeviatoricCoeff); - // std::cout<<"Density "<mMaterialDeviatoricCoefficient = DeviatoricCoeff; this->mMaterialVolumetricCoefficient = VolumetricCoeff; this->mMaterialDensity = Density; - // const SizeType NumNodes = this->GetGeometry().PointsNumber(); - // for (SizeType i = 0; i < NumNodes; ++i) - // { - // this->GetGeometry()[i].FastGetSolutionStepValue(ADAPTIVE_EXPONENT)=VolumetricCoeff; - // this->GetGeometry()[i].FastGetSolutionStepValue(ALPHA_PARAMETER)=DeviatoricCoeff; - // this->GetGeometry()[i].FastGetSolutionStepValue(FLOW_INDEX)=rElementalVariables.EquivalentStrainRate; - // } } template From 284e122b7e23d57d548e65f6230888842f1dc1cc Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Sun, 1 Mar 2020 17:32:28 +0100 Subject: [PATCH 04/47] cleanup - behaviour not changed (IV) --- ..._lagrangian_V_P_implicit_fluid_element.cpp | 64 ++++++++----------- 1 file changed, 27 insertions(+), 37 deletions(-) diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp index 8a9e2bf970d3..9f800c1f6463 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp @@ -56,44 +56,34 @@ void TwoStepUpdatedLagrangianVPImplicitFluidElement::InitializeNonLinearIt } template -void TwoStepUpdatedLagrangianVPImplicitFluidElement::ComputeMaterialParameters(double &Density, - double &DeviatoricCoeff, - double &VolumetricCoeff, - ProcessInfo ¤tProcessInfo, - ElementalVariables &rElementalVariables) -{ - double timeStep = currentProcessInfo[DELTA_TIME]; - - Density = this->GetProperties()[DENSITY]; - double FluidBulkModulus = this->GetProperties()[BULK_MODULUS]; - double FluidYieldShear = this->GetProperties()[YIELD_SHEAR]; - double staticFrictionCoefficient = this->GetProperties()[STATIC_FRICTION]; - - if (FluidBulkModulus == 0) - { - FluidBulkModulus = 1000000000.0; - } - VolumetricCoeff = FluidBulkModulus * timeStep; - - if (FluidYieldShear != 0) - { - // std::cout<<"For a Newtonian fluid I should not enter here"<ComputeNonLinearViscosity(rElementalVariables.EquivalentStrainRate); - } - else if (staticFrictionCoefficient != 0) - { - DeviatoricCoeff = this->ComputePapanastasiouMuIrheologyViscosity(rElementalVariables); - } - else - { - // std::cout<<"For a Newtonian fluid I should enter here"<GetProperties()[DYNAMIC_VISCOSITY]; - } - - this->mMaterialDeviatoricCoefficient = DeviatoricCoeff; - this->mMaterialVolumetricCoefficient = VolumetricCoeff; - this->mMaterialDensity = Density; +void TwoStepUpdatedLagrangianVPImplicitFluidElement::ComputeMaterialParameters( + double &Density, double &DeviatoricCoeff, double &VolumetricCoeff, ProcessInfo ¤tProcessInfo, + ElementalVariables &rElementalVariables) { + double timeStep = currentProcessInfo[DELTA_TIME]; + + Density = this->GetProperties()[DENSITY]; + double FluidBulkModulus = this->GetProperties()[BULK_MODULUS]; + double FluidYieldShear = this->GetProperties()[YIELD_SHEAR]; + double staticFrictionCoefficient = this->GetProperties()[STATIC_FRICTION]; + + if (FluidBulkModulus == 0) { + FluidBulkModulus = 1000000000.0; + } + VolumetricCoeff = FluidBulkModulus * timeStep; + + if (FluidYieldShear != 0) { + // std::cout<<"For a Newtonian fluid I should not enter here"<ComputeNonLinearViscosity(rElementalVariables.EquivalentStrainRate); + } else if (staticFrictionCoefficient != 0) { + DeviatoricCoeff = this->ComputePapanastasiouMuIrheologyViscosity(rElementalVariables); + } else { + // std::cout<<"For a Newtonian fluid I should enter here"<GetProperties()[DYNAMIC_VISCOSITY]; + } + this->mMaterialDeviatoricCoefficient = DeviatoricCoeff; + this->mMaterialVolumetricCoefficient = VolumetricCoeff; + this->mMaterialDensity = Density; } template From d2c7ac603b06ff50c26c4f9f9cfa215c34a5fe79 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Sun, 1 Mar 2020 17:39:57 +0100 Subject: [PATCH 05/47] temporary workaround - adding variable THETA_MOMENTUM --- .../custom_python/pfem_fluid_dynamics_python_application.cpp | 1 + .../pfem_fluid_dynamics_application.cpp | 1 + .../pfem_fluid_dynamics_application_variables.cpp | 1 + .../pfem_fluid_dynamics_application_variables.h | 1 + .../python_scripts/pfem_fluid_nodal_integration_solver.py | 1 + .../python_scripts/pfem_fluid_solver.py | 1 + 6 files changed, 6 insertions(+) diff --git a/applications/PfemFluidDynamicsApplication/custom_python/pfem_fluid_dynamics_python_application.cpp b/applications/PfemFluidDynamicsApplication/custom_python/pfem_fluid_dynamics_python_application.cpp index a3f2433477ed..5b21172ef06e 100755 --- a/applications/PfemFluidDynamicsApplication/custom_python/pfem_fluid_dynamics_python_application.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_python/pfem_fluid_dynamics_python_application.cpp @@ -59,6 +59,7 @@ PYBIND11_MODULE(KratosPfemFluidDynamicsApplication, m) KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, INITIAL_DELTA_TIME); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, CURRENT_DELTA_TIME); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, TIME_INTERVAL_CHANGED); + KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, THETA_MOMENTUM); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, YIELDED); KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, FLOW_INDEX); diff --git a/applications/PfemFluidDynamicsApplication/pfem_fluid_dynamics_application.cpp b/applications/PfemFluidDynamicsApplication/pfem_fluid_dynamics_application.cpp index 3093ee9c07a0..c84b289a16ec 100644 --- a/applications/PfemFluidDynamicsApplication/pfem_fluid_dynamics_application.cpp +++ b/applications/PfemFluidDynamicsApplication/pfem_fluid_dynamics_application.cpp @@ -115,6 +115,7 @@ void KratosPfemFluidDynamicsApplication::Register() KRATOS_REGISTER_VARIABLE(BAD_VELOCITY_CONVERGENCE); KRATOS_REGISTER_VARIABLE(BAD_PRESSURE_CONVERGENCE); KRATOS_REGISTER_VARIABLE(STEPS_WITH_CHANGED_DT); + KRATOS_REGISTER_VARIABLE(THETA_MOMENTUM); //Papanastasiou variables KRATOS_REGISTER_VARIABLE(YIELDED); diff --git a/applications/PfemFluidDynamicsApplication/pfem_fluid_dynamics_application_variables.cpp b/applications/PfemFluidDynamicsApplication/pfem_fluid_dynamics_application_variables.cpp index ab5d51590fd0..05fb365be619 100644 --- a/applications/PfemFluidDynamicsApplication/pfem_fluid_dynamics_application_variables.cpp +++ b/applications/PfemFluidDynamicsApplication/pfem_fluid_dynamics_application_variables.cpp @@ -33,6 +33,7 @@ KRATOS_CREATE_VARIABLE(bool, TIME_INTERVAL_CHANGED) KRATOS_CREATE_VARIABLE(bool, BAD_VELOCITY_CONVERGENCE) KRATOS_CREATE_VARIABLE(bool, BAD_PRESSURE_CONVERGENCE) KRATOS_CREATE_VARIABLE(unsigned int, STEPS_WITH_CHANGED_DT) +KRATOS_CREATE_VARIABLE(double, THETA_MOMENTUM) //Papanastasiou variables KRATOS_CREATE_VARIABLE(double, FLOW_INDEX) diff --git a/applications/PfemFluidDynamicsApplication/pfem_fluid_dynamics_application_variables.h b/applications/PfemFluidDynamicsApplication/pfem_fluid_dynamics_application_variables.h index 77c5460e3b3c..7e9438496b54 100644 --- a/applications/PfemFluidDynamicsApplication/pfem_fluid_dynamics_application_variables.h +++ b/applications/PfemFluidDynamicsApplication/pfem_fluid_dynamics_application_variables.h @@ -55,6 +55,7 @@ KRATOS_DEFINE_APPLICATION_VARIABLE(PFEM_FLUID_DYNAMICS_APPLICATION, bool, TIME_I KRATOS_DEFINE_APPLICATION_VARIABLE(PFEM_FLUID_DYNAMICS_APPLICATION, bool, BAD_VELOCITY_CONVERGENCE) KRATOS_DEFINE_APPLICATION_VARIABLE(PFEM_FLUID_DYNAMICS_APPLICATION, bool, BAD_PRESSURE_CONVERGENCE) KRATOS_DEFINE_APPLICATION_VARIABLE(PFEM_FLUID_DYNAMICS_APPLICATION, unsigned int, STEPS_WITH_CHANGED_DT) +KRATOS_DEFINE_APPLICATION_VARIABLE(PFEM_FLUID_DYNAMICS_APPLICATION, double, THETA_MOMENTUM) //Papanastasiou variables KRATOS_DEFINE_APPLICATION_VARIABLE(PFEM_FLUID_DYNAMICS_APPLICATION, double, FLOW_INDEX) diff --git a/applications/PfemFluidDynamicsApplication/python_scripts/pfem_fluid_nodal_integration_solver.py b/applications/PfemFluidDynamicsApplication/python_scripts/pfem_fluid_nodal_integration_solver.py index 280daf4c3242..8b5d871b019f 100644 --- a/applications/PfemFluidDynamicsApplication/python_scripts/pfem_fluid_nodal_integration_solver.py +++ b/applications/PfemFluidDynamicsApplication/python_scripts/pfem_fluid_nodal_integration_solver.py @@ -170,6 +170,7 @@ def AddVariables(self): self.main_model_part.AddNodalSolutionStepVariable(KratosDelaunay.RIGID_WALL) self.main_model_part.AddNodalSolutionStepVariable(KratosPfemFluid.PROPERTY_ID) + self.main_model_part.AddNodalSolutionStepVariable(KratosPfemFluid.THETA_MOMENTUM) print("::[Pfem Fluid Solver]:: Variables ADDED") diff --git a/applications/PfemFluidDynamicsApplication/python_scripts/pfem_fluid_solver.py b/applications/PfemFluidDynamicsApplication/python_scripts/pfem_fluid_solver.py index d242b12846ac..155a0854f4a1 100644 --- a/applications/PfemFluidDynamicsApplication/python_scripts/pfem_fluid_solver.py +++ b/applications/PfemFluidDynamicsApplication/python_scripts/pfem_fluid_solver.py @@ -216,6 +216,7 @@ def AddVariables(self): self.main_model_part.AddNodalSolutionStepVariable(KratosDelaunay.RIGID_WALL) self.main_model_part.AddNodalSolutionStepVariable(KratosDelaunay.PROPERTY_ID) + self.main_model_part.AddNodalSolutionStepVariable(KratosPfemFluid.THETA_MOMENTUM) print("::[PfemFluidSolver]:: Variables ADDED") From 77ca321b51187407b324367624dc8f712f05c797 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Sun, 1 Mar 2020 17:41:11 +0100 Subject: [PATCH 06/47] cleanup - behaviour not changed (V) --- ...gian_V_P_implicit_fluid_DEM_coupling_element.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_DEM_coupling_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_DEM_coupling_element.cpp index ec6a10c514e8..246b09cfbecc 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_DEM_coupling_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_DEM_coupling_element.cpp @@ -90,23 +90,10 @@ void TwoStepUpdatedLagrangianVPImplicitFluidDEMcouplingElement::ComputeMat DeviatoricCoeff = this->GetProperties()[DYNAMIC_VISCOSITY]; } - // this->ComputeMaterialParametersGranularGas(rElementalVariables,VolumetricCoeff,DeviatoricCoeff); - // std::cout<<"Density "<mMaterialDeviatoricCoefficient = DeviatoricCoeff; this->mMaterialVolumetricCoefficient = VolumetricCoeff; this->mMaterialDensity = Density; - // const SizeType NumNodes = this->GetGeometry().PointsNumber(); - // for (SizeType i = 0; i < NumNodes; ++i) - // { - // this->GetGeometry()[i].FastGetSolutionStepValue(ADAPTIVE_EXPONENT)=VolumetricCoeff; - // this->GetGeometry()[i].FastGetSolutionStepValue(ALPHA_PARAMETER)=DeviatoricCoeff; - // this->GetGeometry()[i].FastGetSolutionStepValue(FLOW_INDEX)=rElementalVariables.EquivalentStrainRate; - // } } template From 26d12a2f2b818dc1faba029e3522a993c3adbf36 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Sun, 1 Mar 2020 17:42:16 +0100 Subject: [PATCH 07/47] cleanup - behaviour not changed (VI) --- ..._P_implicit_fluid_DEM_coupling_element.cpp | 64 ++++++++----------- 1 file changed, 27 insertions(+), 37 deletions(-) diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_DEM_coupling_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_DEM_coupling_element.cpp index 246b09cfbecc..915b4b9ae5ce 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_DEM_coupling_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_DEM_coupling_element.cpp @@ -56,44 +56,34 @@ void TwoStepUpdatedLagrangianVPImplicitFluidDEMcouplingElement::Initialize } template -void TwoStepUpdatedLagrangianVPImplicitFluidDEMcouplingElement::ComputeMaterialParameters(double &Density, - double &DeviatoricCoeff, - double &VolumetricCoeff, - ProcessInfo ¤tProcessInfo, - ElementalVariables &rElementalVariables) -{ - double timeStep = currentProcessInfo[DELTA_TIME]; - - Density = this->GetProperties()[DENSITY]; - double FluidBulkModulus = this->GetProperties()[BULK_MODULUS]; - double FluidYieldShear = this->GetProperties()[YIELD_SHEAR]; - double staticFrictionCoefficient = this->GetProperties()[STATIC_FRICTION]; - - if (FluidBulkModulus == 0) - { - FluidBulkModulus = 1000000000.0; - } - VolumetricCoeff = FluidBulkModulus * timeStep; - - if (FluidYieldShear != 0) - { - // std::cout<<"For a Newtonian fluid I should not enter here"<ComputeNonLinearViscosity(rElementalVariables.EquivalentStrainRate); - } - else if (staticFrictionCoefficient != 0) - { - DeviatoricCoeff = this->ComputePapanastasiouMuIrheologyViscosity(rElementalVariables); - } - else - { - // std::cout<<"For a Newtonian fluid I should enter here"<GetProperties()[DYNAMIC_VISCOSITY]; - } - - this->mMaterialDeviatoricCoefficient = DeviatoricCoeff; - this->mMaterialVolumetricCoefficient = VolumetricCoeff; - this->mMaterialDensity = Density; +void TwoStepUpdatedLagrangianVPImplicitFluidDEMcouplingElement::ComputeMaterialParameters( + double &Density, double &DeviatoricCoeff, double &VolumetricCoeff, ProcessInfo ¤tProcessInfo, + ElementalVariables &rElementalVariables) { + double timeStep = currentProcessInfo[DELTA_TIME]; + + Density = this->GetProperties()[DENSITY]; + double FluidBulkModulus = this->GetProperties()[BULK_MODULUS]; + double FluidYieldShear = this->GetProperties()[YIELD_SHEAR]; + double staticFrictionCoefficient = this->GetProperties()[STATIC_FRICTION]; + + if (FluidBulkModulus == 0) { + FluidBulkModulus = 1000000000.0; + } + VolumetricCoeff = FluidBulkModulus * timeStep; + + if (FluidYieldShear != 0) { + // std::cout<<"For a Newtonian fluid I should not enter here"<ComputeNonLinearViscosity(rElementalVariables.EquivalentStrainRate); + } else if (staticFrictionCoefficient != 0) { + DeviatoricCoeff = this->ComputePapanastasiouMuIrheologyViscosity(rElementalVariables); + } else { + // std::cout<<"For a Newtonian fluid I should enter here"<GetProperties()[DYNAMIC_VISCOSITY]; + } + this->mMaterialDeviatoricCoefficient = DeviatoricCoeff; + this->mMaterialVolumetricCoefficient = VolumetricCoeff; + this->mMaterialDensity = Density; } template From b7e99f132a09a1f09724b1e6ef4e2dc39378e8f0 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Sun, 1 Mar 2020 17:47:39 +0100 Subject: [PATCH 08/47] cleanup - behaviour not changed (VII) --- ..._lagrangian_V_P_implicit_solid_element.cpp | 282 ++++++------------ 1 file changed, 96 insertions(+), 186 deletions(-) diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp index a51dc793fe01..9e3deea3a57b 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp @@ -127,37 +127,21 @@ void TwoStepUpdatedLagrangianVPImplicitSolidElement::InitializeNonLinearIt } template -void TwoStepUpdatedLagrangianVPImplicitSolidElement::ComputeMaterialParameters(double &Density, - double &DeviatoricCoeff, - double &VolumetricCoeff, - ProcessInfo ¤tProcessInfo, - ElementalVariables &rElementalVariables) -{ - - Density = this->GetProperties()[DENSITY]; - double YoungModulus = this->GetProperties()[YOUNG_MODULUS]; - double PoissonRatio = this->GetProperties()[POISSON_RATIO]; - double timeStep = currentProcessInfo[DELTA_TIME]; - - // this->EvaluateInPoint(YoungModulus,YOUNG_MODULUS,N); - // this->EvaluateInPoint(PoissonRatio,POISSON_RATIO,N); - // this->EvaluateInPoint(Density,DENSITY,N); - - // YoungModulus=10000000;//falling cylinder - // PoissonRatio=0.35;//falling cylinder - // YoungModulus=1000000;//dam break fsi - // PoissonRatio=0;//dam break fsi - // YoungModulus=100000000; - // PoissonRatio=0; - - // FirstLame = timeStep*PoissonRatio*YoungModulus/((1.0+PoissonRatio)*(1.0-2.0*PoissonRatio)); - DeviatoricCoeff = timeStep * YoungModulus / (1.0 + PoissonRatio) * 0.5; - // BulkModulus = FirstLame + 2.0*SecondLame/3.0; - VolumetricCoeff = timeStep * PoissonRatio * YoungModulus / ((1.0 + PoissonRatio) * (1.0 - 2.0 * PoissonRatio)) + 2.0 * DeviatoricCoeff / 3.0; - - this->mMaterialDeviatoricCoefficient = DeviatoricCoeff; - this->mMaterialVolumetricCoefficient = VolumetricCoeff; - this->mMaterialDensity = Density; +void TwoStepUpdatedLagrangianVPImplicitSolidElement::ComputeMaterialParameters( + double &Density, double &DeviatoricCoeff, double &VolumetricCoeff, ProcessInfo ¤tProcessInfo, + ElementalVariables &rElementalVariables) { + Density = this->GetProperties()[DENSITY]; + double YoungModulus = this->GetProperties()[YOUNG_MODULUS]; + double PoissonRatio = this->GetProperties()[POISSON_RATIO]; + double timeStep = currentProcessInfo[DELTA_TIME]; + + DeviatoricCoeff = timeStep * YoungModulus / (1.0 + PoissonRatio) * 0.5; + VolumetricCoeff = timeStep * PoissonRatio * YoungModulus / ((1.0 + PoissonRatio) * (1.0 - 2.0 * PoissonRatio)) + + 2.0 * DeviatoricCoeff / 3.0; + + this->mMaterialDeviatoricCoefficient = DeviatoricCoeff; + this->mMaterialVolumetricCoefficient = VolumetricCoeff; + this->mMaterialDensity = Density; } template @@ -325,126 +309,99 @@ void TwoStepUpdatedLagrangianVPImplicitSolidElement::InitializeElementalVa } template <> -void TwoStepUpdatedLagrangianVPImplicitSolidElement<2>::CalcElasticPlasticCauchySplitted(ElementalVariables &rElementalVariables, double TimeStep, unsigned int g) -{ - - rElementalVariables.CurrentTotalCauchyStress = this->mCurrentTotalCauchyStress[g]; - rElementalVariables.CurrentDeviatoricCauchyStress = this->mCurrentDeviatoricCauchyStress[g]; - - double CurrSecondLame = this->mMaterialDeviatoricCoefficient; - // double CurrBulkModulus = this->mMaterialVolumetricCoefficient; - // double CurrFirstLame =CurrBulkModulus - 2.0*CurrSecondLame/3.0; - - double DefX = rElementalVariables.SpatialDefRate[0]; - double DefY = rElementalVariables.SpatialDefRate[1]; - double DefXY = rElementalVariables.SpatialDefRate[2]; +void TwoStepUpdatedLagrangianVPImplicitSolidElement<2>::CalcElasticPlasticCauchySplitted( + ElementalVariables &rElementalVariables, double TimeStep, unsigned int g) { + rElementalVariables.CurrentTotalCauchyStress = this->mCurrentTotalCauchyStress[g]; + rElementalVariables.CurrentDeviatoricCauchyStress = this->mCurrentDeviatoricCauchyStress[g]; - double DefVol = rElementalVariables.VolumetricDefRate; + double CurrSecondLame = this->mMaterialDeviatoricCoefficient; - double sigmaDev_xx = 2 * CurrSecondLame * (DefX - DefVol / 3.0); - double sigmaDev_yy = 2 * CurrSecondLame * (DefY - DefVol / 3.0); - double sigmaDev_xy = 2 * CurrSecondLame * DefXY; + double DefX = rElementalVariables.SpatialDefRate[0]; + double DefY = rElementalVariables.SpatialDefRate[1]; + double DefXY = rElementalVariables.SpatialDefRate[2]; - // double sigmaTot_xx= CurrFirstLame*DefVol + 2.0*CurrSecondLame*DefX; - // double sigmaTot_yy= CurrFirstLame*DefVol + 2.0*CurrSecondLame*DefY; - // double sigmaTot_xy= 2.0*CurrSecondLame*DefXY; + double DefVol = rElementalVariables.VolumetricDefRate; - // sigmaTot_xx=rElementalVariables.CurrentTotalCauchyStress[0] + rElementalVariables.MeanPressure + sigmaDev_xx; - // sigmaTot_yy=rElementalVariables.CurrentTotalCauchyStress[1] + rElementalVariables.MeanPressure + sigmaDev_yy; - // sigmaTot_xy=rElementalVariables.CurrentTotalCauchyStress[2] + sigmaDev_xy; + double sigmaDev_xx = 2 * CurrSecondLame * (DefX - DefVol / 3.0); + double sigmaDev_yy = 2 * CurrSecondLame * (DefY - DefVol / 3.0); + double sigmaDev_xy = 2 * CurrSecondLame * DefXY; - sigmaDev_xx += rElementalVariables.CurrentDeviatoricCauchyStress[0]; - sigmaDev_yy += rElementalVariables.CurrentDeviatoricCauchyStress[1]; - sigmaDev_xy += rElementalVariables.CurrentDeviatoricCauchyStress[2]; + sigmaDev_xx += rElementalVariables.CurrentDeviatoricCauchyStress[0]; + sigmaDev_yy += rElementalVariables.CurrentDeviatoricCauchyStress[1]; + sigmaDev_xy += rElementalVariables.CurrentDeviatoricCauchyStress[2]; - double sigmaTot_xx = sigmaDev_xx + rElementalVariables.MeanPressure; - double sigmaTot_yy = sigmaDev_yy + rElementalVariables.MeanPressure; - double sigmaTot_xy = sigmaDev_xy; + double sigmaTot_xx = sigmaDev_xx + rElementalVariables.MeanPressure; + double sigmaTot_yy = sigmaDev_yy + rElementalVariables.MeanPressure; + double sigmaTot_xy = sigmaDev_xy; - // sigmaTot_xx+=rElementalVariables.CurrentTotalCauchyStress[0]; - // sigmaTot_yy+=rElementalVariables.CurrentTotalCauchyStress[1]; - // sigmaTot_xy+=rElementalVariables.CurrentTotalCauchyStress[2]; + rElementalVariables.UpdatedDeviatoricCauchyStress[0] = sigmaDev_xx; + rElementalVariables.UpdatedDeviatoricCauchyStress[1] = sigmaDev_yy; + rElementalVariables.UpdatedDeviatoricCauchyStress[2] = sigmaDev_xy; - rElementalVariables.UpdatedDeviatoricCauchyStress[0] = sigmaDev_xx; - rElementalVariables.UpdatedDeviatoricCauchyStress[1] = sigmaDev_yy; - rElementalVariables.UpdatedDeviatoricCauchyStress[2] = sigmaDev_xy; + rElementalVariables.UpdatedTotalCauchyStress[0] = sigmaTot_xx; + rElementalVariables.UpdatedTotalCauchyStress[1] = sigmaTot_yy; + rElementalVariables.UpdatedTotalCauchyStress[2] = sigmaTot_xy; - rElementalVariables.UpdatedTotalCauchyStress[0] = sigmaTot_xx; - rElementalVariables.UpdatedTotalCauchyStress[1] = sigmaTot_yy; - rElementalVariables.UpdatedTotalCauchyStress[2] = sigmaTot_xy; - - // this->mCurrentTotalCauchyStress[g]=rElementalVariables.CurrentTotalCauchyStress; - this->mUpdatedTotalCauchyStress[g] = rElementalVariables.UpdatedTotalCauchyStress; - // this->mCurrentDeviatoricCauchyStress[g]=rElementalVariables.CurrentDeviatoricCauchyStress; - this->mUpdatedDeviatoricCauchyStress[g] = rElementalVariables.UpdatedDeviatoricCauchyStress; + this->mUpdatedTotalCauchyStress[g] = rElementalVariables.UpdatedTotalCauchyStress; + this->mUpdatedDeviatoricCauchyStress[g] = rElementalVariables.UpdatedDeviatoricCauchyStress; } template <> -void TwoStepUpdatedLagrangianVPImplicitSolidElement<3>::CalcElasticPlasticCauchySplitted(ElementalVariables &rElementalVariables, double TimeStep, unsigned int g) -{ - - rElementalVariables.CurrentTotalCauchyStress = this->mCurrentTotalCauchyStress[g]; - rElementalVariables.CurrentDeviatoricCauchyStress = this->mCurrentDeviatoricCauchyStress[g]; - - double CurrSecondLame = this->mMaterialDeviatoricCoefficient; - // double CurrBulkModulus = this->mMaterialVolumetricCoefficient; - // double CurrFirstLame = CurrBulkModulus - 2.0*CurrSecondLame/3.0; - - double DefX = rElementalVariables.SpatialDefRate[0]; - double DefY = rElementalVariables.SpatialDefRate[1]; - double DefZ = rElementalVariables.SpatialDefRate[2]; - double DefXY = rElementalVariables.SpatialDefRate[3]; - double DefXZ = rElementalVariables.SpatialDefRate[4]; - double DefYZ = rElementalVariables.SpatialDefRate[5]; - - double DefVol = rElementalVariables.VolumetricDefRate; - - double sigmaDev_xx = 2 * CurrSecondLame * (DefX - DefVol / 3.0); - double sigmaDev_yy = 2 * CurrSecondLame * (DefY - DefVol / 3.0); - double sigmaDev_zz = 2 * CurrSecondLame * (DefZ - DefVol / 3.0); - double sigmaDev_xy = 2 * CurrSecondLame * DefXY; - double sigmaDev_xz = 2 * CurrSecondLame * DefXZ; - double sigmaDev_yz = 2 * CurrSecondLame * DefYZ; - - // double sigmaTot_xx= CurrFirstLame*DefVol + 2*CurrSecondLame*DefX; - // double sigmaTot_yy= CurrFirstLame*DefVol + 2*CurrSecondLame*DefY; - // double sigmaTot_zz= CurrFirstLame*DefVol + 2*CurrSecondLame*DefZ; - // double sigmaTot_xy= 2*CurrSecondLame*DefXY; - // double sigmaTot_xz= 2*CurrSecondLame*DefXZ; - // double sigmaTot_yz= 2*CurrSecondLame*DefYZ; - - sigmaDev_xx += rElementalVariables.CurrentDeviatoricCauchyStress[0]; - sigmaDev_yy += rElementalVariables.CurrentDeviatoricCauchyStress[1]; - sigmaDev_zz += rElementalVariables.CurrentDeviatoricCauchyStress[2]; - sigmaDev_xy += rElementalVariables.CurrentDeviatoricCauchyStress[3]; - sigmaDev_xz += rElementalVariables.CurrentDeviatoricCauchyStress[4]; - sigmaDev_yz += rElementalVariables.CurrentDeviatoricCauchyStress[5]; - - double sigmaTot_xx = sigmaDev_xx + rElementalVariables.MeanPressure; - double sigmaTot_yy = sigmaDev_yy + rElementalVariables.MeanPressure; - double sigmaTot_zz = sigmaDev_zz + rElementalVariables.MeanPressure; - double sigmaTot_xy = sigmaDev_xy; - double sigmaTot_xz = sigmaDev_xz; - double sigmaTot_yz = sigmaDev_yz; - - rElementalVariables.UpdatedDeviatoricCauchyStress[0] = sigmaDev_xx; - rElementalVariables.UpdatedDeviatoricCauchyStress[1] = sigmaDev_yy; - rElementalVariables.UpdatedDeviatoricCauchyStress[2] = sigmaDev_zz; - rElementalVariables.UpdatedDeviatoricCauchyStress[3] = sigmaDev_xy; - rElementalVariables.UpdatedDeviatoricCauchyStress[4] = sigmaDev_xz; - rElementalVariables.UpdatedDeviatoricCauchyStress[5] = sigmaDev_yz; - - rElementalVariables.UpdatedTotalCauchyStress[0] = sigmaTot_xx; - rElementalVariables.UpdatedTotalCauchyStress[1] = sigmaTot_yy; - rElementalVariables.UpdatedTotalCauchyStress[2] = sigmaTot_zz; - rElementalVariables.UpdatedTotalCauchyStress[3] = sigmaTot_xy; - rElementalVariables.UpdatedTotalCauchyStress[4] = sigmaTot_xz; - rElementalVariables.UpdatedTotalCauchyStress[5] = sigmaTot_yz; - - this->mCurrentTotalCauchyStress[g] = rElementalVariables.CurrentTotalCauchyStress; - this->mUpdatedTotalCauchyStress[g] = rElementalVariables.UpdatedTotalCauchyStress; - this->mCurrentDeviatoricCauchyStress[g] = rElementalVariables.CurrentDeviatoricCauchyStress; - this->mUpdatedDeviatoricCauchyStress[g] = rElementalVariables.UpdatedDeviatoricCauchyStress; +void TwoStepUpdatedLagrangianVPImplicitSolidElement<3>::CalcElasticPlasticCauchySplitted( + ElementalVariables &rElementalVariables, double TimeStep, unsigned int g) { + rElementalVariables.CurrentTotalCauchyStress = this->mCurrentTotalCauchyStress[g]; + rElementalVariables.CurrentDeviatoricCauchyStress = this->mCurrentDeviatoricCauchyStress[g]; + + double CurrSecondLame = this->mMaterialDeviatoricCoefficient; + + double DefX = rElementalVariables.SpatialDefRate[0]; + double DefY = rElementalVariables.SpatialDefRate[1]; + double DefZ = rElementalVariables.SpatialDefRate[2]; + double DefXY = rElementalVariables.SpatialDefRate[3]; + double DefXZ = rElementalVariables.SpatialDefRate[4]; + double DefYZ = rElementalVariables.SpatialDefRate[5]; + + double DefVol = rElementalVariables.VolumetricDefRate; + + double sigmaDev_xx = 2 * CurrSecondLame * (DefX - DefVol / 3.0); + double sigmaDev_yy = 2 * CurrSecondLame * (DefY - DefVol / 3.0); + double sigmaDev_zz = 2 * CurrSecondLame * (DefZ - DefVol / 3.0); + double sigmaDev_xy = 2 * CurrSecondLame * DefXY; + double sigmaDev_xz = 2 * CurrSecondLame * DefXZ; + double sigmaDev_yz = 2 * CurrSecondLame * DefYZ; + + sigmaDev_xx += rElementalVariables.CurrentDeviatoricCauchyStress[0]; + sigmaDev_yy += rElementalVariables.CurrentDeviatoricCauchyStress[1]; + sigmaDev_zz += rElementalVariables.CurrentDeviatoricCauchyStress[2]; + sigmaDev_xy += rElementalVariables.CurrentDeviatoricCauchyStress[3]; + sigmaDev_xz += rElementalVariables.CurrentDeviatoricCauchyStress[4]; + sigmaDev_yz += rElementalVariables.CurrentDeviatoricCauchyStress[5]; + + double sigmaTot_xx = sigmaDev_xx + rElementalVariables.MeanPressure; + double sigmaTot_yy = sigmaDev_yy + rElementalVariables.MeanPressure; + double sigmaTot_zz = sigmaDev_zz + rElementalVariables.MeanPressure; + double sigmaTot_xy = sigmaDev_xy; + double sigmaTot_xz = sigmaDev_xz; + double sigmaTot_yz = sigmaDev_yz; + + rElementalVariables.UpdatedDeviatoricCauchyStress[0] = sigmaDev_xx; + rElementalVariables.UpdatedDeviatoricCauchyStress[1] = sigmaDev_yy; + rElementalVariables.UpdatedDeviatoricCauchyStress[2] = sigmaDev_zz; + rElementalVariables.UpdatedDeviatoricCauchyStress[3] = sigmaDev_xy; + rElementalVariables.UpdatedDeviatoricCauchyStress[4] = sigmaDev_xz; + rElementalVariables.UpdatedDeviatoricCauchyStress[5] = sigmaDev_yz; + + rElementalVariables.UpdatedTotalCauchyStress[0] = sigmaTot_xx; + rElementalVariables.UpdatedTotalCauchyStress[1] = sigmaTot_yy; + rElementalVariables.UpdatedTotalCauchyStress[2] = sigmaTot_zz; + rElementalVariables.UpdatedTotalCauchyStress[3] = sigmaTot_xy; + rElementalVariables.UpdatedTotalCauchyStress[4] = sigmaTot_xz; + rElementalVariables.UpdatedTotalCauchyStress[5] = sigmaTot_yz; + + this->mCurrentTotalCauchyStress[g] = rElementalVariables.CurrentTotalCauchyStress; + this->mUpdatedTotalCauchyStress[g] = rElementalVariables.UpdatedTotalCauchyStress; + this->mCurrentDeviatoricCauchyStress[g] = rElementalVariables.CurrentDeviatoricCauchyStress; + this->mUpdatedDeviatoricCauchyStress[g] = rElementalVariables.UpdatedDeviatoricCauchyStress; } template @@ -467,53 +424,6 @@ void TwoStepUpdatedLagrangianVPImplicitSolidElement::UpdateCauchyStress(un this->CalcElasticPlasticCauchySplitted(rElementalVariables, TimeStep, g); } - // ElementalVariables rElementalVariables; - // this->InitializeElementalVariables(rElementalVariables); - - // double theta=0; - // bool computeElement=this->CalcStrainRate(rElementalVariables,rCurrentProcessInfo,g,theta); - - // // //SIGMA(2D)=(F·S·Ft)/J --> already checked -> ok! - // double SigmaXX= ( rElementalVariables.Fgrad(0,0)*rElementalVariables.UpdatedTotalCauchyStress[0]*rElementalVariables.Fgrad(0,0) + - // 2*rElementalVariables.Fgrad(0,0)*rElementalVariables.UpdatedTotalCauchyStress[2]*rElementalVariables.Fgrad(0,1) + - // rElementalVariables.Fgrad(0,1)*rElementalVariables.UpdatedTotalCauchyStress[1]*rElementalVariables.Fgrad(0,1))/rElementalVariables.DetFgrad ; - - // double SigmaYY= ( rElementalVariables.Fgrad(1,0)*rElementalVariables.UpdatedTotalCauchyStress[0]*rElementalVariables.Fgrad(1,0) + - // 2*rElementalVariables.Fgrad(1,1)*rElementalVariables.UpdatedTotalCauchyStress[2]*rElementalVariables.Fgrad(1,0) + - // rElementalVariables.Fgrad(1,1)*rElementalVariables.UpdatedTotalCauchyStress[1]*rElementalVariables.Fgrad(1,1))/rElementalVariables.DetFgrad ; - - // double SigmaXY= (rElementalVariables.Fgrad(0,0)*rElementalVariables.UpdatedTotalCauchyStress[0]*rElementalVariables.Fgrad(1,0) + - // rElementalVariables.Fgrad(0,0)*rElementalVariables.UpdatedTotalCauchyStress[2]*rElementalVariables.Fgrad(1,1) + - // rElementalVariables.Fgrad(0,1)*rElementalVariables.UpdatedTotalCauchyStress[2]*rElementalVariables.Fgrad(1,0) + - // rElementalVariables.Fgrad(0,1)*rElementalVariables.UpdatedTotalCauchyStress[1]*rElementalVariables.Fgrad(1,1))/rElementalVariables.DetFgrad; - - // rElementalVariables.UpdatedTotalCauchyStress[0]=SigmaXX; - // rElementalVariables.UpdatedTotalCauchyStress[1]=SigmaYY; - // rElementalVariables.UpdatedTotalCauchyStress[2]=SigmaXY; - - // this->mUpdatedTotalCauchyStress[g]=rElementalVariables.UpdatedTotalCauchyStress; - - // // //SIGMA(2D)=(F·S·Ft)/J --> already checked -> ok! - // SigmaXX= ( rElementalVariables.Fgrad(0,0)*rElementalVariables.UpdatedDeviatoricCauchyStress[0]*rElementalVariables.Fgrad(0,0) + - // 2*rElementalVariables.Fgrad(0,0)*rElementalVariables.UpdatedDeviatoricCauchyStress[2]*rElementalVariables.Fgrad(0,1) + - // rElementalVariables.Fgrad(0,1)*rElementalVariables.UpdatedDeviatoricCauchyStress[1]*rElementalVariables.Fgrad(0,1))/rElementalVariables.DetFgrad ; - - // SigmaYY= ( rElementalVariables.Fgrad(1,0)*rElementalVariables.UpdatedDeviatoricCauchyStress[0]*rElementalVariables.Fgrad(1,0) + - // 2*rElementalVariables.Fgrad(1,1)*rElementalVariables.UpdatedDeviatoricCauchyStress[2]*rElementalVariables.Fgrad(1,0) + - // rElementalVariables.Fgrad(1,1)*rElementalVariables.UpdatedDeviatoricCauchyStress[1]*rElementalVariables.Fgrad(1,1))/rElementalVariables.DetFgrad ; - - // SigmaXY= (rElementalVariables.Fgrad(0,0)*rElementalVariables.UpdatedDeviatoricCauchyStress[0]*rElementalVariables.Fgrad(1,0) + - // rElementalVariables.Fgrad(0,0)*rElementalVariables.UpdatedDeviatoricCauchyStress[2]*rElementalVariables.Fgrad(1,1) + - // rElementalVariables.Fgrad(0,1)*rElementalVariables.UpdatedDeviatoricCauchyStress[2]*rElementalVariables.Fgrad(1,0) + - // rElementalVariables.Fgrad(0,1)*rElementalVariables.UpdatedDeviatoricCauchyStress[1]*rElementalVariables.Fgrad(1,1))/rElementalVariables.DetFgrad; - - // rElementalVariables.UpdatedDeviatoricCauchyStress[0]=SigmaXX; - // rElementalVariables.UpdatedDeviatoricCauchyStress[1]=SigmaYY; - // rElementalVariables.UpdatedDeviatoricCauchyStress[2]=SigmaXY; - - // this->mUpdatedDeviatoricCauchyStress[g]=rElementalVariables.UpdatedDeviatoricCauchyStress; - - // std::cout<<" UpdateCauchyStress "; this->mCurrentTotalCauchyStress[g] = this->mUpdatedTotalCauchyStress[g]; this->mCurrentDeviatoricCauchyStress[g] = this->mUpdatedDeviatoricCauchyStress[g]; } From 8b5a5321a5f642a9f061b2aec240725eecb38141 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Sun, 1 Mar 2020 17:49:52 +0100 Subject: [PATCH 09/47] cleanup - behaviour not changed (VIII) --- ...ed_lagrangian_V_implicit_solid_element.cpp | 198 +++++++++--------- 1 file changed, 98 insertions(+), 100 deletions(-) diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/updated_lagrangian_V_implicit_solid_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/updated_lagrangian_V_implicit_solid_element.cpp index f5a09d11ad60..427756e23e5d 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/updated_lagrangian_V_implicit_solid_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/updated_lagrangian_V_implicit_solid_element.cpp @@ -68,120 +68,118 @@ Element::Pointer UpdatedLagrangianVImplicitSolidElement::Clone(IndexType N } template <> -void UpdatedLagrangianVImplicitSolidElement<2>::CalcElasticPlasticCauchySplitted(ElementalVariables &rElementalVariables, double TimeStep, unsigned int g) -{ - - rElementalVariables.CurrentTotalCauchyStress = this->mCurrentTotalCauchyStress[g]; - rElementalVariables.CurrentDeviatoricCauchyStress = this->mCurrentDeviatoricCauchyStress[g]; +void UpdatedLagrangianVImplicitSolidElement<2>::CalcElasticPlasticCauchySplitted( + ElementalVariables &rElementalVariables, double TimeStep, unsigned int g) { + rElementalVariables.CurrentTotalCauchyStress = this->mCurrentTotalCauchyStress[g]; + rElementalVariables.CurrentDeviatoricCauchyStress = this->mCurrentDeviatoricCauchyStress[g]; - double CurrSecondLame = this->mMaterialDeviatoricCoefficient; - double CurrBulkModulus = this->mMaterialVolumetricCoefficient; + double CurrSecondLame = this->mMaterialDeviatoricCoefficient; + double CurrBulkModulus = this->mMaterialVolumetricCoefficient; - double CurrFirstLame = 0; - CurrFirstLame = CurrBulkModulus - 2.0 * CurrSecondLame / 3.0; + double CurrFirstLame = 0; + CurrFirstLame = CurrBulkModulus - 2.0 * CurrSecondLame / 3.0; - double DefX = rElementalVariables.SpatialDefRate[0]; - double DefY = rElementalVariables.SpatialDefRate[1]; - double DefXY = rElementalVariables.SpatialDefRate[2]; + double DefX = rElementalVariables.SpatialDefRate[0]; + double DefY = rElementalVariables.SpatialDefRate[1]; + double DefXY = rElementalVariables.SpatialDefRate[2]; - double DefVol = rElementalVariables.VolumetricDefRate; + double DefVol = rElementalVariables.VolumetricDefRate; - double sigmaDev_xx = 2 * CurrSecondLame * (DefX - DefVol / 3.0); - double sigmaDev_yy = 2 * CurrSecondLame * (DefY - DefVol / 3.0); - double sigmaDev_xy = 2 * CurrSecondLame * DefXY; + double sigmaDev_xx = 2 * CurrSecondLame * (DefX - DefVol / 3.0); + double sigmaDev_yy = 2 * CurrSecondLame * (DefY - DefVol / 3.0); + double sigmaDev_xy = 2 * CurrSecondLame * DefXY; - double sigmaTot_xx = CurrFirstLame * DefVol + 2.0 * CurrSecondLame * DefX; - double sigmaTot_yy = CurrFirstLame * DefVol + 2.0 * CurrSecondLame * DefY; - double sigmaTot_xy = 2.0 * CurrSecondLame * DefXY; + double sigmaTot_xx = CurrFirstLame * DefVol + 2.0 * CurrSecondLame * DefX; + double sigmaTot_yy = CurrFirstLame * DefVol + 2.0 * CurrSecondLame * DefY; + double sigmaTot_xy = 2.0 * CurrSecondLame * DefXY; - sigmaDev_xx += rElementalVariables.CurrentDeviatoricCauchyStress[0]; - sigmaDev_yy += rElementalVariables.CurrentDeviatoricCauchyStress[1]; - sigmaDev_xy += rElementalVariables.CurrentDeviatoricCauchyStress[2]; + sigmaDev_xx += rElementalVariables.CurrentDeviatoricCauchyStress[0]; + sigmaDev_yy += rElementalVariables.CurrentDeviatoricCauchyStress[1]; + sigmaDev_xy += rElementalVariables.CurrentDeviatoricCauchyStress[2]; - sigmaTot_xx += rElementalVariables.CurrentTotalCauchyStress[0]; - sigmaTot_yy += rElementalVariables.CurrentTotalCauchyStress[1]; - sigmaTot_xy += rElementalVariables.CurrentTotalCauchyStress[2]; + sigmaTot_xx += rElementalVariables.CurrentTotalCauchyStress[0]; + sigmaTot_yy += rElementalVariables.CurrentTotalCauchyStress[1]; + sigmaTot_xy += rElementalVariables.CurrentTotalCauchyStress[2]; - rElementalVariables.UpdatedDeviatoricCauchyStress[0] = sigmaDev_xx; - rElementalVariables.UpdatedDeviatoricCauchyStress[1] = sigmaDev_yy; - rElementalVariables.UpdatedDeviatoricCauchyStress[2] = sigmaDev_xy; + rElementalVariables.UpdatedDeviatoricCauchyStress[0] = sigmaDev_xx; + rElementalVariables.UpdatedDeviatoricCauchyStress[1] = sigmaDev_yy; + rElementalVariables.UpdatedDeviatoricCauchyStress[2] = sigmaDev_xy; - rElementalVariables.UpdatedTotalCauchyStress[0] = sigmaTot_xx; - rElementalVariables.UpdatedTotalCauchyStress[1] = sigmaTot_yy; - rElementalVariables.UpdatedTotalCauchyStress[2] = sigmaTot_xy; + rElementalVariables.UpdatedTotalCauchyStress[0] = sigmaTot_xx; + rElementalVariables.UpdatedTotalCauchyStress[1] = sigmaTot_yy; + rElementalVariables.UpdatedTotalCauchyStress[2] = sigmaTot_xy; - this->mUpdatedTotalCauchyStress[g] = rElementalVariables.UpdatedTotalCauchyStress; - this->mUpdatedDeviatoricCauchyStress[g] = rElementalVariables.UpdatedDeviatoricCauchyStress; + this->mUpdatedTotalCauchyStress[g] = rElementalVariables.UpdatedTotalCauchyStress; + this->mUpdatedDeviatoricCauchyStress[g] = rElementalVariables.UpdatedDeviatoricCauchyStress; } template <> -void UpdatedLagrangianVImplicitSolidElement<3>::CalcElasticPlasticCauchySplitted(ElementalVariables &rElementalVariables, double TimeStep, unsigned int g) -{ - - rElementalVariables.CurrentTotalCauchyStress = this->mCurrentTotalCauchyStress[g]; - rElementalVariables.CurrentDeviatoricCauchyStress = this->mCurrentDeviatoricCauchyStress[g]; - - double CurrSecondLame = this->mMaterialDeviatoricCoefficient; - double CurrBulkModulus = this->mMaterialVolumetricCoefficient; - - double CurrFirstLame = 0; - CurrFirstLame = CurrBulkModulus - 2.0 * CurrSecondLame / 3.0; - - double DefX = rElementalVariables.SpatialDefRate[0]; - double DefY = rElementalVariables.SpatialDefRate[1]; - double DefZ = rElementalVariables.SpatialDefRate[2]; - double DefXY = rElementalVariables.SpatialDefRate[3]; - double DefXZ = rElementalVariables.SpatialDefRate[4]; - double DefYZ = rElementalVariables.SpatialDefRate[5]; - - double DefVol = rElementalVariables.VolumetricDefRate; - - double sigmaDev_xx = 2 * CurrSecondLame * (DefX - DefVol / 3.0); - double sigmaDev_yy = 2 * CurrSecondLame * (DefY - DefVol / 3.0); - double sigmaDev_zz = 2 * CurrSecondLame * (DefZ - DefVol / 3.0); - double sigmaDev_xy = 2 * CurrSecondLame * DefXY; - double sigmaDev_xz = 2 * CurrSecondLame * DefXZ; - double sigmaDev_yz = 2 * CurrSecondLame * DefYZ; - - double sigmaTot_xx = CurrFirstLame * DefVol + 2 * CurrSecondLame * DefX; - double sigmaTot_yy = CurrFirstLame * DefVol + 2 * CurrSecondLame * DefY; - double sigmaTot_zz = CurrFirstLame * DefVol + 2 * CurrSecondLame * DefZ; - double sigmaTot_xy = 2 * CurrSecondLame * DefXY; - double sigmaTot_xz = 2 * CurrSecondLame * DefXZ; - double sigmaTot_yz = 2 * CurrSecondLame * DefYZ; - - sigmaDev_xx += rElementalVariables.CurrentDeviatoricCauchyStress[0]; - sigmaDev_yy += rElementalVariables.CurrentDeviatoricCauchyStress[1]; - sigmaDev_zz += rElementalVariables.CurrentDeviatoricCauchyStress[2]; - sigmaDev_xy += rElementalVariables.CurrentDeviatoricCauchyStress[3]; - sigmaDev_xz += rElementalVariables.CurrentDeviatoricCauchyStress[4]; - sigmaDev_yz += rElementalVariables.CurrentDeviatoricCauchyStress[5]; - - sigmaTot_xx += rElementalVariables.CurrentTotalCauchyStress[0]; - sigmaTot_yy += rElementalVariables.CurrentTotalCauchyStress[1]; - sigmaTot_zz += rElementalVariables.CurrentTotalCauchyStress[2]; - sigmaTot_xy += rElementalVariables.CurrentTotalCauchyStress[3]; - sigmaTot_xz += rElementalVariables.CurrentTotalCauchyStress[4]; - sigmaTot_yz += rElementalVariables.CurrentTotalCauchyStress[5]; - - rElementalVariables.UpdatedDeviatoricCauchyStress[0] = sigmaDev_xx; - rElementalVariables.UpdatedDeviatoricCauchyStress[1] = sigmaDev_yy; - rElementalVariables.UpdatedDeviatoricCauchyStress[2] = sigmaDev_zz; - rElementalVariables.UpdatedDeviatoricCauchyStress[3] = sigmaDev_xy; - rElementalVariables.UpdatedDeviatoricCauchyStress[4] = sigmaDev_xz; - rElementalVariables.UpdatedDeviatoricCauchyStress[5] = sigmaDev_yz; - - rElementalVariables.UpdatedTotalCauchyStress[0] = sigmaTot_xx; - rElementalVariables.UpdatedTotalCauchyStress[1] = sigmaTot_yy; - rElementalVariables.UpdatedTotalCauchyStress[2] = sigmaTot_zz; - rElementalVariables.UpdatedTotalCauchyStress[3] = sigmaTot_xy; - rElementalVariables.UpdatedTotalCauchyStress[4] = sigmaTot_xz; - rElementalVariables.UpdatedTotalCauchyStress[5] = sigmaTot_yz; - - this->mCurrentTotalCauchyStress[g] = rElementalVariables.CurrentTotalCauchyStress; - this->mUpdatedTotalCauchyStress[g] = rElementalVariables.UpdatedTotalCauchyStress; - this->mCurrentDeviatoricCauchyStress[g] = rElementalVariables.CurrentDeviatoricCauchyStress; - this->mUpdatedDeviatoricCauchyStress[g] = rElementalVariables.UpdatedDeviatoricCauchyStress; +void UpdatedLagrangianVImplicitSolidElement<3>::CalcElasticPlasticCauchySplitted( + ElementalVariables &rElementalVariables, double TimeStep, unsigned int g) { + rElementalVariables.CurrentTotalCauchyStress = this->mCurrentTotalCauchyStress[g]; + rElementalVariables.CurrentDeviatoricCauchyStress = this->mCurrentDeviatoricCauchyStress[g]; + + double CurrSecondLame = this->mMaterialDeviatoricCoefficient; + double CurrBulkModulus = this->mMaterialVolumetricCoefficient; + + double CurrFirstLame = 0; + CurrFirstLame = CurrBulkModulus - 2.0 * CurrSecondLame / 3.0; + + double DefX = rElementalVariables.SpatialDefRate[0]; + double DefY = rElementalVariables.SpatialDefRate[1]; + double DefZ = rElementalVariables.SpatialDefRate[2]; + double DefXY = rElementalVariables.SpatialDefRate[3]; + double DefXZ = rElementalVariables.SpatialDefRate[4]; + double DefYZ = rElementalVariables.SpatialDefRate[5]; + + double DefVol = rElementalVariables.VolumetricDefRate; + + double sigmaDev_xx = 2 * CurrSecondLame * (DefX - DefVol / 3.0); + double sigmaDev_yy = 2 * CurrSecondLame * (DefY - DefVol / 3.0); + double sigmaDev_zz = 2 * CurrSecondLame * (DefZ - DefVol / 3.0); + double sigmaDev_xy = 2 * CurrSecondLame * DefXY; + double sigmaDev_xz = 2 * CurrSecondLame * DefXZ; + double sigmaDev_yz = 2 * CurrSecondLame * DefYZ; + + double sigmaTot_xx = CurrFirstLame * DefVol + 2 * CurrSecondLame * DefX; + double sigmaTot_yy = CurrFirstLame * DefVol + 2 * CurrSecondLame * DefY; + double sigmaTot_zz = CurrFirstLame * DefVol + 2 * CurrSecondLame * DefZ; + double sigmaTot_xy = 2 * CurrSecondLame * DefXY; + double sigmaTot_xz = 2 * CurrSecondLame * DefXZ; + double sigmaTot_yz = 2 * CurrSecondLame * DefYZ; + + sigmaDev_xx += rElementalVariables.CurrentDeviatoricCauchyStress[0]; + sigmaDev_yy += rElementalVariables.CurrentDeviatoricCauchyStress[1]; + sigmaDev_zz += rElementalVariables.CurrentDeviatoricCauchyStress[2]; + sigmaDev_xy += rElementalVariables.CurrentDeviatoricCauchyStress[3]; + sigmaDev_xz += rElementalVariables.CurrentDeviatoricCauchyStress[4]; + sigmaDev_yz += rElementalVariables.CurrentDeviatoricCauchyStress[5]; + + sigmaTot_xx += rElementalVariables.CurrentTotalCauchyStress[0]; + sigmaTot_yy += rElementalVariables.CurrentTotalCauchyStress[1]; + sigmaTot_zz += rElementalVariables.CurrentTotalCauchyStress[2]; + sigmaTot_xy += rElementalVariables.CurrentTotalCauchyStress[3]; + sigmaTot_xz += rElementalVariables.CurrentTotalCauchyStress[4]; + sigmaTot_yz += rElementalVariables.CurrentTotalCauchyStress[5]; + + rElementalVariables.UpdatedDeviatoricCauchyStress[0] = sigmaDev_xx; + rElementalVariables.UpdatedDeviatoricCauchyStress[1] = sigmaDev_yy; + rElementalVariables.UpdatedDeviatoricCauchyStress[2] = sigmaDev_zz; + rElementalVariables.UpdatedDeviatoricCauchyStress[3] = sigmaDev_xy; + rElementalVariables.UpdatedDeviatoricCauchyStress[4] = sigmaDev_xz; + rElementalVariables.UpdatedDeviatoricCauchyStress[5] = sigmaDev_yz; + + rElementalVariables.UpdatedTotalCauchyStress[0] = sigmaTot_xx; + rElementalVariables.UpdatedTotalCauchyStress[1] = sigmaTot_yy; + rElementalVariables.UpdatedTotalCauchyStress[2] = sigmaTot_zz; + rElementalVariables.UpdatedTotalCauchyStress[3] = sigmaTot_xy; + rElementalVariables.UpdatedTotalCauchyStress[4] = sigmaTot_xz; + rElementalVariables.UpdatedTotalCauchyStress[5] = sigmaTot_yz; + + this->mCurrentTotalCauchyStress[g] = rElementalVariables.CurrentTotalCauchyStress; + this->mUpdatedTotalCauchyStress[g] = rElementalVariables.UpdatedTotalCauchyStress; + this->mCurrentDeviatoricCauchyStress[g] = rElementalVariables.CurrentDeviatoricCauchyStress; + this->mUpdatedDeviatoricCauchyStress[g] = rElementalVariables.UpdatedDeviatoricCauchyStress; } template class UpdatedLagrangianVImplicitSolidElement<2>; From a1aa3db9318a839a9c6f4bfca23ef9216d69ab97 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Sun, 1 Mar 2020 18:16:19 +0100 Subject: [PATCH 10/47] Passing ProcessInfo to CalcElasticPlasticCauchySplitted --- ...pdated_lagrangian_V_P_implicit_element.cpp | 2 +- ..._updated_lagrangian_V_P_implicit_element.h | 5 ++-- ..._lagrangian_V_P_implicit_fluid_element.cpp | 4 +-- ...ed_lagrangian_V_P_implicit_fluid_element.h | 5 ++-- ..._lagrangian_V_P_implicit_solid_element.cpp | 6 ++-- ...ed_lagrangian_V_P_implicit_solid_element.h | 5 ++-- .../two_step_updated_lagrangian_element.h | 5 ++-- ...ed_lagrangian_V_implicit_solid_element.cpp | 4 +-- ...ated_lagrangian_V_implicit_solid_element.h | 29 +++++++++---------- 9 files changed, 30 insertions(+), 35 deletions(-) diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.cpp index 3cab186c60df..e0a33ac978e7 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.cpp @@ -123,7 +123,7 @@ void TwoStepUpdatedLagrangianVPImplicitElement::CalculateLocalMomentumEqua this->ComputeMaterialParameters(Density, DeviatoricCoeff, VolumetricCoeff, rCurrentProcessInfo, rElementalVariables); - this->CalcElasticPlasticCauchySplitted(rElementalVariables, TimeStep, g); + this->CalcElasticPlasticCauchySplitted(rElementalVariables, TimeStep, g, rCurrentProcessInfo); // std::vector rOutput; // this->GetElementalValueForOutput(YIELDED,rOutput); diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.h b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.h index 8ae0bc968a30..b7e71459c527 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.h +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.h @@ -427,9 +427,8 @@ class TwoStepUpdatedLagrangianVPImplicitElement : public TwoStepUpdatedLagrangia const ShapeFunctionDerivativesType &rShapeDeriv, const double Weight){}; - void CalcElasticPlasticCauchySplitted(ElementalVariables &rElementalVariables, - double TimeStep, - unsigned int g) override{}; + void CalcElasticPlasticCauchySplitted(ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, + const ProcessInfo &rCurrentProcessInfo) override{}; virtual void CalculateTauFIC(double &TauOne, double ElemSize, diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp index 9f800c1f6463..93f9c9939b76 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp @@ -1495,7 +1495,7 @@ void TwoStepUpdatedLagrangianVPImplicitFluidElement::InitializeElementalVa template <> void TwoStepUpdatedLagrangianVPImplicitFluidElement<2>::CalcElasticPlasticCauchySplitted( - ElementalVariables &rElementalVariables, double TimeStep, unsigned int g) { + ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, const ProcessInfo &rCurrentProcessInfo) { double CurrSecondLame = this->mMaterialDeviatoricCoefficient; double DefX = rElementalVariables.SpatialDefRate[0]; @@ -1522,7 +1522,7 @@ void TwoStepUpdatedLagrangianVPImplicitFluidElement<2>::CalcElasticPlasticCauchy template <> void TwoStepUpdatedLagrangianVPImplicitFluidElement<3>::CalcElasticPlasticCauchySplitted( - ElementalVariables &rElementalVariables, double TimeStep, unsigned int g) { + ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, const ProcessInfo &rCurrentProcessInfo) { double CurrSecondLame = this->mMaterialDeviatoricCoefficient; double DefX = rElementalVariables.SpatialDefRate[0]; diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.h b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.h index 491f3646f630..912fdf2b6843 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.h +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.h @@ -367,9 +367,8 @@ class TwoStepUpdatedLagrangianVPImplicitFluidElement : public TwoStepUpdatedLagr const ShapeFunctionDerivativesType &rShapeDeriv, const double Weight) override; - void CalcElasticPlasticCauchySplitted(ElementalVariables &rElementalVariables, - double TimeStep, - unsigned int g) override; + void CalcElasticPlasticCauchySplitted(ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, + const ProcessInfo &rCurrentProcessInfo) override; void CalculateTauFIC(double &TauOne, double ElemSize, diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp index 9e3deea3a57b..7b1d6f09719e 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp @@ -310,7 +310,7 @@ void TwoStepUpdatedLagrangianVPImplicitSolidElement::InitializeElementalVa template <> void TwoStepUpdatedLagrangianVPImplicitSolidElement<2>::CalcElasticPlasticCauchySplitted( - ElementalVariables &rElementalVariables, double TimeStep, unsigned int g) { + ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, const ProcessInfo &rCurrentProcessInfo) { rElementalVariables.CurrentTotalCauchyStress = this->mCurrentTotalCauchyStress[g]; rElementalVariables.CurrentDeviatoricCauchyStress = this->mCurrentDeviatoricCauchyStress[g]; @@ -348,7 +348,7 @@ void TwoStepUpdatedLagrangianVPImplicitSolidElement<2>::CalcElasticPlasticCauchy template <> void TwoStepUpdatedLagrangianVPImplicitSolidElement<3>::CalcElasticPlasticCauchySplitted( - ElementalVariables &rElementalVariables, double TimeStep, unsigned int g) { + ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, const ProcessInfo &rCurrentProcessInfo) { rElementalVariables.CurrentTotalCauchyStress = this->mCurrentTotalCauchyStress[g]; rElementalVariables.CurrentDeviatoricCauchyStress = this->mCurrentDeviatoricCauchyStress[g]; @@ -421,7 +421,7 @@ void TwoStepUpdatedLagrangianVPImplicitSolidElement::UpdateCauchyStress(un const double TimeStep = rCurrentProcessInfo[DELTA_TIME]; if (computeElement == true) { - this->CalcElasticPlasticCauchySplitted(rElementalVariables, TimeStep, g); + this->CalcElasticPlasticCauchySplitted(rElementalVariables, TimeStep, g, rCurrentProcessInfo); } this->mCurrentTotalCauchyStress[g] = this->mUpdatedTotalCauchyStress[g]; diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.h b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.h index acb492819479..a3d9d6c60f9d 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.h +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.h @@ -341,9 +341,8 @@ class TwoStepUpdatedLagrangianVPImplicitSolidElement : public TwoStepUpdatedLagr const double BoundRHSCoeffAcc, const double BoundRHSCoeffDev) override{}; - void CalcElasticPlasticCauchySplitted(ElementalVariables &rElementalVariables, - double TimeStep, - unsigned int g) override; + void CalcElasticPlasticCauchySplitted(ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, + const ProcessInfo &rCurrentProcessInfo) override; void CalculateLocalContinuityEqForPressure(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_element.h b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_element.h index 83eacc7df3ac..28c52ce9f97e 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_element.h +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_element.h @@ -571,9 +571,8 @@ class TwoStepUpdatedLagrangianElement : public Element bool CheckStrain3(VectorType &SpatialDefRate, MatrixType &SpatialVelocityGrad); - virtual void CalcElasticPlasticCauchySplitted(ElementalVariables &rElementalVariables, - double TimeStep, - unsigned int g){}; + virtual void CalcElasticPlasticCauchySplitted(ElementalVariables &rElementalVariables, double TimeStep, + unsigned int g, const ProcessInfo &rCurrentProcessInfo){}; /// Write the value of a variable at a point inside the element to a double /** diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/updated_lagrangian_V_implicit_solid_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/updated_lagrangian_V_implicit_solid_element.cpp index 427756e23e5d..b1e579d47a01 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/updated_lagrangian_V_implicit_solid_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/updated_lagrangian_V_implicit_solid_element.cpp @@ -69,7 +69,7 @@ Element::Pointer UpdatedLagrangianVImplicitSolidElement::Clone(IndexType N template <> void UpdatedLagrangianVImplicitSolidElement<2>::CalcElasticPlasticCauchySplitted( - ElementalVariables &rElementalVariables, double TimeStep, unsigned int g) { + ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, const ProcessInfo &rCurrentProcessInfo) { rElementalVariables.CurrentTotalCauchyStress = this->mCurrentTotalCauchyStress[g]; rElementalVariables.CurrentDeviatoricCauchyStress = this->mCurrentDeviatoricCauchyStress[g]; @@ -115,7 +115,7 @@ void UpdatedLagrangianVImplicitSolidElement<2>::CalcElasticPlasticCauchySplitted template <> void UpdatedLagrangianVImplicitSolidElement<3>::CalcElasticPlasticCauchySplitted( - ElementalVariables &rElementalVariables, double TimeStep, unsigned int g) { + ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, const ProcessInfo &rCurrentProcessInfo) { rElementalVariables.CurrentTotalCauchyStress = this->mCurrentTotalCauchyStress[g]; rElementalVariables.CurrentDeviatoricCauchyStress = this->mCurrentDeviatoricCauchyStress[g]; diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/updated_lagrangian_V_implicit_solid_element.h b/applications/PfemFluidDynamicsApplication/custom_elements/updated_lagrangian_V_implicit_solid_element.h index f8343331e752..085e80e356d2 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/updated_lagrangian_V_implicit_solid_element.h +++ b/applications/PfemFluidDynamicsApplication/custom_elements/updated_lagrangian_V_implicit_solid_element.h @@ -295,27 +295,26 @@ class UpdatedLagrangianVImplicitSolidElement : public TwoStepUpdatedLagrangianVP /* const ShapeFunctionDerivativesType& rDN_DX, */ /* unsigned int g); */ - void CalcElasticPlasticCauchySplitted(ElementalVariables &rElementalVariables, - double TimeStep, - unsigned int g) override; + void CalcElasticPlasticCauchySplitted(ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, + const ProcessInfo &rCurrentProcessInfo) override; - double GetThetaMomentum() override { return 1.0; }; + double GetThetaMomentum() override { return 1.0; }; - double GetThetaContinuity() override { return 1.0; }; + double GetThetaContinuity() override { return 1.0; }; - ///@} - ///@name Protected Access - ///@{ + ///@} + ///@name Protected Access + ///@{ - ///@} - ///@name Protected Inquiry - ///@{ + ///@} + ///@name Protected Inquiry + ///@{ - ///@} - ///@name Protected LifeCycle - ///@{ + ///@} + ///@name Protected LifeCycle + ///@{ - ///@} + ///@} private: ///@name Static Member Variables From 02c59a8ae79074b62102acf7dfbe4c1fa8a7fed6 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Sun, 1 Mar 2020 18:22:18 +0100 Subject: [PATCH 11/47] cleanup - behaviour not changed (IX) --- ...pdated_lagrangian_V_P_implicit_element.cpp | 31 ------------------- 1 file changed, 31 deletions(-) diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.cpp index e0a33ac978e7..8b52f2a4f7e9 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.cpp @@ -100,7 +100,6 @@ void TwoStepUpdatedLagrangianVPImplicitElement::CalculateLocalMomentumEqua double Density = 0.0; double DeviatoricCoeff = 0; double VolumetricCoeff = 0; - // this->ComputeMaterialParameters(Density,DeviatoricCoeff,VolumetricCoeff,TimeStep); // Loop on integration points for (unsigned int g = 0; g < NumGauss; g++) @@ -125,43 +124,13 @@ void TwoStepUpdatedLagrangianVPImplicitElement::CalculateLocalMomentumEqua this->CalcElasticPlasticCauchySplitted(rElementalVariables, TimeStep, g, rCurrentProcessInfo); - // std::vector rOutput; - // this->GetElementalValueForOutput(YIELDED,rOutput); - if (computeElement == true) { - // Add integration point contribution to the local mass matrix - // double DynamicWeight=GaussWeight*Density; - // this->ComputeMassMatrix(MassMatrix,N,DynamicWeight,MeanValueMass); - this->AddExternalForces(rRightHandSideVector, Density, N, GaussWeight); this->AddInternalForces(rRightHandSideVector, rDN_DX, rElementalVariables, GaussWeight); - // double lumpedDynamicWeight=GaussWeight*Density; - // this->ComputeLumpedMassMatrix(MassMatrix,lumpedDynamicWeight,MeanValueMass); - - // double MeanValueMaterial=0.0; - // this->ComputeMeanValueMaterialTangentMatrix(rElementalVariables,MeanValueMaterial,rDN_DX,DeviatoricCoeff,VolumetricCoeff,GaussWeight,MeanValueMass,TimeStep); - // double deviatoricCoeffTemp=DeviatoricCoeff; - // DeviatoricCoeff=0; - // // Add viscous term - // this->ComputeCompleteTangentTerm(rElementalVariables,rLeftHandSideMatrix,rDN_DX,DeviatoricCoeff,VolumetricCoeff,theta,GaussWeight); - - // double staticFrictionCoefficient=0.34; - // double dynamicFrictionCoefficient=0.6; - // double inertialNumberZero=0.279; - // double grainDiameter=0.001; - // double grainDensity=2500; - // double meanPressure=fabs(rElementalVariables.MeanPressure); - // double deltaFrictionCoefficient=dynamicFrictionCoefficient-staticFrictionCoefficient; - // double smallScale=grainDiameter/sqrt(meanPressure/grainDensity); - // double denominator=inertialNumberZero+rElementalVariables.EquivalentStrainRate*smallScale; - // if(meanPressure!=0 && rElementalVariables.EquivalentStrainRate!=0){ - // DeviatoricCoeff=inertialNumberZero*deltaFrictionCoefficient*meanPressure*smallScale/pow(denominator,2); - // } this->ComputeCompleteTangentTerm(rElementalVariables, StiffnessMatrix, rDN_DX, DeviatoricCoeff, VolumetricCoeff, theta, GaussWeight); - // DeviatoricCoeff=deviatoricCoeffTemp; } } From df1cbcb1f9c77fab1e2a9de96490975ef34bc3f4 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Sun, 1 Mar 2020 18:28:03 +0100 Subject: [PATCH 12/47] Removing ComputeMaterialParameters --- ...pdated_lagrangian_V_P_implicit_element.cpp | 2 -- ..._updated_lagrangian_V_P_implicit_element.h | 6 ---- ..._P_implicit_fluid_DEM_coupling_element.cpp | 31 ------------------- ..._V_P_implicit_fluid_DEM_coupling_element.h | 6 ---- ..._lagrangian_V_P_implicit_fluid_element.cpp | 31 ------------------- ...ed_lagrangian_V_P_implicit_fluid_element.h | 6 ---- ..._lagrangian_V_P_implicit_solid_element.cpp | 18 ----------- ...ed_lagrangian_V_P_implicit_solid_element.h | 6 ---- .../two_step_updated_lagrangian_element.h | 6 ---- 9 files changed, 112 deletions(-) diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.cpp index 8b52f2a4f7e9..75644adca252 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.cpp @@ -120,8 +120,6 @@ void TwoStepUpdatedLagrangianVPImplicitElement::CalculateLocalMomentumEqua bool computeElement = this->CalcMechanicsUpdated(rElementalVariables, rCurrentProcessInfo, rDN_DX, g); - this->ComputeMaterialParameters(Density, DeviatoricCoeff, VolumetricCoeff, rCurrentProcessInfo, rElementalVariables); - this->CalcElasticPlasticCauchySplitted(rElementalVariables, TimeStep, g, rCurrentProcessInfo); if (computeElement == true) diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.h b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.h index b7e71459c527..3ba62dbbb53e 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.h +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.h @@ -342,12 +342,6 @@ class TwoStepUpdatedLagrangianVPImplicitElement : public TwoStepUpdatedLagrangia VectorType &rRightHandSideVector, ProcessInfo &rCurrentProcessInfo) override{}; - void ComputeMaterialParameters(double &Density, - double &DeviatoricCoeff, - double &VolumetricCoeff, - ProcessInfo &rCurrentProcessInfo, - ElementalVariables &rElementalVariables) override{}; - void ComputeMaterialParametersGranularGas(double &Density, double &DeviatoricCoeff, double &VolumetricCoeff, diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_DEM_coupling_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_DEM_coupling_element.cpp index 915b4b9ae5ce..d3cc541224e8 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_DEM_coupling_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_DEM_coupling_element.cpp @@ -55,37 +55,6 @@ void TwoStepUpdatedLagrangianVPImplicitFluidDEMcouplingElement::Initialize KRATOS_CATCH(""); } -template -void TwoStepUpdatedLagrangianVPImplicitFluidDEMcouplingElement::ComputeMaterialParameters( - double &Density, double &DeviatoricCoeff, double &VolumetricCoeff, ProcessInfo ¤tProcessInfo, - ElementalVariables &rElementalVariables) { - double timeStep = currentProcessInfo[DELTA_TIME]; - - Density = this->GetProperties()[DENSITY]; - double FluidBulkModulus = this->GetProperties()[BULK_MODULUS]; - double FluidYieldShear = this->GetProperties()[YIELD_SHEAR]; - double staticFrictionCoefficient = this->GetProperties()[STATIC_FRICTION]; - - if (FluidBulkModulus == 0) { - FluidBulkModulus = 1000000000.0; - } - VolumetricCoeff = FluidBulkModulus * timeStep; - - if (FluidYieldShear != 0) { - // std::cout<<"For a Newtonian fluid I should not enter here"<ComputeNonLinearViscosity(rElementalVariables.EquivalentStrainRate); - } else if (staticFrictionCoefficient != 0) { - DeviatoricCoeff = this->ComputePapanastasiouMuIrheologyViscosity(rElementalVariables); - } else { - // std::cout<<"For a Newtonian fluid I should enter here"<GetProperties()[DYNAMIC_VISCOSITY]; - } - - this->mMaterialDeviatoricCoefficient = DeviatoricCoeff; - this->mMaterialVolumetricCoefficient = VolumetricCoeff; - this->mMaterialDensity = Density; -} - template int TwoStepUpdatedLagrangianVPImplicitFluidDEMcouplingElement::Check(const ProcessInfo &rCurrentProcessInfo) { diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_DEM_coupling_element.h b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_DEM_coupling_element.h index 2fc2110d484e..bf663cac895a 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_DEM_coupling_element.h +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_DEM_coupling_element.h @@ -289,12 +289,6 @@ class TwoStepUpdatedLagrangianVPImplicitFluidDEMcouplingElement : public TwoStep ///@name Protected Operations ///@{ - void ComputeMaterialParameters(double &Density, - double &DeviatoricCoeff, - double &VolumetricCoeff, - ProcessInfo &rCurrentProcessInfo, - ElementalVariables &rElementalVariables) override; - void ComputeBoundRHSVector(VectorType &BoundRHSVector, const ShapeFunctionsType &rN, const double TimeStep, diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp index 93f9c9939b76..a7b4bb363cf9 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp @@ -55,37 +55,6 @@ void TwoStepUpdatedLagrangianVPImplicitFluidElement::InitializeNonLinearIt KRATOS_CATCH(""); } -template -void TwoStepUpdatedLagrangianVPImplicitFluidElement::ComputeMaterialParameters( - double &Density, double &DeviatoricCoeff, double &VolumetricCoeff, ProcessInfo ¤tProcessInfo, - ElementalVariables &rElementalVariables) { - double timeStep = currentProcessInfo[DELTA_TIME]; - - Density = this->GetProperties()[DENSITY]; - double FluidBulkModulus = this->GetProperties()[BULK_MODULUS]; - double FluidYieldShear = this->GetProperties()[YIELD_SHEAR]; - double staticFrictionCoefficient = this->GetProperties()[STATIC_FRICTION]; - - if (FluidBulkModulus == 0) { - FluidBulkModulus = 1000000000.0; - } - VolumetricCoeff = FluidBulkModulus * timeStep; - - if (FluidYieldShear != 0) { - // std::cout<<"For a Newtonian fluid I should not enter here"<ComputeNonLinearViscosity(rElementalVariables.EquivalentStrainRate); - } else if (staticFrictionCoefficient != 0) { - DeviatoricCoeff = this->ComputePapanastasiouMuIrheologyViscosity(rElementalVariables); - } else { - // std::cout<<"For a Newtonian fluid I should enter here"<GetProperties()[DYNAMIC_VISCOSITY]; - } - - this->mMaterialDeviatoricCoefficient = DeviatoricCoeff; - this->mMaterialVolumetricCoefficient = VolumetricCoeff; - this->mMaterialDensity = Density; -} - template double TwoStepUpdatedLagrangianVPImplicitFluidElement::ComputeNonLinearViscosity(double &equivalentStrainRate) { diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.h b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.h index 912fdf2b6843..35a01a6a0276 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.h +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.h @@ -291,12 +291,6 @@ class TwoStepUpdatedLagrangianVPImplicitFluidElement : public TwoStepUpdatedLagr ///@name Protected Operations ///@{ - void ComputeMaterialParameters(double &Density, - double &DeviatoricCoeff, - double &VolumetricCoeff, - ProcessInfo &rCurrentProcessInfo, - ElementalVariables &rElementalVariables) override; - /** * A constistent mass matrix is used. * @param rMassMatrix The local matrix where the result will be added. diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp index 7b1d6f09719e..bc6bda0f29e1 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp @@ -126,24 +126,6 @@ void TwoStepUpdatedLagrangianVPImplicitSolidElement::InitializeNonLinearIt { } -template -void TwoStepUpdatedLagrangianVPImplicitSolidElement::ComputeMaterialParameters( - double &Density, double &DeviatoricCoeff, double &VolumetricCoeff, ProcessInfo ¤tProcessInfo, - ElementalVariables &rElementalVariables) { - Density = this->GetProperties()[DENSITY]; - double YoungModulus = this->GetProperties()[YOUNG_MODULUS]; - double PoissonRatio = this->GetProperties()[POISSON_RATIO]; - double timeStep = currentProcessInfo[DELTA_TIME]; - - DeviatoricCoeff = timeStep * YoungModulus / (1.0 + PoissonRatio) * 0.5; - VolumetricCoeff = timeStep * PoissonRatio * YoungModulus / ((1.0 + PoissonRatio) * (1.0 - 2.0 * PoissonRatio)) + - 2.0 * DeviatoricCoeff / 3.0; - - this->mMaterialDeviatoricCoefficient = DeviatoricCoeff; - this->mMaterialVolumetricCoefficient = VolumetricCoeff; - this->mMaterialDensity = Density; -} - template int TwoStepUpdatedLagrangianVPImplicitSolidElement::Check(const ProcessInfo &rCurrentProcessInfo) { diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.h b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.h index a3d9d6c60f9d..7af3d4c2c69b 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.h +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.h @@ -291,12 +291,6 @@ class TwoStepUpdatedLagrangianVPImplicitSolidElement : public TwoStepUpdatedLagr ///@name Protected Operations ///@{ - void ComputeMaterialParameters(double &Density, - double &DeviatoricCoeff, - double &VolumetricCoeff, - ProcessInfo &rCurrentProcessInfo, - ElementalVariables &rElementalVariables) override; - /// Add integration point contribution to the mass matrix. /** * A constistent mass matrix is used. diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_element.h b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_element.h index 28c52ce9f97e..bf2774f78f8f 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_element.h +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_element.h @@ -358,12 +358,6 @@ class TwoStepUpdatedLagrangianElement : public Element VectorType &rRightHandSideVector, ProcessInfo &rCurrentProcessInfo){}; - virtual void ComputeMaterialParameters(double &Density, - double &DeviatoricCoeff, - double &VolumetricCoeff, - ProcessInfo &rCurrentProcessInfo, - ElementalVariables &rElementalVariables){}; - virtual void ComputeMaterialParametersGranularGas(double &Density, double &DeviatoricCoeff, double &VolumetricCoeff, From 34aab0fad1b26b19c76dfbd777aced58472c7185 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Sun, 1 Mar 2020 18:33:12 +0100 Subject: [PATCH 13/47] Removing CLaws from the fluid element --- ..._lagrangian_V_P_implicit_fluid_element.cpp | 260 ------------------ ...ed_lagrangian_V_P_implicit_fluid_element.h | 12 - 2 files changed, 272 deletions(-) diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp index a7b4bb363cf9..9498bf123156 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp @@ -55,26 +55,6 @@ void TwoStepUpdatedLagrangianVPImplicitFluidElement::InitializeNonLinearIt KRATOS_CATCH(""); } -template -double TwoStepUpdatedLagrangianVPImplicitFluidElement::ComputeNonLinearViscosity(double &equivalentStrainRate) -{ - - double FluidViscosity = this->GetProperties()[DYNAMIC_VISCOSITY]; - double FluidYieldShear = this->GetProperties()[YIELD_SHEAR]; - double FluidAdaptiveExponent = this->GetProperties()[ADAPTIVE_EXPONENT]; - double exponent = -FluidAdaptiveExponent * equivalentStrainRate; - if (equivalentStrainRate != 0) - { - FluidViscosity += (FluidYieldShear / equivalentStrainRate) * (1 - exp(exponent)); - } - if (equivalentStrainRate < 0.00001 && FluidYieldShear != 0 && FluidAdaptiveExponent != 0) - { - // for gamma_dot very small the limit of the Papanastasiou viscosity is mu=m*tau_yield - FluidViscosity = FluidAdaptiveExponent * FluidYieldShear; - } - return FluidViscosity; -} - template void TwoStepUpdatedLagrangianVPImplicitFluidElement::ComputeMaterialParametersGranularGas(double &Density, double &DeviatoricCoeff, @@ -156,246 +136,6 @@ void TwoStepUpdatedLagrangianVPImplicitFluidElement::ComputeMaterialParame rElementalVariables.UpdatedTotalCauchyStress[2] = DeviatoricCoeff * rElementalVariables.SpatialDefRate[2]; } -template -double TwoStepUpdatedLagrangianVPImplicitFluidElement::ComputeJopMuIrheologyViscosity(ElementalVariables &rElementalVariables) -{ - double FluidViscosity = 0; - - double staticFrictionCoefficient = this->GetProperties()[STATIC_FRICTION]; - double dynamicFrictionCoefficient = this->GetProperties()[DYNAMIC_FRICTION]; - double inertialNumberZero = this->GetProperties()[INERTIAL_NUMBER_ZERO]; - double grainDiameter = this->GetProperties()[GRAIN_DIAMETER]; - double grainDensity = this->GetProperties()[GRAIN_DENSITY]; - - double meanPressure = rElementalVariables.MeanPressure; - if (meanPressure > 0) - { - meanPressure = 0.0000001; - } - - double deltaFrictionCoefficient = dynamicFrictionCoefficient - staticFrictionCoefficient; - double inertialNumber = 0; - if (meanPressure != 0) - { - inertialNumber = rElementalVariables.EquivalentStrainRate * grainDiameter / sqrt(fabs(meanPressure) / grainDensity); - } - // double inertialNumber=rElementalVariables.EquivalentStrainRate*grainDiameter/sqrt(fabs(rElementalVariables.MeanPressure)/grainDensity); - - if (rElementalVariables.EquivalentStrainRate != 0 && fabs(meanPressure) != 0) - { - double firstViscousTerm = staticFrictionCoefficient / rElementalVariables.EquivalentStrainRate; - double secondViscousTerm = deltaFrictionCoefficient * inertialNumber / ((inertialNumberZero + inertialNumber) * rElementalVariables.EquivalentStrainRate); - FluidViscosity = (firstViscousTerm + secondViscousTerm) * fabs(meanPressure); - } - else - { - FluidViscosity = 1.0; - } - return FluidViscosity; -} - -template -double TwoStepUpdatedLagrangianVPImplicitFluidElement::ComputeBercovierMuIrheologyViscosity(ElementalVariables &rElementalVariables) -{ - double FluidViscosity = 0; - double staticFrictionCoefficient = this->GetProperties()[STATIC_FRICTION]; - double dynamicFrictionCoefficient = this->GetProperties()[DYNAMIC_FRICTION]; - double inertialNumberZero = this->GetProperties()[INERTIAL_NUMBER_ZERO]; - double grainDiameter = this->GetProperties()[GRAIN_DIAMETER]; - double grainDensity = this->GetProperties()[GRAIN_DENSITY]; - double regularizationCoefficient = this->GetProperties()[REGULARIZATION_COEFFICIENT]; - - double meanPressure = rElementalVariables.MeanPressure; - if (meanPressure > 0) - { - meanPressure = 0.0000001; - } - - double deltaFrictionCoefficient = dynamicFrictionCoefficient - staticFrictionCoefficient; - double inertialNumber = 0; - if (meanPressure != 0) - { - inertialNumber = rElementalVariables.EquivalentStrainRate * grainDiameter / sqrt(fabs(meanPressure) / grainDensity); - } - - if (rElementalVariables.EquivalentStrainRate != 0 && fabs(meanPressure) != 0) - { - double firstViscousTerm = staticFrictionCoefficient / sqrt(pow(rElementalVariables.EquivalentStrainRate, 2) + pow(regularizationCoefficient, 2)); - double secondViscousTerm = deltaFrictionCoefficient * inertialNumber / ((inertialNumberZero + inertialNumber) * rElementalVariables.EquivalentStrainRate); - FluidViscosity = (firstViscousTerm + secondViscousTerm) * fabs(meanPressure); - } - else - { - FluidViscosity = 1.0; - } - - return FluidViscosity; -} - -template -double TwoStepUpdatedLagrangianVPImplicitFluidElement::ComputePapanastasiouMuIrheologyViscosity(ElementalVariables &rElementalVariables) -{ - double FluidViscosity = 0; - double staticFrictionCoefficient = this->GetProperties()[STATIC_FRICTION]; - double dynamicFrictionCoefficient = this->GetProperties()[DYNAMIC_FRICTION]; - double inertialNumberZero = this->GetProperties()[INERTIAL_NUMBER_ZERO]; - double grainDiameter = this->GetProperties()[GRAIN_DIAMETER]; - double grainDensity = this->GetProperties()[GRAIN_DENSITY]; - double regularizationCoefficient = this->GetProperties()[REGULARIZATION_COEFFICIENT]; - - double pressure = rElementalVariables.MeanPressure; - if (pressure > 0) - { - pressure = 0.0000001; - } - - double deltaFrictionCoefficient = dynamicFrictionCoefficient - staticFrictionCoefficient; - double inertialNumber = 0; - if (rElementalVariables.MeanPressure != 0) - { - inertialNumber = rElementalVariables.EquivalentStrainRate * grainDiameter / sqrt(fabs(pressure) / grainDensity); - } - - double exponent = -rElementalVariables.EquivalentStrainRate / regularizationCoefficient; - - if (rElementalVariables.EquivalentStrainRate != 0 && fabs(pressure) != 0) - { - double firstViscousTerm = staticFrictionCoefficient * (1 - exp(exponent)) / rElementalVariables.EquivalentStrainRate; - double secondViscousTerm = deltaFrictionCoefficient * inertialNumber / ((inertialNumberZero + inertialNumber) * rElementalVariables.EquivalentStrainRate); - FluidViscosity = (firstViscousTerm + secondViscousTerm) * fabs(pressure); - } - else - { - FluidViscosity = 1.0; - } - - // const SizeType NumNodes = this->GetGeometry().PointsNumber(); - // for (SizeType i = 0; i < NumNodes; ++i) - // { - // this->GetGeometry()[i].FastGetSolutionStepValue(FLOW_INDEX)=FluidViscosity; - // this->GetGeometry()[i].FastGetSolutionStepValue(ADAPTIVE_EXPONENT)=rElementalVariables.EquivalentStrainRate; - // this->GetGeometry()[i].FastGetSolutionStepValue(ALPHA_PARAMETER)=inertialNumber; - // // std::cout<<"FluidViscosity "< -double TwoStepUpdatedLagrangianVPImplicitFluidElement::ComputeBarkerMuIrheologyViscosity(ElementalVariables &rElementalVariables) -{ - double FluidViscosity = 0; - double staticFrictionCoefficient = this->GetProperties()[STATIC_FRICTION]; - double dynamicFrictionCoefficient = this->GetProperties()[DYNAMIC_FRICTION]; - double inertialNumberZero = this->GetProperties()[INERTIAL_NUMBER_ZERO]; - double grainDiameter = this->GetProperties()[GRAIN_DIAMETER]; - double grainDensity = this->GetProperties()[GRAIN_DENSITY]; - double inertialNumberThreshold = this->GetProperties()[INERTIAL_NUMBER_ONE]; - double infiniteFrictionCoefficient = this->GetProperties()[INFINITE_FRICTION]; - double alphaParameter = this->GetProperties()[ALPHA_PARAMETER]; - - double meanPressure = rElementalVariables.MeanPressure; - if (meanPressure > 0) - { - meanPressure = 0.0000001; - } - - double inertialNumber = 0; - if (meanPressure != 0) - { - inertialNumber = rElementalVariables.EquivalentStrainRate * grainDiameter / sqrt(fabs(meanPressure) / grainDensity); - } - - if (inertialNumber > inertialNumberThreshold) - { - FluidViscosity = (staticFrictionCoefficient * inertialNumberZero + dynamicFrictionCoefficient * inertialNumber + infiniteFrictionCoefficient * pow(inertialNumber, 2)) / (inertialNumberZero + inertialNumber); - } - else - { - double denominator = staticFrictionCoefficient * inertialNumberZero + dynamicFrictionCoefficient * inertialNumberThreshold + infiniteFrictionCoefficient * pow(inertialNumberThreshold, 2); - double exponent = alphaParameter * (inertialNumberZero + inertialNumberThreshold) * (inertialNumberZero + inertialNumberThreshold) / pow(denominator, 2); - double firstAconstant = inertialNumberThreshold * exp(exponent); - FluidViscosity = sqrt(alphaParameter / log(firstAconstant / inertialNumber)); - } - - if (rElementalVariables.EquivalentStrainRate != 0 && fabs(meanPressure) != 0) - { - FluidViscosity *= fabs(meanPressure) / rElementalVariables.EquivalentStrainRate; - } - else - { - FluidViscosity = 1.0; - } - return FluidViscosity; -} - -template -double TwoStepUpdatedLagrangianVPImplicitFluidElement::ComputeBarkerBercovierMuIrheologyViscosity(ElementalVariables &rElementalVariables) -{ - - double FluidViscosity = 0; - - double staticFrictionCoefficient = this->GetProperties()[STATIC_FRICTION]; - double dynamicFrictionCoefficient = this->GetProperties()[DYNAMIC_FRICTION]; - double inertialNumberZero = this->GetProperties()[INERTIAL_NUMBER_ZERO]; - double grainDiameter = this->GetProperties()[GRAIN_DIAMETER]; - double grainDensity = this->GetProperties()[GRAIN_DENSITY]; - double inertialNumberThreshold = this->GetProperties()[INERTIAL_NUMBER_ONE]; - double infiniteFrictionCoefficient = this->GetProperties()[INFINITE_FRICTION]; - double alphaParameter = this->GetProperties()[ALPHA_PARAMETER]; - double regularizationCoefficient = this->GetProperties()[REGULARIZATION_COEFFICIENT]; - - double meanPressure = rElementalVariables.MeanPressure; - if (meanPressure > 0) - { - meanPressure = 0.0000001; - } - - double inertialNumber = 0; - if (meanPressure != 0) - { - inertialNumber = rElementalVariables.EquivalentStrainRate * grainDiameter / sqrt(fabs(meanPressure) / grainDensity); - } - - if (inertialNumber > inertialNumberThreshold) - { - double deltaFrictionCoefficient = dynamicFrictionCoefficient - staticFrictionCoefficient; - double firstViscousTerm = staticFrictionCoefficient; - double secondViscousTerm = deltaFrictionCoefficient * inertialNumber / (inertialNumberZero + inertialNumber); - FluidViscosity = (firstViscousTerm + secondViscousTerm); - } - else - { - double denominator = staticFrictionCoefficient * inertialNumberZero + dynamicFrictionCoefficient * inertialNumberThreshold + infiniteFrictionCoefficient * pow(inertialNumberThreshold, 2); - double exponent = alphaParameter * (inertialNumberZero + inertialNumberThreshold) * (inertialNumberZero + inertialNumberThreshold) / pow(denominator, 2); - double firstAconstant = inertialNumberThreshold * exp(exponent); - FluidViscosity = sqrt(alphaParameter / log(firstAconstant / inertialNumber)); - } - - if (rElementalVariables.EquivalentStrainRate != 0 && fabs(meanPressure) != 0) - { - double exponent = -rElementalVariables.EquivalentStrainRate / regularizationCoefficient; - FluidViscosity *= fabs(meanPressure) * (1 - exp(exponent)) / rElementalVariables.EquivalentStrainRate; - } - else - { - if (meanPressure == 0 && rElementalVariables.EquivalentStrainRate != 0) - { - FluidViscosity *= 1.0 / sqrt(pow(rElementalVariables.EquivalentStrainRate, 2) + pow(regularizationCoefficient, 2)); - } - else if (meanPressure != 0 && rElementalVariables.EquivalentStrainRate == 0) - { - FluidViscosity *= fabs(meanPressure) / sqrt(0.001 + pow(regularizationCoefficient, 2)); - } - else - { - FluidViscosity = 1.0; - } - } - - return FluidViscosity; -} - template int TwoStepUpdatedLagrangianVPImplicitFluidElement::Check(const ProcessInfo &rCurrentProcessInfo) { diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.h b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.h index 35a01a6a0276..1c9b0ccbe453 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.h +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.h @@ -313,24 +313,12 @@ class TwoStepUpdatedLagrangianVPImplicitFluidElement : public TwoStepUpdatedLagr double &bulkCoefficient, double timeStep) override; - double ComputeNonLinearViscosity(double &equivalentStrainRate); - void ComputeMaterialParametersGranularGas(double &Density, double &DeviatoricCoeff, double &VolumetricCoeff, ProcessInfo &rCurrentProcessInfo, ElementalVariables &rElementalVariables) override; - double ComputeJopMuIrheologyViscosity(ElementalVariables &rElementalVariables); - - double ComputeBercovierMuIrheologyViscosity(ElementalVariables &rElementalVariables); - - double ComputePapanastasiouMuIrheologyViscosity(ElementalVariables &rElementalVariables); - - double ComputeBarkerMuIrheologyViscosity(ElementalVariables &rElementalVariables); - - double ComputeBarkerBercovierMuIrheologyViscosity(ElementalVariables &rElementalVariables); - void ComputeBulkMatrixLump(MatrixType &BulkMatrix, const double Weight) override; From 592c7943bc56d1245d4fd5d30e0ad9b3832ce9db Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Mon, 2 Mar 2020 09:05:59 +0100 Subject: [PATCH 14/47] Add ConstitutiveMatrix to ElementalVariables --- ...two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp | 2 ++ ...grangian_V_P_implicit_nodally_integrated_fluid_element.cpp | 4 ++-- ...grangian_V_P_implicit_nodally_integrated_solid_element.cpp | 2 +- ...two_step_updated_lagrangian_V_P_implicit_solid_element.cpp | 2 +- .../custom_elements/two_step_updated_lagrangian_element.h | 1 + 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp index 9498bf123156..afffe46a73a7 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp @@ -1163,6 +1163,8 @@ void TwoStepUpdatedLagrangianVPImplicitFluidElement::InitializeElementalVa } rElementalVariables.voigtsize = voigtsize; + rElementalVariables.ConstitutiveMatrix = ZeroMatrix(voigtsize, voigtsize); + rElementalVariables.DetFgrad = 1.0; rElementalVariables.DetFgradVel = 1.0; diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_nodally_integrated_fluid_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_nodally_integrated_fluid_element.cpp index c017a45de781..dc2461fb15fd 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_nodally_integrated_fluid_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_nodally_integrated_fluid_element.cpp @@ -20,7 +20,7 @@ namespace Kratos { -/* +/* * public TwoStepUpdatedLagrangianVPImplicitNodallyIntegratedFluidElement functions */ @@ -121,7 +121,7 @@ void TwoStepUpdatedLagrangianVPImplicitNodallyIntegratedFluidElement::Init voigtsize = 6; } rElementalVariables.voigtsize = voigtsize; - + rElementalVariables.ConstitutiveMatrix = ZeroMatrix(voigtsize, voigtsize); rElementalVariables.DetFgrad = 1.0; rElementalVariables.DetFgradVel = 1.0; rElementalVariables.DeviatoricInvariant = 1.0; diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_nodally_integrated_solid_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_nodally_integrated_solid_element.cpp index 9a5914aa3944..2c20b5363404 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_nodally_integrated_solid_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_nodally_integrated_solid_element.cpp @@ -192,7 +192,7 @@ void TwoStepUpdatedLagrangianVPImplicitNodallyIntegratedSolidElement::Init voigtsize = 6; } rElementalVariables.voigtsize = voigtsize; - + rElementalVariables.ConstitutiveMatrix = ZeroMatrix(voigtsize, voigtsize); rElementalVariables.DetFgrad = 1; rElementalVariables.DetFgradVel = 1; rElementalVariables.DeviatoricInvariant = 1; diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp index bc6bda0f29e1..3f0e89148319 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp @@ -269,7 +269,7 @@ void TwoStepUpdatedLagrangianVPImplicitSolidElement::InitializeElementalVa voigtsize = 6; } rElementalVariables.voigtsize = voigtsize; - + rElementalVariables.ConstitutiveMatrix = ZeroMatrix(voigtsize, voigtsize); rElementalVariables.DetFgrad = 1; rElementalVariables.DetFgradVel = 1; rElementalVariables.DeviatoricInvariant = 1; diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_element.h b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_element.h index bf2774f78f8f..cb6505276127 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_element.h +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_element.h @@ -85,6 +85,7 @@ class TwoStepUpdatedLagrangianElement : public Element MatrixType FgradVel; MatrixType InvFgradVel; MatrixType SpatialVelocityGrad; + MatrixType ConstitutiveMatrix; // Stress state double MeanPressure; VectorType CurrentTotalCauchyStress; From c545bdbbecad61c300950250d98c218ca0a21d9e Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Mon, 2 Mar 2020 09:43:54 +0100 Subject: [PATCH 15/47] Passing Density Volumetric Deviatoric coeff to ElasticPlasticCauchy (I) --- ..._updated_lagrangian_V_P_implicit_element.cpp | 3 ++- ...ep_updated_lagrangian_V_P_implicit_element.h | 3 ++- ...ed_lagrangian_V_P_implicit_fluid_element.cpp | 8 ++++++-- ...ated_lagrangian_V_P_implicit_fluid_element.h | 3 ++- ...ed_lagrangian_V_P_implicit_solid_element.cpp | 17 ++++++++++++----- ...ated_lagrangian_V_P_implicit_solid_element.h | 3 ++- .../two_step_updated_lagrangian_element.h | 3 ++- 7 files changed, 28 insertions(+), 12 deletions(-) diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.cpp index 75644adca252..ec8bf9e0486b 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.cpp @@ -120,7 +120,8 @@ void TwoStepUpdatedLagrangianVPImplicitElement::CalculateLocalMomentumEqua bool computeElement = this->CalcMechanicsUpdated(rElementalVariables, rCurrentProcessInfo, rDN_DX, g); - this->CalcElasticPlasticCauchySplitted(rElementalVariables, TimeStep, g, rCurrentProcessInfo); + this->CalcElasticPlasticCauchySplitted(rElementalVariables, TimeStep, g, rCurrentProcessInfo, Density, + DeviatoricCoeff, VolumetricCoeff); if (computeElement == true) { diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.h b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.h index 3ba62dbbb53e..1e3e5beac710 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.h +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.h @@ -422,7 +422,8 @@ class TwoStepUpdatedLagrangianVPImplicitElement : public TwoStepUpdatedLagrangia const double Weight){}; void CalcElasticPlasticCauchySplitted(ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, - const ProcessInfo &rCurrentProcessInfo) override{}; + const ProcessInfo &rCurrentProcessInfo, double &Density, + double &DeviatoricCoeff, double &VolumetricCoeff) override{}; virtual void CalculateTauFIC(double &TauOne, double ElemSize, diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp index afffe46a73a7..effabfc77bde 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp @@ -1206,7 +1206,9 @@ void TwoStepUpdatedLagrangianVPImplicitFluidElement::InitializeElementalVa template <> void TwoStepUpdatedLagrangianVPImplicitFluidElement<2>::CalcElasticPlasticCauchySplitted( - ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, const ProcessInfo &rCurrentProcessInfo) { + ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, const ProcessInfo &rCurrentProcessInfo, + double &Density, double &DeviatoricCoeff, double &VolumetricCoeff) { + double CurrSecondLame = this->mMaterialDeviatoricCoefficient; double DefX = rElementalVariables.SpatialDefRate[0]; @@ -1233,7 +1235,9 @@ void TwoStepUpdatedLagrangianVPImplicitFluidElement<2>::CalcElasticPlasticCauchy template <> void TwoStepUpdatedLagrangianVPImplicitFluidElement<3>::CalcElasticPlasticCauchySplitted( - ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, const ProcessInfo &rCurrentProcessInfo) { + ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, const ProcessInfo &rCurrentProcessInfo, + double &Density, double &DeviatoricCoeff, double &VolumetricCoeff) { + double CurrSecondLame = this->mMaterialDeviatoricCoefficient; double DefX = rElementalVariables.SpatialDefRate[0]; diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.h b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.h index 1c9b0ccbe453..e9a18e5a5548 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.h +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.h @@ -350,7 +350,8 @@ class TwoStepUpdatedLagrangianVPImplicitFluidElement : public TwoStepUpdatedLagr const double Weight) override; void CalcElasticPlasticCauchySplitted(ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, - const ProcessInfo &rCurrentProcessInfo) override; + const ProcessInfo &rCurrentProcessInfo, double &Density, + double &DeviatoricCoeff, double &VolumetricCoeff) override; void CalculateTauFIC(double &TauOne, double ElemSize, diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp index 3f0e89148319..ff69e2a642df 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp @@ -292,7 +292,9 @@ void TwoStepUpdatedLagrangianVPImplicitSolidElement::InitializeElementalVa template <> void TwoStepUpdatedLagrangianVPImplicitSolidElement<2>::CalcElasticPlasticCauchySplitted( - ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, const ProcessInfo &rCurrentProcessInfo) { + ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, const ProcessInfo &rCurrentProcessInfo, + double &Density, double &DeviatoricCoeff, double &VolumetricCoeff) { + rElementalVariables.CurrentTotalCauchyStress = this->mCurrentTotalCauchyStress[g]; rElementalVariables.CurrentDeviatoricCauchyStress = this->mCurrentDeviatoricCauchyStress[g]; @@ -330,7 +332,9 @@ void TwoStepUpdatedLagrangianVPImplicitSolidElement<2>::CalcElasticPlasticCauchy template <> void TwoStepUpdatedLagrangianVPImplicitSolidElement<3>::CalcElasticPlasticCauchySplitted( - ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, const ProcessInfo &rCurrentProcessInfo) { + ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, const ProcessInfo &rCurrentProcessInfo, + double &Density, double &DeviatoricCoeff, double &VolumetricCoeff) { + rElementalVariables.CurrentTotalCauchyStress = this->mCurrentTotalCauchyStress[g]; rElementalVariables.CurrentDeviatoricCauchyStress = this->mCurrentDeviatoricCauchyStress[g]; @@ -401,9 +405,12 @@ void TwoStepUpdatedLagrangianVPImplicitSolidElement::UpdateCauchyStress(un // bool computeElement=this->CalcStrainRate(rElementalVariables,rCurrentProcessInfo,rDN_DX,theta); bool computeElement = this->CalcCompleteStrainRate(rElementalVariables, rCurrentProcessInfo, rDN_DX, theta); const double TimeStep = rCurrentProcessInfo[DELTA_TIME]; - if (computeElement == true) - { - this->CalcElasticPlasticCauchySplitted(rElementalVariables, TimeStep, g, rCurrentProcessInfo); + double Density = 0; + double DeviatoricCoeff = 0; + double VolumetricCoeff = 0; + if (computeElement == true) { + this->CalcElasticPlasticCauchySplitted(rElementalVariables, TimeStep, g, rCurrentProcessInfo, Density, + DeviatoricCoeff, VolumetricCoeff); } this->mCurrentTotalCauchyStress[g] = this->mUpdatedTotalCauchyStress[g]; diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.h b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.h index 7af3d4c2c69b..1d4da974fcac 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.h +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.h @@ -336,7 +336,8 @@ class TwoStepUpdatedLagrangianVPImplicitSolidElement : public TwoStepUpdatedLagr const double BoundRHSCoeffDev) override{}; void CalcElasticPlasticCauchySplitted(ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, - const ProcessInfo &rCurrentProcessInfo) override; + const ProcessInfo &rCurrentProcessInfo, double &Density, + double &DeviatoricCoeff, double &VolumetricCoeff) override; void CalculateLocalContinuityEqForPressure(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_element.h b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_element.h index cb6505276127..283772c30a7d 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_element.h +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_element.h @@ -567,7 +567,8 @@ class TwoStepUpdatedLagrangianElement : public Element MatrixType &SpatialVelocityGrad); virtual void CalcElasticPlasticCauchySplitted(ElementalVariables &rElementalVariables, double TimeStep, - unsigned int g, const ProcessInfo &rCurrentProcessInfo){}; + unsigned int g, const ProcessInfo &rCurrentProcessInfo, double &Density, + double &DeviatoricCoeff, double &VolumetricCoeff){}; /// Write the value of a variable at a point inside the element to a double /** From e652853fad0dc9085b9430d36d5af6cff94cdefb Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Mon, 2 Mar 2020 17:07:47 +0100 Subject: [PATCH 16/47] Cloning the CLaw after the element in DelaunayApp --- .../custom_utilities/mesh_data_transfer_utilities.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/applications/DelaunayMeshingApplication/custom_utilities/mesh_data_transfer_utilities.cpp b/applications/DelaunayMeshingApplication/custom_utilities/mesh_data_transfer_utilities.cpp index bb7e59167473..10222e000884 100644 --- a/applications/DelaunayMeshingApplication/custom_utilities/mesh_data_transfer_utilities.cpp +++ b/applications/DelaunayMeshingApplication/custom_utilities/mesh_data_transfer_utilities.cpp @@ -1348,6 +1348,13 @@ void MeshDataTransferUtilities::TransferElementalValuesToElements(ModelPart& rMo new_element->SetProperties(pElemNewProp); } + // Clone the constitutive law + const PropertiesType& rProperties = new_element->GetProperties(); + if (rProperties.Has(CONSTITUTIVE_LAW)) { + const ConstitutiveLaw::Pointer& pConstitutiveLaw = rProperties[CONSTITUTIVE_LAW]; + new_element->SetValue(CONSTITUTIVE_LAW, pConstitutiveLaw->Clone()); + } + //check //new_element->PrintInfo(std::cout); From 2a3b9dbfe2bdf2edc761c265d2746114197f6197 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Mon, 2 Mar 2020 17:09:03 +0100 Subject: [PATCH 17/47] Adding CLaws to CMakeLists.txt --- .../CMakeLists.txt | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/applications/PfemFluidDynamicsApplication/CMakeLists.txt b/applications/PfemFluidDynamicsApplication/CMakeLists.txt index c371c49a90a1..581a095e339d 100755 --- a/applications/PfemFluidDynamicsApplication/CMakeLists.txt +++ b/applications/PfemFluidDynamicsApplication/CMakeLists.txt @@ -38,6 +38,24 @@ set( KRATOS_PFEM_FLUID_DYNAMICS_APPLICATION_CORE ${CMAKE_CURRENT_SOURCE_DIR}/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp ${CMAKE_CURRENT_SOURCE_DIR}/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_DEM_coupling_element.cpp ${CMAKE_CURRENT_SOURCE_DIR}/custom_processes/assign_scalar_variable_to_pfem_entities_process.cpp + + # Fluid constitutive laws + ${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/fluid_laws/fluid_constitutive_law.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/fluid_laws/bingham_2D_law.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/fluid_laws/bingham_3D_law.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/fluid_laws/newtonian_2D_law.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/fluid_laws/newtonian_3D_law.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/fluid_laws/papanastasiou_mu_I_rheology_2D_law.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/fluid_laws/papanastasiou_mu_I_rheology_3D_law.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/fluid_laws/barker_mu_I_rheology_3D_law.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/fluid_laws/bercovier_mu_I_rheology_3D_law.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/fluid_laws/barker_bercovier_mu_I_rheology_3D_law.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/fluid_laws/jop_mu_I_rheology_3D_law.cpp + + # Solid constitutive laws + ${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/solid_laws/solid_constitutive_law.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/solid_laws/hypoelastic_2D_law.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/solid_laws/hypoelastic_3D_law.cpp ) set( KRATOS_PFEM_FLUID_DYNAMICS_APPLICATION_PYTHON_INTERFACE @@ -102,4 +120,4 @@ endif(${INSTALL_TESTING_FILES} MATCHES ON) # Install targets install(TARGETS KratosPfemFluidDynamicsCore DESTINATION libs ) -install(TARGETS KratosPfemFluidDynamicsApplication DESTINATION libs ) \ No newline at end of file +install(TARGETS KratosPfemFluidDynamicsApplication DESTINATION libs ) From fb2a8c755dbfd8626ace7540ed7a541d65bd1096 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Mon, 2 Mar 2020 17:10:04 +0100 Subject: [PATCH 18/47] Registering CLaws in pfem_fluid_dynamics_application.cpp --- .../pfem_fluid_dynamics_application.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/applications/PfemFluidDynamicsApplication/pfem_fluid_dynamics_application.cpp b/applications/PfemFluidDynamicsApplication/pfem_fluid_dynamics_application.cpp index c84b289a16ec..4ed67bed3fc1 100644 --- a/applications/PfemFluidDynamicsApplication/pfem_fluid_dynamics_application.cpp +++ b/applications/PfemFluidDynamicsApplication/pfem_fluid_dynamics_application.cpp @@ -215,7 +215,21 @@ void KratosPfemFluidDynamicsApplication::Register() //Register Conditions - //Register Constitutive Laws + //Register Fluid Constitutive Laws + KRATOS_REGISTER_CONSTITUTIVE_LAW("Bingham2DLaw", mBingham2DLaw); + KRATOS_REGISTER_CONSTITUTIVE_LAW("Bingham3DLaw", mBingham3DLaw); + KRATOS_REGISTER_CONSTITUTIVE_LAW("Newtonian2DLaw", mNewtonian2DLaw); + KRATOS_REGISTER_CONSTITUTIVE_LAW("Newtonian3DLaw", mNewtonian3DLaw); + KRATOS_REGISTER_CONSTITUTIVE_LAW("PapanastasiouMuIRheology2DLaw", mPapanastasiouMuIRheology2DLaw); + KRATOS_REGISTER_CONSTITUTIVE_LAW("PapanastasiouMuIRheology3DLaw", mPapanastasiouMuIRheology3DLaw); + KRATOS_REGISTER_CONSTITUTIVE_LAW("JopMuIRheology3DLaw", mJopMuIRheology3DLaw); + KRATOS_REGISTER_CONSTITUTIVE_LAW("BarkerMuIRheology3DLaw", mBarkerMuIRheology3DLaw); + KRATOS_REGISTER_CONSTITUTIVE_LAW("BarkerBercovierMuIRheology3DLaw", mBarkerBercovierMuIRheology3DLaw); + KRATOS_REGISTER_CONSTITUTIVE_LAW("BercovierMuIRheology3DLaw", mBercovierMuIRheology3DLaw); + + //Register Solid Constitutive Laws + KRATOS_REGISTER_CONSTITUTIVE_LAW("Hypoelastic2DLaw", mHypoelastic2DLaw); + KRATOS_REGISTER_CONSTITUTIVE_LAW("Hypoelastic3DLaw", mHypoelastic3DLaw); //Register Flow Rules From 7703baf9d443daf24c2a07948d211e4dba50f38b Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Mon, 2 Mar 2020 17:10:40 +0100 Subject: [PATCH 19/47] Adding CLaws in pfem_fluid_dynamics_application.h --- .../pfem_fluid_dynamics_application.h | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/applications/PfemFluidDynamicsApplication/pfem_fluid_dynamics_application.h b/applications/PfemFluidDynamicsApplication/pfem_fluid_dynamics_application.h index 334e437eae08..7d83df6908a9 100755 --- a/applications/PfemFluidDynamicsApplication/pfem_fluid_dynamics_application.h +++ b/applications/PfemFluidDynamicsApplication/pfem_fluid_dynamics_application.h @@ -57,7 +57,21 @@ //hardening laws -//constitutive laws +// Fluid constitutive laws +#include "custom_constitutive/fluid_laws/bingham_2D_law.h" +#include "custom_constitutive/fluid_laws/bingham_3D_law.h" +#include "custom_constitutive/fluid_laws/newtonian_2D_law.h" +#include "custom_constitutive/fluid_laws/newtonian_3D_law.h" +#include "custom_constitutive/fluid_laws/papanastasiou_mu_I_rheology_2D_law.h" +#include "custom_constitutive/fluid_laws/papanastasiou_mu_I_rheology_3D_law.h" +#include "custom_constitutive/fluid_laws/jop_mu_I_rheology_3D_law.h" +#include "custom_constitutive/fluid_laws/barker_mu_I_rheology_3D_law.h" +#include "custom_constitutive/fluid_laws/bercovier_mu_I_rheology_3D_law.h" +#include "custom_constitutive/fluid_laws/barker_bercovier_mu_I_rheology_3D_law.h" + +// Solid constitutive laws +#include "custom_constitutive/solid_laws/hypoelastic_2D_law.h" +#include "custom_constitutive/solid_laws/hypoelastic_3D_law.h" #include "pfem_fluid_dynamics_application_variables.h" @@ -273,6 +287,22 @@ class KRATOS_API(PFEM_FLUID_DYNAMICS_APPLICATION) KratosPfemFluidDynamicsApplica /// 3D two step v-p element const TwoStepUpdatedLagrangianElement<3> mTwoStepUpdatedLagrangianElement3D; const TwoStepUpdatedLagrangianElement<3> mTwoStepUpdatedLagrangianElement3Dquadratic; + + // Fluid constitutive laws + const Bingham2DLaw mBingham2DLaw; + const Bingham3DLaw mBingham3DLaw; + const Newtonian2DLaw mNewtonian2DLaw; + const Newtonian3DLaw mNewtonian3DLaw; + const PapanastasiouMuIRheology2DLaw mPapanastasiouMuIRheology2DLaw; + const JopMuIRheology3DLaw mJopMuIRheology3DLaw; + const PapanastasiouMuIRheology3DLaw mPapanastasiouMuIRheology3DLaw; + const BarkerMuIRheology3DLaw mBarkerMuIRheology3DLaw; + const BarkerBercovierMuIRheology3DLaw mBarkerBercovierMuIRheology3DLaw; + const BercovierMuIRheology3DLaw mBercovierMuIRheology3DLaw; + + // Solid constitutive laws + const Hypoelastic3DLaw mHypoelastic3DLaw; + const Hypoelastic2DLaw mHypoelastic2DLaw; ///@} ///@name Private Operators ///@{ From 1f6aa370766ac99884890e118d48c6ec68f2ed40 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Mon, 2 Mar 2020 17:12:35 +0100 Subject: [PATCH 20/47] Adding CLaws to element's base class --- .../two_step_updated_lagrangian_element.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_element.h b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_element.h index 283772c30a7d..118c8d35b335 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_element.h +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_element.h @@ -23,6 +23,7 @@ #include "geometries/geometry.h" #include "utilities/math_utils.h" #include "utilities/geometry_utilities.h" +#include "includes/constitutive_law.h" #include "pfem_fluid_dynamics_application_variables.h" @@ -140,6 +141,12 @@ class TwoStepUpdatedLagrangianElement : public Element typedef Element::PropertiesType PropertiesType; + /// Reference type definition for constitutive laws + typedef ConstitutiveLaw ConstitutiveLawType; + + /// Pointer type for constitutive laws + typedef ConstitutiveLawType::Pointer ConstitutiveLawPointerType; + ///@} ///@name Life Cycle ///@{ @@ -335,6 +342,8 @@ class TwoStepUpdatedLagrangianElement : public Element ///@name Protected member Variables ///@{ + ConstitutiveLaw::Pointer mpConstitutiveLaw = nullptr; + ///@} ///@name Protected Operators ///@{ From 6809ceed0f95e2b720c83677f306e691d54cb1b0 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Mon, 2 Mar 2020 17:13:31 +0100 Subject: [PATCH 21/47] Adding CLaws to implicit element's base class --- .../two_step_updated_lagrangian_V_P_implicit_element.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.h b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.h index 1e3e5beac710..5601fef370b6 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.h +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_element.h @@ -124,6 +124,12 @@ class TwoStepUpdatedLagrangianVPImplicitElement : public TwoStepUpdatedLagrangia typedef typename BaseType::ElementalVariables ElementalVariables; + ///Reference type definition for constitutive laws + typedef ConstitutiveLaw ConstitutiveLawType; + + ///Pointer type for constitutive laws + typedef ConstitutiveLawType::Pointer ConstitutiveLawPointerType; + ///@} ///@name Life Cycle ///@{ @@ -322,6 +328,8 @@ class TwoStepUpdatedLagrangianVPImplicitElement : public TwoStepUpdatedLagrangia ///@name Protected member Variables ///@{ + ConstitutiveLaw::Pointer mpConstitutiveLaw = nullptr; + ///@} ///@name Protected Operators ///@{ From 117ae448daf372c3b398f0e6fe370663b0c11294 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Mon, 2 Mar 2020 17:51:19 +0100 Subject: [PATCH 22/47] Adding CLaws to elements (header) --- ...tep_updated_lagrangian_V_P_implicit_fluid_element.h | 10 ++++++++++ ...tep_updated_lagrangian_V_P_implicit_solid_element.h | 8 ++++++++ .../updated_lagrangian_V_implicit_solid_element.h | 8 ++++++++ 3 files changed, 26 insertions(+) diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.h b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.h index e9a18e5a5548..2020dab964de 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.h +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.h @@ -22,6 +22,7 @@ #include "includes/serializer.h" #include "geometries/geometry.h" #include "utilities/math_utils.h" +#include "includes/constitutive_law.h" #include "custom_elements/two_step_updated_lagrangian_V_P_implicit_element.h" @@ -108,6 +109,13 @@ class TwoStepUpdatedLagrangianVPImplicitFluidElement : public TwoStepUpdatedLagr typedef typename BaseType::ElementalVariables ElementalVariables; typedef GlobalPointersVector> NodeWeakPtrVectorType; + + /// Reference type definition for constitutive laws + typedef ConstitutiveLaw ConstitutiveLawType; + + ///Pointer type for constitutive laws + typedef ConstitutiveLawType::Pointer ConstitutiveLawPointerType; + ///@} ///@name Life Cycle ///@{ @@ -283,6 +291,8 @@ class TwoStepUpdatedLagrangianVPImplicitFluidElement : public TwoStepUpdatedLagr ///@name Protected member Variables ///@{ + ConstitutiveLaw::Pointer mpConstitutiveLaw = nullptr; + ///@} ///@name Protected Operators ///@{ diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.h b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.h index 1d4da974fcac..a4d0633904ee 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.h +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.h @@ -100,6 +100,12 @@ class TwoStepUpdatedLagrangianVPImplicitSolidElement : public TwoStepUpdatedLagr typedef typename BaseType::ElementalVariables ElementalVariables; + ///Reference type definition for constitutive laws + typedef ConstitutiveLaw ConstitutiveLawType; + + ///Pointer type for constitutive laws + typedef ConstitutiveLawType::Pointer ConstitutiveLawPointerType; + ///@} ///@name Life Cycle ///@{ @@ -283,6 +289,8 @@ class TwoStepUpdatedLagrangianVPImplicitSolidElement : public TwoStepUpdatedLagr std::vector mCurrentDeviatoricCauchyStress; std::vector mUpdatedTotalCauchyStress; std::vector mUpdatedDeviatoricCauchyStress; + ConstitutiveLaw::Pointer mpConstitutiveLaw = nullptr; + ///@} ///@name Protected Operators ///@{ diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/updated_lagrangian_V_implicit_solid_element.h b/applications/PfemFluidDynamicsApplication/custom_elements/updated_lagrangian_V_implicit_solid_element.h index 085e80e356d2..280ece64cb2e 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/updated_lagrangian_V_implicit_solid_element.h +++ b/applications/PfemFluidDynamicsApplication/custom_elements/updated_lagrangian_V_implicit_solid_element.h @@ -101,6 +101,12 @@ class UpdatedLagrangianVImplicitSolidElement : public TwoStepUpdatedLagrangianVP typedef typename BaseType::ElementalVariables ElementalVariables; + ///Reference type definition for constitutive laws + typedef ConstitutiveLaw ConstitutiveLawType; + + ///Pointer type for constitutive laws + typedef ConstitutiveLawType::Pointer ConstitutiveLawPointerType; + ///@} ///@name Life Cycle ///@{ @@ -274,6 +280,8 @@ class UpdatedLagrangianVImplicitSolidElement : public TwoStepUpdatedLagrangianVP ///@name Protected member Variables ///@{ + ConstitutiveLaw::Pointer mpConstitutiveLaw = nullptr; + ///@} ///@name Protected Operators ///@{ From a81468c7c017a70feb6d7110d1384835dd2db3ba Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Mon, 2 Mar 2020 17:52:53 +0100 Subject: [PATCH 23/47] Passing Density Volumetric Deviatoric coeff to ElasticPlasticCauchy (II) --- ...ated_lagrangian_V_implicit_solid_element.h | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/updated_lagrangian_V_implicit_solid_element.h b/applications/PfemFluidDynamicsApplication/custom_elements/updated_lagrangian_V_implicit_solid_element.h index 280ece64cb2e..b38ef327fac7 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/updated_lagrangian_V_implicit_solid_element.h +++ b/applications/PfemFluidDynamicsApplication/custom_elements/updated_lagrangian_V_implicit_solid_element.h @@ -303,28 +303,29 @@ class UpdatedLagrangianVImplicitSolidElement : public TwoStepUpdatedLagrangianVP /* const ShapeFunctionDerivativesType& rDN_DX, */ /* unsigned int g); */ - void CalcElasticPlasticCauchySplitted(ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, - const ProcessInfo &rCurrentProcessInfo) override; + void CalcElasticPlasticCauchySplitted(ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, + const ProcessInfo &rCurrentProcessInfo, double &Density, + double &DeviatoricCoeff, double &VolumetricCoeff) override; - double GetThetaMomentum() override { return 1.0; }; + double GetThetaMomentum() override { return 1.0; }; - double GetThetaContinuity() override { return 1.0; }; + double GetThetaContinuity() override { return 1.0; }; - ///@} - ///@name Protected Access - ///@{ + ///@} + ///@name Protected Access + ///@{ - ///@} - ///@name Protected Inquiry - ///@{ + ///@} + ///@name Protected Inquiry + ///@{ - ///@} - ///@name Protected LifeCycle - ///@{ + ///@} + ///@name Protected LifeCycle + ///@{ - ///@} + ///@} -private: + private: ///@name Static Member Variables ///@{ From a18f6cafa5af7103c7d27089970c23759464f701 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Mon, 2 Mar 2020 17:57:11 +0100 Subject: [PATCH 24/47] Initialize CLaws --- ..._lagrangian_V_P_implicit_fluid_element.cpp | 17 ++++-- ..._lagrangian_V_P_implicit_solid_element.cpp | 61 ++++++++++--------- 2 files changed, 46 insertions(+), 32 deletions(-) diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp index effabfc77bde..d9fb7ea3a5ef 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp @@ -37,10 +37,19 @@ Element::Pointer TwoStepUpdatedLagrangianVPImplicitFluidElement::Clone(Ind } template -void TwoStepUpdatedLagrangianVPImplicitFluidElement::Initialize() -{ - KRATOS_TRY; - KRATOS_CATCH(""); +void TwoStepUpdatedLagrangianVPImplicitFluidElement::Initialize() { + KRATOS_TRY; + + // If we are restarting, the constitutive law will be already defined + if (mpConstitutiveLaw == nullptr) { + const Properties &r_properties = this->GetProperties(); + KRATOS_ERROR_IF_NOT(r_properties.Has(CONSTITUTIVE_LAW)) + << "In initialization of Element " << this->Info() << ": No CONSTITUTIVE_LAW defined for property " + << r_properties.Id() << "." << std::endl; + mpConstitutiveLaw = r_properties[CONSTITUTIVE_LAW]->Clone(); + } + + KRATOS_CATCH(""); } template diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp index ff69e2a642df..bd45c4a326d2 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp @@ -68,40 +68,45 @@ Element::Pointer TwoStepUpdatedLagrangianVPImplicitSolidElement::Clone(Ind } template -void TwoStepUpdatedLagrangianVPImplicitSolidElement::Initialize() -{ - KRATOS_TRY; +void TwoStepUpdatedLagrangianVPImplicitSolidElement::Initialize() { + KRATOS_TRY; - // LargeDisplacementElement::Initialize(); - const GeometryType &rGeom = this->GetGeometry(); - SizeType integration_points_number = rGeom.IntegrationPointsNumber(GeometryData::GI_GAUSS_1); - // SizeType integration_points_number = rGeom.IntegrationPointsNumber(GeometryData::GI_GAUSS_4); - if (this->mCurrentTotalCauchyStress.size() != integration_points_number) - this->mCurrentTotalCauchyStress.resize(integration_points_number); + const GeometryType &rGeom = this->GetGeometry(); + SizeType integration_points_number = rGeom.IntegrationPointsNumber(GeometryData::GI_GAUSS_1); - if (this->mCurrentDeviatoricCauchyStress.size() != integration_points_number) - this->mCurrentDeviatoricCauchyStress.resize(integration_points_number); + if (this->mCurrentTotalCauchyStress.size() != integration_points_number) + this->mCurrentTotalCauchyStress.resize(integration_points_number); - if (this->mUpdatedTotalCauchyStress.size() != integration_points_number) - this->mUpdatedTotalCauchyStress.resize(integration_points_number); + if (this->mCurrentDeviatoricCauchyStress.size() != integration_points_number) + this->mCurrentDeviatoricCauchyStress.resize(integration_points_number); - if (this->mUpdatedDeviatoricCauchyStress.size() != integration_points_number) - this->mUpdatedDeviatoricCauchyStress.resize(integration_points_number); + if (this->mUpdatedTotalCauchyStress.size() != integration_points_number) + this->mUpdatedTotalCauchyStress.resize(integration_points_number); - unsigned int voigtsize = 3; - if (TDim == 3) - { - voigtsize = 6; - } - for (unsigned int PointNumber = 0; PointNumber < integration_points_number; PointNumber++) - { - this->mCurrentTotalCauchyStress[PointNumber] = ZeroVector(voigtsize); - this->mCurrentDeviatoricCauchyStress[PointNumber] = ZeroVector(voigtsize); - this->mUpdatedTotalCauchyStress[PointNumber] = ZeroVector(voigtsize); - this->mUpdatedDeviatoricCauchyStress[PointNumber] = ZeroVector(voigtsize); - } + if (this->mUpdatedDeviatoricCauchyStress.size() != integration_points_number) + this->mUpdatedDeviatoricCauchyStress.resize(integration_points_number); - KRATOS_CATCH(""); + unsigned int voigtsize = 3; + if (TDim == 3) { + voigtsize = 6; + } + for (unsigned int PointNumber = 0; PointNumber < integration_points_number; PointNumber++) { + this->mCurrentTotalCauchyStress[PointNumber] = ZeroVector(voigtsize); + this->mCurrentDeviatoricCauchyStress[PointNumber] = ZeroVector(voigtsize); + this->mUpdatedTotalCauchyStress[PointNumber] = ZeroVector(voigtsize); + this->mUpdatedDeviatoricCauchyStress[PointNumber] = ZeroVector(voigtsize); + } + + // If we are restarting, the constitutive law will be already defined + if (mpConstitutiveLaw == nullptr) { + const Properties &r_properties = this->GetProperties(); + KRATOS_ERROR_IF_NOT(r_properties.Has(CONSTITUTIVE_LAW)) + << "In initialization of Element " << this->Info() << ": No CONSTITUTIVE_LAW defined for property " + << r_properties.Id() << "." << std::endl; + mpConstitutiveLaw = r_properties[CONSTITUTIVE_LAW]->Clone(); + } + + KRATOS_CATCH(""); } template From 11c76d0438b8f2fc0eb25af561ba6590a59ed0a0 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Mon, 2 Mar 2020 18:04:10 +0100 Subject: [PATCH 25/47] Check CLaws --- ..._lagrangian_V_P_implicit_fluid_element.cpp | 144 +++++++++++------- ..._lagrangian_V_P_implicit_solid_element.cpp | 144 +++++++++++------- 2 files changed, 182 insertions(+), 106 deletions(-) diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp index d9fb7ea3a5ef..336af8fe324e 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp @@ -146,65 +146,103 @@ void TwoStepUpdatedLagrangianVPImplicitFluidElement::ComputeMaterialParame } template -int TwoStepUpdatedLagrangianVPImplicitFluidElement::Check(const ProcessInfo &rCurrentProcessInfo) -{ - KRATOS_TRY; +int TwoStepUpdatedLagrangianVPImplicitFluidElement::Check(const ProcessInfo &rCurrentProcessInfo) { + KRATOS_TRY; - // Base class checks for positive Jacobian and Id > 0 - int ierr = Element::Check(rCurrentProcessInfo); - if (ierr != 0) - return ierr; + // Base class checks for positive Jacobian and Id > 0 + int ierr = Element::Check(rCurrentProcessInfo); + if (ierr != 0) return ierr; + + // Check that all required variables have been registered + if (VELOCITY.Key() == 0) + KRATOS_THROW_ERROR(std::invalid_argument, + "VELOCITY Key is 0. Check that the application was correctly registered.", ""); + if (ACCELERATION.Key() == 0) + KRATOS_THROW_ERROR(std::invalid_argument, + "ACCELERATION Key is 0. Check that the application was correctly registered.", ""); + if (PRESSURE.Key() == 0) + KRATOS_THROW_ERROR(std::invalid_argument, + "PRESSURE Key is 0. Check that the application was correctly registered.", ""); + if (BODY_FORCE.Key() == 0) + KRATOS_THROW_ERROR(std::invalid_argument, + "BODY_FORCE Key is 0. Check that the application was correctly registered.", ""); + if (DENSITY.Key() == 0) + KRATOS_THROW_ERROR(std::invalid_argument, + "DENSITY Key is 0. Check that the application was correctly registered.", ""); + if (DYNAMIC_VISCOSITY.Key() == 0) + KRATOS_THROW_ERROR(std::invalid_argument, + "DYNAMIC_VISCOSITY Key is 0. Check that the application was correctly registered.", ""); + if (DELTA_TIME.Key() == 0) + KRATOS_THROW_ERROR(std::invalid_argument, + "DELTA_TIME Key is 0. Check that the application was correctly registered.", ""); + + // Check that the element's nodes contain all required SolutionStepData and Degrees of freedom + for (unsigned int i = 0; i < this->GetGeometry().size(); ++i) { + if (this->GetGeometry()[i].SolutionStepsDataHas(VELOCITY) == false) + KRATOS_THROW_ERROR(std::invalid_argument, "missing VELOCITY variable on solution step data for node ", + this->GetGeometry()[i].Id()); + if (this->GetGeometry()[i].SolutionStepsDataHas(PRESSURE) == false) + KRATOS_THROW_ERROR(std::invalid_argument, "missing PRESSURE variable on solution step data for node ", + this->GetGeometry()[i].Id()); + if (this->GetGeometry()[i].SolutionStepsDataHas(BODY_FORCE) == false) + KRATOS_THROW_ERROR(std::invalid_argument, "missing BODY_FORCE variable on solution step data for node ", + this->GetGeometry()[i].Id()); + if (this->GetGeometry()[i].SolutionStepsDataHas(DENSITY) == false) + KRATOS_THROW_ERROR(std::invalid_argument, "missing DENSITY variable on solution step data for node ", + this->GetGeometry()[i].Id()); + if (this->GetGeometry()[i].SolutionStepsDataHas(DYNAMIC_VISCOSITY) == false) + KRATOS_THROW_ERROR(std::invalid_argument, + "missing DYNAMIC_VISCOSITY variable on solution step data for node ", + this->GetGeometry()[i].Id()); + if (this->GetGeometry()[i].HasDofFor(VELOCITY_X) == false || + this->GetGeometry()[i].HasDofFor(VELOCITY_Y) == false || + this->GetGeometry()[i].HasDofFor(VELOCITY_Z) == false) + KRATOS_THROW_ERROR(std::invalid_argument, "missing VELOCITY component degree of freedom on node ", + this->GetGeometry()[i].Id()); + if (this->GetGeometry()[i].HasDofFor(PRESSURE) == false) + KRATOS_THROW_ERROR(std::invalid_argument, "missing PRESSURE component degree of freedom on node ", + this->GetGeometry()[i].Id()); + } - // Check that all required variables have been registered - if (VELOCITY.Key() == 0) - KRATOS_THROW_ERROR(std::invalid_argument, "VELOCITY Key is 0. Check that the application was correctly registered.", ""); - if (ACCELERATION.Key() == 0) - KRATOS_THROW_ERROR(std::invalid_argument, "ACCELERATION Key is 0. Check that the application was correctly registered.", ""); - if (PRESSURE.Key() == 0) - KRATOS_THROW_ERROR(std::invalid_argument, "PRESSURE Key is 0. Check that the application was correctly registered.", ""); - if (BODY_FORCE.Key() == 0) - KRATOS_THROW_ERROR(std::invalid_argument, "BODY_FORCE Key is 0. Check that the application was correctly registered.", ""); - if (DENSITY.Key() == 0) - KRATOS_THROW_ERROR(std::invalid_argument, "DENSITY Key is 0. Check that the application was correctly registered.", ""); - if (DYNAMIC_VISCOSITY.Key() == 0) - KRATOS_THROW_ERROR(std::invalid_argument, "DYNAMIC_VISCOSITY Key is 0. Check that the application was correctly registered.", ""); - if (DELTA_TIME.Key() == 0) - KRATOS_THROW_ERROR(std::invalid_argument, "DELTA_TIME Key is 0. Check that the application was correctly registered.", ""); - - // Check that the element's nodes contain all required SolutionStepData and Degrees of freedom - for (unsigned int i = 0; i < this->GetGeometry().size(); ++i) - { - if (this->GetGeometry()[i].SolutionStepsDataHas(VELOCITY) == false) - KRATOS_THROW_ERROR(std::invalid_argument, "missing VELOCITY variable on solution step data for node ", this->GetGeometry()[i].Id()); - if (this->GetGeometry()[i].SolutionStepsDataHas(PRESSURE) == false) - KRATOS_THROW_ERROR(std::invalid_argument, "missing PRESSURE variable on solution step data for node ", this->GetGeometry()[i].Id()); - if (this->GetGeometry()[i].SolutionStepsDataHas(BODY_FORCE) == false) - KRATOS_THROW_ERROR(std::invalid_argument, "missing BODY_FORCE variable on solution step data for node ", this->GetGeometry()[i].Id()); - if (this->GetGeometry()[i].SolutionStepsDataHas(DENSITY) == false) - KRATOS_THROW_ERROR(std::invalid_argument, "missing DENSITY variable on solution step data for node ", this->GetGeometry()[i].Id()); - if (this->GetGeometry()[i].SolutionStepsDataHas(DYNAMIC_VISCOSITY) == false) - KRATOS_THROW_ERROR(std::invalid_argument, "missing DYNAMIC_VISCOSITY variable on solution step data for node ", this->GetGeometry()[i].Id()); - if (this->GetGeometry()[i].HasDofFor(VELOCITY_X) == false || - this->GetGeometry()[i].HasDofFor(VELOCITY_Y) == false || - this->GetGeometry()[i].HasDofFor(VELOCITY_Z) == false) - KRATOS_THROW_ERROR(std::invalid_argument, "missing VELOCITY component degree of freedom on node ", this->GetGeometry()[i].Id()); - if (this->GetGeometry()[i].HasDofFor(PRESSURE) == false) - KRATOS_THROW_ERROR(std::invalid_argument, "missing PRESSURE component degree of freedom on node ", this->GetGeometry()[i].Id()); - } + // If this is a 2D problem, check that nodes are in XY plane + if (this->GetGeometry().WorkingSpaceDimension() == 2) { + for (unsigned int i = 0; i < this->GetGeometry().size(); ++i) { + if (this->GetGeometry()[i].Z() != 0.0) + KRATOS_THROW_ERROR(std::invalid_argument, + "Node with non-zero Z coordinate found. Id: ", this->GetGeometry()[i].Id()); + } + } - // If this is a 2D problem, check that nodes are in XY plane - if (this->GetGeometry().WorkingSpaceDimension() == 2) - { - for (unsigned int i = 0; i < this->GetGeometry().size(); ++i) - { - if (this->GetGeometry()[i].Z() != 0.0) - KRATOS_THROW_ERROR(std::invalid_argument, "Node with non-zero Z coordinate found. Id: ", this->GetGeometry()[i].Id()); + // Consitutive law checks + const auto &r_properties = this->GetProperties(); + const auto &r_geometry = this->GetGeometry(); + const SizeType dimension = r_geometry.WorkingSpaceDimension(); + mpConstitutiveLaw = this->GetProperties().GetValue(CONSTITUTIVE_LAW); + + // Verify that the constitutive law exists + KRATOS_ERROR_IF_NOT(r_properties.Has(CONSTITUTIVE_LAW)) + << "Constitutive law not provided for property " << r_properties.Id() << std::endl; + + // Verify that the constitutive law has the correct dimension + const SizeType strain_size = r_properties.GetValue(CONSTITUTIVE_LAW)->GetStrainSize(); + + if (dimension == 2) { + KRATOS_ERROR_IF(strain_size < 3 || strain_size > 4) + << "Wrong constitutive law used. This is a 2D element! expected strain size is 3 or 4 " + "(el id = ) " + << this->Id() << std::endl; + } else { + KRATOS_ERROR_IF_NOT(strain_size == 6) << "Wrong constitutive law used. This is a 3D element! " + "expected strain size is 6 (el id = ) " + << this->Id() << std::endl; } - } - return ierr; + // Check constitutive law + return mpConstitutiveLaw->Check(r_properties, r_geometry, rCurrentProcessInfo); - KRATOS_CATCH(""); + return ierr; + + KRATOS_CATCH(""); } template <> diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp index bd45c4a326d2..6b2e301e0e6f 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp @@ -132,65 +132,103 @@ void TwoStepUpdatedLagrangianVPImplicitSolidElement::InitializeNonLinearIt } template -int TwoStepUpdatedLagrangianVPImplicitSolidElement::Check(const ProcessInfo &rCurrentProcessInfo) -{ - KRATOS_TRY; +int TwoStepUpdatedLagrangianVPImplicitSolidElement::Check(const ProcessInfo &rCurrentProcessInfo) { + KRATOS_TRY; - // Base class checks for positive Jacobian and Id > 0 - int ierr = Element::Check(rCurrentProcessInfo); - if (ierr != 0) - return ierr; + // Base class checks for positive Jacobian and Id > 0 + int ierr = Element::Check(rCurrentProcessInfo); + if (ierr != 0) return ierr; + + // Check that all required variables have been registered + if (VELOCITY.Key() == 0) + KRATOS_THROW_ERROR(std::invalid_argument, + "VELOCITY Key is 0. Check that the application was correctly registered.", ""); + if (ACCELERATION.Key() == 0) + KRATOS_THROW_ERROR(std::invalid_argument, + "ACCELERATION Key is 0. Check that the application was correctly registered.", ""); + if (PRESSURE.Key() == 0) + KRATOS_THROW_ERROR(std::invalid_argument, + "PRESSURE Key is 0. Check that the application was correctly registered.", ""); + if (BODY_FORCE.Key() == 0) + KRATOS_THROW_ERROR(std::invalid_argument, + "BODY_FORCE Key is 0. Check that the application was correctly registered.", ""); + if (DENSITY.Key() == 0) + KRATOS_THROW_ERROR(std::invalid_argument, + "DENSITY Key is 0. Check that the application was correctly registered.", ""); + if (DYNAMIC_VISCOSITY.Key() == 0) + KRATOS_THROW_ERROR(std::invalid_argument, + "DYNAMIC_VISCOSITY Key is 0. Check that the application was correctly registered.", ""); + if (DELTA_TIME.Key() == 0) + KRATOS_THROW_ERROR(std::invalid_argument, + "DELTA_TIME Key is 0. Check that the application was correctly registered.", ""); + + // Check that the element's nodes contain all required SolutionStepData and Degrees of freedom + for (unsigned int i = 0; i < this->GetGeometry().size(); ++i) { + if (this->GetGeometry()[i].SolutionStepsDataHas(VELOCITY) == false) + KRATOS_THROW_ERROR(std::invalid_argument, "missing VELOCITY variable on solution step data for node ", + this->GetGeometry()[i].Id()); + if (this->GetGeometry()[i].SolutionStepsDataHas(PRESSURE) == false) + KRATOS_THROW_ERROR(std::invalid_argument, "missing PRESSURE variable on solution step data for node ", + this->GetGeometry()[i].Id()); + if (this->GetGeometry()[i].SolutionStepsDataHas(BODY_FORCE) == false) + KRATOS_THROW_ERROR(std::invalid_argument, "missing BODY_FORCE variable on solution step data for node ", + this->GetGeometry()[i].Id()); + if (this->GetGeometry()[i].SolutionStepsDataHas(DENSITY) == false) + KRATOS_THROW_ERROR(std::invalid_argument, "missing DENSITY variable on solution step data for node ", + this->GetGeometry()[i].Id()); + if (this->GetGeometry()[i].SolutionStepsDataHas(DYNAMIC_VISCOSITY) == false) + KRATOS_THROW_ERROR(std::invalid_argument, + "missing DYNAMIC_VISCOSITY variable on solution step data for node ", + this->GetGeometry()[i].Id()); + if (this->GetGeometry()[i].HasDofFor(VELOCITY_X) == false || + this->GetGeometry()[i].HasDofFor(VELOCITY_Y) == false || + this->GetGeometry()[i].HasDofFor(VELOCITY_Z) == false) + KRATOS_THROW_ERROR(std::invalid_argument, "missing VELOCITY component degree of freedom on node ", + this->GetGeometry()[i].Id()); + if (this->GetGeometry()[i].HasDofFor(PRESSURE) == false) + KRATOS_THROW_ERROR(std::invalid_argument, "missing PRESSURE component degree of freedom on node ", + this->GetGeometry()[i].Id()); + } - // Check that all required variables have been registered - if (VELOCITY.Key() == 0) - KRATOS_THROW_ERROR(std::invalid_argument, "VELOCITY Key is 0. Check that the application was correctly registered.", ""); - if (ACCELERATION.Key() == 0) - KRATOS_THROW_ERROR(std::invalid_argument, "ACCELERATION Key is 0. Check that the application was correctly registered.", ""); - if (PRESSURE.Key() == 0) - KRATOS_THROW_ERROR(std::invalid_argument, "PRESSURE Key is 0. Check that the application was correctly registered.", ""); - if (BODY_FORCE.Key() == 0) - KRATOS_THROW_ERROR(std::invalid_argument, "BODY_FORCE Key is 0. Check that the application was correctly registered.", ""); - if (DENSITY.Key() == 0) - KRATOS_THROW_ERROR(std::invalid_argument, "DENSITY Key is 0. Check that the application was correctly registered.", ""); - if (DYNAMIC_VISCOSITY.Key() == 0) - KRATOS_THROW_ERROR(std::invalid_argument, "DYNAMIC_VISCOSITY Key is 0. Check that the application was correctly registered.", ""); - if (DELTA_TIME.Key() == 0) - KRATOS_THROW_ERROR(std::invalid_argument, "DELTA_TIME Key is 0. Check that the application was correctly registered.", ""); - - // Check that the element's nodes contain all required SolutionStepData and Degrees of freedom - for (unsigned int i = 0; i < this->GetGeometry().size(); ++i) - { - if (this->GetGeometry()[i].SolutionStepsDataHas(VELOCITY) == false) - KRATOS_THROW_ERROR(std::invalid_argument, "missing VELOCITY variable on solution step data for node ", this->GetGeometry()[i].Id()); - if (this->GetGeometry()[i].SolutionStepsDataHas(PRESSURE) == false) - KRATOS_THROW_ERROR(std::invalid_argument, "missing PRESSURE variable on solution step data for node ", this->GetGeometry()[i].Id()); - if (this->GetGeometry()[i].SolutionStepsDataHas(BODY_FORCE) == false) - KRATOS_THROW_ERROR(std::invalid_argument, "missing BODY_FORCE variable on solution step data for node ", this->GetGeometry()[i].Id()); - if (this->GetGeometry()[i].SolutionStepsDataHas(DENSITY) == false) - KRATOS_THROW_ERROR(std::invalid_argument, "missing DENSITY variable on solution step data for node ", this->GetGeometry()[i].Id()); - if (this->GetGeometry()[i].SolutionStepsDataHas(DYNAMIC_VISCOSITY) == false) - KRATOS_THROW_ERROR(std::invalid_argument, "missing DYNAMIC_VISCOSITY variable on solution step data for node ", this->GetGeometry()[i].Id()); - if (this->GetGeometry()[i].HasDofFor(VELOCITY_X) == false || - this->GetGeometry()[i].HasDofFor(VELOCITY_Y) == false || - this->GetGeometry()[i].HasDofFor(VELOCITY_Z) == false) - KRATOS_THROW_ERROR(std::invalid_argument, "missing VELOCITY component degree of freedom on node ", this->GetGeometry()[i].Id()); - if (this->GetGeometry()[i].HasDofFor(PRESSURE) == false) - KRATOS_THROW_ERROR(std::invalid_argument, "missing PRESSURE component degree of freedom on node ", this->GetGeometry()[i].Id()); - } + // If this is a 2D problem, check that nodes are in XY plane + if (this->GetGeometry().WorkingSpaceDimension() == 2) { + for (unsigned int i = 0; i < this->GetGeometry().size(); ++i) { + if (this->GetGeometry()[i].Z() != 0.0) + KRATOS_THROW_ERROR(std::invalid_argument, + "Node with non-zero Z coordinate found. Id: ", this->GetGeometry()[i].Id()); + } + } - // If this is a 2D problem, check that nodes are in XY plane - if (this->GetGeometry().WorkingSpaceDimension() == 2) - { - for (unsigned int i = 0; i < this->GetGeometry().size(); ++i) - { - if (this->GetGeometry()[i].Z() != 0.0) - KRATOS_THROW_ERROR(std::invalid_argument, "Node with non-zero Z coordinate found. Id: ", this->GetGeometry()[i].Id()); + // Consitutive law checks + const auto &r_properties = this->GetProperties(); + const auto &r_geometry = this->GetGeometry(); + const SizeType dimension = r_geometry.WorkingSpaceDimension(); + mpConstitutiveLaw = this->GetProperties().GetValue(CONSTITUTIVE_LAW); + + // Verify that the constitutive law exists + KRATOS_ERROR_IF_NOT(r_properties.Has(CONSTITUTIVE_LAW)) + << "Constitutive law not provided for property " << r_properties.Id() << std::endl; + + // Verify that the constitutive law has the correct dimension + const SizeType strain_size = r_properties.GetValue(CONSTITUTIVE_LAW)->GetStrainSize(); + + if (dimension == 2) { + KRATOS_ERROR_IF(strain_size < 3 || strain_size > 4) + << "Wrong constitutive law used. This is a 2D element! expected strain size is 3 or 4 " + "(el id = ) " + << this->Id() << std::endl; + } else { + KRATOS_ERROR_IF_NOT(strain_size == 6) << "Wrong constitutive law used. This is a 3D element! " + "expected strain size is 6 (el id = ) " + << this->Id() << std::endl; } - } - return ierr; + // Check constitutive law + return mpConstitutiveLaw->Check(r_properties, r_geometry, rCurrentProcessInfo); - KRATOS_CATCH(""); + return ierr; + + KRATOS_CATCH(""); } template From b6a8141bf270575b09ca63d2f3d4e671757ef6de Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Mon, 2 Mar 2020 18:06:02 +0100 Subject: [PATCH 26/47] Updating calculation of stress --- ..._lagrangian_V_P_implicit_fluid_element.cpp | 138 +++++++------ ..._lagrangian_V_P_implicit_solid_element.cpp | 158 ++++++++------- ...ed_lagrangian_V_implicit_solid_element.cpp | 185 +++++++++--------- 3 files changed, 263 insertions(+), 218 deletions(-) diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp index 336af8fe324e..9c807d6b0394 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.cpp @@ -1256,28 +1256,43 @@ void TwoStepUpdatedLagrangianVPImplicitFluidElement<2>::CalcElasticPlasticCauchy ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, const ProcessInfo &rCurrentProcessInfo, double &Density, double &DeviatoricCoeff, double &VolumetricCoeff) { - double CurrSecondLame = this->mMaterialDeviatoricCoefficient; - - double DefX = rElementalVariables.SpatialDefRate[0]; - double DefY = rElementalVariables.SpatialDefRate[1]; - double DefXY = rElementalVariables.SpatialDefRate[2]; - - double DefVol = rElementalVariables.VolumetricDefRate; - double sigmaDev_xx = 2 * CurrSecondLame * (DefX - DefVol / 3.0); - double sigmaDev_yy = 2 * CurrSecondLame * (DefY - DefVol / 3.0); - double sigmaDev_xy = 2 * CurrSecondLame * DefXY; - - double sigmaTot_xx = sigmaDev_xx + rElementalVariables.MeanPressure; - double sigmaTot_yy = sigmaDev_yy + rElementalVariables.MeanPressure; - double sigmaTot_xy = sigmaDev_xy; - - rElementalVariables.UpdatedDeviatoricCauchyStress[0] = sigmaDev_xx; - rElementalVariables.UpdatedDeviatoricCauchyStress[1] = sigmaDev_yy; - rElementalVariables.UpdatedDeviatoricCauchyStress[2] = sigmaDev_xy; - - rElementalVariables.UpdatedTotalCauchyStress[0] = sigmaTot_xx; - rElementalVariables.UpdatedTotalCauchyStress[1] = sigmaTot_yy; - rElementalVariables.UpdatedTotalCauchyStress[2] = sigmaTot_xy; + mpConstitutiveLaw = this->GetProperties().GetValue(CONSTITUTIVE_LAW); + auto constitutive_law_values = + ConstitutiveLaw::Parameters(this->GetGeometry(), this->GetProperties(), rCurrentProcessInfo); + + Flags &constitutive_law_options = constitutive_law_values.GetOptions(); + constitutive_law_options.Set(ConstitutiveLaw::COMPUTE_STRESS, true); + constitutive_law_options.Set(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR, true); + + const Vector &r_shape_functions = row((this->GetGeometry()).ShapeFunctionsValues(), g); + constitutive_law_values.SetShapeFunctionsValues(r_shape_functions); + constitutive_law_values.SetStrainVector(rElementalVariables.SpatialDefRate); + constitutive_law_values.SetStressVector(rElementalVariables.UpdatedDeviatoricCauchyStress); + constitutive_law_values.SetConstitutiveMatrix(rElementalVariables.ConstitutiveMatrix); + + // Temporary workaround, to be updated + auto r_geometry = this->GetGeometry(); + r_geometry[0].SetValue(THETA_MOMENTUM, 0.5); + + mpConstitutiveLaw->CalculateMaterialResponseCauchy(constitutive_law_values); + + rElementalVariables.UpdatedTotalCauchyStress[0] = + rElementalVariables.UpdatedDeviatoricCauchyStress[0] + rElementalVariables.MeanPressure; + rElementalVariables.UpdatedTotalCauchyStress[1] = + rElementalVariables.UpdatedDeviatoricCauchyStress[1] + rElementalVariables.MeanPressure; + rElementalVariables.UpdatedTotalCauchyStress[2] = rElementalVariables.UpdatedDeviatoricCauchyStress[2]; + + const double time_step = rCurrentProcessInfo[DELTA_TIME]; + const double bulk_modulus = this->GetProperties()[BULK_MODULUS]; + const int voigt_size = (this->GetGeometry().WorkingSpaceDimension() - 1) * 3; + + DeviatoricCoeff = rElementalVariables.ConstitutiveMatrix(voigt_size - 1, voigt_size - 1); + VolumetricCoeff = bulk_modulus * time_step; + Density = mpConstitutiveLaw->CalculateValue(constitutive_law_values, DENSITY, Density); + + this->mMaterialDeviatoricCoefficient = DeviatoricCoeff; + this->mMaterialVolumetricCoefficient = VolumetricCoeff; + this->mMaterialDensity = Density; } template <> @@ -1285,44 +1300,47 @@ void TwoStepUpdatedLagrangianVPImplicitFluidElement<3>::CalcElasticPlasticCauchy ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, const ProcessInfo &rCurrentProcessInfo, double &Density, double &DeviatoricCoeff, double &VolumetricCoeff) { - double CurrSecondLame = this->mMaterialDeviatoricCoefficient; - - double DefX = rElementalVariables.SpatialDefRate[0]; - double DefY = rElementalVariables.SpatialDefRate[1]; - double DefZ = rElementalVariables.SpatialDefRate[2]; - double DefXY = rElementalVariables.SpatialDefRate[3]; - double DefXZ = rElementalVariables.SpatialDefRate[4]; - double DefYZ = rElementalVariables.SpatialDefRate[5]; - - double DefVol = rElementalVariables.VolumetricDefRate; - - double sigmaDev_xx = 2 * CurrSecondLame * (DefX - DefVol / 3.0); - double sigmaDev_yy = 2 * CurrSecondLame * (DefY - DefVol / 3.0); - double sigmaDev_zz = 2 * CurrSecondLame * (DefZ - DefVol / 3.0); - double sigmaDev_xy = 2 * CurrSecondLame * DefXY; - double sigmaDev_xz = 2 * CurrSecondLame * DefXZ; - double sigmaDev_yz = 2 * CurrSecondLame * DefYZ; - - double sigmaTot_xx = sigmaDev_xx + rElementalVariables.MeanPressure; - double sigmaTot_yy = sigmaDev_yy + rElementalVariables.MeanPressure; - double sigmaTot_zz = sigmaDev_zz + rElementalVariables.MeanPressure; - double sigmaTot_xy = sigmaDev_xy; - double sigmaTot_xz = sigmaDev_xz; - double sigmaTot_yz = sigmaDev_yz; - - rElementalVariables.UpdatedDeviatoricCauchyStress[0] = sigmaDev_xx; - rElementalVariables.UpdatedDeviatoricCauchyStress[1] = sigmaDev_yy; - rElementalVariables.UpdatedDeviatoricCauchyStress[2] = sigmaDev_zz; - rElementalVariables.UpdatedDeviatoricCauchyStress[3] = sigmaDev_xy; - rElementalVariables.UpdatedDeviatoricCauchyStress[4] = sigmaDev_xz; - rElementalVariables.UpdatedDeviatoricCauchyStress[5] = sigmaDev_yz; - - rElementalVariables.UpdatedTotalCauchyStress[0] = sigmaTot_xx; - rElementalVariables.UpdatedTotalCauchyStress[1] = sigmaTot_yy; - rElementalVariables.UpdatedTotalCauchyStress[2] = sigmaTot_zz; - rElementalVariables.UpdatedTotalCauchyStress[3] = sigmaTot_xy; - rElementalVariables.UpdatedTotalCauchyStress[4] = sigmaTot_xz; - rElementalVariables.UpdatedTotalCauchyStress[5] = sigmaTot_yz; + mpConstitutiveLaw = this->GetProperties().GetValue(CONSTITUTIVE_LAW); + auto constitutive_law_values = + ConstitutiveLaw::Parameters(this->GetGeometry(), this->GetProperties(), rCurrentProcessInfo); + + Flags &constitutive_law_options = constitutive_law_values.GetOptions(); + constitutive_law_options.Set(ConstitutiveLaw::COMPUTE_STRESS, true); + constitutive_law_options.Set(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR, true); + + const Vector &r_shape_functions = row((this->GetGeometry()).ShapeFunctionsValues(), g); + constitutive_law_values.SetShapeFunctionsValues(r_shape_functions); + constitutive_law_values.SetStrainVector(rElementalVariables.SpatialDefRate); + constitutive_law_values.SetStressVector(rElementalVariables.UpdatedDeviatoricCauchyStress); + constitutive_law_values.SetConstitutiveMatrix(rElementalVariables.ConstitutiveMatrix); + + // Temporary workaround, to be updated + auto r_geometry = this->GetGeometry(); + r_geometry[0].SetValue(THETA_MOMENTUM, 0.5); + + mpConstitutiveLaw->CalculateMaterialResponseCauchy(constitutive_law_values); + + rElementalVariables.UpdatedTotalCauchyStress[0] = + rElementalVariables.UpdatedDeviatoricCauchyStress[0] + rElementalVariables.MeanPressure; + rElementalVariables.UpdatedTotalCauchyStress[1] = + rElementalVariables.UpdatedDeviatoricCauchyStress[1] + rElementalVariables.MeanPressure; + rElementalVariables.UpdatedTotalCauchyStress[2] = + rElementalVariables.UpdatedDeviatoricCauchyStress[2] + rElementalVariables.MeanPressure; + rElementalVariables.UpdatedTotalCauchyStress[3] = rElementalVariables.UpdatedDeviatoricCauchyStress[3]; + rElementalVariables.UpdatedTotalCauchyStress[4] = rElementalVariables.UpdatedDeviatoricCauchyStress[4]; + rElementalVariables.UpdatedTotalCauchyStress[5] = rElementalVariables.UpdatedDeviatoricCauchyStress[5]; + + const double time_step = rCurrentProcessInfo[DELTA_TIME]; + const double bulk_modulus = this->GetProperties()[BULK_MODULUS]; + const int voigt_size = (this->GetGeometry().WorkingSpaceDimension() - 1) * 3; + + DeviatoricCoeff = rElementalVariables.ConstitutiveMatrix(voigt_size - 1, voigt_size - 1); + VolumetricCoeff = bulk_modulus * time_step; + Density = mpConstitutiveLaw->CalculateValue(constitutive_law_values, DENSITY, Density); + + this->mMaterialDeviatoricCoefficient = DeviatoricCoeff; + this->mMaterialVolumetricCoefficient = VolumetricCoeff; + this->mMaterialDensity = Density; } template diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp index 6b2e301e0e6f..6eef8b88f7e6 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp @@ -341,36 +341,51 @@ void TwoStepUpdatedLagrangianVPImplicitSolidElement<2>::CalcElasticPlasticCauchy rElementalVariables.CurrentTotalCauchyStress = this->mCurrentTotalCauchyStress[g]; rElementalVariables.CurrentDeviatoricCauchyStress = this->mCurrentDeviatoricCauchyStress[g]; - double CurrSecondLame = this->mMaterialDeviatoricCoefficient; - - double DefX = rElementalVariables.SpatialDefRate[0]; - double DefY = rElementalVariables.SpatialDefRate[1]; - double DefXY = rElementalVariables.SpatialDefRate[2]; + mpConstitutiveLaw = this->GetProperties().GetValue(CONSTITUTIVE_LAW); + auto constitutive_law_values = + ConstitutiveLaw::Parameters(this->GetGeometry(), this->GetProperties(), rCurrentProcessInfo); - double DefVol = rElementalVariables.VolumetricDefRate; + Flags &constitutive_law_options = constitutive_law_values.GetOptions(); + constitutive_law_options.Set(ConstitutiveLaw::COMPUTE_STRESS, true); + constitutive_law_options.Set(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR, false); - double sigmaDev_xx = 2 * CurrSecondLame * (DefX - DefVol / 3.0); - double sigmaDev_yy = 2 * CurrSecondLame * (DefY - DefVol / 3.0); - double sigmaDev_xy = 2 * CurrSecondLame * DefXY; + const Vector &r_shape_functions = row((this->GetGeometry()).ShapeFunctionsValues(), g); + constitutive_law_values.SetShapeFunctionsValues(r_shape_functions); + constitutive_law_values.SetStrainVector(rElementalVariables.SpatialDefRate); + constitutive_law_values.SetStressVector(rElementalVariables.CurrentDeviatoricCauchyStress); - sigmaDev_xx += rElementalVariables.CurrentDeviatoricCauchyStress[0]; - sigmaDev_yy += rElementalVariables.CurrentDeviatoricCauchyStress[1]; - sigmaDev_xy += rElementalVariables.CurrentDeviatoricCauchyStress[2]; + mpConstitutiveLaw->CalculateMaterialResponseCauchy(constitutive_law_values); - double sigmaTot_xx = sigmaDev_xx + rElementalVariables.MeanPressure; - double sigmaTot_yy = sigmaDev_yy + rElementalVariables.MeanPressure; - double sigmaTot_xy = sigmaDev_xy; + rElementalVariables.UpdatedDeviatoricCauchyStress[0] = rElementalVariables.CurrentDeviatoricCauchyStress[0]; + rElementalVariables.UpdatedDeviatoricCauchyStress[1] = rElementalVariables.CurrentDeviatoricCauchyStress[1]; + rElementalVariables.UpdatedDeviatoricCauchyStress[2] = rElementalVariables.CurrentDeviatoricCauchyStress[2]; - rElementalVariables.UpdatedDeviatoricCauchyStress[0] = sigmaDev_xx; - rElementalVariables.UpdatedDeviatoricCauchyStress[1] = sigmaDev_yy; - rElementalVariables.UpdatedDeviatoricCauchyStress[2] = sigmaDev_xy; + rElementalVariables.UpdatedTotalCauchyStress[0] = + rElementalVariables.CurrentDeviatoricCauchyStress[0] + rElementalVariables.MeanPressure; + rElementalVariables.UpdatedTotalCauchyStress[1] = + rElementalVariables.CurrentDeviatoricCauchyStress[1] + rElementalVariables.MeanPressure; + rElementalVariables.UpdatedTotalCauchyStress[2] = rElementalVariables.CurrentDeviatoricCauchyStress[2]; - rElementalVariables.UpdatedTotalCauchyStress[0] = sigmaTot_xx; - rElementalVariables.UpdatedTotalCauchyStress[1] = sigmaTot_yy; - rElementalVariables.UpdatedTotalCauchyStress[2] = sigmaTot_xy; + rElementalVariables.UpdatedDeviatoricCauchyStress[0] = rElementalVariables.CurrentDeviatoricCauchyStress[0]; + rElementalVariables.UpdatedDeviatoricCauchyStress[1] = rElementalVariables.CurrentDeviatoricCauchyStress[1]; + rElementalVariables.UpdatedDeviatoricCauchyStress[2] = rElementalVariables.CurrentDeviatoricCauchyStress[2]; this->mUpdatedTotalCauchyStress[g] = rElementalVariables.UpdatedTotalCauchyStress; this->mUpdatedDeviatoricCauchyStress[g] = rElementalVariables.UpdatedDeviatoricCauchyStress; + + Density = mpConstitutiveLaw->CalculateValue(constitutive_law_values, DENSITY, Density); + + double poisson_ratio = mpConstitutiveLaw->CalculateValue(constitutive_law_values, POISSON_RATIO, poisson_ratio); + double young_modulus = mpConstitutiveLaw->CalculateValue(constitutive_law_values, YOUNG_MODULUS, young_modulus); + const double time_step = rCurrentProcessInfo[DELTA_TIME]; + DeviatoricCoeff = time_step * young_modulus / (2.0 * (1.0 + poisson_ratio)); + VolumetricCoeff = + time_step * poisson_ratio * young_modulus / ((1.0 + poisson_ratio) * (1.0 - 2.0 * poisson_ratio)) + + 2.0 / 3.0 * DeviatoricCoeff; + + this->mMaterialDeviatoricCoefficient = DeviatoricCoeff; + this->mMaterialVolumetricCoefficient = VolumetricCoeff; + this->mMaterialDensity = Density; } template <> @@ -381,56 +396,61 @@ void TwoStepUpdatedLagrangianVPImplicitSolidElement<3>::CalcElasticPlasticCauchy rElementalVariables.CurrentTotalCauchyStress = this->mCurrentTotalCauchyStress[g]; rElementalVariables.CurrentDeviatoricCauchyStress = this->mCurrentDeviatoricCauchyStress[g]; - double CurrSecondLame = this->mMaterialDeviatoricCoefficient; - - double DefX = rElementalVariables.SpatialDefRate[0]; - double DefY = rElementalVariables.SpatialDefRate[1]; - double DefZ = rElementalVariables.SpatialDefRate[2]; - double DefXY = rElementalVariables.SpatialDefRate[3]; - double DefXZ = rElementalVariables.SpatialDefRate[4]; - double DefYZ = rElementalVariables.SpatialDefRate[5]; - - double DefVol = rElementalVariables.VolumetricDefRate; - - double sigmaDev_xx = 2 * CurrSecondLame * (DefX - DefVol / 3.0); - double sigmaDev_yy = 2 * CurrSecondLame * (DefY - DefVol / 3.0); - double sigmaDev_zz = 2 * CurrSecondLame * (DefZ - DefVol / 3.0); - double sigmaDev_xy = 2 * CurrSecondLame * DefXY; - double sigmaDev_xz = 2 * CurrSecondLame * DefXZ; - double sigmaDev_yz = 2 * CurrSecondLame * DefYZ; - - sigmaDev_xx += rElementalVariables.CurrentDeviatoricCauchyStress[0]; - sigmaDev_yy += rElementalVariables.CurrentDeviatoricCauchyStress[1]; - sigmaDev_zz += rElementalVariables.CurrentDeviatoricCauchyStress[2]; - sigmaDev_xy += rElementalVariables.CurrentDeviatoricCauchyStress[3]; - sigmaDev_xz += rElementalVariables.CurrentDeviatoricCauchyStress[4]; - sigmaDev_yz += rElementalVariables.CurrentDeviatoricCauchyStress[5]; - - double sigmaTot_xx = sigmaDev_xx + rElementalVariables.MeanPressure; - double sigmaTot_yy = sigmaDev_yy + rElementalVariables.MeanPressure; - double sigmaTot_zz = sigmaDev_zz + rElementalVariables.MeanPressure; - double sigmaTot_xy = sigmaDev_xy; - double sigmaTot_xz = sigmaDev_xz; - double sigmaTot_yz = sigmaDev_yz; - - rElementalVariables.UpdatedDeviatoricCauchyStress[0] = sigmaDev_xx; - rElementalVariables.UpdatedDeviatoricCauchyStress[1] = sigmaDev_yy; - rElementalVariables.UpdatedDeviatoricCauchyStress[2] = sigmaDev_zz; - rElementalVariables.UpdatedDeviatoricCauchyStress[3] = sigmaDev_xy; - rElementalVariables.UpdatedDeviatoricCauchyStress[4] = sigmaDev_xz; - rElementalVariables.UpdatedDeviatoricCauchyStress[5] = sigmaDev_yz; - - rElementalVariables.UpdatedTotalCauchyStress[0] = sigmaTot_xx; - rElementalVariables.UpdatedTotalCauchyStress[1] = sigmaTot_yy; - rElementalVariables.UpdatedTotalCauchyStress[2] = sigmaTot_zz; - rElementalVariables.UpdatedTotalCauchyStress[3] = sigmaTot_xy; - rElementalVariables.UpdatedTotalCauchyStress[4] = sigmaTot_xz; - rElementalVariables.UpdatedTotalCauchyStress[5] = sigmaTot_yz; - - this->mCurrentTotalCauchyStress[g] = rElementalVariables.CurrentTotalCauchyStress; + mpConstitutiveLaw = this->GetProperties().GetValue(CONSTITUTIVE_LAW); + auto constitutive_law_values = + ConstitutiveLaw::Parameters(this->GetGeometry(), this->GetProperties(), rCurrentProcessInfo); + + Flags &constitutive_law_options = constitutive_law_values.GetOptions(); + constitutive_law_options.Set(ConstitutiveLaw::COMPUTE_STRESS, true); + constitutive_law_options.Set(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR, false); + + const Vector &r_shape_functions = row((this->GetGeometry()).ShapeFunctionsValues(), g); + constitutive_law_values.SetShapeFunctionsValues(r_shape_functions); + constitutive_law_values.SetStrainVector(rElementalVariables.SpatialDefRate); + constitutive_law_values.SetStressVector(rElementalVariables.CurrentDeviatoricCauchyStress); + + mpConstitutiveLaw->CalculateMaterialResponseCauchy(constitutive_law_values); + + rElementalVariables.UpdatedDeviatoricCauchyStress[0] = rElementalVariables.CurrentDeviatoricCauchyStress[0]; + rElementalVariables.UpdatedDeviatoricCauchyStress[1] = rElementalVariables.CurrentDeviatoricCauchyStress[1]; + rElementalVariables.UpdatedDeviatoricCauchyStress[2] = rElementalVariables.CurrentDeviatoricCauchyStress[2]; + rElementalVariables.UpdatedDeviatoricCauchyStress[3] = rElementalVariables.CurrentDeviatoricCauchyStress[3]; + rElementalVariables.UpdatedDeviatoricCauchyStress[4] = rElementalVariables.CurrentDeviatoricCauchyStress[4]; + rElementalVariables.UpdatedDeviatoricCauchyStress[5] = rElementalVariables.CurrentDeviatoricCauchyStress[5]; + + rElementalVariables.UpdatedTotalCauchyStress[0] = + rElementalVariables.CurrentDeviatoricCauchyStress[0] + rElementalVariables.MeanPressure; + rElementalVariables.UpdatedTotalCauchyStress[1] = + rElementalVariables.CurrentDeviatoricCauchyStress[1] + rElementalVariables.MeanPressure; + rElementalVariables.UpdatedTotalCauchyStress[2] = + rElementalVariables.CurrentDeviatoricCauchyStress[2] + rElementalVariables.MeanPressure; + rElementalVariables.UpdatedTotalCauchyStress[3] = rElementalVariables.CurrentDeviatoricCauchyStress[3]; + rElementalVariables.UpdatedTotalCauchyStress[4] = rElementalVariables.CurrentDeviatoricCauchyStress[4]; + rElementalVariables.UpdatedTotalCauchyStress[5] = rElementalVariables.CurrentDeviatoricCauchyStress[5]; + + rElementalVariables.UpdatedDeviatoricCauchyStress[0] = rElementalVariables.CurrentDeviatoricCauchyStress[0]; + rElementalVariables.UpdatedDeviatoricCauchyStress[1] = rElementalVariables.CurrentDeviatoricCauchyStress[1]; + rElementalVariables.UpdatedDeviatoricCauchyStress[2] = rElementalVariables.CurrentDeviatoricCauchyStress[2]; + rElementalVariables.UpdatedDeviatoricCauchyStress[3] = rElementalVariables.CurrentDeviatoricCauchyStress[3]; + rElementalVariables.UpdatedDeviatoricCauchyStress[4] = rElementalVariables.CurrentDeviatoricCauchyStress[4]; + rElementalVariables.UpdatedDeviatoricCauchyStress[5] = rElementalVariables.CurrentDeviatoricCauchyStress[5]; + this->mUpdatedTotalCauchyStress[g] = rElementalVariables.UpdatedTotalCauchyStress; - this->mCurrentDeviatoricCauchyStress[g] = rElementalVariables.CurrentDeviatoricCauchyStress; this->mUpdatedDeviatoricCauchyStress[g] = rElementalVariables.UpdatedDeviatoricCauchyStress; + + Density = mpConstitutiveLaw->CalculateValue(constitutive_law_values, DENSITY, Density); + + double poisson_ratio = mpConstitutiveLaw->CalculateValue(constitutive_law_values, POISSON_RATIO, poisson_ratio); + double young_modulus = mpConstitutiveLaw->CalculateValue(constitutive_law_values, YOUNG_MODULUS, young_modulus); + const double time_step = rCurrentProcessInfo[DELTA_TIME]; + DeviatoricCoeff = time_step * young_modulus / (2.0 * (1.0 + poisson_ratio)); + VolumetricCoeff = + time_step * poisson_ratio * young_modulus / ((1.0 + poisson_ratio) * (1.0 - 2.0 * poisson_ratio)) + + 2.0 / 3.0 * DeviatoricCoeff; + + this->mMaterialDeviatoricCoefficient = DeviatoricCoeff; + this->mMaterialVolumetricCoefficient = VolumetricCoeff; + this->mMaterialDensity = Density; } template diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/updated_lagrangian_V_implicit_solid_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/updated_lagrangian_V_implicit_solid_element.cpp index b1e579d47a01..e389462de574 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/updated_lagrangian_V_implicit_solid_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/updated_lagrangian_V_implicit_solid_element.cpp @@ -69,45 +69,55 @@ Element::Pointer UpdatedLagrangianVImplicitSolidElement::Clone(IndexType N template <> void UpdatedLagrangianVImplicitSolidElement<2>::CalcElasticPlasticCauchySplitted( - ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, const ProcessInfo &rCurrentProcessInfo) { - rElementalVariables.CurrentTotalCauchyStress = this->mCurrentTotalCauchyStress[g]; - rElementalVariables.CurrentDeviatoricCauchyStress = this->mCurrentDeviatoricCauchyStress[g]; + ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, const ProcessInfo &rCurrentProcessInfo, + double &Density, double &DeviatoricCoeff, double &VolumetricCoeff) { + + mpConstitutiveLaw = this->GetProperties().GetValue(CONSTITUTIVE_LAW); + auto constitutive_law_values = + ConstitutiveLaw::Parameters(this->GetGeometry(), this->GetProperties(), rCurrentProcessInfo); - double CurrSecondLame = this->mMaterialDeviatoricCoefficient; - double CurrBulkModulus = this->mMaterialVolumetricCoefficient; + Flags &constitutive_law_options = constitutive_law_values.GetOptions(); + constitutive_law_options.Set(ConstitutiveLaw::COMPUTE_STRESS, true); + constitutive_law_options.Set(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR, false); - double CurrFirstLame = 0; - CurrFirstLame = CurrBulkModulus - 2.0 * CurrSecondLame / 3.0; + rElementalVariables.CurrentTotalCauchyStress = this->mCurrentTotalCauchyStress[g]; + rElementalVariables.CurrentDeviatoricCauchyStress = this->mCurrentDeviatoricCauchyStress[g]; - double DefX = rElementalVariables.SpatialDefRate[0]; - double DefY = rElementalVariables.SpatialDefRate[1]; - double DefXY = rElementalVariables.SpatialDefRate[2]; + const Vector &r_shape_functions = row((this->GetGeometry()).ShapeFunctionsValues(), g); + constitutive_law_values.SetShapeFunctionsValues(r_shape_functions); + constitutive_law_values.SetStrainVector(rElementalVariables.SpatialDefRate); + constitutive_law_values.SetStressVector(rElementalVariables.CurrentDeviatoricCauchyStress); - double DefVol = rElementalVariables.VolumetricDefRate; + mpConstitutiveLaw->CalculateMaterialResponseCauchy(constitutive_law_values); - double sigmaDev_xx = 2 * CurrSecondLame * (DefX - DefVol / 3.0); - double sigmaDev_yy = 2 * CurrSecondLame * (DefY - DefVol / 3.0); - double sigmaDev_xy = 2 * CurrSecondLame * DefXY; + Density = mpConstitutiveLaw->CalculateValue(constitutive_law_values, DENSITY, Density); - double sigmaTot_xx = CurrFirstLame * DefVol + 2.0 * CurrSecondLame * DefX; - double sigmaTot_yy = CurrFirstLame * DefVol + 2.0 * CurrSecondLame * DefY; - double sigmaTot_xy = 2.0 * CurrSecondLame * DefXY; + double poisson_ratio = mpConstitutiveLaw->CalculateValue(constitutive_law_values, POISSON_RATIO, poisson_ratio); + double young_modulus = mpConstitutiveLaw->CalculateValue(constitutive_law_values, YOUNG_MODULUS, young_modulus); + const double time_step = rCurrentProcessInfo[DELTA_TIME]; + DeviatoricCoeff = time_step * young_modulus / (2.0 * (1 + poisson_ratio)); + VolumetricCoeff = + time_step * poisson_ratio * young_modulus / ((1.0 + poisson_ratio) * (1.0 - 2.0 * poisson_ratio)) + + 2.0 / 3.0 * DeviatoricCoeff; - sigmaDev_xx += rElementalVariables.CurrentDeviatoricCauchyStress[0]; - sigmaDev_yy += rElementalVariables.CurrentDeviatoricCauchyStress[1]; - sigmaDev_xy += rElementalVariables.CurrentDeviatoricCauchyStress[2]; + const double current_first_lame = VolumetricCoeff - 2.0 / 3.0 * DeviatoricCoeff; - sigmaTot_xx += rElementalVariables.CurrentTotalCauchyStress[0]; - sigmaTot_yy += rElementalVariables.CurrentTotalCauchyStress[1]; - sigmaTot_xy += rElementalVariables.CurrentTotalCauchyStress[2]; + this->mMaterialDeviatoricCoefficient = DeviatoricCoeff; + this->mMaterialVolumetricCoefficient = VolumetricCoeff; + this->mMaterialDensity = Density; - rElementalVariables.UpdatedDeviatoricCauchyStress[0] = sigmaDev_xx; - rElementalVariables.UpdatedDeviatoricCauchyStress[1] = sigmaDev_yy; - rElementalVariables.UpdatedDeviatoricCauchyStress[2] = sigmaDev_xy; + rElementalVariables.UpdatedDeviatoricCauchyStress[0] = rElementalVariables.CurrentDeviatoricCauchyStress[0]; + rElementalVariables.UpdatedDeviatoricCauchyStress[1] = rElementalVariables.CurrentDeviatoricCauchyStress[1]; + rElementalVariables.UpdatedDeviatoricCauchyStress[2] = rElementalVariables.CurrentDeviatoricCauchyStress[2]; - rElementalVariables.UpdatedTotalCauchyStress[0] = sigmaTot_xx; - rElementalVariables.UpdatedTotalCauchyStress[1] = sigmaTot_yy; - rElementalVariables.UpdatedTotalCauchyStress[2] = sigmaTot_xy; + rElementalVariables.UpdatedTotalCauchyStress[0] = +current_first_lame * rElementalVariables.VolumetricDefRate + + 2.0 * DeviatoricCoeff * rElementalVariables.SpatialDefRate[0] + + rElementalVariables.CurrentTotalCauchyStress[0]; + rElementalVariables.UpdatedTotalCauchyStress[1] = current_first_lame * rElementalVariables.VolumetricDefRate + + 2.0 * DeviatoricCoeff * rElementalVariables.SpatialDefRate[1] + + rElementalVariables.CurrentTotalCauchyStress[1]; + rElementalVariables.UpdatedTotalCauchyStress[2] = + 2.0 * DeviatoricCoeff * rElementalVariables.SpatialDefRate[2] + rElementalVariables.CurrentTotalCauchyStress[2]; this->mUpdatedTotalCauchyStress[g] = rElementalVariables.UpdatedTotalCauchyStress; this->mUpdatedDeviatoricCauchyStress[g] = rElementalVariables.UpdatedDeviatoricCauchyStress; @@ -115,70 +125,67 @@ void UpdatedLagrangianVImplicitSolidElement<2>::CalcElasticPlasticCauchySplitted template <> void UpdatedLagrangianVImplicitSolidElement<3>::CalcElasticPlasticCauchySplitted( - ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, const ProcessInfo &rCurrentProcessInfo) { + ElementalVariables &rElementalVariables, double TimeStep, unsigned int g, const ProcessInfo &rCurrentProcessInfo, + double &Density, double &DeviatoricCoeff, double &VolumetricCoeff) { + + mpConstitutiveLaw = this->GetProperties().GetValue(CONSTITUTIVE_LAW); + auto constitutive_law_values = + ConstitutiveLaw::Parameters(this->GetGeometry(), this->GetProperties(), rCurrentProcessInfo); + + Flags &constitutive_law_options = constitutive_law_values.GetOptions(); + constitutive_law_options.Set(ConstitutiveLaw::COMPUTE_STRESS, true); + constitutive_law_options.Set(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR, false); + rElementalVariables.CurrentTotalCauchyStress = this->mCurrentTotalCauchyStress[g]; rElementalVariables.CurrentDeviatoricCauchyStress = this->mCurrentDeviatoricCauchyStress[g]; - double CurrSecondLame = this->mMaterialDeviatoricCoefficient; - double CurrBulkModulus = this->mMaterialVolumetricCoefficient; - - double CurrFirstLame = 0; - CurrFirstLame = CurrBulkModulus - 2.0 * CurrSecondLame / 3.0; - - double DefX = rElementalVariables.SpatialDefRate[0]; - double DefY = rElementalVariables.SpatialDefRate[1]; - double DefZ = rElementalVariables.SpatialDefRate[2]; - double DefXY = rElementalVariables.SpatialDefRate[3]; - double DefXZ = rElementalVariables.SpatialDefRate[4]; - double DefYZ = rElementalVariables.SpatialDefRate[5]; - - double DefVol = rElementalVariables.VolumetricDefRate; - - double sigmaDev_xx = 2 * CurrSecondLame * (DefX - DefVol / 3.0); - double sigmaDev_yy = 2 * CurrSecondLame * (DefY - DefVol / 3.0); - double sigmaDev_zz = 2 * CurrSecondLame * (DefZ - DefVol / 3.0); - double sigmaDev_xy = 2 * CurrSecondLame * DefXY; - double sigmaDev_xz = 2 * CurrSecondLame * DefXZ; - double sigmaDev_yz = 2 * CurrSecondLame * DefYZ; - - double sigmaTot_xx = CurrFirstLame * DefVol + 2 * CurrSecondLame * DefX; - double sigmaTot_yy = CurrFirstLame * DefVol + 2 * CurrSecondLame * DefY; - double sigmaTot_zz = CurrFirstLame * DefVol + 2 * CurrSecondLame * DefZ; - double sigmaTot_xy = 2 * CurrSecondLame * DefXY; - double sigmaTot_xz = 2 * CurrSecondLame * DefXZ; - double sigmaTot_yz = 2 * CurrSecondLame * DefYZ; - - sigmaDev_xx += rElementalVariables.CurrentDeviatoricCauchyStress[0]; - sigmaDev_yy += rElementalVariables.CurrentDeviatoricCauchyStress[1]; - sigmaDev_zz += rElementalVariables.CurrentDeviatoricCauchyStress[2]; - sigmaDev_xy += rElementalVariables.CurrentDeviatoricCauchyStress[3]; - sigmaDev_xz += rElementalVariables.CurrentDeviatoricCauchyStress[4]; - sigmaDev_yz += rElementalVariables.CurrentDeviatoricCauchyStress[5]; - - sigmaTot_xx += rElementalVariables.CurrentTotalCauchyStress[0]; - sigmaTot_yy += rElementalVariables.CurrentTotalCauchyStress[1]; - sigmaTot_zz += rElementalVariables.CurrentTotalCauchyStress[2]; - sigmaTot_xy += rElementalVariables.CurrentTotalCauchyStress[3]; - sigmaTot_xz += rElementalVariables.CurrentTotalCauchyStress[4]; - sigmaTot_yz += rElementalVariables.CurrentTotalCauchyStress[5]; - - rElementalVariables.UpdatedDeviatoricCauchyStress[0] = sigmaDev_xx; - rElementalVariables.UpdatedDeviatoricCauchyStress[1] = sigmaDev_yy; - rElementalVariables.UpdatedDeviatoricCauchyStress[2] = sigmaDev_zz; - rElementalVariables.UpdatedDeviatoricCauchyStress[3] = sigmaDev_xy; - rElementalVariables.UpdatedDeviatoricCauchyStress[4] = sigmaDev_xz; - rElementalVariables.UpdatedDeviatoricCauchyStress[5] = sigmaDev_yz; - - rElementalVariables.UpdatedTotalCauchyStress[0] = sigmaTot_xx; - rElementalVariables.UpdatedTotalCauchyStress[1] = sigmaTot_yy; - rElementalVariables.UpdatedTotalCauchyStress[2] = sigmaTot_zz; - rElementalVariables.UpdatedTotalCauchyStress[3] = sigmaTot_xy; - rElementalVariables.UpdatedTotalCauchyStress[4] = sigmaTot_xz; - rElementalVariables.UpdatedTotalCauchyStress[5] = sigmaTot_yz; - - this->mCurrentTotalCauchyStress[g] = rElementalVariables.CurrentTotalCauchyStress; + const Vector &r_shape_functions = row((this->GetGeometry()).ShapeFunctionsValues(), g); + constitutive_law_values.SetShapeFunctionsValues(r_shape_functions); + constitutive_law_values.SetStrainVector(rElementalVariables.SpatialDefRate); + constitutive_law_values.SetStressVector(rElementalVariables.CurrentDeviatoricCauchyStress); + + mpConstitutiveLaw->CalculateMaterialResponseCauchy(constitutive_law_values); + + Density = mpConstitutiveLaw->CalculateValue(constitutive_law_values, DENSITY, Density); + + double poisson_ratio = mpConstitutiveLaw->CalculateValue(constitutive_law_values, POISSON_RATIO, poisson_ratio); + double young_modulus = mpConstitutiveLaw->CalculateValue(constitutive_law_values, YOUNG_MODULUS, young_modulus); + const double time_step = rCurrentProcessInfo[DELTA_TIME]; + DeviatoricCoeff = time_step * young_modulus / (2.0 * (1 + poisson_ratio)); + VolumetricCoeff = + time_step * poisson_ratio * young_modulus / ((1.0 + poisson_ratio) * (1.0 - 2.0 * poisson_ratio)) + + 2.0 / 3.0 * DeviatoricCoeff; + + const double current_first_lame = VolumetricCoeff - 2.0 / 3.0 * DeviatoricCoeff; + + this->mMaterialDeviatoricCoefficient = DeviatoricCoeff; + this->mMaterialVolumetricCoefficient = VolumetricCoeff; + this->mMaterialDensity = Density; + + rElementalVariables.UpdatedDeviatoricCauchyStress[0] = rElementalVariables.CurrentDeviatoricCauchyStress[0]; + rElementalVariables.UpdatedDeviatoricCauchyStress[1] = rElementalVariables.CurrentDeviatoricCauchyStress[1]; + rElementalVariables.UpdatedDeviatoricCauchyStress[2] = rElementalVariables.CurrentDeviatoricCauchyStress[2]; + rElementalVariables.UpdatedDeviatoricCauchyStress[3] = rElementalVariables.CurrentDeviatoricCauchyStress[3]; + rElementalVariables.UpdatedDeviatoricCauchyStress[4] = rElementalVariables.CurrentDeviatoricCauchyStress[4]; + rElementalVariables.UpdatedDeviatoricCauchyStress[5] = rElementalVariables.CurrentDeviatoricCauchyStress[5]; + + rElementalVariables.UpdatedTotalCauchyStress[0] = +current_first_lame * rElementalVariables.VolumetricDefRate + + 2.0 * DeviatoricCoeff * rElementalVariables.SpatialDefRate[0] + + rElementalVariables.CurrentTotalCauchyStress[0]; + rElementalVariables.UpdatedTotalCauchyStress[1] = current_first_lame * rElementalVariables.VolumetricDefRate + + 2.0 * DeviatoricCoeff * rElementalVariables.SpatialDefRate[1] + + rElementalVariables.CurrentTotalCauchyStress[1]; + rElementalVariables.UpdatedTotalCauchyStress[2] = current_first_lame * rElementalVariables.VolumetricDefRate + + 2.0 * DeviatoricCoeff * rElementalVariables.SpatialDefRate[2] + + rElementalVariables.CurrentTotalCauchyStress[2]; + rElementalVariables.UpdatedTotalCauchyStress[3] = + 2.0 * DeviatoricCoeff * rElementalVariables.SpatialDefRate[3] + rElementalVariables.CurrentTotalCauchyStress[3]; + rElementalVariables.UpdatedTotalCauchyStress[4] = + 2.0 * DeviatoricCoeff * rElementalVariables.SpatialDefRate[4] + rElementalVariables.CurrentTotalCauchyStress[4]; + rElementalVariables.UpdatedTotalCauchyStress[5] = + 2.0 * DeviatoricCoeff * rElementalVariables.SpatialDefRate[5] + rElementalVariables.CurrentTotalCauchyStress[5]; + this->mUpdatedTotalCauchyStress[g] = rElementalVariables.UpdatedTotalCauchyStress; - this->mCurrentDeviatoricCauchyStress[g] = rElementalVariables.CurrentDeviatoricCauchyStress; this->mUpdatedDeviatoricCauchyStress[g] = rElementalVariables.UpdatedDeviatoricCauchyStress; } From 9f0783a72cccb8f7e2f252067c4c33211338a091 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Mon, 2 Mar 2020 18:06:38 +0100 Subject: [PATCH 27/47] Updating PFEM tests --- .../Test_2D_Bingham/PfemFluidDynamicsMaterials.json | 3 +++ .../Test_2D_FSI/PfemFluidDynamicsMaterials.json | 6 ++++++ .../PfemFluidDynamicsMaterials.json | 3 +++ .../Test_2D_muIrheology/PfemFluidDynamicsMaterials.json | 3 +++ .../PfemFluidDynamicsMaterials.json | 3 +++ 5 files changed, 18 insertions(+) diff --git a/applications/PfemFluidDynamicsApplication/tests/fluid_element_tests/Test_2D_Bingham/PfemFluidDynamicsMaterials.json b/applications/PfemFluidDynamicsApplication/tests/fluid_element_tests/Test_2D_Bingham/PfemFluidDynamicsMaterials.json index 60987b0f4757..5e8303f9e636 100644 --- a/applications/PfemFluidDynamicsApplication/tests/fluid_element_tests/Test_2D_Bingham/PfemFluidDynamicsMaterials.json +++ b/applications/PfemFluidDynamicsApplication/tests/fluid_element_tests/Test_2D_Bingham/PfemFluidDynamicsMaterials.json @@ -3,6 +3,9 @@ "model_part_name" : "PfemFluidModelPart.Parts_Parts_Auto1", "properties_id" : 1, "Material" : { + "constitutive_law" : { + "name" : "Bingham2DLaw" + }, "Variables" : { "DENSITY" : 1550.0, "DYNAMIC_VISCOSITY" : 1.0, diff --git a/applications/PfemFluidDynamicsApplication/tests/fluid_element_tests/Test_2D_FSI/PfemFluidDynamicsMaterials.json b/applications/PfemFluidDynamicsApplication/tests/fluid_element_tests/Test_2D_FSI/PfemFluidDynamicsMaterials.json index 07d4fab071fe..49be464ab3d2 100644 --- a/applications/PfemFluidDynamicsApplication/tests/fluid_element_tests/Test_2D_FSI/PfemFluidDynamicsMaterials.json +++ b/applications/PfemFluidDynamicsApplication/tests/fluid_element_tests/Test_2D_FSI/PfemFluidDynamicsMaterials.json @@ -3,6 +3,9 @@ "model_part_name" : "PfemFluidModelPart.Parts_Parts_Auto4", "properties_id" : 1, "Material" : { + "constitutive_law" : { + "name" : "Newtonian2DLaw" + }, "Variables" : { "DENSITY" : 1000.0, "DYNAMIC_VISCOSITY" : 0.001, @@ -14,6 +17,9 @@ "model_part_name" : "PfemFluidModelPart.Parts_Parts_Auto5", "properties_id" : 2, "Material" : { + "constitutive_law" : { + "name" : "Hypoelastic2DLaw" + }, "Variables" : { "DENSITY" : 2500.0, "YOUNG_MODULUS" : 1000000.0, diff --git a/applications/PfemFluidDynamicsApplication/tests/fluid_element_tests/Test_2D_Newtonian_Sloshing/PfemFluidDynamicsMaterials.json b/applications/PfemFluidDynamicsApplication/tests/fluid_element_tests/Test_2D_Newtonian_Sloshing/PfemFluidDynamicsMaterials.json index 5ba1bfb948c9..695d8f54779c 100644 --- a/applications/PfemFluidDynamicsApplication/tests/fluid_element_tests/Test_2D_Newtonian_Sloshing/PfemFluidDynamicsMaterials.json +++ b/applications/PfemFluidDynamicsApplication/tests/fluid_element_tests/Test_2D_Newtonian_Sloshing/PfemFluidDynamicsMaterials.json @@ -3,6 +3,9 @@ "model_part_name" : "PfemFluidModelPart.Parts_Parts_Auto1", "properties_id" : 1, "Material" : { + "constitutive_law" : { + "name" : "Newtonian2DLaw" + }, "Variables" : { "DENSITY" : 1000.0, "DYNAMIC_VISCOSITY" : 0.001, diff --git a/applications/PfemFluidDynamicsApplication/tests/fluid_element_tests/Test_2D_muIrheology/PfemFluidDynamicsMaterials.json b/applications/PfemFluidDynamicsApplication/tests/fluid_element_tests/Test_2D_muIrheology/PfemFluidDynamicsMaterials.json index 4d26a39696df..bda4a33931d7 100644 --- a/applications/PfemFluidDynamicsApplication/tests/fluid_element_tests/Test_2D_muIrheology/PfemFluidDynamicsMaterials.json +++ b/applications/PfemFluidDynamicsApplication/tests/fluid_element_tests/Test_2D_muIrheology/PfemFluidDynamicsMaterials.json @@ -3,6 +3,9 @@ "model_part_name" : "PfemFluidModelPart.Parts_Parts_Auto1", "properties_id" : 1, "Material" : { + "constitutive_law" : { + "name" : "PapanastasiouMuIRheology2DLaw" + }, "Variables" : { "DENSITY" : 1550.0, "BULK_MODULUS" : 2100000000.0, diff --git a/applications/PfemFluidDynamicsApplication/tests/fluid_element_tests/Test_3D_Newtonian_Sloshing/PfemFluidDynamicsMaterials.json b/applications/PfemFluidDynamicsApplication/tests/fluid_element_tests/Test_3D_Newtonian_Sloshing/PfemFluidDynamicsMaterials.json index 5ba1bfb948c9..cb01efc2653f 100644 --- a/applications/PfemFluidDynamicsApplication/tests/fluid_element_tests/Test_3D_Newtonian_Sloshing/PfemFluidDynamicsMaterials.json +++ b/applications/PfemFluidDynamicsApplication/tests/fluid_element_tests/Test_3D_Newtonian_Sloshing/PfemFluidDynamicsMaterials.json @@ -3,6 +3,9 @@ "model_part_name" : "PfemFluidModelPart.Parts_Parts_Auto1", "properties_id" : 1, "Material" : { + "constitutive_law" : { + "name" : "Newtonian3DLaw" + }, "Variables" : { "DENSITY" : 1000.0, "DYNAMIC_VISCOSITY" : 0.001, From 98b9c0a2b7cedb99f20d381d1fc1db4e0ee8562d Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Mon, 2 Mar 2020 18:25:31 +0100 Subject: [PATCH 28/47] Add solid claw base class --- .../solid_laws/solid_constitutive_law.cpp | 174 ++++++++++++++++ .../solid_laws/solid_constitutive_law.h | 191 ++++++++++++++++++ 2 files changed, 365 insertions(+) create mode 100644 applications/PfemFluidDynamicsApplication/custom_constitutive/solid_laws/solid_constitutive_law.cpp create mode 100644 applications/PfemFluidDynamicsApplication/custom_constitutive/solid_laws/solid_constitutive_law.h diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/solid_laws/solid_constitutive_law.cpp b/applications/PfemFluidDynamicsApplication/custom_constitutive/solid_laws/solid_constitutive_law.cpp new file mode 100644 index 000000000000..40f91ea68263 --- /dev/null +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/solid_laws/solid_constitutive_law.cpp @@ -0,0 +1,174 @@ +//------------------------------------------------------------- +// ___ __ ___ _ _ _ +// KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| | +// | _/ _/ -_) ' \| _|| | || | / _` | +// |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS +// +// BSD License: PfemFluidDynamicsApplication/license.txt +// +// Main authors: Jordi Cotela +// Collaborators: Massimiliano Zecchetto +// +//------------------------------------------------------------- +// + +#include "solid_constitutive_law.h" + +namespace Kratos { + +// Life cycle ///////////////////////////////////////////////////////////////// + +PfemSolidConstitutiveLaw::PfemSolidConstitutiveLaw() : ConstitutiveLaw() {} + +PfemSolidConstitutiveLaw::PfemSolidConstitutiveLaw(const PfemSolidConstitutiveLaw& rOther) : ConstitutiveLaw(rOther) {} + +PfemSolidConstitutiveLaw::~PfemSolidConstitutiveLaw() {} + +// Public operations ////////////////////////////////////////////////////////// + +ConstitutiveLaw::Pointer PfemSolidConstitutiveLaw::Clone() const { + KRATOS_ERROR << "Calling base PfemSolidConstitutiveLaw::Clone method. This " + "class should not be instantiated. Please check your " + "constitutive law." + << std::endl; + return Kratos::make_shared(*this); +} + +void PfemSolidConstitutiveLaw::CalculateMaterialResponseCauchy(Parameters& rValues) { + KRATOS_ERROR << "Calling base " + "PfemSolidConstitutiveLaw::CalculateMaterialResponseCauchy " + "method. This class should not be instantiated. Please " + "check your constitutive law." + << std::endl; +} + +int PfemSolidConstitutiveLaw::Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, + const ProcessInfo& rCurrentProcessInfo) { + KRATOS_ERROR << "Calling base " + "PfemSolidConstitutiveLaw::Check " + "method. This class should not be instantiated. Please " + "check your constitutive law." + << std::endl; + return 999; +} + +// Access ///////////////////////////////////////////////////////////////////// + +double& PfemSolidConstitutiveLaw::CalculateValue(ConstitutiveLaw::Parameters& rParameters, + const Variable& rThisVariable, double& rValue) { + if (rThisVariable.Name() == "DENSITY") { + rValue = this->GetEffectiveDensity(rParameters); + } else if (rThisVariable.Name() == "YOUNG_MODULUS") { + rValue = this->GetEffectiveYoungModulus(rParameters); + } else if (rThisVariable.Name() == "POISSON_RATIO") { + rValue = this->GetEffectivePoissonRatio(rParameters); + } else { + KRATOS_ERROR << " An unexpected property has been passed " << std::endl; + } + return rValue; +} + +// Inquiry //////////////////////////////////////////////////////////////////// + +ConstitutiveLaw::SizeType PfemSolidConstitutiveLaw::WorkingSpaceDimension() { + KRATOS_ERROR << "Calling base " + "PfemSolidConstitutiveLaw::WorkingSpaceDimension " + "method. This class should not be instantiated. Please " + "check your constitutive law." + << std::endl; + return 0; +} + +ConstitutiveLaw::SizeType PfemSolidConstitutiveLaw::GetStrainSize() { + KRATOS_ERROR << "Calling base " + "PfemSolidConstitutiveLaw::GetStrainSize " + "method. This class should not be instantiated. Please " + "check your constitutive law." + << std::endl; + return 0; +} + +// Info /////////////////////////////////////////////////////////////////////// + +std::string PfemSolidConstitutiveLaw::Info() const { return "PfemSolidConstitutiveLaw"; } + +void PfemSolidConstitutiveLaw::PrintInfo(std::ostream& rOStream) const { rOStream << this->Info(); } + +void PfemSolidConstitutiveLaw::PrintData(std::ostream& rOStream) const { rOStream << this->Info(); } + +// Protected operations /////////////////////////////////////////////////////// + +// Protected access /////////////////////////////////////////////////////////// + +double PfemSolidConstitutiveLaw::GetEffectiveYoungModulus(ConstitutiveLaw::Parameters& rParameters) const { + KRATOS_ERROR << "Accessing base class PfemSolidConstitutiveLaw::GetEffectiveYoungModulus." << std::endl; + return 0.0; +} + +double PfemSolidConstitutiveLaw::GetEffectivePoissonRatio(ConstitutiveLaw::Parameters& rParameters) const { + KRATOS_ERROR << "Accessing base class PfemSolidConstitutiveLaw::GetEffectivePoissonRatio." << std::endl; + return 0.0; +} + +double PfemSolidConstitutiveLaw::GetEffectiveDensity(ConstitutiveLaw::Parameters& rParameters) const { + KRATOS_ERROR << "Accessing base class PfemSolidConstitutiveLaw::GetEffectiveDensity." << std::endl; + return 0.0; +} + +double PfemSolidConstitutiveLaw::CalculateAveragedVariable(const Variable& rVariableInput, + ConstitutiveLaw::Parameters& rParameters, + unsigned int step) const { + const GeometryType& r_geometry = rParameters.GetElementGeometry(); + const unsigned int number_of_nodes = r_geometry.size(); + + double result = 0; + for (unsigned int i = 0; i < number_of_nodes; i++) { + result += r_geometry[i].FastGetSolutionStepValue(rVariableInput, step); + } + result /= number_of_nodes; + + return result; +} + +double PfemSolidConstitutiveLaw::GetValueFromTable(const Variable& rIndependentVariable, + const Variable& rDependentVariable, + ConstitutiveLaw::Parameters& rParameters) const { + // Get material properties from constitutive law parameters + const Properties& r_properties = rParameters.GetMaterialProperties(); + + double dependent_at_gauss; + if (r_properties.HasTable(rIndependentVariable, rDependentVariable)) { + // Get geometry and Gauss points data + const auto& r_geometry = rParameters.GetElementGeometry(); + const auto& r_N = rParameters.GetShapeFunctionsValues(); + + // Compute the independent variable at the Gauss point + double independent_at_gauss = 0.0; + for (unsigned int i = 0; i < r_N.size(); ++i) { + const double& r_val = r_geometry[i].FastGetSolutionStepValue(rIndependentVariable); + independent_at_gauss += r_val * r_N[i]; + } + + // Retrieve the dependent variable from the table + const auto& r_table = r_properties.GetTable(rIndependentVariable, rDependentVariable); + dependent_at_gauss = r_table.GetValue(independent_at_gauss); + + } else { + KRATOS_ERROR << "PfemFluidConstitutiveLaw " << this->Info() << " has no table with variables " + << rIndependentVariable << " " << rDependentVariable << std::endl; + } + + return dependent_at_gauss; +} + +// Serialization ////////////////////////////////////////////////////////////// + +void PfemSolidConstitutiveLaw::save(Serializer& rSerializer) const { + KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, ConstitutiveLaw); +} + +void PfemSolidConstitutiveLaw::load(Serializer& rSerializer) { + KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, ConstitutiveLaw); +} + +} // namespace Kratos diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/solid_laws/solid_constitutive_law.h b/applications/PfemFluidDynamicsApplication/custom_constitutive/solid_laws/solid_constitutive_law.h new file mode 100644 index 000000000000..82f1598ff254 --- /dev/null +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/solid_laws/solid_constitutive_law.h @@ -0,0 +1,191 @@ +//------------------------------------------------------------- +// ___ __ ___ _ _ _ +// KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| | +// | _/ _/ -_) ' \| _|| | || | / _` | +// |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS +// +// BSD License: PfemFluidDynamicsApplication/license.txt +// +// Main authors: Jordi Cotela +// Collaborators: Massimiliano Zecchetto +// +//------------------------------------------------------------- +// + +#if !defined(KRATOS_PFEM_SOLID_CONSTITUTIVE_LAW) +#define KRATOS_PFEM_SOLID_CONSTITUTIVE_LAW + +// System includes + +// External includes + +// Project includes +#include "includes/constitutive_law.h" + +namespace Kratos { + +///@addtogroup FluidDynamicsApplication +///@{ + +///@name Kratos Classes +///@{ + +/// This class contains the common infrastructure for solid constitutive laws. +class KRATOS_API(PFEM_FLUID_DYNAMICS_APPLICATION) PfemSolidConstitutiveLaw : public ConstitutiveLaw { + public: + ///@name Type Definitions + ///@{ + + KRATOS_CLASS_POINTER_DEFINITION(PfemSolidConstitutiveLaw); + + typedef ConstitutiveLaw BaseType; + typedef std::size_t SizeType; + + ///@} + ///@name Life Cycle + ///@{ + + /// Default constructor. + PfemSolidConstitutiveLaw(); + + /// Copy constructor. + PfemSolidConstitutiveLaw(const PfemSolidConstitutiveLaw& rOther); + + /// Destructor + ~PfemSolidConstitutiveLaw() override; + + ///@} + ///@name Operations + ///@{ + + /// Initialize a new instance of this type of law + ConstitutiveLaw::Pointer Clone() const override; + + /// Calculate the response of the material for the current strain rate. + /** This is the main method for solid constitutive laws. + * @note Besides computing the response, derived constitutive laws are responsible for setting the + * effective young modulus and poisson ratio for the material, which will be used by the element. + */ + void CalculateMaterialResponseCauchy(ConstitutiveLaw::Parameters& rValues) override; + + /// Validate the data received by the constitutive law + /** @param rMaterialProperties Properties of the parent Element. + * @param rElementGeometry Geometry of the parent Element. + * @param rCurrentProcessInfo ProcessInfo for the problem. + * @return 0 if everything is fine, other values indicate problems. + */ + int Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, + const ProcessInfo& rCurrentProcessInfo) override; + + ///@} + ///@name Access + ///@{ + + /// This always returns this->GetEffectiveDensity() or this->GetEffectiveYoungModulus() or + /// this->GetEffectivePoissonRatio() and copies the result to rValue. + /** @return The effective density + */ + double& CalculateValue(ConstitutiveLaw::Parameters& rParameters, const Variable& rThisVariable, + double& rValue) override; + + ///@} + ///@name Inquiry + ///@{ + + /// This lets user classes know if the constitutive law is defined for 1D, 2D or 3D. + /** @return The number of spatial dimensions (1, 2 or 3). + */ + SizeType WorkingSpaceDimension() override; + + /// This lets the user know the size of the strain rate vector (in Voigt notation) used by the constitutive law. + /** @return The size of the strain rate vector. + */ + SizeType GetStrainSize() override; + + ///@} + ///@name Input and output + ///@{ + + /// @return A short string identifying this constitutive law instance. + std::string Info() const override; + + /// Print basic information about this constitutive law instance. + void PrintInfo(std::ostream& rOStream) const override; + + /// Print detailed information about this constitutive law instance and its managed data. + void PrintData(std::ostream& rOStream) const override; + + ///@} + + protected: + ///@name Protected Operations + ///@{ + + ///@} + ///@name Protected Access + ///@{ + + /** + * @brief Get the Effective Young Modulus object + * @param rParameters constitutive law parameters + * @return double obtained effective young modulus + */ + virtual double GetEffectiveYoungModulus(ConstitutiveLaw::Parameters& rParameters) const; + + /** + * @brief Get the Poisson Ratio Modulus object + * @param rParameters constitutive law parameters + * @return double obtained effective Poisson Ratio + */ + virtual double GetEffectivePoissonRatio(ConstitutiveLaw::Parameters& rParameters) const; + + /** + * @brief Get the Density object + * @param rParameters constitutive law parameters + * @return double obtained effective density + */ + virtual double GetEffectiveDensity(ConstitutiveLaw::Parameters& rParameters) const; + + /** + * @brief Get the averaged value of the Input Variable + * @param rParameters input variable, constitutive law parameters, step in which the variable is to evaluated + * @return double obtained averaged variable + */ + virtual double CalculateAveragedVariable(const Variable& rVariableInput, + ConstitutiveLaw::Parameters& rParameters, unsigned int step) const; + + /** + * @brief Get the Value From Table object + * For an table independent variable, this method returns the table dependent variable + * value. Note that the properties container must have a table relating the two variables. + * @param rIndependentVariable independent variable + * @param rDependentVariable dependent variable + * @param rParameters constitutive law parameters container + * @return double output variable value + */ + virtual double GetValueFromTable(const Variable& rIndependentVariable, const Variable& rDependentVariable, + ConstitutiveLaw::Parameters& rParameters) const; + + ///@} + + private: + ///@name Member Variables + ///@{ + + ///@} + ///@name Serialization + ///@{ + + friend class Serializer; + + void save(Serializer& rSerializer) const override; + + void load(Serializer& rSerializer) override; + + ///@} + +}; // Class PfemSolidConstitutiveLaw + +} // namespace Kratos. + +#endif // KRATOS_PFEM_SOLID_CONSTITUTIVE_LAW defined From be14e5db185a1104d702ba9c32b51d737090e659 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Mon, 2 Mar 2020 18:25:53 +0100 Subject: [PATCH 29/47] Add Hypoelastic 2D claw --- .../solid_laws/hypoelastic_2D_law.cpp | 119 +++++++++++++ .../solid_laws/hypoelastic_2D_law.h | 166 ++++++++++++++++++ 2 files changed, 285 insertions(+) create mode 100644 applications/PfemFluidDynamicsApplication/custom_constitutive/solid_laws/hypoelastic_2D_law.cpp create mode 100644 applications/PfemFluidDynamicsApplication/custom_constitutive/solid_laws/hypoelastic_2D_law.h diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/solid_laws/hypoelastic_2D_law.cpp b/applications/PfemFluidDynamicsApplication/custom_constitutive/solid_laws/hypoelastic_2D_law.cpp new file mode 100644 index 000000000000..8e755cc1767a --- /dev/null +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/solid_laws/hypoelastic_2D_law.cpp @@ -0,0 +1,119 @@ +//------------------------------------------------------------- +// ___ __ ___ _ _ _ +// KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| | +// | _/ _/ -_) ' \| _|| | || | / _` | +// |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS +// +// BSD License: PfemFluidDynamicsApplication/license.txt +// +// Main authors: Alessandro Franci +// Collaborators: +// +//------------------------------------------------------------- +// + +// System includes +#include + +// External includes + +// Project includes +#include "custom_constitutive/solid_laws/hypoelastic_2D_law.h" +#include "includes/checks.h" +#include "pfem_fluid_dynamics_application_variables.h" + +namespace Kratos { + +//********************************CONSTRUCTOR********************************* +//**************************************************************************** + +Hypoelastic2DLaw::Hypoelastic2DLaw() : PfemSolidConstitutiveLaw() {} + +//******************************COPY CONSTRUCTOR****************************** +//**************************************************************************** + +Hypoelastic2DLaw::Hypoelastic2DLaw(const Hypoelastic2DLaw& rOther) : PfemSolidConstitutiveLaw(rOther) {} + +//***********************************CLONE************************************ +//**************************************************************************** + +ConstitutiveLaw::Pointer Hypoelastic2DLaw::Clone() const { return Kratos::make_shared(*this); } + +//*********************************DESTRUCTOR********************************* +//**************************************************************************** + +Hypoelastic2DLaw::~Hypoelastic2DLaw() {} + +ConstitutiveLaw::SizeType Hypoelastic2DLaw::WorkingSpaceDimension() { return 2; } + +ConstitutiveLaw::SizeType Hypoelastic2DLaw::GetStrainSize() { return 3; } + +void Hypoelastic2DLaw::CalculateMaterialResponseCauchy(Parameters& rParameters) { + + const Vector& r_strain_vector = rParameters.GetStrainVector(); + Vector& r_stress_vector = rParameters.GetStressVector(); + + const double young_modulus = this->GetEffectiveYoungModulus(rParameters); + const double poisson_ratio = this->GetEffectivePoissonRatio(rParameters); + const double time_step = rParameters.GetProcessInfo()[DELTA_TIME]; + + const double second_lame = time_step * young_modulus / (2.0 * (1.0 + poisson_ratio)); + + const double strain_trace = r_strain_vector[0] + r_strain_vector[1]; + + r_stress_vector[0] += 2.0 * second_lame * (r_strain_vector[0] - strain_trace / 3.0); + r_stress_vector[1] += 2.0 * second_lame * (r_strain_vector[1] - strain_trace / 3.0); + r_stress_vector[2] += 2.0 * second_lame * r_strain_vector[2]; +} + +int Hypoelastic2DLaw::Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, + const ProcessInfo& rCurrentProcessInfo) { + + KRATOS_CHECK_VARIABLE_KEY(YOUNG_MODULUS); + KRATOS_CHECK_VARIABLE_KEY(POISSON_RATIO); + KRATOS_CHECK_VARIABLE_KEY(DENSITY); + + KRATOS_ERROR_IF(rMaterialProperties[YOUNG_MODULUS] <= 0.0) + << "Incorrect or missing YOUNG_MODULUS provided in process info for Hypoelastic2DLaw: " + << rMaterialProperties[YOUNG_MODULUS] << std::endl; + + KRATOS_ERROR_IF(rMaterialProperties[POISSON_RATIO] < 0.0) + << "Incorrect or missing POISSON_RATIO provided in process info for Hypoelastic2DLaw: " + << rMaterialProperties[POISSON_RATIO] << std::endl; + + KRATOS_ERROR_IF(rMaterialProperties[DENSITY] <= 0.0) + << "Incorrect or missing DENSITY provided in process info for Hypoelastic2DLaw: " + << rMaterialProperties[DENSITY] << std::endl; + + return 0; +} + +std::string Hypoelastic2DLaw::Info() const { return "Hypoelastic2DLaw"; } + +double Hypoelastic2DLaw::GetEffectiveYoungModulus(ConstitutiveLaw::Parameters& rParameters) const { + const Properties& r_properties = rParameters.GetMaterialProperties(); + const double effective_young_modulus = r_properties[YOUNG_MODULUS]; + return effective_young_modulus; +} + +double Hypoelastic2DLaw::GetEffectivePoissonRatio(ConstitutiveLaw::Parameters& rParameters) const { + const Properties& r_properties = rParameters.GetMaterialProperties(); + const double effective_poisson_ratio = r_properties[POISSON_RATIO]; + return effective_poisson_ratio; +} + +double Hypoelastic2DLaw::GetEffectiveDensity(ConstitutiveLaw::Parameters& rParameters) const { + const Properties& r_properties = rParameters.GetMaterialProperties(); + const double effective_density = r_properties[DENSITY]; + return effective_density; +} + +void Hypoelastic2DLaw::save(Serializer& rSerializer) const { + KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, PfemSolidConstitutiveLaw) +} + +void Hypoelastic2DLaw::load(Serializer& rSerializer) { + KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, PfemSolidConstitutiveLaw) +} + +} // Namespace Kratos diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/solid_laws/hypoelastic_2D_law.h b/applications/PfemFluidDynamicsApplication/custom_constitutive/solid_laws/hypoelastic_2D_law.h new file mode 100644 index 000000000000..9151e770f018 --- /dev/null +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/solid_laws/hypoelastic_2D_law.h @@ -0,0 +1,166 @@ +//------------------------------------------------------------- +// ___ __ ___ _ _ _ +// KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| | +// | _/ _/ -_) ' \| _|| | || | / _` | +// |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS +// +// BSD License: PfemFluidDynamicsApplication/license.txt +// +// Main authors: Alessandro Franci +// Collaborators: +// +//------------------------------------------------------------- +// + +#if !defined(KRATOS_HYPOELASTIC_LAW_2D_H_INCLUDED) +#define KRATOS_HYPOELASTIC_LAW_2D_H_INCLUDED + +// System includes + +// External includes + +// Project includes +#include "solid_constitutive_law.h" + +namespace Kratos { +/** + * Defines an Hypoelastic constitutive law for 2D + * This material law is defined by the parameters: + * 1) YOUNG MODULUS + * 2) POISSON RATIO + */ +class KRATOS_API(PFEM_FLUID_DYNAMICS_APPLICATION) Hypoelastic2DLaw : public PfemSolidConstitutiveLaw { + public: + /** + * Type Definitions + */ + typedef ProcessInfo ProcessInfoType; + typedef ConstitutiveLaw BaseType; + typedef std::size_t SizeType; + + /** + * Counted pointer of Hypoelastic2DLaw + */ + KRATOS_CLASS_POINTER_DEFINITION(Hypoelastic2DLaw); + + /** + * Life Cycle + */ + + /** + * Default constructor. + */ + Hypoelastic2DLaw(); + + /** + * Clone function (has to be implemented by any derived class) + * @return a pointer to a new instance of this constitutive law + */ + ConstitutiveLaw::Pointer Clone() const override; + + /** + * Copy constructor. + */ + Hypoelastic2DLaw(const Hypoelastic2DLaw& rOther); + + /** + * Destructor. + */ + ~Hypoelastic2DLaw() override; + + /** + * Operations needed by the base class: + */ + + /** + * @return Working space dimension constitutive law + */ + SizeType WorkingSpaceDimension() override; + + /** + * @return Size of the strain vector (in Voigt notation) for the constitutive law + */ + SizeType GetStrainSize() override; + + void CalculateMaterialResponseCauchy(Parameters& rValues) override; + + /** + * This function is designed to be called once to perform all the checks needed + * on the input provided. Checks can be "expensive" as the function is designed + * to catch user's errors. + * @param rMaterialProperties + * @param rElementGeometry + * @param rCurrentProcessInfo + * @return + */ + int Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, + const ProcessInfo& rCurrentProcessInfo) override; + + /** + * Input and output + */ + + /** + * Turn back information as a string. + */ + std::string Info() const override; + + protected: + ///@name Protected static Member Variables + ///@{ + ///@} + ///@name Protected member Variables + ///@{ + ///@} + ///@name Protected Operators + ///@{ + ///@} + ///@name Protected Operations + ///@{ + + /// Get the effective Young Modulus for the solid. + double GetEffectiveYoungModulus(ConstitutiveLaw::Parameters& rParameters) const override; + + /// Get the effective Poisson ratio for the solid. + double GetEffectivePoissonRatio(ConstitutiveLaw::Parameters& rParameters) const override; + + /// Get the effective density for the solid. + double GetEffectiveDensity(ConstitutiveLaw::Parameters& rParameters) const override; + + ///@} + + private: + ///@name Static Member Variables + ///@{ + + ///@} + ///@name Member Variables + ///@{ + + ///@} + ///@name Private Operators + ///@{ + + ///@} + ///@name Private Operations + ///@{ + + ///@} + ///@name Private Access + ///@{ + + ///@} + ///@name Serialization + ///@{ + friend class Serializer; + + void save(Serializer& rSerializer) const override; + + void load(Serializer& rSerializer) override; + ///@} + +}; // Class Hypoelastic2DLaw + +} // namespace Kratos. + +#endif // KRATOS_HYPOELASTIC_LAW_2D_H_INCLUDED defined From a6d9b3bd9bfb6dcbe882a0bb2e490c130815d91d Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Mon, 2 Mar 2020 18:26:02 +0100 Subject: [PATCH 30/47] Add Hypoelastic 3D claw --- .../solid_laws/hypoelastic_3D_law.cpp | 122 +++++++++++++ .../solid_laws/hypoelastic_3D_law.h | 166 ++++++++++++++++++ 2 files changed, 288 insertions(+) create mode 100644 applications/PfemFluidDynamicsApplication/custom_constitutive/solid_laws/hypoelastic_3D_law.cpp create mode 100644 applications/PfemFluidDynamicsApplication/custom_constitutive/solid_laws/hypoelastic_3D_law.h diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/solid_laws/hypoelastic_3D_law.cpp b/applications/PfemFluidDynamicsApplication/custom_constitutive/solid_laws/hypoelastic_3D_law.cpp new file mode 100644 index 000000000000..9efefbf2a02c --- /dev/null +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/solid_laws/hypoelastic_3D_law.cpp @@ -0,0 +1,122 @@ +//------------------------------------------------------------- +// ___ __ ___ _ _ _ +// KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| | +// | _/ _/ -_) ' \| _|| | || | / _` | +// |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS +// +// BSD License: PfemFluidDynamicsApplication/license.txt +// +// Main authors: Alessandro Franci +// Collaborators: +// +//------------------------------------------------------------- +// + +// System includes +#include + +// External includes + +// Project includes +#include "custom_constitutive/solid_laws/hypoelastic_3D_law.h" +#include "includes/checks.h" +#include "pfem_fluid_dynamics_application_variables.h" + +namespace Kratos { + +//********************************CONSTRUCTOR********************************* +//**************************************************************************** + +Hypoelastic3DLaw::Hypoelastic3DLaw() : PfemSolidConstitutiveLaw() {} + +//******************************COPY CONSTRUCTOR****************************** +//**************************************************************************** + +Hypoelastic3DLaw::Hypoelastic3DLaw(const Hypoelastic3DLaw& rOther) : PfemSolidConstitutiveLaw(rOther) {} + +//***********************************CLONE************************************ +//**************************************************************************** + +ConstitutiveLaw::Pointer Hypoelastic3DLaw::Clone() const { return Kratos::make_shared(*this); } + +//*********************************DESTRUCTOR********************************* +//**************************************************************************** + +Hypoelastic3DLaw::~Hypoelastic3DLaw() {} + +ConstitutiveLaw::SizeType Hypoelastic3DLaw::WorkingSpaceDimension() { return 3; } + +ConstitutiveLaw::SizeType Hypoelastic3DLaw::GetStrainSize() { return 6; } + +void Hypoelastic3DLaw::CalculateMaterialResponseCauchy(Parameters& rParameters) { + + const Vector& r_strain_vector = rParameters.GetStrainVector(); + Vector& r_stress_vector = rParameters.GetStressVector(); + + const double young_modulus = this->GetEffectiveYoungModulus(rParameters); + const double poisson_ratio = this->GetEffectivePoissonRatio(rParameters); + const double time_step = rParameters.GetProcessInfo()[DELTA_TIME]; + + const double second_lame = time_step * young_modulus / (2.0 * (1.0 + poisson_ratio)); + + const double strain_trace = r_strain_vector[0] + r_strain_vector[1] + r_strain_vector[2]; + + r_stress_vector[0] += 2.0 * second_lame * (r_strain_vector[0] - strain_trace / 3.0); + r_stress_vector[1] += 2.0 * second_lame * (r_strain_vector[1] - strain_trace / 3.0); + r_stress_vector[2] += 2.0 * second_lame * (r_strain_vector[2] - strain_trace / 3.0); + r_stress_vector[3] += 2.0 * second_lame * r_strain_vector[3]; + r_stress_vector[4] += 2.0 * second_lame * r_strain_vector[4]; + r_stress_vector[5] += 2.0 * second_lame * r_strain_vector[5]; +} + +int Hypoelastic3DLaw::Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, + const ProcessInfo& rCurrentProcessInfo) { + + KRATOS_CHECK_VARIABLE_KEY(YOUNG_MODULUS); + KRATOS_CHECK_VARIABLE_KEY(POISSON_RATIO); + KRATOS_CHECK_VARIABLE_KEY(DENSITY); + + KRATOS_ERROR_IF(rMaterialProperties[YOUNG_MODULUS] <= 0.0) + << "Incorrect or missing YOUNG_MODULUS provided in process info for Hypoelastic3DLaw: " + << rMaterialProperties[YOUNG_MODULUS] << std::endl; + + KRATOS_ERROR_IF(rMaterialProperties[POISSON_RATIO] < 0.0) + << "Incorrect or missing POISSON_RATIO provided in process info for Hypoelastic3DLaw: " + << rMaterialProperties[POISSON_RATIO] << std::endl; + + KRATOS_ERROR_IF(rMaterialProperties[DENSITY] <= 0.0) + << "Incorrect or missing DENSITY provided in process info for Hypoelastic3DLaw: " + << rMaterialProperties[DENSITY] << std::endl; + + return 0; +} + +std::string Hypoelastic3DLaw::Info() const { return "Hypoelastic3DLaw"; } + +double Hypoelastic3DLaw::GetEffectiveYoungModulus(ConstitutiveLaw::Parameters& rParameters) const { + const Properties& r_properties = rParameters.GetMaterialProperties(); + const double effective_young_modulus = r_properties[YOUNG_MODULUS]; + return effective_young_modulus; +} + +double Hypoelastic3DLaw::GetEffectivePoissonRatio(ConstitutiveLaw::Parameters& rParameters) const { + const Properties& r_properties = rParameters.GetMaterialProperties(); + const double effective_poisson_ratio = r_properties[POISSON_RATIO]; + return effective_poisson_ratio; +} + +double Hypoelastic3DLaw::GetEffectiveDensity(ConstitutiveLaw::Parameters& rParameters) const { + const Properties& r_properties = rParameters.GetMaterialProperties(); + const double effective_density = r_properties[DENSITY]; + return effective_density; +} + +void Hypoelastic3DLaw::save(Serializer& rSerializer) const { + KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, PfemSolidConstitutiveLaw) +} + +void Hypoelastic3DLaw::load(Serializer& rSerializer) { + KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, PfemSolidConstitutiveLaw) +} + +} // Namespace Kratos diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/solid_laws/hypoelastic_3D_law.h b/applications/PfemFluidDynamicsApplication/custom_constitutive/solid_laws/hypoelastic_3D_law.h new file mode 100644 index 000000000000..50951be60402 --- /dev/null +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/solid_laws/hypoelastic_3D_law.h @@ -0,0 +1,166 @@ +//------------------------------------------------------------- +// ___ __ ___ _ _ _ +// KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| | +// | _/ _/ -_) ' \| _|| | || | / _` | +// |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS +// +// BSD License: PfemFluidDynamicsApplication/license.txt +// +// Main authors: Alessandro Franci +// Collaborators: +// +//------------------------------------------------------------- +// + +#if !defined(KRATOS_HYPOELASTIC_LAW_3D_H_INCLUDED) +#define KRATOS_HYPOELASTIC_LAW_3D_H_INCLUDED + +// System includes + +// External includes + +// Project includes +#include "solid_constitutive_law.h" + +namespace Kratos { +/** + * Defines an Hypoelastic constitutive law for 3D + * This material law is defined by the parameters: + * 1) YOUNG MODULUS + * 2) POISSON RATIO + */ +class KRATOS_API(PFEM_FLUID_DYNAMICS_APPLICATION) Hypoelastic3DLaw : public PfemSolidConstitutiveLaw { + public: + /** + * Type Definitions + */ + typedef ProcessInfo ProcessInfoType; + typedef ConstitutiveLaw BaseType; + typedef std::size_t SizeType; + + /** + * Counted pointer of Hypoelastic3DLaw + */ + KRATOS_CLASS_POINTER_DEFINITION(Hypoelastic3DLaw); + + /** + * Life Cycle + */ + + /** + * Default constructor. + */ + Hypoelastic3DLaw(); + + /** + * Clone function (has to be implemented by any derived class) + * @return a pointer to a new instance of this constitutive law + */ + ConstitutiveLaw::Pointer Clone() const override; + + /** + * Copy constructor. + */ + Hypoelastic3DLaw(const Hypoelastic3DLaw& rOther); + + /** + * Destructor. + */ + ~Hypoelastic3DLaw() override; + + /** + * Operations needed by the base class: + */ + + /** + * @return Working space dimension constitutive law + */ + SizeType WorkingSpaceDimension() override; + + /** + * @return Size of the strain vector (in Voigt notation) for the constitutive law + */ + SizeType GetStrainSize() override; + + void CalculateMaterialResponseCauchy(Parameters& rValues) override; + + /** + * This function is designed to be called once to perform all the checks needed + * on the input provided. Checks can be "expensive" as the function is designed + * to catch user's errors. + * @param rMaterialProperties + * @param rElementGeometry + * @param rCurrentProcessInfo + * @return + */ + int Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, + const ProcessInfo& rCurrentProcessInfo) override; + + /** + * Input and output + */ + + /** + * Turn back information as a string. + */ + std::string Info() const override; + + protected: + ///@name Protected static Member Variables + ///@{ + ///@} + ///@name Protected member Variables + ///@{ + ///@} + ///@name Protected Operators + ///@{ + ///@} + ///@name Protected Operations + ///@{ + + /// Get the effective Young Modulus for the solid. + double GetEffectiveYoungModulus(ConstitutiveLaw::Parameters& rParameters) const override; + + /// Get the effective Poisson ratio for the solid. + double GetEffectivePoissonRatio(ConstitutiveLaw::Parameters& rParameters) const override; + + /// Get the effective density for the solid. + double GetEffectiveDensity(ConstitutiveLaw::Parameters& rParameters) const override; + + ///@} + + private: + ///@name Static Member Variables + ///@{ + + ///@} + ///@name Member Variables + ///@{ + + ///@} + ///@name Private Operators + ///@{ + + ///@} + ///@name Private Operations + ///@{ + + ///@} + ///@name Private Access + ///@{ + + ///@} + ///@name Serialization + ///@{ + friend class Serializer; + + void save(Serializer& rSerializer) const override; + + void load(Serializer& rSerializer) override; + ///@} + +}; // Class Hypoelastic3DLaw + +} // namespace Kratos. + +#endif // KRATOS_HYPOELASTIC_LAW_3D_H_INCLUDED defined From 5af4f8916b52a637bb1e8f3e9ba1ff496f4ddcc3 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Mon, 2 Mar 2020 18:49:43 +0100 Subject: [PATCH 31/47] Add fluid claw base class --- .../fluid_laws/fluid_constitutive_law.cpp | 219 ++++++++++++++++++ .../fluid_laws/fluid_constitutive_law.h | 208 +++++++++++++++++ 2 files changed, 427 insertions(+) create mode 100644 applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/fluid_constitutive_law.cpp create mode 100644 applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/fluid_constitutive_law.h diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/fluid_constitutive_law.cpp b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/fluid_constitutive_law.cpp new file mode 100644 index 000000000000..23443de534d4 --- /dev/null +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/fluid_constitutive_law.cpp @@ -0,0 +1,219 @@ +//------------------------------------------------------------- +// ___ __ ___ _ _ _ +// KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| | +// | _/ _/ -_) ' \| _|| | || | / _` | +// |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS +// +// BSD License: PfemFluidDynamicsApplication/license.txt +// +// Main authors: Jordi Cotela +// Collaborators: Massimiliano Zecchetto +// +//------------------------------------------------------------- +// + +#include "fluid_constitutive_law.h" + +namespace Kratos { + +// Life cycle ///////////////////////////////////////////////////////////////// + +PfemFluidConstitutiveLaw::PfemFluidConstitutiveLaw() : ConstitutiveLaw() {} + +PfemFluidConstitutiveLaw::PfemFluidConstitutiveLaw(const PfemFluidConstitutiveLaw& rOther) : ConstitutiveLaw(rOther) {} + +PfemFluidConstitutiveLaw::~PfemFluidConstitutiveLaw() {} + +// Public operations ////////////////////////////////////////////////////////// + +ConstitutiveLaw::Pointer PfemFluidConstitutiveLaw::Clone() const { + KRATOS_ERROR << "Calling base PfemFluidConstitutiveLaw::Clone method. This " + "class should not be instantiated. Please check your " + "constitutive law." + << std::endl; + return Kratos::make_shared(*this); +} + +void PfemFluidConstitutiveLaw::CalculateMaterialResponseCauchy(Parameters& rValues) { + KRATOS_ERROR << "Calling base " + "PfemFluidConstitutiveLaw::CalculateMaterialResponseCauchy " + "method. This class should not be instantiated. Please " + "check your constitutive law." + << std::endl; +} + +int PfemFluidConstitutiveLaw::Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, + const ProcessInfo& rCurrentProcessInfo) { + KRATOS_ERROR << "Calling base " + "PfemFluidConstitutiveLaw::Check " + "method. This class should not be instantiated. Please " + "check your constitutive law." + << std::endl; + return 999; +} + +// Access ///////////////////////////////////////////////////////////////////// + +double& PfemFluidConstitutiveLaw::CalculateValue(ConstitutiveLaw::Parameters& rParameters, + const Variable& rThisVariable, double& rValue) { + + rValue = this->GetEffectiveDensity(rParameters); + + return rValue; +} + +// Inquiry //////////////////////////////////////////////////////////////////// + +ConstitutiveLaw::SizeType PfemFluidConstitutiveLaw::WorkingSpaceDimension() { + KRATOS_ERROR << "Calling base " + "PfemFluidConstitutiveLaw::WorkingSpaceDimension " + "method. This class should not be instantiated. Please " + "check your constitutive law." + << std::endl; + return 0; +} + +ConstitutiveLaw::SizeType PfemFluidConstitutiveLaw::GetStrainSize() { + KRATOS_ERROR << "Calling base " + "PfemFluidConstitutiveLaw::GetStrainSize " + "method. This class should not be instantiated. Please " + "check your constitutive law." + << std::endl; + return 0; +} + +// Info /////////////////////////////////////////////////////////////////////// + +std::string PfemFluidConstitutiveLaw::Info() const { return "PfemFluidConstitutiveLaw"; } + +void PfemFluidConstitutiveLaw::PrintInfo(std::ostream& rOStream) const { rOStream << this->Info(); } + +void PfemFluidConstitutiveLaw::PrintData(std::ostream& rOStream) const { rOStream << this->Info(); } + +// Protected operations /////////////////////////////////////////////////////// + +void PfemFluidConstitutiveLaw::EffectiveViscousConstitutiveMatrix2D(double EffectiveDynamicViscosity, + Matrix& rConstitutiveMatrix) { + constexpr double two_thirds = 2.0 / 3.0; + constexpr double four_thirds = 4.0 / 3.0; + + rConstitutiveMatrix(0, 0) = +EffectiveDynamicViscosity * four_thirds; + rConstitutiveMatrix(0, 1) = -EffectiveDynamicViscosity * two_thirds; + rConstitutiveMatrix(0, 2) = 0.0; + rConstitutiveMatrix(1, 0) = -EffectiveDynamicViscosity * two_thirds; + rConstitutiveMatrix(1, 1) = +EffectiveDynamicViscosity * four_thirds; + rConstitutiveMatrix(1, 2) = 0.0; + rConstitutiveMatrix(2, 0) = 0.0; + rConstitutiveMatrix(2, 1) = 0.0; + rConstitutiveMatrix(2, 2) = +EffectiveDynamicViscosity; +} + +void PfemFluidConstitutiveLaw::EffectiveViscousConstitutiveMatrix3D(double EffectiveDynamicViscosity, + Matrix& rConstitutiveMatrix) { + rConstitutiveMatrix.clear(); + + constexpr double two_thirds = 2.0 / 3.0; + constexpr double four_thirds = 4.0 / 3.0; + + rConstitutiveMatrix(0, 0) = +EffectiveDynamicViscosity * four_thirds; + rConstitutiveMatrix(0, 1) = -EffectiveDynamicViscosity * two_thirds; + rConstitutiveMatrix(0, 2) = -EffectiveDynamicViscosity * two_thirds; + + rConstitutiveMatrix(1, 0) = -EffectiveDynamicViscosity * two_thirds; + rConstitutiveMatrix(1, 1) = +EffectiveDynamicViscosity * four_thirds; + rConstitutiveMatrix(1, 2) = -EffectiveDynamicViscosity * two_thirds; + + rConstitutiveMatrix(2, 0) = -EffectiveDynamicViscosity * two_thirds; + rConstitutiveMatrix(2, 1) = -EffectiveDynamicViscosity * two_thirds; + rConstitutiveMatrix(2, 2) = +EffectiveDynamicViscosity * four_thirds; + + rConstitutiveMatrix(3, 3) = +EffectiveDynamicViscosity; + rConstitutiveMatrix(4, 4) = +EffectiveDynamicViscosity; + rConstitutiveMatrix(5, 5) = +EffectiveDynamicViscosity; +} + +// Protected access /////////////////////////////////////////////////////////// + +double PfemFluidConstitutiveLaw::GetEffectiveViscosity(ConstitutiveLaw::Parameters& rParameters) const { + KRATOS_ERROR << "Accessing base class PfemFluidConstitutiveLaw::GetEffectiveViscosity." << std::endl; + return 0.0; +} + +double PfemFluidConstitutiveLaw::GetEffectiveDensity(ConstitutiveLaw::Parameters& rParameters) const { + KRATOS_ERROR << "Accessing base class PfemFluidConstitutiveLaw::GetEffectiveDensity." << std::endl; + return 0.0; +} + +double PfemFluidConstitutiveLaw::CalculateAveragedVariable(const Variable& rVariableInput, + ConstitutiveLaw::Parameters& rParameters, + unsigned int step) const { + const GeometryType& r_geometry = rParameters.GetElementGeometry(); + const unsigned int number_of_nodes = r_geometry.size(); + + double result = 0; + for (unsigned int i = 0; i < number_of_nodes; i++) { + result += r_geometry[i].FastGetSolutionStepValue(rVariableInput, step); + } + result /= number_of_nodes; + + return result; +} + +double PfemFluidConstitutiveLaw::CalculateInGaussPoint(const Variable& rVariableInput, + ConstitutiveLaw::Parameters& rParameters, + unsigned int step) const { + + const GeometryType& r_geometry = rParameters.GetElementGeometry(); + const unsigned int number_of_nodes = r_geometry.size(); + const auto& r_shape_function = rParameters.GetShapeFunctionsValues(); + double result = 0; + + for (unsigned int i = 0; i < number_of_nodes; i++) { + result += r_shape_function[i] * r_geometry[i].FastGetSolutionStepValue(rVariableInput, step); + } + + return result; +} + +double PfemFluidConstitutiveLaw::GetValueFromTable(const Variable& rIndependentVariable, + const Variable& rDependentVariable, + ConstitutiveLaw::Parameters& rParameters) const { + // Get material properties from constitutive law parameters + const Properties& r_properties = rParameters.GetMaterialProperties(); + + double dependent_at_gauss; + if (r_properties.HasTable(rIndependentVariable, rDependentVariable)) { + // Get geometry and Gauss points data + const auto& r_geometry = rParameters.GetElementGeometry(); + const auto& r_N = rParameters.GetShapeFunctionsValues(); + + // Compute the independent variable at the Gauss point + double independent_at_gauss = 0.0; + for (unsigned int i = 0; i < r_N.size(); ++i) { + const double& r_val = r_geometry[i].FastGetSolutionStepValue(rIndependentVariable); + independent_at_gauss += r_val * r_N[i]; + } + + // Retrieve the dependent variable from the table + const auto& r_table = r_properties.GetTable(rIndependentVariable, rDependentVariable); + dependent_at_gauss = r_table.GetValue(independent_at_gauss); + + } else { + KRATOS_ERROR << "PfemFluidConstitutiveLaw " << this->Info() << " has no table with variables " + << rIndependentVariable << " " << rDependentVariable << std::endl; + } + + return dependent_at_gauss; +} + +// Serialization ////////////////////////////////////////////////////////////// + +void PfemFluidConstitutiveLaw::save(Serializer& rSerializer) const { + KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, ConstitutiveLaw); +} + +void PfemFluidConstitutiveLaw::load(Serializer& rSerializer) { + KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, ConstitutiveLaw); +} + +} // namespace Kratos \ No newline at end of file diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/fluid_constitutive_law.h b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/fluid_constitutive_law.h new file mode 100644 index 000000000000..4411a83b54a4 --- /dev/null +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/fluid_constitutive_law.h @@ -0,0 +1,208 @@ +//------------------------------------------------------------- +// ___ __ ___ _ _ _ +// KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| | +// | _/ _/ -_) ' \| _|| | || | / _` | +// |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS +// +// BSD License: PfemFluidDynamicsApplication/license.txt +// +// Main authors: Jordi Cotela +// Collaborators: Massimiliano Zecchetto +// +//------------------------------------------------------------- +// + +#if !defined(KRATOS_PFEM_FLUID_CONSTITUTIVE_LAW) +#define KRATOS_PFEM_FLUID_CONSTITUTIVE_LAW + +// System includes + +// External includes + +// Project includes +#include "includes/constitutive_law.h" + +namespace Kratos { + +///@addtogroup PfemFluidDynamicsApplication +///@{ + +///@name Kratos Classes +///@{ + +/// This class contains the common infrastructure for the pfem fluid constitutive laws. +class KRATOS_API(PFEM_FLUID_DYNAMICS_APPLICATION) PfemFluidConstitutiveLaw : public ConstitutiveLaw { + public: + ///@name Type Definitions + ///@{ + + KRATOS_CLASS_POINTER_DEFINITION(PfemFluidConstitutiveLaw); + + typedef ConstitutiveLaw BaseType; + typedef std::size_t SizeType; + + ///@} + ///@name Life Cycle + ///@{ + + /// Default constructor. + PfemFluidConstitutiveLaw(); + + /// Copy constructor. + PfemFluidConstitutiveLaw(const PfemFluidConstitutiveLaw& rOther); + + /// Destructor + ~PfemFluidConstitutiveLaw() override; + + ///@} + ///@name Operations + ///@{ + + /// Initialize a new instance of this type of law + ConstitutiveLaw::Pointer Clone() const override; + + /// Calculate the response of the material for the current strain rates. + /** This is the main method for fluid constitutive laws. + * These are returned as rValues.GetConstitutiveMatrix() and rValues.GetStressVector(), respectively. + * @note Besides computing the response, derived constitutive laws are responsible for setting the + * effective viscosity for the law, which will be used by the element to calculate the stabilization Tau. + */ + void CalculateMaterialResponseCauchy(ConstitutiveLaw::Parameters& rValues) override; + + /// Validate the data received by the constitutive law + /** @param rMaterialProperties Properties of the parent Element. + * @param rElementGeometry Geometry of the parent Element. + * @param rCurrentProcessInfo ProcessInfo for the problem. + * @return 0 if everything is fine, other values indicate problems. + */ + int Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, + const ProcessInfo& rCurrentProcessInfo) override; + + ///@} + ///@name Access + ///@{ + + /// This always returns this->GetEffectiveDensity() and copies the result to rValue. + /** @return The effective density + */ + double& CalculateValue(ConstitutiveLaw::Parameters& rParameters, const Variable& rThisVariable, + double& rValue) override; + + ///@} + ///@name Inquiry + ///@{ + + /// This lets user classes know if the constitutive law is defined for 1D, 2D or 3D. + /** @return The number of spatial dimensions (1, 2 or 3). + */ + SizeType WorkingSpaceDimension() override; + + /// This lets the user know the size of the strain rate vector (in Voigt notation) used by the constitutive law. + /** @return The size of the strain rate vector. + */ + SizeType GetStrainSize() override; + + ///@} + ///@name Input and output + ///@{ + + /// @return A short string identifying this constitutive law instance. + std::string Info() const override; + + /// Print basic information about this constitutive law instance. + void PrintInfo(std::ostream& rOStream) const override; + + /// Print detailed information about this constitutive law instance and its managed data. + void PrintData(std::ostream& rOStream) const override; + + ///@} + + protected: + ///@name Protected Operations + ///@{ + + /// Helper function to write the constitutive matrix using an effective viscosity (2D version). + /** It returns a matrix with the same structure as for a Newtonian fluid, using the given viscosity. + * @param[in] EffectiveViscosity Equivalent viscosity for the fluid (dynamic units -- Pa s -- assumed). + * @param[out] rC Resulting constitutive matrix. + */ + void EffectiveViscousConstitutiveMatrix2D(double EffectiveViscosity, Matrix& rC); + + /// Helper function to write the constitutive matrix using an effective viscosity (3D version). + /** It returns a matrix with the same structure as for a Newtonian fluid, using the given viscosity. + * @param[in] EffectiveViscosity Equivalent viscosity for the fluid (dynamic units -- Pa s -- assumed). + * @param[out] rC Resulting constitutive matrix. + */ + void EffectiveViscousConstitutiveMatrix3D(double EffectiveViscosity, Matrix& rC); + + ///@} + ///@name Protected Access + ///@{ + + /** + * @brief Get the Effective Viscosity object + * Get the effective viscosity (in dynamic units -- Pa s) for the fluid. + * @param rParameters constitutive law parameters + * @return double obtained effective viscosity + */ + virtual double GetEffectiveViscosity(ConstitutiveLaw::Parameters& rParameters) const; + + /** + * @brief Get the Effective Density object + * Get the effective density for the fluid. + * @param rParameters constitutive law parameters + * @return double obtained effective density + */ + virtual double GetEffectiveDensity(ConstitutiveLaw::Parameters& rParameters) const; + + /** + * @brief Get the averaged value of the Input Variable + * @param rParameters input variable, constitutive law parameters, step in which the variable is to evaluated + * @return double obtained averaged variable + */ + virtual double CalculateAveragedVariable(const Variable& rVariableInput, + ConstitutiveLaw::Parameters& rParameters, unsigned int step) const; + + /** + * @brief Get the averaged value of the Input Variable + * @param rParameters input variable, constitutive law parameters, step in which the variable is to evaluated + * @return double obtained averaged variable + */ + virtual double CalculateInGaussPoint(const Variable& rVariableInput, + ConstitutiveLaw::Parameters& rParameters, unsigned int step) const; + + /** + * @brief Get the Value From Table object + * For an table independent variable, this method returns the table dependent variable + * value. Note that the properties container must have a table relating the two variables. + * @param rIndependentVariable independent variable + * @param rDependentVariable dependent variable + * @param rParameters constitutive law parameters container + * @return double output variable value + */ + virtual double GetValueFromTable(const Variable& rIndependentVariable, const Variable& rDependentVariable, + ConstitutiveLaw::Parameters& rParameters) const; + + ///@} + + private: + ///@name Member Variables + ///@{ + + ///@} + ///@name Serialization + ///@{ + + friend class Serializer; + + void save(Serializer& rSerializer) const override; + + void load(Serializer& rSerializer) override; + + ///@} + +}; // Class PfemFluidConstitutiveLaw + +} // namespace Kratos. + +#endif // KRATOS_PFEM_FLUID_CONSTITUTIVE_LAW defined From 3c800c2196dfe7bb378a9eeee19f1da6c631f93f Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Mon, 2 Mar 2020 18:54:59 +0100 Subject: [PATCH 32/47] Add Newtonian 2D claw --- .../fluid_laws/newtonian_2D_law.cpp | 108 ++++++++++++ .../fluid_laws/newtonian_2D_law.h | 164 ++++++++++++++++++ 2 files changed, 272 insertions(+) create mode 100644 applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/newtonian_2D_law.cpp create mode 100644 applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/newtonian_2D_law.h diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/newtonian_2D_law.cpp b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/newtonian_2D_law.cpp new file mode 100644 index 000000000000..174c8f536dce --- /dev/null +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/newtonian_2D_law.cpp @@ -0,0 +1,108 @@ +//------------------------------------------------------------- +// ___ __ ___ _ _ _ +// KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| | +// | _/ _/ -_) ' \| _|| | || | / _` | +// |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS +// +// BSD License: PfemFluidDynamicsApplication/license.txt +// +// Main authors: Ruben Zorilla +// Collaborators: Massimiliano Zecchetto +// +//------------------------------------------------------------- +// + +// System includes +#include + +// External includes + +// Project includes +#include "custom_constitutive/fluid_laws/newtonian_2D_law.h" +#include "includes/checks.h" +#include "pfem_fluid_dynamics_application_variables.h" + +namespace Kratos { + +//********************************CONSTRUCTOR********************************* +//**************************************************************************** + +Newtonian2DLaw::Newtonian2DLaw() : PfemFluidConstitutiveLaw() {} + +//******************************COPY CONSTRUCTOR****************************** +//**************************************************************************** + +Newtonian2DLaw::Newtonian2DLaw(const Newtonian2DLaw& rOther) : PfemFluidConstitutiveLaw(rOther) {} + +//***********************************CLONE************************************ +//**************************************************************************** + +ConstitutiveLaw::Pointer Newtonian2DLaw::Clone() const { return Kratos::make_shared(*this); } + +//*********************************DESTRUCTOR********************************* +//**************************************************************************** + +Newtonian2DLaw::~Newtonian2DLaw() {} + +ConstitutiveLaw::SizeType Newtonian2DLaw::WorkingSpaceDimension() { return 2; } + +ConstitutiveLaw::SizeType Newtonian2DLaw::GetStrainSize() { return 3; } + +void Newtonian2DLaw::CalculateMaterialResponseCauchy(Parameters& rValues) { + + const Flags& r_options = rValues.GetOptions(); + const Vector& r_strain_vector = rValues.GetStrainVector(); + Vector& r_stress_vector = rValues.GetStressVector(); + + const double effective_dynamic_viscosity = this->GetEffectiveViscosity(rValues); + + const double strain_trace = r_strain_vector[0] + r_strain_vector[1]; + + r_stress_vector[0] = 2.0 * effective_dynamic_viscosity * (r_strain_vector[0] - strain_trace / 3.0); + r_stress_vector[1] = 2.0 * effective_dynamic_viscosity * (r_strain_vector[1] - strain_trace / 3.0); + r_stress_vector[2] = 2.0 * effective_dynamic_viscosity * r_strain_vector[2]; + + if (r_options.Is(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR)) { + this->EffectiveViscousConstitutiveMatrix2D(effective_dynamic_viscosity, rValues.GetConstitutiveMatrix()); + } +} + +int Newtonian2DLaw::Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, + const ProcessInfo& rCurrentProcessInfo) { + KRATOS_CHECK_VARIABLE_KEY(DYNAMIC_VISCOSITY); + KRATOS_CHECK_VARIABLE_KEY(BULK_MODULUS); + + KRATOS_ERROR_IF(rMaterialProperties[DYNAMIC_VISCOSITY] <= 0.0) + << "Incorrect or missing DYNAMIC_VISCOSITY provided in process info for Newtonian2DLaw: " + << rMaterialProperties[DYNAMIC_VISCOSITY] << std::endl; + + KRATOS_ERROR_IF(rMaterialProperties[BULK_MODULUS] <= 0.0) + << "Incorrect or missing BULK_MODULUS provided in process info for Newtonian3DLaw: " + << rMaterialProperties[BULK_MODULUS] << std::endl; + + return 0; +} + +std::string Newtonian2DLaw::Info() const { return "Newtonian2DLaw"; } + +double Newtonian2DLaw::GetEffectiveViscosity(ConstitutiveLaw::Parameters& rParameters) const { + const Properties& r_properties = rParameters.GetMaterialProperties(); + const double effective_viscosity = r_properties[DYNAMIC_VISCOSITY]; + return effective_viscosity; +} + +double Newtonian2DLaw::GetEffectiveDensity(ConstitutiveLaw::Parameters& rParameters) const { + const Properties& r_properties = rParameters.GetMaterialProperties(); + const double effective_density = r_properties[DENSITY]; + return effective_density; +} + +void Newtonian2DLaw::save(Serializer& rSerializer) const { + KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, PfemFluidConstitutiveLaw) +} + +void Newtonian2DLaw::load(Serializer& rSerializer) { + KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, PfemFluidConstitutiveLaw) +} + +} // Namespace Kratos diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/newtonian_2D_law.h b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/newtonian_2D_law.h new file mode 100644 index 000000000000..434f674fe7e9 --- /dev/null +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/newtonian_2D_law.h @@ -0,0 +1,164 @@ +//------------------------------------------------------------- +// ___ __ ___ _ _ _ +// KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| | +// | _/ _/ -_) ' \| _|| | || | / _` | +// |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS +// +// BSD License: PfemFluidDynamicsApplication/license.txt +// +// Main authors: Ruben Zorilla +// Collaborators: Massimiliano Zecchetto +// +//------------------------------------------------------------- +// + +#if !defined(KRATOS_NEWTONIAN_LAW_2D_H_INCLUDED) +#define KRATOS_NEWTONIAN_LAW_2D_H_INCLUDED + +// System includes + +// External includes + +// Project includes +#include "fluid_constitutive_law.h" + +namespace Kratos { +/** + * Defines a Newtonian constitutive law for 2D + * This material law is defined by the parameters: + * 1) DYNAMIC_VISCOSITY + */ +class KRATOS_API(PFEM_FLUID_DYNAMICS_APPLICATION) Newtonian2DLaw : public PfemFluidConstitutiveLaw { + public: + /** + * Type Definitions + */ + typedef ProcessInfo ProcessInfoType; + typedef ConstitutiveLaw BaseType; + typedef std::size_t SizeType; + + /** + * Counted pointer of Newtonian3DLaw + */ + KRATOS_CLASS_POINTER_DEFINITION(Newtonian2DLaw); + + /** + * Life Cycle + */ + + /** + * Default constructor. + */ + Newtonian2DLaw(); + + /** + * Clone function (has to be implemented by any derived class) + * @return a pointer to a new instance of this constitutive law + */ + ConstitutiveLaw::Pointer Clone() const override; + + /** + * Copy constructor. + */ + Newtonian2DLaw(const Newtonian2DLaw& rOther); + + /** + * Destructor. + */ + ~Newtonian2DLaw() override; + + /** + * Operations needed by the base class: + */ + + /** + * @return Working space dimension constitutive law + */ + SizeType WorkingSpaceDimension() override; + + /** + * @return Size of the strain vector (in Voigt notation) for the constitutive law + */ + SizeType GetStrainSize() override; + + void CalculateMaterialResponseCauchy(Parameters& rValues) override; + + /** + * This function is designed to be called once to perform all the checks needed + * on the input provided. Checks can be "expensive" as the function is designed + * to catch user's errors. + * @param rMaterialProperties + * @param rElementGeometry + * @param rCurrentProcessInfo + * @return + */ + int Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, + const ProcessInfo& rCurrentProcessInfo) override; + + /** + * Input and output + */ + + /** + * Turn back information as a string. + */ + std::string Info() const override; + + protected: + ///@name Protected static Member Variables + ///@{ + ///@} + ///@name Protected member Variables + ///@{ + ///@} + ///@name Protected Operators + ///@{ + ///@} + ///@name Protected Operations + ///@{ + + /// Get the effective viscosity (in dynamic units -- Pa s) for the fluid. + double GetEffectiveViscosity(ConstitutiveLaw::Parameters& rParameters) const override; + + /// Get the effective density for the fluid. + double GetEffectiveDensity(ConstitutiveLaw::Parameters& rParameters) const override; + + ///@} + + private: + ///@name Static Member Variables + ///@{ + + ///@} + ///@name Member Variables + ///@{ + + ///@} + ///@name Private Operators + ///@{ + + ///@} + ///@name Private Operations + ///@{ + ///@} + + ///@} + ///@name Private Access + ///@{ + ///@} + + ///@} + ///@name Serialization + ///@{ + friend class Serializer; + + void save(Serializer& rSerializer) const override; + + void load(Serializer& rSerializer) override; + ///@} + +}; // Class Newtonian2DLaw + +} // namespace Kratos. + +#endif // KRATOS_NEWTONIAN_LAW_2D_H_INCLUDED defined From 8007d2465156a5dbcea6e4e2b5da86e469217b5c Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Mon, 2 Mar 2020 18:55:13 +0100 Subject: [PATCH 33/47] Add Newtonian 3D claw --- .../fluid_laws/newtonian_3D_law.cpp | 111 ++++++++++++ .../fluid_laws/newtonian_3D_law.h | 164 ++++++++++++++++++ 2 files changed, 275 insertions(+) create mode 100644 applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/newtonian_3D_law.cpp create mode 100644 applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/newtonian_3D_law.h diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/newtonian_3D_law.cpp b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/newtonian_3D_law.cpp new file mode 100644 index 000000000000..0894078112a8 --- /dev/null +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/newtonian_3D_law.cpp @@ -0,0 +1,111 @@ +//------------------------------------------------------------- +// ___ __ ___ _ _ _ +// KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| | +// | _/ _/ -_) ' \| _|| | || | / _` | +// |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS +// +// BSD License: PfemFluidDynamicsApplication/license.txt +// +// Main authors: Ruben Zorilla +// Collaborators: Massimiliano Zecchetto +// +//------------------------------------------------------------- +// + +// System includes +#include + +// External includes + +// Project includes +#include "custom_constitutive/fluid_laws/newtonian_3D_law.h" +#include "includes/checks.h" +#include "pfem_fluid_dynamics_application_variables.h" + +namespace Kratos { + +//********************************CONSTRUCTOR********************************* +//**************************************************************************** + +Newtonian3DLaw::Newtonian3DLaw() : PfemFluidConstitutiveLaw() {} + +//******************************COPY CONSTRUCTOR****************************** +//**************************************************************************** + +Newtonian3DLaw::Newtonian3DLaw(const Newtonian3DLaw& rOther) : PfemFluidConstitutiveLaw(rOther) {} + +//***********************************CLONE************************************ +//**************************************************************************** + +ConstitutiveLaw::Pointer Newtonian3DLaw::Clone() const { return Kratos::make_shared(*this); } + +//*********************************DESTRUCTOR********************************* +//**************************************************************************** + +Newtonian3DLaw::~Newtonian3DLaw() {} + +ConstitutiveLaw::SizeType Newtonian3DLaw::WorkingSpaceDimension() { return 3; } + +ConstitutiveLaw::SizeType Newtonian3DLaw::GetStrainSize() { return 6; } + +void Newtonian3DLaw::CalculateMaterialResponseCauchy(Parameters& rValues) { + + const Flags& r_options = rValues.GetOptions(); + const Vector& r_strain_vector = rValues.GetStrainVector(); + Vector& r_stress_vector = rValues.GetStressVector(); + + const double effective_dynamic_viscosity = this->GetEffectiveViscosity(rValues); + + const double strain_trace = r_strain_vector[0] + r_strain_vector[1] + r_strain_vector[2]; + + r_stress_vector[0] = 2.0 * effective_dynamic_viscosity * (r_strain_vector[0] - strain_trace / 3.0); + r_stress_vector[1] = 2.0 * effective_dynamic_viscosity * (r_strain_vector[1] - strain_trace / 3.0); + r_stress_vector[2] = 2.0 * effective_dynamic_viscosity * (r_strain_vector[2] - strain_trace / 3.0); + r_stress_vector[3] = 2.0 * effective_dynamic_viscosity * r_strain_vector[3]; + r_stress_vector[4] = 2.0 * effective_dynamic_viscosity * r_strain_vector[4]; + r_stress_vector[5] = 2.0 * effective_dynamic_viscosity * r_strain_vector[5]; + + if (r_options.Is(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR)) { + this->EffectiveViscousConstitutiveMatrix3D(effective_dynamic_viscosity, rValues.GetConstitutiveMatrix()); + } +} + +int Newtonian3DLaw::Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, + const ProcessInfo& rCurrentProcessInfo) { + KRATOS_CHECK_VARIABLE_KEY(DYNAMIC_VISCOSITY); + KRATOS_CHECK_VARIABLE_KEY(BULK_MODULUS); + + KRATOS_ERROR_IF(rMaterialProperties[DYNAMIC_VISCOSITY] <= 0.0) + << "Incorrect or missing DYNAMIC_VISCOSITY provided in process info for Newtonian3DLaw: " + << rMaterialProperties[DYNAMIC_VISCOSITY] << std::endl; + + KRATOS_ERROR_IF(rMaterialProperties[BULK_MODULUS] <= 0.0) + << "Incorrect or missing BULK_MODULUS provided in process info for Newtonian3DLaw: " + << rMaterialProperties[BULK_MODULUS] << std::endl; + + return 0; +} + +std::string Newtonian3DLaw::Info() const { return "Newtonian3DLaw"; } + +double Newtonian3DLaw::GetEffectiveViscosity(ConstitutiveLaw::Parameters& rParameters) const { + const Properties& r_properties = rParameters.GetMaterialProperties(); + const double effective_viscosity = r_properties[DYNAMIC_VISCOSITY]; + return effective_viscosity; +} + +double Newtonian3DLaw::GetEffectiveDensity(ConstitutiveLaw::Parameters& rParameters) const { + const Properties& r_properties = rParameters.GetMaterialProperties(); + const double effective_density = r_properties[DENSITY]; + return effective_density; +} + +void Newtonian3DLaw::save(Serializer& rSerializer) const { + KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, PfemFluidConstitutiveLaw) +} + +void Newtonian3DLaw::load(Serializer& rSerializer) { + KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, PfemFluidConstitutiveLaw) +} + +} // Namespace Kratos diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/newtonian_3D_law.h b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/newtonian_3D_law.h new file mode 100644 index 000000000000..426c71032588 --- /dev/null +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/newtonian_3D_law.h @@ -0,0 +1,164 @@ +//------------------------------------------------------------- +// ___ __ ___ _ _ _ +// KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| | +// | _/ _/ -_) ' \| _|| | || | / _` | +// |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS +// +// BSD License: PfemFluidDynamicsApplication/license.txt +// +// Main authors: Ruben Zorilla +// Collaborators: Massimiliano Zecchetto +// +//------------------------------------------------------------- +// + +#if !defined(KRATOS_NEWTONIAN_LAW_3D_H_INCLUDED) +#define KRATOS_NEWTONIAN_LAW_3D_H_INCLUDED + +// System includes + +// External includes + +// Project includes +#include "fluid_constitutive_law.h" + +namespace Kratos { +/** + * Defines a Newtonian constitutive law in 3D. + * This material law is defined by the parameters: + * 1) DYNAMIC_VISCOSITY + */ +class KRATOS_API(PFEM_FLUID_DYNAMICS_APPLICATION) Newtonian3DLaw : public PfemFluidConstitutiveLaw { + public: + /** + * Type Definitions + */ + typedef ProcessInfo ProcessInfoType; + typedef ConstitutiveLaw BaseType; + typedef std::size_t SizeType; + + /** + * Counted pointer of Newtonian3DLaw + */ + KRATOS_CLASS_POINTER_DEFINITION(Newtonian2DLaw); + + /** + * Life Cycle + */ + + /** + * Default constructor. + */ + Newtonian3DLaw(); + + /** + * Clone function (has to be implemented by any derived class) + * @return a pointer to a new instance of this constitutive law + */ + ConstitutiveLaw::Pointer Clone() const override; + + /** + * Copy constructor. + */ + Newtonian3DLaw(const Newtonian3DLaw& rOther); + + /** + * Destructor. + */ + ~Newtonian3DLaw() override; + + /** + * Operations needed by the base class: + */ + + /** + * @return Working space dimension constitutive law + */ + SizeType WorkingSpaceDimension() override; + + /** + * @return Size of the strain vector (in Voigt notation) for the constitutive law + */ + SizeType GetStrainSize() override; + + void CalculateMaterialResponseCauchy(Parameters& rValues) override; + + /** + * This function is designed to be called once to perform all the checks needed + * on the input provided. Checks can be "expensive" as the function is designed + * to catch user's errors. + * @param rMaterialProperties + * @param rElementGeometry + * @param rCurrentProcessInfo + * @return + */ + int Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, + const ProcessInfo& rCurrentProcessInfo) override; + + /** + * Input and output + */ + + /** + * Turn back information as a string. + */ + std::string Info() const override; + + protected: + ///@name Protected static Member Variables + ///@{ + ///@} + ///@name Protected member Variables + ///@{ + ///@} + ///@name Protected Operators + ///@{ + ///@} + ///@name Protected Operations + ///@{ + + /// Get the effective viscosity (in dynamic units -- Pa s) for the fluid. + double GetEffectiveViscosity(ConstitutiveLaw::Parameters& rParameters) const override; + + /// Get the effective density for the fluid. + double GetEffectiveDensity(ConstitutiveLaw::Parameters& rParameters) const override; + + ///@} + + private: + ///@name Static Member Variables + ///@{ + + ///@} + ///@name Member Variables + ///@{ + + ///@} + ///@name Private Operators + ///@{ + + ///@} + ///@name Private Operations + ///@{ + ///@} + + ///@} + ///@name Private Access + ///@{ + ///@} + + ///@} + ///@name Serialization + ///@{ + friend class Serializer; + + void save(Serializer& rSerializer) const override; + + void load(Serializer& rSerializer) override; + ///@} + +}; // Class Newtonian3DLaw + +} // namespace Kratos. + +#endif // KRATOS_NEWTONIAN_LAW_3D_H_INCLUDED defined From 1db9f74b328ae1337ea691ea116689437c8e3892 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Mon, 2 Mar 2020 18:57:51 +0100 Subject: [PATCH 34/47] Add Bingham 2D claw --- .../fluid_laws/bingham_2D_law.cpp | 156 ++++++++++++++++ .../fluid_laws/bingham_2D_law.h | 176 ++++++++++++++++++ 2 files changed, 332 insertions(+) create mode 100644 applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/bingham_2D_law.cpp create mode 100644 applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/bingham_2D_law.h diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/bingham_2D_law.cpp b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/bingham_2D_law.cpp new file mode 100644 index 000000000000..7c11a45d1674 --- /dev/null +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/bingham_2D_law.cpp @@ -0,0 +1,156 @@ +//------------------------------------------------------------- +// ___ __ ___ _ _ _ +// KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| | +// | _/ _/ -_) ' \| _|| | || | / _` | +// |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS +// +// BSD License: PfemFluidDynamicsApplication/license.txt +// +// Main authors: Riccardo Rossi, Alessandro Franci +// Collaborators: Massimiliano Zecchetto +// +//------------------------------------------------------------- +// + +// System includes +#include + +// External includes +#include + +// Project includes +#include "custom_constitutive/fluid_laws/bingham_2D_law.h" +#include "includes/checks.h" +#include "includes/properties.h" +#include "pfem_fluid_dynamics_application_variables.h" + +namespace Kratos { + +//********************************CONSTRUCTOR********************************* +//**************************************************************************** + +Bingham2DLaw::Bingham2DLaw() : PfemFluidConstitutiveLaw() {} + +//******************************COPY CONSTRUCTOR****************************** +//**************************************************************************** + +Bingham2DLaw::Bingham2DLaw(const Bingham2DLaw& rOther) : PfemFluidConstitutiveLaw(rOther) {} + +//***********************************CLONE************************************ +//**************************************************************************** + +ConstitutiveLaw::Pointer Bingham2DLaw::Clone() const { return Kratos::make_shared(*this); } + +//*********************************DESTRUCTOR********************************* +//**************************************************************************** + +Bingham2DLaw::~Bingham2DLaw() {} + +ConstitutiveLaw::SizeType Bingham2DLaw::WorkingSpaceDimension() { return 2; } + +ConstitutiveLaw::SizeType Bingham2DLaw::GetStrainSize() { return 3; } + +void Bingham2DLaw::CalculateMaterialResponseCauchy(Parameters& rValues) { + + Flags& r_options = rValues.GetOptions(); + + const Properties& r_properties = rValues.GetMaterialProperties(); + + Vector& r_strain_vector = rValues.GetStrainVector(); + Vector& r_stress_vector = rValues.GetStressVector(); + + const double dynamic_viscosity = this->GetEffectiveDynamicViscosity(rValues); + const double yield_shear = this->GetEffectiveYieldShear(rValues); + const double adaptive_exponent = r_properties[ADAPTIVE_EXPONENT]; + double effective_dynamic_viscosity; + + const double equivalent_strain_rate = + std::sqrt(2.0 * r_strain_vector[0] * r_strain_vector[0] + 2.0 * r_strain_vector[1] * r_strain_vector[1] + + 4.0 * r_strain_vector[2] * r_strain_vector[2]); + + // Ensuring that the case of equivalent_strain_rate = 0 is not problematic + if (equivalent_strain_rate <= 1e-5) { + effective_dynamic_viscosity = yield_shear * adaptive_exponent; + } else { + double regularization = 1.0 - std::exp(-adaptive_exponent * equivalent_strain_rate); + effective_dynamic_viscosity = dynamic_viscosity + regularization * yield_shear / equivalent_strain_rate; + } + + const double strain_trace = r_strain_vector[0] + r_strain_vector[1]; + + r_stress_vector[0] = 2.0 * effective_dynamic_viscosity * (r_strain_vector[0] - strain_trace / 3.0); + r_stress_vector[1] = 2.0 * effective_dynamic_viscosity * (r_strain_vector[1] - strain_trace / 3.0); + r_stress_vector[2] = 2.0 * effective_dynamic_viscosity * r_strain_vector[2]; + + if (r_options.Is(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR)) { + this->EffectiveViscousConstitutiveMatrix2D(effective_dynamic_viscosity, rValues.GetConstitutiveMatrix()); + } +} + +std::string Bingham2DLaw::Info() const { return "Bingham2DLaw"; } + +//******************CHECK CONSISTENCY IN THE CONSTITUTIVE LAW****************** +//***************************************************************************** + +int Bingham2DLaw::Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, + const ProcessInfo& rCurrentProcessInfo) { + + KRATOS_CHECK_VARIABLE_KEY(DYNAMIC_VISCOSITY); + KRATOS_CHECK_VARIABLE_KEY(YIELD_SHEAR); + KRATOS_CHECK_VARIABLE_KEY(ADAPTIVE_EXPONENT); + KRATOS_CHECK_VARIABLE_KEY(BULK_MODULUS); + + if (rMaterialProperties[DYNAMIC_VISCOSITY] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing DYNAMIC_VISCOSITY provided in process info for Bingham2DLaw: " + << rMaterialProperties[DYNAMIC_VISCOSITY] << std::endl; + } + + if (rMaterialProperties[YIELD_SHEAR] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing YIELD_SHEAR provided in process info for Bingham2DLaw: " + << rMaterialProperties[YIELD_SHEAR] << std::endl; + } + + if (rMaterialProperties[ADAPTIVE_EXPONENT] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing ADAPTIVE_EXPONENT provided in process info for Bingham2DLaw: " + << rMaterialProperties[ADAPTIVE_EXPONENT] << std::endl; + } + + if (rMaterialProperties[BULK_MODULUS] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing BULK_MODULUS provided in process info for Bingham2DLaw: " + << rMaterialProperties[BULK_MODULUS] << std::endl; + } + + return 0; +} + +double Bingham2DLaw::GetEffectiveViscosity(ConstitutiveLaw::Parameters& rParameters) const { + return rParameters.GetConstitutiveMatrix()(2, 2); +} + +double Bingham2DLaw::GetEffectiveDensity(ConstitutiveLaw::Parameters& rParameters) const { + const Properties& r_prop = rParameters.GetMaterialProperties(); + const double effective_density = r_prop[DENSITY]; + return effective_density; +} + +double Bingham2DLaw::GetEffectiveDynamicViscosity(ConstitutiveLaw::Parameters& rParameters) const { + const Properties& r_prop = rParameters.GetMaterialProperties(); + const double effective_dynamic_viscosity = r_prop[DYNAMIC_VISCOSITY]; + return effective_dynamic_viscosity; +} + +double Bingham2DLaw::GetEffectiveYieldShear(ConstitutiveLaw::Parameters& rParameters) const { + const Properties& r_prop = rParameters.GetMaterialProperties(); + const double effective_yield_shear = r_prop[YIELD_SHEAR]; + return effective_yield_shear; +} + +void Bingham2DLaw::save(Serializer& rSerializer) const { + KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, PfemFluidConstitutiveLaw) +} + +void Bingham2DLaw::load(Serializer& rSerializer) { + KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, PfemFluidConstitutiveLaw) +} + +} // Namespace Kratos diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/bingham_2D_law.h b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/bingham_2D_law.h new file mode 100644 index 000000000000..39a762f06b28 --- /dev/null +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/bingham_2D_law.h @@ -0,0 +1,176 @@ +//------------------------------------------------------------- +// ___ __ ___ _ _ _ +// KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| | +// | _/ _/ -_) ' \| _|| | || | / _` | +// |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS +// +// BSD License: PfemFluidDynamicsApplication/license.txt +// +// Main authors: Riccardo Rossi, Alessandro Franci +// Collaborators: Massimiliano Zecchetto +// +//------------------------------------------------------------- +// + +#if !defined(KRATOS_BINGHAM_LAW_2D_H_INCLUDED) +#define KRATOS_BINGHAM_LAW_2D_H_INCLUDED + +// System includes + +// External includes + +// Project includes +#include "fluid_constitutive_law.h" + +namespace Kratos { +/** + * Defines a 2D Bingham non-Newtonian constitutive law + * This material law is defined by the parameters: + * 1) DYNAMIC_VISCOSITY + * 2) YIELD_SHEAR + * 3) ADAPTIVE_EXPONENT + */ +class KRATOS_API(PFEM_FLUID_DYNAMICS_APPLICATION) Bingham2DLaw : public PfemFluidConstitutiveLaw { + public: + /** + * Type Definitions + */ + typedef ProcessInfo ProcessInfoType; + typedef ConstitutiveLaw BaseType; + typedef std::size_t SizeType; + + /** + * Counted pointer of Bingham2DLaw + */ + KRATOS_CLASS_POINTER_DEFINITION(Bingham2DLaw); + + /** + * Life Cycle + */ + + /** + * Default constructor. + */ + Bingham2DLaw(); + + /** + * Clone function (has to be implemented by any derived class) + * @return a pointer to a new instance of this constitutive law + */ + ConstitutiveLaw::Pointer Clone() const override; + + /** + * Copy constructor. + */ + Bingham2DLaw(const Bingham2DLaw& rOther); + + /** + * Destructor. + */ + ~Bingham2DLaw() override; + + /** + * Operators + */ + + /** + * Operations needed by the base class: + */ + + /** + * @return Working space dimension constitutive law + */ + SizeType WorkingSpaceDimension() override; + + /** + * @return Size of the strain vector (in Voigt notation) for the constitutive law + */ + SizeType GetStrainSize() override; + + void CalculateMaterialResponseCauchy(Parameters& rValues) override; + + /** + * This function is designed to be called once to perform all the checks needed + * on the input provided. Checks can be "expensive" as the function is designed + * to catch user's errors. + * @param rMaterialProperties + * @param rElementGeometry + * @param rCurrentProcessInfo + * @return + */ + int Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, + const ProcessInfo& rCurrentProcessInfo) override; + + /** + * Input and output + */ + + /** + * Turn back information as a string. + */ + std::string Info() const override; + + protected: + ///@name Protected static Member Variables + ///@{ + ///@} + ///@name Protected member Variables + ///@{ + ///@} + ///@name Protected Operators + ///@{ + ///@} + ///@name Protected Operations + ///@{ + + /// Get the effective viscosity (in dynamic units -- Pa s) for the fluid. + double GetEffectiveViscosity(ConstitutiveLaw::Parameters& rParameters) const override; + + /// Get the effective density for the fluid. + double GetEffectiveDensity(ConstitutiveLaw::Parameters& rParameters) const override; + + /// Get the effective yield shear for the fluid. + double GetEffectiveYieldShear(ConstitutiveLaw::Parameters& rParameters) const; + + /// Get the effective dynamic viscosity for the fluid. + double GetEffectiveDynamicViscosity(ConstitutiveLaw::Parameters& rParameters) const; + + ///@} + + private: + ///@name Static Member Variables + ///@{ + + ///@} + ///@name Member Variables + ///@{ + + ///@} + ///@name Private Operators + ///@{ + + ///@} + ///@name Private Operations + ///@{ + ///@} + + ///@} + ///@name Private Access + ///@{ + ///@} + + ///@} + ///@name Serialization + ///@{ + friend class Serializer; + + void save(Serializer& rSerializer) const override; + + void load(Serializer& rSerializer) override; + ///@} + +}; // Class Bingham2DLaw + +} // namespace Kratos. + +#endif // KRATOS_BINGHAM_LAW_2D_H_INCLUDED defined From b426f366d23399ea3c79c4f706b54ffb865888ec Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Mon, 2 Mar 2020 18:58:02 +0100 Subject: [PATCH 35/47] Add Bingham 3D claw --- .../fluid_laws/bingham_3D_law.cpp | 160 ++++++++++++++++ .../fluid_laws/bingham_3D_law.h | 176 ++++++++++++++++++ 2 files changed, 336 insertions(+) create mode 100644 applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/bingham_3D_law.cpp create mode 100644 applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/bingham_3D_law.h diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/bingham_3D_law.cpp b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/bingham_3D_law.cpp new file mode 100644 index 000000000000..79652f8c3b48 --- /dev/null +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/bingham_3D_law.cpp @@ -0,0 +1,160 @@ +//------------------------------------------------------------- +// ___ __ ___ _ _ _ +// KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| | +// | _/ _/ -_) ' \| _|| | || | / _` | +// |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS +// +// BSD License: PfemFluidDynamicsApplication/license.txt +// +// Main authors: Riccardo Rossi, Alessandro Franci +// Collaborators: Massimiliano Zecchetto +// +//------------------------------------------------------------- +// + +// System includes +#include + +// External includes +#include + +// Project includes +#include "custom_constitutive/fluid_laws/bingham_3D_law.h" +#include "includes/checks.h" +#include "includes/properties.h" +#include "pfem_fluid_dynamics_application_variables.h" + +namespace Kratos { + +//********************************CONSTRUCTOR********************************* +//**************************************************************************** + +Bingham3DLaw::Bingham3DLaw() : PfemFluidConstitutiveLaw() {} + +//******************************COPY CONSTRUCTOR****************************** +//**************************************************************************** + +Bingham3DLaw::Bingham3DLaw(const Bingham3DLaw& rOther) : PfemFluidConstitutiveLaw(rOther) {} + +//***********************************CLONE************************************ +//**************************************************************************** + +ConstitutiveLaw::Pointer Bingham3DLaw::Clone() const { return Kratos::make_shared(*this); } + +//*********************************DESTRUCTOR********************************* +//**************************************************************************** + +Bingham3DLaw::~Bingham3DLaw() {} + +ConstitutiveLaw::SizeType Bingham3DLaw::WorkingSpaceDimension() { return 3; } + +ConstitutiveLaw::SizeType Bingham3DLaw::GetStrainSize() { return 6; } + +void Bingham3DLaw::CalculateMaterialResponseCauchy(Parameters& rValues) { + + Flags& r_options = rValues.GetOptions(); + + const Properties& r_properties = rValues.GetMaterialProperties(); + + Vector& r_strain_vector = rValues.GetStrainVector(); + Vector& r_stress_vector = rValues.GetStressVector(); + + const double dynamic_viscosity = this->GetEffectiveDynamicViscosity(rValues); + const double yield_shear = this->GetEffectiveYieldShear(rValues); + const double adaptive_exponent = r_properties[ADAPTIVE_EXPONENT]; + double effective_dynamic_viscosity; + + const double equivalent_strain_rate = + std::sqrt(2.0 * r_strain_vector[0] * r_strain_vector[0] + 2.0 * r_strain_vector[1] * r_strain_vector[1] + + 2.0 * r_strain_vector[2] * r_strain_vector[2] + 4.0 * r_strain_vector[3] * r_strain_vector[3] + + 4.0 * r_strain_vector[4] * r_strain_vector[4] + 4.0 * r_strain_vector[5] * r_strain_vector[5]); + + // Ensuring that the case of equivalent_strain_rate = 0 is not problematic + if (equivalent_strain_rate <= 1e-5) { + effective_dynamic_viscosity = yield_shear * adaptive_exponent; + } else { + double regularization = 1.0 - std::exp(-adaptive_exponent * equivalent_strain_rate); + effective_dynamic_viscosity = dynamic_viscosity + regularization * yield_shear / equivalent_strain_rate; + } + + const double strain_trace = r_strain_vector[0] + r_strain_vector[1] + r_strain_vector[2]; + + r_stress_vector[0] = 2.0 * effective_dynamic_viscosity * (r_strain_vector[0] - strain_trace / 3.0); + r_stress_vector[1] = 2.0 * effective_dynamic_viscosity * (r_strain_vector[1] - strain_trace / 3.0); + r_stress_vector[2] = 2.0 * effective_dynamic_viscosity * (r_strain_vector[2] - strain_trace / 3.0); + r_stress_vector[3] = 2.0 * effective_dynamic_viscosity * r_strain_vector[3]; + r_stress_vector[4] = 2.0 * effective_dynamic_viscosity * r_strain_vector[4]; + r_stress_vector[5] = 2.0 * effective_dynamic_viscosity * r_strain_vector[5]; + + if (r_options.Is(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR)) { + this->EffectiveViscousConstitutiveMatrix3D(effective_dynamic_viscosity, rValues.GetConstitutiveMatrix()); + } +} + +std::string Bingham3DLaw::Info() const { return "Bingham3DLaw"; } + +//******************CHECK CONSISTENCY IN THE CONSTITUTIVE LAW****************** +//***************************************************************************** + +int Bingham3DLaw::Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, + const ProcessInfo& rCurrentProcessInfo) { + + KRATOS_CHECK_VARIABLE_KEY(DYNAMIC_VISCOSITY); + KRATOS_CHECK_VARIABLE_KEY(YIELD_SHEAR); + KRATOS_CHECK_VARIABLE_KEY(ADAPTIVE_EXPONENT); + KRATOS_CHECK_VARIABLE_KEY(BULK_MODULUS); + + if (rMaterialProperties[DYNAMIC_VISCOSITY] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing DYNAMIC_VISCOSITY provided in process info for Bingham3DLaw: " + << rMaterialProperties[DYNAMIC_VISCOSITY] << std::endl; + } + + if (rMaterialProperties[YIELD_SHEAR] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing YIELD_SHEAR provided in process info for Bingham3DLaw: " + << rMaterialProperties[YIELD_SHEAR] << std::endl; + } + + if (rMaterialProperties[ADAPTIVE_EXPONENT] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing ADAPTIVE_EXPONENT provided in process info for Bingham3DLaw: " + << rMaterialProperties[ADAPTIVE_EXPONENT] << std::endl; + } + + if (rMaterialProperties[BULK_MODULUS] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing BULK_MODULUS provided in process info for Bingham3DLaw: " + << rMaterialProperties[BULK_MODULUS] << std::endl; + } + + return 0; +} + +double Bingham3DLaw::GetEffectiveViscosity(ConstitutiveLaw::Parameters& rParameters) const { + return rParameters.GetConstitutiveMatrix()(5, 5); +} + +double Bingham3DLaw::GetEffectiveDensity(ConstitutiveLaw::Parameters& rParameters) const { + const Properties& r_prop = rParameters.GetMaterialProperties(); + const double effective_density = r_prop[DENSITY]; + return effective_density; +} + +double Bingham3DLaw::GetEffectiveDynamicViscosity(ConstitutiveLaw::Parameters& rParameters) const { + const Properties& r_prop = rParameters.GetMaterialProperties(); + const double effective_dynamic_viscosity = r_prop[DYNAMIC_VISCOSITY]; + return effective_dynamic_viscosity; +} + +double Bingham3DLaw::GetEffectiveYieldShear(ConstitutiveLaw::Parameters& rParameters) const { + const Properties& r_prop = rParameters.GetMaterialProperties(); + const double effective_yield_shear = r_prop[YIELD_SHEAR]; + return effective_yield_shear; +} + +void Bingham3DLaw::save(Serializer& rSerializer) const { + KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, PfemFluidConstitutiveLaw) +} + +void Bingham3DLaw::load(Serializer& rSerializer) { + KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, PfemFluidConstitutiveLaw) +} + +} // Namespace Kratos diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/bingham_3D_law.h b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/bingham_3D_law.h new file mode 100644 index 000000000000..a7efdd801485 --- /dev/null +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/bingham_3D_law.h @@ -0,0 +1,176 @@ +//------------------------------------------------------------- +// ___ __ ___ _ _ _ +// KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| | +// | _/ _/ -_) ' \| _|| | || | / _` | +// |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS +// +// BSD License: PfemFluidDynamicsApplication/license.txt +// +// Main authors: Riccardo Rossi, Alessandro Franci +// Collaborators: Massimiliano Zecchetto +// +//------------------------------------------------------------- +// + +#if !defined(KRATOS_BINGHAM_LAW_3D_H_INCLUDED) +#define KRATOS_BINGHAM_LAW_3D_H_INCLUDED + +// System includes + +// External includes + +// Project includes +#include "fluid_constitutive_law.h" + +namespace Kratos { +/** + * Defines a 3D Bingham non-Newtonian constitutive law + * This material law is defined by the parameters: + * 1) DYNAMIC_VISCOSITY + * 2) YIELD_SHEAR + * 3) ADAPTIVE_EXPONENT + */ +class KRATOS_API(PFEM_FLUID_DYNAMICS_APPLICATION) Bingham3DLaw : public PfemFluidConstitutiveLaw { + public: + /** + * Type Definitions + */ + typedef ProcessInfo ProcessInfoType; + typedef ConstitutiveLaw BaseType; + typedef std::size_t SizeType; + + /** + * Counted pointer of Bingham3DLaw + */ + KRATOS_CLASS_POINTER_DEFINITION(Bingham3DLaw); + + /** + * Life Cycle + */ + + /** + * Default constructor. + */ + Bingham3DLaw(); + + /** + * Clone function (has to be implemented by any derived class) + * @return a pointer to a new instance of this constitutive law + */ + ConstitutiveLaw::Pointer Clone() const override; + + /** + * Copy constructor. + */ + Bingham3DLaw(const Bingham3DLaw& rOther); + + /** + * Destructor. + */ + ~Bingham3DLaw() override; + + /** + * Operators + */ + + /** + * Operations needed by the base class: + */ + + /** + * @return Working space dimension constitutive law + */ + SizeType WorkingSpaceDimension() override; + + /** + * @return Size of the strain vector (in Voigt notation) for the constitutive law + */ + SizeType GetStrainSize() override; + + void CalculateMaterialResponseCauchy(Parameters& rValues) override; + + /** + * This function is designed to be called once to perform all the checks needed + * on the input provided. Checks can be "expensive" as the function is designed + * to catch user's errors. + * @param rMaterialProperties + * @param rElementGeometry + * @param rCurrentProcessInfo + * @return + */ + int Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, + const ProcessInfo& rCurrentProcessInfo) override; + + /** + * Input and output + */ + + /** + * Turn back information as a string. + */ + std::string Info() const override; + + protected: + ///@name Protected static Member Variables + ///@{ + ///@} + ///@name Protected member Variables + ///@{ + ///@} + ///@name Protected Operators + ///@{ + ///@} + ///@name Protected Operations + ///@{ + + /// Get the effective viscosity (in dynamic units -- Pa s) for the fluid. + double GetEffectiveViscosity(ConstitutiveLaw::Parameters& rParameters) const override; + + /// Get the effective density for the fluid. + double GetEffectiveDensity(ConstitutiveLaw::Parameters& rParameters) const override; + + /// Get the effective yield shear for the fluid. + double GetEffectiveYieldShear(ConstitutiveLaw::Parameters& rParameters) const; + + /// Get the effective dynamic viscosity for the fluid. + double GetEffectiveDynamicViscosity(ConstitutiveLaw::Parameters& rParameters) const; + + ///@} + + private: + ///@name Static Member Variables + ///@{ + + ///@} + ///@name Member Variables + ///@{ + + ///@} + ///@name Private Operators + ///@{ + + ///@} + ///@name Private Operations + ///@{ + ///@} + + ///@} + ///@name Private Access + ///@{ + ///@} + + ///@} + ///@name Serialization + ///@{ + friend class Serializer; + + void save(Serializer& rSerializer) const override; + + void load(Serializer& rSerializer) override; + ///@} + +}; // Class Bingham3DLaw + +} // namespace Kratos. + +#endif // KRATOS_BINGHAM_LAW_3D_H_INCLUDED defined From 2a0537a9caf407ddee80fa64ed0fd19c36a5134c Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Mon, 2 Mar 2020 19:15:54 +0100 Subject: [PATCH 36/47] Fixing copy-paste error in Newtonian3DLaw --- .../custom_constitutive/fluid_laws/newtonian_3D_law.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/newtonian_3D_law.h b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/newtonian_3D_law.h index 426c71032588..542b0be3b506 100644 --- a/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/newtonian_3D_law.h +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/newtonian_3D_law.h @@ -40,7 +40,7 @@ class KRATOS_API(PFEM_FLUID_DYNAMICS_APPLICATION) Newtonian3DLaw : public PfemFl /** * Counted pointer of Newtonian3DLaw */ - KRATOS_CLASS_POINTER_DEFINITION(Newtonian2DLaw); + KRATOS_CLASS_POINTER_DEFINITION(Newtonian3DLaw); /** * Life Cycle From 9771969e2f539afc83ad9e6143b0c66598749a18 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Tue, 3 Mar 2020 08:30:30 +0100 Subject: [PATCH 37/47] Add Barker-Bercovier 3D claw --- .../barker_bercovier_mu_I_rheology_3D_law.cpp | 240 ++++++++++++++++++ .../barker_bercovier_mu_I_rheology_3D_law.h | 175 +++++++++++++ 2 files changed, 415 insertions(+) create mode 100644 applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/barker_bercovier_mu_I_rheology_3D_law.cpp create mode 100644 applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/barker_bercovier_mu_I_rheology_3D_law.h diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/barker_bercovier_mu_I_rheology_3D_law.cpp b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/barker_bercovier_mu_I_rheology_3D_law.cpp new file mode 100644 index 000000000000..2a32317a3e25 --- /dev/null +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/barker_bercovier_mu_I_rheology_3D_law.cpp @@ -0,0 +1,240 @@ +//------------------------------------------------------------- +// ___ __ ___ _ _ _ +// KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| | +// | _/ _/ -_) ' \| _|| | || | / _` | +// |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS +// +// BSD License: PfemFluidDynamicsApplication/license.txt +// +// Main authors: Alessandro Franci +// Collaborators: Massimiliano Zecchetto +// +//------------------------------------------------------------- +// + +// System includes +#include + +// External includes +#include + +// Project includes +#include "custom_constitutive/fluid_laws/barker_bercovier_mu_I_rheology_3D_law.h" +#include "includes/checks.h" +#include "includes/properties.h" +#include "pfem_fluid_dynamics_application_variables.h" + +namespace Kratos { + +//********************************CONSTRUCTOR********************************* +//**************************************************************************** + +BarkerBercovierMuIRheology3DLaw::BarkerBercovierMuIRheology3DLaw() : PfemFluidConstitutiveLaw() {} + +//******************************COPY CONSTRUCTOR****************************** +//**************************************************************************** + +BarkerBercovierMuIRheology3DLaw::BarkerBercovierMuIRheology3DLaw(const BarkerBercovierMuIRheology3DLaw& rOther) + : PfemFluidConstitutiveLaw(rOther) {} + +//***********************************CLONE************************************ +//**************************************************************************** + +ConstitutiveLaw::Pointer BarkerBercovierMuIRheology3DLaw::Clone() const { + return Kratos::make_shared(*this); +} + +//*********************************DESTRUCTOR********************************* +//**************************************************************************** + +BarkerBercovierMuIRheology3DLaw::~BarkerBercovierMuIRheology3DLaw() {} + +ConstitutiveLaw::SizeType BarkerBercovierMuIRheology3DLaw::WorkingSpaceDimension() { return 3; } + +ConstitutiveLaw::SizeType BarkerBercovierMuIRheology3DLaw::GetStrainSize() { return 6; } + +void BarkerBercovierMuIRheology3DLaw::CalculateMaterialResponseCauchy(Parameters& rValues) { + + Flags& r_options = rValues.GetOptions(); + + const Properties& r_properties = rValues.GetMaterialProperties(); + + Vector& r_strain_vector = rValues.GetStrainVector(); + Vector& r_stress_vector = rValues.GetStressVector(); + + const double static_friction = r_properties[STATIC_FRICTION]; + const double dynamic_friction = r_properties[DYNAMIC_FRICTION]; + const double delta_friction = dynamic_friction - static_friction; + const double inertial_number_zero = r_properties[INERTIAL_NUMBER_ZERO]; + const double grain_diameter = r_properties[GRAIN_DIAMETER]; + const double grain_density = r_properties[GRAIN_DENSITY]; + const double regularization_coeff = r_properties[REGULARIZATION_COEFFICIENT]; + const double inertial_number_one = r_properties[INERTIAL_NUMBER_ONE]; + const double infinite_friction_coeff = r_properties[INFINITE_FRICTION]; + const double alpha_parameter = r_properties[ALPHA_PARAMETER]; + double inertial_number = 0; + double effective_dynamic_viscosity = 0; + + const double old_pressure = this->CalculateInGaussPoint(PRESSURE, rValues, 1); + const double new_pressure = this->CalculateInGaussPoint(PRESSURE, rValues, 0); + const GeometryType& r_geometry = rValues.GetElementGeometry(); + + const double theta_momentum = r_geometry[0].GetValue(THETA_MOMENTUM); + double mean_pressure = (1.0 - theta_momentum) * old_pressure + theta_momentum * new_pressure; + if (mean_pressure > 0.0) { + mean_pressure = 0.0000001; + } + + const double equivalent_strain_rate = + std::sqrt(2.0 * r_strain_vector[0] * r_strain_vector[0] + 2.0 * r_strain_vector[1] * r_strain_vector[1] + + 2.0 * r_strain_vector[2] * r_strain_vector[2] + 4.0 * r_strain_vector[3] * r_strain_vector[3] + + 4.0 * r_strain_vector[4] * r_strain_vector[4] + 4.0 * r_strain_vector[5] * r_strain_vector[5]); + + if (mean_pressure != 0) { + inertial_number = equivalent_strain_rate * grain_diameter / std::sqrt(std::fabs(mean_pressure) / grain_density); + } + + double exponent = 0.0; + + if (inertial_number > inertial_number_one) { + const double first_viscous_term = static_friction; + const double second_viscous_term = delta_friction * inertial_number / (inertial_number_zero + inertial_number); + effective_dynamic_viscosity = (first_viscous_term + second_viscous_term); + } else { + const double denominator = static_friction * inertial_number_zero + dynamic_friction * inertial_number_one + + infinite_friction_coeff * std::pow(inertial_number_one, 2); + exponent = alpha_parameter * (inertial_number_zero + inertial_number_one) * + (inertial_number_zero + inertial_number_one) / std::pow(denominator, 2); + const double firstAconstant = inertial_number_one * std::exp(exponent); + effective_dynamic_viscosity = std::sqrt(alpha_parameter / std::log(firstAconstant / inertial_number)); + } + + if (equivalent_strain_rate != 0 && std::fabs(mean_pressure) != 0) { + exponent = -equivalent_strain_rate / regularization_coeff; + effective_dynamic_viscosity *= std::fabs(mean_pressure) * (1.0 - std::exp(exponent)) / equivalent_strain_rate; + } else { + if (mean_pressure == 0.0 && equivalent_strain_rate != 0.0) { + effective_dynamic_viscosity *= + 1.0 / std::sqrt(std::pow(equivalent_strain_rate, 2) + std::pow(regularization_coeff, 2)); + } else if (mean_pressure != 0 && equivalent_strain_rate == 0) { + effective_dynamic_viscosity *= + std::fabs(mean_pressure) / std::sqrt(0.001 + std::pow(regularization_coeff, 2)); + } else { + effective_dynamic_viscosity = 1.0; + } + } + + const double strain_trace = r_strain_vector[0] + r_strain_vector[1] + r_strain_vector[2]; + + r_stress_vector[0] = 2.0 * effective_dynamic_viscosity * (r_strain_vector[0] - strain_trace / 3.0); + r_stress_vector[1] = 2.0 * effective_dynamic_viscosity * (r_strain_vector[1] - strain_trace / 3.0); + r_stress_vector[2] = 2.0 * effective_dynamic_viscosity * (r_strain_vector[2] - strain_trace / 3.0); + r_stress_vector[3] = 2.0 * effective_dynamic_viscosity * r_strain_vector[3]; + r_stress_vector[4] = 2.0 * effective_dynamic_viscosity * r_strain_vector[4]; + r_stress_vector[5] = 2.0 * effective_dynamic_viscosity * r_strain_vector[5]; + + if (r_options.Is(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR)) { + this->EffectiveViscousConstitutiveMatrix3D(effective_dynamic_viscosity, rValues.GetConstitutiveMatrix()); + } +} + +std::string BarkerBercovierMuIRheology3DLaw::Info() const { return "BarkerBercovierMuIRheology3DLaw"; } + +//******************CHECK CONSISTENCY IN THE CONSTITUTIVE LAW****************** +//***************************************************************************** + +int BarkerBercovierMuIRheology3DLaw::Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, + const ProcessInfo& rCurrentProcessInfo) { + KRATOS_CHECK_VARIABLE_KEY(STATIC_FRICTION); + KRATOS_CHECK_VARIABLE_KEY(DYNAMIC_FRICTION); + KRATOS_CHECK_VARIABLE_KEY(INERTIAL_NUMBER_ZERO); + KRATOS_CHECK_VARIABLE_KEY(GRAIN_DIAMETER); + KRATOS_CHECK_VARIABLE_KEY(GRAIN_DENSITY); + KRATOS_CHECK_VARIABLE_KEY(REGULARIZATION_COEFFICIENT); + KRATOS_CHECK_VARIABLE_KEY(INERTIAL_NUMBER_ONE); + KRATOS_CHECK_VARIABLE_KEY(ALPHA_PARAMETER); + KRATOS_CHECK_VARIABLE_KEY(INFINITE_FRICTION); + KRATOS_CHECK_VARIABLE_KEY(BULK_MODULUS); + + if (rMaterialProperties[STATIC_FRICTION] <= 0.0) { + KRATOS_ERROR + << "Incorrect or missing STATIC_FRICTION provided in process info for BarkerBercovierMuIRheology3DLaw: " + << rMaterialProperties[STATIC_FRICTION] << std::endl; + } + + if (rMaterialProperties[DYNAMIC_FRICTION] <= 0.0) { + KRATOS_ERROR + << "Incorrect or missing DYNAMIC_FRICTION provided in process info for BarkerBercovierMuIRheology3DLaw: " + << rMaterialProperties[DYNAMIC_FRICTION] << std::endl; + } + + if (rMaterialProperties[INERTIAL_NUMBER_ZERO] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing INERTIAL_NUMBER_ZERO provided in process info for " + "BarkerBercovierMuIRheology3DLaw: " + << rMaterialProperties[INERTIAL_NUMBER_ZERO] << std::endl; + } + + if (rMaterialProperties[INERTIAL_NUMBER_ONE] <= 0.0) { + KRATOS_ERROR + << "Incorrect or missing INERTIAL_NUMBER_ONE provided in process info for BarkerBercovierMuIRheology3DLaw: " + << rMaterialProperties[INERTIAL_NUMBER_ONE] << std::endl; + } + + if (rMaterialProperties[GRAIN_DIAMETER] <= 0.0) { + KRATOS_ERROR + << "Incorrect or missing GRAIN_DIAMETER provided in process info for BarkerBercovierMuIRheology3DLaw: " + << rMaterialProperties[GRAIN_DIAMETER] << std::endl; + } + + if (rMaterialProperties[GRAIN_DENSITY] <= 0.0) { + KRATOS_ERROR + << "Incorrect or missing GRAIN_DENSITY provided in process info for BarkerBercovierMuIRheology3DLaw: " + << rMaterialProperties[GRAIN_DENSITY] << std::endl; + } + + if (rMaterialProperties[REGULARIZATION_COEFFICIENT] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing REGULARIZATION_COEFFICIENT provided in process info for " + "BarkerBercovierMuIRheology3DLaw: " + << rMaterialProperties[REGULARIZATION_COEFFICIENT] << std::endl; + } + + if (rMaterialProperties[INFINITE_FRICTION] <= 0.0) { + KRATOS_ERROR + << "Incorrect or missing INFINITE_FRICTION provided in process info for BarkerBercovierMuIRheology3DLaw: " + << rMaterialProperties[INFINITE_FRICTION] << std::endl; + } + + if (rMaterialProperties[ALPHA_PARAMETER] <= 0.0) { + KRATOS_ERROR + << "Incorrect or missing ALPHA_PARAMETER provided in process info for BarkerBercovierMuIRheology3DLaw: " + << rMaterialProperties[ALPHA_PARAMETER] << std::endl; + } + + if (rMaterialProperties[BULK_MODULUS] <= 0.0) { + KRATOS_ERROR + << "Incorrect or missing BULK_MODULUS provided in process info for BarkerBercovierMuIRheology3DLaw: " + << rMaterialProperties[BULK_MODULUS] << std::endl; + } + + return 0; +} + +double BarkerBercovierMuIRheology3DLaw::GetEffectiveViscosity(ConstitutiveLaw::Parameters& rParameters) const { + return rParameters.GetConstitutiveMatrix()(5, 5); +} + +double BarkerBercovierMuIRheology3DLaw::GetEffectiveDensity(ConstitutiveLaw::Parameters& rParameters) const { + const Properties& r_prop = rParameters.GetMaterialProperties(); + const double effective_density = r_prop[DENSITY]; + return effective_density; +} + +void BarkerBercovierMuIRheology3DLaw::save(Serializer& rSerializer) const { + KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, PfemFluidConstitutiveLaw) +} + +void BarkerBercovierMuIRheology3DLaw::load(Serializer& rSerializer) { + KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, PfemFluidConstitutiveLaw) +} + +} // Namespace Kratos diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/barker_bercovier_mu_I_rheology_3D_law.h b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/barker_bercovier_mu_I_rheology_3D_law.h new file mode 100644 index 000000000000..28cb762ba1f3 --- /dev/null +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/barker_bercovier_mu_I_rheology_3D_law.h @@ -0,0 +1,175 @@ +//------------------------------------------------------------- +// ___ __ ___ _ _ _ +// KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| | +// | _/ _/ -_) ' \| _|| | || | / _` | +// |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS +// +// BSD License: PfemFluidDynamicsApplication/license.txt +// +// Main authors: Alessandro Franci +// Collaborators: Massimiliano Zecchetto +// +//------------------------------------------------------------- +// + +#if !defined(KRATOS_BARKER_BERCOVIER_MU_I_RHEOLOGY_LAW_3D_H_INCLUDED) +#define KRATOS_BARKER_BERCOVIER_MU_I_RHEOLOGY_LAW_3D_H_INCLUDED + +// System includes + +// External includes + +// Project includes +#include "fluid_constitutive_law.h" + +namespace Kratos { +/** + * Defines a 3D Barker-Bercovier mu(I) rheology constitutive law + * This material law is defined by the parameters: + * 1) STATIC_FRICTION + * 2) DYNAMIC_FRICTION + * 3) INERTIAL_NUMBER_ZERO + * 4) GRAIN_DIAMETER + * 5) GRAIN_DENSITY + * 6) REGULARIZATION_COEFFICIENT + * 7) INERTIAL_NUMBER_ONE + * 8) ALPHA_PARAMETER + * 9) INFINITE_FRICTION + */ + +class KRATOS_API(PFEM_FLUID_DYNAMICS_APPLICATION) BarkerBercovierMuIRheology3DLaw : public PfemFluidConstitutiveLaw { + public: + /** + * Type Definitions + */ + typedef ProcessInfo ProcessInfoType; + typedef ConstitutiveLaw BaseType; + typedef std::size_t SizeType; + + /** + * Counted pointer of BarkerBercovierMuIRheology3DLaw + */ + KRATOS_CLASS_POINTER_DEFINITION(BarkerBercovierMuIRheology3DLaw); + + /** + * Life Cycle + */ + + /** + * Default constructor. + */ + BarkerBercovierMuIRheology3DLaw(); + + /** + * Clone function (has to be implemented by any derived class) + * @return a pointer to a new instance of this constitutive law + */ + ConstitutiveLaw::Pointer Clone() const override; + + /** + * Copy constructor. + */ + BarkerBercovierMuIRheology3DLaw(const BarkerBercovierMuIRheology3DLaw& rOther); + + /** + * Destructor. + */ + ~BarkerBercovierMuIRheology3DLaw() override; + + /** + * Operators + */ + + /** + * Operations needed by the base class: + */ + + /** + * @return Working space dimension constitutive law + */ + SizeType WorkingSpaceDimension() override; + + /** + * @return Size of the strain vector (in Voigt notation) for the constitutive law + */ + SizeType GetStrainSize() override; + + void CalculateMaterialResponseCauchy(Parameters& rValues) override; + + /** + * This function is designed to be called once to perform all the checks needed + * on the input provided. Checks can be "expensive" as the function is designed + * to catch user's errors. + * @param rMaterialProperties + * @param rElementGeometry + * @param rCurrentProcessInfo + * @return + */ + int Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, + const ProcessInfo& rCurrentProcessInfo) override; + + /** + * Input and output + */ + + /** + * Turn back information as a string. + */ + std::string Info() const override; + + protected: + ///@name Protected static Member Variables + ///@{ + ///@} + ///@name Protected member Variables + ///@{ + ///@} + ///@name Protected Operators + ///@{ + ///@} + ///@name Protected Operations + ///@{ + + /// Get the effective viscosity (in dynamic units -- Pa s) for the fluid. + double GetEffectiveViscosity(ConstitutiveLaw::Parameters& rParameters) const override; + + /// Get the effective density for the fluid. + double GetEffectiveDensity(ConstitutiveLaw::Parameters& rParameters) const override; + + ///@} + + private: + ///@name Static Member Variables + ///@{ + ///@} + ///@name Member Variables + ///@{ + + ///@} + ///@name Private Operators + ///@{ + + ///@} + ///@name Private Operations + ///@{ + ///@} + + ///@} + ///@name Private Access + ///@{ + ///@} + + ///@} + ///@name Serialization + ///@{ + friend class Serializer; + + void save(Serializer& rSerializer) const override; + + void load(Serializer& rSerializer) override; + +}; // Class BarkerBercovierMuIRheology3DLaw + +} // namespace Kratos. + +#endif // KRATOS_BARKER_BERCOVIER_MU_I_RHEOLOGY_LAW_3D_H_INCLUDED defined From 1f82b94eb9903571810d38ff5e19b40cbc2d64c2 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Tue, 3 Mar 2020 08:30:50 +0100 Subject: [PATCH 38/47] Add Barker 3D claw --- .../barker_mu_I_rheology_3D_law.cpp | 212 ++++++++++++++++++ .../fluid_laws/barker_mu_I_rheology_3D_law.h | 174 ++++++++++++++ 2 files changed, 386 insertions(+) create mode 100644 applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/barker_mu_I_rheology_3D_law.cpp create mode 100644 applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/barker_mu_I_rheology_3D_law.h diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/barker_mu_I_rheology_3D_law.cpp b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/barker_mu_I_rheology_3D_law.cpp new file mode 100644 index 000000000000..46965ec5bbb6 --- /dev/null +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/barker_mu_I_rheology_3D_law.cpp @@ -0,0 +1,212 @@ +//------------------------------------------------------------- +// ___ __ ___ _ _ _ +// KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| | +// | _/ _/ -_) ' \| _|| | || | / _` | +// |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS +// +// BSD License: PfemFluidDynamicsApplication/license.txt +// +// Main authors: Alessandro Franci +// Collaborators: Massimiliano Zecchetto +// +//------------------------------------------------------------- +// + +// System includes +#include + +// External includes +#include + +// Project includes +#include "custom_constitutive/fluid_laws/barker_mu_I_rheology_3D_law.h" +#include "includes/checks.h" +#include "includes/properties.h" +#include "pfem_fluid_dynamics_application_variables.h" + +namespace Kratos { + +//********************************CONSTRUCTOR********************************* +//**************************************************************************** + +BarkerMuIRheology3DLaw::BarkerMuIRheology3DLaw() : PfemFluidConstitutiveLaw() {} + +//******************************COPY CONSTRUCTOR****************************** +//**************************************************************************** + +BarkerMuIRheology3DLaw::BarkerMuIRheology3DLaw(const BarkerMuIRheology3DLaw& rOther) + : PfemFluidConstitutiveLaw(rOther) {} + +//***********************************CLONE************************************ +//**************************************************************************** + +ConstitutiveLaw::Pointer BarkerMuIRheology3DLaw::Clone() const { + return Kratos::make_shared(*this); +} + +//*********************************DESTRUCTOR********************************* +//**************************************************************************** + +BarkerMuIRheology3DLaw::~BarkerMuIRheology3DLaw() {} + +ConstitutiveLaw::SizeType BarkerMuIRheology3DLaw::WorkingSpaceDimension() { return 3; } + +ConstitutiveLaw::SizeType BarkerMuIRheology3DLaw::GetStrainSize() { return 6; } + +void BarkerMuIRheology3DLaw::CalculateMaterialResponseCauchy(Parameters& rValues) { + + Flags& r_options = rValues.GetOptions(); + + const Properties& r_properties = rValues.GetMaterialProperties(); + + Vector& r_strain_vector = rValues.GetStrainVector(); + Vector& r_stress_vector = rValues.GetStressVector(); + + const double static_friction = r_properties[STATIC_FRICTION]; + const double dynamic_friction = r_properties[DYNAMIC_FRICTION]; + const double inertial_number_zero = r_properties[INERTIAL_NUMBER_ZERO]; + const double inertial_number_one = r_properties[INERTIAL_NUMBER_ONE]; + const double grain_diameter = r_properties[GRAIN_DIAMETER]; + const double grain_density = r_properties[GRAIN_DENSITY]; + const double infinite_friction = r_properties[INFINITE_FRICTION]; + const double alpha_parameter = r_properties[ALPHA_PARAMETER]; + double inertial_number = 0; + double effective_dynamic_viscosity = 0; + + const double old_pressure = this->CalculateInGaussPoint(PRESSURE, rValues, 1); + const double new_pressure = this->CalculateInGaussPoint(PRESSURE, rValues, 0); + const GeometryType& r_geometry = rValues.GetElementGeometry(); + + const double theta_momentum = r_geometry[0].GetValue(THETA_MOMENTUM); + double mean_pressure = (1.0 - theta_momentum) * old_pressure + theta_momentum * new_pressure; + if (mean_pressure > 0.0) { + mean_pressure = 0.0000001; + } + + const double equivalent_strain_rate = + std::sqrt(2.0 * r_strain_vector[0] * r_strain_vector[0] + 2.0 * r_strain_vector[1] * r_strain_vector[1] + + 2.0 * r_strain_vector[2] * r_strain_vector[2] + 4.0 * r_strain_vector[3] * r_strain_vector[3] + + 4.0 * r_strain_vector[4] * r_strain_vector[4] + 4.0 * r_strain_vector[5] * r_strain_vector[5]); + + if (mean_pressure != 0) { + inertial_number = equivalent_strain_rate * grain_diameter / std::sqrt(std::fabs(mean_pressure) / grain_density); + } + + if (inertial_number > inertial_number_one) { + effective_dynamic_viscosity = (static_friction * inertial_number_zero + dynamic_friction * inertial_number + + infinite_friction * std::pow(inertial_number, 2)) / + (inertial_number_zero + inertial_number); + } else { + const double denominator = static_friction * inertial_number_zero + dynamic_friction * inertial_number_one + + infinite_friction * std::pow(inertial_number_one, 2); + const double exponent = alpha_parameter * (inertial_number_zero + inertial_number_one) * + (inertial_number_zero + inertial_number_one) / std::pow(denominator, 2); + const double first_a_constant = inertial_number_one * std::exp(exponent); + effective_dynamic_viscosity = std::sqrt(alpha_parameter / std::log(first_a_constant / inertial_number)); + } + + if (equivalent_strain_rate != 0 && std::fabs(mean_pressure) != 0) { + effective_dynamic_viscosity *= std::fabs(mean_pressure) / equivalent_strain_rate; + } else { + effective_dynamic_viscosity = 1.0; + } + + const double strain_trace = r_strain_vector[0] + r_strain_vector[1] + r_strain_vector[2]; + + r_stress_vector[0] = 2.0 * effective_dynamic_viscosity * (r_strain_vector[0] - strain_trace / 3.0); + r_stress_vector[1] = 2.0 * effective_dynamic_viscosity * (r_strain_vector[1] - strain_trace / 3.0); + r_stress_vector[2] = 2.0 * effective_dynamic_viscosity * (r_strain_vector[2] - strain_trace / 3.0); + r_stress_vector[3] = 2.0 * effective_dynamic_viscosity * r_strain_vector[3]; + r_stress_vector[4] = 2.0 * effective_dynamic_viscosity * r_strain_vector[4]; + r_stress_vector[5] = 2.0 * effective_dynamic_viscosity * r_strain_vector[5]; + + if (r_options.Is(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR)) { + this->EffectiveViscousConstitutiveMatrix3D(effective_dynamic_viscosity, rValues.GetConstitutiveMatrix()); + } +} + +std::string BarkerMuIRheology3DLaw::Info() const { return "BarkerMuIRheology3DLaw"; } + +//******************CHECK CONSISTENCY IN THE CONSTITUTIVE LAW****************** +//***************************************************************************** + +int BarkerMuIRheology3DLaw::Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, + const ProcessInfo& rCurrentProcessInfo) { + KRATOS_CHECK_VARIABLE_KEY(STATIC_FRICTION); + KRATOS_CHECK_VARIABLE_KEY(DYNAMIC_FRICTION); + KRATOS_CHECK_VARIABLE_KEY(INERTIAL_NUMBER_ZERO); + KRATOS_CHECK_VARIABLE_KEY(INERTIAL_NUMBER_ONE); + KRATOS_CHECK_VARIABLE_KEY(GRAIN_DIAMETER); + KRATOS_CHECK_VARIABLE_KEY(GRAIN_DENSITY); + KRATOS_CHECK_VARIABLE_KEY(INFINITE_FRICTION); + KRATOS_CHECK_VARIABLE_KEY(ALPHA_PARAMETER); + KRATOS_CHECK_VARIABLE_KEY(BULK_MODULUS); + + if (rMaterialProperties[STATIC_FRICTION] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing STATIC_FRICTION provided in process info for BarkerMuIRheology3DLaw: " + << rMaterialProperties[STATIC_FRICTION] << std::endl; + } + + if (rMaterialProperties[DYNAMIC_FRICTION] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing DYNAMIC_FRICTION provided in process info for BarkerMuIRheology3DLaw: " + << rMaterialProperties[DYNAMIC_FRICTION] << std::endl; + } + + if (rMaterialProperties[INERTIAL_NUMBER_ZERO] <= 0.0) { + KRATOS_ERROR + << "Incorrect or missing INERTIAL_NUMBER_ZERO provided in process info for BarkerMuIRheology3DLaw: " + << rMaterialProperties[INERTIAL_NUMBER_ZERO] << std::endl; + } + + if (rMaterialProperties[INERTIAL_NUMBER_ONE] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing INERTIAL_NUMBER_ONE provided in process info for BarkerMuIRheology3DLaw: " + << rMaterialProperties[INERTIAL_NUMBER_ONE] << std::endl; + } + + if (rMaterialProperties[GRAIN_DIAMETER] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing GRAIN_DIAMETER provided in process info for BarkerMuIRheology3DLaw: " + << rMaterialProperties[GRAIN_DIAMETER] << std::endl; + } + + if (rMaterialProperties[GRAIN_DENSITY] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing GRAIN_DENSITY provided in process info for BarkerMuIRheology3DLaw: " + << rMaterialProperties[GRAIN_DENSITY] << std::endl; + } + + if (rMaterialProperties[INFINITE_FRICTION] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing INFINITE_FRICTION provided in process info for BarkerMuIRheology3DLaw: " + << rMaterialProperties[INFINITE_FRICTION] << std::endl; + } + + if (rMaterialProperties[ALPHA_PARAMETER] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing ALPHA_PARAMETER provided in process info for BarkerMuIRheology3DLaw: " + << rMaterialProperties[ALPHA_PARAMETER] << std::endl; + } + + if (rMaterialProperties[BULK_MODULUS] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing BULK_MODULUS provided in process info for BarkerMuIRheology3DLaw: " + << rMaterialProperties[BULK_MODULUS] << std::endl; + } + + return 0; +} + +double BarkerMuIRheology3DLaw::GetEffectiveViscosity(ConstitutiveLaw::Parameters& rParameters) const { + return rParameters.GetConstitutiveMatrix()(5, 5); +} + +double BarkerMuIRheology3DLaw::GetEffectiveDensity(ConstitutiveLaw::Parameters& rParameters) const { + const Properties& r_prop = rParameters.GetMaterialProperties(); + const double effective_density = r_prop[DENSITY]; + return effective_density; +} + +void BarkerMuIRheology3DLaw::save(Serializer& rSerializer) const { + KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, PfemFluidConstitutiveLaw) +} + +void BarkerMuIRheology3DLaw::load(Serializer& rSerializer) { + KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, PfemFluidConstitutiveLaw) +} + +} // Namespace Kratos diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/barker_mu_I_rheology_3D_law.h b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/barker_mu_I_rheology_3D_law.h new file mode 100644 index 000000000000..58753182145a --- /dev/null +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/barker_mu_I_rheology_3D_law.h @@ -0,0 +1,174 @@ +//------------------------------------------------------------- +// ___ __ ___ _ _ _ +// KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| | +// | _/ _/ -_) ' \| _|| | || | / _` | +// |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS +// +// BSD License: PfemFluidDynamicsApplication/license.txt +// +// Main authors: Alessandro Franci +// Collaborators: Massimiliano Zecchetto +// +//------------------------------------------------------------- +// + +#if !defined(KRATOS_BARKER_MU_I_RHEOLOGY_LAW_3D_H_INCLUDED) +#define KRATOS_BARKER_MU_I_RHEOLOGY_LAW_3D_H_INCLUDED + +// System includes + +// External includes + +// Project includes +#include "fluid_constitutive_law.h" + +namespace Kratos { +/** + * Defines a 3D Barker mu(I) rheology constitutive law + * This material law is defined by the parameters: + * 1) STATIC_FRICTION + * 2) DYNAMIC_FRICTION + * 3) INERTIAL_NUMBER_ZERO + * 4) GRAIN_DIAMETER + * 5) GRAIN_DENSITY + * 6) INERTIAL_NUMBER_ONE + * 7) INFINITE_FRICTION + * 8) ALPHA_PARAMETER + */ + +class KRATOS_API(PFEM_FLUID_DYNAMICS_APPLICATION) BarkerMuIRheology3DLaw : public PfemFluidConstitutiveLaw { + public: + /** + * Type Definitions + */ + typedef ProcessInfo ProcessInfoType; + typedef ConstitutiveLaw BaseType; + typedef std::size_t SizeType; + + /** + * Counted pointer of BarkerMuIRheology3DLaw + */ + KRATOS_CLASS_POINTER_DEFINITION(BarkerMuIRheology3DLaw); + + /** + * Life Cycle + */ + + /** + * Default constructor. + */ + BarkerMuIRheology3DLaw(); + + /** + * Clone function (has to be implemented by any derived class) + * @return a pointer to a new instance of this constitutive law + */ + ConstitutiveLaw::Pointer Clone() const override; + + /** + * Copy constructor. + */ + BarkerMuIRheology3DLaw(const BarkerMuIRheology3DLaw& rOther); + + /** + * Destructor. + */ + ~BarkerMuIRheology3DLaw() override; + + /** + * Operators + */ + + /** + * Operations needed by the base class: + */ + + /** + * @return Working space dimension constitutive law + */ + SizeType WorkingSpaceDimension() override; + + /** + * @return Size of the strain vector (in Voigt notation) for the constitutive law + */ + SizeType GetStrainSize() override; + + void CalculateMaterialResponseCauchy(Parameters& rValues) override; + + /** + * This function is designed to be called once to perform all the checks needed + * on the input provided. Checks can be "expensive" as the function is designed + * to catch user's errors. + * @param rMaterialProperties + * @param rElementGeometry + * @param rCurrentProcessInfo + * @return + */ + int Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, + const ProcessInfo& rCurrentProcessInfo) override; + + /** + * Input and output + */ + + /** + * Turn back information as a string. + */ + std::string Info() const override; + + protected: + ///@name Protected static Member Variables + ///@{ + ///@} + ///@name Protected member Variables + ///@{ + ///@} + ///@name Protected Operators + ///@{ + ///@} + ///@name Protected Operations + ///@{ + + /// Get the effective viscosity (in dynamic units -- Pa s) for the fluid. + double GetEffectiveViscosity(ConstitutiveLaw::Parameters& rParameters) const override; + + /// Get the effective density for the fluid. + double GetEffectiveDensity(ConstitutiveLaw::Parameters& rParameters) const override; + + ///@} + + private: + ///@name Static Member Variables + ///@{ + ///@} + ///@name Member Variables + ///@{ + + ///@} + ///@name Private Operators + ///@{ + + ///@} + ///@name Private Operations + ///@{ + ///@} + + ///@} + ///@name Private Access + ///@{ + ///@} + + ///@} + ///@name Serialization + ///@{ + friend class Serializer; + + void save(Serializer& rSerializer) const override; + + void load(Serializer& rSerializer) override; + +}; // Class BarkerMuIRheology3DLaw + +} // namespace Kratos. + +#endif // KRATOS_BARKER_MU_I_RHEOLOGY_LAW_3D_H_INCLUDED defined From a60c9337e90490fa2759fa60eb9222c67f67a29f Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Tue, 3 Mar 2020 08:31:13 +0100 Subject: [PATCH 39/47] Add Bercovier 3D claw --- .../bercovier_mu_I_rheology_3D_law.cpp | 192 ++++++++++++++++++ .../bercovier_mu_I_rheology_3D_law.h | 172 ++++++++++++++++ 2 files changed, 364 insertions(+) create mode 100644 applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/bercovier_mu_I_rheology_3D_law.cpp create mode 100644 applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/bercovier_mu_I_rheology_3D_law.h diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/bercovier_mu_I_rheology_3D_law.cpp b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/bercovier_mu_I_rheology_3D_law.cpp new file mode 100644 index 000000000000..dfedb3920b1a --- /dev/null +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/bercovier_mu_I_rheology_3D_law.cpp @@ -0,0 +1,192 @@ +//------------------------------------------------------------- +// ___ __ ___ _ _ _ +// KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| | +// | _/ _/ -_) ' \| _|| | || | / _` | +// |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS +// +// BSD License: PfemFluidDynamicsApplication/license.txt +// +// Main authors: Alessandro Franci +// Collaborators: Massimiliano Zecchetto +// +//------------------------------------------------------------- +// + +// System includes +#include + +// External includes +#include + +// Project includes +#include "custom_constitutive/fluid_laws/bercovier_mu_I_rheology_3D_law.h" +#include "includes/checks.h" +#include "includes/properties.h" +#include "pfem_fluid_dynamics_application_variables.h" + +namespace Kratos { + +//********************************CONSTRUCTOR********************************* +//**************************************************************************** + +BercovierMuIRheology3DLaw::BercovierMuIRheology3DLaw() : PfemFluidConstitutiveLaw() {} + +//******************************COPY CONSTRUCTOR****************************** +//**************************************************************************** + +BercovierMuIRheology3DLaw::BercovierMuIRheology3DLaw(const BercovierMuIRheology3DLaw& rOther) + : PfemFluidConstitutiveLaw(rOther) {} + +//***********************************CLONE************************************ +//**************************************************************************** + +ConstitutiveLaw::Pointer BercovierMuIRheology3DLaw::Clone() const { + return Kratos::make_shared(*this); +} + +//*********************************DESTRUCTOR********************************* +//**************************************************************************** + +BercovierMuIRheology3DLaw::~BercovierMuIRheology3DLaw() {} + +ConstitutiveLaw::SizeType BercovierMuIRheology3DLaw::WorkingSpaceDimension() { return 3; } + +ConstitutiveLaw::SizeType BercovierMuIRheology3DLaw::GetStrainSize() { return 6; } + +void BercovierMuIRheology3DLaw::CalculateMaterialResponseCauchy(Parameters& rValues) { + + Flags& r_options = rValues.GetOptions(); + + const Properties& r_properties = rValues.GetMaterialProperties(); + + Vector& r_strain_vector = rValues.GetStrainVector(); + Vector& r_stress_vector = rValues.GetStressVector(); + + const double static_friction = r_properties[STATIC_FRICTION]; + const double dynamic_friction = r_properties[DYNAMIC_FRICTION]; + const double delta_friction = dynamic_friction - static_friction; + const double inertial_number_zero = r_properties[INERTIAL_NUMBER_ZERO]; + const double grain_diameter = r_properties[GRAIN_DIAMETER]; + const double grain_density = r_properties[GRAIN_DENSITY]; + const double regularization_coeff = r_properties[REGULARIZATION_COEFFICIENT]; + double inertial_number = 0; + double effective_dynamic_viscosity = 0; + + const double old_pressure = this->CalculateInGaussPoint(PRESSURE, rValues, 1); + const double new_pressure = this->CalculateInGaussPoint(PRESSURE, rValues, 0); + const GeometryType& r_geometry = rValues.GetElementGeometry(); + + const double theta_momentum = r_geometry[0].GetValue(THETA_MOMENTUM); + double mean_pressure = (1.0 - theta_momentum) * old_pressure + theta_momentum * new_pressure; + if (mean_pressure > 0.0) { + mean_pressure = 0.0000001; + } + + const double equivalent_strain_rate = + std::sqrt(2.0 * r_strain_vector[0] * r_strain_vector[0] + 2.0 * r_strain_vector[1] * r_strain_vector[1] + + 2.0 * r_strain_vector[2] * r_strain_vector[2] + 4.0 * r_strain_vector[3] * r_strain_vector[3] + + 4.0 * r_strain_vector[4] * r_strain_vector[4] + 4.0 * r_strain_vector[5] * r_strain_vector[5]); + + if (mean_pressure != 0) { + inertial_number = equivalent_strain_rate * grain_diameter / std::sqrt(std::fabs(mean_pressure) / grain_density); + } + + if (equivalent_strain_rate != 0 && std::fabs(mean_pressure) != 0) { + const double first_viscous_term = + static_friction / std::sqrt(std::pow(equivalent_strain_rate, 2) + std::pow(regularization_coeff, 2)); + const double second_viscous_term = + delta_friction * inertial_number / ((inertial_number_zero + inertial_number) * equivalent_strain_rate); + effective_dynamic_viscosity = (first_viscous_term + second_viscous_term) * std::fabs(mean_pressure); + } else { + effective_dynamic_viscosity = 1.0; + } + + const double strain_trace = r_strain_vector[0] + r_strain_vector[1] + r_strain_vector[2]; + + r_stress_vector[0] = 2.0 * effective_dynamic_viscosity * (r_strain_vector[0] - strain_trace / 3.0); + r_stress_vector[1] = 2.0 * effective_dynamic_viscosity * (r_strain_vector[1] - strain_trace / 3.0); + r_stress_vector[2] = 2.0 * effective_dynamic_viscosity * (r_strain_vector[2] - strain_trace / 3.0); + r_stress_vector[3] = 2.0 * effective_dynamic_viscosity * r_strain_vector[3]; + r_stress_vector[4] = 2.0 * effective_dynamic_viscosity * r_strain_vector[4]; + r_stress_vector[5] = 2.0 * effective_dynamic_viscosity * r_strain_vector[5]; + + if (r_options.Is(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR)) { + this->EffectiveViscousConstitutiveMatrix3D(effective_dynamic_viscosity, rValues.GetConstitutiveMatrix()); + } +} + +std::string BercovierMuIRheology3DLaw::Info() const { return "BercovierMuIRheology3DLaw"; } + +//******************CHECK CONSISTENCY IN THE CONSTITUTIVE LAW****************** +//***************************************************************************** + +int BercovierMuIRheology3DLaw::Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, + const ProcessInfo& rCurrentProcessInfo) { + KRATOS_CHECK_VARIABLE_KEY(STATIC_FRICTION); + KRATOS_CHECK_VARIABLE_KEY(DYNAMIC_FRICTION); + KRATOS_CHECK_VARIABLE_KEY(INERTIAL_NUMBER_ZERO); + KRATOS_CHECK_VARIABLE_KEY(GRAIN_DIAMETER); + KRATOS_CHECK_VARIABLE_KEY(GRAIN_DENSITY); + KRATOS_CHECK_VARIABLE_KEY(REGULARIZATION_COEFFICIENT); + KRATOS_CHECK_VARIABLE_KEY(BULK_MODULUS); + + if (rMaterialProperties[STATIC_FRICTION] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing STATIC_FRICTION provided in process info for BercovierMuIRheology3DLaw: " + << rMaterialProperties[STATIC_FRICTION] << std::endl; + } + + if (rMaterialProperties[DYNAMIC_FRICTION] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing DYNAMIC_FRICTION provided in process info for BercovierMuIRheology3DLaw: " + << rMaterialProperties[DYNAMIC_FRICTION] << std::endl; + } + + if (rMaterialProperties[INERTIAL_NUMBER_ZERO] <= 0.0) { + KRATOS_ERROR + << "Incorrect or missing INERTIAL_NUMBER_ZERO provided in process info for BercovierMuIRheology3DLaw: " + << rMaterialProperties[INERTIAL_NUMBER_ZERO] << std::endl; + } + + if (rMaterialProperties[GRAIN_DIAMETER] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing GRAIN_DIAMETER provided in process info for BercovierMuIRheology3DLaw: " + << rMaterialProperties[GRAIN_DIAMETER] << std::endl; + } + + if (rMaterialProperties[GRAIN_DENSITY] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing GRAIN_DENSITY provided in process info for BercovierMuIRheology3DLaw: " + << rMaterialProperties[GRAIN_DENSITY] << std::endl; + } + + if (rMaterialProperties[REGULARIZATION_COEFFICIENT] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing REGULARIZATION_COEFFICIENT provided in process info for " + "BercovierMuIRheology3DLaw: " + << rMaterialProperties[REGULARIZATION_COEFFICIENT] << std::endl; + } + + if (rMaterialProperties[BULK_MODULUS] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing BULK_MODULUS provided in process info for " + "BercovierMuIRheology3DLaw: " + << rMaterialProperties[BULK_MODULUS] << std::endl; + } + + return 0; +} + +double BercovierMuIRheology3DLaw::GetEffectiveViscosity(ConstitutiveLaw::Parameters& rParameters) const { + return rParameters.GetConstitutiveMatrix()(5, 5); +} + +double BercovierMuIRheology3DLaw::GetEffectiveDensity(ConstitutiveLaw::Parameters& rParameters) const { + const Properties& r_prop = rParameters.GetMaterialProperties(); + const double effective_density = r_prop[DENSITY]; + return effective_density; +} + +void BercovierMuIRheology3DLaw::save(Serializer& rSerializer) const { + KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, PfemFluidConstitutiveLaw) +} + +void BercovierMuIRheology3DLaw::load(Serializer& rSerializer) { + KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, PfemFluidConstitutiveLaw) +} + +} // Namespace Kratos diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/bercovier_mu_I_rheology_3D_law.h b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/bercovier_mu_I_rheology_3D_law.h new file mode 100644 index 000000000000..380f86171692 --- /dev/null +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/bercovier_mu_I_rheology_3D_law.h @@ -0,0 +1,172 @@ +//------------------------------------------------------------- +// ___ __ ___ _ _ _ +// KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| | +// | _/ _/ -_) ' \| _|| | || | / _` | +// |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS +// +// BSD License: PfemFluidDynamicsApplication/license.txt +// +// Main authors: Alessandro Franci +// Collaborators: Massimiliano Zecchetto +// +//------------------------------------------------------------- +// + +#if !defined(KRATOS_BERCOVIER_MU_I_RHEOLOGY_LAW_3D_H_INCLUDED) +#define KRATOS_BERCOVIER_MU_I_RHEOLOGY_LAW_3D_H_INCLUDED + +// System includes + +// External includes + +// Project includes +#include "fluid_constitutive_law.h" + +namespace Kratos { +/** + * Defines a 3D Bercovier mu(I) non-Newtonian constitutive law + * This material law is defined by the parameters: + * 1) STATIC_FRICTION + * 2) DYNAMIC_FRICTION + * 3) INERTIAL_NUMBER_ZERO + * 4) GRAIN_DIAMETER + * 5) GRAIN_DENSITY + * 6) REGULARIZATION_COEFFICIENT + */ + +class KRATOS_API(PFEM_FLUID_DYNAMICS_APPLICATION) BercovierMuIRheology3DLaw : public PfemFluidConstitutiveLaw { + public: + /** + * Type Definitions + */ + typedef ProcessInfo ProcessInfoType; + typedef ConstitutiveLaw BaseType; + typedef std::size_t SizeType; + /** + * Counted pointer of BercovierMuIRheology3DLaw + */ + + KRATOS_CLASS_POINTER_DEFINITION(BercovierMuIRheology3DLaw); + + /** + * Life Cycle + */ + + /** + * Default constructor. + */ + BercovierMuIRheology3DLaw(); + + /** + * Clone function (has to be implemented by any derived class) + * @return a pointer to a new instance of this constitutive law + */ + ConstitutiveLaw::Pointer Clone() const override; + + /** + * Copy constructor. + */ + BercovierMuIRheology3DLaw(const BercovierMuIRheology3DLaw& rOther); + + /** + * Destructor. + */ + ~BercovierMuIRheology3DLaw() override; + + /** + * Operators + */ + + /** + * Operations needed by the base class: + */ + + /** + * @return Working space dimension constitutive law + */ + SizeType WorkingSpaceDimension() override; + + /** + * @return Size of the strain vector (in Voigt notation) for the constitutive law + */ + SizeType GetStrainSize() override; + + void CalculateMaterialResponseCauchy(Parameters& rValues) override; + + /** + * This function is designed to be called once to perform all the checks needed + * on the input provided. Checks can be "expensive" as the function is designed + * to catch user's errors. + * @param rMaterialProperties + * @param rElementGeometry + * @param rCurrentProcessInfo + * @return + */ + int Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, + const ProcessInfo& rCurrentProcessInfo) override; + + /** + * Input and output + */ + + /** + * Turn back information as a string. + */ + std::string Info() const override; + + protected: + ///@name Protected static Member Variables + ///@{ + ///@} + ///@name Protected member Variables + ///@{ + ///@} + ///@name Protected Operators + ///@{ + ///@} + ///@name Protected Operations + ///@{ + + /// Get the effective viscosity (in dynamic units -- Pa s) for the fluid. + double GetEffectiveViscosity(ConstitutiveLaw::Parameters& rParameters) const override; + + /// Get the effective density for the fluid. + double GetEffectiveDensity(ConstitutiveLaw::Parameters& rParameters) const override; + + ///@} + + private: + ///@name Static Member Variables + ///@{ + ///@} + ///@name Member Variables + ///@{ + + ///@} + ///@name Private Operators + ///@{ + + ///@} + ///@name Private Operations + ///@{ + ///@} + + ///@} + ///@name Private Access + ///@{ + ///@} + + ///@} + ///@name Serialization + ///@{ + friend class Serializer; + + void save(Serializer& rSerializer) const override; + + void load(Serializer& rSerializer) override; + +}; // Class BercovierMuIRheology3DLaw + +} // namespace Kratos. + +#endif // KRATOS_BERCOVIER_MU_I_RHEOLOGY_LAW_3D_H_INCLUDED defined From ca30a04a2f46146e17cae68cb9c6ce5548d73b95 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Tue, 3 Mar 2020 08:31:31 +0100 Subject: [PATCH 40/47] Add Jop 3D claw --- .../fluid_laws/jop_mu_I_rheology_3D_law.cpp | 178 ++++++++++++++++++ .../fluid_laws/jop_mu_I_rheology_3D_law.h | 171 +++++++++++++++++ 2 files changed, 349 insertions(+) create mode 100644 applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/jop_mu_I_rheology_3D_law.cpp create mode 100644 applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/jop_mu_I_rheology_3D_law.h diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/jop_mu_I_rheology_3D_law.cpp b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/jop_mu_I_rheology_3D_law.cpp new file mode 100644 index 000000000000..46dc89075273 --- /dev/null +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/jop_mu_I_rheology_3D_law.cpp @@ -0,0 +1,178 @@ +//------------------------------------------------------------- +// ___ __ ___ _ _ _ +// KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| | +// | _/ _/ -_) ' \| _|| | || | / _` | +// |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS +// +// BSD License: PfemFluidDynamicsApplication/license.txt +// +// Main authors: Alessandro Franci +// Collaborators: Massimiliano Zecchetto +// +//------------------------------------------------------------- +// + +// System includes +#include + +// External includes +#include + +// Project includes +#include "custom_constitutive/fluid_laws/jop_mu_I_rheology_3D_law.h" +#include "includes/checks.h" +#include "includes/properties.h" +#include "pfem_fluid_dynamics_application_variables.h" + +namespace Kratos { + +//********************************CONSTRUCTOR********************************* +//**************************************************************************** + +JopMuIRheology3DLaw::JopMuIRheology3DLaw() : PfemFluidConstitutiveLaw() {} + +//******************************COPY CONSTRUCTOR****************************** +//**************************************************************************** + +JopMuIRheology3DLaw::JopMuIRheology3DLaw(const JopMuIRheology3DLaw& rOther) : PfemFluidConstitutiveLaw(rOther) {} + +//***********************************CLONE************************************ +//**************************************************************************** + +ConstitutiveLaw::Pointer JopMuIRheology3DLaw::Clone() const { return Kratos::make_shared(*this); } + +//*********************************DESTRUCTOR********************************* +//**************************************************************************** + +JopMuIRheology3DLaw::~JopMuIRheology3DLaw() {} + +ConstitutiveLaw::SizeType JopMuIRheology3DLaw::WorkingSpaceDimension() { return 3; } + +ConstitutiveLaw::SizeType JopMuIRheology3DLaw::GetStrainSize() { return 6; } + +void JopMuIRheology3DLaw::CalculateMaterialResponseCauchy(Parameters& rValues) { + + Flags& r_options = rValues.GetOptions(); + + const Properties& r_properties = rValues.GetMaterialProperties(); + + Vector& r_strain_vector = rValues.GetStrainVector(); + Vector& r_stress_vector = rValues.GetStressVector(); + + const double static_friction = r_properties[STATIC_FRICTION]; + const double dynamic_friction = r_properties[DYNAMIC_FRICTION]; + const double delta_friction = dynamic_friction - static_friction; + const double inertial_number_zero = r_properties[INERTIAL_NUMBER_ZERO]; + const double grain_diameter = r_properties[GRAIN_DIAMETER]; + const double grain_density = r_properties[GRAIN_DENSITY]; + double inertial_number = 0; + double effective_dynamic_viscosity = 0; + + const double old_pressure = this->CalculateInGaussPoint(PRESSURE, rValues, 1); + const double new_pressure = this->CalculateInGaussPoint(PRESSURE, rValues, 0); + const GeometryType& r_geometry = rValues.GetElementGeometry(); + + const double theta_momentum = r_geometry[0].GetValue(THETA_MOMENTUM); + double mean_pressure = (1 - theta_momentum) * old_pressure + theta_momentum * new_pressure; + if (mean_pressure > 0) { + mean_pressure = 0.0000001; + } + + const double equivalent_strain_rate = + std::sqrt(2.0 * r_strain_vector[0] * r_strain_vector[0] + 2.0 * r_strain_vector[1] * r_strain_vector[1] + + 2.0 * r_strain_vector[2] * r_strain_vector[2] + 4.0 * r_strain_vector[3] * r_strain_vector[3] + + 4.0 * r_strain_vector[4] * r_strain_vector[4] + 4.0 * r_strain_vector[5] * r_strain_vector[5]); + + if (mean_pressure != 0) { + inertial_number = equivalent_strain_rate * grain_diameter / std::sqrt(std::fabs(mean_pressure) / grain_density); + } + + if (equivalent_strain_rate != 0 && std::fabs(mean_pressure) != 0) { + const double first_viscous_term = static_friction / equivalent_strain_rate; + const double second_viscous_term = + delta_friction * inertial_number / ((inertial_number_zero + inertial_number) * equivalent_strain_rate); + effective_dynamic_viscosity = (first_viscous_term + second_viscous_term) * std::fabs(mean_pressure); + } else { + effective_dynamic_viscosity = 1.0; + } + + const double strain_trace = r_strain_vector[0] + r_strain_vector[1] + r_strain_vector[2]; + + r_stress_vector[0] = 2.0 * effective_dynamic_viscosity * (r_strain_vector[0] - strain_trace / 3.0); + r_stress_vector[1] = 2.0 * effective_dynamic_viscosity * (r_strain_vector[1] - strain_trace / 3.0); + r_stress_vector[2] = 2.0 * effective_dynamic_viscosity * (r_strain_vector[2] - strain_trace / 3.0); + r_stress_vector[3] = 2.0 * effective_dynamic_viscosity * r_strain_vector[3]; + r_stress_vector[4] = 2.0 * effective_dynamic_viscosity * r_strain_vector[4]; + r_stress_vector[5] = 2.0 * effective_dynamic_viscosity * r_strain_vector[5]; + + if (r_options.Is(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR)) { + this->EffectiveViscousConstitutiveMatrix3D(effective_dynamic_viscosity, rValues.GetConstitutiveMatrix()); + } +} + +std::string JopMuIRheology3DLaw::Info() const { return "JopMuIRheology3DLaw"; } + +//******************CHECK CONSISTENCY IN THE CONSTITUTIVE LAW****************** +//***************************************************************************** + +int JopMuIRheology3DLaw::Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, + const ProcessInfo& rCurrentProcessInfo) { + KRATOS_CHECK_VARIABLE_KEY(STATIC_FRICTION); + KRATOS_CHECK_VARIABLE_KEY(DYNAMIC_FRICTION); + KRATOS_CHECK_VARIABLE_KEY(INERTIAL_NUMBER_ZERO); + KRATOS_CHECK_VARIABLE_KEY(GRAIN_DIAMETER); + KRATOS_CHECK_VARIABLE_KEY(GRAIN_DENSITY); + KRATOS_CHECK_VARIABLE_KEY(BULK_MODULUS); + + if (rMaterialProperties[STATIC_FRICTION] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing STATIC_FRICTION provided in process info for JopMuIRheology3DLaw: " + << rMaterialProperties[STATIC_FRICTION] << std::endl; + } + + if (rMaterialProperties[DYNAMIC_FRICTION] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing DYNAMIC_FRICTION provided in process info for JopMuIRheology3DLaw: " + << rMaterialProperties[DYNAMIC_FRICTION] << std::endl; + } + + if (rMaterialProperties[INERTIAL_NUMBER_ZERO] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing INERTIAL_NUMBER_ZERO provided in process info for JopMuIRheology3DLaw: " + << rMaterialProperties[INERTIAL_NUMBER_ZERO] << std::endl; + } + + if (rMaterialProperties[GRAIN_DIAMETER] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing GRAIN_DIAMETER provided in process info for JopMuIRheology3DLaw: " + << rMaterialProperties[GRAIN_DIAMETER] << std::endl; + } + + if (rMaterialProperties[GRAIN_DENSITY] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing GRAIN_DENSITY provided in process info for JopMuIRheology3DLaw: " + << rMaterialProperties[GRAIN_DENSITY] << std::endl; + } + + if (rMaterialProperties[BULK_MODULUS] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing BULK_MODULUS provided in process info for JopMuIRheology3DLaw: " + << rMaterialProperties[BULK_MODULUS] << std::endl; + } + + return 0; +} + +double JopMuIRheology3DLaw::GetEffectiveViscosity(ConstitutiveLaw::Parameters& rParameters) const { + return rParameters.GetConstitutiveMatrix()(5, 5); +} + +double JopMuIRheology3DLaw::GetEffectiveDensity(ConstitutiveLaw::Parameters& rParameters) const { + const Properties& r_properties = rParameters.GetMaterialProperties(); + const double effective_density = r_properties[DENSITY]; + return effective_density; +} + +void JopMuIRheology3DLaw::save(Serializer& rSerializer) const { + KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, PfemFluidConstitutiveLaw) +} + +void JopMuIRheology3DLaw::load(Serializer& rSerializer) { + KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, PfemFluidConstitutiveLaw) +} + +} // Namespace Kratos diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/jop_mu_I_rheology_3D_law.h b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/jop_mu_I_rheology_3D_law.h new file mode 100644 index 000000000000..8d45bd8de437 --- /dev/null +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/jop_mu_I_rheology_3D_law.h @@ -0,0 +1,171 @@ +//------------------------------------------------------------- +// ___ __ ___ _ _ _ +// KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| | +// | _/ _/ -_) ' \| _|| | || | / _` | +// |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS +// +// BSD License: PfemFluidDynamicsApplication/license.txt +// +// Main authors: Alessandro Franci +// Collaborators: Massimiliano Zecchetto +// +//------------------------------------------------------------- +// + +#if !defined(KRATOS_JOP_MU_I_RHEOLOGY_LAW_3D_H_INCLUDED) +#define KRATOS_JOP_MU_I_RHEOLOGY_LAW_3D_H_INCLUDED + +// System includes + +// External includes + +// Project includes +#include "fluid_constitutive_law.h" + +namespace Kratos { +/** + * Defines a 3D Jop mu(I) rheology constitutive law + * This material law is defined by the parameters: + * 1) STATIC_FRICTION + * 2) DYNAMIC_FRICTION + * 3) INERTIAL_NUMBER_ZERO + * 4) GRAIN_DIAMETER + * 5) GRAIN_DENSITY + */ + +class KRATOS_API(PFEM_FLUID_DYNAMICS_APPLICATION) JopMuIRheology3DLaw : public PfemFluidConstitutiveLaw { + public: + /** + * Type Definitions + */ + typedef ProcessInfo ProcessInfoType; + typedef ConstitutiveLaw BaseType; + typedef std::size_t SizeType; + + /** + * Counted pointer of JopMuIRheology3DLaw + */ + KRATOS_CLASS_POINTER_DEFINITION(JopMuIRheology3DLaw); + + /** + * Life Cycle + */ + + /** + * Default constructor. + */ + JopMuIRheology3DLaw(); + + /** + * Clone function (has to be implemented by any derived class) + * @return a pointer to a new instance of this constitutive law + */ + ConstitutiveLaw::Pointer Clone() const override; + + /** + * Copy constructor. + */ + JopMuIRheology3DLaw(const JopMuIRheology3DLaw& rOther); + + /** + * Destructor. + */ + ~JopMuIRheology3DLaw() override; + + /** + * Operators + */ + + /** + * Operations needed by the base class: + */ + + /** + * @return Working space dimension constitutive law + */ + SizeType WorkingSpaceDimension() override; + + /** + * @return Size of the strain vector (in Voigt notation) for the constitutive law + */ + SizeType GetStrainSize() override; + + void CalculateMaterialResponseCauchy(Parameters& rValues) override; + + /** + * This function is designed to be called once to perform all the checks needed + * on the input provided. Checks can be "expensive" as the function is designed + * to catch user's errors. + * @param rMaterialProperties + * @param rElementGeometry + * @param rCurrentProcessInfo + * @return + */ + int Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, + const ProcessInfo& rCurrentProcessInfo) override; + + /** + * Input and output + */ + + /** + * Turn back information as a string. + */ + std::string Info() const override; + + protected: + ///@name Protected static Member Variables + ///@{ + ///@} + ///@name Protected member Variables + ///@{ + ///@} + ///@name Protected Operators + ///@{ + ///@} + ///@name Protected Operations + ///@{ + + /// Get the effective viscosity (in dynamic units -- Pa s) for the fluid. + double GetEffectiveViscosity(ConstitutiveLaw::Parameters& rParameters) const override; + + /// Get the effective density for the fluid. + double GetEffectiveDensity(ConstitutiveLaw::Parameters& rParameters) const override; + + ///@} + + private: + ///@name Static Member Variables + ///@{ + ///@} + ///@name Member Variables + ///@{ + + ///@} + ///@name Private Operators + ///@{ + + ///@} + ///@name Private Operations + ///@{ + ///@} + + ///@} + ///@name Private Access + ///@{ + ///@} + + ///@} + ///@name Serialization + ///@{ + friend class Serializer; + + void save(Serializer& rSerializer) const override; + + void load(Serializer& rSerializer) override; + +}; // Class JopMuIRheology3DLaw + +} // namespace Kratos. + +#endif // KRATOS_JOP_MU_I_RHEOLOGY_LAW_3D_H_INCLUDED defined From 3da7a5a34b1e152a22217dd47a188b7b053ed5d6 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Tue, 3 Mar 2020 08:31:55 +0100 Subject: [PATCH 41/47] Add Papanastasiou 2D claw --- .../papanastasiou_mu_I_rheology_2D_law.cpp | 193 ++++++++++++++++++ .../papanastasiou_mu_I_rheology_2D_law.h | 172 ++++++++++++++++ 2 files changed, 365 insertions(+) create mode 100644 applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/papanastasiou_mu_I_rheology_2D_law.cpp create mode 100644 applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/papanastasiou_mu_I_rheology_2D_law.h diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/papanastasiou_mu_I_rheology_2D_law.cpp b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/papanastasiou_mu_I_rheology_2D_law.cpp new file mode 100644 index 000000000000..b4cc495e4935 --- /dev/null +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/papanastasiou_mu_I_rheology_2D_law.cpp @@ -0,0 +1,193 @@ +//------------------------------------------------------------- +// ___ __ ___ _ _ _ +// KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| | +// | _/ _/ -_) ' \| _|| | || | / _` | +// |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS +// +// BSD License: PfemFluidDynamicsApplication/license.txt +// +// Main authors: Alessandro Franci +// Collaborators: Massimiliano Zecchetto +// +//------------------------------------------------------------- +// + +// System includes +#include + +// External includes +#include + +// Project includes +#include "custom_constitutive/fluid_laws/papanastasiou_mu_I_rheology_2D_law.h" +#include "includes/checks.h" +#include "includes/properties.h" +#include "pfem_fluid_dynamics_application_variables.h" + +namespace Kratos { + +//********************************CONSTRUCTOR********************************* +//**************************************************************************** + +PapanastasiouMuIRheology2DLaw::PapanastasiouMuIRheology2DLaw() : PfemFluidConstitutiveLaw() {} + +//******************************COPY CONSTRUCTOR****************************** +//**************************************************************************** + +PapanastasiouMuIRheology2DLaw::PapanastasiouMuIRheology2DLaw(const PapanastasiouMuIRheology2DLaw& rOther) + : PfemFluidConstitutiveLaw(rOther) {} + +//***********************************CLONE************************************ +//**************************************************************************** + +ConstitutiveLaw::Pointer PapanastasiouMuIRheology2DLaw::Clone() const { + return Kratos::make_shared(*this); +} + +//*********************************DESTRUCTOR********************************* +//**************************************************************************** + +PapanastasiouMuIRheology2DLaw::~PapanastasiouMuIRheology2DLaw() {} + +ConstitutiveLaw::SizeType PapanastasiouMuIRheology2DLaw::WorkingSpaceDimension() { return 2; } + +ConstitutiveLaw::SizeType PapanastasiouMuIRheology2DLaw::GetStrainSize() { return 3; } + +void PapanastasiouMuIRheology2DLaw::CalculateMaterialResponseCauchy(Parameters& rValues) { + + Flags& r_options = rValues.GetOptions(); + + const Properties& r_properties = rValues.GetMaterialProperties(); + + Vector& r_strain_vector = rValues.GetStrainVector(); + Vector& r_stress_vector = rValues.GetStressVector(); + + const double static_friction = r_properties[STATIC_FRICTION]; + const double dynamic_friction = r_properties[DYNAMIC_FRICTION]; + const double delta_friction = dynamic_friction - static_friction; + const double inertial_number_zero = r_properties[INERTIAL_NUMBER_ZERO]; + const double grain_diameter = r_properties[GRAIN_DIAMETER]; + const double grain_density = r_properties[GRAIN_DENSITY]; + const double regularization_coeff = r_properties[REGULARIZATION_COEFFICIENT]; + double inertial_number = 0; + double effective_dynamic_viscosity = 0; + + const double old_pressure = this->CalculateInGaussPoint(PRESSURE, rValues, 1); + const double new_pressure = this->CalculateInGaussPoint(PRESSURE, rValues, 0); + const GeometryType& r_geometry = rValues.GetElementGeometry(); + + const double theta_momentum = r_geometry[0].GetValue(THETA_MOMENTUM); + double mean_pressure = (1.0 - theta_momentum) * old_pressure + theta_momentum * new_pressure; + if (mean_pressure > 0.0) { + mean_pressure = 0.0000001; + } + + const double equivalent_strain_rate = + std::sqrt(2.0 * r_strain_vector[0] * r_strain_vector[0] + 2.0 * r_strain_vector[1] * r_strain_vector[1] + + 4.0 * r_strain_vector[2] * r_strain_vector[2]); + + if (mean_pressure != 0) { + inertial_number = equivalent_strain_rate * grain_diameter / std::sqrt(std::fabs(mean_pressure) / grain_density); + } + + const double exponent = -equivalent_strain_rate / regularization_coeff; + + if (equivalent_strain_rate != 0 && std::fabs(mean_pressure) != 0) { + const double first_viscous_term = static_friction * (1 - std::exp(exponent)) / equivalent_strain_rate; + const double second_viscous_term = + delta_friction * inertial_number / ((inertial_number_zero + inertial_number) * equivalent_strain_rate); + effective_dynamic_viscosity = (first_viscous_term + second_viscous_term) * std::fabs(mean_pressure); + } else { + effective_dynamic_viscosity = 1.0; + } + + const double strain_trace = r_strain_vector[0] + r_strain_vector[1]; + + r_stress_vector[0] = 2.0 * effective_dynamic_viscosity * (r_strain_vector[0] - strain_trace / 3.0); + r_stress_vector[1] = 2.0 * effective_dynamic_viscosity * (r_strain_vector[1] - strain_trace / 3.0); + r_stress_vector[2] = 2.0 * effective_dynamic_viscosity * r_strain_vector[2]; + + if (r_options.Is(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR)) { + this->EffectiveViscousConstitutiveMatrix2D(effective_dynamic_viscosity, rValues.GetConstitutiveMatrix()); + } +} + +std::string PapanastasiouMuIRheology2DLaw::Info() const { return "PapanastasiouMuIRheology2DLaw"; } + +//******************CHECK CONSISTENCY IN THE CONSTITUTIVE LAW****************** +//***************************************************************************** + +int PapanastasiouMuIRheology2DLaw::Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, + const ProcessInfo& rCurrentProcessInfo) { + KRATOS_CHECK_VARIABLE_KEY(STATIC_FRICTION); + KRATOS_CHECK_VARIABLE_KEY(DYNAMIC_FRICTION); + KRATOS_CHECK_VARIABLE_KEY(INERTIAL_NUMBER_ZERO); + KRATOS_CHECK_VARIABLE_KEY(GRAIN_DIAMETER); + KRATOS_CHECK_VARIABLE_KEY(GRAIN_DENSITY); + KRATOS_CHECK_VARIABLE_KEY(REGULARIZATION_COEFFICIENT); + KRATOS_CHECK_VARIABLE_KEY(BULK_MODULUS); + + if (rMaterialProperties[STATIC_FRICTION] <= 0.0) { + KRATOS_ERROR + << "Incorrect or missing STATIC_FRICTION provided in process info for PapanastasiouMuIRheology2DLaw: " + << rMaterialProperties[STATIC_FRICTION] << std::endl; + } + + if (rMaterialProperties[DYNAMIC_FRICTION] <= 0.0) { + KRATOS_ERROR + << "Incorrect or missing DYNAMIC_FRICTION provided in process info for PapanastasiouMuIRheology2DLaw: " + << rMaterialProperties[DYNAMIC_FRICTION] << std::endl; + } + + if (rMaterialProperties[INERTIAL_NUMBER_ZERO] <= 0.0) { + KRATOS_ERROR + << "Incorrect or missing INERTIAL_NUMBER_ZERO provided in process info for PapanastasiouMuIRheology2DLaw: " + << rMaterialProperties[INERTIAL_NUMBER_ZERO] << std::endl; + } + + if (rMaterialProperties[GRAIN_DIAMETER] <= 0.0) { + KRATOS_ERROR + << "Incorrect or missing GRAIN_DIAMETER provided in process info for PapanastasiouMuIRheology2DLaw: " + << rMaterialProperties[GRAIN_DIAMETER] << std::endl; + } + + if (rMaterialProperties[GRAIN_DENSITY] <= 0.0) { + KRATOS_ERROR + << "Incorrect or missing GRAIN_DENSITY provided in process info for PapanastasiouMuIRheology2DLaw: " + << rMaterialProperties[GRAIN_DENSITY] << std::endl; + } + + if (rMaterialProperties[REGULARIZATION_COEFFICIENT] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing REGULARIZATION_COEFFICIENT provided in process info for " + "PapanastasiouMuIRheology2DLaw: " + << rMaterialProperties[REGULARIZATION_COEFFICIENT] << std::endl; + } + + if (rMaterialProperties[BULK_MODULUS] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing BULK_MODULUS provided in process info for " + "PapanastasiouMuIRheology2DLaw: " + << rMaterialProperties[BULK_MODULUS] << std::endl; + } + + return 0; +} + +double PapanastasiouMuIRheology2DLaw::GetEffectiveViscosity(ConstitutiveLaw::Parameters& rParameters) const { + return rParameters.GetConstitutiveMatrix()(2, 2); +} + +double PapanastasiouMuIRheology2DLaw::GetEffectiveDensity(ConstitutiveLaw::Parameters& rParameters) const { + const Properties& r_properties = rParameters.GetMaterialProperties(); + const double effective_density = r_properties[DENSITY]; + return effective_density; +} + +void PapanastasiouMuIRheology2DLaw::save(Serializer& rSerializer) const { + KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, PfemFluidConstitutiveLaw) +} + +void PapanastasiouMuIRheology2DLaw::load(Serializer& rSerializer) { + KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, PfemFluidConstitutiveLaw) +} + +} // Namespace Kratos diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/papanastasiou_mu_I_rheology_2D_law.h b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/papanastasiou_mu_I_rheology_2D_law.h new file mode 100644 index 000000000000..052eb306d161 --- /dev/null +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/papanastasiou_mu_I_rheology_2D_law.h @@ -0,0 +1,172 @@ +//------------------------------------------------------------- +// ___ __ ___ _ _ _ +// KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| | +// | _/ _/ -_) ' \| _|| | || | / _` | +// |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS +// +// BSD License: PfemFluidDynamicsApplication/license.txt +// +// Main authors: Alessandro Franci +// Collaborators: Massimiliano Zecchetto +// +//------------------------------------------------------------- +// + +#if !defined(KRATOS_PAPANASTASIOU_MU_I_RHEOLOGY_LAW_2D_H_INCLUDED) +#define KRATOS_PAPANASTASIOU_MU_I_RHEOLOGY_LAW_2D_H_INCLUDED + +// System includes + +// External includes + +// Project includes +#include "fluid_constitutive_law.h" + +namespace Kratos { +/** + * Defines a 2D Papanastasiou mu(I) rheology constitutive law + * This material law is defined by the parameters: + * 1) STATIC_FRICTION + * 2) DYNAMIC_FRICTION + * 3) INERTIAL_NUMBER_ZERO + * 4) GRAIN_DIAMETER + * 5) GRAIN_DENSITY + * 6) REGULARIZATION_COEFFICIENT + */ + +class KRATOS_API(PFEM_FLUID_DYNAMICS_APPLICATION) PapanastasiouMuIRheology2DLaw : public PfemFluidConstitutiveLaw { + public: + /** + * Type Definitions + */ + typedef ProcessInfo ProcessInfoType; + typedef ConstitutiveLaw BaseType; + typedef std::size_t SizeType; + + /** + * Counted pointer of PapanastasiouMuIRheology2DLaw + */ + KRATOS_CLASS_POINTER_DEFINITION(PapanastasiouMuIRheology2DLaw); + + /** + * Life Cycle + */ + + /** + * Default constructor. + */ + PapanastasiouMuIRheology2DLaw(); + + /** + * Clone function (has to be implemented by any derived class) + * @return a pointer to a new instance of this constitutive law + */ + ConstitutiveLaw::Pointer Clone() const override; + + /** + * Copy constructor. + */ + PapanastasiouMuIRheology2DLaw(const PapanastasiouMuIRheology2DLaw& rOther); + + /** + * Destructor. + */ + ~PapanastasiouMuIRheology2DLaw() override; + + /** + * Operators + */ + + /** + * Operations needed by the base class: + */ + + /** + * @return Working space dimension constitutive law + */ + SizeType WorkingSpaceDimension() override; + + /** + * @return Size of the strain vector (in Voigt notation) for the constitutive law + */ + SizeType GetStrainSize() override; + + void CalculateMaterialResponseCauchy(Parameters& rValues) override; + + /** + * This function is designed to be called once to perform all the checks needed + * on the input provided. Checks can be "expensive" as the function is designed + * to catch user's errors. + * @param rMaterialProperties + * @param rElementGeometry + * @param rCurrentProcessInfo + * @return + */ + int Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, + const ProcessInfo& rCurrentProcessInfo) override; + + /** + * Input and output + */ + + /** + * Turn back information as a string. + */ + std::string Info() const override; + + protected: + ///@name Protected static Member Variables + ///@{ + ///@} + ///@name Protected member Variables + ///@{ + ///@} + ///@name Protected Operators + ///@{ + ///@} + ///@name Protected Operations + ///@{ + + /// Get the effective viscosity (in dynamic units -- Pa s) for the fluid. + double GetEffectiveViscosity(ConstitutiveLaw::Parameters& rParameters) const override; + + /// Get the effective density for the fluid. + double GetEffectiveDensity(ConstitutiveLaw::Parameters& rParameters) const override; + + ///@} + + private: + ///@name Static Member Variables + ///@{ + ///@} + ///@name Member Variables + ///@{ + + ///@} + ///@name Private Operators + ///@{ + + ///@} + ///@name Private Operations + ///@{ + ///@} + + ///@} + ///@name Private Access + ///@{ + ///@} + + ///@} + ///@name Serialization + ///@{ + friend class Serializer; + + void save(Serializer& rSerializer) const override; + + void load(Serializer& rSerializer) override; + +}; // Class PapanastasiouMuIRheology2DLaw + +} // namespace Kratos. + +#endif // KRATOS_PAPANASTASIOU_MU_I_RHEOLOGY_LAW_2D_H_INCLUDED defined From a445c7e48d0507c6b013d49c08d215021c381a64 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Tue, 3 Mar 2020 08:32:05 +0100 Subject: [PATCH 42/47] Add Papanastasiou 3D claw --- .../papanastasiou_mu_I_rheology_3D_law.cpp | 197 ++++++++++++++++++ .../papanastasiou_mu_I_rheology_3D_law.h | 172 +++++++++++++++ 2 files changed, 369 insertions(+) create mode 100644 applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/papanastasiou_mu_I_rheology_3D_law.cpp create mode 100644 applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/papanastasiou_mu_I_rheology_3D_law.h diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/papanastasiou_mu_I_rheology_3D_law.cpp b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/papanastasiou_mu_I_rheology_3D_law.cpp new file mode 100644 index 000000000000..7b0a3fe498d8 --- /dev/null +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/papanastasiou_mu_I_rheology_3D_law.cpp @@ -0,0 +1,197 @@ +//------------------------------------------------------------- +// ___ __ ___ _ _ _ +// KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| | +// | _/ _/ -_) ' \| _|| | || | / _` | +// |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS +// +// BSD License: PfemFluidDynamicsApplication/license.txt +// +// Main authors: Alessandro Franci +// Collaborators: Massimiliano Zecchetto +// +//------------------------------------------------------------- +// + +// System includes +#include + +// External includes +#include + +// Project includes +#include "custom_constitutive/fluid_laws/papanastasiou_mu_I_rheology_3D_law.h" +#include "includes/checks.h" +#include "includes/properties.h" +#include "pfem_fluid_dynamics_application_variables.h" + +namespace Kratos { + +//********************************CONSTRUCTOR********************************* +//**************************************************************************** + +PapanastasiouMuIRheology3DLaw::PapanastasiouMuIRheology3DLaw() : PfemFluidConstitutiveLaw() {} + +//******************************COPY CONSTRUCTOR****************************** +//**************************************************************************** + +PapanastasiouMuIRheology3DLaw::PapanastasiouMuIRheology3DLaw(const PapanastasiouMuIRheology3DLaw& rOther) + : PfemFluidConstitutiveLaw(rOther) {} + +//***********************************CLONE************************************ +//**************************************************************************** + +ConstitutiveLaw::Pointer PapanastasiouMuIRheology3DLaw::Clone() const { + return Kratos::make_shared(*this); +} + +//*********************************DESTRUCTOR********************************* +//**************************************************************************** + +PapanastasiouMuIRheology3DLaw::~PapanastasiouMuIRheology3DLaw() {} + +ConstitutiveLaw::SizeType PapanastasiouMuIRheology3DLaw::WorkingSpaceDimension() { return 3; } + +ConstitutiveLaw::SizeType PapanastasiouMuIRheology3DLaw::GetStrainSize() { return 6; } + +void PapanastasiouMuIRheology3DLaw::CalculateMaterialResponseCauchy(Parameters& rValues) { + + Flags& r_options = rValues.GetOptions(); + + const Properties& r_properties = rValues.GetMaterialProperties(); + + Vector& r_strain_vector = rValues.GetStrainVector(); + Vector& r_stress_vector = rValues.GetStressVector(); + + const double static_friction = r_properties[STATIC_FRICTION]; + const double dynamic_friction = r_properties[DYNAMIC_FRICTION]; + const double delta_friction = dynamic_friction - static_friction; + const double inertial_number_zero = r_properties[INERTIAL_NUMBER_ZERO]; + const double grain_diameter = r_properties[GRAIN_DIAMETER]; + const double grain_density = r_properties[GRAIN_DENSITY]; + const double regularization_coeff = r_properties[REGULARIZATION_COEFFICIENT]; + double inertial_number = 0; + double effective_dynamic_viscosity = 0; + + const double old_pressure = this->CalculateInGaussPoint(PRESSURE, rValues, 1); + const double new_pressure = this->CalculateInGaussPoint(PRESSURE, rValues, 0); + const GeometryType& r_geometry = rValues.GetElementGeometry(); + + const double theta_momentum = r_geometry[0].GetValue(THETA_MOMENTUM); + double mean_pressure = (1.0 - theta_momentum) * old_pressure + theta_momentum * new_pressure; + if (mean_pressure > 0.0) { + mean_pressure = 0.0000001; + } + + const double equivalent_strain_rate = + std::sqrt(2.0 * r_strain_vector[0] * r_strain_vector[0] + 2.0 * r_strain_vector[1] * r_strain_vector[1] + + 2.0 * r_strain_vector[2] * r_strain_vector[2] + 4.0 * r_strain_vector[3] * r_strain_vector[3] + + 4.0 * r_strain_vector[4] * r_strain_vector[4] + 4.0 * r_strain_vector[5] * r_strain_vector[5]); + + if (mean_pressure != 0) { + inertial_number = equivalent_strain_rate * grain_diameter / std::sqrt(std::fabs(mean_pressure) / grain_density); + } + + const double exponent = -equivalent_strain_rate / regularization_coeff; + + if (equivalent_strain_rate != 0 && std::fabs(mean_pressure) != 0) { + const double first_viscous_term = static_friction * (1.0 - std::exp(exponent)) / equivalent_strain_rate; + const double second_viscous_term = + delta_friction * inertial_number / ((inertial_number_zero + inertial_number) * equivalent_strain_rate); + effective_dynamic_viscosity = (first_viscous_term + second_viscous_term) * std::fabs(mean_pressure); + } else { + effective_dynamic_viscosity = 1.0; + } + + const double strain_trace = r_strain_vector[0] + r_strain_vector[1] + r_strain_vector[2]; + + r_stress_vector[0] = 2.0 * effective_dynamic_viscosity * (r_strain_vector[0] - strain_trace / 3.0); + r_stress_vector[1] = 2.0 * effective_dynamic_viscosity * (r_strain_vector[1] - strain_trace / 3.0); + r_stress_vector[2] = 2.0 * effective_dynamic_viscosity * (r_strain_vector[2] - strain_trace / 3.0); + r_stress_vector[3] = 2.0 * effective_dynamic_viscosity * r_strain_vector[3]; + r_stress_vector[4] = 2.0 * effective_dynamic_viscosity * r_strain_vector[4]; + r_stress_vector[5] = 2.0 * effective_dynamic_viscosity * r_strain_vector[5]; + + if (r_options.Is(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR)) { + this->EffectiveViscousConstitutiveMatrix3D(effective_dynamic_viscosity, rValues.GetConstitutiveMatrix()); + } +} + +std::string PapanastasiouMuIRheology3DLaw::Info() const { return "PapanastasiouMuIRheology3DLaw"; } + +//******************CHECK CONSISTENCY IN THE CONSTITUTIVE LAW****************** +//***************************************************************************** + +int PapanastasiouMuIRheology3DLaw::Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, + const ProcessInfo& rCurrentProcessInfo) { + KRATOS_CHECK_VARIABLE_KEY(STATIC_FRICTION); + KRATOS_CHECK_VARIABLE_KEY(DYNAMIC_FRICTION); + KRATOS_CHECK_VARIABLE_KEY(INERTIAL_NUMBER_ZERO); + KRATOS_CHECK_VARIABLE_KEY(GRAIN_DIAMETER); + KRATOS_CHECK_VARIABLE_KEY(GRAIN_DENSITY); + KRATOS_CHECK_VARIABLE_KEY(REGULARIZATION_COEFFICIENT); + KRATOS_CHECK_VARIABLE_KEY(BULK_MODULUS); + + if (rMaterialProperties[STATIC_FRICTION] <= 0.0) { + KRATOS_ERROR + << "Incorrect or missing STATIC_FRICTION provided in process info for PapanastasiouMuIRheology3DLaw: " + << rMaterialProperties[STATIC_FRICTION] << std::endl; + } + + if (rMaterialProperties[DYNAMIC_FRICTION] <= 0.0) { + KRATOS_ERROR + << "Incorrect or missing DYNAMIC_FRICTION provided in process info for PapanastasiouMuIRheology3DLaw: " + << rMaterialProperties[DYNAMIC_FRICTION] << std::endl; + } + + if (rMaterialProperties[INERTIAL_NUMBER_ZERO] <= 0.0) { + KRATOS_ERROR + << "Incorrect or missing INERTIAL_NUMBER_ZERO provided in process info for PapanastasiouMuIRheology3DLaw: " + << rMaterialProperties[INERTIAL_NUMBER_ZERO] << std::endl; + } + + if (rMaterialProperties[GRAIN_DIAMETER] <= 0.0) { + KRATOS_ERROR + << "Incorrect or missing GRAIN_DIAMETER provided in process info for PapanastasiouMuIRheology3DLaw: " + << rMaterialProperties[GRAIN_DIAMETER] << std::endl; + } + + if (rMaterialProperties[GRAIN_DENSITY] <= 0.0) { + KRATOS_ERROR + << "Incorrect or missing GRAIN_DENSITY provided in process info for PapanastasiouMuIRheology3DLaw: " + << rMaterialProperties[GRAIN_DENSITY] << std::endl; + } + + if (rMaterialProperties[REGULARIZATION_COEFFICIENT] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing REGULARIZATION_COEFFICIENT provided in process info for " + "PapanastasiouMuIRheology3DLaw: " + << rMaterialProperties[REGULARIZATION_COEFFICIENT] << std::endl; + } + + if (rMaterialProperties[BULK_MODULUS] <= 0.0) { + KRATOS_ERROR << "Incorrect or missing BULK_MODULUS provided in process info for " + "PapanastasiouMuIRheology3DLaw: " + << rMaterialProperties[BULK_MODULUS] << std::endl; + } + + return 0; +} + +double PapanastasiouMuIRheology3DLaw::GetEffectiveViscosity(ConstitutiveLaw::Parameters& rParameters) const { + return rParameters.GetConstitutiveMatrix()(5, 5); +} + +double PapanastasiouMuIRheology3DLaw::GetEffectiveDensity(ConstitutiveLaw::Parameters& rParameters) const { + const Properties& r_properties = rParameters.GetMaterialProperties(); + const double effective_density = r_properties[DENSITY]; + return effective_density; +} + +void PapanastasiouMuIRheology3DLaw::save(Serializer& rSerializer) const { + KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, PfemFluidConstitutiveLaw) +} + +void PapanastasiouMuIRheology3DLaw::load(Serializer& rSerializer) { + KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, PfemFluidConstitutiveLaw) +} + +} // Namespace Kratos diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/papanastasiou_mu_I_rheology_3D_law.h b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/papanastasiou_mu_I_rheology_3D_law.h new file mode 100644 index 000000000000..eeffce68933d --- /dev/null +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/papanastasiou_mu_I_rheology_3D_law.h @@ -0,0 +1,172 @@ +//------------------------------------------------------------- +// ___ __ ___ _ _ _ +// KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| | +// | _/ _/ -_) ' \| _|| | || | / _` | +// |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS +// +// BSD License: PfemFluidDynamicsApplication/license.txt +// +// Main authors: Alessandro Franci +// Collaborators: Massimiliano Zecchetto +// +//------------------------------------------------------------- +// + +#if !defined(KRATOS_PAPANASTASIOU_MU_I_RHEOLOGY_LAW_3D_H_INCLUDED) +#define KRATOS_PAPANASTASIOU_MU_I_RHEOLOGY_LAW_3D_H_INCLUDED + +// System includes + +// External includes + +// Project includes +#include "fluid_constitutive_law.h" + +namespace Kratos { +/** + * Defines a 3D Papanastasiou mu(I) rheology constitutive law + * This material law is defined by the parameters: + * 1) STATIC_FRICTION + * 2) DYNAMIC_FRICTION + * 3) INERTIAL_NUMBER_ZERO + * 4) GRAIN_DIAMETER + * 5) GRAIN_DENSITY + * 6) REGULARIZATION_COEFFICIENT + */ + +class KRATOS_API(PFEM_FLUID_DYNAMICS_APPLICATION) PapanastasiouMuIRheology3DLaw : public PfemFluidConstitutiveLaw { + public: + /** + * Type Definitions + */ + typedef ProcessInfo ProcessInfoType; + typedef ConstitutiveLaw BaseType; + typedef std::size_t SizeType; + + /** + * Counted pointer of PapanastasiouMuIRheology3DLaw + */ + KRATOS_CLASS_POINTER_DEFINITION(PapanastasiouMuIRheology3DLaw); + + /** + * Life Cycle + */ + + /** + * Default constructor. + */ + PapanastasiouMuIRheology3DLaw(); + + /** + * Clone function (has to be implemented by any derived class) + * @return a pointer to a new instance of this constitutive law + */ + ConstitutiveLaw::Pointer Clone() const override; + + /** + * Copy constructor. + */ + PapanastasiouMuIRheology3DLaw(const PapanastasiouMuIRheology3DLaw& rOther); + + /** + * Destructor. + */ + ~PapanastasiouMuIRheology3DLaw() override; + + /** + * Operators + */ + + /** + * Operations needed by the base class: + */ + + /** + * @return Working space dimension constitutive law + */ + SizeType WorkingSpaceDimension() override; + + /** + * @return Size of the strain vector (in Voigt notation) for the constitutive law + */ + SizeType GetStrainSize() override; + + void CalculateMaterialResponseCauchy(Parameters& rValues) override; + + /** + * This function is designed to be called once to perform all the checks needed + * on the input provided. Checks can be "expensive" as the function is designed + * to catch user's errors. + * @param rMaterialProperties + * @param rElementGeometry + * @param rCurrentProcessInfo + * @return + */ + int Check(const Properties& rMaterialProperties, const GeometryType& rElementGeometry, + const ProcessInfo& rCurrentProcessInfo) override; + + /** + * Input and output + */ + + /** + * Turn back information as a string. + */ + std::string Info() const override; + + protected: + ///@name Protected static Member Variables + ///@{ + ///@} + ///@name Protected member Variables + ///@{ + ///@} + ///@name Protected Operators + ///@{ + ///@} + ///@name Protected Operations + ///@{ + + /// Get the effective viscosity (in dynamic units -- Pa s) for the fluid. + double GetEffectiveViscosity(ConstitutiveLaw::Parameters& rParameters) const override; + + /// Get the effective density for the fluid. + double GetEffectiveDensity(ConstitutiveLaw::Parameters& rParameters) const override; + + ///@} + + private: + ///@name Static Member Variables + ///@{ + ///@} + ///@name Member Variables + ///@{ + + ///@} + ///@name Private Operators + ///@{ + + ///@} + ///@name Private Operations + ///@{ + ///@} + + ///@} + ///@name Private Access + ///@{ + ///@} + + ///@} + ///@name Serialization + ///@{ + friend class Serializer; + + void save(Serializer& rSerializer) const override; + + void load(Serializer& rSerializer) override; + +}; // Class PapanastasiouMuIRheology3DLaw + +} // namespace Kratos. + +#endif // KRATOS_PAPANASTASIOU_MU_I_RHEOLOGY_LAW_3D_H_INCLUDED defined From 027406861b820abc62c57e99f1ba427218cf888f Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Tue, 3 Mar 2020 08:33:58 +0100 Subject: [PATCH 43/47] Updating SDEM-PFEM test --- .../tests/PFEM-DEM_tests/PfemFluidDynamicsMaterials.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/applications/SwimmingDEMApplication/tests/PFEM-DEM_tests/PfemFluidDynamicsMaterials.json b/applications/SwimmingDEMApplication/tests/PFEM-DEM_tests/PfemFluidDynamicsMaterials.json index ba7d80934350..11bdae2d3488 100644 --- a/applications/SwimmingDEMApplication/tests/PFEM-DEM_tests/PfemFluidDynamicsMaterials.json +++ b/applications/SwimmingDEMApplication/tests/PFEM-DEM_tests/PfemFluidDynamicsMaterials.json @@ -3,6 +3,9 @@ "model_part_name" : "PfemFluidModelPart.Parts_Parts_Auto1", "properties_id" : 1, "Material" : { + "constitutive_law" : { + "name" : "Newtonian3DLaw" + }, "Variables" : { "DENSITY" : 1000.0, "DYNAMIC_VISCOSITY" : 0.001, From b0cad68d4b264e18c06d1af15ca95114d35558e8 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Tue, 3 Mar 2020 08:37:04 +0100 Subject: [PATCH 44/47] Updating SDEM-PFEM example --- .../PfemFluidDynamicsMaterials.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/applications/SwimmingDEMApplication/test_examples/PFEMcoupledDEMexample.gid/PfemFluidDynamicsMaterials.json b/applications/SwimmingDEMApplication/test_examples/PFEMcoupledDEMexample.gid/PfemFluidDynamicsMaterials.json index f5c25a2e817a..d7171827f7d6 100644 --- a/applications/SwimmingDEMApplication/test_examples/PFEMcoupledDEMexample.gid/PfemFluidDynamicsMaterials.json +++ b/applications/SwimmingDEMApplication/test_examples/PFEMcoupledDEMexample.gid/PfemFluidDynamicsMaterials.json @@ -3,6 +3,9 @@ "model_part_name" : "PfemFluidModelPart.Parts_Parts_Auto1", "properties_id" : 1, "Material" : { + "constitutive_law" : { + "name" : "Newtonian3DLaw" + }, "Variables" : { "DENSITY" : 1000.0, "DYNAMIC_VISCOSITY" : 0.1, @@ -21,6 +24,9 @@ "model_part_name" : "PfemFluidModelPart.Parts_Parts_Auto3", "properties_id" : 3, "Material" : { + "constitutive_law" : { + "name" : "Hypoelastic3DLaw" + }, "Variables" : { "DENSITY" : 400, "YOUNG_MODULUS" : 2.10000E+06, From 07c5b81112af20bf8d28bfeee9fce03dea7affb6 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Tue, 3 Mar 2020 14:14:13 +0100 Subject: [PATCH 45/47] addressing codacy suggestions (I) --- .../fluid_laws/barker_bercovier_mu_I_rheology_3D_law.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/barker_bercovier_mu_I_rheology_3D_law.cpp b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/barker_bercovier_mu_I_rheology_3D_law.cpp index 2a32317a3e25..4d92bd032eb7 100644 --- a/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/barker_bercovier_mu_I_rheology_3D_law.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/barker_bercovier_mu_I_rheology_3D_law.cpp @@ -94,7 +94,7 @@ void BarkerBercovierMuIRheology3DLaw::CalculateMaterialResponseCauchy(Parameters inertial_number = equivalent_strain_rate * grain_diameter / std::sqrt(std::fabs(mean_pressure) / grain_density); } - double exponent = 0.0; + double exponent; if (inertial_number > inertial_number_one) { const double first_viscous_term = static_friction; From 63e37c3710c76aafd0adc403f0b7eca3fa795227 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Tue, 3 Mar 2020 14:14:24 +0100 Subject: [PATCH 46/47] addressing codacy suggestions (II) --- .../custom_constitutive/fluid_laws/fluid_constitutive_law.cpp | 2 +- .../custom_constitutive/solid_laws/solid_constitutive_law.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/fluid_constitutive_law.cpp b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/fluid_constitutive_law.cpp index 23443de534d4..ea3320ae180b 100644 --- a/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/fluid_constitutive_law.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/fluid_laws/fluid_constitutive_law.cpp @@ -181,7 +181,7 @@ double PfemFluidConstitutiveLaw::GetValueFromTable(const Variable& rInde // Get material properties from constitutive law parameters const Properties& r_properties = rParameters.GetMaterialProperties(); - double dependent_at_gauss; + double dependent_at_gauss = 0; if (r_properties.HasTable(rIndependentVariable, rDependentVariable)) { // Get geometry and Gauss points data const auto& r_geometry = rParameters.GetElementGeometry(); diff --git a/applications/PfemFluidDynamicsApplication/custom_constitutive/solid_laws/solid_constitutive_law.cpp b/applications/PfemFluidDynamicsApplication/custom_constitutive/solid_laws/solid_constitutive_law.cpp index 40f91ea68263..1e0696dfaaf3 100644 --- a/applications/PfemFluidDynamicsApplication/custom_constitutive/solid_laws/solid_constitutive_law.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_constitutive/solid_laws/solid_constitutive_law.cpp @@ -136,7 +136,7 @@ double PfemSolidConstitutiveLaw::GetValueFromTable(const Variable& rInde // Get material properties from constitutive law parameters const Properties& r_properties = rParameters.GetMaterialProperties(); - double dependent_at_gauss; + double dependent_at_gauss = 0; if (r_properties.HasTable(rIndependentVariable, rDependentVariable)) { // Get geometry and Gauss points data const auto& r_geometry = rParameters.GetElementGeometry(); From 9292015f6472b12180db06374c81a749d61f8a03 Mon Sep 17 00:00:00 2001 From: Massimiliano Zecchetto Date: Tue, 3 Mar 2020 14:14:41 +0100 Subject: [PATCH 47/47] addressing codacy suggestions (III) --- ..._lagrangian_V_P_implicit_solid_element.cpp | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp index 6eef8b88f7e6..e462c57e6abc 100644 --- a/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp +++ b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_solid_element.cpp @@ -454,30 +454,30 @@ void TwoStepUpdatedLagrangianVPImplicitSolidElement<3>::CalcElasticPlasticCauchy } template -void TwoStepUpdatedLagrangianVPImplicitSolidElement::UpdateCauchyStress(unsigned int g, ProcessInfo &rCurrentProcessInfo) -{ - - double theta = this->GetThetaContinuity(); - ElementalVariables rElementalVariables; - this->InitializeElementalVariables(rElementalVariables); - ShapeFunctionDerivativesArrayType DN_DX; - Matrix NContainer; - VectorType GaussWeights; - this->CalculateGeometryData(DN_DX, NContainer, GaussWeights); - const ShapeFunctionDerivativesType &rDN_DX = DN_DX[g]; - // bool computeElement=this->CalcStrainRate(rElementalVariables,rCurrentProcessInfo,rDN_DX,theta); - bool computeElement = this->CalcCompleteStrainRate(rElementalVariables, rCurrentProcessInfo, rDN_DX, theta); - const double TimeStep = rCurrentProcessInfo[DELTA_TIME]; - double Density = 0; - double DeviatoricCoeff = 0; - double VolumetricCoeff = 0; - if (computeElement == true) { - this->CalcElasticPlasticCauchySplitted(rElementalVariables, TimeStep, g, rCurrentProcessInfo, Density, - DeviatoricCoeff, VolumetricCoeff); - } +void TwoStepUpdatedLagrangianVPImplicitSolidElement::UpdateCauchyStress(unsigned int g, + ProcessInfo &rCurrentProcessInfo) { + double theta = this->GetThetaContinuity(); + ElementalVariables rElementalVariables; + this->InitializeElementalVariables(rElementalVariables); + ShapeFunctionDerivativesArrayType DN_DX; + Matrix NContainer; + VectorType GaussWeights; + this->CalculateGeometryData(DN_DX, NContainer, GaussWeights); + const ShapeFunctionDerivativesType &rDN_DX = DN_DX[g]; + // bool computeElement=this->CalcStrainRate(rElementalVariables,rCurrentProcessInfo,rDN_DX,theta); + bool computeElement = this->CalcCompleteStrainRate(rElementalVariables, rCurrentProcessInfo, rDN_DX, theta); + const double TimeStep = rCurrentProcessInfo[DELTA_TIME]; + + if (computeElement == true) { + double Density = 0; + double DeviatoricCoeff = 0; + double VolumetricCoeff = 0; + this->CalcElasticPlasticCauchySplitted(rElementalVariables, TimeStep, g, rCurrentProcessInfo, Density, + DeviatoricCoeff, VolumetricCoeff); + } - this->mCurrentTotalCauchyStress[g] = this->mUpdatedTotalCauchyStress[g]; - this->mCurrentDeviatoricCauchyStress[g] = this->mUpdatedDeviatoricCauchyStress[g]; + this->mCurrentTotalCauchyStress[g] = this->mUpdatedTotalCauchyStress[g]; + this->mCurrentDeviatoricCauchyStress[g] = this->mUpdatedDeviatoricCauchyStress[g]; } template