56 RP::add(
"IPShock.BX0u",
"Upstream mag. field value (T)", 1.0e-9);
57 RP::add(
"IPShock.BY0u",
"Upstream mag. field value (T)", 2.0e-9);
58 RP::add(
"IPShock.BZ0u",
"Upstream mag. field value (T)", 3.0e-9);
59 RP::add(
"IPShock.BX0d",
"Downstream mag. field value (T)", 1.0e-9);
60 RP::add(
"IPShock.BY0d",
"Downstream mag. field value (T)", 2.0e-9);
61 RP::add(
"IPShock.BZ0d",
"Downstream mag. field value (T)", 3.0e-9);
62 RP::add(
"IPShock.Width",
"Shock Width (m)", 50000);
64 RP::add(
"IPShock.AMR_L1width",
"L1 AMR region width (m)", 0);
65 RP::add(
"IPShock.AMR_L2width",
"L2 AMR region width (m)", 0);
66 RP::add(
"IPShock.AMR_L3width",
"L3 AMR region width (m)", 0);
67 RP::add(
"IPShock.AMR_L4width",
"L4 AMR region width (m)", 0);
72 RP::add(pop +
"_IPShock.VX0u",
"Upstream Bulk velocity in x", 0.0);
73 RP::add(pop +
"_IPShock.VY0u",
"Upstream Bulk velocity in y", 0.0);
74 RP::add(pop +
"_IPShock.VZ0u",
"Upstream Bulk velocuty in z", 0.0);
75 RP::add(pop +
"_IPShock.rhou",
"Upstream Number density (m^-3)", 1.0e7);
76 RP::add(pop +
"_IPShock.Temperatureu",
"Upstream Temperature (K)", 2.0e6);
78 RP::add(pop +
"_IPShock.VX0d",
"Downstream Bulk velocity in x", 0.0);
79 RP::add(pop +
"_IPShock.VY0d",
"Downstream Bulk velocity in y", 0.0);
80 RP::add(pop +
"_IPShock.VZ0d",
"Downstream Bulk velocuty in z", 0.0);
81 RP::add(pop +
"_IPShock.rhod",
"Downstream Number density (m^-3)", 1.0e7);
82 RP::add(pop +
"_IPShock.Temperatured",
"Downstream Temperature (K)", 2.0e6);
84 RP::add(pop +
"_IPShock.maxwCutoff",
"Cutoff for the maxwellian distribution", 1e-12);
93 RP::get(
"IPShock.BX0u", this->
B0u[0]);
94 RP::get(
"IPShock.BY0u", this->
B0u[1]);
95 RP::get(
"IPShock.BZ0u", this->
B0u[2]);
96 RP::get(
"IPShock.BX0d", this->
B0d[0]);
97 RP::get(
"IPShock.BY0d", this->
B0d[1]);
98 RP::get(
"IPShock.BZ0d", this->
B0d[2]);
111 RP::get(pop +
"_IPShock.VX0u", sP.
V0u[0]);
112 RP::get(pop +
"_IPShock.VY0u", sP.
V0u[1]);
113 RP::get(pop +
"_IPShock.VZ0u", sP.
V0u[2]);
114 RP::get(pop +
"_IPShock.rhou", sP.
DENSITYu);
115 RP::get(pop +
"_IPShock.Temperatureu", sP.
TEMPERATUREu);
117 RP::get(pop +
"_IPShock.VX0d", sP.
V0d[0]);
118 RP::get(pop +
"_IPShock.VY0d", sP.
V0d[1]);
119 RP::get(pop +
"_IPShock.VZ0d", sP.
V0d[2]);
120 RP::get(pop +
"_IPShock.rhod", sP.
DENSITYd);
121 RP::get(pop +
"_IPShock.Temperatured", sP.
TEMPERATUREd);
123 RP::get(pop +
"_IPShock.maxwCutoff", sP.
maxwCutoff);
130 MPI_Comm_rank(MPI_COMM_WORLD,&
myRank);
166 sP.V0utangential =
sqrt(sP.V0u[1]*sP.V0u[1] + sP.V0u[2]*sP.V0u[2]);
167 sP.V0dtangential =
sqrt(sP.V0d[1]*sP.V0d[1] + sP.V0d[2]*sP.V0d[2]);
182 sP.Vucosphi =
abs(sP.V0u[1])/sP.V0utangential;
183 sP.Vdcosphi =
abs(sP.V0d[1])/sP.V0dtangential;
189 if (this->B0u[1] < 0) this->
Byusign=-1;
190 if (this->B0u[1] > 0) this->
Byusign=+1;
192 if (this->B0u[2] < 0) this->
Bzusign=-1;
193 if (this->B0u[2] > 0) this->
Bzusign=+1;
195 if (this->B0d[1] < 0) this->
Bydsign=-1;
196 if (this->B0d[1] > 0) this->
Bydsign=+1;
198 if (this->B0d[2] < 0) this->
Bzdsign=-1;
199 if (this->B0d[2] > 0) this->
Bzdsign=+1;
203 if (sP.V0u[1] < 0) sP.Vyusign=-1;
204 if (sP.V0u[1] > 0) sP.Vyusign=+1;
206 if (sP.V0u[2] < 0) sP.Vzusign=-1;
207 if (sP.V0u[2] > 0) sP.Vzusign=+1;
209 if (sP.V0d[1] < 0) sP.Vydsign=-1;
210 if (sP.V0d[1] > 0) sP.Vydsign=+1;
212 if (sP.V0d[2] < 0) sP.Vzdsign=-1;
213 if (sP.V0d[2] > 0) sP.Vzdsign=+1;
216 if ( (
abs(this->
Bucosphi)-
abs(sP.Vucosphi) > 1e-10) || (this->Byusign*this->Bzusign != sP.Vyusign*sP.Vzusign) )
219 std::cout<<
" Warning: Upstream B and V not parallel"<<std::endl;
220 std::cout<<
" Bucosphi "<<
Bucosphi<<
" Vucosphi "<<sP.Vucosphi<<
" Byusign "<<
Byusign<<
" Bzusign "<<
Bzusign<<
" Vyusign "<<sP.Vyusign<<
" Vzusign "<<sP.Vzusign<<std::endl;
223 if ( (
abs(this->
Bdcosphi)-
abs(sP.Vdcosphi) > 1e-10) || (this->Bydsign*this->Bzdsign != sP.Vydsign*sP.Vzdsign) )
226 std::cout<<
" Warning: Downstream B and V not parallel"<<std::endl;
227 std::cout<<
" Bdcosphi "<<
Bdcosphi<<
" Vdcosphi "<<sP.Vdcosphi<<
" Bydsign "<<
Bydsign<<
" Bzdsign "<<
Bzdsign<<
" Vydsign "<<sP.Vydsign<<
" Vzdsign "<<sP.Vzdsign<<std::endl;
234 std::cout<<
" Warning: Upstream and downstream B_tangentials not in same plane"<<std::endl;
238 if ( (
abs(sP.Vdcosphi)-
abs(sP.Vucosphi) > 1e-10) && (sP.Vydsign*sP.Vzdsign != sP.Vyusign*sP.Vzusign) )
241 std::cout<<
" Warning: Upstream and downstream V_tangentials not in same plane"<<std::endl;
242 std::cout<<
" Vdcosphi "<<sP.Vdcosphi<<
" Vucosphi "<<sP.Vucosphi<<
" Vydsign "<<sP.Vydsign<<
" Vzdsign "<<sP.Vzdsign<<
" Vyusign "<<sP.Vyusign<<
" Vzusign "<<sP.Vzusign<<std::endl;
251 const uint nRequested
264 if (DENSITY < 1e-20) {
265 std::cout<<
"density too low! "<<DENSITY<<
" x "<<x<<
" y "<<y<<
" z "<<z<<std::endl;
272 Real hereBtang = this->
B0u[2] * (MAsq - 1.0)/(MAsq*hereVX/sP.
V0u[0] -1.0);
273 Real hereVtang = hereVX * hereBtang / hereBX;
287 Real initRho = DENSITY;
289 const Real initV0X = hereVX;
290 const Real initV0Y = hereVY;
291 const Real initV0Z = hereVZ;
310 vmesh->getBlockInfo(blockGID,&blockCoords[0]);
311 creal vxBlock = blockCoords[0];
312 creal vyBlock = blockCoords[1];
313 creal vzBlock = blockCoords[2];
314 creal dvxCell = blockCoords[3];
315 creal dvyCell = blockCoords[4];
316 creal dvzCell = blockCoords[5];
318 creal vx = vxBlock + (
i+0.5)*dvxCell - initV0X;
319 creal vy = vyBlock + (
j+0.5)*dvyCell - initV0Y;
320 creal vz = vzBlock + (
k+0.5)*dvzCell - initV0Z;
346 if (DENSITY < 1e-20) {
347 std::cout<<
"density too low! "<<DENSITY<<
" x "<<x<<
" y "<<y<<
" z "<<z<<std::endl;
352 Real hereBtang = this->
B0u[2] * (MAsq - 1.0)/(MAsq*hereVX/sP.
V0u[0] -1.0);
353 Real hereVtang = hereVX * hereBtang / hereBX;
357 Real initRho = DENSITY;
359 const Real initV0X = hereVX;
360 const Real initV0Y = hereVY;
361 const Real initV0Z = hereVZ;
363 creal vx = vx_in - initV0X;
364 creal vy = vy_in - initV0Y;
365 creal vz = vz_in - initV0Z;
378 if (DENSITY < 1e-20) {
379 std::cout<<
"density too low! "<<DENSITY<<
" x "<<x<<
" y "<<y<<
" z "<<z<<std::endl;
387 Real Vtang =
VX * Btang / BX;
399 std::array<Real, 3> V0 {{
VX,
VY,
VZ}};
400 std::vector<std::array<Real, 3>> retval;
401 retval.push_back(V0);
412 if (coord <= 0.0) a = downstream;
413 if (coord >= 1.0) a = upstream;
414 if ((coord > 0.0) && (coord < 1.0)) {
416 Real interpolation = ( 6.0 * coord * coord - 15.0 * coord +10. ) * coord * coord * coord;
417 a = upstream * interpolation + downstream * (1. - interpolation);
428 const auto B0u_l = this->
B0u;
430 const auto Bucosphi_l = this->
Bucosphi;
431 const auto Byusign_l = this->
Byusign;
432 const auto Bzusign_l = this->
Bzusign;
435 fsgrid.parallel_for([](
int timerId) -> phiprof::Timer {
return phiprof::Timer{timerId}; },
436 phiprof::initializeTimer(
"setProjectBField-loop"), technical,
437 [=, *
this](
const fsgrid::Coordinates &coordinates,
const fsgrid::FsStencil& stencil,
cuint sysBoundaryFlag,
cuint sysBoundaryLayer) {
438 const std::array<Real, 3> xyz = coordinates.getPhysicalCoords(stencil.i, stencil.j, stencil.k);
439 auto& cell = perb[stencil.ooo()];
446 Real MassDensity = 0.;
447 Real MassDensityU = 0.;
448 Real EffectiveVu0 = 0.;
457 EffectiveVu0 /= MassDensityU;
460 Real VX = MassDensityU * EffectiveVu0 / MassDensity;
462 Real MAsq = std::pow((EffectiveVu0 / B0u_l[0]), 2) * MassDensityU *
mu0;
463 Real Btang = B0utangential_l * (MAsq - 1.0) / (MAsq *
VX / EffectiveVu0 - 1.0);
467 Real BY =
abs(Btang) * Bucosphi_l * Byusign_l;
468 Real BZ =
abs(Btang) *
sqrt(1. - Bucosphi_l * Bucosphi_l) * Bzusign_l;
483 MPI_Comm_rank(MPI_COMM_WORLD,&
myRank);
485 std::vector<CellID> refinedCells;
487 if(
myRank ==
MASTER_RANK) std::cout <<
"Maximum refinement level is " << mpiGrid.mapping.get_maximum_refinement_level() << std::endl;
501 std::array<double,3> xyz;
508 CellID myCell = mpiGrid.get_existing_cell(xyz);
509 mpiGrid.refine_completely(myCell);
514 refinedCells = mpiGrid.stop_refining();
515 if(
myRank ==
MASTER_RANK) std::cout <<
"Finished first level of refinement" << endl;
526 std::array<double,3> xyz;
533 CellID myCell = mpiGrid.get_existing_cell(xyz);
534 mpiGrid.refine_completely(myCell);
539 refinedCells = mpiGrid.stop_refining();
540 if(
myRank ==
MASTER_RANK) std::cout <<
"Finished second level of refinement" << endl;
551 std::array<double,3> xyz;
558 CellID myCell = mpiGrid.get_existing_cell(xyz);
559 mpiGrid.refine_completely(myCell);
564 refinedCells = mpiGrid.stop_refining();
565 if(
myRank ==
MASTER_RANK) std::cout <<
"Finished third level of refinement" << endl;
576 std::array<double,3> xyz;
583 CellID myCell = mpiGrid.get_existing_cell(xyz);
584 mpiGrid.refine_completely(myCell);
589 refinedCells = mpiGrid.stop_refining();
590 if(
myRank ==
MASTER_RANK) std::cout <<
"Finished fourth level of refinement" << endl;
sqrt(1.0+vA *vA/(c *c))) % Ion-acoustic wave cS
#define ARCH_INNER_BODY(...)
void setBackgroundFieldToZero(FieldSolverGrid &fsgrid, fsgrids::technicalspan technical, fsgrids::bgbspan bgb)
std::vector< IPShockSpeciesParameters > speciesParams
virtual Realf fillPhaseSpace(spatial_cell::SpatialCell *cell, const uint popID, const uint nRequested) const override
static void addParameters(void)
Real interpolate(Real u, Real d, Real x) const
virtual bool initialize(void) override
virtual Realf probePhaseSpace(spatial_cell::SpatialCell *cell, const uint popID, Real vx_in, Real vy_in, Real vz_in) const override
virtual std::vector< std::array< Real, 3 > > getV0(creal x, creal y, creal z, const uint popID) const override
Return a vector containing the velocity coordinate of the centre of each ion population in the distri...
virtual void getParameters(void) override
virtual void setProjectBField(fsgrids::perbspan perb, fsgrids::bgbspan bgb, fsgrids::technicalspan technical, FieldSolverGrid &fsgrid) override
virtual void calcCellParameters(spatial_cell::SpatialCell *cell, creal &t) override
bool refineSpatialCells(dccrg::Dccrg< spatial_cell::SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid) const override
virtual bool initialize()
virtual void getParameters()
vmesh::VelocityMesh * get_velocity_mesh(const size_t &popID)
vmesh::VelocityBlockContainer * get_velocity_blocks(const size_t &popID)
std::array< Real, CellParams::N_SPATIAL_CELL_PARAMS > parameters
vmesh::VelocityBlockContainer * dev_get_velocity_blocks(const size_t &popID)
vmesh::VelocityMesh * dev_get_velocity_mesh(const size_t &popID)
ARCH_HOSTDEV Realf * getData()
fsgrid::FsGrid< FS_STENCIL_WIDTH > FieldSolverGrid
ObjectWrapper & getObjectWrapper()
static void parallel_reduce(const uint(&limits)[NDim], Lambda loop_body, T &sum)
std::span< std::array< Real, fsgrids::bfield::N_BFIELD > > perbspan
std::span< technical > technicalspan
std::span< std::array< Real, bgbfield::N_BGB > > bgbspan
ARCH_HOSTDEV Realf MaxwellianPhaseSpaceDensity(creal &vx, creal &vy, creal &vz, creal &T, creal &rho, creal &mass)
std::vector< species::Species > particleSpecies
static int amrMaxSpatialRefLevel
static int amrMaxAllowedSpatialRefLevel
static ARCH_HOSTDEV VecSimple< T > abs(const VecSimple< T > &l)