diff --git a/src/fluid/boundary/axis.cpp b/src/fluid/boundary/axis.cpp index e447aefc..afdeb865 100644 --- a/src/fluid/boundary/axis.cpp +++ b/src/fluid/boundary/axis.cpp @@ -28,39 +28,31 @@ void Axis::SymmetrizeEx1Side(int jref) { IdefixArray3D Ex1 = this->ex; IdefixArray1D Ex1Avg = this->Ex1Avg; - if(isTwoPi) { - idefix_for("Ex1_ini",0,data->np_tot[IDIR], - KOKKOS_LAMBDA(int i) { - Ex1Avg(i) = ZERO_F; - }); - - idefix_for("Ex1_Symmetrize",data->beg[KDIR],data->end[KDIR],0,data->np_tot[IDIR], - KOKKOS_LAMBDA(int k,int i) { - Kokkos::atomic_add(&Ex1Avg(i), Ex1(k,jref,i)); + idefix_for("Ex1_ini",0,data->np_tot[IDIR], + KOKKOS_LAMBDA(int i) { + Ex1Avg(i) = ZERO_F; }); - if(needMPIExchange) { - #ifdef WITH_MPI - Kokkos::fence(); - // sum along all of the processes on the same r - MPI_Allreduce(MPI_IN_PLACE, Ex1Avg.data(), data->np_tot[IDIR], realMPI, - MPI_SUM, data->mygrid->AxisComm); - #endif - } - int ncells=data->mygrid->np_int[KDIR]; - - idefix_for("Ex1_Store",0,data->np_tot[KDIR],0,data->np_tot[IDIR], - KOKKOS_LAMBDA(int k,int i) { - Ex1(k,jref,i) = Ex1Avg(i)/((real) ncells); - }); - } else { - // if we're not doing full two pi, the flow is symmetric with respect to the axis, and the axis - // EMF is simply zero - idefix_for("Ex1_Store",0,data->np_tot[KDIR],0,data->np_tot[IDIR], + idefix_for("Ex1_Symmetrize",data->beg[KDIR],data->end[KDIR],0,data->np_tot[IDIR], KOKKOS_LAMBDA(int k,int i) { - Ex1(k,jref,i) = ZERO_F; + Kokkos::atomic_add(&Ex1Avg(i), Ex1(k,jref,i)); }); + if(needMPIExchange) { + #ifdef WITH_MPI + Kokkos::fence(); + // sum along all of the processes on the same r + MPI_Allreduce(MPI_IN_PLACE, Ex1Avg.data(), data->np_tot[IDIR], realMPI, + MPI_SUM, data->mygrid->AxisComm); + #endif } + + int ncells=data->mygrid->np_int[KDIR]; + + idefix_for("Ex1_Store",0,data->np_tot[KDIR],0,data->np_tot[IDIR], + KOKKOS_LAMBDA(int k,int i) { + Ex1(k,jref,i) = Ex1Avg(i)/((real) ncells); + }); + #endif } @@ -100,9 +92,9 @@ void Axis::RegularizeCurrentSide(int side) { sign = -1; } IdefixArray1D BAvg = this->Ex1Avg; - IdefixArray1D x2 = data->x[JDIR]; IdefixArray1D x1 = data->x[IDIR]; IdefixArray1D dx3 = data->dx[KDIR]; + IdefixArray1D dx2 = data->dx[JDIR]; idefix_for("B_ini",0,data->np_tot[IDIR], KOKKOS_LAMBDA(int i) { @@ -132,8 +124,7 @@ void Axis::RegularizeCurrentSide(int side) { idefix_for("fixJ",0,data->np_tot[KDIR],0,data->np_tot[IDIR], KOKKOS_LAMBDA(int k,int i) { - real th = x2(jc); - real fact = 2*sign/(deltaPhi*x1(i)*sin(th)); + real fact = 2*sign/(deltaPhi*x1(i)*dx2(jc)); J(IDIR, k,js,i) = BAvg(i)*fact; }); diff --git a/src/fluid/calcRightHandSide.hpp b/src/fluid/calcRightHandSide.hpp index 7777d1c2..0a0d3e19 100644 --- a/src/fluid/calcRightHandSide.hpp +++ b/src/fluid/calcRightHandSide.hpp @@ -363,7 +363,7 @@ struct Fluid_CalcRHSFunctor { #if (GEOMETRY == SPHERICAL) && (COMPONENTS == 3) rhs[iMPHI] /= FABS(sinx2(j)); if constexpr(Phys::mhd) { - rhs[iBPHI] = -dt / (rt(i)*dx(j)) * (Flux(iBPHI, k, j+1, i) - Flux(iBPHI, k, j, i)); + rhs[iBPHI] = -dt / (x1(i)*dx(j)) * (Flux(iBPHI, k, j+1, i) - Flux(iBPHI, k, j, i)); } // MHD #endif // GEOMETRY } diff --git a/test/IO/pydefix/README.md b/test/IO/pydefix/README.md index 820a0958..8dd3f5b4 100644 --- a/test/IO/pydefix/README.md +++ b/test/IO/pydefix/README.md @@ -42,3 +42,10 @@ export pybind11_DIR=env/lib/python3.10/site-packages/pybind11 ``` you can then run cmake which should be able to find pybind11, and compile the code. + +If while running the code using a python interpreter in an environment, you run into errors stating that some module +installed in your environement is not present. This is because pybind11 does not always capture your venv. You need to force the following environement variables (replace XX by your python version) + +```bash +export PYTHONPATH=$VIRTUAL_ENV/lib/python3.XX/site-packages:$PYTHONPATH +```