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

📄 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);


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                        Lake Superior
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

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=[
-8.9154147   1.6615920	
-8.8847064   1.5538653
-8.7270571   1.4396306
-8.6780329   1.3310253
-8.2763869   1.3642085
-7.7589437   1.5521208
-7.3399811   1.5866412
-7.2064877   1.7400111
-6.9871610   1.7838988
-6.9190874   1.6751018
-6.6594362   1.8237880
-6.4705078   2.0285109
-6.3982459   2.0257761
-6.1776033   2.1236043
-5.9683636   1.9041636
-6.0500631   1.6420917
-6.2751037   1.4382319
-6.2083449   1.2768143
-6.3593873   1.1233594
-6.4379782   0.9672913
-6.4389687   0.9408290
-6.3308569   0.9103191
-5.9216680   1.1606956
-5.8853530   1.1594465
-5.5306989   0.8827500
-5.4571118   0.9068911
-5.2776995   0.8218321
-4.6882658   1.0696109
-4.4325551   1.1157840
-3.9867787   1.5284986
-3.6232783   1.5733560
-3.5156848   1.5181578
-3.1151141   1.6162773
-2.6031886   1.9253444
-2.4201615   2.0814581
-2.0576784   2.1825510
-1.9469493   2.3929843
-1.6564457   2.6016249
-1.4385855   2.8113568
-1.1857180   2.9681802
-0.8965760   3.2839699
-0.4656316   3.4939341
-0.0715676   3.6520868
 0.3221563   3.5994536
 0.6089023   3.4943945
 0.6092879   3.3885375
 0.3942456   3.3878929
 0.2866788   3.4141384
 0.0717038   3.3345153
 0.0896864   3.2286668
 0.1076576   3.1757488
-0.1436793   3.0169900
-0.3235837   2.8584538
-0.4676923   2.7529346
-0.9391942   2.0668111
-1.0495193   1.7498742
-1.0882363   1.3531376
-1.0158452   1.3262275
-0.9424102   1.4845979
-0.6152380   1.7477533
-0.5061946   1.9061816
-0.2890742   2.0115316
-0.5066670   1.7473959
-0.6160022   1.5360392
-0.3979720   1.8000363
-0.1808403   1.8525961
 0.2894343   1.7998173
 0.5431103   1.6681146
 0.9058832   1.5373304
 0.9432856   1.3258124
 1.0534256   1.1147328
 1.1641909   0.8507940
 1.3109203   0.6930545
 1.3117251   0.5871977
 1.4214690   0.5351345
 1.9317215   0.5400872
 2.2226054   0.5965222
 2.3340522   0.4391798
 2.4073552   0.4137156
 2.4449497   0.3348350
 2.5909063   0.3369578
 2.6249835   0.4962917
 2.7343488   0.4979874
 2.8454551   0.3938967
 2.9366470   0.3954205
 2.9201944   0.2892562
 2.9931921   0.2905022
 3.3135431   0.7199108
 3.3863589   0.7213257
 3.9960329   1.1315466
 4.0705567   1.0538628
 4.6490632   1.1744760
 4.9039980   1.1550887
 5.4495532   1.1450567
 5.9850466   1.4278414
 6.1653805   1.4607402
 6.3476152   1.4409063
 6.6355959   1.5048353
 6.5309084   1.3948027
 6.4623697   1.2862027
 6.4803085   0.8098819
 6.4094979   0.7542354
 6.4100090   0.7012564
 6.4882671   0.5981826
 6.7068647   0.6065329
 6.8546905   0.5593290
 6.9296957   0.5093111
 7.3625916   0.6332439

⌨️ 快捷键说明

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