Carmen Code
 All Classes Files Functions Variables Macros Pages
Macros | Functions
Carmen.h File Reference

The .h that includes all functions headers. More...

#include "carmen.pre"
#include "PreProcessor.h"
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include "Vector.h"
#include "Matrix.h"
#include "Timer.h"
#include "Parameters.h"
#include "PrintGrid.h"
#include "TimeAverageGrid.h"
#include "Cell.h"
#include "Node.h"
#include "FineMesh.h"
Include dependency graph for Carmen.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define Max(x, y)   (((x) > (y)) ? (x):(y))
 
#define Max3(x, y, z)   (Max((x),Max((y),(z))))
 
#define Min(x, y)   (((x) < (y)) ? (x):(y))
 
#define Min3(x, y, z)   (Min((x),Min((y),(z))))
 
#define power2(x)   ((x)*(x))
 
#define power3(x)   ((x)*(x)*(x))
 
#define Abs(x)   ( ((x) < 0)? -(x):(x) )
 

Functions

void AdaptTimeStep ()
 Adapts time step when required. More...
 
int BC (int i, int AxisNo, int N=(1<< ScaleNb))
 Returns the position of i taking into account the boundary conditions in the direction AxisNo. The number of points in this direction is N.
Example: for AxisNo=1 and for N=256, i must be between 0 and 255. If i=-1, the function returns 255 for periodic boundary conditions and 0 for Neumann boundary conditions. More...
 
int BoundaryRegion (const Vector &X)
 Returns the boundary region type at the position X=(x,y,z).
The returned value correspond to: 0 = Fluid (not in the boundary) 1 = Inflow 2 = Outflow 3 = Solid with free-slip walls 4 = Solid with adiabatic walls 5 = Solid with isothermal walls. More...
 
void Backup (Node *Root)
 Stores the tree structure and data in order to restart a multiresolution computation. More...
 
void Backup (FineMesh *Root)
 Stores the data countained in a regular mesh Root in order to restart a finite volume computation. More...
 
double CPUTimeRef (int iterations, int scales)
 Returns the time required by a finite volume computation using iterations iterations and scales scales. It is use to estimate the CPU time compression. More...
 
real ComputedTolerance (const int ScaleNo)
 Returns the computed tolerance at the scale ScaleNo, either using Harten or Donoho thresholding (if CVS=true). More...
 
int DigitNumber (int arg)
 Returns the number of digits of the integer arg. More...
 
int FileWrite (FILE *f, const char *format, real arg)
 Writes in binary or ASCII mode the real number arg into the file f with the format format. The global parameter DataIsBinary determines this choice. More...
 
Vector Flux (Cell &Cell1, Cell &Cell2, Cell &Cell3, Cell &Cell4, int AxisNo)
 Returns the flux at the interface between Cell2 and Cell3. Here a 4-point space scheme is used. Cell2 and Cell3 are the first neighbours on the left and right sides. Cell1 and Cell4 are the second neighbours on the left and right sides. More...
 
void GetBoundaryCells (Cell &Cell1, Cell &Cell2, Cell &Cell3, Cell &Cell4, Cell &C1, Cell &C2, Cell &C3, Cell &C4, int AxisNo)
 Transform the 4 cells of the flux Cell1, Cell2, Cell3, Cell4 into C1, C2, C3, C4, to take into account boundary conditions (used in Flux.cpp). More...
 
Vector InitAverage (real x, real y=0., real z=0.)
 Returns the initial condition in (x, y, z) form the one defined in carmen.ini. More...
 
real InitResistivity (real x, real y=0., real z=0.)
 Returns the initial resistivity condition in (x, y, z) form the one defined in carmen.eta. More...
 
void InitParameters ()
 Inits parameters from file carmen.par. If a parameter is not mentioned in this file, the default value is used. More...
 
void InitTimeStep ()
 Inits time step and all the parameters which depend on it. More...
 
void InitTree (Node *Root)
 Inits tree structure from initial condition, starting form the node Root. Only for multiresolution computations. More...
 
Vector Limiter (const Vector u, const Vector v)
 Returns the value of the slope limiter between the slopes u and v. More...
 
real Limiter (const real x)
 Returns the valur of slope limiter from a real value x. More...
 
real MinAbs (const real a, const real b)
 Returns the minimum in module of a and b. More...
 
real NormMaxQuantities (const Vector &V)
 Returns the Max-norm of the vector where every quantity is divided by its characteristic value. More...
 
void Performance (const char *FileName)
 Computes the performance of the computation and, for cluster computations, write it into file FileName. More...
 
void PrintIntegral (const char *FileName)
 Writes the integral values, like e.g flame velocity, global error, into file FileName. More...
 
void RefreshTree (Node *Root)
 Refresh the tree structure, i.e. compute the cell-averages of the internal nodes by projection and those of the virtual leaves by prediction. The root node is Root. Only for multiresolution computations. More...
 
void Remesh (Node *Root)
 Remesh the tree structure after a time evolution. The root node is Root. Only for multiresolution computations. More...
 
Vector FluxX (const Vector &Avg)
 Returns the physical flux of MHD equations in X direction. More...
 
Vector FluxY (const Vector &Avg)
 Returns the physical flux of MHD equations in Y direction. More...
 
Vector FluxZ (const Vector &Avg)
 Returns the physical flux of MHD equations in Z direction. More...
 
Vector SchemeHLL (const Cell &Cell1, const Cell &Cell2, const Cell &Cell3, const Cell &Cell4, const int AxisNo)
 Returns the HLL numerical flux for MHD equations. The scheme uses four cells to estimate the flux at the interface. Cell2 and Cell3 are the first neighbours on the left and right sides. Cell1 and Cell4 are the second neighbours on the left and right sides. More...
 
Vector SchemeHLLD (const Cell &Cell1, const Cell &Cell2, const Cell &Cell3, const Cell &Cell4, const int AxisNo)
 Returns the HLLD numerical flux for MHD equations. The scheme uses four cells to estimate the flux at the interface. Cell2 and Cell3 are the first neighbours on the left and right sides. Cell1 and Cell4 are the second neighbours on the left and right sides. More...
 
Matrix stateUstar (const Vector &AvgL, const Vector &AvgR, const real prel, const real prer, real &slopeLeft, real &slopeRight, real &slopeM, real &slopeLeftStar, real &slopeRightStar, int AxisNo)
 Returns the intermediary states of HLLD numerical flux for MHD equations. More...
 
void fluxCorrection (Vector &Flux, const Vector &AvgL, const Vector &AvgR, int AxisNo)
 This function apply the divergence-free correction to the numerical flux. More...
 
void ShowTime (Timer arg)
 Writes on screen the estimation of total and remaining CPU times. These informations are stored in the timer arg. More...
 
int Sign (const real a)
 Returns 1 if a is non-negative, -1 elsewhere. More...
 
Vector ArtificialViscosity (const Vector &Cell1, const Vector &Cell2, real dx, int AxisNo)
 Returns the artificial diffusion source terms in the cell UserCell. More...
 
Vector ResistiveTerms (Cell &Cell1, Cell &Cell2, Cell &Cell3, Cell &Cell4, int AxisNo)
 Returns the resistive source terms in the cell UserCell. More...
 
Vector Source (Cell &UserCell)
 Returns the source term in the cell UserCell. More...
 
real Step (real x)
 Returns a step (1 if x <0, 0 if x >0, 0.5 if x=0) More...
 
void TimeEvolution (FineMesh *Root)
 Computes a time evolution on the regular fine mesh Root. Only for finite volume computations. More...
 
void TimeEvolution (Node *Root)
 Computes a time evolution on the tree structure, the root node being Root. Only for multiresolution computations. More...
 
void View (FineMesh *Root, const char *AverageFileName)
 Writes the current cel–averages of the fine mesh Root into file AverageFileName. Only for finite volume computations. More...
 
void View (Node *Root, const char *TreeFileName, const char *MeshFileName, const char *AverageFileName)
 Writes the data of the tree structure into files TreeFileName (tree structure), MeshFileName (mesh) and AverageFileName (cell-averages). The root node is Root. Only for multiresolution computations. More...
 
void ViewEvery (FineMesh *Root, int arg)
 Same as previous for a fine mesh Root. Only for finite volume computations. More...
 
void ViewEvery (Node *Root, int arg)
 Writes into file the data of the tree structure at iteration arg. The output file names are AverageNNN.dat and MeshNNN.dat, NNN being the iteration in an accurate format. The root node is Root. Only for multiresolution computations. More...
 
void ViewIteration (FineMesh *Root)
 Same as previous for a fine mesh Root. Only for finite volume computations. More...
 
void ViewIteration (Node *Root)
 Writes into file the data of the tree structure from physical time PrintTime1 to physical time PrintTime6. The output file names are Average_N.dat and Mesh_N.dat, N being between 1 and 6. The root node is Root. Only for multiresolution computations. More...
 
void CreateMPIType (FineMesh *Root)
 
void CPUExchange (FineMesh *Root, int)
 Parallel function DOES NOT WORK! More...
 
void FreeMPIType ()
 Parallel function DOES NOT WORK! More...
 
void CreateMPITopology ()
 Parallel function DOES NOT WORK! More...
 
void CreateMPILinks ()
 Parallel function DOES NOT WORK! More...
 
void ReduceIntegralValues ()
 Parallel function DOES NOT WORK! More...
 

Detailed Description

The .h that includes all functions headers.

Macro Definition Documentation

#define Abs (   x)    ( ((x) < 0)? -(x):(x) )

Returns the absolute value of x.

#define Max (   x,
 
)    (((x) > (y)) ? (x):(y))

Returns the Maximum value between x and y.

#define Max3 (   x,
  y,
 
)    (Max((x),Max((y),(z))))

Returns the Maximum value between x, y and z.

#define Min (   x,
 
)    (((x) < (y)) ? (x):(y))

Returns the mininum value between x and y.

#define Min3 (   x,
  y,
 
)    (Min((x),Min((y),(z))))

Returns the minimum value between x, y and z.

#define power2 (   x)    ((x)*(x))

Returns the square of x.

#define power3 (   x)    ((x)*(x)*(x))

Returns the cube of x.

Function Documentation

void AdaptTimeStep ( )

Adapts time step when required.

Returns
void
25 {
26  int RemainingIterations;
27  real RemainingTime;
28 
29 
30  // Security : do nothing if ConstantTimeStep is true
31 
32  if (ConstantTimeStep)
33  return;
34 
35  // Compute remaining time
36 
37  RemainingTime = PhysicalTime-ElapsedTime;
38 
39 
40  // In this case, use time adaptivity based on CFL
41  if(Resistivity)
43  else
45 
46  // Recompute IterationNb
47 
48  if (RemainingTime <= 0.)
49  {
51  }
52  else if (RemainingTime < TimeStep)
53  {
54  TimeStep = RemainingTime;
56  }
57  else
58  {
59  RemainingIterations = (int)(RemainingTime/TimeStep);
60  IterationNb = IterationNo + RemainingIterations;
61  }
62 
63  return;
64 
65 }
real PhysicalTime
Definition: Parameters.cpp:41
int IterationNb
Definition: Parameters.cpp:37
bool Resistivity
Definition: Parameters.cpp:120
real eta
Definition: Parameters.cpp:123
real Eigenvalue
Definition: Parameters.cpp:157
real SpaceStep
Definition: Parameters.cpp:156
int IterationNo
Definition: Parameters.cpp:168
real ElapsedTime
Definition: Parameters.cpp:95
real TimeStep
Definition: Parameters.cpp:40
bool ConstantTimeStep
Definition: Parameters.cpp:94
real CFL
Definition: Parameters.cpp:39
#define real
Definition: PreProcessor.h:31

Here is the caller graph for this function:

Vector ArtificialViscosity ( const Vector Cell1,
const Vector Cell2,
real  dx,
int  AxisNo 
)

Returns the artificial diffusion source terms in the cell UserCell.

Parameters
Cell1Left cell value
Cell2Right cell value
AxisNoAxis of interest
Returns
Vector

X - direction

Y - direction

Z - direction

12 {
13  // --- Local variables ---
14  Vector ML(3), MR(3);
15  Vector Result(QuantityNb);
16  real EL,ER,RL,RR;
17  real viscR, viscX, viscY, viscZ, viscE;
18 
19 
20  for(int i=1; i <= 3; i++){
21  ML.setValue(i, Cell1.value(i+1));
22  MR.setValue(i, Cell2.value(i+1));
23  }
24 
25  RL = Cell1.value(1);
26  RR = Cell2.value(1);
27  EL = Cell1.value(5);
28  ER = Cell2.value(5);
29 
30 
31  if(AxisNo == 1){
33  viscR = (RR - RL)/dx;
34  viscE = (ER - EL)/dx;
35 
36  viscX = (MR.value(1) - ML.value(1))/dx;
37  viscY = (MR.value(2) - ML.value(2))/dx;
38  viscZ = (MR.value(3) - ML.value(3))/dx;
39 
40 
41  }else if(AxisNo == 2){
43  viscR = (RR - RL)/dx;
44  viscE = (ER - EL)/dx;
45 
46  viscX = (MR.value(1) - ML.value(1))/dx;
47  viscY = (MR.value(2) - ML.value(2))/dx;
48  viscZ = (MR.value(3) - ML.value(3))/dx;
49 
50  }else{
52  viscR = (RR - RL)/dx;
53  viscE = (ER - EL)/dx;
54 
55  viscX = (MR.value(1) - ML.value(1))/dx;
56  viscY = (MR.value(2) - ML.value(2))/dx;
57  viscZ = (MR.value(3) - ML.value(3))/dx;
58 
59  }
60 
61 
62  Result.setZero();
63 
64  // These values will be added to the numerical flux
65  Result.setValue(1, chi*viscR);
66  Result.setValue(2, chi*viscX);
67  Result.setValue(3, chi*viscY);
68  Result.setValue(4, chi*viscZ);
69  Result.setValue(5, chi*viscE);
70 
71  return Result;
72 
73 }
int QuantityNb
Definition: Parameters.cpp:171
Standard class for every vector in Carmen.
Definition: Vector.h:29
real chi
Definition: Parameters.cpp:124
real value(const int n) const
Returns the value of the component n.
Definition: Vector.h:565
#define real
Definition: PreProcessor.h:31

Here is the caller graph for this function:

void Backup ( Node Root)

Stores the tree structure and data in order to restart a multiresolution computation.

  • Root denotes the pointer to the first node of the tree structure.

    Parameters
    RootRoot
    Returns
    void
31 {
32  Root->backup();
33 }
void backup()
Backs up the tree structure and the cell-averages into a file carmen.bak. In further computations...
Definition: Node.cpp:2716

Here is the caller graph for this function:

void Backup ( FineMesh Root)

Stores the data countained in a regular mesh Root in order to restart a finite volume computation.

Parameters
RootRoot
Returns
void
43 {
44  Root->backup();
45 }
void backup()
Backs up the tree structure and the cell-averages into a file carmen.bak. In further computations...
Definition: FineMesh.cpp:1741
int BC ( int  i,
int  AxisNo,
int  N = (1<< ScaleNb) 
)

Returns the position of i taking into account the boundary conditions in the direction AxisNo. The number of points in this direction is N.
Example: for AxisNo=1 and for N=256, i must be between 0 and 255. If i=-1, the function returns 255 for periodic boundary conditions and 0 for Neumann boundary conditions.

Parameters
iPosition
AxisNoAxis of interest
NDefaults to (1<<ScaleNb).
Returns
int
38 {
39  int result=-999999;
40 
41  if (AxisNo > Dimension)
42  return 0;
43 
44 #if defined PARMPI
45  if (CMin[AxisNo] == 3) result=i; //Periodic
46  else
47  {
48  if (i<0) if ((coords[0]==0 && AxisNo==1) || (coords[1]==0 && AxisNo==2) || (coords[2]==0 && AxisNo==3)) result=-i-1; //Neumann
49  if (i>=N) if ((coords[0]==CartDims[0]-1 && AxisNo==1) || (coords[1]==CartDims[1]-1 && AxisNo==2)
50  || (coords[2]==CartDims[2]-1 && AxisNo==3)) result=2*N-i-1;
51  if (result==-999999) result=i; //Not the boundary, simple cell from anouther CPU
52  }
53 
54 
55 #else
56  if (CMin[AxisNo] == 3)
57  result = (i+N)%N; // Periodic
58  else if(CMin[AxisNo] == 2)
59  result = ((i+N)/N==1)? i : (2*N-i-1)%N; // Neumann
60 
61 #endif
62 
63  return result;
64 }
int coords[3]
Definition: Parameters.cpp:230
int CMin[4]
Definition: Parameters.cpp:78
int Dimension
Definition: Parameters.cpp:74
int CartDims[3]
Definition: Parameters.cpp:231

Here is the caller graph for this function:

int BoundaryRegion ( const Vector X)

Returns the boundary region type at the position X=(x,y,z).
The returned value correspond to: 0 = Fluid (not in the boundary) 1 = Inflow 2 = Outflow 3 = Solid with free-slip walls 4 = Solid with adiabatic walls 5 = Solid with isothermal walls.

Parameters
XVector
Returns
int
64 {
65  real x=0., y=0., z=0.;
66 
67  int Fluid;
68  int Inflow;
69  int Outflow;
70  int FreeSlipSolid;
71  int AdiabaticSolid;
72  int IsothermalSolid;
73 
74  int Region;
75 
76  // Only in UseBoundaryRegions = true
77 
78  if (!UseBoundaryRegions) return 0;
79 
80  // --- Init values --
81 
82  Fluid = 0;
83  Inflow = 1;
84  Outflow = 2;
85  FreeSlipSolid = 3;
86  AdiabaticSolid = 4;
87  IsothermalSolid = 5;
88 
89  Region = Fluid;
90 
91  x = X.value(1);
92  y = (Dimension > 1)? X.value(2):0.;
93  z = (Dimension > 2)? X.value(3):0.;
94 
95  #include "carmen.bc"
96 
97  return Region;
98 }
int Dimension
Definition: Parameters.cpp:74
real value(const int n) const
Returns the value of the component n.
Definition: Vector.h:565
bool UseBoundaryRegions
Definition: Parameters.cpp:80
#define real
Definition: PreProcessor.h:31

Here is the caller graph for this function:

real ComputedTolerance ( const int  ScaleNo)

Returns the computed tolerance at the scale ScaleNo, either using Harten or Donoho thresholding (if CVS=true).

Parameters
ScaleNoLevel of interest.
Returns
double
23 {
24 //if ThresholdNorm==0 const Tolerance, else L1 Harten norm
25 
26  if(ThresholdNorm)
27  return((Tolerance/GlobalVolume)*exp(Dimension*(ScaleNo-ScaleNb+1)*log(2.)));
28  else
29  return(Tolerance);
30 
31 }
int ScaleNb
Definition: Parameters.cpp:87
int Dimension
Definition: Parameters.cpp:74
real GlobalVolume
Definition: Parameters.cpp:203
real Tolerance
Definition: Parameters.cpp:91
int ThresholdNorm
Definition: Parameters.cpp:100
void CPUExchange ( FineMesh Root,
int   
)

Parallel function DOES NOT WORK!

Parameters
RootFine mesh
Returns
void
350  {
351  CommTimer.start();
352 #if defined PARMPI
353  int i,k;
354  int exNb=0;
355 
356  WhatSend=WS;
357  CellElementsNb=0;
358 
359  for (i=0;i<16;i++) {
360  k=1<<i;
361  if ((WS & k) != 0) CellElementsNb++;
362  }
363 
364  static bool ft=true;
365 // if (ft==true) {
366  CreateMPIType(Root);
367 // CreateMPILinks();
368 // ft=false;
369 // }
370 
371 // MPI_Startall(4*Dimension,req);
372 
373 
374 //Send
375  switch (MPISendType) {
376  case 0:
377  MPI_Ibsend(MPI_BOTTOM, 1, MPItypeSiL, rank_il, 100, comm_cart ,&req[exNb++]);
378  MPI_Ibsend(MPI_BOTTOM, 1, MPItypeSiU, rank_iu, 200, comm_cart, &req[exNb++] );
379  break;
380 
381  case 10:
382  MPI_Isend(MPI_BOTTOM, 1, MPItypeSiL, rank_il, 100, comm_cart,&req[exNb++]);
383  MPI_Isend(MPI_BOTTOM, 1, MPItypeSiU, rank_iu, 200, comm_cart,&req[exNb++]);
384  break;
385 
386  case 20:
387  MPI_Issend(MPI_BOTTOM, 1, MPItypeSiL, rank_il, 100, comm_cart,&req[exNb++]);
388  MPI_Issend(MPI_BOTTOM, 1, MPItypeSiU, rank_iu, 200, comm_cart,&req[exNb++]);
389  break;
390  }
391 
392  if (Dimension >= 2) {
393  switch (MPISendType) {
394  case 0:
395  MPI_Ibsend(MPI_BOTTOM, 1, MPItypeSjL, rank_jl, 300, comm_cart,&req[exNb++]);
396  MPI_Ibsend(MPI_BOTTOM, 1, MPItypeSjU, rank_ju, 400, comm_cart,&req[exNb++]);
397  break;
398 
399  case 10:
400  MPI_Isend(MPI_BOTTOM, 1, MPItypeSjL, rank_jl, 300, comm_cart,&req[exNb++]);
401  MPI_Isend(MPI_BOTTOM, 1, MPItypeSjU, rank_ju, 400, comm_cart,&req[exNb++]);
402  break;
403 
404  case 20:
405  MPI_Issend(MPI_BOTTOM, 1, MPItypeSjL, rank_jl, 300, comm_cart,&req[exNb++]);
406  MPI_Issend(MPI_BOTTOM, 1, MPItypeSjU, rank_ju, 400, comm_cart,&req[exNb++]);
407  break;
408  }
409  }
410 
411  if (Dimension == 3) {
412  switch (MPISendType) {
413  case 0:
414  MPI_Ibsend(MPI_BOTTOM, 1, MPItypeSkL, rank_kl, 500, comm_cart,&req[exNb++]);
415  MPI_Ibsend(MPI_BOTTOM, 1, MPItypeSkU, rank_ku, 600, comm_cart,&req[exNb++]);
416  break;
417 
418  case 10:
419  MPI_Isend(MPI_BOTTOM, 1, MPItypeSkL, rank_kl, 500, comm_cart,&req[exNb++]);
420  MPI_Isend(MPI_BOTTOM, 1, MPItypeSkU, rank_ku, 600, comm_cart,&req[exNb++]);
421  break;
422 
423  case 20:
424  MPI_Issend(MPI_BOTTOM, 1, MPItypeSkL, rank_kl, 500, comm_cart,&req[exNb++]);
425  MPI_Issend(MPI_BOTTOM, 1, MPItypeSkU, rank_ku, 600, comm_cart,&req[exNb++]);
426  break;
427  }
428  }
429 
430 //Recv
431 
432  if (MPIRecvType==0) {
433  MPI_Recv(MPI_BOTTOM, 1, MPItypeRiL, rank_il, 200, comm_cart, &st[6]);
434  MPI_Recv(MPI_BOTTOM, 1, MPItypeRiU, rank_iu, 100, comm_cart, &st[7]);
435  } else
436  {
437  MPI_Irecv(MPI_BOTTOM, 1, MPItypeRiL, rank_il, 200, comm_cart, &req[exNb++]);
438  MPI_Irecv(MPI_BOTTOM, 1, MPItypeRiU, rank_iu, 100, comm_cart, &req[exNb++]);
439  }
440 
441  if (Dimension >= 2) {
442  if (MPIRecvType==0) {
443  MPI_Recv(MPI_BOTTOM, 1, MPItypeRjL, rank_jl, 400, comm_cart, &st[8]);
444  MPI_Recv(MPI_BOTTOM, 1, MPItypeRjU, rank_ju, 300, comm_cart, &st[9]);
445  } else
446  {
447  MPI_Irecv(MPI_BOTTOM, 1, MPItypeRjL, rank_jl, 400, comm_cart, &req[exNb++]);
448  MPI_Irecv(MPI_BOTTOM, 1, MPItypeRjU, rank_ju, 300, comm_cart, &req[exNb++]);
449  }
450  }
451 
452  if (Dimension == 3) {
453  if (MPIRecvType==0) {
454  MPI_Recv(MPI_BOTTOM, 1, MPItypeRkL, rank_kl, 600, comm_cart, &st[10]);
455  MPI_Recv(MPI_BOTTOM, 1, MPItypeRkU, rank_ku, 500, comm_cart, &st[11]);
456  } else
457  {
458  MPI_Irecv(MPI_BOTTOM, 1, MPItypeRkL, rank_kl, 600, comm_cart, &req[exNb++]);
459  MPI_Irecv(MPI_BOTTOM, 1, MPItypeRkU, rank_ku, 500, comm_cart, &req[exNb++]);
460  }
461  }
462 
463  FreeMPIType();
464 #endif
465  CommTimer.stop();
466 }
int MPIRecvType
Definition: Parameters.cpp:239
double stop()
Stop timer and, if asked, returns CPU time from previous start in seconds.
Definition: Timer.cpp:77
int Dimension
Definition: Parameters.cpp:74
void FreeMPIType()
Parallel function DOES NOT WORK!
Definition: Parallel.cpp:247
int rank_ku
Definition: Parameters.cpp:245
int MPISendType
Definition: Parameters.cpp:238
int rank_il
Definition: Parameters.cpp:243
void CreateMPIType(FineMesh *Root)
Definition: Parallel.cpp:121
int WhatSend
Definition: Parameters.cpp:247
Timer CommTimer
Definition: Parameters.cpp:241
void start()
Starts timer.
Definition: Timer.cpp:62
int rank_jl
Definition: Parameters.cpp:244
int rank_ju
Definition: Parameters.cpp:244
int rank_iu
Definition: Parameters.cpp:243
int CellElementsNb
Definition: Parameters.cpp:233
int rank_kl
Definition: Parameters.cpp:245

