Skip to content

Commit a9300f7

Browse files
mknaranjaPhilou31
andauthored
Correct prolongation and restiction operators
corrected prolongation and restriction operator on first and last circles Co-authored-by: Martin Kühn <Martin.Kuehn@DLR.de> Co-authored-by: Philippe Leleux < leleux.philippe0@gmail.com>
1 parent ddc23c2 commit a9300f7

5 files changed

Lines changed: 341 additions & 451 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.16.3)
22

3-
project(GMGPolar VERSION 0.9.0)
3+
project(GMGPolar VERSION 1.0.0)
44

55

66
file(GLOB sources_src "./src/*.cpp" "./src/test_cases/*.cpp")

README.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,29 @@ names, etc).
4141
Building the library
4242
--------------------
4343
44-
The build process is done using ``make``:
44+
The build process is done using CMake:
4545

46-
# run make
47-
make
46+
# Create build directory
47+
mkdir -p build && cd build
48+
# Configure
49+
cmake ..
50+
# Build
51+
cmake --build .
4852

49-
The code is automatically built with `build_intel` or `build_gnu`, depending on your compiler.
53+
Currently, the default build process only supports gnu compiler although Intel compiler
54+
has been successfully tested for some configurations.
5055

5156
Running GmgPolar
5257
------------
5358

5459
You can run the solver without having to write a code (as we do in the next section). After building
55-
the library, a binary is created called ``./build/main``, it takes parameters directly from command-line.
60+
the library, a binary is created called ``./build/gmgpolar_simulation``, it takes parameters directly from command-line.
5661

5762

5863
# To try GmgPolar on a small problem size, without having to write any code,
59-
# ./build/main uses default parameters with a grid 49 x 64.
64+
# ./build/gmgpolar_simulation uses default parameters with a grid 49 x 64.
6065

61-
./build_gnu/main
66+
./build/gmgpolar_simulation
6267

6368
# For more details on the available parameters, see the main.cpp source code.
6469
# You can control the number of OpenMP threads used by changing the environment variable.
@@ -75,14 +80,14 @@ Once the library is built, you can run the debug examples (either C++ or C):
7580
# the option --debug 1 turns on debugging and compares the results of the C++ code
7681
# with the results from the previous matlab implementation.
7782

78-
./build/main --debug 1
83+
./build/gmgpolar_simulation --debug 1
7984

8085

8186
Issue tracker
8287
-------------
8388
If you find any bug, didn't understand a step in the documentation, or if you
8489
have a feature request, submit your issue on our
85-
`Issue Tracker <https://github.com/mknaranja/GMGPolar/issues>`
90+
`Issue Tracker`: https://github.com/mknaranja/GMGPolar/issues
8691
by giving:
8792

8893
- reproducible parameters
@@ -91,7 +96,7 @@ by giving:
9196

9297
Release Notes
9398
-------------
94-
* GmgPolar 0.9
99+
* GmgPolar 1.0
95100
1) Working multigrid cycle
96101
2) In-house solver and possibility to link with MUMPS for the smoothing and coarse grid solution
97102
3) Extrapolation strategies:

batch.sh_paper

Lines changed: 52 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,82 @@
11
#!/bin/bash
2+
#SBATCH --job-name=gmgpolar # create a short name for your job
3+
#SBATCH --output=slurm-%A.out # stdout file %A=job id
4+
#SBATCH --error=slurm-%A.err # stderr file
5+
#SBATCH -N 1
6+
#SBATCH -n 1
7+
#SBATCH -c 4
8+
#SBATCH -t 6000
9+
#SBATCH --exclusive
210

