forked from zuowangda/Fast-Fluid-Dynamics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
geometry.c
66 lines (58 loc) · 2.56 KB
/
geometry.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
///////////////////////////////////////////////////////////////////////////////
//
// Filename: geometry.c
//
// Task: Functions for calculation related to geometry
//
// Modification history:
// 7/10/2013 by Wangda Zuo: First implementation
//
///////////////////////////////////////////////////////////////////////////////
#include <math.h>
#include "data_structure.h"
#include "geometry.h"
/******************************************************************************
| Calcualte the XY area of cell (i,j,k)
******************************************************************************/
REAL area_xy(PARA_DATA *para, REAL **var, int i, int j, int k, int IMAX, int IJMAX)
{
return length_x(para, var, i, j, k, IMAX, IJMAX)
* length_y(para, var, i, j, k, IMAX, IJMAX);
}
/******************************************************************************
| Calcualte the YZ area of cell (i,j,k)
******************************************************************************/
REAL area_yz(PARA_DATA *para, REAL **var, int i, int j, int k, int IMAX, int IJMAX)
{
return length_y(para, var, i, j, k, IMAX, IJMAX)
* length_z(para, var, i, j, k, IMAX, IJMAX);
}
/******************************************************************************
| Calcualte the ZX area of cell (i,j,k)
******************************************************************************/
REAL area_zx(PARA_DATA *para, REAL **var, int i, int j, int k, int IMAX, int IJMAX)
{
return length_z(para, var, i, j, k, IMAX, IJMAX)
* length_x(para, var, i, j, k, IMAX, IJMAX);
}
/******************************************************************************
| Calcualte the length in X of cell (i,j,k)
******************************************************************************/
REAL length_x(PARA_DATA *para, REAL **var, int i, int j, int k, int IMAX, int IJMAX)
{
return fabs(var[GX][IX(i,j,k)]-var[GX][IX(i-1,j,k)]);
}
/******************************************************************************
| Calcualte the length in Y of cell (i,j,k)
******************************************************************************/
REAL length_y(PARA_DATA *para, REAL **var, int i, int j, int k, int IMAX, int IJMAX)
{
return fabs(var[GY][IX(i,j,k)]-var[GY][IX(i,j-1,k)]);
}
/******************************************************************************
| Calcualte the length in Z of cell (i,j,k)
******************************************************************************/
REAL length_z(PARA_DATA *para, REAL **var, int i, int j, int k, int IMAX, int IJMAX)
{
return fabs(var[GZ][IX(i,j,k)]-var[GZ][IX(i,j,k-1)]);
}