FVCOM非结构化网格生成

概述了为FVCOM创建必要的非结构化网格文件的过程,包括开放边界。

SMS

为避免重复,该手册对如何创建非结构化网格,内插测深图以及如何导出相关文件(第20.2节)进行了广泛描述。

注意:在SMS版本10中,要导出“ pts”文件,请在“网格数据”层中选择插值的测深图,右键单击实际的插值测深图,选择“导出”,将文件类型更改为“通用ASCII文件”,或者选择一个文件名(我建议将casename.dat作为输出文件名),然后单击“保存”。可以使用MATLAB fvcom-toolbox函数读取此导出的ASCII文件的格式,read_sms_mesh然后使用导出为FVCOM格式write_FVCOM_bath。创建非结构化网格并保存项目后,将自动创建2dm文件。

我们发现了一些技巧:

  1. 要对域内的分辨率进行一些控制,请创建具有特定节点间距的弧,从而强制网格通过这些节点进行细化。
  2. 在开放边界上具有两个节点的元素的顶点应垂直于边界。尽管要使用MATLAB脚本来获取开放边界的位置,计算当前节点周围的给定一对元素边的方向并计算垂直于该方向并间隔开的模型域内的新点,但这很难自动实现等于两个周围元素的长度应该相对简单地创建。
  3. 质量差的元素(即那些不符合质量标准的元素)通常可以通过选择“元素”>“松弛”来自动修复。如果未选择任何元素,则将放宽整个网格(这可能会导致以前良好的元素以某种方式无法通过质量标准),否则,将仅放宽选定的元素。要提高元素质量,可能需要多次执行Elements> Relax。

导入Shapefile

  1. 在SMS中选择GIS模块。
  2. 从数据菜单中,选择添加Shapefile数据。选择一个shapefile,然后单击“打开”。
  3. 要将shapefile转换为可生成网格的要素,请单击GIS模块中的选择工具,然后选择要使用的多边形。
  4. 在“贴图”菜单中,选择“形状”→“特征对象”,将多边形/线转换为可以在“贴图”模块中照常编辑的特征。

MATLAB fvcom工具箱

