Skip to content

Commit 1eeff0c

Browse files
author
tomo-ono
committed
modify jgg.cpp
1 parent 798235d commit 1eeff0c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/pgen/jgg.cpp

+10-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include "../athena_arrays.hpp"
3434
#include "../coordinates/coordinates.hpp"
3535
#include "../eos/eos.hpp"
36-
#include "../fft/athena_fft.hpp"
3736
#include "../field/field.hpp"
3837
#include "../globals.hpp"
3938
#include "../hydro/hydro.hpp"
@@ -42,6 +41,10 @@
4241
#include "../outputs/outputs.hpp"
4342
#include "../parameter_input.hpp"
4443

44+
#ifdef FFT
45+
#include "../fft/athena_fft.hpp"
46+
#endif
47+
4548
#if !MAGNETIC_FIELDS_ENABLED
4649
#error "This problem generator requires magnetic fields"
4750
#endif
@@ -143,12 +146,13 @@ void Mesh::InitUserMeshData(ParameterInput *pin) {
143146
msg << "### FATAL ERROR in jgg.cpp ProblemGenerator" << std::endl
144147
<< "FFT option is required for error output." << std::endl;
145148
ATHENA_ERROR(msg);
146-
#endif
149+
#else
147150
if (Globals::my_rank==0 || (Globals::nranks>1 && Globals::my_rank == 1)) {
148151
fft_data = new fftw_complex[mesh_size.nx2];
149152
fplan = fftw_plan_dft_1d(mesh_size.nx2, fft_data, fft_data,
150153
FFTW_FORWARD, FFTW_ESTIMATE);
151154
}
155+
#endif
152156

153157
// allocateDataField
154158
AllocateRealUserMeshDataField(4);
@@ -476,9 +480,9 @@ void Mesh::UserWorkInLoop() {
476480
Real vol = pmb->pcoord->GetCellVolume(k,j,i);
477481
Real SN = std::sin(kx*x1+ky*x2+kz*x3);
478482
if (mesh_size.nx3>1) { // 3D
479-
ruser_mesh_data[0](tk,tj,ti) = 2.0*pmb->pfield->bcc(IB1,k,j,i)*vol*SN;
480-
} else { // 2D
481483
ruser_mesh_data[0](tk,tj,ti) = 2.0*pmb->pfield->bcc(IB3,k,j,i)*vol*SN;
484+
} else { // 2D
485+
ruser_mesh_data[0](tk,tj,ti) = 2.0*pmb->pfield->bcc(IB1,k,j,i)*vol*SN;
482486
}
483487
} else { // ipert == 2
484488
ruser_mesh_data[0](tk,tj,ti) = (pmb->pfield->bcc(IB1,k,j,i)-rbx)/dbx0;
@@ -621,6 +625,7 @@ void Mesh::UserWorkInLoop() {
621625
}
622626
}
623627
#endif
628+
#ifdef FFT
624629
// fft execution
625630
if (ipert == 2) {
626631
int exe_rank_dby = (Globals::nranks>1)? 1 : 0;
@@ -688,6 +693,7 @@ void Mesh::UserWorkInLoop() {
688693
}
689694
}
690695
}
696+
#endif
691697
} // flag
692698
return;
693699
}

0 commit comments

Comments
 (0)