Skip to content

Commit 0839e78

Browse files
committed
Merge pull request ComputationalRadiationPhysics#880 from psychocoderHPC/fix-fieldSolverAssert
move field solver condition check to field solver
2 parents c015930 + 132a61b commit 0839e78

File tree

8 files changed

+109
-51
lines changed

8 files changed

+109
-51
lines changed

examples/KelvinHelmholtz/cmakeFlags

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ flags[3]="-DCUDA_ARCH=sm_35 -DPARAM_OVERWRITES:LIST=-DPARAM_CURRENTSOLVER=ZigZag
3636
flags[4]="-DCUDA_ARCH=sm_35 -DPARAM_OVERWRITES:LIST=-DPARAM_CURRENTSOLVER=ZigZag<UsedParticleShape>;-DPARAM_PARTICLESHAPE=PCS"
3737
flags[5]="-DCUDA_ARCH=sm_35 -DPARAM_OVERWRITES:LIST=-DPARAM_CURRENTSOLVER=ZigZag<UsedParticleShape>;-DPARAM_PARTICLESHAPE=TSC"
3838
flags[6]="-DCUDA_ARCH=sm_35 -DPARAM_OVERWRITES:LIST=-DPARAM_CURRENTSOLVER=ZigZag<UsedParticleShape>;-DPARAM_PARTICLESHAPE=TSC;-DPARAM_DIMENSION=DIM2"
39+
flags[7]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_FIELDSOLVER=fieldSolverDirSplitting"
3940

4041

4142
################################################################################

examples/KelvinHelmholtz/include/simulation_defines/param/componentsConfig.param

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,13 @@ namespace picongpu
5050
* - fieldSolverYeeNative : generic version of fieldSolverYee
5151
* (need more shared memory per GPU and is slow)
5252
*/
53-
namespace fieldSolver = fieldSolverYee;
53+
#ifndef PARAM_FIELDSOLVER
54+
/* WARNING: if you change field solver by hand please update your CELL_WIDTH_SI
55+
* in `gridConfig.param` to fulfill the convergence condition (CFL)
56+
*/
57+
#define PARAM_FIELDSOLVER fieldSolverYee
58+
#endif
59+
namespace fieldSolver = PARAM_FIELDSOLVER;
5460

5561
/*enable (1) or disable (0) current calculation*/
5662
#define ENABLE_CURRENT 1

examples/KelvinHelmholtz/include/simulation_defines/param/gridConfig.param

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
/**
22
* Copyright 2013-2015 Axel Huebl, Rene Widera, Richard Pausch
33
*
4-
* This file is part of PIConGPU.
5-
*
6-
* PIConGPU is free software: you can redistribute it and/or modify
7-
* it under the terms of the GNU General Public License as published by
8-
* the Free Software Foundation, either version 3 of the License, or
9-
* (at your option) any later version.
10-
*
11-
* PIConGPU is distributed in the hope that it will be useful,
12-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14-
* GNU General Public License for more details.
15-
*
16-
* You should have received a copy of the GNU General Public License
17-
* along with PIConGPU.
18-
* If not, see <http://www.gnu.org/licenses/>.
19-
*/
20-
4+
* This file is part of PIConGPU.
5+
*
6+
* PIConGPU is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* PIConGPU is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with PIConGPU.
18+
* If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
2121

2222

2323
#pragma once
@@ -32,7 +32,27 @@ namespace picongpu
3232
const double DELTA_T_SI = 1.79e-16;
3333
/** equals X
3434
* unit: meter */
35+
#define fieldSolverDirSplitting 1
36+
#if (PARAM_FIELDSOLVER == 1)
37+
/* THIS CODE PATH IS ONLY USED IF `PARAM_FIELDSOLVER` IS CHANGED IN
38+
* `cmakeFlags` and the field solver there is set to fieldSolverDirSplitting
39+
*
40+
* Directional Splitting requires a fixed ratio between dt and dx
41+
* and in addition cubic cells.
42+
* conditions: dX == dt * c
43+
* dX == dY
44+
* dX == dZ
45+
*/
46+
const double CELL_WIDTH_SI = DELTA_T_SI*SPEED_OF_LIGHT_SI;
47+
#else
48+
/* cell size for Yee solver (must fulfill CFL)
49+
* WARNING: if you change the field solver in `componentsConfig` you
50+
* have to change the CELL_SIZE in this code path
51+
*/
3552
const double CELL_WIDTH_SI = 9.34635e-8;
53+
#endif
54+
#undef fieldSolverDirSplitting
55+
3656
/** equals Y - the propagation direction
3757
* unit: meter */
3858
const double CELL_HEIGHT_SI = CELL_WIDTH_SI;
@@ -47,22 +67,22 @@ namespace picongpu
4767
{32, 32}, /*y direction [negative,positive]*/
4868
{32, 32} /*z direction [negative,positive]*/
4969
}; //unit: number of cells
50-
70+
5171
//! Define the strange of the absober for any direction
5272
const float_X ABSORBER_STRENGTH[3][2] = {
5373
{1.0e-3, 1.0e-3}, /*x direction [negative,positive]*/
5474
{1.0e-3, 1.0e-3}, /*y direction [negative,positive]*/
5575
{1.0e-3, 1.0e-3} /*z direction [negative,positive]*/
56-
}; //unit: none
76+
}; //unit: none
5777

