PLUTO
init.c File Reference

Viscous compressible flow past a cylinder. 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 UserDefBoundary (const Data *d, RBox *box, int side, Grid *grid)
 

Detailed Description

Viscous compressible flow past a cylinder.

Set initial and boundary conditions for a flow past a cylinder in 2D cylindrical polar coordinates $(r,\phi)$. The cylinder has radius 1 and the domain is initially filled with constant-density and pressure gas with value $\rho = 1,\, p = 1/\Gamma$.

The velocity field is initialized using the potential flow solution for an inviscid incompressible flow around a cylinder,

\[ V_r = U\left(1 - \frac{1}{r^2}\right)\cos\theta \,,\qquad V_\phi = -U\left(1 + \frac{1}{r^2}\right)\sin\theta \]

where U, the far-field velocity, is given by the Mach number. The boundary conditions in phi are periodic while the outer radial boundary is set to inflow for negative values of x while outflow for positive values. A no-slip boundary condition is used at the fluid-solid interface.

The flow past the cylinder, no matter how small the viscosity, will acquire vorticity in a thin boundary layer adjacent to the cylinder. Boundary layer separation may occur leading to the formation of a trailing wake behind the cylinder.

The input parameters are:

  • g_inputParam[MACH]: sets the upstream Mach number
  • g_inputParam[NU_VISC]: sets the viscosity
hd_flow_past_cylinder.01.jpg
Density map for configuration #01
hd_flow_past_cylinder.04.jpg
Entropy distribution for configuration #04 using 3 levels of refinement.
Author
A. Mignone (migno.nosp@m.ne@p.nosp@m.h.uni.nosp@m.to.i.nosp@m.t)
Date
Aug 18, 2014

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 59 of file init.c.

63 {}
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 42 of file init.c.

47 {
48  double x, y;
49  double U = g_inputParam[MACH];
50 
51  v[RHO] = 1.0 + 0.05*sin(x2)*cos(x2);
52  v[PRS] = 1.0/g_gamma;
53  v[TRC] = 0.0;
54 
55  v[VX1] = U*(1.0 - 1.0/(x1*x1))*cos(x2);
56  v[VX2] = -U*(1.0 + 1.0/(x1*x1))*sin(x2);
57 }
double g_gamma
Definition: globals.h:112
#define MACH
#define VX2
Definition: mod_defs.h:29
#define RHO
Definition: mod_defs.h:19
#define TRC
Definition: pluto.h:581
#define VX1
Definition: mod_defs.h:28
double g_inputParam[32]
Array containing the user-defined parameters.
Definition: globals.h:131
double * x
Definition: structs.h:80
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.

Assign user-defined boundary conditions in the lower boundary ghost zones. The profile is top-hat:

\[ V_{ij} = \left\{\begin{array}{ll} V_{\rm jet} & \quad\mathrm{for}\quad r_i < 1 \\ \noalign{\medskip} \mathrm{Reflect}(V) & \quad\mathrm{otherwise} \end{array}\right. \]

where $ V_{\rm jet} = (\rho,v,p)_{\rm jet} = (1,M,1/\Gamma)$ and M is the flow Mach number (the unit velocity is the jet sound speed, so $ v = M$).

Assign user-defined boundary conditions:

  • left side (x beg): constant shocked values
  • bottom side (y beg): constant shocked values for x < 1/6 and reflective boundary otherwise.
  • top side (y end): time-dependent boundary: for $ x < x_s(t) = 10 t/\sin\alpha + 1/6 + 1.0/\tan\alpha $ we use fixed (post-shock) values. Unperturbed values otherwise.

Definition at line 66 of file init.c.

71 {
72  int i, j, k, nv;
73  double *x1, *x2, *x3;
74  double x, y, r, rnd, Mach;
75  double c, s;
76 
77  x1 = grid[IDIR].x;
78  x2 = grid[JDIR].x;
79  x3 = grid[KDIR].x;
80 
81  if (side == 0) { /* -- check solution inside domain -- */
82  TOT_LOOP(k,j,i){
83  }
84  }
85 
86  if (side == X1_BEG){ /* -- X1_BEG boundary -- */
87  if (box->vpos == CENTER) {
88  BOX_LOOP(box,k,j,i){
89  d->Vc[RHO][k][j][i] = d->Vc[RHO][k][j][2*IBEG - i - 1];
90  d->Vc[PRS][k][j][i] = d->Vc[PRS][k][j][2*IBEG - i - 1];
91  d->Vc[VX1][k][j][i] = -d->Vc[VX1][k][j][2*IBEG - i - 1];
92  d->Vc[VX2][k][j][i] = -d->Vc[VX2][k][j][2*IBEG - i - 1];
93  }
94  }else if (box->vpos == X1FACE){
95  BOX_LOOP(box,k,j,i){ }
96  }else if (box->vpos == X2FACE){
97  BOX_LOOP(box,k,j,i){ }
98  }else if (box->vpos == X3FACE){
99  BOX_LOOP(box,k,j,i){ }
100  }
101  }
102 
103  if (side == X1_END){ /* -- X1_END boundary -- */
104  if (box->vpos == CENTER) {
105  BOX_LOOP(box,k,j,i){
106  c = cos(x2[j]);
107  s = sin(x2[j]);
108  x = x1[i]*c;
109  y = x1[i]*s;
110  if (x < 0.0){
111 /* rnd = RandomNumber(-1.0, 1.0); */
112  rnd = 0.0;
113  Mach = g_inputParam[MACH]*(1.0 + 0.1*rnd);
114  d->Vc[RHO][k][j][i] = 1.0;
115  d->Vc[PRS][k][j][i] = 1.0/g_gamma;
116  d->Vc[VX1][k][j][i] = Mach*c;
117  d->Vc[VX2][k][j][i] = -Mach*s;
118  }else{
119  d->Vc[RHO][k][j][i] = d->Vc[RHO][k][j][IEND];
120  d->Vc[PRS][k][j][i] = d->Vc[PRS][k][j][IEND];
121  d->Vc[VX1][k][j][i] = d->Vc[VX1][k][j][IEND];
122  d->Vc[VX2][k][j][i] = d->Vc[VX2][k][j][IEND];
123  }
124 
125  }
126  }else if (box->vpos == X1FACE){
127  BOX_LOOP(box,k,j,i){ }
128  }else if (box->vpos == X2FACE){
129  BOX_LOOP(box,k,j,i){ }
130  }else if (box->vpos == X3FACE){
131  BOX_LOOP(box,k,j,i){ }
132  }
133  }
134 }
#define X1_BEG
Boundary region at X1 beg.
Definition: pluto.h:146
double g_gamma
Definition: globals.h:112
#define MACH
#define VX2
Definition: mod_defs.h:29
#define CENTER
Definition: pluto.h:200
int vpos
Location of the variable inside the cell.
Definition: structs.h:359
#define RHO
Definition: mod_defs.h:19
#define X3FACE
Definition: pluto.h:203
#define BOX_LOOP(B, k, j, i)
Definition: macros.h:70
double **** Vc
The main four-index data array used for cell-centered primitive variables.
Definition: structs.h:31
#define X1_END
Boundary region at X1 end.
Definition: pluto.h:147
#define VX1
Definition: mod_defs.h:28
#define KDIR
Definition: pluto.h:195
#define X1FACE
Definition: pluto.h:201
#define TOT_LOOP(k, j, i)
Definition: macros.h:44
#define IDIR
Definition: pluto.h:193
double g_inputParam[32]
Array containing the user-defined parameters.
Definition: globals.h:131
int j
Definition: analysis.c:2
long int IEND
Upper grid index of the computational domain in the the X1 direction for the local processor...
Definition: globals.h:37
int k
Definition: analysis.c:2
double * x
Definition: structs.h:80
tuple c
Definition: menu.py:375
#define s
int i
Definition: analysis.c:2
#define JDIR
Definition: pluto.h:194
#define X2FACE
Definition: pluto.h:202
long int IBEG
Lower grid index of the computational domain in the the X1 direction for the local processor...
Definition: globals.h:35