PLUTO
init.c File Reference

Contains basic functions for problem initialization. More...

#include "pluto.h"
Include dependency graph for init.c:

Go to the source code of this file.

Functions

void Init (double *v, double x1, double x2, double x3)
 
void Analysis (const Data *d, Grid *grid)
 
void BackgroundField (double x1, double x2, double x3, double *B0)
 
void UserDefBoundary (const Data *d, RBox *box, int side, Grid *grid)
 

Detailed Description

Contains basic functions for problem initialization.

The init.c file collects most of the user-supplied functions useful for problem configuration. It is automatically searched for by the makefile.

Author
A. Mignone (migno.nosp@m.ne@p.nosp@m.h.uni.nosp@m.to.i.nosp@m.t)
Date
Sept 10, 2012

Definition in file init.c.

Function Documentation

void Analysis ( const Data d,
Grid grid 
)

Perform runtime data analysis.

Parameters
[in]dthe PLUTO Data structure
[in]gridpointer to array of Grid structures

Definition at line 66 of file init.c.

74 {
75 
76 }
void BackgroundField ( double  x1,
double  x2,
double  x3,
double *  B0 
)

Define the component of a static, curl-free background magnetic field.

Parameters
[in]x1position in the 1st coordinate direction $x_1$
[in]x2position in the 2nd coordinate direction $x_2$
[in]x3position in the 3rd coordinate direction $x_3$
[out]B0array containing the vector componens of the background magnetic field

Definition at line 79 of file init.c.

90 {
91  B0[0] = 0.0;
92  B0[1] = 0.0;
93  B0[2] = 0.0;
94 }

Here is the caller graph for this function:

void Init ( double *  v,
double  x1,
double  x2,
double  x3 
)

The Init() function can be used to assign initial conditions as as a function of spatial position.

Parameters
[out]va pointer to a vector of primitive variables
[in]x1coordinate point in the 1st dimension
[in]x2coordinate point in the 2nd dimension
[in]x3coordinate point in the 3rdt dimension

The meaning of x1, x2 and x3 depends on the geometry:

\[ \begin{array}{cccl} x_1 & x_2 & x_3 & \mathrm{Geometry} \\ \noalign{\medskip} \hline x & y & z & \mathrm{Cartesian} \\ \noalign{\medskip} R & z & - & \mathrm{cylindrical} \\ \noalign{\medskip} R & \phi & z & \mathrm{polar} \\ \noalign{\medskip} r & \theta & \phi & \mathrm{spherical} \end{array} \]

Variable names are accessed by means of an index v[nv], where nv = RHO is density, nv = PRS is pressure, nv = (VX1, VX2, VX3) are the three components of velocity, and so forth.

Definition at line 17 of file init.c.

43 {
44  v[RHO] = 1.0;
45  v[VX1] = 0.0;
46  v[VX2] = 0.0;
47  v[VX3] = 0.0;
48  #if HAVE_ENERGY
49  v[PRS] = 1.0;
50  #endif
51  v[TRC] = 0.0;
52 
53  #if PHYSICS == MHD || PHYSICS == RMHD
54 
55  v[BX1] = 0.0;
56  v[BX2] = 0.0;
57  v[BX3] = 0.0;
58 
59  v[AX1] = 0.0;
60  v[AX2] = 0.0;
61  v[AX3] = 0.0;
62 
63  #endif
64 }
#define VX2
Definition: mod_defs.h:29
#define RHO
Definition: mod_defs.h:19
#define AX2
Definition: mod_defs.h:86
#define TRC
Definition: pluto.h:581
#define VX1
Definition: mod_defs.h:28
#define AX3
Definition: mod_defs.h:87
#define BX3
Definition: mod_defs.h:27
#define AX1
Definition: mod_defs.h:85
#define BX1
Definition: mod_defs.h:25
#define VX3
Definition: mod_defs.h:30
#define BX2
Definition: mod_defs.h:26

Here is the caller graph for this function:

void UserDefBoundary ( const Data d,
RBox box,
int  side,
Grid grid 
)

Assign user-defined boundary conditions.

Parameters
[in,out]dpointer to the PLUTO data structure containing cell-centered primitive quantities (d->Vc) and staggered magnetic fields (d->Vs, when used) to be filled.
[in]boxpointer to a RBox structure containing the lower and upper indices of the ghost zone-centers/nodes or edges at which data values should be assigned.
[in]sidespecifies the boundary side where ghost zones need to be filled. It can assume the following pre-definite values: X1_BEG, X1_END, X2_BEG, X2_END, X3_BEG, X3_END. The special value side == 0 is used to control a region inside the computational domain.
[in]gridpointer to an array of Grid structures.

