Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
readAUX.py
Go to the documentation of this file.
1import numpy as np
2
3class AUX:
4 # Mesh node data
5 meshNodes = np.empty([0, 0])
6
7 # Gauss point data
8 gaussPoints = np.empty([0, 0])
9 sourceID = np.empty(0)
10 sinkID = np.empty(0)
11 qID = np.empty(0)
12 r = np.empty([0, 0])
13 j = np.empty(0)
14 rl = np.empty([0, 0])
15 stress = np.empty([0, 0, 0])
16 pkForce = np.empty([0, 0])
17 stackingFaultForce = np.empty([0, 0])
18 lineTensionForce = np.empty([0, 0])
19 velocity = np.empty([0, 0])
20 elasticEnergyPerLength = np.empty(0)
21 coreEnergyPerLength = np.empty(0)
22 cCD = np.empty([0, 0])
23 cDD = np.empty([0, 0])
24
25 # Periodic patches (if any)
26 periodicPatches = np.empty([0, 0])
27
28def readAUXtxt(filename):
29 try:
30 with open(filename + '.txt', "r") as auxFile:
31 numNodes = int(auxFile.readline().strip())
32 numGPs = int(auxFile.readline().strip())
33 numPGPP = int(auxFile.readline().strip())
34
35 aux = AUX()
36
37 aux.meshNodes = np.empty((numNodes, 4))
38 aux.gaussPoints = np.empty((numGPs, 39))
39 aux.sourceID = np.empty(numGPs)
40 aux.sinkID = np.empty(numGPs)
41 aux.qID = np.empty(numGPs)
42 aux.r = np.empty((numGPs, 3))
43 aux.j = np.empty(numGPs)
44 aux.rl = np.empty((numGPs, 3))
45 aux.stress = np.empty((numGPs, 3, 3))
46 aux.pkForce = np.empty((numGPs, 3))
47 aux.stackingFaultForce = np.empty((numGPs, 3))
48 aux.lineTensionForce = np.empty((numGPs, 3))
49 aux.velocity = np.empty((numGPs, 3))
50 aux.elasticEnergyPerLength = np.empty(numGPs)
51 aux.coreEnergyPerLength = np.empty(numGPs)
52 aux.cCD = np.empty((numGPs, 3))
53 aux.cDD = np.empty((numGPs, 3))
54 aux.periodicPatches = np.empty((numPGPP, 4))
55
56 # mesh nodes
57 for k in range(numNodes):
58 aux.meshNodes[k, :] = np.fromstring(auxFile.readline().strip(), sep=' ')
59
60 # gauss points
61 for k in range(numGPs):
62 data = np.fromstring(auxFile.readline().strip(), sep=' ')
63 aux.gaussPoints[k, :] = data
64
65 aux.sourceID[k] = data[0]
66 aux.sinkID[k] = data[1]
67 aux.qID[k] = data[2]
68 aux.r[k, :] = data[3:6]
69 aux.j[k] = data[6]
70 aux.rl[k, :] = data[7:10]
71 aux.stress[k, :, :] = data[10:19].reshape(3, 3)
72 aux.pkForce[k, :] = data[19:22]
73 aux.stackingFaultForce[k, :] = data[22:25]
74 aux.lineTensionForce[k, :] = data[25:28]
75 aux.velocity[k, :] = data[28:31]
76 aux.elasticEnergyPerLength[k] = data[31]
77 aux.coreEnergyPerLength[k] = data[32]
78 aux.cCD[k, :] = data[33:36]
79 aux.cDD[k, :] = data[36:39]
80
81 # periodic patches
82 for k in range(numPGPP):
83 aux.periodicPatches[k, :] = np.fromstring(auxFile.readline().strip(), sep=' ')
84
85 return aux
86
87 except Exception as e:
88 print(f"Error reading file {filename}: {e}")
89 return None
readAUXtxt(filename)
Definition readAUX.py:28