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

#include <BatteryFixInterfaceGhost.h>

Collaboration diagram for BatteryFixInterfaceGhost< 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
 

Public Member Functions

 BatteryFixInterfaceGhost (const MeshList &meshes, GeomFields &geomFields, Field &varField, Field &diffusivityField)
 
void fixInterfaces ()
 

Private Attributes

GeomFields_geomFields
 
Field_varField
 
Field_diffusivityField
 
const MeshList_meshes
 

Detailed Description

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

Definition at line 24 of file BatteryFixInterfaceGhost.h.

Member Typedef Documentation

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

Definition at line 28 of file BatteryFixInterfaceGhost.h.

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

Definition at line 29 of file BatteryFixInterfaceGhost.h.

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

Definition at line 27 of file BatteryFixInterfaceGhost.h.

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

Definition at line 30 of file BatteryFixInterfaceGhost.h.

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

Definition at line 32 of file BatteryFixInterfaceGhost.h.

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

Definition at line 33 of file BatteryFixInterfaceGhost.h.

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

Definition at line 31 of file BatteryFixInterfaceGhost.h.

Constructor & Destructor Documentation

template<class X, class Diag, class OffDiag>
BatteryFixInterfaceGhost< X, Diag, OffDiag >::BatteryFixInterfaceGhost ( const MeshList meshes,
GeomFields geomFields,
Field varField,
Field diffusivityField 
)
inline

Definition at line 36 of file BatteryFixInterfaceGhost.h.

39  :
40  _meshes(meshes),
41  _geomFields(geomFields),
42  _varField(varField),
43  _diffusivityField(diffusivityField)
44  {}

Member Function Documentation

template<class X, class Diag, class OffDiag>
void BatteryFixInterfaceGhost< X, Diag, OffDiag >::fixInterfaces ( )
inline

Definition at line 47 of file BatteryFixInterfaceGhost.h.

References BatteryFixInterfaceGhost< X, Diag, OffDiag >::_diffusivityField, BatteryFixInterfaceGhost< X, Diag, OffDiag >::_geomFields, BatteryFixInterfaceGhost< X, Diag, OffDiag >::_meshes, BatteryFixInterfaceGhost< X, Diag, OffDiag >::_varField, GeomFields::coordinate, Mesh::getCellCells(), Mesh::getCells(), StorageSite::getCount(), Mesh::getFaceCells(), Mesh::getOtherFaceGroupSite(), Mesh::getOtherMeshID(), Mesh::getParentFaceGroupSite(), Mesh::getParentMeshID(), StorageSite::getSelfCount(), Mesh::isConnectedShell(), and Mesh::isDoubleShell().

Referenced by BatteryModel< T >::Impl::linearizeSpecies().

