Memosa-FVM  0.2
PhononModel< T > Class Template Reference

#include <PhononModel.h>

Inheritance diagram for PhononModel< T >:
Collaboration diagram for PhononModel< T >:

Public Types

typedef NumTypeTraits< T >
::T_Scalar 
T_Scalar
 
typedef Vector< T_Scalar, 3 > VectorT3
 
typedef Array< VectorT3VectorT3Array
 
typedef shared_ptr< VectorT3ArrayT3ptr
 
typedef Kspace< T > Tkspace
 
typedef kvol< T > Tkvol
 
typedef pmode< T > Tmode
 
typedef Array< T > Tarray
 
typedef shared_ptr< TarrayTarrptr
 
typedef map< int, PhononBC< T > * > PhononBCMap
 
typedef Tmode::Mode_ptr Mode_ptr
 
typedef Tmode::Reflection Reflection
 
typedef Tmode::Reflptr Reflptr
 
typedef Tmode::Refl_pair Refl_pair
 
typedef Tmode::Refl_Map Refl_Map
 
typedef Array< int > BCcellArray
 
typedef shared_ptr< BCcellArrayBCellPtr
 
typedef vector< BCellPtrBCcellList
 
typedef Array< bool > BCfaceArray
 
typedef shared_ptr< BCfaceArrayBfacePtr
 
typedef vector< BfacePtrBCfaceList
 

Public Member Functions

 PhononModel (const MeshList &meshes, const GeomFields &geomFields, Tkspace &kspace, PhononMacro &macro)
 
PhononModelOptions< T > & getOptions ()
 
PhononBCMapgetBCs ()
 
void init ()
 
void callBoundaryConditions ()
 
void updateTL ()
 
void COMETupdateTL ()
 
void updatee0 ()
 
void updateHeatFlux ()
 
void initPhononModelLinearization (LinearSystem &ls, Tmode &mode)
 
void linearizePhononModel (LinearSystem &ls, Tmode &mode)
 
bool advance (const int niter)
 
void printTemp ()
 
HeatFluxIntegral (const Mesh &mesh, const int faceGroupId)
 
int getIters ()
 
- Public Member Functions inherited from Model
 Model (const MeshList &meshes)
 
virtual ~Model ()
 
 DEFINE_TYPENAME ("Model")
 
virtual map< string,
shared_ptr< ArrayBase > > & 
getPersistenceData ()
 
virtual void restart ()
 

Private Attributes

const GeomFields_geomFields
 
Tkspace_kspace
 
PhononMacro_macro
 
PhononModelOptions< T > _options
 
PhononBCMap _bcMap
 
MFRPtr _initialnorm
 
int _niters
 
BCcellList _BCells
 
BCfaceList _BFaces
 

Additional Inherited Members

- Protected Attributes inherited from Model
const MeshList _meshes
 
StorageSiteList _varSites
 
StorageSiteList _fluxSites
 
map< string, shared_ptr
< ArrayBase > > 
_persistenceData
 

Detailed Description

template<class T>
class PhononModel< T >

Definition at line 32 of file PhononModel.h.

Member Typedef Documentation

template<class T >
typedef Array<int> PhononModel< T >::BCcellArray

Definition at line 52 of file PhononModel.h.

template<class T >
typedef vector<BCellPtr> PhononModel< T >::BCcellList

Definition at line 54 of file PhononModel.h.

template<class T >
typedef shared_ptr<BCcellArray> PhononModel< T >::BCellPtr

Definition at line 53 of file PhononModel.h.

template<class T >
typedef Array<bool> PhononModel< T >::BCfaceArray

Definition at line 55 of file PhononModel.h.

template<class T >
typedef vector<BfacePtr> PhononModel< T >::BCfaceList

Definition at line 57 of file PhononModel.h.

template<class T >
typedef shared_ptr<BCfaceArray> PhononModel< T >::BfacePtr

Definition at line 56 of file PhononModel.h.

template<class T >
typedef Tmode::Mode_ptr PhononModel< T >::Mode_ptr

Definition at line 47 of file PhononModel.h.

template<class T >
typedef map<int,PhononBC<T>*> PhononModel< T >::PhononBCMap

Definition at line 46 of file PhononModel.h.

template<class T >
typedef Tmode::Refl_Map PhononModel< T >::Refl_Map

Definition at line 51 of file PhononModel.h.

template<class T >
typedef Tmode::Refl_pair PhononModel< T >::Refl_pair

Definition at line 50 of file PhononModel.h.

template<class T >
typedef Tmode::Reflection PhononModel< T >::Reflection

Definition at line 48 of file PhononModel.h.

template<class T >
typedef Tmode::Reflptr PhononModel< T >::Reflptr

Definition at line 49 of file PhononModel.h.

template<class T >
typedef shared_ptr<VectorT3Array> PhononModel< T >::T3ptr

Definition at line 40 of file PhononModel.h.

template<class T >
typedef NumTypeTraits<T>::T_Scalar PhononModel< T >::T_Scalar

Definition at line 37 of file PhononModel.h.

template<class T >
typedef Array<T> PhononModel< T >::Tarray

Definition at line 44 of file PhononModel.h.

template<class T >
typedef shared_ptr<Tarray> PhononModel< T >::Tarrptr

Definition at line 45 of file PhononModel.h.

template<class T >
typedef Kspace<T> PhononModel< T >::Tkspace

Definition at line 41 of file PhononModel.h.

template<class T >
typedef kvol<T> PhononModel< T >::Tkvol

Definition at line 42 of file PhononModel.h.

template<class T >
typedef pmode<T> PhononModel< T >::Tmode

Definition at line 43 of file PhononModel.h.

template<class T >
typedef Vector<T_Scalar,3> PhononModel< T >::VectorT3

Definition at line 38 of file PhononModel.h.

template<class T >
typedef Array<VectorT3> PhononModel< T >::VectorT3Array

