1 /*!
2  * \file   mfront/include/MFront/CalculiXInterface.hxx
3  * \brief  This file declares the CalculiXInterface class
4  * \author Thomas Helfer
5  * \date   17 Jan 2007
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_CALCULIXINTERFACE_HXX
15 #define LIB_MFRONT_CALCULIXINTERFACE_HXX
16 
17 #include<string>
18 #include<iosfwd>
19 
20 #include"TFEL/Utilities/CxxTokenizer.hxx"
21 #include"MFront/UMATInterfaceBase.hxx"
22 
23 namespace mfront{
24 
25   /*!
26    * \brief the interface the CalculiX Standard finite element solver
27    */
28   struct CalculiXInterface
29     : public UMATInterfaceBase
30   {
31     //! name of finite strain strategy attribute
32     static const char *const finiteStrainStrategy;
33     //! \return the name of the interface
34     static std::string getName();
35     /*!
36      * \return true if a finite strain strategy has been set up
37      * \param[in] bd: behaviour description
38      */
39     static bool hasFiniteStrainStrategy(const BehaviourDescription&);
40     /*!
41      * \param[in,out] mb: behaviour description
42      * \param[in] k  : keyword treated
43      * \param[in] i:   list of interfaces to which the keyword is restricted
44      * \param[in] p  : iterator to the current token
45      * \param[in] pe : iterator past the end of the file
46      * \return a pair. The first entry is true if the keyword was
47      * treated by the interface. The second entry is an iterator after
48      * the last token treated.
49      */
50     std::pair<bool,tokens_iterator>
51     treatKeyword(BehaviourDescription&,
52 		 const std::string&,
53 		 const std::vector<std::string>&,
54 		 tokens_iterator,
55 		 const tokens_iterator) override;
56     /*!
57      * \brief write output files
58      * \param[in] mb        : mechanical behaviour description
59      * \param[in] fd        : mfront file description
60      */
61     void endTreatment(const BehaviourDescription&,
62 		      const FileDescription&) const override;
63     /*!
64      * \param[out] d  : target description
65      * \param[out] bd : behaviour description
66      */
67     void getTargetsDescription(TargetsDescription&,
68 			       const BehaviourDescription&) override;
69     //! destructor
70     ~CalculiXInterface() override;
71 
72   protected:
73 
74     std::string getInterfaceName() const override;
75     /*!
76      * \brief write the initialisation of a driving variables
77      * \param[in] os : output file
78      * \param[in] v  : variable to be initialised
79      * \param[in] o  : variable offsert
80      */
81     virtual void
82     writeBehaviourDataGradientSetter(std::ostream&,
83 					    const Gradient&,
84 					    const SupportedTypes::TypeSize) const override;
85     /*!
86      * \brief write the initialisation of a driving variables
87      * \param[in] os : output file
88      * \param[in] v  : variable to be initialised
89      * \param[in] o  : variable offsert
90      */
91     virtual void
92     writeIntegrationDataGradientSetter(std::ostream&,
93 					      const Gradient&,
94 					      const SupportedTypes::TypeSize) const override;
95     /*!
96      * \brief write the instruction of exporting a thermodynamic force in an array
97      * \param[out] out : output stream
98      * \param[in]  a   : array name
99      * \param[in]  f   : thermodynamic force
100      * \param[in]  o   : thermodynamic force offset
101      */
102     virtual void
103     exportThermodynamicForce(std::ostream&,
104 			     const std::string&,
105 			     const ThermodynamicForce&,
106 			     const SupportedTypes::TypeSize) const override;
107     /*!
108      * write interface specific includes
109      * \param[in] out : output file
110      * \param[in] mb  : mechanical behaviour description
111      */
112     virtual void
113     writeInterfaceSpecificIncludes(std::ostream&,
114 				   const BehaviourDescription&) const override;
115     /*!
116      * \brief write the initialisation of a thermodynamic force
117      * \param[in] os : output file
118      * \param[in] v  : variable to be initialised
119      * \param[in] o  : variable offsert
120      */
121     void writeBehaviourDataThermodynamicForceSetter(
122         std::ostream &,
123         const ThermodynamicForce &,
124         const SupportedTypes::TypeSize) const override;
125     /*!
126      * \brief write the call to the base function
127      * \param[in] out:  output file
128      * \param[in] mb:   mechanical behaviour description
129      * \param[in] name: name of the behaviour as defined by interface
130      *                  (generally taking into account the material
131      *                  and the behaviour name)
132      * \param[in] sfeh: name of the function used to handle the stress
133      *                  expansion
134      */
135     virtual void writeFunctionBase(std::ostream&,
136 				   const BehaviourDescription&,
137 				   const std::string&,
138 				   const std::string&) const;
139     /*!
140      * \brief write the call to the base function
141      * \param[in] out:  output file
142      * \param[in] mb:   mechanical behaviour description
143      * \param[in] name: name of the behaviour as defined by interface
144      *                  (generally taking into account the material
145      *                  and the behaviour name)
146      */
147     virtual void
148     writeSmallStrainFunction(std::ostream&,
149 			     const BehaviourDescription&,
150 			     const std::string&) const;
151     /*!
152      * \brief write the integration of a "true" finite strain
153      * behaviour, i.e. a finite strain behaviour not associated to a
154      * finite strain strategy.
155      * \param[in] out:  output file
156      * \param[in] mb:   mechanical behaviour description
157      * \param[in] name: name of the behaviour as defined by interface
158      *                  (generally taking into account the material
159      *                  and the behaviour name)
160      */
161     virtual void
162     writeFiniteStrainFunction(std::ostream&,
163 			      const BehaviourDescription&,
164 			      const std::string&) const;
165     /*!
166      * \brief integrate the behaiour using the
167      * `FiniteRotationSmallStrain` finite strain strategy.
168      * \param[in] out:  output file
169      * \param[in] mb:   mechanical behaviour description
170      * \param[in] name: name of the behaviour as defined by interface
171      *                  (generally taking into account the material
172      *                  and the behaviour name)
173      */
174     virtual void
175     writeFiniteRotationSmallStrainFunction(std::ostream&,
176 					   const BehaviourDescription&,
177 					   const std::string&) const;
178     /*!
179      * \brief integrate the behaiour using the
180      * `MieheApelLambrechtLogarithmiSstrain` finite strain strategy.
181      * \param[in] out:  output file
182      * \param[in] mb:   mechanical behaviour description
183      * \param[in] name: name of the behaviour as defined by interface
184      *                  (generally taking into account the material
185      *                  and the behaviour name)
186      */
187     virtual void
188     writeMieheApelLambrechtLogarithmicStrainFunction(std::ostream&,
189 						     const BehaviourDescription&,
190 						     const std::string&) const;
191     std::string getLibraryName(const BehaviourDescription &) const override;
192     void writeCalculiXBehaviourTraits(std::ostream &,
193                                       const BehaviourDescription &) const;
194     void writeMTestFileGeneratorSetModellingHypothesis(
195         std::ostream &) const override;
196     std::string getModellingHypothesisTest(const Hypothesis) const override;
197     std::map<UMATInterfaceBase::Hypothesis, std::string>
198     gatherModellingHypothesesAndTests(
199         const BehaviourDescription &) const override;
200     std::string getFunctionNameBasis(
201         const std::string &) const override;
202     std::set<Hypothesis> getModellingHypothesesToBeTreated(
203         const BehaviourDescription &) const override;
204     /*!
205      * \return the input file example
206      * \param[in] mb: behaviour description
207      * \param[in] fd: file description
208      * \param[in] b: if true, write the example for
209      * CalculiX-Standard. If false, write the example for
210      * CalculiX-Explicit
211      */
212     virtual void
213     writeInputFileExample(const BehaviourDescription&,
214 			  const FileDescription&,
215 			  const bool) const;
216     //! \return true if the interface handles external state variables
217     bool areExternalStateVariablesSupported() const override;
218     //! \return true if the interface handles temperature increment
219     bool isTemperatureIncrementSupported() const override;
220   }; // end of CalculiXInterface
221 
222 } // end of namespace mfront
223 
224 #endif /* LIB_MFRONT_CALCULIXINTERFACE_HXX */
225