Skip to content

Commit 830abdd

Browse files
committed
add new file
1 parent 8ad30e5 commit 830abdd

File tree

118 files changed

+119602
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+119602
-0
lines changed

2022/pdf/S-CD.pdf

5.95 MB
Binary file not shown.

2022/pdf/S-GS.pdf

3.04 MB
Binary file not shown.

2022/pdf/S-MB.pdf

6.07 MB
Binary file not shown.

2022/pdf/S-PV.pdf

3.39 MB
Binary file not shown.
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
// calcul du couplage entre deux domaines de section rectangulaire Ex*Ey
2+
// a une distance dist
3+
// en contact avec une résistance de contact 1/c
4+
//
5+
// La face opposee de chaque rectangle est a temperature imposee T1 resp T2
6+
// Le couplage est intégré directement dans le système d'équation
7+
//
8+
// version avec les espaces composite
9+
10+
real x0=0,x2=4;
11+
real y0=0,y1=1;
12+
real L= x2-x0;
13+
real k1=1;
14+
real k2=1;
15+
16+
real c=1;
17+
18+
real T0=100.0, T1=00.0;
19+
20+
21+
// mesh construction.
22+
23+
// the curve in y .
24+
func F = 2+0.5*sin(2*pi*(y));
25+
func dF= -1*0.5*pi*2*cos(2*pi*(y));
26+
func dux = (T1-T0)/(L+ (k1/c)/sqrt(1.+0*square(dF))); //
27+
28+
// k du/dn = c[u]
29+
// if we neglect the du/dy
30+
// the solution
31+
// du/dx is constant in x and
32+
// du/dx*L + [u] = T1-T0
33+
// du/dx*L + N.x k/c du/dx = T1-T0
34+
// =>
35+
// du/dx = (T1-T0) /(L+nx*k/c)
36+
37+
// t ->( F,t ) t' = ( dF, 1) n = (-1, dF) / sqrt( 1+ dF^2)
38+
// N.x = 1 / sqrt( 1+ dF^2)
39+
40+
func Te1= T0+x*dux;
41+
func Te2= T1+(x-L)*dux;
42+
43+
real xb1= F(0,0);
44+
real xu1= F(0,1);
45+
46+
border left(t=y1,y0) {x=x0; y=t;label=3;}
47+
border right(t=y0,y1) {x=x2; y=t;label=4;}
48+
border bot1(t=x0,xb1) {y=y0; x=t;label=2;}
49+
border bot2(t=xb1,x2) {y=y0; x=t;label=2;}
50+
border up1(t=x2,xu1) {y=y1; x=t;label=2;}
51+
border up2(t=xu1,x0) {y=y1; x=t;label=2;}
52+
border curve(t=0,1) {y=t;x=F(0,t) ; label=10;}
53+
54+
55+
// Maillages coincidents
56+
int n=30;
57+
int ny=n*(y1-y0);
58+
func Bord = left(ny)+right(ny)+curve(ny*2)
59+
+bot1(n*(xb1-x0))+bot2(n*(x2-xb1))
60+
+up1(n*(x2-xu1))+up2(n*(x2-xu1));
61+
plot(Bord,wait=1);
62+
mesh Th= buildmesh( Bord );
63+
// get region numbion to buid 2 meshes:
64+
int rg1=Th(x0+0.1,y0+0.1).region;
65+
int rg2=Th(x2-0.1,y1-0.1).region;
66+
// 2 meshes conform.
67+
mesh Th1=trunc(Th,region==rg1);
68+
mesh Th2=trunc(Th,region==rg2);
69+
// now the 2 meshes are not conform.
70+
//Th2 = adaptmesh(Th2,0.05,IsMetric=1,nbvx=1000000);
71+
//Th1 = adaptmesh(Th1,0.03,IsMetric=1,nbvx=1000000);
72+
73+
74+
plot(Th1,Th2,wait=1);
75+
76+
fespace Vh1(Th1,P1); //Vh1 u1=T0, v1,Vh1x=x,Vh1y=y,Vh1lab=label;
77+
fespace Vh2(Th2,P1);
78+
79+
// two good approximation of the exact solution.
80+
Vh1 ue1=Te1;
81+
Vh2 ue2=Te2;
82+
plot(ue1,ue2,wait=1,cmm="analytic approximation");
83+
84+
varf V11(u,v) = int2d(Th1)(k1*dx(u)*dx(v) + k1*dy(u)*dy(v)) + int1d(Th1,10,mortar=1)(c*u*v) + on(3,u=T0);
85+
varf V12(u,v) = int1d(Th1,10,mortar=1)(-c*u*v);
86+
varf V21(u,v) = int1d(Th2,10,mortar=1)(-c*u*v);
87+
varf V22(u,v) = int2d(Th2)(k2*dx(u)*dx(v) + k2*dy(u)*dy(v)) + int1d(Th2,10,mortar=1)(c*u*v) + on(4,u=T1);
88+
89+
matrix A11 = V11(Vh1,Vh1);
90+
matrix A12 = V12(Vh2,Vh1);
91+
matrix A21 = V21(Vh1,Vh2);
92+
matrix A22 = V22(Vh2,Vh2);
93+
// test the integrale of on curve line.
94+
95+
{ // verification of matrix A12 and A21...
96+
97+
macro verif1(A,vv) {
98+
real[int] b(A.m);
99+
b=1.;
100+
vv[]=A*b;
101+
cout << " sum = " << vv[].sum << "== " << int1d(Th1,10)(-c) << " == " << int1d(Th2,10)(-c) <<endl;
102+
assert ( abs(vv[].sum-int1d(Th1,10)(-c) ) < 1e-3);
103+
}//
104+
105+
Vh1 v1;
106+
Vh2 v2;
107+
verif1(A12,v1);
108+
verif1(A21,v2);
109+
} // end of verification ..
110+
111+
//matrix A = [[A11, A12],[A12', A22]]; // valable dans le cas conforme uniquement (autrement A12' different de A21)
112+
matrix A = [[A11, A12],[A21, A22]];
113+
114+
// rhs compuation
115+
real[int] B1= V11(0,Vh1);
116+
real[int] B2 = V22(0,Vh2);
117+
real[int] B = [B1,B2];
118+
119+
Vh1 u1;
120+
Vh2 u2;
121+
set(A, solver=UMFPACK);
122+
real[int] T = A^-1*B;
123+
[u1[],u2[]]=T; // dispatch the solution.
124+
125+
plot(u1,u2,value=1,fill=1,wait=1,nbiso=100);
126+
plot(u1,ue1,value=1,fill=0,wait=1);
127+
plot(u2,ue2,value=1,fill=0,wait=1);
128+
cout << " T1=" << int1d(Th1,10)(u1)/int1d(Th1,10)(1.0) << " T2=" << int1d(Th2,10)(u2)/int1d(Th2,10)(1.0) << endl;
129+
130+
// composite version
131+
fespace cVh(<Vh1,Vh2>);
132+
133+
varf compositeVall([u1,u2],[v1,v2]) =
134+
int2d(Th1)(k1*dx(u1)*dx(v1) + k1*dy(u1)*dy(v1))
135+
+ int2d(Th2)(k2*dx(u2)*dx(v2) + k2*dy(u2)*dy(v2))
136+
+ int1d(Th1,10,mortar=1)(c*(u1-u2)*(v1-v2) )
137+
+ on(3,u1=T0)
138+
+ on(4,u2=T1);
139+
//+ int1d(Th1,10,mortar=1)(-c*u2*v1)
140+
//+ int1d(Th2,10,mortar=1)(-c*u1*v2)
141+
//+ int1d(Th2,10,mortar=1)(c*u2*v2)
142+
143+
real[int] cB = compositeVall(0,cVh);
144+
matrix cA = compositeVall(cVh,cVh);
145+
set(cA, solver=UMFPACK);
146+
147+
real[int] cT = cA^-1*cB;
148+
149+
Vh1 uc1;
150+
Vh2 uc2;
151+
[uc1[],uc2[]]=cT; // dispatch the solution.
152+
153+
Vh1 u1diff;
154+
u1diff[] = uc1[]-u1[];
155+
Vh2 u2diff;
156+
u2diff[] = uc2[]-u2[];
157+
158+
plot(uc1,uc2,value=1,fill=1,wait=1,nbiso=100);
159+
plot(uc1,ue1,value=1,fill=0,wait=1);
160+
plot(uc2,ue2,value=1,fill=0,wait=1);
161+
plot(u1diff,u2diff,value=1,fill=1,wait=1,nbiso=100);
162+
cout << " T1=" << int1d(Th1,10)(u1)/int1d(Th1,10)(1.0) << " T2=" << int1d(Th2,10)(u2)/int1d(Th2,10)(1.0) << endl;
163+
164+
matrix D=A -cA;
165+
cout << "D.linfty=" << D.linfty << endl;
166+
real[int] db(B.n);
167+
db=B-cB;
168+
cout << "db.linfty=" << db.linfty << endl;
169+
end;
170+
171+
/// FIN DU PROGRAMME

