⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 meshdemo.m

📁 一个功能强大的非结构网格划分程序,可实现网格的自动剖分,及局部加密与质量控制
💻 M
📖 第 1 页 / 共 2 页
字号:
function meshdemo

% Demo function for mesh2d.
%
% Feel free to "borrow" any of the geometries for your own use.
%
% Example:
%
%   meshdemo;       % Runs the demos
%
% Darren Engwirda - 2006

clc

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                           Circle
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

answer = input(['This is a demo function for mesh2d. \n'                                                     ...
                '\n'                                                                                         ...
                'Several example meshes are shown, starting with some simple examples and progressing to \n' ...
                'the CFD-like applications for which the function was designed. \n'                          ...
                '\n'                                                                                         ...
                'The following is a simple mesh in a circle. Continue?? [y/n] \n'],'s');

if ~strcmp(answer,'y')
    return
end

% Geometry
dtheta = pi/25;
theta  = (-pi:dtheta:(pi-dtheta))';
node   = [cos(theta) sin(theta)];

% Make mesh
[p,t] = mesh2d(node);


answer = input(['The element size function is generated automatically to try to adequately resolve the geometry. \n'    ...
                '\n'                                                                                                    ...
                'This means that the mesh size is related to the length of the line segments used to define the \n'     ...
                'geometry. The following example is the same as the last, but with more lines used to represent the \n' ...
                'circle. Continue?? [y/n] \n'],'s');

if ~strcmp(answer,'y')
    return
end

% Geometry
dtheta = pi/75;
theta  = (-pi:dtheta:(pi-dtheta))';
node   = [cos(theta) sin(theta)];

% Make mesh
[p,t] = mesh2d(node);


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                           Square
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

answer = input(['It is often necessary to specify the element size in some locations and the following example \n' ...
                'illustrates the use of a user specified sizing.'                                                  ...
                '\n'                                                                                               ...
                'Continue [y/n] \n'],'s');

if ~strcmp(answer,'y')
    return
end

close all

node = [
    0   0
    1   0
    1   1
    0   1
        ];

hdata.fun = @hfun1;

[p,t] = mesh2d(node,[],hdata);


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                       Sliver regions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

answer = input(['Mesh2d can now deal with very fine "sliver" geometry features \n' ...
                '\n'                                                               ...
                'Continue [y/n] \n'],'s');

if ~strcmp(answer,'y')
    return
end

close all

        node  = [0 0
                 3 0
                 3 3
                 0 3
                 0.1 1
                 0.11 1
                 0.11 2
                 0.1 2
                 ];
        cnect = [1 2
                 2 3
                 3 4
                 4 1
                 5 6
                 6 7
                 7 8
                 8 5
                 ];

        [p,t] = mesh2d(node,cnect);


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                    Cylinder in crossflow
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

answer = input(['The following is a mesh used to simulate the flow past a cylinder. \n'                ...
                '\n'                                                                                   ...
                'This example also shows how user specified and automatic size functions are combined' ...
                '\n'                                                                                   ...
                'Continue [y/n] \n'],'s');

if ~strcmp(answer,'y')
    return
end

close all

theta = 0:pi/100:(2*pi-pi/100);
x     = cos(theta)/2;
y     = sin(theta)/2;

node = [ x'  y'
        -5  -10
        25  -10
        25   10
        -5   10 
       ];

n = size(node,1)-4;

cnect = [(1:n-1)' (2:n)'
          n        1
          n+1      n+2
          n+2      n+3
          n+3      n+4
          n+4      n+1
        ]; 

hdata = [];
hdata.fun = @hfun2;

[p,t] = mesh2d(node,cnect,hdata);


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                         Airfoil + flap
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

answer = input(['The following is a mesh used to simulate the flow past an airfoil/flap configuration. \n' ...
                '\n'                                                                                       ...
                'Continue [y/n] \n'],'s');

if ~strcmp(answer,'y')
    return
end

close all