Here is the caller graph for this function:

double CPUTimeRef ( int  iterations,
int  scales 
)

Returns the time required by a finite volume computation using iterations iterations and scales scales. It is use to estimate the CPU time compression.

Parameters
iterationsNumber of iterations.
scalesScales
Returns
double
24 {
25  // --- Local variables ---------------------------------------------------
26 
27  int OldIterationNb=0;
28  int OldScaleNb=0;
29  real OldTimeStep=0.;
30  bool ConstantTimeStepOld=ConstantTimeStep;
31 
32  double result=0.;
33 
34  Timer CPURef;
35  FineMesh* MeshRef;
36 
37  // --- Execution ---------------------------------------------------------
38 
39  // Toggle on : Compute reference CPU time
40 
41  ComputeCPUTimeRef = true;
42 
43  // Toggle off : Constant time step
44 
45  ConstantTimeStep = true;
46 
47  // backup values of IterationNb and ScaleNb
48 
49  OldIterationNb = IterationNb;
50  OldScaleNb = ScaleNb;
51  OldTimeStep = TimeStep;
52 
53  // use reference values
54  IterationNb = iterations;
55  ScaleNb = scales;
56  TimeStep = 0.;
57 
58  one_D=1; two_D=1;
59  if (Dimension >= 2) one_D=1<<ScaleNb;
60  if (Dimension == 3) two_D=1<<ScaleNb;
61 
62  // init mesh
63  MeshRef = new FineMesh;
64 
65  // Iterate on time
66 
68  {
69  // start timer
70  CPURef.start();
71 
72  // Compute time evolution
73  TimeEvolution(MeshRef);
74 
75  // check CPU Time
76  CPURef.check();
77 
78  // stop timer
79  CPURef.stop();
80  }
81 
82  // Compute CPUTimeRef
83  result = CPURef.CPUTime();
84  result *= 1./IterationNb;
85  result *= 1<<(Dimension*(OldScaleNb-ScaleNb));
86 
87  // delete MeshRef
88  delete MeshRef;
89 
90  // restore values of IterationNb and ScaleNb
91  IterationNb = OldIterationNb;
92  ScaleNb = OldScaleNb;
93  TimeStep = OldTimeStep;
94  IterationNo = 0;
95 
96  one_D=1; two_D=1;
97  if (Dimension >= 2) one_D=1<<ScaleNb;
98  if (Dimension == 3) two_D=1<<ScaleNb;
99 
100  // Toggle off : Compute reference CPU time
101 
102  ComputeCPUTimeRef = false;
103 
104  // Restore the value of ConstantTimeStep
105 
106  ConstantTimeStep = ConstantTimeStepOld;
107 
108  return result;
109 }
int one_D
Definition: Parameters.cpp:236
int IterationNb
Definition: Parameters.cpp:37
int ScaleNb
Definition: Parameters.cpp:87
double CPUTime()
Returns CPU time from previous start in seconds.
Definition: Timer.cpp:124
bool ComputeCPUTimeRef
Definition: Parameters.cpp:62
An object FineMesh is a regular fine mesh, used for finite volume computations. It is not used for mu...
Definition: FineMesh.h:40
double stop()
Stop timer and, if asked, returns CPU time from previous start in seconds.
Definition: Timer.cpp:77
void TimeEvolution(FineMesh *Root)
Computes a time evolution on the regular fine mesh Root. Only for finite volume computations.
Definition: TimeEvolution.cpp:77
int Dimension
Definition: Parameters.cpp:74
int IterationNo
Definition: Parameters.cpp:168
void start()
Starts timer.
Definition: Timer.cpp:62
real TimeStep
Definition: Parameters.cpp:40
int two_D
Definition: Parameters.cpp:236
bool ConstantTimeStep
Definition: Parameters.cpp:94
void check()
Adds CPU time and real time to their buffers and resets. For long computations, it is recommended to ...
Definition: Timer.cpp:103
An object Timer gives information on the CPU time of long-time computations.
Definition: Timer.h:31
#define real
Definition: PreProcessor.h:31

Here is the caller graph for this function:

void CreateMPILinks ( )

Parallel function DOES NOT WORK!

Returns
void
271  {
272  int exNb;
273  exNb=0;
274 #if defined PARMPI
275 
276 //Send
277 
278  switch (MPISendType) {
279  case 0:
280  MPI_Bsend_init(MPI_BOTTOM, 1, MPItypeSiL, rank_il, 100, comm_cart ,&req[exNb++]);
281  MPI_Bsend_init(MPI_BOTTOM, 1, MPItypeSiU, rank_iu, 200, comm_cart, &req[exNb++]);
282  break;
283 
284  case 10:
285  MPI_Send_init(MPI_BOTTOM, 1, MPItypeSiL, rank_il, 100, comm_cart,&req[exNb++]);
286  MPI_Send_init(MPI_BOTTOM, 1, MPItypeSiU, rank_iu, 200, comm_cart,&req[exNb++]);
287  break;
288 
289  case 20:
290  MPI_Ssend_init(MPI_BOTTOM, 1, MPItypeSiL, rank_il, 100, comm_cart,&req[exNb++]);
291  MPI_Ssend_init(MPI_BOTTOM, 1, MPItypeSiU, rank_iu, 200, comm_cart,&req[exNb++]);
292  break;
293  }
294 
295  if (Dimension >= 2) {
296  switch (MPISendType) {
297  case 0:
298  MPI_Bsend_init(MPI_BOTTOM, 1, MPItypeSjL, rank_jl, 300, comm_cart,&req[exNb++]);
299  MPI_Bsend_init(MPI_BOTTOM, 1, MPItypeSjU, rank_ju, 400, comm_cart,&req[exNb++]);
300  break;
301 
302  case 10:
303  MPI_Send_init(MPI_BOTTOM, 1, MPItypeSjL, rank_jl, 300, comm_cart,&req[exNb++]);
304  MPI_Send_init(MPI_BOTTOM, 1, MPItypeSjU, rank_ju, 400, comm_cart,&req[exNb++]);
305  break;
306 
307  case 20:
308  MPI_Ssend_init(MPI_BOTTOM, 1, MPItypeSjL, rank_jl, 300, comm_cart,&req[exNb++]);
309  MPI_Ssend_init(MPI_BOTTOM, 1, MPItypeSjU, rank_ju, 400, comm_cart,&req[exNb++]);
310  break;
311  }
312  }
313 
314  if (Dimension == 3) {
315  switch (MPISendType) {
316  case 0:
317  MPI_Bsend_init(MPI_BOTTOM, 1, MPItypeSkL, rank_kl, 500, comm_cart,&req[exNb++]);
318  MPI_Bsend_init(MPI_BOTTOM, 1, MPItypeSkU, rank_ku, 600, comm_cart,&req[exNb++]);
319  break;
320 
321  case 10:
322  MPI_Send_init(MPI_BOTTOM, 1, MPItypeSkL, rank_kl, 500, comm_cart,&req[exNb++]);
323  MPI_Send_init(MPI_BOTTOM, 1, MPItypeSkU, rank_ku, 600, comm_cart,&req[exNb++]);
324  break;
325 
326  case 20:
327  MPI_Ssend_init(MPI_BOTTOM, 1, MPItypeSkL, rank_kl, 500, comm_cart,&req[exNb++]);
328  MPI_Ssend_init(MPI_BOTTOM, 1, MPItypeSkU, rank_ku, 600, comm_cart,&req[exNb++]);
329  break;
330  }
331  }
332 
333 //Recv
334 
335  MPI_Recv_init(MPI_BOTTOM, 1, MPItypeRiL, rank_il, 200, comm_cart, &req[exNb++]);
336  MPI_Recv_init(MPI_BOTTOM, 1, MPItypeRiU, rank_iu, 100, comm_cart, &req[exNb++]);
337 
338  if (Dimension >= 2) {
339  MPI_Recv_init(MPI_BOTTOM, 1, MPItypeRjL, rank_jl, 400, comm_cart, &req[exNb++]);
340  MPI_Recv_init(MPI_BOTTOM, 1, MPItypeRjU, rank_ju, 300, comm_cart, &req[exNb++]);
341  }
342 
343  if (Dimension == 3) {
344  MPI_Recv_init(MPI_BOTTOM, 1, MPItypeRkL, rank_kl, 600, comm_cart, &req[exNb++]);
345  MPI_Recv_init(MPI_BOTTOM, 1, MPItypeRkU, rank_ku, 500, comm_cart, &req[exNb++]);
346  }
347 #endif
348 }
int Dimension
Definition: Parameters.cpp:74
int rank_ku
Definition: Parameters.cpp:245
int MPISendType
Definition: Parameters.cpp:238
int rank_il
Definition: Parameters.cpp:243
int rank_jl
Definition: Parameters.cpp:244
int rank_ju
Definition: Parameters.cpp:244
int rank_iu
Definition: Parameters.cpp:243
int rank_kl
Definition: Parameters.cpp:245
void CreateMPITopology ( )

Parallel function DOES NOT WORK!

Returns
void
22  {
23 #if defined PARMPI
24  int src;
25  int periods[]={1,1,1};
26  CartDims[0]=CartDims[1]=CartDims[2]=0;
27 
28  MPI_Dims_create(size,Dimension,CartDims);
29  MPI_Cart_create(MPI_COMM_WORLD,Dimension,CartDims,periods,1,&comm_cart);
30  MPI_Comm_rank(comm_cart, &rank);
31  MPI_Cart_coords(comm_cart,rank,Dimension,coords);
32 
33  MPI_Cart_shift(comm_cart, 0, -1, &src, &rank_il);
34  MPI_Cart_shift(comm_cart, 0, 1, &src, &rank_iu);
35 
36  if (Dimension >= 2) {
37  MPI_Cart_shift(comm_cart, 1, -1, &src, &rank_jl);
38  MPI_Cart_shift(comm_cart, 1, 1, &src, &rank_ju);
39  }
40 
41  if (Dimension == 3) {
42  MPI_Cart_shift(comm_cart, 2, -1, &src, &rank_kl);
43  MPI_Cart_shift(comm_cart, 2, 1, &src, &rank_ku);
44  }
45 #endif
46 }
int rank
Definition: Parameters.cpp:223
int coords[3]
Definition: Parameters.cpp:230
int Dimension
Definition: Parameters.cpp:74
int rank_ku
Definition: Parameters.cpp:245
int rank_il
Definition: Parameters.cpp:243
int CartDims[3]
Definition: Parameters.cpp:231
int size
Definition: Parameters.cpp:224
int rank_jl
Definition: Parameters.cpp:244
int rank_ju
Definition: Parameters.cpp:244
int rank_iu
Definition: Parameters.cpp:243
int rank_kl
Definition: Parameters.cpp:245

Here is the caller graph for this function:

void CreateMPIType ( FineMesh Root)
121  {
122 #if defined PARMPI
123  int i,j,k;
124  int n,d,l;
125 
126  Cell *MeshCell;
127  MeshCell=Root->MeshCell;
128 
129  n=0;
130  for (l=0;l<NeighbourNb;l++)
131  for (j=0;j<one_D;j++)
132  for (k=0;k<two_D;k++) FillNbAddr(Root->Neighbour_iL,l,j,k,n);
133  MPI_Type_hindexed(CellElementsNb*NeighbourNb*one_D*two_D,blocklen,disp,MPI_Type,&MPItypeRiL);
134  MPI_Type_commit(&MPItypeRiL);
135 
136  n=0;
137  for (l=0;l<NeighbourNb;l++)
138  for (j=0;j<one_D;j++)
139  for (k=0;k<two_D;k++) FillNbAddr(Root->Neighbour_iU,l,j,k,n);
140  MPI_Type_hindexed(CellElementsNb*NeighbourNb*one_D*two_D,blocklen,disp,MPI_Type,&MPItypeRiU);
141  MPI_Type_commit(&MPItypeRiU);
142 
143  n=0;
144  for (l=0;l<NeighbourNb;l++)
145  for (j=0;j<one_D;j++)
146  for (k=0;k<two_D;k++) {
147  i=l;
148  d=i + (1<<ScaleNb)*(j + (1<<ScaleNb)*k);
149  FillCellAddr(MeshCell,d,n);
150  }
151  MPI_Type_hindexed(CellElementsNb*NeighbourNb*one_D*two_D,blocklen,disp,MPI_Type,&MPItypeSiL);
152  MPI_Type_commit(&MPItypeSiL);
153 
154  n=0;
155  for (l=0;l<NeighbourNb;l++)
156  for (j=0;j<one_D;j++)
157  for (k=0;k<two_D;k++) {
158  i=(1<<ScaleNb)-NeighbourNb+l;
159  d=i + (1<<ScaleNb)*(j + (1<<ScaleNb)*k);
160  FillCellAddr(MeshCell,d,n);
161  }
162  MPI_Type_hindexed(CellElementsNb*NeighbourNb*one_D*two_D,blocklen,disp,MPI_Type,&MPItypeSiU);
163  MPI_Type_commit(&MPItypeSiU);
164 
165  if (Dimension >= 2) {
166  n=0;
167  for (l=0;l<NeighbourNb;l++)
168  for (i=0;i<one_D;i++)
169  for (k=0;k<two_D;k++) FillNbAddr(Root->Neighbour_jL,l,i,k,n);
170  MPI_Type_hindexed(CellElementsNb*NeighbourNb*one_D*two_D,blocklen,disp,MPI_Type,&MPItypeRjL);
171  MPI_Type_commit(&MPItypeRjL);
172 
173  n=0;
174  for (l=0;l<NeighbourNb;l++)
175  for (i=0;i<one_D;i++)
176  for (k=0;k<two_D;k++) FillNbAddr(Root->Neighbour_jU,l,i,k,n);
177  MPI_Type_hindexed(CellElementsNb*NeighbourNb*one_D*two_D,blocklen,disp,MPI_Type,&MPItypeRjU);
178  MPI_Type_commit(&MPItypeRjU);
179 
180  n=0;
181  for (l=0;l<NeighbourNb;l++)
182  for (i=0;i<one_D;i++)
183  for (k=0;k<two_D;k++) {
184  j=l;
185  d=i + (1<<ScaleNb)*(j + (1<<ScaleNb)*k);
186  FillCellAddr(MeshCell,d,n);
187  }
188  MPI_Type_hindexed(CellElementsNb*NeighbourNb*one_D*two_D,blocklen,disp,MPI_Type,&MPItypeSjL);
189  MPI_Type_commit(&MPItypeSjL);
190 
191  n=0;
192  for (l=0;l<NeighbourNb;l++)
193  for (i=0;i<one_D;i++)
194  for (k=0;k<two_D;k++) {
195  j=(1<<ScaleNb)-NeighbourNb+l;
196  d=i + (1<<ScaleNb)*(j + (1<<ScaleNb)*k);
197  FillCellAddr(MeshCell,d,n);
198  }
199  MPI_Type_hindexed(CellElementsNb*NeighbourNb*one_D*two_D,blocklen,disp,MPI_Type,&MPItypeSjU);
200  MPI_Type_commit(&MPItypeSjU);
201  }
202 
203 
204  if (Dimension == 3) {
205  n=0;
206  for (l=0;l<NeighbourNb;l++)
207  for (i=0;i<one_D;i++)
208  for (j=0;j<two_D;j++) FillNbAddr(Root->Neighbour_kL,l,i,j,n);
209  MPI_Type_hindexed(CellElementsNb*NeighbourNb*one_D*two_D,blocklen,disp,MPI_Type,&MPItypeRkL);
210  MPI_Type_commit(&MPItypeRkL);
211 
212  n=0;
213  for (l=0;l<NeighbourNb;l++)
214  for (i=0;i<one_D;i++)
215  for (j=0;j<two_D;j++) FillNbAddr(Root->Neighbour_kU,l,i,j,n);
216  MPI_Type_hindexed(CellElementsNb*NeighbourNb*one_D*two_D,blocklen,disp,MPI_Type,&MPItypeRkU);
217  MPI_Type_commit(&MPItypeRkU);
218 
219  n=0;
220  for (l=0;l<NeighbourNb;l++)
221  for (i=0;i<one_D;i++)
222  for (j=0;j<two_D;j++) {
223  k=l;
224  d=i + (1<<ScaleNb)*(j + (1<<ScaleNb)*k);
225  FillCellAddr(MeshCell,d,n);
226  }
227  MPI_Type_hindexed(CellElementsNb*NeighbourNb*one_D*two_D,blocklen,disp,MPI_Type,&MPItypeSkL);
228  MPI_Type_commit(&MPItypeSkL);
229 
230  n=0;
231  for (l=0;l<NeighbourNb;l++)
232  for (i=0;i<one_D;i++)
233  for (j=0;j<two_D;j++) {
234  k=(1<<ScaleNb)-NeighbourNb+l;
235  d=i + (1<<ScaleNb)*(j + (1<<ScaleNb)*k);
236  FillCellAddr(MeshCell,d,n);
237  }
238  MPI_Type_hindexed(CellElementsNb*NeighbourNb*one_D*two_D,blocklen,disp,MPI_Type,&MPItypeSkU);
239  MPI_Type_commit(&MPItypeSkU);
240  }
241 
242 #endif
243 }
Cell *** Neighbour_iU
Definition: FineMesh.h:234
int one_D
Definition: Parameters.cpp:236
An object Cell contains all the informations of a cell for both multiresolution and finite volume com...
Definition: Cell.h:41
int ScaleNb
Definition: Parameters.cpp:87
#define MPI_Type
Definition: PreProcessor.h:48
void FillCellAddr(Cell *Mesh4MPI, int d, int &n)
Definition: Parallel.cpp:49
Cell *** Neighbour_jU
Definition: FineMesh.h:234
int Dimension
Definition: Parameters.cpp:74
Cell *** Neighbour_iL
Definition: FineMesh.h:234
Cell *** Neighbour_kU
Definition: FineMesh.h:234
void FillNbAddr(Cell ***Nb, int l, int i, int j, int &n)
Definition: Parallel.cpp:85
int two_D
Definition: Parameters.cpp:236
Cell *** Neighbour_kL
Definition: FineMesh.h:234
int NeighbourNb
Definition: Parameters.cpp:228
Cell *** Neighbour_jL
Definition: FineMesh.h:234
Cell * MeshCell
Definition: FineMesh.h:256
int CellElementsNb
Definition: Parameters.cpp:233

Here is the caller graph for this function:

int DigitNumber ( int  arg)

Returns the number of digits of the integer arg.

Parameters
argArgument
Returns
int
23 {
24  int result;
25  int i;
26 
27  result = 0;
28  i = arg;
29 
30  while(i != 0)
31  {
32  i/=10;
33  result++;
34  }
35 
36  return result;
37 }

Here is the caller graph for this function:

int FileWrite ( FILE *  f,
const char *  format,
real  arg 
)

Writes in binary or ASCII mode the real number arg into the file f with the format format. The global parameter DataIsBinary determines this choice.

Parameters
fFile name
formatFormat
argArgument
Returns
int
23 {
24  int result;
25  real x;
26 
27  x = arg;
28 
29  if (DataIsBinary)
30  result = fwrite(&x,sizeof(real),1,f);
31  else
32  result = fprintf(f, format, x);
33 
34 
35  return result;
36 }
bool DataIsBinary
Definition: Parameters.cpp:145
#define real
Definition: PreProcessor.h:31

Here is the caller graph for this function:

Vector Flux ( Cell Cell1,
Cell Cell2,
Cell Cell3,
Cell Cell4,
int  AxisNo 
)

Returns the flux at the interface between Cell2 and Cell3. Here a 4-point space scheme is used. Cell2 and Cell3 are the first neighbours on the left and right sides. Cell1 and Cell4 are the second neighbours on the left and right sides.

Parameters
Cell1second neighbour on the left side
Cell2first neighbour on the left side
Cell3first neighbour on the right side
Cell4second neighbour on the right side
AxisNoAxis of interest
Returns
Vector
23 {
24  // --- Local variables ---
25 
26  Vector Result(QuantityNb);
27 
28  Cell C1, C2, C3, C4;
29 
30  int BoundaryCell1 = BoundaryRegion(Cell1.center());
31  int BoundaryCell2 = BoundaryRegion(Cell2.center());
32  int BoundaryCell3 = BoundaryRegion(Cell3.center());
33  int BoundaryCell4 = BoundaryRegion(Cell4.center());
34 
35  bool UseBoundaryCells = (UseBoundaryRegions && (BoundaryCell1!=0 || BoundaryCell2!=0 || BoundaryCell3!=0 || BoundaryCell4!=0));
36 
37  // --- Take into account boundary conditions ---
38 
39  if (UseBoundaryCells)
40  GetBoundaryCells(Cell1, Cell2, Cell3, Cell4, C1, C2, C3, C4, AxisNo);
41 
42  switch(SchemeNb)
43  {
44  case 1:
45  default:
46  if (UseBoundaryCells)
47  Result = SchemeHLL(C1, C2, C3, C4, AxisNo);
48  else
49  Result = SchemeHLL(Cell1, Cell2, Cell3, Cell4, AxisNo);
50  break;
51 
52  case 2:
53  if (UseBoundaryCells)
54  Result = SchemeHLLD(C1, C2, C3, C4, AxisNo);
55  else
56  Result = SchemeHLLD(Cell1, Cell2, Cell3, Cell4, AxisNo);
57  break;
58  break;
59 
60  }
61 
62 
63  return Result;
64 }
An object Cell contains all the informations of a cell for both multiresolution and finite volume com...
Definition: Cell.h:41
real center(const int AxisNo) const
Returns the component no. AxisNo of the cell-center position.
Definition: Cell.h:1112
int QuantityNb
Definition: Parameters.cpp:171
Standard class for every vector in Carmen.
Definition: Vector.h:29
void GetBoundaryCells(Cell &Cell1, Cell &Cell2, Cell &Cell3, Cell &Cell4, Cell &C1, Cell &C2, Cell &C3, Cell &C4, int AxisNo)
Transform the 4 cells of the flux Cell1, Cell2, Cell3, Cell4 into C1, C2, C3, C4, to take into accoun...
Definition: GetBoundaryCells.cpp:24
int BoundaryRegion(const Vector &X)
Returns the boundary region type at the position X=(x,y,z). The returned value correspond to: 0 = Fl...
Definition: BoundaryRegion.cpp:63
int SchemeNb
Definition: Parameters.cpp:67
Vector SchemeHLL(const Cell &Cell1, const Cell &Cell2, const Cell &Cell3, const Cell &Cell4, const int AxisNo)
Returns the HLL numerical flux for MHD equations. The scheme uses four cells to estimate the flux at ...
Definition: SchemeHLL.cpp:11
bool UseBoundaryRegions
Definition: Parameters.cpp:80
Vector SchemeHLLD(const Cell &Cell1, const Cell &Cell2, const Cell &Cell3, const Cell &Cell4, const int AxisNo)
Returns the HLLD numerical flux for MHD equations. The scheme uses four cells to estimate the flux at...
Definition: SchemeHLLD.cpp:12

Here is the caller graph for this function:

void fluxCorrection ( Vector Flux,
const Vector AvgL,
const Vector AvgR,
int  AxisNo 
)

This function apply the divergence-free correction to the numerical flux.

Parameters
FluxNumerical flux vector
AvgLLeft average vector
AvgRRight average vector
AxisNoAxis of interest
Returns
void
10 {
11  auxvar = Flux.value(AxisNo+6);
12 
13  Flux.setValue(AxisNo+6, Flux.value(AxisNo+6) + (AvgL.value(6) + .5*(AvgR.value(6) - AvgL.value(6))
14  - ch*.5*(AvgR.value(AxisNo+6) - AvgL.value(AxisNo+6))));
15 
16  Flux.setValue(6, ch*ch*(AvgL.value(AxisNo+6) + .5*(AvgR.value(AxisNo+6) - AvgL.value(AxisNo+6))
17  - .5*(AvgR.value(6) - AvgL.value(6))/ch));
18 
19 }
real ch
Definition: Parameters.cpp:140
real auxvar
Definition: Parameters.cpp:141
void setValue(const int n, const real a)
Sets the component n to value a.
Definition: Vector.h:545
real value(const int n) const
Returns the value of the component n.
Definition: Vector.h:565

Here is the caller graph for this function:

Vector FluxX ( const Vector Avg)

Returns the physical flux of MHD equations in X direction.

Parameters
AvgAverage vector.
Returns
Vector
9 {
10  real rho;
11  real vx, vy, vz;
12  real pre, e;
13  real Bx, By, Bz;
14  real Bx2, By2, Bz2, B2;
15  real vx2, vy2, vz2, v2;
16  real half = 0.5;
17  Vector F(QuantityNb);
18 
19  //Variables
20  rho = Avg.value(1);
21  vx = Avg.value(2)/rho;
22  vy = Avg.value(3)/rho;
23  vz = Avg.value(4)/rho;
24  e = Avg.value(5);
25  Bx = Avg.value(7);
26  By = Avg.value(8);
27  Bz = Avg.value(9);
28 
29  Bx2 = Bx*Bx;
30  By2 = By*By;
31  Bz2 = Bz*Bz;
32  B2 = half*(Bz2+Bx2+By2);
33 
34  vx2 = vx*vx;
35  vy2 = vy*vy;
36  vz2 = vz*vz;
37  v2 = half*(vz2+vx2+vy2);
38 
39  //pressure
40  pre = (Gamma -1.)*(e - rho*v2 - B2);
41 
42  //Physical flux - x-direction
43  F.setValue(1,rho*vx);
44  F.setValue(2,rho*vx2 + pre + half*(Bz2+By2-Bx2));
45  F.setValue(3,rho*vx*vy - Bx*By);
46  F.setValue(4,rho*vx*vz - Bx*Bz);
47  F.setValue(5,(e + pre + B2)*vx - Bx*(vx*Bx + vy*By + vz*Bz) );
48  F.setValue(6,0.0);
49  F.setValue(7,0.0);
50  F.setValue(8,vx*By - vy*Bx);
51  F.setValue(9,vx*Bz - vz*Bx);
52 
53 
54  return F;
55 }
int QuantityNb
Definition: Parameters.cpp:171
Standard class for every vector in Carmen.
Definition: Vector.h:29
real Gamma
Definition: Parameters.cpp:109
real value(const int n) const
Returns the value of the component n.
Definition: Vector.h:565
#define real
Definition: PreProcessor.h:31

Here is the caller graph for this function:

Vector FluxY ( const Vector Avg)

Returns the physical flux of MHD equations in Y direction.

Parameters
AvgAverage vector.
Returns
Vector
59 {
60  real rho;
61  real vx, vy, vz;
62  real pre, e;
63  real Bx, By, Bz;
64  real Bx2, By2, Bz2, B2;
65  real vx2, vy2, vz2, v2;
66  real half = 0.5;
67 
68  Vector G(QuantityNb);
69 
70  //Variables
71  rho = Avg.value(1);
72  vx = Avg.value(2)/rho;
73  vy = Avg.value(3)/rho;
74  vz = Avg.value(4)/rho;
75  e = Avg.value(5);
76  Bx = Avg.value(7);
77  By = Avg.value(8);
78  Bz = Avg.value(9);
79 
80  Bx2 = Bx*Bx;
81  By2 = By*By;
82  Bz2 = Bz*Bz;
83  B2 = half*(Bz2+Bx2+By2);
84 
85  vx2 = vx*vx;
86  vy2 = vy*vy;
87  vz2 = vz*vz;
88  v2 = half*(vz2+vx2+vy2);
89 
90  //pressure
91  pre = (Gamma -1.)*(e - rho*v2 - B2);
92 
93  //Physical flux - y-direction
94  G.setValue(1,rho*vy);
95  G.setValue(2,rho*vx*vy - Bx*By);
96  G.setValue(3,rho*vy2 + pre + half*(Bx2+Bz2-By2));
97  G.setValue(4,rho*vy*vz - By*Bz);
98  G.setValue(5,(e + pre + B2)*vy - By*(vx*Bx + vy*By + vz*Bz));
99  G.setValue(6,0.0);
100  G.setValue(7,vy*Bx - vx*By);
101  G.setValue(8,0.0);
102  G.setValue(9,vy*Bz - vz*By);
103  return G;
104 }
int QuantityNb
Definition: Parameters.cpp:171
Standard class for every vector in Carmen.
Definition: Vector.h:29
real Gamma
Definition: Parameters.cpp:109
real value(const int n) const
Returns the value of the component n.
Definition: Vector.h:565
#define real
Definition: PreProcessor.h:31

Here is the caller graph for this function:

Vector FluxZ ( const Vector Avg)

Returns the physical flux of MHD equations in Z direction.

Parameters
AvgAverage vector.
Returns
Vector
107 {
108  real rho;
109  real vx, vy, vz;
110  real pre, e;
111  real Bx, By, Bz;
112  real Bx2, By2, Bz2, B2;
113  real vx2, vy2, vz2, v2;
114  real half = 0.5;
115 
116  Vector H(QuantityNb);
117 
118  //Variables
119  rho = Avg.value(1);
120  vx = Avg.value(2)/rho;
121  vy = Avg.value(3)/rho;
122  vz = Avg.value(4)/rho;
123  e = Avg.value(5);
124  Bx = Avg.value(7);
125  By = Avg.value(8);
126  Bz = Avg.value(9);
127 
128  Bx2 = Bx*Bx;
129  By2 = By*By;
130  Bz2 = Bz*Bz;
131  B2 = half*(Bz2+Bx2+By2);
132 
133  vx2 = vx*vx;
134  vy2 = vy*vy;
135  vz2 = vz*vz;
136  v2 = half*(vz2+vx2+vy2);
137 
138  //pressure
139  pre = (Gamma -1.)*(e - rho*v2 - B2);
140 
141  //Physical flux - y-direction
142  H.setValue(1,rho*vz);
143  H.setValue(2,rho*vz*vx - Bz*Bx);
144  H.setValue(3,rho*vz*vy - Bz*By);
145  H.setValue(4,rho*vz2 + pre + half*(Bx2+By2-Bz2));
146  H.setValue(5,(e + pre + B2)*vz - Bz*(vx*Bx + vy*By + vz*Bz));
147  H.setValue(6,0.0);
148  H.setValue(7,vz*Bx - vx*Bz);
149  H.setValue(8,vz*By - vy*Bz);
150  H.setValue(9,0.0);
151 
152  return H;
153 }
int QuantityNb
Definition: Parameters.cpp:171
Standard class for every vector in Carmen.
Definition: Vector.h:29
real Gamma
Definition: Parameters.cpp:109
real value(const int n) const
Returns the value of the component n.
Definition: Vector.h:565
#define real
Definition: PreProcessor.h:31

Here is the caller graph for this function:

void FreeMPIType ( )

Parallel function DOES NOT WORK!

Returns
void
247  {
248 #if defined PARMPI
249  MPI_Type_free(&MPItypeSiL);
250  MPI_Type_free(&MPItypeSiU);
251  MPI_Type_free(&MPItypeRiL);
252  MPI_Type_free(&MPItypeRiU);
253 
254  if (Dimension >= 2) {
255  MPI_Type_free(&MPItypeSjL);
256  MPI_Type_free(&MPItypeSjU);
257  MPI_Type_free(&MPItypeRjL);
258  MPI_Type_free(&MPItypeRjU);
259  }
260 
261  if (Dimension == 3) {
262  MPI_Type_free(&MPItypeSkL);
263  MPI_Type_free(&MPItypeSkU);
264  MPI_Type_free(&MPItypeRkL);
265  MPI_Type_free(&MPItypeRkU);
266  }
267 #endif
268 }
int Dimension
Definition: Parameters.cpp:74

Here is the caller graph for this function:

void GetBoundaryCells ( Cell Cell1,
Cell Cell2,
Cell Cell3,
Cell Cell4,
Cell C1,
Cell C2,
Cell C3,
Cell C4,
int  AxisNo 
)

Transform the 4 cells of the flux Cell1, Cell2, Cell3, Cell4 into C1, C2, C3, C4, to take into account boundary conditions (used in Flux.cpp).

Parameters
Cell1second neighbour on the left side
Cell2first neighbour on the left side
Cell3first neighbour on the right side
Cell4second neighbour on the right side
C1Auxiliar cell1
C2Auxiliar cell2
C3Auxiliar cell3
C4Auxiliar cell4
AxisNo...
Returns
void
26 {
27  // --- Local variables ---
28 
29  int InCell1, InCell2, InCell3, InCell4; // Boundary conditions in cells 1, 2, 3, 4
30  real P1, P2, P3, P4; // Pressures in cells 1, 2, 3, 4
31  real T1, T2, T3, T4; // Temperatures in cells 1, 2, 3, 4
32  real rho1, rho2, rho3, rho4; // Densities in cells 1, 2, 3, 4
33  Vector V1(Dimension), V2(Dimension), V3(Dimension), V4(Dimension); // Velocities in cells 1, 2, 3, 4
34  real e1, e2, e3, e4; // Energies in cell 1, 2, 3, 4
35  real Y1=0., Y2=0., Y3=0., Y4=0.; // Partial mass in cell 1, 2, 3, 4
36 
37  int i; // Counter
38 
39  // --- Init C1, C2, C3, C4 ---
40 
41  C1 = Cell1;
42  C2 = Cell2;
43  C3 = Cell3;
44  C4 = Cell4;
45 
46  // --- Depending on the boundary region type, transform C1, C2, C3, C4 ---
47 
48  InCell1 = BoundaryRegion(Cell1.center());
49  InCell2 = BoundaryRegion(Cell2.center());
50  InCell3 = BoundaryRegion(Cell3.center());
51  InCell4 = BoundaryRegion(Cell4.center());
52 
53  // --- Cell2 IN THE BOUNDARY, Cell3 IN THE FLUID -----------------------------------------
54 
55  if (InCell2 !=0 && InCell3 == 0)
56  {
57  switch(InCell2)
58  {
59  // INFLOW
60  case 1:
61  // Dirichlet on temperature
62  T2 = Cell2.temperature();
63  T1 = Cell1.temperature();
64 
65  // Extrapolate pressure
66  P2 = Cell3.oldPressure();
67  P1 = P2;
68  // P1 = 2*P2 - Cell3.pressure();
69 
70  // Compute density
71  rho2 = Gamma*Ma*Ma*P2/T2;
72  rho1 = Gamma*Ma*Ma*P1/T1;
73 
74  // Dirichlet on momentum
75  V2 = (Cell2.density()/rho2)*Cell2.velocity();
76  V1 = (Cell1.density()/rho1)*Cell1.velocity();
77 
78  // Dirichlet on partial mass
79  if (ScalarEqNb == 1)
80  {
81  Y2 = Cell2.average(Dimension+3)/Cell2.density();
82  Y1 = Cell1.average(Dimension+3)/Cell1.density();
83  }
84 
85  // Compute energies
86  e2 = P2/((Gamma-1.)*rho2) + 0.5*N2(V2);
87  e1 = P1/((Gamma-1.)*rho1) + 0.5*N2(V1);
88 
89  // Correct C1 and C2
90  C2.setAverage(1, rho2);
91  C1.setAverage(1, rho1);
92  for (i=1; i<=Dimension; i++)
93  {
94  C2.setAverage(i+1, rho2*V2.value(i));
95  C1.setAverage(i+1, rho1*V1.value(i));
96  }
97  C2.setAverage(Dimension+2,rho2*e2);
98  C1.setAverage(Dimension+2,rho1*e1);
99 
100  if (ScalarEqNb == 1)
101  {
102  C2.setAverage(Dimension+3, rho2*Y2);
103  C1.setAverage(Dimension+3, rho1*Y1);
104  }
105  break;
106 
107  // OUTFLOW : use the old value of the neighbour
108  case 2:
109  C2.setAverage(Cell3.oldAverage());
110  C1.setAverage(Cell3.oldAverage());
111 
112  // Also change the values in the boundary
113  Cell2.setAverage(C2.average());
114  Cell1.setAverage(C1.average());
115  break;
116 
117  // FREE-SLIP WALL : Neuman on all quantities
118  case 3:
119 
120  C2 = Cell3;
121  C1 = Cell4;
122  break;
123 
124  // ADIABATIC WALL
125  case 4:
126 
127  // Dirichlet on velocity
128  V2 = Cell2.velocity();
129  V1 = Cell1.velocity();
130 
131  // Neuman on temperature
132  T2 = Cell3.temperature();
133  T1 = Cell4.temperature();
134 
135  // Neuman on pressure
136  P2 = Cell3.pressure();
137  P1 = Cell4.pressure();
138 
139  // Extrapolate pressure
140  //P2 = 2*Cell3.pressure()-Cell4.pressure();
141  //P1 = P2;
142 
143  // Compute densities
144  rho2 = Gamma*Ma*Ma*P2/T2;
145  rho1 = Gamma*Ma*Ma*P1/T1;
146 
147  // Compute energies
148  e2 = P2/((Gamma-1.)*rho2) + 0.5*N2(V2);
149  e1 = P1/((Gamma-1.)*rho1) + 0.5*N2(V1);
150 
151  // Correct C1 and C2
152  C2.setAverage(1, rho2);
153  C1.setAverage(1, rho1);
154  for (i=1; i<=Dimension; i++)
155  {
156  C2.setAverage(i+1, rho2*V2.value(i));
157  C1.setAverage(i+1, rho1*V1.value(i));
158  }
159  C2.setAverage(Dimension+2,rho2*e2);
160  C1.setAverage(Dimension+2,rho1*e1);
161 
162  // Neuman on partial mass
163  if (ScalarEqNb == 1)
164  {
165  C2.setAverage(Dimension+3, Cell3.average(Dimension+3));
166  C1.setAverage(Dimension+3, Cell4.average(Dimension+3));
167  }
168 
169  break;
170 
171  // ISOTHERMAL WALL
172  case 5:
173 
174  // Dirichlet on velocity
175  V2 = Cell2.velocity();
176  V1 = Cell1.velocity();
177 
178  // Dirichlet on temperature
179  T2 = Cell2.temperature();
180  T1 = Cell1.temperature();
181 
182  // Neuman on pressure
183  P2 = Cell3.pressure();
184  P1 = Cell4.pressure();
185 
186  // Extrapolate pressure
187  //P2 = 2*Cell3.pressure()-Cell4.pressure();
188  //P1 = P2;
189 
190  // Compute densities
191  rho2 = Gamma*Ma*Ma*P2/T2;
192  rho1 = Gamma*Ma*Ma*P1/T1;
193 
194  // Compute energies
195  e2 = P2/((Gamma-1.)*rho2) + 0.5*N2(V2);
196  e1 = P1/((Gamma-1.)*rho1) + 0.5*N2(V1);
197 
198  // Correct C1 and C2
199  C2.setAverage(1, rho2);
200  C1.setAverage(1, rho1);
201  for (i=1; i<=Dimension; i++)
202  {
203  C2.setAverage(i+1, rho2*V2.value(i));
204  C1.setAverage(i+1, rho1*V1.value(i));
205  }
206  C2.setAverage(Dimension+2,rho2*e2);
207  C1.setAverage(Dimension+2,rho1*e1);
208 
209  // Neuman on partial mass
210  if (ScalarEqNb == 1)
211  {
212  C2.setAverage(Dimension+3, Cell3.average(Dimension+3));
213  C1.setAverage(Dimension+3, Cell4.average(Dimension+3));
214  }
215 
216  break;
217  };
218  return;
219  }
220 
221  // --- Cell1 IN THE BOUNDARY, Cell2 IN THE FLUID ------------------------------------------------
222 
223  if (InCell1 != 0 && InCell2 == 0)
224  {
225  switch(InCell1)
226  {
227  // INFLOW
228  case 1:
229  // Dirichlet on temperature
230  T1 = Cell1.temperature();
231 
232  // Extrapolate pressure from old value
233  P1 = Cell2.oldPressure();
234 
235  // Compute density
236  rho1 = Gamma*Ma*Ma*P1/T1;
237 
238  // Dirichlet on momentum
239  V1 = (Cell1.density()/rho1)*Cell1.velocity();
240 
241  // Dirichlet on partial mass
242  if (ScalarEqNb == 1)
243  Y1 = Cell1.average(Dimension+3)/Cell1.density();
244 
245  // Compute energies
246  e1 = P1/((Gamma-1.)*rho1) + 0.5*N2(V1);
247 
248  // Correct C1
249  C1.setAverage(1, rho1);
250  for (i=1; i<=Dimension; i++)
251  C1.setAverage(i+1, rho1*V1.value(i));
252  C1.setAverage(Dimension+2,rho1*e1);
253 
254  if (ScalarEqNb == 1)
255  C1.setAverage(Dimension+3, rho1*Y1);
256  break;
257 
258  // OUTFLOW : Get old value of the neighbour
259  case 2:
260 
261  C1.setAverage(Cell2.oldAverage());
262  break;
263 
264  // FREE-SLIP WALL : Neuman on all quantities
265  case 3:
266 
267  C1 = Cell2;
268  break;
269 
270  // ADIABATIC WALL
271  case 4:
272 
273  // Dirichlet on velocity
274  V1 = Cell1.velocity();
275 
276  // Neuman on temperature
277  T1 = Cell2.temperature();
278 
279  // Neuman on pressure
280  P1 = Cell2.pressure();
281 
282  // Extrapolate pressure
283  //P1 = 2*Cell2.pressure()-Cell3.pressure();
284 
285  // Compute density
286  rho1 = Gamma*Ma*Ma*P1/T1;
287 
288  // Compute energy
289  e1 = P1/((Gamma-1.)*rho1) + 0.5*N2(V1);
290 
291  // Correct C1
292  C1.setAverage(1, rho1);
293  for (i=1; i<=Dimension; i++)
294  C1.setAverage(i+1, rho1*V1.value(i));
295  C1.setAverage(Dimension+2,rho1*e1);
296 
297  // Neuman on partial mass
298  if (ScalarEqNb == 1)
299  C1.setAverage(Dimension+3, Cell2.average(Dimension+3));
300 
301  break;
302 
303  // ISOTHERMAL WALL
304  case 5:
305 
306  // Dirichlet on velocity
307  V1 = Cell1.velocity();
308 
309  // Dirichlet on temperature
310  T1 = Cell1.temperature();
311 
312  // Neuman on pressure
313  P1 = Cell2.pressure();
314 
315  // Extrapolate pressure
316  //P1 = 2*Cell2.pressure()-Cell3.pressure();
317 
318  // Compute density
319  rho1 = Gamma*Ma*Ma*P1/T1;
320 
321  // Compute energies
322  e1 = P1/((Gamma-1.)*rho1) + 0.5*N2(V1);
323 
324  // Correct C1
325  C1.setAverage(1, rho1);
326  for (i=1; i<=Dimension; i++)
327  C1.setAverage(i+1, rho1*V1.value(i));
328  C1.setAverage(Dimension+2,rho1*e1);
329 
330  // Neuman on partial mass
331  if (ScalarEqNb == 1)
332  C1.setAverage(Dimension+3, Cell2.average(Dimension+3));
333 
334  break;
335  };
336  return;
337  }
338  // --- Cell3 IN THE BOUNDARY, Cell2 IN THE FLUID -----------------------------------------
339 
340  if (InCell3 !=0 && InCell2 == 0)
341  {
342  switch(InCell3)
343  {
344  // INFLOW
345  case 1:
346  // Dirichlet on temperature
347  T3 = Cell3.temperature();
348  T4 = Cell4.temperature();
349 
350  // Extrapolate pressure from old value
351  P3 = Cell2.oldPressure();
352  P4 = P3;
353  //P4 = 2*P3 - Cell2.pressure();
354 
355  // Compute densities
356  rho3 = Gamma*Ma*Ma*P3/T3;
357  rho4 = Gamma*Ma*Ma*P4/T4;
358 
359  // Dirichlet on momentum
360  V3 = (Cell3.density()/rho3)*Cell3.velocity();
361  V4 = (Cell4.density()/rho4)*Cell4.velocity();
362 
363  // Dirichlet on partial mass
364  if (ScalarEqNb == 1)
365  {
366  Y3 = Cell3.average(Dimension+3)/Cell3.density();
367  Y4 = Cell4.average(Dimension+3)/Cell4.density();
368  }
369 
370  // Compute energies
371  e3 = P3/((Gamma-1.)*rho3) + 0.5*N2(V3);
372  e4 = P4/((Gamma-1.)*rho4) + 0.5*N2(V4);
373 
374  // Correct C1 and C2
375  C3.setAverage(1, rho3);
376  C4.setAverage(1, rho4);
377  for (i=1; i<=Dimension; i++)
378  {
379  C3.setAverage(i+1, rho3*V3.value(i));
380  C4.setAverage(i+1, rho4*V4.value(i));
381  }
382  C3.setAverage(Dimension+2,rho3*e3);
383  C4.setAverage(Dimension+2,rho4*e4);
384 
385  if (ScalarEqNb == 1)
386  {
387  C3.setAverage(Dimension+3,rho3*Y3);
388  C4.setAverage(Dimension+3,rho4*Y4);
389  }
390  break;
391 
392  // OUTFLOW
393  case 2:
394 
395  C3.setAverage(Cell2.oldAverage());
396  C4.setAverage(Cell2.oldAverage());
397  //C4.setAverage(2*C3.average()-Cell2.average());
398 
399  // Also change the values in the boundary
400  Cell3.setAverage(C3.average());
401  Cell4.setAverage(C4.average());
402  break;
403 
404  // FREE-SLIP WALL : Neuman on all quantities
405  case 3:
406 
407  C3 = Cell2;
408  C4 = Cell1;
409  break;
410 
411  // ADIABATIC WALL
412  case 4:
413 
414  // Dirichlet on velocity
415  V3 = Cell3.velocity();
416  V4 = Cell4.velocity();
417 
418  // Neuman on temperature
419  T3 = Cell2.temperature();
420  T4 = Cell1.temperature();
421 
422  // Neuman on pressure
423  P3 = Cell2.pressure();
424  P4 = Cell1.pressure();
425 
426  // Extrapolate pressure
427  //P3 = 2*Cell2.pressure()-Cell1.pressure();
428  //P4 = P3;
429 
430  // Compute densities
431  rho3 = Gamma*Ma*Ma*P3/T3;
432  rho4 = Gamma*Ma*Ma*P4/T4;
433 
434  // Compute energies
435  e3 = P3/((Gamma-1.)*rho3) + 0.5*N2(V3);
436  e4 = P4/((Gamma-1.)*rho4) + 0.5*N2(V4);
437 
438  // Correct C3 and C4
439  C3.setAverage(1, rho3);
440  C4.setAverage(1, rho4);
441  for (i=1; i<=Dimension; i++)
442  {
443  C3.setAverage(i+1, rho3*V3.value(i));
444  C4.setAverage(i+1, rho4*V4.value(i));
445  }
446  C3.setAverage(Dimension+2,rho3*e3);
447  C4.setAverage(Dimension+2,rho4*e4);
448 
449  // Neuman on partial mass
450  if (ScalarEqNb == 1)
451  {
452  C3.setAverage(Dimension+3, Cell2.average(Dimension+3));
453  C4.setAverage(Dimension+3, Cell1.average(Dimension+3));
454  }
455 
456  break;
457 
458  // ISOTHERMAL WALL
459  case 5:
460 
461  // Dirichlet on velocity
462  V3 = Cell3.velocity();
463  V4 = Cell4.velocity();
464 
465  // Dirichlet on temperature
466  T3 = Cell3.temperature();
467  T4 = Cell4.temperature();
468 
469  // Neuman on pressure
470  P3 = Cell2.pressure();
471  P4 = Cell1.pressure();
472 
473  // Extrapolate pressure
474  //P3 = 2*Cell2.pressure()-Cell1.pressure();
475  //P4 = P3;
476 
477  // Compute densities
478  rho3 = Gamma*Ma*Ma*P3/T3;
479  rho4 = Gamma*Ma*Ma*P4/T4;
480 
481  // Compute energies
482  e3 = P3/((Gamma-1.)*rho3) + 0.5*N2(V3);
483  e4 = P4/((Gamma-1.)*rho4) + 0.5*N2(V4);
484 
485  // Correct C3 and C4
486  C3.setAverage(1, rho3);
487  C4.setAverage(1, rho4);
488  for (i=1; i<=Dimension; i++)
489  {
490  C3.setAverage(i+1, rho3*V3.value(i));
491  C4.setAverage(i+1, rho4*V4.value(i));
492  }
493  C3.setAverage(Dimension+2,rho3*e3);
494  C4.setAverage(Dimension+2,rho4*e4);
495 
496  // Neuman on partial mass
497  if (ScalarEqNb == 1)
498  {
499  C3.setAverage(Dimension+3, Cell2.average(Dimension+3));
500  C4.setAverage(Dimension+3, Cell1.average(Dimension+3));
501  }
502 
503  break;
504  };
505  return;
506  }
507 
508  // --- Cell4 IN THE BOUNDARY, Cell3 IN THE FLUID ------------------------------------------------
509 
510  if (InCell4 != 0 && InCell3 == 0)
511  {
512  switch(InCell4)
513  {
514  // INFLOW
515  case 1:
516  // Dirichlet on temperature
517  T4 = Cell4.temperature();
518 
519  // Extrapolate pressure from old value
520  P4 = Cell3.oldPressure();
521 
522  // Compute density
523  rho4 = Gamma*Ma*Ma*P4/T4;
524 
525  // Dirichlet on momentum
526  V4 = (Cell4.density()/rho4)*Cell4.velocity();
527 
528  // Dirichlet on partial mass
529  if (ScalarEqNb == 1)
530  Y4 = Cell4.average(Dimension+3)/Cell4.density();
531 
532  // Compute energies
533  e4 = P4/((Gamma-1.)*rho4) + 0.5*N2(V4);
534 
535  // Correct C4
536  C4.setAverage(1, rho4);
537  for (i=1; i<=Dimension; i++)
538  C4.setAverage(i+1, rho4*V4.value(i));
539  C4.setAverage(Dimension+2,rho4*e4);
540 
541  if (ScalarEqNb == 1)
542  C4.setAverage(Dimension+3,rho4*Y4);
543  break;
544 
545  // OUTFLOW : Use old cell-average values of the neighbour
546  case 2:
547 
548  C4.setAverage(Cell3.oldAverage());
549  break;
550 
551  // FREE-SLIP WALL : Neuman on all quantities
552  case 3:
553 
554  C4 = Cell3;
555  break;
556 
557  // ADIABATIC WALL
558  case 4:
559 
560  // Dirichlet on velocity
561  V4 = Cell4.velocity();
562 
563  // Neuman on temperature
564  T4 = Cell3.temperature();
565 
566  // Neuman on pressure
567  P4 = Cell3.pressure();
568 
569  // Extrapolate pressure
570  //P4 = 2*Cell3.pressure()-Cell2.pressure();
571 
572  // Compute density
573  rho4 = Gamma*Ma*Ma*P4/T4;
574 
575  // Compute energy
576  e4 = P4/((Gamma-1.)*rho4) + 0.5*N2(V4);
577 
578  // Correct C4
579  C4.setAverage(1, rho4);
580  for (i=1; i<=Dimension; i++)
581  C4.setAverage(i+1, rho4*V4.value(i));
582  C4.setAverage(Dimension+2,rho4*e4);
583 
584  // Neuman on partial mass
585  if (ScalarEqNb == 1)
586  C4.setAverage(Dimension+3, Cell3.average(Dimension+3));
587 
588  break;
589 
590  // ISOTHERMAL WALL
591  case 5:
592 
593  // Dirichlet on velocity
594  V4 = Cell4.velocity();
595 
596  // Dirichlet on temperature
597  T4 = Cell4.temperature();
598 
599  // Neuman on pressure
600  P4 = Cell3.pressure();
601 
602  // Extrapolate pressure
603  //P4 = 2*Cell3.pressure()-Cell2.pressure();
604 
605  // Compute density
606  rho4 = Gamma*Ma*Ma*P4/T4;
607 
608  // Compute energies
609  e4 = P4/((Gamma-1.)*rho4) + 0.5*N2(V4);
610 
611  // Correct C4
612  C4.setAverage(1, rho4);
613  for (i=1; i<=Dimension; i++)
614  C4.setAverage(i+1, rho4*V4.value(i));
615  C4.setAverage(Dimension+2,rho4*e4);
616 
617  // Neuman on partial mass
618  if (ScalarEqNb == 1)
619  C4.setAverage(Dimension+3, Cell3.average(Dimension+3));
620 
621  break;
622  };
623  return;
624  }
625 
626 }
real center(const int AxisNo) const
Returns the component no. AxisNo of the cell-center position.
Definition: Cell.h:1112
Standard class for every vector in Carmen.
Definition: Vector.h:29
real oldPressure() const
Identical to the previous one for the values at the instant n-1.
Definition: Cell.cpp:151
real temperature() const
Returns the cell-average temperature. Does not work for MHD!
Definition: Cell.cpp:184
real N2(const Vector &V)
Returns the L2-norm of the vector.
Definition: Vector.cpp:1525
real density() const
Returns the cell-average density.
Definition: Cell.h:1262
int ScalarEqNb
Definition: Parameters.cpp:69
int Dimension
Definition: Parameters.cpp:74
real velocity(const int AxisNo) const
Returns the component no. AxisNo of the cell-average velocity.
Definition: Cell.h:1354
real Gamma
Definition: Parameters.cpp:109
real oldAverage(const int QuantityNo) const
Returns the component no. QuantityNo of the old cell-average values.
Definition: Cell.h:1176
int BoundaryRegion(const Vector &X)
Returns the boundary region type at the position X=(x,y,z). The returned value correspond to: 0 = Fl...
Definition: BoundaryRegion.cpp:63
real average(const int QuantityNo) const
Returns the component no. QuantityNo of the cell-average value.
Definition: Cell.h:1128
real pressure() const
Returns the cell-average pressure.
Definition: Cell.cpp:84
void setAverage(const int QuantityNo, const real UserAverage)
Sets the cell-average of the quantity QuantityNo to UserAverage. Example:
Definition: Cell.h:921
real Ma
Definition: Parameters.cpp:110
#define real
Definition: PreProcessor.h:31

Here is the caller graph for this function:

Vector InitAverage ( real  x,
real  y = 0.,
real  z = 0. 
)

Returns the initial condition in (x, y, z) form the one defined in carmen.ini.

Parameters
xPosition x
yPosition y. Defaults to 0..
zPosition z. Defaults to 0..
Returns
Vector
23 {
24  // --- Local variables ---
25 
26  Vector Result(QuantityNb);
27  real *Q;
28  Q = new real [QuantityNb+1];
29  int n;
30 
31  // --- Init Q ---
32 
33  for (n = 1; n <= QuantityNb; n++)
34  Q[n]=0.;
35 
36  // --- Use definition of initial Q contained in file 'initial' ---
37 
38  #include "carmen.ini"
39 
40  // --- Fill vector Result and return it ---
41 
42  for (n = 1; n <= QuantityNb; n++)
43  Result.setValue(n, Q[n]);
44 
45  delete[] Q;
46 
47  return Result;
48 }
int QuantityNb
Definition: Parameters.cpp:171
Standard class for every vector in Carmen.
Definition: Vector.h:29
#define real
Definition: PreProcessor.h:31

Here is the caller graph for this function:

void InitParameters ( )

Inits parameters from file carmen.par. If a parameter is not mentioned in this file, the default value is used.

Returns
void

— Compute ch --------------------------------------------------------—

284 {
285  // --- Local variables ---------------------------------------------------------------------
286 
287  int i; // Counter
288 
289  // --- Set global variables from file "carmen.par" -----------------------------------------
290 
291  #include "carmen.par"
292 
293  // --- Adapt IterationNbRef to the dimension -----------------------------------------------
294 
295  IterationNbRef=(int)(exp((4.-Dimension)*log(10.)));
296 
297  // --- Compute the number of children of a given parent cell ---
298 
299  ChildNb = (1<<Dimension);
300 
301 #if defined PARMPI
302 
304  for (i=0;i<4;i++)
305  {
306  AllXMax[i]=XMax[i];
307  AllXMin[i]=XMin[i];
308  }
309 
310  //some combinations give deadlock...
311  MPISendType = 10; //0 - Ibsend; 10 - Isend; 20 - Issend;
312  MPIRecvType = 1; //0 - Recv; 1 - Irecv;
313 
314  CPUScales=0;
315  int tmp=size;
316  while ((tmp=(tmp>>1))>0) CPUScales++;
318 
319  one_D=1; two_D=1;
320  if (Dimension >= 2) one_D=1<<ScaleNb;
321  if (Dimension == 3) two_D=1<<ScaleNb;
322 
323 //#if defined PARMPI
324 
325  NeighbourNb=2;
327 
328  // -- Create memory arrays thats are needs for the MPI Type creation ---
329  disp = new MPI_Aint[NeighbourNb*MaxCellElementsNb*one_D*two_D];
330  blocklen = new int [NeighbourNb*MaxCellElementsNb*one_D*two_D];
331 
332  // --- Allocate additional memory for MPI buffer send---
333  Cell tc;
334  int CellElNb,bufsize;
335  CellElNb=tc.size().dimension()+tc.center().dimension()+tc.average().dimension()+tc.tempAverage().dimension()+tc.divergence().dimension();
336 
337  if (EquationType==6)
338  CellElNb += tc.gradient().lines()*tc.gradient().columns();
339 
340  bufsize=(CellElNb*one_D*two_D*NeighbourNb+MPI_BSEND_OVERHEAD)*2*Dimension+1024;
341  MPIbuffer=new real[bufsize];
342  MPI_Buffer_attach(MPIbuffer,bufsize*sizeof(real));
343 
344 #else
345  NeighbourNb=0;
346 #endif
347 
348 #if defined PARMPI
350 
351  // --- Compute domain coordinates for the processors ---
352  XMin[1] = AllXMin[1] + coords[0]*(AllXMax[1]-AllXMin[1])/CartDims[0];
353  XMax[1] = AllXMin[1] + (coords[0]+1)*(AllXMax[1]-AllXMin[1])/CartDims[0];
354 
355  if (Dimension >= 2)
356  {
357  XMin[2] = AllXMin[2] + coords[1]*(AllXMax[2]-AllXMin[2])/CartDims[1];
358  XMax[2] = AllXMin[2] + (coords[1]+1)*(AllXMax[2]-AllXMin[2])/CartDims[1];
359  }
360 
361  if (Dimension == 3)
362  {
363  XMin[3] = AllXMin[3] + coords[2]*(AllXMax[3]-AllXMin[3])/CartDims[2];
364  XMax[3] = AllXMin[3] + (coords[2]+1)*(AllXMax[3]-AllXMin[3])/CartDims[2];
365  }
366 
367  // --- Set the backup file name for the current processor
368  sprintf(BackupName,"%d_%d_%d_%s",coords[0],coords[1],coords[2],"carmen.bak");
369 #else
370  sprintf(BackupName,"%s","carmen.bak");
371 #endif
372 
373 
374  // --- Use CVS only if Dimension > 1 -------------------------------------------------------
375 
376  if (Dimension == 1)
377  CVS = false;
378 
379  // --- TimeAveraging always false if not Navier-Stokes -------------------------------------
380 
381  if (EquationType != 6)
382  TimeAveraging = false;
383 
384  // --- If there is no file "carmen.bak", set Recovery=false --------------------------------
385 
386  if (!fopen(BackupName,"r"))
387  Recovery = false;
388 
389  // --- If PrintMoreScales != 0 or 1 with Multiresolution = false, print error and stop ---
390 
391  if (!Multiresolution && (!(PrintMoreScales == 0 || PrintMoreScales == -1)) )
392  {
393  cout << "Parameters.cpp: In method `void InitParameters()':\n";
394  cout << "Parameters.cpp: value of PrintMoreScales incompatible with FV computations\n";
395  cout << "Parameters.cpp: must be 0 or -1\n";
396  cout << "carmen: *** [Parameters.o] Execution error\n";
397  cout << "carmen: abort execution.\n";
398  exit(1);
399  }
400 
401  // --- Compute global volume ---------------------------------------------------------------
402 
403  GlobalVolume = fabs(XMax[1]-XMin[1]);
404 
405  if (Dimension > 1)
406  GlobalVolume *= fabs(XMax[2]-XMin[2]);
407 
408  if (Dimension > 2)
409  GlobalVolume *= fabs(XMax[3]-XMin[3]);
410 
411  // --- Compute PostProcessing and DataIsBinary ---------------------------------------------
412 
413  // In 1D, use Gnuplot instead of Data Explorer
414 
415  if (Dimension == 1 && PostProcessing == 2)
416  PostProcessing = 1;
417 
418  // In 2D-3D, use Data Explorer instead of Gnuplot
419 
420  if (Dimension != 1 && PostProcessing == 1)
421  PostProcessing = 2;
422 
423  // --- Compute number of conservative quantities -------------------------------------------
424 
425  QuantityNb = 9;
426 
427  // --- Set the dimension of QuantityMax to QuantityNb ---------------------------------------
428 
430 
431  // --- Set the dimension of QuantityAverage to 4 (pressure, vorticity, entropy, volume)
432 
434 
435  // --- Set the dimension of IntMomentum to dimension ----------------------------------------
436 
438 
439  // --- Compute minimal space step -----------------------------------------------------------
440 
441  SpaceStep = fabs(XMax[1]-XMin[1]);
442 
443  for (i = 2; i <= Dimension; i++)
444  SpaceStep = Min(SpaceStep, fabs(XMax[i]-XMin[i]));
445 
446  SpaceStep /= (1<<ScaleNb);
447 
448  // --- Compute time step from CFL if TimeStep = 0 -------------------------------------------
449 
450  if (TimeStep == 0.)
451  {
452  if (fabs(Eigenvalue)>0.0e-20)
454  else
455  TimeStep = 0.0001;
456  }
457  else
458  ConstantTimeStep = true;
459 
462 
463 }
int one_D
Definition: Parameters.cpp:236
An object Cell contains all the informations of a cell for both multiresolution and finite volume com...
Definition: Cell.h:41
real ch
Definition: Parameters.cpp:140
int ScaleNb
Definition: Parameters.cpp:87
int CPUScales
Definition: Parameters.cpp:225
int IterationNbRef
Definition: Parameters.cpp:38
real center(const int AxisNo) const
Returns the component no. AxisNo of the cell-center position.
Definition: Cell.h:1112
bool TimeAveraging
Definition: Parameters.cpp:60
int QuantityNb
Definition: Parameters.cpp:171
real XMax[4]
Definition: Parameters.cpp:77
int MPIRecvType
Definition: Parameters.cpp:239
int PrintMoreScales
Definition: Parameters.cpp:90
real Eigenvalue
Definition: Parameters.cpp:157
int ChildNb
Definition: Parameters.cpp:213
int coords[3]
Definition: Parameters.cpp:230
real SpaceStep
Definition: Parameters.cpp:156
int Dimension
Definition: Parameters.cpp:74
real GlobalVolume
Definition: Parameters.cpp:203
real AllXMax[4]
Definition: Parameters.cpp:226
int AllTaskScaleNb
Definition: Parameters.cpp:227
#define Min(x, y)
Definition: Carmen.h:62
Vector IntMomentum
Definition: Parameters.cpp:217
int MPISendType
Definition: Parameters.cpp:238
real divergence(const int QuantityNo) const
Returns the component no. QuantityNo of the divergence vector.
Definition: Cell.h:1192
int PostProcessing
Definition: Parameters.cpp:144
real size(const int AxisNo) const
Returns the cell size in the direction AxisNo.
Definition: Cell.h:1095
bool CVS
Definition: Parameters.cpp:97
real average(const int QuantityNo) const
Returns the component no. QuantityNo of the cell-average value.
Definition: Cell.h:1128
void CreateMPITopology()
Parallel function DOES NOT WORK!
Definition: Parallel.cpp:22
real AllXMin[4]
Definition: Parameters.cpp:226
real XMin[4]
Definition: Parameters.cpp:76
real tempAverage(const int QuantityNo) const
Returns the component no. QuantityNo of the temporary cell-average value.
Definition: Cell.h:1144
char BackupName[255]
Definition: Parameters.cpp:257
real TimeStep
Definition: Parameters.cpp:40
int two_D
Definition: Parameters.cpp:236
Vector QuantityAverage
Definition: Parameters.cpp:163
int CartDims[3]
Definition: Parameters.cpp:231
bool ConstantTimeStep
Definition: Parameters.cpp:94
int NeighbourNb
Definition: Parameters.cpp:228
int size
Definition: Parameters.cpp:224
bool Recovery
Definition: Parameters.cpp:59
Vector QuantityMax
Definition: Parameters.cpp:162
int EquationType
Definition: Parameters.cpp:66
bool Multiresolution
Definition: Parameters.cpp:84
real CFL
Definition: Parameters.cpp:39
real gradient(const int i, const int j) const
Returns the component no. i, j of the velocity gradient. Does not work for MHD!
Definition: Cell.h:1225
#define real
Definition: PreProcessor.h:31
int MaxCellElementsNb
Definition: Parameters.cpp:234
void setDimension(const int n)
Sets the dimension of the vector to n and reset values to zero.
Definition: Vector.cpp:298

Here is the caller graph for this function:

real InitResistivity ( real  x,
real  y = 0.,
real  z = 0. 
)

Returns the initial resistivity condition in (x, y, z) form the one defined in carmen.eta.

Parameters
xPosition x
yPosition y. Defaults to 0..
zPosition z. Defaults to 0..
Returns
double
51 {
52  // --- Local variables ---
53 
54  real Result=0.;
55  real Res = 0.;
56 
57  #include "carmen.eta"
58 
59  Result = Res;
60 
61  return Result;
62 }
#define real
Definition: PreProcessor.h:31

Here is the caller graph for this function:

void InitTimeStep ( )

Inits time step and all the parameters which depend on it.

