forked from 541435721/myVTKPythonLibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadAbaqusStressesFromDAT.py
53 lines (37 loc) · 1.81 KB
/
readAbaqusStressesFromDAT.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
#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 readAbaqusStressFromDAT(
data_filename,
verbose=1):
myVTK.myPrint(verbose, "*** readAbaqusStressFromDAT: "+data_filename+" ***")
s_array = myVTK.createFloatArray("", 6)
data_file = open(data_filename, 'r')
context = ""
k_cell = 0
for line in data_file:
if (context == "reading stresses"):
#print line
if ("MAXIMUM" in line):
context = ""
continue
if ("OR" in line):
splitted_line = line.split()
assert (int(splitted_line[0]) == k_cell+1), "Wrong element number. Aborting."
s_list = [float(splitted_line[k]) for k in xrange(3,9)]
s_array.InsertNextTuple(s_list)
k_cell += 1
if (line == " ELEMENT PT FOOT- S11 S22 S33 S12 S13 S23 \n"):
context = "reading stresses"
data_file.close()
myVTK.myPrint(verbose-1, "n_tuples = "+str(s_array.GetNumberOfTuples()))
return s_array