Skip to content
Snippets Groups Projects
Unverified Commit b167823c authored by Jayesh Badwaik's avatar Jayesh Badwaik
Browse files

- everything works

parent 81c37d7f
Branches
No related tags found
No related merge requests found
......@@ -75,7 +75,7 @@ int main(int argc, char** argv)
auto dt = dx / 8;
double time = 0;
double Tfinal = 0.2;
double Tfinal = 0.20;
std::size_t iter = 0;
std::size_t max_iter = 100000;
......@@ -84,21 +84,25 @@ int main(int argc, char** argv)
if (world_rank == 0) {
for (std::size_t i = 0; i < nhalo; ++i) {
halo_send[i] = data[ncell - nhalo + i];
halo_send[i] = static_cast<send_type>(data[ncell - nhalo + i]);
}
MPI_Request send_handle;
MPI_Request recv_handle;
MPI_Irecv(halo_recv.data(), nhalo, mpi_type, 1, 0, MPI_COMM_WORLD, &recv_handle);
MPI_Isend(halo_send.data(), nhalo, mpi_type, 1, 0, MPI_COMM_WORLD, &send_handle);
MPI_Isend(halo_send.data(), nhalo, mpi_type, 1, 1, MPI_COMM_WORLD, &send_handle);
MPI_Wait(&send_handle, MPI_STATUS_IGNORE);
MPI_Wait(&recv_handle, MPI_STATUS_IGNORE);
} else {
for (std::size_t i = 0; i < nhalo; ++i) {
halo_send[i] = data[i];
halo_send[i] = static_cast<send_type>(data[i]);
}
MPI_Request send_handle;
MPI_Request recv_handle;
MPI_Irecv(halo_recv.data(), nhalo, mpi_type, 0, 0, MPI_COMM_WORLD, &recv_handle);
MPI_Irecv(halo_recv.data(), nhalo, mpi_type, 0, 1, MPI_COMM_WORLD, &recv_handle);
MPI_Isend(halo_send.data(), nhalo, mpi_type, 0, 0, MPI_COMM_WORLD, &send_handle);
MPI_Wait(&send_handle, MPI_STATUS_IGNORE);
MPI_Wait(&recv_handle, MPI_STATUS_IGNORE);
}
for (std::size_t i = 1; i < ncell - 1; ++i) {
......@@ -109,12 +113,17 @@ int main(int argc, char** argv)
std::size_t ix = ncell - 1;
tmp[ix]
= data[ix]
+ dt / dx * (numflux(data[ix - 1], data[ix]) - numflux(data[ix], halo_recv[nhalo - 1]));
+ dt / dx * (numflux(data[ix - 1], data[ix]) - numflux(data[ix], halo_recv[0]));
} else {
std::size_t ix = 0;
tmp[ix]
= data[ix]
+ dt / dx * (numflux(data[ix - 1], data[ix]) - numflux(data[ix], halo_recv[0]));
+ dt / dx * (numflux(halo_recv[nhalo - 1], data[ix]) - numflux(data[ix], data[ix + 1]));
ix = ncell - 1;
tmp[ix]
= data[ix]
+ dt / dx * (numflux(data[ix - 1], data[ix]) - numflux(data[ix], data[ix]));
}
for (std::size_t i = 0; i < ncell; ++i) {
......@@ -123,8 +132,10 @@ int main(int argc, char** argv)
time += dt;
++iter;
if (world_rank == 0) {
std::cout << "iter = " << iter << "\ttime = " << time << "\tdt = " << dt << "\n";
}
}
auto const final_filename = "data_" + std::to_string(world_rank) + ".final.txt";
std::ofstream final_file(final_filename);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment