Sei sulla pagina 1di 4

border C1(t=0,0.

1*pi){x=cos(t); y=sin(t);}//1st elec


border C2(t=0.1,0.5*pi){x=cos(t); y=sin(t);}//gap
border C3(t=0.5,0.51*pi){x=cos(t); y=sin(t);}//2nd elec
border C4(t=0.51,1*pi){x=cos(t); y=sin(t);}//gap
border C5(t=1,1.1*pi){x=cos(t); y=sin(t);}//3rd elec
border C6(t=1.1,1.5*pi){x=cos(t); y=sin(t);}//gap
border C7(t=1.5,1.51*pi){x=cos(t); y=sin(t);}//4th elec
border C8(t=1.51,2*pi){x=cos(t); y=sin(t);}//gap
//border E1(t=0,2*pi) { x=0.2*cos(t)-0.5; y=0.2*sin(t)+0.5; }// circle with in a
circle
//border b(t=0,2*pi){ x=0.3+0.3*cos(t); y=0.3*sin(t);label=2;}
// plot(a(50)+b(+30)) ; // to see a plot of the border mesh
// mesh Thwithouthole= buildmesh(a(50)+b(+30));
//plot(Thwithhole,wait=1,ps="Thwithhole.eps");
mesh Th = buildmesh (C(50));
fespace Vh(Th,P1);
Vh u,v;
func f= 0; // definition of a called f function
real cpu=clock(); // get the clock is second
solve Poisson(u,v,solver=LU) = int2d(Th)(sigma*dx(u)*dx(v) + sigma*dy(u)*dy(v)) +
int1d(Th)(c1,1*v)+ int1d(Th)(c2,-1*v);//from the varaitional formulation, current 1
milli amp
plot(u);
cout << " CPU time = " << clock()-cpu << endl;

-- FreeFem++ v4.5 (mar. 11 févr. 2020 20:59:29 - git v4.5-2-g95135963)


Load: lg_fem lg_mesh lg_mesh3 eigenvalue
1 : //Generated automatically
2 : //number of electrodes
3 : int n = 16;
4 : //the angle covered by each electrode
5 : real dt = 0.05;
6 : //the angle covered by the gaps
7 : real dgap = 2*pi/n;
8 : //the electrode locations
9 : real[int] elecs(n);
10 : //the gaps
11 : real[int] gaps(n);
12 : //electrode locations
13 : for(int i=0; i < n; i++) {
14 : elecs[i] = 2*pi*i/n;
15 : gaps[i] = 2*pi*(i+1)/n;
16 : }
17 : //the number of grid points on the electrodes
18 : int me = 50;
19 : //the number of grid points in the gaps
20 : int mg = 50;
21 : bool debug=true;
22 : //the electrodes and gaps
23 : border e0(t=elecs(0),elecs(0)+dt){x=cos(t); y=sin(t); label=0;};
24 : border g0(t=elecs(0)+dt,elecs(1)){x=cos(t); y=sin(t); label=1;};
25 : border e1(t=elecs(1),elecs(1)+dt){x=cos(t); y=sin(t); label=2;};
26 : border g1(t=elecs(1)+dt,elecs(2)){x=cos(t); y=sin(t); label=3;};
27 : border e2(t=elecs(2),elecs(2)+dt){x=cos(t); y=sin(t); label=4;};
28 : border g2(t=elecs(2)+dt,elecs(3)){x=cos(t); y=sin(t); label=5;};
29 : border e3(t=elecs(3),elecs(3)+dt){x=cos(t); y=sin(t); label=6;};
30 : border g3(t=elecs(3)+dt,elecs(4)){x=cos(t); y=sin(t); label=7;};
31 : border e4(t=elecs(4),elecs(4)+dt){x=cos(t); y=sin(t); label=8;};
32 : border g4(t=elecs(4)+dt,elecs(5)){x=cos(t); y=sin(t); label=9;};
33 : border e5(t=elecs(5),elecs(5)+dt){x=cos(t); y=sin(t); label=10;};
34 : border g5(t=elecs(5)+dt,elecs(6)){x=cos(t); y=sin(t); label=11;};
35 : border e6(t=elecs(6),elecs(6)+dt){x=cos(t); y=sin(t); label=12;};
36 : border g6(t=elecs(6)+dt,elecs(7)){x=cos(t); y=sin(t); label=13;};
37 : border e7(t=elecs(7),elecs(7)+dt){x=cos(t); y=sin(t); label=14;};
38 : border g7(t=elecs(7)+dt,elecs(8)){x=cos(t); y=sin(t); label=15;};
39 : border e8(t=elecs(8),elecs(8)+dt){x=cos(t); y=sin(t); label=16;};
40 : border g8(t=elecs(8)+dt,elecs(9)){x=cos(t); y=sin(t); label=17;};
41 : border e9(t=elecs(9),elecs(9)+dt){x=cos(t); y=sin(t); label=18;};
42 : border g9(t=elecs(9)+dt,elecs(10)){x=cos(t); y=sin(t); label=19;};
43 : border e10(t=elecs(10),elecs(10)+dt){x=cos(t); y=sin(t); label=20;};
44 : border g10(t=elecs(10)+dt,elecs(11)){x=cos(t); y=sin(t); label=21;};
45 : border e11(t=elecs(11),elecs(11)+dt){x=cos(t); y=sin(t); label=22;};
46 : border g11(t=elecs(11)+dt,elecs(12)){x=cos(t); y=sin(t); label=23;};
47 : border e12(t=elecs(12),elecs(12)+dt){x=cos(t); y=sin(t); label=24;};
48 : border g12(t=elecs(12)+dt,elecs(13)){x=cos(t); y=sin(t); label=25;};
49 : border e13(t=elecs(13),elecs(13)+dt){x=cos(t); y=sin(t); label=26;};
50 : border g13(t=elecs(13)+dt,elecs(14)){x=cos(t); y=sin(t); label=27;};
51 : border e14(t=elecs(14),elecs(14)+dt){x=cos(t); y=sin(t); label=28;};
52 : border g14(t=elecs(14)+dt,elecs(15)){x=cos(t); y=sin(t); label=29;};
53 : border e15(t=elecs(15),elecs(15)+dt){x=cos(t); y=sin(t); label=30;};
54 : border g15(t=elecs(15)+dt,2*pi){x=cos(t); y=sin(t); label=31;};
55 : plot(e0(me)+g0(mg)+e1(me)+g1(mg)+e2(me)+g2(mg)+e3(me)+g3(mg)+e4(me)+g4(mg)
+e5(me)+g5(mg)+e6(me)+g6(mg)+e7(me)+g7(mg)+e8(me)+g8(mg)+e9(me)+g9(mg)+e10(me)
+g10(mg)+e11(me)+g11(mg)+e12(me)+g12(mg)+e13(me)+g13(mg)+e14(me)+g14(mg)+e15(me)
+g15(mg),wait=debug);
56 : mesh Th = buildmesh(e0(me)+g0(mg)+e1(me)+g1(mg)+e2(me)+g2(mg)+e3(me)+g3(mg)
+e4(me)+g4(mg)+e5(me)+g5(mg)+e6(me)+g6(mg)+e7(me)+g7(mg)+e8(me)+g8(mg)+e9(me)
+g9(mg)+e10(me)+g10(mg)+e11(me)+g11(mg)+e12(me)+g12(mg)+e13(me)+g13(mg)+e14(me)
+g14(mg)+e15(me)+g15(mg));
57 : plot(Th, wait=debug);
58 : fespace Vh(Th,P1);
59 : //projection on to the finite dimensional space
60 : Vh sigma = 1.0*(max(abs(x),abs(y))<=0.1) + 1.0;
61 : plot(sigma,fill=debug,wait=debug);
62 : Vh phi,v;
63 : //obtain the data for all currents
64 : //current passing through0 and 1 electrodes
65 : solve a0(phi,v)
66 : = int2d (Th)(sigma*(dx(phi) * dx(v) + dy(phi) * dy(v)))
67 : -int1d (Th, e0)(v)
68 : +int1d (Th, e1)(v);
69 : plot(phi,wait=debug,fill=true);
70 : //current passing through1 and 2 electrodes
71 : solve a1(phi,v)
72 : = int2d (Th)(sigma*(dx(phi) * dx(v) + dy(phi) * dy(v)))
73 : -int1d (Th, e1)(v)
74 : +int1d (Th, e2)(v);
75 : plot(phi,wait=debug,fill=true);
76 : //current passing through2 and 3 electrodes
77 : solve a2(phi,v)
78 : = int2d (Th)(sigma*(dx(phi) * dx(v) + dy(phi) * dy(v)))
79 : -int1d (Th, e2)(v)
80 : +int1d (Th, e3)(v);
81 : plot(phi,wait=debug,fill=true);
82 : //current passing through3 and 4 electrodes
83 : solve a3(phi,v)
84 : = int2d (Th)(sigma*(dx(phi) * dx(v) + dy(phi) * dy(v)))
85 : -int1d (Th, e3)(v)
86 : +int1d (Th, e4)(v);
87 : plot(phi,wait=debug,fill=true);
88 : //current passing through4 and 5 electrodes
89 : solve a4(phi,v)
90 : = int2d (Th)(sigma*(dx(phi) * dx(v) + dy(phi) * dy(v)))
91 : -int1d (Th, e4)(v)
92 : +int1d (Th, e5)(v);
93 : plot(phi,wait=debug,fill=true);
94 : //current passing through5 and 6 electrodes
95 : solve a5(phi,v)
96 : = int2d (Th)(sigma*(dx(phi) * dx(v) + dy(phi) * dy(v)))
97 : -int1d (Th, e5)(v)
98 : +int1d (Th, e6)(v);
99 : plot(phi,wait=debug,fill=true);
100 : //current passing through6 and 7 electrodes
101 : solve a6(phi,v)
102 : = int2d (Th)(sigma*(dx(phi) * dx(v) + dy(phi) * dy(v)))
103 : -int1d (Th, e6)(v)
104 : +int1d (Th, e7)(v);
105 : plot(phi,wait=debug,fill=true);
106 : //current passing through7 and 8 electrodes
107 : solve a7(phi,v)
108 : = int2d (Th)(sigma*(dx(phi) * dx(v) + dy(phi) * dy(v)))
109 : -int1d (Th, e7)(v)
110 : +int1d (Th, e8)(v);
111 : plot(phi,wait=debug,fill=true);
112 : //current passing through8 and 9 electrodes
113 : solve a8(phi,v)
114 : = int2d (Th)(sigma*(dx(phi) * dx(v) + dy(phi) * dy(v)))
115 : -int1d (Th, e8)(v)
116 : +int1d (Th, e9)(v);
117 : plot(phi,wait=debug,fill=true);
118 : //current passing through9 and 10 electrodes
119 : solve a9(phi,v)
120 : = int2d (Th)(sigma*(dx(phi) * dx(v) + dy(phi) * dy(v)))
121 : -int1d (Th, e9)(v)
122 : +int1d (Th, e10)(v);
123 : plot(phi,wait=debug,fill=true);
124 : //current passing through10 and 11 electrodes
125 : solve a10(phi,v)
126 : = int2d (Th)(sigma*(dx(phi) * dx(v) + dy(phi) * dy(v)))
127 : -int1d (Th, e10)(v)
128 : +int1d (Th, e11)(v);
129 : plot(phi,wait=debug,fill=true);
130 : //current passing through11 and 12 electrodes
131 : solve a11(phi,v)
132 : = int2d (Th)(sigma*(dx(phi) * dx(v) + dy(phi) * dy(v)))
133 : -int1d (Th, e11)(v)
134 : +int1d (Th, e12)(v);
135 : plot(phi,wait=debug,fill=true);
136 : //current passing through12 and 13 electrodes
137 : solve a12(phi,v)
138 : = int2d (Th)(sigma*(dx(phi) * dx(v) + dy(phi) * dy(v)))
139 : -int1d (Th, e12)(v)
140 : +int1d (Th, e13)(v);
141 : plot(phi,wait=debug,fill=true);
142 : //current passing through13 and 14 electrodes
143 : solve a13(phi,v)
144 : = int2d (Th)(sigma*(dx(phi) * dx(v) + dy(phi) * dy(v)))
145 : -int1d (Th, e13)(v)
146 : +int1d (Th, e14)(v);
147 : plot(phi,wait=debug,fill=true);
148 : //current passing through14 and 15 electrodes
149 : solve a14(phi,v)
150 : = int2d (Th)(sigma*(dx(phi) * dx(v) + dy(phi) * dy(v)))
151 : -int1d (Th, e14)(v)
152 : +int1d (Th, e15)(v);
153 : plot(phi,wait=debug,fill=true);
154 : //current passing through15 and 1 electrodes
155 : solve a15(phi,v)
156 : = int2d (Th)(sigma*(dx(phi) * dx(v) + dy(phi) * dy(v)))
157 : -int1d (Th, e15)(v)
158 : +int1d (Th, e1)(v);
159 : plot(phi,wait=debug,fill=true);
160 : sizestack + 1024 =7136 ( 6112 )

-- mesh: Nb of Triangles = 190090, Nb of Vertices 95846

Potrebbero piacerti anche