Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5ed7c6b
+test_bnd_prt_inflow: copy from test_mparticles for now
JamesMcClung Mar 26, 2025
48368e1
test_bnd_prt_inflow: rm vpic stuff
JamesMcClung Mar 26, 2025
84fb632
test_bnd_prt_inflow: bring back TestSetupParticles
JamesMcClung Mar 26, 2025
5557cca
particle: impl operator<< for Inject
JamesMcClung Mar 26, 2025
5bab7aa
test_bnd_prt_inflow: test prt from setupParticle
JamesMcClung Mar 26, 2025
da2d632
setup_particles: use Double3 in npt
JamesMcClung Mar 26, 2025
cd8bb52
test_bnd_prt_inflow: test createMaxwellian
JamesMcClung Mar 26, 2025
1357f4e
test_bnd_prt_inflow: test AdvanceParticle.push_x
JamesMcClung Mar 26, 2025
7e4b07d
test_bnd_prt_inflow: factor out Inflow class
JamesMcClung Mar 26, 2025
b4e0eff
test_bnd_prt_inflow: optimizations
JamesMcClung Mar 26, 2025
ac56f54
test_bnd_prt_inflow: +inject_into and test
JamesMcClung Mar 26, 2025
c384c49
test_bnd_prt_inflow: use TestInjector
JamesMcClung Mar 26, 2025
2c00b52
test_bnd_prt_inflow: take cell_idx
JamesMcClung Mar 26, 2025
8a34d88
test_bnd_prt_inflow: take offset_in_cell_dist
JamesMcClung Mar 26, 2025
6a5974c
setup_particles: +getWeight
JamesMcClung Mar 26, 2025
eca9745
test_bnd_prt_inflow: loop over n_in_cell
JamesMcClung Mar 26, 2025
40ae798
test_bnd_prt_inflow: adjust numbers
JamesMcClung Mar 26, 2025
1b25481
test_bnd_prt_inflow: filter out prts not in domain
JamesMcClung Mar 26, 2025
e6b513e
test_bnd_prt_inflow: +inject_into_patch
JamesMcClung Mar 26, 2025
6466057
test_bnd_prt_inflow: +inject_into_boundary
JamesMcClung Mar 27, 2025
2a18944
test_bnd_prt_inflow: put offset_in_cell_dist in ctor
JamesMcClung Mar 27, 2025
cba843a
test_bnd_prt_inflow: mv getWeight call out of loop
JamesMcClung Mar 27, 2025
22cd653
test_bnd_prt_inflow: support other inj dims
JamesMcClung Mar 27, 2025
d75f2af
test_bnd_prt_inflow: +InjectIntoBoundaryZ
JamesMcClung Mar 27, 2025
2d5b5e1
test_bnd_prt_inflow: infer inj_dim from template
JamesMcClung Mar 27, 2025
14b76df
test_bnd_prt_inflow: rm/rename some tests
JamesMcClung Mar 27, 2025
207af5e
test_bnd_prt_inflow: make inj_dim_idx_ static
JamesMcClung Mar 28, 2025
06761a1
test_bnd_prt_inflow: rename to INJECT_DIM_IDX_
JamesMcClung Mar 28, 2025
05e2f55
test_bnd_prt_inflow: make half() static
JamesMcClung Mar 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/include/particle.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,11 @@ struct Inject

} // namespace particle
} // namespace psc

inline std::ostream& operator<<(std::ostream& os,
const psc::particle::Inject& inj)
{
os << "Inject{x=" << inj.x << ", u=" << inj.u << ", w=" << inj.w
<< ", kind=" << inj.kind << ", tag=" << inj.tag << "}";
return os;
}
27 changes: 17 additions & 10 deletions src/include/setup_particles.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

struct psc_particle_npt
{
int kind; ///< particle kind
double n; ///< density
double p[3]; ///< momentum
double T[3]; ///< temperature
int kind; ///< particle kind
double n; ///< density
Double3 p; ///< momentum
Double3 T; ///< temperature
psc::particle::Tag tag;
};

Expand Down Expand Up @@ -241,6 +241,18 @@ struct SetupParticles
});
}

// ----------------------------------------------------------------------
// getWeight

real_t getWeight(const psc_particle_np& np, int n_in_cell)
{
if (fractional_n_particles_per_cell) {
return 1.;
} else {
return np.n / (n_in_cell * norm_.cori);
}
}

// ----------------------------------------------------------------------
// setupParticles

Expand Down Expand Up @@ -269,12 +281,7 @@ struct SetupParticles
op_cellwise(grid, p, init_np,
[&](int n_in_cell, psc_particle_np& np, Double3& pos) {
for (int cnt = 0; cnt < n_in_cell; cnt++) {
real_t wni;
if (fractional_n_particles_per_cell) {
wni = 1.;
} else {
wni = np.n / (n_in_cell * norm_.cori);
}
real_t wni = getWeight(np, n_in_cell);
auto prt = setupParticle(np, pos, wni);
injector(prt);
}
Expand Down
1 change: 1 addition & 0 deletions src/libpsc/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ add_psc_test(test_output_particles)
add_psc_test(test_mfields)
add_psc_test(test_mfields_cuda)
add_psc_test(test_bnd)
add_psc_test(test_bnd_prt_inflow)
add_psc_test(test_deposit)
add_psc_test(test_current_deposition)
add_psc_test(test_push_particles)
Expand Down
Loading