Completed porting, fixing bugs and testing
This commit is contained in:
		@@ -41,6 +41,7 @@ tau      0.5     # safety factor for time stepsize control (<0 constant delt)
 | 
			
		||||
 | 
			
		||||
itermax       500       # maximal number of pressure iteration in one time step
 | 
			
		||||
eps           0.00001   # stopping tolerance for pressure iteration
 | 
			
		||||
rho           0.52              
 | 
			
		||||
omg           1.8       # relaxation parameter for SOR iteration
 | 
			
		||||
gamma         0.9       # upwind differencing factor gamma
 | 
			
		||||
#===============================================================================
 | 
			
		||||
 
 | 
			
		||||
@@ -41,6 +41,7 @@ tau     0.5		# safety factor for time stepsize control (<0 constant delt)
 | 
			
		||||
 | 
			
		||||
itermax  1000		# maximal number of pressure iteration in one time step
 | 
			
		||||
eps      0.001		# stopping tolerance for pressure iteration
 | 
			
		||||
rho      0.5              
 | 
			
		||||
omg      1.7		# relaxation parameter for SOR iteration
 | 
			
		||||
gamma    0.9		# upwind differencing factor gamma
 | 
			
		||||
#===============================================================================
 | 
			
		||||
 
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -67,15 +67,8 @@ int main (int argc, char** argv)
 | 
			
		||||
        solve(&solver);
 | 
			
		||||
        adaptUV(&solver);
 | 
			
		||||
        t += solver.dt;
 | 
			
		||||
 | 
			
		||||
#ifdef VERBOSE
 | 
			
		||||
        if (rank == 0) {
 | 
			
		||||
            printf("TIME %f , TIMESTEP %f\n", t, solver.dt);
 | 
			
		||||
        }
 | 
			
		||||
#else
 | 
			
		||||
        printProgress(t);
 | 
			
		||||
#endif
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
        break;
 | 
			
		||||
    case RB:
 | 
			
		||||
        printf("Red-black SOR\n");
 | 
			
		||||
@@ -91,16 +84,10 @@ int main (int argc, char** argv)
 | 
			
		||||
        solveRB(&solver);
 | 
			
		||||
        adaptUV(&solver);
 | 
			
		||||
        t += solver.dt;
 | 
			
		||||
 | 
			
		||||
#ifdef VERBOSE
 | 
			
		||||
        if (rank == 0) {
 | 
			
		||||
            printf("TIME %f , TIMESTEP %f\n", t, solver.dt);
 | 
			
		||||
        }
 | 
			
		||||
#else
 | 
			
		||||
        printProgress(t);
 | 
			
		||||
#endif
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    case RBA:
 | 
			
		||||
        printf("Red-black SOR with acceleration\n");
 | 
			
		||||
        while (t <= te) {
 | 
			
		||||
@@ -115,6 +102,10 @@ int main (int argc, char** argv)
 | 
			
		||||
        solveRBA(&solver);
 | 
			
		||||
        adaptUV(&solver);
 | 
			
		||||
        t += solver.dt;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
#ifdef VERBOSE
 | 
			
		||||
        if (rank == 0) {
 | 
			
		||||
@@ -123,9 +114,7 @@ int main (int argc, char** argv)
 | 
			
		||||
#else
 | 
			
		||||
        printProgress(t);
 | 
			
		||||
#endif
 | 
			
		||||
    }
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    E = getTimeStamp();
 | 
			
		||||
    stopProgress();
 | 
			
		||||
 
 | 
			
		||||
@@ -301,6 +301,7 @@ void solve(Solver* solver)
 | 
			
		||||
    int it        = 0;
 | 
			
		||||
    double res    = 1.0;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    while ((res >= epssq) && (it < itermax)) {
 | 
			
		||||
        res = 0.0;
 | 
			
		||||
        exchange(solver, p);
 | 
			
		||||
@@ -317,6 +318,8 @@ void solve(Solver* solver)
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        if (solver->rank == 0) {
 | 
			
		||||
            for (int i = 1; i < imax + 1; i++) {
 | 
			
		||||
                P(i, 0) = P(i, 1);
 | 
			
		||||
@@ -368,21 +371,28 @@ void solveRB(Solver* solver)
 | 
			
		||||
    double epssq  = eps * eps;
 | 
			
		||||
    int it        = 0;
 | 
			
		||||
    double res    = 1.0;
 | 
			
		||||
    int pass, jsw, isw;
 | 
			
		||||
 | 
			
		||||
    while ((res >= epssq) && (it < itermax)) {
 | 
			
		||||
        res = 0.0;
 | 
			
		||||
        exchange(solver, p);
 | 
			
		||||
        jsw = 1;
 | 
			
		||||
 | 
			
		||||
        for (int j = 1; j < jmaxLocal + 1; j++) {
 | 
			
		||||
            for (int i = 1; i < imax + 1; i++) {
 | 
			
		||||
        for (pass = 0; pass < 2; pass++) {
 | 
			
		||||
            isw = jsw;
 | 
			
		||||
            exchange(solver, p);
 | 
			
		||||
 | 
			
		||||
                double r = RHS(i, j) -
 | 
			
		||||
                           ((P(i + 1, j) - 2.0 * P(i, j) + P(i - 1, j)) * idx2 +
 | 
			
		||||
                               (P(i, j + 1) - 2.0 * P(i, j) + P(i, j - 1)) * idy2);
 | 
			
		||||
            for (int j = 1; j < jmaxLocal + 1; j++) {
 | 
			
		||||
                for (int i = isw; i < imax + 1; i += 2) {
 | 
			
		||||
 | 
			
		||||
                P(i, j) -= (factor * r);
 | 
			
		||||
                res += (r * r);
 | 
			
		||||
                    double r = RHS(i, j) -
 | 
			
		||||
                               ((P(i + 1, j) - 2.0 * P(i, j) + P(i - 1, j)) * idx2 +
 | 
			
		||||
                                   (P(i, j + 1) - 2.0 * P(i, j) + P(i, j - 1)) * idy2);
 | 
			
		||||
 | 
			
		||||
                    P(i, j) -= (factor * r);
 | 
			
		||||
                    res += (r * r);
 | 
			
		||||
                }
 | 
			
		||||
                isw = 3 - isw;
 | 
			
		||||
            }
 | 
			
		||||
            jsw = 3 - jsw;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (solver->rank == 0) {
 | 
			
		||||
@@ -430,27 +440,40 @@ void solveRBA(Solver* solver)
 | 
			
		||||
    double dy2    = solver->dy * solver->dy;
 | 
			
		||||
    double idx2   = 1.0 / dx2;
 | 
			
		||||
    double idy2   = 1.0 / dy2;
 | 
			
		||||
    double factor = solver->omega * 0.5 * (dx2 * dy2) / (dx2 + dy2);
 | 
			
		||||
    double factor = 0.5 * (dx2 * dy2) / (dx2 + dy2);
 | 
			
		||||
    double* p     = solver->p;
 | 
			
		||||
    double* rhs   = solver->rhs;
 | 
			
		||||
    double rho    = solver->rho;
 | 
			
		||||
    double epssq  = eps * eps;
 | 
			
		||||
    int it        = 0;
 | 
			
		||||
    double res    = 1.0;
 | 
			
		||||
    double omega = 1.0;
 | 
			
		||||
    int pass, jsw, isw;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    while ((res >= epssq) && (it < itermax)) {
 | 
			
		||||
        res = 0.0;
 | 
			
		||||
        exchange(solver, p);
 | 
			
		||||
        jsw = 1;
 | 
			
		||||
 | 
			
		||||
        for (int j = 1; j < jmaxLocal + 1; j++) {
 | 
			
		||||
            for (int i = 1; i < imax + 1; i++) {
 | 
			
		||||
        for (pass = 0; pass < 2; pass++) {
 | 
			
		||||
            isw = jsw;
 | 
			
		||||
            exchange(solver, p);
 | 
			
		||||
 | 
			
		||||
                double r = RHS(i, j) -
 | 
			
		||||
                           ((P(i + 1, j) - 2.0 * P(i, j) + P(i - 1, j)) * idx2 +
 | 
			
		||||
                               (P(i, j + 1) - 2.0 * P(i, j) + P(i, j - 1)) * idy2);
 | 
			
		||||
            for (int j = 1; j < jmaxLocal + 1; j++) {
 | 
			
		||||
                for (int i = isw; i < imax + 1; i += 2) {
 | 
			
		||||
 | 
			
		||||
                P(i, j) -= (factor * r);
 | 
			
		||||
                res += (r * r);
 | 
			
		||||
                    double r = RHS(i, j) -
 | 
			
		||||
                               ((P(i + 1, j) - 2.0 * P(i, j) + P(i - 1, j)) * idx2 +
 | 
			
		||||
                                   (P(i, j + 1) - 2.0 * P(i, j) + P(i, j - 1)) * idy2);
 | 
			
		||||
 | 
			
		||||
                    P(i, j) -= (omega * factor * r);
 | 
			
		||||
                    res += (r * r);
 | 
			
		||||
                }
 | 
			
		||||
                isw = 3 - isw;
 | 
			
		||||
            }
 | 
			
		||||
            jsw = 3 - jsw;
 | 
			
		||||
            omega = (it == 0 && pass == 0 ? 1.0 / (1.0 - 0.5 * rho * rho)
 | 
			
		||||
                                          : 1.0 / (1.0 - 0.25 * rho * rho * omega));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (solver->rank == 0) {
 | 
			
		||||
 
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 206 KiB After Width: | Height: | Size: 19 KiB  | 
		Reference in New Issue
	
	Block a user