Carmen Code
 All Classes Files Functions Variables Macros Pages
Public Member Functions | List of all members
PrintGrid Class Reference

An object PrintGrid is a special regular grid created to write tree-structured data into an output file. More...

#include <PrintGrid.h>

Public Member Functions

 PrintGrid (int L)
 
 ~PrintGrid ()
 
void setValue (const int i, const int j, const int k, const Vector &UserAverage)
 Sets the cell-average vector located at i, j, k to UserAverage. More...
 
Vector value (const int i, const int j, const int k) const
 Returns the cell-average vector located at i, j, k. More...
 
real value (const int i, const int j, const int k, const int QuantityNo) const
 Returns the quantity QuantityNo of the cell-average vector located at i, j, k. More...
 
real cellValue (const int i, const int j, const int k, const int QuantityNo) const
 Returns the quantity QuantityNo of the cell-average vector located at i, j, k, taking into account boundary conditions. More...
 
real density (const int i, const int j, const int k) const
 Returns the cell-average density located at i, j, k. More...
 
real psi (const int i, const int j, const int k) const
 Returns the cell-average density located at i, j, k. More...
 
real pressure (const int i, const int j, const int k) const
 Returns the cell-average pressure located at i, j, k. More...
 
real temperature (const int i, const int j, const int k) const
 Returns the cell-average temperature located at i, j, k. More...
 
real concentration (const int i, const int j, const int k) const
 Returns the cell-average concentration of the limiting reactant, located at i, j, k. More...
 
real energy (const int i, const int j, const int k) const
 Returns the cell-average energy per unit of volume located at i, j, k. More...
 
real velocity (const int i, const int j, const int k, const int AxisNo) const
 Returns the AxisNo-th component of the cell-average velocity located at i, j, k. More...
 
Vector velocity (const int i, const int j, const int k) const
 Returns the cell-average velocity located at i, j, k. More...
 
real divergenceB (const int i, const int j, const int k) const
 Returns the divergence of magnetic field B located at i, j, k. More...
 
real vorticity (const int i, const int j, const int k) const
 Returns 0 in 1D, the scalar vorticity in 2D, the norm of the cell-average vorticity in 3D, located at i, j, k. Does not work for MHD! More...
 
real magField (const int i, const int j, const int k, const int AxisNo) const
 Returns the AxisNo-th component of the cell-average velocity located at i, j, k. More...
 
Vector magField (const int i, const int j, const int k) const
 Returns the cell-average velocity located at i, j, k. More...
 
void refresh ()
 Stores the cell-average values of the current grid into temporary values, in order to compute cell-averages in the next finer grid. More...
 
void predict (const int l, const int i, const int j, const int k)
 Predicts the cell-average values of the current grid from the values stored in the temporary ones. More...
 
void computePointValue ()
 Transform cell-average values into point values. More...
 

Detailed Description

An object PrintGrid is a special regular grid created to write tree-structured data into an output file.

It contains the following data:

To write tree-structured data into a regular fine grid, one starts with the grid of level 0 and one stops at the level L. For a given grid of level l and a given element i, j, k of this grid, if the node of the tree corresponding to the element is a leaf, the value is replaced by the one of the node, else it is predicted from parents.

Such grid does not contain any cell information, in order to reduce memory requirements.

Constructor & Destructor Documentation

PrintGrid::PrintGrid ( int  L)

Constructor of PrintGrid class. Generates a grid of 2**(Dimension*L) elements.

31 {
32 
33  int n=0; // Array size
34 
35  localScaleNb=L;
36  elementNb = n = (1<<localScaleNb)+1;
37  if (Dimension > 1) elementNb *= n;
38  if (Dimension > 2) elementNb *= n;
39 
40  Q = new Vector[elementNb];
41  Qt = new Vector[elementNb];
42 
43  int i;
44  for (i=0;i<elementNb;i++)
45  {
47  Qt[i].setDimension(QuantityNb);
48  }
49 
50 
51 }
int QuantityNb
Definition: Parameters.cpp:171
Standard class for every vector in Carmen.
Definition: Vector.h:29
int Dimension
Definition: Parameters.cpp:74
void setDimension(const int n)
Sets the dimension of the vector to n and reset values to zero.
Definition: Vector.cpp:298
PrintGrid::~PrintGrid ( )