3-
#fixed variables
11+
##
12+
## This is the run configuration to reproduce GMGPolar results of Figure 8 a) - d) in
13+
## Bourne et al. - Solver comparison for Poisson-like equations on tokamak geometries (2023)
14+
##
15+
#fixed variables (some of these variables have no effect, variables have to be cleaned up for a better presentation)
416
debug=0
517
v1=1
618
v2=1
719
cycle=1
820
compute_rho=0
921
level=-1
10-
plotit=0
11-
solveit=1
1222
maxiter=300
1323
periodic=1
14-
origin_NOT_coarse=0
1524
theta_aniso=0
16-
paraview=0
1725
discr=1
1826
nr_exp=4
1927
ntheta_exp=4
2028
res_norm=3
21-
R0=1e-5
22-
DirBC_Interior=1
29+
R0=1e-6
30+
DirBC_Interior=0
2331
smoother=3
2432
rel_red_conv=1e-11
2533

2634
# Problem
27-
prob=7
35+
# prob=7 # setting not regarded: modified later on in loop
2836
alpha_coeff=2 # Zoni shifted
2937
beta_coeff=1
3038

3139
# geometry/grid
3240
R=1.0
33-
fac_ani=1
34-
mod_pk=0
41+
fac_ani=0
42+
# mod_pk=0 # setting not regarded: modified later on in loop
3543
kappa_eps=0.3
3644
delta_e=0.2
37-
divideBy2=0
45+
# divideBy2=0 # setting not regarded: modified later on in loop
3846

3947
# MG
4048
openmp=4
41-
extrapolation=1
49+
# extrapolation=1 # setting not regarded: modified later on in loop
4250

43-
#f_grid_r="radii_files/aniso3/divide0.txt"
44-
#f_grid_theta="angles_files/aniso3/divide0.txt"
45-
f_grid_r=""
46-
f_grid_theta=""
47-
48-
build_dir=build_gnu
51+
build_dir=build
4952

5053
#overwrite existing file with an empty file
5154
break > output.txt
5255

56+
##########
57+
## create grids
58+
#########
59+
mod_pk=0 # mod_pk has no effect on the creation of grids as the set of (r,theta) is
60+
# the same for all geometries, only the mapping F(r,theta) -> (x,y) changes.
61+
62+
mkdir -p angles_files/Rmax"$R"/aniso"$fac_ani"/
63+
mkdir -p radii_files/Rmax"$R"/aniso"$fac_ani"/
64+
65+
echo $prob $alpha_coeff $beta_coeff $fac_ani $extrapolation $mod_pk
66+
for divideBy2 in 0 1 2 3 4 5 6 # create different grid sizes
67+
do
68+
## ATTENTION / REMARK:
69+
## Please note that these calls will abort/segfault as creation of grids and computation in one step
70+
## is not yet supported by GMGPolar. We will make this functionality available in a future commit.
71+
## Please ignore abort/segfault for the calls in this loop.
72+
./${build_dir}/gmgpolar_simulation -n $nr_exp -a $fac_ani --mod_pk $mod_pk --DirBC_Interior $DirBC_Interior --divideBy2 $divideBy2 -r $R0 --smoother $smoother --verbose 2 --debug $debug --extrapolation $extrapolation --optimized 1 --openmp $openmp --v1 $v1 --v2 $v2 -R $R --prob $prob --maxiter $maxiter --alpha_coeff $alpha_coeff --beta_coeff $beta_coeff --res_norm $res_norm --write_radii_angles 1 --f_grid_r "radii_files/Rmax"$R"/aniso"$fac_ani"/divide"$divideBy2".txt" --f_grid_theta "angles_files/Rmax"$R"/aniso"$fac_ani"/divide"$divideBy2".txt"
73+
done
74+
75+
5376
#################################################
5477
## TABLE 1-2: TEST CASES
5578
#################################################
79+
# module load mumps/mumps-5.4.1/mumps-5.4.1-gcc-11.3.0-openmpi-s7bj6hi
5680
mkdir -p outputs
5781