Returns
void
23 {
24 
25  // --- Init TimeStep --------------------------------------------------------------
26 
27  if (TimeStep == 0)
28  {
31  }
32 
33  // --- Compute number of iterations -----------------------------------------------
34 
35  if (PhysicalTime != 0. && IterationNb == 0)
36  IterationNb = (int)(ceil(PhysicalTime/TimeStep));
37 
38  // --- Compute Refresh ------------------------------------------------------------
39 
40  if (Refresh == 0)
41  Refresh = (int)(ceil(IterationNb/(RefreshNb*1.)));
42 
43  // --- Compute PrintEvery ---------------------------------------------------------
44 
45  if ((PrintEvery == 0)&&(ImageNb != 0))
46  PrintEvery = (int)(ceil(IterationNb/(ImageNb*1.)));
47 
48  // --- Compute iterations for print ----------------------------------------------
49 
50  if (PrintTime1 != 0.)
51  PrintIt1 = (int)(ceil(PrintTime1/TimeStep));
52 
53  if (PrintTime2 != 0.)
54  PrintIt2 = (int)(ceil(PrintTime2/TimeStep));
55 
56  if (PrintTime3 != 0.)
57  PrintIt3 = (int)(ceil(PrintTime3/TimeStep));
58 
59  if (PrintTime4 != 0.)
60  PrintIt4 = (int)(ceil(PrintTime4/TimeStep));
61 
62  if (PrintTime5 != 0.)
63  PrintIt5 = (int)(ceil(PrintTime5/TimeStep));
64 
65  if (PrintTime6 != 0.)
66  PrintIt6 = (int)(ceil(PrintTime6/TimeStep));
67 
68  // --- Compute FV reference time -----------------------------------------------------------
69 
70  if (Multiresolution)
72 
73 }
int PrintIt1
Definition: Parameters.cpp:50
real PhysicalTime
Definition: Parameters.cpp:41
int IterationNb
Definition: Parameters.cpp:37
real PrintTime1
Definition: Parameters.cpp:44
real PrintTime5
Definition: Parameters.cpp:48
int IterationNbRef
Definition: Parameters.cpp:38
int ImageNb
Definition: Parameters.cpp:57
int PrintIt3
Definition: Parameters.cpp:52
bool Resistivity
Definition: Parameters.cpp:120
real eta
Definition: Parameters.cpp:123
real Eigenvalue
Definition: Parameters.cpp:157
int PrintIt2
Definition: Parameters.cpp:51
real SpaceStep
Definition: Parameters.cpp:156
int PrintIt6
Definition: Parameters.cpp:55
int RefreshNb
Definition: Parameters.cpp:43
int Refresh
Definition: Parameters.cpp:42
real PrintTime2
Definition: Parameters.cpp:45
int ScaleNbRef
Definition: Parameters.cpp:88
int PrintIt5
Definition: Parameters.cpp:54
real TimeStep
Definition: Parameters.cpp:40
real PrintTime3
Definition: Parameters.cpp:46
double CPUTimeRef(int iterations, int scales)
Returns the time required by a finite volume computation using iterations iterations and scales scale...
Definition: CPUTimeRef.cpp:23
real PrintTime6
Definition: Parameters.cpp:49
bool Multiresolution
Definition: Parameters.cpp:84
int PrintIt4
Definition: Parameters.cpp:53
double FVTimeRef
Definition: Parameters.cpp:172
real CFL
Definition: Parameters.cpp:39
int PrintEvery
Definition: Parameters.cpp:56
real PrintTime4
Definition: Parameters.cpp:47

Here is the caller graph for this function:

void InitTree ( Node Root)

Inits tree structure from initial condition, starting form the node Root. Only for multiresolution computations.

Parameters
RootRoot
Returns
void
23 {
24  // --- Local variables ---
25 
26  int l; // Counter on levels
27 
28  // --- Init cell-average value in root and split it ---
29 
30  if (Recovery && UseBackup)
31 
32  Root->restore();
33 
34  else
35  {
36  Root->initValue();
37 
38  // --- Add and init nodes in different levels, when necessary ---
39 
40  for (l=1; l <= ScaleNb; l++)
41  Root->addLevel();
42  }
43 
44  // -- Check if tree is graded ---
45 
46  if (debug) Root->checkGradedTree();
47 
48 }
int ScaleNb
Definition: Parameters.cpp:87
void checkGradedTree()
Checks if the tree is graded. If not, an error is emitted. Only for debugging.
Definition: Node.cpp:2630
void initValue()
Computes the initial value.
Definition: Node.cpp:124
bool debug
Definition: Parameters.cpp:142
bool UseBackup
Definition: Parameters.cpp:58
bool Recovery
Definition: Parameters.cpp:59
void addLevel()
Adds levels when needed.
Definition: Node.cpp:191
void restore()
Restores the tree structure and the cell-averages from the file carmen.bak. This file was created by ...
Definition: Node.cpp:2761

Here is the caller graph for this function:

Vector Limiter ( const Vector  u,
const Vector  v 
)

Returns the value of the slope limiter between the slopes u and v.

Parameters
uVector
vVector
Returns
Vector
57 {
58  // Min Mod limiter
59 
60  int LimiterNo = 3;
61 
62  Vector Result(u.dimension());
63  int i;
64  real x, y; // slopes
65 
66  for (i=1; i<=u.dimension(); i++)
67  {
68  x = u.value(i);
69  y = v.value(i);
70 
71  switch(LimiterNo)
72  {
73  // MIN-MOD
74  case 1:
75  if (x == y)
76  Result.setValue(i, 0.);
77  else
78  Result.setValue(i,Min(1., fabs(x)/fabs(x-y)));
79  break;
80 
81  // VAN LEER
82  case 3:
83  default:
84  if ((fabs(x) + fabs(y)) == 0.)
85  Result.setValue(i, 0.);
86  else
87  Result.setValue(i,fabs(x)/(fabs(x)+fabs(y)));
88  break;
89  };
90  }
91 
92  return Result;
93 }
Standard class for every vector in Carmen.
Definition: Vector.h:29
#define Min(x, y)
Definition: Carmen.h:62
int dimension() const
Returns the dimension of the vector.
Definition: Vector.h:535
real value(const int n) const
Returns the value of the component n.
Definition: Vector.h:565
int LimiterNo
Definition: Parameters.cpp:68
#define real
Definition: PreProcessor.h:31

Here is the caller graph for this function:

real Limiter ( const real  x)

Returns the valur of slope limiter from a real value x.

Parameters
x...
Returns
double
23 {
24  real Result = 0.;
25 
26  switch (LimiterNo)
27  {
28  case 1: // Min-Mod
29  Result = Max(0., Min(1.,r));
30  break;
31 
32  case 2: // Van Albada
33  Result = (r<=0.)? 0.: (r*r+r)/(r*r+1.);
34  break;
35 
36  case 3: // Van Leer
37  Result = (r<=0.) ? 0.: (r+Abs(r))/(1.+Abs(r));
38  break;
39 
40  case 4: // Superbee
41  Result = (r<=0.) ? 0.: Max(0.,Max(Min(2.*r,1.),Min(r,2.)));
42  break;
43  case 5: // Monotonized Central
44  Result = max(0.0,min(min(2*r,0.5*(1+r)),2.0));
45  break;
46 
47  };
48 
49  return Result;
50 }
#define Min(x, y)
Definition: Carmen.h:62
#define Abs(x)
Definition: Carmen.h:78
int LimiterNo
Definition: Parameters.cpp:68
#define Max(x, y)
Definition: Carmen.h:54
#define real
Definition: PreProcessor.h:31
real MinAbs ( const real  a,
const real  b 
)

Returns the minimum in module of a and b.

Parameters
aReal value
bReal value
Returns
double
23 {
24  return (fabs(a) <= fabs(b))? a:b;
25 }
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
void Performance ( const char *  FileName)

Computes the performance of the computation and, for cluster computations, write it into file FileName.

Parameters
FileNameName of the file.
Returns
void
23 {
24  // --- Local variables ---
25 
26  bool EndComputation; // True if end computation
27  int FineCellNb; // Number of cells on fine grid
28  int CellPVirt;
29  FILE *output; // Pointer to output file
30 
31  double realtimefull; //full real time
32  double ftime; // real time
33  double ctime; // CPU time
34  unsigned int ttime, rtime; // total and remaining real time (in seconds)
35  unsigned int tctime=0, rctime=0; // total and remaining CPU time (in seconds)
36  unsigned int rest;
37  int day, hour, min, sec;
38 
39  // --- Init EndComputation
40 
41  EndComputation = (IterationNo > IterationNb);
42 
43  // --- Compute FineCellNb ---
44 
45  FineCellNb = 1<<(ScaleNb*Dimension);
46  CellPVirt = 1<<(ScaleNb*(Dimension-1));
47  CellPVirt = CellPVirt*2*Dimension;
48  // --- Write in file ---
49 
50 /*
51  char CPUFileName[255];
52 #if defined PARMPI
53  sprintf(CPUFileName,"%d_%d_%d_%s",coords[0],coords[1],coords[2],FileName);
54 // strcpy(CPUFileName, FileName);
55 #else
56  strcpy(CPUFileName, FileName);
57 #endif
58 */
59 
60  if ((output = fopen(FileName,"w")))
61  {
62 
63  realtimefull=ftime = CPUTime.realTime();
64  ctime = CPUTime.CPUTime();
65 
66  if (!EndComputation)
67  {
68  ttime = (unsigned int)((ftime*IterationNb)/IterationNo);
69  rtime = (unsigned int)((ftime*(IterationNb-IterationNo))/IterationNo);
70  tctime = (unsigned int)((ctime*IterationNb)/IterationNo);
71  rctime = (unsigned int)((ctime*(IterationNb-IterationNo))/IterationNo);
72  }
73 
74  fprintf(output, "Dimension : %12i\n", Dimension);
75 
76  if (EndComputation)
77  fprintf(output, "Iterations : %12i\n", IterationNb);
78  else
79  {
80  fprintf(output, "Iterations (total) : %12i\n", IterationNb);
81  fprintf(output, "Iterations (elapsed) : %12i\n", IterationNo);
82  fprintf(output, "In progress :%13.6f %%\n", 100.*IterationNo/(1.*IterationNb));
83  }
84 
85  fprintf(output, "Scales (max) : %12i\n", ScaleNb);
86  fprintf(output, "Cells (max) : %12i\n", (1<<(ScaleNb*Dimension)));
87 
88  if (Multiresolution)
89  fprintf(output, "Solver : MR\n");
90  else
91  fprintf(output, "Solver : FV\n");
92 
93  //fprintf(output, "Time integration : explicit\n");
94  fprintf(output, "Time accuracy order : %12i\n", StepNb);
95  fprintf(output, "Time step :%13.6e s\n", TimeStep);
96  fprintf(output, "Threshold parameter :%13.6e \n", Tolerance);
97  fprintf(output, "Threshold norm : %12i\n", ThresholdNorm);
98  fprintf(output, "CFL :%13.6e \n", CFL);
99 
100  if(Resistivity)
101  fprintf(output, "Eta :%13.6e \n", eta);
102  if(Diffusivity)
103  fprintf(output, "Chi :%13.6e \n", chi);
104 
105  if (EndComputation)
106  {
107  fprintf(output, "Physical time :%13.6e s\n", ElapsedTime); //TimeStep * IterationNb);
108  fprintf(output, "CPU time (s) :%13.6e s\n", ctime);
109 
110  if (Multiresolution)
111  fprintf(output, "CPU time / it. x pt :%13.6e s\n", ctime/TotalLeafNb);
112  else
113  fprintf(output, "CPU time / it. x pt :%13.6e s\n", ctime/((1<<(ScaleNb*Dimension))*IterationNb));
114 
115  if (Multiresolution)
116  {
117 
118  fprintf(output, "Leaf compression :%13.6f %% \n", (100.*TotalLeafNb)/(1.0*IterationNb*FineCellNb));
119  //fprintf(output, "Memory compression :%13.6f %% \n", (100.*TotalCellNb)/(1.0*IterationNb*(FineCellNb)));
120  fprintf(output, "Memory compression :%13.6f %% \n", (100.*TotalCellNb)/(1.0*IterationNb*(FineCellNb + CellPVirt)));
121  fprintf(output, "CPU compression :%13.6f %% \n", (100.*ctime)/(IterationNb*FVTimeRef));
122  }
123  else
124  {
125  fprintf(output, "Leaf compression :%13.6f %% \n", 100.);
126  fprintf(output, "Memory compression :%13.6f %% \n", 100.);
127  fprintf(output, "CPU compression :%13.6f %% \n", 100.);
128  }
129  }
130  else
131  {
132  fprintf(output, "Total physical time :%13.6e s\n", TimeStep * IterationNb);
133  fprintf(output, "Elapsed physical time :%13.6e s\n", TimeStep * IterationNo);
134  if (Multiresolution)
135  {
136  fprintf(output, "Leaf compression :%13.6f %% \n", (100.*TotalLeafNb)/(1.0*IterationNb*FineCellNb));
137  fprintf(output, "Memory compression :%13.6f %% \n", (100.*TotalCellNb)/(1.0*IterationNo*FineCellNb));
138  fprintf(output, "CPU compression :%13.6f %% \n", (100.*ctime)/(IterationNo*FVTimeRef));
139  }
140  else
141  {
142  fprintf(output, "Leaf compression :%13.6f %% \n", 100.);
143  fprintf(output, "Memory compression :%13.6f %% \n", 100.);
144  fprintf(output, "CPU compression :%13.6f %% \n", 100.);
145  }
146  }
147 
148  fprintf(output, "\n");
149 
150  if (EndComputation)
151  {
152  // --- Print final time ------------------------------------------------
153 
154  rest = (unsigned int)(ctime);
155  day = rest/86400;
156  rest %= 86400;
157  hour = rest/3600;
158  rest %= 3600;
159  min = rest/60;
160  rest %= 60;
161  sec = rest;
162  rest = (unsigned int)(ctime);
163 
164  if (rest >= 86400)
165  fprintf(output, "CPU time : %5d day %2d h %2d min %2d s\n", day, hour, min, sec);
166 
167  if ((rest < 86400)&&(rest >= 3600))
168  fprintf(output, "CPU time : %2d h %2d min %2d s\n", hour, min, sec);
169 
170  if ((rest < 3600)&&(rest >= 60))
171  fprintf(output, "CPU time : %2d min %2d s\n", min, sec);
172 
173  if (rest < 60)
174  fprintf(output, "CPU time : %2d s\n", sec);
175  }
176  else
177  {
178  // --- Print total time ------------------------------------------------
179 
180  rest = tctime;
181  day = rest/86400;
182  rest %= 86400;
183  hour = rest/3600;
184  rest %= 3600;
185  min = rest/60;
186  rest %= 60;
187  sec = rest;
188 
189  if (tctime >= 86400)
190  fprintf(output, "Total CPU time (estimation) : %5d day %2d h %2d min %2d s\n", day, hour, min, sec);
191 
192  if ((tctime < 86400)&&(tctime >= 3600))
193  fprintf(output, "Total CPU time (estimation) : %2d h %2d min %2d s\n", hour, min, sec);
194 
195  if ((tctime < 3600)&&(tctime >= 60))
196  fprintf(output, "Total CPU time (estimation) : %2d min %2d s\n", min, sec);
197 
198  if (tctime < 60)
199  fprintf(output,"Total CPU time (estimation) : %2d s\n", sec);
200 
201  // --- Print remaining time ------------------------------------------------
202 
203  rest = rctime;
204  day = rest/86400;
205  rest %= 86400;
206  hour = rest/3600;
207  rest %= 3600;
208  min = rest/60;
209  rest %= 60;
210  sec = rest;
211 
212  if (rctime >= 86400)
213  fprintf(output, "Remaining CPU time (estimation) : %5d day %2d h %2d min %2d s\n", day, hour, min, sec);
214 
215  if ((rctime < 86400)&&(rctime >= 3600))
216  fprintf(output, "Remaining CPU time (estimation) : %2d h %2d min %2d s\n", hour, min, sec);
217 
218  if ((rctime < 3600)&&(rctime >= 60))
219  fprintf(output, "Remaining CPU time (estimation) : %2d min %2d s\n", min, sec);
220 
221  if (rctime < 60)
222  fprintf(output, "Remaining CPU time (estimation) : %2d s\n", sec);
223 
224  }
225 
226 
227 #if defined PARMPI
228  fprintf(output, "\n");
229  fprintf(output, "Real time (time() function) :%lf\n", realtimefull);
230  fprintf(output, "clock() function :%lf\n", ctime);
231  fprintf(output, "\nCommunications real timer: %lf\n", CommTimer.realTime());
232  fprintf(output, "Communications clock():%lf\n", CommTimer.CPUTime());
233 #endif
234 
235  fprintf(output, "\n");
236  fclose (output);
237  }
238  else
239  {
240  cout << "Performance.cpp: In method `void Performance(Node*, char*)':\n";
241  cout << "Performance.cpp: cannot open file " << FileName << '\n';
242  cout << "carmen: *** [Performance.o] Execution error\n";
243  cout << "carmen: abort execution.\n";
244  exit(1);
245  }
246 }
int IterationNb
Definition: Parameters.cpp:37
int ScaleNb
Definition: Parameters.cpp:87
double CPUTime()
Returns CPU time from previous start in seconds.
Definition: Timer.cpp:124
bool Resistivity
Definition: Parameters.cpp:120
real chi
Definition: Parameters.cpp:124
real eta
Definition: Parameters.cpp:123
real TotalLeafNb
Definition: Parameters.cpp:176
int Dimension
Definition: Parameters.cpp:74
int IterationNo
Definition: Parameters.cpp:168
real ElapsedTime
Definition: Parameters.cpp:95
double realTime()
Returns real time from previous start in seconds.
Definition: Timer.cpp:148
bool Diffusivity
Definition: Parameters.cpp:121
int StepNb
Definition: Parameters.cpp:36
real TotalCellNb
Definition: Parameters.cpp:177
Timer CommTimer
Definition: Parameters.cpp:241
real TimeStep
Definition: Parameters.cpp:40
bool Multiresolution
Definition: Parameters.cpp:84
double FVTimeRef
Definition: Parameters.cpp:172
real Tolerance
Definition: Parameters.cpp:91
int ThresholdNorm
Definition: Parameters.cpp:100
Timer CPUTime
Definition: Parameters.cpp:169
real CFL
Definition: Parameters.cpp:39

Here is the caller graph for this function:

void PrintIntegral ( const char *  FileName)

Writes the integral values, like e.g flame velocity, global error, into file FileName.

Parameters
FileNameName of the file
Returns
void
31 {
32  // --- Local variables ---
33 
34  real t; // time
35  FILE *output; // output file
36  int i; // counter
37  real Volume=1.; // Total volume
38 
39  // --- Open file ---
40 
41  if ( (IterationNo == 0) ? (output = fopen(FileName,"w")) : (output = fopen(FileName,"a")) )
42  {
43  // HEADER
44 
45  if (IterationNo == 0)
46  {
47 
48  fprintf(output, "#");
49  fprintf(output, TXTFORMAT, " Time");
50  fprintf(output, TXTFORMAT, "CFL");
51  fprintf(output, TXTFORMAT, "Energy");
52  fprintf(output, TXTFORMAT, "Div B Max");
53  fprintf(output, TXTFORMAT, "ch");
54  fprintf(output, TXTFORMAT, "Helicity");
55  fprintf(output, TXTFORMAT, "DivB Max norm");
56 /*
57  if (Multiresolution)
58  {
59  fprintf(output, TXTFORMAT, "Memory comp.");
60  fprintf(output, TXTFORMAT, "CPU comp.");
61  if (ExpectedCompression != 0. || CVS)
62  fprintf(output, TXTFORMAT, "Tolerance");
63  // if (CVS)
64  // fprintf(output, TXTFORMAT, "Av. Pressure");
65 
66  }
67 */
68  if (!ConstantTimeStep)
69  {
70  if (StepNb == 3) fprintf(output, TXTFORMAT, "RKF Error");
71  fprintf(output, TXTFORMAT,"Next time step");
72  fprintf(output, "%13s ", "IterationNo");
73  fprintf(output, "%13s ", "IterationNb");
74  }
75 
76  fprintf(output,"\n");
77 
78  }
79 
80  if (ConstantTimeStep)
82  else
83  t = ElapsedTime;
84 
85  fprintf(output, FORMAT, t);
86 
87  // --- Compute total volume ---
88 
89  for (i=1; i<= Dimension; i++)
90  Volume *= fabs(XMax[i]-XMin[i]);
91 
92  // Print CFL
93  fprintf(output, FORMAT,Eigenvalue*TimeStep/SpaceStep);
94 
95  // Print momentum and energy
96  //fprintf(output, FORMAT, GlobalMomentum);
97  fprintf(output, FORMAT, GlobalEnergy);
98  fprintf(output, FORMAT, DIVBMax);
99  fprintf(output, FORMAT, ch);
100  fprintf(output, FORMAT, Helicity);
101  fprintf(output, FORMAT, DIVB);
102 
103 
104 /*
105  if (Multiresolution)
106  {
107  fprintf(output, FORMAT, (1.*CellNb)/(1<<(ScaleNb*Dimension)));
108  fprintf(output, FORMAT, CPUTime.CPUTime()/(IterationNo*FVTimeRef));
109 
110  if (ExpectedCompression != 0.)
111  fprintf(output, FORMAT, Tolerance);
112 
113  // if (CVS)
114  //{
115  // fprintf(output, FORMAT, ComputedTolerance(ScaleNb));
116  // fprintf(output, FORMAT, QuantityAverage.value(1));
117  //}
118  }
119 */
120  if (!ConstantTimeStep)
121  {
122  if (StepNb == 3) fprintf(output, FORMAT, RKFError);
123  fprintf(output, FORMAT, TimeStep);
124  fprintf(output, "%13i ", IterationNo);
125  fprintf(output, "%13i ", IterationNb);
126  }
127 
128  fprintf(output, "\n");
129  fclose(output);
130  }
131  else
132  {
133  cout << "PrintIntegral.cpp: In method `void PrintIntegral(Node*, char*)´:\n";
134  cout << "PrintIntegral.cpp: cannot open file " << FileName << '\n';
135  cout << "carmen: *** [PrintIntegral.o] Execution error\n";
136  cout << "carmen: abort execution.\n";
137  exit(1);
138  }
139 }
int IterationNb
Definition: Parameters.cpp:37
real DIVB
Definition: Parameters.cpp:136
real ch
Definition: Parameters.cpp:140
real XMax[4]
Definition: Parameters.cpp:77
real DIVBMax
Definition: Parameters.cpp:137
real Eigenvalue
Definition: Parameters.cpp:157
#define TXTFORMAT
Definition: PreProcessor.h:33
real SpaceStep
Definition: Parameters.cpp:156
int Dimension
Definition: Parameters.cpp:74
real RKFError
Definition: Parameters.cpp:190
int IterationNo
Definition: Parameters.cpp:168
real ElapsedTime
Definition: Parameters.cpp:95
real GlobalEnergy
Definition: Parameters.cpp:197
real Helicity
Definition: Parameters.cpp:195
int StepNb
Definition: Parameters.cpp:36
real XMin[4]
Definition: Parameters.cpp:76
real TimeStep
Definition: Parameters.cpp:40
#define FORMAT
Definition: PreProcessor.h:32
bool ConstantTimeStep
Definition: Parameters.cpp:94
#define real
Definition: PreProcessor.h:31

Here is the caller graph for this function:

