-
Notifications
You must be signed in to change notification settings - Fork 1
/
aorta_mat_distribution.py
77 lines (71 loc) · 3.26 KB
/
aorta_mat_distribution.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
import sys
sys.path.append("./mesh")
import torch
from PolyhedronMesh import PolyhedronMesh
def generate_mat_distribution(id, folder='./data/'):
if id == 0:
return generate_mat_distribution0(folder)
elif id == 1:
return generate_mat_distribution1(folder)
elif id == 2:
return generate_mat_distribution2(folder)
elif id == 3:
return generate_mat_distribution3(folder)
def generate_mat_distribution0(folder='./data/'):
mesh_tube=PolyhedronMesh()
mesh_tube.load_from_torch(folder+'aorta_tube_solid_1layers.pt')
matMean=torch.load(folder+'125mat.pt')['mean_mat']
Mat=torch.tensor(matMean, dtype=torch.float64)
Mat=Mat.view(-1,6).expand(mesh_tube.element.shape[0], 6)
return Mat
def generate_mat_distribution1(folder='./data/'):
mesh_tube=PolyhedronMesh()
mesh_tube.load_from_torch(folder+'aorta_tube_solid_1layers.pt')
node=mesh_tube.node
element=mesh_tube.element
matMean=torch.load(folder++'125mat.pt')['mean_mat']
#element center
center=node[element].mean(dim=1)
z=center[:,2]
Mat=torch.zeros((element.shape[0], 6), dtype=torch.float64)
Mat[:,0]=matMean[0]*(1+0.1*torch.sin(0.01*z)+0.1*torch.sin(0.1*z)+0.1*torch.sin(z))
Mat[:,1]=matMean[1]*(1+0.1*torch.sin(0.009*z)+0.1*torch.sin(0.09*z)+0.1*torch.sin(z))
Mat[:,2]=matMean[2]*(1+0.1*torch.sin(0.008*z)+0.1*torch.sin(0.08*z)+0.1*torch.sin(z))
Mat[:,3]=matMean[3]*(1+0.1*torch.sin(0.007*z)+0.1*torch.sin(0.07*z)+0.1*torch.sin(z))
Mat[:,4]=matMean[4] # mean orientation
Mat[:,5]=matMean[5] # 1e5, a known constant
return Mat
def generate_mat_distribution2(folder='./data/'):
mesh_tube=PolyhedronMesh()
mesh_tube.load_from_torch(folder+'aorta_tube_solid_1layers.pt')
node=mesh_tube.node
element=mesh_tube.element
matMean=torch.load(folder+'125mat.pt')['mean_mat']
#element center
center=node[element].mean(dim=1)
z=center[:,2]*10
Mat=torch.zeros((element.shape[0], 6), dtype=torch.float64)
Mat[:,0]=matMean[0]*(1+0.1*torch.sin(0.01*z)+0.1*torch.sin(0.1*z)+0.1*torch.sin(z))
Mat[:,1]=matMean[1]*(1+0.1*torch.sin(0.009*z)+0.1*torch.sin(0.09*z)+0.1*torch.sin(z))
Mat[:,2]=matMean[2]*(1+0.1*torch.sin(0.008*z)+0.1*torch.sin(0.08*z)+0.1*torch.sin(z))
Mat[:,3]=matMean[3]*(1+0.1*torch.sin(0.007*z)+0.1*torch.sin(0.07*z)+0.1*torch.sin(z))
Mat[:,4]=matMean[4] # mean orientation
Mat[:,5]=matMean[5] # 1e5, a known constant
return Mat
def generate_mat_distribution3(folder='./data/'):
mesh_tube=PolyhedronMesh()
mesh_tube.load_from_torch(folder+'aorta_tube_solid_1layers.pt')
node=mesh_tube.node
element=mesh_tube.element
matMean=torch.load(folder+'125mat.pt')['mean_mat']
#element center
center=node[element].mean(dim=1)
z=center[:,2]*100
Mat=torch.zeros((element.shape[0], 6), dtype=torch.float64)
Mat[:,0]=matMean[0]*(1+0.1*torch.sin(0.01*z)+0.1*torch.sin(0.1*z)+0.1*torch.sin(z))
Mat[:,1]=matMean[1]*(1+0.1*torch.sin(0.009*z)+0.1*torch.sin(0.09*z)+0.1*torch.sin(z))
Mat[:,2]=matMean[2]*(1+0.1*torch.sin(0.008*z)+0.1*torch.sin(0.08*z)+0.1*torch.sin(z))
Mat[:,3]=matMean[3]*(1+0.1*torch.sin(0.007*z)+0.1*torch.sin(0.07*z)+0.1*torch.sin(z))
Mat[:,4]=matMean[4] # mean orientation
Mat[:,5]=matMean[5] # 1e5, a known constant
return Mat