1 /*! 2 * \file mfront/src/AnsysInterfaceExceptions.cxx 3 * \brief This file implements the AnsysInterfaceExceptions class. 4 * \author Thomas Helfer 5 * \date 12/12/2011 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<cstdlib> 15 #include<sstream> 16 #include<iostream> 17 18 #include "TFEL/Raise.hxx" 19 #include "MFront/Ansys/AnsysInterfaceExceptions.hxx" 20 21 namespace ansys{ 22 23 void throwUnMatchedNumberOfMaterialProperties(const std::string & b,const unsigned short n1,const AnsysInt n2)24 AnsysInterfaceExceptions::throwUnMatchedNumberOfMaterialProperties(const std::string& b, 25 const unsigned short n1, 26 const AnsysInt n2) 27 { 28 std::ostringstream msg; 29 msg << "AnsysInterfaceExceptions::throwUnMatchedNumberOfMaterialProperties : " 30 << "the number of material properties does not match. The behaviour '" 31 << b << "' requires " << n1 << " material properties, and " 32 << n2 << " material properties were declared"; 33 tfel::raise<AnsysException>(msg.str()); 34 } // end of throwUnMatchedNumberOfMaterialProperties 35 36 void throwUnMatchedNumberOfStateVariables(const std::string & b,const unsigned short n1,const AnsysInt n2)37 AnsysInterfaceExceptions::throwUnMatchedNumberOfStateVariables(const std::string& b, 38 const unsigned short n1, 39 const AnsysInt n2) 40 { 41 std::ostringstream msg; 42 msg << "AnsysInterfaceExceptions::throwUnMatchedNumberOfStateVariables : " 43 << "the number of internal state variables does not match. The behaviour '" 44 << b << "' requires " << n1 << " state variables, and " 45 << n2 << " state variables were declared"; 46 tfel::raise<AnsysException>(msg.str()); 47 } // end of throwUnMatchedNumberOfStateVariables 48 49 void treatAnsysException(const std::string & b,const AnsysException & e)50 AnsysInterfaceExceptions::treatAnsysException(const std::string& b, 51 const AnsysException& e) 52 { 53 std::cout << "The behaviour '" << b 54 << "' has thrown an AnsysException : " 55 << e.what() << std::endl; 56 } // end of AnsysInterfaceExceptions::treatAnsysException 57 58 void treatMaterialException(const std::string & b,const tfel::material::MaterialException & e)59 AnsysInterfaceExceptions::treatMaterialException(const std::string& b, 60 const tfel::material::MaterialException& e) 61 { 62 std::cout << "The behaviour '" << b 63 << "' has thrown an MaterialException : " 64 << e.what() << std::endl; 65 } // end of treatMaterialException 66 67 void treatTFELException(const std::string & b,const tfel::exception::TFELException & e)68 AnsysInterfaceExceptions::treatTFELException(const std::string& b, 69 const tfel::exception::TFELException& e) 70 { 71 std::cout << "The behaviour '" << b 72 << "' has thrown a generic tfel exception : " 73 << e.what() << std::endl; 74 } // end of treatTFELException 75 76 void treatStandardException(const std::string & b,const std::exception & e)77 AnsysInterfaceExceptions::treatStandardException(const std::string& b, 78 const std::exception& e) 79 { 80 std::cout << "The behaviour '" << b 81 << "' has thrown a generic standard exception : " 82 << e.what() << std::endl; 83 } // end of treatStandardException 84 85 void treatUnknownException(const std::string & b)86 AnsysInterfaceExceptions::treatUnknownException(const std::string& b) 87 { 88 std::cout << "The behaviour '" << b 89 << "' has thrown an unknown exception" << std::endl; 90 } // end of treatUnknownException 91 92 void throwNegativeTimeStepException(const std::string & b)93 AnsysInterfaceExceptions::throwNegativeTimeStepException(const std::string& b) 94 { 95 tfel::raise("AnsysInterfaceExceptions::throwNegativeTimeStepException: " 96 "negative time step detected for behaviour '"+b+"'"); 97 } // end of AnsysInterfaceExceptions::throwNegativeTimeStepException 98 99 void throwPredictionComputationFailedException(const std::string & b)100 AnsysInterfaceExceptions::throwPredictionComputationFailedException(const std::string& b) 101 { 102 tfel::raise("AnsysInterfaceExceptions::throwPredictionComputationFailedException: " 103 "prediction computation failed for behaviour '"+b+"'"); 104 } 105 106 void throwPredictionOperatorIsNotAvalaible(const std::string & b)107 AnsysInterfaceExceptions::throwPredictionOperatorIsNotAvalaible(const std::string& b) 108 { 109 tfel::raise("AnsysInterfaceExceptions::throwPredictionOperatorIsNotAvalaible: " 110 "behaviour '"+b+"' can't compute a prediction operator"); 111 } // end of AnsysInterfaceExceptions::throwBehaviourIntegrationFailedException 112 113 void throwConsistentTangentOperatorIsNotAvalaible(const std::string & b)114 AnsysInterfaceExceptions::throwConsistentTangentOperatorIsNotAvalaible(const std::string& b) 115 { 116 tfel::raise("AnsysInterfaceExceptions::throwConsistentTangentOperatorIsNotAvalaible: " 117 "behaviour '"+b+"' can't compute a consistent tangent operator"); 118 } // end of AnsysInterfaceExceptions::throwBehaviourIntegrationFailedException 119 120 void throwUnsupportedStressFreeExpansionException(const std::string & b)121 AnsysInterfaceExceptions::throwUnsupportedStressFreeExpansionException(const std::string& b) 122 { 123 tfel::raise("AnsysInterfaceExceptions::throwUnsupportedStressFreeExpansionException: " 124 "behaviour '"+b+"' can handle stress-free expansion but the Ansys interface can't"); 125 } // end of AnsysInterfaceExceptions::throwUnsupportedStressFreeExpansionException 126 127 void displayUnsupportedHypothesisMessage()128 AnsysInterfaceExceptions::displayUnsupportedHypothesisMessage() 129 { 130 std::cout << "AnsysInterfaceExceptions::displayUnsupportedHypothesisMessage : " 131 << "unsupported hypothesis" << std::endl; 132 } 133 134 void exe(const AnsysReal * const,const AnsysReal * const,AnsysReal * const,const AnsysReal * const,const AnsysReal * const,const AnsysReal * const,const AnsysReal * const,const AnsysReal * const,const AnsysInt * const,const AnsysReal * const,const AnsysReal * const,AnsysReal * const,const AnsysInt * const,AnsysReal * const,const StressFreeExpansionHandler<AnsysReal> &)135 AnsysUnSupportedCaseHandler::exe(const AnsysReal *const, 136 const AnsysReal *const, 137 AnsysReal *const, 138 const AnsysReal *const, 139 const AnsysReal *const, 140 const AnsysReal *const, 141 const AnsysReal *const, 142 const AnsysReal *const, 143 const AnsysInt *const, 144 const AnsysReal *const, 145 const AnsysReal *const, 146 AnsysReal *const, 147 const AnsysInt *const, 148 AnsysReal *const, 149 const StressFreeExpansionHandler<AnsysReal>&) 150 { 151 tfel::raise("AnsysUnSupportedCaseHandler::exe : " 152 "we fall in a case that the ansys interface " 153 "is not able to handle."); 154 } // end of exe 155 156 } // end of namespace ansys 157