Memosa-FVM  0.2
LinearizeInterfaceJump< X, Diag, OffDiag > Class Template Reference

#include <LinearizeInterfaceJump.h>

Collaboration diagram for LinearizeInterfaceJump< X, Diag, OffDiag >:

Public Types

typedef NumTypeTraits< X >
::T_Scalar 
T_Scalar
 
typedef CRMatrix< Diag,
OffDiag, X > 
CCMatrix
 
typedef CCMatrix::DiagArray DiagArray
 
typedef Array< T_ScalarTArray
 
typedef Array< X > XArray
 
typedef Vector< T_Scalar, 3 > VectorT3
 
typedef Array< VectorT3VectorT3Array
 
typedef SquareTensor< T_Scalar, 2 > SquareTensorT2
 

Public Member Functions

 LinearizeInterfaceJump (const T_Scalar A_coeff, const X B_coeff, Field &varField)
 
void discretize (const Mesh &mesh, const Mesh &parentMesh, const Mesh &otherMesh, MultiFieldMatrix &mfmatrix, MultiField &xField, MultiField &rField)
 

Private Attributes

Field_varField
 
const T_Scalar _A_coeff
 
const X _B_coeff
 

Detailed Description

template<class X, class Diag, class OffDiag>
class LinearizeInterfaceJump< X, Diag, OffDiag >

Definition at line 24 of file LinearizeInterfaceJump.h.

Member Typedef Documentation

template<class X, class Diag, class OffDiag>
typedef CRMatrix<Diag,OffDiag,X> LinearizeInterfaceJump< X, Diag, OffDiag >::CCMatrix

Definition at line 28 of file LinearizeInterfaceJump.h.

template<class X, class Diag, class OffDiag>
typedef CCMatrix::DiagArray LinearizeInterfaceJump< X, Diag, OffDiag >::DiagArray

Definition at line 29 of file LinearizeInterfaceJump.h.

template<class X, class Diag, class OffDiag>
typedef SquareTensor<T_Scalar,2> LinearizeInterfaceJump< X, Diag, OffDiag >::SquareTensorT2

Definition at line 34 of file LinearizeInterfaceJump.h.

template<class X, class Diag, class OffDiag>
typedef NumTypeTraits<X>::T_Scalar LinearizeInterfaceJump< X, Diag, OffDiag >::T_Scalar

Definition at line 27 of file LinearizeInterfaceJump.h.

template<class X, class Diag, class OffDiag>
typedef Array<T_Scalar> LinearizeInterfaceJump< X, Diag, OffDiag >::TArray

Definition at line 30 of file LinearizeInterfaceJump.h.

template<class X, class Diag, class OffDiag>
typedef Vector<T_Scalar,3> LinearizeInterfaceJump< X, Diag, OffDiag >::VectorT3

Definition at line 32 of file LinearizeInterfaceJump.h.

template<class X, class Diag, class OffDiag>
typedef Array<VectorT3> LinearizeInterfaceJump< X, Diag, OffDiag >::VectorT3Array

Definition at line 33 of file LinearizeInterfaceJump.h.

template<class X, class Diag, class OffDiag>
typedef Array<X> LinearizeInterfaceJump< X, Diag, OffDiag >::XArray

Definition at line 31 of file LinearizeInterfaceJump.h.

Constructor & Destructor Documentation

template<class X, class Diag, class OffDiag>
LinearizeInterfaceJump< X, Diag, OffDiag >::LinearizeInterfaceJump ( const T_Scalar  A_coeff,
const X  B_coeff,
Field varField 
)
inline

Definition at line 37 of file LinearizeInterfaceJump.h.

39  :
40  _varField(varField),
41  _A_coeff(A_coeff),
42  _B_coeff(B_coeff)
43  {}

Member Function Documentation

template<class X, class Diag, class OffDiag>
void LinearizeInterfaceJump< X, Diag, OffDiag >::discretize ( const Mesh mesh,
const Mesh parentMesh,
const Mesh otherMesh,
MultiFieldMatrix mfmatrix,
MultiField xField,
MultiField rField 
)
inline

