@@ -45,6 +45,12 @@ public:
4545 void setNGhost (int _nghost) {nghost = IntVect (_nghost);}
4646 [[nodiscard]] int getNGhost () {return nghost[0 ];}
4747
48+ void setAMRLevel (int _amrlev) { amrlev = _amrlev; }
49+ [[nodiscard]] int getAMRLevel () const { return amrlev; }
50+
51+ void setMGLevel (int _mglev) { mglev = _mglev; }
52+ [[nodiscard]] int getMGLevel () const { return mglev; }
53+
4854 [[nodiscard]] RT dotxy (const MF& r, const MF& z, bool local = false );
4955 [[nodiscard]] RT norm_inf (const MF& res, bool local = false );
5056 int solve_bicgstab (MF& solnL, const MF& rhsL, RT eps_rel, RT eps_abs);
@@ -56,8 +62,8 @@ private:
5662
5763 MLLinOpT<MF>& Lp;
5864 Type solver_type;
59- const int amrlev = 0 ;
60- const int mglev;
65+ int amrlev = 0 ;
66+ int mglev;
6167 int verbose = 0 ;
6268 int maxiter = 100 ;
6369 IntVect nghost = IntVect(0 );
8793MLCGSolverT<MF>::solve_bicgstab (MF& sol, const MF& rhs, RT eps_rel, RT eps_abs)
8894{
8995 BL_PROFILE (" MLCGSolver::bicgstab" );
96+ amrex::Print () << " MLCGSolver::solve_bicgstab start" << " \n " ;
9097
9198 const int ncomp = sol.nComp ();
9299
100+ amrex::Print () << " MLCGSolver_BiCGStab: make ph and sh" << " \n " ;
93101 MF ph = Lp.make (amrlev, mglev, sol.nGrowVect ());
94102 MF sh = Lp.make (amrlev, mglev, sol.nGrowVect ());
103+ amrex::Print () << " MLCGSolver_BiCGStab: ph.setVal(0) and sh.setVal(0)" << " \n " ;
95104 ph.setVal (RT (0.0 ));
96105 sh.setVal (RT (0.0 ));
97106
107+ amrex::Print () << " MLCGSolver_BiCGStab: make sorig,p,r,s,rh,v,t" << " \n " ;
98108 MF sorig = Lp.make (amrlev, mglev, nghost);
99109 MF p = Lp.make (amrlev, mglev, nghost);
100110 MF r = Lp.make (amrlev, mglev, nghost);
@@ -103,16 +113,22 @@ MLCGSolverT<MF>::solve_bicgstab (MF& sol, const MF& rhs, RT eps_rel, RT eps_abs)
103113 MF v = Lp.make (amrlev, mglev, nghost);
104114 MF t = Lp.make (amrlev, mglev, nghost);
105115
116+ amrex::Print () << " MLCGSolver_BiCGStab: Lp.correctionResidual(r,sol,rhs)" << " \n " ;
106117 Lp.correctionResidual (amrlev, mglev, r, sol, rhs, MLLinOpT<MF>::BCMode::Homogeneous);
107118
119+ amrex::Print () << " MLCGSolver_BiCGStab: Lp.normalize(r)" << " \n " ;
108120 // Then normalize
109121 Lp.normalize (amrlev, mglev, r);
110122
123+ amrex::Print () << " MLCGSolver_BiCGStab: LocalCopy sorig from sol" << " \n " ;
111124 sorig.LocalCopy (sol,0 ,0 ,ncomp,nghost);
125+ amrex::Print () << " MLCGSolver_BiCGStab: LocalCopy rh from r" << " \n " ;
112126 rh.LocalCopy (r ,0 ,0 ,ncomp,nghost);
113127
128+ amrex::Print () << " MLCGSolver_BiCGStab: sol.setVal(0)" << " \n " ;
114129 sol.setVal (RT (0.0 ));
115130
131+ amrex::Print () << " MLCGSolver_BiCGStab: rnorm = norm_inf(r)" << " \n " ;
116132 RT rnorm = norm_inf (r);
117133 const RT rnorm0 = rnorm;
118134
@@ -137,25 +153,33 @@ MLCGSolverT<MF>::solve_bicgstab (MF& sol, const MF& rhs, RT eps_rel, RT eps_abs)
137153
138154 for (; iter <= maxiter; ++iter)
139155 {
156+ amrex::Print () << " solve_bicgstab: start iter = " << iter << " \n " ;
157+ amrex::Print () << " Calculate rho" << " \n " ;
140158 const RT rho = dotxy (rh,r);
141159 if ( rho == 0 )
142160 {
143161 ret = 1 ; break ;
144162 }
145163 if ( iter == 1 )
146164 {
165+ amrex::Print () << " Local copy p from r" << " \n " ;
147166 p.LocalCopy (r,0 ,0 ,ncomp,nghost);
148167 }
149168 else
150169 {
170+ amrex::Print () << " Calculate p" << " \n " ;
151171 const RT beta = (rho/rho_1)*(alpha/omega);
152172 MF::Saxpy (p, -omega, v, 0 , 0 , ncomp, nghost); // p += -omega*v
153173 MF::Xpay (p, beta, r, 0 , 0 , ncomp, nghost); // p = r + beta*p
154174 }
175+ amrex::Print () << " Local copy ph from p" << " \n " ;
155176 ph.LocalCopy (p,0 ,0 ,ncomp,nghost);
177+ amrex::Print () << " Lp.apply(v,ph)" << " \n " ;
156178 Lp.apply (amrlev, mglev, v, ph, MLLinOpT<MF>::BCMode::Homogeneous, MLLinOpT<MF>::StateMode::Correction);
179+ amrex::Print () << " Lp.normalize(v)" << " \n " ;
157180 Lp.normalize (amrlev, mglev, v);
158181
182+ amrex::Print () << " Calculate rhTv" << " \n " ;
159183 RT rhTv = dotxy (rh,v);
160184 if ( rhTv != RT (0.0 ) )
161185 {
@@ -165,9 +189,12 @@ MLCGSolverT<MF>::solve_bicgstab (MF& sol, const MF& rhs, RT eps_rel, RT eps_abs)
165189 {
166190 ret = 2 ; break ;
167191 }
192+ amrex::Print () << " Saxpy sol += alpha*ph" << " \n " ;
168193 MF::Saxpy (sol, alpha, ph, 0 , 0 , ncomp, nghost); // sol += alpha * ph
194+ amrex::Print () << " Lincomb s = r - alpha*v" << " \n " ;
169195 MF::LinComb (s, RT (1.0 ), r, 0 , -alpha, v, 0 , 0 , ncomp, nghost); // s = r - alpha * v
170196
197+ amrex::Print () << " rnorm = norm_inf(s)" << " \n " ;
171198 rnorm = norm_inf (s);
172199
173200 if ( verbose > 2 && ParallelDescriptor::IOProcessor () )
@@ -180,14 +207,18 @@ MLCGSolverT<MF>::solve_bicgstab (MF& sol, const MF& rhs, RT eps_rel, RT eps_abs)
180207
181208 if ( rnorm < eps_rel*rnorm0 || rnorm < eps_abs ) { break ; }
182209
210+ amrex::Print () << " LocalCopy sh from s" << " \n " ;
183211 sh.LocalCopy (s,0 ,0 ,ncomp,nghost);
212+ amrex::Print () << " Lp.apply(t,sh)" << " \n " ;
184213 Lp.apply (amrlev, mglev, t, sh, MLLinOpT<MF>::BCMode::Homogeneous, MLLinOpT<MF>::StateMode::Correction);
214+ amrex::Print () << " Lp.normalize(t)" << " \n " ;
185215 Lp.normalize (amrlev, mglev, t);
186216 //
187217 // This is a little funky. I want to elide one of the reductions
188218 // in the following two dotxy()s. We do that by calculating the "local"
189219 // values and then reducing the two local values at the same time.
190220 //
221+ amrex::Print () << " tvals[2]" << " \n " ;
191222 RT tvals[2 ] = { dotxy (t,t,true ), dotxy (t,s,true ) };
192223
193224 BL_PROFILE_VAR (" MLCGSolver::ParallelAllReduce" , blp_par);
@@ -202,9 +233,12 @@ MLCGSolverT<MF>::solve_bicgstab (MF& sol, const MF& rhs, RT eps_rel, RT eps_abs)
202233 {
203234 ret = 3 ; break ;
204235 }
236+ amrex::Print () << " Saxpy sol += omega * sh" << " \n " ;
205237 MF::Saxpy (sol, omega, sh, 0 , 0 , ncomp, nghost); // sol += omega * sh
238+ amrex::Print () << " Lincomb r = s - omega * t" << " \n " ;
206239 MF::LinComb (r, RT (1.0 ), s, 0 , -omega, t, 0 , 0 , ncomp, nghost); // r = s - omega * t
207240
241+ amrex::Print () << " rnorm = norm_inf(r)" << " \n " ;
208242 rnorm = norm_inf (r);
209243
210244 if ( verbose > 2 )
@@ -222,6 +256,7 @@ MLCGSolverT<MF>::solve_bicgstab (MF& sol, const MF& rhs, RT eps_rel, RT eps_abs)
222256 ret = 4 ; break ;
223257 }
224258 rho_1 = rho;
259+ amrex::Print () << " solve_bicgstab: end iter = " << iter << " \n " ;
225260 }
226261
227262 if ( verbose > 0 )
@@ -250,6 +285,7 @@ MLCGSolverT<MF>::solve_bicgstab (MF& sol, const MF& rhs, RT eps_rel, RT eps_abs)
250285 sol.LocalAdd (sorig, 0 , 0 , ncomp, nghost);
251286 }
252287
288+ amrex::Print () << " MLCGSolver::solve_bicgstab end" << " \n " ;
253289 return ret;
254290}
255291
0 commit comments