UCFD_SPARSE  v1.1
Documentation
Loading...
Searching...
No Matches
flux.c
Go to the documentation of this file.
1
19#include "flux.h"
20
21#define max(a,b) (((a) > (b)) ? (a) : (b))
22
30{
38 UCFD_FLOAT rho = u[0];
39 UCFD_FLOAT et = u[NFVARS-1];
40 UCFD_FLOAT temp = 0.0;
41 UCFD_FLOAT contrav = 0.0;
42 int i;
43
44 for (i=0; i<NDIMS; i++) {
45 contrav += u[i+1]*nf[i];
46 temp += u[i+1]*u[i+1];
47 }
48 contrav /= rho;
49
50 // Apply lower bound of pressure value
51 UCFD_FLOAT p = (GAMMA - 1.0)*(et - 0.5*temp/rho);
52 if (p < PMIN) {
53 p = PMIN;
54 et = p/(GAMMA-1.0) + 0.5*temp/rho;
55 u[NFVARS-1] = et;
56 }
57
58 // Total enthalpy
59 UCFD_FLOAT ht = et + p;
60
61 // Computes flux array
62 f[0] = rho*contrav;
63 for (UCFD_INT i=0; i<NDIMS; i++) {
64 f[i+1] = u[i+1] * contrav + nf[i]*p;
65 }
66 f[NFVARS-1] = ht*contrav;
67}
68
78{
79 UCFD_FLOAT rho = u[0];
80 UCFD_FLOAT contrav = 0.0;
81
82 for (UCFD_INT i=0; i<NDIMS; i++) {
83 contrav += u[i+1] * nf[i];
84 }
85 contrav /= rho;
86
87 for (UCFD_INT i=0; i<NTURBVARS; i++) {
88 f[i] = u[NFVARS+i]*contrav;
89 }
90}
91
92
93ucfd_status_t rans_source_jacobian(UCFD_FLOAT *uf, UCFD_FLOAT tmat[NTURBVARS][NTURBVARS], UCFD_FLOAT *dsrc)
94{
95 /* 1-equation RANS model (Spalart-Allmaras) */
96 if (NTURBVARS == 1) tmat[0][0] += dsrc[NVARS-1];
97
98 /* 2-equations RANS model (kw-SST) */
99 else if (NTURBVARS == 2) {
100 UCFD_FLOAT k = uf[NVARS-2] / uf[0];
101 tmat[0][0] += dsrc[NVARS-2];
102 tmat[0][1] += max(BETAST*k, 0.0);
103 tmat[1][1] += dsrc[NVARS-1];
104 }
105 else return UCFD_STATUS_NOT_SUPPORTED;
106
107 return UCFD_STATUS_SUCCESS;
108}
int32_t UCFD_INT
Definition: config.h:20
double UCFD_FLOAT
Definition: config.h:29
void ns_flux_container(UCFD_FLOAT *u, UCFD_FLOAT *nf, UCFD_FLOAT *f)
Computes flux for Navier-Stokes equations.
Definition: flux.c:29
void rans_flux_container(UCFD_FLOAT *u, UCFD_FLOAT *nf, UCFD_FLOAT *f)
Computes flux for RANS equations.
Definition: flux.c:77
ucfd_status_t rans_source_jacobian(UCFD_FLOAT *uf, UCFD_FLOAT tmat[NTURBVARS][NTURBVARS], UCFD_FLOAT *dsrc)
Computes source term Jacobian matrix for RANS equations.
Definition: flux.c:93
#define max(a, b)
Definition: flux.c:21
Header file for numerical flux funtions.
#define BETAST
Definition: flux.h:25
#define PMIN
Definition: flux.h:31
#define GAMMA
Definition: flux.h:28
ucfd_status_t
Definition: ucfd_types.h:10
@ UCFD_STATUS_NOT_SUPPORTED
Definition: ucfd_types.h:18
@ UCFD_STATUS_SUCCESS
Definition: ucfd_types.h:12