Definition at line 39 of file PhononModel.h.

Constructor & Destructor Documentation

template<class T >
PhononModel< T >::PhononModel ( const MeshList meshes,
const GeomFields geomFields,
Tkspace kspace,
PhononMacro macro 
)
inline

Definition at line 59 of file PhononModel.h.

References PhononModel< T >::_BCells, PhononModel< T >::_bcMap, PhononModel< T >::_BFaces, Model::_meshes, PhononBC< T >::bcType, Mesh::getBoundaryFaceGroups(), Mesh::getCells(), StorageSite::getCount(), Mesh::getFaces(), StorageSite::getSelfCount(), FaceGroup::groupType, and FaceGroup::id.

59  :
60 
61  Model(meshes),
62  _geomFields(geomFields),
63  _kspace(kspace),
64  _macro(macro),
65  _BCells(),
66  _BFaces()
67  {
68  //setting boundary conditions
69  const int numMeshes = _meshes.size();
70 
71  for (int n=0; n<numMeshes; n++) //mesh loop beg
72  {
73  const Mesh& mesh = *_meshes[n];
74  const StorageSite& cells=mesh.getCells();
75  const StorageSite& faces=mesh.getFaces();
76  const int cellCount=cells.getSelfCount();
77  const int faceCount=faces.getCount();
78 
79  BCellPtr BCptr(new BCcellArray(cellCount));
80  _BCells.push_back(BCptr);
81  BCptr->zero();
82 
83  BfacePtr BFptr(new BCfaceArray(faceCount));
84  BFptr->zero();
85  _BFaces.push_back(BFptr);
86 
87  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups()) //facegroup loop beg
88  {
89  const FaceGroup& fg = *fgPtr;
90  if (_bcMap.find(fg.id) == _bcMap.end())
91  {
92  PhononBC<T> *bc(new PhononBC<T>());
93 
94  _bcMap[fg.id] = bc;
95  if((fg.groupType == "wall"))
96  {
97  bc->bcType = "reflecting";
98  }
99  else if (fg.groupType == "velocity-inlet")
100  {
101  bc->bcType = "temperature";
102  }
103  else
104  throw CException("PhononModel: unknown face group type "
105  + fg.groupType);
106  }
107  }
108  }
109 
110  }
shared_ptr< BCcellArray > BCellPtr
Definition: PhononModel.h:53
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
int getSelfCount() const
Definition: StorageSite.h:40
Model(const MeshList &meshes)
Definition: Model.cpp:8
Definition: Mesh.h:28
BCcellList _BCells
Definition: PhononModel.h:679
const GeomFields & _geomFields
Definition: PhononModel.h:672
Definition: Mesh.h:49
PhononBCMap _bcMap
Definition: PhononModel.h:676
PhononMacro & _macro
Definition: PhononModel.h:674
string groupType
Definition: Mesh.h:42
const int id
Definition: Mesh.h:41
BCfaceList _BFaces
Definition: PhononModel.h:680
const StorageSite & getFaces() const
Definition: Mesh.h:108
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
shared_ptr< BCfaceArray > BfacePtr
Definition: PhononModel.h:56
Array< bool > BCfaceArray
Definition: PhononModel.h:55
int getCount() const
Definition: StorageSite.h:39
Array< int > BCcellArray
Definition: PhononModel.h:52
Tkspace & _kspace
Definition: PhononModel.h:673

Member Function Documentation

template<class T >
bool PhononModel< T >::advance ( const int  niter)
inline

Definition at line 530 of file PhononModel.h.

References PhononModel< T >::_initialnorm, PhononModel< T >::_kspace, PhononModel< T >::_niters, PhononModel< T >::_options, PhononModel< T >::callBoundaryConditions(), pmode< T >::getfield(), Kspace< T >::getkvol(), Kspace< T >::getlength(), kvol< T >::getmode(), kvol< T >::getmodenum(), LinearSystem::initAssembly(), PhononModel< T >::initPhononModelLinearization(), LinearSystem::initSolve(), PhononModel< T >::linearizePhononModel(), LinearSystem::postSolve(), PhononModel< T >::updatee0(), LinearSystem::updateSolution(), and PhononModel< T >::updateTL().

531  {
532  bool keepGoing(true);
533  for(int n=0; n<niter; n++)
534  {
535  const int klength =_kspace.getlength();
536  MFRPtr rNorm;
537 
538  for(int k=0; k<klength;k++)
539  {
540 
541  Tkvol& kv=_kspace.getkvol(k);
542  const int mlength=kv.getmodenum();
543 
544  for(int m=0;m<mlength;m++)
545  {
546 
547  Tmode& mode=kv.getmode(m);
548 
549  LinearSystem ls;
551  ls.initAssembly();
552  linearizePhononModel(ls,mode);
553  ls.initSolve();
554 
555  MFRPtr kNorm(_options.getPhononLinearSolver().solve(ls));
556 
557  if (!rNorm)
558  rNorm = kNorm;
559  else
560  {
561  // find the array for the 0the direction residual and
562  // add the current residual to it
563  Tkvol& kvol0=_kspace.getkvol(0);
564  Tmode& mode0=kvol0.getmode(0);
565  Field& efield0=mode0.getfield();
566  Field& efield=mode.getfield();
567 
568  ArrayBase& rArray0 = (*rNorm)[efield0];
569  ArrayBase& rArrayd = (*kNorm)[efield];
570  rArray0 += rArrayd;
571  }
572 
573  ls.postSolve();
574  ls.updateSolution();
575 
576  _options.getPhononLinearSolver().cleanup();
577 
578  }
579  }
580 
581  if (!_initialnorm) _initialnorm = rNorm;
582 
583  if (_niters < 5)
584  _initialnorm->setMax(*rNorm);
585 
586 
587  MFRPtr normRatio((*rNorm)/(*_initialnorm));
588 
589  if(_niters % _options.showResidual == 0)
590  cout << _niters << ": " << *rNorm <<endl;
591 
592  _niters++;
593  if ((*rNorm < _options.absTolerance)||(*normRatio < _options.relTolerance ))
594  {
595  //cout << endl;
596  //cout << "Final Residual at "<<_niters<<": "<< *rNorm <<endl;
597  keepGoing=false;
598  break;}
599 
600  updateTL(); //update macroparameters
601  updatee0();
603  }
604 
605  return keepGoing;
606  }
kvol< T > Tkvol
Definition: PhononModel.h:42
void initAssembly()
Definition: Field.h:14
Tkvol & getkvol(int n) const
Definition: Kspace.h:390
int getlength() const
Definition: Kspace.h:391
int getmodenum()
Definition: kvol.h:43
PhononModelOptions< T > _options
Definition: PhononModel.h:675
void updateSolution()
MFRPtr _initialnorm
Definition: PhononModel.h:677
void linearizePhononModel(LinearSystem &ls, Tmode &mode)
Definition: PhononModel.h:445
void initSolve()
shared_ptr< MultiFieldReduction > MFRPtr
void updatee0()
Definition: PhononModel.h:357
void updateTL()
Definition: PhononModel.h:302
void initPhononModelLinearization(LinearSystem &ls, Tmode &mode)
Definition: PhononModel.h:422
pmode< T > Tmode
Definition: PhononModel.h:43
Tkspace & _kspace
Definition: PhononModel.h:673
void callBoundaryConditions()
Definition: PhononModel.h:245
template<class T >
void PhononModel< T >::callBoundaryConditions ( )
inline

