Gmsh划分网格|四点矩形

先看下面这段官方自带脚本

/***********************************************************************  Gmsh tutorial 1**  Variables, elementary entities (points, curves, surfaces), physical*  entities (points, curves, surfaces)**********************************************************************/// The simplest construction in Gmsh's scripting language is the
// `affectation'. The following command defines a new variable `lc':lc = 1e-2;// This variable can then be used in the definition of Gmsh's simplest
// `elementary entity', a `Point'. A Point is defined by a list of four numbers:
// three coordinates (X, Y and Z), and a characteristic length (lc) that sets
// the target element size at the point:Point(1) = {0, 0, 0, lc};// The distribution of the mesh element sizes is then obtained by interpolation
// of these characteristic lengths throughout the geometry. Another method to
// specify characteristic lengths is to use general mesh size Fields (see
// `t10.geo'). A particular case is the use of a background mesh (see `t7.geo').// We can then define some additional points as well as our first curve.  Curves
// are Gmsh's second type of elementery entities, and, amongst curves, straight
// lines are the simplest. A straight line is defined by a list of point
// numbers. In the commands below, for example, the line 1 starts at point 1 and
// ends at point 2:Point(2) = {.1, 0,  0, lc} ;
Point(3) = {.1, .3, 0, lc} ;
Point(4) = {0,  .3, 0, lc} ;Line(1) = {1,2} ;
Line(2) = {3,2} ;
Line(3) = {3,4} ;
Line(4) = {4,1} ;// The third elementary entity is the surface. In order to define a simple
// rectangular surface from the four curves defined above, a curve loop has first
// to be defined. A curve loop is a list of connected curves, a sign being
// associated with each curve (depending on the orientation of the curve):Curve Loop(1) = {4,1,-2,3} ;// We can then define the surface as a list of curve loops (only one here, since
// there are no holes--see `t4.geo'):Plane Surface(1) = {1} ;// At this level, Gmsh knows everything to display the rectangular surface 6 and
// to mesh it. An optional step is needed if we want to group elementary
// geometrical entities into more meaningful groups, e.g. to define some
// mathematical ("domain", "boundary"), functional ("left wing", "fuselage") or
// material ("steel", "carbon") properties.
//
// Such groups are called "Physical Groups" in Gmsh. By default, if physical
// groups are defined, Gmsh will export in output files only those elements that
// belong to at least one physical group. (To force Gmsh to save all elements,
// whether they belong to physical groups or not, set "Mesh.SaveAll=1;", or
// specify "-save_all" on the command line.)
//
// Here we define a physical curve that groups the left, bottom and right lines
// in a single group (with prescribed tag 5); and a physical surface with name
// "My surface" (with an automatic tag) containg the geometrical surface 1:Physical Curve(5) = {1, 2, 4} ;
Physical Surface("My surface") = {1} ;// Note that starting with Gmsh 3.0, models can be built using different
// geometry kernels than the default "built-in" kernel. By specifying
//
//   SetFactory("OpenCASCADE");
//
// any subsequent command in the .geo file would be handled by the OpenCASCADE
// geometry kernel instead of the built-in kernel. A rectangular surface could
// then simply be created with
//
//   Rectangle(2) = {.2, 0, 0, 0.1, 0.3};
//
// See tutorial/t16.geo for a complete example, and demos/boolean for more.
//+
Field[1] = Box;
//+
Delete Field [1];

以下是该Gmsh脚本代码的逐段解释:


1. 定义特征长度

lc = 1e-2;
  • 作用:设置网格的特征长度为0.01,该值将影响后续生成的网格密度。
    取0.01时,如下:

取0.1时,如下:

  • 说明lc 是局部网格尺寸的基准值,越小生成的网格越密。

2. 创建点(Points)

Point(1) = {0, 0, 0, lc};
Point(2) = {.1, 0,  0, lc};
Point(3) = {.1, .3, 0, lc};
Point(4) = {0,  .3, 0, lc};
  • 作用:在二维平面上定义四个点。
  • 参数Point(标签) = {X坐标, Y坐标, Z坐标, 特征长度}
  • 结果:四个点构成矩形的四个顶点(左下、右下、右上、左上)。

3. 创建线段(Lines)

Line(1) = {1, 2};  // 从点1到点2的线段
Line(2) = {3, 2};  // 从点3到点2的线段
Line(3) = {3, 4};  // 从点3到点4的线段
Line(4) = {4, 1};  // 从点4到点1的线段
  • 作用:通过连接点生成四条线段。
  • 注意:线段方向影响后续曲线环的定义,负号表示反向(例如 -2 表示线段2的反方向)。

4. 定义曲线环(Curve Loop)

