Memosa-FVM  0.2
ThermalModel< T >::Impl Class Reference

#include <ThermalModel_impl.h>

Collaboration diagram for ThermalModel< T >::Impl:

Public Types

typedef Array< T > TArray
 
typedef Vector< T, 3 > VectorT3
 
typedef Array< VectorT3VectorT3Array
 
typedef Gradient< T > TGradType
 
typedef Array< Gradient< T > > TGradArray
 
typedef CRMatrix< T, T, T > T_Matrix
 

Public Member Functions

 Impl (const GeomFields &geomFields, ThermalFields &thermalFields, const MeshList &meshes)
 
void init ()
 
ThermalBCMapgetBCMap ()
 
ThermalVCMapgetVCMap ()
 
ThermalBC< T > & getBC (const int id)
 
ThermalModelOptions< T > & getOptions ()
 
void initLinearization (LinearSystem &ls)
 
void linearize (LinearSystem &ls)
 
getHeatFluxIntegral (const Mesh &mesh, const int faceGroupId)
 
void advance (const int niter)
 
void printBCs ()
 
void updateTime ()
 
void dumpMatrix (const string fileBase)
 
void computeIBFaceTemperature (const StorageSite &particles)
 

Private Attributes

const MeshList _meshes
 
const GeomFields_geomFields
 
ThermalFields_thermalFields
 
ThermalBCMap _bcMap
 
ThermalVCMap _vcMap
 
ThermalModelOptions< T > _options
 
GradientModel< T > _temperatureGradientModel
 
MFRPtr _initialNorm
 
int _niters
 

Detailed Description

template<class T>
class ThermalModel< T >::Impl

Definition at line 31 of file ThermalModel_impl.h.

Member Typedef Documentation

template<class T>
typedef CRMatrix<T,T,T> ThermalModel< T >::Impl::T_Matrix

Definition at line 39 of file ThermalModel_impl.h.

template<class T>
typedef Array<T> ThermalModel< T >::Impl::TArray

Definition at line 34 of file ThermalModel_impl.h.

template<class T>
typedef Array<Gradient<T> > ThermalModel< T >::Impl::TGradArray

Definition at line 38 of file ThermalModel_impl.h.

template<class T>
typedef Gradient<T> ThermalModel< T >::Impl::TGradType

Definition at line 37 of file ThermalModel_impl.h.

template<class T>
typedef Vector<T,3> ThermalModel< T >::Impl::VectorT3

Definition at line 35 of file ThermalModel_impl.h.

template<class T>
typedef Array<VectorT3> ThermalModel< T >::Impl::VectorT3Array

Definition at line 36 of file ThermalModel_impl.h.

Constructor & Destructor Documentation

template<class T>
ThermalModel< T >::Impl::Impl ( const GeomFields geomFields,
ThermalFields thermalFields,
const MeshList meshes 
)
inline

Definition at line 41 of file ThermalModel_impl.h.

References Model::_meshes, ThermalBC< T >::bcType, Mesh::getBoundaryFaceGroups(), Mesh::getID(), FaceGroup::groupType, FaceGroup::id, and ThermalVC< T >::vcType.

