Skip to content

Commit 9d92bfe

Browse files
authored
Simplify input file for DIMENSIONS < 3 setups (#274)
1 parent 84c1763 commit 9d92bfe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+70
-320
lines changed

doc/source/reference/idefix.ini.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ allows for comments, which should start with ``#``.
1616

1717
``Grid`` section
1818
--------------------
19-
The grid section defines the grid total dimension. It consists of 3 entries ``X1-grid``, ``X2-grid`` and ``X3-grid``. Each entry defines the repartition of the grid points in the corresponding direction (the grid is always rectilinear).
19+
The grid section defines the grid total dimension. It consists of 3 entries ``X1-grid``, ``X2-grid`` (when DIMENSIONS>=2) and ``X3-grid`` (when DIMENSIONS=3). Each entry defines the repartition of the grid points in the corresponding direction (the grid is always rectilinear).
2020
Each entry defines a series of grid blocks which are concatenated along the direction. Each block in a direction can have a different spacing rule (uniform, log or stretched). The definition of the Grid entries is as follows
2121

2222
+----------------------------+-------------------------+------------------------------+
@@ -332,8 +332,8 @@ this block is simply ignored.
332332
------------------------
333333

334334
This section describes the boundary conditions used by the code. There are 6 entries
335-
which need to be defined: ``X1-beg``, ``X2-beg``, ``X3-beg`` for the left boundaries in the direction X1, X2, X3,
336-
and ``X1-end``, ``X2-end``, ``X3-end`` for the right boundaries. Each boundary can be assigned the following types of conditions
335+
that need to be defined: ``X1-beg``, ``X2-beg``, ``X3-beg`` for the left boundaries in the direction X1, X2, X3,
336+
and ``X1-end``, ``X2-end``, ``X3-end`` for the right boundaries. ``X2`` boundaries are mandatory only when DIMENSIONS>=2 and ``X3`` when DIMENSIONS=3. Each boundary can be assigned the following types of conditions
337337

338338
+----------------+------------------------------------------------------------------------------------------------------------------+
339339
| Boundary type | Comment |

src/dataBlock/planetarySystem/planetarySystem.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,16 @@ indirect term, with multiple planets that don't feel each others.");
8383
IDEFIX_ERROR("need to define a planet-to-primary mass ratio via planetToPrimary");
8484
}
8585
#if GEOMETRY == POLAR || GEOMETRY == CARTESIAN
86-
if ((this->data->mygrid->xbeg[KDIR] == 0)
87-
|| (this->data->mygrid->xend[KDIR] == 0)) {
88-
this->halfdisk = true;
89-
} else {
86+
#if DIMENSIONS == 3
87+
if ((this->data->mygrid->xbeg[KDIR] == 0)
88+
|| (this->data->mygrid->xend[KDIR] == 0)) {
89+
this->halfdisk = true;
90+
} else {
91+
this->halfdisk = false;
92+
}
93+
#else // DIMENSIONS == 3
9094
this->halfdisk = false;
91-
}
95+
#endif // DIMENSIONS == 3
9296
#elif GEOMETRY == SPHERICAL
9397
if ( (this->data->mygrid->xbeg[JDIR] == M_PI/2.0)
9498
|| (this->data->mygrid->xend[JDIR] == M_PI/2.0)) {

src/gravity/laplacian.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ class DataBlock;
1919
class Laplacian {
2020
public:
2121
// Types of boundary which can be treated
22-
enum LaplacianBoundaryType {internalgrav, periodic, nullgrad, nullpot, userdef, axis, origin};
22+
enum LaplacianBoundaryType {internalgrav,
23+
periodic,
24+
nullgrad,
25+
nullpot,
26+
userdef,
27+
axis,
28+
origin,
29+
undefined};
2330

2431
Laplacian() = default;
2532
Laplacian(DataBlock *, std::array<LaplacianBoundaryType,3>,

src/gravity/selfGravity.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ void SelfGravity::Init(Input &input, DataBlock *datain) {
4242
}
4343

4444
// Get the gravity-related boundary conditions
45-
for(int dir = 0 ; dir < 3 ; dir++) {
45+
for (int dir = 0 ; dir < 3 ; dir++) {
46+
this->lbound[dir] = Laplacian::LaplacianBoundaryType::undefined;
47+
this->rbound[dir] = Laplacian::LaplacianBoundaryType::undefined;
48+
}
49+
for(int dir = 0 ; dir < DIMENSIONS ; dir++) {
4650
std::string label = std::string("boundary-X")+std::to_string(dir+1)+std::string("-beg");
4751
std::string boundary = input.Get<std::string>("SelfGravity",label,0);
4852

src/grid.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Grid::Grid(Input &input) {
5555
npoints[dir] = 1;
5656
nghost[dir] = 0;
5757
std::string label = std::string("X")+std::to_string(dir+1)+std::string("-grid");
58-
int numPatch = input.Get<int>("Grid",label,0);
58+
5959

6060
if(dir<DIMENSIONS) {
6161
#if ORDER < 4
@@ -64,6 +64,7 @@ Grid::Grid(Input &input) {
6464
nghost[dir] = 3;
6565
#endif
6666
npoints[dir] = 0;
67+
int numPatch = input.Get<int>("Grid",label,0);
6768
for(int patch = 0; patch < numPatch ; patch++) {
6869
npoints[dir] += input.Get<int>("Grid",label,2+3*patch );
6970
}
@@ -73,7 +74,14 @@ Grid::Grid(Input &input) {
7374
for(int dir = 0 ; dir < 3 ; dir++) {
7475
np_tot[dir] = npoints[dir] + 2*nghost[dir];
7576
np_int[dir] = npoints[dir];
77+
lbound[dir] = undefined;
78+
rbound[dir] = undefined;
79+
}
80+
81+
// Default boundary conditions on each axis
7682

83+
84+
for(int dir = 0 ; dir < DIMENSIONS ; dir++) {
7785
std::string label = std::string("X")+std::to_string(dir+1)+std::string("-beg");
7886
std::string boundary = input.Get<std::string>("Boundary",label,0);
7987

@@ -337,6 +345,9 @@ void Grid::ShowConfig() {
337345
case userdef:
338346
lboundString="userdef";
339347
break;
348+
case undefined:
349+
lboundString="undefined";
350+
break;
340351
default:
341352
lboundString="unknown";
342353
}
@@ -362,6 +373,8 @@ void Grid::ShowConfig() {
362373
case userdef:
363374
rboundString="userdef";
364375
break;
376+
case undefined:
377+
lboundString="undefined";
365378
default:
366379
rboundString="unknown";
367380
}

src/gridHost.cpp

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,17 @@ void GridHost::MakeGrid(Input &input) {
5050

5151
// Get grid parameters from input file, block [Grid]
5252
for(int dir = 0 ; dir < 3 ; dir++) {
53-
std::string label = std::string("X")+std::to_string(dir+1)+std::string("-grid");
54-
int numPatch = input.Get<int>("Grid",label,0);
53+
// These are extra dimensions that are not being used.
5554

56-
xstart[dir] = input.Get<real>("Grid",label,1);
57-
xend[dir] = input.Get<real>("Grid",label,4+(numPatch-1)*3);
58-
59-
this->xbeg[dir] = xstart[dir];
60-
this->xend[dir] = xend[dir];
55+
if(dir<DIMENSIONS) {
56+
std::string label = std::string("X")+std::to_string(dir+1)+std::string("-grid");
57+
int numPatch = input.Get<int>("Grid",label,0);
6158

59+
xstart[dir] = input.Get<real>("Grid",label,1);
60+
xend[dir] = input.Get<real>("Grid",label,4+(numPatch-1)*3);
6261

63-
if(dir<DIMENSIONS) {
62+
this->xbeg[dir] = xstart[dir];
63+
this->xend[dir] = xend[dir];
6464
// First, we fill cells for any non strecthed patch
6565
// Loop on all the patches
6666
int idxstart = nghost[dir];
@@ -200,10 +200,16 @@ void GridHost::MakeGrid(Input &input) {
200200
} else {
201201
// dir >= DIMENSIONS/ Init simple uniform grid
202202
for(int i = 0 ; i < np_tot[dir] ; i++) {
203-
dx[dir](i) = (xend[dir]-xstart[dir])/(np_int[dir]);
204-
x[dir](i)=xstart[dir] + (i-nghost[dir]+HALF_F)*dx[dir](i);
205-
xl[dir](i)=xstart[dir] + (i-nghost[dir])*dx[dir](i);
206-
xr[dir](i)=xstart[dir] + (i-nghost[dir]+1)*dx[dir](i);
203+
// Initialize to default values
204+
xstart[dir] = -0.5;
205+
xend[dir] = 0.5;
206+
207+
this->xbeg[dir] = xstart[dir];
208+
this->xend[dir] = xend[dir];
209+
dx[dir](i) = 1.0;
210+
x[dir](i)=0.0;
211+
xl[dir](i)=-0.5;
212+
xr[dir](i)=0.5;
207213
}
208214
}
209215
}

src/idefix.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ using IdfxFileHandler = FILE*;
217217
#endif
218218

219219
// Types of boundary which can be treated
220-
enum BoundaryType { internal, periodic, reflective, outflow, shearingbox, axis, userdef};
220+
enum BoundaryType { internal, periodic, reflective, outflow, shearingbox, axis, userdef, undefined};
221221
enum BoundarySide { left, right};
222222
enum class SliceType {Cut, Average};
223223

test/HD/FargoPlanet/setup.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ void UserdefBoundary(Hydro *hydro, int dir, BoundarySide side, real t) {
4343
IdefixArray4D<real> Vc = hydro->Vc;
4444
auto *data = hydro->data;
4545
IdefixArray1D<real> x1 = data->x[IDIR];
46-
IdefixArray1D<real> x3 = data->x[KDIR];
4746
if(dir==IDIR) {
4847
int ighost,ibeg,iend;
4948
if(side == left) {
@@ -56,7 +55,6 @@ void UserdefBoundary(Hydro *hydro, int dir, BoundarySide side, real t) {
5655
ibeg, iend,
5756
KOKKOS_LAMBDA (int k, int j, int i) {
5857
real R=x1(i);
59-
real z=x3(k);
6058
real Vk = 1.0/sqrt(R);
6159

6260
Vc(RHO,k,j,i) = Vc(RHO,k,j,2*ighost - i +1);
@@ -75,7 +73,6 @@ void UserdefBoundary(Hydro *hydro, int dir, BoundarySide side, real t) {
7573
ibeg, iend,
7674
KOKKOS_LAMBDA (int k, int j, int i) {
7775
real R=x1(i);
78-
real z=x3(k);
7976
real Vk = 1.0/sqrt(R);
8077

8178
Vc(RHO,k,j,i) = Vc(RHO,k,j,ighost);

test/HD/VSI/idefix.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[Grid]
22
X1-grid 1 1.0 1024 l 3.0
33
X2-grid 1 1.2707963267948965 512 u 1.8707963267948966
4-
X3-grid 1 0.0 1 u 6.283185307179586
54

65
[TimeIntegrator]
76
CFL 0.8
@@ -22,8 +21,6 @@ X1-beg userdef
2221
X1-end outflow
2322
X2-beg outflow
2423
X2-end outflow
25-
X3-beg periodic
26-
X3-end periodic
2724

2825
[Setup]
2926
epsilon 0.1

test/HD/ViscousDisk/idefix-rkl.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[Grid]
22
X1-grid 1 1.0 64 u 3.0
33
X2-grid 1 1.2707963267948965 64 u 1.8707963267948966
4-
X3-grid 1 0.0 1 u 6.283185307179586
54

65
[TimeIntegrator]
76
CFL 0.5
@@ -23,8 +22,6 @@ X1-beg userdef
2322
X1-end userdef
2423
X2-beg userdef
2524
X2-end userdef
26-
X3-beg periodic
27-
X3-end periodic
2825

2926
[Setup]
3027
epsilon 0.1

0 commit comments

Comments
 (0)