Skip to content

Commit 7e7c7dc

Browse files
simoniusranocha
authored andcommitted
Boundary conditions per direction (#37)
* Added individual switches for periodic boundarys in x, y and z direction. * forgot to remove some old #ifdefs * Updated MATLAB scripts accordingly. * move NONPERIODIC_BOUNDARY_EXISTS * update induction equation * update ideal_gas_Euler * updated the advection equations and changed the M_INV_B to M_INV_(X/Y/Z) as requested * fix include_physics/linear_variable_advection.h
1 parent efba4d4 commit 7e7c7dc

24 files changed

Lines changed: 1940 additions & 1798 deletions

examples/ideal_MHD.m

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@
4444
I_Tech('optimizations') = ' -cl-mad-enable -cl-no-signed-zeros -cl-finite-math-only';
4545
end
4646

47-
I_RunOps('periodic') = 'NONE'; % 'NONE', 'USE_PERIODIC'; must be set to 'USE_PERIODIC'
48-
% if periodic boundary conditions should be used
49-
50-
I_RunOps('order') = 6; I_RunOps('operator_form') = 'classical'; % order: 2, 4, 6; operator_form: classical, extended
47+
I_RunOps('periodic_x') = 'USE_PERIODIC_X'; % 'NONE', 'USE_PERIODIC_X'; must be set to 'USE_PERIODIC_X'
48+
% if periodic boundary conditions in x-direction should be used
49+
I_RunOps('periodic_y') = 'USE_PERIODIC_Y'; % 'NONE', 'USE_PERIODIC_Y'; must be set to 'USE_PERIODIC_Y'
50+
% if periodic boundary conditions in y-direction should be used
51+
I_RunOps('periodic_z') = 'USE_PERIODIC_Z'; % 'NONE', 'USE_PERIODIC_Z'; must be set to 'USE_PERIODIC_Z'
52+
% if periodic boundary conditions in z-direction should be used
53+
54+
I_RunOps('order') = 4; I_RunOps('operator_form') = 'classical'; % order: 2, 4, 6; operator_form: classical, extended
5155
I_RunOps('conservation_laws') = 'ideal_MHD';
5256
I_RunOps('testcase') = 'alfven_periodic';
5357
I_RunOps('plot_numerical_solution') = 'z';

examples/ideal_MHD_Dipole.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,12 @@
4444
I_Tech('optimizations') = ' -cl-mad-enable -cl-no-signed-zeros -cl-finite-math-only';
4545
end
4646

47-
I_RunOps('periodic') = 'NONE'; % 'NONE', 'USE_PERIODIC'; must be set to 'USE_PERIODIC'
48-
% if periodic boundary conditions should be used
47+
I_RunOps('periodic_x') = 'NONE'; % 'NONE', 'USE_PERIODIC_X'; must be set to 'USE_PERIODIC_X'
48+
% if periodic boundary conditions in x-direction should be used
49+
I_RunOps('periodic_y') = 'NONE'; % 'NONE', 'USE_PERIODIC_Y'; must be set to 'USE_PERIODIC_Y'
50+
% if periodic boundary conditions in y-direction should be used
51+
I_RunOps('periodic_z') = 'NONE'; % 'NONE', 'USE_PERIODIC_Z'; must be set to 'USE_PERIODIC_Z'
52+
% if periodic boundary conditions in z-direction should be used
4953

5054
I_RunOps('order') = 4; I_RunOps('operator_form') = 'classical'; % order: 2, 4, 6; operator_form: classical, extended
5155
I_RunOps('conservation_laws') = 'ideal_MHD';

examples/ideal_gas_Euler.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,12 @@
4444
I_Tech('optimizations') = ' -cl-mad-enable -cl-no-signed-zeros -cl-finite-math-only';
4545
end
4646

47-
I_RunOps('periodic') = 'NONE'; % 'NONE', 'USE_PERIODIC'; must be set to 'USE_PERIODIC'
48-
% if periodic boundary conditions should be used
47+
I_RunOps('periodic_x') = 'NONE'; % 'NONE', 'USE_PERIODIC_X'; must be set to 'USE_PERIODIC_X'
48+
% if periodic boundary conditions in x-direction should be used
49+
I_RunOps('periodic_y') = 'NONE'; % 'NONE', 'USE_PERIODIC_Y'; must be set to 'USE_PERIODIC_Y'
50+
% if periodic boundary conditions in y-direction should be used
51+
I_RunOps('periodic_z') = 'NONE'; % 'NONE', 'USE_PERIODIC_Z'; must be set to 'USE_PERIODIC_Z'
52+
% if periodic boundary conditions in z-direction should be used
4953

5054
I_RunOps('order') = 4; I_RunOps('operator_form') = 'classical'; % order: 2, 4, 6; operator_form: classical, extended
5155
I_RunOps('conservation_laws') = 'ideal_gas_Euler';

examples/ideal_gas_Euler_Taylor_Green_vortex.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,12 @@
4444
I_Tech('optimizations') = ' -cl-mad-enable -cl-no-signed-zeros -cl-finite-math-only';
4545
end
4646

47-
I_RunOps('periodic') = 'USE_PERIODIC'; % 'USE_PERIODIC', 'USE_PERIODIC'; must be set to 'USE_PERIODIC'
48-
% if periodic boundary conditions should be used
47+
I_RunOps('periodic_x') = 'USE_PERIODIC_X'; % 'NONE', 'USE_PERIODIC_X'; must be set to 'USE_PERIODIC_X'
48+
% if periodic boundary conditions in x-direction should be used
49+
I_RunOps('periodic_y') = 'USE_PERIODIC_Y'; % 'NONE', 'USE_PERIODIC_Y'; must be set to 'USE_PERIODIC_Y'
50+
% if periodic boundary conditions in y-direction should be used
51+
I_RunOps('periodic_z') = 'USE_PERIODIC_Z'; % 'NONE', 'USE_PERIODIC_Z'; must be set to 'USE_PERIODIC_Z'
52+
% if periodic boundary conditions in z-direction should be used
4953

5054
I_RunOps('order') = 6; I_RunOps('operator_form') = 'classical'; % order: 2, 4, 6; operator_form: classical, extended
5155
I_RunOps('conservation_laws') = 'ideal_gas_Euler';

examples/induction_equation.m

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,12 @@
4646
I_Tech('optimizations') = ' -cl-mad-enable -cl-no-signed-zeros -cl-finite-math-only';
4747
end
4848

49-
I_RunOps('periodic') = 'USE_PERIODIC'; % 'NONE', 'USE_PERIODIC'; must be set to 'USE_PERIODIC'
50-
% if periodic boundary conditions should be used
49+
I_RunOps('periodic_x') = 'USE_PERIODIC_X'; % 'NONE', 'USE_PERIODIC_X'; must be set to 'USE_PERIODIC_X'
50+
% if periodic boundary conditions in x-direction should be used
51+
I_RunOps('periodic_y') = 'USE_PERIODIC_Y'; % 'NONE', 'USE_PERIODIC_Y'; must be set to 'USE_PERIODIC_Y'
52+
% if periodic boundary conditions in y-direction should be used
53+
I_RunOps('periodic_z') = 'USE_PERIODIC_Z'; % 'NONE', 'USE_PERIODIC_Z'; must be set to 'USE_PERIODIC_Z'
54+
% if periodic boundary conditions in z-direction should be used
5155

5256
I_RunOps('order') = 4; I_RunOps('operator_form') = 'classical'; % order: 2, 4, 6; operator_form: classical, extended
5357
I_RunOps('conservation_laws') = 'induction_equation';
@@ -65,7 +69,7 @@
6569
BalanceLaws.compute_numerical_solution(field_u1, field_u2);
6670
fprintf('Total runtime: %.3f seconds Kernel runtime: %d\n', I_Results('runtime'), I_Results('kernel_runtime'));
6771

68-
if strcmp(I_RunOps('periodic'), 'USE_PERIODIC')
72+
if strcmp(I_RunOps('periodic_x'), 'USE_PERIODIC_X') && strcmp(I_RunOps('periodic_y'), 'USE_PERIODIC_Y') && strcmp(I_RunOps('periodic_z'), 'USE_PERIODIC_Z')
6973
rel_err = I_Results('rel_err');
7074
for comp=0:I_BalanceLaws('NUM_CONSERVED_VARS') - 1
7175
fprintf('Relative Error of Field Component %d: %.15f %%\n', comp, 100*rel_err(comp + 1))

examples/linear_constant_advection.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,13 @@
4545
I_Tech('optimizations') = ' -cl-mad-enable -cl-no-signed-zeros -cl-finite-math-only';
4646
end
4747

48-
I_RunOps('periodic') = 'NONE'; % 'NONE', 'USE_PERIODIC'; must be set to 'USE_PERIODIC'
49-
% if periodic boundary conditions should be used
48+
I_RunOps('periodic_x') = 'NONE'; % 'NONE', 'USE_PERIODIC_X'; must be set to 'USE_PERIODIC_X'
49+
% if periodic boundary conditions in x-direction should be used
50+
I_RunOps('periodic_y') = 'NONE'; % 'NONE', 'USE_PERIODIC_Y'; must be set to 'USE_PERIODIC_Y'
51+
% if periodic boundary conditions in y-direction should be used
52+
I_RunOps('periodic_z') = 'NONE'; % 'NONE', 'USE_PERIODIC_Z'; must be set to 'USE_PERIODIC_Z'
53+
% if periodic boundary conditions in z-direction should be used
54+
5055
I_RunOps('order') = 4; I_RunOps('operator_form') = 'classical'; % order: 2, 4, 6; operator_form: classical, extended
5156
I_RunOps('conservation_laws') = 'linear_constant_advection';
5257
I_RunOps('testcase') = 'donut';

examples/linear_variable_advection.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,12 @@
4444
I_Tech('optimizations') = ' -cl-mad-enable -cl-no-signed-zeros -cl-finite-math-only';
4545
end
4646

47-
I_RunOps('periodic') = 'NONE'; % 'NONE', 'USE_PERIODIC'; must be set to 'USE_PERIODIC'
48-
% if periodic boundary conditions should be used
47+
I_RunOps('periodic_x') = 'NONE'; % 'NONE', 'USE_PERIODIC_X'; must be set to 'USE_PERIODIC_X'
48+
% if periodic boundary conditions in x-direction should be used
49+
I_RunOps('periodic_y') = 'NONE'; % 'NONE', 'USE_PERIODIC_Y'; must be set to 'USE_PERIODIC_Y'
50+
% if periodic boundary conditions in y-direction should be used
51+
I_RunOps('periodic_z') = 'USE_PERIODIC_Z'; % 'NONE', 'USE_PERIODIC_Z'; must be set to 'USE_PERIODIC_Z'
52+
% if periodic boundary conditions in z-direction should be used
4953

5054
I_RunOps('order') = 4; I_RunOps('operator_form') = 'classical'; % order: 2, 4, 6; operator_form: classical, extended
5155
I_RunOps('conservation_laws') = 'linear_variable_advection';

include/2ndOrder.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@
1515
}
1616
*/
1717

18-
#ifdef USE_PERIODIC
18+
1919
//------------------------------------------------------------------------------
2020
// Periodic Derivative Operator
2121
//------------------------------------------------------------------------------
2222
#define ORDER 2
23-
#define NUM_BOUNDS 0
24-
#define STENCIL_WIDTH 3
23+
#define NUM_BOUNDS_P 0
24+
#define STENCIL_WIDTH_P 3
2525

2626
/*
2727
Coefficients of the first derivative operator.
2828
2929
For each row, the central coefficient corresponds to the nodes at which the
3030
derivative is computed.
3131
*/
32-
REAL constant SBP_diff[2*NUM_BOUNDS+1][STENCIL_WIDTH] = {
32+
REAL constant SBP_diff_P[2*NUM_BOUNDS_P+1][STENCIL_WIDTH_P] = {
3333
// central coefficients
3434
{-1.0/2.0, 0.0, 1.0/2.0},
3535
};
@@ -40,27 +40,27 @@ Coefficients of the inverse mass/norm matrix.
4040
4141
The central coefficient corresponds to the inner nodes of the grid and is 1.
4242
*/
43-
REAL constant M_INV[2*NUM_BOUNDS+1] = {
43+
REAL constant M_INV_P[2*NUM_BOUNDS_P+1] = {
4444
// central coefficients
4545
1.0,
4646
};
4747

48-
#else
48+
4949
//------------------------------------------------------------------------------
5050
// Non-Periodic Derivative Operator
5151
//------------------------------------------------------------------------------
5252

5353
#define ORDER 2
54-
#define NUM_BOUNDS 1
55-
#define STENCIL_WIDTH 3
54+
#define NUM_BOUNDS_B 1
55+
#define STENCIL_WIDTH_B 3
5656

5757
/*
5858
Coefficients of the first derivative operator.
5959
6060
For each row, the central coefficient corresponds to the nodes at which the
6161
derivative is computed.
6262
*/
63-
REAL constant SBP_diff[2*NUM_BOUNDS+1][STENCIL_WIDTH] = {
63+
REAL constant SBP_diff_B[2*NUM_BOUNDS_B+1][STENCIL_WIDTH_B] = {
6464
// left boundary coefficients
6565
{0.0, -1.0, 1.0},
6666
// central coefficients
@@ -75,7 +75,7 @@ Coefficients of the inverse mass/norm matrix.
7575
7676
The central coefficient corresponds to the inner nodes of the grid and is 1.
7777
*/
78-
REAL constant M_INV[2*NUM_BOUNDS+1] = {
78+
REAL constant M_INV_B[2*NUM_BOUNDS_B+1] = {
7979
// left boundary coefficients
8080
2.0,
8181
// central coefficients
@@ -84,4 +84,4 @@ REAL constant M_INV[2*NUM_BOUNDS+1] = {
8484
2.0
8585
};
8686

87-
#endif // USE_PERIODIC
87+

include/2ndOrderExtended.h

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@
1313
}
1414
*/
1515

16-
#ifdef USE_PERIODIC
16+
1717
//------------------------------------------------------------------------------
1818
// Periodic Derivative Operator
1919
//------------------------------------------------------------------------------
2020
#define ORDER 2
21-
#define NUM_BOUNDS 0
22-
#define STENCIL_WIDTH 3
21+
#define NUM_BOUNDS_P 0
22+
#define STENCIL_WIDTH_P 3
2323

2424
/*
2525
Coefficients of the first derivative operator.
2626
2727
For each row, the central coefficient corresponds to the nodes at which the
2828
derivative is computed.
2929
*/
30-
REAL constant SBP_diff[2*NUM_BOUNDS+1][STENCIL_WIDTH] = {
30+
REAL constant SBP_diff_P[2*NUM_BOUNDS_P+1][STENCIL_WIDTH_P] = {
3131
// central coefficients
3232
{-1.0/2.0, 0.0, 1.0/2.0},
3333
};
@@ -39,27 +39,27 @@ Coefficients of the inverse mass/norm matrix.
3939
4040
The central coefficient corresponds to the inner nodes of the grid and is 1.
4141
*/
42-
REAL constant M_INV[2*NUM_BOUNDS+1] = {
42+
REAL constant M_INV_P[2*NUM_BOUNDS_P+1] = {
4343
// central coefficients
4444
1.0,
4545
};
4646

47-
#else
47+
4848
//------------------------------------------------------------------------------
4949
// Non-Periodic Derivative Operator
5050
//------------------------------------------------------------------------------
5151

5252
#define ORDER 2
53-
#define NUM_BOUNDS 3
54-
#define STENCIL_WIDTH 5
53+
#define NUM_BOUNDS_B 3
54+
#define STENCIL_WIDTH_B 5
5555

5656
/*
5757
Coefficients of the first derivative operator.
5858
5959
For each row, the central coefficient corresponds to the nodes at which the
6060
derivative is computed.
6161
*/
62-
REAL constant SBP_diff[2*NUM_BOUNDS+1][STENCIL_WIDTH] = {
62+
REAL constant SBP_diff_B[2*NUM_BOUNDS_B+1][STENCIL_WIDTH_B] = {
6363
// left boundary coefficients
6464
{0.0, 0.0, -6.0/5.0, 7.0/5.0, -1.0/5.0},
6565
{0.0, -1.0/2.0, 0.0, 1.0/2.0, 0.0},
@@ -78,7 +78,7 @@ Coefficients of the inverse mass/norm matrix.
7878
7979
The central coefficient corresponds to the inner nodes of the grid and is 1.
8080
*/
81-
REAL constant M_INV[2*NUM_BOUNDS+1] = {
81+
REAL constant M_INV_B[2*NUM_BOUNDS_B+1] = {
8282
// left boundary coefficients
8383
12.0/5.0,
8484
6.0/7.0,
@@ -91,4 +91,3 @@ REAL constant M_INV[2*NUM_BOUNDS+1] = {
9191
12.0/5.0
9292
};
9393

94-
#endif // USE_PERIODIC

include/4thOrder.h

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,20 @@
1515
}
1616
*/
1717

18-
#ifdef USE_PERIODIC
1918
//------------------------------------------------------------------------------
2019
// Periodic Derivative Operator
2120
//------------------------------------------------------------------------------
2221
#define ORDER 4
23-
#define NUM_BOUNDS 0
24-
#define STENCIL_WIDTH 5
22+
#define NUM_BOUNDS_P 0
23+
#define STENCIL_WIDTH_P 5
2524

2625
/*
2726
Coefficients of the first derivative operator.
2827
2928
For each row, the central coefficient corresponds to the nodes at which the
3029
derivative is computed.
3130
*/
32-
REAL constant SBP_diff[2*NUM_BOUNDS+1][STENCIL_WIDTH] = {
31+
REAL constant SBP_diff_P[2*NUM_BOUNDS_P+1][STENCIL_WIDTH_P] = {
3332
// central coefficients
3433
{1.0/12.0, -2.0/3.0, 0.0, 2.0/3.0, -1.0/12.0},
3534
};
@@ -40,27 +39,27 @@ Coefficients of the inverse mass/norm matrix.
4039
4140
The central coefficient corresponds to the inner nodes of the grid and is 1.
4241
*/
43-
REAL constant M_INV[2*NUM_BOUNDS+1] = {
42+
REAL constant M_INV_P[2*NUM_BOUNDS_P+1] = {
4443
// central coefficients
4544
1.0
4645
};
4746

48-
#else
47+
4948
//------------------------------------------------------------------------------
5049
// Non-Periodic Derivative Operator
5150
//------------------------------------------------------------------------------
5251

5352
#define ORDER 4
54-
#define NUM_BOUNDS 4
55-
#define STENCIL_WIDTH 7
53+
#define NUM_BOUNDS_B 4
54+
#define STENCIL_WIDTH_B 7
5655

5756
/*
5857
Coefficients of the first derivative operator.
5958
6059
For each row, the central coefficient corresponds to the nodes at which the
6160
derivative is computed.
6261
*/
63-
REAL constant SBP_diff[2*NUM_BOUNDS+1][STENCIL_WIDTH] = {
62+
REAL constant SBP_diff_B[2*NUM_BOUNDS_B+1][STENCIL_WIDTH_B] = {
6463
// left boundary coefficients
6564
{0.0, 0.0, 0.0, -24.0/17.0, 59.0/34.0, -4.0/17.0, -3.0/34.0},
6665
{0.0, 0.0, -1.0/2.0, 0.0, 1.0/2.0, 0.0, 0.0},
@@ -80,7 +79,7 @@ Coefficients of the inverse mass/norm matrix.
8079
8180
The central coefficient corresponds to the inner nodes of the grid and is 1.
8281
*/
83-
REAL constant M_INV[2*NUM_BOUNDS+1] = {
82+
REAL constant M_INV_B[2*NUM_BOUNDS_B+1] = {
8483
// left boundary coefficients
8584
48.0/17.0,
8685
48.0/59.0,
@@ -95,4 +94,3 @@ REAL constant M_INV[2*NUM_BOUNDS+1] = {
9594
48.0/17.0
9695
};
9796

98-
#endif // USE_PERIODIC

0 commit comments

Comments
 (0)