Statistiques
| Révision :

root / Parameters_sm_fsn_fss_fsv / pulvinus-images.cpp @ 19

Historique | Voir | Annoter | Télécharger (9,94 ko)

1
include "getARGV.idp"
2
//include "bib_meca2d.cpp"
3

    
4
//usage :
5
//Freefem++ pulvinus.edp [-fE fEvalue] [-Nit Nit] [-geometry g]
6
//arguments:
7
//-fE fEvalue:
8
//-Nit Nit: number of iterations
9
//-geometry g: differnet geometries
10
//1: 
11
//2: 
12
//3: 
13

    
14

    
15

    
16
func real lineD(real xA, real xB, real yA, real yB)
17
{        return (yB-yA)/(xB-xA);
18
}
19

    
20
func real lineC(real xA, real xB, real yA, real yB)
21
{        return (yA*xB-yB*xA)/(xB-xA);
22
}
23

    
24
//real PI=3.14159265;
25

    
26
func real angleToVertical(real Mx, real My, real Nx, real Ny)
27
{ /*  Computes the sinus of angle between the MN vector and Oy   */
28
        return asin((Nx-Mx)/sqrt((Mx-Nx)^2+(My-Ny)^2))*180/pi;
29
}
30

    
31

    
32
/*************************************************************
33
 *                  PARAMETERS
34
 * **********************************************************/
35
 
36
// reading script arguments
37
for (int i=0;i<ARGV.n;++i)
38
{ cout << ARGV[i] << " ";}
39
cout<<endl;
40

    
41
verbosity = getARGV("-vv", 0);
42
int vdebug = getARGV("-d", 1);
43
// swelling ability of each region is a parameter
44
real sm = -getARGV("-sm", 0.568354);// mesophyl swelling property
45
real fsn = getARGV("-fsn", 0.899975);// nectary     sn/sm
46
real fss = getARGV("-fss", 1.19112);// side        ss/sm
47
real fsv = getARGV("-fsv", 0.491088);// vasculature sv/sm
48
int Nit = getARGV("-Nit", 1);
49
string geom = getARGV("-geometry", "1");
50
string output = getARGV("-out", ".");
51

    
52

    
53
cout<<"----------------------------------------------"<< endl;
54
cout<<"   sm="<<sm<< endl;
55

    
56
// ---------------- geometrical parameters
57

    
58
// (lengths are measured in micrometers)
59
real units=200;
60

    
61
// pulvinus dimensions
62
real lx=491.0/units;       //sd =34.4
63
real ly= 240.0/units;      //sd=36.0
64

    
65
// nectary height
66
real hnect = 38.8/units;   //sd=9.6
67
real R=363.0/units;    //sd=49.4
68

    
69
// side dimensions
70
real hside=91.4/units;     //12.6
71
real lside=47.6/units/2;     //6.6
72

    
73
// vasculature dimensions
74
real vthickness=34.3/units;//5.5
75
real cwidth=74.8/units;    //15.2
76
real cwidthdry=44.2/units; //8.4
77

    
78
// vasculature displacement (from vascular bundle distance)
79
real vd=(cwidth-cwidthdry)/2;
80
real vposition=lx/2-vthickness-hnect/ly*(lx/2-cwidth/2-vthickness); //cout<<"vposition="<<vposition<<endl;
81

    
82
// mesh parameters
83
int nvertex=50; cout << "nvertex="<<nvertex<<endl;
84
real pinned=lx/nvertex/2;
85

    
86

    
87
// ---------------- Material properties
88

    
89
real nu = 0.29;    // Poisson's ratio
90

    
91
// Young modulus
92
real Ev;   // vasculature Young modulus
93
real fEm; // mesophyl Em/Ev 
94
real fEn;  // nectary  En/Ev 
95
real fEs;  // side     Es/Ev 
96
        
