Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
53 changes: 53 additions & 0 deletions setups/tests/deposit/deposit-gr.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[simulation]
name = "deposit-test"
engine = "srpic"
runtime = 10.0

[grid]
resolution = [256, 256]
extent = [[0.0, 1.0], [0.0, 1.0]]

[grid.metric]
metric = "minkowski"

[grid.boundaries]
fields = [["PERIODIC"], ["PERIODIC"]]
particles = [["PERIODIC"], ["PERIODIC"]]

[scales]
larmor0 = 0.1
skindepth0 = 0.1

[algorithms]
current_filters = 4

[algorithms.timestep]
CFL = 0.5

[particles]
ppc0 = 10.0

[[particles.species]]
label = "e-"
mass = 1.0
charge = -1.0
maxnpart = 1e2

[[particles.species]]
label = "e+"
mass = 1.0
charge = 1.0
maxnpart = 1e2

[setup]

[output]
format = "hdf5"
interval_time = 0.01

[output.quantities]
quantities = ["N_1", "N_2", "E", "B", "J"]

[diagnostics]
colored_stdout = true
blocking_timers = true
69 changes: 69 additions & 0 deletions setups/tests/deposit/deposit-mink.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[simulation]
name = "deposit-test-mink"
engine = "srpic"
runtime = 10.0

[grid]
resolution = [512, 512]
extent = [[0.0, 1.0], [0.0, 1.0]]

[grid.metric]
metric = "minkowski"

[grid.boundaries]
fields = [["PERIODIC"], ["PERIODIC"]]
particles = [["PERIODIC"], ["PERIODIC"]]

[scales]
larmor0 = 0.1
skindepth0 = 0.1

[algorithms]
current_filters = 4

[algorithms.timestep]
CFL = 0.5

[particles]
ppc0 = 10.0

[[particles.species]]
label = "e-"
mass = 1.0
charge = -1.0
maxnpart = 1e2

[[particles.species]]
label = "e+"
mass = 1.0
charge = 1.0
maxnpart = 1e2

[setup]
x1s = [0.25]
y1s = [0.85]
z1s = [0.33]
ux1s = [0.6]
uy1s = [-0.3]
uz1s = [-0.2]

x2s = [0.25]
y2s = [0.85]
z2s = [0.33]
ux2s = [-0.2]
uy2s = [-0.2]
uz2s = [0.1]

[output]
format = "hdf5"
interval_time = 0.01

[output.fields]
quantities = ["N_1", "N_2", "E", "B", "J"]

[checkpoint]
keep = 0

[diagnostics]
colored_stdout = true
blocking_timers = true
53 changes: 53 additions & 0 deletions setups/tests/deposit/deposit-sr.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[simulation]
name = "deposit-test"
engine = "srpic"
runtime = 10.0

[grid]
resolution = [256, 256]
extent = [[0.0, 1.0], [0.0, 1.0]]

[grid.metric]
metric = "minkowski"

[grid.boundaries]
fields = [["PERIODIC"], ["PERIODIC"]]
particles = [["PERIODIC"], ["PERIODIC"]]

[scales]
larmor0 = 0.1
skindepth0 = 0.1

[algorithms]
current_filters = 4

[algorithms.timestep]
CFL = 0.5

[particles]
ppc0 = 10.0

[[particles.species]]
label = "e-"
mass = 1.0
charge = -1.0
maxnpart = 1e2

[[particles.species]]
label = "e+"
mass = 1.0
charge = 1.0
maxnpart = 1e2

[setup]

[output]
format = "hdf5"
interval_time = 0.01

[output.quantities]
quantities = ["N_1", "N_2", "E", "B", "J"]

[diagnostics]
colored_stdout = true
blocking_timers = true
116 changes: 43 additions & 73 deletions setups/tests/deposit/pgen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,8 @@
#include "enums.h"
#include "global.h"

#include "arch/kokkos_aliases.h"
#include "arch/traits.h"
#include "utils/comparators.h"
#include "utils/formatting.h"
#include "utils/log.h"
#include "utils/numeric.h"

#include "archetypes/energy_dist.h"
#include "archetypes/particle_injector.h"
#include "archetypes/problem_generator.h"
#include "framework/domain/domain.h"
Expand All @@ -26,10 +20,20 @@ namespace user {
struct PGen : public arch::ProblemGenerator<S, M> {

// compatibility traits for the problem generator
static constexpr auto engines = traits::compatible_with<SimEngine::SRPIC>::value;
static constexpr auto metrics = traits::compatible_with<Metric::Minkowski>::value;
static constexpr auto dimensions =
traits::compatible_with<Dim::_1D, Dim::_2D, Dim::_3D>::value;
static constexpr auto engines {
traits::compatible_with<SimEngine::SRPIC, SimEngine::GRPIC>::value
};
static constexpr auto metrics {
traits::compatible_with<Metric::Minkowski,
Metric::Spherical,
Metric::QSpherical,
Metric::Kerr_Schild,
Metric::QKerr_Schild,
Metric::Kerr_Schild_0>::value
};
static constexpr auto dimensions {
traits::compatible_with<Dim::_1D, Dim::_2D, Dim::_3D>::value
};

// for easy access to variables in the child class
using arch::ProblemGenerator<S, M>::D;
Expand All @@ -47,85 +51,51 @@ namespace user {
const auto x1s = params.template get<std::vector<real_t>>("setup.x1s", empty);
const auto y1s = params.template get<std::vector<real_t>>("setup.y1s", empty);
const auto z1s = params.template get<std::vector<real_t>>("setup.z1s", empty);
const auto ux1s = params.template get<std::vector<real_t>>("setup.ux1s",
const auto phi1s = params.template get<std::vector<real_t>>("setup.phi1s",
empty);
const auto ux1s = params.template get<std::vector<real_t>>("setup.ux1s",
empty);
const auto uy1s = params.template get<std::vector<real_t>>("setup.uy1s",
const auto uy1s = params.template get<std::vector<real_t>>("setup.uy1s",
empty);
const auto uz1s = params.template get<std::vector<real_t>>("setup.uz1s",
const auto uz1s = params.template get<std::vector<real_t>>("setup.uz1s",
empty);

const auto x2s = params.template get<std::vector<real_t>>("setup.x2s", empty);
const auto y2s = params.template get<std::vector<real_t>>("setup.y2s", empty);
const auto z2s = params.template get<std::vector<real_t>>("setup.z2s", empty);
const auto ux2s = params.template get<std::vector<real_t>>("setup.ux2s",
const auto ux2s = params.template get<std::vector<real_t>>("setup.ux2s",
empty);
const auto uy2s = params.template get<std::vector<real_t>>("setup.uy2s",
const auto uy2s = params.template get<std::vector<real_t>>("setup.uy2s",
empty);
const auto uz2s = params.template get<std::vector<real_t>>("setup.uz2s",
const auto uz2s = params.template get<std::vector<real_t>>("setup.uz2s",
empty);
// std::vector<real_t> x, y, z, ux_1, uy_1, uz_1, ux_2, uy_2, uz_2;
// x.push_back(0.85);
// x.push_back(0.123);
// if constexpr (D == Dim::_2D || D == Dim::_3D) {
// y.push_back(0.32);
// y.push_back(0.321);
// }
// if constexpr (D == Dim::_3D) {
// z.push_back(0.231);
// z.push_back(0.687);
// }
// ux_1.push_back(1.0);
// uy_1.push_back(-1.0);
// uz_1.push_back(0.0);
// ux_1.push_back(1.0);
// uy_1.push_back(-2.0);
// uz_1.push_back(1.0);
//
// ux_2.push_back(1.0);
// uy_2.push_back(1.0);
// uz_2.push_back(0.0);
// ux_2.push_back(-2.0);
// uy_2.push_back(3.0);
// uz_2.push_back(-1.0);
//
const std::map<std::string, std::vector<real_t>> data_1 {
{ "x1", x1s},
{ "x2", y1s},
{ "x3", z1s},
{"ux1", ux1s},
{"ux2", uy1s},
{"ux3", uz1s}
const auto phi2s = params.template get<std::vector<real_t>>("setup.phi2s",
empty);
std::map<std::string, std::vector<real_t>> data_1 {
{ "x1", x1s },
{ "x2", y1s },
{ "ux1", ux1s },
{ "ux2", uy1s },
{ "ux3", uz1s }
};
const std::map<std::string, std::vector<real_t>> data_2 {
{ "x1", x2s},
{ "x2", y2s},
{ "x3", z2s},
{"ux1", ux2s},
{"ux2", uy2s},
{"ux3", uz2s}
std::map<std::string, std::vector<real_t>> data_2 {
{ "x1", x2s },
{ "x2", y2s },
{ "ux1", ux2s },
{ "ux2", uy2s },
{ "ux3", uz2s }
};
if constexpr (M::CoordType == Coord::Cart or D == Dim::_3D) {
data_1["x3"] = z1s;
data_2["x3"] = z2s;
} else if constexpr (D == Dim::_2D) {
data_1["phi"] = phi1s;
data_2["phi"] = phi2s;
}

arch::InjectGlobally<S, M>(global_domain, local_domain, (arch::spidx_t)1, data_1);
arch::InjectGlobally<S, M>(global_domain, local_domain, (arch::spidx_t)2, data_2);
}

// void CustomPostStep(std::size_t, long double time, Domain<S, M>& domain) {
// if (time >= 0.1) {
// for (auto& species : domain.species) {
// auto ux1 = species.ux1;
// auto ux2 = species.ux2;
// auto ux3 = species.ux3;
// Kokkos::parallel_for(
// "Stop",
// species.rangeActiveParticles(),
// Lambda(index_t p) {
// ux1(p) = ZERO;
// ux2(p) = ZERO;
// ux3(p) = ZERO;
// });
// }
// }
// }
};

} // namespace user
Expand Down
18 changes: 9 additions & 9 deletions src/framework/domain/communications.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ namespace ntt {
using comm_params_t = std::pair<address_t, std::vector<range_tuple_t>>;

template <SimEngine::type S, class M>
auto GetSendRecvRanks(Metadomain<S, M>* metadomain,
Domain<S, M>& domain,
dir::direction_t<M::Dim> direction)
-> std::pair<address_t, address_t> {
auto GetSendRecvRanks(
Metadomain<S, M>* metadomain,
Domain<S, M>& domain,
dir::direction_t<M::Dim> direction) -> std::pair<address_t, address_t> {
Domain<S, M>* send_to_nghbr_ptr = nullptr;
Domain<S, M>* recv_from_nghbr_ptr = nullptr;
// set pointers to the correct send/recv domains
Expand Down Expand Up @@ -119,11 +119,11 @@ namespace ntt {
}

template <SimEngine::type S, class M>
auto GetSendRecvParams(Metadomain<S, M>* metadomain,
Domain<S, M>& domain,
dir::direction_t<M::Dim> direction,
bool synchronize)
-> std::pair<comm_params_t, comm_params_t> {
auto GetSendRecvParams(
Metadomain<S, M>* metadomain,
Domain<S, M>& domain,
dir::direction_t<M::Dim> direction,
bool synchronize) -> std::pair<comm_params_t, comm_params_t> {
const auto [send_indrank,
recv_indrank] = GetSendRecvRanks(metadomain, domain, direction);
const auto [send_ind, send_rank] = send_indrank;
Expand Down
Loading