forked from 541435721/myVTKPythonLibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwriteFiberOrientationFileForAbaqus.py
47 lines (36 loc) · 1.63 KB
/
writeFiberOrientationFileForAbaqus.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
#coding=utf8
########################################################################
### ###
### Created by Martin Genet, 2012-2016 ###
### ###
### University of California at San Francisco (UCSF), USA ###
### Swiss Federal Institute of Technology (ETH), Zurich, Switzerland ###
### École Polytechnique, Palaiseau, France ###
### ###
########################################################################
import myVTKPythonLibrary as myVTK
########################################################################
def writeFiberOrientationFileForAbaqus(
mesh,
filename,
eF_field_name="eF",
eS_field_name="eS",
sep=", ",
verbose=1):
myVTK.myPrint(verbose, "*** writeFiberOrientationFileForAbaqus ***")
orientation_file = open(filename, "w")
orientation_file.write(", 1., 0., 0., 0., 1., 0."+"\n")
n_cells = mesh.GetNumberOfCells()
eF_array = mesh.GetCellData().GetArray(eF_field_name)
eS_array = mesh.GetCellData().GetArray(eS_field_name)
eF = numpy.empty(3)
eS = numpy.empty(3)
for k_cell in xrange(n_cells):
eF_array.GetTuple(k_cell, eF)
eS_array.GetTuple(k_cell, eS)
line = str(k_cell+1)
for k in xrange(3): line += sep + str(eF[k])
for k in xrange(3): line += sep + str(eS[k])
line += "\n"
orientation_file.write(line)
orientation_file.close()