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

Time Average Grid. More...

#include <TimeAverageGrid.h>

Public Member Functions

 TimeAverageGrid (const int UserScaleNb, const int UserQuantityNb)
 Constructor of TimeAverageGrid class. For a given variable number. More...
 
 TimeAverageGrid (const int UserScaleNb)
 Constructor of TimeAverageGrid class. More...
 
 ~TimeAverageGrid ()
 Destructor of TimeAverageGrid clas. More...
 
void updateValue (const int ElementNo, const int QuantityNo, const real UserValue)
 Update Values. For a given element. More...
 
void updateValue (const int i, const int j, const int k, const int QuantityNo, const real UserValue)
 Update Values. At position i,j,k. More...
 
void updateValue (const int i, const int j, const int k, const Vector arg)
 Update values. More...
 
void updateSample ()
 Update number of samples. More...
 
real value (const int ElementNo, const int QuantityNo) const
 Get value at the position ElementNo. More...
 
real value (const int i, const int j, const int k, const int QuantityNo) const
 Get value at the position i,j,k. More...
 
real density (const int i, const int j, const int k) const
 Get density at the position i,j,k. More...
 
real velocity (const int i, const int j, const int k, const int AxisNo) const
 Get velocity at the position i,j,k. More...
 
real stress (const int i, const int j, const int k, const int No) const
 

Detailed Description

Time Average Grid.

Constructor & Destructor Documentation

TimeAverageGrid::TimeAverageGrid ( const int  UserScaleNb,
const int  UserQuantityNb 
)

Constructor of TimeAverageGrid class. For a given variable number.

Parameters
UserScaleNbLevel
UserQuantityNbVariable number
31 {
32 
33  // Init SampleNb, LocalScaleNb, LocalQuantityNb, and ElementNb
34 
35  SampleNb = 0;
36  LocalScaleNb = UserScaleNb;
37  LocalQuantityNb = UserQuantityNb;
38  ElementNb = 1 << ( Dimension*LocalScaleNb );
39 
40  // Allocate array of time-averages
41 
42 // Q = new Vector[ElementNb](LocalQuantityNb); //!!!No ISO C++ compartable!!!
43  Q = new Vector[ElementNb];
44  int i;
45  for (i=0;i<ElementNb;i++) Q[i].setDimension(LocalQuantityNb);
46 }
Standard class for every vector in Carmen.
Definition: Vector.h:29
int Dimension
Definition: Parameters.cpp:74
TimeAverageGrid::TimeAverageGrid ( const int  UserScaleNb)

Constructor of TimeAverageGrid class.

Parameters
UserScaleNbLevel
54 {
55 
56  // Default quantity number (3 in 1D, 6 in 2D, 10 in 3D)
57 
58  switch(Dimension)
59  {
60  case 1:
61  LocalQuantityNb = 3;
62  break;
63 
64  case 2:
65  LocalQuantityNb = 6;
66  break;
67 
68  case 3:
69  LocalQuantityNb = 10;
70  break;
71 
72  };
73 
74  // Init SampleNb, LocalScaleNb, LocalQuantityNb, and ElementNb
75 
76  SampleNb = 0;
77  LocalScaleNb = UserScaleNb;
78  ElementNb = 1 << ( Dimension*LocalScaleNb );
79 
80  // Allocate array of time-averages
81 
82 // Q = new Vector[ElementNb](LocalQuantityNb); !!!No ISO C++ compartable!!!
83  Q = new Vector[ElementNb];
84  int i;
85  for (i=0;i<ElementNb;i++) Q[i].setDimension(LocalQuantityNb);
86 }
Standard class for every vector in Carmen.
Definition: Vector.h:29
int Dimension
Definition: Parameters.cpp:74
TimeAverageGrid::~TimeAverageGrid ( )

Destructor of TimeAverageGrid clas.

95 {
96  // Deallocate array of time-averages
97 
98  delete[] Q;
99 }

Member Function Documentation

real TimeAverageGrid::density ( const int  i,
const int  j,
const int  k 
) const
inline

Get density at the position i,j,k.

Parameters
iPosition x
jPosition y
kPosition z
Returns
real
160 {
161  return value(i,j,k,1);
162 }
real value(const int ElementNo, const int QuantityNo) const
Get value at the position ElementNo.
Definition: TimeAverageGrid.h:196

Here is the caller graph for this function:

real TimeAverageGrid::stress ( const int  i,
const int  j,
const int  k,
const int  No 
) const
191 {
192  real rho = density(i,j,k);
193  real rhoV1=0., rhoV2=0., rhoV1V2=0.;
194 
195  switch(No)
196  {
197  case 1:
198  rhoV1 = value(i,j,k,2); // rhoU
199  rhoV2 = value(i,j,k,2); // rhoU
200  rhoV1V2 = value(i,j,k,Dimension+2); // rhoUU
201  break;
202 
203  case 2:
204  rhoV1 = value(i,j,k,2); // rhoU
205  rhoV2 = value(i,j,k,3); // rhoV
206  rhoV1V2 = value(i,j,k,Dimension+3); // rhoUV
207  break;
208 
209  case 3:
210  rhoV1 = value(i,j,k,3); // rhoV
211  rhoV2 = value(i,j,k,3); // rhoV
212  rhoV1V2 = value(i,j,k,Dimension+4); // rhoVV
213  break;
214 
215  case 4:
216  rhoV1 = value(i,j,k,2); // rhoU
217  rhoV2 = value(i,j,k,4); // rhoW
218  rhoV1V2 = value(i,j,k,Dimension+5); // rhoUW
219  break;
220 
221  case 5:
222  rhoV1 = value(i,j,k,3); // rhoV
223  rhoV2 = value(i,j,k,4); // rhoW
224  rhoV1V2 = value(i,j,k,Dimension+6); // rhoVW
225  break;
226 
227  case 6:
228  rhoV1 = value(i,j,k,4); // rhoW
229  rhoV2 = value(i,j,k,4); // rhoW
230  rhoV1V2 = value(i,j,k,Dimension+7); // rhoWW
231  break;
232  };
233 
234  return ( ( rhoV1V2 - (rhoV1*rhoV2)/rho )/rho );
235 
236 }
real value(const int ElementNo, const int QuantityNo) const
Get value at the position ElementNo.
Definition: TimeAverageGrid.h:196
int Dimension
Definition: Parameters.cpp:74
real density(const int i, const int j, const int k) const
Get density at the position i,j,k.
Definition: TimeAverageGrid.h:159
#define real
Definition: PreProcessor.h:31

Here is the caller graph for this function:

void TimeAverageGrid::updateSample ( )
inline

Update number of samples.

Returns
void
172 {
173  SampleNb++;
174 }

Here is the caller graph for this function:

void TimeAverageGrid::updateValue ( const int  ElementNo,
const int  QuantityNo,
const real  UserValue 
)

Update Values. For a given element.

Parameters
ElementNoElement number
QuantityNoVariable number
UserValueReal value
Returns
void
108 {
109  real eps = 1./(SampleNb+1.);
110 
111  (Q+ElementNo)->setValue(QuantityNo, eps*UserValue + (1-eps)*(Q+ElementNo)->value(QuantityNo));
112 }
real value(const int ElementNo, const int QuantityNo) const
Get value at the position ElementNo.
Definition: TimeAverageGrid.h:196
#define real
Definition: PreProcessor.h:31

Here is the caller graph for this function:

void TimeAverageGrid::updateValue ( const int  i,
const int  j,
const int  k,
const int  QuantityNo,
const real  UserValue 
)

Update Values. At position i,j,k.

Parameters
iPosition x
jPosition y
kPosition z
QuantityNoVariable number
UserValueReal value
Returns
void
122 {
123  // --- Local variables ---
124 
125  int n = (1<<LocalScaleNb);
126  int ElementNo = i + n*(j + n*k);
127 
128  updateValue(ElementNo, QuantityNo, UserValue);
129 }
void updateValue(const int ElementNo, const int QuantityNo, const real UserValue)
Update Values. For a given element.
Definition: TimeAverageGrid.cpp:107
void TimeAverageGrid::updateValue ( const int  i,
const int  j,
const int  k,
const Vector  arg 
)

Update values.

Parameters
iPosition x
jPosition y
kPosition z
argVector
Returns
void
138 {
139  real rho=0.;
140  real U=0., V=0., W=0.;
141 
142  // Compute density and velocity
143 
144  rho = arg.value(1);
145  U = arg.value(2)/rho;
146  if (Dimension > 1) V = arg.value(3)/rho;
147  if (Dimension > 2) W = arg.value(4)/rho;
148 
149 
150  // update values
151 
152  updateValue(i,j,k,1,rho);
153 
154  switch(Dimension)
155  {
156  case 1:
157  updateValue(i,j,k,2,rho*U);
158  updateValue(i,j,k,3,rho*U*U);
159  break;
160 
161  case 2:
162  updateValue(i,j,k,2,rho*U);
163  updateValue(i,j,k,3,rho*V);
164  updateValue(i,j,k,4,rho*U*U);
165  updateValue(i,j,k,5,rho*U*V);
166  updateValue(i,j,k,6,rho*V*V);
167  break;
168 
169  case 3:
170  updateValue(i,j,k,2,rho*U);
171  updateValue(i,j,k,3,rho*V);
172  updateValue(i,j,k,4,rho*W);
173  updateValue(i,j,k,5,rho*U*U);
174  updateValue(i,j,k,6,rho*U*V);
175  updateValue(i,j,k,7,rho*V*V);
176  updateValue(i,j,k,8,rho*U*W);
177  updateValue(i,j,k,9,rho*V*W);
178  updateValue(i,j,k,10,rho*W*W);
179  break;
180  };
181 
182 }
void updateValue(const int ElementNo, const int QuantityNo, const real UserValue)
Update Values. For a given element.
Definition: TimeAverageGrid.cpp:107
int Dimension
Definition: Parameters.cpp:74
real value(const int n) const
Returns the value of the component n.
Definition: Vector.h:565
#define real
Definition: PreProcessor.h:31
real TimeAverageGrid::value ( const int  ElementNo,
const int  QuantityNo 
) const
inline

Get value at the position ElementNo.

Parameters
ElementNoElement number
QuantityNoVariable number
Returns
real
197 {
198  return (Q+ElementNo)->value(QuantityNo);
199 }

Here is the caller graph for this function:

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

Get value at the position i,j,k.

Parameters
iPosition x
jPosition y
kPosition z
QuantityNoVariable number
Returns
real
209 {
210  return value(i + (1<<LocalScaleNb)*(j +(1<<LocalScaleNb)*k), QuantityNo);
211 }
real value(const int ElementNo, const int QuantityNo) const
Get value at the position ElementNo.
Definition: TimeAverageGrid.h:196
real TimeAverageGrid::velocity ( const int  i,
const int  j,
const int  k,
const int  AxisNo 
) const
inline

Get velocity at the position i,j,k.

Parameters
iPosition x
jPosition y
kPosition z
AxisNoAxis of interest
Returns
real
184 {
185  return value(i,j,k,AxisNo+1)/value(i,j,k,1);
186 }
real value(const int ElementNo, const int QuantityNo) const
Get value at the position ElementNo.
Definition: TimeAverageGrid.h:196

Here is the caller graph for this function:


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