Statistiques
| Révision :

root / Test-Formulation / test-formulation.cpp @ 19

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

1
include "getARGV.idp"
2

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

    
13

    
14
/*************************************************************
15
 *                  PARAMETERS
16
 * **********************************************************/
17
 
18
// reading script arguments
19
for (int i=0;i<ARGV.n;++i)
20
{ cout << ARGV[i] << " ";}
21
cout<<endl;
22

    
23
verbosity = getARGV("-vv", 0);
24
int vdebug = getARGV("-d", 1);
25
real E = getARGV("-E", 0.2);
26
real s = -getARGV("-s", 0.4);
27
string outputdir = getARGV("-out", ".");
28

    
29

    
30
cout<<"----------------------------------------------"<< endl;
31
cout<<"E="<<E <<"   s="<<s<< endl;
32

    
33
// ---------------- geometrical parameters
34

    
35
// (lengths are measured in micrometers)
36
real units=1;
37

    
38
// pulvinus dimensions
39
real lx=1/units;       //sd =34.4
40
real ly= 1/units;      //sd=36.0
41

    
42

    
43
// mesh parameters
44
int nvertex=10;
45
cout << "nvertex="<<nvertex<<endl;
46

    
47
int[int] labs=[10,20,30,40]; // bottom, right, top, left
48
mesh Th=square(lx*nvertex,ly*nvertex, label=labs, region=0, [x*lx,y*ly]);
49

    
50
// bounding box for the plot (use the same for all images so that they can be superposed)
51
func bb=[[-1,-1],[lx+1,ly+1]];
52
real coef=1;
53

    
54
string root=outputdir+"/test-formulation";
55

    
56

    
57
// -------------------- define the finite element space
58

    
59
fespace Vh(Th,[P2,P2]);  // vector on the mesh (displacement vector)
60
Vh [u1,u2], [v1,v2];
61

    
62
fespace Sh(Th, P2);   // scalar on the mesh, P2 elements
63
fespace Sh0(Th,P0);   // scalar on the mesh, P0 elements
64
fespace Sh1(Th,P1);   // scalar on the mesh, P1 elements
65

    
66
Sh0 Eh=E;// Young modulus
67
Sh0 sh=s;// hydrophobicity as swelling ability
68
real nu = 0.29;    // Poisson's ratio
69

    
70

    
71
func mu=E/(2*(1+nu));
72
func lambda=E*nu/((1+nu)*(1-2*nu));
73
//func K=lambda+2*mu/3;
74
func K=lambda+mu;
75

    
76
// macro to redefine variables on the displaced mesh 
77
macro redefineVariable(vvv)
78
{        real[int] temp(vvv[].n);
79
        temp=vvv[]; vvv=0; vvv[]=temp;
80
        vvv=vvv;
81
}//
82

    
83

    
84
real sqrt2=sqrt(2.);
85
macro epsilon(u1,u2)  [dx(u1),dy(u2),(dy(u1)+dx(u2))/sqrt2] // EOM
86
//the sqrt2 is because we want: epsilon(u1,u2)'* epsilon(v1,v2) $==  \epsilon(\bm{u}): \epsilon(\bm{v})$
87
macro div(u1,u2) ( dx(u1)+dy(u2) ) // EOM
88

    
89

    
90
/*************************************************************
91
 *                  SOLVING THE FEM
92
 * **********************************************************/
93

    
94
solve Lame([u1,u2],[v1,v2])=
95
  int2d(Th)(
96
            lambda*div(u1,u2)*div(v1,v2)         
97
            + 2.*mu*( epsilon(u1,u2)'*epsilon(v1,v2) ) 
98
              )
99
  - int2d(Th) ( K*sh*div(v1,v2))
100
  + on(10,u2=0, u1=0)
101
  //+ on(40,u1=0) 
102
  ;
103

    
104

    
105
/*************************************************************
106
 * **********************************************************/
107

    
108

    
109
Sh0 e11=dx(u1)+1.;
110
Sh0 e12=1/2.*(dx(u2) + dy(u1));
111
Sh0 e22=dy(u2)+1.;
112

    
113
Sh0 strain=e11+e22 ;
114
Sh0 Det=e11*e22-e12*e12;
115

    
116
Sh0 l1=abs(strain+sqrt(strain*strain-4*Det))/2.;
117
Sh0 l2=abs(strain-sqrt(strain*strain-4*Det))/2.;
118

    
119
Sh0 lmax=(l1-l2+abs(l1-l2))/2.+l2;
120
Sh0 lmin=(l1-l2-abs(l1-l2))/2.+l2;
121

    
122
Sh0 strainanisotropy=lmin/lmax;
123
plot(strainanisotropy, fill=1, value=true, ps="satrainanisotropy-s"+string(s)+".png",  bb=bb, wait=1);
124

    
125
mesh Thm1=movemesh(Th, [x+u1, y+u2]);
126
plot(Th, Thm1, ps=root+"_geometry-moved.png", wait=1, bb=bb);
127

    
128

    
129
// compute original and deformed volume
130

    
131
real vol0=int2d(Th)(1);
132
real vol=int2d(Thm1)(1);
133

    
134
// compute mean strain
135
real meanstrain=int2d(Th)(strain/2)/vol0;
136

    
137
// compute mean strain anisotropy
138
real straina0=int2d(Th)(strainanisotropy)/vol0;
139

    
140
real straina1=int2d(Thm1)(strainanisotropy)/vol;
141

    
142
real strainamixed=int2d(Thm1)(strainanisotropy)/vol0;
143

    
144

    
145

    
146
cout<<"Initial volume:"<<string(vol0)<<endl;
147
cout<<"Final volume:"<<string(vol)<<endl;
148
cout<<"A1/A0="<<vol/vol0<<endl;
149
cout<<"Mean strain:"<<string(meanstrain)<<endl;
150
cout<<"Strain anisotropy 0:"<<string(straina0)<<endl;
151
cout<<"Strain anisotropy 1:"<<string(straina1)<<endl;
152
cout<<"Strain anisotropy mixed:"<<string(strainamixed)<<endl;
153

    
154

    
155
plot(Th, Thm1, ps="deformation-s"+string(s)+".png",  bb=bb, wait=1);
156

    
157