Memosa-FVM  0.2
COMETBoundary.h
Go to the documentation of this file.
1 // This file os part of FVM
2 // Copyright (c) 2012 FVM Authors
3 // See LICENSE file for terms.
4 
5 #ifndef _COMETBOUNDARY_H_
6 #define _COMETBOUNDARY_H_
7 
8 #include "Mesh.h"
9 #include <math.h>
10 #include "NumType.h"
11 #include "Array.h"
12 #include "Vector.h"
13 #include "Field.h"
14 #include "StorageSite.h"
15 #include "CRConnectivity.h"
16 #include "GeomFields.h"
17 #include "pmode.h"
18 #include "Kspace.h"
19 #include "kvol.h"
20 #include "SquareTensor.h"
21 #include "GradientModel.h"
22 #include "FluxLimiters.h"
23 
24 template<class T>
26 {
27  public :
28 
34  typedef Kspace<T> Tkspace;
35  typedef kvol<T> Tkvol;
36  typedef pmode<T> Tmode;
37  typedef typename Tmode::Refl_pair Refl_pair;
42 
43  COMETBoundary(const StorageSite& faces,
44  const Mesh& mesh,
45  const GeomFields& geomFields,
46  Tkspace& kspace,
48  const int fg_id):
49  _faces(faces),
50  _cells(mesh.getCells()),
51  _faceCells(mesh.getFaceCells(_faces)),
52  _cellCells(mesh.getCellCells()),
53  _faceArea(dynamic_cast<const VectorT3Array&>(geomFields.area[_faces])),
54  _cellCoords(dynamic_cast<const VectorT3Array&>(geomFields.coordinate[_cells])),
55  _kspace(kspace),
56  _eArray(kspace.geteArray()),
57  _geomFields(geomFields),
58  _mesh(mesh)
59  {}
60 
62  {
63 
65 
66  for (int j=0; j<_faces.getCount();j++)
67  {
68  applyTemperatureWallFine(j, bTemp[j], gradMatrix);
69  }
70  }
71 
73  {
74  for (int j=0; j<_faces.getCount();j++)
75  {
76  applyTemperatureWallCoarse(j, bTemp[j]);
77  }
78  }
79 
80  void applyTemperatureWallFine(int f, const T Twall, const GradMatrix& gMat) const
81  {
82 
83  const int c0 = _faceCells(f,0);
84  const int c1 = _faceCells(f,1);
85 
86  const int neibcount=_cellCells.getCount(c0);
87 
88  const VectorT3Array& faceCoords=
89  dynamic_cast<const VectorT3Array&>(_geomFields.coordinate[_faces]);
90 
91  GradArray Grads(_kspace.gettotmodes());
92  Grads.zero();
93  TArray pointMin(_kspace.gettotmodes());
94  pointMin=-1;
95  TArray pointMax(_kspace.gettotmodes());
96  pointMax.zero();
97  TArray pointLim(_kspace.gettotmodes());
98  pointLim=100;
99 
100  VectorT3 Gcoeff;
101 
102  for(int j=0;j<neibcount;j++) //first loop to get grad and max/min vals
103  {
104  const int cell1=_cellCells(c0,j);
105  const VectorT3 Gcoeff=gMat.getCoeff(c0, cell1);
106 
107  int c0ind=_kspace.getGlobalIndex(c0,0);
108  int c1ind=_kspace.getGlobalIndex(cell1,0);
109 
110  for(int k=0;k<_kspace.gettotmodes();k++)
111  {
112  const T e1=_eArray[c1ind];
113  const T e0=_eArray[c0ind];
114  T& curMax=pointMax[k];
115  T& curMin=pointMin[k];
116  Grads[k].accumulate(Gcoeff, e1-e0);
117 
118  if(e1>curMax)
119  curMax=e1;
120 
121  if(curMin==-1)
122  curMin=e1;
123  else
124  {
125  if(e1<curMin)
126  curMin=e1;
127  }
128 
129  c0ind++;
130  c1ind++;
131  }
132  }
133 
134  const StorageSite& allFaces(_mesh.getFaces());
135  const VectorT3Array& allFaceCoords=
136  dynamic_cast<const VectorT3Array&>(_geomFields.coordinate[allFaces]);
137  const CRConnectivity& cellFaces(_mesh.getCellFaces());
138 
139  for(int j=0;j<neibcount;j++) //second loop to calculate limiting coeff
140  {
141  const int f1(cellFaces(c0,j));
142  const VectorT3 dr0(allFaceCoords[f1]-_cellCoords[c0]);
143  int c0ind=_kspace.getGlobalIndex(c0,0);
144  //vanLeer lf;
145 
146  for(int k=0;k<_kspace.gettotmodes();k++)
147  {
148  const T minVal=pointMin[k];
149  const T maxVal=pointMax[k];
150  const T de0(Grads[k]*dr0);
151  T& cl=pointLim[k];
152  //computeLimitCoeff(cl, _eArray[c0ind], de0, minVal, maxVal, lf);
153  c0ind++;
154  }
155  }
156 
157  int numK=_kspace.getlength();
158 
159  VectorT3 rVec=_cellCoords[c1]-_cellCoords[c0];
160  VectorT3 fVec=faceCoords[f]-_cellCoords[c0];
161 
162  for (int k=0;k<numK;k++)
163  {
164  Tkvol& kv=_kspace.getkvol(k);
165  int numM=kv.getmodenum();
166 
167  for (int m=0;m<numM;m++)
168  {
169  Tmode& mode=kv.getmode(m);
170  VectorT3 vg = mode.getv();
171  const int index=mode.getIndex()-1;
172  const VectorT3 en = _faceArea[f];
173  const T vg_dot_en = vg[0]*en[0]+vg[1]*en[1]+vg[2]*en[2];
174  const int c0ind=_kspace.getGlobalIndex(c0,index);
175  const int c1ind=_kspace.getGlobalIndex(c1,index);
176  const GradType& grad=Grads[index];
177 
178  if (vg_dot_en > T_Scalar(0.0))
179  {
180  const T SOU=(fVec[0]*grad[0]+fVec[1]*grad[1]+
181  fVec[2]*grad[2])*pointLim[index];
182  _eArray[c1ind]=_eArray[c0ind]+SOU;
183  }
184  else
185  _eArray[c1ind]=mode.calce0(Twall);
186  }
187  }
188  }
189 
190  void applyTemperatureWallCoarse(int f,const T Twall) const
191  {
192 
193  const int c0 = _faceCells(f,0);
194  const int c1 = _faceCells(f,1);
195 
196  int numK=_kspace.getlength();
197 
198  for (int k=0;k<numK;k++)
199  {
200  Tkvol& kv=_kspace.getkvol(k);
201  int numM=kv.getmodenum();
202 
203  for (int m=0;m<numM;m++)
204  {
205  Tmode& mode=kv.getmode(m);
206  VectorT3 vg = mode.getv();
207  const int index=mode.getIndex()-1;
208  const VectorT3 en = _faceArea[f];
209  const T vg_dot_en = vg[0]*en[0]+vg[1]*en[1]+vg[2]*en[2];
210  const int c0ind=_kspace.getGlobalIndex(c0,index);
211  const int c1ind=_kspace.getGlobalIndex(c1,index);
212 
213  if (vg_dot_en > T_Scalar(0.0))
214  {
215  _eArray[c1ind]=_eArray[c0ind];
216  }
217  else
218  _eArray[c1ind]=mode.calce0(Twall);
219  }
220  }
221  }
222 
223  protected:
224 
234  const Mesh& _mesh;
235 };
236 
237 #endif
pair< Reflection, Reflection > Refl_pair
Definition: pmode.h:29
int getCount(const int i) const
virtual void zero()
Definition: Array.h:281
void applyTemperatureWallCoarse(int f, const T Twall) const
Field coordinate
Definition: GeomFields.h:19
Array< GradType > GradArray
Definition: COMETBoundary.h:39
Tvec getv()
Definition: pmode.h:59
Definition: Kspace.h:28
Tkspace & _kspace
GradModelType::GradMatrixType GradMatrix
Definition: COMETBoundary.h:41
T calce0(T Tl)
Definition: pmode.h:88
const VectorT3Array & _cellCoords
Tkvol & getkvol(int n) const
Definition: Kspace.h:390
Tmode & getmode(int n) const
Definition: kvol.h:44
int getlength() const
Definition: Kspace.h:391
Gradient< T > GradType
Definition: COMETBoundary.h:38
Vector< T_Scalar, 3 > VectorT3
Definition: COMETBoundary.h:32
COMETBoundary(const StorageSite &faces, const Mesh &mesh, const GeomFields &geomFields, Tkspace &kspace, COMETModelOptions< T > &opts, const int fg_id)
Definition: COMETBoundary.h:43
Kspace< T > Tkspace
Definition: COMETBoundary.h:34
Definition: Mesh.h:49
kvol< T > Tkvol
Definition: COMETBoundary.h:35
int getmodenum()
Definition: kvol.h:43
Coord & getCoeff(const int i, const int j)
Array< int > IntArray
Definition: COMETBoundary.h:30
void applyTemperatureWallFine(FloatValEvaluator< T > &bTemp) const
Definition: COMETBoundary.h:61
Array< VectorT3 > VectorT3Array
Definition: COMETBoundary.h:33
const CRConnectivity & getCellFaces() const
Definition: Mesh.cpp:454
const Mesh & _mesh
int getIndex()
Definition: pmode.h:73
void applyTemperatureWallCoarse(FloatValEvaluator< T > &bTemp) const
Definition: COMETBoundary.h:72
int getGlobalIndex(const int cell, const int count)
Definition: Kspace.h:1216
Tmode::Refl_pair Refl_pair
Definition: COMETBoundary.h:37
const VectorT3Array & _faceArea
const GeomFields & _geomFields
const StorageSite & getFaces() const
Definition: Mesh.h:108
void applyTemperatureWallFine(int f, const T Twall, const GradMatrix &gMat) const
Definition: COMETBoundary.h:80
const CRConnectivity & _faceCells
const StorageSite & _faces
pmode< T > Tmode
Definition: COMETBoundary.h:36
GradientModel< T > GradModelType
Definition: COMETBoundary.h:40
NumTypeTraits< T >::T_Scalar T_Scalar
Definition: COMETBoundary.h:29
static GradMatrixType & getGradientMatrix(const Mesh &mesh, const GeomFields &geomFields)
TArray & _eArray
int gettotmodes()
Definition: Kspace.h:393
const StorageSite & _cells
int getCount() const
Definition: StorageSite.h:39
const CRConnectivity & _cellCells
Definition: pmode.h:18
Definition: kvol.h:14
Array< T_Scalar > TArray
Definition: COMETBoundary.h:31