mirror of
https://git.gfz-potsdam.de/naaice/tug.git
synced 2025-12-15 18:38:23 +01:00
put parallel for clauses in parallel construct
This commit is contained in:
parent
ee77b5f7f3
commit
9bb4d130c5
@ -393,37 +393,42 @@ static void BTCS_2D(Grid<T> &grid, Boundary<T> &bc, T timestep,
|
||||
|
||||
Eigen::MatrixX<T> concentrations = grid.getConcentrations();
|
||||
|
||||
#pragma omp parallel for num_threads(numThreads) private(A, b, row_t1)
|
||||
for (int i = 0; i < rowMax; i++) {
|
||||
#pragma omp parallel num_threads(numThreads)
|
||||
{
|
||||
#pragma omp parallel for private(A, b, row_t1)
|
||||
for (int i = 0; i < rowMax; i++) {
|
||||
|
||||
A = createCoeffMatrix(alphaX, bcLeft, bcRight, colMax, i, sx);
|
||||
b = createSolutionVector(concentrations, alphaX, alphaY, bcLeft, bcRight,
|
||||
bcTop, bcBottom, colMax, i, sx, sy);
|
||||
A = createCoeffMatrix(alphaX, bcLeft, bcRight, colMax, i, sx);
|
||||
b = createSolutionVector(concentrations, alphaX, alphaY, bcLeft, bcRight,
|
||||
bcTop, bcBottom, colMax, i, sx, sy);
|
||||
|
||||
row_t1 = solverFunc(A, b);
|
||||
row_t1 = solverFunc(A, b);
|
||||
|
||||
concentrations_t1.row(i) = row_t1;
|
||||
concentrations_t1.row(i) = row_t1;
|
||||
}
|
||||
|
||||
#pragma omp single
|
||||
{
|
||||
concentrations_t1.transposeInPlace();
|
||||
concentrations.transposeInPlace();
|
||||
alphaX.transposeInPlace();
|
||||
alphaY.transposeInPlace();
|
||||
}
|
||||
|
||||
#pragma omp parallel for private(A, b, row_t1)
|
||||
for (int i = 0; i < colMax; i++) {
|
||||
// swap alphas, boundary conditions and sx/sy for column-wise calculation
|
||||
A = createCoeffMatrix(alphaY, bcTop, bcBottom, rowMax, i, sy);
|
||||
b = createSolutionVector(concentrations_t1, alphaY, alphaX, bcTop,
|
||||
bcBottom, bcLeft, bcRight, rowMax, i, sy, sx);
|
||||
|
||||
row_t1 = solverFunc(A, b);
|
||||
|
||||
concentrations.row(i) = row_t1;
|
||||
}
|
||||
#pragma omp single
|
||||
{ concentrations.transposeInPlace(); }
|
||||
}
|
||||
|
||||
concentrations_t1.transposeInPlace();
|
||||
concentrations.transposeInPlace();
|
||||
alphaX.transposeInPlace();
|
||||
alphaY.transposeInPlace();
|
||||
|
||||
#pragma omp parallel for num_threads(numThreads) private(A, b, row_t1)
|
||||
for (int i = 0; i < colMax; i++) {
|
||||
// swap alphas, boundary conditions and sx/sy for column-wise calculation
|
||||
A = createCoeffMatrix(alphaY, bcTop, bcBottom, rowMax, i, sy);
|
||||
b = createSolutionVector(concentrations_t1, alphaY, alphaX, bcTop, bcBottom,
|
||||
bcLeft, bcRight, rowMax, i, sy, sx);
|
||||
|
||||
row_t1 = solverFunc(A, b);
|
||||
|
||||
concentrations.row(i) = row_t1;
|
||||
}
|
||||
|
||||
concentrations.transposeInPlace();
|
||||
|
||||
grid.setConcentrations(concentrations);
|
||||
}
|
||||
|
||||
|
||||
@ -276,66 +276,78 @@ static void FTCS_2D(Grid<T> &grid, Boundary<T> &bc, T timestep,
|
||||
// inner cells
|
||||
// these are independent of the boundary condition type
|
||||
// omp_set_num_threads(10);
|
||||
#pragma omp parallel for num_threads(numThreads)
|
||||
for (int row = 1; row < rowMax - 1; row++) {
|
||||
for (int col = 1; col < colMax - 1; col++) {
|
||||
concentrations_t1(row, col) = grid.getConcentrations()(row, col) +
|
||||
timestep / (deltaRow * deltaRow) *
|
||||
(calcVerticalChange(grid, row, col)) +
|
||||
timestep / (deltaCol * deltaCol) *
|
||||
(calcHorizontalChange(grid, row, col));
|
||||
int row;
|
||||
int col;
|
||||
#pragma omp parallel num_threads(numThreads)
|
||||
{
|
||||
#pragma omp parallel for
|
||||
for (int row = 1; row < rowMax - 1; row++) {
|
||||
for (int col = 1; col < colMax - 1; col++) {
|
||||
concentrations_t1(row, col) =
|
||||
grid.getConcentrations()(row, col) +
|
||||
timestep / (deltaRow * deltaRow) *
|
||||
(calcVerticalChange(grid, row, col)) +
|
||||
timestep / (deltaCol * deltaCol) *
|
||||
(calcHorizontalChange(grid, row, col));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// boundary conditions
|
||||
// left without corners / looping over rows
|
||||
// hold column constant at index 0
|
||||
int col = 0;
|
||||
#pragma omp parallel for num_threads(numThreads)
|
||||
for (int row = 1; row < rowMax - 1; row++) {
|
||||
concentrations_t1(row, col) =
|
||||
grid.getConcentrations()(row, col) +
|
||||
timestep / (deltaCol * deltaCol) *
|
||||
(calcHorizontalChangeLeftBoundary(grid, bc, row, col)) +
|
||||
timestep / (deltaRow * deltaRow) * (calcVerticalChange(grid, row, col));
|
||||
}
|
||||
// boundary conditions
|
||||
// left without corners / looping over rows
|
||||
// hold column constant at index 0
|
||||
#pragma omp single
|
||||
col = 0;
|
||||
#pragma omp parallel for
|
||||
for (int row = 1; row < rowMax - 1; row++) {
|
||||
concentrations_t1(row, col) =
|
||||
grid.getConcentrations()(row, col) +
|
||||
timestep / (deltaCol * deltaCol) *
|
||||
(calcHorizontalChangeLeftBoundary(grid, bc, row, col)) +
|
||||
timestep / (deltaRow * deltaRow) *
|
||||
(calcVerticalChange(grid, row, col));
|
||||
}
|
||||
|
||||
// right without corners / looping over rows
|
||||
// hold column constant at max index
|
||||
col = colMax - 1;
|
||||
#pragma omp parallel for num_threads(numThreads)
|
||||
for (int row = 1; row < rowMax - 1; row++) {
|
||||
concentrations_t1(row, col) =
|
||||
grid.getConcentrations()(row, col) +
|
||||
timestep / (deltaCol * deltaCol) *
|
||||
(calcHorizontalChangeRightBoundary(grid, bc, row, col)) +
|
||||
timestep / (deltaRow * deltaRow) * (calcVerticalChange(grid, row, col));
|
||||
}
|
||||
// right without corners / looping over rows
|
||||
// hold column constant at max index
|
||||
#pragma omp single
|
||||
col = colMax - 1;
|
||||
#pragma omp parallel for
|
||||
for (int row = 1; row < rowMax - 1; row++) {
|
||||
concentrations_t1(row, col) =
|
||||
grid.getConcentrations()(row, col) +
|
||||
timestep / (deltaCol * deltaCol) *
|
||||
(calcHorizontalChangeRightBoundary(grid, bc, row, col)) +
|
||||
timestep / (deltaRow * deltaRow) *
|
||||
(calcVerticalChange(grid, row, col));
|
||||
}
|
||||
|
||||
// top without corners / looping over columns
|
||||
// hold row constant at index 0
|
||||
int row = 0;
|
||||
#pragma omp parallel for num_threads(numThreads)
|
||||
for (int col = 1; col < colMax - 1; col++) {
|
||||
concentrations_t1(row, col) =
|
||||
grid.getConcentrations()(row, col) +
|
||||
timestep / (deltaRow * deltaRow) *
|
||||
(calcVerticalChangeTopBoundary(grid, bc, row, col)) +
|
||||
timestep / (deltaCol * deltaCol) *
|
||||
(calcHorizontalChange(grid, row, col));
|
||||
}
|
||||
// top without corners / looping over columns
|
||||
// hold row constant at index 0
|
||||
#pragma omp single
|
||||
row = 0;
|
||||
#pragma omp parallel for
|
||||
for (int col = 1; col < colMax - 1; col++) {
|
||||
concentrations_t1(row, col) =
|
||||
grid.getConcentrations()(row, col) +
|
||||
timestep / (deltaRow * deltaRow) *
|
||||
(calcVerticalChangeTopBoundary(grid, bc, row, col)) +
|
||||
timestep / (deltaCol * deltaCol) *
|
||||
(calcHorizontalChange(grid, row, col));
|
||||
}
|
||||
|
||||
// bottom without corners / looping over columns
|
||||
// hold row constant at max index
|
||||
row = rowMax - 1;
|
||||
#pragma omp parallel for num_threads(numThreads)
|
||||
for (int col = 1; col < colMax - 1; col++) {
|
||||
concentrations_t1(row, col) =
|
||||
grid.getConcentrations()(row, col) +
|
||||
timestep / (deltaRow * deltaRow) *
|
||||
(calcVerticalChangeBottomBoundary(grid, bc, row, col)) +
|
||||
timestep / (deltaCol * deltaCol) *
|
||||
(calcHorizontalChange(grid, row, col));
|
||||
// bottom without corners / looping over columns
|
||||
// hold row constant at max index
|
||||
#pragma omp single
|
||||
row = rowMax - 1;
|
||||
#pragma omp parallel for
|
||||
for (int col = 1; col < colMax - 1; col++) {
|
||||
concentrations_t1(row, col) =
|
||||
grid.getConcentrations()(row, col) +
|
||||
timestep / (deltaRow * deltaRow) *
|
||||
(calcVerticalChangeBottomBoundary(grid, bc, row, col)) +
|
||||
timestep / (deltaCol * deltaCol) *
|
||||
(calcHorizontalChange(grid, row, col));
|
||||
}
|
||||
}
|
||||
|
||||
// corner top left
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user