Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
220 commits
Select commit Hold shift + click to select a range
a8f228d
First commit of the "Get'EM Back" project!
Antoinehoff Oct 11, 2025
007a639
Merge remote-tracking branch 'origin/main' into get_em_back
Antoinehoff Oct 11, 2025
1291837
fix merge conflicts
Antoinehoff Oct 11, 2025
033255e
rename apardot output file name from "dapartdt" to "apardot"
Antoinehoff Oct 14, 2025
6cdedc0
add BC for ampere and ohm laws, fix the acquisition of apar and apard…
Antoinehoff Oct 14, 2025
0cf7fa4
typo in m0_gyroavg (.marr stayed)
Antoinehoff Oct 14, 2025
509c55b
fix host array alloc and add a boolean to check if the field is em in…
Antoinehoff Oct 14, 2025
355f6f9
add diagnostic for integrated Apar energy.
Antoinehoff Oct 15, 2025
ec3574b
Merge branch 'get_em_back' of https://github.com/ammarhakim/gkeyll in…
Antoinehoff Oct 15, 2025
d426e40
remove unused arrays
Antoinehoff Oct 15, 2025
255ac96
bufix: move the apar enery dynvec inside the if em statement.
Antoinehoff Oct 15, 2025
3be111e
kSq in the Ohm's law fem_poisson_perp solver is now updated by releas…
Antoinehoff Oct 15, 2025
5819a15
need to pass bc in the structure to do the release remake poisson per…
Antoinehoff Oct 15, 2025
952e1ee
Add 1x solvers for EM, refactor a few arrays, remove unused ones, add…
Antoinehoff Oct 17, 2025
5a45f77
Unstable: Merge remote-tracking branch 'origin/main' into get_em_back
Antoinehoff Oct 17, 2025
e2dfc0c
still unstable version but compiles.
Antoinehoff Oct 17, 2025
736260b
remove em from species and put it in the collisionless structure. Note:
Antoinehoff Oct 17, 2025
1a6cce3
Separation of the "NO_BY" and ES/EM options. collisionless_id sets no…
Antoinehoff Oct 17, 2025
b0a64aa
adapt the regression tests that were using GKYL_GK_COLLISIONLESS_ES_N…
Antoinehoff Oct 17, 2025
6edf384
reduction of t_end of this rt to make it much faster to run (4sec aga…
Antoinehoff Oct 17, 2025
c955dc8
dummy commit to connect with DR #867
Antoinehoff Oct 21, 2025
cae1c9b
add smoothing of apardot add also gyro_apardot (to pass it to the spe…
Antoinehoff Oct 23, 2025
b469f26
add all the empty kernels.
Antoinehoff Oct 23, 2025
8631c32
I think we have every declaration of every add_em + no_by now 🤪
Antoinehoff Oct 23, 2025
06a2b88
reorganize how the kernel are declared, first all the electrostatic s…
Antoinehoff Oct 24, 2025
66f0ff3
the empty kernels to add EM are now connected to the GK updater. The …
Antoinehoff Oct 24, 2025
ef755a8
Merge remote-tracking branch 'origin/main' into get_em_back
Antoinehoff Oct 24, 2025
3504b47
fix a bug introduced by the merge
Antoinehoff Oct 24, 2025
4f6805f
bugfix: m0 moment of species was allocated twice
Antoinehoff Oct 24, 2025
26e1383
add empty dg_gk em kernels
Antoinehoff Oct 27, 2025
bf31f29
replace phi and dualcurlbhatoverB by apar and apardot
Antoinehoff Oct 27, 2025
3fe8d4e
this is a chunky commit but it looks like it works in the electrostat…
Antoinehoff Nov 5, 2025
0a145a3
Merge remote-tracking branch 'origin/main' into get_em_back 😮‍💨
Antoinehoff Nov 5, 2025
70bcd7e
microfix of a bug that occured during the merge of main
Antoinehoff Nov 5, 2025
fcf2904
manualy port the collisionless_id and use it to decide if we add apar…
Antoinehoff Nov 6, 2025
5df88fc
remove unused zero surf vpar kernel and adjust logic between EM and E…
Antoinehoff Nov 6, 2025
37799cb
Simplification of the field enum table. We do not set if we have ES o…
Antoinehoff Nov 6, 2025
4435311
Add a field_id to activate EM effects regardless of a possible EM spe…
Antoinehoff Nov 6, 2025
5989b56
need to add a EM_IWL field_id too
Antoinehoff Nov 6, 2025
9e35f23
forgot to connect ampere bc input with the field initialization.
Antoinehoff Nov 6, 2025
46ccfb5
Split the collisionless flux kernels between electrostatic (es) and e…
Antoinehoff Nov 6, 2025
bc0b6d6
restore the config and mkdeps
Antoinehoff Nov 6, 2025
07f4f6b
Merge remote-tracking branch 'origin/main' into get_em_back
Antoinehoff Nov 7, 2025
7eb79c3
Clean a bit the interface with return 0 kernels
Antoinehoff Nov 7, 2025
314530e
fix an error were apardot was expanded on bP and not bC
Antoinehoff Nov 7, 2025
a37c075
the d3d rt gk 2x2v test is running with the EM activated now 🥁 It doe…
Antoinehoff Nov 7, 2025
3ad12af
Merge remote-tracking branch 'origin/main' into get_em_back
Antoinehoff Nov 7, 2025
99e785f
always init m1 moment because we want to use it even if we do not set…
Antoinehoff Nov 7, 2025
a6e7cfb
fix the output of Apar and Apardot, we still have to figure how to ha…
Antoinehoff Nov 8, 2025
a644c6f
Rstore the GKYL_GK_FIELD_ES_IWL enum because GKYL_GK_FIELD_ES is not …
Antoinehoff Nov 10, 2025
e1009f9
Include the new GKYL_GK_FIELD_ES_IWL to the logic in field.c and upda…
Antoinehoff Nov 10, 2025
1fd7b56
add a new regression test for alfven wave that tries to imitate the g…
Antoinehoff Nov 11, 2025
2ad20e5
this commit is shady but it has ideas on how to step Apar correctly
Antoinehoff Nov 12, 2025
0892043
a 1/J factor was missing in the kernel, the e_3mag is now computed us…
Antoinehoff Nov 13, 2025
99a4183
Merge branch 'get_em_back' of https://github.com/ammarhakim/gkeyll in…
Antoinehoff Nov 13, 2025
ef81b69
introduce apar_curr which is the current RK stage version of apar and…
Antoinehoff Nov 13, 2025
846f63f
typo in the new signature of the euler stepping method
Antoinehoff Nov 13, 2025
5293f64
remove a debugging clear line
Antoinehoff Nov 13, 2025
b49ebf8
The kinetic alfven wave test is almost working but the frequency of t…
Antoinehoff Nov 14, 2025
38ffe42
the alfven test is still producing the wrong physics but it can do it…
Antoinehoff Nov 14, 2025
5b8708d
It is always one typo away 🤪 alfven rt test now retrieves the correct…
Antoinehoff Nov 14, 2025
7b2bae3
The weak division memory was not released properly for Ohm's law in 1x
Antoinehoff Dec 1, 2025
be8cb11
put the correct q profile (it was the PT discharge not the NT one bef…
Antoinehoff Dec 2, 2025
4490d73
a 1/2 factor is missing in the computation of the electrostatic energ…
Antoinehoff Dec 2, 2025
3f3a56b
add diagnostics for energy stored in Aparallel and its time derivativ…
Antoinehoff Dec 2, 2025
5f1f9da
We accumulate the helmholtz constant for the Ohm solve just before so…
Antoinehoff Dec 8, 2025
ea23578
apar_curr is now allocated as a normal gkyl array and we copy the cur…
Antoinehoff Dec 8, 2025
3346a44
clean unused code. This code can retrieve the frequencies measured in…
Antoinehoff Dec 8, 2025
04b132a
update alfven wave reg test. This commit is multi GPU compute-sanitiz…
Antoinehoff Dec 8, 2025
331ec9f
reduction of the rt alfven 1x2v frame number to 1
Antoinehoff Dec 8, 2025
1d15fd8
Reorganize the allocation for cdim>1 and use gk_field_copy_range to u…
Antoinehoff Dec 8, 2025
4d65045
Bug fix: the new metric variables used in 2x2v EM kernels were not se…
Antoinehoff Dec 9, 2025
0e511ca
indent correctly some lines for readability (I know this is already r…
Antoinehoff Dec 9, 2025
12f34ff
ampere bc are now overwritten by periodicity as for the es field.
Antoinehoff Dec 9, 2025
52ee2a0
the definition of the lapWeightAmpere was not compatible with higher …
Antoinehoff Dec 10, 2025
31218d9
add regression test for alfven wave 2x2v
Antoinehoff Dec 10, 2025
72d304f
This version does not work -- Merge remote-tracking branch 'origin/ma…
Antoinehoff Dec 19, 2025
1bb5cee
The EM terms are now implemented with the latest gk field refactor. 1…
Antoinehoff Dec 22, 2025
ef3930d
Merge remote-tracking branch 'origin/main' into get_em_back
Antoinehoff Dec 22, 2025
3d1ecbd
EM function pointers were not activated correctly in gk_field_1x afte…
Antoinehoff Dec 22, 2025
0189c18
caught a sign error in the setting of Ohm's law for 2x2v
Antoinehoff Dec 22, 2025
abe304b
update alfven 2x2v regression test
Antoinehoff Dec 22, 2025
b911193
EM frames wirting disapeared during the merge with main
Antoinehoff Dec 22, 2025
b3dccac
remove unused global current density array release in gk_field_fem_re…
Antoinehoff Dec 23, 2025
4bde80a
🐛🪤 found a bug where apar was passed instead of apardot in the collis…
Antoinehoff Dec 24, 2025
f18632c
update documentation for gkyl_gk_collisionless_flux_new to clarify th…
Antoinehoff Dec 24, 2025
545b397
create function to pointer to enable or not the twist-and-shift appli…
Antoinehoff Dec 26, 2025
a3beade
put back the new multiplier for CFL rate in gk_species_get_cfl_dynami…
Antoinehoff Dec 26, 2025
c4724b6
remove unused gkcls->apar and apardot arrays.
Antoinehoff Dec 26, 2025
f96b303
remove the "es" in the electrostatic kernel naming to ease comparison…
Antoinehoff Dec 26, 2025
66b6702
finish the removal of GKYL_GK_COLLISIONLESS_ES_NO_BY and replace by a…
Antoinehoff Dec 26, 2025
2f312d6
remove one indentation to reduce the number of changed lines and ease…
Antoinehoff Dec 26, 2025
4b30097
Add em extension to the naming of the copy and combine field method t…
Antoinehoff Dec 26, 2025
90d7150
Remove unused apar_fem array
Antoinehoff Dec 26, 2025
0a1fbad
correct logic for IWL EM
Antoinehoff Dec 26, 2025
b048256
make sure that apar is acquired also when there is no collisionless t…
Antoinehoff Dec 26, 2025
652c4b7
remove obsolete comment
Antoinehoff Dec 26, 2025
de94c1e
🔥🐛🔥 the 2x2v flux surf y kernels were chosen in the 3x2v case....
Antoinehoff Dec 26, 2025
1addd80
I don't know if it's needed but I find it scary to manipulate unalloc…
Antoinehoff Dec 26, 2025
5eb7799
Remove unused variable declaration in the electrostatic case.
Antoinehoff Dec 26, 2025
a5236a4
We now smooth aparout which is apardot used to setp apar so that apar…
Antoinehoff Dec 29, 2025
7eec0e6
the smoothing of apar here is a bad idea as it messes up with the 1x …
Antoinehoff Dec 29, 2025
bf10790
Add the 3x2v alfven regression test
Antoinehoff Feb 9, 2026
41d8875
Remove empty lines
Antoinehoff Feb 10, 2026
8528c0b
update calculation of alphavpar in the 1x1v case according to the lat…
Antoinehoff Feb 10, 2026
2c4a660
indentation fix
Antoinehoff Feb 10, 2026
00f1192
Benign bug fix. The conditions on colless_type was badly written. Thi…
Antoinehoff Feb 11, 2026
6ead1c6
Following the last commit, add extra parenthesis in logic to ensure t…
Antoinehoff Feb 11, 2026
7b819c0
remove unused kernel
Antoinehoff Feb 12, 2026
ac10eb7
remove unused return zero vpar kernel and handle improve spacing
Antoinehoff Feb 12, 2026
e5a0cf6
🐛* Rehandling of the EM workflow. Now, we call the RHS species functi…
Antoinehoff Feb 17, 2026
b5874bd
I don't think we need fdot scaling in the rhs star
Antoinehoff Feb 17, 2026
183d7ed
regroup the lines that are meant to compute Apardot
Antoinehoff Feb 17, 2026
8da594c
Refactor dg volume pointer to function naming to differentiate betwee…
Antoinehoff Feb 17, 2026
4bb8717
🔥🐛🔥 the rhs was always static, bug introduce during the logic rehandl…
Antoinehoff Feb 17, 2026
0c48925
small bug fix of the collisionless type
Antoinehoff Feb 17, 2026
7ab3268
finish GPU implementation of full upwind em scheme. Tested in all alf…
Antoinehoff Feb 17, 2026
33731ed
These new apar volume kernels use the product rule to compute
Antoinehoff Feb 18, 2026
3ffc485
add a coputation of the EM fiels at initial condition to write out Ap…
Antoinehoff Feb 27, 2026
7fcc669
set the kernel back to their original format (without zeroing out the…
Antoinehoff Feb 27, 2026
da74b08
create a unit test for the helmholtz perp solver (Poisson perp with k…
Antoinehoff Feb 27, 2026
a56ec71
Merge remote-tracking branch 'origin/main' into get_em_back_full_upwind
Antoinehoff Feb 28, 2026
62b27f7
Merge branch 'get_em_back_full_upwind' of https://github.com/ammarhak…
Antoinehoff Feb 28, 2026
29e0ae4
manual fix to the previous merge with main, this branch compiles
Antoinehoff Mar 2, 2026
425b049
Merge remote-tracking branch 'origin/Makefile-long-line-fix' into get…
Antoinehoff Mar 2, 2026
8f5118e
adapt the em regression test with the new mac2p enum
Antoinehoff Mar 2, 2026
69c49b3
add a KBM regression test, the branch works fine with the latest main…
Antoinehoff Mar 2, 2026
3da6a27
small logic bug fix
Antoinehoff Mar 2, 2026
313e5ca
Merge remote-tracking branch 'origin/main' into get_em_back_full_upwind
Antoinehoff Mar 30, 2026
ee68ddb
fix a bug rising from merge
Antoinehoff Mar 30, 2026
80c4918
Add the helical geometry SOL regression test (see Section 6 of Mandel…
Antoinehoff Mar 30, 2026
2098654
Add citation to Mandel 2020
Antoinehoff Mar 30, 2026
7d607e9
add Apar solve in the timing metrics
Antoinehoff Mar 30, 2026
6fdeef4
refactor some names to be clear about what is axis and what is center…
Antoinehoff Mar 31, 2026
4f1333e
add an option in the gk field table to have a static Apar, this means…
Antoinehoff Apr 3, 2026
86d1b10
fix the is_apar_static option
Antoinehoff Apr 3, 2026
826c982
remove unused variables
Antoinehoff Apr 6, 2026
fe27709
leave apar stepping even if apar is static since it is already forcin…
Antoinehoff Apr 6, 2026
cc2d4e5
Merge branch 'get_em_back_full_upwind' of https://github.com/ammarhak…
Antoinehoff Apr 6, 2026
267e8ed
rerunning the maaxima scripts changes the kernel for unknown reason, …
Antoinehoff Apr 6, 2026
06c3289
this seems more correct fomr the gkylcas pov but I don't see any diff…
Antoinehoff Apr 6, 2026
561c01b
the electrostatic contribution is not written in one line anymore, th…
Antoinehoff Apr 7, 2026
5f3b878
standardize the space at the end of the line.
Antoinehoff Apr 7, 2026
eeacdd1
split the electrostatic contributions between parallel streaming and …
Antoinehoff Apr 7, 2026
a16ea9b
another logic simplification of the kernels generation.
Antoinehoff Apr 7, 2026
d20f703
Found a missing factor in conf surf flux kernel for Apar, it seems th…
Antoinehoff Apr 7, 2026
59fa650
try a reformulation of the vpar surf flux kernel using ∇Apar x b . ∇H…
Antoinehoff Apr 8, 2026
c91b27e
use bioverJB instead of the e_3_mag and metric tensor component
Antoinehoff Apr 8, 2026
72a597a
the sign of the v parallel surface flux ∇A x b . ∇H term was wrong, t…
Antoinehoff Apr 9, 2026
119c3c7
this is a refactor version of the kernel, rewritten to match equation…
Antoinehoff Apr 11, 2026
45a54f5
Merge remote-tracking branch 'origin/main' into get_em_back_full_upwind
Antoinehoff Apr 13, 2026
a30f152
this commit runs the alfven 3x2v test without any aliasing error 🏆 fo…
Antoinehoff Apr 17, 2026
1c31d53
forgot a line in the kernel generation, everything is fine 🐶🔥
Antoinehoff Apr 17, 2026
a12859a
this is the minimal correction to get rid of the spurious alfven 3x2v…
Antoinehoff Apr 17, 2026
24ef656
remove unused variable
Antoinehoff Apr 20, 2026
3ee4437
add tool to potentially smooth Apar if required
Antoinehoff Apr 20, 2026
e4553d4
Merge branch 'get_em_back_full_upwind' of https://github.com/ammarhak…
Antoinehoff Apr 20, 2026
75a2216
Apar is now computed from the initial state when starting from a frame
Antoinehoff Apr 20, 2026
a6c6bbf
Add a new field info parameter that we can use to force an Ampere com…
Antoinehoff Apr 23, 2026
9ce537c
change the structure of the EM GK solver to avoid redundant computati…
Antoinehoff Apr 23, 2026
445820c
additional optimization of EM: the two hyper DG updaters defined in E…
Antoinehoff Apr 23, 2026
7e43419
logic error in the GPU code, something is still wrong in the GPU code…
Antoinehoff Apr 23, 2026
ec00993
fix a boolean that should have been an int. This error was present si…
Antoinehoff Apr 23, 2026
08fafab
update the helical sol regression test with the fixed geometry. The g…
Antoinehoff Apr 23, 2026
27962cb
Merge remote-tracking branch 'origin/ctest_helmholtz_perp' into get_e…
Antoinehoff Apr 24, 2026
b60c82d
rename the helmholtz unit test
Antoinehoff Apr 24, 2026
f826da7
Merge branch 'poisson_perp_bias' into em_poisson_perp
Antoinehoff Apr 24, 2026
002a31b
Merge remote-tracking branch 'origin/ctest_helmholtz_perp' into em_po…
Antoinehoff Apr 25, 2026
8ab0a7f
the merge between EM and poisson_perp compiles now, unit test passes,…
Antoinehoff Apr 25, 2026
e36d84e
set IWL updater for EM too
Antoinehoff Apr 25, 2026
2225a38
put back the PT q profile as the NT one makes the regression test uns…
Antoinehoff Apr 25, 2026
0bb65ce
The code is valgrind and compute sanitizer clean except some NCCL err…
Antoinehoff Apr 25, 2026
612d582
Merge branch 'get_em_back' of https://github.com/ammarhakim/gkeyll in…
Antoinehoff Apr 27, 2026
0b6dfbb
Merge remote-tracking branch 'origin/em_poisson_perp' into get_em_back
Antoinehoff Apr 27, 2026
ee5f6d7
remove unnecessary cleanup of 'wk' files in the Makefile
Antoinehoff Apr 27, 2026
c2a0e04
Merge of EM and ES kernels to simplify the code.
Antoinehoff Apr 27, 2026
b0f904f
bug fix in the EM 2x2v kernels, the 2D limit of the Apar cross produc…
Antoinehoff Apr 27, 2026
3a1f97c
refactor the inactive flux surface kernels
Antoinehoff Apr 28, 2026
336fdde
vpar surface flux kernels written with the nodal expansion done after…
Antoinehoff Apr 28, 2026
efb002f
down projection of gradH x gradA and A . gradH
Antoinehoff Apr 28, 2026
f5b3806
This commit shows the exact same conservation properties as in the ma…
Antoinehoff Apr 30, 2026
ef3270e
Merge remote-tracking branch 'origin/poisson_perp_bias' into get_em_back
Antoinehoff Apr 30, 2026
8db0b1c
Remove the bias from Apar and Apardot solvers as they do not need to …
Antoinehoff Apr 30, 2026
974afea
Merge remote-tracking branch 'origin/poisson_perp_bias' into get_em_back
Antoinehoff Apr 30, 2026
9d78ea5
minimize diff with poisson_perp_bias
Antoinehoff Apr 30, 2026
7a65117
Merge remote-tracking branch 'origin/poisson_perp_bias' into get_em_back
Antoinehoff Apr 30, 2026
4b1715b
Merge remote-tracking branch 'origin/poisson_perp_bias' into get_em_back
Antoinehoff May 1, 2026
c4a9de5
cosmetics
Antoinehoff May 1, 2026
c85f670
Merge remote-tracking branch 'origin/poisson_perp_bias' into get_em_back
Antoinehoff May 1, 2026
2427245
Merge remote-tracking branch 'origin/main' into get_em_back
Antoinehoff May 2, 2026
b4f603e
Merge remote-tracking branch 'origin/main' into get_em_back
Antoinehoff May 2, 2026
f026601
Merge remote-tracking branch 'origin/main' into get_em_back
Antoinehoff May 6, 2026
31b08aa
rename the surface flux solver em_star to complete_em and reset the c…
Antoinehoff May 6, 2026
56acd04
add standard naming of regression test
Antoinehoff May 6, 2026
ec901ae
Add the helical EM 2x2v regression test, this passes the particle con…
Antoinehoff May 17, 2026
2054437
ensure coherent naming in the helical 3x2v tests and activate EM by d…
Antoinehoff May 17, 2026
f32ad1e
improve comment
Antoinehoff May 18, 2026
ee8142b
Merge remote-tracking branch 'origin/main' into get_em_back
Antoinehoff May 18, 2026
84044a6
Merge remote-tracking branch 'origin/main' into get_em_back
Antoinehoff May 20, 2026
3891523
add an array to store the gyroaveraged m1 moment for possibly FLR eff…
Antoinehoff May 22, 2026
dbfab35
implement a method to remove the flux surface average. For now it is …
Antoinehoff May 30, 2026
e4d065a
Merge remote-tracking branch 'origin/main' into get_em_back
Antoinehoff Jun 1, 2026
a3f49ad
Merge remote-tracking branch 'origin/main' into get_em_back
Antoinehoff Jun 1, 2026
8f98da1
Merge remote-tracking branch 'origin/main' into get_em_back
Antoinehoff Jun 10, 2026
3def11f
add a sanity check where we also solve ampere and output it to compar…
Antoinehoff Jun 10, 2026
73a6195
remove "Electromagnetic Inner wall limited" entry from gk_field_type …
Antoinehoff Jun 10, 2026
06d9f6e
fix some confusion between remove zonal function and boolean
Antoinehoff Jun 11, 2026
b2b779d
add a new option to smooth Aparallel along z after stepping it. A new…
Antoinehoff Jun 11, 2026
b8a6730
Merge remote-tracking branch 'origin/main' into get_em_back
Antoinehoff Jun 17, 2026
876113f
remove gk_field_id from the table since this is now decided by the co…
Antoinehoff Jun 18, 2026
c6401fd
set the fem_projection_par_apar_func to none in the 1x em solver
Antoinehoff Jun 18, 2026
ebb992e
GKYL_FIELD_ES does not exist anymore as this is decided through the c…
Antoinehoff Jun 18, 2026
9289c86
add output of the solution of the ampere's law and unify the descript…
Antoinehoff Jun 18, 2026
d0410e7
Merge remote-tracking branch 'origin/main' into get_em_back
Antoinehoff Jun 18, 2026
39d1e4b
Merge remote-tracking branch 'origin/main' into get_em_back
Antoinehoff Jun 29, 2026
121ba48
some merge fix
Antoinehoff Jun 29, 2026
4527210
Merge remote-tracking branch 'origin/main' into get_em_back-main_merg…
Antoinehoff Sep 2, 2026
c5db4a6
merge fix
Antoinehoff Sep 2, 2026
36905bb
Make the dg gk unit test electromagnetic
Antoinehoff Sep 2, 2026
509304c
We now always apply Apar smoothing, `smooth_apar_z` option is removed.
Antoinehoff Sep 8, 2026
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
2 changes: 1 addition & 1 deletion Makefile_for_ext_C_input
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,4 @@ $(BINS): %: %.c
${CC} ${CFLAGS} ${INCLUDES} $< -o $@ -L${G0_LIB_DIR} ${G0_RPATH} ${G0_LIBS} ${LIB_DIRS} ${EXT_LIBS}

clean:
rm -rf $(BINS) *.d wk
rm -rf $(BINS) *.d
5 changes: 1 addition & 4 deletions core/zero/gkyl_eqn_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ enum gkyl_eqn_type {

// Identifiers for specific gyrokinetic field object types.
enum gkyl_gkfield_id {
GKYL_GK_FIELD_ES = 0, // Electrostatic GK. This is default.
GKYL_GK_FIELD = 0, // This is default.
GKYL_GK_FIELD_BOLTZMANN = 1, // GK Boltzmann, isothermal electrons, phi = phi_sheath + (T_e/e)*ln(n_i/n_is).
GKYL_GK_FIELD_ADIABATIC = 2, // GK field with an adiabatic species.
GKYL_GK_FIELD_EM = 4, // Electromagnetic GK.
Expand Down Expand Up @@ -181,9 +181,6 @@ enum gkyl_gk_anomalous_diff_id {
enum gkyl_gk_collisionless_type {
GKYL_GK_COLLISIONLESS_NONE = 0, // Turns off collisionless terms.
GKYL_GK_COLLISIONLESS_ES, // Electrostatic.
GKYL_GK_COLLISIONLESS_ES_NO_BY, // Electrostatic, w/o toroidal field (b_y=0).
GKYL_GK_COLLISIONLESS_EM_BPERP, // Electromagnetic with B_perp fluctuations.
GKYL_GK_COLLISIONLESS_EM_BPAR, // Electromagnetic with B_par fluctuations.
GKYL_GK_COLLISIONLESS_EM, // Electromagnetic with B_perp and B_par fluctuations.
GKYL_GK_COLLISIONLESS_NEUTRAL, // Neutral collisionless terms.
GKYL_GK_COLLISIONLESS_PASSIVE, // Passive advection (for dev/debug).
Expand Down
274 changes: 273 additions & 1 deletion gyrokinetic/apps/gk_field.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,19 @@ gk_field_calc_energy_dt_active(gkyl_gyrokinetic_app *app, const struct gk_field
app->stat.phidot_tm += gkyl_time_diff_now_sec(wst);
}

static void
gk_field_calc_apar_energy_dt_active(gkyl_gyrokinetic_app *app, const struct gk_field *field, double dt, double *energy_reduced)
{
struct timespec wst = gkyl_wall_clock();
gkyl_array_integrate_advance(field->calc_em_energy, field->apar,
1.0/dt, field->apar_energy_fac, &app->local, &app->local, energy_reduced);
app->stat.phidot_tm += gkyl_time_diff_now_sec(wst);
}

static void
gk_field_calc_energy_dt_none(gkyl_gyrokinetic_app *app, const struct gk_field *field, double dt, double *energy_reduced)
{
// Do nothing.
}

static void
Expand Down Expand Up @@ -181,6 +191,67 @@ gk_field_calc_energy_enabled(struct gkyl_gyrokinetic_app *app, const struct gk_f

gkyl_dynvec_append(field->integ_energy_dot, tm, energy_dot_global);
}

if (field->is_em) {
// Calculate Aparallel energy.
gkyl_array_integrate_advance(field->calc_em_energy, field->apar,
1.0, field->apar_energy_fac, &app->local, &app->local, field->em_energy_red);

gkyl_comm_allreduce(app->comm, GKYL_DOUBLE, GKYL_SUM, 1, field->em_energy_red, field->em_energy_red_global);

double energy_global[1] = { 0.0 };
if (app->use_gpu)
gkyl_cu_memcpy(energy_global, field->em_energy_red_global, sizeof(double[1]), GKYL_CU_MEMCPY_D2H);
else
energy_global[0] = field->em_energy_red_global[0];

if (app->cdim == 1)
energy_global[0] *= field->apar_energy_fac_1d;

gkyl_dynvec_append(field->integ_apar_energy, tm, energy_global);

// Calculate d(Aparallel)/dt energy.
gkyl_array_integrate_advance(field->calc_em_energy, field->apardot,
1.0, field->apar_energy_fac, &app->local, &app->local, field->em_energy_red);

gkyl_comm_allreduce(app->comm, GKYL_DOUBLE, GKYL_SUM, 1, field->em_energy_red, field->em_energy_red_global);

double energy_dot_global[1] = { 0.0 };
if (app->use_gpu)
gkyl_cu_memcpy(energy_dot_global, field->em_energy_red_global, sizeof(double[1]), GKYL_CU_MEMCPY_D2H);
else
energy_dot_global[0] = field->em_energy_red_global[0];

// if (app->cdim == 1)
// energy_dot_global[0] *= field->apar_energy_fac_1d;

gkyl_dynvec_append(field->integ_apardot_energy, tm, energy_dot_global);

if (field->info.time_rate_diagnostics) {
gkyl_comm_allreduce(app->comm, GKYL_DOUBLE, GKYL_SUM, 1, field->apar_energy_red_old, field->em_energy_red_global);
double energy_dot_global_old[1] = { 0.0 };
if (app->use_gpu)
gkyl_cu_memcpy(energy_dot_global_old, field->em_energy_red_global, sizeof(double[1]), GKYL_CU_MEMCPY_D2H);
else
energy_dot_global_old[0] = field->em_energy_red_global[0];
if (app->cdim == 1)
energy_dot_global_old[0] *= field->apar_energy_fac_1d;

gkyl_comm_allreduce(app->comm, GKYL_DOUBLE, GKYL_SUM, 1, field->apar_energy_red_new, field->em_energy_red_global);
double energy_dot_global_new[1] = { 0.0 };
if (app->use_gpu)
gkyl_cu_memcpy(energy_dot_global_new, field->em_energy_red_global, sizeof(double[1]), GKYL_CU_MEMCPY_D2H);
else
energy_dot_global_new[0] = field->em_energy_red_global[0];
if (app->cdim == 1)
energy_dot_global_new[0] *= field->apar_energy_fac_1d;

double energy_dot_global[1] = { 0.0 };
energy_dot_global[0] = energy_dot_global_new[0] - energy_dot_global_old[0];

gkyl_dynvec_append(field->integ_apar_energy_dot, tm, energy_dot_global);
}
}
}

static void
Expand All @@ -189,6 +260,55 @@ gk_field_calc_energy_disabled(struct gkyl_gyrokinetic_app *app, const struct gk_
// Do nothing.
}

static void
gk_field_combine_enabled(struct gkyl_array *out, double c1,
const struct gkyl_array *arr1, double c2, const struct gkyl_array *arr2,
const struct gkyl_range *rng)
{
gkyl_array_accumulate_range(gkyl_array_set_range(out, c1, arr1, rng),
c2, arr2, rng);
}

static void
gk_field_combine_disabled(struct gkyl_array *out, double c1,
const struct gkyl_array *arr1, double c2, const struct gkyl_array *arr2,
const struct gkyl_range *rng)
{
// Do nothing.
}

static void
gk_field_step_apar_enabled(gkyl_gyrokinetic_app *app, struct gk_field *field, struct gkyl_array* out, double dt,
const struct gkyl_array* inp)
{
// Apar^{n+1} = Apar^{n} + dt*dApar/dt
gkyl_array_accumulate(gkyl_array_scale(out, dt), 1.0, inp);

// Smooth Apar along z.
field->fem_projection_par_apar_func(app, field, out, out);
}

static void
gk_field_step_apar_disabled(gkyl_gyrokinetic_app *app, struct gk_field *field, struct gkyl_array* out, double dt,
const struct gkyl_array* inp)
{
// Do nothing.
}

static void
gk_field_copy_range_enabled(struct gkyl_array *out,
const struct gkyl_array *inp, const struct gkyl_range *range)
{
gkyl_array_copy_range(out, inp, range);
}

static void
gk_field_copy_range_disabled(struct gkyl_array *out,
const struct gkyl_array *inp, const struct gkyl_range *range)
{
// Do nothing.
}

static void
gk_field_time_rate_diags_new(struct gkyl_gyrokinetic_app *app, struct gk_field *f)
{
Expand All @@ -206,6 +326,22 @@ gk_field_time_rate_diags_new(struct gkyl_gyrokinetic_app *app, struct gk_field *
}
f->integ_energy_dot = gkyl_dynvec_new(GKYL_DOUBLE, 1);
f->is_first_energy_dot_write_call = true;
if (f->is_em){
f->calc_apar_energy_dt_func = gk_field_calc_apar_energy_dt_active;
if (app->use_gpu) {
f->apar_energy_red_new = gkyl_cu_malloc(sizeof(double[1]));
f->apar_energy_red_old = gkyl_cu_malloc(sizeof(double[1]));
gkyl_cu_memset(f->apar_energy_red_new, 0, sizeof(double[1]));
gkyl_cu_memset(f->apar_energy_red_old, 0, sizeof(double[1]));
} else {
f->apar_energy_red_new = gkyl_malloc(sizeof(double[1]));
f->apar_energy_red_old = gkyl_malloc(sizeof(double[1]));
memset(f->apar_energy_red_new, 0, sizeof(double[1]));
memset(f->apar_energy_red_old, 0, sizeof(double[1]));
}
f->integ_apar_energy_dot = gkyl_dynvec_new(GKYL_DOUBLE, 1);
}
f->is_first_apar_energy_dot_write_call = true;
}

static void
Expand All @@ -225,6 +361,7 @@ gk_field_energy_new(struct gkyl_gyrokinetic_app *app, struct gk_field *f)

f->calc_energy_func = gk_field_calc_energy_enabled;
f->calc_energy_dt_func = gk_field_calc_energy_dt_none;
f->calc_apar_energy_dt_func = gk_field_calc_energy_dt_none;

if (f->info.time_rate_diagnostics) {
gk_field_time_rate_diags_new(app, f);
Expand All @@ -233,6 +370,13 @@ gk_field_energy_new(struct gkyl_gyrokinetic_app *app, struct gk_field *f)
// Factors for ES energy.
f->es_energy_fac = mkarr(app->use_gpu, (2*(app->cdim/3)+1)*app->basis.num_basis, app->local_ext.volume);
f->es_energy_fac_1d = 0.0;

if (f->is_em) {
f->integ_apar_energy = gkyl_dynvec_new(GKYL_DOUBLE, 1);
f->integ_apardot_energy = gkyl_dynvec_new(GKYL_DOUBLE, 1);
f->apar_energy_fac = mkarr(app->use_gpu, (2*(app->cdim/3)+1)*app->basis.num_basis, app->local_ext.volume);
f->apar_energy_fac_1d = 0;
}
}

static void
Expand All @@ -247,6 +391,16 @@ gk_field_time_rate_diags_release(const struct gkyl_gyrokinetic_app *app, struct
gkyl_free(f->em_energy_red_old);
}
gkyl_dynvec_release(f->integ_energy_dot);
if (f->is_em) {
if (app->use_gpu) {
gkyl_cu_free(f->apar_energy_red_new);
gkyl_cu_free(f->apar_energy_red_old);
} else {
gkyl_free(f->apar_energy_red_new);
gkyl_free(f->apar_energy_red_old);
}
gkyl_dynvec_release(f->integ_apar_energy_dot);
}
}

static void
Expand All @@ -267,6 +421,12 @@ gk_field_energy_release(const struct gkyl_gyrokinetic_app *app, struct gk_field
}

gkyl_array_release(f->es_energy_fac);

if (f->is_em) {
gkyl_dynvec_release(f->integ_apar_energy);
gkyl_dynvec_release(f->integ_apardot_energy);
gkyl_array_release(f->apar_energy_fac);
}
}

// Initialize field object.
Expand All @@ -277,7 +437,25 @@ gk_field_new(struct gkyl_gk *gk, struct gkyl_gyrokinetic_app *app)

f->info = gk->field;

f->gkfield_id = f->info.gkfield_id ? f->info.gkfield_id : GKYL_GK_FIELD_ES;
f->gkfield_id = f->info.gkfield_id ? f->info.gkfield_id : GKYL_GK_FIELD;

f->is_em = f->info.gkfield_id == GKYL_GK_FIELD_EM;
// Ensure that if any species is electromagnetic, the field is electromagnetic.
for (int i=0; i<app->num_species; ++i) {
struct gk_species *s = &app->species[i];
f->is_em = f->is_em || (s->info.collisionless.type == GKYL_GK_COLLISIONLESS_EM);
}
if (f->is_em) {
assert(f->info.mu0 > 0.0);
f->step_apar = gk_field_step_apar_enabled;
f->em_combine_func = gk_field_combine_enabled;
f->em_copy_func = gk_field_copy_range_enabled;
} else {
f->step_apar = gk_field_step_apar_disabled;
f->em_combine_func = gk_field_combine_disabled;
f->em_copy_func = gk_field_copy_range_disabled;
}
f->calc_init_apar = f->info.calc_init_apar;

f->calc_init_field = !f->info.zero_init_field;
f->update_field = !f->info.is_static;
Expand Down Expand Up @@ -323,6 +501,46 @@ gk_field_rhs(gkyl_gyrokinetic_app *app, struct gk_field *field)
app->stat.field_phi_solve_tm += gkyl_time_diff_now_sec(wst);
}

void
gk_field_em_rhs(gkyl_gyrokinetic_app *app, struct gk_field *field, const struct gkyl_array *f_in[], struct gkyl_array *rhs_in[])
{
// Compute Apardot through Ohm's law.
struct timespec wst = gkyl_wall_clock();
field->em_rhs_func(app, field, f_in, rhs_in);
app->stat.field_tm += gkyl_time_diff_now_sec(wst);
}

void gk_field_calc_apar_ic(gkyl_gyrokinetic_app *app, struct gk_field *field, struct gkyl_array *out)
{
struct timespec wst = gkyl_wall_clock();
field->ampere_solve(app, field, out);
// Smooth Apar after solving Ampere's law.
gk_field_fem_projection_par(app, field, out, out);
app->stat.field_apar_solve_tm += gkyl_time_diff_now_sec(wst);
}

void gk_field_step_apar(gkyl_gyrokinetic_app *app, struct gk_field *field, struct gkyl_array* out, double a, const struct gkyl_array* inp)
{
struct timespec wst = gkyl_wall_clock();
field->step_apar(app, field, out, a, inp);
app->stat.field_apar_solve_tm += gkyl_time_diff_now_sec(wst);
}

void
gk_field_em_combine(struct gk_field *field, struct gkyl_array *out, double c1,
const struct gkyl_array *arr1, double c2, const struct gkyl_array *arr2,
const struct gkyl_range *rng)
{
field->em_combine_func(out, c1, arr1, c2, arr2, rng);
}

void
gk_field_em_copy_range(struct gk_field *field, struct gkyl_array *out,
const struct gkyl_array *inp, const struct gkyl_range *range)
{
field->em_copy_func(out, inp, range);
}

void
gk_field_calc_energy(gkyl_gyrokinetic_app *app, double tm, const struct gk_field *field)
{
Expand All @@ -337,6 +555,12 @@ gk_field_calc_energy_dt(gkyl_gyrokinetic_app *app, const struct gk_field *field,
field->calc_energy_dt_func(app, field, dt, energy_reduced);
}

void
gk_field_calc_apar_energy_dt(gkyl_gyrokinetic_app *app, const struct gk_field *field, double dt, double *energy_reduced)
{
field->calc_apar_energy_dt_func(app, field, dt, energy_reduced);
}

void gk_field_accumulate_rho_c_adiabatic(gkyl_gyrokinetic_app *app, struct gk_field *field,
struct gk_species *s, struct gkyl_array **bflux)
{
Expand Down Expand Up @@ -372,6 +596,54 @@ gk_field_accumulate_rho_c(gkyl_gyrokinetic_app *app, struct gk_field *field,
app->stat.field_phi_rhs_tm += gkyl_time_diff_now_sec(wst);
}

void
gk_field_accumulate_current_dens(gkyl_gyrokinetic_app *app, struct gk_field *field,
const struct gkyl_array *fin[])
{
struct timespec wst = gkyl_wall_clock();
gkyl_array_clear(field->currentDens, 0.0);
for (int i=0; i<app->num_species; ++i) {
struct gk_species *s = &app->species[i];
gk_species_moment_calc(&s->m1, s->local, app->local, fin[i]);
s->gyroaverage(app, s, s->m1.marr, s->m1_gyroavg);
gkyl_array_accumulate_range(field->currentDens, s->info.charge, s->m1_gyroavg, &app->local);
}
app->stat.field_apar_rhs_tm += gkyl_time_diff_now_sec(wst);
}

void
gk_field_accumulate_current_dens_dot(gkyl_gyrokinetic_app *app, struct gk_field *field,
struct gkyl_array *rhs_in[])
{
struct timespec wst = gkyl_wall_clock();
gkyl_array_clear(field->currentDensdot, 0.0);
for (int i=0; i<app->num_species; ++i) {
struct gk_species *s = &app->species[i];
gk_species_moment_calc(&s->m1, s->local, app->local, rhs_in[i]);
s->gyroaverage(app, s, s->m1.marr, s->m1_gyroavg);
gkyl_array_accumulate_range(field->currentDensdot, s->info.charge, s->m1_gyroavg, &app->local);
}
app->stat.field_apar_rhs_tm += gkyl_time_diff_now_sec(wst);
}

void
gk_field_accumulate_ohms_kSq(gkyl_gyrokinetic_app *app, struct gk_field *field,
const struct gkyl_array *fin[])
{
struct timespec wst = gkyl_wall_clock();
gkyl_array_clear(field->dApartdtSlvr_kSq, 0.0);
for (int i=0; i<app->num_species; ++i) {
struct gk_species *s = &app->species[i];
gk_species_moment_calc(&s->m0, s->local, app->local, fin[i]);
// Gyroaverage the density if needed.
s->gyroaverage(app, s, s->m0.marr, s->m0_gyroavg);
// Use m0 to update also update the kSq matrix for the Ohm's law solver.
double fac = -s->info.charge*s->info.charge/s->info.mass;
gkyl_array_accumulate_range(field->dApartdtSlvr_kSq, fac, s->m0_gyroavg, &app->local);
}
app->stat.field_apar_rhs_tm += gkyl_time_diff_now_sec(wst);
}

void
gk_field_fem_projection_par(gkyl_gyrokinetic_app *app, struct gk_field *field, struct gkyl_array *arr_dg, struct gkyl_array *arr_fem)
{
Expand Down
Loading
Loading