5882
echo "prob alpha_coeff beta_coeff fac_ani extrapolation mod_pk"
@@ -61,35 +85,25 @@ for mod_pk in 2 1
6185
do
6286
# Cartesian + beta 0 + ani 0
6387
prob=7
64-
fac_ani=0
65-
# for beta_coeff in 0 1
66-
# do
6788
echo $prob $alpha_coeff $beta_coeff $fac_ani $extrapolation $mod_pk
68-
for extrapolation in 0 1
89+
for extrapolation in 1
6990
do
7091
for divideBy2 in 0 1 2 3 4 5 6 #iterate over the different grid sizes
7192
do
72-
echo "./${build_dir}/main -n "$nr_exp" -a "$fac_ani" --mod_pk "$mod_pk" --DirBC_Interior "$DirBC_Interior" --divideBy2 0 -r "$R0" --smoother "$smoother" --verbose 2 --debug "$debug" --extrapolation "$extrapolation" --optimized 1 --openmp "$openmp" --v1 "$v1" --v2 "$v2" -R "$R" --prob "$prob" --maxiter "$maxiter" --alpha_coeff "$alpha_coeff" --beta_coeff "$beta_coeff" --res_norm "$res_norm" --f_grid_r radii_files/Rmax"$R"/aniso"$fac_ani"/divide"$divideBy2".txt --f_grid_theta angles_files/Rmax"$R"/aniso"$fac_ani"/divide"$divideBy2".txt --rel_red_conv "$rel_red_conv" 1> outputs/job.out_"$fac_ani"_"$mod_pk"_"$prob"_"$beta_coeff"_"$extrapolation"_"$divideBy2"_"$rel_red_conv".txt 2> outputs/job.err_"$fac_ani"_"$mod_pk"_"$prob"_"$beta_coeff"_"$extrapolation"_"$divideBy2"_"$rel_red_conv".txt"
73-
./${build_dir}/main -n $nr_exp -a $fac_ani --mod_pk $mod_pk --DirBC_Interior $DirBC_Interior --divideBy2 0 -r $R0 --smoother $smoother --verbose 2 --debug $debug --extrapolation $extrapolation --optimized 1 --openmp $openmp --v1 $v1 --v2 $v2 -R $R --prob $prob --maxiter $maxiter --alpha_coeff $alpha_coeff --beta_coeff $beta_coeff --res_norm $res_norm --f_grid_r "radii_files/Rmax"$R"/aniso"$fac_ani"/divide"$divideBy2".txt" --f_grid_theta "angles_files/Rmax"$R"/aniso"$fac_ani"/divide"$divideBy2".txt" --rel_red_conv $rel_red_conv 1> "outputs/job.out_"$fac_ani"_"$mod_pk"_"$prob"_"$beta_coeff"_"$extrapolation"_"$divideBy2".txt" 2> "outputs/job.err_"$fac_ani"_"$mod_pk"_"$prob"_"$beta_coeff"_"$extrapolation"_"$divideBy2".txt"
93+
echo "./${build_dir}/gmgpolar_simulation -n "$nr_exp" -a "$fac_ani" --mod_pk "$mod_pk" --DirBC_Interior "$DirBC_Interior" --divideBy2 0 -r "$R0" --smoother "$smoother" --verbose 2 --debug "$debug" --extrapolation "$extrapolation" --optimized 1 --openmp "$openmp" --v1 "$v1" --v2 "$v2" -R "$R" --prob "$prob" --maxiter "$maxiter" --alpha_coeff "$alpha_coeff" --beta_coeff "$beta_coeff" --res_norm "$res_norm" --f_grid_r radii_files/Rmax"$R"/aniso"$fac_ani"/divide"$divideBy2".txt --f_grid_theta angles_files/Rmax"$R"/aniso"$fac_ani"/divide"$divideBy2".txt --rel_red_conv "$rel_red_conv" 1> outputs/job.out_"$fac_ani"_"$mod_pk"_"$prob"_"$beta_coeff"_"$extrapolation"_"$divideBy2"_"$rel_red_conv".txt 2> outputs/job.err_"$fac_ani"_"$mod_pk"_"$prob"_"$beta_coeff"_"$extrapolation"_"$divideBy2"_"$rel_red_conv".txt"
94+
./${build_dir}/gmgpolar_simulation -n $nr_exp -a $fac_ani --mod_pk $mod_pk --DirBC_Interior $DirBC_Interior --divideBy2 0 -r $R0 --smoother $smoother --verbose 2 --debug $debug --extrapolation $extrapolation --optimized 1 --openmp $openmp --v1 $v1 --v2 $v2 -R $R --prob $prob --maxiter $maxiter --alpha_coeff $alpha_coeff --beta_coeff $beta_coeff --res_norm $res_norm --f_grid_r "radii_files/Rmax"$R"/aniso"$fac_ani"/divide"$divideBy2".txt" --f_grid_theta "angles_files/Rmax"$R"/aniso"$fac_ani"/divide"$divideBy2".txt" --rel_red_conv $rel_red_conv 1> "outputs/job.out_"$fac_ani"_"$mod_pk"_"$prob"_"$beta_coeff"_"$extrapolation"_"$divideBy2"_"$rel_red_conv".txt" 2> "outputs/job.err_"$fac_ani"_"$mod_pk"_"$prob"_"$beta_coeff"_"$extrapolation"_"$divideBy2"_"$rel_red_conv".txt"
7495
done
7596
done
76-
# done
7797

