@@ -48,13 +48,6 @@ using namespace parthenon::driver::prelude;
4848void ProblemGenerator (Mesh *pmesh, ParameterInput *pin, MeshData<Real> *md) {
4949 auto vflow = pin->GetReal (" problem/kh" , " vflow" );
5050 auto iprob = pin->GetInteger (" problem/kh" , " iprob" );
51- // Get pointer to first block (always exists) for common data like loop bounds
52- auto pmb = md->GetBlockData (0 )->GetBlockPointer ();
53- auto ib = pmb->cellbounds .GetBoundsI (IndexDomain::interior);
54- auto jb = pmb->cellbounds .GetBoundsJ (IndexDomain::interior);
55- auto kb = pmb->cellbounds .GetBoundsK (IndexDomain::interior);
56- auto gam = pin->GetReal (" hydro" , " gamma" );
57- auto gm1 = (gam - 1.0 );
5851
5952 // Initialize conserved variables
6053 // Get a MeshBlockPack on device with all conserved variables
@@ -63,24 +56,71 @@ void ProblemGenerator(Mesh *pmesh, ParameterInput *pin, MeshData<Real> *md) {
6356
6457 // Silly ADIOS2 test
6558
66- adios2::fstream iStream (" test.bp" , adios2::fstream::in, MPI_COMM_WORLD);
67- adios2::fstep iStep;
68- // There's only a single step in the input file, so there's no issue using the while
69- // logic here.
70- while (adios2::getstep (iStream, iStep)) {
71- // only read row of current rank
72- const adios2::Dims start{static_cast <unsigned long >(parthenon::Globals::my_rank), 0 };
73- const adios2::Dims count{1 , 4 };
74- auto mydata = iStream.read <double >(" myvarname" , start, count);
75- std::cerr << " [" << parthenon::Globals::my_rank << " ] " ;
76- for (auto var : mydata) {
77- std::cerr << var << " " ;
59+ for (int b = 0 ; b < num_blocks; b++) {
60+ auto pmb = md->GetBlockData (b)->GetBlockPointer ();
61+ const auto loc = pmb->pmy_mesh ->Forest ().GetLegacyTreeLocation (pmb->loc );
62+ const auto mb1 = pmb->block_size .nx (parthenon::X1DIR);
63+ const auto mb2 = pmb->block_size .nx (parthenon::X2DIR);
64+ const auto mb3 = pmb->block_size .nx (parthenon::X3DIR);
65+ const auto gis = loc.lx1 () * mb1;
66+ const auto gjs = loc.lx2 () * mb2;
67+ const auto gks = loc.lx3 () * mb3;
68+ adios2::fstream iStream (" test3d.bp" , adios2::fstream::in, MPI_COMM_WORLD);
69+ adios2::fstep iStep;
70+ // There's only a single step in the input file, so there's no issue using the while
71+ // logic here.
72+ while (adios2::getstep (iStream, iStep)) {
73+ // only read row of current rank
74+ const adios2::Dims start{0 , static_cast <unsigned long >(gks),
75+ static_cast <unsigned long >(gjs),
76+ static_cast <unsigned long >(gis)};
77+ const adios2::Dims count{4 , static_cast <unsigned long >(mb3),
78+ static_cast <unsigned long >(mb2),
79+ static_cast <unsigned long >(mb1)};
80+ auto mydata = iStream.read <double >(" myvarname" , start, count);
81+ std::cerr << " [" << parthenon::Globals::my_rank << " :" << b << " ]" ;
82+ for (int i = 0 ; i < 10 ; i++) {
83+ std::cerr << mydata[i] << " " ;
84+ }
85+ std::cerr << " \n " ;
86+
87+ auto ib = pmb->cellbounds .GetBoundsI (IndexDomain::interior);
88+ auto jb = pmb->cellbounds .GetBoundsJ (IndexDomain::interior);
89+ auto kb = pmb->cellbounds .GetBoundsK (IndexDomain::interior);
90+ // initialize conserved variables
91+ auto &mbd = pmb->meshblock_data .Get ();
92+ auto &u_dev = mbd->Get (" cons" ).data ;
93+ auto &coords = pmb->coords ;
94+ // initializing on host
95+ auto u = u_dev.GetHostMirrorAndCopy ();
96+
97+ // Read problem parameters
98+ for (int k = kb.s ; k <= kb.e ; k++) {
99+ for (int j = jb.s ; j <= jb.e ; j++) {
100+ for (int i = ib.s ; i <= ib.e ; i++) {
101+ const auto kk = k - kb.s ;
102+ const auto jj = j - jb.s ;
103+ const auto ii = i - ib.s ;
104+ u (IDN, k, j, i) = mydata[((0 * mb3 + kk) * mb2 + jj) * mb1 + ii];
105+ u (IM2, k, j, i) = mydata[((1 * mb3 + kk) * mb2 + jj) * mb1 + ii];
106+ u (IEN, k, j, i) = mydata[((2 * mb3 + kk) * mb2 + jj) * mb1 + ii];
107+ }
108+ }
109+ }
110+ // copy initialized vars to device
111+ u_dev.DeepCopy (u);
112+ // Just to be sure we break (to not read any other steps if present in the bp file)
113+ break ;
78114 }
79- std::cerr << " \n " ;
80- // Just to be sure we break (to not read any other steps if present in the bp file)
81- break ;
115+ iStream.close ();
82116 }
83- iStream.close ();
117+ // Get pointer to first block (always exists) for common data like loop bounds
118+ auto pmb = md->GetBlockData (0 )->GetBlockPointer ();
119+ auto ib = pmb->cellbounds .GetBoundsI (IndexDomain::interior);
120+ auto jb = pmb->cellbounds .GetBoundsJ (IndexDomain::interior);
121+ auto kb = pmb->cellbounds .GetBoundsK (IndexDomain::interior);
122+ auto gam = pin->GetReal (" hydro" , " gamma" );
123+ auto gm1 = (gam - 1.0 );
84124
85125 // --- iprob=1. This was the classic, unresolved K-H test.
86126
0 commit comments