### Working tangent block formulation

parent 323faba3
 ... ... @@ -32,19 +32,13 @@ ds = Measure("ds", subdomain_data=facets) material = mf.MFrontNonlinearMaterial("../materials/src/libBehaviour.so", "HeatTransfer", material = mf.MFrontNonlinearMaterial("materials/src/libBehaviour.so", "StationaryHeatTransfer", hypothesis="plane_strain") problem = mf.MFrontNonlinearProblem(T, material, quadrature_degree=0) problem.bc = bc flux = mf.ThermalFlux(T) problem.define_form(flux) import mgis.behaviour as mgis_bv for t in problem.material.behaviour.tangent_operator_blocks: print('d{}_d{} size {}x{}'.format(t.name,t.name, mgis_bv.getVariableSize(t, problem.material.hypothesis), mgis_bv.getVariableSize(t, problem.material.hypothesis))) problem.register_gradient("TemperatureGradient", grad(T)) T.interpolate(Constant(Tl)) ... ...
 #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Feb 1 08:49:11 2019 @author: bleyerj """ from dolfin import * import mfront_wrapper as mf import numpy as np from ufl import diag width = 1. height = 1. mesh = RectangleMesh(Point(0., 0.), Point(width, height), 20, 10) Ve = VectorElement("CG", mesh.ufl_cell(), 1) V = FunctionSpace(mesh, MixedElement([Ve, Ve])) u = Function(V, name="Displacements") (u1, u2) = split(u) def bottom(x, on_boundary): return near(x, 0) and on_boundary def top(x, on_boundary): return near(x, height) and on_boundary def left(x, on_boundary): return near(x, 0) and on_boundary bc = [DirichletBC(V.sub(0).sub(0), Constant(0), left), DirichletBC(V.sub(1).sub(0), Constant(0), left), DirichletBC(V.sub(0).sub(1), Constant(0), bottom), DirichletBC(V.sub(1).sub(1), Constant(0), bottom), DirichletBC(V.sub(0).sub(1), Constant(-1), top), DirichletBC(V.sub(1).sub(1), Constant(-1), top)] facets = MeshFunction("size_t", mesh, 1) ds = Measure("ds", subdomain_data=facets) material = mf.MFrontNonlinearMaterial("materials/src/libBehaviour.so", "TwoPhasesGeneralizedElasticity", hypothesis="plane_strain") problem = mf.MFrontNonlinearProblem(u, material, quadrature_degree=0) problem.bc = bc problem.register_gradient("MatrixStrain", sym(grad(u1)), symmetric=True) problem.register_gradient("InclusionStrain", sym(grad(u2)), symmetric=True) problem.register_gradient("RelativeDisplacement", diag(u2-u1), symmetric=True) problem.solve(u.vector()) u1 = u.sub(0, True) u2 = u.sub(1, True) x = np.linspace(0, width, 100) import matplotlib.pyplot as plt plt.figure() plt.plot(x, np.array([u1(xi, height/2) for xi in x]), label=r"\$u_x\$ (matrix)") plt.plot(x, np.array([u2(xi, height/2) for xi in x]), label=r"\$u_x\$ (inclusion)") plt.legend() plt.show() \ No newline at end of file
 ... ... @@ -13,9 +13,9 @@ Et = E/100. # hardening slope H = E*Et/(E-Et) mesh = Mesh("../meshes/thick_cylinder.xml") mesh = Mesh("meshes/thick_cylinder.xml") facets = MeshFunction("size_t", mesh, "../meshes/thick_cylinder_facet_region.xml") facets = MeshFunction("size_t", mesh, "meshes/thick_cylinder_facet_region.xml") ds = Measure('ds', subdomain_data=facets) ... ... @@ -40,19 +40,20 @@ for hypothesis in ["plane_strain", "axisymmetric"]: "PoissonRatio": nu, "HardeningSlope": H, "YieldStrength": sig0} material = mf.MFrontNonlinearMaterial("../materials/src/libBehaviour.so", material = mf.MFrontNonlinearMaterial("materials/src/libBehaviour.so", "IsotropicLinearHardeningPlasticity", hypothesis=hypothesis, material_properties=mat_prop) problem = mf.MFrontNonlinearProblem(u, material, quadrature_degree=4) problem.bc = bc problem.define_form(mf.Stress(u, name="sigma")) # problem.define_form(mf.Stress(u, name="sigma")) problem.register_gradient("Strain", sym(grad(u)), symmetric=True) problem.set_loading(loading*dot(n, u)*measure*ds(4)) p = problem.get_state_variable(name="EquivalentPlasticStrain") assert (ufl.shape(p) == ()) epsel = problem.get_state_variable(name="ElasticStrain") assert (ufl.shape(epsel)==(4, )) # p = problem.get_state_variable(name="EquivalentPlasticStrain") # assert (ufl.shape(p) == ()) # epsel = problem.get_state_variable(name="ElasticStrain") # assert (ufl.shape(epsel)==(4, )) file_results = XDMFFile("results/plasticity_{}_results.xdmf".format(hypothesis)) file_results.parameters["flush_output"] = True ... ... @@ -69,9 +70,9 @@ for hypothesis in ["plane_strain", "axisymmetric"]: file_results.write(u, t) p_avg.assign(project(epsel, P0)) file_results.write(p_avg, t) results[i+1, :] = (u(Ri, 0), t) # p_avg.assign(project(epsel, P0)) # file_results.write(p_avg, t) # results[i+1, :] = (u(Ri, 0), t) import matplotlib.pyplot as plt ... ...
 @DSL DefaultGenericBehaviour; @Behaviour MultiPhase; @Author Thomas Helfer; @Date 15/02/2019; @Gradient real eps1; @Flux real sig1; @Gradient real toto; @Flux real sig2; @Gradient real V; @Flux real I; // @AdditionalTangentOperatorBlock dsig1_deps1; @Parameter C11 = 10e3; @Parameter C12 = 5e-4; @Parameter C22 = 2e3; @Parameter kappa = 1e6; @Integrator{ sig1 = C11*(eps1+deps1); sig2 = C22*(toto+dtoto); I = kappa*V } // end of @Integrator @TangentOperator { //dj_ddgT = k * tmatrix::Id(); dsig1_ddeps1 = C11* Stensor4::Id(); } // end of @TangentOperator
 /*! * \file LogarithmicStrainPlasticity-generic.hxx * \brief This file declares the umat interface for the LogarithmicStrainPlasticity behaviour law * \author Helfer Thomas * \date 5 / 12 / 13 */ #ifndef LIB_GENERIC_LOGARITHMICSTRAINPLASTICITY_HXX #define LIB_GENERIC_LOGARITHMICSTRAINPLASTICITY_HXX #include"TFEL/Config/TFELConfig.hxx" #include"MFront/GenericBehaviour/BehaviourData.h" #ifdef _WIN32 #ifndef NOMINMAX #define NOMINMAX #endif /* NOMINMAX */ #include #ifdef small #undef small #endif /* small */ #endif /* _WIN32 */ #ifndef MFRONT_SHAREDOBJ #define MFRONT_SHAREDOBJ TFEL_VISIBILITY_EXPORT #endif /* MFRONT_SHAREDOBJ */ #ifdef __cplusplus extern "C"{ #endif /* __cplusplus */ MFRONT_SHAREDOBJ void LogarithmicStrainPlasticity_setOutOfBoundsPolicy(const int); MFRONT_SHAREDOBJ int LogarithmicStrainPlasticity_setParameter(const char *const,const double); MFRONT_SHAREDOBJ int LogarithmicStrainPlasticity_setUnsignedShortParameter(const char *const,const unsigned short); /*! * \param[in,out] d: material data */ MFRONT_SHAREDOBJ int LogarithmicStrainPlasticity_AxisymmetricalGeneralisedPlaneStrain(MFront_GB_BehaviourData* const); /*! * \param[in,out] d: material data */ MFRONT_SHAREDOBJ int LogarithmicStrainPlasticity_Axisymmetrical(MFront_GB_BehaviourData* const); /*! * \param[in,out] d: material data */ MFRONT_SHAREDOBJ int LogarithmicStrainPlasticity_PlaneStrain(MFront_GB_BehaviourData* const); /*! * \param[in,out] d: material data */ MFRONT_SHAREDOBJ int LogarithmicStrainPlasticity_GeneralisedPlaneStrain(MFront_GB_BehaviourData* const); /*! * \param[in,out] d: material data */ MFRONT_SHAREDOBJ int LogarithmicStrainPlasticity_Tridimensional(MFront_GB_BehaviourData* const); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* LIB_GENERIC_LOGARITHMICSTRAINPLASTICITY_HXX */
 ... ... @@ -30,6 +30,7 @@ #include"TFEL/Math/Matrix/tmatrixIO.hxx" #include"TFEL/Math/st2tost2.hxx" #include"TFEL/Math/ST2toST2/ST2toST2ConceptIO.hxx" #include"TFEL/Math/ST2toST2/ST2toST2View.hxx" #include"TFEL/Material/ModellingHypothesis.hxx" #include "MFront/GenericBehaviour/State.hxx" ... ... @@ -138,12 +139,11 @@ IsotropicLinearHardeningPlasticityBehaviourData() {} /*! * \brief Copy constructor * \brief copy constructor */ IsotropicLinearHardeningPlasticityBehaviourData(const IsotropicLinearHardeningPlasticityBehaviourData& src) : eto(src.eto), sig(src.sig) , sig(src.sig), young(src.young), nu(src.nu), H(src.H), ... ...
This diff is collapsed.
 /*! * \file TFEL/Material/LogarithmicStrainPlasticityBehaviourData.hxx * \brief this file implements the LogarithmicStrainPlasticityBehaviourData class. * File generated by tfel version 3.3.0 * \author Helfer Thomas * \date 5 / 12 / 13 */ #ifndef LIB_TFELMATERIAL_LOGARITHMICSTRAINPLASTICITY_BEHAVIOUR_DATA_HXX #define LIB_TFELMATERIAL_LOGARITHMICSTRAINPLASTICITY_BEHAVIOUR_DATA_HXX #include #include #include #include #include #include #include"TFEL/Raise.hxx" #include"TFEL/PhysicalConstants.hxx" #include"TFEL/Config/TFELConfig.hxx" #include"TFEL/Config/TFELTypes.hxx" #include"TFEL/Metaprogramming/StaticAssert.hxx" #include"TFEL/TypeTraits/IsFundamentalNumericType.hxx" #include"TFEL/TypeTraits/IsReal.hxx" #include"TFEL/Math/General/IEEE754.hxx" #include"TFEL/Math/stensor.hxx" #include"TFEL/Math/Stensor/StensorConceptIO.hxx" #include"TFEL/Math/tmatrix.hxx" #include"TFEL/Math/Matrix/tmatrixIO.hxx" #include"TFEL/Math/st2tost2.hxx" #include"TFEL/Math/ST2toST2/ST2toST2ConceptIO.hxx" #include"TFEL/Material/ModellingHypothesis.hxx" #include "MFront/GenericBehaviour/State.hxx" #include "MFront/GenericBehaviour/BehaviourData.hxx" namespace tfel{ namespace material{ //! \brief forward declaration template class LogarithmicStrainPlasticityBehaviourData; //! \brief forward declaration template class LogarithmicStrainPlasticityIntegrationData; //! \brief forward declaration template std::ostream& operator <<(std::ostream&,const LogarithmicStrainPlasticityBehaviourData&); template class LogarithmicStrainPlasticityBehaviourData { static constexpr unsigned short N = ModellingHypothesisToSpaceDimension::value; TFEL_STATIC_ASSERT(N==1||N==2||N==3); TFEL_STATIC_ASSERT(tfel::typetraits::IsFundamentalNumericType::cond); TFEL_STATIC_ASSERT(tfel::typetraits::IsReal::cond); friend std::ostream& operator<< <>(std::ostream&,const LogarithmicStrainPlasticityBehaviourData&); /* integration data is declared friend to access driving variables at the beginning of the time step */ friend class LogarithmicStrainPlasticityIntegrationData; static constexpr unsigned short TVectorSize = N; typedef tfel::math::StensorDimeToSize StensorDimeToSize; static constexpr unsigned short StensorSize = StensorDimeToSize::value; typedef tfel::math::TensorDimeToSize TensorDimeToSize; static constexpr unsigned short TensorSize = TensorDimeToSize::value; using ushort = unsigned short; using Types = tfel::config::Types; using real = typename Types::real; using time = typename Types::time; using length = typename Types::length; using frequency = typename Types::frequency; using stress = typename Types::stress; using strain = typename Types::strain; using strainrate = typename Types::strainrate; using stressrate = typename Types::stressrate; using temperature = typename Types::temperature; using thermalexpansion = typename Types::thermalexpansion; using thermalconductivity = typename Types::thermalconductivity; using massdensity = typename Types::massdensity; using energydensity = typename Types::energydensity; using TVector = typename Types::TVector; using Stensor = typename Types::Stensor; using Stensor4 = typename Types::Stensor4; using FrequencyStensor = typename Types::FrequencyStensor; using ForceTVector = typename Types::ForceTVector; using StressStensor = typename Types::StressStensor; using StressRateStensor = typename Types::StressRateStensor; using DisplacementTVector = typename Types::DisplacementTVector; using StrainStensor = typename Types::StrainStensor; using StrainRateStensor = typename Types::StrainRateStensor; using StiffnessTensor = typename Types::StiffnessTensor; using Tensor = typename Types::Tensor; using FrequencyTensor = typename Types::FrequencyTensor; using StressTensor = typename Types::StressTensor; using ThermalExpansionCoefficientTensor = typename Types::ThermalExpansionCoefficientTensor; using DeformationGradientTensor = typename Types::DeformationGradientTensor; using DeformationGradientRateTensor = typename Types::DeformationGradientRateTensor; using TemperatureGradient = typename Types::TemperatureGradient; using HeatFlux = typename Types::HeatFlux; using TangentOperator = StiffnessTensor; using PhysicalConstants = tfel::PhysicalConstants; protected: StrainStensor eto; StressStensor sig; StrainStensor eel; strain p; temperature T; public: /*! * \brief Default constructor */ LogarithmicStrainPlasticityBehaviourData() {} /*! * \brief Copy constructor */ LogarithmicStrainPlasticityBehaviourData(const LogarithmicStrainPlasticityBehaviourData& src) : eto(src.eto), sig(src.sig) , eel(src.eel), p(src.p), T(src.T) {} /* * \brief constructor for the Generic interface * \param[in] mgb_d: behaviour data */ LogarithmicStrainPlasticityBehaviourData(const mfront::gb::BehaviourData& mgb_d) : eel(&mgb_d.s0.internal_state_variables), p(mgb_d.s0.internal_state_variables[StensorSize]), T(mgb_d.s0.external_state_variables) { } /* * \brief Assignement operator */ LogarithmicStrainPlasticityBehaviourData& operator=(const LogarithmicStrainPlasticityBehaviourData& src){ this->eto = src.eto; this->sig = src.sig; this->eel = src.eel; this->p = src.p; this->T = src.T; return *this; } void exportStateData(mfront::gb::State& mbg_s1) const { using namespace tfel::math; tfel::fsalgo::copy::exe(this->sig.begin(), mbg_s1.thermodynamic_forces); tfel::fsalgo::copy::exe(this->eel.begin(), mbg_s1.internal_state_variables); mbg_s1.internal_state_variables[StensorSize] = this->p; } // end of exportStateData }; // end of LogarithmicStrainPlasticityBehaviourDataclass template std::ostream& operator <<(std::ostream& os,const LogarithmicStrainPlasticityBehaviourData& b) { os << "εᵗᵒ : " << b.eto << '\n'; os << "σ : " << b.sig << '\n'; os << "εᵉˡ : " << b.eel << '\n'; os << "p : " << b.p << '\n'; os << "T : " << b.T << '\n'; return os; } } // end of namespace material } // end of namespace tfel #endif /* LIB_TFELMATERIAL_LOGARITHMICSTRAINPLASTICITY_BEHAVIOUR_DATA_HXX */
 /*! * \file TFEL/Material/LogarithmicStrainPlasticityIntegrationData.hxx * \brief this file implements the LogarithmicStrainPlasticityIntegrationData class. * File generated by tfel version 3.3.0 * \author Helfer Thomas * \date 5 / 12 / 13 */ #ifndef LIB_TFELMATERIAL_LOGARITHMICSTRAINPLASTICITY_INTEGRATION_DATA_HXX #define LIB_TFELMATERIAL_LOGARITHMICSTRAINPLASTICITY_INTEGRATION_DATA_HXX #include #include #include #include #include #include"TFEL/Raise.hxx" #include"TFEL/PhysicalConstants.hxx" #include"TFEL/Config/TFELConfig.hxx" #include"TFEL/Config/TFELTypes.hxx" #include"TFEL/Metaprogramming/StaticAssert.hxx" #include"TFEL/TypeTraits/IsFundamentalNumericType.hxx" #include"TFEL/TypeTraits/IsScalar.hxx" #include"TFEL/TypeTraits/IsReal.hxx" #include"TFEL/TypeTraits/Promote.hxx" #include"TFEL/Math/General/IEEE754.hxx" #include"TFEL/Math/stensor.hxx" #include"TFEL/Math/st2tost2.hxx" #include "MFront/GenericBehaviour/State.hxx" #include "MFront/GenericBehaviour/BehaviourData.hxx" namespace tfel{ namespace material{ //! \brief forward declaration template class LogarithmicStrainPlasticityIntegrationData; //! \brief forward declaration template std::ostream& operator <<(std::ostream&,const LogarithmicStrainPlasticityIntegrationData&); template class LogarithmicStrainPlasticityIntegrationData { static constexpr unsigned short N = ModellingHypothesisToSpaceDimension::value; TFEL_STATIC_ASSERT(N==1||N==2||N==3); TFEL_STATIC_ASSERT(tfel::typetraits::IsFundamentalNumericType::cond); TFEL_STATIC_ASSERT(tfel::typetraits::IsReal::cond); friend std::ostream& operator<< <>(std::ostream&,const LogarithmicStrainPlasticityIntegrationData&); static constexpr unsigned short TVectorSize = N; typedef tfel::math::StensorDimeToSize StensorDimeToSize; static constexpr unsigned short StensorSize = StensorDimeToSize::value; typedef tfel::math::TensorDimeToSize TensorDimeToSize; static constexpr unsigned short TensorSize = TensorDimeToSize::value; using ushort = unsigned short; using Types = tfel::config::Types; using real = typename Types::real; using time = typename Types::time; using length = typename Types::length; using frequency = typename Types::frequency; using stress = typename Types::stress; using strain = typename Types::strain; using strainrate = typename Types::strainrate; using stressrate = typename Types::stressrate; using temperature = typename Types::temperature; using thermalexpansion = typename Types::thermalexpansion; using thermalconductivity = typename Types::thermalconductivity; using massdensity = typename Types::massdensity; using energydensity = typename Types::energydensity; using TVector = typename Types::TVector; using Stensor = typename Types::Stensor; using Stensor4 = typename Types::Stensor4; using FrequencyStensor = typename Types::FrequencyStensor; using ForceTVector = typename Types::ForceTVector; using StressStensor = typename Types::StressStensor; using StressRateStensor = typename Types::StressRateStensor; using DisplacementTVector = typename Types::DisplacementTVector; using StrainStensor = typename Types::StrainStensor; using StrainRateStensor = typename Types::StrainRateStensor; using StiffnessTensor = typename Types::StiffnessTensor; using Tensor = typename Types::Tensor; using FrequencyTensor = typename Types::FrequencyTensor; using StressTensor = typename Types::StressTensor; using ThermalExpansionCoefficientTensor = typename Types::ThermalExpansionCoefficientTensor; using DeformationGradientTensor = typename Types::DeformationGradientTensor; using DeformationGradientRateTensor = typename Types::DeformationGradientRateTensor; using TemperatureGradient = typename Types::TemperatureGradient; using HeatFlux = typename Types::HeatFlux; using TangentOperator = StiffnessTensor; using PhysicalConstants = tfel::PhysicalConstants; protected: /*! * \brief eto increment */ StrainStensor deto; /*! * \brief time increment */ time dt; temperature dT; public: /*! * \brief Default constructor */ LogarithmicStrainPlasticityIntegrationData()