1 /*!
2  * \file   include/MFront/BehaviourBrick/InelasticFlowBase.hxx
3  * \brief
4  * \author Thomas Helfer
5  * \date   15/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 #ifndef LIB_MFRONT_BEHAVIOURBRICK_INELASTICFLOWBASE_HXX
15 #define LIB_MFRONT_BEHAVIOURBRICK_INELASTICFLOWBASE_HXX
16 
17 #include <vector>
18 #include "MFront/StandardElastoViscoPlasticityBrick.hxx"
19 #include "MFront/BehaviourBrick/PorosityEvolutionAlgorithm.hxx"
20 #include "MFront/BehaviourBrick/InelasticFlow.hxx"
21 
22 namespace mfront {
23 
24   namespace bbrick {
25 
26     /*!
27      * \brief an helper class which provide common method for all inelastic
28      * potentials.
29      */
30     struct InelasticFlowBase : InelasticFlow {
31       void initialize(BehaviourDescription&,
32                       AbstractBehaviourDSL&,
33                       const std::string&,
34                       const DataMap&) override;
35 
36       void setPorosityEvolutionHandled(const bool) override;
37 
38       bool isCoupledWithPorosityEvolution() const override;
39 
40       void endTreatment(BehaviourDescription&,
41                         const AbstractBehaviourDSL&,
42                         const StressPotential&,
43                         const std::string&) const override;
44 
45       void completeVariableDeclaration(BehaviourDescription&,
46                                        const AbstractBehaviourDSL&,
47                                        const std::string&) const override;
48       std::vector<OptionDescription> getOptions() const override;
49       bool requiresActivationState() const override;
50       void computeInitialActivationState(BehaviourDescription&,
51                                          const StressPotential&,
52                                          const std::string&) const override;
53       std::string updateNextEstimateOfThePorosityIncrement(
54           const BehaviourDescription&, const std::string&) const override;
55       /*!
56        * \return the code updating the upper bound of the porosity.
57        * If this flow does not affect the porosity growth, the returned
58        * value may be empty. By default, this method calls the
59        * `updatePorosityUpperBound` of the underlying stress criterion.
60        * \param[in] bd: behaviour description
61        * \param[in] id: flow id
62        */
63       std::string updatePorosityUpperBound(const BehaviourDescription&,
64                                            const std::string&) const override;
65       //! destructor
66       ~InelasticFlowBase() override;
67 
68      protected:
69       //! \brief policy on how the porosity affects the flow rule
70       enum PorosityEffectOnFlowRule {
71         /*!
72          * \brief default choice. The effect of the porosity depends
73          * on the stress criterion (see the
74          * `StressCriterion::getPorosityEffectOnEquivalentPlasticStrain` method).
75          */
76         UNDEFINED_POROSITY_EFFECT_ON_EQUIVALENT_PLASTIC_STRAIN,
77         /*!
78          * \brief This value indicate that the flow rule is not affected by the
79          * porosity evolution.
80          */
81         NO_POROSITY_EFFECT_ON_EQUIVALENT_PLASTIC_STRAIN,
82         /*!
83          * \brief This value indicate that the flow rule must be corrected by
84          * the standard \f$(1-f)\f$ factor where \f$f\f$ is the porosity.
85          */
86         STANDARD_POROSITY_CORRECTION_ON_EQUIVALENT_PLASTIC_STRAIN
87       };
88       //! \return the effect of the porosity on the flow rule.
89       virtual PorosityEffectOnFlowRule getPorosityEffectOnEquivalentPlasticStrain() const;
90       //! \return if this flow contributes to porosity growth
91       virtual bool contributesToPorosityGrowth() const;
92       /*!
93        * \brief add the contribution of this inelastic flow to the implicit
94        * equation associated with the porosity evolution.
95        * \param[in] ib: integrator code block
96        * \param[in] dsl: abstract behaviour dsl
97        * \param[in] bd: behaviour description
98        * \param[in] sp: stress potential
99        * \param[in] id: flow id
100        */
101       virtual void
102       addFlowContributionToTheImplicitEquationAssociatedWithPorosityEvolution(
103           CodeBlock&,
104           const BehaviourDescription&,
105           const AbstractBehaviourDSL&,
106           const StressPotential&,
107           const std::string&) const;
108       /*!
109        * \brief compute the effective stress at \f$t+\theta\,dt\f$.
110        * \param[in] id: flow id
111        */
112       virtual std::string computeEffectiveStress(const std::string& id) const;
113       /*!
114        * \param[in] bd: behaviour description
115        * \param[in] sp: stress potential
116        * \param[in] id: flow id
117        * \param[in] b: tells if an analytical jacobian is required
118        */
119       virtual std::string buildFlowImplicitEquations(
120           const BehaviourDescription&,
121           const StressPotential&,
122           const std::string&,
123           const bool) const = 0;
124       //! stress criterion
125       std::shared_ptr<StressCriterion> sc;
126       //! flow criterion
127       std::shared_ptr<StressCriterion> fc;
128       //! isotropic hardening rules
129       std::vector<std::shared_ptr<IsotropicHardeningRule>> ihrs;
130       //! kinematic hardening rules
131       std::vector<std::shared_ptr<KinematicHardeningRule>> khrs;
132       //! Effect of the porosity on the flow rule.
133       PorosityEffectOnFlowRule porosity_effect_on_equivalent_plastic_strain =
134           UNDEFINED_POROSITY_EFFECT_ON_EQUIVALENT_PLASTIC_STRAIN;
135       //! \brief algorithm used to handle the porosity evolution
136       PorosityEvolutionAlgorithm porosity_evolution_algorithm =
137           PorosityEvolutionAlgorithm::STAGGERED_SCHEME;
138       /*!
139        * \brief minimum value of the cosine of the angle between two successive
140        * estimates of the flow direction. If the computed angle is lower than
141        * this threshold, the Newton step is rejected.
142        *
143        * \note the value of this parameter must be in the range [-1:1]. If this
144        * parameter is not in that range (which is the default), the code
145        * checking the value of the cosine is not generated.
146        */
147       double cosine_threshold = 2;
148       /*!
149        * \brief a factor \f$alpha\f$ which gives the threshold below which the
150        * check on the cosine of the angle between two successive
151        * estimates of the flow direction is performed, i.e. the test is
152        * performed if the iteration counter is greater than \f$alpha \cdot
153        * i_{\max{}}\f$ where \f$i_{\max{}}\f$ is the maximum number of
154        * iterations.
155        */
156       double cosine_check_minimum_iteration_factor = 0;
157       /*!
158        * \brief a factor \f$alpha\f$ which gives the threshold upper which the
159        * check on the cosine of the angle between two successive
160        * estimates of the flow direction is performed, i.e. the test is
161        * performed if the iteration counter is below \f$alpha \cdot
162        * i_{\max{}}\f$ where \f$i_{\max{}}\f$ is the maximum number of
163        * iterations.
164        */
165       double cosine_check_maximum_iteration_factor = 1;
166       /*!
167        * \brief flag stating that the porosity evolution is handled by the brick
168        */
169       bool porosity_evolution_explicitely_handled = false;
170       /*!
171        * \brief flag stating if the contribution to the porosity growth
172        * associated with this flow, if any, must be saved in a dedicated
173        * auxiliary state variable.
174        */
175       bool save_porosity_increase = false;
176     };  // end of struct InelasticFlowBase
177 
178   }  // end of namespace bbrick
179 
180 }  // end of namespace mfront
181 
182 #endif /* LIB_MFRONT_BEHAVIOURBRICK_INELASTICFLOWBASE_HXX */
183