Curve Loop(1) = {4, 1, -2, 3};
  • 作用:将线段组合成闭合的环形,用于生成平面。
  • 顺序:按闭合路径依次连接线段:
    1. 线段4(点4→点1)
    2. 线段1(点1→点2)
    3. 线段-2(点2→点3,反向线段2)
    4. 线段3(点3→点4)

5. 创建平面表面(Surface)

Plane Surface(1) = {1};
  • 作用:通过曲线环1生成平面表面。
  • 说明:此处定义了一个矩形区域,后续将在此区域内生成网格。

6. 定义物理实体(Physical Entities)

Physical Curve(5) = {1, 2, 4};
Physical Surface("My surface") = {1};
  • 作用:将几何实体分组,用于后续仿真或导出。
    • 物理曲线5:包含线段1、2、4,代表模型的边界(例如左、下、右边)。
    • 物理表面"My surface":包含表面1,代表整个矩形区域。
  • 意义:物理实体用于在导出网格时标记不同区域(如边界条件、材料属性)。

7. 其他代码片段

Field[1] = Box;
Delete Field [1];
  • 作用:尝试定义一个 Box 类型的场(用于控制网格尺寸),但随后被删除。
  • 说明:这段代码可能是测试或误操作,实际未生效。

关键概念总结

  1. 特征长度 lc:控制网格密度,值越小网格越密。
  2. 曲线环方向:线段的正负号决定方向,确保闭合路径正确。
  3. 物理实体
    • 定义仿真中需要关注的区域(如边界、体积)。
    • 默认仅导出属于物理实体的网格单元。

生成的几何结构

  • 一个矩形区域,左下角在原点 (0,0),右上角在 (0.1, 0.3)。
  • 物理曲线标记了左、下、右边界,物理表面标记了整个矩形区域。

通过此脚本,Gmsh将生成一个带有结构化网格的矩形,并仅导出标记的物理实体部分。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/80149.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

leetcode0215. 数组中的第K个最大元素-medium

1 题目:数组中的第K个最大元素 官方标定难度:中 给定整数数组 nums 和整数 k,请返回数组中第 k 个最大的元素。 请注意,你需要找的是数组排序后的第 k 个最大的元素,而不是第 k 个不同的元素。 你必须设计并实现时…

rocketmq 环境配置[python]

因本人是 python 开发,macbook 开发。windows 可以采取配置远程 linux 解释器或者 pycharm 专业版的 docker 解释器进行开发 M1 芯片 本地运行 rocketmq rocketmq Python 开源地址: https://github.com/apache/rocketmq-client-python 因为需要 linu…

OCCT知识笔记之OCAF框架详解

OCAF框架在OCCT项目中的构建与使用指南 Open CASCADE Application Framework (OCAF)是Open CASCADE Technology (OCCT)中用于管理CAD数据的核心框架,它提供了一种结构化方式来组织和管理复杂的CAD数据,如装配体、形状、属性(颜色、材料)和元数据等。本文…

go-数据库基本操作

1. 配置数据库 package mainimport ("gorm.io/driver/mysql""gorm.io/gorm" ) #配置表结构 type User struct {ID int64 json:"id" gorm:"primary_key" // 主键ID自增长Username stringPassword string } #配置连接接信息 func…

【含文档+PPT+源码】基于大数据的交通流量预测系统

技术栈说明 技术栈: 后端:Django(后端是前后端分离的) 前端:Vue.js ElementUI 开发工具: Python3.9以上 Pycharm MySQL5.7/MySQL8 VSCode 项目演示视频 基于大数据的交通流量预测系统

海盗王3.0的数据库3合1并库处理方案

原版的海盗王数据库有3个accountserver,gamedb,tradedb,对应到是账号数据库,游戏数据库,商城数据库。 一直都有个想法,如何把这3个库合并到一起,这样可以实现一些功能。 涉及到sqlserver的数据库…

Apollo Client 1.6.0 + @RefreshScope + @Value 刷新问题解析

问题描述 在使用 Apollo Client 1.6.0 结合 Spring Cloud 的 RefreshScope 和 Value 注解时,遇到以下问题: 项目启动时第一次属性注入成功后续配置变更时,Value 属性会刷新,但总是刷新为第一次的旧值,而不是最新的配…

LearnOpenGL --- 你好三角形

你好&#xff0c;三角形的课后练习题 文章目录 你好&#xff0c;三角形的课后练习题一、创建相同的两个三角形&#xff0c;但对它们的数据使用不同的VAO和VBO 一、创建相同的两个三角形&#xff0c;但对它们的数据使用不同的VAO和VBO #include <glad/glad.h> #include &…

STM32F407VET6实战:CRC校验

CRC校验在数据传输快&#xff0c;且量大的时候使用。下面是STM32F407VET6HAL库使用CRC校验的思路。 步骤实现&#xff1a; CubeMX配置 c // 在CubeMX中启用CRC模块 // AHB总线时钟自动启用 HAL库代码 c // 初始化&#xff08;main函数中&#xff09; CRC_HandleTypeDef …

