Changeset dfed1c for src/smoother/gsrb.cpp
- Timestamp:
- Nov 22, 2011, 9:22:10 PM (14 years ago)
- Children:
- facba0
- Parents:
- 66f24d
- File:
-
- 1 edited
-
src/smoother/gsrb.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/smoother/gsrb.cpp
r66f24d rdfed1c 13 13 14 14 #include "base/discretization.hpp" 15 #include "base/timer.hpp" 15 16 #include "base/stencil.hpp" 17 #include "comm/comm.hpp" 16 18 #include "grid/grid.hpp" 17 19 #include "smoother/gsrb.hpp" … … 21 23 void GaussSeidelRB::Compute(Grid& sol, Grid& rhs) 22 24 { 23 #ifdef DEBUG 25 #ifdef DEBUG_MATRIX_CHECKS 24 26 sol.IsConsistent(); 25 27 rhs.IsConsistent(); 28 #endif 29 30 #ifdef DEBUG 26 31 sol.IsCompatible(rhs); 27 32 #endif 28 33 29 int i,j,k; 34 Timer::Start("SmootherWithoutCommunication"); 35 36 Index i; 30 37 vmg_float temp; 31 38 const Stencil& A = MG::GetDiscretization()->GetStencil(); 32 39 const vmg_float prefactor_inv = 1.0 / MG::GetDiscretization()->OperatorPrefactor(sol); 33 40 const vmg_float diag_inv = 1.0 / A.GetDiag(); 41 const int off = rhs.Global().BeginLocal().Sum() - rhs.Local().HasHalo1().Sum(); 34 42 35 for (i =rhs.Local().Begin().X(); i<rhs.Local().End().X(); i++)36 for ( j=rhs.Local().Begin().Y(); j<rhs.Local().End().Y(); j++)37 for ( k=rhs.Local().Begin().Z() + ((i+j+1) % 2); k<rhs.Local().End().Z(); k+=2) {43 for (i.X()=rhs.Local().Begin().X(); i.X()<rhs.Local().End().X(); ++i.X()) 44 for (i.Y()=rhs.Local().Begin().Y(); i.Y()<rhs.Local().End().Y(); ++i.Y()) 45 for (i.Z()=rhs.Local().Begin().Z() + ((i.X()+i.Y()+off+1) % 2); i.Z()<rhs.Local().End().Z(); i.Z()+=2) { 38 46 39 temp = prefactor_inv * rhs.GetCorrectedVal(i ,j,k);47 temp = prefactor_inv * rhs.GetCorrectedVal(i); 40 48 41 for (Stencil::iterator iter=A.begin(); iter!=A.end(); iter++)42 temp -= iter-> val * sol.GetVal(i+iter->m, j+iter->n, k+iter->o);49 for (Stencil::iterator iter=A.begin(); iter!=A.end(); ++iter) 50 temp -= iter->Val() * sol.GetVal(i + iter->Disp()); 43 51 44 sol(i , j, k) = temp * diag_inv;52 sol(i) = temp * diag_inv; 45 53 46 54 } 47 55 48 for (i=rhs.Local().Begin().X(); i<rhs.Local().End().X(); i++) 49 for (j=rhs.Local().Begin().Y(); j<rhs.Local().End().Y(); j++) 50 for (k=rhs.Local().Begin().Z() + ((i+j) % 2); k<rhs.Local().End().Z(); k+=2) { 56 Timer::Stop("SmootherWithoutCommunication"); 51 57 52 temp = prefactor_inv * rhs.GetCorrectedVal(i,j,k);58 MG::GetComm()->CommToGhosts(sol); 53 59 54 for (Stencil::iterator iter=A.begin(); iter!=A.end(); iter++) 55 temp -= iter->val * sol.GetVal(i+iter->m, j+iter->n, k+iter->o); 60 Timer::Start("SmootherWithoutCommunication"); 56 61 57 sol(i, j, k) = temp * diag_inv; 62 for (i.X()=rhs.Local().Begin().X(); i.X()<rhs.Local().End().X(); ++i.X()) 63 for (i.Y()=rhs.Local().Begin().Y(); i.Y()<rhs.Local().End().Y(); ++i.Y()) 64 for (i.Z()=rhs.Local().Begin().Z() + ((i.X()+i.Y()+off) % 2); i.Z()<rhs.Local().End().Z(); i.Z()+=2) { 65 66 temp = prefactor_inv * rhs.GetCorrectedVal(i); 67 68 for (Stencil::iterator iter=A.begin(); iter!=A.end(); ++iter) 69 temp -= iter->Val() * sol.GetVal(i + iter->Disp()); 70 71 sol(i) = temp * diag_inv; 58 72 59 73 } 74 75 Timer::Stop("SmootherWithoutCommunication"); 60 76 }
Note:
See TracChangeset
for help on using the changeset viewer.
