1 /*!
2  * \file   AbaqusExplicitSymbolsGenerator.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/AbaqusExplicitInterface.hxx"
19 #include "MFront/AbaqusExplicitSymbolsGenerator.hxx"
20 
21 namespace mfront {
22 
23   AbaqusExplicitSymbolsGenerator::AbaqusExplicitSymbolsGenerator() = default;
24 
25   void AbaqusExplicitSymbolsGenerator::writeAdditionalSymbols(
26       std::ostream&,
27       const StandardBehaviourInterface&,
28       const BehaviourDescription&,
29       const FileDescription&,
30       const std::string&,
31       const Hypothesis) const {
32   }  // end of AbaqusExplicitSymbolsGenerator::writeAdditionalSymbols
33 
34   void AbaqusExplicitSymbolsGenerator::writeSpecificSymbols(
35       std::ostream& out,
36       const StandardBehaviourInterface& i,
37       const BehaviourDescription& mb,
38       const FileDescription&,
39       const std::string& name) const {
40     if(mb.getSymmetryType()==mfront::ORTHOTROPIC){
41       if(!mb.hasAttribute(AbaqusExplicitInterface::orthotropyManagementPolicy)){
42 	out << "MFRONT_SHAREDOBJ unsigned short " << i.getFunctionNameBasis(name)
43 	    << "_OrthotropyManagementPolicy = 0u;\n\n";
44       } else {
45 	const auto omp =
46 	  mb.getAttribute<std::string>(AbaqusExplicitInterface::orthotropyManagementPolicy);
47 	if(omp=="MFront"){
48 	  out << "MFRONT_SHAREDOBJ unsigned short " << i.getFunctionNameBasis(name)
49 	      << "_OrthotropyManagementPolicy = 2u;\n\n";
50 	} else if(omp=="Native"){
51 	  out << "MFRONT_SHAREDOBJ unsigned short " << i.getFunctionNameBasis(name)
52 	      << "_OrthotropyManagementPolicy = 1u;\n\n";
53 	} else {
54 	  tfel::raise("AbaqusExplicitSymbolsGenerator::writeSpecificSymbols: "
55 		      "unsupported orthotropy management policy");
56 	}
57       }
58     }
59   } // end of AbaqusExplicitSymbolsGenerator::writeSpecificSymbols
60 
61   void AbaqusExplicitSymbolsGenerator::writeBehaviourTypeSymbols(
62       std::ostream& out,
63       const StandardBehaviourInterface& i,
64       const BehaviourDescription& mb,
65       const std::string& name) const {
66     out << "MFRONT_SHAREDOBJ unsigned short " << i.getFunctionNameBasis(name)
67 	<< "_BehaviourType = " ;
68     if(mb.getBehaviourType()==BehaviourDescription::STANDARDSTRAINBASEDBEHAVIOUR){
69       tfel::raise_if(!AbaqusInterfaceBase::hasFiniteStrainStrategy(mb),
70                      "AbaqusExplicitSymbolsGenerator::writeBehaviourTypeSymbols: "
71                      "behaviours written in the small strain framework "
72                      "must be embedded in a strain strategy");
73       out << "2u;\n\n";
74     } else if(mb.getBehaviourType()==BehaviourDescription::STANDARDFINITESTRAINBEHAVIOUR){
75       out << "2u;\n\n";
76     } else {
77       tfel::raise("AbaqusExplicitSymbolsGenerator::writeBehaviourTypeSymbols: "
78 		  "unsupported behaviour type");
79     }
80   } // end of AbaqusExplicitSymbolsGenerator::writeBehaviourTypeSymbols
81 
82   void AbaqusExplicitSymbolsGenerator::writeBehaviourKinematicSymbols(
83       std::ostream& out,
84       const StandardBehaviourInterface& i,
85       const BehaviourDescription& mb,
86       const std::string& name) const {
87     out << "MFRONT_SHAREDOBJ unsigned short " << i.getFunctionNameBasis(name)
88 	<< "_BehaviourKinematic = " ;
89     if(mb.getBehaviourType()==BehaviourDescription::STANDARDSTRAINBASEDBEHAVIOUR){
90       tfel::raise_if(!AbaqusInterfaceBase::hasFiniteStrainStrategy(mb),
91 		     "AbaqusExplicitSymbolsGenerator::writeBehaviourKinematicSymbols: "
92 		     "behaviours written in the small strain framework "
93 		     "must be embedded in a strain strategy");
94       out << "3u;\n\n";
95     } else if(mb.getBehaviourType()==BehaviourDescription::STANDARDFINITESTRAINBEHAVIOUR){
96       out << "3u;\n\n";
97     } else {
98       tfel::raise("AbaqusExplicitSymbolsGenerator::writeBehaviourKinematicSymbols: "
99 		  "unsupported behaviour type");
100     }
101   } // end of AbaqusExplicitSymbolsGenerator::writeBehaviourKinematicSymbols
102 
103   bool AbaqusExplicitSymbolsGenerator::handleStrainMeasure() const{
104     return true;
105   }  // end of AbaqusExplicitSymbolsGenerator::handleStrainMeasure
106 
107   AbaqusExplicitSymbolsGenerator::~AbaqusExplicitSymbolsGenerator() = default;
108 
109 }  // end of namespace mfront
110