Carmen Code
 All Classes Files Functions Variables Macros Pages
Functions
NormMaxQuantities.cpp File Reference

Compute the Linf norm of a vector containing the physical quantities divided by their characteristic value. More...

#include "Carmen.h"
Include dependency graph for NormMaxQuantities.cpp:

Functions

real NormMaxQuantities (const Vector &V)
 Returns the Max-norm of the vector where every quantity is divided by its characteristic value. More...
 

Detailed Description

Compute the Linf norm of a vector containing the physical quantities divided by their characteristic value.

Author
Anna Karina Fontes Gomes
Date
January-2017

Function Documentation

real NormMaxQuantities ( const Vector V)

Returns the Max-norm of the vector where every quantity is divided by its characteristic value.

Parameters
VVector
Returns
double
26 {
27  Vector W(QuantityNb);
28  int AxisNo=1;
29  real MomentumMax=0.;
30  real MagMax=0.;
31 
32 
33 
34  W.setZero();
35 
36 /*
37  // Density
38  W.setValue(1, V.value(1)/QuantityMax.value(1));
39 
40  // Momentum
41  W.setValue(2 , V.value(2)/QuantityMax.value(2) );
42  W.setValue(3 , V.value(3)/QuantityMax.value(3) );
43  W.setValue(4 , V.value(4)/QuantityMax.value(4) );
44 
45  // Energy
46  W.setValue(5 , V.value(5)/QuantityMax.value(5) );
47 
48  // psi
49  // W.setValue(6, V.value(6)/QuantityMax.value(6));
50 
51  // Magnetic Field
52  W.setValue(7 , V.value(7)/QuantityMax.value(7) );
53  W.setValue(8 , V.value(8)/QuantityMax.value(8) );
54  W.setValue(9 , V.value(9)/QuantityMax.value(9) );
55 */
56 
57  // --- Compute Linf norm --
58 
59  W.setValue(1, (V.value(1))/QuantityMax.value(1));
60  W.setValue(5, (V.value(5))/QuantityMax.value(5));
61  //W.setValue(6, (V.value(6))/QuantityMax.value(6));
62 
63 
64  for (AxisNo = 1; AxisNo <= Dimension; AxisNo++)
65  {
66  MomentumMax = Max( MomentumMax, QuantityMax.value(AxisNo+1) );
67  MagMax = Max( MagMax, QuantityMax.value(AxisNo+6) );
68  W.setValue(2, W.value(2) + V.value(AxisNo+1)*V.value(AxisNo+1));
69  W.setValue(7, W.value(7) + V.value(AxisNo+6)*V.value(AxisNo+6));
70  }
71 
72  if(Dimension==2){
73  W.setValue(4, (V.value(4))/QuantityMax.value(4));
74  W.setValue(9, (V.value(9))/QuantityMax.value(9));
75  }
76 
77  W.setValue(2, sqrt(W.value(2))/MomentumMax);
78  W.setValue(7, sqrt(W.value(7))/MagMax );
79 
80  if(IterationNo==0)return NMax(V);
81  return NMax(W);
82 }
int QuantityNb
Definition: Parameters.cpp:171
Standard class for every vector in Carmen.
Definition: Vector.h:29
int Dimension
Definition: Parameters.cpp:74
int IterationNo
Definition: Parameters.cpp:168
real NMax(const Vector &V)
Returns the Max-norm of the vector.
Definition: Vector.cpp:1543
Vector QuantityMax
Definition: Parameters.cpp:162
real value(const int n) const
Returns the value of the component n.
Definition: Vector.h:565
#define Max(x, y)
Definition: Carmen.h:54
#define real
Definition: PreProcessor.h:31