要使用fvcom-toolbox 创建FVCOM所需的ASCII文件,过程如下:

  1. 用读取SMS网格和测深read_sms_mesh
  2. 提取开放边界节点(add_obc_nodes_list),为的参数中的ObcType赋值为2 add_obc_nodes_list(在Beardsley和Haidvogel(1981)之后被“钳制”)。有关ObcType选项,请参见FVCOM手册中的表6.1。
  3. 使用导出FVCOM网格ASCII文件(_grd.datwrite_FVCOM_grid
  4. 使用导出FVCOM水深ASCII文件(_dep.datwrite_FVCOM_bath
  5. 使用导出FVCOM开放边界ASCII文件(_obc.datwrite_FVCOM_obc

使用fvcom-toolbox微调SMS网格

FVCOM手册中的第77页,图6.2建议沿开放边界的元素应尽可能靠近直角三角形。这样,fvcom-toolbox包含一个名为的例程fix_inside_boundary,该例程将读取给定的SMS非结构化网格并调整与指定的开放边界相邻的节点的位置,以确保它们尽可能接近直角。生成的网格没有执行额外的质量检查,因此通常有必要将网格加载到SMS中,以确保所有元素均符合FVCOM手册中定义的质量标准。为了简化此过程,write_SMS_2dm创建了一个新功能,可以将非结构化网格导出为SMS格式。下图显示了优化SMS非结构化网格(红色)和调整后的网格(蓝色)的结果。

 

fix_inside_boundary.m脚本有点蛮力,并且在开放边界上的第一个和最后一个节点都遇到困难。这可能会在拐角处以及陆地和开放边界之间创建重叠元素。为了减轻这种情况,请使您的开放边界更加弯曲,或者进行编辑fix_inside_boundary.m以检查两个相邻元素边与当前节点之间的角度是否达到某个最小值(即,如果角度小于90度,请跳过此节点)。

最后,纠正重叠元素所需的重新调整可能会导致2dm文件中的元素表出现问题。因此,有时有必要在SMS中选择一个节点字符串并运行Nodestrings> Renumber。然后可以对测深法进行插值并根据需要导出。

下面给出了一个示例MATLAB脚本,其中显示了如何读取SMS文件并执行优化。

 % Read in an existing SMS mesh and adjust the nodes adjacent to the 
    % open boundary to be approximately normal to it.
 
    matlabrc
    close all
    clc
 
    global ftbverbose
    ftbverbose = 1; % be noisy
 
    %%%------------------------------------------------------------------------
    %%%                          INPUT CONFIGURATION
    %%%
    %%% Define the input parameters here.
    %%%
    %%%------------------------------------------------------------------------
 
    conf.base = '/data/medusa/pica/models/FVCOM/wavehub/run/';
 
    % Case name for the model inputs and outputs
    conf.casename = 'wavehub_v1';
 
    conf.coordType = 'cartesian'; % 'cartesian' or 'spherical'
 
    % Give some names to the boundaries. This must match the number of node
    % strings defined in SMS. Ideally, the order of the names should match the
    % order in which the boundaries were made in SMS.
    conf.boundaryNames = {'West'}; % Number is important!
 
    % Type of open boundary treatment (see Table 6.1 in the manual and mod_obcs.F).
    % 1 or 2 - Active (ASL): sea level is specified at the open boundary.
    % 3 or 4 - Clamped: zeta = 0 at the boundary (Beardsley and Haidvogel, 1981).
    % 5 or 6 - Implicit Gravity Wave Radiation.
    % 7 or 8 - Partial Clamped Gravity Wave Radiation (Blumberg and Kantha, 1985).
    % 9 or 10 - Explicit Orlanski Radiation (Orlanski, 1976; Chapman, 1985)
    conf.obc_type = 1;
 
    % Output file prefix.
    conf.outbase = fullfile(conf.base, 'input', conf.casename);
 
 
    %%%------------------------------------------------------------------------
    %%%                      END OF INPUT CONFIGURATION
    %%%------------------------------------------------------------------------
 
    %% Prepare the data
 
    % Read the input mesh and bathymetry. Also creates the data necessary for
    % the Coriolis correction in FVCOM.
    Mobj = read_sms_mesh(...
        '2dm', fullfile(conf.base, 'raw_data/', [conf.casename, '.2dm']),...
        'bath', fullfile(conf.base, 'raw_data/',[conf.casename, '.dat']),...
        'coordinate', conf.coordType, 'addCoriolis', true);
 
    % Parse the open boundary nodes and adjust accordingly.
    x3 = Mobj.x;
    y3 = Mobj.y;
    if Mobj.have_strings
        for i = 1:size(Mobj.read_obc_nodes,2)
            nodeList = double(cell2mat(Mobj.read_obc_nodes(i)));
            Mobj = add_obc_nodes_list(Mobj, nodeList, conf.boundaryNames{i}, conf.obc_type);
            % For each of the open boundaries, find the points inside the
            % boundary and move the closest existing point to that location.
            % This should make the boundaries more orthogonal (as suggested by
            % the FVCOM manual in Figure 6.2 on page 77 [as of 2013-03-11]).
            [x3, y3] = fix_inside_boundary(x3, y3, Mobj.read_obc_nodes{i});
        end
    end
 
    %% Write out the required files.
 
    % Make the output directory if it doesn't exist.
    if exist(conf.outbase, 'dir') ~= 7
        mkdir(conf.outbase)
    end
 
    % Save a new 2dm file from the adjusted points for final touching up in
    % SMS.
    write_SMS_2dm(fullfile(conf.outbase, [conf.casename, '_adjusted.2dm']), ...
        Mobj.tri, x3, y3, Mobj.read_obc_nodes)
 
  • 4
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值