-
Notifications
You must be signed in to change notification settings - Fork 3
/
macros.edp
92 lines (68 loc) · 3.18 KB
/
macros.edp
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
/* Florian OMNES (florian.omnes@upmc.fr) */
/* Charles DAPOGNY (charles.dapogny@univ-grenoble-alpes.fr) */
/* Pascal FREY (pascal.frey@upmc.fr) */
/* Yannick PRIVAT (yannick.privat@upmc.fr */
/* Copyright Sorbonne-Universités 2015-2018 */
/* PLEASE DO NOT REMOVE THIS BANNER */
/* Macros used throughout the code */
/* Horizontal component of a typical Poiseuille flow */
func real poiseuillex(real xa,real ya,real xb,real yb,real xx,real yy) {
real alpha = 1;
real ymin = min(ya, yb);
real ymax = max(ya, yb);
real xmin = min(xa, xb);
real xmax = max(xa, xb);
real s = (xa-xx)/(xa-xb);
// cout << xmin << endl;
return (yy>ymin)*(yy<ymax)*(xx>xmin)*(xx<xmax)*alpha*s*(1-s)*(-(yb-ya));
}
/* Vertical component of a typical Poiseuille flow */
func real poiseuilley(real xa,real ya,real xb,real yb,real xx,real yy) {
real alpha = 1;
real ymin = min(ya, yb);
real ymax = max(ya, yb);
real xmin = min(xa, xb);
real xmax = max(xa, xb);
real s = (ya-yy)/(ya-yb);
return (yy>ymin)*(yy<ymax)*(xx>xmin)*(xx<xmax)*alpha*s*(1-s)*((xb-xa));
}
/* Strain tensor */
macro EPS(u, v) [dx(u), 1./2*(dx(v)+dy(u)), 1./2*(dx(v)+dy(u)), dy(v)] // EOM
/* Jacobian matrix */
macro GRAD(u, v) [dx(u), dy(u), dx(v), dy(v)] // EOM
/* (u \cdot \nabla) V */
macro UgradV(u1,u2,v1,v2) [ [u1,u2]'*[dx(v1),dy(v1)] , [u1,u2]'*[dx(v2),dy(v2)] ]// EOM
/* Divergence of u */
macro div(u, v) (dx(u)+dy(v)) // EOM
/* Stress tensor involved in the elasticity system for velocity extension/regularization */
macro SIG(u, v) [2*muela*dx(u) + laela*div(u,v), muela*(dx(v)+dy(u)), muela*(dx(v)+dy(u)), 2*muela*dy(v) + laela*div(u,v)] //EOM
/* Normal component of the matrix M */
macro MN(M) [M[0]*N.x+M[1]*N.y, M[2]*N.x+M[3]*N.y] //EOM
/* Transpose of M */
macro tr(M) M' //EOM
/* u \cdot n for a vector function u=(u1,u2) */
macro dotN(u1,u2) (u1*N.x+u2*N.y) //EOM
/* u \cdot \tau for a vector function u=(u1,u2) */
macro dotT(u1,u2) (u1*N.y-u2*N.x) //EOM
/* Objective function = weighted sum of energy dissipation and least-square difference with a
prescribed flow */
macro J() (2*delta*nu*int2d(Th)(tr(EPS(ux,uy))*EPS(ux,uy)) + ((1.-delta)/2)*int1d(Th,2)((ux-uxx)^2+(uy-uyy)^2)) //EOM
/* Shape derivative of the objective function */
macro IJ() (-2*delta*nu*tr(EPS(ux,uy))*EPS(ux,uy) + 2*nu*tr(EPS(ux,uy))*EPS(vx,vy)) //EOM
/* Volume of a shape supplied by mesh Th */
macro vol(Th) int2d(Th)(1.) //EOM
/* Perimeter of the contour of a shape supplied by mesh Th */
macro perim(Th) int1d(Th)(1.) //EOM
/* Constraint function = weighted sum of volume and perimeter */
macro contr(Th) (beta*int2d(Th)(1.)+(1.-beta)*int1d(Th)(1.)) //EOM
/* Augmented Lagrangian */
macro EL() (J/J0 + l*(contr(Th) - ctarget)/c0 + b/2 * ((contr(Th) - ctarget)^2)/(c0^2)) //EOM
//macro gradV() (IJ/J0 + l/vol0 + b*(vol(Th)-voltarget)/(vol0^2)) //EOM
/* Shape gradient of the constraint function */
macro gradC() (beta*1+(1.-beta)*kappa) //EOM
/* Shape-gradient of the Lagrangian */
macro gradDF() (IJ/J0 + l*gradC/c0 + b*gradC*(contr(Th)-ctarget)/(c0^2)) //EOM
/* (Vector) gradient of a scale function u */
macro grad(u) [dx(u), dy(u)] // EOM
/* (Scalar) tangential derivative of a scalar function u */
macro gradT(u) (grad(u) - grad(u)'*[N.x, N.y]*[N.x, N.y]) // EOM