Distructor of the PrintGrid class. Removes the grid.

60 {
61  delete[] Q;
62  delete[] Qt;
63 }

Member Function Documentation

real PrintGrid::cellValue ( const int  i,
const int  j,
const int  k,
const int  QuantityNo 
) const

Returns the quantity QuantityNo of the cell-average vector located at i, j, k, taking into account boundary conditions.

Parameters
iPosition x
jPosition y
kPosition z
QuantityNoNumber of MHD variables.
Returns
real
114 {
115  // --- Local variables ---
116 
117  int n = (1<<localScaleNb)+1; // n = 2^localScaleNb+1
118  int li=0, lj=0, lk=0; // local i,j,k
119 
120 
121  if (CMin[1] == 2)
122  li = ((i+n)/n==1)? i : (2*n-i-1)%n; // Neumann
123  else
124  li = (i+n)%n; // Periodic
125 
126  // -- in y --
127 
128  if (Dimension > 1)
129  {
130  if (CMin[2] == 2)
131  lj = ((j+n)/n==1)? j : (2*n-j-1)%n; // Neumann
132  else
133  lj = (j+n)%n; // Periodic
134  }
135 
136  // -- in z --
137 
138  if (Dimension > 2)
139  {
140  if (CMin[3] == 2)
141  lk = ((k+n)/n==1)? k : (2*n-k-1)%n; // Neumann
142  else
143  lk = (k+n)%n; // Periodic
144  }
145 
146  return (Q + li + n*(lj + n*lk))->value(QuantityNo);
147 }
int CMin[4]
Definition: Parameters.cpp:78
int Dimension
Definition: Parameters.cpp:74
Vector value(const int i, const int j, const int k) const
Returns the cell-average vector located at i, j, k.
Definition: PrintGrid.cpp:86

Here is the caller graph for this function:

void PrintGrid::computePointValue ( )

Transform cell-average values into point values.

Returns
void
544 {
545  int i=0, j=0, k=0;
546  int l=localScaleNb;
547  int n=(1<<l);
548 
549  switch(Dimension)
550  {
551  case 1:
552  for (i=0;i<=n;i++)
553  setValue(i,j,k,.5*(tempValue(l,i-1,j,k)+tempValue(l,i,j,k)));
554  break;
555 
556  case 2:
557  for (i=0;i<=n;i++)
558  for (j=0;j<=n;j++)
559  setValue(i,j,k, .25*(tempValue(l,i-1,j-1,k)+tempValue(l,i-1,j,k)+tempValue(l,i,j-1,k)+tempValue(l,i,j,k)) );
560  break;
561 
562  default:
563  for (i=0;i<=n;i++)
564  for (j=0;j<=n;j++)
565  for (k=0;k<=n;k++)
566  setValue(i,j,k,.125*(tempValue(l,i-1,j-1,k-1)+tempValue(l,i-1,j,k-1)+tempValue(l,i,j-1,k-1)+tempValue(l,i,j,k-1)
567  +tempValue(l,i-1,j-1,k)+tempValue(l,i-1,j,k)+tempValue(l,i,j-1,k)+tempValue(l,i,j,k)) );
568  break;
569  };
570 }
int Dimension
Definition: Parameters.cpp:74
void setValue(const int i, const int j, const int k, const Vector &UserAverage)
Sets the cell-average vector located at i, j, k to UserAverage.
Definition: PrintGrid.cpp:71
real PrintGrid::concentration ( const int  i,
const int  j,
const int  k 
) const

Returns the cell-average concentration of the limiting reactant, located at i, j, k.

Parameters
iPosition x
jPosition y
kPosition z
Returns
real
220 {
221 
222  if (EquationType >=3 && EquationType <=5)
223  return value(i,j,k,2);
224 
225  return 0.;
226 }
int EquationType
Definition: Parameters.cpp:66
Vector value(const int i, const int j, const int k) const
Returns the cell-average vector located at i, j, k.
Definition: PrintGrid.cpp:86
real PrintGrid::density ( const int  i,
const int  j,
const int  k 
) const
inline

