@@ -24,14 +24,11 @@ int main (int argc, char* argv[])
2424 Real prob_hi_y = 1 .;,
2525 Real prob_hi_z = 1 .);
2626
27- int solver_type = 0 ;
28-
2927 {
3028 ParmParse pp;
3129 AMREX_D_TERM (pp.query (" n_cell_x" , n_cell_x);,
3230 pp.query (" n_cell_y" , n_cell_y);,
3331 pp.query (" n_cell_z" , n_cell_z));
34- pp.query (" solver_type" , solver_type);
3532 }
3633
3734 Box domain (IntVect (0 ),IntVect (AMREX_D_DECL (n_cell_x-1 ,n_cell_y-1 ,n_cell_z-1 )));
@@ -63,41 +60,43 @@ int main (int argc, char* argv[])
6360 auto rhosum = rhs.sum (0 );
6461 rhs.plus (-rhosum/geom.Domain ().d_numPts (), 0 , 1 );
6562
66- double tsetup, tsolve;
67-
6863#if (AMREX_SPACEDIM == 3)
69- if (solver_type == 1 ) {
70- auto t0 = amrex::second ();
71- FFT::PoissonHybrid<MultiFab> fft_poisson (geom);
72- auto t1 = amrex::second ();
73- tsetup = t1-t0;
74-
75- for (int n = 0 ; n < 2 ; ++n) {
76- auto ta = amrex::second ();
77- fft_poisson.solve (soln, rhs);
78- auto tb = amrex::second ();
79- tsolve = tb-ta;
80- }
81- } else
64+ Array<int ,2 > solvers{0 ,1 };
65+ #else
66+ Array<int ,2 > solvers{0 };
8267#endif
83- {
84- auto t0 = amrex::second ();
85- FFT::Poisson<MultiFab> fft_poisson (geom);
86- auto t1 = amrex::second ();
87- tsetup = t1-t0;
88-
89- for (int n = 0 ; n < 2 ; ++n) {
90- auto ta = amrex::second ();
91- fft_poisson.solve (soln, rhs);
92- auto tb = amrex::second ();
93- tsolve = tb-ta;
68+
69+ for (int solver_type : solvers) {
70+ double tsetup, tsolve;
71+ if (solver_type == 0 ) {
72+ auto t0 = amrex::second ();
73+ FFT::Poisson<MultiFab> fft_poisson (geom);
74+ auto t1 = amrex::second ();
75+ tsetup = t1-t0;
76+
77+ for (int n = 0 ; n < 2 ; ++n) {
78+ auto ta = amrex::second ();
79+ fft_poisson.solve (soln, rhs);
80+ auto tb = amrex::second ();
81+ tsolve = tb-ta;
82+ }
83+ } else {
84+ auto t0 = amrex::second ();
85+ FFT::PoissonHybrid<MultiFab> fft_poisson (geom);
86+ auto t1 = amrex::second ();
87+ tsetup = t1-t0;
88+
89+ for (int n = 0 ; n < 2 ; ++n) {
90+ auto ta = amrex::second ();
91+ fft_poisson.solve (soln, rhs);
92+ auto tb = amrex::second ();
93+ tsolve = tb-ta;
94+ }
9495 }
95- }
9696
97- amrex::Print () << " AMReX FFT setup time: " << tsetup << " , solve time "
98- << tsolve << " \n " ;
97+ amrex::Print () << " AMReX FFT setup time: " << tsetup
98+ << " , solve time " << tsolve << " \n " ;
9999
100- {
101100 MultiFab phi (soln.boxArray (), soln.DistributionMap (), 1 , 1 );
102101 MultiFab res (soln.boxArray (), soln.DistributionMap (), 1 , 0 );
103102 MultiFab::Copy (phi, soln, 0 , 0 , 1 , 0 );
0 commit comments