Definition at line 245 of file PhononModel.h.

References PhononModel< T >::_bcMap, PhononModel< T >::_geomFields, PhononModel< T >::_kspace, Model::_meshes, PhononModel< T >::_options, PhononInterface< X >::applyInterfaceCondition(), PhononBoundary< X >::applyReflectingWall(), PhononBoundary< X >::applyTemperatureWall(), PhononBC< T >::bcType, Mesh::getBoundaryFaceGroups(), Mesh::getInterfaceGroups(), FloatVarDict< T >::getVal(), FaceGroup::id, and FaceGroup::site.

Referenced by PhononModel< T >::advance().

246  {
247  const int numMeshes = _meshes.size();
248  for (int n=0; n<numMeshes; n++)
249  {
250  const Mesh& mesh = *_meshes[n];
251 
252  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
253  {
254  const FaceGroup& fg = *fgPtr;
255  const StorageSite& faces = fg.site;
256  const PhononBC<T>& bc = *_bcMap[fg.id];
257 
258  PhononBoundary<T> pbc(faces, mesh,_geomFields,_kspace,_options,fg.id);
259 
260  if (bc.bcType == "reflecting")
261  {
262 
264  bReflection(bc.getVal("specifiedReflection"),faces);
265 
266  pbc.applyReflectingWall(bReflection);
267  }
268  else if(bc.bcType=="temperature")
269  {
270 
272  bTemperature(bc.getVal("specifiedTemperature"),faces);
273 
274  pbc.applyTemperatureWall(bTemperature);
275  }
276  else
277  {
278  cout<<"Couldn't find boundary condition"<<endl;
279  break;
280  }
281  };
282  foreach(const FaceGroupPtr fgPtr, mesh.getInterfaceGroups())
283  {
284  int otherMeshID = 0;
285  T_Scalar btrans = _options["transmissivity0to1"];
286  T_Scalar brefl = 1.0 - _options["transmissivity1to0"];
287  if (n==0)
288  {
289  otherMeshID = 1;
290  btrans = _options["transmissivity1to0"];
291  brefl = 1.0 - _options["transmissivity0to1"];
292  }
293  const Mesh& otherMesh = *_meshes[otherMeshID];
294  const FaceGroup& fg = *fgPtr;
295  PhononInterface<T> pInt(fg, mesh, otherMesh,_geomFields,_kspace,_kspace,_options);
296 
297  pInt.applyInterfaceCondition(brefl,btrans);
298  };
299  };
300  };
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
Definition: Mesh.h:28
string bcType
Definition: PhononBC.h:21
const GeomFields & _geomFields
Definition: PhononModel.h:672
Definition: Mesh.h:49
PhononBCMap _bcMap
Definition: PhononModel.h:676
NumTypeTraits< T >::T_Scalar T_Scalar
Definition: PhononModel.h:37
PhononModelOptions< T > _options
Definition: PhononModel.h:675
FloatVal< T > getVal(const string varName) const
Definition: FloatVarDict.h:85
const int id
Definition: Mesh.h:41
const MeshList _meshes
Definition: Model.h:29
const FaceGroupList & getInterfaceGroups() const
Definition: Mesh.h:190
Tkspace & _kspace
Definition: PhononModel.h:673
StorageSite site
Definition: Mesh.h:40
template<class T >
void PhononModel< T >::COMETupdateTL ( )
inline

Definition at line 341 of file PhononModel.h.

References PhononModel< T >::_kspace, PhononModel< T >::_macro, Model::_meshes, PhononMacro::e0, Mesh::getCells(), StorageSite::getCount(), Kspace< T >::NewtonSolve(), and PhononMacro::temperature.

342  {
343  const int numMeshes = _meshes.size();
344  for (int n=0; n<numMeshes; n++)
345  {
346  const Mesh& mesh = *_meshes[n];
347  const StorageSite& cells = mesh.getCells();
348  const int numcells = cells.getCount();
349  Tarray& TL=dynamic_cast<Tarray&>(_macro.temperature[cells]);
350  Tarray& e0Array=dynamic_cast<Tarray&>(_macro.e0[cells]);
351 
352  for(int c=0;c<numcells;c++)
353  _kspace.NewtonSolve(TL[c],e0Array[c]);
354  }
355  }
void NewtonSolve(T &guess, const T e_sum)
Definition: Kspace.h:425
Field temperature
Definition: PhononMacro.h:21
Definition: Mesh.h:49
PhononMacro & _macro
Definition: PhononModel.h:674
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
Array< T > Tarray
Definition: PhononModel.h:44
int getCount() const
Definition: StorageSite.h:39
Tkspace & _kspace
Definition: PhononModel.h:673
template<class T >
PhononBCMap& PhononModel< T >::getBCs ( )
inline