5878
const uint32_t ABSORBER_FADE_IN_STEPS = 16;
59-
79+
6080
/** When to move the co-moving window.
6181
* An initial pseudo particle, flying with the speed of light,
6282
* is fired at the begin of the simulation.
6383
* When it reaches slide_point % of the absolute(*) simulation area,
6484
* the co-moving window starts to move with the speed of light.
65-
*
85+
*
6686
* (*) Note: beware, that there is one "hidden" row of gpus at the y-front,
6787
* when you use the co-moving window
6888
* 0.75 means only 75% of simulation area is used for real simulation

examples/LaserWakefield/cmakeFlags

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,15 @@
3131

3232
flags[0]="-DCUDA_ARCH=sm_20"
3333
flags[1]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_FIELDSOLVER=fieldSolverLehe;-DPARAM_PARTICLEPUSHER=Vay"
34-
flags[2]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_FIELDSOLVER=fieldSolverDirSplitting"
35-
flags[3]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_CURRENTSOLVER=Esirkepov;-DPARAM_PARTICLESHAPE=CIC"
36-
flags[4]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_CURRENTSOLVER=VillaBune;-DPARAM_PARTICLESHAPE=CIC"
37-
flags[5]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_PRECISION=precision64Bit"
38-
flags[6]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_FIELDSOLVER=fieldSolverDirSplitting;-DPARAM_PRECISION=precision64Bit"
39-
flags[7]="-DCUDA_ARCH=sm_35 -DPARAM_OVERWRITES:LIST=-DENABLE_CURRENT=0"
40-
flags[8]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_DIMENSION=DIM2"
41-
flags[9]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_CURRENTSOLVER=Esirkepov;-DPARAM_PARTICLESHAPE=CIC;-DPARAM_DIMENSION=DIM2"
42-
flags[10]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_PRECISION=precision64Bit;-DPARAM_DIMENSION=DIM2"
43-
flags[11]="-DCUDA_ARCH=sm_35 -DPARAM_OVERWRITES:LIST=-DENABLE_CURRENT=0;-DPARAM_DIMENSION=DIM2"
44-
flags[12]="-DCUDA_ARCH=sm_35 -DPARAM_OVERWRITES:LIST=-DPARAM_IONS=1;-DPARAM_IONIZATION=1"
34+
flags[2]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_CURRENTSOLVER=Esirkepov;-DPARAM_PARTICLESHAPE=CIC"
35+
flags[3]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_CURRENTSOLVER=VillaBune;-DPARAM_PARTICLESHAPE=CIC"
36+
flags[4]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_PRECISION=precision64Bit"
37+
flags[5]="-DCUDA_ARCH=sm_35 -DPARAM_OVERWRITES:LIST=-DENABLE_CURRENT=0"
38+
flags[6]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_DIMENSION=DIM2"
39+
flags[7]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_CURRENTSOLVER=Esirkepov;-DPARAM_PARTICLESHAPE=CIC;-DPARAM_DIMENSION=DIM2"
40+
flags[8]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_PRECISION=precision64Bit;-DPARAM_DIMENSION=DIM2"
41+
flags[9]="-DCUDA_ARCH=sm_35 -DPARAM_OVERWRITES:LIST=-DENABLE_CURRENT=0;-DPARAM_DIMENSION=DIM2"
42+
flags[10]="-DCUDA_ARCH=sm_35 -DPARAM_OVERWRITES:LIST=-DPARAM_IONS=1;-DPARAM_IONIZATION=1"
4543
################################################################################
4644
# execution
4745

src/picongpu/include/fields/MaxwellSolver/DirSplitting/DirSplitting.hpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,34 @@ namespace dirSplitting
4040
{
4141
using namespace PMacc;
4242

43-
class DirSplitting
43+
/** Check Directional Splitting grid and time conditions
44+
*
45+
* This is a workaround that the condition check is only
46+
* triggered if the current used solver is `DirSplitting`
47+
*/
48+
template<typename T_UsedSolver, typename T_Dummy=void>
49+
struct ConditionCheck
50+
{
51+
};
52+
53+
template<typename T_Dummy>
54+
struct ConditionCheck<DirSplitting, T_Dummy>
55+
{
56+
/* Directional Splitting conditions:
57+
*
58+
* using SI units to avoid round off errors
59+
*/
60+
PMACC_CASSERT_MSG(DirectionSplitting_Set_dX_equal_dt_times_c____check_your_gridConfig_param_file,
61+
(SI::SPEED_OF_LIGHT_SI * SI::DELTA_T_SI) == SI::CELL_WIDTH_SI);
62+
PMACC_CASSERT_MSG(DirectionSplitting_use_cubic_cells____check_your_gridConfig_param_file,
63+
SI::CELL_HEIGHT_SI == SI::CELL_WIDTH_SI);
64+
#if (SIMDIM == DIM3)
65+
PMACC_CASSERT_MSG(DirectionSplitting_use_cubic_cells____check_your_gridConfig_param_file,
66+
SI::CELL_DEPTH_SI == SI::CELL_WIDTH_SI);
67+
#endif
68+
};
69+
70+
class DirSplitting : private ConditionCheck<fieldSolver::FieldSolver>
4471
{
4572
private:
4673
template<typename CursorE, typename CursorB, typename GridSize>

src/picongpu/include/fields/MaxwellSolver/None/NoSolver.hpp

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,31 @@ namespace picongpu
3434
{
3535
using namespace PMacc;
3636

37+
/** Check Yee grid and time conditions
38+
*
39+
* This is a workaround that the condition check is only
40+
* triggered if the current used solver is `NoSolver`
41+
*/
42+
template<typename T_UsedSolver, typename T_Dummy=void>
43+
struct ConditionCheck
44+
{
45+
};
46+
47+
template<typename T_Dummy>
48+
struct ConditionCheck<NoSolver, T_Dummy>
49+
{
50+
/* Courant-Friedrichs-Levy-Condition for Yee Field Solver: */
51+
PMACC_CASSERT_MSG(Courant_Friedrichs_Levy_condition_failure____check_your_gridConfig_param_file,
52+
(SPEED_OF_LIGHT*SPEED_OF_LIGHT*DELTA_T*DELTA_T*INV_CELL2_SUM)<=1.0);
53+
};
3754

38-
class NoSolver
55+
class NoSolver : private ConditionCheck<fieldSolver::FieldSolver>
3956
{
4057
private:
4158
typedef MappingDesc::SuperCellSize SuperCellSize;
4259

4360
MappingDesc cellDescription;
4461

45-
template<uint32_t AREA>
46-
void updateE()
47-
{
48-
return;
49-
}
50-
51-
template<uint32_t AREA>
52-
void updateBHalf()
53-
{
54-
return;
55-
}
56-
5762
public:
5863

5964
NoSolver(MappingDesc cellDescription) : cellDescription(cellDescription)

src/picongpu/include/fields/MaxwellSolver/Yee/YeeSolver.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,18 @@ class YeeSolver
5757
private:
5858
typedef MappingDesc::SuperCellSize SuperCellSize;
5959

60+
6061
FieldE* fieldE;
6162
FieldB* fieldB;
6263
MappingDesc cellDescription;
6364

6465
template<uint32_t AREA>
6566
void updateE()
6667
{
68+
/* Courant-Friedrichs-Levy-Condition for Yee Field Solver: */
69+
PMACC_CASSERT_MSG(Courant_Friedrichs_Levy_condition_failure____check_your_gridConfig_param_file,
70+
(SPEED_OF_LIGHT*SPEED_OF_LIGHT*DELTA_T*DELTA_T*INV_CELL2_SUM)<=1.0);
71+
6772
typedef SuperCellDescription<
6873
SuperCellSize,
6974
typename CurlB::LowerMargin,

src/picongpu/include/simulation_defines/unitless/gridConfig.unitless

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,4 @@ namespace picongpu
4747
const float_X INV_CELL2_SUM = 1.0 / ( CELL_WIDTH * CELL_WIDTH );
4848
#endif
4949

50-
/* Courant-Friedrichs-Levy-Condition for Yee Field Solver: */
51-
PMACC_CASSERT_MSG(Courant_Friedrichs_Levy_condition_failure____check_your_gridConfig_param_file,
52-
(SPEED_OF_LIGHT*SPEED_OF_LIGHT*DELTA_T*DELTA_T*INV_CELL2_SUM)<=1.0);
53-
5450
}

0 commit comments

Comments
 (0)