54 this->
ALPHA *= M_PI / 4.0;
60 RP::add(
"test_fp.V0",
"Velocity magnitude (m/s)", 1.0e6);
61 RP::add(
"test_fp.B0",
"Magnetic field value in the non-zero patch (T)", 1.0e-9);
62 RP::add(
"test_fp.rho",
"Number density (m^-3)", 1.0e7);
63 RP::add(
"test_fp.Temperature",
"Temperature (K)", 1.0e-6);
64 RP::add(
"test_fp.angle",
"Orientation of the propagation expressed in pi/4", 0.0);
65 RP::add(
"test_fp.Bdirection",
"Direction of the magnetic field (0:x, 1:y, 2:z, 3:all)", 0);
66 RP::add(
"test_fp.shear",
"Add a shear (if false, V=0.5 everywhere).",
true);
74 std::cerr <<
"The selected project does not support multiple particle populations! Aborting in " << __FILE__ <<
" line " << __LINE__ << std::endl;
77 RP::get(
"test_fp.B0", this->
B0);
78 RP::get(
"test_fp.V0", this->
V0);
79 RP::get(
"test_fp.rho", this->
DENSITY);
81 RP::get(
"test_fp.angle", this->
ALPHA);
82 RP::get(
"test_fp.Bdirection", this->
CASE);
83 RP::get(
"test_fp.shear", this->
shear);
87 if (
abs(value) < 1e-5)
return 0.0;
88 else return value /
abs(value);
105 std::array<Real, 3> initV0 = this->
getV0(x, y, z, popID)[0];
106 const Real initV0X = initV0[0];
107 const Real initV0Y = initV0[1];
108 const Real initV0Z = initV0[2];
127 vmesh->getBlockInfo(blockGID,&blockCoords[0]);
128 creal vxBlock = blockCoords[0];
129 creal vyBlock = blockCoords[1];
130 creal vzBlock = blockCoords[2];
131 creal dvxCell = blockCoords[3];
132 creal dvyCell = blockCoords[4];
133 creal dvzCell = blockCoords[5];
135 creal vx = vxBlock + (
i+0.5)*dvxCell - initV0X;
136 creal vy = vyBlock + (
j+0.5)*dvyCell - initV0Y;
137 creal vz = vzBlock + (
k+0.5)*dvzCell - initV0Z;
163 std::array<Real, 3> initV0 = this->
getV0(x, y, z, popID)[0];
164 const Real initV0X = initV0[0];
165 const Real initV0Y = initV0[1];
166 const Real initV0Z = initV0[2];
168 creal vx = vx_in - initV0X;
169 creal vy = vy_in - initV0Y;
170 creal vz = vz_in - initV0Z;
181 const Real areaFactor = 1.0;
183 const auto B0_l = this->
B0;
184 const auto CASE_l = this->
CASE;
186 fsgrid.parallel_for([](
int timerId) -> phiprof::Timer {
return phiprof::Timer{timerId}; },
187 phiprof::initializeTimer(
"setProjectBField-loop"), technical,
188 [=](
const fsgrid::Coordinates &coordinates,
const fsgrid::FsStencil& stencil,
cuint sysBoundaryFlag,
cuint sysBoundaryLayer) {
189 const std::array<Real, 3> xyz = coordinates.getPhysicalCoords(stencil.i, stencil.j, stencil.k);
190 const std::array<Real, 3> gridSpacing = coordinates.physicalGridSpacing;
191 auto& cell = perb[stencil.ooo()];
193 creal dx = gridSpacing[0] * 3.5;
194 creal dy = gridSpacing[1] * 3.5;
195 creal dz = gridSpacing[2] * 3.5;
196 creal x = xyz[0] + 0.5 * gridSpacing[0];
197 creal y = xyz[1] + 0.5 * gridSpacing[1];
198 creal z = xyz[2] + 0.5 * gridSpacing[2];
203 if (y >= -dy && y <= dy) {
204 if (z >= -dz && z <= dz) {
211 if (x >= -
dx && x <=
dx) {
212 if (z >= -dz && z <= dz) {
219 if (x >= -
dx && x <=
dx) {
220 if (y >= -dy && y <= dy) {
231 if (y >= -dy && y <= dy) {
232 if (z >= -dz && z <= dz) {
236 if (x >= -
dx && x <=
dx) {
237 if (z >= -dz && z <= dz) {
241 if (x >= -
dx && x <=
dx) {
242 if (y >= -dy && y <= dy) {
265 vector<std::array<Real, 3>> centerPoints;
268 if (this->
shear ==
true)
272 switch (this->
CASE) {
275 eta = (-(y + 0.5 * dy) * sin(this->
ALPHA) + (z + 0.5 * dz) * cos(this->
ALPHA)) / (2.0 *
sqrt(2.0));
277 VY =
sign(cos(this->
ALPHA)) * 0.5 + 0.1*cos(this->
ALPHA) * sin(2.0 * M_PI * eta);
278 VZ =
sign(sin(this->
ALPHA)) * 0.5 + 0.1*sin(this->
ALPHA) * sin(2.0 * M_PI * eta);
282 eta = (-(z + 0.5 * dz) * sin(this->
ALPHA) + (x + 0.5 *
dx) * cos(this->
ALPHA)) / (2.0 *
sqrt(2.0));
283 VX =
sign(sin(this->
ALPHA)) * 0.5 + 0.1*sin(this->
ALPHA) * sin(2.0 * M_PI * eta);
285 VZ =
sign(cos(this->
ALPHA)) * 0.5 + 0.1*cos(this->
ALPHA) * sin(2.0 * M_PI * eta);
289 eta = (-(x + 0.5 *
dx) * sin(this->
ALPHA) + (y + 0.5 * dy) * cos(this->
ALPHA)) / (2.0 *
sqrt(2.0));
290 VX =
sign(cos(this->
ALPHA)) * 0.5 + 0.1*cos(this->
ALPHA) * sin(2.0 * M_PI * eta);
291 VY =
sign(sin(this->
ALPHA)) * 0.5 + 0.1*sin(this->
ALPHA) * sin(2.0 * M_PI * eta);
295 std::cerr <<
"not implemented in " << __FILE__ <<
":" << __LINE__ << std::endl;
300 switch (this->
CASE) {
324 VX *= this->
V0 * 2.0;
325 VY *= this->
V0 * 2.0;
326 VZ *= this->
V0 * 2.0;
328 std::array<Real, 3> point {{
VX,
VY,
VZ}};
329 centerPoints.push_back(point);
339 vector<std::array<Real, 3>> centerPoints;
345 return this->
getV0(x,y,z,
dx,dy,dz,popID);
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)
virtual bool initialize()
virtual void getParameters()
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 setProjectBField(fsgrids::perbspan perb, fsgrids::bgbspan bgb, fsgrids::technicalspan technical, FieldSolverGrid &fsgrid) override
virtual bool initialize(void) override
virtual void calcCellParameters(spatial_cell::SpatialCell *cell, creal &t) override
Real sign(creal value) const
virtual Realf fillPhaseSpace(spatial_cell::SpatialCell *cell, const uint popID, const uint nRequested) const override
static void addParameters(void)
virtual void getParameters(void) override
virtual Realf probePhaseSpace(spatial_cell::SpatialCell *cell, const uint popID, Real vx_in, Real vy_in, Real vz_in) const override
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 ARCH_HOSTDEV VecSimple< T > abs(const VecSimple< T > &l)