void ReduceIntegralValues ( )

Parallel function DOES NOT WORK!

Returns
void
469  {
470 real rb; //Recieve Buffer
471 rb=0.0;
472  CommTimer.start();
473 #if defined PARMPI
474  MPI_Reduce(&ErrorMax,&rb,1,MPI_Type,MPI_MAX,0,MPI_COMM_WORLD);
475  ErrorMax=rb;
476 
477  MPI_Reduce(&ErrorMid,&rb,1,MPI_Type,MPI_SUM,0,MPI_COMM_WORLD);
478  ErrorMid=rb/size;
479 
480  MPI_Reduce(&ErrorL2,&rb,1,MPI_Type,MPI_SUM,0,MPI_COMM_WORLD);
481  ErrorL2=rb/size;
482 
483  MPI_Reduce(&ErrorNb,&rb,1,MPI_Type,MPI_SUM,0,MPI_COMM_WORLD);
484  ErrorNb=rb;
485 
486  MPI_Allreduce(&FlameVelocity,&rb,1,MPI_Type,MPI_SUM,MPI_COMM_WORLD);
487  FlameVelocity=rb;
488 
489  MPI_Allreduce(&GlobalMomentum,&rb,1,MPI_Type,MPI_SUM,MPI_COMM_WORLD);
490  GlobalMomentum=rb;
491 
492  MPI_Allreduce(&GlobalEnergy,&rb,1,MPI_Type,MPI_SUM,MPI_COMM_WORLD);
493  GlobalEnergy=rb;
494 
495  MPI_Reduce(&ExactMomentum,&rb,1,MPI_Type,MPI_SUM,0,MPI_COMM_WORLD);
496  ExactMomentum=rb;
497 
498  MPI_Reduce(&ExactEnergy,&rb,1,MPI_Type,MPI_SUM,0,MPI_COMM_WORLD);
499  ExactEnergy=rb;
500 
501  MPI_Allreduce(&GlobalReactionRate,&rb,1,MPI_Type,MPI_SUM,MPI_COMM_WORLD);
503 
504  MPI_Allreduce(&EigenvalueMax, &rb,1,MPI_Type,MPI_MAX,MPI_COMM_WORLD);
505  EigenvalueMax=rb;
506 
507 #endif
508  CommTimer.stop();
509 }
#define MPI_Type
Definition: PreProcessor.h:48
double stop()
Stop timer and, if asked, returns CPU time from previous start in seconds.
Definition: Timer.cpp:77
int ErrorNb
Definition: Parameters.cpp:185
real ExactMomentum
Definition: Parameters.cpp:199
real GlobalEnergy
Definition: Parameters.cpp:197
real ErrorL2
Definition: Parameters.cpp:183
real ErrorMax
Definition: Parameters.cpp:179
real GlobalMomentum
Definition: Parameters.cpp:196
real FlameVelocity
Definition: Parameters.cpp:201
Timer CommTimer
Definition: Parameters.cpp:241
void start()
Starts timer.
Definition: Timer.cpp:62
real GlobalReactionRate
Definition: Parameters.cpp:205
int size
Definition: Parameters.cpp:224
real EigenvalueMax
Definition: Parameters.cpp:161
real ExactEnergy
Definition: Parameters.cpp:200
real ErrorMid
Definition: Parameters.cpp:181
#define real
Definition: PreProcessor.h:31

Here is the caller graph for this function:

void RefreshTree ( Node Root)

Refresh the tree structure, i.e. compute the cell-averages of the internal nodes by projection and those of the virtual leaves by prediction. The root node is Root. Only for multiresolution computations.

Parameters
RootRoot
Returns
void
23 {
24  // --- Project : compute cell-average values in all nodes ---
25  Root->project();
26 
27  // --- Fill virtual children with predicted values ---
28  Root->fillVirtualChildren();
29 }
void fillVirtualChildren()
Fills the cell-average values of every virtual leaf with values predicted from its parent and uncles...
Definition: Node.cpp:624
Cell * project()
Computes the cell-average values of all nodes that are not leaves by projection from the cell-average...
Definition: Node.cpp:661

Here is the caller graph for this function:

void Remesh ( Node Root)

Remesh the tree structure after a time evolution. The root node is Root. Only for multiresolution computations.

Parameters
RootRoot
Returns
void
23 {
24  // --- Refresh tree structure ---
25 // RefreshTree(Root);
26 
27  // --- Check if tree is graded ---
28  if (debug) Root->checkGradedTree();
29 
30  // --- Adapt : depending on details, refine or combine ---
31  Root->adapt();
32 
33  // --- Check if tree is graded ---
34  if (debug) Root->checkGradedTree();
35 }
void checkGradedTree()
Checks if the tree is graded. If not, an error is emitted. Only for debugging.
Definition: Node.cpp:2630
int adapt()
Computes the details in the leaves and its parent nodes and, in function of the threshold Tolerance...
Definition: Node.cpp:691
bool debug
Definition: Parameters.cpp:142

Here is the caller graph for this function:

Vector ResistiveTerms ( Cell Cell1,
Cell Cell2,
Cell Cell3,
Cell Cell4,
int  AxisNo 
)

Returns the resistive source terms in the cell UserCell.

Parameters
Cell1Cell 1
Cell2Cell 2
Cell3Cell 3
Cell4Cell 4
AxisNoAxis of interest
Returns
Vector

X - direction

2D

Y - direction

2D

Z - direction

3D

12 {
13  // --- Local variables ---
14  Vector B(3), Bi(3), Bj(3), Bk(3);
15  Vector Result(QuantityNb);
16  Vector Bavg(3);
17  real Jx = 0., Jy = 0., Jz = 0.;
18  real dx, dy, dz;
19  real ResX= 0., ResY= 0., ResZ= 0., ResE= 0.;
20  real eta0=0., etai=0., etaj=0., etak=0., etaR=0.;
21 
22  dx = Cell2.size(1);
23  dy = Cell2.size(2);
24  dz = Cell2.size(3);
25 
26  eta0 = Cell1.Res;
27  etai = Cell2.Res;
28  etaj = Cell3.Res;
29  etak = Cell4.Res;
30 
31  for(int i=1; i <= 3; i++){
32  B.setValue (i, Cell1.average(i+6));
33  Bi.setValue(i, Cell2.average(i+6));
34  Bj.setValue(i, Cell3.average(i+6));
35  Bk.setValue(i, Cell4.average(i+6));
36  }
37 
38 
39  if(AxisNo == 1){
41  etaR = (eta0 + etai)/2.;
42 
43  Bavg.setValue(2, 0.5*(B.value(2) + Bi.value(2)));
44  Bavg.setValue(3, 0.5*(B.value(3) + Bi.value(3)));
45 
46  Jy = -(B.value(3) - Bi.value(3))/dx;
47  Jz = (B.value(2) - Bi.value(2))/dx;
48 
50  Jz = Jz - (B.value(1) - Bj.value(1))/dy;
51 
52  if(Dimension==3){
53  Jy = Jy + (B.value(1) - Bk.value(1))/dz;
54  }
55 
56  ResE = etaR*(Bavg.value(2)*Jz - Bavg.value(3)*Jy);
57  ResX = 0.;
58  ResY = etaR*Jz;
59  ResZ = -etaR*Jy;
60 
61 
62  }else if(AxisNo == 2){
64  etaR = (eta0 + etaj)/2.;
65 
66  Bavg.setValue(1, 0.5*(B.value(1) + Bj.value(1)));
67  Bavg.setValue(3, 0.5*(B.value(3) + Bj.value(3)));
68 
69  Jx = (B.value(3) - Bj.value(3))/dy;
70  Jz = -(B.value(1) - Bj.value(1))/dy;
71 
73  Jz = Jz + (B.value(2) - Bi.value(2))/dx;
74 
75  if(Dimension==3){
76  Jx = Jx + (B.value(2) - Bk.value(2))/dz;
77  }
78 
79  ResE = etaR*(Bavg.value(3)*Jx - Bavg.value(1)*Jz);
80  ResX = -etaR*Jz;
81  ResY = 0.;
82  ResZ = etaR*Jx;
83 
84  }else{
86  etaR = (eta0 + etak)/2.;
87 
88  Bavg.setValue(1, 0.5*(B.value(1) + Bk.value(1)));
89  Bavg.setValue(2, 0.5*(B.value(2) + Bk.value(2)));
90 
91  Jx = -(B.value(2) - Bk.value(2))/dz;
92  Jy = (B.value(1) - Bk.value(1))/dz;
93 
95  Jx = Jx + (B.value(3) - Bj.value(3))/dy;
96  Jy = Jy - (B.value(3) - Bi.value(3))/dx;
97 
98  ResE = etaR*(Bavg.value(1)*Jy - Bavg.value(2)*Jx);
99  ResX = etaR*Jy;
100  ResY = -etaR*Jx;
101  ResZ = 0.;
102  }
103 
104 
105  Result.setZero();
106 
107  // These values will be added to the numerical flux
108  Result.setValue(5, ResE);
109  Result.setValue(7, ResX);
110  Result.setValue(8, ResY);
111  Result.setValue(9, ResZ);
112 
113  return Result;
114 
115 }
int QuantityNb
Definition: Parameters.cpp:171
Standard class for every vector in Carmen.
Definition: Vector.h:29
real Res
Definition: Cell.h:857
int Dimension
Definition: Parameters.cpp:74
real size(const int AxisNo) const
Returns the cell size in the direction AxisNo.
Definition: Cell.h:1095
real average(const int QuantityNo) const
Returns the component no. QuantityNo of the cell-average value.
Definition: Cell.h:1128
#define real
Definition: PreProcessor.h:31

Here is the caller graph for this function:

Vector SchemeHLL ( const Cell Cell1,
const Cell Cell2,
const Cell Cell3,
const Cell Cell4,
const int  AxisNo 
)

Returns the HLL numerical flux for MHD equations. The scheme uses four cells to estimate the flux at the interface. Cell2 and Cell3 are the first neighbours on the left and right sides. Cell1 and Cell4 are the second neighbours on the left and right sides.

Parameters
Cell1second neighbour on the left side
Cell2first neighbour on the left side
Cell3first neighbour on the right side
Cell4second neighbour on the right side
AxisNoAxis of interest.
Returns
Vector
12 {
13 
14  // General variables
15 
16  Vector LeftAverage(QuantityNb); //
17  Vector RightAverage(QuantityNb); // Conservative quantities
18  Vector Result(QuantityNb); // MHD numerical flux
19  int aux=0;
20  // Variables for the HLL scheme
21  Vector FL(QuantityNb), FR(QuantityNb); //Left and right physical fluxes
22  Vector VL(3), VR(3); // Left and right velocities
23  Vector BL(3), BR(3); // Left and right velocities
24  real rhoL=0., rhoR=0.; // Left and right densities
25  real eL=0., eR=0.; // Left and right energies
26  real preL=0., preR=0.;
27  real bkL=0., bkR=0.;
28  real aL=0., aR=0.;
29  real bL=0., bR=0.;
30  real cfL=0., cfR=0.;
31  real SL=0., SR=0.;
32  real dx=0.;
33  dx = Cell2.size(AxisNo);
34  real r, Limit, LeftSlope = 0., RightSlope = 0.; // Left and right slopes
35  int i;
36 
37 // --- Limiter function ---------------------------------------------------------
38 
39  for (i=1; i<=QuantityNb; i++)
40  {
41  // --- Compute left cell-average value ---
42 
43  if (Cell2.average(i) != Cell1.average(i))
44  {
45  RightSlope = Cell3.average(i)-Cell2.average(i);
46  LeftSlope = Cell2.average(i)-Cell1.average(i);
47  r = RightSlope/LeftSlope;
48  Limit = Limiter(r);
49  LeftAverage.setValue(i, Cell2.average(i) + 0.5*Limit*LeftSlope);
50  aux = 1;
51  }
52  else
53  LeftAverage.setValue(i, Cell2.average(i));
54 
55  // --- Compute right cell-average value ---
56 
57  if (Cell3.average(i) != Cell2.average(i))
58  {
59  RightSlope = Cell4.average(i)-Cell3.average(i);
60  LeftSlope = Cell3.average(i)-Cell2.average(i);
61  r = RightSlope/LeftSlope;
62  Limit = Limiter(r);
63  RightAverage.setValue(i, Cell3.average(i) - 0.5*Limit*LeftSlope);
64  aux = 1;
65  }
66  else
67  RightAverage.setValue(i, Cell3.average(i));
68  }
69 
70 
71  // --- HLL scheme -------------------------------------------------------------
72 
73  // --- Conservative variables ---
74 
75  // Left and right densities
76  rhoL = LeftAverage.value(1);
77  rhoR = RightAverage.value(1);
78 
79  // Left and right momentum and magnetic field
80  for (int i=1;i<=3;i++)
81  {
82  VL.setValue( i, LeftAverage.value(i+1));
83  VR.setValue( i, RightAverage.value(i+1));
84  BL.setValue( i, LeftAverage.value(i+6));
85  BR.setValue( i, RightAverage.value(i+6));
86  }
87 
88  // Left and right energies
89  eL = LeftAverage.value(5);
90  eR = RightAverage.value(5);
91 
92  // Left and right pressures
93  preL = (Gamma -1.)*(eL - 0.5*(VL*VL)/rhoL - 0.5*(BL*BL));
94  preR = (Gamma -1.)*(eR - 0.5*(VR*VR)/rhoR - 0.5*(BR*BR));
95 
96  // --- Magnetoacoustic waves calculations --
97 
98  bkL = power2(BL.value(AxisNo))/rhoL;
99  bkR = power2(BR.value(AxisNo))/rhoR;
100 
101  aL = Gamma*preL/rhoL;
102  aR = Gamma*preR/rhoR;
103 
104  bL = (BL*BL)/rhoL;
105  bR = (BR*BR)/rhoR;
106 
107  // Left and Right fast speeds
108  cfL = sqrt(0.5*(aL + bL + sqrt(power2(aL + bL) - 4.0*aL*bkL)));
109  cfR = sqrt(0.5*(aR + bR + sqrt(power2(aR + bR) - 4.0*aR*bkR)));
110 
111  // Left and right slopes
112  SL = Min(Min(VL.value(AxisNo)/rhoL - cfL, VR.value(AxisNo)/rhoR - cfR),0.0);
113  SR = Max(Max(VL.value(AxisNo)/rhoL + cfL, VR.value(AxisNo)/rhoR + cfR),0.0);
114 
115  // --- Physical flux ---
116  if(AxisNo ==1){
117  EigenvalueX = Max(Max(Abs(SL),Abs(SR)),EigenvalueX);
118  FL = FluxX(LeftAverage);
119  FR = FluxX(RightAverage);
120  }else if(AxisNo ==2){
121  EigenvalueY = Max(Max(Abs(SL),Abs(SR)),EigenvalueY);
122  FL = FluxY(LeftAverage);
123  FR = FluxY(RightAverage);
124  }else{
125  EigenvalueZ = Max(Max(Abs(SL),Abs(SR)),EigenvalueZ);
126  FL = FluxZ(LeftAverage);
127  FR = FluxZ(RightAverage);
128  }
129 
130 
131  // --- HLL Riemann Solver ---
132 
133  for(int i=1;i<=QuantityNb;i++)
134  {
135  Result.setValue(i, (SR*FL.value(i) - SL*FR.value(i) + SR*SL*(RightAverage.value(i) - LeftAverage.value(i)))/(SR-SL));
136  }
137 
138  // Parabolic-Hyperbolic divergence Cleaning (Dedner, 2002)
139  fluxCorrection(Result, LeftAverage, RightAverage, AxisNo);
140 
141  // Artificial diffusion terms
142  if(Diffusivity && aux==1) Result = Result - ArtificialViscosity(LeftAverage,RightAverage,dx,AxisNo);
143 
144  return Result;
145 
146 }
#define power2(x)
Definition: Carmen.h:70
real EigenvalueZ
Definition: Parameters.cpp:160
Vector FluxY(const Vector &Avg)
Returns the physical flux of MHD equations in Y direction.
Definition: PhysicalFluxMHD.cpp:58
int QuantityNb
Definition: Parameters.cpp:171
Standard class for every vector in Carmen.
Definition: Vector.h:29
Vector ArtificialViscosity(const Vector &Cell1, const Vector &Cell2, real dx, int AxisNo)
Returns the artificial diffusion source terms in the cell UserCell.
Definition: ArtificialViscosity.cpp:11
#define Min(x, y)
Definition: Carmen.h:62
real Gamma
Definition: Parameters.cpp:109
Vector Limiter(const Vector u, const Vector v)
Returns the value of the slope limiter between the slopes u and v.
Definition: Limiter.cpp:56
bool Diffusivity
Definition: Parameters.cpp:121
Vector FluxX(const Vector &Avg)
Returns the physical flux of MHD equations in X direction.
Definition: PhysicalFluxMHD.cpp:8
real size(const int AxisNo) const
Returns the cell size in the direction AxisNo.
Definition: Cell.h:1095
void fluxCorrection(Vector &Flux, const Vector &AvgL, const Vector &AvgR, int AxisNo)
This function apply the divergence-free correction to the numerical flux.
Definition: FluxCorrection.cpp:9
real average(const int QuantityNo) const
Returns the component no. QuantityNo of the cell-average value.
Definition: Cell.h:1128
Vector FluxZ(const Vector &Avg)
Returns the physical flux of MHD equations in Z direction.
Definition: PhysicalFluxMHD.cpp:106
#define Abs(x)
Definition: Carmen.h:78
real EigenvalueY
Definition: Parameters.cpp:159
real EigenvalueX
Definition: Parameters.cpp:158
#define Max(x, y)
Definition: Carmen.h:54
#define real
Definition: PreProcessor.h:31

Here is the caller graph for this function:

Vector SchemeHLLD ( const Cell Cell1,
const Cell Cell2,
const Cell Cell3,
const Cell Cell4,
const int  AxisNo 
)

Returns the HLLD numerical flux for MHD equations. The scheme uses four cells to estimate the flux at the interface. Cell2 and Cell3 are the first neighbours on the left and right sides. Cell1 and Cell4 are the second neighbours on the left and right sides.

Parameters
Cell1second neighbour on the left side
Cell2first neighbour on the left side
Cell3first neighbour on the right side
Cell4second neighbour on the right side
AxisNoAxis of interest.
Returns
Vector
13 {
14 
15  // General variables
16 
17  Vector LeftAverage(QuantityNb); //
18  Vector RightAverage(QuantityNb); // Conservative quantities
19  Vector Result(QuantityNb); // MHD numerical flux
20  int aux=0;
21 
22  // Variables for the HLL scheme
23  Vector FL(QuantityNb), FR(QuantityNb); //Left and right physical fluxes
24  Vector VL(3), VR(3); // Left and right velocities
25  Vector BL(3), BR(3); // Left and right velocities
26  real rhoL=0., rhoR=0.; // Left and right densities
27  real eL=0., eR=0.; // Left and right energies
28  real preL=0., preR=0.;
29  real bkL=0., bkR=0.;
30  real aL=0., aR=0.;
31  real bL=0., bR=0.;
32  real cfL=0., cfR=0.;
33  real SL=0., SR=0.;
34  real SLS=0., SRS=0.;
35  real SM=0.;
36  Matrix U(QuantityNb,4);
37  Matrix F(QuantityNb,2);
38  real dx=0.;
39  dx = Cell2.size(AxisNo);
40  real r, Limit, LeftSlope = 0., RightSlope = 0.; // Left and right slopes
41  int i;
42 
43 // --- Limiter function ---------------------------------------------------------
44 
45  for (i=1; i<=QuantityNb; i++)
46  {
47  // --- Compute left cell-average value ---
48 
49  if (Cell2.average(i) != Cell1.average(i))
50  {
51  RightSlope = Cell3.average(i)-Cell2.average(i);
52  LeftSlope = Cell2.average(i)-Cell1.average(i);
53  r = RightSlope/LeftSlope;
54  Limit = Limiter(r);
55  LeftAverage.setValue(i, Cell2.average(i) + 0.5*Limit*LeftSlope);
56  aux = 1;
57  }
58  else
59  LeftAverage.setValue(i, Cell2.average(i));
60 
61  // --- Compute right cell-average value ---
62 
63  if (Cell3.average(i) != Cell2.average(i))
64  {
65  RightSlope = Cell4.average(i)-Cell3.average(i);
66  LeftSlope = Cell3.average(i)-Cell2.average(i);
67  r = RightSlope/LeftSlope;
68  Limit = Limiter(r);
69  RightAverage.setValue(i, Cell3.average(i) - 0.5*Limit*LeftSlope);
70  aux = 1;
71  }
72  else
73  RightAverage.setValue(i, Cell3.average(i));
74  }
75 
76  // --- HLLD scheme -------------------------------------------------------------
77 
78  // --- Conservative variables ---
79 
80  // Left and right densities
81  rhoL = LeftAverage.value(1);
82  rhoR = RightAverage.value(1);
83 
84  // Left and right momentum and magnetic field
85  for (int i=1;i<=3;i++)
86  {
87  VL.setValue( i, LeftAverage.value (i+1));
88  VR.setValue( i, RightAverage.value(i+1));
89  BL.setValue( i, LeftAverage.value (i+6));
90  BR.setValue( i, RightAverage.value(i+6));
91  }
92 
93  // Left and right energies
94  eL = LeftAverage.value(5);
95  eR = RightAverage.value(5);
96 
97  // Left and right pressures
98  preL = (Gamma -1.)*(eL - 0.5*(VL*VL)/rhoL - 0.5*(BL*BL));
99  preR = (Gamma -1.)*(eR - 0.5*(VR*VR)/rhoR - 0.5*(BR*BR));
100 
101  // --- Magnetoacoustic waves computation --
102  bkL = power2(BL.value(AxisNo))/rhoL;
103  bkR = power2(BR.value(AxisNo))/rhoR;
104 
105  aL = Gamma*preL/rhoL;
106  aR = Gamma*preR/rhoR;
107 
108  bL = (BL*BL)/rhoL;
109  bR = (BR*BR)/rhoR;
110 
111  // Left and Right fast speeds
112  cfL = sqrt(0.5*(aL + bL + sqrt(power2(aL + bL) - 4.0*aL*bkL)));
113  cfR = sqrt(0.5*(aR + bR + sqrt(power2(aR + bR) - 4.0*aR*bkR)));
114 
115  // Left and Right slopes
116  SL = Min((VL.value(AxisNo))/rhoL, (VR.value(AxisNo))/rhoR) - Max(cfL,cfR);
117  SR = Max((VL.value(AxisNo))/rhoL, (VR.value(AxisNo))/rhoR) + Max(cfL,cfR);
118 
119  // --- Physical flux ---
120  if(AxisNo ==1){
121  EigenvalueX = Max(Max(Abs(SL),Abs(SR)),EigenvalueX);
122  FL = FluxX(LeftAverage);
123  FR = FluxX(RightAverage);
124  }else if(AxisNo ==2){
125  EigenvalueY = Max(Max(Abs(SL),Abs(SR)),EigenvalueY);
126  FL = FluxY(LeftAverage);
127  FR = FluxY(RightAverage);
128  }else{
129  EigenvalueZ = Max(Max(Abs(SL),Abs(SR)),EigenvalueZ);
130  FL = FluxZ(LeftAverage);
131  FR = FluxZ(RightAverage);
132  }
133 
134  // Intermediary states U* and U**
135  U = stateUstar(LeftAverage, RightAverage, preL, preR, SL, SR, SM, SLS, SRS,AxisNo);
136 
137  // --- HLLD Riemann Solver ---
138 
139  for(int i=1;i<=QuantityNb;i++)
140  {
141  //Flux Function - Equation 66
142  //F_L
143  if(SL>=0.)
144  Result.setValue(i, FL.value(i));
145  //F-star left // FL=FLstar
146  else if(SLS>=0. && SL<0.)
147  Result.setValue(i, FL.value(i) + SL*(U.value(i,1) - LeftAverage.value(i)));
148  //F-star-star left
149  else if(SM>=0. && SLS<0.)
150  Result.setValue(i, FL.value(i) + SLS*U.value(i,3) - (SLS - SL)*U.value(i,1) - SL*LeftAverage.value(i));
151  //F-star-star right
152  else if(SRS>=0. && SM<0.)
153  Result.setValue(i, FR.value(i) + SRS*U.value(i,4) - (SRS - SR)*U.value(i,2) - SR*RightAverage.value(i));
154  //F-star right
155  else if(SR>=0. && SRS<0.)
156  Result.setValue(i, FR.value(i) + SR*(U.value(i,2) - RightAverage.value(i)));
157  //F_R
158  else
159  Result.setValue(i, FR.value(i));
160  }
161  // Parabolic-Hyperbolic divergence Cleaning (Dedner, 2002)
162  //fluxCorrection(Result, Cell2.average(), Cell3.average(), AxisNo);
163  fluxCorrection(Result, LeftAverage, RightAverage, AxisNo);
164 
165  // Artificial diffusion terms
166  if(Diffusivity && aux==1) Result = Result - ArtificialViscosity(LeftAverage,RightAverage,dx,AxisNo);
167 
168  return Result;
169 
170 }
#define power2(x)
Definition: Carmen.h:70
real EigenvalueZ
Definition: Parameters.cpp:160
Vector FluxY(const Vector &Avg)
Returns the physical flux of MHD equations in Y direction.
Definition: PhysicalFluxMHD.cpp:58
int QuantityNb
Definition: Parameters.cpp:171
Standard class for every vector in Carmen.
Definition: Vector.h:29
Vector ArtificialViscosity(const Vector &Cell1, const Vector &Cell2, real dx, int AxisNo)
Returns the artificial diffusion source terms in the cell UserCell.
Definition: ArtificialViscosity.cpp:11
#define Min(x, y)
Definition: Carmen.h:62
real Gamma
Definition: Parameters.cpp:109
Vector Limiter(const Vector u, const Vector v)
Returns the value of the slope limiter between the slopes u and v.
Definition: Limiter.cpp:56
bool Diffusivity
Definition: Parameters.cpp:121
Vector FluxX(const Vector &Avg)
Returns the physical flux of MHD equations in X direction.
Definition: PhysicalFluxMHD.cpp:8
real size(const int AxisNo) const
Returns the cell size in the direction AxisNo.
Definition: Cell.h:1095
void fluxCorrection(Vector &Flux, const Vector &AvgL, const Vector &AvgR, int AxisNo)
This function apply the divergence-free correction to the numerical flux.
Definition: FluxCorrection.cpp:9
real average(const int QuantityNo) const
Returns the component no. QuantityNo of the cell-average value.
Definition: Cell.h:1128
Standard class for every matrix in Carmen.
Definition: Matrix.h:28
Vector FluxZ(const Vector &Avg)
Returns the physical flux of MHD equations in Z direction.
Definition: PhysicalFluxMHD.cpp:106
#define Abs(x)
Definition: Carmen.h:78
real EigenvalueY
Definition: Parameters.cpp:159
real EigenvalueX
Definition: Parameters.cpp:158
#define Max(x, y)
Definition: Carmen.h:54
Matrix stateUstar(const Vector &AvgL, const Vector &AvgR, const real prel, const real prer, real &slopeLeft, real &slopeRight, real &slopeM, real &slopeLeftStar, real &slopeRightStar, int AxisNo)
Returns the intermediary states of HLLD numerical flux for MHD equations.
Definition: IntermediaryStates.cpp:12
#define real
Definition: PreProcessor.h:31

