From 490451dd3552d7121cecdb368f13aa1e692a1097 Mon Sep 17 00:00:00 2001 From: Cameron Yang Date: Thu, 14 Nov 2019 13:59:56 -0800 Subject: Added +/- settings for .bulk_vel_dir (previously .direction) --- Source/Initialization/PlasmaInjector.cpp | 38 +++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 10 deletions(-) (limited to 'Source/Initialization/PlasmaInjector.cpp') diff --git a/Source/Initialization/PlasmaInjector.cpp b/Source/Initialization/PlasmaInjector.cpp index 300c41f7b..85c089c3f 100644 --- a/Source/Initialization/PlasmaInjector.cpp +++ b/Source/Initialization/PlasmaInjector.cpp @@ -275,17 +275,26 @@ void PlasmaInjector::parseMomentum (ParmParse& pp) int dir = 0; std::string direction = "x"; pp.query("beta", beta); + if(beta < 0){ + amrex::Abort("Please enter a positive beta value. Drift direction is set with .bulk_vel_dir = 'x' or '+x', '-x', 'y' or '+y', etc."); + } pp.query("theta", theta); - pp.query("direction", direction); - if(direction == "x" || direction == "X"){ + pp.query("bulk_vel_dir", direction); + if(direction[0] == '-'){ + beta = -beta; + } + if((direction == "x" || direction[1] == 'x') || + (direction == "X" || direction[1] == 'X')){ dir = 0; - } else if (direction == "y" || direction == "Y"){ + } else if ((direction == "y" || direction[1] == 'y') || + (direction == "Y" || direction[1] == 'Y')){ dir = 1; - } else if (direction == "z" || direction == "Z"){ + } else if ((direction == "z" || direction[1] == 'z') || + (direction == "Z" || direction[1] == 'Z')){ dir = 2; } else{ std::stringstream stringstream; - stringstream << "Direction " << direction << " is not recognzied. Please enter x, y, or z."; + stringstream << "Cannot interpret .bulk_vel_dir input '" << direction << "'. Please enter +/- x, y, or z with no whitespace between the sign and other character."; direction = stringstream.str(); amrex::Abort(direction.c_str()); } @@ -297,17 +306,26 @@ void PlasmaInjector::parseMomentum (ParmParse& pp) int dir = 0; std::string direction = "x"; pp.query("beta", beta); + if(beta < 0){ + amrex::Abort("Please enter a positive beta value. Drift direction is set with .bulk_vel_dir = 'x' or '+x', '-x', 'y' or '+y', etc."); + } pp.query("theta", theta); - pp.query("direction", direction); - if(direction == "x" || direction == "X"){ + pp.query("bulk_vel_dir", direction); + if(direction[0] == '-'){ + beta = -beta; + } + if((direction == "x" || direction[1] == 'x') || + (direction == "X" || direction[1] == 'X')){ dir = 0; - } else if (direction == "y" || direction == "Y"){ + } else if ((direction == "y" || direction[1] == 'y') || + (direction == "Y" || direction[1] == 'Y')){ dir = 1; - } else if (direction == "z" || direction == "Z"){ + } else if ((direction == "z" || direction[1] == 'z') || + (direction == "Z" || direction[1] == 'Z')){ dir = 2; } else{ std::stringstream stringstream; - stringstream << "Direction " << direction << " is not recognzied. Please enter x, y, or z."; + stringstream << "Cannot interpret .bulk_vel_dir input '" << direction << "'. Please enter +/- x, y, or z with no whitespace between the sign and other character."; direction = stringstream.str(); amrex::Abort(direction.c_str()); } -- cgit v1.2.3 From 6c0b080598b8d34abb29f254b5e82d3f7dce38ec Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Thu, 19 Dec 2019 17:06:54 -0800 Subject: splitting distance depends on ppc only if uniform per cell --- Source/Initialization/PlasmaInjector.cpp | 1 + Source/Particles/PhysicalParticleContainer.cpp | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'Source/Initialization/PlasmaInjector.cpp') diff --git a/Source/Initialization/PlasmaInjector.cpp b/Source/Initialization/PlasmaInjector.cpp index 5464430cf..261a14fc5 100644 --- a/Source/Initialization/PlasmaInjector.cpp +++ b/Source/Initialization/PlasmaInjector.cpp @@ -109,6 +109,7 @@ PlasmaInjector::PlasmaInjector (int ispecies, const std::string& name) part_pos_s.end(), part_pos_s.begin(), ::tolower); + num_particles_per_cell_each_dim.assign(3, 0); if (part_pos_s == "python") { return; } else if (part_pos_s == "singleparticle") { diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index d5c08074a..de0f0a813 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -1431,15 +1431,19 @@ PhysicalParticleContainer::SplitParticles(int lev) { pti.GetPosition(xp, yp, zp); - // offset for split particles is computed as a function of cell size - // and number of particles per cell, so that a uniform distribution - // before splitting results in a uniform distribution after splitting const amrex::Vector ppc_nd = plasma_injector->num_particles_per_cell_each_dim; const std::array& dx = WarpX::CellSize(lev); amrex::Vector split_offset = {dx[0]/2._rt/ppc_nd[0], dx[1]/2._rt/ppc_nd[1], dx[2]/2._rt/ppc_nd[2]}; - + if (ppc_nd[0] > 0){ + // offset for split particles is computed as a function of cell size + // and number of particles per cell, so that a uniform distribution + // before splitting results in a uniform distribution after splitting + split_offset[0] /= ppc_nd[0]; + split_offset[1] /= ppc_nd[1]; + split_offset[2] /= ppc_nd[2]; + } // particle Array Of Structs data auto& particles = pti.GetArrayOfStructs(); // particle Struct Of Arrays data -- cgit v1.2.3