Definition at line 46 of file LinearizeInterfaceJump.h.

References LinearizeInterfaceJump< X, Diag, OffDiag >::_A_coeff, LinearizeInterfaceJump< X, Diag, OffDiag >::_B_coeff, LinearizeInterfaceJump< X, Diag, OffDiag >::_varField, Mesh::getCellCells(), Mesh::getCells(), CRMatrix< T_Diag, T_OffDiag, X >::getCoeff(), StorageSite::getCount(), CRMatrix< T_Diag, T_OffDiag, X >::getDiag(), Mesh::getFaceCells(), MultiFieldMatrix::getMatrix(), Mesh::getOtherFaceGroupSite(), Mesh::getParentFaceGroupSite(), and StorageSite::getSelfCount().

Referenced by SpeciesModel< T >::Impl::linearize(), ElectricModel< T >::Impl::linearizeElectroStatics(), BatteryModel< T >::Impl::linearizePC(), BatteryModel< T >::Impl::linearizePC_Thermal(), BatteryModel< T >::Impl::linearizePotential(), BatteryModel< T >::Impl::linearizeSpecies(), and BatteryModel< T >::Impl::linearizeThermal().

49  {
50  const StorageSite& cells = mesh.getCells();
51  const StorageSite& faces = mesh.getParentFaceGroupSite();
52  const MultiField::ArrayIndex cVarIndex(&_varField,&cells);
53 
54  CCMatrix& matrix = dynamic_cast<CCMatrix&>(mfmatrix.getMatrix(cVarIndex,cVarIndex));
55 
56  const XArray& xCell = dynamic_cast<const XArray&>(xField[cVarIndex]);
57 
58  const CRConnectivity& cellCells = mesh.getCellCells();
59 
60  XArray& rCell = dynamic_cast<XArray&>(rField[cVarIndex]);
61 
62  DiagArray& diag = matrix.getDiag();
63 
64  // In the following, parent is assumed to be on the left, and
65  // the other mesh is assumed to be on the right when implimenting
66  // the (Phi_R = A*Phi_L + B) equation
67 
68  // parent mesh info
69  const CRConnectivity& parentFaceCells = parentMesh.getFaceCells(faces);
70  const StorageSite& parentCells = parentMesh.getCells();
71  const MultiField::ArrayIndex cVarIndexParent(&_varField,&parentCells);
72  XArray& rParentCell = dynamic_cast<XArray&>(rField[cVarIndexParent]);
73  CCMatrix& parentmatrix = dynamic_cast<CCMatrix&>(mfmatrix.getMatrix(cVarIndexParent,cVarIndexParent));
74  DiagArray& parentdiag = parentmatrix.getDiag();
75 
76  // other mesh info
77  const StorageSite& otherFaces = mesh.getOtherFaceGroupSite();
78  const CRConnectivity& otherFaceCells = otherMesh.getFaceCells(otherFaces);
79  const StorageSite& otherCells = otherMesh.getCells();
80  const MultiField::ArrayIndex cVarIndexOther(&_varField,&otherCells);
81  XArray& rOtherCell = dynamic_cast<XArray&>(rField[cVarIndexOther]);
82  CCMatrix& othermatrix = dynamic_cast<CCMatrix&>(mfmatrix.getMatrix(cVarIndexOther,cVarIndexOther));
83  DiagArray& otherdiag = othermatrix.getDiag();
84 
85  for (int f=0; f<faces.getCount(); f++)
86  {
87  //get parent mesh fluxes and coeffs
88  int c0p = parentFaceCells(f,0);
89  int c1p = parentFaceCells(f,1);
90  if (c1p < parentCells.getSelfCount())
91  {
92  // c0 is ghost cell and c1 is boundry cell, so swap cell numbers
93  // so that c1p refers to the ghost cell in the following
94  int temp = c0p;
95  c0p = c1p;
96  c1p = temp;
97  }
98 
99  const X leftFlux = rParentCell[c1p]; // inward shell flux on the left
100  const OffDiag dRC0dXC3 = parentmatrix.getCoeff(c1p, c0p);
101  const Diag dRC0dXC0 = parentdiag[c1p];
102 
103  //get other mesh fluxes and coeffs
104  int c0o = otherFaceCells(f,0);
105  int c1o = otherFaceCells(f,1);
106  if (c1o < otherCells.getSelfCount())
107  {
108  // c0 is ghost cell and c1 is boundry cell, so swap cell numbers
109  // so that c1o refers to the ghost cell in the following
110  int temp = c0o;
111  c0o = c1o;
112  c1o = temp;
113  }
114 
115  const X rightFlux = rOtherCell[c1o]; // inward shell flux on the right
116  const OffDiag dRC0dXC2 = othermatrix.getCoeff(c1o, c0o);
117  const OffDiag dRC0dXC1 = otherdiag[c1o];
118 
119 
120  //now put flux information from meshes into shell cells
121  const int c0 = f;
122  const int c1 = cellCells(f,0);
123  const int c2 = cellCells(f,1);
124  const int c3 = cellCells(f,2);
125 
126  // left shell cell - 3 neighbors
127  OffDiag& offdiagC0_C1 = matrix.getCoeff(c0, c1);
128  OffDiag& offdiagC0_C2 = matrix.getCoeff(c0, c2);
129  OffDiag& offdiagC0_C3 = matrix.getCoeff(c0, c3);
130 
131  rCell[c0] = rightFlux + leftFlux;
132  offdiagC0_C1 = dRC0dXC1;
133  offdiagC0_C3 = dRC0dXC3;
134  offdiagC0_C2 = dRC0dXC2;
135  diag[c0] = dRC0dXC0;
136 
137  // right shell cell - 1 neighbor
138  OffDiag& offdiagC1_C0 = matrix.getCoeff(c1, c0);
139 
140  rCell[c1] = _A_coeff*xCell[c0] + _B_coeff - xCell[c1];
143 
144  // set other coeffs to zero for right shell cell
145  OffDiag& offdiagC1_C2 = matrix.getCoeff(c1, c2);
146  OffDiag& offdiagC1_C3 = matrix.getCoeff(c1, c3);
147  offdiagC1_C2 = NumTypeTraits<OffDiag>::getZero();
148  offdiagC1_C3 = NumTypeTraits<OffDiag>::getZero();
149 
150  if (c0==0)
151  {
152  cout << xCell[c0] << " " << xCell[c1] << " " << xCell[c2] << " " << xCell[c3] << endl;
153  }
154 
155  }
156 
157  }
Matrix & getMatrix(const Index &rowIndex, const Index &colIndex)
int getSelfCount() const
Definition: StorageSite.h:40
const StorageSite & getParentFaceGroupSite() const
Definition: Mesh.h:329
CCMatrix::DiagArray DiagArray
const StorageSite & getOtherFaceGroupSite() const
Definition: Mesh.h:332
pair< const Field *, const StorageSite * > ArrayIndex
Definition: MultiField.h:21
CRMatrix< Diag, OffDiag, X > CCMatrix
const CRConnectivity & getCellCells() const
Definition: Mesh.cpp:480
const StorageSite & getCells() const
Definition: Mesh.h:109
const CRConnectivity & getFaceCells(const StorageSite &site) const
Definition: Mesh.cpp:388
int getCount() const
Definition: StorageSite.h:39

Member Data Documentation

template<class X, class Diag, class OffDiag>
const T_Scalar LinearizeInterfaceJump< X, Diag, OffDiag >::_A_coeff
private
template<class X, class Diag, class OffDiag>
const X LinearizeInterfaceJump< X, Diag, OffDiag >::_B_coeff
private
template<class X, class Diag, class OffDiag>
Field& LinearizeInterfaceJump< X, Diag, OffDiag >::_varField
private

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