1 /*!
2  * \file   StressPotential.hxx
3  * \brief
4  * \author Thomas Helfer
5  * \date   20/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  * <!-- Local IspellDict: english -->
13  */
14 
15 #ifndef LIB_MFRONT_BEHAVIOURBRICK_STRESSPOTENTIAL_HXX
16 #define LIB_MFRONT_BEHAVIOURBRICK_STRESSPOTENTIAL_HXX
17 
18 #include <map>
19 #include <string>
20 #include <vector>
21 #include "TFEL/Material/ModellingHypothesis.hxx"
22 #include "MFront/MFrontConfig.hxx"
23 #include "MFront/VariableDescription.hxx"
24 #include "MFront/BehaviourDescription.hxx"
25 
26 namespace tfel {
27   namespace utilities {
28     // forward declaration
29     struct Data;
30   }  // end of namespace utilities
31 }  // end of namespace tfel
32 
33 namespace mfront {
34 
35   // forward declaration
36   struct AbstractBehaviourDSL;
37 
38   namespace bbrick {
39 
40     // forward declaration
41     struct OptionDescription;
42 
43     //! \brief class describing the computation of the stress.
44     struct MFRONT_VISIBILITY_EXPORT StressPotential {
45       //! \brief a simple alias
46       using DataMap = std::map<std::string, tfel::utilities::Data>;
47       //! \brief a simple alias
48       using ModellingHypothesis = tfel::material::ModellingHypothesis;
49       //! \brief a simple alias
50       using Hypothesis = ModellingHypothesis::Hypothesis;
51       //! \brief a simple alias
52       using BehaviourSymmetry = mfront::BehaviourSymmetryType;
53       //! \brief a simple alias
54       using MaterialProperty = BehaviourDescription::MaterialProperty;
55       //! \return the name of the stress potential
56       virtual std::string getName() const = 0;
57       /*!
58        * \param[in] bd: behavour description
59        * \param[in] b: if true, all options are returned. Otherwise, only the
60        * most adapted options for the behaviour are returned.
61        * \return the stress potential option description
62        */
63       virtual std::vector<OptionDescription> getOptions(
64           const BehaviourDescription&, const bool) const = 0;
65       /*!
66        * \param[in,out] bd: behaviour description
67        * \param[in,out] dsl: abstract behaviour dsl
68        * \param[in] d: options
69        */
70       virtual void initialize(BehaviourDescription&,
71                               AbstractBehaviourDSL&,
72                               const DataMap&) = 0;
73       /*!
74        * \brief This method returns the list of supported modelling
75        * hypotheses that are supported by the stress potential.
76        *
77        * This method is called after the input file processing. Two
78        * cases may arise:
79        * - if the user has specified a list of supported modelling
80        *   hypotheses, this list is used to check if the user's request
81        *   can be fulfilled. If the stress potential returns an empty list, it
82        *   means that the stress potential does not have any restriction.
83        * - if the user has not specified the list of supported modelling
84        *   hypotheses, this method is used to select a list of supported
85        *   modelling hypotheses. If the stress potential returns an empty list,
86        *   it means that the stress potential does not participate to the
87        *   modelling hypotheses selection. If all the stress potentials returns
88        *   an empty list, a set of default modelling hypotheses is selected.
89        *
90        * \param[in/out] bd: behaviour description
91        * \param[in] dsl: abstract behaviour dsl
92        */
93       virtual std::vector<Hypothesis> getSupportedModellingHypotheses(
94           const BehaviourDescription&, const AbstractBehaviourDSL&) const = 0;
95       /*!
96        * \brief complete the variable description
97        * \param[in] dsl: abstract behaviour dsl
98 
99        */
100       virtual void completeVariableDeclaration(
101           BehaviourDescription&, const AbstractBehaviourDSL&) const = 0;
102       /*!
103        * \brief method called at the end of the input file processing
104        * \param[in/out] bd: behaviour description
105        * \param[in] dsl: abstract behaviour dsl
106        */
107       virtual void endTreatment(BehaviourDescription&,
108                                 const AbstractBehaviourDSL&) const = 0;
109       /*!
110        * \return a vector of tuples giving information about the stress
111        * derivatives. Each tuple contains:
112        * - the expression of the stress derivative.
113        * - the name of the variable with respect to which, the stress has been
114        *   derived.
115        * - the type of the variable with respect to which, the stress has been
116        *   derived.
117        * \param[in] bd: behaviour description
118        */
119       virtual std::vector<std::tuple<std::string,
120                                      std::string,
121                                      mfront::SupportedTypes::TypeFlag>>
122       getStressDerivatives(const BehaviourDescription& bd) const = 0;
123       /*!
124        * \brief write the jacobian blocks corresponding the derivative of
125        * implicit equation associated with a variable \f$v\f$ knowing the
126        * derivative of \f$\frac{d\,v}{d\underline{s}}\f$ where
127        * \f$\underline{s}\f$ is the effective stress.
128        * \param[in, out] bd: behaviour description
129        * \param[in] t: variable type
130        * \param[in] v: variable name
131        * \param[in] dfv_ds: derivative of the implicit equation associated
132        * to v
133        * with respect to the effective stress
134        * \param[in] b: boolean static that the flow criterion is deviatoric
135        */
136       virtual std::string generateImplicitEquationDerivatives(
137           const BehaviourDescription&,
138           const std::string&,
139           const std::string&,
140           const std::string&,
141           const bool) const = 0;
142       /*!
143        * \brief add the lines that defines `sigel`, the elastic prediction of
144        * the stress. This definition is added
145        * to the `BehaviourData::BeforeInitializeLocalVariables` code block.
146        * \param[in/out] bd: behaviour description
147        */
148       virtual void computeElasticPrediction(BehaviourDescription&) const = 0;
149       /*!
150        * \brief return an expression that can be used to normalise implicit
151        * equations of the order of the stress
152        * \param[in] bd: behaviour description
153        */
154       virtual std::string getStressNormalisationFactor(
155           const BehaviourDescription&) const = 0;
156       /*!
157        * \brief return an expression that can be used as a lower bound for the
158        * equivalent stress,
159        * \param[in] bd: behaviour description
160        */
161       virtual std::string getEquivalentStressLowerBound(
162           const BehaviourDescription&) const = 0;
163       //! destructor
164       virtual ~StressPotential();
165     };  // end of struct StressPotential
166 
167   }  // end of namespace bbrick
168 
169 }  // end of namespace mfront
170 
171 #endif /* LIB_MFRONT_BEHAVIOURBRICK_STRESSPOTENTIAL_HXX */
172