diff --git a/applications/DelaunayMeshingApplication/custom_utilities/mesh_data_transfer_utilities.cpp b/applications/DelaunayMeshingApplication/custom_utilities/mesh_data_transfer_utilities.cpp index ab2360b7302f..556fc022945c 100644 --- a/applications/DelaunayMeshingApplication/custom_utilities/mesh_data_transfer_utilities.cpp +++ b/applications/DelaunayMeshingApplication/custom_utilities/mesh_data_transfer_utilities.cpp @@ -1347,6 +1347,13 @@ void MeshDataTransferUtilities::TransferElementalValuesToElements(ModelPart& rMo new_element->SetProperties(p_new_property); } + // 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); 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 ) 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..4d92bd032eb7 --- /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; + + 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 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 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 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 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 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..ea3320ae180b --- /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 = 0; + 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 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 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 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..542b0be3b506 --- /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(Newtonian3DLaw); + + /** + * 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 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 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 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 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 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..1e0696dfaaf3 --- /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 = 0; + 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 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..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 @@ -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++) @@ -121,47 +120,16 @@ void TwoStepUpdatedLagrangianVPImplicitElement::CalculateLocalMomentumEqua bool computeElement = this->CalcMechanicsUpdated(rElementalVariables, rCurrentProcessInfo, rDN_DX, g); - this->ComputeMaterialParameters(Density, DeviatoricCoeff, VolumetricCoeff, rCurrentProcessInfo, rElementalVariables); - - this->CalcElasticPlasticCauchySplitted(rElementalVariables, TimeStep, g); - - // std::vector rOutput; - // this->GetElementalValueForOutput(YIELDED,rOutput); + this->CalcElasticPlasticCauchySplitted(rElementalVariables, TimeStep, g, rCurrentProcessInfo, Density, + DeviatoricCoeff, VolumetricCoeff); 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; } } 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..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 ///@{ @@ -342,12 +350,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, @@ -427,9 +429,9 @@ 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, 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_DEM_coupling_element.cpp b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_DEM_coupling_element.cpp index ec6a10c514e8..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,60 +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->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 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 3e358c56646c..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 @@ -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 @@ -55,91 +64,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); - // 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 - { - // std::cout<<"For a Newtonian fluid I should enter here"<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 -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, @@ -222,305 +146,103 @@ void TwoStepUpdatedLagrangianVPImplicitFluidElement::ComputeMaterialParame } 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)); +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; + + // 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()); } - else if (meanPressure != 0 && rElementalVariables.EquivalentStrainRate == 0) - { - FluidViscosity *= fabs(meanPressure) / sqrt(0.001 + pow(regularizationCoefficient, 2)); - } - else - { - FluidViscosity = 1.0; + + // 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()); + } } - } - return FluidViscosity; -} + // 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; + } -template -int TwoStepUpdatedLagrangianVPImplicitFluidElement::Check(const ProcessInfo &rCurrentProcessInfo) -{ - KRATOS_TRY; + // Check constitutive law + return mpConstitutiveLaw->Check(r_properties, r_geometry, rCurrentProcessInfo); - // 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()); - } - - // 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()); - } - } - - return ierr; - - KRATOS_CATCH(""); + KRATOS_CATCH(""); } template <> @@ -1488,6 +1210,8 @@ void TwoStepUpdatedLagrangianVPImplicitFluidElement::InitializeElementalVa } rElementalVariables.voigtsize = voigtsize; + rElementalVariables.ConstitutiveMatrix = ZeroMatrix(voigtsize, voigtsize); + rElementalVariables.DetFgrad = 1.0; rElementalVariables.DetFgradVel = 1.0; @@ -1528,155 +1252,95 @@ void TwoStepUpdatedLagrangianVPImplicitFluidElement::InitializeElementalVa } template <> -void TwoStepUpdatedLagrangianVPImplicitFluidElement<2>::CalcElasticPlasticCauchySplitted(ElementalVariables &rElementalVariables, double TimeStep, unsigned int 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]; - - 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= 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; - - rElementalVariables.UpdatedTotalCauchyStress[0] = sigmaTot_xx; - 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; - // } - // } +void TwoStepUpdatedLagrangianVPImplicitFluidElement<2>::CalcElasticPlasticCauchySplitted( + 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, 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 <> -void TwoStepUpdatedLagrangianVPImplicitFluidElement<3>::CalcElasticPlasticCauchySplitted(ElementalVariables &rElementalVariables, double TimeStep, unsigned int 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; - - // 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; - 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, 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, 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_fluid_element.h b/applications/PfemFluidDynamicsApplication/custom_elements/two_step_updated_lagrangian_V_P_implicit_fluid_element.h index 491f3646f630..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 ///@{ @@ -291,12 +301,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. @@ -319,24 +323,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; @@ -367,9 +359,9 @@ 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, 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_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 a51dc793fe01..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 @@ -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 @@ -127,99 +132,103 @@ 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; -} - -template -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; +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; + + // 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 @@ -303,7 +312,7 @@ void TwoStepUpdatedLagrangianVPImplicitSolidElement::InitializeElementalVa voigtsize = 6; } rElementalVariables.voigtsize = voigtsize; - + rElementalVariables.ConstitutiveMatrix = ZeroMatrix(voigtsize, voigtsize); rElementalVariables.DetFgrad = 1; rElementalVariables.DetFgradVel = 1; rElementalVariables.DeviatoricInvariant = 1; @@ -325,197 +334,150 @@ 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]; - - 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= CurrFirstLame*DefVol + 2.0*CurrSecondLame*DefX; - // double sigmaTot_yy= CurrFirstLame*DefVol + 2.0*CurrSecondLame*DefY; - // double sigmaTot_xy= 2.0*CurrSecondLame*DefXY; - - // 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; - - 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; - - // 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.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; +void TwoStepUpdatedLagrangianVPImplicitSolidElement<2>::CalcElasticPlasticCauchySplitted( + 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]; + + 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.UpdatedTotalCauchyStress[0] = + rElementalVariables.CurrentDeviatoricCauchyStress[0] + rElementalVariables.MeanPressure; + rElementalVariables.UpdatedTotalCauchyStress[1] = + rElementalVariables.CurrentDeviatoricCauchyStress[1] + rElementalVariables.MeanPressure; + rElementalVariables.UpdatedTotalCauchyStress[2] = rElementalVariables.CurrentDeviatoricCauchyStress[2]; + + 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 <> -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, const ProcessInfo &rCurrentProcessInfo, + double &Density, double &DeviatoricCoeff, double &VolumetricCoeff) { + + rElementalVariables.CurrentTotalCauchyStress = this->mCurrentTotalCauchyStress[g]; + rElementalVariables.CurrentDeviatoricCauchyStress = this->mCurrentDeviatoricCauchyStress[g]; + + 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->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 -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) - { - 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; +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); + } - // std::cout<<" UpdateCauchyStress "; - 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 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..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 ///@{ @@ -291,12 +299,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. @@ -341,9 +343,9 @@ 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, 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 83eacc7df3ac..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" @@ -85,6 +86,7 @@ class TwoStepUpdatedLagrangianElement : public Element MatrixType FgradVel; MatrixType InvFgradVel; MatrixType SpatialVelocityGrad; + MatrixType ConstitutiveMatrix; // Stress state double MeanPressure; VectorType CurrentTotalCauchyStress; @@ -139,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 ///@{ @@ -334,6 +342,8 @@ class TwoStepUpdatedLagrangianElement : public Element ///@name Protected member Variables ///@{ + ConstitutiveLaw::Pointer mpConstitutiveLaw = nullptr; + ///@} ///@name Protected Operators ///@{ @@ -358,12 +368,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, @@ -571,9 +575,9 @@ 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, double &Density, + double &DeviatoricCoeff, double &VolumetricCoeff){}; /// 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 f5a09d11ad60..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 @@ -68,120 +68,125 @@ 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]; - - 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 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 = 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]; - - 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; - - this->mUpdatedTotalCauchyStress[g] = rElementalVariables.UpdatedTotalCauchyStress; - this->mUpdatedDeviatoricCauchyStress[g] = rElementalVariables.UpdatedDeviatoricCauchyStress; +void UpdatedLagrangianVImplicitSolidElement<2>::CalcElasticPlasticCauchySplitted( + 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]; + + 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.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; } 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, 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]; + + 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->mUpdatedDeviatoricCauchyStress[g] = rElementalVariables.UpdatedDeviatoricCauchyStress; } template class UpdatedLagrangianVImplicitSolidElement<2>; 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..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 @@ -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 ///@{ @@ -295,9 +303,9 @@ 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, double &Density, + double &DeviatoricCoeff, double &VolumetricCoeff) override; double GetThetaMomentum() override { return 1.0; }; @@ -317,7 +325,7 @@ class UpdatedLagrangianVImplicitSolidElement : public TwoStepUpdatedLagrangianVP ///@} -private: + private: ///@name Static Member Variables ///@{ 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 64bb326a51d0..34e791467aaa 100644 --- a/applications/PfemFluidDynamicsApplication/pfem_fluid_dynamics_application.cpp +++ b/applications/PfemFluidDynamicsApplication/pfem_fluid_dynamics_application.cpp @@ -111,6 +111,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); @@ -210,7 +211,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 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 ///@{ 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") 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, 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, 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,