Vue3中实现轮播图

目录 1. 轮播图介绍 2. 实现轮播图 2.1 准备工作 1、准备至少三张图片&#xff0c;并将图片文件名改为数字123 2、搭好HTML的标签 3、写好按钮和图片标签 ​编辑 2.2 单向绑定图片 2.3 在按钮里使用方法 2.4 运行代码 3. 完整代码 1. 轮播图介绍 首先&#xff0c;什么是…

Linux远程连接服务

远程连接服务器简介 远程连接服务器通过文字或图形接口方式来远程登录系统&#xff0c;让你在远程终端前登录linux主机以取得可操作主机接口&#xff08;shell&#xff09;&#xff0c;而登录后的操作感觉就像是坐在系统前面一样。 远程连接服务器的功能 分享主机的运算能力 远…

MySQL面试知识点详解

一、MySQL基础架构 1. MySQL逻辑架构 MySQL采用分层架构设计&#xff0c;主要分为&#xff1a; 连接层&#xff1a;处理客户端连接、授权认证等 服务层&#xff1a;包含查询解析、分析、优化、缓存等 引擎层&#xff1a;负责数据存储和提取&#xff08;InnoDB、MyISAM等&am…

牛客网NC22000:数字反转之-三位数

牛客网NC22000:数字反转之-三位数 &#x1f50d; 题目描述 时间限制&#xff1a;C/C/Rust/Pascal 1秒&#xff0c;其他语言2秒 空间限制&#xff1a;C/C/Rust/Pascal 32M&#xff0c;其他语言64M &#x1f4dd; 输入输出说明 输入描述: 输入一个3位整数n (100 ≤ n ≤ 999)…

C++跨平台开发:突破不同平台的技术密码

Windows 平台开发经验 开发环境搭建 在 Windows 平台进行 C 开发&#xff0c;最常用的集成开发环境&#xff08;IDE&#xff09;是 Visual Studio。你可以从Visual Studio 官网下载安装包&#xff0c;根据安装向导进行安装。安装时&#xff0c;在 “工作负载” 界面中&#xff…

[250516] OpenAI 升级 ChatGPT:GPT-4.1 及 Mini 版上线!

目录 ChatGPT 迎来重要更新&#xff1a;GPT-4.1 和 GPT-4.1 mini 正式上线用户如何访问新模型&#xff1f;技术亮点与用户体验优化 ChatGPT 迎来重要更新&#xff1a;GPT-4.1 和 GPT-4.1 mini 正式上线 OpenAI 宣布在 ChatGPT 平台正式推出其最新的 AI 模型 GPT-4.1 和 GPT-4.…

计算机指令分类和具体的表示的方式

1.关于计算机的指令系统 下面的这个就是我们的一个简单的计算机里面涉及到的指令&#xff1a; m就是我们的存储器里面的地址&#xff0c;可以理解为memory这个意思&#xff0c;r可以理解为rom这样的单词的首字母&#xff0c;帮助我们去进行这个相关的指令的记忆&#xff0c;不…

前端脚手架开发指南:提高开发效率的核心操作

前端脚手架通过自动化的方式可以提高开发效率并减少重复工作&#xff0c;而最强大的脚手架并不是现成的那些工具而是属于你自己团队量身定制的脚手架&#xff01;本篇文章将带你了解脚手架开发的基本技巧&#xff0c;帮助你掌握如何构建适合自己需求的工具&#xff0c;并带着你…

SpringBoot常用注解详解

文章目录 1. 前言2. 核心注解2.1 SpringBootApplication2.2 Configuration2.3 EnableAutoConfiguration2.4 ComponentScan2.5 Bean2.6 Autowired2.7 Qualifier2.8 Primary2.9 Value2.10 PropertySource2.11 ConfigurationProperties2.12 Profile 3. Web开发相关注解3.1 Control…

项目管理进阶:全文解读企业IT系统全生命周期管理与运营平台建设方案【附全文阅读】

本文介绍了《企业IT系统全生命周期管理与运营平台建设方案》的项目内容&#xff0c;包括项目背景、蓝图架构、核心业务流程、系统总体架构、解决方案等。 重点内容&#xff1a; 1. 项目背景&#xff1a;介绍企业IT系统全生命周期管理的重要性。 2. 蓝图架构&#xff1a;描述项目…

记录一次vue项目页面内嵌iframe页面实现跨域上传和下载附件的功能

功能背景&#xff1a;项目部署在外网&#xff0c;然后其中有一个功能需要上传下载附件&#xff0c;附件是上传到华为云对象存储服务OBS中&#xff08;私有云&#xff09;&#xff0c;所以采用iframe嵌套页面的方式解决跨域问题。 实现思路&#xff1a; 1、父窗口封装一个组件专…