1 /*!
2  * \file   src/System/ExternalLibraryManager.cxx
3  * \brief
4  * \author Thomas Helfer
5  * \date   31 Oct 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 #include <cctype>
15 #include <cstring>
16 #include <fstream>
17 #include <stdexcept>
18 #if (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__)
19 #ifndef NOMINMAX
20 #define NOMINMAX
21 #endif
22 #include <windows.h>
23 #else
24 #include <dlfcn.h>
25 #endif /* (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__) */
26 
27 #include <iterator>
28 
29 #include "TFEL/Raise.hxx"
30 #include "TFEL/System/getFunction.h"
31 #include "TFEL/System/LibraryInformation.hxx"
32 #include "TFEL/System/ExternalLibraryManager.hxx"
33 
34 namespace tfel {
35 
36   namespace system {
37 
38 #if (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__)
39     // code retrieved from
40     // http://www.codeproject.com/Tips/479880/GetLastError-as-std-string
getLastWin32Error()41     static std::string getLastWin32Error() {
42       const DWORD error = GetLastError();
43       if (error) {
44         LPVOID lpMsgBuf;
45         DWORD bufLen = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
46                                          FORMAT_MESSAGE_IGNORE_INSERTS,
47                                      nullptr, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
48                                      (LPTSTR)&lpMsgBuf, 0, nullptr);
49         if (bufLen) {
50           LPCSTR lpMsgStr = (LPTSTR)lpMsgBuf;
51           std::string result(lpMsgStr, lpMsgStr + bufLen);
52           LocalFree(lpMsgBuf);
53           return result;
54         }
55       }
56       return std::string();
57     }
58 #endif /*  (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__) */
59 
getErrorMessage()60     static std::string getErrorMessage() {
61 #if (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__)
62       return getLastWin32Error();
63 #else
64       const auto e = ::dlerror();
65       if (e != nullptr) {
66         return std::string(e);
67       }
68       return "";
69 #endif /* (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__) */
70     }  // end of  getErrorMessage
71 
ExternalLibraryManagerCheckModellingHypothesisName(const std::string & h)72     static void ExternalLibraryManagerCheckModellingHypothesisName(const std::string& h) {
73       raise_if(!((h == "AxisymmetricalGeneralisedPlaneStrain") ||
74                  (h == "AxisymmetricalGeneralisedPlaneStress") || (h == "Axisymmetrical") ||
75                  (h == "PlaneStress") || (h == "PlaneStrain") || (h == "GeneralisedPlaneStrain") ||
76                  (h == "Tridimensional")),
77                "ExternalLibraryManagerCheckModellingHypothesisName : "
78                "invalid or unsupported hypothesis '" +
79                    h +
80                    "'. The following "
81                    "hypotheses are supported:\n"
82                    "- AxisymmetricalGeneralisedPlaneStrain\n"
83                    "- Axisymmetrical\n"
84                    "- PlaneStress\n"
85                    "- PlaneStrain\n"
86                    "- GeneralisedPlaneStrain\n"
87                    "- Tridimensional");
88     }  // end of ExternalLibraryManagerCheckModellingHypothesisName
89 
decomposeVariableName(const std::string & n)90     static std::string decomposeVariableName(const std::string& n) {
91       auto throw_if = [](const bool c, const std::string& m) {
92         raise_if(c, "tfel::system::decomposeVariableName: " + m);
93       };
94       auto p = n.cbegin();
95       auto pe = n.cend();
96       while ((p != pe) && (*p != '[')) {
97         ++p;
98       }
99       if (p == pe) {
100         return n;
101       }
102       auto r = std::string{n.cbegin(), p};
103       ++p;
104       throw_if(p == pe, "unexpected end of string 'n'");
105       throw_if(!std::isdigit(*p), "unexpected a digit 'n'");
106       r += "__";
107       while ((p != pe) && (std::isdigit(*p))) {
108         r.push_back(*p);
109         ++p;
110       }
111       throw_if(p == pe, "unexpected end of string '" + n + "'");
112       throw_if(*p != ']', "invalid variable name '" + n + "'");
113       ++p;
114       throw_if(p != pe, "invalid variable name '" + n + "'");
115       r += "__";
116       return r;
117     }  // end of decomposeVariableName
118 
getExternalLibraryManager()119     ExternalLibraryManager& ExternalLibraryManager::getExternalLibraryManager() {
120       static ExternalLibraryManager elm;
121       return elm;
122     }  // end of ExternalLibraryManager::getExternalLibraryManager()
123 
124     ExternalLibraryManager::ExternalLibraryManager() = default;
125 
126 #if (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__)
127     static HINSTANCE__*
128 #else
129     static void*
130 #endif /* (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__) */
load_library(const std::string & l)131     load_library(const std::string& l) {
132 #if (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__)
133       return ::LoadLibrary(TEXT(l.c_str()));
134 #else
135       return ::dlopen(l.c_str(), RTLD_NOW);
136 #endif /* (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__) */
137     }  // end of load_library
138 
139 #if (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__)
140     static std::pair<HINSTANCE__*, std::string>
141 #else
142     static std::pair<void*, std::string>
143 #endif /* (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__) */
try_open(const std::string & l)144     try_open(const std::string& l) {
145       auto starts_with = [](const std::string& s1, const char* const s2) {
146         const auto ls2 = std::strlen(s2);
147         return ((s1.size() >= ls2) && (std::equal(s2, s2 + ls2, s1.begin())));
148       };  // end of starts_with
149       auto ends_with = [](const std::string& s1, const char* const s2) {
150         const auto ls2 = std::strlen(s2);
151         if (!(s1.size() >= ls2)) {
152           return false;
153         }
154         return std::equal(s2, s2 + ls2, s1.begin() + (s1.size() - ls2));
155       };  // end of ends_with
156 #if (defined(macintosh) || defined(Macintosh) || (defined(__APPLE__) && defined(__MACH__)))
157       const char* const ext = ".dylib";
158 #elif (defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__))
159       const char* const ext = ".dll";
160 #else
161       const char* const ext = ".so";
162 #endif
163       auto ln = l;
164       auto lib = load_library(l);
165 #if defined(__CYGWIN__)
166       if ((lib == nullptr) && (!starts_with(l, "cyg"))) {
167         ln = "cyg" + l;
168         lib = load_library(ln);
169         if (lib == nullptr) {
170           if (!ends_with(l, ext)) {
171             ln = "cyg" + l + ext;
172             lib = load_library(ln);
173           }
174         }
175       }
176 #endif
177 #if !(defined(_WIN32) || defined(_WIN64))
178       if ((lib == nullptr) && (!starts_with(l, "lib"))) {
179         ln = "lib" + l;
180         lib = load_library(ln);
181         if (lib == nullptr) {
182           if (!ends_with(l, ext)) {
183             ln = "lib" + l + ext;
184             lib = load_library(ln);
185           }
186         }
187       }
188 #endif
189       if ((lib == nullptr) && (!ends_with(l, ext))) {
190         ln = l + ext;
191         lib = load_library(ln);
192       }
193       // retrieving the initial error message
194       if (lib == nullptr) {
195         ln = l;
196         lib = load_library(ln);
197       }
198       return {lib, ln};
199     }  // end of try_open
200 
getLibraryPath(const std::string & l)201     std::string ExternalLibraryManager::getLibraryPath(const std::string& l) {
202       auto throw_if = [](const bool c, const std::string& m) {
203         raise_if(c, "ExternalLibraryManager::getLibraryPath: " + m);
204       };
205 #if (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__)
206       auto lib = this->loadLibrary(l);
207       char path[MAX_PATH];
208       GetModuleFileNameA(lib, path, sizeof(path));
209       return std::string{path};
210 #else
211       auto tokenize = [](const std::string& s, const char c) {
212         std::vector<std::string> r;
213         std::string::size_type b = 0u;
214         std::string::size_type e = s.find_first_of(c, b);
215         while (std::string::npos != e || std::string::npos != b) {
216           // Found a token, add it to the vector.
217           r.push_back(s.substr(b, e - b));
218           b = s.find_first_not_of(c, e);
219           e = s.find_first_of(c, b);
220         }
221         return r;
222       };
223       auto exists = [](const std::string& f) {
224         std::ifstream file(f);
225         return static_cast<bool>(file);
226       };
227       auto lib = try_open(l);
228       throw_if(lib.first == nullptr, "can't load library '" + l + "'");
229       // check if file exists
230       if (exists(lib.second)) {
231         return lib.second;
232       }
233       // look in LD_LIBRARY_PATH
234       const auto ld = std::getenv("LD_LIBRARY_PATH");
235       throw_if(ld == nullptr, "can't find library '" + l + "'");
236       for (const auto& p : tokenize(ld, ':')) {
237         const auto lp = p + '/' + lib.second;
238         if (exists(lp)) {
239           return lp;
240         }
241       }
242       throw_if(true, "can't find library '" + l + "'");
243 #endif /* (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__) */
244     }  // end of ExternalLibraryManager::getLibraryPath
245 
246 #if (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__)
247     HINSTANCE__*
248 #else
249     void*
250 #endif /* (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__) */
loadLibrary(const std::string & name,const bool b)251     ExternalLibraryManager::loadLibrary(const std::string& name, const bool b) {
252       auto p = this->librairies.find(name);
253       if (p == librairies.end()) {
254         // this library has not been
255         auto r = try_open(name);
256         auto lib = r.first;
257         raise_if((lib == nullptr) && (!b),
258                  "ExternalLibraryManager::loadLibrary:"
259                  " library '" +
260                      name +
261                      "' could not be loaded, "
262                      "(" +
263                      getErrorMessage() + ")");
264         if ((lib == nullptr) && (b)) {
265           return lib;
266         }
267         this->librairies.insert({name, lib});
268         return lib;
269       }
270       return p->second;
271     }  // end of ExternalLibraryManager::loadLibrary
272 
getEntryPoints(const std::string & l)273     std::vector<std::string> ExternalLibraryManager::getEntryPoints(const std::string& l) {
274       auto ends_with = [](const std::string& s1, const std::string& s2) {
275         return ((s1.size() >= s2.size()) && (std::equal(s2.rbegin(), s2.rend(), s1.rbegin())));
276       };  // end of ends_with
277       auto r = std::vector<std::string>{};
278       auto lib = try_open(l);
279       raise_if(lib.first == nullptr,
280                "ExternalLibraryManager::getEntryPoints:"
281                " library '" +
282                    l +
283                    "' could not be loaded, "
284                    "(" +
285                    getErrorMessage() + ")");
286       auto pl = this->getLibraryPath(lib.second);
287       for (const auto& s : LibraryInformation(pl).symbols()) {
288         if (ends_with(s, "_mfront_ept")) {
289           r.push_back(s.substr(0, s.size() - 11));
290         }
291       }
292       return r;
293     }  // end of ExternalLibraryManager::getEntryPoints
294 
getMaterialKnowledgeType(const std::string & l,const std::string & f)295     unsigned short ExternalLibraryManager::getMaterialKnowledgeType(const std::string& l,
296                                                                     const std::string& f) {
297       auto throw_if = [l, f](const bool c, const std::string& m) {
298         raise_if(c, "ExternalLibraryManager::getMaterialKnowledgeType: " + m);
299       };
300       const auto lib = this->loadLibrary(l);
301       const int nb = ::tfel_getUnsignedShort(lib, (f + "_mfront_mkt").c_str());
302       throw_if(nb == -1,
303                "the material knowledge type could not be read "
304                "(" +
305                    getErrorMessage() + ")");
306       if (nb == 0) {
307         return 0u;
308       } else if (nb == 1) {
309         return 1u;
310       }
311       throw_if(nb != 2, "invalid material knowledge type");
312       return 2u;
313     }  // end of ExternalLibraryManager::getMaterialKnowledgeType
314 
contains(const std::string & l,const std::string & s)315     bool ExternalLibraryManager::contains(const std::string& l, const std::string& s) {
316       const auto lib = this->loadLibrary(l);
317 #if (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__)
318       int (*p)() = (int (*)())::GetProcAddress(lib, s.c_str());
319       return p != static_cast<int (*)()>(nullptr);
320 #else
321       void* p = ::dlsym(lib, s.c_str());
322       return p != nullptr;
323 #endif /* (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__) */
324     }  // end of ExternalLibraryManager::contains
325 
getSource(const std::string & l,const std::string & f)326     std::string ExternalLibraryManager::getSource(const std::string& l, const std::string& f) {
327       auto s = std::string{};
328       const auto lib = this->loadLibrary(l);
329 #if (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__)
330       const auto p = (const char* const*)::GetProcAddress(lib, (f + "_src").c_str());
331 #else
332       auto p = ::dlsym(lib, (f + "_src").c_str());
333 #endif /* (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__) */
334       if (p != nullptr) {
335 #if (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__)
336         s = *p;
337 #else
338         s = *(static_cast<const char* const*>(p));
339 #endif /* (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__) */
340       }
341       return s;
342     }  // end of ExternalLibraryManager::getSource
343 
getInterface(const std::string & l,const std::string & f)344     std::string ExternalLibraryManager::getInterface(const std::string& l, const std::string& f) {
345       const auto lib = this->loadLibrary(l);
346 #if (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__)
347       const auto p = (const char* const*)::GetProcAddress(lib, (f + "_mfront_interface").c_str());
348 #else
349       const auto p = ::dlsym(lib, (f + "_mfront_interface").c_str());
350 #endif /* (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__) */
351       raise_if(p == nullptr,
352                "ExternalLibraryManager::getInterface: "
353                "no interface found for entry point '" +
354                    f +
355                    "' "
356                    "in library '" +
357                    l + "'");
358 #if (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__)
359       return *p;
360 #else
361       return *(static_cast<const char* const*>(p));
362 #endif /* (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__) */
363     }  // end of ExternalLibraryManager::getInterface
364 
getMaterial(const std::string & l,const std::string & f)365     std::string ExternalLibraryManager::getMaterial(const std::string& l, const std::string& f) {
366       const auto lib = this->loadLibrary(l);
367 #if (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__)
368       const auto p = (const char* const*)::GetProcAddress(lib, (f + "_mfront_material").c_str());
369 #else
370       const auto p = ::dlsym(lib, (f + "_mfront_material").c_str());
371 #endif /* (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__) */
372       if (p == nullptr) {
373         return "";
374       }
375 #if (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__)
376       return *p;
377 #else
378       return *(static_cast<const char* const*>(p));
379 #endif /* (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__) */
380     }  // end of ExternalLibraryManager::getMaterial
381 
getTFELVersion(const std::string & l,const std::string & f)382     std::string ExternalLibraryManager::getTFELVersion(const std::string& l, const std::string& f) {
383       const auto lib = this->loadLibrary(l);
384 #if (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__)
385       const auto p = (const char* const*)::GetProcAddress(lib, (f + "_tfel_version").c_str());
386 #else
387       const auto p = ::dlsym(lib, (f + "_tfel_version").c_str());
388 #endif /* (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__) */
389       if (p == nullptr) {
390         return "";
391       }
392 #if (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__)
393       return *p;
394 #else
395       return *(static_cast<const char* const*>(p));
396 #endif /* (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__) */
397     }  // end of ExternalLibraryManager::getTFELVersion
398 
getSupportedModellingHypotheses(const std::string & l,const std::string & f)399     std::vector<std::string> ExternalLibraryManager::getSupportedModellingHypotheses(
400         const std::string& l, const std::string& f) {
401       std::vector<std::string> h;
402       const auto lib = this->loadLibrary(l);
403       const auto nb = ::tfel_getUnsignedShort(lib, (f + "_nModellingHypotheses").c_str());
404       char** res;
405       raise_if(nb == -1,
406                "ExternalLibraryManager::"
407                "getSupportedModellingHypotheses: "
408                "number of modelling hypotheses could not be read (" +
409                    getErrorMessage() + ")");
410       res = ::tfel_getArrayOfStrings(lib, (f + "_ModellingHypotheses").c_str());
411       raise_if(res == nullptr,
412                "ExternalLibraryManager::"
413                "getSupportedModellingHypotheses: "
414                "modelling hypotheses could not be read (" +
415                    getErrorMessage() + ")");
416       std::copy(res, res + nb, std::back_inserter(h));
417       return h;
418     }  // end of ExternalLibraryManager::getSupportedModellingHypotheses
419 
setOutOfBoundsPolicy(const std::string & l,const std::string & f,const tfel::material::OutOfBoundsPolicy p)420     void ExternalLibraryManager::setOutOfBoundsPolicy(const std::string& l,
421                                                       const std::string& f,
422                                                       const tfel::material::OutOfBoundsPolicy p) {
423       const auto lib = this->loadLibrary(l);
424       int(TFEL_ADDCALL_PTR fct)(int);
425       fct = ::tfel_getSetOutOfBoundsPolicyFunction(lib, (f + "_setOutOfBoundsPolicy").c_str());
426       raise_if(fct == nullptr,
427                "ExternalLibraryManager::setOutOfBoundsPolicy: "
428                "can't get the '" +
429                    f +
430                    "_setOutOfBoundsPolicy' function "
431                    "(" +
432                    getErrorMessage() + ")");
433       if (p == tfel::material::None) {
434         fct(0);
435       } else if (p == tfel::material::Warning) {
436         fct(1);
437       } else if (p == tfel::material::Strict) {
438         fct(2);
439       } else {
440         raise(
441             "ExternalLibraryManager::setOutOfBoundsPolicy: "
442             "unsupported policy");
443       }
444     }  // end of ExternalLibraryManager::setParameter
445 
setParameter(const std::string & l,const std::string & f,const std::string & p,const double v)446     void ExternalLibraryManager::setParameter(const std::string& l,
447                                               const std::string& f,
448                                               const std::string& p,
449                                               const double v) {
450       const auto lib = this->loadLibrary(l);
451       int(TFEL_ADDCALL_PTR fct)(const char* const, const double);
452       fct = ::tfel_getSetParameterFunction(lib, (f + "_setParameter").c_str());
453       raise_if(fct == nullptr,
454                "ExternalLibraryManager::setParameter: "
455                "can't get the '" +
456                    f + "_setParameter' function (" + getErrorMessage() + ")");
457       raise_if(!fct(p.c_str(), v),
458                "ExternalLibraryManager::setParameter: "
459                "call to the '" +
460                    f + "_setParameter' function failed");
461     }  // end of ExternalLibraryManager::setParameter
462 
setParameter(const std::string & l,const std::string & f,const std::string & p,const int v)463     void ExternalLibraryManager::setParameter(const std::string& l,
464                                               const std::string& f,
465                                               const std::string& p,
466                                               const int v) {
467       const auto lib = this->loadLibrary(l);
468       int(TFEL_ADDCALL_PTR fct)(const char* const, const int);
469       fct = ::tfel_getSetIntegerParameterFunction(lib, (f + "_setIntegerParameter").c_str());
470       raise_if(fct == nullptr,
471                "ExternalLibraryManager::setParameter: "
472                "can't get the '" +
473                    f + "_setParameter' function (" + getErrorMessage() + ")");
474       raise_if(!fct(p.c_str(), v),
475                "ExternalLibraryManager::setParameter: "
476                "call to the '" +
477                    f + "_setParameter' function failed");
478     }  // end of ExternalLibraryManager::setParameter
479 
setParameter(const std::string & l,const std::string & f,const std::string & p,const unsigned short v)480     void ExternalLibraryManager::setParameter(const std::string& l,
481                                               const std::string& f,
482                                               const std::string& p,
483                                               const unsigned short v) {
484       const auto lib = this->loadLibrary(l);
485       int(TFEL_ADDCALL_PTR fct)(const char* const, const unsigned short);
486       fct = ::tfel_getSetUnsignedShortParameterFunction(lib,
487                                                         (f + "_setUnsignedShortParameter").c_str());
488       raise_if(fct == nullptr,
489                "ExternalLibraryManager::setParameter: "
490                "can't get the '" +
491                    f + "_setParameter' function (" + getErrorMessage() + ")");
492       raise_if(!fct(p.c_str(), v),
493                "ExternalLibraryManager::setParameter: "
494                "call to the '" +
495                    f + "_setParameter' function failed");
496     }  // end of ExternalLibraryManager::setParameter
497 
setParameter(const std::string & l,const std::string & f,const std::string & h,const std::string & p,const double v)498     void ExternalLibraryManager::setParameter(const std::string& l,
499                                               const std::string& f,
500                                               const std::string& h,
501                                               const std::string& p,
502                                               const double v) {
503       const auto lib = this->loadLibrary(l);
504       int(TFEL_ADDCALL_PTR fct)(const char* const, const double);
505       fct = ::tfel_getSetParameterFunction(lib, (f + "_" + h + "_setParameter").c_str());
506       if (fct == nullptr) {
507         fct = ::tfel_getSetParameterFunction(lib, (f + "_setParameter").c_str());
508       }
509       raise_if(fct == nullptr,
510                "ExternalLibraryManager::setParameter: "
511                "can't get the '" +
512                    f + "_setParameter' function (" + getErrorMessage() + ")");
513       raise_if(!fct(p.c_str(), v),
514                "ExternalLibraryManager::setParameter: "
515                "call to the '" +
516                    f + "_setParameter' function failed");
517     }  // end of ExternalLibraryManager::setParameter
518 
setParameter(const std::string & l,const std::string & f,const std::string & h,const std::string & p,const int v)519     void ExternalLibraryManager::setParameter(const std::string& l,
520                                               const std::string& f,
521                                               const std::string& h,
522                                               const std::string& p,
523                                               const int v) {
524       const auto lib = this->loadLibrary(l);
525       int(TFEL_ADDCALL_PTR fct)(const char* const, const int);
526       fct = ::tfel_getSetIntegerParameterFunction(lib,
527                                                   (f + "_" + h + "_setIntegerParameter").c_str());
528       if (fct == nullptr) {
529         fct = ::tfel_getSetIntegerParameterFunction(lib, (f + "_setIntegerParameter").c_str());
530       }
531       raise_if(fct == nullptr,
532                "ExternalLibraryManager::setParameter: "
533                "can't get the '" +
534                    f + "_setParameter' function (" + getErrorMessage() + ")");
535       raise_if(!fct(p.c_str(), v),
536                "ExternalLibraryManager::setParameter: "
537                "call to the '" +
538                    f + "_setParameter' function failed");
539     }  // end of ExternalLibraryManager::setParameter
540 
setParameter(const std::string & l,const std::string & f,const std::string & h,const std::string & p,const unsigned short v)541     void ExternalLibraryManager::setParameter(const std::string& l,
542                                               const std::string& f,
543                                               const std::string& h,
544                                               const std::string& p,
545                                               const unsigned short v) {
546       const auto lib = this->loadLibrary(l);
547       int(TFEL_ADDCALL_PTR fct)(const char* const, const unsigned short);
548       fct = ::tfel_getSetUnsignedShortParameterFunction(
549           lib, (f + "_" + h + "_setUnsignedShortParameter").c_str());
550       if (fct == nullptr) {
551         fct = ::tfel_getSetUnsignedShortParameterFunction(
552             lib, (f + "_setUnsignedShortParameter").c_str());
553       }
554       raise_if(fct == nullptr,
555                "ExternalLibraryManager::setParameter: "
556                "can't get the '" +
557                    f + "_setParameter' function (" + getErrorMessage() + ")");
558       raise_if(!fct(p.c_str(), v),
559                "ExternalLibraryManager::setParameter: "
560                "call to the '" +
561                    f + "_setParameter' function failed");
562     }  // end of ExternalLibraryManager::setParameter
563 
getRealParameterDefaultValue(const std::string & l,const std::string & f,const std::string & h,const std::string & p)564     double ExternalLibraryManager::getRealParameterDefaultValue(const std::string& l,
565                                                                 const std::string& f,
566                                                                 const std::string& h,
567                                                                 const std::string& p) {
568       const auto lib = this->loadLibrary(l);
569       const auto pn = decomposeVariableName(p);
570       const auto n1 = f + "_" + h + "_" + pn + "_ParameterDefaultValue";
571       if (this->contains(l, n1)) {
572         return tfel_getDouble(lib, n1.c_str());
573       }
574       const auto n2 = f + "_" + pn + "_ParameterDefaultValue";
575       raise_if(!this->contains(l, n2),
576                "ExternalLibraryManager::getRealParameterDefaultValue: "
577                "can't get default value for parameter '" +
578                    p + "'");
579       return tfel_getDouble(lib, n2.c_str());
580     }  // end of ExternalLibraryManager::getRealParameterDefaultValue
581 
getIntegerParameterDefaultValue(const std::string & l,const std::string & f,const std::string & h,const std::string & p)582     int ExternalLibraryManager::getIntegerParameterDefaultValue(const std::string& l,
583                                                                 const std::string& f,
584                                                                 const std::string& h,
585                                                                 const std::string& p) {
586       const auto lib = this->loadLibrary(l);
587       const auto pn = decomposeVariableName(p);
588       const auto n1 = f + "_" + h + "_" + pn + "_ParameterDefaultValue";
589       if (this->contains(l, n1)) {
590         return tfel_getInteger(lib, n1.c_str());
591       }
592       const auto n2 = f + "_" + pn + "_ParameterDefaultValue";
593       raise_if(!this->contains(l, n2),
594                "ExternalLibraryManager::getIntegerParameterDefaultValue: "
595                "can't get default value for parameter '" +
596                    p + "'");
597       return tfel_getInteger(lib, n2.c_str());
598     }  // end of ExternalLibraryManager::getIntegerParameterDefaultValue
599 
getUnsignedShortParameterDefaultValue(const std::string & l,const std::string & f,const std::string & h,const std::string & p)600     unsigned short ExternalLibraryManager::getUnsignedShortParameterDefaultValue(
601         const std::string& l, const std::string& f, const std::string& h, const std::string& p) {
602       const auto lib = this->loadLibrary(l);
603       const auto pn = decomposeVariableName(p);
604       const auto n1 = f + "_" + h + "_" + pn + "_ParameterDefaultValue";
605       auto res = ::tfel_getUnsignedShort(lib, n1.c_str());
606       if (res < 0) {
607         res = ::tfel_getUnsignedShort(lib, (f + "_" + pn + "_ParameterDefaultValue").c_str());
608         raise_if(res < 0,
609                  "ExternalLibraryManager::"
610                  "getUnsignedShortParameterDefaultValue: "
611                  "information could not be read (" +
612                      getErrorMessage() + ")");
613       }
614       return static_cast<unsigned short>(res);
615     }  // end of ExternalLibraryManager::getUnsignedShortParameterDefaultValue
616 
hasBounds(const std::string & l,const std::string & f,const std::string & h,const std::string & n)617     bool ExternalLibraryManager::hasBounds(const std::string& l,
618                                            const std::string& f,
619                                            const std::string& h,
620                                            const std::string& n) {
621       const auto vn = decomposeVariableName(n);
622       const auto n1 = f + "_" + h + "_" + vn + "_LowerBound";
623       const auto n2 = f + "_" + h + "_" + vn + "_UpperBound";
624       const auto n3 = f + "_" + vn + "_LowerBound";
625       const auto n4 = f + "_" + vn + "_UpperBound";
626       return ((this->contains(l, n1)) || (this->contains(l, n2)) || (this->contains(l, n3)) ||
627               (this->contains(l, n4)));
628     }  // end of ExternalLibraryManager::hasBounds
629 
hasLowerBound(const std::string & l,const std::string & f,const std::string & h,const std::string & n)630     bool ExternalLibraryManager::hasLowerBound(const std::string& l,
631                                                const std::string& f,
632                                                const std::string& h,
633                                                const std::string& n) {
634       const auto vn = decomposeVariableName(n);
635       const auto n1 = f + "_" + h + "_" + vn + "_LowerBound";
636       const auto n2 = f + "_" + vn + "_LowerBound";
637       return ((this->contains(l, n1)) || (this->contains(l, n2)));
638     }  // end of ExternalLibraryManager::hasLowerBound
639 
hasUpperBound(const std::string & l,const std::string & f,const std::string & h,const std::string & n)640     bool ExternalLibraryManager::hasUpperBound(const std::string& l,
641                                                const std::string& f,
642                                                const std::string& h,
643                                                const std::string& n) {
644       const auto vn = decomposeVariableName(n);
645       const auto n1 = f + "_" + h + "_" + vn + "_UpperBound";
646       const auto n2 = f + "_" + vn + "_UpperBound";
647       return ((this->contains(l, n1)) || (this->contains(l, n2)));
648     }  // end of ExternalLibraryManager::hasUpperBound
649 
getLowerBound(const std::string & l,const std::string & f,const std::string & h,const std::string & n)650     long double ExternalLibraryManager::getLowerBound(const std::string& l,
651                                                       const std::string& f,
652                                                       const std::string& h,
653                                                       const std::string& n) {
654       const auto lib = this->loadLibrary(l);
655       const auto vn = decomposeVariableName(n);
656       const auto n1 = f + "_" + h + "_" + vn + "_LowerBound";
657       if (this->contains(l, n1)) {
658         return tfel_getLongDouble(lib, n1.c_str());
659       }
660       const auto n2 = f + "_" + vn + "_LowerBound";
661       raise_if(!this->contains(l, n2),
662                "ExternalLibraryManager::getLowerBound: "
663                "no lower bound associated to variable '" +
664                    vn + "'");
665       return tfel_getLongDouble(lib, n2.c_str());
666     }  // end of ExternalLibraryManager::getLowerBound
667 
getUpperBound(const std::string & l,const std::string & f,const std::string & h,const std::string & n)668     long double ExternalLibraryManager::getUpperBound(const std::string& l,
669                                                       const std::string& f,
670                                                       const std::string& h,
671                                                       const std::string& n) {
672       const auto lib = this->loadLibrary(l);
673       const auto vn = decomposeVariableName(n);
674       const auto n1 = f + "_" + h + "_" + vn + "_UpperBound";
675       if (this->contains(l, n1)) {
676         return tfel_getLongDouble(lib, n1.c_str());
677       }
678       const auto n2 = f + "_" + vn + "_UpperBound";
679       raise_if(!this->contains(l, n2),
680                "ExternalLibraryManager::getUpperBound: "
681                "no upper bound associated to variable '" +
682                    vn + "'");
683       return tfel_getLongDouble(lib, n2.c_str());
684     }  // end of ExternalLibraryManager::getUpperBound
685 
hasPhysicalBounds(const std::string & l,const std::string & f,const std::string & h,const std::string & n)686     bool ExternalLibraryManager::hasPhysicalBounds(const std::string& l,
687                                                    const std::string& f,
688                                                    const std::string& h,
689                                                    const std::string& n) {
690       const auto vn = decomposeVariableName(n);
691       const auto n1 = f + "_" + h + "_" + vn + "_LowerPhysicalBound";
692       const auto n2 = f + "_" + h + "_" + vn + "_UpperPhysicalBound";
693       const auto n3 = f + "_" + vn + "_LowerPhysicalBound";
694       const auto n4 = f + "_" + vn + "_UpperPhysicalBound";
695       return ((this->contains(l, n1)) || (this->contains(l, n2)) || (this->contains(l, n3)) ||
696               (this->contains(l, n4)));
697     }  // end of ExternalLibraryManager::hasPhysicalBounds
698 
hasLowerPhysicalBound(const std::string & l,const std::string & f,const std::string & h,const std::string & n)699     bool ExternalLibraryManager::hasLowerPhysicalBound(const std::string& l,
700                                                        const std::string& f,
701                                                        const std::string& h,
702                                                        const std::string& n) {
703       const auto vn = decomposeVariableName(n);
704       const auto n1 = f + "_" + h + "_" + vn + "_LowerPhysicalBound";
705       const auto n2 = f + "_" + vn + "_LowerPhysicalBound";
706       return ((this->contains(l, n1)) || (this->contains(l, n2)));
707     }  // end of ExternalLibraryManager::hasLowerPhysicalBound
708 
hasUpperPhysicalBound(const std::string & l,const std::string & f,const std::string & h,const std::string & n)709     bool ExternalLibraryManager::hasUpperPhysicalBound(const std::string& l,
710                                                        const std::string& f,
711                                                        const std::string& h,
712                                                        const std::string& n) {
713       const auto vn = decomposeVariableName(n);
714       const auto n1 = f + "_" + h + "_" + vn + "_UpperPhysicalBound";
715       const auto n2 = f + "_" + vn + "_UpperPhysicalBound";
716       return ((this->contains(l, n1)) || (this->contains(l, n2)));
717     }  // end of ExternalLibraryManager::hasUpperPhysicalBound
718 
getLowerPhysicalBound(const std::string & l,const std::string & f,const std::string & h,const std::string & n)719     long double ExternalLibraryManager::getLowerPhysicalBound(const std::string& l,
720                                                               const std::string& f,
721                                                               const std::string& h,
722                                                               const std::string& n) {
723       const auto lib = this->loadLibrary(l);
724       const auto vn = decomposeVariableName(n);
725       const auto n1 = f + "_" + h + "_" + vn + "_LowerPhysicalBound";
726       if (this->contains(l, n1)) {
727         return tfel_getLongDouble(lib, n1.c_str());
728       }
729       const auto n2 = f + "_" + vn + "_LowerPhysicalBound";
730       raise_if(!this->contains(l, n2),
731                "ExternalLibraryManager::getLowerPhysicalBound: "
732                "no physical lower bound associated to variable '" +
733                    vn + "'");
734       return tfel_getLongDouble(lib, n2.c_str());
735     }  // end of ExternalLibraryManager::getLowerPhysicalBound
736 
getUpperPhysicalBound(const std::string & l,const std::string & f,const std::string & h,const std::string & n)737     long double ExternalLibraryManager::getUpperPhysicalBound(const std::string& l,
738                                                               const std::string& f,
739                                                               const std::string& h,
740                                                               const std::string& n) {
741       const auto lib = this->loadLibrary(l);
742       const auto vn = decomposeVariableName(n);
743       const auto n1 = f + "_" + h + "_" + vn + "_UpperPhysicalBound";
744       if (this->contains(l, n1)) {
745         return tfel_getLongDouble(lib, n1.c_str());
746       }
747       const auto n2 = f + "_" + vn + "_UpperPhysicalBound";
748       raise_if(!this->contains(l, n2),
749                "ExternalLibraryManager::getUpperPhysicalBound: "
750                "no physical upper bound associated to variable '" +
751                    vn + "'");
752       return tfel_getLongDouble(lib, n2.c_str());
753     }  // end of ExternalLibraryManager::getUpperPhysicalBound
754 
getCastemFunctionNumberOfVariables(const std::string & l,const std::string & f)755     unsigned short ExternalLibraryManager::getCastemFunctionNumberOfVariables(
756         const std::string& l, const std::string& f) {
757       const auto lib = this->loadLibrary(l);
758       const auto res = ::tfel_getCastemFunctionNumberOfVariables(lib, f.c_str());
759       raise_if(res < 0,
760                "ExternalLibraryManager::getCastemFunctionNumberOfVariables: "
761                "number of variables could not be read (" +
762                    getErrorMessage() + ")");
763       return static_cast<unsigned short>(res);
764     }
765 
getUMATRequiresStiffnessTensor(const std::string & l,const std::string & f,const std::string & h)766     bool ExternalLibraryManager::getUMATRequiresStiffnessTensor(const std::string& l,
767                                                                 const std::string& f,
768                                                                 const std::string& h) {
769       ExternalLibraryManagerCheckModellingHypothesisName(h);
770       int res;
771       const auto lib = this->loadLibrary(l);
772       res = ::tfel_getUMATRequiresStiffnessTensor(lib, (f + "_" + h).c_str());
773       if (res < 0) {
774         res = ::tfel_getUMATRequiresStiffnessTensor(lib, f.c_str());
775       }
776       raise_if(res < 0,
777                "ExternalLibraryManager::getUMATRequiresStiffnessTensor: "
778                "information could not be read (" +
779                    getErrorMessage() + ")");
780       if (res == 1) {
781         return true;
782       }
783       raise_if(res != 0,
784                "ExternalLibraryManager::getUMATRequiresStiffnessTensor: "
785                "invalid returned value");
786       return false;
787     }  // end of ExternalLibraryManager::getUMATRequiresStiffnessTensor
788 
getUMATRequiresThermalExpansionCoefficientTensor(const std::string & l,const std::string & f,const std::string & h)789     bool ExternalLibraryManager::getUMATRequiresThermalExpansionCoefficientTensor(
790         const std::string& l, const std::string& f, const std::string& h) {
791       ExternalLibraryManagerCheckModellingHypothesisName(h);
792       auto lib = this->loadLibrary(l);
793       auto res =
794           ::tfel_getUMATRequiresThermalExpansionCoefficientTensor(lib, (f + "_" + h).c_str());
795       if (res < 0) {
796         res = ::tfel_getUMATRequiresThermalExpansionCoefficientTensor(lib, f.c_str());
797       }
798       raise_if(res < 0,
799                "ExternalLibraryManager::"
800                "getUMATRequiresThermalExpansionCoefficientTensor: "
801                "information could not be read (" +
802                    getErrorMessage() + ")");
803       if (res == 1) {
804         return true;
805       }
806       raise_if(res != 0,
807                "ExternalLibraryManager::"
808                "getUMATRequiresThermalExpansionCoefficientTensor: "
809                "invalid returned value");
810       return false;
811     }  // end of ExternalLibraryManager::getUMATRequiresThermalExpansionCoefficientTensor
812 
checkIfAsterBehaviourSavesTangentOperator(const std::string & l,const std::string & f)813     bool ExternalLibraryManager::checkIfAsterBehaviourSavesTangentOperator(const std::string& l,
814                                                                            const std::string& f) {
815       const auto lib = this->loadLibrary(l);
816       const auto res = ::tfel_checkIfAsterBehaviourSavesTangentOperator(lib, f.c_str());
817       raise_if(res < 0,
818                "ExternalLibraryManager::"
819                "checkIfAsterBehaviourSaveTangentOperator: "
820                "information could not be read (" +
821                    getErrorMessage() + ")");
822       if (res == 1) {
823         return true;
824       }
825       raise_if(res != 0,
826                "ExternalLibraryManager::"
827                "checkIfAsterBehaviourSaveTangentOperator: "
828                "invalid returned value");
829       return false;
830     }  // end of ExternalLibraryManager::checkIfAsterBehaviourSaveTangentOperator
831 
getAsterFiniteStrainFormulation(const std::string & l,const std::string & f)832     unsigned short ExternalLibraryManager::getAsterFiniteStrainFormulation(const std::string& l,
833                                                                            const std::string& f) {
834       const auto lib = this->loadLibrary(l);
835       const auto s = f + "_FiniteStrainFormulation";
836       const auto res = ::tfel_getUnsignedShort(lib, s.c_str());
837       raise_if(res < 0,
838                "ExternalLibraryManager::"
839                "getAsterFiniteStrainFormulation: "
840                "information could not be read (" +
841                    getErrorMessage() + ")");
842       raise_if((res != 1) && (res != 2),
843                "ExternalLibraryManager::"
844                "getAsterFiniteStrainFormulation: "
845                "invalid returned value");
846       return static_cast<unsigned short>(res);
847     }  // end of ExternalLibraryManager::getAsterFiniteStrainFormulation
848 
849     AsterIntegrationErrorMessageFctPtr
getAsterIntegrationErrorMessageFunction(const std::string & l,const std::string & f)850     ExternalLibraryManager::getAsterIntegrationErrorMessageFunction(const std::string& l,
851                                                                     const std::string& f) {
852       const auto lib = this->loadLibrary(l);
853       const auto s = f + "_getIntegrationErrorMessage";
854       return ::tfel_getAsterIntegrationErrorMessage(lib, s.c_str());
855     }  // end of ExternalLibraryManager::getAsterIntegrationErrorMessage
856 
getAbaqusOrthotropyManagementPolicy(const std::string & l,const std::string & f)857     unsigned short ExternalLibraryManager::getAbaqusOrthotropyManagementPolicy(
858         const std::string& l, const std::string& f) {
859       const auto lib = this->loadLibrary(l);
860       const auto s = f + "_OrthotropyManagementPolicy";
861       const auto res = ::tfel_getUnsignedShort(lib, s.c_str());
862       raise_if(res < 0,
863                "ExternalLibraryManager::"
864                "getAbaqusOrthotropyManagementPolicy: "
865                "information could not be read (" +
866                    getErrorMessage() + ")");
867       raise_if((res != 0) && (res != 1) && (res != 2),
868                "ExternalLibraryManager::"
869                "getAbaqusOrthotropyManagementPolicy: "
870                "invalid returned value");
871       return static_cast<unsigned short>(res);
872     }  // end of ExternalLibraryManager::getAbaqusOrthotropyManagementPolicy
873 
getCastemFunctionVariables(const std::string & l,const std::string & f)874     std::vector<std::string> ExternalLibraryManager::getCastemFunctionVariables(
875         const std::string& l, const std::string& f) {
876       std::vector<std::string> vars;
877       this->getCastemFunctionVariables(vars, l, f);
878       return vars;
879     }  // end of ExternalLibraryManager::getCastemFunctionVariables
880 
getCastemFunctionVariables(std::vector<std::string> & vars,const std::string & l,const std::string & f)881     void ExternalLibraryManager::getCastemFunctionVariables(std::vector<std::string>& vars,
882                                                             const std::string& l,
883                                                             const std::string& f) {
884       const auto lib = this->loadLibrary(l);
885       unsigned short nb = this->getCastemFunctionNumberOfVariables(l, f);
886       char** res = ::tfel_getCastemFunctionVariables(lib, f.c_str());
887       char** p;
888       raise_if(res == nullptr,
889                "ExternalLibraryManager::getCastemFunctionNumberOfVariables: "
890                " variables names could not be read (" +
891                    getErrorMessage() + ")");
892       for (p = res; p != res + nb; ++p) {
893         vars.emplace_back(*p);
894       }
895     }  // end of ExternalLibraryManager::getCastemFunctionVariables
896 
getGenericBehaviourFunction(const std::string & l,const std::string & f)897     GenericBehaviourFctPtr ExternalLibraryManager::getGenericBehaviourFunction(const std::string& l,
898                                                            const std::string& f) {
899       const auto lib = this->loadLibrary(l);
900       const auto fct = ::tfel_getGenericBehaviourFunction(lib, f.c_str());
901       raise_if(fct == nullptr,
902                "ExternalLibraryManager::getGenericBehaviourFunction: "
903                "could not load generic gehaviour function '" +
904 	       f + "' (" + getErrorMessage() + ")");
905       return fct;
906     }
907 
908 
getCyranoFunction(const std::string & l,const std::string & f)909     CyranoFctPtr ExternalLibraryManager::getCyranoFunction(const std::string& l,
910                                                            const std::string& f) {
911       const auto lib = this->loadLibrary(l);
912       const auto fct = ::tfel_getCyranoFunction(lib, f.c_str());
913       raise_if(fct == nullptr,
914                "ExternalLibraryManager::getCyranoFunction: "
915                "could not load Cyrano function '" +
916                    f +
917                    "' "
918                    "(" +
919                    getErrorMessage() + ")");
920       return fct;
921     }
922 
getAbaqusExternalBehaviourFunction(const std::string & l,const std::string & f)923     AbaqusFctPtr ExternalLibraryManager::getAbaqusExternalBehaviourFunction(const std::string& l,
924                                                                             const std::string& f) {
925       const auto lib = this->loadLibrary(l);
926       const auto fct = ::tfel_getAbaqusExternalBehaviourFunction(lib, f.c_str());
927       raise_if(fct == nullptr,
928                "ExternalLibraryManager::getAbaqusExternalBehaviourFunction: "
929                "could not load Abaqus external behaviour '" +
930                    f +
931                    "' "
932                    "(" +
933                    getErrorMessage() + ")");
934       return fct;
935     }
936 
getAnsysExternalBehaviourFunction(const std::string & l,const std::string & f)937     AnsysFctPtr ExternalLibraryManager::getAnsysExternalBehaviourFunction(const std::string& l,
938                                                                           const std::string& f) {
939       const auto lib = this->loadLibrary(l);
940       const auto fct = ::tfel_getAnsysExternalBehaviourFunction(lib, f.c_str());
941       raise_if(fct == nullptr,
942                "ExternalLibraryManager::getAnsysExternalBehaviourFunction: "
943                "could not load Ansys external behaviour '" +
944                    f +
945                    "' "
946                    "(" +
947                    getErrorMessage() + ")");
948       return fct;
949     }
950 
getAbaqusExplicitExternalBehaviourFunction(const std::string & l,const std::string & f)951     AbaqusExplicitFctPtr ExternalLibraryManager::getAbaqusExplicitExternalBehaviourFunction(
952         const std::string& l, const std::string& f) {
953       const auto lib = this->loadLibrary(l);
954       const auto fct = ::tfel_getAbaqusExplicitExternalBehaviourFunction(lib, f.c_str());
955       raise_if(fct == nullptr,
956                "ExternalLibraryManager::"
957                "getAbaqusExplicitExternalBehaviourFunction: "
958                "could not load AbaqusExplicit external "
959                "behaviour '" +
960                    f + "' (" + getErrorMessage() + ")");
961       return fct;
962     }
963 
getCalculiXExternalBehaviourFunction(const std::string & l,const std::string & f)964     CalculiXFctPtr ExternalLibraryManager::getCalculiXExternalBehaviourFunction(
965         const std::string& l, const std::string& f) {
966       const auto lib = this->loadLibrary(l);
967       auto fct = ::tfel_getCalculiXExternalBehaviourFunction(lib, f.c_str());
968       raise_if(fct == nullptr,
969                "ExternalLibraryManager::"
970                "getCalculiXExternalBehaviourFunction: "
971                "could not load CalculiX external behaviour '" +
972                    f +
973                    "' "
974                    "(" +
975                    getErrorMessage() + ")");
976       return fct;
977     }
978 
getCastemExternalBehaviourFunction(const std::string & l,const std::string & f)979     CastemFctPtr ExternalLibraryManager::getCastemExternalBehaviourFunction(const std::string& l,
980                                                                             const std::string& f) {
981       const auto lib = this->loadLibrary(l);
982       const auto fct = ::tfel_getCastemExternalBehaviourFunction(lib, f.c_str());
983       raise_if(fct == nullptr,
984                "ExternalLibraryManager::"
985                "getCastemExternalBehaviourFunction: "
986                "could not load castem external behaviour '" +
987                    f +
988                    "' "
989                    "(" +
990                    getErrorMessage() + ")");
991       return fct;
992     }
993 
getAsterFunction(const std::string & l,const std::string & f)994     AsterFctPtr ExternalLibraryManager::getAsterFunction(const std::string& l,
995                                                          const std::string& f) {
996       const auto lib = this->loadLibrary(l);
997       const auto fct = ::tfel_getAsterFunction(lib, f.c_str());
998       raise_if(fct == nullptr,
999                "ExternalLibraryManager::getAsterFunction: "
1000                "could not load Aster function '" +
1001                    f +
1002                    "' "
1003                    "(" +
1004                    getErrorMessage() + ")");
1005       return fct;
1006     }
1007 
getEuroplexusFunction(const std::string & l,const std::string & f)1008     EuroplexusFctPtr ExternalLibraryManager::getEuroplexusFunction(const std::string& l,
1009                                                                    const std::string& f) {
1010       const auto lib = this->loadLibrary(l);
1011       const auto fct = ::tfel_getEuroplexusFunction(lib, f.c_str());
1012       raise_if(fct == nullptr,
1013                "ExternalLibraryManager::getEuroplexusFunction: "
1014                " could not load Europlexus function '" +
1015                    f +
1016                    "' "
1017                    "(" +
1018                    getErrorMessage() + ")");
1019       return fct;
1020     }
1021 
getUMATNames(std::vector<std::string> & vars,const std::string & l,const std::string & f,const std::string & h,const std::string & n)1022     void ExternalLibraryManager::getUMATNames(std::vector<std::string>& vars,
1023                                               const std::string& l,
1024                                               const std::string& f,
1025                                               const std::string& h,
1026                                               const std::string& n) {
1027       if(!h.empty()){
1028 	ExternalLibraryManagerCheckModellingHypothesisName(h);
1029       }
1030       const auto lib = this->loadLibrary(l);
1031       auto nb = -1;
1032       if(!h.empty()){
1033 	nb = ::tfel_getUnsignedShort(lib, (f + "_" + h + "_n" + n).c_str());
1034       }
1035       if (nb == -1) {
1036 	nb = ::tfel_getUnsignedShort(lib, (f + "_n" + n).c_str());
1037       }
1038       raise_if(nb == -1,
1039                "ExternalLibraryManager::getUMATNames: "
1040                "number of variables names could not be read "
1041                "(" + getErrorMessage() + ")");
1042       char** res = nullptr;
1043       if(!h.empty()){
1044 	res = ::tfel_getArrayOfStrings(lib, (f + "_" + h + '_' + n).c_str());
1045       }
1046       if (res == nullptr) {
1047         res = ::tfel_getArrayOfStrings(lib, (f + '_' + n).c_str());
1048       }
1049       raise_if(res == nullptr,
1050                "ExternalLibraryManager::getUMATNames: "
1051                "variables names could not be read "
1052                "(" + getErrorMessage() + ")");
1053       std::copy(res, res + nb, std::back_inserter(vars));
1054     }  // end of ExternalLibraryManager::getUMATNames
1055 
getUMATTypes(std::vector<int> & types,const std::string & l,const std::string & f,const std::string & h,const std::string & n)1056     void ExternalLibraryManager::getUMATTypes(std::vector<int>& types,
1057                                               const std::string& l,
1058                                               const std::string& f,
1059                                               const std::string& h,
1060                                               const std::string& n) {
1061       if(!h.empty()){
1062 	ExternalLibraryManagerCheckModellingHypothesisName(h);
1063       }
1064       const auto lib = this->loadLibrary(l);
1065       auto nb = -1;
1066       if(!h.empty()){
1067 	nb = ::tfel_getUnsignedShort(lib, (f + "_" + h + "_n" + n).c_str());
1068       }
1069       if (nb == -1) {
1070 	nb = ::tfel_getUnsignedShort(lib, (f + "_n" + n).c_str());
1071       }
1072       raise_if(nb == -1,
1073                "ExternalLibraryManager::getUMATTypes: "
1074                "number of variables names could not be read "
1075                "(" + getErrorMessage() + ")");
1076       int* res = nullptr;
1077       if(!h.empty()){
1078 	res = ::tfel_getArrayOfInts(lib, (f + "_" + h + '_' + n+"Types").c_str());
1079       }
1080       if (res == nullptr) {
1081         res = ::tfel_getArrayOfInts(lib, (f + '_' + n+"Types").c_str());
1082       }
1083       raise_if(res == nullptr,
1084                "ExternalLibraryManager::getUMATTypes: "
1085                "variables names could not be read "
1086                "(" + getErrorMessage() + ")");
1087       std::copy(res, res + nb, std::back_inserter(types));
1088     }  // end of ExternalLibraryManager::getUMATTypes
1089 
isUMATBehaviourUsableInPurelyImplicitResolution(const std::string & l,const std::string & f,const std::string & h)1090     bool ExternalLibraryManager::isUMATBehaviourUsableInPurelyImplicitResolution(
1091         const std::string& l, const std::string& f, const std::string& h) {
1092       ExternalLibraryManagerCheckModellingHypothesisName(h);
1093       const auto lib = this->loadLibrary(l);
1094       int b = ::tfel_getBool(lib, (f + "_" + h + "_UsableInPurelyImplicitResolution").c_str());
1095       if (b == -1) {
1096         b = ::tfel_getBool(lib, (f + "_UsableInPurelyImplicitResolution").c_str());
1097       }
1098       if (b == -1) {
1099         return false;
1100       }
1101       return (b == 1);
1102     }  // end of ExternalLibraryManager::isUMATBehaviourUsableInPurelyImplicitResolution
1103 
checkIfUMATBehaviourUsesGenericPlaneStressAlgorithm(const std::string & l,const std::string & f)1104     bool ExternalLibraryManager::checkIfUMATBehaviourUsesGenericPlaneStressAlgorithm(
1105         const std::string& l, const std::string& f) {
1106       const auto lib = this->loadLibrary(l);
1107       const auto b = ::tfel_getBool(lib, (f + "_UsesGenericPlaneStressAlgorithm").c_str());
1108       if (b == -1) {
1109         return false;
1110       }
1111       return b == 1;
1112     }  // end of ExternalLibraryManager::checkIfUMATBehaviourUsesGenericPlaneStressAlgorithm
1113 
getUMATBehaviourType(const std::string & l,const std::string & f)1114     unsigned short ExternalLibraryManager::getUMATBehaviourType(const std::string& l,
1115                                                                 const std::string& f) {
1116       const auto lib = this->loadLibrary(l);
1117       const auto u = ::tfel_getUnsignedShort(lib, (f + "_BehaviourType").c_str());
1118       raise_if(u == -1,
1119                "ExternalLibraryManager::getUMATBehaviourType: "
1120                "behaviour type could not be read (" +
1121                    getErrorMessage() + ")");
1122       return static_cast<unsigned short>(u);
1123     }  // end of ExternalLibraryManager::getUMATBehaviourType
1124 
getUMATBehaviourKinematic(const std::string & l,const std::string & f)1125     unsigned short ExternalLibraryManager::getUMATBehaviourKinematic(const std::string& l,
1126                                                                      const std::string& f) {
1127       const auto lib = this->loadLibrary(l);
1128       const auto u = ::tfel_getUnsignedShort(lib, (f + "_BehaviourKinematic").c_str());
1129       raise_if(u == -1,
1130                "ExternalLibraryManager::getUMATBehaviourKinematic: "
1131                "behaviour type could not be read (" +
1132                    getErrorMessage() + ")");
1133       return static_cast<unsigned short>(u);
1134     }  // end of ExternalLibraryManager::getUMATBehaviourKinematic
1135 
getUMATSymmetryType(const std::string & l,const std::string & f)1136     unsigned short ExternalLibraryManager::getUMATSymmetryType(const std::string& l,
1137                                                                const std::string& f) {
1138       const auto lib = this->loadLibrary(l);
1139       const auto u = ::tfel_getUnsignedShort(lib, (f + "_SymmetryType").c_str());
1140       raise_if(u == -1,
1141                "ExternalLibraryManager::getUMATSymmetryType: "
1142                "symmetry type could not be read (" +
1143                    getErrorMessage() + ")");
1144       return static_cast<unsigned short>(u);
1145     }  // end of ExternalLibraryManager::getUMATSymmetryType
1146 
getUMATElasticSymmetryType(const std::string & l,const std::string & f)1147     unsigned short ExternalLibraryManager::getUMATElasticSymmetryType(const std::string& l,
1148                                                                       const std::string& f) {
1149       const auto lib = this->loadLibrary(l);
1150       const auto u = ::tfel_getUnsignedShort(lib, (f + "_ElasticSymmetryType").c_str());
1151       raise_if(u == -1,
1152                "ExternalLibraryManager::getUMATElasticSymmetryType: "
1153                "elastic symmetry type could not be read "
1154                "(" + getErrorMessage() + ")");
1155       return static_cast<unsigned short>(u);
1156     }  // end of ExternalLibraryManager::getUMATElasticSymmetryType
1157 
getUMATMaterialPropertiesNames(const std::string & l,const std::string & f,const std::string & h)1158     std::vector<std::string> ExternalLibraryManager::getUMATMaterialPropertiesNames(
1159         const std::string& l, const std::string& f, const std::string& h) {
1160       std::vector<std::string> vars;
1161       this->getUMATNames(vars, l, f, h, "MaterialProperties");
1162       return vars;
1163     }  // end of ExternalLibraryManager::getUMATMaterialPropertiesNames
1164 
getUMATGradientsNames(const std::string & l,const std::string & f)1165     std::vector<std::string> ExternalLibraryManager::getUMATGradientsNames(
1166         const std::string& l, const std::string& f) {
1167       std::vector<std::string> names;
1168       this->getUMATNames(names, l, f, "", "Gradients");
1169       return names;
1170     }  // end of ExternalLibraryManager::getUMATGradientsNames
1171 
getUMATDrivingVariablesNames(const std::string & l,const std::string & f)1172     std::vector<std::string> ExternalLibraryManager::getUMATDrivingVariablesNames(
1173         const std::string& l, const std::string& f) {
1174       return this->getUMATGradientsNames(l,f);
1175     }  // end of ExternalLibraryManager::getUMATDrivingVariablesNames
1176 
getUMATGradientsTypes(const std::string & l,const std::string & f)1177     std::vector<int> ExternalLibraryManager::getUMATGradientsTypes(
1178         const std::string& l, const std::string& f) {
1179       std::vector<int> types;
1180       this->getUMATTypes(types, l, f, "", "Gradients");
1181       return types;
1182     }  // end of ExternalLibraryManager::getUMATGradientsTypes
1183 
getUMATDrivingVariablesTypes(const std::string & l,const std::string & f)1184     std::vector<int> ExternalLibraryManager::getUMATDrivingVariablesTypes(
1185         const std::string& l, const std::string& f) {
1186       return this->getUMATGradientsTypes(l,f);
1187     } // end of ExternalLibraryManager::getUMATDrivingVariablesTypes
1188 
getUMATThermodynamicForcesNames(const std::string & l,const std::string & f)1189     std::vector<std::string> ExternalLibraryManager::getUMATThermodynamicForcesNames(
1190         const std::string& l, const std::string& f) {
1191       std::vector<std::string> names;
1192       this->getUMATNames(names, l, f, "", "ThermodynamicForces");
1193       return names;
1194     }  // end of ExternalLibraryManager::getUMATThermodynamicForcesNames
1195 
getUMATThermodynamicForcesTypes(const std::string & l,const std::string & f)1196     std::vector<int> ExternalLibraryManager::getUMATThermodynamicForcesTypes(
1197         const std::string& l, const std::string& f) {
1198       std::vector<int> types;
1199       this->getUMATTypes(types, l, f, "", "ThermodynamicForces");
1200       return types;
1201     }  // end of ExternalLibraryManager::getUMATThermodynamicForcesTypes
1202 
getUMATInternalStateVariablesNames(const std::string & l,const std::string & f,const std::string & h)1203     std::vector<std::string> ExternalLibraryManager::getUMATInternalStateVariablesNames(
1204         const std::string& l, const std::string& f, const std::string& h) {
1205       std::vector<std::string> vars;
1206       this->getUMATNames(vars, l, f, h, "InternalStateVariables");
1207       return vars;
1208     }  // end of ExternalLibraryManager::getUMATInternalStateVariablesNames
1209 
getUMATInternalStateVariablesTypes(const std::string & l,const std::string & f,const std::string & h)1210     std::vector<int> ExternalLibraryManager::getUMATInternalStateVariablesTypes(
1211         const std::string& l, const std::string& f, const std::string& h) {
1212       std::vector<int> types;
1213       this->getUMATTypes(types,l,f,h,"InternalStateVariables");
1214       return types;
1215     }  // end of ExternalLibraryManager::getUMATInternalVariablesTypes
1216 
getUMATExternalStateVariablesNames(const std::string & l,const std::string & f,const std::string & h)1217     std::vector<std::string> ExternalLibraryManager::getUMATExternalStateVariablesNames(
1218         const std::string& l, const std::string& f, const std::string& h) {
1219       std::vector<std::string> vars;
1220       this->getUMATNames(vars, l, f, h, "ExternalStateVariables");
1221       return vars;
1222     }  // end of ExternalLibraryManager::getUMATMaterialPropertiesNames
1223 
getUMATParametersNames(const std::string & l,const std::string & f,const std::string & h)1224     std::vector<std::string> ExternalLibraryManager::getUMATParametersNames(const std::string& l,
1225                                                                             const std::string& f,
1226                                                                             const std::string& h) {
1227       std::vector<std::string> names;
1228       this->getUMATNames(names, l, f, h, "Parameters");
1229       return names;
1230     }  // end of ExternalLibraryManager::getUMATMaterialPropertiesNames
1231 
getUMATParametersTypes(const std::string & l,const std::string & f,const std::string & h)1232     std::vector<int> ExternalLibraryManager::getUMATParametersTypes(const std::string& l,
1233                                                                     const std::string& f,
1234                                                                     const std::string& h) {
1235       std::vector<int> types;
1236       this->getUMATTypes(types,l,f,h,"Parameters");
1237       return types;
1238     }  // end of ExternalLibraryManager::getUMATInternalVariablesTypes
1239 
getCastemFunction(const std::string & l,const std::string & f)1240     CastemFunctionPtr ExternalLibraryManager::getCastemFunction(const std::string& l,
1241                                                                 const std::string& f) {
1242       const auto lib = this->loadLibrary(l);
1243       auto fct = ::tfel_getCastemFunction(lib, f.c_str());
1244       raise_if(fct == nullptr,
1245                "ExternalLibraryManager::getCastemFunction: "
1246                "could not load castem function '" +
1247                    f +
1248                    "' "
1249                    "(" +
1250                    getErrorMessage() + ")");
1251       return fct;
1252     }
1253 
getCFunction0(const std::string & l,const std::string & f)1254     CFunction0Ptr ExternalLibraryManager::getCFunction0(const std::string& l,
1255                                                         const std::string& f) {
1256       const auto lib = this->loadLibrary(l);
1257       const auto fct = ::tfel_getCFunction0(lib, f.c_str());
1258       raise_if(fct == nullptr,
1259                "ExternalLibraryManager::getCFunction0: "
1260                "could not load function '" +
1261                    f +
1262                    "' "
1263                    "(" +
1264                    getErrorMessage() + ")");
1265       return fct;
1266     }
1267 
getCFunction1(const std::string & l,const std::string & f)1268     CFunction1Ptr ExternalLibraryManager::getCFunction1(const std::string& l,
1269                                                         const std::string& f) {
1270       const auto lib = this->loadLibrary(l);
1271       const auto fct = ::tfel_getCFunction1(lib, f.c_str());
1272       raise_if(fct == nullptr,
1273                "ExternalLibraryManager::getCFunction1: "
1274                "could not load function '" +
1275                    f +
1276                    "' "
1277                    "(" +
1278                    getErrorMessage() + ")");
1279       return fct;
1280     }
1281 
getCFunction2(const std::string & l,const std::string & f)1282     CFunction2Ptr ExternalLibraryManager::getCFunction2(const std::string& l,
1283                                                         const std::string& f) {
1284       const auto lib = this->loadLibrary(l);
1285       const auto fct = ::tfel_getCFunction2(lib, f.c_str());
1286       raise_if(fct == nullptr,
1287                "ExternalLibraryManager::getCFunction2: "
1288                "could not load function '" +
1289                    f +
1290                    "' "
1291                    "(" +
1292                    getErrorMessage() + ")");
1293       return fct;
1294     }
1295 
getCFunction3(const std::string & l,const std::string & f)1296     CFunction3Ptr ExternalLibraryManager::getCFunction3(const std::string& l,
1297                                                         const std::string& f) {
1298       const auto lib = this->loadLibrary(l);
1299       const auto fct = ::tfel_getCFunction3(lib, f.c_str());
1300       raise_if(fct == nullptr,
1301                "ExternalLibraryManager::getCFunction3: "
1302                "could not load function '" +
1303                    f +
1304                    "' "
1305                    "(" +
1306                    getErrorMessage() + ")");
1307       return fct;
1308     }
1309 
getCFunction4(const std::string & l,const std::string & f)1310     CFunction4Ptr ExternalLibraryManager::getCFunction4(const std::string& l,
1311                                                         const std::string& f) {
1312       const auto lib = this->loadLibrary(l);
1313       const auto fct = ::tfel_getCFunction4(lib, f.c_str());
1314       raise_if(fct == nullptr,
1315                "ExternalLibraryManager::getCFunction4: "
1316                "could not load function '" +
1317                    f +
1318                    "' "
1319                    "(" +
1320                    getErrorMessage() + ")");
1321       return fct;
1322     }
1323 
getCFunction5(const std::string & l,const std::string & f)1324     CFunction5Ptr ExternalLibraryManager::getCFunction5(const std::string& l,
1325                                                         const std::string& f) {
1326       const auto lib = this->loadLibrary(l);
1327       const auto fct = ::tfel_getCFunction5(lib, f.c_str());
1328       raise_if(fct == nullptr,
1329                "ExternalLibraryManager::getCFunction5: "
1330                "could not load function '" +
1331                    f +
1332                    "' "
1333                    "(" +
1334                    getErrorMessage() + ")");
1335       return fct;
1336     }
1337 
getCFunction6(const std::string & l,const std::string & f)1338     CFunction6Ptr ExternalLibraryManager::getCFunction6(const std::string& l,
1339                                                         const std::string& f) {
1340       const auto lib = this->loadLibrary(l);
1341       const auto fct = ::tfel_getCFunction6(lib, f.c_str());
1342       raise_if(fct == nullptr,
1343                "ExternalLibraryManager::getCFunction6: "
1344                "could not load function '" +
1345                    f +
1346                    "' "
1347                    "(" +
1348                    getErrorMessage() + ")");
1349       return fct;
1350     }
1351 
getCFunction7(const std::string & l,const std::string & f)1352     CFunction7Ptr ExternalLibraryManager::getCFunction7(const std::string& l,
1353                                                         const std::string& f) {
1354       const auto lib = this->loadLibrary(l);
1355       const auto fct = ::tfel_getCFunction7(lib, f.c_str());
1356       raise_if(fct == nullptr,
1357                "ExternalLibraryManager::getCFunction7: "
1358                "could not load function '" +
1359                    f +
1360                    "' "
1361                    "(" +
1362                    getErrorMessage() + ")");
1363       return fct;
1364     }
1365 
getCFunction8(const std::string & l,const std::string & f)1366     CFunction8Ptr ExternalLibraryManager::getCFunction8(const std::string& l,
1367                                                         const std::string& f) {
1368       const auto lib = this->loadLibrary(l);
1369       const auto fct = ::tfel_getCFunction8(lib, f.c_str());
1370       raise_if(fct == nullptr,
1371                "ExternalLibraryManager::getCFunction8: "
1372                "could not load function '" +
1373                    f +
1374                    "' "
1375                    "(" +
1376                    getErrorMessage() + ")");
1377       return fct;
1378     }
1379 
getCFunction9(const std::string & l,const std::string & f)1380     CFunction9Ptr ExternalLibraryManager::getCFunction9(const std::string& l,
1381                                                         const std::string& f) {
1382       const auto lib = this->loadLibrary(l);
1383       const auto fct = ::tfel_getCFunction9(lib, f.c_str());
1384       raise_if(fct == nullptr,
1385                "ExternalLibraryManager::getCFunction9: "
1386                "could not load function '" +
1387                    f +
1388                    "' "
1389                    "(" +
1390                    getErrorMessage() + ")");
1391       return fct;
1392     }
1393 
getCFunction10(const std::string & l,const std::string & f)1394     CFunction10Ptr ExternalLibraryManager::getCFunction10(const std::string& l,
1395                                                           const std::string& f) {
1396       const auto lib = this->loadLibrary(l);
1397       const auto fct = ::tfel_getCFunction10(lib, f.c_str());
1398       raise_if(fct == nullptr,
1399                "ExternalLibraryManager::getCFunction10: "
1400                "could not load function '" +
1401                    f +
1402                    "' "
1403                    "(" +
1404                    getErrorMessage() + ")");
1405       return fct;
1406     }
1407 
getCFunction11(const std::string & l,const std::string & f)1408     CFunction11Ptr ExternalLibraryManager::getCFunction11(const std::string& l,
1409                                                           const std::string& f) {
1410       const auto lib = this->loadLibrary(l);
1411       const auto fct = ::tfel_getCFunction11(lib, f.c_str());
1412       raise_if(fct == nullptr,
1413                "ExternalLibraryManager::getCFunction11: "
1414                "could not load function '" +
1415                    f +
1416                    "' "
1417                    "(" +
1418                    getErrorMessage() + ")");
1419       return fct;
1420     }
1421 
getCFunction12(const std::string & l,const std::string & f)1422     CFunction12Ptr ExternalLibraryManager::getCFunction12(const std::string& l,
1423                                                           const std::string& f) {
1424       const auto lib = this->loadLibrary(l);
1425       const auto fct = ::tfel_getCFunction12(lib, f.c_str());
1426       raise_if(fct == nullptr,
1427                "ExternalLibraryManager::getCFunction12: "
1428                "could not load function '" +
1429                    f +
1430                    "' "
1431                    "(" +
1432                    getErrorMessage() + ")");
1433       return fct;
1434     }
1435 
getCFunction13(const std::string & l,const std::string & f)1436     CFunction13Ptr ExternalLibraryManager::getCFunction13(const std::string& l,
1437                                                           const std::string& f) {
1438       const auto lib = this->loadLibrary(l);
1439       const auto fct = ::tfel_getCFunction13(lib, f.c_str());
1440       raise_if(fct == nullptr,
1441                "ExternalLibraryManager::getCFunction13: "
1442                "could not load function '" +
1443                    f +
1444                    "' "
1445                    "(" +
1446                    getErrorMessage() + ")");
1447       return fct;
1448     }
1449 
getCFunction14(const std::string & l,const std::string & f)1450     CFunction14Ptr ExternalLibraryManager::getCFunction14(const std::string& l,
1451                                                           const std::string& f) {
1452       const auto lib = this->loadLibrary(l);
1453       const auto fct = ::tfel_getCFunction14(lib, f.c_str());
1454       raise_if(fct == nullptr,
1455                "ExternalLibraryManager::getCFunction14: "
1456                "could not load function '" +
1457                    f +
1458                    "' "
1459                    "(" +
1460                    getErrorMessage() + ")");
1461       return fct;
1462     }
1463 
getCFunction15(const std::string & l,const std::string & f)1464     CFunction15Ptr ExternalLibraryManager::getCFunction15(const std::string& l,
1465                                                           const std::string& f) {
1466       const auto lib = this->loadLibrary(l);
1467       const auto fct = ::tfel_getCFunction15(lib, f.c_str());
1468       raise_if(fct == nullptr,
1469                "ExternalLibraryManager::getCFunction15: "
1470                "could not load function '" +
1471                    f +
1472                    "' "
1473                    "(" +
1474                    getErrorMessage() + ")");
1475       return fct;
1476     }
1477 
getFortranFunction0(const std::string & l,const std::string & f)1478     FortranFunction0Ptr ExternalLibraryManager::getFortranFunction0(const std::string& l,
1479                                                                     const std::string& f) {
1480       const auto lib = this->loadLibrary(l);
1481       const auto fct = ::tfel_getFortranFunction0(lib, f.c_str());
1482       raise_if(fct == nullptr,
1483                "ExternalLibraryManager::getFortranFunction0: "
1484                "could not load function '" +
1485                    f +
1486                    "' "
1487                    "(" +
1488                    getErrorMessage() + ")");
1489       return fct;
1490     }
1491 
getFortranFunction1(const std::string & l,const std::string & f)1492     FortranFunction1Ptr ExternalLibraryManager::getFortranFunction1(const std::string& l,
1493                                                                     const std::string& f) {
1494       const auto lib = this->loadLibrary(l);
1495       const auto fct = ::tfel_getFortranFunction1(lib, f.c_str());
1496       raise_if(fct == nullptr,
1497                "ExternalLibraryManager::getFortranFunction1: "
1498                "could not load function '" +
1499                    f +
1500                    "' "
1501                    "(" +
1502                    getErrorMessage() + ")");
1503       return fct;
1504     }
1505 
getFortranFunction2(const std::string & l,const std::string & f)1506     FortranFunction2Ptr ExternalLibraryManager::getFortranFunction2(const std::string& l,
1507                                                                     const std::string& f) {
1508       const auto lib = this->loadLibrary(l);
1509       const auto fct = ::tfel_getFortranFunction2(lib, f.c_str());
1510       raise_if(fct == nullptr,
1511                "ExternalLibraryManager::getFortranFunction2: "
1512                "could not load function '" +
1513                    f +
1514                    "' "
1515                    "(" +
1516                    getErrorMessage() + ")");
1517       return fct;
1518     }
1519 
getFortranFunction3(const std::string & l,const std::string & f)1520     FortranFunction3Ptr ExternalLibraryManager::getFortranFunction3(const std::string& l,
1521                                                                     const std::string& f) {
1522       const auto lib = this->loadLibrary(l);
1523       const auto fct = ::tfel_getFortranFunction3(lib, f.c_str());
1524       raise_if(fct == nullptr,
1525                "ExternalLibraryManager::getFortranFunction3: "
1526                "could not load function '" +
1527                    f +
1528                    "' "
1529                    "(" +
1530                    getErrorMessage() + ")");
1531       return fct;
1532     }
1533 
getFortranFunction4(const std::string & l,const std::string & f)1534     FortranFunction4Ptr ExternalLibraryManager::getFortranFunction4(const std::string& l,
1535                                                                     const std::string& f) {
1536       const auto lib = this->loadLibrary(l);
1537       const auto fct = ::tfel_getFortranFunction4(lib, f.c_str());
1538       raise_if(fct == nullptr,
1539                "ExternalLibraryManager::getFortranFunction4: "
1540                "could not load function '" +
1541                    f +
1542                    "' "
1543                    "(" +
1544                    getErrorMessage() + ")");
1545       return fct;
1546     }
1547 
getFortranFunction5(const std::string & l,const std::string & f)1548     FortranFunction5Ptr ExternalLibraryManager::getFortranFunction5(const std::string& l,
1549                                                                     const std::string& f) {
1550       const auto lib = this->loadLibrary(l);
1551       const auto fct = ::tfel_getFortranFunction5(lib, f.c_str());
1552       raise_if(fct == nullptr,
1553                "ExternalLibraryManager::getFortranFunction5: "
1554                "could not load function '" +
1555                    f +
1556                    "' "
1557                    "(" +
1558                    getErrorMessage() + ")");
1559       return fct;
1560     }
1561 
getFortranFunction6(const std::string & l,const std::string & f)1562     FortranFunction6Ptr ExternalLibraryManager::getFortranFunction6(const std::string& l,
1563                                                                     const std::string& f) {
1564       const auto lib = this->loadLibrary(l);
1565       const auto fct = ::tfel_getFortranFunction6(lib, f.c_str());
1566       raise_if(fct == nullptr,
1567                "ExternalLibraryManager::getFortranFunction6: "
1568                "could not load function '" +
1569                    f +
1570                    "' "
1571                    "(" +
1572                    getErrorMessage() + ")");
1573       return fct;
1574     }
1575 
getFortranFunction7(const std::string & l,const std::string & f)1576     FortranFunction7Ptr ExternalLibraryManager::getFortranFunction7(const std::string& l,
1577                                                                     const std::string& f) {
1578       const auto lib = this->loadLibrary(l);
1579       const auto fct = ::tfel_getFortranFunction7(lib, f.c_str());
1580       raise_if(fct == nullptr,
1581                "ExternalLibraryManager::getFortranFunction7: "
1582                "could not load function '" +
1583                    f +
1584                    "' "
1585                    "(" +
1586                    getErrorMessage() + ")");
1587       return fct;
1588     }
1589 
getFortranFunction8(const std::string & l,const std::string & f)1590     FortranFunction8Ptr ExternalLibraryManager::getFortranFunction8(const std::string& l,
1591                                                                     const std::string& f) {
1592       const auto lib = this->loadLibrary(l);
1593       const auto fct = ::tfel_getFortranFunction8(lib, f.c_str());
1594       raise_if(fct == nullptr,
1595                "ExternalLibraryManager::getFortranFunction8: "
1596                "could not load function '" +
1597                    f +
1598                    "' "
1599                    "(" +
1600                    getErrorMessage() + ")");
1601       return fct;
1602     }
1603 
getFortranFunction9(const std::string & l,const std::string & f)1604     FortranFunction9Ptr ExternalLibraryManager::getFortranFunction9(const std::string& l,
1605                                                                     const std::string& f) {
1606       const auto lib = this->loadLibrary(l);
1607       const auto fct = ::tfel_getFortranFunction9(lib, f.c_str());
1608       raise_if(fct == nullptr,
1609                "ExternalLibraryManager::getFortranFunction9: "
1610                "could not load function '" +
1611                    f +
1612                    "' "
1613                    "(" +
1614                    getErrorMessage() + ")");
1615       return fct;
1616     }
1617 
getFortranFunction10(const std::string & l,const std::string & f)1618     FortranFunction10Ptr ExternalLibraryManager::getFortranFunction10(const std::string& l,
1619                                                                       const std::string& f) {
1620       const auto lib = this->loadLibrary(l);
1621       const auto fct = ::tfel_getFortranFunction10(lib, f.c_str());
1622       raise_if(fct == nullptr,
1623                "ExternalLibraryManager::getFortranFunction10: "
1624                "could not load function '" +
1625                    f +
1626                    "' "
1627                    "(" +
1628                    getErrorMessage() + ")");
1629       return fct;
1630     }
1631 
getFortranFunction11(const std::string & l,const std::string & f)1632     FortranFunction11Ptr ExternalLibraryManager::getFortranFunction11(const std::string& l,
1633                                                                       const std::string& f) {
1634       const auto lib = this->loadLibrary(l);
1635       const auto fct = ::tfel_getFortranFunction11(lib, f.c_str());
1636       raise_if(fct == nullptr,
1637                "ExternalLibraryManager::getFortranFunction11: "
1638                "could not load function '" +
1639                    f +
1640                    "' "
1641                    "(" +
1642                    getErrorMessage() + ")");
1643       return fct;
1644     }
1645 
getFortranFunction12(const std::string & l,const std::string & f)1646     FortranFunction12Ptr ExternalLibraryManager::getFortranFunction12(const std::string& l,
1647                                                                       const std::string& f) {
1648       const auto lib = this->loadLibrary(l);
1649       const auto fct = ::tfel_getFortranFunction12(lib, f.c_str());
1650       raise_if(fct == nullptr,
1651                "ExternalLibraryManager::getFortranFunction12: "
1652                "could not load function '" +
1653                    f +
1654                    "' "
1655                    "(" +
1656                    getErrorMessage() + ")");
1657       return fct;
1658     }
1659 
getFortranFunction13(const std::string & l,const std::string & f)1660     FortranFunction13Ptr ExternalLibraryManager::getFortranFunction13(const std::string& l,
1661                                                                       const std::string& f) {
1662       const auto lib = this->loadLibrary(l);
1663       const auto fct = ::tfel_getFortranFunction13(lib, f.c_str());
1664       raise_if(fct == nullptr,
1665                "ExternalLibraryManager::getFortranFunction13: "
1666                "could not load function '" +
1667                    f +
1668                    "' "
1669                    "(" +
1670                    getErrorMessage() + ")");
1671       return fct;
1672     }
1673 
getFortranFunction14(const std::string & l,const std::string & f)1674     FortranFunction14Ptr ExternalLibraryManager::getFortranFunction14(const std::string& l,
1675                                                                       const std::string& f) {
1676       const auto lib = this->loadLibrary(l);
1677       const auto fct = ::tfel_getFortranFunction14(lib, f.c_str());
1678       raise_if(fct == nullptr,
1679                "ExternalLibraryManager::getFortranFunction14: "
1680                "could not load function '" +
1681                    f +
1682                    "' "
1683                    "(" +
1684                    getErrorMessage() + ")");
1685       return fct;
1686     }
1687 
getFortranFunction15(const std::string & l,const std::string & f)1688     FortranFunction15Ptr ExternalLibraryManager::getFortranFunction15(const std::string& l,
1689                                                                       const std::string& f) {
1690       const auto lib = this->loadLibrary(l);
1691       const auto fct = ::tfel_getFortranFunction15(lib, f.c_str());
1692       raise_if(fct == nullptr,
1693                "ExternalLibraryManager::getFortranFunction15: "
1694                "could not load function '" +
1695                    f +
1696                    "' "
1697                    "(" +
1698                    getErrorMessage() + ")");
1699       return fct;
1700     }
1701 
1702     ExternalLibraryManager::~ExternalLibraryManager() = default;
1703 
1704   }  // end of namespace system
1705 
1706 }  // end of namespace tfel
1707