[![DOI](https://zenodo.org/badge/276864022.svg)](https://zenodo.org/badge/latestdoi/276864022)
# FEMT2D
This repository contains the MATLAB toolbox `FEMT2D`.
It provides a discretization of Helmholtz type PDE's in two dimensions using first or second order Lagrange elements on triangular meshes.
## Requirements
Besides a basic MATLAB installation, a mesh generator is required for setting up the triangulation. Currently, only triangular meshes generated by the [_Triangle_ library](https://www.cs.cmu.edu/~quake/triangle.html) (references see below) are supported.
To make the creation of 2-D triangular meshes more user-friendly, the installation of [PyGIMLi](http://www.pygimli.org) is strongly recommended.
`FEMT2D` has been tested with MATLAB R2020a. Earlier releases work well also. Also note that compatibility with [Octave](http://www.octave.org) has not been tested.
To activate rendering of $\LaTeX$ expressions within this `README.md`, download and activate this [Chrome extension](https://chrome.google.com/webstore/detail/mathjax-plugin-for-github/ioemnmodlmafdkllaclgeombjnmnbima).
#### References
* FEMT2D: FE simulation of 2D Magnetotellurics in MATLAB. https://doi.org/10.5281/zenodo.3955407
* Jonathan Richard Shewchuk, _Triangle: Engineering a 2D Quality Mesh Generator and Delaunay Triangulator_, in "Applied Computational Geometry: Towards Geometric Engineering" (Ming C. Lin and Dinesh Manocha, editors), volume 1148 of Lecture Notes in Computer Science, pages 203-222, Springer-Verlag, Berlin, May 1996.
* Jonathan Richard Shewchuk, _Delaunay Refinement Algorithms for Triangular Mesh Generation_, Computational Geometry: Theory and Applications 22(1-3):21-74, May 2002.
* Franke, A., Börner, R. U., & Spitzer, K. (2007). *Adaptive unstructured grid finite element simulation of two-dimensional magnetotelluric fields for arbitrary surface and seafloor topography*. Geophysical Journal International, 171(1), 71-86.
* Börner, R. U. (2010). Numerical modelling in geo-electromagnetics: advances and challenges. Surveys in Geophysics, 31(2), 225-245.
* Rücker, C., Günther, T., Wagner, F.M., 2017. pyGIMLi: An open-source library for modelling and inversion in geophysics, Computers and Geosciences, 109, 106-123, doi: 10.1016/j.cageo.2017.07.011.
## Installation
Clone this repository.
```bash
git clone https://github.com/ruboerner/FEMT2D.git
```
Then enter the newly created folder `FEMT2D`:
```bash
cd FEMT2D
```
## Quick start
For a quick demonstration, simply call
```matlab
>> demo.driverWeaver
```
which loads a triangular mesh, and evaluates the response of two quarter-spaces for a given period at predefined observation points.
A few typical plots, such as profiles of apparent resistivities, phases, and magnetic transfer functions will be generated.
## Folder structure
Inside the `FEMT2D` folder, there are a few subfolders. The folders with leading `+`, e.g., `+fe`, contain _packages_ and have their own namespace.
```
FEMT2D
├── +demo
├── +fe
├── +mesh
├── +mt
├── +plot
├── +tools
├── Notebooks
├── meshes
```
From the top-level folder `FEMT2D` you can start a demonstration by typing, e.g.,
```matlab
demo.driverCOMMEMI_2D_0
```
which will calculate the model responses of model 2D-0 from the _COMMEMI_ model suite.
The folder `Notebooks` contains example _Jupyter Notebooks_ which introduce the user into the process of mesh generation using _PyGIMLi_.
Each of these Notebooks creates a particular set of files in the folder `meshes`. The meshes can later be read by routines which reside in the `+mesh` folder.
## Details of the toolbox
After reading in a _Triangle_ triangulation file, the mesh topology is stored within a MATLAB `struct`.
```matlab
mesh = mesh.getMesh('filename', 'meshes/commemi2d0.1', 'format', 'triangle');
```
`'filename'` corresponds to the basename of a mesh file in the `meshes` folder. Note that the actual files have the extensions `.poly`, `.ele`, and `.node`.
If the files in the `meshes` folder are, e.g.,
```
meshes
├── commemi2d0.1.ele
├── commemi2d0.1.node
├── commemi2d0.1.poly
```
then the corresponding `filename` in the parameter list of `mesh.getMesh()` would be `commemi2d0.1`.
### The `mesh` structure
The `mesh` structure contains the following fields:
| field name | dimension | description |
|------------|:--------------------|-------------|
| `node` | `2 x np` | node coordinates |
| `tri2node` | `3 x nt` | table of triangles defined by their indices as listed in the array `node` |
| `tri2subdomain` | `1 x nt` | array of subdomain number each triangle belongs to |
| `marker` | `1 x nt` | array of attributes associated with nodes |
| `edge2node` | `2 x ne` | table of edges and their node indices |
| `tri2edge`| `3 x nt` | table of edges and their associated triangle index |
| `nt` | scalar | number of triangles $n_t$ |
| `np` | scalar | number of nodes $n_p$ |
| `ne` | scalar | number of edges $n_e$ |
| `bdEdges` | vector | indices of boundary edges |
| `bdNodes` | vector | indices of boundary nodes |
| `Bk` | `2 x 2 x nt` | array of matrices defining the affine map $B_k$ from reference element to each of the $k=1,\dots,n_t$ domain elements |
| `Binv` | `2 x 2 x nt` | array of matrices $B_k^{-1}$ |
| `detBk` | `nt x 1` | array of determinants of $B_k$, $\text{det}(B_k)$ |
| `area` | `nt x 1` | array of all $k=1,\dots,n_t$ triangular element surface areas, i.e., `area = 0.5 * detBk` |
|
### The `fem` structure
The finite element method associates the triangulation with specific basis functions defined on the elements and identifies the degrees of freedom (DOFS).
```matlab
freq = 0.01;
sigma = [1e-1, 1e-1, 1e-2, 1e-2, 1e-14];
mu = ones(size(sigma));
fem = fe.FEMproblem('mesh', mesh, ...
'elementtype', 'Lagrange', ...
'order', 2, 'dimension', 2, ...
'sigma', sigma, 'mu', mu, ...
'polarization', 'both', ...
'frequency', freq, ...
'verbose', true);
```
As one can conclude from the above example, the mesh consists of five subdomains each of which is associated with a unique parameter (here `sigma` denotes the electrical conductivity $\sigma$ given in S/m and `mu` is the relative magnetic permeability $\mu_r$, such that $\mu = \mu_r \mu_0$ with $\mu_0 = 4 \pi \cdot10^{-7}$ Vs/Am).
In the given example, the solutions of the Helmholtz equations (for both magnetotelluric polarizations) are desired at a frequency `freq` of 0.01 Hz. The polynomial order `order` of the Lagrange elements is 2, i.e., we use quadratic (second order) finite element basis functions.
The numerical accuracy is always much better when second-order elements are employed.
After calling `FEMproblem`, the `fem` structure contains the following fields:
| field name | dimension | description | default |
|------------|:----------|-----------------------|---------|
| `mesh` | struct | copy of `mesh` struct | - |
| `order` | scalar | 1 or 2 for linear or quadratic elements, resp. | 1 |
| `dimension` | scalar | spatial dimension (currently only 2D is implemented) | 2 |
| `app` | struct | contains application (PDE) specific parameters, e.g., the frequency `frequency` for the MT case | - |
| `polarization` | string | indicates whether E- (`'epol'`), H- (`'hpol'`) or both (`'both'`) polarizations are desired | `'both'` |
| `elementtype` | type of finite elements | `'Lagrange'` |
| `sigma` | `nt x 1` | elementwise electrical conductivities $\sigma$ in S/m | - |
| `mu` | `nt x 1` | elementwise relative permeabilities $\mu_r$ | - |
| `stripair` | scalar | indicator that controls whether the Air halfspace has to be excluded (e.g., for the MT for H-polarization) | - |
| `istrip` | scalar | subdomain number associated with the Air halfspace that has to be stripped from mesh for MT | - |
| `coorddofs` | `2 x ndofs` | coordinates of the DOFS | - |
| `elem2dofs` | `(order * 3) x nt` | array of elements and their associated DO
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答! matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答! matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答! matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答! matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答! matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随
资源推荐
资源详情
资源评论
收起资源包目录
毕业设计&课设-二维大地电磁法的MATLAB有限元模拟.zip (83个子文件)
FEMT2D-master
Notebooks
COMMEMI_2D_0.ipynb 156KB
COMMEMI_2D_4.ipynb 138KB
Layered_Halfspace.ipynb 136KB
COMMEMI_2D_3.ipynb 151KB
CreateTriangleMesh.ipynb 200KB
COMMEMI_2D_2.ipynb 155KB
Weaver.ipynb 81KB
Model_with_magnetic_Permeability.ipynb 165KB
COMMEMI_2D_1.ipynb 184KB
.gitattributes 30B
+fe
getQfull.m 2KB
getQ.m 3KB
FEMsolve.m 1KB
finddofsinsubdomain.m 906B
getBasisLagrange.m 2KB
FEMproblem.m 6KB
removeDirichlet.m 5KB
FEMassemble.m 4KB
+mesh
getMeshFromTriangleFile.m 557B
getTablesFromTriangle.m 1KB
completeMesh.m 3KB
getMesh.m 1KB
+mt
postProcessing.m 265B
getImpedance.m 306B
getRhoa.m 347B
getH1dMT.m 3KB
getFields.m 628B
getPhase.m 305B
getE1dMT.m 2KB
getTipper.m 175B
meshes
commemi2d3.1.ele 895KB
commemi2d4.poly 2KB
commemi2d1.1.poly 13KB
layered.1.poly 54KB
commemi2d3.1.node 759KB
permeability.1.ele 2.93MB
model_with_topography.poly 8KB
commemi2d3.1.poly 32KB
commemi2d1.poly 668B
layered.1.node 1.08MB
commemi2d4.1.node 4.24MB
weaver.1.ele 1.04MB
model_with_topography.1.ele 424KB
commemi2d2.poly 1KB
commemi2d1.1.ele 382KB
commemi2d0.poly 933B
weaver.1.node 924KB
weaver.1.poly 19KB
layered.1.ele 1.32MB
model_with_topography.1.poly 21KB
commemi2d2.1.ele 921KB
commemi2d0.1.node 225KB
commemi2d3.poly 1KB
weaver.poly 756B
commemi2d4.1.poly 307KB
permeability.1.node 2.29MB
commemi2d0.1.ele 255KB
commemi2d2.1.node 785KB
commemi2d1.1.node 340KB
permeability.poly 2KB
commemi2d0.1.poly 13KB
layered.poly 757B
commemi2d2.1.poly 26KB
permeability.1.poly 147KB
model_with_topography.1.node 372KB
commemi2d4.1.ele 5.49MB
+demo
driver_topography.m 1KB
driverCOMMEMI_2D_3.m 2KB
driverWeaver.m 2KB
driver_permeability.m 2KB
driverCOMMEMI_2D_0.m 1KB
driverLayered.m 2KB
driverCOMMEMI_2D_1.m 1KB
driverCOMMEMI_2D_4.m 2KB
driverCOMMEMI_2D_2.m 1KB
.gitignore 46B
+tools
pick.m 596B
asColumn.m 65B
asRow.m 59B
README.md 17KB
+plot
plotSubdomains.m 620B
patchplotConst.m 755B
plotMT.m 4KB
共 83 条
- 1
资源评论
毕业小助手
- 粉丝: 2080
- 资源: 1712
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功