97
// measured values for the density
98
//Region,Mean_tissue_density,SD_tissue_density
99
real dm=0.668060839; //sd=0.04091249
100
real dn=1.01896008; //sd=0.015464575
101
real ds=0.918032482; //sd=0.075097509
102
real dv=0.882171532; //sd=0.066651037
103

    
104
real nEd=1.0;
105

    
106
// Young modulus
107
Ev=1;   // vasculature Young modulus
108
fEm=(dm/dv)^nEd; // mesophyl Em/Ev 
109
fEn=(dn/dv)^nEd;  // nectary  En/Ev 
110
fEs=(ds/dv)^nEd;  // side     Es/Ev 
111

    
112
// hydrophobicity as swelling ability
113

    
114

    
115
/*************************************************************
116
 *                  GEOMETRY and MESH
117
 * **********************************************************/
118

    
119
string geomfilename="geometry"+geom+".cpp";
120
cout<<"including "<<geomfilename<<endl;
121
include "geometry1.cpp";
122

    
123
// -------------------- define the finite element space
124

    
125
fespace Vh(Th,[P2,P2]);  // vector on the mesh (displacement vector)
126
Vh [u1,u2], [v1,v2];
127

    
128
fespace Sh(Th, P2);   // scalar on the mesh, P2 elements
129
fespace Sh0(Th,P0);   // scalar on the mesh, P0 elements
130
fespace Sh1(Th,P1);   // scalar on the mesh, P1 elements
131

    
132
Sh0 strain, stress;
133

    
134
// bounding box for the plot (use the same for all images so that they can be superposed)
135
func bb=[[-lx/2*1.5,-ly*1],[lx/2*1.5,ly*.1]];
136
real coef=1;
137
cout << "Coefficent of amplification:"<<coef<<endl;
138
//plot(Th, fill=1, ps=output+"/original_geometry.png", bb=bb); -------------------------------
139

    
140
// macro to redefine variables on the displaced mesh 
141
macro redefineVariable(vvv)
142
{        real[int] temp(vvv[].n);
143
        temp=vvv[]; vvv=0; vvv[]=temp;
144
        vvv=vvv;
145
}//
146

    
147

    
148
real sqrt2=sqrt(2.);
149
macro epsilon(u1,u2)  [dx(u1),dy(u2),(dy(u1)+dx(u2))/sqrt2] // EOM
150
//the sqrt2 is because we want: epsilon(u1,u2)'* epsilon(v1,v2) $==  \epsilon(\bm{u}): \epsilon(\bm{v})$
151
macro div(u1,u2) ( dx(u1)+dy(u2) ) // EOM
152

    
153
/*************************************************************
154
 *                  MECHANICS
155
 * **********************************************************/
156

    
157
// definition of integer functions for the structural domains
158
func vasculature=int(vasculatureBool(x,y));
159
func nectary=int(nectaryBool(x,y));
160
func side=int(sideBool(x,y));
161
func mesophyl=int(mesophylBool(x,y));
162
func geometry = 1*vasculature + 3*nectary + 2*side + 4*mesophyl;
163

    
164
// definition of FE variables for the structural domains
165
Sh0 vasculatureh=vasculature;
166
//plot(vasculatureh,wait=1,value=true,fill=1, ps=output+"/vasculature-original.png", bb=bb);
167

    
168
Sh0 nectaryh=nectary;
169
//plot(nectaryh,wait=1,value=true,fill=1, ps=output+"/nectary-original.png", bb=bb);
170

    
171
Sh0 sideh=side;
172
//plot(sideh,wait=1,value=true,fill=1, ps=output+"/side-original.png", bb=bb);
173

    
174
Sh0 mesophylh=mesophyl;
175
//plot(mesophylh,wait=1,value=true,fill=1, ps=output+"/mesophyl-original.png", bb=bb);
176

    
177
Sh0 geometryh=geometry;
178
string fname=output+"/geometry-original.png";
179
plot(geometryh,fill=1, ps=fname, bb=bb);
180

    
181
// spatial dependence of Young modulus
182
func E=Ev*(vasculature + fEn*nectary + fEs*side + fEm*mesophyl);
183
Sh0 Eh=E;
184

    
185
// spatial dependence of the swelling property
186
func s=sm*(fsv*vasculature + fsn*nectary + fss*side + mesophyl);
187
Sh0 sh=s;
188

    
189
func mu=E/(2*(1+nu));
190
func lambda=E*nu/((1+nu)*(1-2*nu));
191
func K=lambda+2*mu/3;
192

    
193

    
194

    
195
/*************************************************************
196
 *                  SOLVING THE FEM
197
 * **********************************************************/
