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

Standard class for every matrix in Carmen. More...

#include <Matrix.h>

Public Member Functions

 Matrix ()
 Constructor of matrix class. Generates a 1,1 matrix equal to zero. More...
 
 Matrix (const int i, const int j)
 Generates a matrix with i lines and j columns, each component being equal to zero. Example : More...
 
 Matrix (const int i)
 Generates a square matrix with i lines and i columns, each component being equal to zero. Example : More...
 
 Matrix (const Matrix &M)
 Generates a copy of the matrix M. Example : More...
 
 Matrix (const Vector &V)
 Generates a vector-matrix identical to V. Example : More...
 
 ~Matrix ()
 Distructor of matrix class. Deallocate memory of the matrix. More...
 
void setValue (const int i, const int j, const real a)
 Sets the component i, j to value a. More...
 
void setZero ()
 Sets all the components to zero. More...
 
real value (const int i, const int j) const
 Returns the value of the component i, j. More...
 
int lines () const
 Returns the number of lines of the matrix. More...
 
int columns () const
 Returns the number of columns of the matrix. More...
 
bool operator== (const Matrix &M) const
 Compares the current matrix to a matrix M and returns true if they are equal. More...
 
void operator= (const Matrix &M)
 Set the current matrix to the dimension and the value of M. More...
 
void operator+= (const Matrix &M)
 Adds M to the current matrix. More...
 
Matrix operator+ (const Matrix &M) const
 Returns the addition of the current matrix and M. More...
 
void operator-= (const Matrix &M)
 Subtracts M to the current matrix. More...
 
Matrix operator- (const Matrix &M) const
 Returns the difference between the current matrix and M. More...
 
Matrix operator- () const
 Returns the opposite of the current matrix. More...
 
void operator*= (const real a)
 Multiplies the current matrix by a real a. More...
 
Matrix operator* (const real a) const
 Returns the product of the current matrix and a real a. More...
 
void operator/= (const real a)
 Divides the current matrix by a real a. More...
 
Matrix operator/ (const real a) const
 Returns the division of the current matrix by a real a. More...
 
Matrix operator* (const Matrix &M) const
 Returns the product of the current matrix and a matrix M. More...
 
Vector operator* (const Vector &V) const
 Returns the product of the current matrix and a vectorV. More...
 
void setEigenMatrix (const bool isLeft, const int AxisNo, const Vector V, const real c, const real h=0.)
 Sets matrix as eigenmatrix. More...
 

Public Attributes

int Lines
 
int Columns
 
realU
 

Detailed Description

Standard class for every matrix in Carmen.

It contains the following data:
the number of lines Lines ;
the number of columns Columns ;
the array of reals *U.

Constructor & Destructor Documentation

Matrix::Matrix ( )

Constructor of matrix class. Generates a 1,1 matrix equal to zero.

Example :

#include "Matrix.h"

Matrix M;

31 {
32  Lines = Columns = 1;
33  U = new real;
34  *U = 0.;
35 }
real * U
Definition: Matrix.h:438
int Columns
Definition: Matrix.h:437
int Lines
Definition: Matrix.h:437
#define real
Definition: PreProcessor.h:31
Matrix::Matrix ( const int  i,
const int  j 
)

Generates a matrix with i lines and j columns, each component being equal to zero. Example :

#include "Matrix.h"

Matrix M(4,5);

Parameters
i
j

41 {
42  int n; // Counter
43 
44  Lines = i;
45  Columns = j;
46 
47  // If the size of the matrix is equal to zero, do not allocate memory
48  if (Lines==0 && Columns==0) return;
49 
50  U = new real[Lines*Columns];
51 
52  for (n = 1; n <= Lines*Columns; n++)
53  *(U+n-1) = 0.;
54 }
real * U
Definition: Matrix.h:438
int Columns
Definition: Matrix.h:437
int Lines
Definition: Matrix.h:437
#define real
Definition: PreProcessor.h:31
Matrix::Matrix ( const int  i)

Generates a square matrix with i lines and i columns, each component being equal to zero. Example :

#include "Matrix.h"

Matrix M(4);

Parameters
i

60 {
61  int n; // Counter
62 
63  Lines = i;
64  Columns = i;
65 
66  U = new real[Lines*Columns];
67 
68  for (n = 1; n <= Lines*Columns; n++)
69  *(U+n-1) = 0.;
70 }
real * U
Definition: Matrix.h:438
int Columns
Definition: Matrix.h:437
int Lines
Definition: Matrix.h:437
#define real
Definition: PreProcessor.h:31
Matrix::Matrix ( const Matrix M)

Generates a copy of the matrix M. Example :

#include "Matrix.h"

Matrix M(2,3);
Matrix P(M)

Parameters
MMatrix

76 {
77  int i,j;
78 
79  Lines = M.lines();
80  Columns = M.columns();
81 
82  U = new real[Lines*Columns];
83 
84  for (i = 1; i <= Lines; i++)
85  for (j = 1; j <= Columns; j++)
86  setValue(i, j, M.value(i,j));
87 }
real * U
Definition: Matrix.h:438
real value(const int i, const int j) const
Returns the value of the component i, j.
Definition: Matrix.h:515
int Columns
Definition: Matrix.h:437
int lines() const
Returns the number of lines of the matrix.
Definition: Matrix.h:486
int columns() const
Returns the number of columns of the matrix.
Definition: Matrix.h:495
void setValue(const int i, const int j, const real a)
Sets the component i, j to value a.
Definition: Matrix.h:505
int Lines
Definition: Matrix.h:437
#define real
Definition: PreProcessor.h:31
Matrix::Matrix ( const Vector V)

Generates a vector-matrix identical to V. Example :

#include "Matrix.h"

Matrix V(3);
Matrix P(V);

Parameters
V

93 {
94  int i;
95 
96  Lines = V.dimension();
97  Columns = 1;
98 
99  U = new real[Lines*Columns];
100 
101  for (i = 1; i <= Lines; i++)
102  setValue(i, 1, V.value(i));
103 }
real * U
Definition: Matrix.h:438
int dimension() const
Returns the dimension of the vector.
Definition: Vector.h:535
int Columns
Definition: Matrix.h:437
void setValue(const int i, const int j, const real a)
Sets the component i, j to value a.
Definition: Matrix.h:505
real value(const int n) const
Returns the value of the component n.
Definition: Vector.h:565
int Lines
Definition: Matrix.h:437
#define real
Definition: PreProcessor.h:31
Matrix::~Matrix ( )