Definition at line 113 of file PhononModel.h.

References PhononModel< T >::_bcMap.

113 {return _bcMap;}
PhononBCMap _bcMap
Definition: PhononModel.h:676
template<class T >
int PhononModel< T >::getIters ( )
inline

Definition at line 668 of file PhononModel.h.

References PhononModel< T >::_niters.

668 {return _niters;}
template<class T >
PhononModelOptions<T>& PhononModel< T >::getOptions ( )
inline

Definition at line 112 of file PhononModel.h.

References PhononModel< T >::_options.

112 {return _options;}
PhononModelOptions< T > _options
Definition: PhononModel.h:675
template<class T >
T PhononModel< T >::HeatFluxIntegral ( const Mesh mesh,
const int  faceGroupId 
)
inline

Definition at line 623 of file PhononModel.h.

References PhononModel< T >::_geomFields, PhononModel< T >::_kspace, GeomFields::area, Mesh::getBoundaryFaceGroups(), Mesh::getCells(), StorageSite::getCount(), kvol< T >::getdk3(), Kspace< T >::getDK3(), Mesh::getFaceCells(), pmode< T >::getfield(), Kspace< T >::getkvol(), Kspace< T >::getlength(), kvol< T >::getmode(), kvol< T >::getmodenum(), pmode< T >::getv(), FaceGroup::id, and FaceGroup::site.

