1 /*! 2 * \file mfront/include/MFront/AbstractBehaviourDSL.hxx 3 * \brief 4 * 5 * \author Thomas Helfer 6 * \date October 23, 2014 7 * \copyright Copyright (C) 2006-2018 CEA/DEN, EDF R&D. All rights 8 * reserved. 9 * This project is publicly released under either the GNU GPL Licence 10 * or the CECILL-A licence. A copy of thoses licences are delivered 11 * with the sources of TFEL. CEA or EDF may also distribute this 12 * project under specific licensing conditions. 13 */ 14 15 #ifndef LIB_MFRONT_ABSTRACTBEHAVIOURDSL_HXX 16 #define LIB_MFRONT_ABSTRACTBEHAVIOURDSL_HXX 17 18 #include <memory> 19 #include <iosfwd> 20 #include "MFront/MFrontConfig.hxx" 21 #include "TFEL/Material/ModellingHypothesis.hxx" 22 23 #include "MFront/AbstractDSL.hxx" 24 #include "MFront/VariableDescription.hxx" 25 #include "MFront/BehaviourDescription.hxx" 26 #include "MFront/BehaviourDSLDescription.hxx" 27 #include "MFront/MFrontTemplateGenerationOptions.hxx" 28 29 namespace mfront { 30 31 // forward declaration 32 struct MaterialPropertyDescription; 33 34 /*! 35 * Interface class for all domain specific languages. 36 */ 37 struct MFRONT_VISIBILITY_EXPORT AbstractBehaviourDSL 38 : public virtual AbstractDSL { 39 //! a simple alias 40 using MaterialPropertyInput = BehaviourDescription::MaterialPropertyInput; 41 //! constructor 42 AbstractBehaviourDSL() = default; 43 //! a simple alias 44 using ModellingHypothesis = tfel::material::ModellingHypothesis; 45 //! a simple alias 46 using Hypothesis = ModellingHypothesis::Hypothesis; 47 //! \return the target of the dsl 48 DSLTarget getTargetType() const override final; 49 //! \return a description of the DSL 50 virtual BehaviourDSLDescription getBehaviourDSLDescription() const = 0; 51 //! \return the behaviour description 52 virtual const BehaviourDescription& getBehaviourDescription() const = 0; 53 /*! 54 * \brief add the given material properties 55 * \param[in] mps: material properties 56 */ 57 virtual void addMaterialProperties(const VariableDescriptionContainer&) = 0; 58 /*! 59 * \brief add the given parameters 60 * \param[in] params: parameters 61 */ 62 virtual void addParameters(const VariableDescriptionContainer&) = 0; 63 /*! 64 * \brief add the given state variables 65 * \param[in] ivs: state variables 66 */ 67 virtual void addStateVariables(const VariableDescriptionContainer&) = 0; 68 /*! 69 * \brief add the given auxiliary state variables 70 * \param[in] ivs: auxiliary state variables 71 */ 72 virtual void addAuxiliaryStateVariables( 73 const VariableDescriptionContainer&) = 0; 74 /*! 75 * \brief add the given external state variables 76 * \param[in] evs: external state variables 77 */ 78 virtual void addExternalStateVariables( 79 const VariableDescriptionContainer&) = 0; 80 /*! 81 * \brief add the given local state variables 82 * \param[in] lvs: local state variables 83 */ 84 virtual void addLocalVariables(const VariableDescriptionContainer&) = 0; 85 /*! 86 * \brief add the given integration variables 87 * \param[in] lvs: integration variables 88 */ 89 virtual void addIntegrationVariables( 90 const VariableDescriptionContainer&) = 0; 91 /*! 92 * \return a template for the given code block 93 * \param[in] c: code block name 94 * \param[in] o: generation options 95 */ 96 virtual std::string getCodeBlockTemplate( 97 const std::string&, const MFrontTemplateGenerationOptions&) const = 0; 98 /*! 99 * \return the list of hypothesis a priori supported by 100 * the parser. 101 * 102 * To enable other hypothesis or restrict the hypotheses 103 * supported, the user must use the `@ModellingHypothesis` or 104 * `@ModellingHypotheses` keywords. 105 */ 106 virtual std::set<Hypothesis> getDefaultModellingHypotheses() const = 0; 107 /*! 108 * \brief write the call to a material property 109 * \param[out] out: output stream 110 * \param[in] m: material property description 111 * \param[in] f: function converting input variable name. 112 * The function f can be used to specify how evaluate a variable value. 113 * For example, if we want to evaluate the variable name 'V' at 114 * the end of the time step, we could make f return V+dV 115 */ 116 virtual void writeMaterialPropertyEvaluation( 117 std::ostream&, 118 const BehaviourDescription::MaterialProperty&, 119 std::function<std::string(const MaterialPropertyInput&)>&) const = 0; 120 /*! 121 * \brief This function handles a material property treated as a 122 * dependency of the current file. 123 * 124 * This function: 125 * - analyse the given file using the MaterialPropertyDSL 126 * - register the function name generated by the MFront interface 127 * - add the function name to the list of material laws used by 128 * the current file 129 * - declared the headers generated by the MFront interface for inclusion 130 * - launch mfront in a sub-process to generate the source files 131 * associated with this material property and have them compiled 132 * when mandatory (done by the callMFront method). 133 * 134 * \param[in] f : file in which the material law is 135 * implemented. This must be the full path. 136 */ 137 virtual std::shared_ptr<MaterialPropertyDescription> 138 handleMaterialPropertyDescription(const std::string&) = 0; 139 /*! 140 * \return true if the given modelling hypothesis is handled by 141 * the parser 142 * 143 * Some parsers have restrictions on the modelling hypotheses 144 * supported. For example, the isotropic behaviours were not able 145 * to handle plane stress hypotheses when this comment was 146 * written(but it was planned, so this comment may be outdated 147 * now). 148 * 149 * The fact that this method returns true means that the user 150 * *can* provide code to support this modelling hypothesis. For 151 * example, to support plane stress in RungeKutta and Implicit 152 * parsers, the user must provide some hand-crafted code. He must 153 * enable this modelling hypothesis by calling explicitely 154 * `@ModellingHypothesis` or `@ModellingHypotheses` keywords. 155 */ 156 virtual bool isModellingHypothesisSupported(const Hypothesis) const = 0; 157 //! destructor 158 ~AbstractBehaviourDSL() override; 159 }; 160 161 } // end of namespace mfront 162 163 #endif /* LIB_MFRONT_ABSTRACTBEHAVIOURDSL_HXX */ 164