Distructor of matrix class. Deallocate memory of the matrix.

113 {
114  // If the size of the matrix is equal to zero, do not deallocate memory
115  if (Lines==0 && Columns==0) return;
116 
117  delete[] U;
118 }
real * U
Definition: Matrix.h:438
int Columns
Definition: Matrix.h:437
int Lines
Definition: Matrix.h:437

Member Function Documentation

int Matrix::columns ( ) const
inline

Returns the number of columns of the matrix.

Returns
int
496 {
497  return Columns;
498 }
int Columns
Definition: Matrix.h:437

Here is the caller graph for this function:

int Matrix::lines ( ) const
inline

Returns the number of lines of the matrix.

Returns
int
487 {
488  return Lines;
489 }
int Lines
Definition: Matrix.h:437

Here is the caller graph for this function:

Matrix Matrix::operator* ( const real  a) const

Returns the product of the current matrix and a real a.

Example :

#include "Matrix.h"

Matrix M(2,2);
Matrix P;
real x = 2.;
...
P = M*x;

The operation P = x*M can also be done. See operator*(const real a, const Matrix& M).

Parameters
aReal value
Returns
Matrix

281 {
282  int i,j;
283  Matrix result(Lines, Columns);
284 
285  for (i = 1; i <= Lines; i++)
286  for (j = 1; j <= Columns; j++)
287  result.setValue(i, j, value(i,j)*a);
288 
289  return result;
290 }
real value(const int i, const int j) const
Returns the value of the component i, j.
Definition: Matrix.h:515
int Columns
Definition: Matrix.h:437
Standard class for every matrix in Carmen.
Definition: Matrix.h:28
int Lines
Definition: Matrix.h:437
Matrix Matrix::operator* ( const Matrix M) const

Returns the product of the current matrix and a matrix M.

Example :

#include "Matrix.h"

Matrix M(2,3);
Matrix P(3,1);
Matrix Q;
...
Q = M*P;

Parameters
MMatrix
Returns
Matrix

332 {
333  int i, j, k;
334  Matrix result(lines(), M.columns());
335 
336  for (i = 1; i <= lines(); i++)
337  for (j = 1; j <= M.columns(); j++)
338  for (k = 1; k <= columns(); k++)
339  result.setValue(i,j, result.value(i,j) + value(i,k)*M.value(k,j));
340 
341  return result;
342 }
real value(const int i, const int j) const
Returns the value of the component i, j.
Definition: Matrix.h:515
Standard class for every matrix in Carmen.
Definition: Matrix.h:28
int lines() const
Returns the number of lines of the matrix.
Definition: Matrix.h:486
int columns() const
Returns the number of columns of the matrix.
Definition: Matrix.h:495
void setValue(const int i, const int j, const real a)
Sets the component i, j to value a.
Definition: Matrix.h:505
Vector Matrix::operator* ( const Vector V) const

Returns the product of the current matrix and a vectorV.

Example :

#include "Matrix.h"

Matrix M(2,3);
Vector V(3);
Vector P;
...
P = M*V;

Parameters
VVector
Returns
Vector

351 {
352  int i, k;
353 
354  Vector result(lines());
355 
356  for (i = 1; i <= lines(); i++)
357  for (k = 1; k <= columns(); k++)
358  result.setValue(i, result.value(i) + value(i,k)*V.value(k));
359 
360  return result;
361 
362 }
Standard class for every vector in Carmen.
Definition: Vector.h:29
real value(const int i, const int j) const
Returns the value of the component i, j.
Definition: Matrix.h:515
int lines() const
Returns the number of lines of the matrix.
Definition: Matrix.h:486
int columns() const
Returns the number of columns of the matrix.
Definition: Matrix.h:495
real value(const int n) const
Returns the value of the component n.
Definition: Vector.h:565
void Matrix::operator*= ( const real  a)

Multiplies the current matrix by a real a.

Example :

#include "Matrix.h"

Matrix M(2,2);
real x = 2.;
...
M *= x;

Parameters
aReal value
Returns
void

269 {
270  int n;
271 
272  for (n=1; n<=Lines*Columns; n++)
273  *(U+n-1) *= a;
274 }
real * U
Definition: Matrix.h:438
int Columns
Definition: Matrix.h:437
int Lines
Definition: Matrix.h:437
Matrix Matrix::operator+ ( const Matrix M) const

Returns the addition of the current matrix and M.

Example :

#include "Matrix.h"

Matrix M(2,2);
Matrix P(2,2);
Matrix U;
...
U = M + P;

Parameters
MMatrix
Returns
Matrix

202 {
203  int i, j;
204  Matrix result(Lines, Columns);
205 
206  for (i = 1; i <= Lines; i++)
207  for (j = 1; j <= Columns; j++)
208  result.setValue(i, j, value(i,j) + M.value(i,j));
209 
210  return result;
211 }
real value(const int i, const int j) const
Returns the value of the component i, j.
Definition: Matrix.h:515
int Columns
Definition: Matrix.h:437
Standard class for every matrix in Carmen.
Definition: Matrix.h:28
int Lines
Definition: Matrix.h:437
void Matrix::operator+= ( const Matrix M)

Adds M to the current matrix.

Example :

#include "Matrix.h"

Matrix M(2,2);
Matrix P(2,2);
...
P += M;

Parameters
MMatrix
Returns
void

188 {
189  int i, j;
190 
191  for (i = 1; i <= Lines; i++)
192  for (j = 1; j <= Columns; j++)
193  setValue(i, j, value(i,j) + M.value(i,j));
194 }
real value(const int i, const int j) const
Returns the value of the component i, j.
Definition: Matrix.h:515
int Columns
Definition: Matrix.h:437
void setValue(const int i, const int j, const real a)
Sets the component i, j to value a.
Definition: Matrix.h:505
int Lines
Definition: Matrix.h:437
Matrix Matrix::operator- ( const Matrix M) const

Returns the difference between the current matrix and M.

Example :

#include "Matrix.h"

Matrix M(2,2);
Matrix P(2,2);
Matrix U;
...
U = M - P;

Parameters
MMatrix
Returns
Matrix

235 {
236  int i, j;
237  Matrix result(Lines, Columns);
238 
239  for (i = 1; i <= Lines; i++)
240  for (j = 1; j <= Columns; j++)
241  result.setValue(i, j, value(i,j) - M.value(i,j));
242 
243  return result;
244 }
real value(const int i, const int j) const
Returns the value of the component i, j.
Definition: Matrix.h:515
int Columns
Definition: Matrix.h:437
Standard class for every matrix in Carmen.
Definition: Matrix.h:28
int Lines
Definition: Matrix.h:437
Matrix Matrix::operator- ( ) const

Returns the opposite of the current matrix.

Example :

#include "Matrix.h"

Matrix M(2,2);
Matrix P;
...
P = -M;

Returns
Matrix

250 {
251  int i, j;
252  Matrix result(Lines, Columns);
253 
254  for (i = 1; i <= Lines; i++)
255  for (j = 1; j <= Columns; j++)
256  result.setValue(i, j, -value(i,j));
257 
258  return result;
259 }
real value(const int i, const int j) const
Returns the value of the component i, j.
Definition: Matrix.h:515
int Columns
Definition: Matrix.h:437
Standard class for every matrix in Carmen.
Definition: Matrix.h:28
int Lines
Definition: Matrix.h:437
void Matrix::operator-= ( const Matrix M)

Subtracts M to the current matrix.

Example :

#include "Matrix.h"

Matrix M(2,2);
Matrix P(2,2);
...
P -= M;

Parameters
MMatrix
Returns
void

221 {
222  int i, j;
223 
224  for (i = 1; i <= Lines; i++)
225  for (j = 1; j <= Columns; j++)
226  setValue(i, j, value(i,j) - M.value(i,j));
227 }
real value(const int i, const int j) const
Returns the value of the component i, j.
Definition: Matrix.h:515
int Columns
Definition: Matrix.h:437
void setValue(const int i, const int j, const real a)
Sets the component i, j to value a.
Definition: Matrix.h:505
int Lines
Definition: Matrix.h:437
Matrix Matrix::operator/ ( const real  a) const

Returns the division of the current matrix by a real a.

Example :

#include "Matrix.h"

Matrix M(2,2);
Matrix P;
real x = 2.;
...
P = M / x;

Parameters
aReal value
Returns
Matrix

313 {
314  int i,j;
315  Matrix result(Lines, Columns);
316 
317  for (i = 1; i <= Lines; i++)
318  for (j = 1; j <= Columns; j++)
319  result.setValue(i, j, value(i,j)/a);
320 
321  return result;
322 }
real value(const int i, const int j) const
Returns the value of the component i, j.
Definition: Matrix.h:515
int Columns
Definition: Matrix.h:437
Standard class for every matrix in Carmen.
Definition: Matrix.h:28
int Lines
Definition: Matrix.h:437
void Matrix::operator/= ( const real  a)

Divides the current matrix by a real a.

Example :

#include "Matrix.h"

Matrix M(2,2);
real x = 2.;
...
M /= x;

Parameters
aReal value
Returns
void

300 {
301  int n;
302 
303  for (n=1; n<=Lines*Columns; n++)
304  *(U+n-1) /= a;
305 }
real * U
Definition: Matrix.h:438
int Columns
Definition: Matrix.h:437
int Lines
Definition: Matrix.h:437
void Matrix::operator= ( const Matrix M)

Set the current matrix to the dimension and the value of M.

Example :

#include "Matrix.h"

Matrix M(2,2);
Matrix P;
...
P = M;

Parameters
MMatrix
Returns
void

162 {
163  int i, j;
164 
165  if (M.lines() != Lines || M.columns() != Columns)
166  {
167  delete[] U;
168 
169  Lines = M.lines();
170  Columns = M.columns();
171 
172  U = new real[Lines*Columns];
173  }
174 
175  for (i = 1; i <= Lines; i++)
176  for (j = 1; j <= Columns; j++)
177  setValue(i, j, M.value(i,j));
178 }
real * U
Definition: Matrix.h:438
real value(const int i, const int j) const
Returns the value of the component i, j.
Definition: Matrix.h:515
int Columns
Definition: Matrix.h:437
int lines() const
Returns the number of lines of the matrix.
Definition: Matrix.h:486
int columns() const
Returns the number of columns of the matrix.
Definition: Matrix.h:495
void setValue(const int i, const int j, const real a)
Sets the component i, j to value a.
Definition: Matrix.h:505
int Lines
Definition: Matrix.h:437
#define real
Definition: PreProcessor.h:31
bool Matrix::operator== ( const Matrix M) const

Compares the current matrix to a matrix M and returns true if they are equal.

Example :

#include "Matrix.h"

Matrix M(2,2);
Matrix P(2,2);
real x;
...
if (M == P)
x = M.value(1,1);

Parameters
MMatrix
Returns
bool

144 {
145  int i, j;
146 
147  for (i = 1; i <= Lines; i++)
148  for (j = 1; j <= Columns; j++)
149  if ( value(i,j) != M.value(i,j) ) return false;
150 
151  return true;
152 }
real value(const int i, const int j) const
Returns the value of the component i, j.
Definition: Matrix.h:515
int Columns
Definition: Matrix.h:437
int Lines
Definition: Matrix.h:437
void Matrix::setEigenMatrix ( const bool  isLeft,
const int  AxisNo,
const Vector  V,
const real  c,
const real  h = 0. 
)

Sets matrix as eigenmatrix.

Parameters
isLeftBoolean variable. True if location is on the left.
AxisNoAxis of interest.
VVector
cReal value
hReal value
Returns
void
371 {
372 
373  // --- Local variables ---
374 
375  int n; // Counter
376  real u = V.value(1);
377  real v = (Dimension > 1) ? V.value(2): 0.;
378  real w = (Dimension > 2) ? V.value(3): 0.;
379 
380  // --- Allocate memory and set to zero ---
381 
382  delete[] U;
383 
385 
386  U = new real[Lines*Columns];
387 
388  for (n = 1; n <= Lines*Columns; n++)
389  *(U+n-1) = 0.;
390 
391  // --- Fill values ---
392 
393  switch (Dimension)
394  {
395 
396  // --- 1D CASE --------------------------------------------------------------------------------
397 
398  case 1:
399  if (isLeft)
400  {
401  // --- Left eigenmatrix ---
402 
403 // setValue(1,1, (c*c)*(1.- ((Gamma-1.)*u*u)/(2.*c*c)));
404 // setValue(2,1, (c*c)*(.5*(((Gamma-1.)*u*u)/(2.*c*c) - (u/c))));
405 // setValue(3,1, (c*c)*(.5*(((Gamma-1.)*u*u)/(2.*c*c) + (u/c))));
406 //
407 // setValue(1,2, (c*c)*((Gamma-1.)*u/(c*c)));
408 // setValue(2,2, (c*c)*(((Gamma-1.)/(2.*c*c))*(c/(Gamma-1.)-u)));
409 // setValue(3,2, (c*c)*(((Gamma-1.)/(2.*c*c))*(-c/(Gamma-1.)-u)));
410 //
411 // setValue(1,3, (c*c)*(-(Gamma-1.)/(c*c)));
412 // setValue(2,3, (c*c)*((Gamma-1.)/(2.*c*c)));
413 // setValue(3,3, (c*c)*((Gamma-1.)/(2.*c*c)));
414 
415 // matrices de Vinokur
416 
417  setValue(1,1, (1.- ((Gamma-1.)*u*u)/(2.*c*c)));
418  setValue(2,1, (.5*(((Gamma-1.)*u*u)/(2.*c*c) - (u/c))));
419  setValue(3,1, (.5*(((Gamma-1.)*u*u)/(2.*c*c) + (u/c))));
420 
421  setValue(1,2, ((Gamma-1.)*u/(c*c)));
422  setValue(2,2, (((Gamma-1.)/(2.*c*c))*(c/(Gamma-1.)-u)));
423  setValue(3,2, (((Gamma-1.)/(2.*c*c))*(-c/(Gamma-1.)-u)));
424 
425  setValue(1,3, (-(Gamma-1.)/(c*c)));
426  setValue(2,3, ((Gamma-1.)/(2.*c*c)));
427  setValue(3,3, ((Gamma-1.)/(2.*c*c)));
428 
429  }
430  else
431  {
432  // --- Right eigenmatrix ---
433 
434 // setValue(1,1, 1./(c*c));
435 // setValue(2,1, u/(c*c));
436 // setValue(3,1, .5*(u*u)/(c*c));
437 //
438 // setValue(1,2, 1./(c*c));
439 // setValue(2,2, (u+c)/(c*c));
440 // setValue(3,2, (h+ c*u)/(c*c));
441 //
442 // setValue(1,3, 1./(c*c));
443 // setValue(2,3, (u-c)/(c*c));
444 // setValue(3,3, (h-u*c)/(c*c));
445 
446 
447 // matrices de Vinokur
448 
449  setValue(1,1, 1.);
450  setValue(2,1, u);
451  setValue(3,1, .5*(u*u));
452 
453  setValue(1,2, 1.);
454  setValue(2,2, (u+c));
455  setValue(3,2, (h+ c*u));
456 
457  setValue(1,3, 1.);
458  setValue(2,3, (u-c));
459  setValue(3,3, (h-u*c));
460 
461 
462  }
463  break;
464 
465 
466  // --- 2D CASE --------------------------------------------------------------------------------
467 
468  case 2:
469  if (isLeft)
470  {
471  // --- Left eigenmatrix ---
472 
473  switch(AxisNo)
474  {
475  case 1:
476 // setValue(1,1, (c*c)*(1.-((Gamma-1.)*(u*u+v*v)/(2.*c*c))));
477 // setValue(2,1, (c*c)*(-v));
478 // setValue(3,1, (c*c)*(.5*( (Gamma-1.)*(u*u+v*v)/(2.*c*c) - u/c )));
479 // setValue(4,1, (c*c)*(.5*( (Gamma-1.)*(u*u+v*v)/(2.*c*c) + u/c )));
480 //
481 // setValue(1,2, (c*c)*((Gamma-1.)*u/(c*c)));
482 // setValue(2,2, 0.);
483 // setValue(3,2, (c*c)*((c/(Gamma-1.)-u)*((Gamma-1.)/(2.*c*c))));
484 // setValue(4,2, (c*c)*((-c/(Gamma-1.)-u)*((Gamma-1.)/(2.*c*c))));
485 //
486 // setValue(1,3, (c*c)*((Gamma-1.)*v/(c*c)));
487 // setValue(2,3, (c*c)*1.);
488 // setValue(3,3, (c*c)*(-(Gamma-1.)*v/(2.*c*c)));
489 // setValue(4,3, (c*c)*(-(Gamma-1.)*v/(2.*c*c)));
490 //
491 // setValue(1,4, (c*c)*(-(Gamma-1.)/(c*c)));
492 // setValue(2,4, 0.);
493 // setValue(3,4, (c*c)*((Gamma-1.)/(2.*c*c)));
494 // setValue(4,4, (c*c)*((Gamma-1.)/(2.*c*c)));
495 
496 
497 // matrix vinokur
498 
499  setValue(1,1, (1.-((Gamma-1.)*(u*u+v*v)/(2.*c*c))));
500  setValue(2,1, (-v));
501  setValue(3,1, (.5*( (Gamma-1.)*(u*u+v*v)/(2.*c*c) - u/c )));
502  setValue(4,1, (.5*( (Gamma-1.)*(u*u+v*v)/(2.*c*c) + u/c )));
503 
504  setValue(1,2, ((Gamma-1.)*u/(c*c)));
505  setValue(2,2, 0.);
506  setValue(3,2, ((c/(Gamma-1.)-u)*((Gamma-1.)/(2.*c*c))));
507  setValue(4,2, ((-c/(Gamma-1.)-u)*((Gamma-1.)/(2.*c*c))));
508 
509  setValue(1,3, ((Gamma-1.)*v/(c*c)));
510  setValue(2,3, 1.);
511  setValue(3,3, (-(Gamma-1.)*v/(2.*c*c)));
512  setValue(4,3, (-(Gamma-1.)*v/(2.*c*c)));
513 
514  setValue(1,4, (-(Gamma-1.)/(c*c)));
515  setValue(2,4, 0.);
516  setValue(3,4, ((Gamma-1.)/(2.*c*c)));
517  setValue(4,4, ((Gamma-1.)/(2.*c*c)));
518 
519 
520  break;
521 
522  case 2:
523 // setValue(1,1, (c*c)*(1.-((Gamma-1.)*(u*u+v*v)/(2.*c*c))));
524 // setValue(2,1, (c*c)*(-v));
525 // setValue(3,1, (c*c)*(.5*( (Gamma-1.)*(u*u+v*v)/(2.*c*c) - u/c )));
526 // setValue(4,1, (c*c)*(.5*( (Gamma-1.)*(u*u+v*v)/(2.*c*c) + u/c )));
527 //
528 // setValue(1,2, (c*c)*((Gamma-1.)*u/(c*c)));
529 // setValue(2,2, 0.);
530 // setValue(3,2, (c*c)*((c/(Gamma-1.)-u)*((Gamma-1.)/(2.*c*c))));
531 // setValue(4,2, (c*c)*((-c/(Gamma-1.)-u)*((Gamma-1.)/(2.*c*c))));
532 //
533 // setValue(1,3, (c*c)*((Gamma-1.)*v/(c*c)));
534 // setValue(2,3, (c*c)*1.);
535 // setValue(3,3, (c*c)*(-(Gamma-1.)*v/(2.*c*c)));
536 // setValue(4,3, (c*c)*(-(Gamma-1.)*v/(2.*c*c)));
537 //
538 // setValue(1,4, (c*c)*(-(Gamma-1.)/(c*c)));
539 // setValue(2,4, 0.);
540 // setValue(3,4, (c*c)*((Gamma-1.)/(2.*c*c)));
541 // setValue(4,4, (c*c)*((Gamma-1.)/(2.*c*c)));
542 
543 
544 // matrix vinokur
545  setValue(1,1, (1.-((Gamma-1.)*(u*u+v*v)/(2.*c*c))));
546  setValue(2,1, (-v));
547  setValue(3,1, (.5*( (Gamma-1.)*(u*u+v*v)/(2.*c*c) - u/c )));
548  setValue(4,1, (.5*( (Gamma-1.)*(u*u+v*v)/(2.*c*c) + u/c )));
549 
550  setValue(1,2, ((Gamma-1.)*u/(c*c)));
551  setValue(2,2, 0.);
552  setValue(3,2, ((c/(Gamma-1.)-u)*((Gamma-1.)/(2.*c*c))));
553  setValue(4,2, ((-c/(Gamma-1.)-u)*((Gamma-1.)/(2.*c*c))));
554 
555  setValue(1,3, ((Gamma-1.)*v/(c*c)));
556  setValue(2,3, 1.);
557  setValue(3,3, (-(Gamma-1.)*v/(2.*c*c)));
558  setValue(4,3, (-(Gamma-1.)*v/(2.*c*c)));
559 
560  setValue(1,4, (-(Gamma-1.)/(c*c)));
561  setValue(2,4, 0.);
562  setValue(3,4, ((Gamma-1.)/(2.*c*c)));
563  setValue(4,4, ((Gamma-1.)/(2.*c*c)));
564 
565 
566  break;
567  };
568  }
569  else
570  {
571  // --- Right eigenmatrix ---
572 
573  switch(AxisNo)
574  {
575  case 1:
576 // setValue(1,1, 1./(c*c));
577 // setValue(2,1, u/(c*c));
578 // setValue(3,1, v/(c*c));
579 // setValue(4,1, .5*(u*u+v*v)/(c*c));
580 //
581 // setValue(1,2, 0.);
582 // setValue(2,2, 0.);
583 // setValue(3,2, 1./(c*c));
584 // setValue(4,2, v/(c*c));
585 //
586 // setValue(1,3, 1./(c*c));
587 // setValue(2,3, (u+c)/(c*c));
588 // setValue(3,3, v/(c*c));
589 // setValue(4,3, (h+ c*u)/(c*c));
590 //
591 // setValue(1,4, 1./(c*c));
592 // setValue(2,4, (u-c)/(c*c));
593 // setValue(3,4, v/(c*c));
594 // setValue(4,4, (h- c*u)/(c*c));
595 
596 
597 // matrix vinokur
598  setValue(1,1, 1.);
599  setValue(2,1, u);
600  setValue(3,1, v);
601  setValue(4,1, .5*(u*u+v*v));
602 
603  setValue(1,2, 0.);
604  setValue(2,2, 0.);
605  setValue(3,2, 1.);
606  setValue(4,2, v);
607 
608  setValue(1,3, 1.);
609  setValue(2,3, (u+c));
610  setValue(3,3, v);
611  setValue(4,3, (h+ c*u));
612 
613  setValue(1,4, 1.);
614  setValue(2,4, (u-c));
615  setValue(3,4, v);
616  setValue(4,4, (h- c*u));
617 
618  break;
619 
620  case 2:
621 // setValue(1,1, 0.);
622 // setValue(2,1, 0.);
623 // setValue(3,1, 1./(c*c));
624 // setValue(4,1, u/(c*c));
625 //
626 // setValue(1,2, 1./(c*c));
627 // setValue(2,2, u/(c*c));
628 // setValue(3,2, v/(c*c));
629 // setValue(4,2, .5*(u*u+v*v)/(c*c));
630 //
631 // setValue(1,3, 1./(c*c));
632 // setValue(2,3, u/(c*c));
633 // setValue(3,3, (v+c)/(c*c));
634 // setValue(4,3, (h+ c*v)/(c*c));
635 //
636 // setValue(1,4, 1./(c*c));
637 // setValue(2,4, u/(c*c));
638 // setValue(3,4, (v-c)/(c*c));
639 // setValue(4,4, (h- c*v)/(c*c));
640 
641 
642 // matrix vinokur
643 
644  setValue(1,1, 0.);
645  setValue(2,1, 0.);
646  setValue(3,1, 1.);
647  setValue(4,1, u);
648 
649  setValue(1,2, 1.);
650  setValue(2,2, u);
651  setValue(3,2, v);
652  setValue(4,2, .5*(u*u+v*v));
653 
654  setValue(1,3, 1.);
655  setValue(2,3, u);
656  setValue(3,3, (v+c));
657  setValue(4,3, (h+ c*v));
658 
659  setValue(1,4, 1.);
660  setValue(2,4, u);
661  setValue(3,4, (v-c));
662  setValue(4,4, (h- c*v));
663 
664  break;
665  };
666  }
667  break;
668 
669  // --- 3D CASE --------------------------------------------------------------------------------
670 
671  case 3:
672  if (isLeft)
673  {
674  // --- Left eigenmatrix ---
675 
676  switch(AxisNo)
677  {
678 // case 1:
679 // setValue(1,1, (c*c)*(1.-( (Gamma-1.)*(u*u+v*v+w*w)/(2.*c*c))));
680 // setValue(2,1, (c*c)*(-v));
681 // setValue(3,1, (c*c)*(-w));
682 // setValue(4,1, (c*c)*(.5*( (Gamma-1.)*(u*u+v*v+w*w)/(2.*c*c) - u/c )));
683 // setValue(5,1, (c*c)*(.5*( (Gamma-1.)*(u*u+v*v+w*w)/(2.*c*c) + u/c )));
684 //
685 // setValue(1,2, (c*c)*((Gamma-1.)*u/(c*c)));
686 // setValue(2,2, 0.);
687 // setValue(3,2, 0.);
688 // setValue(4,2, (c*c)*((c/(Gamma-1.)-u)*((Gamma-1.)/(2.*c*c))));
689 // setValue(5,2, (c*c)*((-c/(Gamma-1.)-u)*((Gamma-1.)/(2.*c*c))));
690 //
691 // setValue(1,3, (c*c)*((Gamma-1.)*v/(c*c)));
692 // setValue(2,3, (c*c)*(1.));
693 // setValue(3,3, 0.);
694 // setValue(4,3, (c*c)*(-v*(Gamma-1.)/(2.*c*c)));
695 // setValue(5,3, (c*c)*(-v*(Gamma-1.)/(2.*c*c)));
696 //
697 // setValue(1,4, (c*c)*((Gamma-1.)*w/(c*c)));
698 // setValue(2,4, 0.);
699 // setValue(3,4, (c*c)*(1.));
700 // setValue(4,4, (c*c)*(-w*(Gamma-1.)/(2.*c*c)));
701 // setValue(5,4, (c*c)*(-w*(Gamma-1.)/(2.*c*c)));
702 //
703 // setValue(1,5, (c*c)*(-(Gamma-1.)/(c*c)));
704 // setValue(2,5, 0.);
705 // setValue(3,5, 0.);
706 // setValue(4,5, (c*c)*((Gamma-1.)/(2.*c*c)));
707 // setValue(5,5, (c*c)*((Gamma-1.)/(2.*c*c)));
708 // break;
709 
710 // matrix vinokur
711  case 1:
712  setValue(1,1, (1.-( (Gamma-1.)*(u*u+v*v+w*w)/(2.*c*c))));
713  setValue(2,1, (-v));
714  setValue(3,1, (-w));
715  setValue(4,1, (.5*( (Gamma-1.)*(u*u+v*v+w*w)/(2.*c*c) - u/c )));
716  setValue(5,1, (.5*( (Gamma-1.)*(u*u+v*v+w*w)/(2.*c*c) + u/c )));
717 
718  setValue(1,2, (Gamma-1.)*u/(c*c));
719  setValue(2,2, 0.);
720  setValue(3,2, 0.);
721  setValue(4,2, ((c/(Gamma-1.)-u)*((Gamma-1.)/(2.*c*c))));
722  setValue(5,2, ((-c/(Gamma-1.)-u)*((Gamma-1.)/(2.*c*c))));
723 
724  setValue(1,3, ((Gamma-1.)*v/(c*c)));
725  setValue(2,3, (1.));
726  setValue(3,3, 0.);
727  setValue(4,3, -v*(Gamma-1.)/(2.*c*c));
728  setValue(5,3, -v*(Gamma-1.)/(2.*c*c));
729 
730  setValue(1,4, (Gamma-1.)*w/(c*c));
731  setValue(2,4, 0.);
732  setValue(3,4, (1.));
733  setValue(4,4, -w*(Gamma-1.)/(2.*c*c));
734  setValue(5,4, -w*(Gamma-1.)/(2.*c*c));
735 
736  setValue(1,5, (-(Gamma-1.)/(c*c)));
737  setValue(2,5, 0.);
738  setValue(3,5, 0.);
739  setValue(4,5, (Gamma-1.)/(2.*c*c));
740  setValue(5,5, (Gamma-1.)/(2.*c*c));
741  break;
742 
743 
744 
745 
746 
747 
748 
749 
750 // case 2:
751 // setValue(1,1,(c*c)*( -u));
752 // setValue(2,1, (c*c)*(1.-( (Gamma-1.)*(u*u+v*v+w*w)/(2.*c*c))));
753 // setValue(3,1, (c*c)*(-w));
754 // setValue(4,1, (c*c)*(.5*( (Gamma-1.)*(u*u+v*v+w*w)/(2.*c*c) - v/c )));
755 // setValue(5,1, (c*c)*(.5*( (Gamma-1.)*(u*u+v*v+w*w)/(2.*c*c) + v/c )));
756 //
757 // setValue(1,2, 0.);
758 // setValue(2,2, (c*c)*((Gamma-1.)*u/(c*c)));
759 // setValue(3,2, 0.);
760 // setValue(4,2, (c*c)*(-u*(Gamma-1.)/(2.*c*c)));
761 // setValue(5,2, (c*c)*(-u*(Gamma-1.)/(2.*c*c)));
762 //
763 // setValue(1,3, (c*c)*(1.));
764 // setValue(2,3, (c*c)*((Gamma-1.)*v/(c*c)));
765 // setValue(3,3, 0.);
766 // setValue(4,3, (c*c)*((c/(Gamma-1.)-v)*((Gamma-1.)/(2.*c*c))));
767 // setValue(5,3, (c*c)*((-c/(Gamma-1.)-v)*((Gamma-1.)/(2.*c*c))));
768 //
769 // setValue(1,4, 0.);
770 // setValue(2,4, (c*c)*((Gamma-1.)*w/(c*c)));
771 // setValue(3,4, (c*c)*(1.));
772 // setValue(4,4, (c*c)*(-w*(Gamma-1.)/(2.*c*c)));
773 // setValue(5,4, (c*c)*(-w*(Gamma-1.)/(2.*c*c)));
774 //
775 // setValue(1,5, 0.);
776 // setValue(2,5, (c*c)*(-(Gamma-1.)/(c*c)));
777 // setValue(3,5, 0.);
778 // setValue(4,5, (c*c)*((Gamma-1.)/(2.*c*c)));
779 // setValue(5,5, (c*c)*((Gamma-1.)/(2.*c*c)));
780 // break;
781 
782 // matrix vinokur
783  case 2:
784  setValue(1,1, -u);
785  setValue(2,1, (1.-( (Gamma-1.)*(u*u+v*v+w*w)/(2.*c*c))));
786  setValue(3,1, -w);
787  setValue(4,1, (.5*( (Gamma-1.)*(u*u+v*v+w*w)/(2.*c*c) - v/c )));
788  setValue(5,1, (.5*( (Gamma-1.)*(u*u+v*v+w*w)/(2.*c*c) + v/c )));
789 
790  setValue(1,2, 0.);
791  setValue(2,2, (Gamma-1.)*u/(c*c));
792  setValue(3,2, 0.);
793  setValue(4,2, (-u*(Gamma-1.)/(2.*c*c)));
794  setValue(5,2, (-u*(Gamma-1.)/(2.*c*c)));
795 
796  setValue(1,3, (c*c)*(1.));
797  setValue(2,3, (c*c)*((Gamma-1.)*v/(c*c)));
798  setValue(3,3, 0.);
799  setValue(4,3, (c*c)*((c/(Gamma-1.)-v)*((Gamma-1.)/(2.*c*c))));
800  setValue(5,3, (c*c)*((-c/(Gamma-1.)-v)*((Gamma-1.)/(2.*c*c))));
801 
802  setValue(1,4, 0.);
803  setValue(2,4, ((Gamma-1.)*w/(c*c)));
804  setValue(3,4, 1.);
805  setValue(4,4, -w*(Gamma-1.)/(2.*c*c));
806  setValue(5,4, -w*(Gamma-1.)/(2.*c*c));
807 
808  setValue(1,5, 0.);
809  setValue(2,5, -(Gamma-1.)/(c*c));
810  setValue(3,5, 0.);
811  setValue(4,5, (Gamma-1.)/(2.*c*c));
812  setValue(5,5, (Gamma-1.)/(2.*c*c));
813  break;
814 
815 
816 
817 // case 3:
818 // setValue(1,1, (c*c)*(-u));
819 // setValue(2,1, (c*c)*(-v));
820 // setValue(3,1, (c*c)*(1.-( (Gamma-1.)*(u*u+v*v+w*w)/(2.*c*c))));
821 // setValue(4,1, (c*c)*(.5*( (Gamma-1.)*(u*u+v*v+w*w)/(2.*c*c) - w/c )));
822 // setValue(5,1, (c*c)*(.5*( (Gamma-1.)*(u*u+v*v+w*w)/(2.*c*c) + w/c )));
823 //
824 // setValue(1,2, (c*c)*(1.));
825 // setValue(2,2, 0.);
826 // setValue(3,2, (c*c)*((Gamma-1.)*u/(c*c)));
827 // setValue(4,2, (c*c)*(-(Gamma-1.)*u/(2.*c*c)));
828 // setValue(5,2, (c*c)*(-(Gamma-1.)*u/(2.*c*c)));
829 //
830 // setValue(1,3, 0.);
831 // setValue(2,3, (c*c)*(1.));
832 // setValue(3,3, (c*c)*((Gamma-1.)*v/(c*c)));
833 // setValue(4,3, (c*c)*(-(Gamma-1.)*v/(2.*c*c)));
834 // setValue(5,3, (c*c)*(-(Gamma-1.)*v/(2.*c*c)));
835 //
836 // setValue(1,4, 0.);
837 // setValue(2,4, 0.);
838 // setValue(3,4, (c*c)*((Gamma-1.)*w/(c*c)));
839 // setValue(4,4, (c*c)*((c/(Gamma-1.)-w)*((Gamma-1.)/(2.*c*c))));
840 // setValue(5,4, (c*c)*((-c/(Gamma-1.)-w)*((Gamma-1.)/(2.*c*c))));
841 //
842 // setValue(1,5, 0.);
843 // setValue(2,5, 0.);
844 // setValue(3,5, (c*c)*(-(Gamma-1.)/(c*c)));
845 // setValue(4,5, (c*c)*((Gamma-1.)/(2.*c*c)));
846 // setValue(5,5, (c*c)*((Gamma-1.)/(2.*c*c)));
847 // break;
848 
849 
850 // matrix vinokur
851  case 3:
852  setValue(1,1, -u);
853  setValue(2,1, -v);
854  setValue(3,1, (1.-( (Gamma-1.)*(u*u+v*v+w*w)/(2.*c*c))));
855  setValue(4,1, (.5*( (Gamma-1.)*(u*u+v*v+w*w)/(2.*c*c) - w/c )));
856  setValue(5,1, (.5*( (Gamma-1.)*(u*u+v*v+w*w)/(2.*c*c) + w/c )));
857 
858  setValue(1,2, 1.);
859  setValue(2,2, 0.);
860  setValue(3,2, (Gamma-1.)*u/(c*c));
861  setValue(4,2, -(Gamma-1.)*u/(2.*c*c));
862  setValue(5,2, -(Gamma-1.)*u/(2.*c*c));
863 
864  setValue(1,3, 0.);
865  setValue(2,3, 1.);
866  setValue(3,3, (Gamma-1.)*v/(c*c));
867  setValue(4,3, -(Gamma-1.)*v/(2.*c*c));
868  setValue(5,3, -(Gamma-1.)*v/(2.*c*c));
869 
870  setValue(1,4, 0.);
871  setValue(2,4, 0.);
872  setValue(3,4, (Gamma-1.)*w/(c*c));
873  setValue(4,4, ((c/(Gamma-1.)-w)*((Gamma-1.)/(2.*c*c))));
874  setValue(5,4, ((-c/(Gamma-1.)-w)*((Gamma-1.)/(2.*c*c))));
875 
876  setValue(1,5, 0.);
877  setValue(2,5, 0.);
878  setValue(3,5, -(Gamma-1.)/(c*c));
879  setValue(4,5, (Gamma-1.)/(2.*c*c));
880  setValue(5,5, (Gamma-1.)/(2.*c*c));
881  break;
882 
883 
884 
885  };
886  }
887  else
888  {
889  // --- Right eigenmatrix ---
890 
891  switch(AxisNo)
892  {
893 // case 1:
894 // setValue(1,1, 1./(c*c));
895 // setValue(2,1, u/(c*c));
896 // setValue(3,1, v/(c*c));
897 // setValue(4,1, w/(c*c));
898 // setValue(5,1, .5*(u*u+v*v+w*w)/(c*c));
899 //
900 // setValue(1,2, 0.);
901 // setValue(2,2, 0.);
902 // setValue(3,2, 1./(c*c));
903 // setValue(4,2, 0.);
904 // setValue(5,2, v/(c*c));
905 //
906 // setValue(1,3, 0.);
907 // setValue(2,3, 0.);
908 // setValue(3,3, 0.);
909 // setValue(4,3, 1./(c*c));
910 // setValue(5,3, w/(c*c));
911 //
912 // setValue(1,4, 1./(c*c));
913 // setValue(2,4, (u+c)/(c*c));
914 // setValue(3,4, v/(c*c));
915 // setValue(4,4, w/(c*c));
916 // setValue(5,4, (h+ c*u)/(c*c));
917 //
918 // setValue(1,5, 1.);
919 // setValue(2,5, (u-c)/(c*c));
920 // setValue(3,5, v/(c*c));
921 // setValue(4,5, w/(c*c));
922 // setValue(5,5, (h- c*u)/(c*c));
923 // break;
924 
925 // matrix vinokur
926  case 1:
927  setValue(1,1, 1.);
928  setValue(2,1, u);
929  setValue(3,1, v);
930  setValue(4,1, w);
931  setValue(5,1, .5*(u*u+v*v+w*w));
932 
933  setValue(1,2, 0.);
934  setValue(2,2, 0.);
935  setValue(3,2, 1.);
936  setValue(4,2, 0.);
937  setValue(5,2, v);
938 
939  setValue(1,3, 0.);
940  setValue(2,3, 0.);
941  setValue(3,3, 0.);
942  setValue(4,3, 1.);
943  setValue(5,3, w);
944 
945  setValue(1,4, 1.);
946  setValue(2,4, u+c);
947  setValue(3,4, v);
948  setValue(4,4, w);
949  setValue(5,4, h+ c*u);
950 
951  setValue(1,5, 1.);
952  setValue(2,5, u-c);
953  setValue(3,5, v);
954  setValue(4,5, w);
955  setValue(5,5, h- c*u);
956  break;
957 
958 
959 // matrix vinokur
960  case 2:
961  setValue(1,1, 0.);
962  setValue(2,1, 0.);
963  setValue(3,1, 1.);
964  setValue(4,1, 0.);
965  setValue(5,1, u);
966 
967  setValue(1,2, 1.);
968  setValue(2,2, u);
969  setValue(3,2, v);
970  setValue(4,2, w);
971  setValue(5,2, .5*(u*u+v*v+w*w));
972 
973  setValue(1,3, 0.);
974  setValue(2,3, 0.);
975  setValue(3,3, 0.);
976  setValue(4,3, 1.);
977  setValue(5,3, w);
978 
979  setValue(1,4, 1.);
980  setValue(2,4, u);
981  setValue(3,4, v+c);
982  setValue(4,4, w);
983  setValue(5,4, h+ c*v);
984 
985  setValue(1,5, 1.);
986  setValue(2,5, u);
987  setValue(3,5, v-c);
988  setValue(4,5, w);
989  setValue(5,5, h- c*v);
990  break;
991 
992 // matrix vinokur
993 
994  case 3:
995  setValue(1,1, 0.);
996  setValue(2,1, 1.);
997  setValue(3,1, 0.);
998  setValue(4,1, 0.);
999  setValue(5,1, u);
1000 
1001  setValue(1,2, 0.);
1002  setValue(2,2, 0.);
1003  setValue(3,2, 1.);
1004  setValue(4,2, 0.);
1005  setValue(5,2, v);
1006 
1007  setValue(1,3, 1.);
1008  setValue(2,3, u);
1009  setValue(3,3, v);
1010  setValue(4,3, w);
1011  setValue(5,3, .5*(u*u+v*v+w*w));
1012 
1013  setValue(1,4, 1.);
1014  setValue(2,4, u);
1015  setValue(3,4, v);
1016  setValue(4,4, w+c);
1017  setValue(5,4, h+ c*w);
1018 
1019  setValue(1,5, 1.);
1020  setValue(2,5, u);
1021  setValue(3,5, v);
1022  setValue(4,5, w-c);
1023  setValue(5,5, h- c*w);
1024  break;
1025  };
1026  }
1027  break;
1028  };
1029 
1030 }
int QuantityNb
Definition: Parameters.cpp:171
real * U
Definition: Matrix.h:438
int Dimension
Definition: Parameters.cpp:74
real Gamma
Definition: Parameters.cpp:109
int Columns
Definition: Matrix.h:437
void setValue(const int i, const int j, const real a)
Sets the component i, j to value a.
Definition: Matrix.h:505
real value(const int n) const
Returns the value of the component n.
Definition: Vector.h:565
int Lines
Definition: Matrix.h:437
#define real
Definition: PreProcessor.h:31
void Matrix::setValue ( const int  i,
const int  j,
const real  a 
)
inline

Sets the component i, j to value a.

Example :

#include "Matrix.h"

Matrix M(2,2);
real x = 3.;
real y = 1.;
M.setValue(1,1,x);
M.setValue(2,1,y);

Parameters
iPosition
jPosition
aValue
Returns
void

506 {
507  *( U + (i-1)*Columns + (j-1) ) = a;
508 }
real * U
Definition: Matrix.h:438
int Columns
Definition: Matrix.h:437

Here is the caller graph for this function:

void Matrix::setZero ( )

Sets all the components to zero.

Returns
void
128 {
129  int n;
130 
131  for (n = 1; n <= Lines*Columns; n++)
132  *(U+n-1) = 0.;
133 }
real * U
Definition: Matrix.h:438
int Columns
Definition: Matrix.h:437
int Lines
Definition: Matrix.h:437

Here is the caller graph for this function:

real Matrix::value ( const int  i,
const int  j 
) const
inline

Returns the value of the component i, j.

Example :

#include "Matrix.h"

Matrix M(2,2);
real x;
real y;
...
x = M.value(1,1);
y = M.value(2,1);

Parameters
i
j
Returns
real

516 {
517  return *(U+(i-1)*Columns+(j-1));
518 }
real * U
Definition: Matrix.h:438
int Columns
Definition: Matrix.h:437

Here is the caller graph for this function:

Member Data Documentation

int Matrix::Columns

Lines and columns of the matrix

int Matrix::Lines
real* Matrix::U

Components


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