File: periodic4.edp

package info (click to toggle)
freefem%2B%2B 3.47%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 132,088 kB
  • ctags: 19,726
  • sloc: cpp: 138,951; ansic: 22,605; sh: 4,951; makefile: 2,935; fortran: 1,147; perl: 768; awk: 282; php: 182
file content (34 lines) | stat: -rw-r--r-- 1,212 bytes parent folder | download | duplicates (4)
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
real r=0.25;
// a diamond with a hole
border a(t=0,1){x=-t+1; y=t;label=1;}; 
border b(t=0,1){ x=-t; y=1-t;label=2;};
border c(t=0,1){ x=t-1; y=-t;label=3;};
border d(t=0,1){ x=t; y=-1+t;label=4;};
border e(t=0,2*pi){ x=r*cos(t); y=-r*sin(t);label=0;};
int n = 10;
mesh Th= buildmesh(a(n)+b(n)+c(n)+d(n)+e(n)); 
plot(Th,wait=1);
real r2=1.732;
func abs=sqrt(x^2+y^2);
//  warning for periodic condition:
//  side a and c \hfilll
//  on side a (label 1) $ x \in [0,1] $ or $ x-y\in [-1,1] $ \hfilll
//  on side c (label 3) $ x \in [-1,0]$ or $ x-y\in[-1,1] $\hfilll
// so the common abcissa can be repectively $x$ and $x+1$
// or you can can try curviline abcissa $x-y$ and $x-y$ 
//  1 first way
// fespace Vh(Th,P2,periodic=[[2,1+x],[4,x],[1,x],[3,1+x]]);     
// 2 second way
 fespace Vh(Th,P2,periodic=[[2,x+y],[4,x+y],[1,x-y],[3,x-y]]);     

 Vh uh,vh;             

 func f=(y+x+1)*(y+x-1)*(y-x+1)*(y-x-1);                
 real intf = int2d(Th)(f);
 real mTh = int2d(Th)(1.);
real moyf =  intf/mTh;
cout << moyf << endl; 
 problem laplace(uh,vh) =                     
    int2d(Th)( dx(uh)*dx(vh) + dy(uh)*dy(vh) ) + int2d(Th)( (moyf-f)*vh ) ;                
laplace; 
  plot(uh,wait=1,ps="perio4.eps");