624  {
625  T r(0.);
626  bool found = false;
627  const T DK3=_kspace.getDK3();
628  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
629  {
630  const FaceGroup& fg = *fgPtr;
631  if (fg.id == faceGroupId)
632  {
633  const StorageSite& faces = fg.site;
634  const int nFaces = faces.getCount();
635  const StorageSite& cells = mesh.getCells();
636  const CRConnectivity& faceCells=mesh.getFaceCells(faces);
637  const Field& areaField=_geomFields.area;
638  const VectorT3Array& faceArea=dynamic_cast<const VectorT3Array&>(areaField[faces]);
639 
640 
641  for(int k=0;k<_kspace.getlength();k++)
642  {
643  Tkvol& kv=_kspace.getkvol(k);
644  int modenum=kv.getmodenum();
645  for(int m=0;m<modenum;m++)
646  {
647  VectorT3 vg=kv.getmode(m).getv();
648  T dk3=kv.getdk3();
649  Field& efield=kv.getmode(m).getfield();
650  const Tarray& eval=dynamic_cast<const Tarray&>(efield[cells]);
651  for(int f=0; f<nFaces; f++)
652  {
653  const VectorT3 An=faceArea[f];
654  const int c1=faceCells(f,1);
655  const T vgdotAn=An[0]*vg[0]+An[1]*vg[1]+An[2]*vg[2];
656  r += eval[c1]*vgdotAn*dk3/DK3;
657  }
658  found=true;
659  }
660  }
661  }
662  }
663  if (!found)
664  throw CException("getHeatFluxIntegral: invalid faceGroupID");
665  return r*DK3;
666  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
kvol< T > Tkvol
Definition: PhononModel.h:42
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
Definition: Mesh.h:28
Definition: Field.h:14
Tkvol & getkvol(int n) const
Definition: Kspace.h:390
int getlength() const
Definition: Kspace.h:391
const GeomFields & _geomFields
Definition: PhononModel.h:672
int getmodenum()
Definition: kvol.h:43
T getDK3() const
Definition: Kspace.h:408
const int id
Definition: Mesh.h:41
const StorageSite & getCells() const
Definition: Mesh.h:109
const CRConnectivity & getFaceCells(const StorageSite &site) const
Definition: Mesh.cpp:388
Array< T > Tarray
Definition: PhononModel.h:44
int getCount() const
Definition: StorageSite.h:39
Field area
Definition: GeomFields.h:23
Tkspace & _kspace
Definition: PhononModel.h:673
StorageSite site
Definition: Mesh.h:40
template<class T >
void PhononModel< T >::init ( )
inlinevirtual

Implements Model.

Definition at line 115 of file PhononModel.h.

References PhononModel< T >::_BCells, PhononModel< T >::_bcMap, PhononModel< T >::_BFaces, PhononModel< T >::_geomFields, PhononModel< T >::_initialnorm, PhononModel< T >::_kspace, PhononModel< T >::_macro, Model::_meshes, PhononModel< T >::_niters, PhononModel< T >::_options, Field::addArray(), GeomFields::area, GeomFields::areaMag, pmode< T >::calce0(), PhononMacro::e0, Kspace< T >::findSpecs(), Mesh::getBoundaryFaceGroups(), Mesh::getCells(), StorageSite::getCount(), kvol< T >::getdk3(), Kspace< T >::getDK3(), pmode< T >::gete0field(), Mesh::getFaceCells(), pmode< T >::getfield(), Kspace< T >::getkvol(), Kspace< T >::getlength(), kvol< T >::getmode(), kvol< T >::getmodenum(), StorageSite::getOffset(), pmode< T >::getreflmap(), pmode< T >::getresid(), pmode< T >::getv(), FaceGroup::id, FaceGroup::site, sqrt(), and PhononMacro::temperature.

116  {
117 
118  _initialnorm = MFRPtr();
119  _niters=0;
120  const int numMeshes=_meshes.size();
121 
122  for (int n=0;n<numMeshes;n++) //mesh loop beg
123  {
124  const Mesh& mesh=*_meshes[n];
125  const int numK=_kspace.getlength();
126  const StorageSite& cells=mesh.getCells();
127  const int numcells=cells.getCount();
128 
129  //initialize lattice temperature
130  shared_ptr<Tarray> TLcell(new Tarray(numcells));
131  const T Tinit=_options["initialTemperature"];
132  *TLcell=Tinit;
133  _macro.temperature.addArray(cells,TLcell);
134 
135  T e0sum=0.;
136 
137  for (int k=0;k<numK;k++) //kspace loop beg
138  {
139  Tkvol& kv=_kspace.getkvol(k);
140  const int numM=kv.getmodenum();
141  const T dk3=kv.getdk3();
142 
143  for (int m=0;m<numM;m++) //mode loop beg
144  {
145  //initialize each phonon mode
146  Tmode& mode=kv.getmode(m);
147  Field& efield=mode.getfield();
148  Field& e0field=mode.gete0field();
149  Field& resfield=mode.getresid();
150  Tarrptr e0var=shared_ptr<Tarray>(new Tarray(numcells));
151  Tarrptr evar=shared_ptr<Tarray>(new Tarray(numcells));
152  Tarrptr resid=shared_ptr<Tarray>(new Tarray(numcells));
153  const T einit=mode.calce0(Tinit);
154  e0sum+=einit*dk3;
155  *evar=einit;
156  *e0var=einit;
157  *resid=0.;
158  efield.addArray(cells,evar);
159  e0field.addArray(cells,e0var);
160  resfield.addArray(cells,resid);
161  }; //mode loop end
162  }; //kspace loop end
163 
164  e0sum=e0sum/_kspace.getDK3();
165  shared_ptr<Tarray> e0cell(new Tarray(numcells));
166  *e0cell=e0sum;
167  _macro.e0.addArray(cells,e0cell);
168  shared_ptr<Tarray> e0ResidCell(new Tarray(numcells));
169  *e0ResidCell=0.;
170  // _macro.e0Residual.addArray(cells,e0ResidCell);
171 
172  // Compute reflections--later, should be moved inside above loop
173 
174  for (int k=0;k<numK;k++) //kspace loop beg
175  {
176  Tkvol& kv=_kspace.getkvol(k);
177  const int numM=kv.getmodenum();
178  //const T dk3=kv.getdk3();
179 
180  for (int m=0;m<numM;m++) //mode loop beg
181  {
182  Tmode& mode=kv.getmode(m);
183  Refl_Map& rmap=mode.getreflmap();
184  VectorT3 vg=mode.getv();
185  T vmag=sqrt(pow(vg[0],2)+pow(vg[1],2)+pow(vg[2],2));
186  VectorT3 si=vg/vmag;
187  VectorT3 so;
188 
189  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
190  {
191  const FaceGroup& fg = *fgPtr;
192  const StorageSite& faces = fg.site;
193  const Field& AreaMagField=_geomFields.areaMag;
194  const Tarray& AreaMag=dynamic_cast<const Tarray&>(AreaMagField[faces]);
195  const Field& AreaDirField=_geomFields.area;
196  const VectorT3Array& AreaDir=
197  dynamic_cast<const VectorT3Array&>(AreaDirField[faces]);
198 
199  const VectorT3 n=AreaDir[0]/AreaMag[0];
200  const T sidotn=si[0]*n[0]+si[1]*n[1]+si[2]*n[2];
201 
202  if (sidotn > T_Scalar(0.0))
203  {
204  so=si-2.*(si[0]*n[0]+si[1]*n[1]+si[2]*n[2])*n;
205  T soMag=sqrt(pow(so[0],2)+pow(so[1],2)+pow(so[2],2));
206  so/=soMag;
207  so*=vmag;
208  Refl_pair refls;
209  Refl_pair reflsFrom;
210  _kspace.findSpecs(n,m,k,refls);
211  rmap[fg.id]=refls;
212  const int k1=refls.first.second;
213  Tmode& mode2=_kspace.getkvol(k1).getmode(m);
214  Refl_Map& rmap2=mode2.getreflmap();
215  reflsFrom.first.second=-1;
216  reflsFrom.second.second=k;
217  rmap2[fg.id]=reflsFrom;
218  }
219  }
220  }
221  }
222 
223  BCcellArray& BCArray=*(_BCells[n]);
224  BCfaceArray& BCfArray=*(_BFaces[n]);
225  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
226  {
227  const FaceGroup& fg = *fgPtr;
228  if((_bcMap[fg.id]->bcType == "reflecting"))
229  {
230  const CRConnectivity& BfaceCells=mesh.getFaceCells(fg.site);
231  const int faceCount=fg.site.getCount();
232  const int offSet=fg.site.getOffset();
233  for(int i=0;i<faceCount;i++)
234  {
235  int cell1=BfaceCells(i,0);
236  BCArray[cell1]=1;
237  }
238  for(int i=offSet;i<offSet+faceCount;i++)
239  BCfArray[i]=true;
240  }
241  }
242  }
243  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
kvol< T > Tkvol
Definition: PhononModel.h:42
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
void findSpecs(const Tvec n, const int m, const int k, Refl_pair &refls)
Definition: Kspace.h:742
Definition: Mesh.h:28
Definition: Field.h:14
Tkvol & getkvol(int n) const
Definition: Kspace.h:390
BCcellList _BCells
Definition: PhononModel.h:679
Tmode & getmode(int n) const
Definition: kvol.h:44
int getlength() const
Definition: Kspace.h:391
shared_ptr< Tarray > Tarrptr
Definition: PhononModel.h:45
const GeomFields & _geomFields
Definition: PhononModel.h:672
Field temperature
Definition: PhononMacro.h:21
Definition: Mesh.h:49
PhononBCMap _bcMap
Definition: PhononModel.h:676
int getmodenum()
Definition: kvol.h:43
T getDK3() const
Definition: Kspace.h:408
NumTypeTraits< T >::T_Scalar T_Scalar
Definition: PhononModel.h:37
PhononModelOptions< T > _options
Definition: PhononModel.h:675
PhononMacro & _macro
Definition: PhononModel.h:674
Tangent sqrt(const Tangent &a)
Definition: Tangent.h:317
const int id
Definition: Mesh.h:41
BCfaceList _BFaces
Definition: PhononModel.h:680
MFRPtr _initialnorm
Definition: PhononModel.h:677
Tmode::Refl_pair Refl_pair
Definition: PhononModel.h:50
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
Tmode::Refl_Map Refl_Map
Definition: PhononModel.h:51
Array< bool > BCfaceArray
Definition: PhononModel.h:55
void addArray(const StorageSite &, shared_ptr< ArrayBase > a)
Definition: Field.cpp:72
const CRConnectivity & getFaceCells(const StorageSite &site) const
Definition: Mesh.cpp:388
Array< T > Tarray
Definition: PhononModel.h:44
int getOffset() const
Definition: StorageSite.h:87
int getCount() const
Definition: StorageSite.h:39
shared_ptr< MultiFieldReduction > MFRPtr
Field area
Definition: GeomFields.h:23
Field areaMag
Definition: GeomFields.h:25
Array< int > BCcellArray
Definition: PhononModel.h:52
pmode< T > Tmode
Definition: PhononModel.h:43
Tkspace & _kspace
Definition: PhononModel.h:673
StorageSite site
Definition: Mesh.h:40
template<class T >
void PhononModel< T >::initPhononModelLinearization ( LinearSystem ls,
Tmode mode 
)
inline

Definition at line 422 of file PhononModel.h.

References Model::_meshes, MultiField::addArray(), MultiFieldMatrix::addMatrix(), Field::getArrayPtr(), Mesh::getCellCells(), Mesh::getCells(), pmode< T >::getfield(), LinearSystem::getMatrix(), and LinearSystem::getX().

Referenced by PhononModel< T >::advance().

423  {
424  const int numMeshes = _meshes.size();
425  for (int n=0; n<numMeshes; n++)
426  {
427  const Mesh& mesh = *_meshes[n];
428  const StorageSite& cells = mesh.getCells();
429 
430  Field& fnd = mode.getfield();
431 
432  MultiField::ArrayIndex vIndex(&fnd,&cells);
433 
434  ls.getX().addArray(vIndex,fnd.getArrayPtr(cells));
435 
436  const CRConnectivity& cellCells = mesh.getCellCells();
437 
438  shared_ptr<Matrix> m(new CRMatrix<T,T,T>(cellCells));
439 
440  ls.getMatrix().addMatrix(vIndex,vIndex,m);
441  }
442 
443  };
Definition: Field.h:14
Definition: Mesh.h:49
pair< const Field *, const StorageSite * > ArrayIndex
Definition: MultiField.h:21
const MeshList _meshes
Definition: Model.h:29
const CRConnectivity & getCellCells() const
Definition: Mesh.cpp:480
const StorageSite & getCells() const
Definition: Mesh.h:109
void addMatrix(const Index &rowI, const Index &colI, shared_ptr< Matrix > m)
void addArray(const ArrayIndex &aIndex, shared_ptr< ArrayBase > a)
Definition: MultiField.cpp:270
MultiField & getX()
Definition: LinearSystem.h:32
shared_ptr< ArrayBase > getArrayPtr(const StorageSite &)
Definition: Field.cpp:63
MultiFieldMatrix & getMatrix()
Definition: LinearSystem.h:37
template<class T >
void PhononModel< T >::linearizePhononModel ( LinearSystem ls,
Tmode mode 
)
inline

Definition at line 445 of file PhononModel.h.

References PhononModel< T >::_bcMap, PhononModel< T >::_geomFields, Model::_meshes, GeomFields::area, GeomFields::areaMag, PhononBC< T >::bcType, LinearSystem::getB(), Mesh::getBoundaryFaceGroups(), Mesh::getCells(), StorageSite::getCount(), pmode< T >::gete0field(), Mesh::getFaceCells(), pmode< T >::getfield(), LinearSystem::getMatrix(), pmode< T >::gettau(), pmode< T >::getv(), LinearSystem::getX(), FaceGroup::id, Linearizer::linearize(), and FaceGroup::site.

Referenced by PhononModel< T >::advance().

446  {
447  // _velocityGradientModel.compute();
448  DiscrList discretizations;
449 
450  Field& fnd = mode.getfield(); //field for e"
451  Field& e0fld=mode.gete0field(); //field for e0
452  T tau=mode.gettau();
453  VectorT3 vg=mode.getv();
454 
455  shared_ptr<Discretization>
456  colldisc(new PhononCollisionDiscretization<T,T,T>(_meshes, _geomFields,fnd,e0fld,tau));
457 
458  discretizations.push_back(colldisc);
459 
460  shared_ptr<Discretization>
462 
463  discretizations.push_back(convdisc);
464 
465  Linearizer linearizer;
466 
467  linearizer.linearize(discretizations,_meshes,ls.getMatrix(),
468  ls.getX(), ls.getB());
469 
470 
471 
472  // boundary conditions
473  const int numMeshes = _meshes.size();
474  for (int n=0; n<numMeshes; n++)
475  {
476  const Mesh& mesh = *_meshes[n];
477  const StorageSite& cells = mesh.getCells();
478  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
479  {
480  const FaceGroup& fg = *fgPtr;
481  const StorageSite& faces = fg.site;
482  const int nFaces = faces.getCount();
483  const PhononBC<T>& bc = *_bcMap[fg.id];
484  Tarray& dsf = dynamic_cast< Tarray&>(fnd[cells]);
485  BaseGenericPhononBCS<T,T,T> gpbc(faces, mesh, _geomFields,
486  fnd,
487  ls.getMatrix(),
488  ls.getX(),
489  ls.getB());
490 
491 
492  const CRConnectivity& faceCells = mesh.getFaceCells(faces);
493  const Field& areaMagField = _geomFields.areaMag;
494  const Tarray& faceAreaMag = dynamic_cast<const Tarray &>(areaMagField[faces]);
495  const Field& areaField = _geomFields.area;
496  const VectorT3Array& faceArea=dynamic_cast<const VectorT3Array&>(areaField[faces]);
497 
498  if (( bc.bcType == "CopyBC"))
499  {
500  for(int f=0; f< nFaces; f++)
501  {
502  gpbc.applyExtrapolationBC(f);
503  }
504  }
505  else{
506  for(int f=0; f< nFaces; f++)
507  {
508  const VectorT3 en = faceArea[f]/faceAreaMag[f];
509  const T v_dot_en = vg[0]*en[0]+vg[1]*en[1]+vg[2]*en[2];
510 
511  if(v_dot_en < T_Scalar(0.0))
512  {
513  //incoming direction - dirchlet bc
514  const int c1= faceCells(f,1); // boundary cell
515  T bvalue =dsf[c1];
516  gpbc.applyDirichletBC(f,bvalue);
517  }
518  else
519  {
520  //outgoing direction - extrapolation bc
521  gpbc.applyExtrapolationBC(f);
522  }
523  }
524  }
525  }
526  }
527 
528  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
Definition: Mesh.h:28
Definition: Field.h:14
string bcType
Definition: PhononBC.h:21
const GeomFields & _geomFields
Definition: PhononModel.h:672
Definition: Mesh.h:49
PhononBCMap _bcMap
Definition: PhononModel.h:676
NumTypeTraits< T >::T_Scalar T_Scalar
Definition: PhononModel.h:37
const int id
Definition: Mesh.h:41
vector< shared_ptr< Discretization > > DiscrList
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
const CRConnectivity & getFaceCells(const StorageSite &site) const
Definition: Mesh.cpp:388
Array< T > Tarray
Definition: PhononModel.h:44
int getCount() const
Definition: StorageSite.h:39
MultiField & getB()
Definition: LinearSystem.h:33
Field area
Definition: GeomFields.h:23
MultiField & getX()
Definition: LinearSystem.h:32
Field areaMag
Definition: GeomFields.h:25
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 PhononModel< T >::printTemp ( )
inline

Definition at line 608 of file PhononModel.h.

References PhononModel< T >::_macro, Model::_meshes, Mesh::getCells(), StorageSite::getCount(), and PhononMacro::temperature.

609  {
610  const int numMeshes = _meshes.size();
611  for (int n=0; n<numMeshes; n++)
612  {
613  const Mesh& mesh = *_meshes[n];
614  const StorageSite& cells = mesh.getCells();
615  const int numcells=cells.getCount();
616  Tarray& TL=dynamic_cast<Tarray&>(_macro.temperature[cells]);
617  for(int i=0;i<numcells;i++)
618  cout<<TL[i]<<" "<<i<<endl;
619  }
620 
621  }
Field temperature
Definition: PhononMacro.h:21
Definition: Mesh.h:49
PhononMacro & _macro
Definition: PhononModel.h:674
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
Array< T > Tarray
Definition: PhononModel.h:44
int getCount() const
Definition: StorageSite.h:39
template<class T >
void PhononModel< T >::updatee0 ( )
inline

Definition at line 357 of file PhononModel.h.

References PhononModel< T >::_kspace, PhononModel< T >::_macro, Model::_meshes, pmode< T >::calce0(), Mesh::getCells(), StorageSite::getCount(), pmode< T >::gete0field(), Kspace< T >::getkvol(), Kspace< T >::getlength(), kvol< T >::getmode(), kvol< T >::getmodenum(), and PhononMacro::temperature.

Referenced by PhononModel< T >::advance().

358  {
359 
360  const int numMeshes = _meshes.size();
361  for (int n=0; n<numMeshes; n++)
362  {
363  const Mesh& mesh = *_meshes[n];
364  const StorageSite& cells = mesh.getCells();
365  const int numcells = cells.getCount();
366  const int numK=_kspace.getlength();
367  Tarray& TL=dynamic_cast<Tarray&>(_macro.temperature[cells]);
368 
369  for(int k=0;k<numK;k++)
370  {
371  Tkvol& kv=_kspace.getkvol(k);
372  const int modenum=kv.getmodenum();
373 
374  for(int m=0;m<modenum;m++)
375  {
376  Tmode& mode=kv.getmode(m);
377  Field& e0field=mode.gete0field();
378  Tarray& e0_val=dynamic_cast<Tarray&>(e0field[cells]);
379  for(int c=0;c<numcells;c++)
380  e0_val[c]=mode.calce0(TL[c]);
381  }
382  }
383 
384  }
385  }
kvol< T > Tkvol
Definition: PhononModel.h:42
Definition: Field.h:14
Tkvol & getkvol(int n) const
Definition: Kspace.h:390
int getlength() const
Definition: Kspace.h:391
Field temperature
Definition: PhononMacro.h:21
Definition: Mesh.h:49
int getmodenum()
Definition: kvol.h:43
PhononMacro & _macro
Definition: PhononModel.h:674
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
Array< T > Tarray
Definition: PhononModel.h:44
int getCount() const
Definition: StorageSite.h:39
pmode< T > Tmode
Definition: PhononModel.h:43
Tkspace & _kspace
Definition: PhononModel.h:673
template<class T >
void PhononModel< T >::updateHeatFlux ( )
inline

Definition at line 387 of file PhononModel.h.

References PhononModel< T >::_kspace, PhononModel< T >::_macro, Model::_meshes, Field::addArray(), Mesh::getCells(), StorageSite::getCount(), kvol< T >::getdk3(), pmode< T >::getfield(), Kspace< T >::getkvol(), Kspace< T >::getlength(), kvol< T >::getmode(), kvol< T >::getmodenum(), pmode< T >::getv(), and PhononMacro::heatFlux.

388  {
389  const int numMeshes = _meshes.size();
390  for (int n=0; n<numMeshes; n++)
391  {
392  VectorT3 zero_vec;
393  const Mesh& mesh = *_meshes[n];
394  const StorageSite& cells = mesh.getCells();
395  const int numcells = cells.getCount();
396  T3ptr heatFluxptr=T3ptr(new VectorT3Array(numcells));
397  VectorT3Array& heatFlux=*heatFluxptr;
398  zero_vec[0]=0.;zero_vec[1]=0.;zero_vec[2]=0.;
399  heatFlux=zero_vec;
400 
401  const int numK=_kspace.getlength();
402  for(int k=0;k<numK;k++)
403  {
404  Tkvol& kv=_kspace.getkvol(k);
405  T dk3=kv.getdk3();
406  const int modenum=kv.getmodenum();
407  for(int m=0;m<modenum;m++)
408  {
409  Tmode& mode=kv.getmode(m);
410  VectorT3 vg=mode.getv();
411  Field& efield=mode.getfield();
412  const Tarray& eval=dynamic_cast<const Tarray&>(efield[cells]);
413 
414  for(int c=0;c<numcells;c++)
415  heatFlux[c]+=eval[c]*vg*dk3;
416  }
417  }
418  _macro.heatFlux.addArray(cells,heatFluxptr);
419  }
420  }
kvol< T > Tkvol
Definition: PhononModel.h:42
shared_ptr< VectorT3Array > T3ptr
Definition: PhononModel.h:40
Definition: Field.h:14
Tkvol & getkvol(int n) const
Definition: Kspace.h:390
int getlength() const
Definition: Kspace.h:391
Definition: Mesh.h:49
PhononMacro & _macro
Definition: PhononModel.h:674
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
void addArray(const StorageSite &, shared_ptr< ArrayBase > a)
Definition: Field.cpp:72
Array< T > Tarray
Definition: PhononModel.h:44
int getCount() const
Definition: StorageSite.h:39
Array< VectorT3 > VectorT3Array
Definition: PhononModel.h:39
Field heatFlux
Definition: PhononMacro.h:27
pmode< T > Tmode
Definition: PhononModel.h:43
Tkspace & _kspace
Definition: PhononModel.h:673
T getdk3()
Definition: kvol.h:42
template<class T >
void PhononModel< T >::updateTL ( )
inline

Definition at line 302 of file PhononModel.h.

References PhononModel< T >::_kspace, PhononModel< T >::_macro, Model::_meshes, Mesh::getCells(), StorageSite::getCount(), kvol< T >::getdk3(), pmode< T >::getfield(), Kspace< T >::getkvol(), Kspace< T >::getlength(), kvol< T >::getmode(), kvol< T >::getmodenum(), pmode< T >::gettau(), Kspace< T >::NewtonSolve(), and PhononMacro::temperature.

Referenced by PhononModel< T >::advance().

303  {
304 
305  const int numMeshes = _meshes.size();
306  for (int n=0; n<numMeshes; n++)
307  {
308  const Mesh& mesh = *_meshes[n];
309  const StorageSite& cells = mesh.getCells();
310  const int numcells = cells.getCount();
311  const int numK=_kspace.getlength();
312  Tarray& TL=dynamic_cast<Tarray&>(_macro.temperature[cells]);
313  Tarrptr e_sumptr=shared_ptr<Tarray>(new Tarray(numcells));
314  Tarray& e_sum=*(e_sumptr);
315  e_sum=0.;
316 
317  for(int k=0;k<numK;k++)
318  {
319  Tkvol& kv=_kspace.getkvol(k);
320  const int modenum=kv.getmodenum();
321  T dk3=kv.getdk3();
322 
323  for(int m=0;m<modenum;m++)
324  {
325  Tmode& mode=kv.getmode(m);
326  T tau=mode.gettau();
327  Field& efield=mode.getfield();
328  Tarray& e_val=dynamic_cast<Tarray&>(efield[cells]);
329 
330  for(int c=0;c<numcells;c++)
331  e_sum[c]+=e_val[c]*dk3/tau;
332 
333  }
334  }
335 
336  for(int c=0;c<numcells;c++)
337  _kspace.NewtonSolve(TL[c],e_sum[c]);
338  }
339  }
kvol< T > Tkvol
Definition: PhononModel.h:42
void NewtonSolve(T &guess, const T e_sum)
Definition: Kspace.h:425
Definition: Field.h:14
Tkvol & getkvol(int n) const
Definition: Kspace.h:390
int getlength() const
Definition: Kspace.h:391
shared_ptr< Tarray > Tarrptr
Definition: PhononModel.h:45
Field temperature
Definition: PhononMacro.h:21
Definition: Mesh.h:49
int getmodenum()
Definition: kvol.h:43
PhononMacro & _macro
Definition: PhononModel.h:674
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
Array< T > Tarray
Definition: PhononModel.h:44
int getCount() const
Definition: StorageSite.h:39
pmode< T > Tmode
Definition: PhononModel.h:43
Tkspace & _kspace
Definition: PhononModel.h:673

Member Data Documentation

template<class T >
BCcellList PhononModel< T >::_BCells
private

Definition at line 679 of file PhononModel.h.

Referenced by PhononModel< T >::init(), and PhononModel< T >::PhononModel().

template<class T >
BCfaceList PhononModel< T >::_BFaces
private

Definition at line 680 of file PhononModel.h.

Referenced by PhononModel< T >::init(), and PhononModel< T >::PhononModel().

template<class T >
MFRPtr PhononModel< T >::_initialnorm
private

Definition at line 677 of file PhononModel.h.

Referenced by PhononModel< T >::advance(), and PhononModel< T >::init().

template<class T >
int PhononModel< T >::_niters
private

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