-
Notifications
You must be signed in to change notification settings - Fork 23
/
cfd_commons.h
115 lines (114 loc) · 4.83 KB
/
cfd_commons.h
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/****************************************************************************
* ArtraCFD *
* <By Huangrui Mo> *
* Copyright (C) Huangrui Mo <[email protected]> *
* This file is part of ArtraCFD. *
* ArtraCFD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
****************************************************************************/
/****************************************************************************
* Header File Guards to Avoid Interdependence
****************************************************************************/
#ifndef ARTRACFD_CFD_COMMONS_H_ /* if undefined */
#define ARTRACFD_CFD_COMMONS_H_ /* set a unique marker */
/****************************************************************************
* Required Header Files
****************************************************************************/
#include "commons.h"
/****************************************************************************
* Data Structure Declarations
****************************************************************************/
/****************************************************************************
* Public Functions Declaration
****************************************************************************/
/*
* Average method
*
* Function
* Compute averaged variables at interface.
*/
extern void SymmetricAverage(const int averager, const Real gamma,
const Real UL[restrict], const Real UR[restrict], Real Uo[restrict]);
/*
* Jacobian matrices, eigenvalues, and eigenvectors
*
* Function
* Compute eigenvalues and eigenvectors.
*/
extern void Eigenvalue(const int s, const Real Uo[restrict], Real Lambda[restrict]);
extern void EigenvalueSplitting(const int splitter, const Real Lambda[restrict],
Real LambdaP[restrict], Real LambdaN[restrict]);
extern void EigenvectorL(const int s, const Real gamma, const Real Uo[restrict],
Real L[restrict][DIMU]);
extern void EigenvectorR(const int s, const Real Uo[restrict], Real R[restrict][DIMU]);
/*
* Convective fluxes
*
* Function
* Compute convective fluxes.
*/
extern void ConvectiveFlux(const int s, const Real gamma, const Real U[restrict], Real F[restrict]);
/*
* Physical property
*/
extern Real Viscosity(const Real T);
extern Real PrandtlNumber(void);
/*
* Compute the values of primitive variable vector
*
* Function
* Compute primitive variable vector according to conservative vector.
*/
extern void MapPrimitive(const Real gamma, const Real gasR, const Real U[restrict], Real Uo[restrict]);
extern Real ComputePressure(const Real gamma, const Real U[restrict]);
extern Real ComputeTemperature(const Real cv, const Real U[restrict]);
/*
* Compute and update conservative variable vector
*
* Function
* Compute conservative variable vector according to primitive vector.
*/
extern void MapConservative(const Real gamma, const Real Uo[restrict], Real U[restrict]);
/*
* Index math
*
* Function
* Calculate the node index.
*/
extern int IndexNode(const int k, const int j, const int i, const int jMax, const int iMax);
/*
* Verify node region
*
* Function
* Check whether a node is within the part box.
*/
extern int InPartBox(const int k, const int j, const int i, const int pbox[restrict][LIMIT]);
/*
* Coordinates transformation
*
* Function
* Transform coordinates between node coordinates and general coordinates.
*/
extern int MapNode(const Real s, const Real sMin, const Real dds, const int ng);
extern int ConfineSpace(const int n, const int nMin, const int nMax);
extern Real MapPoint(const int n, const Real sMin, const Real ds, const int ng);
/*
* Common math functions
*/
extern Real MinReal(const Real x, const Real y);
extern Real MaxReal(const Real x, const Real y);
extern int EqualReal(const Real x, const Real y);
extern int MinInt(const int x, const int y);
extern int MaxInt(const int x, const int y);
extern int Sign(const Real x);
extern Real Dot(const Real V1[restrict], const Real V2[restrict]);
extern Real Norm(const Real V[restrict]);
extern Real Dist2(const Real V1[restrict], const Real V2[restrict]);
extern Real Dist(const Real V1[restrict], const Real V2[restrict]);
extern void Cross(const Real V1[restrict], const Real V2[restrict], Real V[restrict]);
extern void OrthogonalSpace(const Real N[restrict], Real Ta[restrict], Real Tb[restrict]);
extern void Normalize(const int dimV, const Real normalizer, Real V[restrict]);
#endif
/* a good practice: end file with a newline */