forked from eacdamal/simpar
Change order of loops
Try to avoid branching in loops as it prevents vectorization Signed-off-by: Christoph Niethammer <niethammer@hlrs.de>
This commit is contained in:
parent
39bee2e2e6
commit
d6a0d64176
1 changed files with 6 additions and 7 deletions
|
@ -72,13 +72,12 @@ int main()
|
||||||
*/
|
*/
|
||||||
for (int i = 2; i < dt; i++)
|
for (int i = 2; i < dt; i++)
|
||||||
{
|
{
|
||||||
// Loop over spatial steps
|
// Loop over spatial steps for flow
|
||||||
for (int k = 1; k < kmax; k++)
|
for (int k = 1; k < kmax; k++) {
|
||||||
{
|
|
||||||
Q[k][i + 1] = Q[k][i] + h * (alpha * (P[k - 1][i] - P[k][i]) - beta * Q[k][i] * abs(Q[k][i]));
|
Q[k][i + 1] = Q[k][i] + h * (alpha * (P[k - 1][i] - P[k][i]) - beta * Q[k][i] * abs(Q[k][i]));
|
||||||
|
}
|
||||||
// DO NOT calculate pressure for the last element such as it is given by default
|
// Loop over steps for pressure, DO NOT calculate pressure for the last element as it is given as a boundary condition
|
||||||
if (k != kmax - 1)
|
for (int k = 1; k < kmax - 1; k++) {
|
||||||
P[k][i + 1] = P[k][i - 2] + h * (gamma * (Q[k][i] - Q[k + 1][i]));
|
P[k][i + 1] = P[k][i - 2] + h * (gamma * (Q[k][i] - Q[k + 1][i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue