Skip to content

Commit

Permalink
增加mpi描述
Browse files Browse the repository at this point in the history
  • Loading branch information
du2693742095 committed Apr 19, 2023
1 parent b6b5f0e commit 2a1ee33
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 11 deletions.
22 changes: 11 additions & 11 deletions CFD学习/CGNS/CGNS介绍.md
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ ier = cgp_coord_read_data(int i_file, int i_base, int i_zone, int i_coord,



# 单区网格单元信息
# 单区网格拓扑信息

## 单元cell

Expand Down Expand Up @@ -614,16 +614,16 @@ Element数据可以分为两大类: **普通形状单元** 和 **混合单元**(

CGNS 支持八种单元形状: 点、[线](http:https://cgns.github.io/CGNS_docs_current/sids/conv.html#unst_line)、 [三角形](http:https://cgns.github.io/CGNS_docs_current/sids/conv.html#unst_tri)、[四边形](http:https://cgns.github.io/CGNS_docs_current/sids/conv.html#unst_quad)、 [四面体](http:https://cgns.github.io/CGNS_docs_current/sids/conv.html#unst_tetra)、[五面体](http:https://cgns.github.io/CGNS_docs_current/sids/conv.html#unst_penta)、 [六棱柱](http:https://cgns.github.io/CGNS_docs_current/sids/conv.html#unst_pyramid)和[六面体](http:https://cgns.github.io/CGNS_docs_current/sids/conv.html#unst_hexa)。描述体积的单元称为[3D Elements](http:https://cgns.github.io/CGNS_docs_current/sids/conv.html#unst_3d)。描述面的是[2D Elements](http:https://cgns.github.io/CGNS_docs_current/sids/conv.html#unst_2d)。线和点元素分别称为[1D](http:https://cgns.github.io/CGNS_docs_current/sids/conv.html#unst_line)和0D Elements。线性插值指两个点组成一条线, 二次插值即两个点组成的线中间还会多一个点, 三次及四次插值同上. 一般来说只会用到线性插值和二次插值, 下面是单元类型及对应的表:

| 类型 | 形状 | 线性插值 | 二次插值 | 三次插值 | 四次插值 |
| ---- | ------------------------------------------------------------ | --------- | -------------------- | ------------------------------ | ------------------------------ |
| 0D | Point(点) | `NODE` | `NODE` | `NODE` | `NODE` |
| 1D | [Line](http:https://cgns.github.io/CGNS_docs_current/sids/conv.html#unst_line)(线) | `BAR_2` | `BAR_3` | `BAR_4` | `BAR_5` |
| 2D | [Triangle](http:https://cgns.github.io/CGNS_docs_current/sids/conv.html#unst_tri)(三角形) | `TRI_3` | `TRI_6` | `TRI_9, TRI_10` | `TRI_12, TRI_15` |
| | [Quadrangle](http:https://cgns.github.io/CGNS_docs_current/sids/conv.html#unst_quad)(四边形) | `QUAD_4` | `QUAD_8, QUAD_9` | `QUAD_12, QUAD_16` | `QUAD_P4_16, QUAD_25` |
| 3D | [Tetrahedron](http:https://cgns.github.io/CGNS_docs_current/sids/conv.html#unst_tetra)(四面体) | `TETRA_4` | `TETRA_10` | `TETRA_16, TETRA_20` | `TETRA_22, TETRA_34, TETRA_35` |
| | [Pyramid](http:https://cgns.github.io/CGNS_docs_current/sids/conv.html#unst_pyramid)(金字塔形) | `PYRA_5` | `PYRA_13, PYRA_14` | `PYRA_21, PYRA_29, PYRA_30` | `PYRA_P4_29, PYRA_50, PYRA_55` |
| | [Pentahedron](http:https://cgns.github.io/CGNS_docs_current/sids/conv.html#unst_penta)(五面体) | `PENTA_6` | `PENTA_15, PENTA_18` | `PENTA_24, PENTA_38, PENTA_40` | `PENTA_33, PENTA_66, PENTA_75` |
| | [Hexahedron](http:https://cgns.github.io/CGNS_docs_current/sids/conv.html#unst_hexa)(六面体) | `HEXA_8` | `HEXA_20, HEXA_27` | `HEXA_32, HEXA_56, HEXA_64` | `HEXA_44, HEXA_98, HEXA_125` |
| 类型 | 形状 | 线性插值 | 二次插值 | 三次插值 | 四次插值 |
| ---- | ------------------------------------------------------------ | --------- | -------------------- | ------------------------------ | -------------------------------- |
| 0D | Point(点) | `NODE` | `NODE` | `NODE` | `NODE` |
| 1D | [Line](http:https://cgns.github.io/CGNS_docs_current/sids/conv.html#unst_line)(线) | `BAR_2` | `BAR_3` | `BAR_4` | `BAR_5` |
| 2D | [Triangle](http:https://cgns.github.io/CGNS_docs_current/sids/conv.html#unst_tri)(三角形) | `TRI_3` | `TRI_6` | `TRI_9, TRI_10` | `TRI_12, TRI_15` |
| | [Quadrangle](http:https://cgns.github.io/CGNS_docs_current/sids/conv.html#unst_quad)(四边形) | `QUAD_4` | `QUAD_8, QUAD_9` | `QUAD_12, QUAD_16` | `QUAD_P4_16, QUAD_25` |
| 3D | [Tetrahedron](http:https://cgns.github.io/CGNS_docs_current/sids/conv.html#unst_tetra)(四面体) | `TETRA_4` | `TETRA_10` | `TETRA_16, TETRA_20` | `TETRA_22, TETRA_34, TETRA_35` |
| | [Pyramid](http:https://cgns.github.io/CGNS_docs_current/sids/conv.html#unst_pyramid)(金字塔形) | `PYRA_5` | `PYRA_13, PYRA_14` | `PYRA_21, PYRA_29, PYRA_30` | `PYRA_P4_29, PYRA_50, PYRA_55` |
| | [Pentahedron](http:https://cgns.github.io/CGNS_docs_current/sids/conv.html#unst_penta)(五面体) | `PENTA_6` | `PENTA_15, PENTA_18` | `PENTA_24, PENTA_38, PENTA_40` | `PENTA_33, PENTA_66, PENTA_75` |
| | [Hexahedron](http:https://cgns.github.io/CGNS_docs_current/sids/conv.html#unst_hexa)(六面体) | `HEXA_8` | `HEXA_20, HEXA_27` | `HEXA_32, HEXA_56, HEXA_64` | `HEXA_44, HEXA_98, HEXA_125` |

### 混合单元

Expand Down
Binary file added Picture/image-20230419143340625.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 88 additions & 0 deletions 编程语言笔记/MPI/mpi学习.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# mpi学习

## 简介

mpi间的通信是根据节点ID来的



## 全局通信

即多个节点间通信,不只是单点间的通信

### MPI_Alltoall & MPI_Alltoallv、

MPI_Alltoall表示通信域内每个节点都要向其它节点发送和接受数据,发送和接收的数据长度固定,由 `sendcount``sendtype` 一起决定。

```c
int MPI_Alltoall(const void *sendbuf,
int sendcount,
MPI_Datatype sendtype,
void *recvbuf,
int recvcount,
MPI_Datatype recvtype,
MPI_Comm comm)
```
- sendbuf代表发送缓冲区的起始地址
- sendcount代表要发送的数量
- sendtype代表发送的数据类型
- recvbuf代表接收缓冲区的起始位置
- recvcount代表要接收的数量
- recvtype代表要接收的类型
- comm代表通信子
当进程需要向其它进程发送数据长度不定的数据时,就需要用MPI_Alltoallv来解决,
```
int MPI_Alltoallv(const void *sendbuf,
const int *sendcounts,
const int *sdispls,
MPI_Datatype sendtype,
void *recvbuf,
const int *recvcounts,
const int *rdispls,
MPI_Datatype recvtype,
MPI_Comm comm)
```
相比MPI_Alltoall,这个方法有几个参数不一样:
- `sendcounts` 和 `recvcounts`。这两个参数是两个数组,数组中元素代表该下标位置的进程收发的数据长度是多少个类型长度。eg:sendcounts[0]=3,sendcounts[1]=4,代表该节点要往0号节点发送3个sendtype的数据,往1号节点发送4个sendtype的数据。
- `sdispls` 和 `rdispls` 。两个数组,数组中的每个元素代表了要发送(接收)的那块数据相对于缓冲区起始位置的位移量。
## 集合通信
### MPI_Reduce
用于实现高效的全局运算,如求和,求最大值等,各个节点参与计算,将结果返回到根节点处。
```c
int MPI_Reduce(void* input_data_p,
void* output_data_p,
int count,
MPI_Datatype datatype,
MPI_Op operator,
int dest_process,
MPI_Comm comm);
```

- input_data_p指向每个进程想要参与运算的数据,output_data_p只在根节点中有效,包含计算的结果
- operator表示对数据的操作,具体有一下类型:

| 运算符值 | 含义 |
| ---------- | -------------------------- |
| MPI_MAX | 求最大值 |
| MPI_MIN | 求最小值 |
| MPI_SUM | 求累加和 |
| MPI_PROD | 求累乘值 |
| MPI_LAND | 逻辑与 |
| MPI_BAND | 按位与 |
| MPI_LOR | 逻辑或 |
| MPI_BOR | 按位或 |
| MPI_LOR | 逻辑异或 |
| MPI_BOR | 按位异或 |
| MPI_MAXLOC | 求最大值和最大值所在的位置 |
| MPI_MINLOC | 求最小值和最小值所在的位置 |

0 comments on commit 2a1ee33

Please sign in to comment.