7898
# Polar + beta 0-1 + ani 0-1
7999
prob=6
80-
for fac_ani in 0 1
81-
do
82-
# for beta_coeff in 0 1
83-
# do
84-
echo $prob $alpha_coeff $beta_coeff $fac_ani $extrapolation $mod_pk
85-
for extrapolation in 0 1
100+
echo $prob $alpha_coeff $beta_coeff $fac_ani $extrapolation $mod_pk
101+
for extrapolation in 1
102+
do
103+
for divideBy2 in 0 1 2 3 4 5 6 #iterate over the different grid sizes
86104
do
87-
for divideBy2 in 0 1 2 3 4 5 6 #iterate over the different grid sizes
88-
do
89-
echo "./${build_dir}/main -n "$nr_exp" -a "$fac_ani" --mod_pk "$mod_pk" --DirBC_Interior "$DirBC_Interior" --divideBy2 0 -r "$R0" --smoother "$smoother" --verbose 2 --debug "$debug" --extrapolation "$extrapolation" --optimized 1 --openmp "$openmp" --v1 "$v1" --v2 "$v2" -R "$R" --prob "$prob" --maxiter "$maxiter" --alpha_coeff "$alpha_coeff" --beta_coeff "$beta_coeff" --res_norm "$res_norm" --f_grid_r radii_files/Rmax"$R"/aniso"$fac_ani"/divide"$divideBy2".txt --f_grid_theta angles_files/Rmax"$R"/aniso"$fac_ani"/divide"$divideBy2".txt --rel_red_conv "$rel_red_conv" 1> outputs/job.out_"$fac_ani"_"$mod_pk"_"$prob"_"$beta_coeff"_"$extrapolation"_"$divideBy2"_"$rel_red_conv".txt 2> outputs/job.err_"$fac_ani"_"$mod_pk"_"$prob"_"$beta_coeff"_"$extrapolation"_"$divideBy2"_"$rel_red_conv".txt"
90-
./${build_dir}/main -n $nr_exp -a $fac_ani --mod_pk $mod_pk --DirBC_Interior $DirBC_Interior --divideBy2 0 -r $R0 --smoother $smoother --verbose 2 --debug $debug --extrapolation $extrapolation --optimized 1 --openmp $openmp --v1 $v1 --v2 $v2 -R $R --prob $prob --maxiter $maxiter --alpha_coeff $alpha_coeff --beta_coeff $beta_coeff --res_norm $res_norm --f_grid_r "radii_files/Rmax"$R"/aniso"$fac_ani"/divide"$divideBy2".txt" --f_grid_theta "angles_files/Rmax"$R"/aniso"$fac_ani"/divide"$divideBy2".txt" --rel_red_conv $rel_red_conv 1> "outputs/job.out_"$fac_ani"_"$mod_pk"_"$prob"_"$beta_coeff"_"$extrapolation"_"$divideBy2".txt" 2> "outputs/job.err_"$fac_ani"_"$mod_pk"_"$prob"_"$beta_coeff"_"$extrapolation"_"$divideBy2".txt"
91-
done
105+
echo "./${build_dir}/gmgpolar_simulation -n "$nr_exp" -a "$fac_ani" --mod_pk "$mod_pk" --DirBC_Interior "$DirBC_Interior" --divideBy2 0 -r "$R0" --smoother "$smoother" --verbose 2 --debug "$debug" --extrapolation "$extrapolation" --optimized 1 --openmp "$openmp" --v1 "$v1" --v2 "$v2" -R "$R" --prob "$prob" --maxiter "$maxiter" --alpha_coeff "$alpha_coeff" --beta_coeff "$beta_coeff" --res_norm "$res_norm" --f_grid_r radii_files/Rmax"$R"/aniso"$fac_ani"/divide"$divideBy2".txt --f_grid_theta angles_files/Rmax"$R"/aniso"$fac_ani"/divide"$divideBy2".txt --rel_red_conv "$rel_red_conv" 1> outputs/job.out_"$fac_ani"_"$mod_pk"_"$prob"_"$beta_coeff"_"$extrapolation"_"$divideBy2"_"$rel_red_conv".txt 2> outputs/job.err_"$fac_ani"_"$mod_pk"_"$prob"_"$beta_coeff"_"$extrapolation"_"$divideBy2"_"$rel_red_conv".txt"
106+
./${build_dir}/gmgpolar_simulation -n $nr_exp -a $fac_ani --mod_pk $mod_pk --DirBC_Interior $DirBC_Interior --divideBy2 0 -r $R0 --smoother $smoother --verbose 2 --debug $debug --extrapolation $extrapolation --optimized 1 --openmp $openmp --v1 $v1 --v2 $v2 -R $R --prob $prob --maxiter $maxiter --alpha_coeff $alpha_coeff --beta_coeff $beta_coeff --res_norm $res_norm --f_grid_r "radii_files/Rmax"$R"/aniso"$fac_ani"/divide"$divideBy2".txt" --f_grid_theta "angles_files/Rmax"$R"/aniso"$fac_ani"/divide"$divideBy2".txt" --rel_red_conv $rel_red_conv 1> "outputs/job.out_"$fac_ani"_"$mod_pk"_"$prob"_"$beta_coeff"_"$extrapolation"_"$divideBy2"_"$rel_red_conv".txt" 2> "outputs/job.err_"$fac_ani"_"$mod_pk"_"$prob"_"$beta_coeff"_"$extrapolation"_"$divideBy2"_"$rel_red_conv".txt"
92107
done
93-
# done
94-
done
108+
done
95109
done