198

    
199
solve Lame([u1,u2],[v1,v2])=
200
  int2d(Th)(
201
            lambda*div(u1,u2)*div(v1,v2)         
202
            + 2.*mu*( epsilon(u1,u2)'*epsilon(v1,v2) ) 
203
              )
204
  - int2d(Th) ( K*sh*div(v1,v2))
205
  + on(32,u1=vd,u2=0)
206
  + on(33,u1=-vd,u2=0) 
207
  ;
208

    
209

    
210
stress=2*K*(strain-s);
211

    
212
Sh0 e11=dx(u1)+1.;
213
Sh0 e12=1/2.*(dx(u2) + dy(u1));
214
Sh0 e22=dy(u2)+1.;
215

    
216
strain=e11+e22 ;
217
Sh0 Det=e11*e22-e12*e12;
218

    
219
Sh0 l1=abs(strain+sqrt(strain*strain-4*Det))/2.;
220
Sh0 l2=abs(strain-sqrt(strain*strain-4*Det))/2.;
221

    
222
Sh0 lmax=(l1-l2+abs(l1-l2))/2.+l2;
223
Sh0 lmin=(l1-l2-abs(l1-l2))/2.+l2;
224

    
225
Sh0 strainanisotropy=lmin/lmax;
226

    
227

    
228
/*************************************************************
229
 *                  VISUALISATION
230
 * **********************************************************/
231
real voltotal0=int2d(Th)(1);
232
real volvasculature0=int2d(Th)(vasculatureh);
233
real volnectary0=int2d(Th)(nectaryh);
234
real volmesophyl0=int2d(Th)(mesophylh);
235
real volside0=int2d(Th)(sideh);
236

    
237
cout<<"Original volume="<<voltotal0<<endl;
238
cout<<"Original vasculature volume="<<volvasculature0<<endl;
239

    
240

    
241

    
242
mesh Th0=Th;
243
Th=movemesh(Th,[x+u1*coef,y+u2*coef]);
244

    
245

    
246

    
247
// compute mean strain per region
248
real straintotal=int2d(Th)(strain)/voltotal0;
249
real strainvasculature=int2d(Th)(strain*vasculatureh)/volvasculature0;
250
real strainnectary=int2d(Th)(strain*nectaryh)/volnectary0;
251
real strainside=int2d(Th)(strain*sideh)/volside0;
252
real strainmesophyl=int2d(Th)(strain*mesophylh)/volmesophyl0;
253

    
254

    
255
// compute mean strain anisotropy per region
256
real satotal=int2d(Th)(strainanisotropy)/voltotal0;
257
real savasculature=int2d(Th)(strainanisotropy*vasculatureh)/volvasculature0;
258
real sanectary=int2d(Th)(strainanisotropy*nectaryh)/volnectary0;
259
real saside=int2d(Th)(strainanisotropy*sideh)/volside0;
260
real samesophyl=int2d(Th)(strainanisotropy*mesophylh)/volmesophyl0;
261

    
262

    
263
cout<<"Mean strain and strain anisotropy per region :"<<endl;
264
cout<<"Mesophyll:"<<strainmesophyl<<"   "<<samesophyl<<endl;
265
cout<<"Nectary:"<<strainnectary<<"   "<<sanectary<<endl;
266
cout<<"Side:"<<strainside<<"   "<<saside<<endl;
267
cout<<"Vasculature:"<<strainvasculature<<"   "<<savasculature<<endl;
268
cout<<"Total:"<<straintotal<<"   "<<satotal<<endl;
269

    
270

    
271

    
272
plot(Th, Th0, wait=1, ps=output+"/geometry-deformed-superposed_sm"+string(sm)+"_fsn"+string(fsn)+"_fss"+string(fss)+"_fsv"+string(fsv)+".png",bb=bb);
273

    
274

    
275
redefineVariable(strain);
276
redefineVariable(stress);
277
plot(strain, fill=1,wait=1,value=true, ps="strain.png",bb=bb);
278
plot(stress, fill=1,wait=1,value=true, ps="stress.png",bb=bb);
279

    
280

    
281
redefineVariable(geometryh);
282
plot(geometryh, fill=1, ps=output+"/geometry-deformed_sm"+string(sm)+".png",bb=bb);
283

    
284
redefineVariable(vasculatureh);
285
redefineVariable(nectaryh);
286
redefineVariable(sideh);
287
redefineVariable(mesophylh);
288

    
289
// compute structure volumes
290
real voltotal=int2d(Th)(1);
291
real volvasculature=int2d(Th)(vasculatureh);
292
real volnectary=int2d(Th)(nectaryh);
293
real volside=int2d(Th)(sideh);
294
real volmesophyl=int2d(Th)(mesophylh);
295

    
296
cout<<"Deformed total volume="<<voltotal<<endl;
297
cout<<"Deformed vasculature volume="<<volvasculature<<endl;
298

    
299

    
300
/*************************************************************
301
 *         LOOKING FOR ANGLE AND NECKHEIGHT
302
 * **********************************************************/
303

    
304
// displaced upper corner
305
real Nx=lx/2+u1(lx/2.,0), Ny=u2(lx/2.,0);
306

    
307

    
308
// compute tangentangle
309
real height=ly/nvertex/100;
310
real Mx=lx/2+u1(lx/2.,-height), My=-height+u2(lx/2.,-height);
311
real tangentangle=angleToVertical(Mx, My, Nx, Ny);
312
cout<<"Tangent angle="<<tangentangle<<endl;
313

    
314
// compute sideangle
315
height=hside;
316
Mx=lx/2+u1(lx/2.,-height); My=-height+u2(lx/2.,-height);
317
real sideangle=angleToVertical(Mx, My, Nx, Ny);
318

    
319

    
320
cout<<"Side angle="<<sideangle<<endl;
321

    
322

    
323
real am=volmesophyl0/volmesophyl;
324
real an=volnectary0/volnectary;
325
real as=volside0/volside;
326
real av=volvasculature0/volvasculature;
327

    
328

    
329

    
330
/*************************************************************
331
 *         Writing results
332
 * **********************************************************/
333
 
334
 
335

    
336
ofstream textfile(output+"/results.csv", append);
337
        
338
/*
339
sm;fsn;fss;fsv;tangentangle;sideangle;am;an;as;av;sam;san;sas;sav
340
*/
341

    
342

    
343
textfile<<sm<<";"<<fsn<<";"<<fss<<";"<<fsv<<";"<<tangentangle/38<<";"<<sideangle/38
344
<<";"<<am<<";"<<an<<";"<<as<<";"<<av
345
<<";"<<samesophyl<<";"<<sanectary<<";"<<saside<<";"<<savasculature
346
<<endl;
347

    
348

    
349
cout<<sm<<";"<<fsn<<";"<<fss<<";"<<fsv<<";"<<tangentangle/38<<";"<<sideangle/38
350
<<";"<<am<<";"<<an<<";"<<as<<";"<<av
351
<<";"<<samesophyl<<";"<<sanectary<<";"<<saside<<";"<<savasculature
352
<<endl;
353

    
354

    
355

    
356