43  :
44  _meshes(meshes),
45  _geomFields(geomFields),
46  _thermalFields(thermalFields),
49  _initialNorm(),
50  _niters(0)
51  {
52  const int numMeshes = _meshes.size();
53  for (int n=0; n<numMeshes; n++)
54  {
55  const Mesh& mesh = *_meshes[n];
56  ThermalVC<T> *vc(new ThermalVC<T>());
57  vc->vcType = "flow";
58  _vcMap[mesh.getID()] = vc;
59 
60  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
61  {
62  const FaceGroup& fg = *fgPtr;
63  ThermalBC<T> *bc(new ThermalBC<T>());
64 
65  _bcMap[fg.id] = bc;
66 
67  if ((fg.groupType == "wall") ||
68  (fg.groupType == "symmetry"))
69  {
70  bc->bcType = "SpecifiedHeatFlux";
71  }
72  else if ((fg.groupType == "velocity-inlet") ||
73  (fg.groupType == "pressure-outlet"))
74  {
75  bc->bcType = "SpecifiedTemperature";
76  }
77  else
78  throw CException("ThermalModel: unknown face group type "
79  + fg.groupType);
80  }
81  }
82  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
ThermalFields & _thermalFields
Definition: Mesh.h:28
Definition: Mesh.h:49
string groupType
Definition: Mesh.h:42
GradientModel< T > _temperatureGradientModel
const int id
Definition: Mesh.h:41
Field temperatureGradient
Definition: ThermalFields.h:21
const GeomFields & _geomFields
const MeshList _meshes
int getID() const
Definition: Mesh.h:106

Member Function Documentation

template<class T>
void ThermalModel< T >::Impl::advance ( const int  niter)
inline

Definition at line 424 of file ThermalModel_impl.h.

References LinearSystem::initAssembly(), LinearSystem::initSolve(), LinearSystem::postSolve(), and LinearSystem::updateSolution().

425  {
426  for(int n=0; n<niter; n++)
427  {
428  LinearSystem ls;
429  initLinearization(ls);
430 
431  ls.initAssembly();
432 
433  linearize(ls);
434 
435  ls.initSolve();
436 
437  MFRPtr rNorm(_options.getLinearSolver().solve(ls));
438 
439  if (!_initialNorm) _initialNorm = rNorm;
440 
441  MFRPtr normRatio((*rNorm)/(*_initialNorm));
442 
443  cout << _niters << ": " << *rNorm << endl;
444 
445 
446  _options.getLinearSolver().cleanup();
447 
448  ls.postSolve();
449  ls.updateSolution();
450 
451  _niters++;
452  if (*rNorm < _options.absoluteTolerance ||
453  *normRatio < _options.relativeTolerance)
454  break;
455  }
456  }
void linearize(LinearSystem &ls)
void initAssembly()
void initLinearization(LinearSystem &ls)
void updateSolution()
void initSolve()
ThermalModelOptions< T > _options
shared_ptr< MultiFieldReduction > MFRPtr
template<class T>
void ThermalModel< T >::Impl::computeIBFaceTemperature ( const StorageSite particles)
inline

Definition at line 575 of file ThermalModel_impl.h.

References Model::_meshes, Mesh::getCells(), StorageSite::getCount(), Mesh::getIBFaces(), Mesh::isShell(), and Array< T >::zero().

576  {
577  typedef CRMatrixTranspose<T,T,T> IMatrix;
578 
579  const TArray& pT =
580  dynamic_cast<const TArray&>(_thermalFields.temperature[particles]);
581 
582  const int numMeshes = _meshes.size();
583  for (int n=0; n<numMeshes; n++)
584  {
585  const Mesh& mesh = *_meshes[n];
586  if (!mesh.isShell() && mesh.getIBFaces().getCount() > 0){
587  const StorageSite& cells = mesh.getCells();
588  const StorageSite& ibFaces = mesh.getIBFaces();
589 
590  GeomFields::SSPair key1(&ibFaces,&cells);
591  const IMatrix& mIC =
592  dynamic_cast<const IMatrix&>
594 
595  GeomFields::SSPair key2(&ibFaces,&particles);
596  const IMatrix& mIP =
597  dynamic_cast<const IMatrix&>
599 
600  shared_ptr<TArray> ibT(new TArray(ibFaces.getCount()));
601 
602  const TArray& cT =
603  dynamic_cast<const TArray&>(_thermalFields.temperature[cells]);
604 
605 
606  ibT->zero();
607 
608  mIC.multiplyAndAdd(*ibT,cT);
609  mIP.multiplyAndAdd(*ibT,pT);
610  _thermalFields.temperature.addArray(ibFaces,ibT);
611  }
612  }
613 
614  }
const StorageSite & getIBFaces() const
Definition: Mesh.h:111
ThermalFields & _thermalFields
Definition: Mesh.h:49
map< SSPair, shared_ptr< Matrix > > _interpolationMatrices
Definition: GeomFields.h:50
const StorageSite & getCells() const
Definition: Mesh.h:109
const GeomFields & _geomFields
void addArray(const StorageSite &, shared_ptr< ArrayBase > a)
Definition: Field.cpp:72
bool isShell() const
Definition: Mesh.h:323
const MeshList _meshes
int getCount() const
Definition: StorageSite.h:39
pair< const StorageSite *, const StorageSite * > SSPair
Definition: GeomFields.h:48
template<class T>
void ThermalModel< T >::Impl::dumpMatrix ( const string  fileBase)
inline

Definition at line 499 of file ThermalModel_impl.h.

References Model::_meshes, LinearSystem::getB(), Mesh::getCells(), CRConnectivity::getCol(), CRMatrix< T_Diag, T_OffDiag, X >::getConnectivity(), CRMatrix< T_Diag, T_OffDiag, X >::getDiag(), LinearSystem::getMatrix(), MultiFieldMatrix::getMatrix(), CRMatrix< T_Diag, T_OffDiag, X >::getOffDiag(), CRConnectivity::getRow(), StorageSite::getSelfCount(), LinearSystem::initAssembly(), and LinearSystem::initSolve().

500  {
501  LinearSystem ls;
502  initLinearization(ls);
503 
504  ls.initAssembly();
505 
506  linearize(ls);
507 
508  ls.initSolve();
509 
510  MultiFieldMatrix& matrix = ls.getMatrix();
511  MultiField& b = ls.getB();
512 for ( unsigned int id = 0; id < _meshes.size(); id++ ){
513  const Mesh& mesh = *_meshes[id];
514  const StorageSite& cells = mesh.getCells();
515 
517 
518  T_Matrix& tMatrix =
519  dynamic_cast<T_Matrix&>(matrix.getMatrix(tIndex,tIndex));
520 
521  TArray& tDiag = tMatrix.getDiag();
522  TArray& tCoeff = tMatrix.getOffDiag();
523 
524  TArray& rCell = dynamic_cast<TArray&>(b[tIndex]);
525 
526  const CRConnectivity& cr = tMatrix.getConnectivity();
527 
528  const Array<int>& row = cr.getRow();
529  const Array<int>& col = cr.getCol();
530 
531  const int nCells = cells.getSelfCount();
532  int nCoeffs = nCells;
533 
534  for(int i=0; i<nCells; i++)
535  for(int jp=row[i]; jp<row[i+1]; jp++)
536  {
537  const int j = col[jp];
538  if (j<nCells) nCoeffs++;
539  }
540  stringstream ss;
541  ss << id;
542  string matFileName = fileBase + "_mesh" + ss.str() + ".mat";
543 
544 
545  FILE *matFile = fopen(matFileName.c_str(),"wb");
546 
547  fprintf(matFile,"%%%%MatrixMarket matrix coordinate real general\n");
548  fprintf(matFile,"%d %d %d\n", nCells,nCells,nCoeffs);
549 
550  for(int i=0; i<nCells; i++)
551  {
552  fprintf(matFile,"%d %d %lf\n", i+1, i+1, tDiag[i]);
553  for(int jp=row[i]; jp<row[i+1]; jp++)
554  {
555  const int j = col[jp];
556  if (j<nCells)
557  fprintf(matFile,"%d %d %lf\n", i+1, j+1, tCoeff[jp]);
558  }
559  }
560 
561  fclose(matFile);
562 
563  string rhsFileName = fileBase + ".rhs";
564  FILE *rhsFile = fopen(rhsFileName.c_str(),"wb");
565 
566  for(int i=0; i<nCells; i++)
567  fprintf(rhsFile,"%lf\n",-rCell[i]);
568 
569  fclose(rhsFile);
570 
571  }
572 }
const Array< int > & getCol() const
void linearize(LinearSystem &ls)
const Array< int > & getRow() const
void initAssembly()
Matrix & getMatrix(const Index &rowIndex, const Index &colIndex)
int getSelfCount() const
Definition: StorageSite.h:40
ThermalFields & _thermalFields
Definition: Mesh.h:49
void initLinearization(LinearSystem &ls)
pair< const Field *, const StorageSite * > ArrayIndex
Definition: MultiField.h:21
void initSolve()
const StorageSite & getCells() const
Definition: Mesh.h:109
CRMatrix< T, T, T > T_Matrix
const MeshList _meshes
MultiField & getB()
Definition: LinearSystem.h:33
MultiFieldMatrix & getMatrix()
Definition: LinearSystem.h:37
template<class T>
ThermalBC<T>& ThermalModel< T >::Impl::getBC ( const int  id)
inline

Definition at line 177 of file ThermalModel_impl.h.

177 {return *_bcMap[id];}
template<class T>
ThermalBCMap& ThermalModel< T >::Impl::getBCMap ( )
inline

Definition at line 174 of file ThermalModel_impl.h.

174 {return _bcMap;}
template<class T>
T ThermalModel< T >::Impl::getHeatFluxIntegral ( const Mesh mesh,
const int  faceGroupId 
)
inline

Definition at line 400 of file ThermalModel_impl.h.

References Mesh::getBoundaryFaceGroups(), StorageSite::getCount(), FaceGroup::id, and FaceGroup::site.

401  {
402  T r(0.);
403  bool found = false;
404  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
405  {
406  const FaceGroup& fg = *fgPtr;
407  if (fg.id == faceGroupId)
408  {
409  const StorageSite& faces = fg.site;
410  const int nFaces = faces.getCount();
411  const TArray& heatFlux =
412  dynamic_cast<const TArray&>(_thermalFields.heatFlux[faces]);
413  for(int f=0; f<nFaces; f++)
414  r += heatFlux[f];
415  found=true;
416  }
417  }
418  if (!found)
419  throw CException("getHeatFluxIntegral: invalid faceGroupID");
420  return r;
421  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
ThermalFields & _thermalFields
Definition: Mesh.h:28
const int id
Definition: Mesh.h:41
int getCount() const
Definition: StorageSite.h:39
StorageSite site
Definition: Mesh.h:40
template<class T>
ThermalModelOptions<T>& ThermalModel< T >::Impl::getOptions ( )
inline

Definition at line 179 of file ThermalModel_impl.h.

179 {return _options;}
ThermalModelOptions< T > _options
template<class T>
ThermalVCMap& ThermalModel< T >::Impl::getVCMap ( )
inline

Definition at line 175 of file ThermalModel_impl.h.

175 {return _vcMap;}
template<class T>
void ThermalModel< T >::Impl::init ( )
inline

Definition at line 84 of file ThermalModel_impl.h.

References Model::_meshes, Mesh::getBoundaryFaceGroups(), Mesh::getCells(), StorageSite::getCount(), StorageSite::getCountLevel1(), Mesh::getFaces(), Mesh::getID(), Mesh::getInterfaceGroups(), and FaceGroup::site.

85  {
86  const int numMeshes = _meshes.size();
87  for (int n=0; n<numMeshes; n++)
88  {
89  const Mesh& mesh = *_meshes[n];
90 
91  const StorageSite& cells = mesh.getCells();
92  const ThermalVC<T>& vc = *_vcMap[mesh.getID()];
93 
94  //temperature
95  shared_ptr<TArray> tCell(new TArray(cells.getCountLevel1()));
96  *tCell = _options["initialTemperature"];
97  _thermalFields.temperature.addArray(cells,tCell);
98 
99  if(_options.transient)
100  {
101  _thermalFields.temperatureN1.addArray(cells, dynamic_pointer_cast<ArrayBase>(tCell->newCopy()));
102  if (_options.timeDiscretizationOrder > 1)
103  _thermalFields.temperatureN2.addArray(cells, dynamic_pointer_cast<ArrayBase>(tCell->newCopy()));
104  }
105 
106  //conductivity
107  shared_ptr<TArray> condCell(new TArray(cells.getCountLevel1()));
108  *condCell = vc["thermalConductivity"];
109  _thermalFields.conductivity.addArray(cells,condCell);
110 
111  //source
112  shared_ptr<TArray> sCell(new TArray(cells.getCountLevel1()));
113  *sCell = T(0.);
114  _thermalFields.source.addArray(cells,sCell);
115 
116  //create a zero field
117  shared_ptr<TArray> zeroCell(new TArray(cells.getCountLevel1()));
118  *zeroCell = T(0.0);
119  _thermalFields.zero.addArray(cells,zeroCell);
120 
121  //create a one field
122  shared_ptr<TArray> oneCell(new TArray(cells.getCountLevel1()));
123  *oneCell = T(1.0);
124  _thermalFields.one.addArray(cells,oneCell);
125 
126  //create specific heat field rho*Cp
127  shared_ptr<TArray> cp(new TArray(cells.getCount()));
128  *cp = vc["density"] * vc["specificHeat"];
130 
131  //initial temparature gradient array
132  shared_ptr<TGradArray> gradT(new TGradArray(cells.getCountLevel1()));
133  gradT->zero();
135 
136  //inital convection flux at faces
137 
138  const StorageSite& allFaces = mesh.getFaces();
139  shared_ptr<TArray> convFlux(new TArray(allFaces.getCount()));
140  convFlux->zero();
141  _thermalFields.convectionFlux.addArray(allFaces,convFlux);
142 
143  //heat flux at faces
144  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
145  {
146  const FaceGroup& fg = *fgPtr;
147  const StorageSite& faces = fg.site;
148 
149  shared_ptr<TArray> fluxFace(new TArray(faces.getCount()));
150 
151  fluxFace->zero();
152  _thermalFields.heatFlux.addArray(faces,fluxFace);
153 
154  }
155  foreach(const FaceGroupPtr fgPtr, mesh.getInterfaceGroups())
156  {
157  const FaceGroup& fg = *fgPtr;
158  const StorageSite& faces = fg.site;
159 
160  shared_ptr<TArray> fluxFace(new TArray(faces.getCount()));
161 
162  fluxFace->zero();
163  _thermalFields.heatFlux.addArray(faces,fluxFace);
164 
165  }
166 
167 
168  }
170  _niters =0;
171  _initialNorm = MFRPtr();
172  }
Array< Gradient< T > > TGradArray
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
ThermalFields & _thermalFields
Field convectionFlux
Definition: ThermalFields.h:24
Definition: Mesh.h:28
Field conductivity
Definition: ThermalFields.h:22
Definition: Mesh.h:49
Field specificHeat
Definition: ThermalFields.h:19
Field temperatureN2
Definition: ThermalFields.h:18
Field temperatureGradient
Definition: ThermalFields.h:21
const StorageSite & getFaces() const
Definition: Mesh.h:108
const StorageSite & getCells() const
Definition: Mesh.h:109
int getCountLevel1() const
Definition: StorageSite.h:72
ThermalModelOptions< T > _options
void addArray(const StorageSite &, shared_ptr< ArrayBase > a)
Definition: Field.cpp:72
const MeshList _meshes
int getCount() const
Definition: StorageSite.h:39
shared_ptr< MultiFieldReduction > MFRPtr
const FaceGroupList & getInterfaceGroups() const
Definition: Mesh.h:190
Field temperatureN1
Definition: ThermalFields.h:17
void syncLocal()
Definition: Field.cpp:334
int getID() const
Definition: Mesh.h:106
StorageSite site
Definition: Mesh.h:40
template<class T>
void ThermalModel< T >::Impl::initLinearization ( LinearSystem ls)
inline

Definition at line 181 of file ThermalModel_impl.h.

References Model::_meshes, MultiField::addArray(), MultiFieldMatrix::addMatrix(), Mesh::getBoundaryFaceGroups(), Mesh::getCellCells(), Mesh::getCells(), StorageSite::getCount(), Mesh::getFaceCells(), Mesh::getInterfaceGroups(), LinearSystem::getMatrix(), LinearSystem::getX(), and FaceGroup::site.

182  {
183  const int numMeshes = _meshes.size();
184  for (int n=0; n<numMeshes; n++)
185  {
186  const Mesh& mesh = *_meshes[n];
187 
188  const StorageSite& cells = mesh.getCells();
190 
191  ls.getX().addArray(tIndex,_thermalFields.temperature.getArrayPtr(cells));
192 
193  const CRConnectivity& cellCells = mesh.getCellCells();
194 
195  shared_ptr<Matrix> m(new CRMatrix<T,T,T>(cellCells));
196 
197  ls.getMatrix().addMatrix(tIndex,tIndex,m);
198 
199  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
200  {
201  const FaceGroup& fg = *fgPtr;
202  const StorageSite& faces = fg.site;
203 
205  ls.getX().addArray(fIndex,_thermalFields.heatFlux.getArrayPtr(faces));
206 
207  const CRConnectivity& faceCells = mesh.getFaceCells(faces);
208 
209  shared_ptr<Matrix> mft(new FluxJacobianMatrix<T,T>(faceCells));
210  ls.getMatrix().addMatrix(fIndex,tIndex,mft);
211 
212  shared_ptr<Matrix> mff(new DiagonalMatrix<T,T>(faces.getCount()));
213  ls.getMatrix().addMatrix(fIndex,fIndex,mff);
214  }
215 
216  foreach(const FaceGroupPtr fgPtr, mesh.getInterfaceGroups())
217  {
218  const FaceGroup& fg = *fgPtr;
219  const StorageSite& faces = fg.site;
220 
222  ls.getX().addArray(fIndex,_thermalFields.heatFlux.getArrayPtr(faces));
223 
224  const CRConnectivity& faceCells = mesh.getFaceCells(faces);
225 
226  shared_ptr<Matrix> mft(new FluxJacobianMatrix<T,T>(faceCells));
227  ls.getMatrix().addMatrix(fIndex,tIndex,mft);
228 
229  shared_ptr<Matrix> mff(new DiagonalMatrix<T,T>(faces.getCount()));
230  ls.getMatrix().addMatrix(fIndex,fIndex,mff);
231  }
232 
233  }
234  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
ThermalFields & _thermalFields
Definition: Mesh.h:28
Definition: Mesh.h:49
pair< const Field *, const StorageSite * > ArrayIndex
Definition: MultiField.h:21
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
void addMatrix(const Index &rowI, const Index &colI, shared_ptr< Matrix > m)
const MeshList _meshes
int getCount() const
Definition: StorageSite.h:39
void addArray(const ArrayIndex &aIndex, shared_ptr< ArrayBase > a)
Definition: MultiField.cpp:270
const FaceGroupList & getInterfaceGroups() const
Definition: Mesh.h:190
MultiField & getX()
Definition: LinearSystem.h:32
shared_ptr< ArrayBase > getArrayPtr(const StorageSite &)
Definition: Field.cpp:63
MultiFieldMatrix & getMatrix()
Definition: LinearSystem.h:37
StorageSite site
Definition: Mesh.h:40
template<class T>
void ThermalModel< T >::Impl::linearize ( LinearSystem ls)
inline

Definition at line 236 of file ThermalModel_impl.h.

References Model::_meshes, BaseGenericBCS< X, Diag, OffDiag >::applyInterfaceBC(), ThermalBC< T >::bcType, LinearSystem::getB(), Mesh::getBoundaryFaceGroups(), StorageSite::getCount(), Mesh::getInterfaceGroups(), LinearSystem::getMatrix(), FloatVarDict< T >::getVal(), LinearSystem::getX(), FaceGroup::id, Linearizer::linearize(), and FaceGroup::site.

237  {
239 
240  DiscrList discretizations;
241 
242  shared_ptr<Discretization>
248  discretizations.push_back(dd);
249 
250  shared_ptr<Discretization>
257  _options.useCentralDifference));
258  discretizations.push_back(cd);
259 
260 
261  shared_ptr<Discretization>
263  (_meshes,
264  _geomFields,
267  discretizations.push_back(sd);
268 
269  if (_options.transient)
270  {
271  shared_ptr<Discretization>
273  (_meshes, _geomFields,
278  _options["timeStep"]));
279  discretizations.push_back(td);
280  }
281 
282  shared_ptr<Discretization>
285 
286  discretizations.push_back(ibm);
287 
288 
289  Linearizer linearizer;
290 
291  linearizer.linearize(discretizations,_meshes,ls.getMatrix(),
292  ls.getX(), ls.getB());
293 
294  const int numMeshes = _meshes.size();
295  for (int n=0; n<numMeshes; n++)
296  {
297  const Mesh& mesh = *_meshes[n];
298 
299  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
300  {
301  const FaceGroup& fg = *fgPtr;
302  const StorageSite& faces = fg.site;
303 
304  const ThermalBC<T>& bc = *_bcMap[fg.id];
305 
306 
307  GenericBCS<T,T,T> gbc(faces,mesh,
308  _geomFields,
311  ls.getMatrix(), ls.getX(), ls.getB());
312 
313  if (bc.bcType == "SpecifiedTemperature")
314  {
316  bT(bc.getVal("specifiedTemperature"),faces);
318  {
319  const TArray& convectingFlux =
320  dynamic_cast<const TArray&>
322  const int nFaces = faces.getCount();
323 
324  for(int f=0; f<nFaces; f++)
325  {
326  if (convectingFlux[f] > 0.)
327  {
328  gbc.applyExtrapolationBC(f);
329  }
330  else
331  {
332  gbc.applyDirichletBC(f,bT[f]);
333  }
334  }
335  }
336  else
337  gbc.applyDirichletBC(bT);
338  }
339  else if (bc.bcType == "SpecifiedHeatFlux")
340  {
342  bHeatFlux(bc.getVal("specifiedHeatFlux"),faces);
343 
344  const int nFaces = faces.getCount();
345 
346  for(int f=0; f<nFaces; f++)
347  {
348  gbc.applyNeumannBC(f, bHeatFlux[f]);
349  }
350  }
351  else if (bc.bcType == "Symmetry")
352  {
353  T zeroFlux(NumTypeTraits<T>::getZero());
354  gbc.applyNeumannBC(zeroFlux);
355  }
356  else if (bc.bcType == "Convective")
357  {
358  FloatValEvaluator<T> hCoeff(bc.getVal("convectiveCoefficient"), faces);
359  FloatValEvaluator<T> Xinf(bc.getVal("farFieldTemperature"), faces);
360  const int nFaces = faces.getCount();
361  for(int f=0; f<nFaces; f++)
362  gbc.applyConvectionBC(f, hCoeff[f], Xinf[f]);
363  }
364  else if (bc.bcType == "Radiative")
365  {
366  FloatValEvaluator<T> emissivity(bc.getVal("surfaceEmissivity"), faces);
367  FloatValEvaluator<T> Xinf(bc.getVal("farFieldTemperature"), faces);
368  const int nFaces = faces.getCount();
369  for(int f=0; f<nFaces; f++)
370  gbc.applyRadiationBC(f, emissivity[f], Xinf[f]);
371  }
372  else if (bc.bcType == "Mixed")
373  {
374  FloatValEvaluator<T> hCoeff(bc.getVal("convectiveCoefficient"), faces);
375  FloatValEvaluator<T> emissivity(bc.getVal("surfaceEmissivity"), faces);
376  FloatValEvaluator<T> Xinf(bc.getVal("farFieldTemperature"), faces);
377  const int nFaces = faces.getCount();
378  for(int f=0; f<nFaces; f++)
379  gbc.applyMixedBC(f, hCoeff[f], emissivity[f], Xinf[f]);
380  }
381  else
382  throw CException(bc.bcType + " not implemented for ThermalModel");
383  }
384 
385  foreach(const FaceGroupPtr fgPtr, mesh.getInterfaceGroups())
386  {
387  const FaceGroup& fg = *fgPtr;
388  const StorageSite& faces = fg.site;
389  GenericBCS<T,T,T> gbc(faces,mesh,
390  _geomFields,
393  ls.getMatrix(), ls.getX(), ls.getB());
394 
395  gbc.applyInterfaceBC();
396  }
397  }
398  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
ThermalFields & _thermalFields
Field convectionFlux
Definition: ThermalFields.h:24
bool hasArray(const StorageSite &s) const
Definition: Field.cpp:37
Definition: Mesh.h:28
Field conductivity
Definition: ThermalFields.h:22
Definition: Mesh.h:49
Field specificHeat
Definition: ThermalFields.h:19
FloatVal< T > getVal(const string varName) const
Definition: FloatVarDict.h:85
GradientModel< T > _temperatureGradientModel
const int id
Definition: Mesh.h:41
vector< shared_ptr< Discretization > > DiscrList
Field temperatureN2
Definition: ThermalFields.h:18
Field temperatureGradient
Definition: ThermalFields.h:21
const GeomFields & _geomFields
void applyInterfaceBC(const int f) const
Definition: GenericBCS.h:325
ThermalModelOptions< T > _options
const MeshList _meshes
int getCount() const
Definition: StorageSite.h:39
MultiField & getB()
Definition: LinearSystem.h:33
string bcType
Definition: ThermalBC.h:19
const FaceGroupList & getInterfaceGroups() const
Definition: Mesh.h:190
MultiField & getX()
Definition: LinearSystem.h:32
Field temperatureN1
Definition: ThermalFields.h:17
virtual void linearize(DiscrList &discretizations, const MeshList &meshes, MultiFieldMatrix &matrix, MultiField &x, MultiField &b)
Definition: Linearizer.cpp:17
MultiFieldMatrix & getMatrix()
Definition: LinearSystem.h:37
StorageSite site
Definition: Mesh.h:40
template<class T>
void ThermalModel< T >::Impl::printBCs ( )
inline

Definition at line 458 of file ThermalModel_impl.h.

459  {
460  foreach(typename ThermalBCMap::value_type& pos, _bcMap)
461  {
462  cout << "Face Group " << pos.first << ":" << endl;
463  cout << " bc type " << pos.second->bcType << endl;
464  foreach(typename ThermalBC<T>::value_type& vp, *pos.second)
465  {
466  cout << " " << vp.first << " " << vp.second.constant << endl;
467  }
468  }
469  }
template<class T>
void ThermalModel< T >::Impl::updateTime ( )
inline

Definition at line 472 of file ThermalModel_impl.h.

References Model::_meshes, Mesh::getCells(), and StorageSite::getCountLevel1().

473  {
474  const int numMeshes = _meshes.size();
475  for (int n=0; n<numMeshes; n++) {
476 
477  const Mesh& mesh = *_meshes[n];
478  const StorageSite& cells = mesh.getCells();
479  const int nCells = cells.getCountLevel1();
480 
481  TArray& temperature =
482  dynamic_cast<TArray&>(_thermalFields.temperature[cells]);
483  TArray& temperatureN1 =
484  dynamic_cast<TArray&>(_thermalFields.temperatureN1[cells]);
485 
486  if (_options.timeDiscretizationOrder > 1)
487  {
488  TArray& temperatureN2 =
489  dynamic_cast<TArray&>(_thermalFields.temperatureN2[cells]);
490  temperatureN2 = temperatureN1;
491  }
492  temperatureN1 = temperature;
493  }
494  }
ThermalFields & _thermalFields
Definition: Mesh.h:49
Field temperatureN2
Definition: ThermalFields.h:18
const StorageSite & getCells() const
Definition: Mesh.h:109
int getCountLevel1() const
Definition: StorageSite.h:72
ThermalModelOptions< T > _options
const MeshList _meshes
Field temperatureN1
Definition: ThermalFields.h:17

Member Data Documentation

template<class T>
ThermalBCMap ThermalModel< T >::Impl::_bcMap
private

Definition at line 621 of file ThermalModel_impl.h.

template<class T>
const GeomFields& ThermalModel< T >::Impl::_geomFields
private

Definition at line 618 of file ThermalModel_impl.h.

template<class T>
MFRPtr ThermalModel< T >::Impl::_initialNorm
private

Definition at line 626 of file ThermalModel_impl.h.

template<class T>
const MeshList ThermalModel< T >::Impl::_meshes
private

Definition at line 617 of file ThermalModel_impl.h.

template<class T>
int ThermalModel< T >::Impl::_niters
private

Definition at line 627 of file ThermalModel_impl.h.

template<class T>
ThermalModelOptions<T> ThermalModel< T >::Impl::_options
private

Definition at line 623 of file ThermalModel_impl.h.

template<class T>
GradientModel<T> ThermalModel< T >::Impl::_temperatureGradientModel
private

Definition at line 624 of file ThermalModel_impl.h.

template<class T>
ThermalFields& ThermalModel< T >::Impl::_thermalFields
private

Definition at line 619 of file ThermalModel_impl.h.

template<class T>
ThermalVCMap ThermalModel< T >::Impl::_vcMap
private

Definition at line 622 of file ThermalModel_impl.h.


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