src/level.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,18 @@ std::vector<int> level::get_stencil(int j)
376376
*/
377377
void level::define_nz_P()
378378
{
379-
nz_P = 9 * ntheta_int * (nr_int / 2 - 1) / 2 + 3 * ntheta_int;
379+
// nz_P = 9 * ntheta_int * (nr_int / 2 - 1) / 2 + 3 * ntheta_int;
380+
nz_P = (nr_int / 2 + 1) * (ntheta_int / 2) // coarse nodes
381+
+ 2 * (nr_int / 2 + 1) * ntheta_int / 2 // same theta
382+
+ 2 * (nr_int / 2) * ntheta_int / 2 // same r
383+
+ 4 * (nr_int / 2) * ntheta_int / 2; // diagonal relations
384+
380385
nz_P_inj = mc;
381-
nz_P_ex = 7 * ntheta_int * (nr_int / 2 - 1) / 2 + 3 * ntheta_int;
386+
// nz_P_ex = 7 * ntheta_int * (nr_int / 2 - 1) / 2 + 3 * ntheta_int;
387+
nz_P_ex = (nr_int / 2 + 1) * (ntheta_int / 2) // coarse nodes
388+
+ 2 * (nr_int / 2 + 1) * ntheta_int / 2 // same theta
389+
+ 2 * (nr_int / 2) * ntheta_int / 2 // same r
390+
+ 2 * (nr_int / 2) * ntheta_int / 2; // diagonal relations
382391

383392
// 9 * ntheta_int * nr_int / 4
384393
// - 9 * ntheta_int / 2

0 commit comments

Comments
 (0)