Returns the cell-average density located at i, j, k.

Parameters
iPosition x
jPosition y
kPosition z
Returns
real
307 {
308  return value(i,j,k,1);
309 }
Vector value(const int i, const int j, const int k) const
Returns the cell-average vector located at i, j, k.
Definition: PrintGrid.cpp:86

Here is the caller graph for this function:

real PrintGrid::divergenceB ( const int  i,
const int  j,
const int  k 
) const

Returns the divergence of magnetic field B located at i, j, k.

Parameters
iPosition x
jPosition y
kPosition z
Returns
real
236 {
237  int L=localScaleNb;
238  int n = (1<<L);
239  real dx=0., dy=0., dz=0.;
240  real Div=0.;
241  real By1=0., By2=0., Bz1=0., Bz2=0.;
242  real Bx1=0., Bx2=0.;
243  real Bx =0., By=0.;
244  if (Dimension == 1){
245  dx = (XMax[1]-XMin[1])/n;
246 
247  Bx1 = magField(BC(i-1,1,n), BC(j,2,n),BC(k,3,n),1);
248  Bx2 = magField(BC(i+1,1,n), BC(j,2,n),BC(k,3,n),1);
249 
250  Div = (Bx2-Bx1)/(2.*dx);
251 
252  }else if (Dimension == 2){
253 
254  dx = (XMax[1]-XMin[1])/n;
255  dy = (XMax[2]-XMin[2])/n;
256  Bx1 = magField(BC(i-1,1,n), BC(j ,2,n),BC(k,3,n),1);
257  Bx2 = magField(BC(i+1,1,n), BC(j ,2,n),BC(k,3,n),1);
258  By1 = magField(BC(i ,1,n), BC(j-1,2,n),BC(k,3,n),2);
259  By2 = magField(BC(i ,1,n), BC(j+1,2,n),BC(k,3,n),2);
260  Bx = magField(BC(i,1,n), BC(j,2,n),BC(k,3,n),1);
261  By = magField(BC(i,1,n), BC(j,2,n),BC(k,3,n),2);
262 
263  //if(Bx2!=Bx1 && By2!=By1)
264  Div = ((Bx2-Bx1)/(dx) + (By2-By1)/(dy))/((fabs(Bx1)+fabs(Bx2))/(dx) + (fabs(By1)+fabs(By2))/(dy) + 1.120e-13);
265  //else
266  // Div = ((Bx2-Bx1)/(2.*dx) + (By2-By1)/(2.*dy));
267  }else if (Dimension == 3){
268 
269  dx = (XMax[1]-XMin[1])/n;
270  dy = (XMax[2]-XMin[2])/n;
271  dz = (XMax[3]-XMin[3])/n;
272 
273  Bx1 = magField(BC(i-1,1,n), BC(j ,2,n),BC(k ,3,n),1);
274  Bx2 = magField(BC(i+1,1,n), BC(j ,2,n),BC(k ,3,n),1);
275  By1 = magField(BC(i ,1,n), BC(j-1,2,n),BC(k ,3,n),2);
276  By2 = magField(BC(i ,1,n), BC(j+1,2,n),BC(k ,3,n),2);
277  Bz1 = magField(BC(i ,1,n), BC(j ,2,n),BC(k-1,3,n),3);
278  Bz2 = magField(BC(i ,1,n), BC(j ,2,n),BC(k+1,3,n),3);
279 
280  Div = (Bx2-Bx1)/(2.*dx) + (By2-By1)/(2.*dy) + (Bz2-Bz1)/(2.*dz);
281 
282  }
283 
284  return Div;
285 }
real XMax[4]
Definition: Parameters.cpp:77
real magField(const int i, const int j, const int k, const int AxisNo) const
Returns the AxisNo-th component of the cell-average velocity located at i, j, k.
Definition: PrintGrid.h:347
int Dimension
Definition: Parameters.cpp:74
int BC(int i, int AxisNo, int N)
Returns the position of i taking into account the boundary conditions in the direction AxisNo...
Definition: BC.cpp:37
real XMin[4]
Definition: Parameters.cpp:76
#define real
Definition: PreProcessor.h:31

Here is the caller graph for this function:

real PrintGrid::energy ( const int  i,
const int  j,
const int  k 
) const
inline

Returns the cell-average energy per unit of volume located at i, j, k.

Parameters
iPosition x
jPosition y
kPosition z
Returns
real
327 {
328  return value(i,j,k,5);
329 }
Vector value(const int i, const int j, const int k) const
Returns the cell-average vector located at i, j, k.
Definition: PrintGrid.cpp:86

Here is the caller graph for this function:

real PrintGrid::magField ( const int  i,
const int  j,
const int  k,
const int  AxisNo 
) const
inline

Returns the AxisNo-th component of the cell-average velocity located at i, j, k.

Parameters
iPosition x
jPosition y
kPosition z
AxisNoAxis of interest
Returns
real
348 {
349  return cellValue(i,j,k,AxisNo+6);
350 }
real cellValue(const int i, const int j, const int k, const int QuantityNo) const
Returns the quantity QuantityNo of the cell-average vector located at i, j, k, taking into account bo...
Definition: PrintGrid.cpp:113

Here is the caller graph for this function:

Vector PrintGrid::magField ( const int  i,
const int  j,
const int  k 
) const

Returns the cell-average velocity located at i, j, k.

Parameters
iPosition x
jPosition y
kPosition z
Returns
Vector
170 {
171  Vector V(3);
172 
173  for (int AxisNo=1; AxisNo <= 3; AxisNo++)
174  V.setValue( AxisNo, cellValue(i,j,k,AxisNo+6));
175 
176  return V;
177 }
Standard class for every vector in Carmen.
Definition: Vector.h:29
real cellValue(const int i, const int j, const int k, const int QuantityNo) const
Returns the quantity QuantityNo of the cell-average vector located at i, j, k, taking into account bo...
Definition: PrintGrid.cpp:113
void PrintGrid::predict ( const int  l,
const int  i,
const int  j,
const int  k 
)

Predicts the cell-average values of the current grid from the values stored in the temporary ones.