Here is the caller graph for this function:

void ShowTime ( Timer  arg)

Writes on screen the estimation of total and remaining CPU times. These informations are stored in the timer arg.

Parameters
argArgument
Returns
void
24 {
25 // double ftime; // real time
26  double ctime; // CPU time
27 // unsigned int ttime, rtime; // total and remaining real time (in seconds)
28  unsigned int tctime, rctime; // total and remaining CPU time (in seconds)
29 
30  int day, hour, min, sec;
31  unsigned int rest;
32 
33  // --- Write total and remaining estimated time -----------------------
34 
35 // ftime = arg.GetRealTime();
36  ctime = arg.CPUTime();
37 // ttime = (unsigned int)((ftime*IterationNb)/IterationNo);
38 // rtime = (unsigned int)((ftime*(IterationNb-IterationNo))/IterationNo);
39  tctime = (unsigned int)((ctime*IterationNb)/IterationNo);
40  rctime = (unsigned int)((ctime*(IterationNb-IterationNo))/IterationNo);
41 
42  // --- Show total time ------------------------------------------------
43 
44  rest = tctime;
45  day = rest/86400;
46  rest %= 86400;
47  hour = rest/3600;
48  rest %= 3600;
49  min = rest/60;
50  rest %= 60;
51  sec = rest;
52 
53  printf("\033[1A\033[1A");
54 
55  if (tctime >= 86400)
56  printf("Total CPU time (estimation) : %5d day %2d h %2d min %2d s\n", day, hour, min, sec);
57 
58  if ((tctime < 86400)&&(tctime >= 3600))
59  printf("Total CPU time (estimation) : %2d h %2d min %2d s \n", hour, min, sec);
60 
61  if ((tctime < 3600)&&(tctime >= 60))
62  printf("Total CPU time (estimation) : %2d min %2d s \n", min, sec);
63 
64  if (tctime < 60)
65  printf("Total CPU time (estimation) : %2d s \n", sec);
66 
67  // --- Show remaining time ------------------------------------------------
68 
69  rest = rctime;
70  day = rest/86400;
71  rest %= 86400;
72  hour = rest/3600;
73  rest %= 3600;
74  min = rest/60;
75  rest %= 60;
76  sec = rest;
77 
78  if (rctime >= 86400)
79  printf("Remaining CPU time (estimation) : %5d day %2d h %2d min %2d s\n", day, hour, min, sec);
80 
81  if ((rctime < 86400)&&(rctime >= 3600))
82  printf("Remaining CPU time (estimation) : %2d h %2d min %2d s \n", hour, min, sec);
83 
84  if ((rctime < 3600)&&(rctime >= 60))
85  printf("Remaining CPU time (estimation) : %2d min %2d s \n", min, sec);
86 
87  if (rctime < 60)
88  printf("Remaining CPU time (estimation) : %2d s \n", sec);
89 
90 }
int IterationNb
Definition: Parameters.cpp:37
double CPUTime()
Returns CPU time from previous start in seconds.
Definition: Timer.cpp:124
int IterationNo
Definition: Parameters.cpp:168

Here is the caller graph for this function:

int Sign ( const real  a)

Returns 1 if a is non-negative, -1 elsewhere.

Parameters
aReal value
Returns
int
23 {
24  if (a >= 0)
25  return 1;
26  else
27  return -1;
28 }
Vector Source ( Cell UserCell)

Returns the source term in the cell UserCell.

Parameters
UserCellCell value
Returns
Vector

Gravity vector

24 {
25  // --- Local variables ---
26 
27  Vector Force(Dimension);
28  Vector Result(QuantityNb);
29  Result.setZero();
30 
32  Vector V(3);
33  real Gx=0., Gy=0., Gz=0.,rho=0.;
34  for(int i=1;i<=3;i++)
35  V.setValue(i,UserCell.average(i+1));
36  rho = UserCell.density();
37  Gz = 0.2;
38  Result.setValue(2,rho*Gx);
39  Result.setValue(3,rho*Gy);
40  Result.setValue(4,rho*Gz);
41  Result.setValue(5,rho*(Gx*V.value(1) + Gy*V.value(2) + Gz*V.value(3)));
42 
43  Result.setZero();
44  return Result;
45 
46 }
int QuantityNb
Definition: Parameters.cpp:171
Standard class for every vector in Carmen.
Definition: Vector.h:29
real density() const
Returns the cell-average density.
Definition: Cell.h:1262
int Dimension
Definition: Parameters.cpp:74
real average(const int QuantityNo) const
Returns the component no. QuantityNo of the cell-average value.
Definition: Cell.h:1128
#define real
Definition: PreProcessor.h:31

Here is the caller graph for this function:

Matrix stateUstar ( const Vector AvgL,
const Vector AvgR,
const real  prel,
const real  prer,
real slopeLeft,
real slopeRight,
real slopeM,
real slopeLeftStar,
real slopeRightStar,
int  AxisNo 
)

Returns the intermediary states of HLLD numerical flux for MHD equations.

Parameters
AvgLLeft average vector
AvgRRight average vector
prelLeft pressure
prerRight pressure
slopeLeftLeft slope
slopeRightRight slope
slopeMSlope value computed for HLLD
slopeLeftStarLeft star slope (intermediary states)
slopeRightStarRight star slope (intermediary states)
AxisNoAxis of interest
Returns
Matrix

variables U-star

variables U-star-star

13 {
14  real rhol=0.,rhor=0.;
15  real psil=0.,psir=0.;
16  real vxl=0.,vxr=0.,vyl=0.,vyr=0.,vzl=0.,vzr=0.;
17  real Bxr=0.,Bxl=0.,Byl=0.,Byr=0.,Bzl=0.,Bzr=0.;
18  real vl=0.,vr=0.,mf=0.;
19  real Bl=0.,Br=0.;
20  real pTl=0.,pTr=0.;
21  real vBl=0.,vBr=0.;
22  real el=0., er=0.;
23  real rhols=0.,rhors=0.;
24  real vxls=0.,vxrs=0.,vyls=0.,vyrs=0.,vzls=0.,vzrs=0.;
25  real Bxls=0.,Bxrs=0.,Byls=0.,Byrs=0.,Bzls=0.,Bzrs=0.;
26  real pTs=0.;
27  real vBls=0.,vBrs=0.;
28  real Els=0.,Ers=0.;
29  real rholss=0.,rhorss=0.;
30  real vxlss=0.,vxrss=0.,vylss=0.,vyrss=0.,vzlss=0.,vzrss=0.;
31  real Bxlss=0.,Bxrss=0.,Bylss=0.,Byrss=0.,Bzlss=0.,Bzrss=0.;
32  real vBlss=0.,vBrss=0.;
33  real Elss=0.,Erss=0.;
34  int Bsign=0;
35  real half=0.5;
36  real epsilon2=1e-16;
37  real auxl=0.,auxr=0., Sqrtrhols=0.;
38 
39  Matrix U(QuantityNb,4);
40 
41  //Variables
42  rhol = AvgL.value(1);
43  vxl = AvgL.value(2)/rhol;
44  vyl = AvgL.value(3)/rhol;
45  vzl = AvgL.value(4)/rhol;
46  el = AvgL.value(5);
47  psil = AvgL.value(6);
48  Bxl = AvgL.value(7);
49  Byl = AvgL.value(8);
50  Bzl = AvgL.value(9);
51 
52  rhor = AvgR.value(1);
53  vxr = AvgR.value(2)/rhor;
54  vyr = AvgR.value(3)/rhor;
55  vzr = AvgR.value(4)/rhor;
56  er = AvgR.value(5);
57  psir = AvgR.value(6);
58  Bxr = AvgR.value(7);
59  Byr = AvgR.value(8);
60  Bzr = AvgR.value(9);
61 
62  //v_x and v_y
63  vl = AvgL.value(AxisNo+1)/rhol;
64  vr = AvgR.value(AxisNo+1)/rhor;
65 
66  // Average B value
67  mf = (AvgL.value(AxisNo+6)+AvgR.value(AxisNo+6))/(double (2.0));
68 
69  if(AxisNo==1)
70  {
71  //|B|
72  Bl = sqrt( mf*mf + Byl*Byl + Bzl*Bzl );
73  Br = sqrt( mf*mf + Byr*Byr + Bzr*Bzr );
74  //Inner product v.B
75  vBl = vxl*mf + vyl*Byl + vzl*Bzl;
76  vBr = vxr*mf + vyr*Byr + vzr*Bzr;
77  }else if(AxisNo==2){
78  //|B|
79  Bl = sqrt( Bxl*Bxl + mf*mf + Bzl*Bzl );
80  Br = sqrt( Bxr*Bxr + mf*mf + Bzr*Bzr );
81  //Inner product v.B
82  vBl = vxl*Bxl + vyl*mf + vzl*Bzl;
83  vBr = vxr*Bxr + vyr*mf + vzr*Bzr;
84  }else{
85  //|B|
86  Bl = sqrt( Bxl*Bxl + Byl*Byl + mf*mf );
87  Br = sqrt( Bxr*Bxr + Byr*Byr + mf*mf );
88  //Inner product v.B
89  vBl = vxl*Bxl + vyl*Byl + vzl*mf;
90  vBr = vxr*Bxr + vyr*Byr + vzr*mf;
91  }
92 
93  //Total Pressure
94  pTl = prel + half*Bl*Bl;
95  pTr = prer + half*Br*Br;
96 
97  // S_M - Equation 38
98  slopeM = ((slopeRight - vr)*rhor*vr - (slopeLeft - vl)*rhol*vl - pTr +pTl)/
99  ((slopeRight - vr)*rhor - (slopeLeft - vl)*rhol);
100 
101  //Sign function
102  if(mf > 0) Bsign = 1;
103  else Bsign = -1;
104 
106 
107  //density - Equation 43
108  rhols = rhol*(slopeLeft-vl)/(slopeLeft-slopeM);
109  rhors = rhor*(slopeRight-vr)/(slopeRight-slopeM);
110 
111  if(AxisNo==1){
112  //velocities
113  //Equation 39
114  vxls = slopeM;
115  vxrs = vxls;
116  //B_x
117  Bxls = mf;
118  Bxrs = Bxls;
119 
120  auxl= (rhol*(slopeLeft - vl)*(slopeLeft - slopeM)-mf*mf);
121  auxr= (rhor*(slopeRight - vr)*(slopeRight - slopeM)-mf*mf);
122 
123  if( fabs(auxl)<epsilon2 ||
124  ( ( ( fabs(slopeM -vl) ) < epsilon2 ) &&
125  ( ( fabs(Byl) + fabs(Bzl) ) < epsilon2 ) &&
126  ( ( mf*mf ) > (Gamma*prel) ) ) ) {
127  vyls = vyl;
128  vzls = vzl;
129  Byls = Byl;
130  Bzls = Bzl;
131  }else{
132  //Equation 44
133  vyls = vyl - mf*Byl*(slopeM-vl)/auxl;
134  //Equation 46
135  vzls = vzl - mf*Bzl*(slopeM-vl)/auxl;
136  //Equation 45
137  Byls = Byl*(rhol*(slopeLeft-vl)*(slopeLeft-vl) - mf*mf)/auxl;
138  //Equation 47
139  Bzls = Bzl*(rhol*(slopeLeft-vl)*(slopeLeft-vl) - mf*mf)/auxl;
140  }
141  if( fabs(auxr)<epsilon2 ||
142  ( ( ( fabs(slopeM -vr) ) < epsilon2 ) &&
143  ( ( fabs(Byr) + fabs(Bzr) ) < epsilon2 ) &&
144  ( ( mf*mf ) > (Gamma*prer) ) ) ) {
145  vyrs = vyr;
146  vzrs = vzr;
147  Byrs = Byr;
148  Bzrs = Bzr;
149  }else{
150  //Equation 44
151  vyrs = vyr - mf*Byr*(slopeM-vr)/auxr;
152  //Equation 46
153  vzrs = vzr - mf*Bzr*(slopeM-vr)/auxr;
154  //Equation 45;
155  Byrs = Byr*(rhor*(slopeRight-vr)*(slopeRight-vr) - mf*mf)/auxr;
156  //Equation 47
157  Bzrs = Bzr*(rhor*(slopeRight-vr)*(slopeRight-vr) - mf*mf)/auxr;
158  }
159 
160  }else if(AxisNo==2){
161  //velocities
162  //Equation 39
163  vyls = slopeM;
164  vyrs = vyls;
165  //B_y
166  Byls = mf;
167  Byrs = Byls;
168 
169  auxl= (rhol*(slopeLeft - vl)*(slopeLeft - slopeM)-mf*mf);
170  auxr= (rhor*(slopeRight - vr)*(slopeRight - slopeM)-mf*mf);
171 
172  if( fabs(auxl)<epsilon2 ||
173  ( ( ( fabs(slopeM -vl) ) < epsilon2 ) &&
174  ( ( fabs(Bxl) + fabs(Bzl) ) < epsilon2 ) &&
175  ( ( mf*mf ) > (Gamma*prel) ) ) ) {
176  vxls = vxl;
177  vzls = vzl;
178  Bxls = Bxl;
179  Bzls = Bzl;
180  }else{
181  //Equation 44
182  vxls = vxl - mf*Bxl*(slopeM-vl)/auxl;
183  //Equation 46
184  vzls = vzl - mf*Bzl*(slopeM-vl)/auxl;
185  //Equation 45
186  Bxls = Bxl*(rhol*(slopeLeft-vl)*(slopeLeft-vl) - mf*mf)/auxl;
187  //Equation 47
188  Bzls = Bzl*(rhol*(slopeLeft-vl)*(slopeLeft-vl) - mf*mf)/auxl;
189  }
190 
191  if( fabs(auxr)<epsilon2 ||
192  ( ( ( fabs(slopeM -vr) ) < epsilon2 ) &&
193  ( ( fabs(Bxr) + fabs(Bzr) ) < epsilon2 ) &&
194  ( ( mf*mf ) > (Gamma*prer) ) ) ) {
195  vxrs = vxr;
196  vzrs = vzr;
197  Bxrs = Bxr;
198  Bzrs = Bzr;
199  }else{
200  //Equation 44
201  vxrs = vxr - mf*Bxr*(slopeM-vr)/auxr;
202  //Equation 46
203  vzrs = vzr - mf*Bzr*(slopeM-vr)/auxr;
204  //Equation 45
205  Bxrs = Bxr*(rhor*(slopeRight-vr)*(slopeRight-vr) - mf*mf)/auxr;
206  //Equation 47
207  Bzrs = Bzr*(rhor*(slopeRight-vr)*(slopeRight-vr) - mf*mf)/auxr;
208  }
209  }else{
210  //velocities
211  //Equation 39
212  vzls = slopeM;
213  vzrs = vzls;
214  //B_z
215  Bzls = mf;
216  Bzrs = Bzls;
217 
218  auxl= (rhol*(slopeLeft - vl)*(slopeLeft - slopeM)-mf*mf);
219  auxr= (rhor*(slopeRight - vr)*(slopeRight - slopeM)-mf*mf);
220 
221  if( fabs(auxl)<epsilon2 ||
222  ( ( ( fabs(slopeM -vl) ) < epsilon2 ) &&
223  ( ( fabs(Bxl) + fabs(Byl) ) < epsilon2 ) &&
224  ( ( mf*mf ) > (Gamma*prel) ) ) ) {
225  vxls = vxl;
226  vyls = vyl;
227  Bxls = Bxl;
228  Byls = Byl;
229  }else{
230  //Equation 44
231  vxls = vxl - mf*Bxl*(slopeM-vl)/auxl;
232  //Equation 46
233  vyls = vyl - mf*Byl*(slopeM-vl)/auxl;
234  //Equation 45
235  Bxls = Bxl*(rhol*(slopeLeft-vl)*(slopeLeft-vl) - mf*mf)/auxl;
236  //Equation 47
237  Byls = Byl*(rhol*(slopeLeft-vl)*(slopeLeft-vl) - mf*mf)/auxl;
238  }
239 
240  if( fabs(auxr)<epsilon2 ||
241  ( ( ( fabs(slopeM -vr) ) < epsilon2 ) &&
242  ( ( fabs(Bxr) + fabs(Byr) ) < epsilon2 ) &&
243  ( ( mf*mf ) > (Gamma*prer) ) ) ) {
244  vxrs = vxr;
245  vyrs = vyr;
246  Bxrs = Bxr;
247  Byrs = Byr;
248  }else{
249  //Equation 44
250  vxrs = vxr - mf*Bxr*(slopeM-vr)/auxr;
251  //Equation 46
252  vyrs = vyr - mf*Byr*(slopeM-vr)/auxr;
253  //Equation 45
254  Bxrs = Bxr*(rhor*(slopeRight-vr)*(slopeRight-vr) - mf*mf)/auxr;
255  //Equation 47
256  Byrs = Byr*(rhor*(slopeRight-vr)*(slopeRight-vr) - mf*mf)/auxr;
257  }
258  }
259 
260  //total pressure - Equation 41
261  pTs = pTl + rhol*(slopeLeft - vl)*(slopeM - vl);
262 
263  //inner product vs*Bs
264  vBls = vxls*Bxls + vyls*Byls + vzls*Bzls;
265  vBrs = vxrs*Bxrs + vyrs*Byrs + vzrs*Bzrs;
266 
267  //energy - Equation 48
268  Els = ((slopeLeft -vl)*el - pTl*vl+pTs*slopeM+mf*(vBl - vBls))/(slopeLeft - slopeM);
269  Ers = ((slopeRight-vr)*er - pTr*vr+pTs*slopeM+mf*(vBr - vBrs))/(slopeRight - slopeM);
270 
271  //U-star variables
272  //Left
273  U.setValue(1,1,rhols);
274  U.setValue(2,1,rhols*vxls);
275  U.setValue(3,1,rhols*vyls);
276  U.setValue(4,1,rhols*vzls);
277  U.setValue(5,1,Els);
278  U.setValue(6,1,psil);
279  U.setValue(7,1,Bxls);
280  U.setValue(8,1,Byls);
281  U.setValue(9,1,Bzls);
282  //Right
283  U.setValue(1,2,rhors);
284  U.setValue(2,2,rhors*vxrs);
285  U.setValue(3,2,rhors*vyrs);
286  U.setValue(4,2,rhors*vzrs);
287  U.setValue(5,2,Ers);
288  U.setValue(6,2,psir);
289  U.setValue(7,2,Bxrs);
290  U.setValue(8,2,Byrs);
291  U.setValue(9,2,Bzrs);
292 
293 
295 
296 
297  Sqrtrhols = (sqrt(rhols)+sqrt(rhors));
298 
299  if((mf*mf/min((Bl*Bl),(Br*Br))) < epsilon2){
300  for(int k=1;k<=QuantityNb;k++){
301  U.setValue(k,3, U.value(k,1));
302  U.setValue(k,4, U.value(k,2));
303  }
304  }else{
305  //density - Equation 49
306  rholss = rhols;
307  rhorss = rhors;
308 
309  if(AxisNo==1){
310  //velocities
311  //Equation 39
312  vxlss = slopeM;
313  vxrss = slopeM;
314  //Equation 59
315  vylss = (sqrt(rhols)*vyls + sqrt(rhors)*vyrs + (Byrs - Byls)*Bsign)/Sqrtrhols;
316  vyrss = vylss;
317  //Equation 60
318  vzlss = (sqrt(rhols)*vzls + sqrt(rhors)*vzrs + (Bzrs - Bzls)*Bsign)/Sqrtrhols;
319  vzrss = vzlss;
320 
321  //Magnetic Field components
322  //B_x
323  Bxlss = mf;
324  Bxrss = mf;
325  //Equation 61
326  Bylss = (sqrt(rhols)*Byrs + sqrt(rhors)*Byls + sqrt(rhols*rhors)*(vyrs - vyls)*Bsign)/Sqrtrhols;
327  Byrss = Bylss;
328  //Equation 62
329  Bzlss = (sqrt(rhols)*Bzrs + sqrt(rhors)*Bzls + sqrt(rhols*rhors)*(vzrs - vzls)*Bsign)/Sqrtrhols;
330  Bzrss = Bzlss;
331  }
332  else if(AxisNo==2){
333  //velocities
334  //Equation 59
335  vxlss = (sqrt(rhols)*vxls + sqrt(rhors)*vxrs + (Bxrs - Bxls)*Bsign)/Sqrtrhols;
336  vxrss = vxlss;
337  //Equation 39
338  vylss = slopeM;
339  vyrss = slopeM;
340  //Equation 60
341  vzlss = (sqrt(rhols)*vzls + sqrt(rhors)*vzrs + (Bzrs - Bzls)*Bsign)/Sqrtrhols;
342  vzrss = vzlss;
343 
344  //Magnetic Field components
345  //Equation 61
346  Bxlss = (sqrt(rhols)*Bxrs + sqrt(rhors)*Bxls + sqrt(rhols*rhors)*(vxrs - vxls)*Bsign)/Sqrtrhols;
347  Bxrss = Bxlss;
348  //B_y
349  Bylss = mf;
350  Byrss = mf;
351  //Equation 62
352  Bzlss = (sqrt(rhols)*Bzrs + sqrt(rhors)*Bzls + sqrt(rhols*rhors)*(vzrs - vzls)*Bsign)/Sqrtrhols;
353  Bzrss = Bzlss;
354 
355  }else{
356  //velocities
357  //Equation 59
358  vxlss = (sqrt(rhols)*vxls + sqrt(rhors)*vxrs + (Bxrs - Bxls)*Bsign)/Sqrtrhols;
359  vxrss = vxlss;
360  //Equation 60
361  vylss = (sqrt(rhols)*vyls + sqrt(rhors)*vyrs + (Byrs - Byls)*Bsign)/Sqrtrhols;
362  vyrss = vylss;
363  //Equation 39
364  vzlss = slopeM;
365  vzrss = slopeM;
366 
367  //Magnetic Field components
368  //Equation 61
369  Bxlss = (sqrt(rhols)*Bxrs + sqrt(rhors)*Bxls + sqrt(rhols*rhors)*(vxrs - vxls)*Bsign)/Sqrtrhols;
370  Bxrss = Bxlss;
371  //Equation 62
372  Bylss = (sqrt(rhols)*Byrs + sqrt(rhors)*Byls + sqrt(rhols*rhors)*(vyrs - vyls)*Bsign)/Sqrtrhols;
373  Byrss = Bylss;
374  //B_y
375  Bzlss = mf;
376  Bzrss = mf;
377 
378  }
379 
380 
381  //inner product vss*Bss
382  vBlss = vxlss*Bxlss + vylss*Bylss + vzlss*Bzlss;
383  vBrss = vxrss*Bxrss + vyrss*Byrss + vzrss*Bzrss;
384 
385  //Energy - Equation 63
386  Elss = Els - sqrt(rhols)*(vBls - vBlss)*Bsign;
387  Erss = Ers + sqrt(rhors)*(vBrs - vBrss)*Bsign;
388 
389 
390 
391 
392  //U-star-star variables
393  //Left
394  U.setValue(1,3,rholss);
395  U.setValue(2,3,rholss*vxlss);
396  U.setValue(3,3,rholss*vylss);
397  U.setValue(4,3,rholss*vzlss);
398  U.setValue(5,3,Elss);
399  U.setValue(6,3,psil);
400  U.setValue(7,3,Bxlss);
401  U.setValue(8,3,Bylss);
402  U.setValue(9,3,Bzlss);
403  //Right
404  U.setValue(1,4,rhorss);
405  U.setValue(2,4,rhorss*vxrss);
406  U.setValue(3,4,rhorss*vyrss);
407  U.setValue(4,4,rhorss*vzrss);
408  U.setValue(5,4,Erss);
409  U.setValue(6,4,psir);
410  U.setValue(7,4,Bxrss);
411  U.setValue(8,4,Byrss);
412  U.setValue(9,4,Bzrss);
413  }
414  //Equation 61 - S-star left and S-star right
415  slopeLeftStar = slopeM - Abs(mf)/sqrt(rhols);
416  slopeRightStar = slopeM + Abs(mf)/sqrt(rhors);
417 
418  return U;
419 }
int QuantityNb
Definition: Parameters.cpp:171
real Gamma
Definition: Parameters.cpp:109
Standard class for every matrix in Carmen.
Definition: Matrix.h:28
#define Abs(x)
Definition: Carmen.h:78
real value(const int n) const
Returns the value of the component n.
Definition: Vector.h:565
#define real
Definition: PreProcessor.h:31

