Skip to content
Merged

GR #83

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
239 commits
Select commit Hold shift + click to select a range
1df0cce
compilable example for grpic
Sep 24, 2024
0c81d9b
starting a test pgen
alisagk Sep 24, 2024
fc126af
engines/grpic: added relevant libraries
alisagk Sep 24, 2024
c7fc87a
kernels/ampere_gr: fixed dublicate ErrorIF
alisagk Sep 24, 2024
d106f45
engines/grpic: minor syntax adustments to match engines/srpic
alisagk Sep 24, 2024
70fa507
engines/grpic: added initialisation of fields and boundary conditions
alisagk Sep 24, 2024
53e6861
engines/grpic: added cope of em field into em0
alisagk Sep 25, 2024
011e024
engines/grpic: added computation of aux fields
alisagk Sep 25, 2024
cdf69db
engines/grpis: fixed "aux" for passing to aux kernels, added Faraday …
alisagk Sep 25, 2024
e96b41c
minor: added a comment on Faraday step
alisagk Sep 25, 2024
ee95412
engines/grpic: bc for B&B0
alisagk Sep 25, 2024
25b4e76
engine/grpic: fixed passing ni2 to faraday kernel. prep for ampere ke…
alisagk Sep 25, 2024
9c04fe2
engines/grpic: added ampere and subsequent BC
alisagk Sep 25, 2024
f14b643
engine/grpic: added everything for initial step, except BC for aux
alisagk Sep 26, 2024
910e535
engines/grpis: minor update to first aux step for consistency
alisagk Sep 27, 2024
faf471b
engines/grpic: fixed ComputeAuxE function
alisagk Sep 27, 2024
dfe51f4
engines/grpic: fixed Faraday function
alisagk Sep 27, 2024
e57cbf8
engines/grpis: fixed Ampere function
alisagk Sep 27, 2024
eeac7ff
engines/grpic: added a class for field_bc to accomodate passing em, e…
alisagk Sep 27, 2024
c841400
engines/grpic: cut out 3d from absorb BCs
alisagk Sep 27, 2024
03b0559
minot: fix syntax
alisagk Sep 27, 2024
cbe2fee
minor: cut out options from gr_bc class
alisagk Sep 27, 2024
67ec720
minor: cut out gr_bc from most bc functions since only horizon bc nee…
alisagk Sep 27, 2024
34a42a4
engines/grpic: added gr_bc into step=0 functions
alisagk Sep 27, 2024
a3d5db8
engines/grpic: added BC for em0
alisagk Sep 27, 2024
313850b
added a kernel for OpenBoundaries
alisagk Sep 27, 2024
0d05349
engines/grpic: implemented function to call for OpenBoundaries_kernel
alisagk Sep 30, 2024
9c8efaa
enginesgrpic: added aux field boundaries calls to initial step
alisagk Sep 30, 2024
2569aec
added TimeAverageDB() and kernel for it in kernels/aux
alisagk Sep 30, 2024
3cac38a
engines/grpic: first half of the main step for field solver
alisagk Sep 30, 2024
386958f
added TimeAverageJ() and its kernel in kernels/aux
alisagk Sep 30, 2024
139d179
engines/grpic: added all steps relevant to field solver
alisagk Sep 30, 2024
52fb48b
engines/grpic: added function for Ampere currents
alisagk Sep 30, 2024
781bd42
see below -- added call from the time step
alisagk Sep 30, 2024
3615f79
engines/grpic: started ParticlePush
alisagk Oct 1, 2024
a3eba30
see below
alisagk Oct 1, 2024
1c62424
engines/grpic: added timers
alisagk Oct 1, 2024
ec795db
parameters: changed to requiring n=2 for GRPIC
alisagk Oct 1, 2024
bcc87d3
minor: fixed description for qkerr metric for h_tilde
alisagk Oct 1, 2024
4393c21
parameters: restored !=1
alisagk Oct 1, 2024
31582dc
archetypes/field_setter: fixed wrong conversion of theta and call for…
alisagk Oct 2, 2024
0901469
kernels/fields_bc: fixed if statement for open BC
alisagk Oct 2, 2024
f67d40f
kernels/fields_bc: added a separate kernel for aux fields
alisagk Oct 2, 2024
fd4c61f
see below
alisagk Oct 2, 2024
bbb2729
engines/grpic: also changed range for axis BC in this commit and comm…
alisagk Oct 2, 2024
8ef8b7f
engines/grpic: changed range for axis BC
alisagk Oct 2, 2024
67ad01a
updated pgen for wald
alisagk Oct 3, 2024
731559e
engines/grpic: adjusted ranges for all kernels
alisagk Oct 3, 2024
4ea3c9c
minor changes to kernels/fields_bc gr-specific
alisagk Oct 3, 2024
9b1f59f
wald: vertical potential setup
alisagk Oct 4, 2024
fca070f
kernel/ampere_gr: bug for theta=0
alisagk Oct 4, 2024
2a2a12f
kernels/faraday_gr: bug at i2min
alisagk Oct 4, 2024
2acf70b
kernels/aux: bugs in time averaging
alisagk Oct 4, 2024
1656da3
metric: kerr-schild a=0 minor fixes
alisagk Oct 5, 2024
c51f80c
minor kernels/aux_gr
alisagk Oct 18, 2024
be2ec2b
monor style
alisagk Oct 18, 2024
50dfdb3
engines/grpic: parameters for field boundaries
alisagk Oct 18, 2024
418d035
minor notes
alisagk Oct 21, 2024
117426a
implemented absorbing boundaries for gr
alisagk Oct 23, 2024
4abd107
working EM solver fully implemented
alisagk Oct 31, 2024
59be02a
compilible pusher in gr
alisagk Nov 5, 2024
fb0788b
consistent type for pusher_niter
alisagk Nov 6, 2024
619bacd
cleaned up an unused var
alisagk Nov 7, 2024
4835101
fixed bug in output for dimensions of coordinates of particles in GR
alisagk Nov 7, 2024
247177e
fixed coordinate transformation for a global injector. When we inject…
alisagk Nov 8, 2024
a33d664
minor consistensy with sr
alisagk Nov 8, 2024
702b013
kernels/particle_pusher_gr:
alisagk Dec 3, 2024
b58ede4
metrics: all gr metrics now have functional form of derivatives of th…
alisagk Dec 3, 2024
2edb197
setups/grpic/pusher: pgen and inputs for pusher tests
alisagk Dec 3, 2024
796cfcb
engines/grpic: added timestep correction for gr pusher
alisagk Dec 3, 2024
3d7e781
erased stretching of initial field
alisagk Dec 4, 2024
d0a4418
engines/grpic: updated routines for current (cur --> cur0) and added …
alisagk Dec 4, 2024
794beaa
BC for currents
alisagk Dec 4, 2024
28f590a
engines/grpic: discard first step if fieldsolver = false
alisagk Dec 6, 2024
6ad04be
GeodesicFullPush bug for utheta
alisagk Dec 6, 2024
9f34be4
minor gr pusher
alisagk Dec 11, 2024
e5b0267
pgen and inputs for pusher debugging updated
alisagk Dec 11, 2024
c9b70f5
boris tests with non-zero spin
alisagk Dec 16, 2024
668db7b
updated setups
alisagk Dec 17, 2024
98287db
engines/grpic: fixed the bug i introduced
alisagk Dec 18, 2024
fc48458
Delete setups/grpic/orbits directory
alisagk Dec 18, 2024
6c502a2
setups/grpic: updated setup for vacuum
alisagk Dec 18, 2024
1b81abe
updated setups
alisagk Dec 18, 2024
2e1cb0c
added separate setup for deposit debugging
alisagk Dec 18, 2024
58a3e5d
deleted deposit test from pusher tests
alisagk Dec 18, 2024
4466840
communication should be for j0 for GRPIC
alisagk Dec 18, 2024
ef83590
1. implemented working boundary conditions for currents,
alisagk Dec 18, 2024
03c0af1
improved setup for deposit testing
alisagk Dec 18, 2024
8faf543
minor fix for qks
alisagk Jan 2, 2025
b4a874e
minor for engines/grpic
alisagk Jan 2, 2025
d817b47
implementing threshold-dependent injection is in progress
alisagk Jan 3, 2025
1328097
updated pgen
alisagk Jan 3, 2025
a400ced
minor
alisagk Jan 3, 2025
5b653e0
implemented output of Aph for 2d GRPIC
alisagk Jan 9, 2025
c8c81c7
updated pgen for wald solution with plasma
alisagk Jan 9, 2025
2d9a0fa
gr minor
alisagk Jan 13, 2025
c836ceb
added an option for controlling initial B-field discretisation
alisagk Jan 14, 2025
1227bf6
grpic vacuum wald test improved
alisagk Jan 15, 2025
02c8d5e
kernels: all fields are absorbed in GR BC
alisagk Jan 15, 2025
df3be98
updated deposit setup
alisagk Jan 30, 2025
a9f25d2
engines/grpic: minor updates
alisagk Jan 30, 2025
05b9b86
compilable example for grpic
Sep 24, 2024
010d041
starting a test pgen
alisagk Sep 24, 2024
5efd556
engines/grpic: added relevant libraries
alisagk Sep 24, 2024
397a27f
kernels/ampere_gr: fixed dublicate ErrorIF
alisagk Sep 24, 2024
86b5a61
engines/grpic: minor syntax adustments to match engines/srpic
alisagk Sep 24, 2024
48095ee
engines/grpic: added initialisation of fields and boundary conditions
alisagk Sep 24, 2024
95efa49
engines/grpic: added cope of em field into em0
alisagk Sep 25, 2024
efcb68f
engines/grpic: added computation of aux fields
alisagk Sep 25, 2024
365d03b
engines/grpis: fixed "aux" for passing to aux kernels, added Faraday …
alisagk Sep 25, 2024
22262de
minor: added a comment on Faraday step
alisagk Sep 25, 2024
9912542
engines/grpic: bc for B&B0
alisagk Sep 25, 2024
50dcef8
engine/grpic: fixed passing ni2 to faraday kernel. prep for ampere ke…
alisagk Sep 25, 2024
215f3c5
engines/grpic: added ampere and subsequent BC
alisagk Sep 25, 2024
afc1620
engine/grpic: added everything for initial step, except BC for aux
alisagk Sep 26, 2024
f3496b9
engines/grpis: minor update to first aux step for consistency
alisagk Sep 27, 2024
2eaba26
engines/grpic: fixed ComputeAuxE function
alisagk Sep 27, 2024
7adc709
engines/grpic: fixed Faraday function
alisagk Sep 27, 2024
8c4451d
engines/grpis: fixed Ampere function
alisagk Sep 27, 2024
b4619de
engines/grpic: added a class for field_bc to accomodate passing em, e…
alisagk Sep 27, 2024
01c9d0d
engines/grpic: cut out 3d from absorb BCs
alisagk Sep 27, 2024
d1fce86
minot: fix syntax
alisagk Sep 27, 2024
8d410ad
minor: cut out options from gr_bc class
alisagk Sep 27, 2024
38931ab
minor: cut out gr_bc from most bc functions since only horizon bc nee…
alisagk Sep 27, 2024
de10607
engines/grpic: added gr_bc into step=0 functions
alisagk Sep 27, 2024
c4649f4
engines/grpic: added BC for em0
alisagk Sep 27, 2024
bb7afaf
added a kernel for OpenBoundaries
alisagk Sep 27, 2024
2a73574
engines/grpic: implemented function to call for OpenBoundaries_kernel
alisagk Sep 30, 2024
37a34ea
enginesgrpic: added aux field boundaries calls to initial step
alisagk Sep 30, 2024
454b590
added TimeAverageDB() and kernel for it in kernels/aux
alisagk Sep 30, 2024
fd5d1b4
engines/grpic: first half of the main step for field solver
alisagk Sep 30, 2024
5aba20a
added TimeAverageJ() and its kernel in kernels/aux
alisagk Sep 30, 2024
b5207e3
engines/grpic: added all steps relevant to field solver
alisagk Sep 30, 2024
4d1d0b0
engines/grpic: added function for Ampere currents
alisagk Sep 30, 2024
04201ce
see below -- added call from the time step
alisagk Sep 30, 2024
a673621
engines/grpic: started ParticlePush
alisagk Oct 1, 2024
76f4e81
see below
alisagk Oct 1, 2024
1d53dc9
engines/grpic: added timers
alisagk Oct 1, 2024
77b162f
parameters: changed to requiring n=2 for GRPIC
alisagk Oct 1, 2024
7176727
minor: fixed description for qkerr metric for h_tilde
alisagk Oct 1, 2024
df2a47d
parameters: restored !=1
alisagk Oct 1, 2024
baafca9
archetypes/field_setter: fixed wrong conversion of theta and call for…
alisagk Oct 2, 2024
c660f8a
kernels/fields_bc: fixed if statement for open BC
alisagk Oct 2, 2024
896c7f7
kernels/fields_bc: added a separate kernel for aux fields
alisagk Oct 2, 2024
cfa7003
see below
alisagk Oct 2, 2024
e2e91d2
engines/grpic: also changed range for axis BC in this commit and comm…
alisagk Oct 2, 2024
f277b2a
engines/grpic: changed range for axis BC
alisagk Oct 2, 2024
fce3b6e
updated pgen for wald
alisagk Oct 3, 2024
b1e4146
engines/grpic: adjusted ranges for all kernels
alisagk Oct 3, 2024
c2b00e0
minor changes to kernels/fields_bc gr-specific
alisagk Oct 3, 2024
693d67c
wald: vertical potential setup
alisagk Oct 4, 2024
7aea0ad
kernel/ampere_gr: bug for theta=0
alisagk Oct 4, 2024
0d011a1
kernels/faraday_gr: bug at i2min
alisagk Oct 4, 2024
1595432
kernels/aux: bugs in time averaging
alisagk Oct 4, 2024
c15b6cf
metric: kerr-schild a=0 minor fixes
alisagk Oct 5, 2024
5a81f69
minor kernels/aux_gr
alisagk Oct 18, 2024
fb95209
engines/grpic: parameters for field boundaries
alisagk Oct 18, 2024
ee2bd29
minor notes
alisagk Oct 21, 2024
dd7277c
implemented absorbing boundaries for gr
alisagk Oct 23, 2024
7aad0cc
working EM solver fully implemented
alisagk Oct 31, 2024
e761525
compilible pusher in gr
alisagk Nov 5, 2024
3fc4497
consistent type for pusher_niter
alisagk Nov 6, 2024
c7d78cd
cleaned up an unused var
alisagk Nov 7, 2024
8cc33c7
fixed bug in output for dimensions of coordinates of particles in GR
alisagk Nov 7, 2024
470f733
fixed coordinate transformation for a global injector. When we inject…
alisagk Nov 8, 2024
37c4b0d
minor consistensy with sr
alisagk Nov 8, 2024
2b2e6a9
kernels/particle_pusher_gr:
alisagk Dec 3, 2024
e69021a
metrics: all gr metrics now have functional form of derivatives of th…
alisagk Dec 3, 2024
05b30f8
setups/grpic/pusher: pgen and inputs for pusher tests
alisagk Dec 3, 2024
048dd57
engines/grpic: added timestep correction for gr pusher
alisagk Dec 3, 2024
a86182c
erased stretching of initial field
alisagk Dec 4, 2024
c1ed577
engines/grpic: updated routines for current (cur --> cur0) and added …
alisagk Dec 4, 2024
062a8b8
BC for currents
alisagk Dec 4, 2024
ca04d96
engines/grpic: discard first step if fieldsolver = false
alisagk Dec 6, 2024
30f87f4
GeodesicFullPush bug for utheta
alisagk Dec 6, 2024
1fd9cc2
minor gr pusher
alisagk Dec 11, 2024
cd11618
pgen and inputs for pusher debugging updated
alisagk Dec 11, 2024
9e3c47f
boris tests with non-zero spin
alisagk Dec 16, 2024
d0349bf
updated setups
alisagk Dec 17, 2024
1e1c50b
engines/grpic: fixed the bug i introduced
alisagk Dec 18, 2024
1aefb65
Delete setups/grpic/orbits directory
alisagk Dec 18, 2024
755aaa8
setups/grpic: updated setup for vacuum
alisagk Dec 18, 2024
ba72d3b
updated setups
alisagk Dec 18, 2024
70edd43
added separate setup for deposit debugging
alisagk Dec 18, 2024
50818fc
deleted deposit test from pusher tests
alisagk Dec 18, 2024
8e04145
communication should be for j0 for GRPIC
alisagk Dec 18, 2024
277bccf
1. implemented working boundary conditions for currents,
alisagk Dec 18, 2024
cc07d45
improved setup for deposit testing
alisagk Dec 18, 2024
d2df467
minor fix for qks
alisagk Jan 2, 2025
68aeddc
minor for engines/grpic
alisagk Jan 2, 2025
4e873ff
implementing threshold-dependent injection is in progress
alisagk Jan 3, 2025
32fcfaf
updated pgen
alisagk Jan 3, 2025
5ba8397
minor
alisagk Jan 3, 2025
fdf2e73
implemented output of Aph for 2d GRPIC
alisagk Jan 9, 2025
1d11b58
updated pgen for wald solution with plasma
alisagk Jan 9, 2025
5a72128
added an option for controlling initial B-field discretisation
alisagk Jan 14, 2025
9bc2f6d
grpic vacuum wald test improved
alisagk Jan 15, 2025
6505496
kernels: all fields are absorbed in GR BC
alisagk Jan 15, 2025
3cee9ad
fields_bcs
haykh Jan 30, 2025
6dcb21a
gr pusher: particles are deleted under the horizon when they reach N_…
alisagk Jan 30, 2025
a9fa292
Merge remote-tracking branch 'refs/remotes/origin/dev/gr-1.1.0' into …
alisagk Jan 30, 2025
4a18833
engines/grpic: adjustments after merging
alisagk Jan 30, 2025
a243e75
gr absorb BC for fields: minor, tanh is computed only once now
alisagk Jan 31, 2025
6c0ae14
dxmin compare between meshblocks
haykh Jan 31, 2025
fb0d706
dxmin compare between meshblocks (smaller precision)
haykh Jan 31, 2025
6cc29ac
bug in gr pusher -- BC at one of the axes
alisagk Jan 31, 2025
f861da4
vacuum wald setup updated after merging
alisagk Jan 31, 2025
2e4df9a
updated input for wald after merging
alisagk Jan 31, 2025
1460569
BCs for GR same as SR
haykh Jan 31, 2025
fe4bc15
Merge branch 'dev/gr-1.1.0' of github.com:entity-toolkit/entity into …
haykh Jan 31, 2025
043a1be
temporary hack for aux BCs (need to be done carefully)
haykh Jan 31, 2025
888c7de
changed BC flag to MATCH everywhere
alisagk Feb 18, 2025
61d735c
MATCH BCs
alisagk Feb 18, 2025
4a4f858
kernels/faraday_gr: bug -- set ghost cells between mesh boundaries
alisagk Mar 6, 2025
01aa65a
restored faraday_gr at i2=i2min because it was correct
alisagk Mar 10, 2025
2cee034
inj fixed
haykh Mar 12, 2025
26ea9a3
bug in polar_area qks
alisagk Apr 8, 2025
f4c9a6c
axis boundary conditions now match SRPIC
alisagk Apr 8, 2025
b430107
comm aux
haykh Apr 10, 2025
fbd6c26
proper ordering of comm vs flds
haykh Apr 10, 2025
4fc9809
updated wald setup
alisagk Apr 11, 2025
dd4f756
minor change in input
alisagk Apr 25, 2025
368b5a8
particles are now deleted when they cross ghost zone
alisagk Apr 25, 2025
7e73df9
updated horizon boundaries for fields
alisagk Apr 25, 2025
1d2bb1b
adjusted horizon BCs to work with nfilters>0; depleted aux horizon BCs
alisagk May 20, 2025
7ac1b68
adjusted engine accordingly (previous below)
alisagk May 20, 2025
3cfbb98
rebase with 1.2.0rc
haykh May 28, 2025
9ab8aa5
Merge branch '1.2.0rc' into dev/gr-1.1.0
haykh Jun 13, 2025
81cdc01
merge 1.2.0rc + pgens separation
haykh Jun 13, 2025
f667d72
ds param fix
haykh Jun 13, 2025
dcfea62
minor refactor + BCs aligned with sr
haykh Jun 14, 2025
7470a41
minor bug in AbsorbCur: sign < 0
alisagk Jun 14, 2025
ffe110c
(RUNTEST)
haykh Jun 15, 2025
d750384
minor bug in test for plaw dist GR
haykh Jun 15, 2025
9a4d2b6
minor nix-shell fix for newest HIP/ROCm
haykh Jun 15, 2025
1149632
minor bugfix in test for stats
haykh Jun 15, 2025
b581ba3
(RUNTEST)
haykh Jun 15, 2025
9d3a6e7
minor bug in parallel checkpoint test
haykh Jun 15, 2025
d50161f
fixed deposit test for dprec (RUNTEST)
haykh Jun 15, 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
4 changes: 3 additions & 1 deletion dev/nix/kokkos.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ let
getArch =
_:
if gpu != "NONE" && arch == "NATIVE" then
throw "Please specify an architecture when the GPU support is enabled. Available architectures: https://kokkos.org/kokkos-core-wiki/keywords.html#architectures"
throw "Please specify an architecture when the GPU support is enabled. Available architectures: https://kokkos.org/kokkos-core-wiki/get-started/configuration-guide.html#gpu-architectures"
else
arch;
cmakeExtraFlags = {
"HIP" = [
"-D Kokkos_ENABLE_HIP=ON"
"-D Kokkos_ARCH_${getArch { }}=ON"
# remove leading AMD_
"-D AMDGPU_TARGETS=${builtins.replaceStrings [ "amd_" ] [ "" ] (pkgs.lib.toLower (getArch { }))}"
"-D CMAKE_C_COMPILER=hipcc"
"-D CMAKE_CXX_COMPILER=hipcc"
];
Expand Down
85 changes: 85 additions & 0 deletions pgens/accretion/accretion.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
[simulation]
name = "wald"
engine = "grpic"
runtime = 500.0

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

[grid.metric]
metric = "qkerr_schild"
qsph_r0 = 0.0
qsph_h = 0.0
ks_a = 0.95

[grid.boundaries]
fields = [["MATCH"]]
particles = [["ABSORB"]]

[grid.boundaries.absorb]
ds = 1.0

[scales]
larmor0 = 0.025
skindepth0 = 0.5

[algorithms]
current_filters = 4

[algorithms.gr]
pusher_niter = 10
pusher_eps = 1e-2

[algorithms.timestep]
CFL = 0.5
correction = 1.0

[algorithms.toggles]
deposit = true
fieldsolver = true

[particles]
ppc0 = 4.0
use_weights = true
clear_interval = 100

[[particles.species]]
label = "e-"
mass = 1.0
charge = -1.0
maxnpart = 2e8
pusher = "Boris"

[[particles.species]]
label = "e+"
mass = 1.0
charge = 1.0
maxnpart = 2e8
pusher = "Boris"

[setup]
multiplicity = 1.0
sigma_max = 1000.0
temperature = 0.01
xi_min = [1.5, 0.0]
xi_max = [4.0, 3.14159265]
m_eps = 1.0

[output]
format = "hdf5"

[output.fields]
interval_time = 1.0
quantities = ["D", "B", "N_1", "N_2", "A"]

[output.particles]
enable = false

[output.spectra]
enable = false

[diagnostics]
interval = 2
colored_stdout = true
blocking_timers = true
281 changes: 281 additions & 0 deletions pgens/accretion/pgen.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,281 @@
#ifndef PROBLEM_GENERATOR_H
#define PROBLEM_GENERATOR_H

#include "enums.h"
#include "global.h"

#include "arch/kokkos_aliases.h"
#include "arch/traits.h"
#include "utils/numeric.h"

#include "archetypes/energy_dist.h"
#include "archetypes/particle_injector.h"
#include "archetypes/problem_generator.h"
#include "archetypes/spatial_dist.h"
#include "framework/domain/metadomain.h"

#include "kernels/particle_moments.hpp"

namespace user {
using namespace ntt;

template <class M, Dimension D>
struct InitFields {
InitFields(M metric_, real_t m_eps) : metric { metric_ }, m_eps { m_eps } {}

Inline auto A_3(const coord_t<D>& x_Cd) const -> real_t {
return HALF * (metric.template h_<3, 3>(x_Cd) +
TWO * metric.spin() * metric.template h_<1, 3>(x_Cd) *
metric.beta1(x_Cd));
}

Inline auto A_1(const coord_t<D>& x_Cd) const -> real_t {
return HALF * (metric.template h_<1, 3>(x_Cd) +
TWO * metric.spin() * metric.template h_<1, 1>(x_Cd) *
metric.beta1(x_Cd));
}

Inline auto A_0(const coord_t<D>& x_Cd) const -> real_t {
real_t g_00 { -metric.alpha(x_Cd) * metric.alpha(x_Cd) +
metric.template h_<1, 1>(x_Cd) * metric.beta1(x_Cd) *
metric.beta1(x_Cd) };
return HALF * (metric.template h_<1, 3>(x_Cd) * metric.beta1(x_Cd) +
TWO * metric.spin() * g_00);
}

Inline auto bx1(const coord_t<D>& x_Ph) const -> real_t { // at ( i , j + HALF )
coord_t<D> xi { ZERO }, x0m { ZERO }, x0p { ZERO };
metric.template convert<Crd::Ph, Crd::Cd>(x_Ph, xi);

x0m[0] = xi[0];
x0m[1] = xi[1] - HALF * m_eps;
x0p[0] = xi[0];
x0p[1] = xi[1] + HALF * m_eps;

real_t inv_sqrt_detH_ijP { ONE / metric.sqrt_det_h({ xi[0], xi[1] }) };

if (cmp::AlmostZero(x_Ph[1])) {
return ONE;
} else {
return (A_3(x0p) - A_3(x0m)) * inv_sqrt_detH_ijP / m_eps;
}
}

Inline auto bx2(const coord_t<D>& x_Ph) const -> real_t { // at ( i + HALF , j )
coord_t<D> xi { ZERO }, x0m { ZERO }, x0p { ZERO };
metric.template convert<Crd::Ph, Crd::Cd>(x_Ph, xi);

x0m[0] = xi[0] - HALF * m_eps;
x0m[1] = xi[1];
x0p[0] = xi[0] + HALF * m_eps;
x0p[1] = xi[1];

real_t inv_sqrt_detH_ijP { ONE / metric.sqrt_det_h({ xi[0], xi[1] }) };
if (cmp::AlmostZero(x_Ph[1])) {
return ZERO;
} else {
return -(A_3(x0p) - A_3(x0m)) * inv_sqrt_detH_ijP / m_eps;
}
}

Inline auto bx3(const coord_t<D>& x_Ph) const -> real_t {
return ZERO;
}

Inline auto dx1(const coord_t<D>& x_Ph) const -> real_t {
return ZERO;
}

Inline auto dx2(const coord_t<D>& x_Ph) const -> real_t {
return ZERO;
}

Inline auto dx3(const coord_t<D>& x_Ph) const -> real_t {
return ZERO;
}

private:
const M metric;
const real_t m_eps;
};

template <SimEngine::type S, class M>
struct PointDistribution : public arch::SpatialDistribution<S, M> {
PointDistribution(const std::vector<real_t>& xi_min,
const std::vector<real_t>& xi_max,
const real_t sigma_thr,
const real_t dens_thr,
const SimulationParams& params,
Domain<S, M>* domain_ptr)
: arch::SpatialDistribution<S, M> { domain_ptr->mesh.metric }
, metric { domain_ptr->mesh.metric }
, EM { domain_ptr->fields.em }
, density { domain_ptr->fields.buff }
, sigma_thr { sigma_thr }
, inv_n0 { ONE / params.template get<real_t>("scales.n0") }
, dens_thr { dens_thr } {
std::copy(xi_min.begin(), xi_min.end(), x_min);
std::copy(xi_max.begin(), xi_max.end(), x_max);

std::vector<unsigned short> specs {};
for (auto& sp : domain_ptr->species) {
if (sp.mass() > 0) {
specs.push_back(sp.index());
}
}

Kokkos::deep_copy(density, ZERO);
auto scatter_buff = Kokkos::Experimental::create_scatter_view(density);
// some parameters
auto& mesh = domain_ptr->mesh;
const auto use_weights = params.template get<bool>(
"particles.use_weights");
const auto ni2 = mesh.n_active(in::x2);

for (const auto& sp : specs) {
auto& prtl_spec = domain_ptr->species[sp - 1];
// clang-format off
Kokkos::parallel_for(
"ComputeMoments",
prtl_spec.rangeActiveParticles(),
kernel::ParticleMoments_kernel<S, M, FldsID::Rho, 3>({}, scatter_buff, 0u,
prtl_spec.i1, prtl_spec.i2, prtl_spec.i3,
prtl_spec.dx1, prtl_spec.dx2, prtl_spec.dx3,
prtl_spec.ux1, prtl_spec.ux2, prtl_spec.ux3,
prtl_spec.phi, prtl_spec.weight, prtl_spec.tag,
prtl_spec.mass(), prtl_spec.charge(),
use_weights,
metric, mesh.flds_bc(),
ni2, inv_n0, ZERO));
// clang-format on
}
Kokkos::Experimental::contribute(density, scatter_buff);
}

Inline auto sigma_crit(const coord_t<M::Dim>& x_Ph) const -> bool {
coord_t<M::Dim> xi { ZERO };
if constexpr (M::Dim == Dim::_2D) {
metric.template convert<Crd::Ph, Crd::Cd>(x_Ph, xi);
const auto i1 = static_cast<int>(xi[0]) + static_cast<int>(N_GHOSTS);
const auto i2 = static_cast<int>(xi[1]) + static_cast<int>(N_GHOSTS);
const vec_t<Dim::_3D> B_cntrv { EM(i1, i2, em::bx1),
EM(i1, i2, em::bx2),
EM(i1, i2, em::bx3) };
const vec_t<Dim::_3D> D_cntrv { EM(i1, i2, em::dx1),
EM(i1, i2, em::dx2),
EM(i1, i2, em::dx3) };
vec_t<Dim::_3D> B_cov { ZERO };
metric.template transform<Idx::U, Idx::D>(xi, B_cntrv, B_cov);
const auto bsqr =
DOT(B_cntrv[0], B_cntrv[1], B_cntrv[2], B_cov[0], B_cov[1], B_cov[2]);
const auto dens = density(i1, i2, 0);
return (bsqr > sigma_thr * dens) || (dens < dens_thr);
}
return false;
}

Inline auto operator()(const coord_t<M::Dim>& x_Ph) const -> real_t override {
auto fill = true;
for (auto d = 0u; d < M::Dim; ++d) {
fill &= x_Ph[d] > x_min[d] and x_Ph[d] < x_max[d] and sigma_crit(x_Ph);
}
return fill ? ONE : ZERO;
}

private:
tuple_t<real_t, M::Dim> x_min;
tuple_t<real_t, M::Dim> x_max;
const real_t sigma_thr;
const real_t dens_thr;
const real_t inv_n0;
Domain<S, M>* domain_ptr;
ndfield_t<M::Dim, 3> density;
ndfield_t<M::Dim, 6> EM;
const M metric;
};

template <SimEngine::type S, class M>
struct PGen : public arch::ProblemGenerator<S, M> {
// compatibility traits for the problem generator
static constexpr auto engines { traits::compatible_with<SimEngine::GRPIC>::value };
static constexpr auto metrics {
traits::compatible_with<Metric::Kerr_Schild, Metric::QKerr_Schild, Metric::Kerr_Schild_0>::value
};
static constexpr auto dimensions { traits::compatible_with<Dim::_2D>::value };

// for easy access to variables in the child class
using arch::ProblemGenerator<S, M>::D;
using arch::ProblemGenerator<S, M>::C;
using arch::ProblemGenerator<S, M>::params;

const std::vector<real_t> xi_min;
const std::vector<real_t> xi_max;
const real_t sigma0, sigma_max, multiplicity, nGJ, temperature, m_eps;

InitFields<M, D> init_flds;
const Metadomain<S, M>* metadomain;

inline PGen(SimulationParams& p, const Metadomain<S, M>& m)
: arch::ProblemGenerator<S, M>(p)
, xi_min { p.template get<std::vector<real_t>>("setup.xi_min") }
, xi_max { p.template get<std::vector<real_t>>("setup.xi_max") }
, sigma_max { p.template get<real_t>("setup.sigma_max") }
, sigma0 { p.template get<real_t>("scales.sigma0") }
, multiplicity { p.template get<real_t>("setup.multiplicity") }
, nGJ { p.template get<real_t>("scales.B0") *
SQR(p.template get<real_t>("scales.skindepth0")) }
, temperature { p.template get<real_t>("setup.temperature") }
, m_eps { p.template get<real_t>("setup.m_eps") }
, init_flds { m.mesh().metric, m_eps }
, metadomain { &m } {}

inline void InitPrtls(Domain<S, M>& local_domain) {
const auto energy_dist = arch::Maxwellian<S, M>(local_domain.mesh.metric,
local_domain.random_pool,
temperature);
const auto spatial_dist = PointDistribution<S, M>(xi_min,
xi_max,
sigma_max / sigma0,
multiplicity * nGJ,
params,
&local_domain);

const auto injector =
arch::NonUniformInjector<S, M, arch::Maxwellian, PointDistribution>(
energy_dist,
spatial_dist,
{ 1, 2 });
arch::InjectNonUniform<S, M, decltype(injector)>(params,
local_domain,
injector,
1.0,
true);
}

void CustomPostStep(std::size_t, long double time, Domain<S, M>& local_domain) {
const auto energy_dist = arch::Maxwellian<S, M>(local_domain.mesh.metric,
local_domain.random_pool,
temperature);
const auto spatial_dist = PointDistribution<S, M>(xi_min,
xi_max,
sigma_max / sigma0,
multiplicity * nGJ,
params,
&local_domain);

const auto injector =
arch::NonUniformInjector<S, M, arch::Maxwellian, PointDistribution>(
energy_dist,
spatial_dist,
{ 1, 2 });
arch::InjectNonUniform<S, M, decltype(injector)>(params,
local_domain,
injector,
1.0,
true);
}
};

} // namespace user

#endif
Loading