Parameters
lLevel
iPosition x
jPosition y
kPosition z
Returns
void
475 {
476  // --- Local variables ---
477 
478  int pi=1, pj=1, pk=1; // Parity of i,j,k
479 
480  Vector Result(QuantityNb);
481 
482  // --- Init result with the cell-average value of Qt ---
483 
484  Result = tempValue(l-1,(i+4)/2-2,(j+4)/2-2,(k+4)/2-2);
485 
486  // --- 1D case ---
487 
488  pi = (i%2 == 0)?1:-1;
489  Result += (pi*-.125) * tempValue(l-1,(i+4)/2-2+1,(j+4)/2-2,(k+4)/2-2);
490  Result -= (pi*-.125) * tempValue(l-1,(i+4)/2-2-1,(j+4)/2-2,(k+4)/2-2);
491 
492  // --- 2D case ---
493 
494  if (Dimension > 1)
495  {
496  pj = (j%2 == 0)?1:-1;
497  Result += (pj*-.125) * tempValue(l-1,(i+4)/2-2,(j+4)/2-2+1,(k+4)/2-2);
498  Result -= (pj*-.125) * tempValue(l-1,(i+4)/2-2,(j+4)/2-2-1,(k+4)/2-2);
499 
500  Result += (pi*pj*.015625) * tempValue(l-1,(i+4)/2-2+1,(j+4)/2-2+1,(k+4)/2-2);
501  Result -= (pi*pj*.015625) * tempValue(l-1,(i+4)/2-2+1,(j+4)/2-2-1,(k+4)/2-2);
502  Result -= (pi*pj*.015625) * tempValue(l-1,(i+4)/2-2-1,(j+4)/2-2+1,(k+4)/2-2);
503  Result += (pi*pj*.015625) * tempValue(l-1,(i+4)/2-2-1,(j+4)/2-2-1,(k+4)/2-2);
504  }
505 
506  // --- 3D case ---
507 
508  if (Dimension > 2)
509  {
510  pk = (k%2 == 0)?1:-1;
511  Result += (pk*-.125) * tempValue(l-1,(i+4)/2-2,(j+4)/2-2,(k+4)/2-2+1);
512  Result -= (pk*-.125) * tempValue(l-1,(i+4)/2-2,(j+4)/2-2,(k+4)/2-2-1);
513 
514  Result += (pi*pk*.015625) * tempValue(l-1,(i+4)/2-2+1,(j+4)/2-2,(k+4)/2-2+1);
515  Result -= (pi*pk*.015625) * tempValue(l-1,(i+4)/2-2+1,(j+4)/2-2,(k+4)/2-2-1);
516  Result -= (pi*pk*.015625) * tempValue(l-1,(i+4)/2-2-1,(j+4)/2-2,(k+4)/2-2+1);
517  Result += (pi*pk*.015625) * tempValue(l-1,(i+4)/2-2-1,(j+4)/2-2,(k+4)/2-2-1);
518 
519  Result += (pj*pk*.015625) * tempValue(l-1,(i+4)/2-2,(j+4)/2-2+1,(k+4)/2-2+1);
520  Result -= (pj*pk*.015625) * tempValue(l-1,(i+4)/2-2,(j+4)/2-2+1,(k+4)/2-2-1);
521  Result -= (pj*pk*.015625) * tempValue(l-1,(i+4)/2-2,(j+4)/2-2-1,(k+4)/2-2+1);
522  Result += (pj*pk*.015625) * tempValue(l-1,(i+4)/2-2,(j+4)/2-2-1,(k+4)/2-2-1);
523 
524  Result += (pi*pj*pk*-.001953125) * tempValue(l-1,(i+4)/2-2+1,(j+4)/2-2+1,(k+4)/2-2+1);
525  Result -= (pi*pj*pk*-.001953125) * tempValue(l-1,(i+4)/2-2+1,(j+4)/2-2+1,(k+4)/2-2-1);
526  Result -= (pi*pj*pk*-.001953125) * tempValue(l-1,(i+4)/2-2+1,(j+4)/2-2-1,(k+4)/2-2+1);
527  Result += (pi*pj*pk*-.001953125) * tempValue(l-1,(i+4)/2-2+1,(j+4)/2-2-1,(k+4)/2-2-1);
528  Result -= (pi*pj*pk*-.001953125) * tempValue(l-1,(i+4)/2-2-1,(j+4)/2-2+1,(k+4)/2-2+1);
529  Result += (pi*pj*pk*-.001953125) * tempValue(l-1,(i+4)/2-2-1,(j+4)/2-2+1,(k+4)/2-2-1);
530  Result += (pi*pj*pk*-.001953125) * tempValue(l-1,(i+4)/2-2-1,(j+4)/2-2-1,(k+4)/2-2+1);
531  Result -= (pi*pj*pk*-.001953125) * tempValue(l-1,(i+4)/2-2-1,(j+4)/2-2-1,(k+4)/2-2-1);
532  }
533 
534  setValue(i,j,k,Result);
535 }
int QuantityNb
Definition: Parameters.cpp:171
Standard class for every vector in Carmen.
Definition: Vector.h:29
int Dimension
Definition: Parameters.cpp:74
real pi
Definition: Parameters.cpp:165
void setValue(const int i, const int j, const int k, const Vector &UserAverage)
Sets the cell-average vector located at i, j, k to UserAverage.
Definition: PrintGrid.cpp:71

Here is the caller graph for this function:

real PrintGrid::pressure ( const int  i,
const int  j,
const int  k 
) const

Returns the cell-average pressure located at i, j, k.

Parameters
iPosition x
jPosition y
kPosition z
Returns
real
185 {
186  Vector V(3), B(3);
187  real rho, rhoE;
188 
189  rho = density(i,j,k);
190  V = velocity(i,j,k);
191  B = magField(i,j,k);
192  rhoE = energy(i,j,k);
193 
194  return (Gamma-1.)*(rhoE - .5*rho*(V*V) - .5*(B*B));
195 }
Standard class for every vector in Carmen.
Definition: Vector.h:29
real magField(const int i, const int j, const int k, const int AxisNo) const
Returns the AxisNo-th component of the cell-average velocity located at i, j, k.
Definition: PrintGrid.h:347
real Gamma
Definition: Parameters.cpp:109
real velocity(const int i, const int j, const int k, const int AxisNo) const
Returns the AxisNo-th component of the cell-average velocity located at i, j, k.
Definition: PrintGrid.h:337
real energy(const int i, const int j, const int k) const
Returns the cell-average energy per unit of volume located at i, j, k.
Definition: PrintGrid.h:326
real density(const int i, const int j, const int k) const
Returns the cell-average density located at i, j, k.
Definition: PrintGrid.h:306
#define real
Definition: PreProcessor.h:31

