2D-MPI Multigrid complete and tested
This commit is contained in:
@@ -44,6 +44,7 @@ eps 0.0001 # stopping tolerance for pressure iteration
|
||||
rho 0.52
|
||||
omg 1.8 # relaxation parameter for SOR iteration
|
||||
gamma 0.9 # upwind differencing factor gamma
|
||||
levels 5 # Multigrid levels
|
||||
|
||||
# Particle Tracing Data:
|
||||
# -----------------------
|
||||
|
@@ -26,8 +26,8 @@ p_init 1.0 # initial value for pressure
|
||||
|
||||
xlength 30.0 # domain size in x-direction
|
||||
ylength 4.0 # domain size in y-direction
|
||||
imax 200 # number of interior cells in x-direction
|
||||
jmax 50 # number of interior cells in y-direction
|
||||
imax 1200 # number of interior cells in x-direction
|
||||
jmax 160 # number of interior cells in y-direction
|
||||
|
||||
# Time Data:
|
||||
# ---------
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -680,9 +680,10 @@ double smoothRB(Solver* solver)
|
||||
void multiGrid(Solver* solver)
|
||||
{
|
||||
double res = 0.0;
|
||||
int imax = solver->imax;
|
||||
int jmax = solver->jmax;
|
||||
if (solver->currentlevel == (solver->levels - 1)) {
|
||||
int imax = solver->imax;
|
||||
int jmax = solver->jmax;
|
||||
if (solver->currentlevel == (solver->levels - 1) ||
|
||||
(solver->imax <= 40 || solver->jmax <= 40)) {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
smoothRB(solver);
|
||||
}
|
||||
@@ -692,18 +693,7 @@ void multiGrid(Solver* solver)
|
||||
for (int i = 0; i < 5; i++) {
|
||||
smoothRB(solver);
|
||||
if (solver->currentlevel == 0) {
|
||||
|
||||
double* p = solver->p;
|
||||
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
P(i, 0) = P(i, 1);
|
||||
P(i, jmax + 1) = P(i, jmax);
|
||||
}
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
P(0, j) = P(1, j);
|
||||
P(imax + 1, j) = P(imax, j);
|
||||
}
|
||||
setPressureBoundaryCondition(solver);
|
||||
}
|
||||
}
|
||||
Solver coarseSolver = copySolver(solver);
|
||||
@@ -726,46 +716,26 @@ void multiGrid(Solver* solver)
|
||||
correct(solver);
|
||||
|
||||
if (solver->currentlevel == 0) {
|
||||
|
||||
double* p = solver->p;
|
||||
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
P(i, 0) = P(i, 1);
|
||||
P(i, jmax + 1) = P(i, jmax);
|
||||
}
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
P(0, j) = P(1, j);
|
||||
P(imax + 1, j) = P(imax, j);
|
||||
}
|
||||
setPressureBoundaryCondition(solver);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
res = smoothRB(solver);
|
||||
if (solver->currentlevel == 0) {
|
||||
|
||||
double* p = solver->p;
|
||||
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
P(i, 0) = P(i, 1);
|
||||
P(i, jmax + 1) = P(i, jmax);
|
||||
}
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
P(0, j) = P(1, j);
|
||||
P(imax + 1, j) = P(imax, j);
|
||||
}
|
||||
setPressureBoundaryCondition(solver);
|
||||
}
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
if (solver->currentlevel == 0) {printf("Residuum: %.6f\n", res); }
|
||||
#ifdef VERBOSE
|
||||
if (solver->currentlevel == 0) {
|
||||
printf("Residuum: %.6f\n", res);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void restrictMG(Solver* solver)
|
||||
{
|
||||
int imax = solver->imax;
|
||||
int jmax = solver->jmax;
|
||||
int imax = solver->imax / 2;
|
||||
int jmax = solver->jmax / 2;
|
||||
double* r = solver->r[solver->currentlevel + 1];
|
||||
double* oldr = solver->r[solver->currentlevel];
|
||||
|
||||
@@ -892,3 +862,19 @@ void writeResult(Solver* solver)
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
void setPressureBoundaryCondition(Solver* solver)
|
||||
{
|
||||
double* p = solver->p;
|
||||
int imax = solver->imax;
|
||||
int jmax = solver->jmax;
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
P(i, 0) = P(i, 1);
|
||||
P(i, jmax + 1) = P(i, jmax);
|
||||
}
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
P(0, j) = P(1, j);
|
||||
P(imax + 1, j) = P(imax, j);
|
||||
}
|
||||
}
|
@@ -59,6 +59,7 @@ extern void computeTimestep(Solver*);
|
||||
extern void setBoundaryConditions(Solver*);
|
||||
extern void setSpecialBoundaryCondition(Solver*);
|
||||
extern void setObjectBoundaryCondition(Solver*);
|
||||
extern void setPressureBoundaryCondition(Solver*);
|
||||
extern void computeFG(Solver*);
|
||||
extern void adaptUV(Solver*);
|
||||
extern void writeResult(Solver*);
|
||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 117 KiB After Width: | Height: | Size: 17 KiB |
Reference in New Issue
Block a user