Definition at line 98 of file init.c.

119 {
120  int i, j, k, nv;
121  double *x1, *x2, *x3;
122 
123  x1 = grid[IDIR].x;
124  x2 = grid[JDIR].x;
125  x3 = grid[KDIR].x;
126 
127  if (side == 0) { /* -- check solution inside domain -- */
128  DOM_LOOP(k,j,i){};
129  }
130 
131  if (side == X1_BEG){ /* -- X1_BEG boundary -- */
132  if (box->vpos == CENTER) {
133  BOX_LOOP(box,k,j,i){ }
134  }else if (box->vpos == X1FACE){
135  BOX_LOOP(box,k,j,i){ }
136  }else if (box->vpos == X2FACE){
137  BOX_LOOP(box,k,j,i){ }
138  }else if (box->vpos == X3FACE){
139  BOX_LOOP(box,k,j,i){ }
140  }
141  }
142 
143  if (side == X1_END){ /* -- X1_END boundary -- */
144  if (box->vpos == CENTER) {
145  BOX_LOOP(box,k,j,i){ }
146  }else if (box->vpos == X1FACE){
147  BOX_LOOP(box,k,j,i){ }
148  }else if (box->vpos == X2FACE){
149  BOX_LOOP(box,k,j,i){ }
150  }else if (box->vpos == X3FACE){
151  BOX_LOOP(box,k,j,i){ }
152  }
153  }
154 
155  if (side == X2_BEG){ /* -- X2_BEG boundary -- */
156  if (box->vpos == CENTER) {
157  BOX_LOOP(box,k,j,i){ }
158  }else if (box->vpos == X1FACE){
159  BOX_LOOP(box,k,j,i){ }
160  }else if (box->vpos == X2FACE){
161  BOX_LOOP(box,k,j,i){ }
162  }else if (box->vpos == X3FACE){
163  BOX_LOOP(box,k,j,i){ }
164  }
165  }
166 
167  if (side == X2_END){ /* -- X2_END boundary -- */
168  if (box->vpos == CENTER) {
169  BOX_LOOP(box,k,j,i){ }
170  }else if (box->vpos == X1FACE){
171  BOX_LOOP(box,k,j,i){ }
172  }else if (box->vpos == X2FACE){
173  BOX_LOOP(box,k,j,i){ }
174  }else if (box->vpos == X3FACE){
175  BOX_LOOP(box,k,j,i){ }
176  }
177  }
178 
179  if (side == X3_BEG){ /* -- X3_BEG boundary -- */
180  if (box->vpos == CENTER) {
181  BOX_LOOP(box,k,j,i){ }
182  }else if (box->vpos == X1FACE){
183  BOX_LOOP(box,k,j,i){ }
184  }else if (box->vpos == X2FACE){
185  BOX_LOOP(box,k,j,i){ }
186  }else if (box->vpos == X3FACE){
187  BOX_LOOP(box,k,j,i){ }
188  }
189  }
190 
191  if (side == X3_END){ /* -- X3_END boundary -- */
192  if (box->vpos == CENTER) {
193  BOX_LOOP(box,k,j,i){ }
194  }else if (box->vpos == X1FACE){
195  BOX_LOOP(box,k,j,i){ }
196  }else if (box->vpos == X2FACE){
197  BOX_LOOP(box,k,j,i){ }
198  }else if (box->vpos == X3FACE){
199  BOX_LOOP(box,k,j,i){ }
200  }
201  }
202 }
#define X3_BEG
Boundary region at X3 beg.
Definition: pluto.h:150
#define X1_BEG
Boundary region at X1 beg.
Definition: pluto.h:146
DOM_LOOP(k, j, i)
Definition: analysis.c:22
#define CENTER
Definition: pluto.h:200
int vpos
Location of the variable inside the cell.
Definition: structs.h:359
#define X3FACE
Definition: pluto.h:203
#define BOX_LOOP(B, k, j, i)
Definition: macros.h:70
#define X1_END
Boundary region at X1 end.
Definition: pluto.h:147
#define KDIR
Definition: pluto.h:195
#define X1FACE
Definition: pluto.h:201
#define IDIR
Definition: pluto.h:193
#define X2_END
Boundary region at X2 end.
Definition: pluto.h:149
int j
Definition: analysis.c:2
int k
Definition: analysis.c:2
double * x
Definition: structs.h:80
#define X3_END
Boundary region at X3 end.
Definition: pluto.h:151
int i
Definition: analysis.c:2
#define X2_BEG
Boundary region at X2 beg.
Definition: pluto.h:148
#define JDIR
Definition: pluto.h:194
#define X2FACE
Definition: pluto.h:202

Here is the call graph for this function: