5 #ifndef _COMETINTERFACE_H_
6 #define _COMETINTERFACE_H_
48 const int Fid0=ic.
FgID0;
49 const int Fid1=ic.
FgID1;
59 const IntArray& scatter01=(*ScatMap01.find(&faces1)->second);
67 const int faceCount=faces0.
getCount();
86 kclist01.resize(faceCount);
87 kclist10.resize(faceCount);
89 for(
int f=0;f<faceCount;f++)
92 VectorT3 n=An/
sqrt(pow(An[0],2)+pow(An[1],2)+pow(An[2],2));
93 const int cell0=faceCells0(f,0);
94 const int cell0ghost=faceCells0(f,1);
95 const int cell1ghost=scatter01[f];
96 const int cell1=CellCells1(cell1ghost,0);
97 const int f1=CellFaces1(cell1ghost,0)-face1Offset;
98 const VectorT3 c0Pos=coord0Array[cell0];
99 const VectorT3 cGhstPos=coord0Array[cell0ghost];
100 const VectorT3 from0toGhst=cGhstPos-c0Pos;
101 T TL1(TL1Array[cell1]), TL0(TL0Array[cell0]);
103 if((n[0]*from0toGhst[0]+n[1]*from0toGhst[1]+n[2]*from0toGhst[2])<0.)
119 for(
int binIndx=0;binIndx<binNos;binIndx++)
129 const T t01=transArray01[binIndx];
131 const T t10=transArray10[binIndx];
149 T v0dotN=vg0[0]*n[0]+vg0[1]*n[1]+vg0[2]*n[2];
160 in0sum-=v0dotN*dk30*mode0.
calce0(TL0);
171 T v1dotN=vg1[0]*n[0]+vg1[1]*n[1]+vg1[2]*n[2];
182 in1sum+=v1dotN*dk31*mode1.
calce0(TL1);
193 T v0dotN=vg0[0]*n[0]+vg0[1]*n[1]+vg0[2]*n[2];
208 T v1dotN=vg1[0]*n[0]+vg1[1]*n[1]+vg1[2]*n[2];
225 for(
int binIndx=0;binIndx<binNos;binIndx++)
235 const T t01=transArray01[binIndx];
237 const T t10=transArray10[binIndx];
255 T v0dotN=vg0[0]*n[0]+vg0[1]*n[1]+vg0[2]*n[2];
261 conn01->
addSelf(count0,count0,1.);
265 in0sum-=v0dotN*dk30*mode0.
calce0(TL0);
276 T v1dotN=vg1[0]*n[0]+vg1[1]*n[1]+vg1[2]*n[2];
282 conn10->
addSelf(count1,count1,1.);
286 in1sum+=v1dotN*dk31*mode1.
calce0(TL1);
296 T de0dT0=mode0.
calce0(TL0);
299 T v0dotN=vg0[0]*n[0]+vg0[1]*n[1]+vg0[2]*n[2];
303 for(
int kkI=0;kkI<k0kpts.
getLength();kkI++)
310 T vv0dotN=vvg0[0]*n[0]+vvg0[1]*n[1]+vvg0[2]*n[2];
314 T coeff=vv0dotN*ddk30/in0sum*r01*de0dT0;
315 conn01->
addSelf(count0,ccount0,coeff);
320 for(
int kkI=0;kkI<k1kpts.
getLength();kkI++)
327 T vv1dotN=vvg1[0]*n[0]+vvg1[1]*n[1]+vvg1[2]*n[2];
331 T coeff=-vv1dotN*ddk31/in0sum*t10*de0dT0;
332 conn01->
addOther(count0,ccount1,coeff);
344 T de0dT1=mode1.
calce0(TL1);
347 T v1dotN=vg1[0]*n[0]+vg1[1]*n[1]+vg1[2]*n[2];
351 for(
int kkI=0;kkI<k1kpts.
getLength();kkI++)
358 T vv1dotN=vvg1[0]*n[0]+vvg1[1]*n[1]+vvg1[2]*n[2];
362 T coeff=-vv1dotN*ddk31/in1sum*r10*de0dT1;
363 conn10->
addSelf(count1,ccount1,coeff);
368 for(
int kkI=0;kkI<k0kpts.
getLength();kkI++)
375 T vv0dotN=vvg0[0]*n[0]+vvg0[1]*n[1]+vvg0[2]*n[2];
379 T coeff=vv0dotN*ddk30/in1sum*t01*de0dT1;
380 conn10->
addOther(count1,ccount0,coeff);
404 const int Fid0=ic.
FgID0;
405 const int Fid1=ic.
FgID1;
410 const int faceCount=faces0.
getCount();
417 throw CException(
"Must have the same wave vector space on either side.");
423 for(
int f=0;f<faceCount;f++)
432 for(
int i=0;i<klen;i++)
446 for(
int i=0;i<klen;i++)
460 kclist01.push_back(conn01);
461 kclist10.push_back(conn10);
469 const int listSize=fineList.size();
470 for(
int ic=0;ic<listSize;ic++)
477 const int Fg0=fineIC.
FgID0;
478 const int Fg1=fineIC.
FgID1;
486 const IntArray& common01=*(ComMap.find(&fineFaces1)->second);
488 const int faceCount=fineFaces1.
getCount();
494 coarseList[ic]=coarseICptr;
503 Mesh& Cmesh0=*coarseMeshes[Mid0];
504 Mesh& Cmesh1=*coarseMeshes[Mid1];
511 for(
int f=0;f<faceCount;f++)
512 if(FineToCoarse0[f]>coarseCount)
513 coarseCount=FineToCoarse0[f];
517 IntArray& CoarseComm01=*CoarseComm01Ptr;
519 IntArray& CoarseComm10=*CoarseComm10Ptr;
522 Ckclist01.
resize(coarseCount, NULL);
524 Ckclist10.resize(coarseCount, NULL);
530 for(
int f=0;f<faceCount;f++)
531 sumArea[FineToCoarse0[f]]+=FArea0[f];
533 for(
int f=0;f<faceCount;f++)
535 const int f1=common01[f];
536 const int cF0=FineToCoarse0[f];
537 const int cF1=FineToCoarse1[f1];
538 CoarseComm01[cF0]=cF1;
539 CoarseComm10[cF1]=cF0;
540 const VectorT3& sumVec=sumArea[cF0];
542 const T num=sumVec[0]*partVec[0]+sumVec[1]*partVec[1]+
543 sumVec[2]*partVec[2];
544 const T den=sumVec[0]*sumVec[0]+sumVec[1]*sumVec[1]+
546 const T factor=num/den;
548 TKConn& Fconn01=*Fkclist01[f];
549 TKConn& Fconn10=*Fkclist10[f1];
551 if(Ckclist01[cF0]==NULL)
557 Ckclist01[cF0]=Cconn01;
561 TKConn Cconn01(k0len+1,k1len+1);
565 (Ckclist01[cF0])->addToSelf(Cconn01);
566 (Ckclist01[cF0])->addToOther(Cconn01);
569 if(Ckclist10[cF1]==NULL)
575 Ckclist10[cF1]=Cconn10;
579 TKConn Cconn10(k1len+1,k0len+1);
583 (Ckclist10[cF1])->addToSelf(Cconn10);
584 (Ckclist10[cF1])->addToOther(Cconn10);
589 coarseFaces0.
getCommonMap()[&coarseFaces1]=CoarseComm01Ptr;
590 coarseFaces1.
getCommonMap()[&coarseFaces0]=CoarseComm10Ptr;
842 const T DK30=kspace0.
getDK3();
843 const T DK31=kspace1.
getDK3();
847 const IntArray& common01=(*CommMap01.find(&faces1)->second);
851 const int numFaces=faces0.
getCount();
855 TArray transmitted(klen1);
860 for(
int f0=0;f0<numFaces;f0++)
862 const int cell0=faceCells0(f0,0);
863 const int f1=common01[f0];
864 const int cell1ghost=faceCells1(f1,1);
865 const int cell1=faceCells1(f1,0);
867 const TKConn& Kconn1=*KconnList1[f1];
877 transmitted+=reflected;
879 kspace1.
addFASint(cell1ghost,transmitted);
887 int Mid0,Mid1,Fid0,Fid1;
898 const T DK30=kspace0.
getDK3();
899 const T DK31=kspace1.
getDK3();
903 const IntArray& common01=(*CommMap01.find(&faces1)->second);
908 const int numFaces=faces0.
getCount();
912 TArray transmitted01(klen1);
913 TArray reflected10(klen1);
914 TArray transmitted10(klen0);
915 TArray reflected01(klen0);
918 TArray currentSol0(klen0);
919 TArray currentSol1(klen1);
921 for(
int f0=0;f0<numFaces;f0++)
923 int cell0=faceCells0(f0,0);
924 int cell0ghost=faceCells0(f0,1);
926 int cell1ghost=faceCells1(f1,1);
927 int cell1=faceCells1(f1,0);
929 const TKConn& Kconn1=*KconnList1[f1];
930 const TKConn& Kconn0=*KconnList0[f0];
942 transmitted01+=reflected10;
943 transmitted01-=currentSol1;
945 kspace1.
addFASint(cell1ghost,transmitted01);
950 transmitted10+=reflected01;
951 transmitted10-=currentSol0;
953 kspace0.
addFASint(cell0ghost,transmitted10);
969 throw CException(
"makeValueArray: Array not the same size as the k-space!");
981 for(
int k=0;k<kpts;k++)
985 for(
int m=0;m<numModes;m++)
989 o[count]=mode.
calce0(Temp);
995 throw CException(
"makeEquilibriumArray: Array not the same size as the k-space!");
1009 TlArray[cell]=BVec[klen];
1012 throw CException(
"Distribute: Array not the same size as the k-space!");
1025 throw CException(
"DistributeResid: Array not the same size as the k-space!");
1035 for(
int k=0;k<klen;k++)
1039 for(
int m=0;m<numModes;m++)
1060 const VectorT3 c0Pos=coordArray[cell0];
1061 const VectorT3 cGhstPos=coordArray[cell0ghost];
1062 const VectorT3 from0toGhst=cGhstPos-c0Pos;
1064 VectorT3 n=Af/
sqrt(pow(Af[0],2)+pow(Af[1],2)+pow(Af[2],2));
1066 if((n[0]*from0toGhst[0]+n[1]*from0toGhst[1]+n[2]*from0toGhst[2])<0.)
1073 for(
int k=0;k<kpts;k++)
1078 for(
int m=0;m<numModes;m++)
1082 T VdotN=vg[0]*n[0]+vg[1]*n[1]+vg[2]*n[2];
1086 sume+=eArray[index]*dk3;
1104 for(
int k=0;k<kpts;k++)
1108 for(
int m=0;m<numModes;m++)
1113 TArray& fasArray=
dynamic_cast<TArray&
>(fasField[cells]);
1114 bVec[count]+=fasArray[c];
1118 bVec[klen]+=fasArray[c];
void geteCellVals(const int c, TArray &o)
map< int, int > MeshKspaceMap
void addCountOther(const int index, const int count)
void addSelf(const int i, const int j, const T val)
void makeCoarseCoeffs(const IClist &fineList, IClist &coarseList, MeshList &coarseMeshes)
Tkvol & getkvol(int n) const
Tmode & getmode(int n) const
TArray & getTransArray(Tkspace &toKspace)
MeshKspaceMap _MeshKspaceMap
StorageSite::CommonMap CommonMap
const FaceGroup & getFaceGroup(const int fgId) const
const CommonMap & getCommonMap() const
const GeomFields & _geomFields
Array< int > * FineToCoarse1
COMETInterface(const MeshList &meshes, TkspList &klist, MeshKspaceMap &MKMap, PhononMacro ¯o, const GeomFields &geomFields)
void ZeroGhost(const int msh, const int cell)
void calcTemp(T &guess, const T e_sum, const Tvec An)
shared_ptr< FreqBin > BinPtr
void addCountSelf(const int index, const int count)
void updateResid(const COMETIC< T > &ic, const bool plusFAS)
void copyFrom(KSConnectivity &from)
Tangent sqrt(const Tangent &a)
const CRConnectivity & getCellFaces() const
void makeDMMcoeffs(COMETIC< T > &ic)
void multiplyOther(const TArray &x, TArray &b, const T scale) const
void makeEquilibriumArray(const int msh, const T Temp, TArray &o)
void setResidCell(const int c, const TArray &o)
void resize(const int newLength)
void updateOtherGhost(const COMETIC< T > &ic, const int Mid0, const bool plusFAS)
Array< VectorT3 > VectorT3Array
DensityOfStates< T > DOST
map< const StorageSite *, shared_ptr< Array< int > > > CommonMap
IntArray & getMIndices(const int fBin)
vector< Tkspace * > TkspList
const CRConnectivity & getCellCells() const
const StorageSite & getCells() const
StorageSite::ScatterMap ScatterMap
void makeNoInterfaceCoeffs(COMETIC< T > &ic)
const ScatterMap & getScatterMap() const
const CRConnectivity & getFaceCells(const StorageSite &site) const
map< const StorageSite *, shared_ptr< Array< int > > > ScatterMap
DensityOfStates< T > * getDOSptr()
void makeValueArray(const int msh, const int c, TArray &o)
Vector< T_Scalar, 3 > VectorT3
shared_ptr< IntArray > IntArrayPtr
void findWallTemp(const int meshID, const int cell0, const int cell0ghost, const VectorT3 Af, T &Tguess)
Array< int > * FineToCoarse0
IntArray & getKIndices(const int fBin)
void Distribute(const int msh, const int cell, TArray &BVec)
void DistributeResid(const int msh, const int cell, TArray &BVec)
KSConnectivity< T > TKConn
void multiplySelf(const TArray &x, TArray &b, const T scale) const
vector< COMETIC< T > * > IClist
void addOther(const int i, const int j, const T val)
void seteCellVals(const int c, const TArray &o)
vector< TKConn * > TKClist
void addFAS(const int msh, const int c, TArray &bVec)
vector< Mesh * > MeshList
NumTypeTraits< T >::T_Scalar T_Scalar
void addFASint(const int c, TArray &Bvec)
const TKClist & getKConnectivity(const int fgid) const