-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusub.cpp.py
79 lines (65 loc) · 3.21 KB
/
usub.cpp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#coding=utf8
########################################################################
### ###
### Created by Martin Genet, 2008-2016 ###
### ###
### Laboratoire de Mécanique et de Technologie (LMT), Cachan, France ###
### Lawrence Berkeley National Laboratory, California, USA ###
### University of California at San Francisco, USA ###
### Swiss Federal Institute of Technology (ETH), Zurich, Switzerland ###
### École Polytechnique, Palaiseau, France ###
### ###
########################################################################
import glob
usub_cpp_file = open("usub.cpp", "w")
usub_cpp_file.write('''\
// Generated by usub.cpp.py.
#ifndef usub_cpp
#define usub_cpp
#include <stdio.h>
#include <string.h>
''')
uexternaldbs = glob.glob("UEXTERNALDB_*")
assert (len(uexternaldbs) in (0,1)), "There should be zero or one UEXTERNALDB folder. Aborting."
if (len(uexternaldbs) == 1):
usub_cpp_file.write('''\
#include "'''+uexternaldbs[0]+'''/uexternaldb.cpp"
extern "C" void uexternaldb_(int* lop, int* lrestart, double* time, double* dtime, int* kstep, int* kinc)
{
uexternaldb::uexternaldb(lop, lrestart, time, dtime, kstep, kinc);
} // void uexternaldb_
''')
umats = glob.glob("UMAT_C_*")
if (len(umats) > 0):
usub_cpp_file.write('''\
#include "umat_data.cpp"
''')
for umat in umats:
usub_cpp_file.write('''\
#include "''' + umat + '''/umat.cpp"
''')
usub_cpp_file.write('''\
/**
*
* This is the general UMat function.
* Depending on the name of the material model chosen in ABAQUS, the specific UMat function is executed.
* Before that, a UMatData structure is created, that contains all data given by ABAQUS, but reinterpreted in LMT++ types (names are conserved).
*
*/
extern "C" void umat_(double* stress, double* statev, double* ddsdde, double* sse, double* spd, double* scd, double* rpl, double* ddsddt, double* drplde, double* drpldt, double* stran, double* dstran, double* time, double* dtime, double* temp, double* dtemp, double* predef, double* dpred, char *cmname, int *ndi, int *nshr, int *ntens, int *nstatv, double* props, int *nprops, double* coords, double* drot, double* pnewdt, double* celent, double* dfgrd0, double* dfgrd1, int *noel, int *npt, int *layer, int *kspt, int *kstep, int *kinc, short cmname_len)
{
''')
for umat in umats:
usub_cpp_file.write('''\
if (strncmp(cmname, "'''+umat+'''", '''+str(len(umat))+''') == 0)
{
UMatData<'''+umat.lower()+'''::ndim, '''+umat.lower()+'''::nvec, '''+umat.lower()+'''::npro, '''+umat.lower()+'''::nsta> umat_data(stress, statev, ddsdde, sse, spd, scd, rpl, ddsddt, drplde, drpldt, stran, dstran, time, dtime, temp, dtemp, predef, dpred, cmname, ndi, nshr, ntens, nstatv, props, nprops, coords, drot, pnewdt, celent, dfgrd0, dfgrd1, noel, npt, layer, kspt, kstep, kinc, cmname_len);
'''+umat.lower()+'''::umat(umat_data);
}
''')
usub_cpp_file.write('''\
} // void umat_
''')
usub_cpp_file.write('''\
#endif // # ifndef usub_cpp
''')