Here is the caller graph for this function:

real PrintGrid::psi ( const int  i,
const int  j,
const int  k 
) const
inline

Returns the cell-average density located at i, j, k.

Parameters
iPosition x
jPosition y
kPosition z
Returns
real
317 {
318  return value(i,j,k,6);
319 }
Vector value(const int i, const int j, const int k) const
Returns the cell-average vector located at i, j, k.
Definition: PrintGrid.cpp:86

Here is the caller graph for this function:

void PrintGrid::refresh ( )

Stores the cell-average values of the current grid into temporary values, in order to compute cell-averages in the next finer grid.

Returns
void
463 {
464  for (int n=0; n<elementNb; n++)
465  *(Qt+n) = *(Q+n);
466 }

Here is the caller graph for this function:

void PrintGrid::setValue ( const int  i,
const int  j,
const int  k,
const Vector UserAverage 
)

Sets the cell-average vector located at i, j, k to UserAverage.

Parameters
iPosition x
jPosition y
kPosition z
UserAverageVector of averages
Returns
void
72 {
73  // --- Local variables ---
74 
75  int n=(1<<localScaleNb)+1; // n = 2^localScaleNb+1
76 
77  *(Q + i + n*(j + n*k)) = UserAverage;
78 }

Here is the caller graph for this function:

real PrintGrid::temperature ( const int  i,
const int  j,
const int  k 
) const

Returns the cell-average temperature located at i, j, k.

Parameters
iPosition x
jPosition y
kPosition z
Returns
real
203 {
204  real rho, p;
205 
206  if (EquationType >=3 && EquationType <=5)
207  return value(i,j,k,1);
208 
209  rho = density(i,j,k);
210  p = pressure(i,j,k);
211 
212  return Gamma*Ma*Ma*p/rho;
213 }
real pressure(const int i, const int j, const int k) const
Returns the cell-average pressure located at i, j, k.
Definition: PrintGrid.cpp:184
real Gamma
Definition: Parameters.cpp:109
int EquationType
Definition: Parameters.cpp:66
Vector value(const int i, const int j, const int k) const
Returns the cell-average vector located at i, j, k.
Definition: PrintGrid.cpp:86
real density(const int i, const int j, const int k) const
Returns the cell-average density located at i, j, k.
Definition: PrintGrid.h:306
real Ma
Definition: Parameters.cpp:110
#define real
Definition: PreProcessor.h:31
Vector PrintGrid::value ( const int  i,
const int  j,
const int  k 
) const

Returns the cell-average vector located at i, j, k.

Parameters
iPosition x
jPosition y
kPosition z
Returns
Vector
87 {
88  // --- Local variables ---
89 
90  int n = (1<<localScaleNb)+1; // n = 2^localScaleNb
91 
92  return *(Q + i + n*(j + n*k));
93 }

Here is the caller graph for this function:

real PrintGrid::value ( const int  i,
const int  j,
const int  k,
const int  QuantityNo 
) const

Returns the quantity QuantityNo of the cell-average vector located at i, j, k.

Parameters
iPosition x
jPosition y
kPosition z
QuantityNoNumber of MHD variables.
Returns
real
100 {
101  // --- Local variables ---
102 
103  int n = (1<<localScaleNb)+1; // n = 2^localScaleNb
104 
105  return (Q + i + n*(j + n*k))->value(QuantityNo);
106 }
Vector value(const int i, const int j, const int k) const
Returns the cell-average vector located at i, j, k.
Definition: PrintGrid.cpp:86
real PrintGrid::velocity ( const int  i,
const int  j,
const int  k,
const int  AxisNo 
) const
inline

Returns the AxisNo-th component of the cell-average velocity located at i, j, k.

Parameters
iPosition x
jPosition y
kPosition z
AxisNoAxis of interest.
Returns
real
338 {
339  return cellValue(i,j,k,AxisNo+1)/cellValue(i,j,k,1);
340 }
real cellValue(const int i, const int j, const int k, const int QuantityNo) const
Returns the quantity QuantityNo of the cell-average vector located at i, j, k, taking into account bo...
Definition: PrintGrid.cpp:113

Here is the caller graph for this function:

Vector PrintGrid::velocity ( const int  i,
const int  j,
const int  k 
) const

Returns the cell-average velocity located at i, j, k.

Parameters
iPosition x
jPosition y
kPosition z
Returns
Vector
155 {
156  Vector V(3);
157 
158  for (int AxisNo=1; AxisNo <= 3; AxisNo++)
159  V.setValue( AxisNo, cellValue(i,j,k,AxisNo+1)/cellValue(i,j,k,1));
160 
161  return V;
162 }
Standard class for every vector in Carmen.
Definition: Vector.h:29
real cellValue(const int i, const int j, const int k, const int QuantityNo) const
Returns the quantity QuantityNo of the cell-average vector located at i, j, k, taking into account bo...
Definition: PrintGrid.cpp:113
real PrintGrid::vorticity ( const int  i,
const int  j,
const int  k 
) const

Returns 0 in 1D, the scalar vorticity in 2D, the norm of the cell-average vorticity in 3D, located at i, j, k. Does not work for MHD!

Parameters
iPosition x
jPosition y
kPosition z
Returns
real

dx + 0.5*abs(By1)/dy + 1.120e-13;

295 {
296 /*
297  int L=localScaleNb;
298  real dx=0., dy=0., dz=0.;
299  real U=0.,V=0.,W=0.;
300  real Uy1=0., Uy2=0., Uz1=0., Uz2=0.;
301  real Vx1=0., Vx2=0., Vz1=0., Vz2=0.;
302  real Wx1=0., Wx2=0., Wy1=0., Wy2=0.;
303 
304  int n = (1<<L); // n = 2^localScaleNb
305 
306  real result=0.;
307 
308  if (Dimension == 1)
309  return 0.;
310 
311  // Compute vorticity components
312 
313  dx = (XMax[1]-XMin[1])/n;
314  dy = (XMax[2]-XMin[2])/n;
315 
316  Vx1 = velocity(BC(i-1,1,n), BC(j ,2,n),BC(k,3,n),2);
317  Vx2 = velocity(BC(i+1,1,n), BC(j ,2,n),BC(k,3,n),2);
318  Uy1 = velocity(BC(i ,1,n), BC(j-1,2,n),BC(k,3,n),1);
319  Uy2 = velocity(BC(i ,1,n), BC(j+1,2,n),BC(k,3,n),1);
320 
321  if (Dimension == 2)
322  W = (Vx2-Vx1)/(2.*dx) - (Uy2-Uy1)/(2.*dy);
323  else
324  {
325  dz = (XMax[3]-XMin[3])/(1<<L);
326 
327  Uz1 = velocity(BC(i ,1,n), BC(j ,2,n),BC(k-1,3,n),1);
328  Uz1 = velocity(BC(i ,1,n), BC(j ,2,n),BC(k+1,3,n),1);
329 
330  Vz1 = velocity(BC(i ,1,n), BC(j ,2,n),BC(k-1,3,n),2);
331  Vz1 = velocity(BC(i ,1,n), BC(j ,2,n),BC(k+1,3,n),2);
332 
333  Wx1 = velocity(BC(i-1,1,n), BC(j ,2,n),BC(k ,3,n),3);
334  Wx2 = velocity(BC(i+1,1,n), BC(j ,2,n),BC(k ,3,n),3);
335 
336  Wy1 = velocity(BC(i ,1,n), BC(j-1,2,n),BC(k ,3,n),3);
337  Wy2 = velocity(BC(i ,1,n), BC(j+1,2,n),BC(k ,3,n),3);
338 
339  U = (Wy2-Wy1)/(2.*dy) - (Vz2-Vz1)/(2.*dz);
340  V = (Uz2-Uz1)/(2.*dz) - (Wx2-Wx1)/(2.*dx);
341  W = (Vx2-Vx1)/(2.*dx) - (Uy2-Uy1)/(2.*dy);
342 
343  }
344 
345  switch(Dimension)
346  {
347  case 2:
348  result = W;
349  break;
350 
351  case 3:
352  result = sqrt(U*U+V*V+W*W);
353  };
354 */
355 
356 // return result;
357  int L=localScaleNb;
358  int n = (1<<L);
359  real dx=0., dy=0., dz=0.;
360  real Div=0.;
361  real By1=0., By2=0., Bz1=0., Bz2=0.;
362  real Bx1=0., Bx2=0.;
363  real Bx =0., By=0.;
364  if (Dimension == 1){
365  dx = (XMax[1]-XMin[1])/n;
366 
367  Bx1 = magField(BC(i-1,1,n), BC(j,2,n),BC(k,3,n),1);
368  Bx2 = magField(BC(i+1,1,n), BC(j,2,n),BC(k,3,n),1);
369 
370  Div = (Bx2-Bx1)/(2.*dx);
371 
372  }else if (Dimension == 2){
373 
374  dx = (XMax[1]-XMin[1])/n;
375  dy = (XMax[2]-XMin[2])/n;
376  Bx1 = magField(BC(i-1,1,n), BC(j ,2,n),BC(k,3,n),1);
377  Bx2 = magField(BC(i+1,1,n), BC(j ,2,n),BC(k,3,n),1);
378  By1 = magField(BC(i ,1,n), BC(j-1,2,n),BC(k,3,n),2);
379  By2 = magField(BC(i ,1,n), BC(j+1,2,n),BC(k,3,n),2);
380  Bx = magField(BC(i,1,n), BC(j,2,n),BC(k,3,n),1);
381  By = magField(BC(i,1,n), BC(j,2,n),BC(k,3,n),2);
382 
383  //if(Bx2!=Bx1 && By2!=By1)
384  //Div = ((abs(Bx1)+abs(Bx2))/(2.*dx) + (abs(By1)+abs(By2))/(2.*dy) + 1.120e-13);
385  Div = 0.5*Abs(Bx1);
386  //else
387  // Div = ((Bx2-Bx1)/(2.*dx) + (By2-By1)/(2.*dy));
388  }else if (Dimension == 3){
389 
390  dx = (XMax[1]-XMin[1])/n;
391  dy = (XMax[2]-XMin[2])/n;
392  dz = (XMax[3]-XMin[3])/n;
393 
394  Bx1 = magField(BC(i-1,1,n), BC(j ,2,n),BC(k ,3,n),1);
395  Bx2 = magField(BC(i+1,1,n), BC(j ,2,n),BC(k ,3,n),1);
396  By1 = magField(BC(i ,1,n), BC(j-1,2,n),BC(k ,3,n),2);
397  By2 = magField(BC(i ,1,n), BC(j+1,2,n),BC(k ,3,n),2);
398  Bz1 = magField(BC(i ,1,n), BC(j ,2,n),BC(k-1,3,n),3);
399  Bz2 = magField(BC(i ,1,n), BC(j ,2,n),BC(k+1,3,n),3);
400 
401  Div = (Bx2-Bx1)/(2.*dx) + (By2-By1)/(2.*dy) + (Bz2-Bz1)/(2.*dz);
402 
403  }
404 
405  return Div;
406 }
real XMax[4]
Definition: Parameters.cpp:77
real magField(const int i, const int j, const int k, const int AxisNo) const
Returns the AxisNo-th component of the cell-average velocity located at i, j, k.
Definition: PrintGrid.h:347
int Dimension
Definition: Parameters.cpp:74
int BC(int i, int AxisNo, int N)
Returns the position of i taking into account the boundary conditions in the direction AxisNo...
Definition: BC.cpp:37
real XMin[4]
Definition: Parameters.cpp:76
#define Abs(x)
Definition: Carmen.h:78
#define real
Definition: PreProcessor.h:31

Here is the caller graph for this function:


The documentation for this class was generated from the following files: