Skip to content

Add FEM building blocks to IPPL #338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 298 commits into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
298 commits
Select commit Hold shift + click to select a range
f446dcb
added quad unit test
lukasbuehler Oct 26, 2023
27ff2bb
updated gitignore to ignore build directories
lukasbuehler Oct 26, 2023
27ba3ef
Merge branch 'master' into fem-framework
lukasbuehler Oct 26, 2023
0aef72d
FEM WIP refactoring the finite element space classes
lukasbuehler Oct 30, 2023
b814070
FEM WIP Refactoring 1
lukasbuehler Nov 5, 2023
d2a6bff
FEM WIP Add new functions to Element class and Quadrature
lukasbuehler Nov 7, 2023
3815695
FEM WIP fixing compiler errors (not compiling atm)
lukasbuehler Nov 7, 2023
d380430
FEM WIP fixed more compiler errors
lukasbuehler Nov 7, 2023
f77208a
FEM WIP fixed errors, added DOF function implementations and unit tests
lukasbuehler Nov 8, 2023
ff0e718
FEM WIP working on resolving compilation issues
lukasbuehler Nov 9, 2023
14c80c7
added unit test for global Lagrange DOF indices
lukasbuehler Nov 9, 2023
538b0dd
FEM WIP more work on spaces and testing
lukasbuehler Nov 9, 2023
0a1a178
FEM Fix naming of element vertex point vector
lukasbuehler Nov 9, 2023
3583391
FEM WIP LagrangeSpace unit tests now working, but not passing
lukasbuehler Nov 9, 2023
5650e20
Added value_type to operations
lukasbuehler Nov 9, 2023
3bcc6c2
Add constructor to NDIndex that takes a Vector of
lukasbuehler Nov 9, 2023
2570a90
FEM WIP added more unit tests for FiniteElementSpace
lukasbuehler Nov 9, 2023
e1e49e4
FEM WIP worked on unit tests for FiniteElementSpace
lukasbuehler Nov 10, 2023
68e9d5b
FEM implemented finiteelementspace unit tests
lukasbuehler Nov 10, 2023
0979cd5
FEM WIP Add more tests to FEMSpace unit tests and fix bugs
lukasbuehler Nov 12, 2023
b3a843f
FEM LagrangeSpace unit tests are now working for Order 1
lukasbuehler Nov 12, 2023
d712767
FEM Small code cleanup
lukasbuehler Nov 12, 2023
72cf5d1
added unit tests for lagrange basis functions order 1
lukasbuehler Nov 13, 2023
4170a76
had to change vector to kokkos view in assembly
lukasbuehler Nov 14, 2023
2547acb
FEM Removed debug print-outs
lukasbuehler Nov 14, 2023
dbd270e
FEM Removed skip serial macros
lukasbuehler Nov 14, 2023
884c314
FEM WIP fixed lagrange space with lambda function
lukasbuehler Nov 16, 2023
c125f85
FEM WIP implemented evaluateLoadVector (untested)
lukasbuehler Nov 16, 2023
37cfc0a
FEM Refactored Quadrature, added gauss jacobi
lukasbuehler Nov 22, 2023
b65dd49
added quadrature unit tests
lukasbuehler Nov 23, 2023
52129d4
FEM Gauss-Jacobi quadrature works if forced to do 100 iterations
lukasbuehler Nov 23, 2023
1d6607f
FEM Gauss-Jacobi quadrature works if forced to do 100 iterations
lukasbuehler Nov 23, 2023
7943d7c
Merge branch 'fem-framework' of github.com:s-mayani/ippl into fem-fra…
lukasbuehler Nov 23, 2023
315ffb0
FEM added gauss jacobi added chebychev test
lukasbuehler Nov 23, 2023
e21bb61
FEM WIP added 3D and worked on quadrature
lukasbuehler Nov 24, 2023
410f2bf
FEM WIP started implementing tests for 3D
lukasbuehler Nov 24, 2023
818bba9
3D basis functions and gradients of bases working
lukasbuehler Nov 24, 2023
73368c4
FEM Gauss-Jacobi aborts if error is sufficiently small
lukasbuehler Nov 24, 2023
0b0b36c
Added Chebyshev nodes as initial conditions for Gauss-Jacobi quadrature
lukasbuehler Nov 27, 2023
a52d1d8
FEM WIP started with FEM Poisson solver
lukasbuehler Nov 28, 2023
0579807
FEM WIP trying to fix build problems with FEMPoissonSolver
lukasbuehler Dec 1, 2023
b347c56
FEM pre field assembly function rework
lukasbuehler Dec 4, 2023
44ba9f4
FEM WIP the solver compiles!
lukasbuehler Dec 5, 2023
0e19df3
FEM fixed unit tests
lukasbuehler Dec 5, 2023
aa2783f
FEM added unit tests to spot problem with quadrature nodes
lukasbuehler Dec 5, 2023
ffbd498
FEMPoissonSolver is running, but something is wrong
lukasbuehler Dec 5, 2023
32a3571
FEM Fixed more FiniteElementSpace unit tests
lukasbuehler Dec 5, 2023
a47ffb9
FEM working on the solver
lukasbuehler Dec 5, 2023
8232050
FEM WIP solver post meeting with sonali
lukasbuehler Dec 6, 2023
0938c6b
Remove unused code in LagrangeSpace.h and
lukasbuehler Dec 7, 2023
763e389
FEM WIP Lagrange unit test works, ignoring ghost cells in assembly
lukasbuehler Dec 7, 2023
85a5bda
FEM WIP added zero-dirichlet BDCs
lukasbuehler Dec 8, 2023
c958f67
moved getting the global DOF NDIndices to function
lukasbuehler Dec 8, 2023
63a9f5a
FEM WIP Implemented solver from scratch, off by factor 10
lukasbuehler Dec 8, 2023
30a2138
FEM WIP fix bug that caused it not to do more than 1 iteration, but i…
lukasbuehler Dec 9, 2023
a8bff5e
FEM WIP trying to fix the FEMPoissonSolver
lukasbuehler Dec 10, 2023
abfe6a8
FEM WIP debugging
lukasbuehler Dec 11, 2023
c59b1cf
FEM WIP using evaluateLoadVector, not working
lukasbuehler Dec 11, 2023
1756e5c
FEM implemented unit test to confirm that evaluateLoadVector is wrong
lukasbuehler Dec 11, 2023
456f79a
FEM WIP bug fixes and improved unit tests
lukasbuehler Dec 11, 2023
0c20ae8
FEM WIP first iteration looks better
lukasbuehler Dec 11, 2023
d41447a
FEM WIP: It also converges using the laplace operator...
lukasbuehler Dec 11, 2023
4982eb3
FEM WIP debugging with -laplace setting the ghost cells not even working
lukasbuehler Dec 11, 2023
886f5c4
FEM WIP THE SOLVER WORKS! now need to clean up
lukasbuehler Dec 12, 2023
bac2d1f
FEM WIP solver cleanup before implementing scaling study
lukasbuehler Dec 12, 2023
1c968c7
FEM WIP improved output of FEM solver
lukasbuehler Dec 12, 2023
e8b3e4e
FEM solver residue bug fix and started with documentation
lukasbuehler Dec 12, 2023
47cb703
FEM started implementing Gaussian test, test seems wrong
lukasbuehler Dec 13, 2023
8ce369f
FEM fixed gaussian 1D solution function with sonali
lukasbuehler Dec 14, 2023
ffafe13
usign mu = 0.5 yields much better convergence
lukasbuehler Dec 14, 2023
79ff97d
added spacing and added higher test sizes
lukasbuehler Dec 14, 2023
7a555ed
FEM WIP trying to debug 3D gaussian
lukasbuehler Dec 15, 2023
bb049ed
FEM documentation and clean up pt 1
lukasbuehler Dec 19, 2023
1ef88bc
implemented solving sinusoidal 2d and 3d
lukasbuehler Dec 19, 2023
19cfec9
documentation part 2
lukasbuehler Dec 19, 2023
bbcd1f5
fixed lagrange unit tests
lukasbuehler Dec 20, 2023
97d90d5
FEM added unit test for hexahedral element
lukasbuehler Jan 8, 2024
633d2e1
FEM removed unused file
lukasbuehler Jan 8, 2024
22e5a1d
FEM fixed the plotting scripts
lukasbuehler Jan 8, 2024
953ec6e
FEM Worked on documentation
lukasbuehler Jan 8, 2024
7bb45d2
FEM WIP stuff
lukasbuehler Jan 30, 2024
1f6e90f
finished documentation and added dimension input to FEM solver test
lukasbuehler Feb 3, 2024
ac3e10e
merge master
s-mayani Apr 25, 2024
aaada03
add missing typenames
s-mayani Apr 25, 2024
91f318a
fix some stuff due to merge
s-mayani Apr 26, 2024
5af4520
add value_type to meta_lower, meta_upper, and meta_lower_and_upper si…
s-mayani Apr 26, 2024
d48837c
fix call to layout constructor, which had missing arguments
s-mayani Apr 26, 2024
a369726
add misisng template arguments in PCG declaration
s-mayani Apr 26, 2024
213dac8
remove this pointer from template argument in lambda, was complaining
s-mayani May 1, 2024
47c9dd7
replace pow by own power function since pow not constexpr
s-mayani May 1, 2024
af63cea
remove this-> from template argument in lambda
s-mayani May 2, 2024
59d35d6
fix typo
s-mayani May 2, 2024
41a827a
remove this-> which caused problems inside template parameters
s-mayani May 2, 2024
28acdfb
merge master to update CMakeLists
s-mayani May 6, 2024
4941224
Revert "commits 41a827a 59d35d6 af63cea 213dac8 a369726"
s-mayani May 6, 2024
06beb1e
add template arguments to PCG declaration
s-mayani May 6, 2024
a616da3
fix some bugs in unit tests due to changes in master
s-mayani May 9, 2024
0b530cc
change to CG instead of PCG; no segfault anymore
s-mayani May 9, 2024
32a7a9e
fix some more bugs in fem unit tests
s-mayani May 9, 2024
7a3bb40
Merge branch 'master' into fem-framework
s-mayani May 10, 2024
a63bed3
make elements into a kokkos loop; add timers
s-mayani May 16, 2024
6d6d41a
remove repeated stopTimer
s-mayani May 21, 2024
83ced3e
add scaling test for fem (fixed problem size and iterated 10 times)
s-mayani May 23, 2024
9cc1115
separate element Indices into a different class method
s-mayani May 23, 2024
20ec11d
add a lot of stuff for testing OpenMP parallelisation and debugging p…
s-mayani Jun 6, 2024
d03cf22
MPI parallelisation works in 1D for 2 ranks
s-mayani Jun 12, 2024
7a8b3cd
implement mapping from element NDIndex to index
s-mayani Jun 19, 2024
7157c3f
MPI distributed element division generalized using mapping
s-mayani Jun 19, 2024
67314ac
make lagrange tests compatible with new constructor of LagrangeSpace
s-mayani Jun 19, 2024
34192cc
test
s-mayani Jun 19, 2024
ae9a962
make unit tests compatible with new LagrangeSpace constructor
s-mayani Jun 19, 2024
f547901
add unit test for getElementIndex
s-mayani Jun 19, 2024
6787992
remove getFieldEntry and make the element contributions atomic adds
s-mayani Jun 26, 2024
e3fb162
fix some issues and make unit tests compatible
s-mayani Jun 27, 2024
07824ee
made unit tests work multi-node for evaluateLoadVector, and evaluateA…
s-mayani Jul 1, 2024
6c6a8f5
add TODO message
s-mayani Jul 1, 2024
f92a4b0
small changes
s-mayani Jul 5, 2024
a3284c9
cleanup debug prints
s-mayani Jul 5, 2024
bd180fa
throw exception in halocells
s-mayani Jul 5, 2024
d902d10
fix exception being thrown in 1d
s-mayani Jul 5, 2024
5868414
remove debug prints
s-mayani Jul 5, 2024
684fc0b
add timers inside FEM and remove some unnecessary stuff
s-mayani Jul 8, 2024
bb77e9f
remove unnecessary files
s-mayani Jul 8, 2024
11d633d
make it compile on GPU
s-mayani Jul 9, 2024
ec90298
add scaling study test program
s-mayani Jul 9, 2024
0ca68f5
remove for loop from 3D test
s-mayani Jul 9, 2024
861fa65
change to not use std::function for f_sol since it causes issues on GPU
s-mayani Jul 9, 2024
9f3e2f9
remove std:: uses and add KOKKOS_FUNCTION
s-mayani Aug 27, 2024
5c695bc
need to add KOKKOS_INLINE_FUNCTION to mesh class to work with FEM
s-mayani Aug 27, 2024
7183cc3
remove std::function, add some debug output
s-mayani Aug 27, 2024
332a151
added test code to test kokkos with virtual functions
s-mayani Aug 27, 2024
f81e21f
add ElementType as template parameter and template ref_element on that
s-mayani Sep 4, 2024
a517211
add element type as template parameter
s-mayani Sep 4, 2024
21e84c1
add more test code, and template parameter solution in TestCode.cpp
s-mayani Sep 4, 2024
e868640
change pass by reference to pass by value and add print debug statements
s-mayani Sep 10, 2024
a95c9a6
remove Element.h/hpp and define everything inside each element class
s-mayani Sep 11, 2024
8e46a4c
reproducer works now
s-mayani Sep 11, 2024
a93cd0c
pass by reference instead of value since it makes no difference
s-mayani Sep 11, 2024
72cb8e4
remove std:: from size_t
s-mayani Sep 11, 2024
cfeb078
replace std::abs by Kokkos::abs
s-mayani Sep 11, 2024
b598549
replace std::function by template F, but this causes error; also some…
s-mayani Sep 17, 2024
eb7f410
add reproducer for lambda compilation problem
s-mayani Sep 17, 2024
69c9938
make lambda into a functor
s-mayani Sep 18, 2024
5b9f753
comment out getGlobalDOFNDIndices as there is something going wrong t…
s-mayani Sep 18, 2024
09f8f78
remove debug prints
s-mayani Sep 18, 2024
0d6ea79
TestLambda reproducer works with functor
s-mayani Sep 18, 2024
a5eb27a
removed const and getGlobalNDIndices
s-mayani Sep 19, 2024
87f52f7
remove debug prints
s-mayani Sep 19, 2024
eda1a77
change back test to include convergence study
s-mayani Sep 19, 2024
d5bae02
change scaling test to compile, re-add to CMakeLists
s-mayani Sep 20, 2024
e9b9678
remove unnecessary types and long names
s-mayani Sep 24, 2024
2c913e0
remove unnecessary typenames
s-mayani Sep 25, 2024
287fb13
change test/FEM tests to match new changes in FEM
s-mayani Sep 27, 2024
3a3ff35
add error computation according to energy norm in FEM
s-mayani Oct 4, 2024
169c01b
forgor square root
s-mayani Oct 4, 2024
380d22f
bring branch up to date with master
s-mayani Oct 11, 2024
0402d7d
add infinity norm
s-mayani Oct 16, 2024
9afa5b2
change RHS to have interpolation for the Load vector computation
s-mayani Oct 29, 2024
4a9b1d3
getting 2nd order convergence now; bug fixed in interpolation both in…
s-mayani Nov 4, 2024
7100f3f
fix L2 norm for multi-rank
s-mayani Nov 4, 2024
24a3553
Merge remote-tracking branch 'origin' into fem-framework
s-mayani Nov 4, 2024
8bf1607
cleanup and make L2 norm available from test
s-mayani Nov 4, 2024
211aeb5
more cleanup
s-mayani Nov 4, 2024
f8456ad
apply clang formatting
s-mayani Nov 5, 2024
f2ac779
cleanup Element classes + add comments
s-mayani Nov 5, 2024
6d4f3e8
make unit tests compile again
s-mayani Nov 5, 2024
3bd858f
fix evaluate Load Vector unit test
s-mayani Nov 6, 2024
77ad89c
make FEM an option in alpine - compiles but complains about division …
s-mayani Nov 7, 2024
90b178d
forgot to change class members dependant on mesh in setMesh()
s-mayani Nov 7, 2024
ff3b5c4
remove all consts from Mesh type arguments as not const reference any…
s-mayani Nov 7, 2024
cda6a1c
add periodic test case
s-mayani Nov 7, 2024
f389763
dirty PBC implementation; 1D, serial only for evalLoadVector
s-mayani Nov 8, 2024
20962af
remove const qualifier from Mesh in tests of lagrange space
s-mayani Nov 11, 2024
e6285a9
remove const qualifier from Mesh in FEM unit tests
s-mayani Nov 11, 2024
43a1202
fixed some segfault issue in alpine when using FEM
s-mayani Nov 11, 2024
f3e7678
forgot to initialize RHS in setRHS
s-mayani Nov 11, 2024
51d818a
periodic BC infrastructure for FEM
s-mayani Nov 12, 2024
4bec7bb
Merge branch 'IPPL-framework:master' into fem-framework
s-mayani Nov 13, 2024
0bf914d
cleanup and change how we deal with BCs - apply and then a shift from…
s-mayani Nov 16, 2024
3b148c3
remove unnecessary code
s-mayani Nov 19, 2024
90d3c40
put BC apply inside periodic check
s-mayani Nov 19, 2024
bc2700d
fix apply to physical cells to check whether upper or lower face too,…
s-mayani Nov 19, 2024
67e3bbd
remove applyBCs in operator; some debug output
s-mayani Nov 19, 2024
cf2352f
fix apply periodic to physical for > 1D
s-mayani Nov 19, 2024
ead0e57
remove some debug stuff
s-mayani Nov 19, 2024
476ea65
add ZeroFace BCs in unit test to make it pass
s-mayani Nov 23, 2024
18db132
add tests of FEM and CG!
s-mayani Nov 26, 2024
7cd37a7
add more stuff to Alpine for FEM
s-mayani Nov 26, 2024
347672c
Merge branch 'IPPL-framework:master' into fem-framework
s-mayani Nov 28, 2024
f6e1546
changed testCG_convergence_fem - it's a periodic BCs test for FEM usi…
s-mayani Dec 2, 2024
cf81baa
cleanup
s-mayani Dec 4, 2024
aa7988e
more cleanup and renaming
s-mayani Dec 4, 2024
a6bd083
add scaling tests
s-mayani Dec 4, 2024
7e338f6
add gaussian 1D FEM convergence test
s-mayani Dec 4, 2024
f85b9f7
cleanup in periodic convergence study
s-mayani Dec 4, 2024
b603c66
change iterations in scaling periodic
s-mayani Dec 4, 2024
0fa8266
remove isAllperiodic = false for OPEN Case - works
s-mayani Dec 20, 2024
fd43d8f
add TestOld3d which is based on the old 3D gaussian test case - but t…
s-mayani Dec 20, 2024
67682c6
restructuring
s-mayani Feb 5, 2025
2b49d97
replace ippl dot by explicit dot product as this affects timings
s-mayani Feb 5, 2025
1642930
Merge branch 'master' into fem-framework
s-mayani Feb 5, 2025
1ff6da3
add nonhomogeneous dirichlet treatment in fem
s-mayani Feb 5, 2025
05868d6
add non homogeneous dirichlet BCs 1D simple test
s-mayani Feb 5, 2025
cd7abe8
seems to converge
s-mayani Feb 5, 2025
421ba95
add more tests for homogeneous Dirichlet BCs
s-mayani Feb 6, 2025
804e751
cleanup
s-mayani Feb 11, 2025
2f7ca5b
add 3D gaussian with imposed Dirichlet value at boundaries
s-mayani Feb 11, 2025
7cf9f3c
missing Kokkos fence which was causing sporadic errors
s-mayani Feb 18, 2025
749a46a
kokkos fence caused issues on GPU; the actual problem was the change …
s-mayani Feb 18, 2025
300388d
Merge branch 'fem-framework' into nonhomogeneous-dirichlet
s-mayani Feb 18, 2025
5e1e0af
added cos1d nonhom dirichlet bc test; converges 2nd order
s-mayani Feb 21, 2025
c70c274
changed 3d test case as gaussian is actually not constant face so mak…
s-mayani Feb 27, 2025
71fd437
Merge branch 'master' into fem-framework
s-mayani Mar 18, 2025
802f8ee
add bc for constant face on physical cells + account for corner cells
s-mayani Mar 27, 2025
2f8c83c
add constant face BC in test - testing phase have some print outs
s-mayani Mar 27, 2025
7e5d44a
added change of using constant face and bcapply in evalLoadVector and…
s-mayani Mar 28, 2025
8eada5d
this change does not break convergence
s-mayani Mar 28, 2025
d4a3470
add a new halo exchange function that doesn't double count boundary c…
s-mayani Apr 2, 2025
46c0dd5
this now works 2d multi-node using the new halo exchange function... …
s-mayani Apr 2, 2025
5332add
cleanup
s-mayani Apr 2, 2025
5e3e329
change starting point for 3D case to check in parallel
s-mayani Apr 2, 2025
9f23914
fix MPI comm; works on odd ranks for 2D now
s-mayani Apr 8, 2025
df14bdd
fix 3D case - corner cell was being skipped in ghost to physical assi…
s-mayani Apr 24, 2025
883848f
start convergence study from higher size to avoid planes in domain de…
s-mayani Apr 24, 2025
24d2192
documentation
s-mayani Apr 24, 2025
ff3d55a
remove dirichlet val from tests
s-mayani Apr 24, 2025
ce8cf3a
remove dirichletval_m from LagrangeSpace since changed to use IPPL BC…
s-mayani Apr 24, 2025
6f1c96f
change name of assignPeriodicGhostCellToPhysical and cleanup
s-mayani Apr 24, 2025
72fd35c
fixed problem of BCs not propagating through CG iterations
s-mayani Apr 24, 2025
f88a4f9
fix some typos in tests
s-mayani Apr 25, 2025
8634b14
Merge branch 'fem-framework' into nonhomogeneous-dirichlet
s-mayani Apr 25, 2025
a836d77
Merge nonhomogeneous-dirichlet into fem-framework
s-mayani Apr 25, 2025
76d2c0a
fix some ghost cell issues in Periodic BCs
s-mayani Apr 29, 2025
15f416f
add descriptions to all the FEM tests
s-mayani Apr 29, 2025
0409bee
fix else if to else otherwise zero BCs don't work
s-mayani Apr 29, 2025
e2fe163
add computation of average of sol on space + division by space volume
s-mayani Apr 29, 2025
ad70f90
add averaging to 0 in periodic BCs test case to account for constant …
s-mayani Apr 29, 2025
5d02053
tested with shifted domain (0,2) instead of (-1,1) - works
s-mayani Apr 29, 2025
d77ca00
change to stop it complaining about planes in domain decomposition wi…
s-mayani Apr 29, 2025
4508b3b
Merge pull request #2 from s-mayani/fem-addAveraging
s-mayani Apr 29, 2025
c07a934
Merge branch 'master' into fem-framework
s-mayani Apr 29, 2025
ca88dc3
make CMake compatible with new IPPL cmake; fix a typo
s-mayani Apr 29, 2025
a9bca6b
cleanup
s-mayani Apr 29, 2025
023595c
Merge branch 'master' into fem-framework
s-mayani May 14, 2025
65eb641
forgot to add FEM subdirectory in unit tests
s-mayani May 14, 2025
8861581
some more things missing in unit tests
s-mayani May 14, 2025
23bf726
implement PR comments
s-mayani May 19, 2025
b151e15
implement PR comments bis
s-mayani May 19, 2025
8173248
more PR comments incorporated
s-mayani May 20, 2025
2dfada9
Merge branch 'master' into fem-framework
s-mayani May 20, 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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ build*/
*~
*.~

# ignore build directories
build*/

# ignore .vscode directory
.vscode
1 change: 0 additions & 1 deletion alpine/AlpineManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class AlpineManager : public ippl::PicManager<T, Dim, ParticleContainer<T, Dim>,
std::string solver_m;
std::string stepMethod_m;
std::vector<std::string> preconditioner_params_m;

public:
AlpineManager(size_type totalP_, int nt_, Vector_t<int, Dim>& nr_, double lbt_,
std::string& solver_, std::string& stepMethod_,
Expand Down
2 changes: 1 addition & 1 deletion alpine/FieldSolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ class FieldSolver : public ippl::FieldSolverBase<T, Dim> {
void setPotentialBCs() {
// CG requires explicit periodic boundary conditions while the periodic Poisson solver
// simply assumes them
typedef ippl::BConds<Field<T, Dim>, Dim> bc_type;
if (this->getStype() == "CG" || this->getStype() == "PCG") {
typedef ippl::BConds<Field<T, Dim>, Dim> bc_type;
bc_type allPeriodic;
for (unsigned int i = 0; i < 2 * Dim; ++i) {
allPeriodic[i] = std::make_shared<ippl::PeriodicFace<Field<T, Dim>>>(i);
Expand Down
2 changes: 1 addition & 1 deletion alpine/LandauDamping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// Example:
// srun ./LandauDamping 128 128 128 10000 10 FFT 0.01 LeapFrog --overallocate 2.0 --info 10

constexpr unsigned Dim = 3;
constexpr unsigned Dim = 2;
using T = double;
const char* TestName = "LandauDamping";

Expand Down
14 changes: 8 additions & 6 deletions doc/examples/BasicsFFT.hpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
/**
@page basics_fft Basics: FFT
@section fft Introduction
The FFT(Fast Fourier Transform) class performs complex-to-complex, real-to-complex and real-to-real on IPPL Fields.
Currently, we use heffte for taking the transforms and the class FFT serves as an interface between IPPL and heffte. In making this interface,
we have referred Cabana library https://github.com/ECP-copa/Cabana.
The FFT(Fast Fourier Transform) class performs complex-to-complex, real-to-complex and real-to-real
on IPPL Fields. Currently, we use heffte for taking the transforms and the class FFT serves as an
interface between IPPL and heffte. In making this interface, we have referred Cabana library
https://github.com/ECP-copa/Cabana.

* @subsection FFT Transformation Types
*
* FFT is templated on the type of transform to be performed, the dimensionality of the Field to transform, and the
*
* FFT is templated on the type of transform to be performed, the dimensionality of the Field to
transform, and the
* floating-point precision type of the Field (float or double).
*
*
* **Types of transformation**
* - complex-to-complex FFT: 'ippl::CCTransform'
* - real-to-complex FFT: 'ippl::RCTransform'
Expand Down
98 changes: 57 additions & 41 deletions doc/examples/BasicsFields.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@

/**
* @page basics_fields Basics: Fields
*
*
*
* @page basics_fields Basics: Fields
*
*
*
@section field_intro Introduction
This sections provides the readers with a brief background on the used classes for handling Fields in IPPL.
* ## FieldLayout
This sections provides the readers with a brief background on the used classes for handling Fields
in IPPL.
* ## FieldLayout
//
FieldLayout describes how a given index space (represented by an NDIndex
object) is distributed among MPI ranks. It performs the initial
Expand All @@ -21,17 +22,23 @@ partitioned by flagging that axis as 'SERIAL' (instead of 'PARALLEL').
// all parallel layout, standard domain, normal axis order
ippl::FieldLayout<dim> layout(MPI_COMM_WORLD, owned, isParallel);
* @endcode
In this example, we create a 3-dimensional FieldLayout with 25 points in each direction. The layout is distributed among MPI ranks.
In this example, we create a 3-dimensional FieldLayout with 25 points in each direction. The layout
is distributed among MPI ranks.


* ## BareField
The BareField class in IPPL is a template class that represents a numerical field in a computational domain. It is designed to handle data in up to three dimensions and supports various data types through its template parameter T.
It provides a Kokkos-based multidimensional array, or view, which is the main data structure used to store field values.
The class is integrated with IPPL's field layout and halo cell system for managing computational domains and communication between them, especially in parallel computing environments.
A field can be initialized with a specific layout, and it supports operations such as resizing, updating the layout, and operations related to ghost cells which are used for boundary conditions and domain communication.
It offers functions for calculating aggregate values over the field, such as sums, maxima, minima, and products.
Fields can be assigned values from constants or other fields through expression templates, allowing for complex computations and assignments.
The class provides range policies for iteration that can exclude or include ghost layers, giving flexibility in how the field data is traversed and manipulated.
* ## BareField
The BareField class in IPPL is a template class that represents a numerical field in a computational
domain. It is designed to handle data in up to three dimensions and supports various data types
through its template parameter T. It provides a Kokkos-based multidimensional array, or view, which
is the main data structure used to store field values. The class is integrated with IPPL's field
layout and halo cell system for managing computational domains and communication between them,
especially in parallel computing environments. A field can be initialized with a specific layout,
and it supports operations such as resizing, updating the layout, and operations related to ghost
cells which are used for boundary conditions and domain communication. It offers functions for
calculating aggregate values over the field, such as sums, maxima, minima, and products. Fields can
be assigned values from constants or other fields through expression templates, allowing for complex
computations and assignments. The class provides range policies for iteration that can exclude or
include ghost layers, giving flexibility in how the field data is traversed and manipulated.


*@code
Expand All @@ -48,15 +55,18 @@ ippl::BareField<double, dim> field(layout, 1);


*@section Field Field
The Field class in IPPL is an advanced version of BareField, augmented with a mesh for defining the spatial domain and equipped with customizable boundary conditions. The class is templated to be flexible for various data types (T), dimensions (Dim), mesh types (Mesh), and centering schemes (Centering), along with additional Kokkos view arguments (ViewArgs...).
It's associated with a Mesh object that dictates the structure of the simulation space.
Boundary conditions can be set and updated, affecting how the field interacts with the limits of the simulation space.
Offers methods for calculating volume integrals and averages, which are useful for analyzing the field over its entire domain.
Inherits from BareField, allowing for basic field operations and attribute access.
The Field class in IPPL is an advanced version of BareField, augmented with a mesh for defining the
spatial domain and equipped with customizable boundary conditions. The class is templated to be
flexible for various data types (T), dimensions (Dim), mesh types (Mesh), and centering schemes
(Centering), along with additional Kokkos view arguments (ViewArgs...). It's associated with a Mesh
object that dictates the structure of the simulation space. Boundary conditions can be set and
updated, affecting how the field interacts with the limits of the simulation space. Offers methods
for calculating volume integrals and averages, which are useful for analyzing the field over its
entire domain. Inherits from BareField, allowing for basic field operations and attribute access.

### Example: Creating a Field
* The following example showcases the creation and basic manipulation of a field in IPPL:
*
*
* @code{.cpp}
using namespace ippl;

Expand All @@ -82,7 +92,8 @@ UniformCartesian<double,dim> mesh(owned, hx, origin);
Field<double,dim> field(mesh, layout);
@endcode
*
* This example outlines the steps to define a three-dimensional field, specifying its layout and parallelization strategy.
* This example outlines the steps to define a three-dimensional field, specifying its layout and
parallelization strategy.
*


Expand All @@ -98,7 +109,7 @@ auto fieldNorm = norm(field,p);
// Computes dot product of vector fields (in each element) and returns a scalar field
auto field = dot(vfield, vfield)

// Innerproduct of two scalar fields and returns a scalar
// Innerproduct of two scalar fields and returns a scalar
auto fSquare = innerProduct(field, field);

// Computes the sum of the field
Expand All @@ -110,10 +121,10 @@ auto fieldVolIntegral = field.getVolumeIntegral();


*@subsubsection field_properties Field Properties
*@code
*@code
// Returns the range policy for the fields excluding the ghosts layers.
// If you want to include ghost layers specify nghost as an argument
auto fieldRange = field.getFieldRangePolicy();
auto fieldRange = field.getFieldRangePolicy();

// Return the number of ghost layers in the field
auto nghost = field.getNghost();
Expand All @@ -139,7 +150,7 @@ auto field2 = field1.deepCopy();
// Return the underyling Kokkos View of the field
auto fview = field.getView();

// Return the Host Mirror corresponding to the Kokkos device view
// Return the Host Mirror corresponding to the Kokkos device view
// of the field. It is a no-op if the field is already on the host.
auto fHostView = field.getHostMirror();

Expand All @@ -149,31 +160,33 @@ Kokkos::deep_copy(fview, fHostView); // host to device
*@endcode

* @subsubsection init_field_from_func Initializing a Field from a Function
* @code
* @code
const ippl::NDIndex<Dim>& lDom = fieldLayout.getLocalNDIndex();
const int nghost = field.getNghost();
auto fview = field.getView();

using index_array_type = typenamep ippl::RangePolicy<Dim>::index_array_type;

ippl::parallel_for(
ippl::parallel_for(
"Assign a field based on func", field.getFieldRangePolicy(),
KOKKOS_LAMBDA(const index_array_type& args) {
// local to global index conversion
Vector<double, Dim> xvec = (args + lDom.first() - nghost + 0.5) * hr + origin;

// ippl::apply accesses the view at the given indices and obtains a
// ippl::apply accesses the view at the given indices and obtains a
// reference; see src/Expression/IpplOperations.h
ippl::apply(fview, args) = func(xvec);
});
*@endcode

- To write dimension independent kernels use the wrappers 'ippl::parallel_for' and 'ippl::parallel_reduce'.
- If you don't want dimension independence in your application then you can just use 'Kokkos::parallel_for' and 'Kokkos::parallel_reduce'.
- To write dimension independent kernels use the wrappers 'ippl::parallel_for' and
'ippl::parallel_reduce'.
- If you don't want dimension independence in your application then you can just use
'Kokkos::parallel_for' and 'Kokkos::parallel_reduce'.
* @subsubsection boundary_conditions_fields Boundary Conditions for Fields
Setting BCs for fields is a necessary prerequisite before applying differential operators on fields! Otherwise
you will get garbage for the points close to the boundary.
*@code
Setting BCs for fields is a necessary prerequisite before applying differential operators on fields!
Otherwise you will get garbage for the points close to the boundary.
*@code
typedef ippl::BConds<Field<t, Dim>, Dim> bc_type;
bc_type bc;
// Available BCs in Ippl see src/Field/BcTypes.h
Expand All @@ -196,22 +209,25 @@ sfield_type sfield (field.get_mesh(), field.getLayout());
vfield_type vfield (field.get_mesh (), field.getLayout ());
mfield_type mfield (field.get_mesh (), field.getLayout ());

// Computes gradient of a scalar field by cell - centered finite difference and returns a vector field
vfield = grad(field);
// Computes gradient of a scalar field by cell - centered finite difference and returns a vector
field vfield = grad(field);

// Computes divergence of a vector field by cell - centered finite difference and returns a scalar field
field = div(vfield);
// Computes divergence of a vector field by cell - centered finite difference and returns a scalar
field field = div(vfield);

// Computes curl of a scalar field by cell - centered finite difference and returns a vector field
// Only available in 3 D for the moment
vfield = curl(field);

// Computes Hessian of a scalar field by cell - centered finite difference and returns a matrix field
// Computes Hessian of a scalar field by cell - centered finite difference and returns a matrix
field
// There is no native matrix data type in ippl so the output field is vector of vectors
mfield = hess(field);

// Computes Laplacian of a scalar field by cell - centered finite difference and returns a scalar field .
// At the moment ippl does not do a copy of the original field when you specify the same scalar field
// Computes Laplacian of a scalar field by cell - centered finite difference and returns a scalar
field .
// At the moment ippl does not do a copy of the original field when you specify the same scalar
field
// in both rhs and lhs . So the user has to allocate a different scalar field for lhs and rhs .
sfield = laplace(field);

Expand Down
35 changes: 22 additions & 13 deletions doc/examples/BasicsIndex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
@page basic_index Basics: Index and NDIndex
* @section index Introduction
* ## Index
*
* The Index class represents a strided range of indices, and it is used to define the index extent of Field objects on construction.
*
*
* The Index class represents a strided range of indices, and it is used to define the index extent
of Field objects on construction.
*
* **Constructors**:
* - `Index()`: Creates a null interval with no elements.
* - `Index(n)`: Instantiates an Index object representing the range of integers from 0 to n-1 inclusive, with implied stride 1.
* - `Index(a,b)`: Instantiates an Index object representing the range of integers [a , b], with implied stride 1.
* - `Index(a,b,s)`: Instantiates an Index object representing the range of integers [a , b], with stride s.
* - `Index(n)`: Instantiates an Index object representing the range of integers from 0 to n-1
inclusive, with implied stride 1.
* - `Index(a,b)`: Instantiates an Index object representing the range of integers [a , b], with
implied stride 1.
* - `Index(a,b,s)`: Instantiates an Index object representing the range of integers [a , b], with
stride s.
*
* **Examples**:
* ```cpp
Expand All @@ -26,12 +30,15 @@
* I+j : a+j+i*s // For i in [0..n-1]
* j-I : j-a-i*s
* j*I : j*a + i*j*s
* I/j : a/j + i*s/j // Note: j/I is not defined due to non-uniform stride and fraction prohibition.
* I/j : a/j + i*s/j // Note: j/I is not defined due to non-uniform stride and fraction
prohibition.
* ```
*
* ## NDIndex
*
* NDIndex is a class that acts as a container for multiple Index instances. It simplifies operations such as intersections across N dimensions by forwarding requests to its contained Index objects.
*
* ## NDIndex
*
* NDIndex is a class that acts as a container for multiple Index instances. It simplifies
operations such as intersections across N dimensions by forwarding requests to its contained Index
objects.
*
@section Example Usage
The following example demonstrates the use of Index and NDIndex classes.
Expand All @@ -47,7 +54,9 @@ isParallel.fill(true);

ippl::FieldLayout<dim> layoutInput(MPI_COMM_WORLD, ownedInput, isParallel);
@endcode
*
* In this example, we define an NDIndex object `ownedInput` with three Index objects `Iinput`, `Jinput`, and `Kinput`. We then create a FieldLayout object `layoutInput` using the NDIndex object and a boolean array `isParallel` that specifies the parallel dimensions.
*
* In this example, we define an NDIndex object `ownedInput` with three Index objects `Iinput`,
`Jinput`, and `Kinput`. We then create a FieldLayout object `layoutInput` using the NDIndex object
and a boolean array `isParallel` that specifies the parallel dimensions.
*
*/
14 changes: 7 additions & 7 deletions doc/examples/BasicsMesh.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/**
@page basic_mesh Basics: Mesh
*@section mesh Introduction
*The Mesh class in IPPL is a basic class used for creating and handling meshes in simulations.
*It lets you work with meshes of different sizes and types. You can get or set where the mesh starts (its origin) and find out the size of the grid it covers.
*It's set up so other parts of the program can be updated if the mesh changes, like if it gets bigger or needs to be rearranged.
*The Mesh class in IPPL is a basic class used for creating and handling meshes in simulations.
*It lets you work with meshes of different sizes and types. You can get or set where the mesh starts
(its origin) and find out the size of the grid it covers. *It's set up so other parts of the program
can be updated if the mesh changes, like if it gets bigger or needs to be rearranged.
@section example_usage Example Usage
The following example demonstrates the use of the Mesh class in IPPL:
* @code
Expand All @@ -18,8 +19,7 @@ The following example demonstrates the use of the Mesh class in IPPL:
ippl::Vector<double, dim> origin = {0.0, 0.0, 0.0};
Mesh_t mesh(owned, hx, origin);
* @endcode
In this example, we initialize a 3-dimensional mesh using 25 points in each direction.
We then define the mesh's origin, spacing, and size, and create a Mesh object using these parameters.
In this example, we initialize a 3-dimensional mesh using 25 points in each direction.
We then define the mesh's origin, spacing, and size, and create a Mesh object using these
parameters.
*/


Loading