5 #ifndef _PHONONMODEL_H_
6 #define _PHONONMODEL_H_
40 typedef shared_ptr<VectorT3Array>
T3ptr;
69 const int numMeshes =
_meshes.size();
71 for (
int n=0; n<numMeshes; n++)
77 const int faceCount=faces.
getCount();
99 else if (fg.
groupType ==
"velocity-inlet")
101 bc->
bcType =
"temperature";
104 throw CException(
"PhononModel: unknown face group type "
120 const int numMeshes=
_meshes.size();
122 for (
int n=0;n<numMeshes;n++)
127 const int numcells=cells.
getCount();
130 shared_ptr<Tarray> TLcell(
new Tarray(numcells));
131 const T Tinit=
_options[
"initialTemperature"];
137 for (
int k=0;k<numK;k++)
143 for (
int m=0;m<numM;m++)
153 const T einit=mode.
calce0(Tinit);
165 shared_ptr<Tarray> e0cell(
new Tarray(numcells));
168 shared_ptr<Tarray> e0ResidCell(
new Tarray(numcells));
174 for (
int k=0;k<numK;k++)
180 for (
int m=0;m<numM;m++)
185 T vmag=
sqrt(pow(vg[0],2)+pow(vg[1],2)+pow(vg[2],2));
194 const Tarray& AreaMag=
dynamic_cast<const Tarray&
>(AreaMagField[faces]);
199 const VectorT3 n=AreaDir[0]/AreaMag[0];
200 const T sidotn=si[0]*n[0]+si[1]*n[1]+si[2]*n[2];
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));
212 const int k1=refls.first.second;
215 reflsFrom.first.second=-1;
216 reflsFrom.second.second=k;
217 rmap2[fg.
id]=reflsFrom;
228 if((
_bcMap[fg.
id]->bcType ==
"reflecting"))
233 for(
int i=0;i<faceCount;i++)
235 int cell1=BfaceCells(i,0);
238 for(
int i=offSet;i<offSet+faceCount;i++)
247 const int numMeshes =
_meshes.size();
248 for (
int n=0; n<numMeshes; n++)
260 if (bc.
bcType ==
"reflecting")
264 bReflection(bc.
getVal(
"specifiedReflection"),faces);
268 else if(bc.
bcType==
"temperature")
272 bTemperature(bc.
getVal(
"specifiedTemperature"),faces);
278 cout<<
"Couldn't find boundary condition"<<endl;
290 btrans =
_options[
"transmissivity1to0"];
291 brefl = 1.0 -
_options[
"transmissivity0to1"];
305 const int numMeshes =
_meshes.size();
306 for (
int n=0; n<numMeshes; n++)
310 const int numcells = cells.
getCount();
314 Tarray& e_sum=*(e_sumptr);
317 for(
int k=0;k<numK;k++)
323 for(
int m=0;m<modenum;m++)
330 for(
int c=0;c<numcells;c++)
331 e_sum[c]+=e_val[c]*dk3/tau;
336 for(
int c=0;c<numcells;c++)
343 const int numMeshes =
_meshes.size();
344 for (
int n=0; n<numMeshes; n++)
348 const int numcells = cells.
getCount();
352 for(
int c=0;c<numcells;c++)
360 const int numMeshes =
_meshes.size();
361 for (
int n=0; n<numMeshes; n++)
365 const int numcells = cells.
getCount();
369 for(
int k=0;k<numK;k++)
374 for(
int m=0;m<modenum;m++)
379 for(
int c=0;c<numcells;c++)
380 e0_val[c]=mode.
calce0(TL[c]);
389 const int numMeshes =
_meshes.size();
390 for (
int n=0; n<numMeshes; n++)
395 const int numcells = cells.
getCount();
398 zero_vec[0]=0.;zero_vec[1]=0.;zero_vec[2]=0.;
402 for(
int k=0;k<numK;k++)
407 for(
int m=0;m<modenum;m++)
412 const Tarray& eval=
dynamic_cast<const Tarray&
>(efield[cells]);
414 for(
int c=0;c<numcells;c++)
415 heatFlux[c]+=eval[c]*vg*dk3;
424 const int numMeshes =
_meshes.size();
425 for (
int n=0; n<numMeshes; n++)
455 shared_ptr<Discretization>
458 discretizations.push_back(colldisc);
460 shared_ptr<Discretization>
463 discretizations.push_back(convdisc);
473 const int numMeshes =
_meshes.size();
474 for (
int n=0; n<numMeshes; n++)
482 const int nFaces = faces.
getCount();
494 const Tarray& faceAreaMag =
dynamic_cast<const Tarray &
>(areaMagField[faces]);
498 if (( bc.
bcType ==
"CopyBC"))
500 for(
int f=0; f< nFaces; f++)
502 gpbc.applyExtrapolationBC(f);
506 for(
int f=0; f< nFaces; f++)
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];
514 const int c1= faceCells(f,1);
516 gpbc.applyDirichletBC(f,bvalue);
521 gpbc.applyExtrapolationBC(f);
532 bool keepGoing(
true);
533 for(
int n=0; n<niter; n++)
538 for(
int k=0; k<klength;k++)
544 for(
int m=0;m<mlength;m++)
576 _options.getPhononLinearSolver().cleanup();
590 cout <<
_niters <<
": " << *rNorm <<endl;
593 if ((*rNorm <
_options.absTolerance)||(*normRatio <
_options.relTolerance ))
610 const int numMeshes =
_meshes.size();
611 for (
int n=0; n<numMeshes; n++)
615 const int numcells=cells.
getCount();
617 for(
int i=0;i<numcells;i++)
618 cout<<TL[i]<<
" "<<i<<endl;
631 if (fg.
id == faceGroupId)
634 const int nFaces = faces.
getCount();
645 for(
int m=0;m<modenum;m++)
650 const Tarray& eval=
dynamic_cast<const Tarray&
>(efield[cells]);
651 for(
int f=0; f<nFaces; 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;
664 throw CException(
"getHeatFluxIntegral: invalid faceGroupID");
Tmode::Reflection Reflection
shared_ptr< BCcellArray > BCellPtr
shared_ptr< Reflection > Reflptr
const FaceGroupList & getBoundaryFaceGroups() const
pair< Reflection, Reflection > Refl_pair
void NewtonSolve(T &guess, const T e_sum)
shared_ptr< FaceGroup > FaceGroupPtr
shared_ptr< VectorT3Array > T3ptr
void findSpecs(const Tvec n, const int m, const int k, Refl_pair &refls)
PhononModelOptions< T > & getOptions()
T HeatFluxIntegral(const Mesh &mesh, const int faceGroupId)
Tkvol & getkvol(int n) const
void applyReflectingWall(int f, const X refl) const
Tmode & getmode(int n) const
shared_ptr< Tarray > Tarrptr
const GeomFields & _geomFields
shared_ptr< pmode< T > > Mode_ptr
NumTypeTraits< T >::T_Scalar T_Scalar
vector< BCellPtr > BCcellList
PhononModelOptions< T > _options
map< int, Refl_pair > Refl_Map
FloatVal< T > getVal(const string varName) const
Tangent sqrt(const Tangent &a)
void linearizePhononModel(LinearSystem &ls, Tmode &mode)
pair< const Field *, const StorageSite * > ArrayIndex
vector< BfacePtr > BCfaceList
vector< shared_ptr< Discretization > > DiscrList
const StorageSite & getFaces() const
Tmode::Refl_pair Refl_pair
const CRConnectivity & getCellCells() const
const StorageSite & getCells() const
shared_ptr< BCfaceArray > BfacePtr
Array< bool > BCfaceArray
bool advance(const int niter)
void addArray(const StorageSite &, shared_ptr< ArrayBase > a)
const CRConnectivity & getFaceCells(const StorageSite &site) const
void addMatrix(const Index &rowI, const Index &colI, shared_ptr< Matrix > m)
Array< VectorT3 > VectorT3Array
pair< T, int > Reflection
map< int, PhononBC< T > * > PhononBCMap
shared_ptr< MultiFieldReduction > MFRPtr
void addArray(const ArrayIndex &aIndex, shared_ptr< ArrayBase > a)
const FaceGroupList & getInterfaceGroups() const
void applyInterfaceCondition(int f, const X refl, const X trans) const
void applyTemperatureWall(int f, const X Twall) const
shared_ptr< ArrayBase > getArrayPtr(const StorageSite &)
Vector< T_Scalar, 3 > VectorT3
PhononModel(const MeshList &meshes, const GeomFields &geomFields, Tkspace &kspace, PhononMacro ¯o)
void initPhononModelLinearization(LinearSystem &ls, Tmode &mode)
virtual void linearize(DiscrList &discretizations, const MeshList &meshes, MultiFieldMatrix &matrix, MultiField &x, MultiField &b)
MultiFieldMatrix & getMatrix()
vector< Mesh * > MeshList
void callBoundaryConditions()