1 /*! 2 * \file mfront/src/NortonInelasticFlow.cxx 3 * \brief 4 * \author Thomas Helfer 5 * \date 28/03/2018 6 * \copyright Copyright (C) 2006-2018 CEA/DEN, EDF R&D. All rights 7 * reserved. 8 * This project is publicly released under either the GNU GPL Licence 9 * or the CECILL-A licence. A copy of thoses licences are delivered 10 * with the sources of TFEL. CEA or EDF may also distribute this 11 * project under specific licensing conditions. 12 */ 13 14 #include "TFEL/Glossary/Glossary.hxx" 15 #include "TFEL/Glossary/GlossaryEntry.hxx" 16 #include "MFront/ImplicitDSLBase.hxx" 17 #include "MFront/NonLinearSystemSolver.hxx" 18 #include "MFront/BehaviourBrick/BrickUtilities.hxx" 19 #include "MFront/BehaviourBrick/StressCriterion.hxx" 20 #include "MFront/BehaviourBrick/StressPotential.hxx" 21 #include "MFront/BehaviourBrick/IsotropicHardeningRule.hxx" 22 #include "MFront/BehaviourBrick/KinematicHardeningRule.hxx" 23 #include "MFront/BehaviourBrick/OptionDescription.hxx" 24 #include "MFront/BehaviourBrick/ViscoplasticFlowBase.hxx" 25 26 namespace mfront { 27 28 namespace bbrick { 29 initialize(BehaviourDescription & bd,AbstractBehaviourDSL & dsl,const std::string & id,const DataMap & d)30 void ViscoplasticFlowBase::initialize(BehaviourDescription& bd, 31 AbstractBehaviourDSL& dsl, 32 const std::string& id, 33 const DataMap& d) { 34 using namespace tfel::glossary; 35 constexpr const auto uh = ModellingHypothesis::UNDEFINEDHYPOTHESIS; 36 InelasticFlowBase::initialize(bd, dsl, id, d); 37 // checking options 38 mfront::bbrick::check(d, this->getOptions()); 39 if (id.empty()) { 40 addStateVariable(bd, "strain", "p", 41 Glossary::EquivalentViscoplasticStrain); 42 } else { 43 addStateVariable(bd, "strain", "p" + id, 44 static_cast<const std::string&>( 45 Glossary::EquivalentViscoplasticStrain) + 46 id); 47 } 48 for (const auto& vn : {"vp", "dvp_dseqe", "dvp_dp"}) { 49 bd.reserveName(uh, vn + id); 50 } 51 } // end of ViscoplasticFlowBase::initialize 52 buildFlowImplicitEquations(const BehaviourDescription & bd,const StressPotential & sp,const std::string & id,const bool b) const53 std::string ViscoplasticFlowBase::buildFlowImplicitEquations( 54 const BehaviourDescription& bd, 55 const StressPotential& sp, 56 const std::string& id, 57 const bool b) const { 58 constexpr const auto uh = ModellingHypothesis::UNDEFINEDHYPOTHESIS; 59 auto c = std::string{}; 60 if (b) { 61 if (!this->ihrs.empty()) { 62 c += computeElasticLimitAndDerivative(this->ihrs, id); 63 } 64 c += this->computeFlowRateAndDerivative(id); 65 c += "fp" + id + " -= (this->dt) * vp" + id + ";\n"; 66 c += sp.generateImplicitEquationDerivatives( 67 bd, "strain", "p" + id, 68 "-(this->dt) * dvp" + id + "_dseqe" + id + " * dseq" + id + "_ds" + id, 69 this->sc->isNormalDeviatoric()); 70 if (!this->ihrs.empty()) { 71 c += "dfp" + id + "_ddp" + id + " += (this->dt) * dvp" + id + "_dseqe" + 72 id + "*dR" + id + "_ddp" + id + ";\n"; 73 } 74 auto kid = decltype(khrs.size()){}; 75 for (const auto& khr : khrs) { 76 c += khr->generateImplicitEquationDerivatives( 77 "p", "(this->dt) * dvp" + id + "_dseqe " + id + " * dseq" + id + 78 "_ds" + id, 79 id, std::to_string(kid)); 80 ++kid; 81 } 82 if (this->isCoupledWithPorosityEvolution()) { 83 const auto& f = 84 bd.getBehaviourData(uh).getStateVariableDescriptionByExternalName( 85 tfel::glossary::Glossary::Porosity); 86 c += "dfp" + id + "_dd" + f.name + " = "; 87 c += "- theta * (this->dt) * dvp" + id + "_dseqe" + id + " * "; 88 c += "dseq" + id + "_d" + f.name + ";\n"; 89 } 90 } else { 91 if (!this->ihrs.empty()) { 92 c += computeElasticLimit(this->ihrs, id); 93 } 94 c += this->computeFlowRate(id); 95 c += "fp" + id + " -= (this->dt) * vp" + id + ";\n"; 96 } 97 return c; 98 } // end of ViscoplasticFlowBase::buildFlowImplicitEquations 99 100 ViscoplasticFlowBase::~ViscoplasticFlowBase() = default; 101 102 } // end of namespace bbrick 103 104 } // end of namespace mfront 105