1 /*! 2 * \file CyranoSymbolsGenerator.cxx 3 * \brief 4 * \author th202608 5 * \date 19/07/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 #include <ostream> 15 #include "TFEL/Raise.hxx" 16 #include "MFront/BehaviourDescription.hxx" 17 #include "MFront/StandardBehaviourInterface.hxx" 18 #include "MFront/CyranoSymbolsGenerator.hxx" 19 20 namespace mfront { 21 22 CyranoSymbolsGenerator::CyranoSymbolsGenerator() = default; 23 writeAdditionalSymbols(std::ostream &,const StandardBehaviourInterface &,const BehaviourDescription &,const FileDescription &,const std::string &,const Hypothesis) const24 void CyranoSymbolsGenerator::writeAdditionalSymbols( 25 std::ostream&, 26 const StandardBehaviourInterface&, 27 const BehaviourDescription&, 28 const FileDescription&, 29 const std::string&, 30 const Hypothesis) const { 31 } // end of CyranoSymbolsGenerator::writeAdditionalSymbols 32 writeBehaviourTypeSymbols(std::ostream & out,const StandardBehaviourInterface & i,const BehaviourDescription & mb,const std::string & name) const33 void CyranoSymbolsGenerator::writeBehaviourTypeSymbols( 34 std::ostream& out, 35 const StandardBehaviourInterface& i, 36 const BehaviourDescription& mb, 37 const std::string& name) const { 38 auto throw_if = [](const bool b, const std::string& m) { 39 tfel::raise_if( 40 b, "CyranoSymbolsGenerator::writeBehaviourTypeSymbols: " + m); 41 }; 42 out << "MFRONT_SHAREDOBJ unsigned short " 43 << i.getFunctionNameBasis(name) << "_BehaviourType = "; 44 if (mb.getBehaviourType() == 45 BehaviourDescription::STANDARDSTRAINBASEDBEHAVIOUR) { 46 if (mb.isStrainMeasureDefined()) { 47 if (mb.getStrainMeasure() == BehaviourDescription::LINEARISED) { 48 out << "1u;\n\n"; 49 } else if (mb.getStrainMeasure() == BehaviourDescription::HENCKY) { 50 out << "2u;\n\n"; 51 } else { 52 throw_if( 53 true, 54 "the cyrano interface only supports:\n" 55 "- small strain behaviours: the only strain measure " 56 "supported is the HPP one (linearised)\n" 57 "- finite strain behaviours based on the Hencky strain measure"); 58 } 59 } else { 60 out << "1u;\n\n"; 61 } 62 } else { 63 throw_if(true, "unsupported behaviour type"); 64 } 65 } // end of CyranoSymbolsGenerator::writeBehaviourTypeSymbols 66 writeBehaviourKinematicSymbols(std::ostream & out,const StandardBehaviourInterface & i,const BehaviourDescription & mb,const std::string & name) const67 void CyranoSymbolsGenerator::writeBehaviourKinematicSymbols( 68 std::ostream& out, 69 const StandardBehaviourInterface& i, 70 const BehaviourDescription& mb, 71 const std::string& name) const { 72 auto throw_if = [](const bool b, const std::string& m) { 73 if (b) { 74 tfel::raise( 75 "CyranoSymbolsGenerator::writeBehaviourKinematicSymbols: " + 76 m); 77 } 78 }; 79 out << "MFRONT_SHAREDOBJ unsigned short " 80 << i.getFunctionNameBasis(name) << "_BehaviourKinematic = "; 81 if (mb.getBehaviourType() == 82 BehaviourDescription::STANDARDSTRAINBASEDBEHAVIOUR) { 83 if (mb.isStrainMeasureDefined()) { 84 if (mb.getStrainMeasure() == BehaviourDescription::LINEARISED) { 85 out << "1u;\n\n"; 86 } else if (mb.getStrainMeasure() == BehaviourDescription::HENCKY) { 87 out << "4u;\n\n"; 88 } else { 89 throw_if( 90 true, 91 "the cyrano interface only supports:\n" 92 "- small strain behaviours: the only strain measure " 93 "supported is the HPP one (linearised)\n" 94 "- finite strain behaviours based on the Hencky strain measure"); 95 } 96 } else { 97 out << "1u;\n\n"; 98 } 99 } else { 100 throw_if(true, "unsupported behaviour type"); 101 } 102 } // end of CyranoSymbolsGenerator::writeBehaviourKinematicSymbols 103 handleStrainMeasure() const104 bool CyranoSymbolsGenerator::handleStrainMeasure() const{ 105 return true; 106 } // end of CyranoSymbolsGenerator::handleStrainMeasure 107 108 CyranoSymbolsGenerator::~CyranoSymbolsGenerator() = default; 109 110 } // end of namespace mfront 111