# Adaptive Mesh Refinement
![adaptive mesh refinement](demo.jpg)
This software supports an adaptive mesh refinement of a two-dimensional grid by comparing a *metric* evaluated at *nodes* on the grid, or *mesh*.
### Installation
Download or pull this repository. From MATLAB, run the `meshToyProblem.m` script and/or the `runAllTests.m` script to verify that the software is running. No additional compilation steps are required.
### Algorithm Overview
*For an example of this code in action, see the `meshToyProblem.m` script*
A mesh refinement problem begins with a *mesh* composed of a single *cell*; each cell is represented by four corners, each an individual *node*. Nodes are characterized by a *metric*, i.e., the value asociated with the (*x*, *y*) position that the node represents. Accordingly, the nodes, represented by the `adaptiveMesh.Node` class, are responsible for computing evaluating the metric. To run an adaptive mesh refinement for your problem of interest, you must first create a class that extends the `adaptiveMesh.Node` class and overrides the `getMetric()` function. An example of a custon Node class is supplied in the `ToyNode` class located in the `tests` folder.
To initialize the mesh, represented by the `adaptiveMesh.Mesh` class, instantiate the object and specify the bounds and node class:
```matlab
mapMesh = adaptiveMesh.Mesh();
bounds = [-1, 1, -2, 2]; % rectangle with x-bounds of [-1, 1] and y-bounds of [-2, 2]
templateNode = MyNodeClass(); % A node class you have created that extends adaptiveMesh.Node
mapMesh.init(bounds, templateNode)
```
At this point, the mesh is very simple: a single cell with a node at each of the four corners: (*x*, *y*) = { (-1, -2), (-1, 2), (1, 2), (1, -2) }. The next step is to specify the mesh refinement limits, primarily by setting a minimum number of refinement steps and minimum cell dimensions:
```matlab
mapMesh.setMinLevel(2);
mapMesh.setMinCellSize([1e-4, 2e-4]);
```
The minimum level (specified by the `setMinLevel()` function) defines the minimum level of mesh refinement that must occur. When the mesh is initialized to a single cell, that cell is at level 0. Subdividing this level-0 cell yields four cells, each with a level of 1. Similarly, subdividing one of these smaller cells creates four even smaller cells, each at level 2. The mesh refinement is forced to continue until the entire mesh is composed of cells with levels of at least the minimum level. Thus, constraining the minimum level to be 2 guarantees that the single initial cell will be subidivided into 4^2 = 16 cells. Equivalently, the width and height of the initial cell will be split into 2^2 = 4 equally-sized segments.
While the minimum level ensures the refinement does not "quit" too soon, the minimum cell size prevents the refinement from continuing for an infinitely long period of time. A cell is allowed to subdivide as long as the four cells that will be created have dimensions greater than the minimum cell size. In the example code above, the minimum cell width is 1e-4 and the minimum cell height is 2e-4. Thus, a cell with a width smaller than 2e-4 or a height smaller than 4e-4 will not be permitted to subdivide.
Once the mesh settings are configured, call the refine function to run the algorithm:
```matlab
mapMesh.refine()
```
When the refinement process is complete, the refined mesh is available from the mesh class properties, `mapMesh.nodeMap` and `mapMesh.cellMap`. See the example script, `meshToyProblem.m` for an example.
### Documentation
The code is reasonably well documented, and this documentation can be visually inspected via MATLAB's `doc` command:
```matlab
doc adpativeMesh.Cell
doc adpativeMesh.Mesh
doc adaptiveMesh.Node
```
Each of these commands opens the MATLAB web browser to view HTML class documentation.
### Acknowledgements
This software employs an indexing strategy found in the following paper:
* Ji, H., Lien, F.-S., and Yee, E., "A new adaptive mesh refinement data structure with an application to detonation", *Journal of Computational Physics*, 229(**23**), 20 November 2010, pp. 8981&endash;8993. DOI: [10.1016/j.jcp.2010.08.023](https://doi.org/10.1016/j.jcp.2010.08.023)
没有合适的资源?快使用搜索试试~ 我知道了~
matlab节点定位代码-adaptive-mesh-refinement:MATLAB的自适应网格细化算法
共12个文件
m:8个
md:2个
jpg:1个
需积分: 49 16 下载量 186 浏览量
2021-05-27
23:17:48
上传
评论 3
收藏 109KB ZIP 举报
温馨提示
matlab官方定位代码自适应网格细化 该软件通过比较在网格或网格上的节点处评估的度量来支持二维网格的自适应网格细化。 安装 下载或提取此存储库。 在MATLAB中,运行meshToyProblem.m脚本和/或runAllTests.m脚本以验证软件是否正在运行。 无需其他编译步骤。 算法概述 有关此代码的实际示例,请参见meshToyProblem.m脚本 网格细化问题始于由单个单元格组成的网格。 每个像元由四个角表示,每个角代表一个单独的节点。 节点以度量为特征,即与该节点表示的( x , y )位置相关联的值。 因此,由adaptiveMesh.Node类表示的节点负责计算评估指标。 要针对您所关注的问题运行自适应网格细化,必须首先创建一个类,该类扩展adaptiveMesh.Node类并覆盖getMetric()函数。 custon Node类的示例在tests文件夹中的ToyNode类中提供。 要初始化由adaptiveMesh.Mesh类表示的网格,请实例化对象并指定边界和节点类: mapMesh = adaptiveMesh.Mesh(); bounds = [- 1
资源详情
资源评论
资源推荐
收起资源包目录
adaptive-mesh-refinement-master.zip (12个子文件)
adaptive-mesh-refinement-master
meshToyProblem.m 1KB
tests
testToyProblem.m 1KB
testCell.m 1KB
ToyNode.m 368B
demo.jpg 104KB
runAllTests.m 243B
LICENSE.md 1KB
.gitignore 4B
+adaptiveMesh
Mesh.m 17KB
Node.m 3KB
Cell.m 24KB
README.md 4KB
共 12 条
- 1
weixin_38531017
- 粉丝: 8
- 资源: 917
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0