2022/pdf/edp2-full/3d-leman.edp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
load "msh3"
2+
load "medit"
3+
int nn=10;
4+
// a potentiel flow on a lac ..
5+
// a first freefem++ 3d example
6+
// ------ not to bad ......
7+
verbosity=3;
8+
mesh Th2("lac-leman-v4.msh");
9+
fespace Vh2(Th2,P1);
10+
Vh2 deep;
11+
{ Vh2 v;
12+
macro Grad(u) [dx(u),dy(u)] //
13+
solve P(deep,v)= int2d(Th2)(Grad(deep)'*Grad(v))+int2d(Th2)(v)
14+
+on(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,deep=-1);
15+
deep = deep*5/abs(deep[].min);
16+
plot(deep,wait=1,cmm="min: "+deep[].min+ " max: "+deep[].max );
17+
}
18+
Vh2 ux,uz,p2;
19+
int[int] rup=[0,200], rdown=[0,100],rmid(17*2);
20+
for(int i=0;i<rmid.n;++i)
21+
rmid[i]=1+i/2;
22+
cout << rmid << endl;
23+
real maxdeep = deep[].min;
24+
mesh3 Th=buildlayers(Th2,nn,
25+
coef= deep/maxdeep,
26+
zbound=[deep,0],
27+
labelmid=rmid,
28+
labelup = rup,
29+
labeldown = rdown);
30+
//medit("Leman",Th);
31+
fespace Vh(Th,P13d);
32+
Vh p,q;
33+
// (-deep[].min)*c = 0.5 Km
34+
// c =
35+
real cc=(0.5/-deep[].min);
36+
cout << cc << " cc = " << endl;
37+
cc=1; // otherwise bug in bounding condition ...
38+
macro Grad(u) [dx(u),dy(u),cc*dz(u)] //
39+
40+
real ain=int2d(Th,1)(1.);
41+
real aout=int2d(Th,2)(1.);
42+
cout << " area " << ain << " " << aout << endl;
43+
real din=1./ain;
44+
real dout=-1./aout;
45+
solve P(p,q)= int3d(Th)(Grad(p)'*Grad(q)+1e-5*p*q)-int2d(Th,1)(q*din)+int2d(Th,2)(q*dout);
46+
47+
plot(p,wait=1,nbiso=30,value=1);
48+
medit("potentiel",Th,p);

2022/pdf/edp2-full/3daximesh.edp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
load "msh3" load "medit"
2+
mesh3 Th;
3+
try {Th=readmesh3("/tmp/3daxi.mesh");} // try to read
4+
catch(...) { // if not build ...
5+
func f=2*((0.1+(((x/3))*(x-1)*(x-1)/1+x/100))^(1/3.)-(0.1)^(1/3.));
6+
real yf=f(1.2,0);
7+
border up(t=1.2,0.){ x=t;y=f;label=0;}
8+
border axe2(t=0.2,1.15) { x=t;y=0;label=0;}
9+
border hole(t=pi,0) { x= 0.15 + 0.05*cos(t);y= 0.05*sin(t); label=1;}
10+
border axe1(t=0,0.1) { x=t;y=0;label=0;}
11+
border queue(t=0,1) { x= 1.15 + 0.05*t; y = yf*t; label =0;}
12+
int np= 100;
13+
func bord= up(np)+axe1(np/10)+hole(np/10)+axe2(8*np/10)+ queue(np/10);
14+
plot( bord);
15+
mesh Th2=buildmesh(bord);
16+
plot(Th2,wait=1);
17+
int[int] l23=[0,0,1,1];
18+
Th=buildlayers(Th2,coef= max(.15,y/max(f,0.05)), 50 ,zbound=[0,2*pi]
19+
,transfo=[x,y*cos(z),y*sin(z)],facemerge=1,labelmid=l23);
20+
savemesh(Th,"/tmp/3daxi.mesh");
21+
}
22+
23+
macro Grad(u) [dx(u),dy(u),dz(u)] //
24+
fespace Vh(Th,P1); Vh u,v;
25+
solve Poisson(u,v) = int3d(Th)( Grad(u)'*Grad(v) ) - int3d(Th)( v) + on(1,u=1);
26+
plot(u,wait=1,nbiso=20,value=1);
27+
medit("u",Th,u);

2022/pdf/edp2-full/Adapt-uv.edp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
border C(t=0,2*pi){x=cos(t);y=sin(t);};
2+
3+
mesh Th= buildmesh(C(20));
4+
func u = ( (10*x^3+y^3) + tanh(500*(sin(5*y)-2*x) ));
5+
func v = ( (10*y^3+x^3) + tanh(5000*(sin(5*x)-2*y) ));
6+
7+
real xz = 0.5, yz = 0.3 , dz=0.05;
8+
func bb=[[xz-dz,yz-dz],[xz+dz,yz+dz]];
9+
int nn = Th.nv;
10+
plot(Th, cmm = 0 + " nv =" + Th.nv, ps="../plots/aTh-"+0+".eps" );
11+
12+
for(int iter=1;iter < 20; ++iter )
13+
{
14+
Th = adaptmesh(Th,[u,v],err=0.06,nbvx=50000,thetamax=30);
15+
if(abs(Th.nv - nn) < nn*0.005) break;
16+
nn = Th.nv;
17+
plot(Th, cmm = iter + " nv =" + Th.nv, ps="../plots/aTh-"+iter+".eps" );
18+
plot(Th, cmm = iter + " nv =" + Th.nv, ps="../plots/zTh-"+iter+".eps", bb = bb,wait=1 ,WindowIndex=1);
19+
20+
}
21+
// plot ...
22+
fespace Vh(Th,P1);
23+
Vh uh=u,vh=v;
24+
25+
load "msh3"
26+
meshS Thu= movemesh23(Th,transfo=[x,y,u/10]);Thu=change(Thu,fregion=1);
27+
meshS Thv= movemesh23(Th,transfo=[x,y,v/10]);Thv=change(Thv,fregion=2);
28+
29+
30+
plot(uh,dim=3, cmm="uh",wait=1,fill=1);
31+
plot(vh,dim=3, cmm="vh",wait=1,fill=1);
32+
plot(Thu,Thv,wait=1);
33+
//plot(Thv,wait=1);
34+
load "medit" medit("Thu",Thu,Thv);

2022/pdf/edp2-full/AdaptP3.edp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
load "MetricPk" load "Element_P3"
2+
int[int] lab=[1,1,1,1];
3+
mesh Th = square(10,10,label=lab);
4+
Th=trunc(Th,x<0.2 | y<0.2, label=1);
5+
fespace Vh(Th,P3);
6+
fespace Metric(Th,[P1,P1,P1]);
7+
Vh u,v;
8+
real error=0.01;
9+
solve Poisson(u,v,solver=CG,eps=1.0e-6) =
10+
int2d(Th,qforder=5)( u*v*1.0e-10+ dx(u)*dx(v) + dy(u)*dy(v))
11+
+ int2d(Th,qforder=5)( (x-y)*v);
12+
// Do sub optimal adaptation in Norm $W^{r,p}$ for $Pk$
13+
real Nt= 1000,r = 1, k =3, p=1;
14+
15+
for (int i=0;i< 4;i++)
16+
{
17+
Metric [m11,m12,m22];
18+
m11[]=MetricPk(Th,u , kDeg=k,rDeg=r,pExp=p, mass=Nt/2);
19+
Th = adaptmesh(Th,m11,m12,m22,IsMetric=true, nbvx= Nt*2);
20+
u=u;// reinterpolation of u on new mesh Th.
21+
Poisson;
22+
plot(Th,wait=1);
23+
plot(u,wait=1);
24+
25+
} ;

2022/pdf/edp2-full/Ali-Bouchta-B.pgm

Lines changed: 4 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)