48  {
49 
50  // this function edits the interface ghost cells when an unconnected
51  // doubleShell is present at that interface. It does 3 things:
52  //
53  // 1) changes the interface ghost cell's centroid to that of the interface
54  // instead of the interior cell of the adjacent mesh to which it is connected
55  // through the scatter/gather map that we want to remain intact.
56  // 2) copies the diffusivity from the interior cell to the interface ghost cell
57  // instead of the diffusivity that the ghost cell picked up from the adjacent mesh
58  // 3) copies in interface values being stored in the doubleShell mesh to the
59  // interface ghost cells instead of them holding the value from the interior
60  // cell of the adjacent mesh.
61 
62  cout << "BATTERY FIX INTEFACE GHOST" << endl;
63 
64  const int numMeshes = _meshes.size();
65 
66  for (int n=0; n<numMeshes; n++)
67  {
68  const Mesh& mesh = *_meshes[n];
69 
70  //only do process if it is an unconnected doubleShell
71  if ((mesh.isDoubleShell())&&(!(mesh.isConnectedShell())))
72  {
73  const StorageSite& cells = mesh.getCells();
74  const CRConnectivity& cellCells = mesh.getCellCells();
75  const XArray& varCell = dynamic_cast<const XArray&>(_varField[cells]);
76 
77  const int parentMeshID = mesh.getParentMeshID();
78  const Mesh& parentMesh = *_meshes[parentMeshID];
79  const StorageSite& parentFaces = mesh.getParentFaceGroupSite();
80  const CRConnectivity& parentFaceCells = parentMesh.getFaceCells(parentFaces);
81  const StorageSite& parentCells = parentMesh.getCells();
82  VectorT3Array& parentCellCentroid = dynamic_cast<VectorT3Array&>(_geomFields.coordinate[parentCells]);
83  VectorT3Array& parentFaceCentroid = dynamic_cast<VectorT3Array&>(_geomFields.coordinate[parentFaces]);
84  TArray& diffusivityParent = dynamic_cast<TArray&>(_diffusivityField[parentCells]);
85  XArray& varCellParent = dynamic_cast<XArray&>(_varField[parentCells]);
86 
87 
88  const int otherMeshID = mesh.getOtherMeshID();
89  const Mesh& otherMesh = *_meshes[otherMeshID];
90  const StorageSite& otherFaces = mesh.getOtherFaceGroupSite();
91  const CRConnectivity& otherFaceCells = otherMesh.getFaceCells(otherFaces);
92  const StorageSite& otherCells = otherMesh.getCells();
93  VectorT3Array& otherCellCentroid = dynamic_cast<VectorT3Array&>(_geomFields.coordinate[otherCells]);
94  VectorT3Array& otherFaceCentroid = dynamic_cast<VectorT3Array&>(_geomFields.coordinate[otherFaces]);
95  TArray& diffusivityOther = dynamic_cast<TArray&>(_diffusivityField[otherCells]);
96  XArray& varCellOther = dynamic_cast<XArray&>(_varField[otherCells]);
97 
98 
99  for (int f=0; f<parentFaces.getCount(); f++)
100  {
101  int c0p = parentFaceCells(f,0);
102  int c1p = parentFaceCells(f,1);
103  if (c1p < parentCells.getSelfCount())
104  {
105  // c0 is ghost cell and c1 is boundry cell, so swap cell numbers
106  // so that c1p refers to the ghost cell in the following
107  int temp = c0p;
108  c0p = c1p;
109  c1p = temp;
110  }
111  //cout << "Parent: " << c1p << " " << (parentCellCentroid[c1p])[0] << " " << (parentFaceCentroid[f])[0] << endl;
112 
113  // change centroid
114  parentCellCentroid[c1p] = parentFaceCentroid[f];
115 
116  // copy diffusivity from interior cell to ghost
117  // (instead of diff picked up from other mesh during sync)
118  diffusivityParent[c1p] = diffusivityParent[c0p];
119 
120  // copy solution variable value from shell to ghost cell
121  const int c0 = f;
122  varCellParent[c1p] = varCell[c0];
123 
124  }
125 
126  for (int f=0; f<otherFaces.getCount(); f++)
127  {
128  //get other mesh fluxes and coeffs
129  int c0o = otherFaceCells(f,0);
130  int c1o = otherFaceCells(f,1);
131  if (c1o < otherCells.getSelfCount())
132  {
133  // c0 is ghost cell and c1 is boundry cell, so swap cell numbers
134  // so that c1o refers to the ghost cell in the following
135  int temp = c0o;
136  c0o = c1o;
137  c1o = temp;
138  }
139 
140  //cout << "Other: " << c1o << " " << (otherCellCentroid[c1o])[0] << " " << (otherFaceCentroid[f])[0] << endl;
141 
142  // change centroid
143  otherCellCentroid[c1o] = otherFaceCentroid[f];
144 
145  // copy diffusivity from interior cell to ghost
146  // (instead of diff picked up from other mesh during sync)
147  diffusivityOther[c1o] = diffusivityOther[c0o];
148 
149  // copy solution variable value from shell to ghost cell
150  const int c1 = cellCells(f,0);
151  varCellOther[c1o] = varCell[c1];
152  }
153 
154  }
155  }
156 
157  //output for two material 54 cell case to check centroid changes
158  if (0)
159  {
160  for (int n=0; n<numMeshes; n++)
161  {
162  const Mesh& mesh = *_meshes[n];
163  const StorageSite& cells = mesh.getCells();
164 
165  const int nCells = cells.getCount();
166 
167  VectorT3Array& cellCentroid = dynamic_cast<VectorT3Array&>(_geomFields.coordinate[cells]);
168 
169  cout << "Mesh: " << n << endl;
170  for (int c=0; c<nCells; c++)
171  {
172  if (((cellCentroid[c])[2] < -3.33)&&((cellCentroid[c])[2] > -3.34))
173  cout << c << ": " << (cellCentroid[c])[0] << " " << (cellCentroid[c])[1] << endl;
174  }
175  }
176  }
177 
178  }
bool isDoubleShell() const
Definition: Mesh.h:324
int getSelfCount() const
Definition: StorageSite.h:40
Field coordinate
Definition: GeomFields.h:19
const StorageSite & getParentFaceGroupSite() const
Definition: Mesh.h:329
bool isConnectedShell() const
Definition: Mesh.h:325
Definition: Mesh.h:49
int getOtherMeshID() const
Definition: Mesh.h:327
const StorageSite & getOtherFaceGroupSite() const
Definition: Mesh.h:332
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 getParentMeshID() const
Definition: Mesh.h:326
int getCount() const
Definition: StorageSite.h:39

Member Data Documentation

template<class X, class Diag, class OffDiag>
Field& BatteryFixInterfaceGhost< X, Diag, OffDiag >::_diffusivityField
private
template<class X, class Diag, class OffDiag>
GeomFields& BatteryFixInterfaceGhost< X, Diag, OffDiag >::_geomFields
private
template<class X, class Diag, class OffDiag>
const MeshList& BatteryFixInterfaceGhost< X, Diag, OffDiag >::_meshes
private
template<class X, class Diag, class OffDiag>
Field& BatteryFixInterfaceGhost< X, Diag, OffDiag >::_varField
private

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