wing = [
 1.00003  0.00126  
 0.99730  0.00170  
 0.98914  0.00302  
 0.97563  0.00518  
 0.95693  0.00812  
 0.93324  0.01176  
 0.90482  0.01602  
 0.87197  0.02079  
 0.83506  0.02597  
 0.79449  0.03145  
 0.75070  0.03712  
 0.70417  0.04285  
 0.65541  0.04854  
 0.60496  0.05405  
 0.55335  0.05924  
 0.50117  0.06397  
 0.44897  0.06811  
 0.39733  0.07150  
 0.34681  0.07402  
 0.29796  0.07554  
 0.25131  0.07597  
 0.20738  0.07524  
 0.16604  0.07320  
 0.12732  0.06915  
 0.09230  0.06265  
 0.06203  0.05382  
 0.03730  0.04324  
 0.01865  0.03176  
 0.00628  0.02030  
 0.00015  0.00956  
 0.00000  0.00000  
 0.00533 -0.00792  
 0.01557 -0.01401  
 0.03029 -0.01870  
 0.04915 -0.02248  
 0.07195 -0.02586  
 0.09868 -0.02922  
 0.12954 -0.03282  
 0.16483 -0.03660  
 0.20483 -0.04016  
 0.24869 -0.04283  
 0.29531 -0.04446  
 0.34418 -0.04510  
 0.39476 -0.04482  
 0.44650 -0.04371  
 0.49883 -0.04188  
 0.55117 -0.03945  
 0.60296 -0.03655  
 0.65360 -0.03327  
 0.70257 -0.02975  
 0.74930 -0.02607  
 0.79330 -0.02235  
 0.83407 -0.01866  
 0.87118 -0.01512  
 0.90420 -0.01180  
 0.93279 -0.00880  
 0.95661 -0.00621  
 0.97543 -0.00410  
 0.98901 -0.00254  
 0.99722 -0.00158  
 0.99997 -0.00126   
 ];

flap = rotate(0.4*wing,10);
flap = move(flap,0.95,-0.1);
wing = rotate(wing,5);
wing = move(wing,0,0.05);

wall = [
      -1      -3
       4      -3
       4       3
      -1       3 
       ];

nwing = size(wing,1);
nflap = size(flap,1);
nwall = size(wall,1);

cwing = [(1:nwing-1)', (2:nwing)'; nwing, 1];
cflap = [(1:nflap-1)', (2:nflap)'; nflap, 1];
cwall = [(1:nwall-1)', (2:nwall)'; nwall, 1];

cnect = [
        cwing
        cflap+nwing
        cwall+nflap+nwing
        ];

node = [wing; flap; wall];

hdata = [];
hdata.edgeh = [(1:size(cnect,1)-4)', 0.005*ones(size(cnect,1)-4,1)];

options.dhmax = 0.25;

[p,t] = mesh2d(node,cnect,hdata,options);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                        河流
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

answer = input(['The following is a mesh of Lake Superior and is a standard test of mesh algorithms. \n' ...
                '\n'                                                                                     ...
                'This example uses the automatic size function only'                                     ...
                '\n'                                                                                     ...
                'Continue [y/n] \n'],'s');

if ~strcmp(answer,'y')
    return
end

close all

%       From:
%       Computer Solutions Europe AB
%       Bjornnasvagen 21
%       S-113 47 Stockholm
%       SWEDEN
%       Tel:    +46 8 15 30 22
%       Fax:    +46 8 15 76 35
%       E-mail: info@comsol.se
%       URL:    http://www.comsol.se/

p1=[
40388958.94	3568824.25
40389408.97	3568742.25
40389692.69	3568631.75
40390153.88	3568354.5
40390541.16	3568103.25
40390754.84	3567948
40390972	3567770.25
40391300	3567432.75
40391416.09	3567291.25
40391583.16	3567037.5
40391692.88	3566873.25
40391845.41	3566605.75
40391936.72	3566417.25
40392189.81	3565992.25
40392461.75	3565558.25
40392562.94	3565290.75
40392767.97	3564852.25
40392867.91	3564665
40393000.97	3564406.25
40393086.63	3564221.75
40393205.91	3563958.5
40393275.56	3563767.75
40393382.03	3563490.25
40393416.16	3563308.5
40393526.88	3563056
40393831.52	3563001.625
40393933.06	3562983.5
40394162.26	3563000.909
40394216.13	3563005
40394424	3563015.75
40394703.38	3563061.75
40394931.63	3563097
40395216.03	3563147.5
40395463.63	3563146.25
40395738.75	3563163
40395979.5	3563153.75
40396262.63	3563124.5
40396321.91	3563120.653
40396321.91	3561801.377
40396062.16	3561859.25
40395587.53	3561941.25
40395134.16	3562011.5
40394698.41	3562037
40394206.91	3562022.75
40394017.13	3561996.75
40393621.03	3561937.75
40393231.03	3561821.25
40393084.55	3561788.734
40393029.44	3561776.5
40392787.41	3561633.093
40392680.09	3561569.5
40392558.53	3561492.25
40392335.91	3561357.75
40392002.25	3561114.25
40391830.69	3561008
40391592.94	3560874.5
40391193.22	3560592.5
40390765.13	3560300.5
40390564.59	3560166
40390098.81	3559965.75
40389615.03	3559809.5
40389331.25	3559691.5
40388908.94	3559563.5
40388451	3559441.5
40388062.34	3559243.25
40387893.63	3559170.5
40387427.78	3558946.5
40387293.56	3558830.5
40387100.84	3558659.5
40386681.81	3558361.25
40386502.34	3558231.25
40386131.13	3557972.75
40385747.5	3557659.25
40385358.03	3557315
40385173.66	3557160.75
40384996.41	3557018.5
40384780.28	3556850.5
40384336.47	3556621
40384277.52	3556597.71
40383870.91	3556437
40383535.28	3556243.75
40383237.95	3556115.306
40383135.97	3556071.25
40383005.67	3556011.056
40382922.48	3555972.628
40382693.04	3555866.635
40382677.59	3555859.5
40382657.27	3555850.988
40382616.89	3555834.07
40382556.19	3555808.639
40382465.09	3555770.469
40382263.47	3555686
40381962.15	3555490.101
40381676.45	3555343.167
40381581.21	3555294.189
40381379.83	3555123.419
40381285	3555043
40381029.81	3554731
40380851.38	3554491.5
40380588.59	3554122.75
40380327.91	3553680
40380059.97	3553293.5
40379945.75	3553070.047
40379842.59	3552868.25
40379796.84	3552596
40379744.78	3552367.25
40379722.02	3552040.953
40379707.22	3551828.75
40379690.56	3551757.25
40379660.04	3551708.138
40379523.93	3551776.191
40379325.59	3551875.365
40379133.03	3551971.645
40378890.19	3552093.065
40378743.19	3552166.563
40378650.45	3552212.933
40378618.3	3552229.006
40378495.39	3552290.462
40378315.88	3552380.216
40378171.71	3552452.303
40378123.65	3552476.332
40378247.97	3552624.25
40378587.44	3553038.25
40378739.44	3553236.25
40378974.63	3553554.437
40379053.03	3553660.5
40379186.34	3553821.5
40379332.17	3554068.313
40379449.56	3554267
40379548.84	3554456
40379783.66	3554866.5
40379903.56	3555045.5
40380221.5	3555441
40380464.72	3555659.491
40380580.78	3555763.75
40380683.84	3555895.25
40380828.33	3556103.846
40380964.72	3556300.75
40381271.02	3556632.923
40381546.97	3556926.5
40381902.53	3557309.75
40381926.39	3557332.637
40381944.21	3557349.735
40381985.9	3557389.72
40382035.57	3557437.367
40382047.99	3557449.279
40382051.1	3557452.257
40382051.87	3557453.002
40382052.13	3557453.25
40382161.38	3557541.714
40382281.84	3557639.25
40382486.31	3557770.75
40382749.21	3557976.775
40383040.34	3558139.904
40383353.56	3558315.419
40383520.6	3558409.018
40383635.37	3558473.328
40383719.45	3558617.007
40383786.25	3558731.154
40383856.91	3558939.325
40383902.75	3559160.864
40383897.57	3559460.749
40383895.11	3559603.942
40383788.13	3560076.101
40383673.57	3560581.771
40383581.9	3561276.945
40383558.98	3561544.32
40383536.06	3561765.859
40383552.19	3562278.25
40383367.28	3562640.062
40383300.75	3562770.25
40383214.78	3562988.5
40383218.19	3563455.75
40383148.53	3563701
40383023.46	3564009.283
40382984.63	3564105
40382917.75	3564300.75
40382866.75	3564510.75
40382814.88	3564752.75
40382757.53	3565028.5
40382787.69	3565249.5
40382826.53	3565503
40382958.63	3565680
40383207.44	3566020.5
40383479.36	3566261.48
40383548.78	3566323
40383672.36	3566464.433
40383723.53	3566523
40383881.38	3566665
40384100.53	3566841
40384487.81	3567137.5
40384855.19	3567455
40385238.38	3567736.25
40385653.19	3568020.25
40385813.25	3568126.75
40385909.59	3568184.75
40386335.16	3568402.25
40386773.63	3568696.25
40386977.93	3568643.188
40387046.03	3568625.5
40387120.08	3568645.14
40387332.56	3568701.5
40387822.91	3568754.75
40388029.03	3568791.5
40388270.28	3568824
40388520.28	3568818.75
];

p2=[
40385136.56	3558533.466
40385531.06	3558738.939
40385864.18	3558962.219
40386169.11	3559285.007
40386297.96	3559403.596
40386379.54	3559479.002
40386489.09	3559580.25
40386635.59	3559714
40386823.78	3559883.75
40386963.87	3559993.25
40387010.56	3560029.75
40387223.5	3560199.75
40387411.41	3560310.5
40387671.25	3560461.75
40387857.97	3560575.25
40388173.81	3560681.75
40388294.34	3560705.25
40388580.28	3560742
40388675.59	3560754.25
40388877.5	3560820.75
40389365.09	3560882
40389606.72	3560897.25
40389746.78	3560908.5
40390052.29	3560996.494
40390152.13	3561025.25
40390371.69	3561155
40390534.63	3561247
40390909.72	3561450.25
40391169.88	3561662.406
40391279.13	3561751.5
40391650.13	3562080.25
40391901.63	3562225
40392081.97	3562335
40392305.34	3562457.75
40392515.63	3562558
40392740.66	3562711.75
40392836.07	3562819.756
40392798.88	3563035.75
40392707.58	3563211.061
40392683	3563258.25
40392572.44	3563446
40392471.87	3563656.563
40392438.34	3563726.75
40392357.59	3563886.75
40392293.34	3564162.5
40392233.34	3564382.75
40392153.69	3564629.75
40392003.22	3564964.063
40391953.06	3565075.5
40391893	3565295
40391823.88	3565544.5
40391791.03	3565749.25
40391688.72	3566038.474
40391632.56	3566197.25
40391543.35	3566400.107
40391448.41	3566616
40391217.11	3566855.377
40391115.78	3566960.25
40390957.91	3567086.75
40390619.09	3567337
40390466.28	3567425.75
40390250.22	3567535.5
40390112.19	3567642
40390007.04	3567735.648
40389926.09	3567807.75
40389615.75	3567844.903
40389498	3567859
40389326.07	3567813.001
40389280.28	3567800.75
40389100.05	3567843.125
40389039.97	3567857.25
40388990.26	3567860.778
40388789.3	3567875.042
40388659.56	3567884.25
40388461.63	3567917
40388244.05	3567900.424
40388084.25	3567888.25
40387839.53	3567858.25
40387542.31	3567826.188
40387410.78	3567812
40387268.48	3567775.532
40386970.84	3567699.25
40386790.06	3567661.75
40386365.84	3567522.75
40386137	3567437.75
40385734.34	3567234.25
40385541.56	3567107
40385355.44	3567006.75
40385231.18	3566931.056
40385144.5	3566878.25
40385053.85	3566829.221
40384715.56	3566646.25
40384512.13	3566553.25
40384280.88	3566437.5
40384110.03	3566326
40383922.74	3566240.5

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -