Skip to content

Commit

Permalink
fix bugs in netcdf and new_blockdt (#181)
Browse files Browse the repository at this point in the history
- fix new_blockdt
- fix 3d netcdf output
  • Loading branch information
chengcli authored Oct 13, 2024
1 parent e221969 commit 46a7e25
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions patches/21.new_blockdt.patch
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
diff --git a/src/hydro/new_blockdt.cpp b/src/hydro/new_blockdt.cpp
index 0dfe3b29..71e4f7aa 100644
index c664de5d..9286f0d7 100644
--- a/src/hydro/new_blockdt.cpp
+++ b/src/hydro/new_blockdt.cpp
@@ -29,6 +29,10 @@
#include "hydro.hpp"
#include "hydro_diffusion/hydro_diffusion.hpp"

+// snap injection
+#include <impl.hpp>
+#include <snap/implicit/implicit_solver.hpp>
+
// MPI/OpenMP header
#ifdef MPI_PARALLEL
#include <mpi.h>
@@ -112,9 +116,21 @@ void Hydro::NewBlockTimeStep() {
@@ -82,6 +86,7 @@ void Hydro::NewBlockTimeStep() {
#pragma ivdep
for (int i=is; i<=ie; ++i) {
wi[IDN] = w(IDN,k,j,i);
+ for (int n=1; n<IVX; ++n) wi[n] = w(n,k,j,i);
wi[IVX] = w(IVX,k,j,i);
wi[IVY] = w(IVY,k,j,i);
wi[IVZ] = w(IVZ,k,j,i);
@@ -115,9 +120,21 @@ void Hydro::NewBlockTimeStep() {
Real speed1 = std::max(cspeed, (std::abs(wi[IVX]) + cs));
Real speed2 = std::max(cspeed, (std::abs(wi[IVY]) + cs));
Real speed3 = std::max(cspeed, (std::abs(wi[IVZ]) + cs));
Expand Down
2 changes: 1 addition & 1 deletion src/outputs/netcdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ void NetcdfOutput::WriteOutputFile(Mesh *pm, ParameterInput *pin, bool flag) {

if (ncells3 > 1) {
for (int k = out_ks; k <= out_ke + 1; ++k)
data[k - out_ks] = (float)(pmb->pcoord->x1f(k));
data[k - out_ks] = (float)(pmb->pcoord->x3f(k));
nc_put_var_float(ifile, ivx3f, data);
}

Expand Down

0 comments on commit 46a7e25

Please sign in to comment.