rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
ellipt_compliant_gen_model_data.m
1 function model_data = ellipt_compliant_gen_model_data(model);
2 %function model_data = ellipt_compliant_gen_model_data(model)
3 %
4 % computation of mu independet data
5 % input: model
6 %
7 % output:
8 % model_data.grid: contains p,e,t
9 % call model_data.grid.p etc
10 % model_data.dl: decomposed domain
11 %
12 
13 % B. Haasdonk 8.3.2010
14 % S. Langhof
15 
16 
17 % alles was geometrie generiert
18 
19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20 %%%%%%%%%%%%GEOMETRY
21 X=[];
22 Y=[];
23 def=repmat([3;4], 1, model.B1*model.B2);
24 GEO=[];
25 
26 %%%%%%%%%%%%%%%%%%%
27 %%%%% X direction
28 x1=0:model.B1-1;
29 x2=1:model.B1;
30 
31 X=[x1;x2;x2;x1];
32 X=X*(1/model.B1);
33 
34 X=repmat(X,1,model.B2);
35 
36 %%%%%%%%%%%%%%%%%%%%
37 %%%%% Y direction
38 y1=1:(model.B2);
39 y1=repmat(y1,1,model.B1);
40 y1=sort(y1);
41 
42 y2=0:(model.B2-1);
43 y2=repmat(y2,1,model.B1);
44 y2=sort(y2);
45 
46 Y=[y1;y1;y2;y2];
47 Y=Y*(1/model.B2);
48 
49 GEO=cat(1,def,X,Y);
50 
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
52 %%%mesh and boundary creation
53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54 
55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56 %%%%%%Mesh generation
57 dl=decsg(GEO);
58 if model.mesh_type==1
59  [p,e,t]=initmesh(dl);
60  not=length(t);
61  while not <= model.number_of_triangles_overall
62  [p,e,t]=refinemesh(dl, p, e, t);
63  not=length(t);
64  end
65 else
66  wert=1/(sqrt(model.B1*model.B2*model.number_of_triangles_block/3));
67  [p,e,t]=initmesh(dl, 'hmax',wert);
68 end
69 
70 
71 
72 
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74 %%%%%%%%%%%%%%%%%%%%%%ATTENTION%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75 %following section will be moved to ellipt_compliant_detailed_simulation.m
76 %because of the parameter dependency of the boundary matrix
77 
78 %
79 %
80 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81 % %%%%%create boundary matrix
82 %
83 % %set boundary condition
84 % %bottom+top: from left to right
85 % %left+right: from bottom to top
86 %
87 %
88 % noc_bm=length(dl); %number of columns
89 %
90 % check_left_region = dl(6,:); %number of block left hand side
91 % check_right_region = dl(7,:);
92 % check_region = dl(6:7,:);
93 %
94 % zeros_left=find(check_left_region == 0); %find 0's. this edge is an outer
95 % zeros_right=find(check_right_region == 0); %boundary
96 %
97 % nonzeros_left=find(check_left_region);
98 % nonzeros_right=find(check_right_region);
99 %
100 % inner_boundary_index=intersect(nonzeros_left, nonzeros_right); %index of non zero columns in dl
101 %
102 % zero_index=find(check_region==0);
103 % outer_boundary_index=ceil(zero_index/2);
104 % outer_boundary_index=outer_boundary_index';
105 %
106 % check_max_length = zeros(4,max(model.B1,model.B2));
107 % for i=1:model.B1
108 % check_max_length(1,i)=length(model.gamma_bottom{i}{1})+length(model.gamma_bottom{i}{2})+4; %bottom
109 % check_max_length(2,i)=length(model.gamma_top{i}{3})+length(model.gamma_top{i}{4})+8; %top
110 % end
111 % for l=1:model.B2
112 % check_max_length(3,l)=length(model.gamma_left{l}{1})+length(model.gamma_left{l}{2})+4; %left
113 % check_max_length(4,l)=length(model.gamma_right{l}{1})+length(model.gamma_right{l}{2})+4; %right
114 % end
115 %
116 % nor_bm=max(max(check_max_length)); %number of rows BM
117 %
118 %
119 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
120 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
121 % %%%Boundary matrix
122 % BM=zeros(nor_bm, noc_bm); %zeros BM Matrix
123 %
124 %
125 % %%%%% x1/x2, y1/y2 values
126 % check_y1=dl(4,:);
127 % check_y2=dl(5,:);
128 %
129 % check_x1=dl(2,:);
130 % check_x2=dl(3,:);
131 %
132 % %find indices of gamma top
133 % one_y1_index=find(check_y1 == 1);
134 % one_y2_index=find(check_y1 == 1);
135 %
136 % one_y_index = intersect(one_y1_index, one_y2_index);
137 %
138 % check_x1_one = check_x1(one_y_index);
139 %
140 % top_tmp=0;
141 % [tmp, top_tmp]=sort(check_x1_one);
142 %
143 % k=0;
144 % top_index=0; %
145 % for l=top_tmp
146 % k=k+1;
147 % top_index(k)=one_y_index(l); %top_index: top indices from left to right
148 % end
149 %
150 % %find indices of gamma bottom
151 %
152 % zero_y1_index=find(check_y1 == 0);
153 % zero_y2_index=find(check_y2 == 0);
154 %
155 % zero_y_index= intersect(zero_y1_index, zero_y2_index);
156 %
157 % check_x1_zero=check_x1(zero_y_index);
158 %
159 % bottom_tmp=0;
160 % [tmp, bottom_tmp]=sort(check_x1_zero);
161 % k=0;
162 % bottom_index=0; %
163 % for l=bottom_tmp
164 % k=k+1;
165 % bottom_index(k)=zero_y_index(l); %bottom index: bottom indices from left to right
166 % end
167 %
168 % %find left index
169 %
170 % zero_x1_index=find(check_x1 == 0);
171 % zero_x2_index=find(check_x2 == 0);
172 %
173 % zero_x_index=intersect(zero_x1_index, zero_x2_index);
174 %
175 % check_y1_zero=check_y1(zero_x_index); %
176 %
177 % left_tmp=0;
178 % [tmp, left_tmp]=sort(check_y1_zero);
179 % k=0;
180 % left_index=0; %
181 % for l=left_tmp
182 % k=k+1;
183 % left_index(k)=zero_x_index(l); %left index: left indices from left to right
184 % end
185 %
186 % %find right index
187 %
188 % one_x1_index=find(check_x1 == 1);
189 % one_x2_index=find(check_x2 == 1);
190 %
191 % one_x_index=intersect(one_x1_index, one_x2_index);
192 %
193 % check_y1_one=check_y1(one_x_index); %
194 %
195 % right_tmp=0;
196 % [tmp, right_tmp]=sort(check_y1_one);
197 % k=0;
198 % right_index=0; %
199 % for l=right_tmp
200 % k=k+1;
201 % right_index(k)=one_x_index(l); %right index: right indices from left to right
202 % end
203 %
204 %
205 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
206 % %%%%%%final creation of boundaries
207 %
208 % %outer bound indices
209 % outer_bound=[top_index, bottom_index, right_index, left_index];
210 % outer_bound=sort(outer_bound);
211 %
212 % %inner bound indices
213 % tmp_noc_vec=1:noc_bm;
214 % for i=outer_bound
215 % tmp_noc_vec(i)=-1;
216 % end
217 % inner_bound=find(tmp_noc_vec >=0);
218 %
219 %
220 %
221 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%55
222 % %%%inner boundaries
223 % std_inner_boundary_char=['0','0','1','0']; %double(...) -> 48 48 49 48
224 % std_inner_boundary_num=[0,repmat(1,1,5)];
225 %
226 % std_inner_boundary=[std_inner_boundary_num,double(std_inner_boundary_char)];
227 %
228 % if length(std_inner_boundary) < nor_bm %fill up with zeros
229 % std_inner_boundary(nor_bm);
230 % end
231 %
232 % %positioning of inner boundary condition
233 % for i=inner_bound
234 % BM(:,i)=std_inner_boundary(:);
235 % end
236 %
237 %
238 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
239 % %%%outer boundaries
240 %
241 % %top boundary
242 %
243 % %max length of vec
244 % %l_top_bound=max(check_max_length(2,:));
245 %
246 % %TOP=zeros(l_top_bound, model.B1);
247 % clear fronttail
248 % fronttail=repmat(1,1,4); %definition of dim, diri, lq, lg
249 %
250 % for i=1:model.B1
251 % lh=length(model.gamma_top{i}{3}); %number of chars for h
252 % lr=length(model.gamma_top{i}{4}); %number of chars for r
253 % outer_topboundary_num(i,:)=[fronttail,lh, lr, 48, 48];
254 % end
255 %
256 % outer_topboundary_num=outer_topboundary_num';
257 %
258 % tmp_char={};
259 % for i=1:model.B1
260 % tmp_char3=model.gamma_top{i}{3};
261 % tmp_char4=model.gamma_top{i}{4};
262 %
263 % tmp_char{i}=[tmp_char3,tmp_char4]; %
264 % end
265 %
266 % for i=1:model.B1
267 % outer_topboundary(:,i)=[outer_topboundary_num(:,i);double(tmp_char{i})'];
268 % if length(outer_topboundary(:,i)) < nor_bm
269 % outer_topboundary(nor_bm,i) = 0;
270 % end
271 % end
272 %
273 %
274 % %positioning of top boundary conditions
275 % outer_topbound_loop=outer_topboundary;
276 % for i=top_index
277 % BM(:,i)=outer_topbound_loop(:,1);
278 % outer_topbound_loop(:,1)=[];
279 % end
280 %
281 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
282 % %%%bottom boundaries
283 %
284 % clear fronttail
285 % fronttail=[1,0]; %definition of dim, diri, lq, lg
286 %
287 % for i=1:model.B1
288 % lq=length(model.gamma_bottom{i}{1}); %number of chars for
289 % lg=length(model.gamma_bottom{i}{2}); %number of chars for
290 % outer_bottomboundary_num(i,:)=[fronttail,lq, lg];
291 % end
292 %
293 % outer_bottomboundary_num=outer_bottomboundary_num';
294 %
295 % tmp_char={};
296 % for i=1:model.B1
297 % tmp_char1=model.gamma_bottom{i}{1};
298 % tmp_char2=model.gamma_bottom{i}{2};
299 %
300 % tmp_char{i}=[tmp_char1,tmp_char2]; %
301 % end
302 %
303 % a=[];
304 % for i=1:model.B1
305 % a=[];
306 % a=[outer_bottomboundary_num(:,i);double(tmp_char{i})'];
307 % if length(a) < nor_bm
308 % a(nor_bm);
309 % end
310 % outer_bottomboundary(:,i)=a;
311 %
312 % % outer_bottomboundary(:,i)=[outer_bottomboundary_num(:,i);double(tmp_char{i})'];
313 % % if length(outer_bottomboundary(:,i)) < nor_bm
314 % % outer_bottomboundary(nor_bm,i) = 0;
315 % % end
316 % end
317 %
318 % %positioning of bottom boundary conditions
319 % outer_bottombound_loop=outer_bottomboundary;
320 % for i=bottom_index
321 % BM(:,i)=outer_bottombound_loop(:,1);
322 % outer_bottombound_loop(:,1)=[];
323 % end
324 %
325 %
326 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
327 % %%%%%%left boundaries
328 % clear fronttail
329 % fronttail=[1,0]; %definition of dim, diri, lq, lg
330 %
331 % for i=1:model.B2
332 % lq=length(model.gamma_left{i}{1}); %number of chars for
333 % lg=length(model.gamma_left{i}{2}); %number of chars for
334 % outer_leftboundary_num(i,:)=[fronttail,lq, lg];
335 % end
336 %
337 % outer_leftboundary_num=outer_leftboundary_num';
338 %
339 % tmp_char={};
340 % for i=1:model.B2
341 % tmp_char1=model.gamma_left{i}{1};
342 % tmp_char2=model.gamma_left{i}{2};
343 %
344 % tmp_char{i}=[tmp_char1,tmp_char2]; %
345 % end
346 %
347 % a=[];
348 % for i=1:model.B2
349 % a=[];
350 % a=[outer_leftboundary_num(:,i);double(tmp_char{i})'];
351 % if length(a) < nor_bm
352 % a(nor_bm);
353 % end
354 % outer_leftboundary(:,i)=a;
355 %
356 % % outer_bottomboundary(:,i)=[outer_bottomboundary_num(:,i);double(tmp_char{i})'];
357 % % if length(outer_bottomboundary(:,i)) < nor_bm
358 % % outer_bottomboundary(nor_bm,i) = 0;
359 % % end
360 % end
361 %
362 % %positioning of left boundary conditions
363 % outer_leftbound_loop=outer_leftboundary;
364 % for i=left_index
365 % BM(:,i)=outer_leftbound_loop(:,1);
366 % outer_leftbound_loop(:,1)=[];
367 % end
368 %
369 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
370 % %%%%%%right boundaries
371 % clear fronttail
372 % fronttail=[1,0]; %definition of dim, diri, lq, lg
373 %
374 % for i=1:model.B2
375 % lq=length(model.gamma_right{i}{1}); %number of chars for
376 % lg=length(model.gamma_right{i}{2}); %number of chars for
377 % outer_rightboundary_num(i,:)=[fronttail,lq, lg];
378 % end
379 %
380 % outer_rightboundary_num=outer_rightboundary_num';
381 %
382 % tmp_char={};
383 % for i=1:model.B2
384 % tmp_char1=model.gamma_right{i}{1};
385 % tmp_char2=model.gamma_right{i}{2};
386 %
387 % tmp_char{i}=[tmp_char1,tmp_char2]; %
388 % end
389 %
390 % a=[];
391 % for i=1:model.B2
392 % a=[];
393 % a=[outer_rightboundary_num(:,i);double(tmp_char{i})'];
394 % if length(a) < nor_bm
395 % a(nor_bm);
396 % end
397 % outer_rightboundary(:,i)=a;
398 %
399 % % outer_bottomboundary(:,i)=[outer_bottomboundary_num(:,i);double(tmp_char{i})'];
400 % % if length(outer_bottomboundary(:,i)) < nor_bm
401 % % outer_bottomboundary(nor_bm,i) = 0;
402 % % end
403 % end
404 %
405 % %positioning of left boundary conditions
406 % outer_rightbound_loop=outer_rightboundary;
407 % for i=right_index
408 % BM(:,i)=outer_rightbound_loop(:,1);
409 % outer_rightbound_loop(:,1)=[];
410 % end
411 
412 
413 grid = [];
414 grid.p = p;
415 grid.e = e;
416 grid.t = t;
417 
418 model_data.grid = grid;
419 
420 model_data.dl=dl;
421 %model_data.dl = dl;
422 %model_data.boundary_matrix=BM;
423 
424 
425 %eof
426 
427 
428 % inner = [3, 7, 2, 9];
429 % all = 1:100;
430 
431 % b = zeros(1,length(all));
432 % b(inner)= 1;
433 % outer = find(b==0);
434 
435 % b = [1,5,3,8]
436 % setdiff(1:100,b)
437 
438 
439