//======================================================================================== // Athena++ astrophysical MHD code // Copyright(C) 2014 James M. Stone and other code contributors // Licensed under the 3-clause BSD License, see LICENSE file for details //======================================================================================== //! \file turb.cpp //! \brief Problem generator for turbulence driver // C headers // C++ headers #include #include #include #include // Athena++ headers #include "../athena.hpp" #include "../athena_arrays.hpp" #include "../coordinates/coordinates.hpp" #include "../eos/eos.hpp" #include "../fft/athena_fft.hpp" #include "../field/field.hpp" #include "../globals.hpp" #include "../hydro/hydro.hpp" #include "../mesh/mesh.hpp" #include "../parameter_input.hpp" #include "../utils/utils.hpp" #ifdef OPENMP_PARALLEL #include #endif //======================================================================================== //! \fn void Mesh::InitUserMeshData(ParameterInput *pin) // \brief //======================================================================================== void Mesh::InitUserMeshData(ParameterInput *pin) { if (SELF_GRAVITY_ENABLED) { Real four_pi_G = pin->GetReal("problem","four_pi_G"); SetFourPiG(four_pi_G); } // turb_flag is initialzed in the Mesh constructor to 0 by default; // turb_flag = 1 for decaying turbulence // turb_flag = 2 for impulsively driven turbulence // turb_flag = 3 for continuously driven turbulence turb_flag = pin->GetInteger("problem","turb_flag"); if (turb_flag != 0) { #ifndef FFT std::stringstream msg; msg << "### FATAL ERROR in TurbulenceDriver::TurbulenceDriver" << std::endl << "non zero Turbulence flag is set without FFT!" << std::endl; ATHENA_ERROR(msg); return; #endif } return; } //======================================================================================== //! \fn void MeshBlock::ProblemGenerator(ParameterInput *pin) // \brief //======================================================================================== void MeshBlock::ProblemGenerator(ParameterInput *pin) { Real width = pin->GetReal("problem","width"); Real b0 = pin->GetReal("problem","b0"); Real gamma = pin->GetReal("problem","gamma"); Real bx0, p0, gam1, y0; p0 = 1.0; gam1 = gamma-1.0; for (int k=ks; k<=ke; k++) { for (int j=js; j<=je; j++) { for (int i=is; i<=ie; i++) { phydro->u(IDN,k,j,i) = 1.0; phydro->u(IM1,k,j,i) = 0.0; phydro->u(IM2,k,j,i) = 0.0; phydro->u(IM3,k,j,i) = 0.0; if (NON_BAROTROPIC_EOS) { phydro->u(IEN,k,j,i) = p0/gam1; } } } } if (MAGNETIC_FIELDS_ENABLED) { b0 = pin->GetReal("problem", "b0"); for (int k=ks; k<=ke; ++k) { for (int j=js; j<=je; ++j) { for (int i=is; i<=ie+1; ++i) { y0 = pcoord->x2v(j); pfield->b.x1f(k,j,i) = b0 * tanh(y0/width); if (i>is){ bx0 = 0.5*(pfield->b.x1f(k,j,i)+pfield->b.x1f(k,j,i-1)); phydro->u(IEN,k,j,i-1) += (bx0*bx0)/2.0; } } } } for (int k=ks; k<=ke; ++k) { for (int j=js; j<=je+1; ++j) { for (int i=is; i<=ie; ++i) { pfield->b.x2f(k,j,i) = 0.0; } } } for (int k=ks; k<=ke+1; ++k) { for (int j=js; j<=je; ++j) { for (int i=is;i<=ie;++i) { pfield->b.x3f(k,j,i) = 0.0; } } } } } //======================================================================================== //! \fn void Mesh::UserWorkAfterLoop(ParameterInput *pin) // \brief //======================================================================================== void Mesh::UserWorkAfterLoop(ParameterInput *pin) { }