1 /*!
2  * \file   mfront/includes/MFront/StandardElastoViscoPlasticityBrick.hxx
3  * \brief
4  * \author Thomas Helfer
5  * \date   15/03/2018
6  */
7 
8 #ifndef LIB_MFRONT_STANDARDELASTOVISCOPLASTICITYBRICK_HXX
9 #define LIB_MFRONT_STANDARDELASTOVISCOPLASTICITYBRICK_HXX
10 
11 #include <map>
12 #include <string>
13 #include <memory>
14 #include "MFront/CodeBlock.hxx"
15 #include "MFront/BehaviourBrickBase.hxx"
16 #include "MFront/BehaviourBrick/PorosityEvolutionAlgorithm.hxx"
17 
18 namespace mfront {
19 
20   namespace bbrick {
21     // forward declaration
22     struct StressPotential;
23     // forward declaration
24     struct InelasticFlow;
25     // forward declaration
26     struct PorosityNucleationModel;
27   }  // end of namespace bbrick
28 
29   /*!
30    * \brief The `StandardElastoViscoPlasticityBrick` is meant to describe a
31    * behaviour based on:
32    * - a stress potential describing how the stress is computed. The most
33    *   used one will probably be the `Hooke` stress potential.
34    * - a list of inelastic flows which describe how inelastic strains evolve.
35    */
36   struct StandardElastoViscoPlasticityBrick : public BehaviourBrickBase {
37     /*!
38      * \brief if the staggered algorithm is used to treat the porosity
39      * evolution, this variable gives the name of a boolean variable which can
40      * is false during the iteration of the staggered algorithm and set to true
41      * once the staggered algorithm has converged.
42      *
43      * The rationale behing this is that the exact jacobian of the full system
44      * of implicit equations is required to compute the consistent tangent
45      * operator. Thus, once the staggered algorithm has converged, this jacobian
46      * must be built. This flag allows to switch from a reduced system of
47      * equations to the full system of equations.
48      */
49     static const char* const computeStandardSystemOfImplicitEquations;
50     /*!
51      * \brief if the staggered approach is used, this is the name of an
52      * auxiliary state variable which states if the material point is
53      * totally damaged. If this variable is equal to 0, then the material is
54      * still able to sustain stress. If this variable is equal to 1, the
55      * material is totally damaged.
56      */
57     static const char* const brokenVariable;
58     /*!
59      * \brief if the staggered approach is used, this is the name of a
60      * local variable which states if the staggered approach succeeded.
61      */
62     static const char* const fixedPointConverged;
63     /*!
64      * \brief if the staggered approach is used, this is the name of a
65      * local variable which holds the current estimate of the porosity
66      * increment.
67      */
68     static const char* const currentEstimateOfThePorosityIncrement;
69     /*!
70      * \brief if the staggered approach is used, this is the name of a variable
71      * which holds a next estimate of the porosity increment.
72      */
73     static const char* const nextEstimateOfThePorosityIncrement;
74     /*!
75      * \brief if the staggered approach is used, this is the name of a variable
76      * which holds a next estimate of the porosity at the end of the time step.
77      */
78     static const char* const nextEstimateOfThePorosityAtTheEndOfTheTimeStep;
79     /*!
80      * \brief this is the name of a variable which holds the upper bound of the
81      * porosity.
82      */
83     static const char* const porosityUpperBound;
84     /*!
85      * \brief this is the name of a parameter which holds a safety factor for
86      * the porosity upper bound, because most of the stress criteria becomes
87      * singular when the associated upper bound is reached.
88      */
89     static const char* const porosityUpperBoundSafetyFactor;
90     /*!
91      * \brief this is the name of a parameter which holds a safety factor for
92      * the porosity upper bound when trying to detect the fracture of the
93      * material.
94      */
95     static const char* const porosityUpperBoundSafetyFactorForFractureDetection;
96     /*!
97      * \brief if the staggered approach is used, this is the name of a
98      * variable
99      * which holds the difference between the new and the current estimates
100      * of
101      * the porosity increment.
102      */
103     static const char* const
104         differenceBetweenSuccessiveEstimatesOfThePorosityIncrement;
105     /*!
106      * \brief if the staggered approach is used, this is the name of a parameter
107      * which holds the value of criterion on the difference between the new and
108      * the current estimates of the porosity increment used to stop the
109      * staggered scheme.
110      */
111     static const char* const staggeredSchemeConvergenceCriterion;
112     /*!
113      * \brief if the staggered approach is used, this is the name of a local
114      * variable which holds the number of iterations of the staggered scheme
115      * already performed.
116      */
117     static const char* const staggeredSchemeIterationCounter;
118     /*!
119      * \brief if the staggered approach is used, this is the name of a parameter
120      * which holds the maximum number of iterations of the staggered scheme.
121      */
122     static const char* const maximumNumberOfIterationsOfTheStaggeredScheme;
123     /*!
124      * \brief if the staggered approach is used, this is the name of a
125      * instance of the `tfel::math::BissectionAlgorithmBase` class.
126      */
127     static const char* const staggeredSchemeBissectionAlgorithm;
128     /*!
129      * \brief if the staggered approach is used and that the acceleration
130      * algorithm used is the Aitken one, this is the name of a
131      * instance of the `tfel::math::AitkenAccelerationAlgorithm` class.
132      */
133     static const char* const staggeredSchemeAitkenAccelerationAlgorithm;
134     /*!
135      * \brief constructor
136      * \param[in] dsl_ : calling domain specific language
137      * \param[in] bd_  : behaviour description
138      */
139     StandardElastoViscoPlasticityBrick(AbstractBehaviourDSL&,
140                                        BehaviourDescription&);
141     std::string getName() const override;
142     BehaviourBrickDescription getDescription() const override;
143     std::vector<bbrick::OptionDescription> getOptions(
144         const bool) const override;
145     void initialize(const Parameters&, const DataMap&) override;
146     std::vector<Hypothesis> getSupportedModellingHypotheses() const override;
147     void completeVariableDeclaration() const override;
148     void endTreatment() const override;
149     //! destructor
150     ~StandardElastoViscoPlasticityBrick() override;
151 
152    private:
153     /*!
154      * \brief method part of the `initialize` method which treats the
155      * `porosity_evolution` section.
156      * \param[in] e: data declared in the `porosity_evolution` section.
157      * \return if the porosity evolution
158      */
159     bool treatPorosityEvolutionSection(const Data&);
160     /*!
161      * \brief method part of the `treatPorosityEvolutionAlgorithmSection` method
162      * which treats the `algorithm` subsection of the `porosity_evolution`
163      * section.
164      * \param[in] d: data declared in the algorithm subsection of the
165      * `porosity_evolution` section.
166      */
167     void treatPorosityEvolutionAlgorithmSection(const Data&);
168     /*!
169      * \brief extract the parameters associated with the staggered scheme
170      * \param[in] algorithm_parameters: parameters
171      */
172     void treatStaggeredPorosityEvolutionAlgorithmParameters(const DataMap&);
173     //! \return if a coupling with the porosity evolution is required
174     bool isCoupledWithPorosityEvolution() const;
175     /*!
176      * \brief add the contribution of this inelastic flow to the implicit
177      * equation associated with the porosity evolution.
178      * \param[in] ib: integrator code block
179      */
180     void
181     addElasticContributionToTheImplicitEquationAssociatedWithPorosityEvolution(
182         CodeBlock&) const;
183     //! \return a map associating a map and its idea
184     std::map<std::string, std::shared_ptr<bbrick::InelasticFlow>>
185     buildInelasticFlowsMap() const;
186     //! \brief stress potential
187     std::shared_ptr<bbrick::StressPotential> stress_potential;
188     //! \brief inelastic flows
189     std::vector<std::shared_ptr<bbrick::InelasticFlow>> flows;
190     //! \brief nucleation models
191     std::vector<std::shared_ptr<bbrick::PorosityNucleationModel>>
192         nucleation_models;
193     /*!
194      * \brief porosity growth policy
195      *
196      * By default, no porosity growth is considered if no inelastic flow is
197      * coupled with the porosity evolution, even though some inelastic flows
198      * are not purely deviatoric.
199      *
200      * However, if a `porosity_evolution` section is defined, then standard
201      * growth of the porosity is considered, i.e. each inelastic flow
202      * which is not purely deviatoric contributes to the porosity growth by
203      * the standard term:
204      * \f[
205      * \left(1-f\right)\,\mathop{trace}\left(\underline{\dot{\varepsilon}}^{p}\)
206      * \f]
207      */
208     enum {
209       UNDEFINEDPOROSITYGROWTHPOLICY,
210       STANDARDVISCOPLASTICPOROSITYGROWTHPOLICY
211     } porosity_growth_policy = UNDEFINEDPOROSITYGROWTHPOLICY;
212     //! \brief algorithm used to handle the porosity evolution
213     mfront::bbrick::PorosityEvolutionAlgorithm porosity_evolution_algorithm =
214         mfront::bbrick::PorosityEvolutionAlgorithm::STAGGERED_SCHEME;
215     //! \brief structure holding the parameters for the staggered scheme
216     struct StaggeredSchemeParameters {
217       /*!
218        * \brief value used to check if the values of the porosity between two
219        * iterations of the staggered scheme are almost identical, i.e. that
220        * the
221        * value of the porosity has become stationnary.
222        */
223       double convergence_criterion = 1e-10;
224       //! \brief maximum number of iterations of the staggered scheme
225       unsigned short maximum_number_of_iterations = 100;
226       /*!
227        * \brief list of possible acceleration algorithm
228        */
229       enum AccelerationAlgorithm {
230         RELAXATION,
231         AITKEN
232       };  // end of enum AccelerationAlgorithm
233           //! \brief selected acceleration algorithm
234       AccelerationAlgorithm acceleration_algorithm = AITKEN;
235     };  // end of  struct StaggeredSchemeParameters
236     //! \brief parameters for the staggered scheme
237     StaggeredSchemeParameters staggered_scheme_parameters;
238     /*!
239      * \brief a boolean stating if the elastic contribution to the porosity
240      * growth must be taken into account.
241      */
242     bool elastic_contribution = false;
243   };  // end of StandardElastoViscoPlasticityBrick
244 
245 }  // end of namespace mfront
246 
247 #endif /* LIB_MFRONT_STANDARDELASTOVISCOPLASTICITYBRICK_HXX */
248