Last change
on this file since 272 was
258,
checked in by ole, 20 years ago
|
Added C-headers to share code
Removed length and distance from util
|
File size:
764 bytes
|
Line | |
---|
1 | |
---|
2 | void _limit(int N, double beta, double* qc, double* qv, |
---|
3 | double* qmin, double* qmax) { |
---|
4 | |
---|
5 | int k, i, k3; |
---|
6 | double dq, dqa[3], phi, r; |
---|
7 | |
---|
8 | for (k=0; k<N; k++) { |
---|
9 | k3 = k*3; |
---|
10 | |
---|
11 | //Find the gradient limiter (phi) across vertices |
---|
12 | phi = 1.0; |
---|
13 | for (i=0; i<3; i++) { |
---|
14 | r = 1.0; |
---|
15 | |
---|
16 | dq = qv[k3+i] - qc[k]; //Delta between vertex and centroid values |
---|
17 | dqa[i] = dq; //Save dq for use in the next loop |
---|
18 | |
---|
19 | if (dq > 0.0) r = (qmax[k] - qc[k])/dq; |
---|
20 | if (dq < 0.0) r = (qmin[k] - qc[k])/dq; |
---|
21 | |
---|
22 | |
---|
23 | phi = min( min(r*beta, 1.0), phi); |
---|
24 | } |
---|
25 | |
---|
26 | //Then update using phi limiter |
---|
27 | for (i=0; i<3; i++) { |
---|
28 | qv[k3+i] = qc[k] + phi*dqa[i]; |
---|
29 | } |
---|
30 | } |
---|
31 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.