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

This computes the resistive terms of energy and magnetic field Equations. More...

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

Functions

Vector ResistiveTerms (Cell &Cell1, Cell &Cell2, Cell &Cell3, Cell &Cell4, int AxisNo)
 Returns the resistive source terms in the cell UserCell. More...
 

Detailed Description

This computes the resistive terms of energy and magnetic field Equations.

Author
Anna Karina Fontes Gomes
Version
2.0
Date
Sep-2016

Function Documentation

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: