-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgrowth.js
215 lines (199 loc) · 5.75 KB
/
growth.js
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/**
* @page Growth
* Growth functions
*
* Grow functions affect the rest configuration of the model's geometry
*
* Depends on algebra.js and geometry.js
*/
function myGrowth() {
// Variables storing growth parametres
this.g={}; // growth tensor in material coordinates (a 3x3 matrix)
this.T=0; // time constant
}
function initGrowth(params) {
var gr=new myGrowth();
gr.G=params.G;
gr.T=params.T;
return gr;
}
/**
* @function growHomogeneous
*/
function growHomogeneous(ge,gr) {
var nt=ge.nt;
var t=ge.t;
var p=ge.p;
var r=ge.r;
var H=gr.G; // homogeneous growth factor
var i,j,k,m,n;
// for each tetrahedron
for(i=0;i<nt;i++) {
// for each tetra. node
for(j=0;j<4;j++) {
n=t[4*i+j]; // material node indices
m=4*i+j; // rest node indices
// growth function: homogeneous growth
for(k=0;k<3;k++) {
r[m*3+k]=p[n*3+k]*H;
}
}
}
}
/**
* @function growBlockBorderInstantaneous
*/
function growBlockBorderInstantaneous(ge,gr) {
var nw=ge.nw;
var nh=ge.nh;
var nd=ge.nd;
var t=ge.t;
var p=ge.p;
var r=ge.r;
var H=gr.G;
var i,j,k,l,m,n;
var numbox,numtet,im,ir;
// tetrahedral boxes
j=nh-2;
for(i=0;i<nw-1;i++)
for(k=0;k<nd-1;k++)
{
// box element index
numbox=i*(nh-1)*(nd-1)+j*(nd-1)+k;
// box's tetrahedral element index
for(l=0;l<5;l++) {
numtet=numbox*5+l;
// tetrahedron's node index
for(m=0;m<4;m++) {
im=t[numtet*4+m]; // material vertex index
ir=numtet*4+m; // rest vertex index
for(n=0;n<3;n++)
r[ir*3+n]=p[im*3+n]*H;
}
}
}
}
/**
* @function growRingBorderInstantaneous
*/
function growRingBorderInstantaneous(ge,gr) {
var ntheta=ge.ntheta;
var nxy=ge.nxy;
var nz=ge.nz;
var t=ge.t;
var p=ge.p;
var r=ge.r;
var H=gr.G;
var i,j,k,l,m,n;
var numbox,numtet,im,ir;
// tetrahedral boxes
j=nxy-2;
for(i=0;i<ntheta;i++)
for(k=0;k<nz-1;k++)
{
// box element index
numbox=i*(nxy-1)*(nz-1)+j*(nz-1)+k;
// box's tetrahedral element index
for(l=0;l<5;l++) {
numtet=numbox*5+l;
// tetrahedron's node index
for(m=0;m<4;m++) {
im=t[numtet*4+m]; // material vertex index
ir=numtet*4+m; // rest vertex index
for(n=0;n<3;n++)
r[ir*3+n]=p[im*3+n]*H;
}
}
}
}
/**
* @function growRingBorderProgressive
*/
function growRingBorderProgressive(ge,gr,time) {
var ntheta=ge.ntheta;
var nxy=ge.nxy;
var nz=ge.nz;
var t=ge.t;
var p=ge.p;
var r=ge.r;
var H=gr.G;
var T=gr.T;
var i,j,k,l,m,n;
var numbox,numtet,im,ir;
if(time>T)
return;
// tetrahedral boxes
j=nxy-2;
for(i=0;i<ntheta;i++)
for(k=0;k<nz-1;k++)
{
// box element index
numbox=i*(nxy-1)*(nz-1)+j*(nz-1)+k;
// box's tetrahedral element index
for(l=0;l<5;l++) {
numtet=numbox*5+l;
// tetrahedron's node index
for(m=0;m<4;m++) {
im=t[numtet*4+m]; // material vertex index
ir=numtet*4+m; // rest vertex index
for(n=0;n<3;n++)
r[ir*3+n]=p[im*3+n]*Math.pow(H,1/(T/dt));
}
}
}
}
/**
* @function growRingTangentialInstantaneous
* @description Each vertex in the original ring has coordinates x,y,z. The coordinates x,y are in the plane of the ring, z is in the plane of its thickness. The function growTangential produces a tangential expansion of the ring at rest, i.e., it alters the x,y coordinates, without changing the z coordinate (thickness), nor the radial size of each finite element. WRONG FOLLOWS: This is achieved by displacing each x,y point radially. The amount of displacement is such that the angle supported by each finite element will be multiplied by the dilatation parametre D. The total perimeter of a ring at a distance R from the central axis is 2*pi*R and will become 2*pi*R*D. Then, each point x,y at distance R has to be displaced to a distance R*D, i.e., they have to be multiplied by a factor D such that (x*D)^2+(y*D)^2=(R*D)^2.
*/
function growRingTangentialInstantaneous(ge,gr) {
var ntheta=ge.ntheta;
var nxy=ge.nxy;
var nz=ge.nz;
var t=ge.t;
var r=ge.r;
var Ro=ge.Ro;
var Ri=ge.Ri;
var D=gr.G;
var i,j,k,l,m,n;
var numbox,numtet;
var im,ir;
var theta,R,z;
var a,di,dj,dtheta;
for(i=0;i<ntheta;i++)
for(j=0;j<nxy-1;j++)
for(k=0;k<nz-1;k++)
{
numbox=i*(nxy-1)*(nz-1)+j*(nz-1)+k;
for(l=0;l<5;l++) {
numtet=numbox*5+l;
a=tetraTopo[l].split(" ");
for(m=0;m<4;m++) {
ir=numtet*4+m; // index of rest vertex
di=parseInt(a[m].charAt(0));
dj=parseInt(a[m].charAt(1));
theta=2*Math.PI*(i+di)/ntheta;
R=Ro*((j+dj)/nxy)+Ri*(1-(j+dj)/nxy);
dtheta=(D-1)*(Math.PI/ntheta)*(2*di-1);
r[ir*3+0]=R*Math.cos(theta+dtheta);
r[ir*3+1]=R*Math.sin(theta+dtheta);
}
}
}
}
/**
* @function growSurface
*/
function growSurfaceHomogeneousInstantaneous(ge,gr) {
var nt=ge.nt;
var r=ge.r;
var H=gr.G; // homogeneous growth
var i,j,k,ir;
for(i=0;i<nt;i++) // each tetrahedron
for(j=0;j<4;j++) {
ir=4*i+j; // rest vertex
for(k=0;k<3;k++) {
r[3*ir+k]*=H;
}
}
}