Here is the caller graph for this function:

real Step ( real  x)

Returns a step (1 if x <0, 0 if x >0, 0.5 if x=0)

Parameters
xReal value
Returns
double
25 {
26  if (x < 0.)
27  return 1.;
28  else if (x > 0.)
29  return 0.;
30  else
31  return .5;
32 }
void TimeEvolution ( FineMesh Root)

Computes a time evolution on the regular fine mesh Root. Only for finite volume computations.

Parameters
RootFine mesh
Returns
void
78 {
79 
80  // --- Store cell-average values into temporary ---
81  Root->store();
82 
83  for (StepNo = 1; StepNo <= StepNb; StepNo++)
84  {
85  // --- Compute divergence for neighbour cells ---
86  //The same conception with background computations, see upper...
87  Root->computeDivergence(1);
88  // --- Runge-Kutta step for neighbour cells ---
89  Root->RungeKutta(1);
90  // --- Divergence cleaning source term
91  Root->computeCorrection(1);
92  // --- Start inter-CPU exchanges ---
93  CPUExchange(Root, SendQ);
94  // --- Compute divergence for internal cells ---
95  Root->computeDivergence(0);
96  // --- Runge-Kutta step for internal cells ---
97  Root->RungeKutta(0);
98  // --- Divergence cleaning source term
99  Root->computeCorrection(0);
100 
101 #if defined PARMPI
102  CommTimer.start(); //Communication Timer Start
103  //Waiting while inter-CPU exchanges are finished
104  if (MPIRecvType == 1) //for nonblocking recive...
105  MPI_Waitall(4*Dimension,req,st);
106  CommTimer.stop();
107 #endif
108 
109  }
110 
111  // --- Check stability ---
112  Root->checkStability();
113 
114  // --- Compute integral values ---
115  Root->computeIntegral();
116 
117  // --- Compute elapsed time and adapt time step ---
118 
119  if (!ComputeCPUTimeRef)
120  {
124  // --- Compute divergence-free correction constant
125  //ch = CFL*SpaceStep/TimeStep;
127  }
128 
129  // --- Compute time-average values ---
130 
131  if (TimeAveraging)
132  Root->computeTimeAverage();
133 
134 }
void computeCorrection(int)
Computes divergence cleaning source term (only for MHD).
Definition: FineMesh.cpp:540
void checkStability() const
Checks if the computation is numerically unstable, i.e. if one of the cell-averages is overflow...
Definition: FineMesh.cpp:927
real ch
Definition: Parameters.cpp:140
real EigenvalueZ
Definition: Parameters.cpp:160
bool TimeAveraging
Definition: Parameters.cpp:60
bool ComputeCPUTimeRef
Definition: Parameters.cpp:62
int MPIRecvType
Definition: Parameters.cpp:239
int StepNo
Definition: Parameters.cpp:167
double stop()
Stop timer and, if asked, returns CPU time from previous start in seconds.
Definition: Timer.cpp:77
void computeTimeAverage()
Computes the time-average value in every cell.
Definition: FineMesh.cpp:1803
real Eigenvalue
Definition: Parameters.cpp:157
void computeIntegral()
Computes integral values like e.g. flame velocity, global error, etc.
Definition: FineMesh.cpp:965
real SpaceStep
Definition: Parameters.cpp:156
int Dimension
Definition: Parameters.cpp:74
real ElapsedTime
Definition: Parameters.cpp:95
int StepNb
Definition: Parameters.cpp:36
Timer CommTimer
Definition: Parameters.cpp:241
void RungeKutta(int)
Computes the Runge-Kutta step.
Definition: FineMesh.cpp:807
void start()
Starts timer.
Definition: Timer.cpp:62
real TimeStep
Definition: Parameters.cpp:40
void AdaptTimeStep()
Adapts time step when required.
Definition: AdaptTimeStep.cpp:24
bool ConstantTimeStep
Definition: Parameters.cpp:94
real EigenvalueY
Definition: Parameters.cpp:159
void store()
Stores cell-average values into temporary cell-average values.
Definition: FineMesh.cpp:882
void computeDivergence(int)
Computes the divergence vector with the space discretization scheme.
Definition: FineMesh.cpp:426
int SendQ
Definition: Parameters.cpp:252
real EigenvalueX
Definition: Parameters.cpp:158
#define Max(x, y)
Definition: Carmen.h:54
real CFL
Definition: Parameters.cpp:39
void CPUExchange(FineMesh *Root, int)
Parallel function DOES NOT WORK!
Definition: Parallel.cpp:350

Here is the caller graph for this function:

void TimeEvolution ( Node Root)

Computes a time evolution on the tree structure, the root node being Root. Only for multiresolution computations.

Parameters
RootRoot node
Returns
void
20 {
21 
22  // --- Smooth data ---
23 
24  if ( SmoothCoeff != 0.)
25  Root->smooth();
26 
27  // --- Store cell-average values of leaves ---
28  Root->store();
29 
30  // --- Refresh tree structure ---
31  RefreshTree(Root);
32 
33  for (StepNo = 1; StepNo <= StepNb; StepNo++)
34  {
35  // --- Compute divergence ---
36  Root->computeDivergence();
37  // --- Runge-Kutta step ---
38  Root->RungeKutta();
39  // --- Divergence cleaning source-terms
40  Root->computeCorrection();
41 
42  }
43 
44  // --- Refresh tree structure ---
45  RefreshTree(Root);
46 
47 
48 
49  // --- Check stability ---
50  Root->checkStability();
51 
52  // --- Compute integral values ---
53  Root->computeIntegral();
54 
55  // --- Compute total number of cells and leaves ---
56 
59  //cout<<"eigen= "<<Eigenvalue<<endl;
60  // --- Compute elapsed time and adapt time step ---
64 
65  // --- Compute divergence-free correction constant
66  //ch = CFL*SpaceStep/TimeStep;
68 
69 }
void RefreshTree(Node *Root)
Refresh the tree structure, i.e. compute the cell-averages of the internal nodes by projection and th...
Definition: RefreshTree.cpp:22
real ch
Definition: Parameters.cpp:140
real EigenvalueZ
Definition: Parameters.cpp:160
int StepNo
Definition: Parameters.cpp:167
void RungeKutta()
Computes one Runge-Kutta step.
Definition: Node.cpp:2345
int LeafNb
Definition: Parameters.cpp:175
real Eigenvalue
Definition: Parameters.cpp:157
real TotalLeafNb
Definition: Parameters.cpp:176
real SmoothCoeff
Definition: Parameters.cpp:99
real SpaceStep
Definition: Parameters.cpp:156
void computeCorrection()
Computes velocity gradient (only for Navier-Stokes).
Definition: Node.cpp:2188
real ElapsedTime
Definition: Parameters.cpp:95
int StepNb
Definition: Parameters.cpp:36
int CellNb
Definition: Parameters.cpp:174
real TotalCellNb
Definition: Parameters.cpp:177
void checkStability()
Checks if the computation is numerically unstable, i.e. if one of the cell-averages is overflow...
Definition: Node.cpp:2430
real TimeStep
Definition: Parameters.cpp:40
void AdaptTimeStep()
Adapts time step when required.
Definition: AdaptTimeStep.cpp:24
void computeIntegral()
Computes integral values like e.g. flame velocity, global error, etc.
Definition: Node.cpp:2470
bool ConstantTimeStep
Definition: Parameters.cpp:94
real EigenvalueY
Definition: Parameters.cpp:159
void computeDivergence()
Computes the divergence vector with the space discretization scheme.
Definition: Node.cpp:1977
void smooth()
Deletes the details in the highest level.
Definition: Node.cpp:2874
real EigenvalueX
Definition: Parameters.cpp:158
#define Max(x, y)
Definition: Carmen.h:54
real CFL
Definition: Parameters.cpp:39
void store()
Stores cell-average values into temporary cell-average values.
Definition: Node.cpp:1913
void View ( FineMesh Root,
const char *  AverageFileName 
)

Writes the current cel–averages of the fine mesh Root into file AverageFileName. Only for finite volume computations.

Parameters
RootFine mesh
AverageFileNameFile name
Returns
void
88 {
89  char buf[256];
90  int iaux;
91 
92 
93  char CPUFileName[255];
94 #if defined PARMPI
95  sprintf(CPUFileName,"%d_%d_%d_%s",coords[0],coords[1],coords[2],AverageFileName);
96 #else
97  strcpy(CPUFileName, AverageFileName);
98 #endif
99 
100  // write header for graphic visualization
101  Root->writeHeader(CPUFileName);
102 
103  // write cell-average values for graphic visualization
104  Root->writeAverage(CPUFileName);
105 
106  // Compress data
107  if (Dimension != 1)
108  {
109  if (ZipData)
110  {
111  sprintf(buf,"gzip %s",CPUFileName);
112  iaux=system(buf);
113  }
114  }
115 
116  // --- Write time-average values into file ---
117 
118  if (TimeAveraging)
119  Root->writeTimeAverage("TimeAverage.dat");
120 
121 }
void writeTimeAverage(const char *FileName) const
Write time-averages into file FileName.
Definition: FineMesh.cpp:1835
bool TimeAveraging
Definition: Parameters.cpp:60
int coords[3]
Definition: Parameters.cpp:230
int Dimension
Definition: Parameters.cpp:74
void writeAverage(const char *FileName)
Write cell-averages for GNUplot, Data Explorer, TecPLot and VTK into file FileName.
Definition: FineMesh.cpp:1263
bool ZipData
Definition: Parameters.cpp:146
void writeHeader(const char *FileName) const
Write header for GNUplot, Data Explorer, TecPLot and VTK into file FileName.
Definition: FineMesh.cpp:1096

Here is the caller graph for this function:

void View ( Node Root,
const char *  TreeFileName,
const char *  MeshFileName,
const char *  AverageFileName 
)

Writes the data of the tree structure into files TreeFileName (tree structure), MeshFileName (mesh) and AverageFileName (cell-averages). The root node is Root. Only for multiresolution computations.

Parameters
RootRoot node
TreeFileNameTree file name
MeshFileNameMesh file name
AverageFileNameAverage file name
Returns
void
36 {
37  char buf[256];
38  int iaux;
39 
40  // write tree (debugging only)
41  if (debug) Root->writeTree(TreeFileName);
42 
43 // Root->computeCorrection();
44 
45  // write mesh for graphic visualisation
46  if (Dimension != 1)
47  {
48  Root->writeHeader(MeshFileName);
49  Root->writeAverage(MeshFileName);
50 
51  // Compress data (if parameter ZipData is true)
52  if (ZipData)
53  {
54  sprintf(buf,"gzip %s",MeshFileName);
55  iaux=system(buf);
56  }
57  }
58  else
59  Root->writeMesh(MeshFileName);
60 
61 
62  // write cell-averages in multiresolution representation (1D) or on fine grid (2-3D)
63  if (Dimension != 1)
64  {
65  Root->writeFineGrid(AverageFileName,ScaleNb+PrintMoreScales);
66 
67  // Compress data
68  if (ZipData)
69  {
70  sprintf(buf,"gzip %s",AverageFileName);
71  iaux=system(buf);
72  }
73  }
74  else
75  {
76  Root->writeHeader(AverageFileName);
77  Root->writeAverage(AverageFileName);
78  }
79 }
void writeTree(const char *FileName) const
Writes tree structure into file FileName. Only for debugging.
Definition: Node.cpp:955
int ScaleNb
Definition: Parameters.cpp:87
void writeFineGrid(const char *FileName, const int L=ScaleNb) const
Writes cell-average values on a regular grid of level L into file FileName.
Definition: Node.cpp:1174
int PrintMoreScales
Definition: Parameters.cpp:90
int Dimension
Definition: Parameters.cpp:74
void writeMesh(const char *FileName) const
Writes mesh data for Gnuplot into file FileName.
Definition: Node.cpp:1819
bool debug
Definition: Parameters.cpp:142
void writeAverage(const char *FileName)
Writes cell-average values in multiresolution representation and the corresponding mesh into file Fil...
Definition: Node.cpp:1089
void writeHeader(const char *FileName) const
Writes header for Data Explorer into file FileName.
Definition: Node.cpp:1028
bool ZipData
Definition: Parameters.cpp:146
void ViewEvery ( FineMesh Root,
int  arg 
)

Same as previous for a fine mesh Root. Only for finite volume computations.

Parameters
RootFine mesh
argargument
Returns
void
54 {
55  char AverageName[256]; // File name for AverageNNN.dat
56  char AverageFormat[256]; // File format for AverageNNN.dat
57 
58  sprintf(AverageFormat, "Average%s0%ii.vtk", "%", DigitNumber(IterationNb));
59  sprintf(AverageName, AverageFormat, arg);
60 
61  View(Root, AverageName);
62 }
int IterationNb
Definition: Parameters.cpp:37
int DigitNumber(int arg)
Returns the number of digits of the integer arg.
Definition: DigitNumber.cpp:22
void View(FineMesh *Root, const char *AverageFileName)
Writes the current cel–averages of the fine mesh Root into file AverageFileName. Only for finite volu...
Definition: View.cpp:87

Here is the caller graph for this function:

void ViewEvery ( Node Root,
int  arg 
)

Writes into file the data of the tree structure at iteration arg. The output file names are AverageNNN.dat and MeshNNN.dat, NNN being the iteration in an accurate format. The root node is Root. Only for multiresolution computations.

Parameters
RootRoot node
argArgument
Returns
void
33 {
34  char AverageName[256]; // File name for AverageNNN.dat
35  char MeshName[256]; // File name for MeshNNN.dat
36  char AverageFormat[256]; // File format for AverageNNN.dat
37  char MeshFormat[256]; // File format for MeshNNN.dat
38 
39  sprintf(AverageFormat, "Average%s0%ii.vtk", "%", DigitNumber(IterationNb));
40  sprintf(AverageName, AverageFormat, arg);
41  sprintf(MeshFormat, "Mesh%s0%ii.dat", "%", DigitNumber(IterationNb));
42  sprintf(MeshName, MeshFormat,arg);
43 
44  View(Root, "Tree.dat", MeshName, AverageName);
45 }
int IterationNb
Definition: Parameters.cpp:37
int DigitNumber(int arg)
Returns the number of digits of the integer arg.
Definition: DigitNumber.cpp:22
void View(FineMesh *Root, const char *AverageFileName)
Writes the current cel–averages of the fine mesh Root into file AverageFileName. Only for finite volu...
Definition: View.cpp:87
void ViewIteration ( FineMesh Root)

Same as previous for a fine mesh Root. Only for finite volume computations.

Parameters
RootFine mesh
Returns
void
61 {
62  if (IterationNo == PrintIt1)
63  View(Root, "Average_1.vtk");
64 
65  if (IterationNo == PrintIt2)
66  View(Root, "Average_2.vtk");
67 
68  if (IterationNo == PrintIt3)
69  View(Root, "Average_3.vtk");
70 
71  if (IterationNo == PrintIt4)
72  View(Root, "Average_4.vtk");
73 
74  if (IterationNo == PrintIt5)
75  View(Root, "Average_5.vtk");
76 
77  if (IterationNo == PrintIt6)
78  View(Root, "Average_6.vtk");
79 }
int PrintIt1
Definition: Parameters.cpp:50
int PrintIt3
Definition: Parameters.cpp:52
int PrintIt2
Definition: Parameters.cpp:51
int IterationNo
Definition: Parameters.cpp:168
int PrintIt6
Definition: Parameters.cpp:55
int PrintIt5
Definition: Parameters.cpp:54
void View(FineMesh *Root, const char *AverageFileName)
Writes the current cel–averages of the fine mesh Root into file AverageFileName. Only for finite volu...
Definition: View.cpp:87
int PrintIt4
Definition: Parameters.cpp:53

Here is the caller graph for this function:

void ViewIteration ( Node Root)

Writes into file the data of the tree structure from physical time PrintTime1 to physical time PrintTime6. The output file names are Average_N.dat and Mesh_N.dat, N being between 1 and 6. The root node is Root. Only for multiresolution computations.

Parameters
RootRoot node
Returns
void
34 {
35  if (IterationNo == PrintIt1)
36  View(Root, "Tree.dat", "Mesh_1.dat", "Average_1.vtk");
37 
38  if (IterationNo == PrintIt2)
39  View(Root, "Tree.dat", "Mesh_2.dat", "Average_2.vtk");
40 
41  if (IterationNo == PrintIt3)
42  View(Root, "Tree.dat", "Mesh_3.dat", "Average_3.vtk");
43 
44  if (IterationNo == PrintIt4)
45  View(Root, "Tree.dat", "Mesh_4.dat", "Average_4.vtkt");
46 
47  if (IterationNo == PrintIt5)
48  View(Root, "Tree.dat", "Mesh_5.dat", "Average_5.vtk");
49 
50  if (IterationNo == PrintIt6)
51  View(Root, "Tree.dat", "Mesh_6.dat", "Average_6.vtk");
52 }
int PrintIt1
Definition: Parameters.cpp:50
int PrintIt3
Definition: Parameters.cpp:52
int PrintIt2
Definition: Parameters.cpp:51
int IterationNo
Definition: Parameters.cpp:168
int PrintIt6
Definition: Parameters.cpp:55
int PrintIt5
Definition: Parameters.cpp:54
void View(FineMesh *Root, const char *AverageFileName)
Writes the current cel–averages of the fine mesh Root into file AverageFileName. Only for finite volu...
Definition: View.cpp:87
int PrintIt4
Definition: Parameters.cpp:53