task8
This commit is contained in:
parent
3763c53dab
commit
3882aee07a
71 changed files with 160045 additions and 0 deletions
26
ex3/seq/generate_mesh/L_shape.m
Normal file
26
ex3/seq/generate_mesh/L_shape.m
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
% Copyright: Reza Mokhtari
|
||||
clear all
|
||||
clc
|
||||
%% plot L-shape
|
||||
g=[2 0 2 0 0 1 0;
|
||||
2 2 2 0 1 1 0;
|
||||
2 2 1 1 1 1 0;
|
||||
2 1 1 1 2 1 0;
|
||||
2 1 0 2 2 1 0;
|
||||
2 0 0 2 0 1 0]';
|
||||
[p,e,t] = initmesh(g,'hmax',0.5);
|
||||
pdemesh(p,e,t)
|
||||
|
||||
%% GH
|
||||
% output from <https://de.mathworks.com/help/pde/ug/initmesh.html initmesh>
|
||||
%
|
||||
% coordinates p: [2][nnode]
|
||||
% connectivity t: [4][nelem] with t(4,:) are the subdomain numbers
|
||||
% edges e: [7][nedges] boundary edges
|
||||
% e([1,2],:) - start/end vertex of edge
|
||||
% e([3,4],:) - start/end values
|
||||
% e(5,:) - segment number
|
||||
% e([6,7],:) - left/right subdomain
|
||||
|
||||
% flatpak run org.octave.Octave <filename>
|
||||
ascii_write_mesh( p, t, e, mfilename);
|
||||
43
ex3/seq/generate_mesh/ascii_read_meshvector.m
Normal file
43
ex3/seq/generate_mesh/ascii_read_meshvector.m
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
function [ xc, ia, v ] = ascii_read_meshvector( fname )
|
||||
%
|
||||
% Loads the 2D triangular mesh (coordinates, vertex connectivity)
|
||||
% together with values on its vertices from an ASCII file.
|
||||
% Matlab indexing is stored (starts with 1).
|
||||
%
|
||||
% The input file format is compatible
|
||||
% with Mesh_2d_3_matlab:Write_ascii_matlab(..) in jacobi_oo_stl/geom.h
|
||||
%
|
||||
%
|
||||
% IN: fname - filename
|
||||
% OUT: xc - coordinates
|
||||
% ia - mesh connectivity
|
||||
% v - solution vector
|
||||
|
||||
DELIMETER = ' ';
|
||||
|
||||
fprintf('Read file %s\n',fname)
|
||||
|
||||
% Read mesh constants
|
||||
nn = dlmread(fname,DELIMETER,[0 0 0 3]); %% row_1, col_1, row_2, col_2 in C indexing!!!
|
||||
nnode = nn(1);
|
||||
ndim = nn(2);
|
||||
nelem = nn(3);
|
||||
nvert = nn(4);
|
||||
|
||||
% Read coordinates
|
||||
row_start = 0+1;
|
||||
row_end = 0+nnode;
|
||||
xc = dlmread(fname,DELIMETER,[row_start 0 row_end ndim-1]);
|
||||
|
||||
% Read connectivity
|
||||
row_start = row_end+1;
|
||||
row_end = row_end+nelem;
|
||||
ia = dlmread(fname,DELIMETER,[row_start 0 row_end nvert-1]);
|
||||
|
||||
% Read solution
|
||||
row_start = row_end+1;
|
||||
row_end = row_end+nnode;
|
||||
v = dlmread(fname,DELIMETER,[row_start 0 row_end 0]);
|
||||
end
|
||||
|
||||
|
||||
49
ex3/seq/generate_mesh/ascii_write_mesh.m
Normal file
49
ex3/seq/generate_mesh/ascii_write_mesh.m
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
function ascii_write_mesh( xc, ia, e, basename)
|
||||
%
|
||||
% Saves the 2D triangular mesh in the minimal way (only coordinates, vertex connectivity, minimal boundary edge info)
|
||||
% in an ASCII file.
|
||||
% Matlab indexing is stored (starts with 1).
|
||||
%
|
||||
% The output file format is compatible with Mesh_2d_3_matlab:Mesh_2d_3_matlab(std::string const &fname) in jacobi_oo_stl/geom.h
|
||||
%
|
||||
% IN:
|
||||
% coordinates xc: [2][nnode]
|
||||
% connectivity ia: [4][nelem] with t(4,:) are the subdomain numbers
|
||||
% edges e: [7][nedges] boundary edges
|
||||
% e([1,2],:) - start/end vertex of edge
|
||||
% e([3,4],:) - start/end values
|
||||
% e(5,:) - segment number
|
||||
% e([6,7],:) - left/right subdomain
|
||||
% basename: file name without extension
|
||||
%
|
||||
% Data have been generated via <https://de.mathworks.com/help/pde/ug/initmesh.html initmesh>.
|
||||
%
|
||||
fname = [basename, '.txt'];
|
||||
|
||||
nnode = int32(size(xc,2));
|
||||
ndim = int32(size(xc,1));
|
||||
nelem = int32(size(ia,2));
|
||||
nvert_e = int32(3);
|
||||
|
||||
|
||||
dlmwrite(fname,nnode,'delimiter','\t','precision',16) % number of nodes
|
||||
dlmwrite(fname,ndim,'-append','delimiter','\t','precision',16) % space dimension
|
||||
dlmwrite(fname,nelem,'-append','delimiter','\t','precision',16) % number of elements
|
||||
dlmwrite(fname,nvert_e,'-append','delimiter','\t','precision',16) % number of vertices per element
|
||||
|
||||
% dlmwrite(fname,xc(:),'-append','delimiter','\t','precision',16) % coordinates
|
||||
dlmwrite(fname,xc([1,2],:).','-append','delimiter','\t','precision',16) % coordinates
|
||||
|
||||
% no subdomain info transferred
|
||||
tmp=int32(ia(1:3,:));
|
||||
% dlmwrite(fname,tmp(:),'-append','delimiter','\t','precision',16) % connectivity in Matlab indexing
|
||||
dlmwrite(fname,tmp(:,:).','-append','delimiter','\t','precision',16) % connectivity in Matlab indexing
|
||||
|
||||
% store only start and end point of boundary edges,
|
||||
nbedges = size(e,2);
|
||||
dlmwrite(fname,nbedges,'-append','delimiter','\t','precision',16) % number boundary edges
|
||||
tmp=int32(e(1:2,:));
|
||||
% dlmwrite(fname,tmp(:),'-append','delimiter','\t','precision',16) % boundary edges in Matlab indexing
|
||||
dlmwrite(fname,tmp(:,:).','-append','delimiter','\t','precision',16) % boundary edges in Matlab indexing
|
||||
|
||||
end
|
||||
56
ex3/seq/generate_mesh/chip_2materials.asv
Normal file
56
ex3/seq/generate_mesh/chip_2materials.asv
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
% Square:
|
||||
% flatpak run org.octave.Octave <filename>
|
||||
% or
|
||||
% octave --no-window-system --no-gui -qf <filename>
|
||||
|
||||
clear all
|
||||
clc
|
||||
% %% L-shape
|
||||
% g=[2 0 2 0 0 1 0; % #vertices,v_1x, v_2x, v_1y, v_2y, subdomain_left, subdomain_right
|
||||
% 2 2 2 0 1 1 0;
|
||||
% 2 2 1 1 0.5 1 0;
|
||||
% 2 1 1 0.5 2 1 0;
|
||||
% 2 1 0 2 2 1 0;
|
||||
% 2 0 0 2 0 1 0]';
|
||||
|
||||
%% square
|
||||
% g=[2 0 1 0 0 1 0; % #vertices,v_1x, v_2x, v_1y, v_2y, subdomain_left, subdomain_right
|
||||
% 2 1 1 0 1 1 0;
|
||||
% 2 1 0 1 1 1 0;
|
||||
% 2 0 0 1 0 1 0]';
|
||||
|
||||
g=[2 0.00 1.00 0.00 0.00 1 0; % #vertices,v_1x, v_2x, v_1y, v_2y, subdomain_left, subdomain_right
|
||||
2 1.00 1.00 0.00 0.60 1 0;
|
||||
2 1.00 0.83 0.60 0.60 1 0;
|
||||
2 0.83 0.17 0.60 0.60 1 2;
|
||||
2 0.17 0.00 0.60 0.60 1 0;
|
||||
2 0.00 0.00 0.60 0.00 1 0;
|
||||
2 0.83 0.83 0.60 0.80 2 0;
|
||||
2 0.83 0.17 0.80 0.80 2 0;
|
||||
2 0.17 0.17 0.80 0.60 2 0;
|
||||
2
|
||||
]';
|
||||
|
||||
|
||||
[p,e,t] = initmesh(g,'hmax',0.1);
|
||||
%[p,e,t] = initmesh(g,'hmax',0.6);
|
||||
pdemesh(p,e,t)
|
||||
% pdemesh(p,e,t,"NodeLabels","on")
|
||||
|
||||
%% GH
|
||||
% output from <https://de.mathworks.com/help/pde/ug/initmesh.html initmesh>
|
||||
%
|
||||
% coordinates p: [2][nnode]
|
||||
% connectivity t: [4][nelem] with t(4,:) are the subdomain numbers
|
||||
% edges e: [7][nedges] boundary edges
|
||||
% e([1,2],:) - start/end vertex of edge
|
||||
% e([3,4],:) - start/end values
|
||||
% e(5,:) - segment number
|
||||
% e([6,7],:) - left/right subdomain
|
||||
|
||||
ascii_write_mesh( p, t, e, mfilename);
|
||||
|
||||
|
||||
|
||||
% tmp=t(1:3,:)
|
||||
|
||||
59
ex3/seq/generate_mesh/chip_2materials.m
Normal file
59
ex3/seq/generate_mesh/chip_2materials.m
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
% Square:
|
||||
% flatpak run org.octave.Octave <filename>
|
||||
% or
|
||||
% octave --no-window-system --no-gui -qf <filename>
|
||||
|
||||
clear all
|
||||
clc
|
||||
% %% L-shape
|
||||
% g=[2 0 2 0 0 1 0; % #vertices,v_1x, v_2x, v_1y, v_2y, subdomain_left, subdomain_right
|
||||
% 2 2 2 0 1 1 0;
|
||||
% 2 2 1 1 0.5 1 0;
|
||||
% 2 1 1 0.5 2 1 0;
|
||||
% 2 1 0 2 2 1 0;
|
||||
% 2 0 0 2 0 1 0]';
|
||||
|
||||
%% square
|
||||
% g=[2 0 1 0 0 1 0; % #vertices,v_1x, v_2x, v_1y, v_2y, subdomain_left, subdomain_right
|
||||
% 2 1 1 0 1 1 0;
|
||||
% 2 1 0 1 1 1 0;
|
||||
% 2 0 0 1 0 1 0]';
|
||||
|
||||
g=[2 0.00 1.00 0.00 0.00 1 0; % #vertices,v_1x, v_2x, v_1y, v_2y, subdomain_left, subdomain_right
|
||||
2 1.00 1.00 0.00 0.60 1 0;
|
||||
2 1.00 0.83 0.60 0.60 1 0;
|
||||
2 0.83 0.17 0.60 0.60 1 2;
|
||||
2 0.17 0.00 0.60 0.60 1 0;
|
||||
2 0.00 0.00 0.60 0.00 1 0;
|
||||
2 0.83 0.83 0.60 0.80 2 0;
|
||||
2 0.83 0.17 0.80 0.80 2 0;
|
||||
2 0.17 0.17 0.80 0.60 2 0;
|
||||
2 0.50 0.65 0.15 0.30 1 0;
|
||||
2 0.65 0.50 0.30 0.45 1 0;
|
||||
2 0.50 0.35 0.45 0.30 1 0;
|
||||
2 0.35 0.50 0.30 0.15 1 0
|
||||
]';
|
||||
|
||||
|
||||
[p,e,t] = initmesh(g,'hmax',0.1);
|
||||
%[p,e,t] = initmesh(g,'hmax',0.6);
|
||||
pdemesh(p,e,t)
|
||||
% pdemesh(p,e,t,"NodeLabels","on")
|
||||
|
||||
%% GH
|
||||
% output from <https://de.mathworks.com/help/pde/ug/initmesh.html initmesh>
|
||||
%
|
||||
% coordinates p: [2][nnode]
|
||||
% connectivity t: [4][nelem] with t(4,:) are the subdomain numbers
|
||||
% edges e: [7][nedges] boundary edges
|
||||
% e([1,2],:) - start/end vertex of edge
|
||||
% e([3,4],:) - start/end values
|
||||
% e(5,:) - segment number
|
||||
% e([6,7],:) - left/right subdomain
|
||||
|
||||
ascii_write_mesh( p, t, e, mfilename);
|
||||
|
||||
|
||||
|
||||
% tmp=t(1:3,:)
|
||||
|
||||
442
ex3/seq/generate_mesh/chip_2materials.txt
Normal file
442
ex3/seq/generate_mesh/chip_2materials.txt
Normal file
|
|
@ -0,0 +1,442 @@
|
|||
143
|
||||
2
|
||||
235
|
||||
3
|
||||
0 0
|
||||
1 0
|
||||
1 0.6
|
||||
0.83 0.6
|
||||
0.17 0.6
|
||||
0 0.6
|
||||
0.83 0.8
|
||||
0.17 0.8
|
||||
0.5 0.15
|
||||
0.65 0.3
|
||||
0.5 0.45
|
||||
0.35 0.3
|
||||
0.5 0.6
|
||||
0.1 0
|
||||
0.2 0
|
||||
0.3 0
|
||||
0.4 0
|
||||
0.5 0
|
||||
0.6 0
|
||||
0.7 0
|
||||
0.8 0
|
||||
0.9 0
|
||||
1 0.09999999999999999
|
||||
1 0.2
|
||||
1 0.3
|
||||
1 0.4
|
||||
1 0.5
|
||||
0.915 0.6
|
||||
0.7474999999999999 0.6
|
||||
0.665 0.6
|
||||
0.5825 0.6
|
||||
0.08500000000000001 0.6
|
||||
0 0.5
|
||||
0 0.4
|
||||
0 0.3
|
||||
0 0.2
|
||||
0 0.09999999999999998
|
||||
0.83 0.6666666666666666
|
||||
0.83 0.7333333333333334
|
||||
0.7357142857142857 0.8
|
||||
0.6414285714285715 0.8
|
||||
0.5471428571428572 0.8
|
||||
0.4528571428571429 0.8
|
||||
0.3585714285714286 0.8
|
||||
0.2642857142857143 0.8
|
||||
0.17 0.7333333333333334
|
||||
0.17 0.6666666666666667
|
||||
0.55 0.2
|
||||
0.6 0.25
|
||||
0.6 0.35
|
||||
0.55 0.4
|
||||
0.45 0.4
|
||||
0.4 0.35
|
||||
0.4 0.25
|
||||
0.45 0.2
|
||||
0.4175 0.6
|
||||
0.335 0.6
|
||||
0.2525000000000001 0.6
|
||||
0.1830860259018252 0.2575705887159407
|
||||
0.8214251519279839 0.3400910341194828
|
||||
0.7367356972768339 0.1545851641648327
|
||||
0.2747763926099513 0.4393279804701981
|
||||
0.3380125422979773 0.1490600318288089
|
||||
0.6665431110538135 0.4469555482086437
|
||||
0.296713959802076 0.6824750976249487
|
||||
0.6823887570446404 0.6988381196783868
|
||||
0.4119540982524374 0.7139680155366132
|
||||
0.5440762920546971 0.6844981967009994
|
||||
0.5488863849623231 0.08065734809935345
|
||||
0.4593284290899015 0.5303257942069471
|
||||
0.04745577342231752 0.04558193320280449
|
||||
0.9559081045112219 0.04706196837962208
|
||||
0.05571697787757442 0.5345441974182679
|
||||
0.9416966513970901 0.5479893966941878
|
||||
0.1309631118646534 0.4236995315406518
|
||||
0.8774128939624196 0.1557894847622768
|
||||
0.1554747804750385 0.1294581622541261
|
||||
0.8486232790977517 0.4679895901706703
|
||||
0.6534945367503546 0.09649470230789628
|
||||
0.3483977396498218 0.4781934195718026
|
||||
0.2483039178930304 0.335106363798257
|
||||
0.7530934478381617 0.2592989646850651
|
||||
0.7295364126041498 0.3701003238893228
|
||||
0.2683233659762636 0.2447136364527485
|
||||
0.9143800070052596 0.3450037074593404
|
||||
0.08822015826359252 0.2520686350157191
|
||||
0.4537059191295885 0.0741756455143039
|
||||
0.5413507019951419 0.5280898867902438
|
||||
0.7096450191787081 0.527961160509049
|
||||
0.6159682017017379 0.6625663124322685
|
||||
0.3592388637053299 0.07610221596732396
|
||||
0.765108404514371 0.6997816378729095
|
||||
0.4717177437761203 0.6663200430010416
|
||||
0.4854679354770992 0.7329870341912208
|
||||
0.3877365265315627 0.1908548279285711
|
||||
0.6099395334451564 0.4066137391340408
|
||||
0.2306877192446715 0.6964953882347311
|
||||
0.3598161445533513 0.6657912069407611
|
||||
0.3382100905575304 0.732458120815991
|
||||
0.1406562191310727 0.3365009009737865
|
||||
0.8627012941703919 0.2566782703816746
|
||||
0.2195359644497203 0.524181436329583
|
||||
0.2504057789554006 0.09656440959640891
|
||||
0.8609688932847446 0.07036423491723381
|
||||
0.0792332959701036 0.1598167751696082
|
||||
0.6633419637279835 0.2041432332102987
|
||||
0.7388720146622824 0.07177243733659958
|
||||
0.7591410509968218 0.4592275943922892
|
||||
0.9241864378600493 0.4352795696806243
|
||||
0.3282800786487374 0.3684755144155539
|
||||
0.6245001642495908 0.5273679175283577
|
||||
0.2130990814013797 0.1830560609252357
|
||||
0.5860181519062729 0.1635732828628243
|
||||
0.6061461985296173 0.729233213750633
|
||||
0.8749038211558559 0.5412768202367876
|
||||
0.06388571113668819 0.4576480010754793
|
||||
0.1589795129567917 0.06144175630803391
|
||||
0.9474526566112427 0.1539503712832068
|
||||
0.4177070399492428 0.4686211281102174
|
||||
0.4145875508081387 0.1396001690291554
|
||||
0.5820204934211082 0.4600303136127304
|
||||
0.6511979703975962 0.3749576639917713
|
||||
0.3372051416899794 0.2181481953330509
|
||||
0.3797444568480455 0.5346313255081716
|
||||
0.1963130627907262 0.3991956927382116
|
||||
0.1304008926063841 0.5145372655094962
|
||||
0.8068811529542688 0.1870998775716188
|
||||
0.7950607772011259 0.5328892529726835
|
||||
0.3014379962113258 0.5295700784399427
|
||||
0.936043535437924 0.2249829012752652
|
||||
0.06786843512715206 0.3723100832440311
|
||||
0.3696426508429986 0.4176130572447811
|
||||
0.8035652723323531 0.1069250059276683
|
||||
0.2809344756318412 0.1774925274550569
|
||||
0.1433346549100507 0.1960253034218661
|
||||
0.0900292624482301 0.08257958227890218
|
||||
0.8629115739649835 0.3994504619777429
|
||||
0.8044908795850402 0.4077054699969835
|
||||
0.9235971226529696 0.08805709002620099
|
||||
0.9180779212435105 0.4985449668591332
|
||||
0.9284411152026488 0.2819128596134682
|
||||
0.07377871769355998 0.3152655928916893
|
||||
0.1898942752170752 0.4604566556725514
|
||||
27 3 74
|
||||
47 5 58
|
||||
28 4 115
|
||||
58 5 102
|
||||
29 4 38
|
||||
22 2 72
|
||||
52 11 119
|
||||
50 10 122
|
||||
39 7 40
|
||||
69 9 87
|
||||
124 57 129
|
||||
71 14 136
|
||||
48 9 113
|
||||
104 22 139
|
||||
17 18 87
|
||||
51 50 96
|
||||
18 19 69
|
||||
79 20 107
|
||||
20 21 107
|
||||
21 22 104
|
||||
23 24 118
|
||||
25 26 85
|
||||
85 26 109
|
||||
54 12 123
|
||||
70 11 88
|
||||
74 28 115
|
||||
31 13 88
|
||||
37 1 71
|
||||
32 6 73
|
||||
1 14 71
|
||||
55 54 95
|
||||
14 15 117
|
||||
105 37 136
|
||||
102 5 126
|
||||
73 33 116
|
||||
33 34 116
|
||||
30 29 66
|
||||
31 30 90
|
||||
56 13 93
|
||||
66 29 92
|
||||
29 38 92
|
||||
13 31 68
|
||||
38 39 92
|
||||
45 8 46
|
||||
68 42 94
|
||||
89 30 111
|
||||
68 31 90
|
||||
66 41 114
|
||||
116 34 131
|
||||
43 44 67
|
||||
69 19 79
|
||||
2 23 72
|
||||
19 20 79
|
||||
115 4 128
|
||||
4 29 128
|
||||
67 44 99
|
||||
65 45 97
|
||||
15 16 103
|
||||
16 17 91
|
||||
45 46 97
|
||||
6 33 73
|
||||
57 56 98
|
||||
53 52 132
|
||||
81 12 110
|
||||
12 53 110
|
||||
87 9 120
|
||||
13 56 70
|
||||
30 31 111
|
||||
88 11 121
|
||||
82 10 106
|
||||
72 23 139
|
||||
70 56 124
|
||||
5 32 126
|
||||
9 55 120
|
||||
81 59 84
|
||||
11 51 121
|
||||
82 60 83
|
||||
58 57 65
|
||||
46 47 97
|
||||
40 41 66
|
||||
42 43 94
|
||||
65 57 98
|
||||
44 45 99
|
||||
41 42 114
|
||||
67 56 93
|
||||
49 48 113
|
||||
10 49 106
|
||||
56 57 124
|
||||
57 58 129
|
||||
86 36 105
|
||||
91 63 103
|
||||
118 24 130
|
||||
26 27 109
|
||||
35 36 86
|
||||
36 37 105
|
||||
3 28 74
|
||||
29 30 89
|
||||
86 59 100
|
||||
32 73 126
|
||||
85 60 101
|
||||
107 21 133
|
||||
84 59 112
|
||||
112 59 135
|
||||
96 64 121
|
||||
83 60 138
|
||||
127 61 133
|
||||
106 49 113
|
||||
81 62 125
|
||||
110 53 132
|
||||
80 62 132
|
||||
125 62 143
|
||||
79 61 106
|
||||
82 61 127
|
||||
137 78 138
|
||||
10 82 83
|
||||
103 63 134
|
||||
12 81 84
|
||||
104 76 133
|
||||
109 27 140
|
||||
100 81 125
|
||||
37 71 136
|
||||
95 54 123
|
||||
18 69 87
|
||||
96 50 122
|
||||
13 70 88
|
||||
89 64 108
|
||||
109 78 137
|
||||
30 66 90
|
||||
90 66 114
|
||||
95 63 120
|
||||
17 87 91
|
||||
39 40 92
|
||||
40 66 92
|
||||
43 67 94
|
||||
13 68 93
|
||||
93 68 94
|
||||
67 93 94
|
||||
123 84 134
|
||||
91 87 120
|
||||
83 64 122
|
||||
31 88 111
|
||||
47 58 97
|
||||
58 65 97
|
||||
45 65 99
|
||||
56 67 98
|
||||
98 67 99
|
||||
65 98 99
|
||||
59 81 100
|
||||
34 35 131
|
||||
60 82 101
|
||||
24 25 130
|
||||
116 75 126
|
||||
102 62 129
|
||||
105 77 135
|
||||
16 91 103
|
||||
22 72 139
|
||||
101 76 130
|
||||
117 77 136
|
||||
59 86 135
|
||||
9 69 113
|
||||
61 82 106
|
||||
61 79 107
|
||||
21 104 133
|
||||
64 83 108
|
||||
108 78 128
|
||||
27 74 140
|
||||
60 85 137
|
||||
11 70 119
|
||||
62 81 110
|
||||
64 89 111
|
||||
111 88 121
|
||||
112 103 134
|
||||
77 103 112
|
||||
69 79 113
|
||||
79 106 113
|
||||
42 68 114
|
||||
68 90 114
|
||||
29 89 128
|
||||
115 78 140
|
||||
100 75 131
|
||||
131 35 142
|
||||
103 77 117
|
||||
15 103 117
|
||||
130 25 141
|
||||
118 76 139
|
||||
119 70 124
|
||||
119 80 132
|
||||
63 91 120
|
||||
55 95 120
|
||||
51 96 121
|
||||
64 111 121
|
||||
10 83 122
|
||||
64 96 122
|
||||
12 84 123
|
||||
63 95 123
|
||||
62 80 129
|
||||
80 119 124
|
||||
75 100 125
|
||||
126 75 143
|
||||
62 102 143
|
||||
73 116 126
|
||||
101 82 127
|
||||
76 101 127
|
||||
89 108 128
|
||||
78 115 128
|
||||
58 102 129
|
||||
80 124 129
|
||||
25 85 141
|
||||
76 118 130
|
||||
35 86 142
|
||||
75 116 131
|
||||
62 110 132
|
||||
52 119 132
|
||||
61 107 133
|
||||
76 127 133
|
||||
84 112 134
|
||||
63 123 134
|
||||
86 105 135
|
||||
77 112 135
|
||||
77 105 136
|
||||
14 117 136
|
||||
108 83 138
|
||||
85 109 137
|
||||
78 108 138
|
||||
60 137 138
|
||||
76 104 139
|
||||
23 118 139
|
||||
78 109 140
|
||||
74 115 140
|
||||
85 101 141
|
||||
101 130 141
|
||||
86 100 142
|
||||
100 131 142
|
||||
75 125 143
|
||||
102 126 143
|
||||
59
|
||||
1 14
|
||||
14 15
|
||||
15 16
|
||||
16 17
|
||||
17 18
|
||||
18 19
|
||||
19 20
|
||||
20 21
|
||||
21 22
|
||||
22 2
|
||||
2 23
|
||||
23 24
|
||||
24 25
|
||||
25 26
|
||||
26 27
|
||||
27 3
|
||||
3 28
|
||||
28 4
|
||||
4 29
|
||||
29 30
|
||||
30 31
|
||||
31 13
|
||||
5 32
|
||||
32 6
|
||||
6 33
|
||||
33 34
|
||||
34 35
|
||||
35 36
|
||||
36 37
|
||||
37 1
|
||||
4 38
|
||||
38 39
|
||||
39 7
|
||||
7 40
|
||||
40 41
|
||||
41 42
|
||||
42 43
|
||||
43 44
|
||||
44 45
|
||||
45 8
|
||||
8 46
|
||||
46 47
|
||||
47 5
|
||||
9 48
|
||||
48 49
|
||||
49 10
|
||||
10 50
|
||||
50 51
|
||||
51 11
|
||||
11 52
|
||||
52 53
|
||||
53 12
|
||||
12 54
|
||||
54 55
|
||||
55 9
|
||||
13 56
|
||||
56 57
|
||||
57 58
|
||||
58 5
|
||||
35
ex3/seq/generate_mesh/save_mesh2_mini.m
Normal file
35
ex3/seq/generate_mesh/save_mesh2_mini.m
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
function save_mesh2_mini( xc, ia, e, basename)
|
||||
% Save the 3D triangular mesh in the minimal way (only coordinates and vertex connectivity)
|
||||
% in binary file.
|
||||
% The indexing in the connectivity is changed to C-style (starts with 0)
|
||||
%
|
||||
% coordinates xc: [2][nnode]
|
||||
% connectivity ia: [4][nelem] with t(4,:) are the subdomain numbers
|
||||
% edges e: [7][nedges] boundary edges
|
||||
% e([1,2],:) - start/end vertex of edge
|
||||
% e([3,4],:) - start/end values
|
||||
% e(5,:) - segment number
|
||||
% e([6,7],:) - left/right subdomain
|
||||
% basename: file name without extension
|
||||
% data from
|
||||
% output from <https://de.mathworks.com/help/pde/ug/initmesh.html initmesh>
|
||||
%
|
||||
fname = [basename, '.bin'];
|
||||
offset = 1; % index difference from C to Matlab
|
||||
|
||||
nnode = size(xc,2);
|
||||
ndim = size(xc,1);
|
||||
nelem = size(ia,2);
|
||||
nvert_e = 3;
|
||||
|
||||
fileID = fopen(fname,'w');
|
||||
fwrite(fileID, nnode, 'int'); % number of nodes
|
||||
fwrite(fileID, ndim, 'int'); % space dimension
|
||||
fwrite(fileID, nelem, 'int'); % number of elements
|
||||
fwrite(fileID, nvert_e, 'int'); % number of vertices per element
|
||||
|
||||
fwrite(fileID, xc(:), 'double'); % coordinates
|
||||
tmp=ia(1:3,:)-offset;
|
||||
fwrite(fileID, tmp(:), 'double'); % connectivity
|
||||
|
||||
end
|
||||
43
ex3/seq/generate_mesh/square.m
Normal file
43
ex3/seq/generate_mesh/square.m
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
% Square:
|
||||
% flatpak run org.octave.Octave <filename>
|
||||
% or
|
||||
% octave --no-window-system --no-gui -qf <filename>
|
||||
|
||||
clear all
|
||||
clc
|
||||
% %% L-shape
|
||||
% g=[2 0 2 0 0 1 0; % #vertices,v_1x, v_2x, v_1y, v_2y, subdomain_left, subdomain_right
|
||||
% 2 2 2 0 1 1 0;
|
||||
% 2 2 1 1 0.5 1 0;
|
||||
% 2 1 1 0.5 2 1 0;
|
||||
% 2 1 0 2 2 1 0;
|
||||
% 2 0 0 2 0 1 0]';
|
||||
|
||||
%% square
|
||||
g=[2 0 1 0 0 1 0; % #vertices,v_1x, v_2x, v_1y, v_2y, subdomain_left, subdomain_right
|
||||
2 1 1 0 1 1 0;
|
||||
2 1 0 1 1 1 0;
|
||||
2 0 0 1 0 1 0]';
|
||||
|
||||
[p,e,t] = initmesh(g,'hmax',0.01);
|
||||
%[p,e,t] = initmesh(g,'hmax',0.6);
|
||||
pdemesh(p,e,t)
|
||||
% pdemesh(p,e,t,"NodeLabels","on")
|
||||
|
||||
%% GH
|
||||
% output from <https://de.mathworks.com/help/pde/ug/initmesh.html initmesh>
|
||||
%
|
||||
% coordinates p: [2][nnode]
|
||||
% connectivity t: [4][nelem] with t(4,:) are the subdomain numbers
|
||||
% edges e: [7][nedges] boundary edges
|
||||
% e([1,2],:) - start/end vertex of edge
|
||||
% e([3,4],:) - start/end values
|
||||
% e(5,:) - segment number
|
||||
% e([6,7],:) - left/right subdomain
|
||||
|
||||
ascii_write_mesh( p, t, e, mfilename);
|
||||
|
||||
|
||||
|
||||
% tmp=t(1:3,:)
|
||||
|
||||
30
ex3/seq/generate_mesh/square.txt
Normal file
30
ex3/seq/generate_mesh/square.txt
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
9
|
||||
2
|
||||
8
|
||||
3
|
||||
0 0
|
||||
1 0
|
||||
1 1
|
||||
0 1
|
||||
0.5 0
|
||||
1 0.5
|
||||
0.5 1
|
||||
0 0.5
|
||||
0.5 0.5
|
||||
8 1 9
|
||||
5 2 9
|
||||
6 3 9
|
||||
7 4 9
|
||||
1 5 9
|
||||
2 6 9
|
||||
3 7 9
|
||||
4 8 9
|
||||
8
|
||||
1 5
|
||||
5 2
|
||||
2 6
|
||||
6 3
|
||||
3 7
|
||||
7 4
|
||||
4 8
|
||||
8 1
|
||||
BIN
ex3/seq/generate_mesh/square_06.jpg
Normal file
BIN
ex3/seq/generate_mesh/square_06.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
30
ex3/seq/generate_mesh/square_06_0.txt
Normal file
30
ex3/seq/generate_mesh/square_06_0.txt
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
9
|
||||
2
|
||||
8
|
||||
3
|
||||
0 0
|
||||
1 0
|
||||
1 1
|
||||
0 1
|
||||
0.5 0
|
||||
1 0.5
|
||||
0.5 1
|
||||
0 0.5
|
||||
0.5 0.5
|
||||
8 1 9
|
||||
5 2 9
|
||||
6 3 9
|
||||
7 4 9
|
||||
1 5 9
|
||||
2 6 9
|
||||
3 7 9
|
||||
4 8 9
|
||||
8
|
||||
1 5
|
||||
5 2
|
||||
2 6
|
||||
6 3
|
||||
3 7
|
||||
7 4
|
||||
4 8
|
||||
8 1
|
||||
20
ex3/seq/generate_mesh/visualize_results.m
Normal file
20
ex3/seq/generate_mesh/visualize_results.m
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
%% Visualize results
|
||||
%
|
||||
% flatpak run org.octave.Octave <filename>
|
||||
% or
|
||||
% octave --no-window-system --no-gui -qf <filename>
|
||||
%
|
||||
% or
|
||||
% matlab -nosplash < <filename>
|
||||
|
||||
clear all
|
||||
clc
|
||||
|
||||
%%
|
||||
fname = 'uv.txt';
|
||||
|
||||
[xc,ia,v] = ascii_read_meshvector(fname);
|
||||
|
||||
h = trisurf(ia, xc(:,1), xc(:,2), v);
|
||||
|
||||
waitfor(h) % wait for closing the figure
|
||||
Loading…
Add table
Add a link
Reference in a new issue