Memosa-FVM  0.2
COMETModel< T > Class Template Reference

#include <COMETModel.h>

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

Public Types

typedef NumTypeTraits< T >
::T_Scalar 
T_Scalar
 
typedef Array< int > IntArray
 
typedef Array< T > TArray
 
typedef shared_ptr< TArrayTArrptr
 
typedef Array< bool > BArray
 
typedef Array2D< T > TArray2D
 
typedef Vector< T, 3 > VectorT3
 
typedef Array< VectorT3VectorT3Array
 
typedef shared_ptr< VectorT3ArrayVT3Ptr
 
typedef StressTensor< T > StressTensorT6
 
typedef Array< StressTensorT6StressTensorArray
 
typedef std::vector< Field * > stdVectorField
 
typedef DistFunctFields< T > TDistFF
 
typedef Vector< T, 5 > VectorT5
 
typedef Array< VectorT5VectorT5Array
 
typedef Vector< T, 6 > VectorT6
 
typedef Array< VectorT6VectorT6Array
 
typedef Vector< T, 10 > VectorT10
 
typedef Array< VectorT10VectorT10Array
 
typedef shared_ptr< MeshListMshLstPtr
 
typedef shared_ptr< MeshMeshPtr
 
typedef shared_ptr< GeomFieldsGeoFldsPtr
 
typedef shared_ptr< StorageSiteSSPtr
 
typedef shared_ptr
< CRConnectivity
CRPtr
 
typedef Array< int > BCfaceArray
 
typedef shared_ptr< BCfaceArrayBfacePtr
 
typedef vector< BfacePtrBCfaceList
 
typedef Array< int > BCcellArray
 
typedef shared_ptr< BCcellArrayBCellPtr
 
typedef vector< BCellPtrBCcellList
 
typedef Quadrature< T > TQuad
 
typedef std::map< int, COMETBC
< T > * > 
COMETBCMap
 
typedef std::map< int, COMETVC
< T > * > 
COMETVCMap
 
typedef COMETModel< T > TCOMET
 
typedef shared_ptr< TCOMETTCOMETPtr
 
typedef MultiField::ArrayIndex Index
 
typedef pair< Index, IndexEntryIndex
 
typedef pair< const
StorageSite *, const
StorageSite * > 
SSPair
 
typedef map< EntryIndex,
shared_ptr< Matrix > > 
MatrixMap
 
typedef map< Index, int > MatrixSizeMap
 
typedef map< const Mesh *, int > SizeMap
 
typedef map< const StorageSite
*, StorageSite * > 
SiteMap
 
typedef map< SSPair,
shared_ptr< Array< int > > > 
MatrixMappersMap
 
typedef map< Index, shared_ptr
< StorageSite > > 
StorageSiteMap
 
typedef map< const StorageSite
*, shared_ptr< StorageSite > > 
GhostStorageSiteMap
 
typedef NumTypeTraits< T >
::T_Scalar 
T_Scalar
 
typedef Vector< T_Scalar, 3 > VectorT3
 
typedef Array< VectorT3VectorT3Array
 
typedef shared_ptr< VectorT3ArrayVT3Ptr
 
typedef Kspace< T > Tkspace
 
typedef TkspaceTkspPtr
 
typedef vector< Tkspace * > TkspList
 
typedef kvol< T > Tkvol
 
typedef pmode< T > Tmode
 
typedef Array< bool > BArray
 
typedef Array< int > IntArray
 
typedef shared_ptr< IntArrayIntArrPtr
 
typedef Array< T > TArray
 
typedef shared_ptr< TArrayTArrptr
 
typedef map< int, COMETBC< T > * > COMETBCMap
 
typedef vector< COMETIC< T > * > IClist
 
typedef map< int, int > MeshKspaceMap
 
typedef COMETModel< T > TCOMET
 
typedef shared_ptr< TCOMETTCOMETPtr
 
typedef COMETModelOptions< T > TCModOpts
 
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 shared_ptr< MeshListMshLstPtr
 
typedef shared_ptr< MeshMeshPtr
 
typedef shared_ptr< GeomFieldsGeoFldsPtr
 
typedef shared_ptr< TkspaceKspPtr
 
typedef shared_ptr< PhononMacroPMacroPtr
 
typedef shared_ptr< StorageSiteSSPtr
 
typedef shared_ptr
< CRConnectivity
CRPtr
 
typedef Array< int > BCfaceArray
 
typedef shared_ptr< BCfaceArrayBfacePtr
 
typedef vector< BfacePtrBCfaceList
 
typedef Array< int > BCcellArray
 
typedef shared_ptr< BCcellArrayBCellPtr
 
typedef vector< BCellPtrBCcellList
 
typedef vector< IntArrPtrMeshICmap
 
typedef KSConnectivity< T > TKConnectivity
 
typedef TKConnectivityTKCptr
 
typedef vector< TKCptrTKClist
 
typedef map< int, TKClistFgTKClistMap
 
typedef vector< shared_ptr
< Field > > 
FieldVector
 
typedef pair< const
StorageSite *, const
StorageSite * > 
SSPair
 
typedef map< SSPair,
shared_ptr< Array< int > > > 
ScatGathMaps
 
typedef map< const StorageSite
*, StorageSite * > 
SiteMap
 

Public Member Functions

 COMETModel (const MeshList &meshes, const int level, GeomFields &geomFields, MacroFields &macroFields, Quadrature< T > &quad, const int ibm=0, GeomFields *finestGeomFields=NULL, const MeshList *finestMeshes=NULL, MacroFields *finestMacroFields=NULL)
 
void init ()
 
void MakeCoarseModel (TCOMET *finerModel)
 
void MakeIBCoarseModel (TCOMET *finerModel, const StorageSite &solidFaces)
 
void MakeCoarseIndex (const StorageSite &solidFaces)
 
void MakeParallel ()
 
void InitializeMacroparameters ()
 
void InitializeFgammaCoefficients ()
 
void ComputeMacroparameters ()
 
void ComputeCOMETMacroparameters ()
 
void ComputeFineMacroparameters ()
 
void ComputeCoarseMacroparameters ()
 
void ComputeMacroparametersESBGK ()
 
void ComputeCollisionfrequency ()
 
void MomentHierarchy ()
 
void EntropyGeneration ()
 
void initializeMaxwellianEq ()
 
void NewtonsMethodBGK (const int ktrial)
 
void EquilibriumDistributionBGK ()
 
void setJacobianBGK (SquareMatrix< T, 5 > &fjac, VectorT5 &fvec, const VectorT5 &xn, const VectorT3 &v, const int c)
 
void NewtonsMethodESBGK (const int ktrial)
 
void EquilibriumDistributionESBGK ()
 
void setJacobianESBGK (SquareMatrix< T, 10 > &fjac, VectorT10 &fvec, const VectorT10 &xn, const VectorT3 &v, const int c)
 
void initializeMaxwellian ()
 
void initializeFineMaxwellian ()
 
void initializeCoarseMaxwellian ()
 
void weightedMaxwellian (double weight1, double uvel1, double vvel1, double wvel1, double uvel2, double vvel2, double wvel2, double temp1, double temp2)
 
void weightedMaxwellian (double weight1, double uvel1, double uvel2, double temp1, double temp2)
 
COMETBCMapgetBCMap ()
 
COMETVCMapgetVCMap ()
 
COMETModelOptions< T > & getOptions ()
 
const map< int, vector< int > > & getFaceReflectionArrayMap () const
 
map< string, shared_ptr
< ArrayBase > > & 
getPersistenceData ()
 
void restart ()
 
void SetBoundaryConditions ()
 
void updateTime ()
 
void callCOMETBoundaryConditions ()
 
void OutputDsfBLOCK (const char *filename)
 
void MakeCoarseMesh1 (const MeshList &inMeshes, GeomFields &inGeomFields, MeshList &outMeshes)
 
int MakeCoarseMesh2 (const MeshList &inMeshes, GeomFields &inGeomFields, GeomFields &coarseGeomFields, MeshList &outMeshes)
 
void syncGhostCoarsening (const MeshList &inMeshes, GeomFields &inGeomFields, MeshList &outMeshes)
 
void computeIBFaceDsf (const StorageSite &solidFaces, const int method, const int RelaxDistribution=0)
 
void computeSolidFacePressure (const StorageSite &solidFaces)
 
void computeSolidFaceDsf (const StorageSite &solidFaces, const int method, const int RelaxDistribution=0)
 
void correctMassDeficit ()
 
void correctMassDeficit2 (double n1, double n2)
 
const double ConservationofMassCheck ()
 
void ConservationofMFSolid (const StorageSite &solidFaces) const
 
void doSweeps (const int sweeps, const int num)
 
void doSweeps (const int sweeps, const int num, const StorageSite &solidFaces)
 
void smooth (const int num, const StorageSite &solidFaces)
 
void smooth (const int num)
 
updateResid (const bool addFAS)
 
updateResid (const bool addFAS, const StorageSite &solidFaces)
 
void cycle ()
 
void cycle (const StorageSite &solidFaces)
 
void injectResid ()
 
void makeFAS ()
 
void makeFAS (const StorageSite &solidFaces)
 
void correctSolution ()
 
void advance (const int iters)
 
advance (const int iters, const StorageSite &solidFaces)
 
void computeSurfaceForce (const StorageSite &solidFaces, bool perUnitArea, bool IBM=0)
 
void OutputDsfPOINT ()
 
DistFunctFields< T > & getdsf ()
 
const DistFunctFields< T > & getdsf1 () const
 
const DistFunctFields< T > & getdsf2 () const
 
const DistFunctFields< T > & getdsfEq () const
 
const DistFunctFields< T > & getdsfEqES () const
 
DistFunctFields< T > & getdsf0 ()
 
DistFunctFields< T > & getdsfInj ()
 
DistFunctFields< T > & getdsfRes ()
 
DistFunctFields< T > & getdsfFAS ()
 
void setBCMap (COMETBCMap *bcMap)
 
void setCoarserLevel (TCOMET *cl)
 
void setFinerLevel (TCOMET *fl)
 
int getLevel ()
 
const MeshListgetMeshList ()
 
GeomFieldsgetGeomFields ()
 
TQuadgetQuadrature ()
 
MacroFieldsgetMacro ()
 
getResidual ()
 
 COMETModel (const MeshList &meshes, const int level, GeomFields &geomFields, TkspList &kspaces, PhononMacro &macro)
 
TCModOptsgetOptions ()
 
COMETBCMapgetBCs ()
 
MeshKspaceMapgetMKMap ()
 
void init ()
 
void initFromOld ()
 
void initCoarse ()
 
void setLocalScatterMaps (const Mesh &mesh0, StorageSite &faces0, const Mesh &mesh1, StorageSite &faces1)
 
void applyTemperatureBoundaries ()
 
void initializeTemperatureBoundaries ()
 
void MakeCoarseModel (TCOMET *finerModel)
 
void setFinestLevel (TCOMET *finest)
 
void MakeNewKspaces (TkspList &inList, TkspList &outList)
 
void MakeInteriorCoarseMesh (const MeshList &inMeshes, GeomFields &inGeomFields, MeshList &outMeshes, IntArray &CoarseCounts, map< const StorageSite *, IntArray * > &PreFacePairMap, IntArray &CoarseGhost, SiteMap &siteMap)
 
void syncGhostCoarsening (const MeshList &inMeshes, GeomFields &inGeomFields, MeshList &outMeshes, ScatGathMaps &coarseScatMaps, ScatGathMaps &coarseGathMaps, IntArray &coarseSizes, IntArray &CoarseGhost)
 
void makeCoarseScatGath (const MeshList &inMeshes, SiteMap &siteMap, ScatGathMaps &coarseScatMaps, ScatGathMaps &coarseGathMaps)
 
int FinishCoarseMesh (const MeshList &inMeshes, GeomFields &inGeomFields, MeshList &outMeshes, IntArray &CoarseCounts, map< const StorageSite *, IntArray * > &PreFacePairMap, IntArray &coarseGhost)
 
int coarsenInterior (const int m, const Mesh &mesh, GeomFields &inGeomFields, int &coarseCount)
 
int correctSingleNeighbor (const int m, const Mesh &mesh, GeomFields &inGeomFields, int coarseCount, map< const StorageSite *, IntArray * > PreFacePairMap)
 
void coarsenInterfaceCells (COMETIC< T > &ic, IntArray &coarseCounts, GeomFields &inGeomFields, const MeshList &inMeshes)
 
void doSweeps (const int sweeps)
 
void smooth (int dir)
 
updateResid (const bool addFAS)
 
void swapGhostInfo ()
 
void cycle ()
 
void injectResid ()
 
void makeFAS ()
 
void sete0 ()
 
void correctSolution ()
 
void updateTL ()
 
void advance (const int iters)
 
HeatFluxIntegral (const Mesh &mesh, const int faceGroupId)
 
HeatFluxIntegralFace (const Mesh &mesh, const int f)
 
ArrayBasebinwiseHeatFluxIntegral (const Mesh &mesh, const int faceGroupId)
 
ArrayBasemodewiseHeatFluxIntegral (const Mesh &mesh, const int faceGroupId)
 
getWallArea (const Mesh &mesh, const int faceGroupId)
 
VectorT3 getWallAreaVector (const Mesh &mesh, const int faceGroupId)
 
ArrayBasegetValueArray (const Mesh &mesh, const int cell)
 
void equilibrate ()
 
ArrayBasegetLatticeTemp (const Mesh &mesh)
 
void setStraightLine (const T T1, const T T2)
 
void calcModeTemps ()
 
void calcBandTemps ()
 
void calcBandRelEnergy ()
 
void calcModeFlux ()
 
void calcBandFlux ()
 
calcDomainStats ()
 
void makeCellColors (const int level)
 
void makePlotColors (const int level)
 
void makeFinestToCoarseConn ()
 
TCOMETgetModelPointer (const int level)
 
bool sameFaceGroup (const Mesh &mesh, const int f0, const int f1)
 
getAverageTemperature ()
 
void makeNonEqTemp ()
 
void setBCMap (COMETBCMap *bcMap)
 
void setCoarserLevel (TCOMET *cl)
 
void setFinerLevel (TCOMET *fl)
 
TCOMETgetFinerModel ()
 
int getLevel ()
 
const MeshListgetMeshList ()
 
GeomFieldsgetGeomFields ()
 
TkspListgetKspaces ()
 
TkspacegetKspace (const int i)
 
PhononMacrogetMacro ()
 
getResidual ()
 
IClistgetIClist ()
 
MeshICmapgetMeshICmap ()
 
- Public Member Functions inherited from Model
 Model (const MeshList &meshes)
 
virtual ~Model ()
 
 DEFINE_TYPENAME ("Model")
 

Private Attributes

const int _level
 
GeomFields_geomFields
 
GeomFields _coarseGeomFields
 
GeomFields_finestGeomFields
 
const MeshList_finestMeshes
 
Quadrature< T > & _quadrature
 
const int _ibm
 
MacroFields_macroFields
 
MacroFields_finestMacroFields
 
TCOMET_finestLevel
 
TCOMET_coarserLevel
 
TCOMET_finerLevel
 
DistFunctFields< T > _dsfPtr
 
DistFunctFields< T > _dsfPtr1
 
DistFunctFields< T > _dsfPtr2
 
DistFunctFields< T > _dsfEqPtr
 
DistFunctFields< T > _dsfEqPtrES
 
DistFunctFields< T > _dsfPtr0
 
DistFunctFields< T > _dsfPtrInj
 
DistFunctFields< T > _dsfPtrRes
 
DistFunctFields< T > _dsfPtrFAS
 
COMETBCMap _bcMap
 
COMETVCMap _vcMap
 
COMETModelOptions< T > _options
 
_residual
 
_initialResidual
 
MFRPtr _initialKmodelNorm
 
BCcellList _BCells
 
BCfaceList _BFaces
 
BCcellList _ZCells
 
int _niters
 
map< int, vector< int > > _faceReflectionArrayMap
 
map< string, shared_ptr
< ArrayBase > > 
_persistenceData
 
SizeMap _coarseSizes
 
SizeMap _coarseGhostSizes
 
SiteMap _siteMap
 
GhostStorageSiteMap _sharedSiteMap
 
MatrixMappersMap _coarseScatterMaps
 
MatrixMappersMap _coarseGatherMaps
 
TkspList_kspaces
 
PhononMacro_macro
 
TCModOpts _options
 
MeshKspaceMap _MeshKspaceMap
 
IClist _IClist
 
MeshICmap _MeshToIC
 
int _rank
 

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 COMETModel< T >

Definition at line 51 of file esbgkbase/COMETModel.h.

Member Typedef Documentation

template<class T >
typedef Array<bool> COMETModel< T >::BArray

Definition at line 35 of file phononbase/COMETModel.h.

template<class T >
typedef Array<bool> COMETModel< T >::BArray

Definition at line 58 of file esbgkbase/COMETModel.h.

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

Definition at line 61 of file phononbase/COMETModel.h.

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

Definition at line 84 of file esbgkbase/COMETModel.h.

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

Definition at line 63 of file phononbase/COMETModel.h.

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

Definition at line 86 of file esbgkbase/COMETModel.h.

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

Definition at line 62 of file phononbase/COMETModel.h.

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

Definition at line 85 of file esbgkbase/COMETModel.h.

template<class T >
typedef Array<int> COMETModel< T >::BCfaceArray

Definition at line 58 of file phononbase/COMETModel.h.

template<class T >
typedef Array<int> COMETModel< T >::BCfaceArray

Definition at line 81 of file esbgkbase/COMETModel.h.

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

Definition at line 60 of file phononbase/COMETModel.h.

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

Definition at line 83 of file esbgkbase/COMETModel.h.

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

Definition at line 59 of file phononbase/COMETModel.h.

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

Definition at line 82 of file esbgkbase/COMETModel.h.

template<class T >
typedef map<int,COMETBC<T>*> COMETModel< T >::COMETBCMap

Definition at line 40 of file phononbase/COMETModel.h.

template<class T >
typedef std::map<int,COMETBC<T>*> COMETModel< T >::COMETBCMap

Definition at line 90 of file esbgkbase/COMETModel.h.

template<class T >
typedef std::map<int,COMETVC<T>*> COMETModel< T >::COMETVCMap

Definition at line 91 of file esbgkbase/COMETModel.h.

template<class T >
typedef shared_ptr<CRConnectivity> COMETModel< T >::CRPtr

Definition at line 57 of file phononbase/COMETModel.h.

template<class T >
typedef shared_ptr<CRConnectivity> COMETModel< T >::CRPtr

Definition at line 79 of file esbgkbase/COMETModel.h.

template<class T >
typedef pair<Index,Index> COMETModel< T >::EntryIndex

Definition at line 96 of file esbgkbase/COMETModel.h.

template<class T >
typedef map<int, TKClist> COMETModel< T >::FgTKClistMap

Definition at line 68 of file phononbase/COMETModel.h.

template<class T >
typedef vector<shared_ptr<Field> > COMETModel< T >::FieldVector

Definition at line 69 of file phononbase/COMETModel.h.

template<class T >
typedef shared_ptr<GeomFields> COMETModel< T >::GeoFldsPtr

Definition at line 53 of file phononbase/COMETModel.h.

template<class T >
typedef shared_ptr<GeomFields> COMETModel< T >::GeoFldsPtr

Definition at line 77 of file esbgkbase/COMETModel.h.

template<class T >
typedef map<const StorageSite*,shared_ptr<StorageSite> > COMETModel< T >::GhostStorageSiteMap

Definition at line 107 of file esbgkbase/COMETModel.h.

template<class T >
typedef vector<COMETIC<T>*> COMETModel< T >::IClist

Definition at line 41 of file phononbase/COMETModel.h.

template<class T >
typedef MultiField::ArrayIndex COMETModel< T >::Index

Definition at line 95 of file esbgkbase/COMETModel.h.

template<class T >
typedef Array<int> COMETModel< T >::IntArray

Definition at line 36 of file phononbase/COMETModel.h.

template<class T >
typedef Array<int> COMETModel< T >::IntArray

Definition at line 55 of file esbgkbase/COMETModel.h.

template<class T >
typedef shared_ptr<IntArray> COMETModel< T >::IntArrPtr

Definition at line 37 of file phononbase/COMETModel.h.

template<class T >
typedef shared_ptr<Tkspace> COMETModel< T >::KspPtr

Definition at line 54 of file phononbase/COMETModel.h.

template<class T >
typedef map<EntryIndex,shared_ptr<Matrix> > COMETModel< T >::MatrixMap

Definition at line 99 of file esbgkbase/COMETModel.h.

template<class T >
typedef map<SSPair,shared_ptr<Array<int> > > COMETModel< T >::MatrixMappersMap

Definition at line 104 of file esbgkbase/COMETModel.h.

template<class T >
typedef map<Index,int> COMETModel< T >::MatrixSizeMap

Definition at line 100 of file esbgkbase/COMETModel.h.

template<class T >
typedef vector<IntArrPtr> COMETModel< T >::MeshICmap

Definition at line 64 of file phononbase/COMETModel.h.

template<class T >
typedef map<int,int> COMETModel< T >::MeshKspaceMap

Definition at line 42 of file phononbase/COMETModel.h.

template<class T >
typedef shared_ptr<Mesh> COMETModel< T >::MeshPtr

Definition at line 52 of file phononbase/COMETModel.h.

template<class T >
typedef shared_ptr<Mesh> COMETModel< T >::MeshPtr

Definition at line 76 of file esbgkbase/COMETModel.h.

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

Definition at line 46 of file phononbase/COMETModel.h.

template<class T >
typedef shared_ptr<MeshList> COMETModel< T >::MshLstPtr

Definition at line 51 of file phononbase/COMETModel.h.

template<class T >
typedef shared_ptr<MeshList> COMETModel< T >::MshLstPtr

Definition at line 75 of file esbgkbase/COMETModel.h.

template<class T >
typedef shared_ptr<PhononMacro> COMETModel< T >::PMacroPtr

Definition at line 55 of file phononbase/COMETModel.h.

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

Definition at line 50 of file phononbase/COMETModel.h.

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

Definition at line 49 of file phononbase/COMETModel.h.

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

Definition at line 47 of file phononbase/COMETModel.h.

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

Definition at line 48 of file phononbase/COMETModel.h.

template<class T >
typedef map<SSPair,shared_ptr<Array<int> > > COMETModel< T >::ScatGathMaps

Definition at line 71 of file phononbase/COMETModel.h.

template<class T >
typedef map<const StorageSite*, StorageSite*> COMETModel< T >::SiteMap

Definition at line 72 of file phononbase/COMETModel.h.

template<class T >
typedef map<const StorageSite*,StorageSite*> COMETModel< T >::SiteMap

Definition at line 102 of file esbgkbase/COMETModel.h.

template<class T >
typedef map<const Mesh*,int> COMETModel< T >::SizeMap

Definition at line 101 of file esbgkbase/COMETModel.h.

template<class T >
typedef pair<const StorageSite*, const StorageSite*> COMETModel< T >::SSPair

Definition at line 70 of file phononbase/COMETModel.h.

template<class T >
typedef pair<const StorageSite*, const StorageSite*> COMETModel< T >::SSPair

Definition at line 97 of file esbgkbase/COMETModel.h.

template<class T >
typedef shared_ptr<StorageSite> COMETModel< T >::SSPtr

Definition at line 56 of file phononbase/COMETModel.h.

template<class T >
typedef shared_ptr<StorageSite> COMETModel< T >::SSPtr

Definition at line 78 of file esbgkbase/COMETModel.h.

template<class T >
typedef std::vector<Field*> COMETModel< T >::stdVectorField

Definition at line 65 of file esbgkbase/COMETModel.h.

template<class T >
typedef map<Index,shared_ptr<StorageSite> > COMETModel< T >::StorageSiteMap

Definition at line 106 of file esbgkbase/COMETModel.h.

template<class T >
typedef Array<StressTensorT6> COMETModel< T >::StressTensorArray

Definition at line 64 of file esbgkbase/COMETModel.h.

template<class T >
typedef StressTensor<T> COMETModel< T >::StressTensorT6

Definition at line 63 of file esbgkbase/COMETModel.h.

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

Definition at line 26 of file phononbase/COMETModel.h.

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

Definition at line 54 of file esbgkbase/COMETModel.h.

template<class T >
typedef Array<T> COMETModel< T >::TArray

Definition at line 38 of file phononbase/COMETModel.h.

template<class T >
typedef Array<T> COMETModel< T >::TArray

Definition at line 56 of file esbgkbase/COMETModel.h.

template<class T >
typedef Array2D<T> COMETModel< T >::TArray2D

Definition at line 59 of file esbgkbase/COMETModel.h.

template<class T >
typedef shared_ptr<TArray> COMETModel< T >::TArrptr

Definition at line 39 of file phononbase/COMETModel.h.

template<class T >
typedef shared_ptr<TArray> COMETModel< T >::TArrptr

Definition at line 57 of file esbgkbase/COMETModel.h.

template<class T >
typedef COMETModelOptions<T> COMETModel< T >::TCModOpts

Definition at line 45 of file phononbase/COMETModel.h.

template<class T >
typedef COMETModel<T> COMETModel< T >::TCOMET

Definition at line 43 of file phononbase/COMETModel.h.

template<class T >
typedef COMETModel<T> COMETModel< T >::TCOMET

Definition at line 92 of file esbgkbase/COMETModel.h.

template<class T >
typedef shared_ptr<TCOMET> COMETModel< T >::TCOMETPtr

Definition at line 44 of file phononbase/COMETModel.h.

template<class T >
typedef shared_ptr<TCOMET> COMETModel< T >::TCOMETPtr

Definition at line 93 of file esbgkbase/COMETModel.h.

template<class T >
typedef DistFunctFields<T> COMETModel< T >::TDistFF

Definition at line 66 of file esbgkbase/COMETModel.h.

template<class T >
typedef vector<TKCptr> COMETModel< T >::TKClist

Definition at line 67 of file phononbase/COMETModel.h.

template<class T >
typedef KSConnectivity<T> COMETModel< T >::TKConnectivity

Definition at line 65 of file phononbase/COMETModel.h.

template<class T >
typedef TKConnectivity* COMETModel< T >::TKCptr

Definition at line 66 of file phononbase/COMETModel.h.

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

Definition at line 30 of file phononbase/COMETModel.h.

template<class T >
typedef vector<Tkspace*> COMETModel< T >::TkspList

Definition at line 32 of file phononbase/COMETModel.h.

template<class T >
typedef Tkspace* COMETModel< T >::TkspPtr

Definition at line 31 of file phononbase/COMETModel.h.

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

Definition at line 33 of file phononbase/COMETModel.h.

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

Definition at line 34 of file phononbase/COMETModel.h.

template<class T >
typedef Quadrature<T> COMETModel< T >::TQuad

Definition at line 88 of file esbgkbase/COMETModel.h.

template<class T >
typedef Vector<T,10> COMETModel< T >::VectorT10

Definition at line 72 of file esbgkbase/COMETModel.h.

template<class T >
typedef Array<VectorT10> COMETModel< T >::VectorT10Array

Definition at line 73 of file esbgkbase/COMETModel.h.

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

Definition at line 27 of file phononbase/COMETModel.h.

template<class T >
typedef Vector<T,3> COMETModel< T >::VectorT3

Definition at line 60 of file esbgkbase/COMETModel.h.

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

Definition at line 28 of file phononbase/COMETModel.h.

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

Definition at line 61 of file esbgkbase/COMETModel.h.

template<class T >
typedef Vector<T,5> COMETModel< T >::VectorT5

Definition at line 68 of file esbgkbase/COMETModel.h.

template<class T >
typedef Array<VectorT5> COMETModel< T >::VectorT5Array

Definition at line 69 of file esbgkbase/COMETModel.h.

template<class T >
typedef Vector<T,6> COMETModel< T >::VectorT6

Definition at line 70 of file esbgkbase/COMETModel.h.

template<class T >
typedef Array<VectorT6> COMETModel< T >::VectorT6Array

Definition at line 71 of file esbgkbase/COMETModel.h.

template<class T >
typedef shared_ptr<VectorT3Array> COMETModel< T >::VT3Ptr

Definition at line 29 of file phononbase/COMETModel.h.

template<class T >
typedef shared_ptr<VectorT3Array> COMETModel< T >::VT3Ptr

Definition at line 62 of file esbgkbase/COMETModel.h.

Constructor & Destructor Documentation

template<class T >
COMETModel< T >::COMETModel ( const MeshList meshes,
const int  level,
GeomFields geomFields,
MacroFields macroFields,
Quadrature< T > &  quad,
const int  ibm = 0,
GeomFields finestGeomFields = NULL,
const MeshList finestMeshes = NULL,
MacroFields finestMacroFields = NULL 
)
inline

Calculation of macro-parameters density, temperature, components of velocity, pressure by taking moments of distribution function using quadrature points and weights from quadrature.h

Definition at line 115 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_BCells, COMETModel< T >::_BFaces, COMETModel< T >::_level, Model::_meshes, COMETModel< T >::_vcMap, COMETModel< T >::_ZCells, COMETModel< T >::ComputeCollisionfrequency(), COMETModel< T >::ComputeFineMacroparameters(), COMETModel< T >::ComputeMacroparameters(), Mesh::getCells(), StorageSite::getCount(), Mesh::getFaces(), Mesh::getID(), StorageSite::getSelfCount(), COMETModel< T >::init(), COMETModel< T >::initializeFineMaxwellian(), COMETModel< T >::InitializeMacroparameters(), COMETModel< T >::initializeMaxwellian(), COMETModel< T >::initializeMaxwellianEq(), COMETModel< T >::SetBoundaryConditions(), and COMETVC< T >::vcType.

Referenced by COMETModel< T >::MakeCoarseModel(), and COMETModel< T >::MakeIBCoarseModel().

116  :
117 
118  Model(meshes),
119  _level(level),
120  _geomFields(geomFields),
121  _quadrature(quad),
122  _macroFields(macroFields),
123  _dsfPtr(_meshes,_quadrature,"dsf_"),
124  _dsfPtr1(_meshes,_quadrature,"dsf1_"),
125  _dsfPtr2(_meshes,_quadrature,"dsf2_"),
126  _dsfEqPtr(_meshes,_quadrature,"dsfEq_"),
127  _dsfEqPtrES(_meshes,_quadrature,"dsfEqES_"),
128  _dsfPtr0(_meshes,_quadrature,"dsf0_"),
129  _dsfPtrInj(_meshes,_quadrature,"dsfInj_"),
130  _dsfPtrRes(_meshes,_quadrature,"dsfRes_"),
131  _dsfPtrFAS(_meshes,_quadrature,"dsfFAS_"),
132  _coarseGeomFields("coarse"),
134  _niters(0),
135  _residual(0.0),
136  _initialResidual(0.0),
137  _ibm(ibm),
138  _finestGeomFields(finestGeomFields ? *finestGeomFields : _geomFields),
139  _finestMeshes(finestMeshes ? *finestMeshes : _meshes),
140  _finestMacroFields(finestMacroFields ? *finestMacroFields : _macroFields)
141  {
142 
143  const int numMeshes = _meshes.size();
144  for (int n=0; n<numMeshes; n++)
145  {
146  const Mesh& mesh = *_meshes[n];
147  const StorageSite& faces=mesh.getFaces();
148  const StorageSite& cells=mesh.getCells();
149  const int faceCount=faces.getCount();
150  const int cellCount=cells.getSelfCount();
151 
152  BfacePtr BFptr(new BCfaceArray(faceCount));
153  BFptr->zero();
154  _BFaces.push_back(BFptr);
155 
156  BCellPtr BCptr(new BCcellArray(cellCount));
157  _BCells.push_back(BCptr);
158  BCptr->zero();
159 
160  BCellPtr ZCptr(new BCcellArray(cellCount));
161  _ZCells.push_back(ZCptr);
162  ZCptr->zero();
163  if(_level==0)
164  {
165  COMETVC<T> *vc(new COMETVC<T>());
166  vc->vcType = "flow";
167  _vcMap[mesh.getID()] = vc;
168  }
169  }
170 
171  if(_level==0)
172  {
174  init();
178  ComputeMacroparameters(); //calculate density,velocity,temperature
180  ComputeCollisionfrequency(); //calculate viscosity, collisionFrequency
181  initializeMaxwellianEq(); //equilibrium distribution
182  }
183  }
const MeshList & _finestMeshes
Array< int > BCcellArray
DistFunctFields< T > _dsfPtrInj
GeomFields & _geomFields
int getSelfCount() const
Definition: StorageSite.h:40
Model(const MeshList &meshes)
Definition: Model.cpp:8
shared_ptr< BCcellArray > BCellPtr
DistFunctFields< T > _dsfPtr2
Quadrature< T > & _quadrature
Definition: Mesh.h:49
void initializeFineMaxwellian()
void ComputeCollisionfrequency()
shared_ptr< BCfaceArray > BfacePtr
void ComputeFineMacroparameters()
DistFunctFields< T > _dsfPtrFAS
void initializeMaxwellianEq()
GeomFields & _finestGeomFields
const StorageSite & getFaces() const
Definition: Mesh.h:108
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
void ComputeMacroparameters()
DistFunctFields< T > _dsfEqPtrES
MacroFields & _finestMacroFields
void SetBoundaryConditions()
DistFunctFields< T > _dsfPtr0
DistFunctFields< T > _dsfPtrRes
DistFunctFields< T > _dsfPtr
int getCount() const
Definition: StorageSite.h:39
DistFunctFields< T > _dsfPtr1
GeomFields _coarseGeomFields
DistFunctFields< T > _dsfEqPtr
void InitializeMacroparameters()
int getID() const
Definition: Mesh.h:106
Array< int > BCfaceArray
template<class T >
COMETModel< T >::COMETModel ( const MeshList meshes,
const int  level,
GeomFields geomFields,
TkspList kspaces,
PhononMacro macro 
)
inline

Definition at line 74 of file phononbase/COMETModel.h.

References COMETModel< T >::_BCells, COMETModel< T >::_bcMap, COMETModel< T >::_BFaces, COMETModel< T >::_level, Model::_meshes, COMETModel< T >::_MeshKspaceMap, COMETModel< T >::_rank, Mesh::getBoundaryFaceGroups(), Mesh::getCells(), StorageSite::getCount(), Mesh::getFaces(), and FaceGroup::id.

75  :
76  Model(meshes),
77  _level(level),
78  _geomFields(geomFields),
79  _kspaces(kspaces),
80  _macro(macro),
81  _finestLevel(NULL),
82  _coarserLevel(NULL),
83  _finerLevel(NULL),
84  _residual(1.0),
85  _MeshToIC(),
86  _rank(-1)
87  {
88  const int numMeshes = _meshes.size();
89 
90 #ifdef FVM_PARALLEL
91  _rank=MPI::COMM_WORLD.Get_rank();
92 #endif
93 
94  for (int n=0; n<numMeshes; n++)
95  {
96  Mesh& mesh = *_meshes[n];
97  const StorageSite& faces=mesh.getFaces();
98  const StorageSite& cells=mesh.getCells();
99  const int faceCount=faces.getCount();
100  const int cellCount=cells.getCount();
101  _MeshKspaceMap[n]=-1; //mesh map not set
102 
103  BfacePtr BFptr(new BCfaceArray(faceCount));
104  BFptr->zero();
105  _BFaces.push_back(BFptr);
106 
107  BCellPtr BCptr(new BCcellArray(cellCount));
108  _BCells.push_back(BCptr);
109  BCptr->zero();
110 
111  if(_level==0)
112  {
113  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
114  {
115  const FaceGroup& fg = *fgPtr;
116  if (_bcMap.find(fg.id) == _bcMap.end() && fg.id>0)
117  {
118  COMETBC<T> *bc(new COMETBC<T>());
119  _bcMap[fg.id] = bc;
120  }
121  }
122  }
123  }
124  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
Array< int > BCcellArray
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
GeomFields & _geomFields
Model(const MeshList &meshes)
Definition: Model.cpp:8
shared_ptr< BCcellArray > BCellPtr
Definition: Mesh.h:28
Definition: Mesh.h:49
shared_ptr< BCfaceArray > BfacePtr
const int id
Definition: Mesh.h:41
const StorageSite & getFaces() const
Definition: Mesh.h:108
PhononMacro & _macro
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
MeshKspaceMap _MeshKspaceMap
int getCount() const
Definition: StorageSite.h:39
Array< int > BCfaceArray

Member Function Documentation

template<class T >
void COMETModel< T >::advance ( const int  iters)
inline

Definition at line 3270 of file phononbase/COMETModel.h.

References COMETModel< T >::_options, COMETModel< T >::_residual, COMETModel< T >::cycle(), and COMETModel< T >::updateResid().

3271  {
3272  _residual=updateResid(false);
3273  int niters=0;
3274  const T absTol=_options.absTolerance;
3275  const int show=_options.showResidual;
3276 
3277  while((niters<iters) && (_residual>absTol))
3278  {
3279  cycle();
3280  niters++;
3281  _residual=updateResid(false);
3282  if(niters%show==0)
3283  cout<<"Iteration:"<<niters<<" Residual:"<<_residual<<endl;
3284 
3285  }
3286 
3287  //applyTemperatureBoundaries();
3288  //calcModeTemps();
3289  }
T updateResid(const bool addFAS)
COMETModelOptions< T > _options
template<class T >
void COMETModel< T >::advance ( const int  iters)
inline

Definition at line 5388 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_initialResidual, COMETModel< T >::_options, COMETModel< T >::_residual, COMETModel< T >::callCOMETBoundaryConditions(), COMETModel< T >::cycle(), and COMETModel< T >::updateResid().

5389  {
5391  _residual=updateResid(false);
5393  T residualRatio(1.0);
5394 
5395 #ifdef FVM_PARALLEL
5396  if ( MPI::COMM_WORLD.Get_rank() == 0 )
5397  cout<<"Initial Residual:"<<_initialResidual<<" ResidualRatio: "<<residualRatio<<endl;
5398 #endif
5399 
5400 
5401 #ifndef FVM_PARALLEL
5402  cout << "Initial Residual:"<<_initialResidual<<" ResidualRatio: "<<residualRatio<<endl;
5403 #endif
5404 
5405 
5406 
5407  int niters=0;
5408  const T absTol=_options.absoluteTolerance;
5409  const T relTol=_options.relativeTolerance;
5410  const int show=_options.showResidual;
5411 
5412  while((niters<iters) && ((_residual>absTol)&&(residualRatio>relTol)))
5413  {
5414  cycle();
5415  niters++;
5416  _residual=updateResid(false);
5417  if(niters==1)
5419  residualRatio=_residual/_initialResidual;
5420 #ifdef FVM_PARALLEL
5421  if((niters%show==0)&&(MPI::COMM_WORLD.Get_rank()==0))
5422  cout<<"Iteration:"<<niters<<" Residual:"<<_residual<<" ResidualRatio: "<<residualRatio<<endl;
5423 #endif
5424 
5425 #ifndef FVM_PARALLEL
5426  if(niters%show==0)
5427  cout<<"Iteration:"<<niters<<" Residual:"<<_residual<<" ResidualRatio: "<<residualRatio<<endl;
5428 #endif
5429  }
5431  //cout<<endl<<"Total Iterations:"<<niters<<" Residual:"<<_residual<<endl;
5432  }
T updateResid(const bool addFAS)
COMETModelOptions< T > _options
void callCOMETBoundaryConditions()
template<class T >
T COMETModel< T >::advance ( const int  iters,
const StorageSite solidFaces 
)
inline

Definition at line 5434 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_initialResidual, COMETModel< T >::_options, COMETModel< T >::_residual, COMETModel< T >::callCOMETBoundaryConditions(), COMETModel< T >::cycle(), and COMETModel< T >::updateResid().

5435  {
5437  _residual=updateResid(false,solidFaces);
5439  T residualRatio(1.0);
5440 
5441 #ifdef FVM_PARALLEL
5442  if ( MPI::COMM_WORLD.Get_rank() == 0 )
5443  cout<<"Initial Residual:"<<_initialResidual<<" ResidualRatio: "<<residualRatio<<endl;
5444 #endif
5445 
5446 
5447 #ifndef FVM_PARALLEL
5448  cout << "Initial Residual:"<<_initialResidual<<" ResidualRatio: "<<residualRatio<<endl;
5449 #endif
5450 
5451 
5452 
5453  int niters=0;
5454  const T absTol=_options.absoluteTolerance;
5455  const T relTol=_options.relativeTolerance;
5456  const int show=_options.showResidual;
5457 
5458  while((niters<iters) && ((_residual>absTol)&&(residualRatio>relTol)))
5459  {
5460  cycle(solidFaces);
5461  niters++;
5462  _residual=updateResid(false,solidFaces);
5463  if(niters==1)
5465  residualRatio=_residual/_initialResidual;
5466 #ifdef FVM_PARALLEL
5467  if((niters%show==0)&&(MPI::COMM_WORLD.Get_rank()==0))
5468  cout<<"Iteration:"<<niters<<" Residual:"<<_residual<<" ResidualRatio: "<<residualRatio<<endl;
5469 #endif
5470 
5471 #ifndef FVM_PARALLEL
5472  if(niters%show==0)
5473  cout<<"Iteration:"<<niters<<" Residual:"<<_residual<<" ResidualRatio: "<<residualRatio<<endl;
5474 #endif
5475  }
5477  return _residual;
5478  //cout<<endl<<"Total Iterations:"<<niters<<" Residual:"<<_residual<<endl;
5479  }
T updateResid(const bool addFAS)
COMETModelOptions< T > _options
void callCOMETBoundaryConditions()
template<class T >
void COMETModel< T >::applyTemperatureBoundaries ( )
inline

Definition at line 1011 of file phononbase/COMETModel.h.

References COMETModel< T >::_bcMap, COMETModel< T >::_geomFields, COMETModel< T >::_kspaces, COMETModel< T >::_level, Model::_meshes, COMETModel< T >::_MeshKspaceMap, COMETModel< T >::_options, COMETBoundary< T >::applyTemperatureWallCoarse(), COMETBC< T >::bcType, Mesh::getBoundaryFaceGroups(), FloatVarDict< T >::getVal(), FaceGroup::id, and FaceGroup::site.

Referenced by COMETModel< T >::initCoarse(), and COMETModel< T >::smooth().

1012  {
1013  const int numMeshes=_meshes.size();
1014 
1015  for(int n=0;n<numMeshes;n++)
1016  {
1017  const Mesh& mesh=*_meshes[n];
1018  Tkspace& kspace=*_kspaces[_MeshKspaceMap[n]];
1019  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
1020  {
1021  const FaceGroup& fg = *fgPtr;
1022  if(fg.id>0)
1023  {
1024  const StorageSite& faces = fg.site;
1025  const COMETBC<T>& bc = *_bcMap[fg.id];
1026 
1027  COMETBoundary<T> cbc(faces, mesh,_geomFields,kspace,_options,fg.id);
1028 
1029  if(bc.bcType=="temperature")
1030  {
1032  bTemperature(bc.getVal("specifiedTemperature"),faces);
1033 
1034  if(_level>0 || _options.Convection=="FirstOrder")
1035  cbc.applyTemperatureWallCoarse(bTemperature);
1036  else
1037  cbc.applyTemperatureWallCoarse(bTemperature);
1038 
1039  }
1040  }
1041  }
1042  }
1043  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
GeomFields & _geomFields
Definition: Mesh.h:28
Definition: Mesh.h:49
COMETModelOptions< T > _options
FloatVal< T > getVal(const string varName) const
Definition: FloatVarDict.h:85
const int id
Definition: Mesh.h:41
string bcType
const MeshList _meshes
Definition: Model.h:29
MeshKspaceMap _MeshKspaceMap
Kspace< T > Tkspace
StorageSite site
Definition: Mesh.h:40
template<class T >
ArrayBase* COMETModel< T >::binwiseHeatFluxIntegral ( const Mesh mesh,
const int  faceGroupId 
)
inline

Definition at line 3400 of file phononbase/COMETModel.h.

References COMETModel< T >::_geomFields, COMETModel< T >::_kspaces, COMETModel< T >::_MeshKspaceMap, GeomFields::area, Mesh::getBoundaryFaceGroups(), StorageSite::getCount(), kvol< T >::getdk3(), Kspace< T >::getDOSptr(), Kspace< T >::geteArray(), Mesh::getFaceCells(), DensityOfStates< T >::getFreqMidsT(), Kspace< T >::getGlobalIndex(), Mesh::getID(), pmode< T >::getIndex(), DensityOfStates< T >::getKIndices(), Kspace< T >::getkvol(), Array< T >::getLength(), DensityOfStates< T >::getMIndices(), kvol< T >::getmode(), pmode< T >::getv(), FaceGroup::id, FaceGroup::site, and Array< T >::zero().

3401  {
3402  bool found = false;
3403  const int n=mesh.getID();
3404  Tkspace& kspace=*_kspaces[_MeshKspaceMap[n]];
3405  DensityOfStates<T>& dos=*kspace.getDOSptr();
3406  TArray& freqMids=dos.getFreqMidsT();
3407  const T binNos=freqMids.getLength();
3408  TArray& eArray=kspace.geteArray();
3409  TArray* qptr(new TArray(binNos));
3410  TArray& q(*qptr);
3411  q.zero();
3412 
3413  //const T hbar=6.582119e-16; // (eV s)
3414 
3415  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
3416  {
3417  const FaceGroup& fg = *fgPtr;
3418  if (fg.id == faceGroupId)
3419  {
3420  const StorageSite& faces = fg.site;
3421  const int nFaces = faces.getCount();
3422  //const StorageSite& cells = mesh.getCells();
3423  const CRConnectivity& faceCells=mesh.getFaceCells(faces);
3424  const Field& areaField=_geomFields.area;
3425  const VectorT3Array& faceArea=dynamic_cast<const VectorT3Array&>(areaField[faces]);
3426 
3427  for(int f=0; f<nFaces; f++)
3428  {
3429  const VectorT3 An=faceArea[f];
3430  const int c1=faceCells(f,1);
3431 
3432  for(int binIndx=0;binIndx<binNos;binIndx++)
3433  {
3434  IntArray& kpts=dos.getKIndices(binIndx);
3435  IntArray& mpts=dos.getMIndices(binIndx);
3436 
3437  for(int k=0;k<kpts.getLength();k++)
3438  {
3439  Tkvol& kv=kspace.getkvol(kpts[k]);
3440  T dk3=kv.getdk3();
3441  Tmode& mode=kv.getmode(mpts[k]);
3442  VectorT3 vg=mode.getv();
3443  T vgdotAn=vg[0]*An[0]+vg[1]*An[1]+vg[2]*An[2];
3444  const int index=mode.getIndex()-1;
3445  int cellIndex=kspace.getGlobalIndex(c1,index);
3446  q[binIndx]+= eArray[cellIndex]*vgdotAn*dk3;//*energy;
3447  cellIndex++;
3448  }
3449  }
3450  }
3451  found=true;
3452  }
3453  }
3454 
3455  if (!found)
3456  throw CException("getHeatFluxIntegral: invalid faceGroupID");
3457  return qptr;
3458  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
GeomFields & _geomFields
Definition: Mesh.h:28
Array< T > TArray
Definition: Field.h:14
const int id
Definition: Mesh.h:41
IntArray & getMIndices(const int fBin)
TArray & getFreqMidsT()
MeshKspaceMap _MeshKspaceMap
const CRConnectivity & getFaceCells(const StorageSite &site) const
Definition: Mesh.cpp:388
int getCount() const
Definition: StorageSite.h:39
Array< int > IntArray
IntArray & getKIndices(const int fBin)
Field area
Definition: GeomFields.h:23
Kspace< T > Tkspace
int getID() const
Definition: Mesh.h:106
StorageSite site
Definition: Mesh.h:40
int getLength() const
Definition: Array.h:87
template<class T >
void COMETModel< T >::calcBandFlux ( )
inline

Definition at line 3886 of file phononbase/COMETModel.h.

References COMETModel< T >::_kspaces, COMETModel< T >::_macro, Model::_meshes, COMETModel< T >::_MeshKspaceMap, PhononMacro::BandFlux, Mesh::getCells(), StorageSite::getCount(), kvol< T >::getdk3(), Kspace< T >::getDK3(), Kspace< T >::getDOSptr(), Kspace< T >::gete(), DensityOfStates< T >::getFreqMidsT(), pmode< T >::getIndex(), DensityOfStates< T >::getKIndices(), Kspace< T >::getkvol(), Array< T >::getLength(), DensityOfStates< T >::getMIndices(), kvol< T >::getmode(), pmode< T >::getv(), and Array< T >::zero().

3887  {
3888  const int numMeshes=_meshes.size();
3889  const T eVtoJoule=1.60217646e-19;
3890  for (int n=0;n<numMeshes;n++)
3891  {
3892  Mesh& mesh=*_meshes[n];
3893  if(_MeshKspaceMap[n]==-1)
3894  throw CException("Have not set the Kspace for this Mesh!!");
3895  Tkspace& kspace=*_kspaces[_MeshKspaceMap[n]];
3896  //const int numK=kspace.getlength();
3897  const StorageSite& cells=mesh.getCells();
3898  const int numcells=cells.getCount();
3899  //const int modeCount=kspace.getkvol(0).getmodenum();
3900  const T DK3=kspace.getDK3();
3901  DensityOfStates<T>& dos=*kspace.getDOSptr();
3902  const int bandCount=dos.getFreqMidsT().getLength();
3903 
3904  FieldVector* FieldVecPtr=new FieldVector();
3905  _macro.BandFlux[n]=FieldVecPtr;
3906  for(int b=0;b<bandCount;b++)
3907  {
3908  shared_ptr<Field> bandField(new Field("BandFlux"));
3909  VT3Ptr qptr(new VectorT3Array(numcells));
3910  VectorT3Array& q(*qptr);
3911  q.zero();
3912  bandField->addArray(cells,qptr);
3913  FieldVecPtr->push_back(bandField);
3914  IntArray& kpts=dos.getKIndices(b);
3915  IntArray& mpts=dos.getMIndices(b);
3916  for(int c=0;c<numcells;c++)
3917  {
3918  for(int i=0;i<kpts.getLength();i++)
3919  {
3920  const int k=kpts[i];
3921  const int m=mpts[i];
3922  Tmode& mode=kspace.getkvol(k).getmode(m);
3923  T dk3=kspace.getkvol(k).getdk3();
3924  const int index=mode.getIndex()-1;
3925  q[c]+=mode.getv()*(dk3/DK3)*kspace.gete(c,index)*eVtoJoule;
3926  }
3927 
3928  }
3929  for(int i=0;i<q.getLength();i++)
3930  q[i]*=DK3;
3931  }
3932  }
3933  }
Definition: Field.h:14
Definition: Mesh.h:49
vector< shared_ptr< Field > > FieldVector
Array< VectorT3 > VectorT3Array
IntArray & getMIndices(const int fBin)
PhononMacro & _macro
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
TArray & getFreqMidsT()
MeshKspaceMap _MeshKspaceMap
shared_ptr< VectorT3Array > VT3Ptr
int getCount() const
Definition: StorageSite.h:39
Array< int > IntArray
IntArray & getKIndices(const int fBin)
Kspace< T > Tkspace
FieldVectorMap BandFlux
Definition: PhononMacro.h:33
int getLength() const
Definition: Array.h:87
template<class T >
void COMETModel< T >::calcBandRelEnergy ( )
inline

Definition at line 3772 of file phononbase/COMETModel.h.

References COMETModel< T >::_kspaces, COMETModel< T >::_macro, Model::_meshes, COMETModel< T >::_MeshKspaceMap, PhononMacro::BandRelEnergy, Mesh::getCells(), StorageSite::getCount(), kvol< T >::getdk3(), Kspace< T >::getDK3(), Kspace< T >::getDOSptr(), Kspace< T >::gete(), DensityOfStates< T >::getFreqMidsT(), pmode< T >::getIndex(), DensityOfStates< T >::getKIndices(), Kspace< T >::getkvol(), Array< T >::getLength(), Kspace< T >::getlength(), DensityOfStates< T >::getMIndices(), kvol< T >::getmode(), kvol< T >::getmodenum(), and Array< T >::zero().

3773  {
3774  const int numMeshes=_meshes.size();
3775  for (int n=0;n<numMeshes;n++)
3776  {
3777  Mesh& mesh=*_meshes[n];
3778  if(_MeshKspaceMap[n]==-1)
3779  throw CException("Have not set the Kspace for this Mesh!!");
3780  Tkspace& kspace=*_kspaces[_MeshKspaceMap[n]];
3781  const T DK3=kspace.getDK3();
3782  DensityOfStates<T>& dos=*kspace.getDOSptr();
3783  const StorageSite& cells=mesh.getCells();
3784  const int numcells=cells.getCount();
3785  TArray eSum(numcells);
3786  eSum.zero();
3787  const int bandCount=dos.getFreqMidsT().getLength();
3788  const int numK=kspace.getlength();
3789  FieldVector* FieldVecPtr=new FieldVector();
3790  _macro.BandRelEnergy[n]=FieldVecPtr;
3791 
3792  for(int c=0;c<numcells;c++)
3793  {
3794  int index(0);
3795  for(int k=0;k<numK;k++)
3796  {
3797  Tkvol& kv=kspace.getkvol(k);
3798  T dk3=kv.getdk3();
3799  const int numM=kv.getmodenum();
3800  for(int m=0;m<numM;m++)
3801  {
3802  eSum[c]+=kspace.gete(c,index)*(dk3/DK3);
3803  index++;
3804  }
3805  }
3806  }
3807 
3808  for(int b=0;b<bandCount;b++)
3809  {
3810  shared_ptr<Field> bandField(new Field("bandRelEnergy"));
3811  TArrptr Tptr(new TArray(numcells));
3812  bandField->addArray(cells,Tptr);
3813  FieldVecPtr->push_back(bandField);
3814  TArray& bandEn=*Tptr;
3815  bandEn.zero();
3816  IntArray& kpts=dos.getKIndices(b);
3817  IntArray& mpts=dos.getMIndices(b);
3818  for(int c=0;c<numcells;c++)
3819  {
3820  T cellSum(0);
3821  for(int i=0;i<kpts.getLength();i++)
3822  {
3823  const int k=kpts[i];
3824  const int m=mpts[i];
3825  T dk3=kspace.getkvol(k).getdk3();
3826  Tmode& mode=kspace.getkvol(k).getmode(m);
3827  const int index=mode.getIndex()-1;
3828  cellSum+=kspace.gete(c,index)*(dk3/DK3);
3829  }
3830  bandEn[c]=cellSum/eSum[c];
3831  }
3832  }
3833 
3834  }
3835  }
shared_ptr< TArray > TArrptr
Array< T > TArray
Definition: Field.h:14
Definition: Mesh.h:49
vector< shared_ptr< Field > > FieldVector
IntArray & getMIndices(const int fBin)
PhononMacro & _macro
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
TArray & getFreqMidsT()
MeshKspaceMap _MeshKspaceMap
FieldVectorMap BandRelEnergy
Definition: PhononMacro.h:32
int getCount() const
Definition: StorageSite.h:39
Array< int > IntArray
IntArray & getKIndices(const int fBin)
Kspace< T > Tkspace
int getLength() const
Definition: Array.h:87
template<class T >
void COMETModel< T >::calcBandTemps ( )
inline

Definition at line 3724 of file phononbase/COMETModel.h.

References COMETModel< T >::_kspaces, COMETModel< T >::_macro, Model::_meshes, COMETModel< T >::_MeshKspaceMap, PhononMacro::BandTemperatures, Kspace< T >::calcBandTemp(), Mesh::getCells(), StorageSite::getCount(), kvol< T >::getdk3(), Kspace< T >::getDOSptr(), Kspace< T >::gete(), DensityOfStates< T >::getFreqMidsT(), pmode< T >::getIndex(), DensityOfStates< T >::getKIndices(), Kspace< T >::getkvol(), Array< T >::getLength(), DensityOfStates< T >::getMIndices(), kvol< T >::getmode(), PhononMacro::temperature, and Array< T >::zero().

3725  {
3726  const int numMeshes=_meshes.size();
3727  for (int n=0;n<numMeshes;n++)
3728  {
3729  Mesh& mesh=*_meshes[n];
3730  if(_MeshKspaceMap[n]==-1)
3731  throw CException("Have not set the Kspace for this Mesh!!");
3732  Tkspace& kspace=*_kspaces[_MeshKspaceMap[n]];
3733  DensityOfStates<T>& dos=*kspace.getDOSptr();
3734  const StorageSite& cells=mesh.getCells();
3735  const TArray& TL=dynamic_cast<const TArray&>(_macro.temperature[cells]);
3736  const int numcells=cells.getCount();
3737  TArray eSum(numcells);
3738  const int bandCount=dos.getFreqMidsT().getLength();
3739 
3740  FieldVector* FieldVecPtr=new FieldVector();
3741  _macro.BandTemperatures[n]=FieldVecPtr;
3742  for(int b=0;b<bandCount;b++)
3743  {
3744  eSum.zero();
3745  shared_ptr<Field> bandField(new Field("bandTemp"));
3746  TArrptr Tptr(new TArray(numcells));
3747  bandField->addArray(cells,Tptr);
3748  FieldVecPtr->push_back(bandField);
3749  TArray& bandTemp=*Tptr;
3750  bandTemp.zero();
3751  IntArray& kpts=dos.getKIndices(b);
3752  IntArray& mpts=dos.getMIndices(b);
3753  for(int c=0;c<numcells;c++)
3754  {
3755  for(int i=0;i<kpts.getLength();i++)
3756  {
3757  const int k=kpts[i];
3758  const int m=mpts[i];
3759  T dk3=kspace.getkvol(k).getdk3();
3760  Tmode& mode=kspace.getkvol(k).getmode(m);
3761  const int index=mode.getIndex()-1;
3762  eSum[c]+=kspace.gete(c,index)*dk3;
3763  }
3764  }
3765  for(int c=0;c<numcells;c++)
3766  bandTemp[c]=kspace.calcBandTemp(TL[c],eSum[c],kpts,mpts);
3767  }
3768 
3769  }
3770  }
shared_ptr< TArray > TArrptr
Array< T > TArray
Definition: Field.h:14
Field temperature
Definition: PhononMacro.h:21
Definition: Mesh.h:49
vector< shared_ptr< Field > > FieldVector
IntArray & getMIndices(const int fBin)
PhononMacro & _macro
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
TArray & getFreqMidsT()
MeshKspaceMap _MeshKspaceMap
FieldVectorMap BandTemperatures
Definition: PhononMacro.h:31
int getCount() const
Definition: StorageSite.h:39
Array< int > IntArray
IntArray & getKIndices(const int fBin)
Kspace< T > Tkspace
int getLength() const
Definition: Array.h:87
template<class T >
T COMETModel< T >::calcDomainStats ( )
inline

Definition at line 3935 of file phononbase/COMETModel.h.

References COMETModel< T >::_bcMap, COMETModel< T >::_geomFields, Model::_meshes, GeomFields::area, GeomFields::areaMag, fabs(), Mesh::getBoundaryFaceGroups(), Mesh::getCells(), StorageSite::getCount(), StorageSite::getSelfCount(), FaceGroup::id, FaceGroup::site, GeomFields::volume, and Array< T >::zero().

Referenced by COMETModel< T >::init().

3936  {
3937  const int numMeshes=_meshes.size();
3938  TArray meshVols(numMeshes);
3939  T totalVol(0.);
3940  meshVols.zero();
3941  T interfaceArea(0.);
3942  T interfaceAreaX(0.);
3943  T interfaceAreaY(0.);
3944  T interfaceAreaZ(0.);
3945  int interfaceFaces(0);
3946 
3947  for (int n=0;n<numMeshes;n++)
3948  {
3949  Mesh& mesh=*_meshes[n];
3950  const StorageSite& cells=mesh.getCells();
3951  const TArray& vol=dynamic_cast<const TArray&>(_geomFields.volume[cells]);
3952 
3953  for(int c=0;c<cells.getSelfCount();c++)
3954  meshVols[n]+=vol[c];
3955 
3956  totalVol+=meshVols[n];
3957 
3958  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
3959  {
3960  const FaceGroup& fg = *fgPtr;
3961  if(fg.id>0)
3962  {
3963  if(_bcMap[fg.id]->bcType == "Interface")
3964  {
3965  const StorageSite& faces=fg.site;
3966  const int numFaces=faces.getCount();
3967  const Field& AreaMagField=_geomFields.areaMag;
3968  const TArray& AreaMag=
3969  dynamic_cast<const TArray&>(AreaMagField[faces]);
3970  const VectorT3Array& AreaDir=
3971  dynamic_cast<const VectorT3Array&>(_geomFields.area[faces]);
3972 
3973  interfaceFaces+=numFaces;
3974 
3975  for(int f=0;f<numFaces;f++)
3976  {
3977  interfaceArea+=AreaMag[f];
3978  interfaceAreaX+=fabs(AreaDir[f][0]);
3979  interfaceAreaY+=fabs(AreaDir[f][1]);
3980  interfaceAreaZ+=fabs(AreaDir[f][2]);
3981  }
3982 
3983  }
3984  }
3985  }
3986  }
3987 
3988  interfaceArea/=2.;
3989  interfaceAreaX/=2.;
3990  interfaceAreaY/=2.;
3991  interfaceAreaZ/=2.;
3992  interfaceFaces/=2;
3993 
3994  for (int n=0;n<numMeshes;n++)
3995  {
3996  Mesh& mesh=*_meshes[n];
3997  const StorageSite& cells=mesh.getCells();
3998  cout<<endl;
3999  cout<<"Mesh: "<<n<<endl;
4000  cout<<"Self Cell Count: "<<cells.getSelfCount()<<endl;
4001  cout<<"Ghost Cell Count: "<<cells.getCount()-cells.getSelfCount()<<endl;
4002  cout<<"Mesh Volume: "<<meshVols[n]<<endl;
4003  }
4004 
4005  cout<<endl;
4006  cout<<"Total Volume: "<<totalVol<<endl;
4007  cout<<"Interface Area: "<<interfaceArea<<endl;
4008  cout<<"Interface Area (X): "<<interfaceAreaX<<endl;
4009  cout<<"Interface Area (Y): "<<interfaceAreaY<<endl;
4010  cout<<"Interface Area (Z): "<<interfaceAreaZ<<endl;
4011  cout<<"Area/Volume: "<<interfaceArea/totalVol<<endl;
4012  cout<<"Volume/Area: "<<totalVol/interfaceArea<<endl;
4013  cout<<"Interface Face Count: "<<interfaceFaces<<endl;
4014  return interfaceArea/totalVol;
4015 
4016  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
GeomFields & _geomFields
int getSelfCount() const
Definition: StorageSite.h:40
Definition: Mesh.h:28
Array< T > TArray
Definition: Field.h:14
Definition: Mesh.h:49
const int id
Definition: Mesh.h:41
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
Field volume
Definition: GeomFields.h:26
Tangent fabs(const Tangent &a)
Definition: Tangent.h:312
int getCount() const
Definition: StorageSite.h:39
Field area
Definition: GeomFields.h:23
Field areaMag
Definition: GeomFields.h:25
StorageSite site
Definition: Mesh.h:40
template<class T >
void COMETModel< T >::calcModeFlux ( )
inline

Definition at line 3837 of file phononbase/COMETModel.h.

References COMETModel< T >::_kspaces, COMETModel< T >::_macro, Model::_meshes, COMETModel< T >::_MeshKspaceMap, PhononMacro::BranchFlux, Mesh::getCells(), StorageSite::getCount(), kvol< T >::getdk3(), Kspace< T >::getDK3(), Kspace< T >::gete(), pmode< T >::getIndex(), Kspace< T >::getkvol(), Array< T >::getLength(), Kspace< T >::getlength(), kvol< T >::getmode(), kvol< T >::getmodenum(), pmode< T >::getv(), PhononMacro::heatFlux, and Array< T >::zero().

3838  {
3839  const int numMeshes=_meshes.size();
3840  const T eVtoJoule=1.60217646e-19;
3841  for (int n=0;n<numMeshes;n++)
3842  {
3843  Mesh& mesh=*_meshes[n];
3844  if(_MeshKspaceMap[n]==-1)
3845  throw CException("Have not set the Kspace for this Mesh!!");
3846  Tkspace& kspace=*_kspaces[_MeshKspaceMap[n]];
3847  const int numK=kspace.getlength();
3848  const StorageSite& cells=mesh.getCells();
3849  const int numcells=cells.getCount();
3850  const int modeCount=kspace.getkvol(0).getmodenum();
3851  const T DK3=kspace.getDK3();
3852  VectorT3Array& Q=dynamic_cast<VectorT3Array&>(_macro.heatFlux[cells]);
3853  Q.zero();
3854 
3855  FieldVector* FieldVecPtr=new FieldVector();
3856  _macro.BranchFlux[n]=FieldVecPtr;
3857  for(int m=0;m<modeCount;m++)
3858  {
3859  shared_ptr<Field> modeField(new Field("mode"));
3860  VT3Ptr qptr(new VectorT3Array(numcells));
3861  VectorT3Array& q(*qptr);
3862  q.zero();
3863  modeField->addArray(cells,qptr);
3864  FieldVecPtr->push_back(modeField);
3865 
3866  for(int c=0;c<numcells;c++)
3867  {
3868  for(int k=0;k<numK;k++)
3869  {
3870  Tmode& mode=kspace.getkvol(k).getmode(m);
3871  T dk3=kspace.getkvol(k).getdk3();
3872  const int index=mode.getIndex()-1;
3873  q[c]+=mode.getv()*(dk3/DK3)*kspace.gete(c,index)*eVtoJoule;
3874  Q[c]+=mode.getv()*(dk3/DK3)*kspace.gete(c,index)*eVtoJoule;
3875  }
3876 
3877  }
3878  for(int i=0;i<q.getLength();i++)
3879  q[i]*=DK3;
3880  }
3881  for(int i=0;i<Q.getLength();i++)
3882  Q[i]*=DK3;
3883  }
3884  }
virtual void zero()
Definition: Array.h:281
Definition: Field.h:14
Definition: Mesh.h:49
vector< shared_ptr< Field > > FieldVector
Array< VectorT3 > VectorT3Array
PhononMacro & _macro
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
MeshKspaceMap _MeshKspaceMap
shared_ptr< VectorT3Array > VT3Ptr
int getCount() const
Definition: StorageSite.h:39
FieldVectorMap BranchFlux
Definition: PhononMacro.h:30
Kspace< T > Tkspace
Field heatFlux
Definition: PhononMacro.h:27
int getLength() const
Definition: Array.h:87
template<class T >
void COMETModel< T >::calcModeTemps ( )
inline

Definition at line 3685 of file phononbase/COMETModel.h.

References COMETModel< T >::_kspaces, COMETModel< T >::_macro, Model::_meshes, COMETModel< T >::_MeshKspaceMap, PhononMacro::BranchTemperatures, Kspace< T >::calcModeTemp(), Mesh::getCells(), StorageSite::getCount(), kvol< T >::getdk3(), Kspace< T >::gete(), pmode< T >::getIndex(), Kspace< T >::getkvol(), Kspace< T >::getlength(), kvol< T >::getmode(), PhononMacro::temperature, and Array< T >::zero().

3686  {
3687  const int numMeshes=_meshes.size();
3688  for (int n=0;n<numMeshes;n++)
3689  {
3690  Mesh& mesh=*_meshes[n];
3691  if(_MeshKspaceMap[n]==-1)
3692  throw CException("Have not set the Kspace for this Mesh!!");
3693  Tkspace& kspace=*_kspaces[_MeshKspaceMap[n]];
3694  const int numK=kspace.getlength();
3695  const StorageSite& cells=mesh.getCells();
3696  const int numcells=cells.getCount();
3697  FieldVector& FieldVec=*_macro.BranchTemperatures[n];
3698  const int modeCount=FieldVec.size();
3699  TArray eSum(numcells);
3700  const TArray& TL=dynamic_cast<const TArray&>(_macro.temperature[cells]);
3701 
3702  for(int m=0;m<modeCount;m++)
3703  {
3704  eSum.zero();
3705  Field& modeField=*FieldVec[m];
3706  TArray& modeTemp=dynamic_cast<TArray&>(modeField[cells]);
3707  for(int c=0;c<numcells;c++)
3708  {
3709  for(int k=0;k<numK;k++)
3710  {
3711  T dk3=kspace.getkvol(k).getdk3();
3712  Tmode& mode=kspace.getkvol(k).getmode(m);
3713  const int index=mode.getIndex()-1;
3714  eSum[c]+=kspace.gete(c,index)*dk3;
3715  }
3716  }
3717  for(int c=0;c<numcells;c++)
3718  modeTemp[c]=kspace.calcModeTemp(TL[c],eSum[c],m);
3719  }
3720 
3721  }
3722  }
Array< T > TArray
Definition: Field.h:14
Field temperature
Definition: PhononMacro.h:21
Definition: Mesh.h:49
vector< shared_ptr< Field > > FieldVector
PhononMacro & _macro
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
MeshKspaceMap _MeshKspaceMap
int getCount() const
Definition: StorageSite.h:39
FieldVectorMap BranchTemperatures
Definition: PhononMacro.h:29
Kspace< T > Tkspace
template<class T >
void COMETModel< T >::callCOMETBoundaryConditions ( )
inline

Definition at line 2426 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_bcMap, COMETModel< T >::_dsfPtr, COMETModel< T >::_faceReflectionArrayMap, COMETModel< T >::_geomFields, COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_quadrature, COMETBoundaryConditions< X, Diag, OffDiag >::applyNSInterfaceBC(), COMETBoundaryConditions< X, Diag, OffDiag >::applyPressureInletBC(), COMETBoundaryConditions< X, Diag, OffDiag >::applyPressureOutletBC(), COMETBoundaryConditions< X, Diag, OffDiag >::applyRealWallBC(), COMETBoundaryConditions< X, Diag, OffDiag >::applyZeroGradientBC(), COMETBC< T >::bcType, Mesh::getBoundaryFaceGroups(), Mesh::getInterfaceGroups(), FloatVarDict< T >::getVal(), FaceGroup::groupType, FaceGroup::id, and FaceGroup::site.

Referenced by COMETModel< T >::advance(), COMETModel< T >::smooth(), and COMETModel< T >::updateResid().

2427  {
2428  const int numMeshes = _meshes.size();
2429  for (int n=0; n<numMeshes; n++)
2430  {
2431  const Mesh& mesh = *_meshes[n];
2432 
2433  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
2434  {
2435  const FaceGroup& fg = *fgPtr;
2436  const StorageSite& faces = fg.site;
2437  //const int nFaces = faces.getCount();
2438  const COMETBC<T>& bc = *_bcMap[fg.id];
2440  FloatValEvaluator<VectorT3> bVelocity(bc.getVal("specifiedXVelocity"),
2441  bc.getVal("specifiedYVelocity"),
2442  bc.getVal("specifiedZVelocity"),
2443  faces);
2444  FloatValEvaluator<T> accomCoeff(bc.getVal("accommodationCoefficient"),faces);
2445  FloatValEvaluator<T> bTemperature(bc.getVal("specifiedTemperature"),faces);
2446  FloatValEvaluator<T> bPressure(bc.getVal("specifiedPressure"),faces);
2447  if(bc.bcType=="PressureInletBC")
2448  {
2449  cbc.applyPressureInletBC(bTemperature,bPressure);
2450  }
2451  else if(bc.bcType=="PressureOutletBC")
2452  {
2453  cbc.applyPressureOutletBC(bTemperature,bPressure);
2454  }
2455  else if (bc.bcType == "RealWallBC")
2456  {
2457  //kbc.applyRealWallBC(bVelocity,bTemperature,accomCoeff);
2458  map<int, vector<int> >::iterator pos = _faceReflectionArrayMap.find(fg.id);
2459  const vector<int>& vecReflection=(*pos).second;
2460  cbc.applyRealWallBC(bVelocity,bTemperature,accomCoeff,vecReflection);
2461  }
2462  /*
2463  else if(bc.bcType=="SymmetryBC")
2464  {
2465  //kbc.applySpecularWallBC(); //old boundary works only for cartesian-type quadrature
2466  map<int, vector<int> >::iterator pos = _faceReflectionArrayMap.find(fg.id);
2467  const vector<int>& vecReflection=(*pos).second;
2468  cbc.applySpecularWallBC(vecReflection);
2469  }
2470  */
2471  else if(bc.bcType=="ZeroGradBC")
2472  {
2473  cbc.applyZeroGradientBC();
2474  }
2475  }
2476  foreach(const FaceGroupPtr igPtr, mesh.getInterfaceGroups())
2477  {
2478 
2479  const FaceGroup& ig = *igPtr;
2480  const StorageSite& faces = ig.site;
2481  //const int nFaces = faces.getCount();
2482 
2483 
2485  if(ig.groupType=="NSinterface")
2486  {
2487  cbc.applyNSInterfaceBC();//bTemperature,bPressure,bVelocity,bStress);
2488  }
2489  }
2490  }//end of loop through meshes
2491  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
GeomFields & _geomFields
Definition: Mesh.h:28
Quadrature< T > & _quadrature
Definition: Mesh.h:49
string groupType
Definition: Mesh.h:42
FloatVal< T > getVal(const string varName) const
Definition: FloatVarDict.h:85
const int id
Definition: Mesh.h:41
map< int, vector< int > > _faceReflectionArrayMap
string bcType
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
DistFunctFields< T > _dsfPtr
const FaceGroupList & getInterfaceGroups() const
Definition: Mesh.h:190
StorageSite site
Definition: Mesh.h:40
template<class T >
void COMETModel< T >::coarsenInterfaceCells ( COMETIC< T > &  ic,
IntArray coarseCounts,
GeomFields inGeomFields,
const MeshList inMeshes 
)
inline

Definition at line 2509 of file phononbase/COMETModel.h.

References COMETModel< T >::_BFaces, COMETModel< T >::_level, GeomFields::areaMag, COMETIC< T >::FgID0, COMETIC< T >::FgID1, GeomFields::fineToCoarse, Mesh::getAllFaceCells(), Mesh::getCellCells(), Mesh::getCellFaces(), Mesh::getCells(), StorageSite::getCommonMap(), StorageSite::getCount(), CRConnectivity::getCount(), Mesh::getFaceCells(), Mesh::getFaceGroup(), Mesh::getFaces(), StorageSite::getSelfCount(), CRConnectivity::getTranspose(), COMETIC< T >::MeshID0, COMETIC< T >::MeshID1, CRConnectivity::multiply(), FaceGroup::site, and Array< T >::zero().

Referenced by COMETModel< T >::MakeInteriorCoarseMesh().

2511  {
2512  const int Mid0=ic.MeshID0;
2513  const int Mid1=ic.MeshID1;
2514  const int Fid0=ic.FgID0;
2515  const int Fid1=ic.FgID1;
2516  const Mesh& mesh0=*inMeshes[Mid0];
2517  const Mesh& mesh1=*inMeshes[Mid1];
2518  const StorageSite& faces0=mesh0.getFaceGroup(Fid0).site;
2519  const StorageSite& faces1=mesh1.getFaceGroup(Fid1).site;
2520  const StorageSite& cells0=mesh0.getCells();
2521  const StorageSite& cells1=mesh1.getCells();
2522  const StorageSite& globFaces0=mesh0.getFaces();
2523  const StorageSite::CommonMap& ComMap = faces0.getCommonMap();
2524  const IntArray& common01=*(ComMap.find(&faces1)->second);
2525  const CRConnectivity& faceCells0=mesh0.getFaceCells(faces0);
2526  const CRConnectivity& faceCells1=mesh1.getFaceCells(faces1);
2527  const CRConnectivity& cellCells0=mesh0.getCellCells();
2528  const CRConnectivity& cellCells1=mesh1.getCellCells();
2529  const CRConnectivity& globFaceCells0=mesh0.getAllFaceCells();
2530  const CRConnectivity& globCellFaces0=mesh0.getCellFaces();
2531  const int inFaceCount=faces0.getCount();
2532  Field& areaMagField=inGeomFields.areaMag;
2533  const TArray& areaMagArray0=dynamic_cast<const TArray&>(areaMagField[globFaces0]);
2534  const BCfaceArray& inBCfArray0=*(_BFaces[Mid0]);
2535 
2536  const CRPtr cellFaces0Ptr=faceCells0.getTranspose();
2537  const CRConnectivity& cellFaces0=*cellFaces0Ptr;
2538  const CRPtr cellsIntGhost0Ptr=cellFaces0.multiply(faceCells0,true);
2539  const CRConnectivity& cellsIntGhost0=*cellsIntGhost0Ptr;
2540 
2541  IntArray CoarseFineCount(cells0.getCount());
2542  CoarseFineCount.zero();
2543 
2544  IntArray& f2c0=dynamic_cast<IntArray&>(inGeomFields.fineToCoarse[cells0]);
2545  IntArray& f2c1=dynamic_cast<IntArray&>(inGeomFields.fineToCoarse[cells1]);
2546  int& count0=coarseCounts[Mid0];
2547  int& count1=coarseCounts[Mid1];
2548 
2549  //const VectorT3Array& cpos0=dynamic_cast<const VectorT3Array&>(inGeomFields.coordinate[cells0]);
2550  //const VectorT3Array& cpos1=dynamic_cast<const VectorT3Array&>(inGeomFields.coordinate[cells1]);
2551 
2552  //agglomerate mesh0 first
2553  int pairWith;
2554 
2555  if(_level>=0)
2556  {
2557  for(int f=0;f<inFaceCount;f++)
2558  {
2559  const int c=faceCells0(f,0);
2560  const int cCoarse=CoarseFineCount[c];
2561  if(f2c0[c]<0 || cCoarse<4) //dont bother if im already paired
2562  {
2563  //loop through all neighbors to find pairing
2564  const int neibCount=cellCells0.getCount(c);
2565  pairWith=-2;
2566  T maxArea=0.;
2567  int c2;
2568  for(int neib=0;neib<neibCount;neib++)
2569  {
2570  const int fglob=globCellFaces0(c,neib);
2571 
2572  if(inBCfArray0[fglob]==0) //not a boundary face
2573  {
2574  if(c==globFaceCells0(fglob,1))
2575  c2=globFaceCells0(fglob,0);
2576  else
2577  c2=globFaceCells0(fglob,1);
2578 
2579  int c2Coarse=f2c0[c2];
2580 
2581  if(_level==0)
2582  {
2583  if(c2Coarse==-1)// || CoarseFineCount[c2Coarse]<5) //not already paired
2584  {
2585  if(areaMagArray0[fglob]>maxArea)
2586  {
2587  pairWith=c2;
2588  maxArea=areaMagArray0[fglob];
2589  if(cellsIntGhost0.getCount(c2)>0) //pick first interface cell
2590  break;
2591  }
2592  }
2593  }
2594  else
2595  {
2596  if(c2Coarse==-1)
2597  {
2598  if(areaMagArray0[fglob]>maxArea)
2599  {
2600  pairWith=c2;
2601  maxArea=areaMagArray0[fglob];
2602  if(cellsIntGhost0.getCount(c2)>0) //pick first interface cell
2603  break;
2604  }
2605  }
2606  }
2607 
2608  }
2609  }
2610 
2611  if(pairWith>=0)
2612  {
2613  int c2Coarse=f2c0[pairWith];
2614  if(c2Coarse==-1 && f2c0[c]==-1)
2615  {
2616  f2c0[pairWith]=count0;
2617  f2c0[c]=count0;
2618  CoarseFineCount[count0]++;
2619  count0++;
2620  }
2621  else if(f2c0[c]==-1 && c2Coarse>=0)
2622  f2c0[c]=c2Coarse;/*
2623  else if(f2c0[c]!=-1 && c2Coarse==-1)
2624  f2c0[pairWith]=f2c0[c];
2625  */
2626  }
2627  }
2628  }
2629  }
2630  else
2631  {
2632  for(int f=0;f<inFaceCount;f++)
2633  {
2634  const int c=faceCells0(f,0);
2635  if(f2c0[c]<0) //dont bother if im already paired
2636  {
2637  //loop through all neighbors to find pairing
2638  const int neibCount=cellCells0.getCount(c);
2639  pairWith=-1;
2640  T maxArea=0.;
2641  int c2;
2642  for(int neib=0;neib<neibCount;neib++)
2643  {
2644  const int fglob=globCellFaces0(c,neib);
2645 
2646  if(inBCfArray0[fglob]==0) //not a boundary face
2647  {
2648  if(c==globFaceCells0(fglob,1))
2649  c2=globFaceCells0(fglob,0);
2650  else
2651  c2=globFaceCells0(fglob,1);
2652 
2653  if(f2c0[c2]==-1) //not already paired
2654  {
2655  if(areaMagArray0[fglob]>maxArea)
2656  {
2657  pairWith=c2;
2658  maxArea=areaMagArray0[fglob];
2659  }
2660  }
2661 
2662  }
2663  }
2664 
2665  if(pairWith!=-1)
2666  {
2667  f2c0[pairWith]=count0;
2668  f2c0[c]=count0;
2669  count0++;
2670  }
2671  }
2672  }
2673  }
2674 
2675  StorageSite preCoarse0(count0);
2676  CRPtr preCoarseToFineCells0=CRPtr(new CRConnectivity(preCoarse0,cells0));
2677  preCoarseToFineCells0->initCount();
2678 
2679  for(int c=0;c<cells0.getSelfCount();c++)
2680  if(f2c0[c]!=-1)
2681  preCoarseToFineCells0->addCount(f2c0[c],1);
2682 
2683 
2684  preCoarseToFineCells0->finishCount();
2685 
2686  for(int c=0;c<cells0.getSelfCount();c++)
2687  if(f2c0[c]!=-1)
2688  preCoarseToFineCells0->add(f2c0[c],c);
2689 
2690  preCoarseToFineCells0->finishAdd();
2691 
2692  //now use mesh0 pairing to pair mesh1
2693  for(int f=0;f<inFaceCount;f++)
2694  {
2695  const int f1=common01[f];
2696  //const int c01ghost=faceCells1(f1,1);
2697  const int c01=faceCells1(f1,0);
2698  const int c00=faceCells0(f,0);
2699  if(f2c0[c00]>-1) //dont bother if im already paired, mesh0 must be paired
2700  {
2701  //const int neibCount0=cellCells0.getCount(c00);
2702  const int coarseC00=f2c0[c00];
2703  const int cC00fineCnt=preCoarseToFineCells0->getCount(coarseC00);
2704 
2705  for(int cC00fine=0;cC00fine<cC00fineCnt;cC00fine++) //who is mesh0 paired with
2706  {
2707  //const int c10=cellCells0(c00,neib0);
2708  const int fineCell=(*preCoarseToFineCells0)(coarseC00,cC00fine);
2709  if(fineCell!=c00)//(f2c0[c00]==f2c0[c10])
2710  {
2711  const int c10gNeibs=cellsIntGhost0.getCount(fineCell); //cell is on an interface
2712  for(int c10ghost=0;c10ghost<c10gNeibs;c10ghost++)
2713  {
2714  const int c10g=cellsIntGhost0(fineCell,c10ghost);
2715  const int f10=cellFaces0(c10g,0);
2716  const int f11=common01[f10];
2717  //const int c11ghost=faceCells1(f11,1);
2718  const int c11=faceCells1(f11,0);
2719  const int neibCount1=cellCells1.getCount(c01);
2720  bool isNeib(false);
2721  for(int c01neibs=0;c01neibs<neibCount1;c01neibs++)
2722  {
2723  if(cellCells1(c01,c01neibs)==c11)
2724  {
2725  isNeib=true;
2726  break;
2727  }
2728  }
2729 
2730  if(isNeib) //direct neighbor
2731  {
2732  if(f2c1[c11]>-1 && f2c1[c01]<0) //other guy paired, im not
2733  f2c1[c01]=f2c1[c11];
2734  else if(f2c1[c01]>-1 && f2c1[c11]<0) //im paired, other guy's not
2735  f2c1[c11]=f2c1[c01];
2736  else if(f2c1[c11]<0 && f2c1[c01]<0) //both not paired
2737  {
2738  f2c1[c11]=count1;
2739  f2c1[c01]=count1;
2740  count1++;
2741  }
2742  }
2743  else if(_level<-1) //check for indirect neighbors
2744  {
2745  const int c11neibCnt=cellCells1.getCount(c11);
2746  int middleMan=-1;
2747  for(int c11nb=0;c11nb<c11neibCnt;c11nb++)
2748  {
2749  const int c11neib=cellCells1(c11,c11nb);
2750  for(int c01neibs=0;c01neibs<neibCount1;c01neibs++)
2751  {
2752  if(cellCells1(c01,c01neibs)==c11neib)
2753  {
2754  middleMan=c11neib;
2755  break;
2756  }
2757  }
2758  }
2759  if(middleMan!=-1)
2760  {
2761  if(f2c1[middleMan]==-1)
2762  {
2763  if(f2c1[c11]<0 && f2c1[c01]<0) //both not paired
2764  {
2765  f2c1[c11]=count1;
2766  f2c1[c01]=count1;
2767  f2c1[middleMan]=count1;
2768  count1++;
2769  }
2770  else if(f2c1[c11]>-1 && f2c1[c01]<0) //other guy paired, im not
2771  {
2772  f2c1[c01]=f2c1[c11];
2773  f2c1[middleMan]=f2c1[c11];
2774  }
2775  else if(f2c1[c01]>-1 && f2c1[c11]<0) //im paired, other guy's not
2776  {
2777  f2c1[c11]=f2c1[c01];
2778  f2c1[middleMan]=f2c1[c01];
2779  }
2780  }
2781  }
2782  }
2783 
2784  }
2785  }
2786  }
2787 
2788  /*
2789  if(f2c1[c01]==-1) //still hasnt been paired -- means mesh0 cell wasnt paired.
2790  {
2791  f2c1[c01]=count1;
2792  count1++;
2793  }*/
2794 
2795  }
2796  }
2797 
2798  }
int getCount(const int i) const
virtual void zero()
Definition: Array.h:281
int getSelfCount() const
Definition: StorageSite.h:40
Array< T > TArray
Definition: Field.h:14
const FaceGroup & getFaceGroup(const int fgId) const
Definition: Mesh.cpp:1570
Definition: Mesh.h:49
const CommonMap & getCommonMap() const
Definition: StorageSite.h:60
Field fineToCoarse
Definition: GeomFields.h:41
const CRConnectivity & getAllFaceCells() const
Definition: Mesh.cpp:378
const CRConnectivity & getCellFaces() const
Definition: Mesh.cpp:454
map< const StorageSite *, shared_ptr< Array< int > > > CommonMap
Definition: StorageSite.h:25
const StorageSite & getFaces() const
Definition: Mesh.h:108
const CRConnectivity & getCellCells() const
Definition: Mesh.cpp:480
const StorageSite & getCells() const
Definition: Mesh.h:109
shared_ptr< CRConnectivity > CRPtr
const CRConnectivity & getFaceCells(const StorageSite &site) const
Definition: Mesh.cpp:388
shared_ptr< CRConnectivity > multiply(const CRConnectivity &b, const bool implicitDiagonal) const
shared_ptr< CRConnectivity > getTranspose() const
int getCount() const
Definition: StorageSite.h:39
Array< int > IntArray
Field areaMag
Definition: GeomFields.h:25
Array< int > BCfaceArray
StorageSite site
Definition: Mesh.h:40
template<class T >
int COMETModel< T >::coarsenInterior ( const int  m,
const Mesh mesh,
GeomFields inGeomFields,
int &  coarseCount 
)
inline

Definition at line 2249 of file phononbase/COMETModel.h.

References COMETModel< T >::_BFaces, GeomFields::areaMag, GeomFields::fineToCoarse, Mesh::getCellFaces(), Mesh::getCells(), CRConnectivity::getCount(), Mesh::getFaceCells(), Mesh::getFaces(), and StorageSite::getSelfCount().

Referenced by COMETModel< T >::MakeInteriorCoarseMesh().

2251  {
2252  const StorageSite& inCells=mesh.getCells();
2253  const StorageSite& inFaces=mesh.getFaces();
2254  const int inCellCount=inCells.getSelfCount();
2255  const CRConnectivity& inCellinFaces=mesh.getCellFaces();
2256  const CRConnectivity& inFaceinCells=mesh.getFaceCells(inFaces);
2257  Field& areaMagField=inGeomFields.areaMag;
2258  const TArray& areaMagArray=dynamic_cast<const TArray&>(areaMagField[inFaces]);
2259  const BCfaceArray& inBCfArray=*(_BFaces[m]);
2260 
2261  IntArray& FineToCoarse=dynamic_cast<IntArray&>(inGeomFields.fineToCoarse[inCells]);
2262 
2263  //first sweep to make initial pairing
2264  int pairWith;
2265  for(int c=0;c<inCellCount;c++)
2266  {
2267  if(FineToCoarse[c]<0) //dont bother if im already paired
2268  {
2269  //loop through all neighbors to find pairing
2270  const int neibCount=inCellinFaces.getCount(c);
2271  pairWith=-1;
2272  T maxArea=0.;
2273  int c2;
2274  for(int neib=0;neib<neibCount;neib++)
2275  {
2276  const int f=inCellinFaces(c,neib);
2277 
2278  if(inBCfArray[f]==0) //not a boundary face
2279  {
2280  if(c==inFaceinCells(f,1))
2281  c2=inFaceinCells(f,0);
2282  else
2283  c2=inFaceinCells(f,1);
2284 
2285  if(FineToCoarse[c2]==-1) //not already paired
2286  {
2287  if(areaMagArray[f]>maxArea)
2288  {
2289  pairWith=c2;
2290  maxArea=areaMagArray[f];
2291  }
2292  }
2293 
2294  }
2295  }
2296 
2297  if(pairWith!=-1)
2298  {
2299  FineToCoarse[c]=coarseCount;
2300  FineToCoarse[pairWith]=coarseCount;
2301  coarseCount++;
2302  }
2303  }
2304  }
2305 
2306  //second sweep to group stragglers, or group with self
2307  for(int c=0;c<inCellCount;c++)
2308  {
2309  if(FineToCoarse[c]==-1)
2310  {
2311  const int neibCount=inCellinFaces.getCount(c);
2312  T maxArea=0.;
2313  int c2,c2perm;
2314  pairWith=-2;
2315 
2316  for(int neib=0;neib<neibCount;neib++)
2317  {
2318  const int f=inCellinFaces(c,neib);
2319 
2320  if(inBCfArray[f]==0) //not a boundary face
2321  {
2322  if(c==inFaceinCells(f,1))
2323  c2=inFaceinCells(f,0);
2324  else
2325  c2=inFaceinCells(f,1);
2326 
2327  if(areaMagArray[f]>maxArea)
2328  {
2329  pairWith=FineToCoarse[c2]; //coarse level cell
2330  c2perm=c2; //fine level cell
2331  maxArea=areaMagArray[f];
2332  }
2333  }
2334  }
2335 
2336  if(pairWith==-2) //could not find suitable pair
2337  {
2338  FineToCoarse[c]=coarseCount;
2339  coarseCount++;
2340  }
2341  else //found cell to pair with
2342  {
2343  if(FineToCoarse[c2perm]==-1)
2344  {
2345  FineToCoarse[c]=coarseCount;
2346  FineToCoarse[c2perm]=coarseCount;
2347  coarseCount++;
2348  }
2349  else
2350  FineToCoarse[c]=FineToCoarse[c2perm];
2351  }
2352  }
2353  }
2354  return coarseCount;
2355  }
int getCount(const int i) const
int getSelfCount() const
Definition: StorageSite.h:40
Array< T > TArray
Definition: Field.h:14
Field fineToCoarse
Definition: GeomFields.h:41
const CRConnectivity & getCellFaces() const
Definition: Mesh.cpp:454
const StorageSite & getFaces() const
Definition: Mesh.h:108
const StorageSite & getCells() const
Definition: Mesh.h:109
const CRConnectivity & getFaceCells(const StorageSite &site) const
Definition: Mesh.cpp:388
Array< int > IntArray
Field areaMag
Definition: GeomFields.h:25
Array< int > BCfaceArray
template<class T >
void COMETModel< T >::ComputeCoarseMacroparameters ( )
inline

Definition at line 1353 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_macroFields, Model::_meshes, Field::addArray(), Mesh::getCells(), StorageSite::getCount(), MacroFields::velocityFASCorrection, MacroFields::velocityInjected, and MacroFields::velocityResidual.

Referenced by COMETModel< T >::MakeIBCoarseModel().

1354  {
1355  const int numMeshes = _meshes.size();
1356  const T zero(0.0);
1357  for (int n=0; n<numMeshes; n++)
1358  {
1359 
1360  const Mesh& mesh = *_meshes[n];
1361  const StorageSite& cells = mesh.getCells();
1362  const int nCells = cells.getCount(); //
1363 
1364  VectorT3 zeroVelocity;
1365  zeroVelocity[0] = zero;
1366  zeroVelocity[1] = zero;
1367  zeroVelocity[2] = zero;
1368 
1369  shared_ptr<VectorT3Array> vRCell(new VectorT3Array(nCells));
1370  *vRCell = zeroVelocity;
1371  _macroFields.velocityResidual.addArray(cells,vRCell);
1372 
1373  shared_ptr<VectorT3Array> vICell(new VectorT3Array(nCells));
1374  *vICell = zeroVelocity;
1375  _macroFields.velocityInjected.addArray(cells,vICell);
1376 
1377  shared_ptr<VectorT3Array> vFCell(new VectorT3Array(nCells));
1378  *vFCell = zeroVelocity;
1380 
1381  /*
1382  VectorT3Array& vR = dynamic_cast<VectorT3Array&>(_macroFields.velocityResidual[cells]);
1383  VectorT3Array& vI = dynamic_cast<VectorT3Array&>(_macroFields.velocityInjected[cells]);
1384  VectorT3Array& vF = dynamic_cast<VectorT3Array&>(_macroFields.velocityFASCorrection[cells]);
1385 
1386  for(int c=0; c<nCells;c++)
1387  {
1388  vR[c][0]=0.0;
1389  vR[c][1]=0.0;
1390  vR[c][2]=0.0;
1391 
1392  vI[c][0]=0.0;
1393  vI[c][1]=0.0;
1394  vI[c][2]=0.0;
1395 
1396  vF[c][0]=0.0;
1397  vF[c][1]=0.0;
1398  vF[c][2]=0.0;
1399  }
1400  */
1401 
1402  }// end of loop over nmeshes
1403  //fclose(pFile);
1404  }
Field velocityInjected
Definition: MacroFields.h:17
Definition: Mesh.h:49
Field velocityResidual
Definition: MacroFields.h:16
Array< VectorT3 > VectorT3Array
MacroFields & _macroFields
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
Field velocityFASCorrection
Definition: MacroFields.h:18
int getCount() const
Definition: StorageSite.h:39
template<class T >
void COMETModel< T >::ComputeCollisionfrequency ( )
inline

Definition at line 1486 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_options, MacroFields::collisionFrequency, MacroFields::density, Mesh::getCells(), StorageSite::getCount(), MacroFields::temperature, and MacroFields::viscosity.

Referenced by COMETModel< T >::COMETModel(), COMETModel< T >::cycle(), COMETModel< T >::MakeIBCoarseModel(), and COMETModel< T >::smooth().

1486  {
1487  const int numMeshes = _meshes.size();
1488  for (int n=0; n<numMeshes; n++)
1489  {
1490 
1491  const T rho_init=_options["rho_init"];
1492  const T T_init= _options["T_init"];
1493  const T mu_w= _options["mu_w"];
1494  const T Tmuref= _options["Tmuref"];
1495  const T muref= _options["muref"];
1496  const T R=8314.0/_options["molecularWeight"];
1497  const T nondim_length=_options["nonDimLt"];
1498 
1499  const T mu0=rho_init*R* T_init*nondim_length/pow(2*R* T_init,0.5);
1500 
1501 
1502  const Mesh& mesh = *_meshes[n];
1503  const StorageSite& cells = mesh.getCells();
1504  const int nCells = cells.getCount();
1505 
1506  TArray& density = dynamic_cast<TArray&>(_macroFields.density[cells]);
1507  TArray& viscosity = dynamic_cast<TArray&>(_macroFields.viscosity[cells]);
1508  TArray& temperature = dynamic_cast<TArray&>(_macroFields.temperature[cells]);
1509 
1510  TArray& collisionFrequency = dynamic_cast<TArray&>(_macroFields.collisionFrequency[cells]);
1511  for(int c=0; c<nCells;c++)
1512  {
1513  viscosity[c]= muref*pow(temperature[c]*T_init/ Tmuref,mu_w); // viscosity power law
1514  collisionFrequency[c]=density[c]*temperature[c]/viscosity[c]*mu0;
1515  }
1516 
1517  if(_options.fgamma==2){
1518  for(int c=0; c<nCells;c++)
1519  collisionFrequency[c]=_options.Prandtl*collisionFrequency[c];
1520  }
1521 
1522  }
1523  }
Array< T > TArray
Definition: Mesh.h:49
COMETModelOptions< T > _options
Field viscosity
Definition: MacroFields.h:20
Field temperature
Definition: MacroFields.h:22
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
int getCount() const
Definition: StorageSite.h:39
Field collisionFrequency
Definition: MacroFields.h:24
Field density
Definition: MacroFields.h:21
template<class T >
void COMETModel< T >::ComputeCOMETMacroparameters ( )
inline

Definition at line 1235 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfPtr, COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_quadrature, MacroFields::density, Mesh::getCells(), StorageSite::getCount(), MacroFields::pressure, MacroFields::Stress, MacroFields::temperature, and MacroFields::velocity.

Referenced by COMETModel< T >::cycle(), and COMETModel< T >::smooth().

1236  {
1237  //FILE * pFile;
1238  //pFile = fopen("distfun_mf.txt","w");
1239  const int numMeshes = _meshes.size();
1240  for (int n=0; n<numMeshes; n++)
1241  {
1242 
1243  const Mesh& mesh = *_meshes[n];
1244  const StorageSite& cells = mesh.getCells();
1245  const int nCells = cells.getCount(); //
1246 
1247 
1248  TArray& density = dynamic_cast<TArray&>(_macroFields.density[cells]);
1249  TArray& temperature = dynamic_cast<TArray&>(_macroFields.temperature[cells]);
1250  const VectorT3Array& v = dynamic_cast<const VectorT3Array&>(_macroFields.velocity[cells]);
1251  TArray& pressure = dynamic_cast<TArray&>(_macroFields.pressure[cells]);
1252  const int N123 = _quadrature.getDirCount();
1253 
1254  const TArray& cx = dynamic_cast<const TArray&>(*_quadrature.cxPtr);
1255  const TArray& cy = dynamic_cast<const TArray&>(*_quadrature.cyPtr);
1256  const TArray& cz = dynamic_cast<const TArray&>(*_quadrature.czPtr);
1257  const TArray& wts= dynamic_cast<const TArray&>(*_quadrature.dcxyzPtr);
1258 
1259  VectorT6Array& stress = dynamic_cast<VectorT6Array&>(_macroFields.Stress[cells]);
1260 
1261  //initialize density,velocity,temperature to zero
1262  for(int c=0; c<nCells;c++)
1263  {
1264  density[c]=0.0;
1265  temperature[c]=0.0;
1266  stress[c][0]=0.0;stress[c][1]=0.0;stress[c][2]=0.0;
1267  stress[c][3]=0.0;stress[c][4]=0.0;stress[c][5]=0.0;
1268 
1269  }
1270 
1271 
1272  for(int j=0;j<N123;j++){
1273 
1274  Field& fnd = *_dsfPtr.dsf[j];
1275  const TArray& f = dynamic_cast<const TArray&>(fnd[cells]);
1276 
1277  //fprintf(pFile,"%d %12.6f %E %E %E %E \n",j,dcxyz[j],cx[j],cy[j],f[80],density[80]+dcxyz[j]*f[80]);
1278 
1279  for(int c=0; c<nCells;c++){
1280  density[c] = density[c]+wts[j]*f[c];
1281  temperature[c]= temperature[c]+(pow(cx[j],2.0)+pow(cy[j],2.0)
1282  +pow(cz[j],2.0))*f[c]*wts[j];
1283 
1284  }
1285 
1286  }
1287 
1288 
1289 
1290  for(int c=0; c<nCells;c++){
1291  temperature[c]=temperature[c]-(pow(v[c][0],2.0)
1292  +pow(v[c][1],2.0)
1293  +pow(v[c][2],2.0))*density[c];
1294  temperature[c]=temperature[c]/(1.5*density[c]);
1295  pressure[c]=density[c]*temperature[c];
1296  }
1297 
1298  //Find Pxx,Pyy,Pzz,Pxy,Pyz,Pzx, etc in field
1299 
1300  for(int j=0;j<N123;j++){
1301  Field& fnd = *_dsfPtr.dsf[j];
1302  const TArray& f = dynamic_cast<const TArray&>(fnd[cells]);
1303  for(int c=0; c<nCells;c++){
1304  stress[c][0] +=pow((cx[j]-v[c][0]),2.0)*f[c]*wts[j];
1305  stress[c][1] +=pow((cy[j]-v[c][1]),2.0)*f[c]*wts[j];
1306  stress[c][2] +=pow((cz[j]-v[c][2]),2.0)*f[c]*wts[j];
1307  stress[c][3] +=(cx[j]-v[c][0])*(cy[j]-v[c][1])*f[c]*wts[j];
1308  stress[c][4] +=(cy[j]-v[c][1])*(cz[j]-v[c][2])*f[c]*wts[j];
1309  stress[c][5] +=(cz[j]-v[c][2])*(cx[j]-v[c][0])*f[c]*wts[j];
1310 
1311  }}
1312 
1313 
1314  }// end of loop over nmeshes
1315  //fclose(pFile);
1316  }
Quadrature< T > & _quadrature
Array< T > TArray
Definition: Field.h:14
Field Stress
Definition: MacroFields.h:37
Definition: Mesh.h:49
Field temperature
Definition: MacroFields.h:22
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
Array< VectorT6 > VectorT6Array
Field velocity
Definition: MacroFields.h:15
Field pressure
Definition: MacroFields.h:19
DistFunctFields< T > _dsfPtr
int getCount() const
Definition: StorageSite.h:39
Field density
Definition: MacroFields.h:21
template<class T >
void COMETModel< T >::ComputeFineMacroparameters ( )
inline

Definition at line 1318 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_macroFields, Model::_meshes, Field::addArray(), Mesh::getCells(), StorageSite::getCount(), and MacroFields::velocityResidual.

Referenced by COMETModel< T >::COMETModel().

1319  {
1320  const int numMeshes = _meshes.size();
1321  const T zero(0.0);
1322  for (int n=0; n<numMeshes; n++)
1323  {
1324 
1325  const Mesh& mesh = *_meshes[n];
1326  const StorageSite& cells = mesh.getCells();
1327  const int nCells = cells.getCount(); //
1328 
1329  VectorT3 zeroVelocity;
1330  zeroVelocity[0] = zero;
1331  zeroVelocity[1] = zero;
1332  zeroVelocity[2] = zero;
1333 
1334  shared_ptr<VectorT3Array> vRCell(new VectorT3Array(nCells));
1335  *vRCell = zeroVelocity;
1336  _macroFields.velocityResidual.addArray(cells,vRCell);
1337 
1338  /*
1339  VectorT3Array& vR = dynamic_cast<VectorT3Array&>(_macroFields.velocityResidual[cells]);
1340 
1341  for(int c=0; c<nCells;c++)
1342  {
1343  vR[c][0]=0.0;
1344  vR[c][1]=0.0;
1345  vR[c][2]=0.0;
1346  }
1347  */
1348 
1349  }// end of loop over nmeshes
1350  //fclose(pFile);
1351  }
Definition: Mesh.h:49
Field velocityResidual
Definition: MacroFields.h:16
Array< VectorT3 > VectorT3Array
MacroFields & _macroFields
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
int getCount() const
Definition: StorageSite.h:39
template<class T >
void COMETModel< T >::computeIBFaceDsf ( const StorageSite solidFaces,
const int  method,
const int  RelaxDistribution = 0 
)
inline

Definition at line 3473 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfEqPtrES, COMETModel< T >::_dsfPtr, COMETModel< T >::_finestGeomFields, COMETModel< T >::_finestMeshes, COMETModel< T >::_geomFields, GeomFields::_interpolationMatrices, COMETModel< T >::_level, COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_options, COMETModel< T >::_quadrature, Field::addArray(), MacroFields::collisionFrequency, GeomFields::coordinate, MacroFields::density, GeomFields::finestToCoarse, Mesh::getAllFaceCells(), Mesh::getCells(), CRConnectivity::getCol(), Mesh::getConnectivity(), StorageSite::getCount(), StorageSite::getCountLevel1(), Array< T >::getData(), Mesh::getFaces(), Mesh::getIBFaceList(), Mesh::getIBFaces(), CRConnectivity::getRow(), GeomFields::ibType, Mesh::isShell(), sqrt(), MacroFields::temperature, MacroFields::velocity, MacroFields::viscosity, and Array< T >::zero().

Referenced by COMETModel< T >::cycle(), and COMETModel< T >::smooth().

3474  {
3475  typedef CRMatrixTranspose<T,T,T> IMatrix;
3476  typedef CRMatrixTranspose<T,VectorT3,VectorT3> IMatrixV3;
3477  if (method==1){
3478  const int numMeshes = _meshes.size();
3479  const int numFields= _quadrature.getDirCount();
3480  for (int direction = 0; direction < numFields; direction++)
3481  {
3482  Field& fnd = *_dsfPtr.dsf[direction];
3483  const TArray& pV =
3484  dynamic_cast<const TArray&>(fnd[solidFaces]);
3485  #ifdef FVM_PARALLEL
3486  MPI::COMM_WORLD.Allreduce( MPI::IN_PLACE,pV.getData(),solidFaces.getCount() , MPI::DOUBLE, MPI::SUM);
3487  #endif
3488 
3489  for (int n=0; n<numMeshes; n++)
3490  {
3491  const Mesh& mesh = *_meshes[n];
3492  const Mesh& fMesh = *_finestMeshes[n];
3493  if (!mesh.isShell() && mesh.getIBFaces().getCount() > 0){
3494 
3495  const StorageSite& cells = mesh.getCells();
3496  const StorageSite& fCells = fMesh.getCells();
3497  const StorageSite& ibFaces = mesh.getIBFaces();
3498  const StorageSite& fIbFaces = fMesh.getIBFaces();
3499 
3500  GeomFields::SSPair key1(&fIbFaces,&fCells);
3501  const IMatrix& mIC =
3502  dynamic_cast<const IMatrix&>
3504 
3505  IMatrix mICV(mIC);
3506 
3507 
3508  GeomFields::SSPair key2(&fIbFaces,&solidFaces);
3509  const IMatrix& mIP =
3510  dynamic_cast<const IMatrix&>
3512 
3513  IMatrix mIPV(mIP);
3514 
3515 
3516  shared_ptr<TArray> ibV(new TArray(ibFaces.getCount()));
3517 
3518  Field& FinestToCoarseField=_finestGeomFields.finestToCoarse;
3519  const Array<Vector<int,25> >& FinestToCoarse=dynamic_cast<const Array<Vector<int,25> >&>(FinestToCoarseField[fCells]);
3520 
3521  const TArray& cV =
3522  dynamic_cast<const TArray&>(fnd[cells]);
3523  TArray cFV(fCells.getCountLevel1());
3524  for(int c=0;c<fCells.getCountLevel1();c++)
3525  cFV[c]=cV[FinestToCoarse[c][_level]];
3526 
3527  ibV->zero();
3528 
3529  mICV.multiplyAndAdd(*ibV,cFV);
3530  mIPV.multiplyAndAdd(*ibV,pV);
3531 
3532 #if 0
3533  ofstream debugFile;
3534  stringstream ss(stringstream::in | stringstream::out);
3535  ss << MPI::COMM_WORLD.Get_rank();
3536  string fname1 = "IBVelocity_proc" + ss.str() + ".dat";
3537  debugFile.open(fname1.c_str());
3538 
3539  //debug use
3540  const Array<int>& ibFaceList = mesh.getIBFaceList();
3541  const StorageSite& faces = mesh.getFaces();
3542  const VectorT3Array& faceCentroid =
3543  dynamic_cast<const VectorT3Array&> (_geomFields.coordinate[faces]);
3544  const double angV = 1.0;
3545  VectorT3 center;
3546  center[0]=0.;
3547  center[1]=0.;
3548  center[2]=0.;
3549 
3550  for(int f=0; f<ibFaces.getCount();f++){
3551  int fID = ibFaceList[f];
3552  debugFile << "f=" << f << setw(10) << " fID = " << fID << " faceCentroid = " << faceCentroid[fID] << " ibV = " << (*ibV)[f] << endl;
3553  }
3554 
3555  debugFile.close();
3556 #endif
3557 
3558  fnd.addArray(ibFaces,ibV);
3559  }
3560  }
3561  }
3562  /*
3563  for (int n=0; n<numMeshes; n++)
3564  {
3565  const Mesh& mesh = *_meshes[n];
3566  if (!mesh.isShell() && mesh.getIBFaces().getCount() > 0){
3567 
3568  const StorageSite& cells = mesh.getCells();
3569  const StorageSite& cells = mesh.getCells();
3570  const StorageSite& ibFaces = mesh.getIBFaces();
3571  const StorageSite& fIbFaces = fMesh.getIBFaces();
3572 
3573  GeomFields::SSPair key1(&fIbFaces,&fCells);
3574  const IMatrix& mIC =
3575  dynamic_cast<const IMatrix&>
3576  (*_finestGeomFields._interpolationMatrices[key1]);
3577 
3578  IMatrixV3 mICV3(mIC);
3579 
3580  GeomFields::SSPair key2(&fIbFaces,&solidFaces);
3581  const IMatrix& mIP =
3582  dynamic_cast<const IMatrix&>
3583  (*_finestGeomFields._interpolationMatrices[key2]);
3584 
3585  IMatrixV3 mIPV3(mIP);
3586 
3587  shared_ptr<VectorT3Array> ibVvel(new VectorT3Array(ibFaces.getCount()));
3588 
3589 
3590  const VectorT3Array& cVel =
3591  dynamic_cast<VectorT3Array&>(_macroFields.velocity[cells]);
3592  const VectorT3Array& sVel =
3593  dynamic_cast<VectorT3Array&>(_macroFields.velocity[solidFaces]);
3594 
3595  ibVvel->zero();
3596 
3597  //velocity interpolation (cells+solidfaces)
3598  mICV3.multiplyAndAdd(*ibVvel,cVel);
3599  mIPV3.multiplyAndAdd(*ibVvel,sVel);
3600  _macroFields.velocity.addArray(ibFaces,ibVvel);
3601 
3602 
3603  }
3604  }
3605  */
3606  }
3607 
3608  if (method==2){
3609  const int numMeshes = _meshes.size();
3610  const int nSolidFaces = solidFaces.getCount();
3611 
3612  shared_ptr<TArray> muSolid(new TArray(nSolidFaces));
3613  *muSolid =0;
3614  _macroFields.viscosity.addArray(solidFaces,muSolid);
3615 
3616  shared_ptr<TArray> nueSolid(new TArray(nSolidFaces));
3617  *nueSolid =0;
3618  _macroFields.collisionFrequency.addArray(solidFaces,nueSolid);
3619 
3620  const T rho_init=_options["rho_init"];
3621  const T T_init= _options["T_init"];
3622  const T mu_w= _options["mu_w"];
3623  const T Tmuref= _options["Tmuref"];
3624  const T muref= _options["muref"];
3625  const T R=8314.0/_options["molecularWeight"];
3626  const T nondim_length=_options["nonDimLt"];
3627 
3628  const T mu0=rho_init*R* T_init*nondim_length/pow(2*R* T_init,0.5);
3629 
3630  TArray& density = dynamic_cast<TArray&>(_macroFields.density[solidFaces]);
3631  TArray& viscosity = dynamic_cast<TArray&>(_macroFields.viscosity[solidFaces]);
3632  TArray& temperature = dynamic_cast<TArray&>(_macroFields.temperature[solidFaces]);
3633  TArray& collisionFrequency = dynamic_cast<TArray&>(_macroFields.collisionFrequency[solidFaces]);
3634 
3635  for(int c=0; c<nSolidFaces;c++)
3636  {
3637  viscosity[c]= muref*pow(temperature[c]*T_init/ Tmuref,mu_w); // viscosity power law
3638  collisionFrequency[c]=density[c]*temperature[c]/viscosity[c]*mu0;
3639  }
3640 
3641  if(_options.fgamma==2){
3642  for(int c=0; c<nSolidFaces;c++)
3643  collisionFrequency[c]=_options.Prandtl*collisionFrequency[c];
3644  }
3645 
3646 
3647 
3648 
3649  for (int n=0; n<numMeshes; n++)
3650  {
3651  const Mesh& mesh = *_meshes[n];
3652  const Mesh& fMesh = *_finestMeshes[n];
3653  if (!mesh.isShell() && mesh.getIBFaces().getCount() > 0){
3654 
3655  const StorageSite& cells = mesh.getCells();
3656  const StorageSite& fCells = fMesh.getCells();
3657  const StorageSite& ibFaces = mesh.getIBFaces();
3658  const StorageSite& fIbFaces = fMesh.getIBFaces();
3659 
3660  GeomFields::SSPair key1(&fIbFaces,&fCells);
3661  const IMatrix& mIC =
3662  dynamic_cast<const IMatrix&>
3664 
3665  IMatrix mICV(mIC);
3666  IMatrixV3 mICV3(mIC);
3667 
3668  GeomFields::SSPair key2(&fIbFaces,&solidFaces);
3669  const IMatrix& mIP =
3670  dynamic_cast<const IMatrix&>
3672 
3673  IMatrix mIPV(mIP);
3674  IMatrixV3 mIPV3(mIP);
3675 
3676  shared_ptr<TArray> ibVtemp(new TArray(ibFaces.getCount()));
3677  shared_ptr<TArray> ibVnue(new TArray(ibFaces.getCount()));
3678  shared_ptr<TArray> ibVdensity(new TArray(ibFaces.getCount()));
3679  shared_ptr<VectorT3Array> ibVvel(new VectorT3Array(ibFaces.getCount()));
3680 
3681  const TArray& cTemp =
3682  dynamic_cast<TArray&>(_macroFields.temperature[cells]);
3683  const VectorT3Array& cVel =
3684  dynamic_cast<VectorT3Array&>(_macroFields.velocity[cells]);
3685  const TArray& cDensity =
3686  dynamic_cast<TArray&>(_macroFields.density[cells]);
3687  const TArray& sDensity =
3688  dynamic_cast<TArray&>(_macroFields.density[solidFaces]);
3689  const TArray& cNue =
3690  dynamic_cast<TArray&>(_macroFields.collisionFrequency[cells]);
3691  const TArray& sNue =
3692  dynamic_cast<TArray&>(_macroFields.collisionFrequency[solidFaces]);
3693  const TArray& sTemp =
3694  dynamic_cast<TArray&>(_macroFields.temperature[solidFaces]);
3695  const VectorT3Array& sVel =
3696  dynamic_cast<VectorT3Array&>(_macroFields.velocity[solidFaces]);
3697 
3698  ibVnue->zero();
3699  ibVtemp->zero();
3700  ibVvel->zero();
3701  ibVdensity->zero();
3702 
3703 
3704  Field& FinestToCoarseField=_finestGeomFields.finestToCoarse;
3705  const Array<Vector<int,25> >& FinestToCoarse=dynamic_cast<const Array<Vector<int,25> >&>(FinestToCoarseField[fCells]);
3706 
3707  TArray cFTemp(fCells.getCount());
3708  VectorT3Array cFVel(fCells.getCount());
3709  TArray cFDensity(fCells.getCount());
3710  TArray cFNue(fCells.getCount());
3711 
3712  for(int c=0;c<fCells.getCount();c++)
3713  {
3714  cFTemp[c]=cTemp[FinestToCoarse[c][_level]];
3715  cFVel[c]=cVel[FinestToCoarse[c][_level]];
3716  cFDensity[c]=cDensity[FinestToCoarse[c][_level]];
3717  cFNue[c]=cNue[FinestToCoarse[c][_level]];
3718  }
3719 
3720  //nue interpolation (cells)
3721  mICV.multiplyAndAdd(*ibVnue,cFNue);
3722  mIPV.multiplyAndAdd(*ibVnue,sNue);
3723  _macroFields.collisionFrequency.addArray(ibFaces,ibVnue);
3724  //temperature interpolation (cells+solidfaces)
3725  mICV.multiplyAndAdd(*ibVtemp,cFTemp);
3726  mIPV.multiplyAndAdd(*ibVtemp,sTemp);
3727  _macroFields.temperature.addArray(ibFaces,ibVtemp);
3728  //density interpolation (cells+solidfaces)
3729  mICV.multiplyAndAdd(*ibVdensity,cFDensity);
3730  mIPV.multiplyAndAdd(*ibVdensity,sDensity);
3731  _macroFields.density.addArray(ibFaces,ibVdensity);
3732  //velocity interpolation (cells+solidfaces)
3733  mICV3.multiplyAndAdd(*ibVvel,cFVel);
3734  mIPV3.multiplyAndAdd(*ibVvel,sVel);
3735  _macroFields.velocity.addArray(ibFaces,ibVvel);
3736 
3737 
3738  }
3739  }
3740 
3741  const int f_out = 3;
3742  if (f_out ==1){
3743  //Step 2 Find fgamma using macroparameters
3744  const int numMeshes = _meshes.size();
3745  for (int n=0; n<numMeshes; n++)
3746  {
3747  const Mesh& mesh = *_meshes[n];
3748  if (!mesh.isShell() && mesh.getIBFaces().getCount() > 0){
3749  const int numDirections = _quadrature.getDirCount();
3750  const StorageSite& ibFaces = mesh.getIBFaces();
3751  const int nibFaces=ibFaces.getCount();
3752  const double pi=_options.pi;
3753  const TArray& ibTemp =
3754  dynamic_cast<TArray&>(_macroFields.temperature[ibFaces]);
3755  const VectorT3Array& ibVel =
3756  dynamic_cast<VectorT3Array&>(_macroFields.velocity[ibFaces]);
3757  const TArray& ibDensity =
3758  dynamic_cast<TArray&>(_macroFields.density[ibFaces]);
3759 
3760  for (int j=0; j<numDirections; j++)
3761  {
3762  shared_ptr<TArray> ibFndPtrEqES(new TArray(nibFaces));
3763  TArray& ibFndEqES= *ibFndPtrEqES;
3764  ibFndPtrEqES->zero();
3765  Field& fndEqES = *_dsfEqPtrES.dsf[j];
3766 
3767  for (int i=0; i<nibFaces; i++)
3768  {
3769  const TArray& cx = dynamic_cast<const TArray&>(*_quadrature.cxPtr);
3770  const TArray& cy = dynamic_cast<const TArray&>(*_quadrature.cyPtr);
3771  const TArray& cz = dynamic_cast<const TArray&>(*_quadrature.czPtr);
3772  const T ibu = ibVel[i][0];
3773  const T ibv = ibVel[i][1];
3774  const T ibw = ibVel[i][2];
3775  ibFndEqES[i]=ibDensity[i]/pow(pi*ibTemp[i],1.5)*exp(-(pow(cx[j]-ibu,2.0)+pow(cy[j]-ibv,2.0)+pow(cz[j]-ibw,2.0))/ibTemp[i]);
3776  }
3777  fndEqES.addArray(ibFaces,ibFndPtrEqES);
3778  }
3779  }
3780  }
3781  }
3782  else if(f_out==2)
3783  {
3784  //Step 2 Find fgamma using interpolation (only ESBGK for now)
3785  for (int n=0; n<numMeshes; n++)
3786  {
3787  const int numFields= _quadrature.getDirCount();
3788  for (int direction = 0; direction < numFields; direction++)
3789  {
3790  Field& fndEqES = *_dsfEqPtrES.dsf[direction];
3791  const Mesh& mesh = *_meshes[n];
3792  if (!mesh.isShell() && mesh.getIBFaces().getCount() > 0){
3793 
3794  const StorageSite& cells = mesh.getCells();
3795  const StorageSite& ibFaces = mesh.getIBFaces();
3796 
3797  GeomFields::SSPair key1(&ibFaces,&cells);
3798  const IMatrix& mIC =
3799  dynamic_cast<const IMatrix&>
3801 
3802  IMatrix mICV(mIC);
3803 
3804  GeomFields::SSPair key2(&ibFaces,&solidFaces);
3805  const IMatrix& mIP =
3806  dynamic_cast<const IMatrix&>
3808 
3809  IMatrix mIPV(mIP);
3810 
3811  shared_ptr<TArray> ibVf(new TArray(ibFaces.getCount()));
3812 
3813  const TArray& cf =
3814  dynamic_cast<const TArray&>(fndEqES[cells]);
3815 
3816  ibVf->zero();
3817 
3818  //distribution function interpolation (cells)
3819  mICV.multiplyAndAdd(*ibVf,cf);
3820  fndEqES.addArray(ibFaces,ibVf);
3821 
3822  }
3823  }
3824  }
3825  }
3826  //Step3: Relax Distribution function from ibfaces to solid face
3827  for (int n=0; n<numMeshes; n++)
3828  {
3829  const int numDirections = _quadrature.getDirCount();
3830  for (int j=0; j<numDirections; j++)
3831  {
3832  Field& fnd = *_dsfPtr.dsf[j];
3833  TArray& dsf = dynamic_cast< TArray&>(fnd[solidFaces]);
3834 
3835 #ifdef FVM_PARALLEL
3836  MPI::COMM_WORLD.Allreduce( MPI::IN_PLACE,dsf.getData(),solidFaces.getCount() , MPI::DOUBLE, MPI::SUM);
3837 #endif
3838  const Mesh& mesh = *_meshes[n];
3839  const Mesh& fMesh = *_finestMeshes[n];
3840  if (!mesh.isShell() && mesh.getIBFaces().getCount() > 0){
3841  const StorageSite& ibFaces = mesh.getIBFaces();
3842  const StorageSite& fIbFaces = fMesh.getIBFaces();
3843  TArray& dsfIB = dynamic_cast< TArray&>(fnd[ibFaces]);
3844  Field& fndEqES = *_dsfEqPtrES.dsf[j];
3845  TArray& dsfEqES = dynamic_cast< TArray&>(fndEqES[ibFaces]);
3846  const StorageSite& faces = fMesh.getFaces();
3847  const StorageSite& cells = mesh.getCells();
3848  const CRConnectivity& faceCells = mesh.getAllFaceCells();
3849  const CRConnectivity& ibFacesTosolidFaces
3850  = fMesh.getConnectivity(fIbFaces,solidFaces);
3851  const IntArray& ibFaceIndices = fMesh.getIBFaceList();
3852  const IntArray& ibType = dynamic_cast<const IntArray&>(_geomFields.ibType[cells]);
3853  const IntArray& sFCRow = ibFacesTosolidFaces.getRow();
3854  const IntArray& sFCCol = ibFacesTosolidFaces.getCol();
3855  const int nibFaces = ibFaces.getCount();
3856  const int nFaces = faces.getCount();
3857  const TArray& cx = dynamic_cast<const TArray&>(*_quadrature.cxPtr);
3858  const TArray& cy = dynamic_cast<const TArray&>(*_quadrature.cyPtr);
3859  const TArray& cz = dynamic_cast<const TArray&>(*_quadrature.czPtr);
3860  VectorT3Array& v = dynamic_cast<VectorT3Array&>(_macroFields.velocity[solidFaces]);
3861 
3862  for(int f=0; f<nibFaces; f++)
3863  {
3864  dsfIB[f]=0.0;
3865  double distIBSolidInvSum(0.0);
3866  for(int nc = sFCRow[f]; nc<sFCRow[f+1]; nc++)
3867  {
3868  const int c = sFCCol[nc];
3869  const int faceIB= ibFaceIndices[f];
3870  const VectorT3Array& solidFaceCentroid =
3871  dynamic_cast<const VectorT3Array&> (_finestGeomFields.coordinate[solidFaces]);
3872  const VectorT3Array& faceCentroid =
3873  dynamic_cast<const VectorT3Array&> (_finestGeomFields.coordinate[faces]);
3874 
3875  double distIBSolid (0.0);
3876  // based on distance - will be thought
3877  distIBSolid = sqrt(pow((faceCentroid[faceIB][0]-solidFaceCentroid[c][0]),2)+
3878  pow((faceCentroid[faceIB][1]-solidFaceCentroid[c][1]),2)+
3879  pow((faceCentroid[faceIB][2]-solidFaceCentroid[c][2]),2));
3880  distIBSolidInvSum += 1/pow(distIBSolid,RelaxDistribution);
3881  }
3882  for(int nc = sFCRow[f]; nc<sFCRow[f+1]; nc++)
3883  {
3884  const int c = sFCCol[nc];
3885  const VectorT3Array& solidFaceCentroid =
3886  dynamic_cast<const VectorT3Array&> (_finestGeomFields.coordinate[solidFaces]);
3887  const VectorT3Array& faceCentroid =
3888  dynamic_cast<const VectorT3Array&> (_finestGeomFields.coordinate[faces]);
3889  const TArray& nue =
3890  dynamic_cast<TArray&>(_macroFields.collisionFrequency[ibFaces]);
3891  const int faceIB= ibFaceIndices[f];
3892  // const T coeff = iCoeffs[nc];
3893  double time_to_wall (0.0);
3894  double distIBSolid (0.0);
3895  const T uwall = v[c][0];
3896  const T vwall = v[c][1];
3897  const T wwall = v[c][2];
3898  // based on distance - will be thought
3899  distIBSolid = sqrt(pow((faceCentroid[faceIB][0]-solidFaceCentroid[c][0]),2)+
3900  pow((faceCentroid[faceIB][1]-solidFaceCentroid[c][1]),2)+
3901  pow((faceCentroid[faceIB][2]-solidFaceCentroid[c][2]),2));
3902  time_to_wall = -1*(pow(distIBSolid,2)/((cx[j]-uwall)*(faceCentroid[faceIB][0]-solidFaceCentroid[c][0])+(cy[j]-vwall)*(faceCentroid[faceIB][1]-solidFaceCentroid[c][1])+(cz[j]-wwall)*(faceCentroid[faceIB][2]-solidFaceCentroid[c][2])));
3903  if(time_to_wall<0)
3904  time_to_wall = 0;
3905 
3906  dsfIB[f] += (dsfEqES[f]-(dsfEqES[f]-dsf[c])*exp(-time_to_wall*nue[f]))/(pow(distIBSolid,RelaxDistribution)*distIBSolidInvSum);
3907 
3908  }
3909 
3910  }
3911  }
3912  }
3913  }
3914  }
3915  if (method==3){
3916  const int numMeshes = _meshes.size();
3917  for (int n=0; n<numMeshes; n++)
3918  {
3919  const Mesh& mesh = *_meshes[n];
3920  if (!mesh.isShell() && mesh.getIBFaces().getCount() > 0){
3921 
3922  const StorageSite& cells = mesh.getCells();
3923  const StorageSite& ibFaces = mesh.getIBFaces();
3924 
3925  GeomFields::SSPair key1(&ibFaces,&cells);
3926  const IMatrix& mIC =
3927  dynamic_cast<const IMatrix&>
3929 
3930  IMatrixV3 mICV3(mIC);
3931 
3932  GeomFields::SSPair key2(&ibFaces,&solidFaces);
3933  const IMatrix& mIP =
3934  dynamic_cast<const IMatrix&>
3936 
3937  IMatrixV3 mIPV3(mIP);
3938 
3939  shared_ptr<VectorT3Array> ibVvel(new VectorT3Array(ibFaces.getCount()));
3940 
3941 
3942  const VectorT3Array& cVel =
3943  dynamic_cast<VectorT3Array&>(_macroFields.velocity[cells]);
3944  const VectorT3Array& sVel =
3945  dynamic_cast<VectorT3Array&>(_macroFields.velocity[solidFaces]);
3946 
3947  ibVvel->zero();
3948 
3949  //velocity interpolation (cells+solidfaces)
3950  mICV3.multiplyAndAdd(*ibVvel,cVel);
3951  mIPV3.multiplyAndAdd(*ibVvel,sVel);
3952  _macroFields.velocity.addArray(ibFaces,ibVvel);
3953 
3954 
3955  }
3956  }
3957  const int nSolidFaces = solidFaces.getCount();
3958 
3959  shared_ptr<TArray> muSolid(new TArray(nSolidFaces));
3960  *muSolid =0;
3961  _macroFields.viscosity.addArray(solidFaces,muSolid);
3962 
3963  shared_ptr<TArray> nueSolid(new TArray(nSolidFaces));
3964  *nueSolid =0;
3965  _macroFields.collisionFrequency.addArray(solidFaces,nueSolid);
3966 
3967  const T rho_init=_options["rho_init"];
3968  const T T_init= _options["T_init"];
3969  const T mu_w= _options["mu_w"];
3970  const T Tmuref= _options["Tmuref"];
3971  const T muref= _options["muref"];
3972  const T R=8314.0/_options["molecularWeight"];
3973  const T nondim_length=_options["nonDimLt"];
3974 
3975  const T mu0=rho_init*R* T_init*nondim_length/pow(2*R* T_init,0.5);
3976 
3977  TArray& density = dynamic_cast<TArray&>(_macroFields.density[solidFaces]);
3978  TArray& viscosity = dynamic_cast<TArray&>(_macroFields.viscosity[solidFaces]);
3979  TArray& temperature = dynamic_cast<TArray&>(_macroFields.temperature[solidFaces]);
3980  TArray& collisionFrequency = dynamic_cast<TArray&>(_macroFields.collisionFrequency[solidFaces]);
3981 
3982  for(int c=0; c<nSolidFaces;c++)
3983  {
3984  viscosity[c]= muref*pow(temperature[c]*T_init/ Tmuref,mu_w); // viscosity power law
3985  collisionFrequency[c]=density[c]*temperature[c]/viscosity[c]*mu0;
3986  }
3987 
3988  if(_options.fgamma==2){
3989  for(int c=0; c<nSolidFaces;c++)
3990  collisionFrequency[c]=_options.Prandtl*collisionFrequency[c];
3991  }
3992 
3993  //Step 2 Find fgamma using interpolation (only ESBGK for now)
3994  const int numFields= _quadrature.getDirCount();
3995  for (int direction = 0; direction < numFields; direction++)
3996  {
3997  shared_ptr<TArray> ibVf(new TArray(solidFaces.getCount()));
3998  Field& fndEqES = *_dsfEqPtrES.dsf[direction];
3999  ibVf->zero();
4000  for (int n=0; n<numMeshes; n++)
4001  {
4002  const Mesh& mesh = *_meshes[n];
4003  if (!mesh.isShell() && mesh.getIBFaces().getCount() > 0){
4004 
4005  const StorageSite& cells = mesh.getCells();
4006  const StorageSite& ibFaces = mesh.getIBFaces();
4007 
4008  GeomFields::SSPair key1(&solidFaces,&cells);
4009  const IMatrix& mIC =
4010  dynamic_cast<const IMatrix&>
4012 
4013  IMatrix mICV(mIC);
4014 
4015  const TArray& cf =
4016  dynamic_cast<const TArray&>(fndEqES[cells]);
4017 
4018  ibVf->zero();
4019 
4020  //distribution function interpolation (cells)
4021  mICV.multiplyAndAdd(*ibVf,cf);
4022  }
4023  }
4024  fndEqES.addArray(solidFaces,ibVf);
4025  }
4026  for (int n=0; n<numMeshes; n++)
4027  {
4028  const int numDirections = _quadrature.getDirCount();
4029  for (int j=0; j<numDirections; j++)
4030  {
4031  Field& fnd = *_dsfPtr.dsf[j];
4032  TArray& dsf = dynamic_cast< TArray&>(fnd[solidFaces]);
4033  Field& fndEqES = *_dsfEqPtrES.dsf[j];
4034  TArray& dsfEqES = dynamic_cast< TArray&>(fndEqES[solidFaces]);
4035 #ifdef FVM_PARALLEL
4036  MPI::COMM_WORLD.Allreduce( MPI::IN_PLACE,dsf.getData(),solidFaces.getCount() , MPI::DOUBLE, MPI::SUM);
4037  MPI::COMM_WORLD.Allreduce( MPI::IN_PLACE,dsfEqES.getData(),solidFaces.getCount() , MPI::DOUBLE, MPI::SUM);
4038 #endif
4039 
4040  const Mesh& mesh = *_meshes[n];
4041  if (!mesh.isShell() && mesh.getIBFaces().getCount() > 0){
4042  const StorageSite& ibFaces = mesh.getIBFaces();
4043  const StorageSite& faces = mesh.getFaces();
4044  const StorageSite& cells = mesh.getCells();
4045  const CRConnectivity& faceCells = mesh.getAllFaceCells();
4046  const CRConnectivity& ibFacesTosolidFaces
4047  = mesh.getConnectivity(ibFaces,solidFaces);
4048  const IntArray& ibFaceIndices = mesh.getIBFaceList();
4049  const IntArray& ibType = dynamic_cast<const IntArray&>(_geomFields.ibType[cells]);
4050  const IntArray& sFCRow = ibFacesTosolidFaces.getRow();
4051  const IntArray& sFCCol = ibFacesTosolidFaces.getCol();
4052  const int nibFaces = ibFaces.getCount();
4053  const int nFaces = faces.getCount();
4054  const TArray& cx = dynamic_cast<const TArray&>(*_quadrature.cxPtr);
4055  const TArray& cy = dynamic_cast<const TArray&>(*_quadrature.cyPtr);
4056  const TArray& cz = dynamic_cast<const TArray&>(*_quadrature.czPtr);
4057  VectorT3Array& v = dynamic_cast<VectorT3Array&>(_macroFields.velocity[solidFaces]);
4058  shared_ptr<TArray> ibVf(new TArray(ibFaces.getCount()));
4059  ibVf->zero();
4060  TArray& ibVfA= *ibVf;
4061  for(int f=0; f<nibFaces; f++)
4062  {
4063  double distIBSolidInvSum(0.0);
4064  for(int nc = sFCRow[f]; nc<sFCRow[f+1]; nc++)
4065  {
4066  const int c = sFCCol[nc];
4067  const int faceIB= ibFaceIndices[f];
4068  const VectorT3Array& solidFaceCentroid =
4069  dynamic_cast<const VectorT3Array&> (_geomFields.coordinate[solidFaces]);
4070  const VectorT3Array& faceCentroid =
4071  dynamic_cast<const VectorT3Array&> (_geomFields.coordinate[faces]);
4072 
4073  double distIBSolid (0.0);
4074  // based on distance - will be thought
4075  distIBSolid = sqrt(pow((faceCentroid[faceIB][0]-solidFaceCentroid[c][0]),2)+
4076  pow((faceCentroid[faceIB][1]-solidFaceCentroid[c][1]),2)+
4077  pow((faceCentroid[faceIB][2]-solidFaceCentroid[c][2]),2));
4078  distIBSolidInvSum += 1/pow(distIBSolid,RelaxDistribution);
4079  }
4080  for(int nc = sFCRow[f]; nc<sFCRow[f+1]; nc++)
4081  {
4082  const int c = sFCCol[nc];
4083  const VectorT3Array& solidFaceCentroid =
4084  dynamic_cast<const VectorT3Array&> (_geomFields.coordinate[solidFaces]);
4085  const VectorT3Array& faceCentroid =
4086  dynamic_cast<const VectorT3Array&> (_geomFields.coordinate[faces]);
4087  const TArray& nue =
4088  dynamic_cast<TArray&>(_macroFields.collisionFrequency[solidFaces]);
4089  const TArray& nueC =
4090  dynamic_cast<TArray&>(_macroFields.collisionFrequency[cells]);
4091  const int faceIB= ibFaceIndices[f];
4092  const T uwall = v[c][0];
4093  const T vwall = v[c][1];
4094  const T wwall = v[c][2];
4095  // const T coeff = iCoeffs[nc];
4096  double time_to_wall (0.0);
4097  double distIBSolid (0.0);
4098  // based on distance - will be thought
4099  distIBSolid = sqrt(pow((faceCentroid[faceIB][0]-solidFaceCentroid[c][0]),2)+
4100  pow((faceCentroid[faceIB][1]-solidFaceCentroid[c][1]),2)+
4101  pow((faceCentroid[faceIB][2]-solidFaceCentroid[c][2]),2));
4102  time_to_wall = -1*(pow(distIBSolid,2)/((cx[j]-uwall)*(faceCentroid[faceIB][0]-solidFaceCentroid[c][0])+(cy[j]-vwall)*(faceCentroid[faceIB][1]-solidFaceCentroid[c][1])+(cz[j]-wwall)*(faceCentroid[faceIB][2]-solidFaceCentroid[c][2])));
4103  if(time_to_wall<0)
4104  time_to_wall = 0;
4105  ibVfA[f] += (dsfEqES[c]-(dsfEqES[c]-dsf[c])*exp(-time_to_wall*nue[c]))/(pow(distIBSolid,RelaxDistribution)*distIBSolidInvSum);
4106  }
4107 
4108  }
4109 
4110  fnd.addArray(ibFaces,ibVf);
4111  }
4112  }
4113  }
4114  }
4115  }
const MeshList & _finestMeshes
const Array< int > & getCol() const
virtual void zero()
Definition: Array.h:281
const Array< int > & getRow() const
GeomFields & _geomFields
const StorageSite & getIBFaces() const
Definition: Mesh.h:111
Field coordinate
Definition: GeomFields.h:19
const CRConnectivity & getConnectivity(const StorageSite &from, const StorageSite &to) const
Definition: Mesh.cpp:416
Quadrature< T > & _quadrature
Array< T > TArray
Definition: Field.h:14
const Array< int > & getIBFaceList() const
Definition: Mesh.cpp:686
Definition: Mesh.h:49
COMETModelOptions< T > _options
Field ibType
Definition: GeomFields.h:38
Field viscosity
Definition: MacroFields.h:20
Tangent sqrt(const Tangent &a)
Definition: Tangent.h:317
const CRConnectivity & getAllFaceCells() const
Definition: Mesh.cpp:378
Field temperature
Definition: MacroFields.h:22
Array< VectorT3 > VectorT3Array
GeomFields & _finestGeomFields
map< SSPair, shared_ptr< Matrix > > _interpolationMatrices
Definition: GeomFields.h:50
const StorageSite & getFaces() const
Definition: Mesh.h:108
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
int getCountLevel1() const
Definition: StorageSite.h:72
void addArray(const StorageSite &, shared_ptr< ArrayBase > a)
Definition: Field.cpp:72
DistFunctFields< T > _dsfEqPtrES
Definition: Array.h:14
Field velocity
Definition: MacroFields.h:15
bool isShell() const
Definition: Mesh.h:323
Field finestToCoarse
Definition: GeomFields.h:42
DistFunctFields< T > _dsfPtr
int getCount() const
Definition: StorageSite.h:39
Array< int > IntArray
Field collisionFrequency
Definition: MacroFields.h:24
Field density
Definition: MacroFields.h:21
pair< const StorageSite *, const StorageSite * > SSPair
Definition: GeomFields.h:48
template<class T >
void COMETModel< T >::ComputeMacroparameters ( )
inline

Definition at line 1143 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfPtr, COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_quadrature, MacroFields::density, Mesh::getCells(), StorageSite::getCount(), MacroFields::pressure, MacroFields::Stress, MacroFields::temperature, and MacroFields::velocity.

Referenced by COMETModel< T >::COMETModel(), and COMETModel< T >::MakeIBCoarseModel().

1144  {
1145  //FILE * pFile;
1146  //pFile = fopen("distfun_mf.txt","w");
1147  const int numMeshes = _meshes.size();
1148  for (int n=0; n<numMeshes; n++)
1149  {
1150 
1151  const Mesh& mesh = *_meshes[n];
1152  const StorageSite& cells = mesh.getCells();
1153  const int nCells = cells.getCount(); //
1154 
1155 
1156  TArray& density = dynamic_cast<TArray&>(_macroFields.density[cells]);
1157  TArray& temperature = dynamic_cast<TArray&>(_macroFields.temperature[cells]);
1158  VectorT3Array& v = dynamic_cast<VectorT3Array&>(_macroFields.velocity[cells]);
1159  TArray& pressure = dynamic_cast<TArray&>(_macroFields.pressure[cells]);
1160  const int N123 = _quadrature.getDirCount();
1161 
1162  const TArray& cx = dynamic_cast<const TArray&>(*_quadrature.cxPtr);
1163  const TArray& cy = dynamic_cast<const TArray&>(*_quadrature.cyPtr);
1164  const TArray& cz = dynamic_cast<const TArray&>(*_quadrature.czPtr);
1165  const TArray& wts= dynamic_cast<const TArray&>(*_quadrature.dcxyzPtr);
1166 
1167  VectorT6Array& stress = dynamic_cast<VectorT6Array&>(_macroFields.Stress[cells]);
1168 
1169  //initialize density,velocity,temperature to zero
1170  for(int c=0; c<nCells;c++)
1171  {
1172  density[c]=0.0;
1173  v[c][0]=0.0;
1174  v[c][1]=0.0;
1175  v[c][2]=0.0;
1176  temperature[c]=0.0;
1177  stress[c][0]=0.0;stress[c][1]=0.0;stress[c][2]=0.0;
1178  stress[c][3]=0.0;stress[c][4]=0.0;stress[c][5]=0.0;
1179 
1180  }
1181 
1182 
1183  for(int j=0;j<N123;j++){
1184 
1185  Field& fnd = *_dsfPtr.dsf[j];
1186  const TArray& f = dynamic_cast<const TArray&>(fnd[cells]);
1187 
1188  //fprintf(pFile,"%d %12.6f %E %E %E %E \n",j,dcxyz[j],cx[j],cy[j],f[80],density[80]+dcxyz[j]*f[80]);
1189 
1190  for(int c=0; c<nCells;c++){
1191  density[c] = density[c]+wts[j]*f[c];
1192  v[c][0]= v[c][0]+(cx[j]*f[c])*wts[j];
1193  v[c][1]= v[c][1]+(cy[j]*f[c])*wts[j];
1194  v[c][2]= v[c][2]+(cz[j]*f[c])*wts[j];
1195  temperature[c]= temperature[c]+(pow(cx[j],2.0)+pow(cy[j],2.0)
1196  +pow(cz[j],2.0))*f[c]*wts[j];
1197 
1198  }
1199 
1200  }
1201 
1202 
1203 
1204  for(int c=0; c<nCells;c++){
1205  v[c][0]=v[c][0]/density[c];
1206  v[c][1]=v[c][1]/density[c];
1207  v[c][2]=v[c][2]/density[c];
1208  temperature[c]=temperature[c]-(pow(v[c][0],2.0)
1209  +pow(v[c][1],2.0)
1210  +pow(v[c][2],2.0))*density[c];
1211  temperature[c]=temperature[c]/(1.5*density[c]);
1212  pressure[c]=density[c]*temperature[c];
1213  }
1214 
1215  //Find Pxx,Pyy,Pzz,Pxy,Pyz,Pzx, etc in field
1216 
1217  for(int j=0;j<N123;j++){
1218  Field& fnd = *_dsfPtr.dsf[j];
1219  const TArray& f = dynamic_cast<const TArray&>(fnd[cells]);
1220  for(int c=0; c<nCells;c++){
1221  stress[c][0] +=pow((cx[j]-v[c][0]),2.0)*f[c]*wts[j];
1222  stress[c][1] +=pow((cy[j]-v[c][1]),2.0)*f[c]*wts[j];
1223  stress[c][2] +=pow((cz[j]-v[c][2]),2.0)*f[c]*wts[j];
1224  stress[c][3] +=(cx[j]-v[c][0])*(cy[j]-v[c][1])*f[c]*wts[j];
1225  stress[c][4] +=(cy[j]-v[c][1])*(cz[j]-v[c][2])*f[c]*wts[j];
1226  stress[c][5] +=(cz[j]-v[c][2])*(cx[j]-v[c][0])*f[c]*wts[j];
1227 
1228  }}
1229 
1230 
1231  }// end of loop over nmeshes
1232  //fclose(pFile);
1233  }
Quadrature< T > & _quadrature
Array< T > TArray
Definition: Field.h:14
Field Stress
Definition: MacroFields.h:37
Definition: Mesh.h:49
Field temperature
Definition: MacroFields.h:22
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
Array< VectorT6 > VectorT6Array
Field velocity
Definition: MacroFields.h:15
Field pressure
Definition: MacroFields.h:19
DistFunctFields< T > _dsfPtr
int getCount() const
Definition: StorageSite.h:39
Field density
Definition: MacroFields.h:21
template<class T >
void COMETModel< T >::ComputeMacroparametersESBGK ( )
inline

Definition at line 1406 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfEqPtr, COMETModel< T >::_dsfPtr, COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_options, COMETModel< T >::_quadrature, MacroFields::density, Mesh::getCells(), StorageSite::getCount(), MacroFields::Txx, MacroFields::Txy, MacroFields::Tyy, MacroFields::Tyz, MacroFields::Tzx, MacroFields::Tzz, and MacroFields::velocity.

Referenced by COMETModel< T >::EquilibriumDistributionESBGK().

1407  {
1408 
1409  const int numMeshes = _meshes.size();
1410  for (int n=0; n<numMeshes; n++)
1411  {
1412  const Mesh& mesh = *_meshes[n];
1413  const StorageSite& cells = mesh.getCells();
1414  const int nCells = cells.getCount();
1415 
1416  const TArray& density = dynamic_cast<const TArray&>(_macroFields.density[cells]);
1417  const VectorT3Array& v = dynamic_cast<const VectorT3Array&>(_macroFields.velocity[cells]);
1418 
1419  TArray& Txx = dynamic_cast<TArray&>(_macroFields.Txx[cells]);
1420  TArray& Tyy = dynamic_cast<TArray&>(_macroFields.Tyy[cells]);
1421  TArray& Tzz = dynamic_cast<TArray&>(_macroFields.Tzz[cells]);
1422  TArray& Txy = dynamic_cast<TArray&>(_macroFields.Txy[cells]);
1423  TArray& Tyz = dynamic_cast<TArray&>(_macroFields.Tyz[cells]);
1424  TArray& Tzx = dynamic_cast<TArray&>(_macroFields.Tzx[cells]);
1425 
1426  const int N123 = _quadrature.getDirCount();
1427 
1428  const TArray& cx = dynamic_cast<const TArray&>(*_quadrature.cxPtr);
1429  const TArray& cy = dynamic_cast<const TArray&>(*_quadrature.cyPtr);
1430  const TArray& cz = dynamic_cast<const TArray&>(*_quadrature.czPtr);
1431  const TArray& wts= dynamic_cast<const TArray&>(*_quadrature.dcxyzPtr);
1432 
1433  const double Pr=_options.Prandtl;
1434  //cout <<"Prandlt" <<Pr<<endl;
1435 
1436  //initialize density,velocity,temperature to zero
1437  for(int c=0; c<nCells;c++)
1438  {
1439  Txx[c]=0.0;
1440  Tyy[c]=0.0;
1441  Tzz[c]=0.0;
1442  Txy[c]=0.0;
1443  Tyz[c]=0.0;
1444  Tzx[c]=0.0;
1445  }
1446  for(int j=0;j<N123;j++){
1447 
1448  Field& fnd = *_dsfPtr.dsf[j];
1449  const TArray& f = dynamic_cast<const TArray&>(fnd[cells]);
1450  Field& fndEq = *_dsfEqPtr.dsf[j];
1451  const TArray& fgam = dynamic_cast<const TArray&>(fndEq[cells]);
1452  for(int c=0; c<nCells;c++){
1453  Txx[c]=Txx[c]+pow(cx[j]-v[c][0],2)*((1-1/Pr)*f[c]+1/Pr*fgam[c])*wts[j];
1454  Tyy[c]=Tyy[c]+pow(cy[j]-v[c][1],2)*((1-1/Pr)*f[c]+1/Pr*fgam[c])*wts[j] ;
1455  Tzz[c]=Tzz[c]+pow(cz[j]-v[c][2],2)*((1-1/Pr)*f[c]+1/Pr*fgam[c])*wts[j];
1456  //Txy[c]=Txy[c]+(cx[j])*(cy[j])*((1-1/Pr)*f[c]+1/Pr*fgam[c])*wts[j];
1457  //Tyz[c]=Tyz[c]+(cy[j])*(cz[j])*((1-1/Pr)*f[c]+1/Pr*fgam[c])*wts[j]; //Tzx[c]=Tzx[c]+(cz[j])*(cx[j])*((1-1/Pr)*f[c]+1/Pr*fgam[c])*wts[j];
1458 
1459 
1460  Txy[c]=Txy[c]+(cx[j]-v[c][0])*(cy[j]-v[c][1])*((1-1/Pr)*f[c]+1/Pr*fgam[c])*wts[j];
1461  Tyz[c]=Tyz[c]+(cy[j]-v[c][1])*(cz[j]-v[c][2])*((1-1/Pr)*f[c]+1/Pr*fgam[c])*wts[j];
1462  Tzx[c]=Tzx[c]+(cz[j]-v[c][2])*(cx[j]-v[c][0])*((1-1/Pr)*f[c]+1/Pr*fgam[c])*wts[j];
1463  }
1464  }
1465 
1466  for(int c=0; c<nCells;c++){
1467  Txx[c]=Txx[c]/density[c];
1468  Tyy[c]=Tyy[c]/density[c];
1469  Tzz[c]=Tzz[c]/density[c];
1470  Txy[c]=Txy[c]/density[c];
1471  Tyz[c]=Tyz[c]/density[c];
1472  Tzx[c]=Tzx[c]/density[c];
1473  }
1474 
1475  }
1476  }
Quadrature< T > & _quadrature
Array< T > TArray
Definition: Field.h:14
Definition: Mesh.h:49
COMETModelOptions< T > _options
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
Field velocity
Definition: MacroFields.h:15
DistFunctFields< T > _dsfPtr
int getCount() const
Definition: StorageSite.h:39
DistFunctFields< T > _dsfEqPtr
Field density
Definition: MacroFields.h:21
template<class T >
void COMETModel< T >::computeSolidFaceDsf ( const StorageSite solidFaces,
const int  method,
const int  RelaxDistribution = 0 
)
inline

Definition at line 4154 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfEqPtrES, COMETModel< T >::_dsfPtr, COMETModel< T >::_finestGeomFields, COMETModel< T >::_finestMeshes, COMETModel< T >::_geomFields, GeomFields::_interpolationMatrices, COMETModel< T >::_level, COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_options, COMETModel< T >::_quadrature, Field::addArray(), MacroFields::collisionFrequency, GeomFields::coordinate, MacroFields::density, GeomFields::finestToCoarse, Mesh::getCells(), CRConnectivity::getCol(), Mesh::getConnectivity(), StorageSite::getCount(), StorageSite::getCountLevel1(), Mesh::getFaces(), Mesh::getIBFaceList(), Mesh::getIBFaces(), CRConnectivity::getRow(), Mesh::isShell(), sqrt(), MacroFields::temperature, MacroFields::velocity, MacroFields::viscosity, and Array< T >::zero().

Referenced by COMETModel< T >::cycle(), and COMETModel< T >::smooth().

4155  {
4156  typedef CRMatrixTranspose<T,T,T> IMatrix;
4157  typedef CRMatrixTranspose<T,VectorT3,VectorT3> IMatrixV3;
4158  const int numFields= _quadrature.getDirCount();
4159  if (method==1){
4160  const int numMeshes = _meshes.size();
4161  for (int direction = 0; direction < numFields; direction++) {
4162  Field& fnd = *_dsfPtr.dsf[direction];
4163  shared_ptr<TArray> ibV(new TArray(solidFaces.getCount()));
4164  ibV->zero();
4165  for (int n=0; n<numMeshes; n++)
4166  {
4167  const Mesh& mesh = *_meshes[n];
4168  const Mesh& fMesh = *_finestMeshes[n];
4169  if (!mesh.isShell() && mesh.getIBFaces().getCount() > 0){
4170 
4171  const StorageSite& cells = mesh.getCells();
4172  const StorageSite& fCells = fMesh.getCells();
4173 
4174  GeomFields::SSPair key1(&solidFaces,&fCells);
4175  const IMatrix& mIC =
4176  dynamic_cast<const IMatrix&>
4178 
4179  IMatrix mICV(mIC);
4180 
4181  Field& FinestToCoarseField=_finestGeomFields.finestToCoarse;
4182  const Array<Vector<int,25> >& FinestToCoarse=dynamic_cast<const Array<Vector<int,25> >&>(FinestToCoarseField[fCells]);
4183 
4184  const TArray& cV =
4185  dynamic_cast<const TArray&>(fnd[cells]);
4186  TArray cFV(fCells.getCountLevel1());
4187  for(int c=0;c<fCells.getCountLevel1();c++)
4188  cFV[c]=cV[FinestToCoarse[c][_level]];
4189 
4190  ibV->zero();
4191 
4192  mICV.multiplyAndAdd(*ibV,cFV);
4193 #if 0
4194  ofstream debugFile;
4195  stringstream ss(stringstream::in | stringstream::out);
4196  ss << MPI::COMM_WORLD.Get_rank();
4197  string fname1 = "IBVelocity_proc" + ss.str() + ".dat";
4198  debugFile.open(fname1.c_str());
4199 
4200  //debug use
4201  const Array<int>& ibFaceList = mesh.getIBFaceList();
4202  const StorageSite& faces = mesh.getFaces();
4203  const VectorT3Array& faceCentroid =
4204  dynamic_cast<const VectorT3Array&> (_geomFields.coordinate[faces]);
4205  const double angV = 1.0;
4206  VectorT3 center;
4207  center[0]=0.;
4208  center[1]=0.;
4209  center[2]=0.;
4210 
4211  for(int f=0; f<ibFaces.getCount();f++){
4212  int fID = ibFaceList[f];
4213  debugFile << "f=" << f << setw(10) << " fID = " << fID << " faceCentroid = " << faceCentroid[fID] << " ibV = " << (*ibV)[f] << endl;
4214  }
4215 
4216  debugFile.close();
4217 #endif
4218 
4219  }
4220 
4221  }
4222  fnd.addArray(solidFaces,ibV);
4223  }
4224  }
4225  if (method==2){
4226 
4227  // Step0: Compute Interpolation Matrices from (only) Cells to IBFaces
4228  const int numMeshes = _meshes.size();
4229  for (int n=0; n<numMeshes; n++)
4230  {
4231  const Mesh& mesh = *_meshes[n];
4232  const Mesh& fMesh = *_finestMeshes[n];
4233 
4234  const int numFields= _quadrature.getDirCount();
4235  for (int direction = 0; direction < numFields; direction++)
4236  {
4237  Field& fnd = *_dsfPtr.dsf[direction];
4238  Field& fndEqES = *_dsfEqPtrES.dsf[direction];
4239  const Mesh& mesh = *_meshes[n];
4240  if (!mesh.isShell() && mesh.getIBFaces().getCount() > 0){
4241 
4242  const StorageSite& cells = mesh.getCells();
4243  const StorageSite& fCells = fMesh.getCells();
4244  const StorageSite& faces = mesh.getFaces();
4245  const StorageSite& fFaces = fMesh.getFaces();
4246  const StorageSite& ibFaces = mesh.getIBFaces();
4247  const StorageSite& fIbFaces = fMesh.getIBFaces();
4248 
4249  //GeomFields::SSPair key1(&faces,&cells);
4250  GeomFields::SSPair key1(&fFaces,&fCells);
4251  //GeomFields::SSPair key1(&fIbFaces,&fCells);
4252  const IMatrix& mIC =
4253  dynamic_cast<const IMatrix&>
4255 
4256  IMatrix mICV(mIC);
4257 
4258  const TArray& cf =
4259  dynamic_cast<const TArray&>(fnd[cells]);
4260  const TArray& cfEq =
4261  dynamic_cast<const TArray&>(fndEqES[cells]);
4262 
4263  Field& FinestToCoarseField=_finestGeomFields.finestToCoarse;
4264  const Array<Vector<int,25> >& FinestToCoarse=dynamic_cast<const Array<Vector<int,25> >&>(FinestToCoarseField[fCells]);
4265 
4266  TArray cFf(fCells.getCount());
4267  TArray cFfEq(fCells.getCount());
4268 
4269  for(int c=0;c<fCells.getCount();c++)
4270  {
4271  cFf[c]=cf[FinestToCoarse[c][_level]];
4272  cFfEq[c]=cfEq[FinestToCoarse[c][_level]];
4273  }
4274 
4275  shared_ptr<TArray> ibVf(new TArray(ibFaces.getCount()));
4276  ibVf->zero();
4277  if (_options.fgamma==2){
4278  shared_ptr<TArray> ibVfEq(new TArray(ibFaces.getCount()));
4279  ibVfEq->zero();
4280  mICV.multiplyAndAdd(*ibVfEq,cFfEq);
4281  fndEqES.addArray(ibFaces,ibVfEq);
4282  }
4283  mICV.multiplyAndAdd(*ibVf,cFf);
4284  fnd.addArray(ibFaces,ibVf);
4285 
4286  }
4287  }
4288  }
4289  const int nSolidFaces = solidFaces.getCount();
4290 
4291  shared_ptr<TArray> muSolid(new TArray(nSolidFaces));
4292  *muSolid =0;
4293  _macroFields.viscosity.addArray(solidFaces,muSolid);
4294 
4295  shared_ptr<TArray> nueSolid(new TArray(nSolidFaces));
4296  *nueSolid =0;
4297  _macroFields.collisionFrequency.addArray(solidFaces,nueSolid);
4298 
4299  const T rho_init=_options["rho_init"];
4300  const T T_init= _options["T_init"];
4301  const T mu_w= _options["mu_w"];
4302  const T Tmuref= _options["Tmuref"];
4303  const T muref= _options["muref"];
4304  const T R=8314.0/_options["molecularWeight"];
4305  const T nondim_length=_options["nonDimLt"];
4306 
4307  const T mu0=rho_init*R* T_init*nondim_length/pow(2*R* T_init,0.5);
4308 
4309  TArray& density = dynamic_cast<TArray&>(_macroFields.density[solidFaces]);
4310  TArray& viscosity = dynamic_cast<TArray&>(_macroFields.viscosity[solidFaces]);
4311  TArray& temperature = dynamic_cast<TArray&>(_macroFields.temperature[solidFaces]);
4312  TArray& collisionFrequency = dynamic_cast<TArray&>(_macroFields.collisionFrequency[solidFaces]);
4313 
4314  for(int c=0; c<nSolidFaces;c++)
4315  {
4316  viscosity[c]= muref*pow(temperature[c]*T_init/ Tmuref,mu_w); // viscosity power law
4317  collisionFrequency[c]=density[c]*temperature[c]/viscosity[c]*mu0;
4318  }
4319 
4320  if(_options.fgamma==2){
4321  for(int c=0; c<nSolidFaces;c++)
4322  collisionFrequency[c]=_options.Prandtl*collisionFrequency[c];
4323  }
4324 
4325  //Step 1 Interpolate Macroparameters and f to IBface
4326  for (int n=0; n<numMeshes; n++)
4327  {
4328  const Mesh& mesh = *_meshes[n];
4329  const Mesh& fMesh = *_finestMeshes[n];
4330  if (!mesh.isShell() && mesh.getIBFaces().getCount() > 0){
4331 
4332  const StorageSite& cells = mesh.getCells();
4333  const StorageSite& fCells = fMesh.getCells();
4334  const StorageSite& ibFaces = mesh.getIBFaces();
4335  const StorageSite& fIbFaces = fMesh.getIBFaces();
4336 
4337  GeomFields::SSPair key1(&fIbFaces,&fCells);
4338  const IMatrix& mIC =
4339  dynamic_cast<const IMatrix&>
4341 
4342  IMatrix mICV(mIC);
4343  IMatrixV3 mICV3(mIC);
4344 
4345  GeomFields::SSPair key2(&fIbFaces,&solidFaces);
4346  const IMatrix& mIP =
4347  dynamic_cast<const IMatrix&>
4349 
4350  IMatrix mIPV(mIP);
4351  IMatrixV3 mIPV3(mIP);
4352 
4353  shared_ptr<TArray> ibVtemp(new TArray(ibFaces.getCount()));
4354  shared_ptr<TArray> ibVnue(new TArray(ibFaces.getCount()));
4355  shared_ptr<TArray> ibVdensity(new TArray(ibFaces.getCount()));
4356  shared_ptr<VectorT3Array> ibVvel(new VectorT3Array(ibFaces.getCount()));
4357 
4358  const TArray& cTemp =
4359  dynamic_cast<TArray&>(_macroFields.temperature[cells]);
4360  const VectorT3Array& cVel =
4361  dynamic_cast<VectorT3Array&>(_macroFields.velocity[cells]);
4362  const TArray& cDensity =
4363  dynamic_cast<TArray&>(_macroFields.density[cells]);
4364  const TArray& sDensity =
4365  dynamic_cast<TArray&>(_macroFields.density[solidFaces]);
4366  const TArray& cNue =
4367  dynamic_cast<TArray&>(_macroFields.collisionFrequency[cells]);
4368  const TArray& sNue =
4369  dynamic_cast<TArray&>(_macroFields.collisionFrequency[solidFaces]);
4370  const TArray& sTemp =
4371  dynamic_cast<TArray&>(_macroFields.temperature[solidFaces]);
4372  const VectorT3Array& sVel =
4373  dynamic_cast<VectorT3Array&>(_macroFields.velocity[solidFaces]);
4374 
4375  ibVnue->zero();
4376  ibVtemp->zero();
4377  ibVvel->zero();
4378  ibVdensity->zero();
4379 
4380 
4381  Field& FinestToCoarseField=_finestGeomFields.finestToCoarse;
4382  const Array<Vector<int,25> >& FinestToCoarse=dynamic_cast<const Array<Vector<int,25> >&>(FinestToCoarseField[fCells]);
4383 
4384  TArray cFTemp(fCells.getCount());
4385  VectorT3Array cFVel(fCells.getCount());
4386  TArray cFDensity(fCells.getCount());
4387  TArray cFNue(fCells.getCount());
4388 
4389  for(int c=0;c<fCells.getCount();c++)
4390  {
4391  cFTemp[c]=cTemp[FinestToCoarse[c][_level]];
4392  cFVel[c]=cVel[FinestToCoarse[c][_level]];
4393  cFDensity[c]=cDensity[FinestToCoarse[c][_level]];
4394  cFNue[c]=cNue[FinestToCoarse[c][_level]];
4395  }
4396 
4397  //nue interpolation (cells)
4398  mICV.multiplyAndAdd(*ibVnue,cFNue);
4399  mIPV.multiplyAndAdd(*ibVnue,sNue);
4400  _macroFields.collisionFrequency.addArray(ibFaces,ibVnue);
4401  //temperature interpolation (cells+solidfaces)
4402  mICV.multiplyAndAdd(*ibVtemp,cFTemp);
4403  mIPV.multiplyAndAdd(*ibVtemp,sTemp);
4404  _macroFields.temperature.addArray(ibFaces,ibVtemp);
4405  //density interpolation (cells+solidfaces)
4406  mICV.multiplyAndAdd(*ibVdensity,cFDensity);
4407  mIPV.multiplyAndAdd(*ibVdensity,sDensity);
4408  _macroFields.density.addArray(ibFaces,ibVdensity);
4409  //velocity interpolation (cells+solidfaces)
4410  mICV3.multiplyAndAdd(*ibVvel,cFVel);
4411  mIPV3.multiplyAndAdd(*ibVvel,sVel);
4412  _macroFields.velocity.addArray(ibFaces,ibVvel);
4413 
4414 
4415  }
4416  }
4417  if (_options.fgamma==1){
4418  //Step 2 Find fgamma using macroparameters
4419  const int numMeshes = _meshes.size();
4420  for (int n=0; n<numMeshes; n++)
4421  {
4422  const Mesh& mesh = *_meshes[n];
4423  if (!mesh.isShell() && mesh.getIBFaces().getCount() > 0){
4424  const int numDirections = _quadrature.getDirCount();
4425  const StorageSite& ibFaces = mesh.getIBFaces();
4426  const int nibFaces=ibFaces.getCount();
4427  const double pi=_options.pi;
4428  const TArray& ibTemp =
4429  dynamic_cast<TArray&>(_macroFields.temperature[ibFaces]);
4430  const VectorT3Array& ibVel =
4431  dynamic_cast<VectorT3Array&>(_macroFields.velocity[ibFaces]);
4432  const TArray& ibDensity =
4433  dynamic_cast<TArray&>(_macroFields.density[ibFaces]);
4434 
4435  for (int j=0; j<numDirections; j++)
4436  {
4437  shared_ptr<TArray> ibFndPtrEqES(new TArray(nibFaces));
4438  TArray& ibFndEqES= *ibFndPtrEqES;
4439 
4440  ibFndPtrEqES->zero();
4441 
4442  Field& fndEqES = *_dsfEqPtrES.dsf[j];
4443 
4444  for (int i=0; i<nibFaces; i++)
4445  {
4446  const TArray& cx = dynamic_cast<const TArray&>(*_quadrature.cxPtr);
4447  const TArray& cy = dynamic_cast<const TArray&>(*_quadrature.cyPtr);
4448  const TArray& cz = dynamic_cast<const TArray&>(*_quadrature.czPtr);
4449  const T ibu = ibVel[i][0];
4450  const T ibv = ibVel[i][1];
4451  const T ibw = ibVel[i][2];
4452  ibFndEqES[i]=ibDensity[i]/pow(pi*ibTemp[i],1.5)*exp(-(pow(cx[j]-ibu,2.0)+pow(cy[j]-ibv,2.0)+pow(cz[j]-ibw,2.0))/ibTemp[i]);
4453  }
4454  fndEqES.addArray(ibFaces,ibFndPtrEqES);
4455  }
4456  }
4457  }
4458  }
4459 
4460  //Step3: Relax Distribution function from ibfaces to solid face
4461  const int numDirections = _quadrature.getDirCount();
4462  for (int j=0; j<numDirections; j++)
4463  {
4464  const int nSolidFaces = solidFaces.getCount();
4465  shared_ptr<TArray> solidFndPtr(new TArray(nSolidFaces));
4466  solidFndPtr->zero();
4467  TArray& solidFnd= *solidFndPtr;
4468  Field& fnd = *_dsfPtr.dsf[j];
4469  Field& fndEqES = *_dsfEqPtrES.dsf[j];
4470  const TArray& cx = dynamic_cast<const TArray&>(*_quadrature.cxPtr);
4471  const TArray& cy = dynamic_cast<const TArray&>(*_quadrature.cyPtr);
4472  const TArray& cz = dynamic_cast<const TArray&>(*_quadrature.czPtr);
4473  for (int n=0; n<numMeshes; n++)
4474  {
4475  const Mesh& mesh = *_meshes[n];
4476  const Mesh& fMesh = *_finestMeshes[n];
4477  if (!mesh.isShell() && mesh.getIBFaces().getCount() > 0){
4478  const StorageSite& ibFaces = mesh.getIBFaces();
4479  const StorageSite& fIbFaces = fMesh.getIBFaces();
4480  const CRConnectivity& solidFacesToibFaces
4481  = fMesh.getConnectivity(solidFaces,fIbFaces);
4482  const IntArray& ibFaceIndices = fMesh.getIBFaceList();
4483  const IntArray& sFCRow = solidFacesToibFaces.getRow();
4484  const IntArray& sFCCol = solidFacesToibFaces.getCol();
4485  TArray& dsf = dynamic_cast< TArray&>(fnd[ibFaces]);
4486  TArray& dsfEqES = dynamic_cast< TArray&>(fndEqES[ibFaces]);
4487  VectorT3Array& v = dynamic_cast<VectorT3Array&>(_macroFields.velocity[solidFaces]);
4488 
4489  for(int f=0; f<nSolidFaces; f++)
4490  {
4491  double distIBSolidInvSum(0.0);
4492  for(int nc = sFCRow[f]; nc<sFCRow[f+1]; nc++)
4493  {
4494  const StorageSite& faces = fMesh.getFaces();
4495  const int c = sFCCol[nc];
4496  const int faceIB= ibFaceIndices[c];
4497  const VectorT3Array& solidFaceCentroid =
4498  dynamic_cast<const VectorT3Array&> (_finestGeomFields.coordinate[solidFaces]);
4499  const VectorT3Array& faceCentroid =
4500  dynamic_cast<const VectorT3Array&> (_finestGeomFields.coordinate[faces]);
4501 
4502  double distIBSolid (0.0);
4503  // based on distance - will be thought
4504  distIBSolid = sqrt(pow((faceCentroid[faceIB][0]-solidFaceCentroid[f][0]),2)+
4505  pow((faceCentroid[faceIB][1]-solidFaceCentroid[f][1]),2)+
4506  pow((faceCentroid[faceIB][2]-solidFaceCentroid[f][2]),2));
4507  distIBSolidInvSum += 1/pow(distIBSolid,RelaxDistribution);
4508  }
4509  for(int nc = sFCRow[f]; nc<sFCRow[f+1]; nc++)
4510  {
4511  const int c = sFCCol[nc];
4512  const StorageSite& faces = fMesh.getFaces();
4513  const VectorT3Array& solidFaceCentroid =
4514  dynamic_cast<const VectorT3Array&> (_finestGeomFields.coordinate[solidFaces]);
4515  const VectorT3Array& faceCentroid =
4516  dynamic_cast<const VectorT3Array&> (_finestGeomFields.coordinate[faces]);
4517  const int faceIB= ibFaceIndices[c];
4518  T time_to_wall (0.0);
4519  T distIBSolid (0.0);
4520  distIBSolid = sqrt(pow((faceCentroid[faceIB][0]-solidFaceCentroid[f][0]),2)+
4521  pow((faceCentroid[faceIB][1]-solidFaceCentroid[f][1]),2)+
4522  pow((faceCentroid[faceIB][2]-solidFaceCentroid[f][2]),2));
4523  // based on distance - will be thought
4524  const T uwall = v[f][0];
4525  const T vwall = v[f][1];
4526  const T wwall = v[f][2];
4527  const TArray& nue =
4528  dynamic_cast<TArray&>(_macroFields.collisionFrequency[ibFaces]);
4529  time_to_wall = (pow(distIBSolid,2)/((cx[j]-uwall)*(faceCentroid[faceIB][0]-solidFaceCentroid[f][0])+(cy[j]-vwall)*(faceCentroid[faceIB][1]-solidFaceCentroid[f][1])+(cz[j]-wwall)*(faceCentroid[faceIB][2]-solidFaceCentroid[f][2])));
4530  if(time_to_wall<0)
4531  time_to_wall = 0;
4532 
4533  solidFnd[f] += (dsfEqES[c]-(dsfEqES[c]-dsf[c])*exp(-time_to_wall*nue[c]))/(pow(distIBSolid,RelaxDistribution)*distIBSolidInvSum);
4534  }
4535 
4536  }
4537  }
4538  }
4539  fnd.addArray(solidFaces,solidFndPtr);
4540  }
4541  }
4542  if (method==3){
4543  const int numDirections = _quadrature.getDirCount();
4544  for (int j=0; j<numDirections; j++)
4545  {
4546  const int nSolidFaces = solidFaces.getCount();
4547  shared_ptr<TArray> solidFndPtr(new TArray(nSolidFaces));
4548  solidFndPtr->zero();
4549  TArray& solidFnd= *solidFndPtr;
4550  Field& fnd = *_dsfPtr.dsf[j];
4551  Field& fndEqES = *_dsfEqPtrES.dsf[j];
4552  const TArray& cx = dynamic_cast<const TArray&>(*_quadrature.cxPtr);
4553  const TArray& cy = dynamic_cast<const TArray&>(*_quadrature.cyPtr);
4554  const TArray& cz = dynamic_cast<const TArray&>(*_quadrature.czPtr);
4555  const int numMeshes = _meshes.size();
4556  for (int n=0; n<numMeshes; n++)
4557  {
4558  const Mesh& mesh = *_meshes[n];
4559  if (!mesh.isShell() && mesh.getIBFaces().getCount() > 0){
4560  const StorageSite& cells = mesh.getCells();
4561  const StorageSite& ibFaces = mesh.getIBFaces();
4562  const CRConnectivity& solidFacesToCells
4563  = mesh.getConnectivity(solidFaces,cells);
4564  const IntArray& sFCRow = solidFacesToCells.getRow();
4565  const IntArray& sFCCol = solidFacesToCells.getCol();
4566  TArray& dsf = dynamic_cast< TArray&>(fnd[cells]);
4567  TArray& dsfEqES = dynamic_cast< TArray&>(fndEqES[cells]);
4568  VectorT3Array& v = dynamic_cast<VectorT3Array&>(_macroFields.velocity[solidFaces]);
4569 
4570  for(int f=0; f<nSolidFaces; f++)
4571  {
4572  double distIBSolidInvSum(0.0);
4573  for(int nc = sFCRow[f]; nc<sFCRow[f+1]; nc++)
4574  {
4575  const StorageSite& faces = mesh.getFaces();
4576  const int c = sFCCol[nc];
4577  const VectorT3Array& solidFaceCentroid =
4578  dynamic_cast<const VectorT3Array&> (_geomFields.coordinate[solidFaces]);
4579  const VectorT3Array& faceCentroid =
4580  dynamic_cast<const VectorT3Array&> (_geomFields.coordinate[cells]);
4581 
4582  double distIBSolid (0.0);
4583  // based on distance - will be thought
4584  distIBSolid = sqrt(pow((faceCentroid[c][0]-solidFaceCentroid[f][0]),2)+
4585  pow((faceCentroid[c][1]-solidFaceCentroid[f][1]),2)+
4586  pow((faceCentroid[c][2]-solidFaceCentroid[f][2]),2));
4587  distIBSolidInvSum += 1/pow(distIBSolid,RelaxDistribution);
4588  }
4589  for(int nc = sFCRow[f]; nc<sFCRow[f+1]; nc++)
4590  {
4591  const int c = sFCCol[nc];
4592  const StorageSite& faces = mesh.getFaces();
4593  const VectorT3Array& solidFaceCentroid =
4594  dynamic_cast<const VectorT3Array&> (_geomFields.coordinate[solidFaces]);
4595  const VectorT3Array& faceCentroid =
4596  dynamic_cast<const VectorT3Array&> (_geomFields.coordinate[cells]);
4597  T time_to_wall (0.0);
4598  T distIBSolid (0.0);
4599  const T uwall = v[f][0];
4600  const T vwall = v[f][1];
4601  const T wwall = v[f][2];
4602  distIBSolid = sqrt(pow((faceCentroid[c][0]-solidFaceCentroid[f][0]),2)+
4603  pow((faceCentroid[c][1]-solidFaceCentroid[f][1]),2)+
4604  pow((faceCentroid[c][2]-solidFaceCentroid[f][2]),2));
4605  // based on distance - will be thought
4606 
4607  const TArray& nue =
4608  dynamic_cast<TArray&>(_macroFields.collisionFrequency[cells]);
4609  time_to_wall = (pow(distIBSolid,2)/((cx[j]-uwall)*(faceCentroid[c][0]-solidFaceCentroid[f][0])+(cy[j]-vwall)*(faceCentroid[c][1]-solidFaceCentroid[f][1])+(cz[j]-wwall)*(faceCentroid[c][2]-solidFaceCentroid[f][2])));
4610  if(time_to_wall<0)
4611  time_to_wall = 0;
4612 
4613  solidFnd[f] += (dsfEqES[c]-(dsfEqES[c]-dsf[c])*exp(-time_to_wall*nue[c]))/(pow(distIBSolid,RelaxDistribution)*distIBSolidInvSum);
4614  }
4615 
4616  }
4617  }
4618  }
4619  fnd.addArray(solidFaces,solidFndPtr);
4620 
4621  }
4622  }
4623  }
const MeshList & _finestMeshes
const Array< int > & getCol() const
virtual void zero()
Definition: Array.h:281
const Array< int > & getRow() const
GeomFields & _geomFields
const StorageSite & getIBFaces() const
Definition: Mesh.h:111
Field coordinate
Definition: GeomFields.h:19
const CRConnectivity & getConnectivity(const StorageSite &from, const StorageSite &to) const
Definition: Mesh.cpp:416
Quadrature< T > & _quadrature
Array< T > TArray
Definition: Field.h:14
const Array< int > & getIBFaceList() const
Definition: Mesh.cpp:686
Definition: Mesh.h:49
COMETModelOptions< T > _options
Field viscosity
Definition: MacroFields.h:20
Tangent sqrt(const Tangent &a)
Definition: Tangent.h:317
Field temperature
Definition: MacroFields.h:22
Array< VectorT3 > VectorT3Array
GeomFields & _finestGeomFields
map< SSPair, shared_ptr< Matrix > > _interpolationMatrices
Definition: GeomFields.h:50
const StorageSite & getFaces() const
Definition: Mesh.h:108
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
int getCountLevel1() const
Definition: StorageSite.h:72
void addArray(const StorageSite &, shared_ptr< ArrayBase > a)
Definition: Field.cpp:72
DistFunctFields< T > _dsfEqPtrES
Definition: Array.h:14
Field velocity
Definition: MacroFields.h:15
bool isShell() const
Definition: Mesh.h:323
Field finestToCoarse
Definition: GeomFields.h:42
DistFunctFields< T > _dsfPtr
int getCount() const
Definition: StorageSite.h:39
Array< int > IntArray
Field collisionFrequency
Definition: MacroFields.h:24
Field density
Definition: MacroFields.h:21
pair< const StorageSite *, const StorageSite * > SSPair
Definition: GeomFields.h:48
template<class T >
void COMETModel< T >::computeSolidFacePressure ( const StorageSite solidFaces)
inline

Definition at line 4117 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_geomFields, GeomFields::_interpolationMatrices, COMETModel< T >::_macroFields, Model::_meshes, Field::addArray(), Mesh::getCells(), StorageSite::getCount(), Array< T >::getData(), Mesh::getIBFaces(), Mesh::isShell(), MacroFields::pressure, and Array< T >::zero().

4118  {
4119  typedef CRMatrixTranspose<T,T,T> IMatrix;
4120  const int numMeshes = _meshes.size();
4121  for (int n=0; n<numMeshes; n++)
4122  {
4123  shared_ptr<TArray> ibP(new TArray(solidFaces.getCount()));
4124  ibP->zero();
4125  const Mesh& mesh = *_meshes[n];
4126  if (!mesh.isShell() && mesh.getIBFaces().getCount() > 0){
4127 
4128  const StorageSite& cells = mesh.getCells();
4129 
4130  GeomFields::SSPair key1(&solidFaces,&cells);
4131  const IMatrix& mIC =
4132  dynamic_cast<const IMatrix&>
4134 
4135  IMatrix mICV(mIC);
4136 
4137  const TArray& cP =
4138  dynamic_cast<TArray&>(_macroFields.pressure[cells]);
4139 
4140  ibP->zero();
4141 
4142 
4143  //nue interpolation (cells)
4144  mICV.multiplyAndAdd(*ibP,cP);
4145  }
4146  _macroFields.pressure.addArray(solidFaces,ibP);
4147  }
4148 #ifdef FVM_PARALLEL
4149  TArray& pressure = dynamic_cast<TArray&>(_macroFields.pressure[solidFaces]);
4150  MPI::COMM_WORLD.Allreduce( MPI::IN_PLACE,pressure.getData(),solidFaces.getCount() , MPI::DOUBLE, MPI::SUM);
4151 #endif
4152  }
GeomFields & _geomFields
const StorageSite & getIBFaces() const
Definition: Mesh.h:111
Array< T > TArray
Definition: Mesh.h:49
map< SSPair, shared_ptr< Matrix > > _interpolationMatrices
Definition: GeomFields.h:50
MacroFields & _macroFields
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
Field pressure
Definition: MacroFields.h:19
bool isShell() const
Definition: Mesh.h:323
int getCount() const
Definition: StorageSite.h:39
pair< const StorageSite *, const StorageSite * > SSPair
Definition: GeomFields.h:48
template<class T >
void COMETModel< T >::computeSurfaceForce ( const StorageSite solidFaces,
bool  perUnitArea,
bool  IBM = 0 
)
inline

Definition at line 5481 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfPtr, COMETModel< T >::_geomFields, GeomFields::_interpolationMatrices, COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_options, COMETModel< T >::_quadrature, Field::addArray(), GeomFields::area, GeomFields::areaMag, MacroFields::force, Mesh::getCells(), CRConnectivity::getCol(), Mesh::getConnectivity(), StorageSite::getCount(), CRConnectivity::getRow(), StorageSite::getSelfCount(), MacroFields::velocity, and Array< T >::zero().

5482  {
5483  typedef CRMatrixTranspose<T,T,T> IMatrix;
5484 
5485  const int nSolidFaces = solidFaces.getCount();
5486 
5487  boost::shared_ptr<VectorT3Array>
5488  forcePtr( new VectorT3Array(nSolidFaces));
5489  VectorT3Array& force = *forcePtr;
5490 
5491  force.zero();
5492  _macroFields.force.addArray(solidFaces,forcePtr);
5493 
5494  const VectorT3Array& solidFaceArea =
5495  dynamic_cast<const VectorT3Array&>(_geomFields.area[solidFaces]);
5496 
5497  const TArray& solidFaceAreaMag =
5498  dynamic_cast<const TArray&>(_geomFields.areaMag[solidFaces]);
5499 
5500  const int numMeshes = _meshes.size();
5501  for (int n=0; n<numMeshes; n++)
5502  {
5503  const Mesh& mesh = *_meshes[n];
5504  const StorageSite& cells = mesh.getCells();
5505 
5506  const VectorT3Array& v = dynamic_cast<const VectorT3Array&>(_macroFields.velocity[cells]);
5507  const TArray& cx = dynamic_cast<const TArray&>(*_quadrature.cxPtr);
5508  const TArray& cy = dynamic_cast<const TArray&>(*_quadrature.cyPtr);
5509  const TArray& cz = dynamic_cast<const TArray&>(*_quadrature.czPtr);
5510  const TArray& wts = dynamic_cast<const TArray&>(*_quadrature.dcxyzPtr);
5511 
5512  const CRConnectivity& solidFacesToCells
5513  = mesh.getConnectivity(solidFaces,cells);
5514  const IntArray& sFCRow = solidFacesToCells.getRow();
5515  const IntArray& sFCCol = solidFacesToCells.getCol();
5516 
5517  const T Lx=_options["nonDimLx"];
5518  const T Ly=_options["nonDimLy"];
5519  const T Lz=_options["nonDimLz"];
5520 
5521 
5522  const int N123= _quadrature.getDirCount();
5523 
5524  const int selfCount = cells.getSelfCount();
5525  for(int f=0; f<nSolidFaces; f++){
5526 
5527  StressTensor<T> stress = NumTypeTraits<StressTensor<T> >::getZero();
5528 
5529  if (IBM){
5530  const VectorT3Array& vs = dynamic_cast<const VectorT3Array&>(_macroFields.velocity[solidFaces]);
5531  GeomFields::SSPair key1(&solidFaces,&cells);
5532  const IMatrix& mIC =
5533  dynamic_cast<const IMatrix&>
5535  const Array<T>& iCoeffs = mIC.getCoeff();
5536  for(int j=0;j<N123;j++){
5537  Field& fnd = *_dsfPtr.dsf[j];
5538  const TArray& f_dsf = dynamic_cast<const TArray&>(fnd[cells]);
5539  const TArray& fs_dsf = dynamic_cast<const TArray&>(fnd[solidFaces]);
5540  stress[0] -=pow((cx[j]-vs[f][0]),2.0)*fs_dsf[f]*wts[j];
5541  stress[1] -=pow((cy[j]-vs[f][1]),2.0)*fs_dsf[f]*wts[j];
5542  stress[2] -=pow((cz[j]-vs[f][2]),2.0)*fs_dsf[f]*wts[j];
5543  stress[3] -=(cx[j]-vs[f][0])*(cy[j]-vs[f][1])*fs_dsf[f]*wts[j];
5544  stress[4] -=(cy[j]-vs[f][1])*(cz[j]-vs[f][2])*fs_dsf[f]*wts[j];
5545  stress[5] -=(cx[j]-vs[f][0])*(cz[j]-vs[f][2])*fs_dsf[f]*wts[j];
5546  /*
5547  for(int nc = sFCRow[f]; nc<sFCRow[f+1]; nc++)
5548  {
5549 
5550  const int c = sFCCol[nc];
5551  const T coeff = iCoeffs[nc];
5552  stress[0] -=coeff*pow((cx[j]-v[c][0]),2.0)*f_dsf[c]*wts[j];
5553  stress[1] -=coeff*pow((cy[j]-v[c][1]),2.0)*f_dsf[c]*wts[j];
5554  stress[2] -=coeff*pow((cz[j]-v[c][2]),2.0)*f_dsf[c]*wts[j];
5555  stress[3] -=coeff*(cx[j]-v[c][0])*(cy[j]-v[c][1])*f_dsf[c]*wts[j];
5556  stress[4] -=coeff*(cy[j]-v[c][1])*(cz[j]-v[c][2])*f_dsf[c]*wts[j];
5557  stress[5] -=coeff*(cx[j]-v[c][0])*(cz[j]-v[c][2])*f_dsf[c]*wts[j];
5558  }
5559  */
5560  }
5561  }
5562  else
5563  {
5564  for(int j=0;j<N123;j++){
5565  Field& fnd = *_dsfPtr.dsf[j];
5566  const TArray& f_dsf = dynamic_cast<const TArray&>(fnd[cells]);
5567  for(int nc = sFCRow[f]; nc<sFCRow[f+1]; nc++)
5568  {
5569 
5570  const int c = sFCCol[nc];
5571  if ( c < selfCount ){
5572  stress[0] +=pow((cx[j]-v[c][0]),2.0)*f_dsf[c]*wts[j];
5573  stress[1] +=pow((cy[j]-v[c][1]),2.0)*f_dsf[c]*wts[j];
5574  stress[2] +=pow((cz[j]-v[c][2]),2.0)*f_dsf[c]*wts[j];
5575  stress[3] +=(cx[j]-v[c][0])*(cy[j]-v[c][1])*f_dsf[c]*wts[j];
5576  stress[4] +=(cy[j]-v[c][1])*(cz[j]-v[c][2])*f_dsf[c]*wts[j];
5577  stress[5] +=(cx[j]-v[c][0])*(cz[j]-v[c][2])*f_dsf[c]*wts[j];
5578  }
5579  }
5580  }
5581 
5582  }
5583 
5584 
5585  const VectorT3& Af = solidFaceArea[f];
5586  force[f][0] = Af[0]*Ly*Lz*stress[0] + Af[1]*Lz*Lx*stress[3] + Af[2]*Lx*Ly*stress[5];
5587  force[f][1] = Af[0]*Ly*Lz*stress[3] + Af[1]*Lz*Lx*stress[1] + Af[2]*Lx*Ly*stress[4];
5588  force[f][2] = Af[0]*Ly*Lz*stress[5] + Af[1]*Lz*Lx*stress[4] + Af[2]*Ly*Ly*stress[2];
5589  if (perUnitArea){
5590  force[f] /= solidFaceAreaMag[f];}
5591  }
5592  }
5593  }
const Array< int > & getCol() const
virtual void zero()
Definition: Array.h:281
const Array< int > & getRow() const
GeomFields & _geomFields
int getSelfCount() const
Definition: StorageSite.h:40
const CRConnectivity & getConnectivity(const StorageSite &from, const StorageSite &to) const
Definition: Mesh.cpp:416
Quadrature< T > & _quadrature
Array< T > TArray
Definition: Field.h:14
Definition: Mesh.h:49
COMETModelOptions< T > _options
Field force
Definition: MacroFields.h:36
Array< VectorT3 > VectorT3Array
map< SSPair, shared_ptr< Matrix > > _interpolationMatrices
Definition: GeomFields.h:50
MacroFields & _macroFields
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
Field velocity
Definition: MacroFields.h:15
DistFunctFields< T > _dsfPtr
int getCount() const
Definition: StorageSite.h:39
Array< int > IntArray
Field area
Definition: GeomFields.h:23
Field areaMag
Definition: GeomFields.h:25
pair< const StorageSite *, const StorageSite * > SSPair
Definition: GeomFields.h:48
template<class T >
const double COMETModel< T >::ConservationofMassCheck ( )
inline

Definition at line 4808 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfPtr, COMETModel< T >::_geomFields, Model::_meshes, COMETModel< T >::_quadrature, GeomFields::area, GeomFields::areaMag, Mesh::getAllFaceCells(), Mesh::getCells(), StorageSite::getCount(), StorageSite::getCountLevel1(), Mesh::getFaces(), GeomFields::ibFaceIndex, GeomFields::ibType, and Mesh::IBTYPE_FLUID.

4809  {
4810  const int numMeshes = _meshes.size();
4811  T ndens_tot(0.0) ;
4812 
4813  for (int n=0; n<numMeshes; n++)
4814  {
4815  const Mesh& mesh = *_meshes[n];
4816  const StorageSite& cells = mesh.getCells();
4817  const IntArray& ibType = dynamic_cast<const IntArray&>(_geomFields.ibType[cells]);
4818  const StorageSite& faces = mesh.getFaces();
4819  const TArray& wts= dynamic_cast<const TArray&>(*_quadrature.dcxyzPtr);
4820  const int numDirections = _quadrature.getDirCount();
4821  const IntArray& ibFaceIndex = dynamic_cast<const IntArray&>(_geomFields.ibFaceIndex[faces]);
4822  const VectorT3Array& faceArea =
4823  dynamic_cast<const VectorT3Array&>(_geomFields.area[faces]);
4824  const TArray& faceAreaMag =
4825  dynamic_cast<const TArray&>(_geomFields.areaMag[faces]);
4826  const CRConnectivity& faceCells = mesh.getAllFaceCells();
4827  const int nFaces = faces.getCount();
4828 
4829  for(int c=0; c<cells.getCountLevel1(); c++)
4830  {
4831  if (ibType[c] == Mesh::IBTYPE_FLUID)
4832  {
4833  for (int j=0; j<numDirections; j++)
4834  {
4835  Field& fnd = *_dsfPtr.dsf[j];
4836  TArray& dsf = dynamic_cast< TArray&>(fnd[cells]);
4837  ndens_tot += wts[j]*dsf[c];
4838  }
4839  }
4840  }
4841  }
4842  cout << "Hello, I have" << ndens_tot << "number density";
4843  return ndens_tot;
4844  }
GeomFields & _geomFields
Quadrature< T > & _quadrature
Array< T > TArray
Definition: Field.h:14
Definition: Mesh.h:49
Field ibType
Definition: GeomFields.h:38
const CRConnectivity & getAllFaceCells() const
Definition: Mesh.cpp:378
const StorageSite & getFaces() const
Definition: Mesh.h:108
const MeshList _meshes
Definition: Model.h:29
Field ibFaceIndex
Definition: GeomFields.h:40
const StorageSite & getCells() const
Definition: Mesh.h:109
int getCountLevel1() const
Definition: StorageSite.h:72
DistFunctFields< T > _dsfPtr
int getCount() const
Definition: StorageSite.h:39
Array< int > IntArray
Field area
Definition: GeomFields.h:23
Field areaMag
Definition: GeomFields.h:25
template<class T >
void COMETModel< T >::ConservationofMFSolid ( const StorageSite solidFaces) const
inline

Definition at line 4846 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfPtr, COMETModel< T >::_finestGeomFields, COMETModel< T >::_finestMacroFields, COMETModel< T >::_options, COMETModel< T >::_quadrature, GeomFields::area, GeomFields::areaMag, GeomFields::coordinate, MacroFields::density, epsilon, StorageSite::getCount(), MacroFields::temperature, and MacroFields::velocity.

Referenced by COMETModel< T >::cycle(), and COMETModel< T >::smooth().

4847  {
4848  const double pi=_options.pi;
4849  const double epsilon=_options.epsilon_ES;
4850  const int nSolidFaces = solidFaces.getCount();
4851  for (int i=0; i<nSolidFaces; i++)
4852  {
4853  const int numDirections = _quadrature.getDirCount();
4854  const TArray& cx = dynamic_cast<const TArray&>(*_quadrature.cxPtr);
4855  const TArray& cy = dynamic_cast<const TArray&>(*_quadrature.cyPtr);
4856  const TArray& cz = dynamic_cast<const TArray&>(*_quadrature.czPtr);
4857  const VectorT3Array& solidFaceCentroid =
4858  dynamic_cast<const VectorT3Array&>(_finestGeomFields.coordinate[solidFaces]);
4859  const VectorT3Array& solidFaceArea =
4860  dynamic_cast<const VectorT3Array&>(_finestGeomFields.area[solidFaces]);
4861  const TArray& solidFaceAreaMag =
4862  dynamic_cast<const TArray&>(_finestGeomFields.areaMag[solidFaces]);
4863  const TArray& wts= dynamic_cast<const TArray&>(*_quadrature.dcxyzPtr);
4864  VectorT3Array& v = dynamic_cast<VectorT3Array&>(_finestMacroFields.velocity[solidFaces]);
4865  TArray& density = dynamic_cast<TArray&>(_finestMacroFields.density[solidFaces]);
4866  TArray& temperature = dynamic_cast<TArray&>(_finestMacroFields.temperature[solidFaces]);
4867  const T uwall = v[i][0];
4868  const T vwall = v[i][1];
4869  const T wwall = v[i][2];
4870  const T Twall = temperature[i];
4871 
4872  T Nmr(0.0) ;
4873  T Dmr(0.0) ;
4874  T incomFlux(0.0);
4875  for (int j=0; j<numDirections; j++)
4876  {
4877  Field& fnd = *_dsfPtr.dsf[j];
4878  TArray& dsf = dynamic_cast< TArray&>(fnd[solidFaces]);
4879  const VectorT3 en = solidFaceArea[i]/solidFaceAreaMag[i];
4880  const T c_dot_en = cx[j]*en[0]+cy[j]*en[1]+cz[j]*en[2];
4881  const T wallV_dot_en = uwall*en[0]+vwall*en[1]+wwall*en[2];
4882  const T fwall = 1.0/pow(pi*Twall,1.5)*exp(-(pow(cx[j]-uwall,2.0)+pow(cy[j]-vwall,2.0)+pow(cz[j]-wwall,2.0))/Twall);
4883 
4884  if (c_dot_en-wallV_dot_en > 0) //incoming
4885  {
4886  Dmr = Dmr - fwall*wts[j]*(c_dot_en-wallV_dot_en);
4887  incomFlux=incomFlux-dsf[i]*wts[j]*(c_dot_en-wallV_dot_en);
4888  }
4889  else
4890  {
4891  Nmr = Nmr + dsf[i]*wts[j]*(c_dot_en-wallV_dot_en);
4892  }
4893  }
4894  const T nwall = Nmr/Dmr; // wall number density for initializing Maxwellian
4895 
4896  density[i]=nwall;
4897 
4898  for (int j=0; j<numDirections; j++)
4899  {
4900  Field& fnd = *_dsfPtr.dsf[j];
4901  TArray& dsf = dynamic_cast< TArray&>(fnd[solidFaces]);
4902  const VectorT3 en = solidFaceArea[i]/solidFaceAreaMag[i];
4903  const T c_dot_en = cx[j]*en[0]+cy[j]*en[1]+cz[j]*en[2];
4904  const T wallV_dot_en = uwall*en[0]+vwall*en[1]+wwall*en[2];
4905  if (c_dot_en-wallV_dot_en > 0)
4906  {
4907  dsf[i] = nwall/pow(pi*Twall,1.5)*exp(-(pow(cx[j]-uwall,2.0)+pow(cy[j]-vwall,2.0)+pow(cz[j]-wwall,2.0))/Twall);
4908  }
4909  else
4910  dsf[i]=dsf[i];
4911  }
4912  }
4913  }
#define epsilon
Definition: Mesh.cpp:17
Field coordinate
Definition: GeomFields.h:19
Quadrature< T > & _quadrature
Array< T > TArray
Definition: Field.h:14
COMETModelOptions< T > _options
Field temperature
Definition: MacroFields.h:22
GeomFields & _finestGeomFields
MacroFields & _finestMacroFields
Field velocity
Definition: MacroFields.h:15
DistFunctFields< T > _dsfPtr
int getCount() const
Definition: StorageSite.h:39
Field area
Definition: GeomFields.h:23
Field areaMag
Definition: GeomFields.h:25
Field density
Definition: MacroFields.h:21
template<class T >
void COMETModel< T >::correctMassDeficit ( )
inline

Definition at line 4628 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfEqPtrES, COMETModel< T >::_dsfPtr, COMETModel< T >::_geomFields, Model::_meshes, COMETModel< T >::_quadrature, GeomFields::area, GeomFields::areaMag, Mesh::getAllFaceCells(), Mesh::getCells(), StorageSite::getCount(), Mesh::getFaces(), Mesh::getIBFaces(), StorageSite::getSelfCount(), GeomFields::ibFaceIndex, GeomFields::ibType, Mesh::IBTYPE_BOUNDARY, Mesh::IBTYPE_FLUID, and GeomFields::volume.

4629  {
4630 
4631  const int numMeshes = _meshes.size();
4632  T netFlux(0.0);
4633 
4634  for (int n=0; n<numMeshes; n++)
4635  {
4636  const Mesh& mesh = *_meshes[n];
4637  const StorageSite& ibFaces = mesh.getIBFaces();
4638  const StorageSite& cells = mesh.getCells();
4639  const IntArray& ibType = dynamic_cast<const IntArray&>(_geomFields.ibType[cells]);
4640  const StorageSite& faces = mesh.getFaces();
4641  const TArray& cx = dynamic_cast<const TArray&>(*_quadrature.cxPtr);
4642  const TArray& cy = dynamic_cast<const TArray&>(*_quadrature.cyPtr);
4643  const TArray& cz = dynamic_cast<const TArray&>(*_quadrature.czPtr);
4644  const TArray& wts= dynamic_cast<const TArray&>(*_quadrature.dcxyzPtr);
4645  const int numDirections = _quadrature.getDirCount();
4646  const IntArray& ibFaceIndex = dynamic_cast<const IntArray&>(_geomFields.ibFaceIndex[faces]);
4647  const VectorT3Array& faceArea =
4648  dynamic_cast<const VectorT3Array&>(_geomFields.area[faces]);
4649  const TArray& faceAreaMag =
4650  dynamic_cast<const TArray&>(_geomFields.areaMag[faces]);
4651  const CRConnectivity& faceCells = mesh.getAllFaceCells();
4652  const int nibFaces = ibFaces.getCount();
4653 
4654  for(int f=0; f<nibFaces; f++)
4655  {
4656  const int c0 = faceCells(f,0);
4657  const int c1 = faceCells(f,1);
4658  if (((ibType[c0] == Mesh::IBTYPE_FLUID) && (ibType[c1] == Mesh::IBTYPE_BOUNDARY)) ||
4659  ((ibType[c1] == Mesh::IBTYPE_FLUID) && (ibType[c0] == Mesh::IBTYPE_BOUNDARY)))
4660  {
4661  const int ibFace = ibFaceIndex[f];
4662  if (ibFace < 0)
4663  throw CException("invalid ib face index");
4664  if (ibType[c0] == Mesh::IBTYPE_FLUID)
4665  {
4666  const VectorT3 en = faceArea[f]/faceAreaMag[f];
4667  for (int j=0; j<numDirections; j++)
4668  {
4669  const T c_dot_en = cx[j]*en[0]+cy[j]*en[1]+cz[j]*en[2];
4670  Field& fnd = *_dsfPtr.dsf[j];
4671  TArray& dsf = dynamic_cast<TArray&>(fnd[ibFaces]);
4672 
4673  netFlux -= dsf[f]*c_dot_en*wts[j]/abs(c_dot_en);
4674  }
4675 
4676  }
4677  else
4678  {
4679  const VectorT3 en = faceArea[f]/faceAreaMag[f];
4680  for (int j=0; j<numDirections; j++)
4681  {
4682  const T c_dot_en = cx[j]*en[0]+cy[j]*en[1]+cz[j]*en[2];
4683  Field& fnd = *_dsfPtr.dsf[j];
4684  TArray& dsf = dynamic_cast<TArray&>(fnd[ibFaces]);
4685 
4686  netFlux += dsf[f]*c_dot_en*wts[j]/abs(c_dot_en);
4687  }
4688  }
4689  }
4690  }
4691  }
4692 
4693 #ifdef FVM_PARALLEL
4694  MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &netFlux, 1, MPI::DOUBLE, MPI::SUM);
4695 #endif
4696 
4697  T volumeSum(0.);
4698 
4699  for (int n=0; n<numMeshes; n++)
4700  {
4701  const Mesh& mesh = *_meshes[n];
4702  const StorageSite& cells = mesh.getCells();
4703  const IntArray& ibType = dynamic_cast<const IntArray&>(_geomFields.ibType[cells]);
4704  const TArray& cellVolume = dynamic_cast<const TArray&>(_geomFields.volume[cells]);
4705  for(int c=0; c<cells.getSelfCount(); c++)
4706  if (ibType[c] == Mesh::IBTYPE_FLUID)
4707  volumeSum += cellVolume[c];
4708  }
4709 #ifdef FVM_PARALLEL
4710  MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &volumeSum, 1, MPI::DOUBLE, MPI::SUM);
4711 #endif
4712 
4713  netFlux /= volumeSum;
4714  for (int n=0; n<numMeshes; n++)
4715  {
4716  const Mesh& mesh = *_meshes[n];
4717  const StorageSite& cells = mesh.getCells();
4718  const IntArray& ibType = dynamic_cast<const IntArray&>(_geomFields.ibType[cells]);
4719  const TArray& cellVolume = dynamic_cast<const TArray&>(_geomFields.volume[cells]);
4720  const TArray& wts= dynamic_cast<const TArray&>(*_quadrature.dcxyzPtr);
4721 
4722  for(int c=0; c<cells.getSelfCount(); c++)
4723  {
4724  if (ibType[c] == Mesh::IBTYPE_FLUID){
4725  const int numDirections = _quadrature.getDirCount();
4726  T cellMass(0.0);
4727  for (int j=0; j<numDirections; j++)
4728  {
4729  Field& fnd = *_dsfPtr.dsf[j];
4730  TArray& dsf = dynamic_cast< TArray&>(fnd[cells]);
4731  cellMass += wts[j]*dsf[c];
4732  }
4733 
4734  for (int j=0; j<numDirections; j++)
4735  {
4736  Field& fnd = *_dsfPtr.dsf[j];
4737  TArray& dsf = dynamic_cast< TArray&>(fnd[cells]);
4738  Field& feqES = *_dsfEqPtrES.dsf[j]; //for fgamma_2
4739  TArray& fgam = dynamic_cast< TArray&>(feqES[cells]);
4740  fgam[c] = fgam[c]*(1+netFlux*cellVolume[c]/cellMass);
4741  dsf[c] = dsf[c]*(1+netFlux*cellVolume[c]/cellMass);
4742  }
4743  }
4744 
4745  }
4746  }
4747  }
GeomFields & _geomFields
int getSelfCount() const
Definition: StorageSite.h:40
const StorageSite & getIBFaces() const
Definition: Mesh.h:111
Quadrature< T > & _quadrature
Array< T > TArray
Definition: Field.h:14
Definition: Mesh.h:49
Field ibType
Definition: GeomFields.h:38
const CRConnectivity & getAllFaceCells() const
Definition: Mesh.cpp:378
const StorageSite & getFaces() const
Definition: Mesh.h:108
const MeshList _meshes
Definition: Model.h:29
Field ibFaceIndex
Definition: GeomFields.h:40
const StorageSite & getCells() const
Definition: Mesh.h:109
Field volume
Definition: GeomFields.h:26
DistFunctFields< T > _dsfEqPtrES
DistFunctFields< T > _dsfPtr
int getCount() const
Definition: StorageSite.h:39
Array< int > IntArray
Field area
Definition: GeomFields.h:23
Field areaMag
Definition: GeomFields.h:25
template<class T >
void COMETModel< T >::correctMassDeficit2 ( double  n1,
double  n2 
)
inline

Definition at line 4749 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfEqPtrES, COMETModel< T >::_dsfPtr, COMETModel< T >::_geomFields, Model::_meshes, COMETModel< T >::_quadrature, Mesh::getCells(), StorageSite::getSelfCount(), GeomFields::ibType, Mesh::IBTYPE_FLUID, and GeomFields::volume.

4750  {
4751 
4752  const int numMeshes = _meshes.size();
4753  T netFlux(0.0);
4754 
4755  netFlux=n2-n1;
4756 
4757  T volumeSum(0.);
4758 
4759  for (int n=0; n<numMeshes; n++)
4760  {
4761  const Mesh& mesh = *_meshes[n];
4762  const StorageSite& cells = mesh.getCells();
4763  const IntArray& ibType = dynamic_cast<const IntArray&>(_geomFields.ibType[cells]);
4764  const TArray& cellVolume = dynamic_cast<const TArray&>(_geomFields.volume[cells]);
4765  for(int c=0; c<cells.getSelfCount(); c++)
4766  if (ibType[c] == Mesh::IBTYPE_FLUID)
4767  volumeSum += cellVolume[c];
4768  }
4769 #ifdef FVM_PARALLEL
4770  MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &volumeSum, 1, MPI::DOUBLE, MPI::SUM);
4771 #endif
4772 
4773  netFlux /= volumeSum;
4774  for (int n=0; n<numMeshes; n++)
4775  {
4776  const Mesh& mesh = *_meshes[n];
4777  const StorageSite& cells = mesh.getCells();
4778  const IntArray& ibType = dynamic_cast<const IntArray&>(_geomFields.ibType[cells]);
4779  const TArray& cellVolume = dynamic_cast<const TArray&>(_geomFields.volume[cells]);
4780  const TArray& wts= dynamic_cast<const TArray&>(*_quadrature.dcxyzPtr);
4781 
4782  for(int c=0; c<cells.getSelfCount(); c++)
4783  {
4784  if (ibType[c] == Mesh::IBTYPE_FLUID){
4785  const int numDirections = _quadrature.getDirCount();
4786  T cellMass(0.0);
4787  for (int j=0; j<numDirections; j++)
4788  {
4789  Field& fnd = *_dsfPtr.dsf[j];
4790  TArray& dsf = dynamic_cast< TArray&>(fnd[cells]);
4791  cellMass += wts[j]*dsf[c];
4792  }
4793 
4794  for (int j=0; j<numDirections; j++)
4795  {
4796  Field& fnd = *_dsfPtr.dsf[j];
4797  TArray& dsf = dynamic_cast< TArray&>(fnd[cells]);
4798  Field& feqES = *_dsfEqPtrES.dsf[j]; //for fgamma_2
4799  TArray& fgam = dynamic_cast< TArray&>(feqES[cells]);
4800  fgam[c] = fgam[c]*(1+netFlux*cellVolume[c]/cellMass);
4801  dsf[c] = dsf[c]*(1+netFlux*cellVolume[c]/cellMass);
4802  }
4803  }
4804 
4805  }
4806  }
4807  }
GeomFields & _geomFields
int getSelfCount() const
Definition: StorageSite.h:40
Quadrature< T > & _quadrature
Array< T > TArray
Definition: Field.h:14
Definition: Mesh.h:49
Field ibType
Definition: GeomFields.h:38
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
Field volume
Definition: GeomFields.h:26
DistFunctFields< T > _dsfEqPtrES
DistFunctFields< T > _dsfPtr
Array< int > IntArray
template<class T >
int COMETModel< T >::correctSingleNeighbor ( const int  m,
const Mesh mesh,
GeomFields inGeomFields,
int  coarseCount,
map< const StorageSite *, IntArray * >  PreFacePairMap 
)
inline

Definition at line 2357 of file phononbase/COMETModel.h.

References COMETModel< T >::_bcMap, GeomFields::fineToCoarse, Mesh::getBoundaryFaceGroups(), Mesh::getCells(), StorageSite::getCount(), Mesh::getFaceCells(), Mesh::getFaces(), Mesh::getInterfaceGroups(), Array< T >::getLength(), StorageSite::getSelfCount(), FaceGroup::id, and FaceGroup::site.

Referenced by COMETModel< T >::MakeInteriorCoarseMesh().

2360  {
2361 
2362  const StorageSite& inCells=mesh.getCells();
2363  const int inCellTotal=inCells.getCount();
2364  const StorageSite& inFaces=mesh.getFaces();
2365  const int inFaceCount=inFaces.getCount();
2366  const CRConnectivity& inFaceinCells=mesh.getFaceCells(inFaces);
2367  const IntArray& FineToCoarseConst=dynamic_cast<const IntArray&>
2368  (inGeomFields.fineToCoarse[inCells]);
2369 
2370  IntArray FineToCoarse(FineToCoarseConst.getLength());
2371  FineToCoarse=FineToCoarseConst;
2372 
2373  int coarseGhost=coarseCount;
2374  int outGhost(0);
2375  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
2376  {
2377  const FaceGroup& fg=*fgPtr;
2378 
2379  if(fg.id>0)
2380  {
2381  const CRConnectivity& faceCells=mesh.getFaceCells(fg.site);
2382  const int faceCount=fg.site.getCount();
2383 
2384  if(_bcMap[fg.id]->bcType == "Interface")
2385  {
2386  IntArray& FaceFine2Coarse=*PreFacePairMap[&fg.site];
2387 
2388  int coarseFaces(0);
2389  for(int i=0;i<faceCount;i++)
2390  {
2391  const int cghost=faceCells(i,1);
2392  FineToCoarse[cghost]=FaceFine2Coarse[i]+coarseGhost;
2393  if(FaceFine2Coarse[i]>coarseFaces)
2394  coarseFaces=FaceFine2Coarse[i];
2395  }
2396  coarseGhost+=coarseFaces+1;
2397  outGhost+=coarseFaces+1;
2398  }
2399  else if(_bcMap[fg.id]->bcType == "temperature" ||
2400  _bcMap[fg.id]->bcType == "reflecting" )
2401  {
2402  for(int i=0;i<faceCount;i++)
2403  {
2404  const int cghost=faceCells(i,1);
2405  FineToCoarse[cghost]=coarseGhost;
2406  coarseGhost++;
2407  outGhost++;
2408  }
2409  }
2410 
2411  }
2412  }
2413 
2414  foreach(const FaceGroupPtr fgPtr, mesh.getInterfaceGroups())
2415  {
2416  const FaceGroup& fg=*fgPtr;
2417  const CRConnectivity& faceCells=mesh.getFaceCells(fg.site);
2418  const int faceCount=fg.site.getCount();
2419 
2420  for(int i=0;i<faceCount;i++)
2421  {
2422  const int cghost=faceCells(i,1);
2423  FineToCoarse[cghost]=coarseGhost;
2424  coarseGhost++;
2425  outGhost++;
2426  }
2427 
2428  }
2429 
2430  StorageSite preOutCells(coarseCount,outGhost);
2431  CRPtr CoarseToFineCells=CRPtr(new CRConnectivity(preOutCells,inCells));
2432  CoarseToFineCells->initCount();
2433 
2434  for(int c=0;c<inCellTotal;c++)
2435  CoarseToFineCells->addCount(FineToCoarse[c],1);
2436 
2437  CoarseToFineCells->finishCount();
2438 
2439  for(int c=0;c<inCellTotal;c++)
2440  CoarseToFineCells->add(FineToCoarse[c],c);
2441 
2442  CoarseToFineCells->finishAdd();
2443 
2444  CRPtr FineFacesCoarseCells=CRPtr(new CRConnectivity(inFaces,preOutCells));
2445  FineFacesCoarseCells->initCount();
2446 
2447  //count surviving faces
2448  int survivingFaces=0;
2449  int coarse0, coarse1;
2450  for(int f=0;f<inFaceCount;f++)
2451  {
2452  coarse0=FineToCoarse[inFaceinCells(f,0)];
2453  coarse1=FineToCoarse[inFaceinCells(f,1)];
2454  if(coarse0!=coarse1)
2455  {
2456  survivingFaces++;
2457  FineFacesCoarseCells->addCount(f,2);
2458  }
2459  }
2460 
2461  FineFacesCoarseCells->finishCount();
2462 
2463  //make non-zero's
2464  for(int f=0;f<inFaceCount;f++)
2465  {
2466  int fc0=inFaceinCells(f,0);
2467  int fc1=inFaceinCells(f,1);
2468  int cc0=FineToCoarse[fc0];
2469  int cc1=FineToCoarse[fc1];
2470  if(cc0!=cc1)
2471  {
2472  FineFacesCoarseCells->add(f,cc0);
2473  FineFacesCoarseCells->add(f,cc1);
2474  }
2475  }
2476 
2477  FineFacesCoarseCells->finishAdd();
2478 
2479  CRPtr CoarseCellsFineFaces=FineFacesCoarseCells->getTranspose();
2480  CRPtr CellCellCoarse=CoarseCellsFineFaces->multiply(*FineFacesCoarseCells,true);
2481 
2482 
2483  for(int c=0;c<preOutCells.getSelfCount();c++)
2484  {
2485  if(CellCellCoarse->getCount(c)<2)
2486  {
2487  /*
2488  const int bigCoarse=(*CellCellCoarse)(c,0);
2489  const int fineCount=CoarseToFineCells->getCount(c);
2490 
2491  for(int j=0;j<fineCount;j++)
2492  {
2493  const int fc=(*CoarseToFineCells)(c,j);
2494  FineToCoarse[fc]=bigCoarse;
2495  }
2496  coarseCount-=1;
2497  */
2498 
2499  const int removal=(*CoarseToFineCells)(c,0);
2500  FineToCoarse[removal]=coarseCount;
2501  coarseCount++;
2502 
2503  }
2504  }
2505 
2506  return coarseCount;
2507  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
Definition: Mesh.h:28
Field fineToCoarse
Definition: GeomFields.h:41
const int id
Definition: Mesh.h:41
const StorageSite & getFaces() const
Definition: Mesh.h:108
const StorageSite & getCells() const
Definition: Mesh.h:109
shared_ptr< CRConnectivity > CRPtr
const CRConnectivity & getFaceCells(const StorageSite &site) const
Definition: Mesh.cpp:388
int getCount() const
Definition: StorageSite.h:39
Array< int > IntArray
const FaceGroupList & getInterfaceGroups() const
Definition: Mesh.h:190
StorageSite site
Definition: Mesh.h:40
template<class T >
void COMETModel< T >::correctSolution ( )
inline

Definition at line 3158 of file phononbase/COMETModel.h.

References COMETModel< T >::_BFaces, COMETModel< T >::_coarserLevel, COMETModel< T >::_kspaces, COMETModel< T >::_macro, Model::_meshes, COMETModel< T >::_MeshKspaceMap, Mesh::getCellFaces(), Mesh::getCells(), Mesh::getConnectivity(), StorageSite::getCount(), CRConnectivity::getCount(), Kspace< T >::geteArray(), Kspace< T >::getGlobalIndex(), Kspace< T >::getInjArray(), COMETModel< T >::getKspace(), Kspace< T >::getkvol(), Kspace< T >::getlength(), COMETModel< T >::getMacro(), COMETModel< T >::getMeshList(), kvol< T >::getmodenum(), StorageSite::getSelfCount(), PhononMacro::temperature, and PhononMacro::TlInjected.

3159  {
3160  const int numMeshes = _meshes.size();
3161 
3162  for (int n=0; n<numMeshes; n++)
3163  {
3164  const Mesh& finerMesh=*_meshes[n];
3165  int Knum=_MeshKspaceMap[n];
3166  Tkspace& finerKspace=*_kspaces[Knum];
3167  const Mesh& coarserMesh=*(_coarserLevel->getMeshList())[n];
3168  Tkspace& coarserKspace=_coarserLevel->getKspace(Knum);
3169  PhononMacro& coarserMacro=_coarserLevel->getMacro();
3170  const StorageSite& finerCells=finerMesh.getCells();
3171  const StorageSite& coarserCells=coarserMesh.getCells();
3172  const CRConnectivity& CoarserToFiner=coarserMesh.getConnectivity(coarserCells,finerCells);
3173  const CRConnectivity& coarseCellFaces=coarserMesh.getCellFaces();
3174  BCfaceArray& BCfArray=*(_BFaces[n]);
3175 
3176  TArray& coarserArray=coarserKspace.geteArray();
3177  TArray& finerArray=finerKspace.geteArray();
3178  TArray& injArray=coarserKspace.getInjArray();
3179 
3180  const int cellCount=coarserCells.getSelfCount();
3181  const int cellTotCount=coarserCells.getCount();
3182 
3183  for(int c=0;c<cellCount;c++)
3184  {
3185  const int fineCount=CoarserToFiner.getCount(c);
3186  for(int fc=0;fc<fineCount;fc++)
3187  {
3188  int coarserCellIndex=coarserKspace.getGlobalIndex(c,0);
3189  const int finerCell=CoarserToFiner(c,fc);
3190  int finerCellIndex=finerKspace.getGlobalIndex(finerCell,0);
3191  const int klen=finerKspace.getlength();
3192  for(int k=0;k<klen;k++)
3193  {
3194  Tkvol& kvol=finerKspace.getkvol(k);
3195  const int numModes=kvol.getmodenum();
3196  for(int m=0;m<numModes;m++)
3197  {
3198  const T correction=coarserArray[coarserCellIndex]-injArray[coarserCellIndex];
3199  finerArray[finerCellIndex]+=correction;
3200  coarserCellIndex++;
3201  finerCellIndex++;
3202  }
3203  }
3204  }
3205  }
3206 
3207  for(int c=cellCount;c<cellTotCount;c++)
3208  {
3209  const int f=coarseCellFaces(c,0);
3210  if(BCfArray[f]==4) //correct interface cells only
3211  {
3212  const int fineCount=CoarserToFiner.getCount(c);
3213  for(int fc=0;fc<fineCount;fc++)
3214  {
3215  const int finerCell=CoarserToFiner(c,fc);
3216  int coarserCellIndex=coarserKspace.getGlobalIndex(c,0);
3217  int finerCellIndex=finerKspace.getGlobalIndex(finerCell,0);
3218  const int klen=finerKspace.getlength();
3219 
3220  for(int k=0;k<klen;k++)
3221  {
3222  Tkvol& kvol=finerKspace.getkvol(k);
3223  const int numModes=kvol.getmodenum();
3224  for(int m=0;m<numModes;m++)
3225  {
3226  const T correction=coarserArray[coarserCellIndex]-injArray[coarserCellIndex];
3227  finerArray[finerCellIndex]+=correction;
3228  coarserCellIndex++;
3229  finerCellIndex++;
3230  }
3231  }
3232 
3233  }
3234  }
3235  }
3236 
3237  TArray& coarserArrayM=dynamic_cast<TArray&>(coarserMacro.temperature[coarserCells]);
3238  TArray& injArrayM=dynamic_cast<TArray&>(coarserMacro.TlInjected[coarserCells]);
3239  TArray& finerArrayM=dynamic_cast<TArray&>(_macro.temperature[finerCells]);
3240 
3241  for(int c=0;c<cellCount;c++)
3242  {
3243  const int fineCount=CoarserToFiner.getCount(c);
3244  const T correction=coarserArrayM[c]-injArrayM[c];
3245 
3246  for(int fc=0;fc<fineCount;fc++)
3247  finerArrayM[CoarserToFiner(c,fc)]+=correction;
3248  }
3249  }
3250  }
Tkspace & getKspace(const int i)
int getCount(const int i) const
int getSelfCount() const
Definition: StorageSite.h:40
const CRConnectivity & getConnectivity(const StorageSite &from, const StorageSite &to) const
Definition: Mesh.cpp:416
Array< T > TArray
Field temperature
Definition: PhononMacro.h:21
Definition: Mesh.h:49
int getmodenum()
Definition: kvol.h:43
const CRConnectivity & getCellFaces() const
Definition: Mesh.cpp:454
PhononMacro & _macro
const MeshList _meshes
Definition: Model.h:29
MacroFields & getMacro()
const StorageSite & getCells() const
Definition: Mesh.h:109
MeshKspaceMap _MeshKspaceMap
Field TlInjected
Definition: PhononMacro.h:25
const MeshList & getMeshList()
int getCount() const
Definition: StorageSite.h:39
Kspace< T > Tkspace
Definition: kvol.h:14
Array< int > BCfaceArray
template<class T >
void COMETModel< T >::correctSolution ( )
inline

Definition at line 5336 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_coarserLevel, COMETModel< T >::_dsfPtr, COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_quadrature, DistFunctFields< T >::dsf, Mesh::getCells(), Mesh::getConnectivity(), CRConnectivity::getCount(), COMETModel< T >::getdsf(), COMETModel< T >::getdsf0(), COMETModel< T >::getMacro(), COMETModel< T >::getMeshList(), StorageSite::getSelfCount(), MacroFields::velocity, and MacroFields::velocityInjected.

Referenced by COMETModel< T >::cycle().

5337  {
5338  const int numMeshes = _meshes.size();
5339 
5340  for (int n=0; n<numMeshes; n++)
5341  {
5342  const Mesh& finerMesh=*_meshes[n];
5343  const Mesh& coarserMesh=*(_coarserLevel->getMeshList())[n];
5344  MacroFields& coarserMacro=_coarserLevel->getMacro();
5345  DistFunctFields<T>& coarserdsf = _coarserLevel->getdsf();
5346  DistFunctFields<T>& coarserdsf0 = _coarserLevel->getdsf0();
5347  const StorageSite& finerCells=finerMesh.getCells();
5348  const StorageSite& coarserCells=coarserMesh.getCells();
5349  const CRConnectivity& CoarserToFiner=coarserMesh.getConnectivity(coarserCells,finerCells);
5350 
5351  const int cellCount=coarserCells.getSelfCount();
5352 
5353  const int numDir=_quadrature.getDirCount();
5354  for(int dir=0;dir<numDir;dir++)
5355  {
5356  Field& fnd = *_dsfPtr.dsf[dir];
5357  Field& cfnd = *coarserdsf.dsf[dir];
5358  Field& cfndInj = *coarserdsf0.dsf[dir];
5359  TArray& finerArray = dynamic_cast<TArray&>(fnd[finerCells]);
5360  TArray& coarserArray = dynamic_cast<TArray&>(cfnd[coarserCells]);
5361  TArray& injArray = dynamic_cast<TArray&>(cfndInj[coarserCells]);
5362 
5363  for(int c=0;c<cellCount;c++)
5364  {
5365  const int fineCount=CoarserToFiner.getCount(c);
5366  const T correction=coarserArray[c]-injArray[c];
5367 
5368  for(int fc=0;fc<fineCount;fc++)
5369  finerArray[CoarserToFiner(c,fc)]+=correction;
5370  }
5371  }
5372 
5373  VectorT3Array& coarserArray=dynamic_cast<VectorT3Array&>(coarserMacro.velocity[coarserCells]);
5374  VectorT3Array& injArray=dynamic_cast<VectorT3Array&>(coarserMacro.velocityInjected[coarserCells]);
5375  VectorT3Array& finerArray=dynamic_cast<VectorT3Array&>(_macroFields.velocity[finerCells]);
5376 
5377  for(int c=0;c<cellCount;c++)
5378  {
5379  const int fineCount=CoarserToFiner.getCount(c);
5380  const VectorT3 correction=coarserArray[c]-injArray[c];
5381 
5382  for(int fc=0;fc<fineCount;fc++)
5383  finerArray[CoarserToFiner(c,fc)]+=correction;
5384  }
5385  }
5386  }
int getCount(const int i) const
int getSelfCount() const
Definition: StorageSite.h:40
const CRConnectivity & getConnectivity(const StorageSite &from, const StorageSite &to) const
Definition: Mesh.cpp:416
Quadrature< T > & _quadrature
Array< T > TArray
Definition: Field.h:14
Field velocityInjected
Definition: MacroFields.h:17
Definition: Mesh.h:49
DistFunctFields< T > & getdsf()
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
MacroFields & getMacro()
const StorageSite & getCells() const
Definition: Mesh.h:109
const MeshList & getMeshList()
Field velocity
Definition: MacroFields.h:15
std::vector< Field * > dsf
DistFunctFields< T > _dsfPtr
DistFunctFields< T > & getdsf0()
template<class T >
void COMETModel< T >::cycle ( )
inline

Definition at line 2971 of file phononbase/COMETModel.h.

References COMETModel< T >::_coarserLevel, COMETModel< T >::_level, COMETModel< T >::_options, COMETModel< T >::correctSolution(), COMETModel< T >::cycle(), COMETModel< T >::doSweeps(), COMETModel< T >::injectResid(), COMETModel< T >::makeFAS(), COMETModel< T >::sete0(), and COMETModel< T >::updateResid().

2972  {
2973  doSweeps(_options.preSweeps);
2974 
2975  if(_level+1<_options.maxLevels)
2976  {
2977  updateResid(_level!=0);
2978  injectResid();
2979  _coarserLevel->sete0();
2981  _coarserLevel->cycle();
2982  correctSolution();
2983  }
2984 
2985  doSweeps(_options.postSweeps);
2986  }
T updateResid(const bool addFAS)
COMETModelOptions< T > _options
void doSweeps(const int sweeps, const int num)
template<class T >
void COMETModel< T >::cycle ( )
inline

Definition at line 5113 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_coarserLevel, COMETModel< T >::_level, COMETModel< T >::_options, COMETModel< T >::ComputeCollisionfrequency(), COMETModel< T >::ComputeCOMETMacroparameters(), COMETModel< T >::correctSolution(), COMETModel< T >::cycle(), COMETModel< T >::doSweeps(), COMETModel< T >::EquilibriumDistributionBGK(), COMETModel< T >::EquilibriumDistributionESBGK(), COMETModel< T >::initializeMaxwellianEq(), COMETModel< T >::injectResid(), COMETModel< T >::makeFAS(), and COMETModel< T >::updateResid().

Referenced by COMETModel< T >::advance(), and COMETModel< T >::cycle().

5114  {
5115  if(_level+1<_options.maxLevels)
5116  doSweeps(_options.preSweeps,1);
5117  else
5118  doSweeps(_options.preCoarsestSweeps,1);
5119  if(_level+1<_options.maxLevels)
5120  {
5121  if(_level==0)
5122  updateResid(false);
5123  else
5124  updateResid(true);
5125 
5126  injectResid();
5129  if (_options.fgamma==0){_coarserLevel->initializeMaxwellianEq();}
5132 
5134  _coarserLevel->cycle();
5135  correctSolution();
5136 
5139  if (_options.fgamma==0){initializeMaxwellianEq();}
5141  if (_options.fgamma==2){EquilibriumDistributionESBGK();}
5142  }
5143  if(_level+1<_options.maxLevels)
5144  doSweeps(_options.postSweeps,0);
5145  else
5146  {
5147  if(_options.postCoarsestSweeps==1)
5148  doSweeps(_options.postCoarsestSweeps,0);
5149  else if(_options.postCoarsestSweeps>1)
5150  doSweeps(_options.postCoarsestSweeps,1);
5151  }
5152  }
T updateResid(const bool addFAS)
COMETModelOptions< T > _options
void ComputeCollisionfrequency()
void initializeMaxwellianEq()
void ComputeCOMETMacroparameters()
void EquilibriumDistributionESBGK()
void EquilibriumDistributionBGK()
void doSweeps(const int sweeps, const int num)
template<class T >
void COMETModel< T >::cycle ( const StorageSite solidFaces)
inline

Definition at line 5155 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_coarserLevel, COMETModel< T >::_level, COMETModel< T >::_options, COMETModel< T >::ComputeCollisionfrequency(), COMETModel< T >::ComputeCOMETMacroparameters(), COMETModel< T >::computeIBFaceDsf(), COMETModel< T >::computeSolidFaceDsf(), COMETModel< T >::ConservationofMFSolid(), COMETModel< T >::correctSolution(), COMETModel< T >::cycle(), COMETModel< T >::doSweeps(), COMETModel< T >::EquilibriumDistributionBGK(), COMETModel< T >::EquilibriumDistributionESBGK(), COMETModel< T >::initializeMaxwellianEq(), COMETModel< T >::injectResid(), COMETModel< T >::makeFAS(), COMETModel< T >::MakeParallel(), and COMETModel< T >::updateResid().

5156  {
5157  if(_level+1<_options.maxLevels)
5158  doSweeps(_options.preSweeps,1,solidFaces);
5159  else
5160  doSweeps(_options.preCoarsestSweeps,1,solidFaces);
5161  if(_level+1<_options.maxLevels)
5162  {
5163  if(_level==0)
5164  updateResid(false,solidFaces);
5165  else
5166  updateResid(true,solidFaces);
5167 
5168  injectResid();
5171  if (_options.fgamma==0){_coarserLevel->initializeMaxwellianEq();}
5175  _coarserLevel->computeSolidFaceDsf(solidFaces,_options.method,_options.relaxDistribution);
5176  _coarserLevel->ConservationofMFSolid(solidFaces);
5177  _coarserLevel->computeIBFaceDsf(solidFaces,_options.method,_options.relaxDistribution);
5178 
5179  _coarserLevel->makeFAS(solidFaces);
5180  _coarserLevel->cycle(solidFaces);
5181  correctSolution();
5182 
5185  if (_options.fgamma==0){initializeMaxwellianEq();}
5187  if (_options.fgamma==2){EquilibriumDistributionESBGK();}
5188  MakeParallel();
5189  computeSolidFaceDsf(solidFaces,_options.method,_options.relaxDistribution);
5190  ConservationofMFSolid(solidFaces);
5191  computeIBFaceDsf(solidFaces,_options.method,_options.relaxDistribution);
5192  }
5193  if(_level+1<_options.maxLevels)
5194  doSweeps(_options.postSweeps,0,solidFaces);
5195  else
5196  {
5197  if(_options.postCoarsestSweeps==1)
5198  doSweeps(_options.postCoarsestSweeps,0,solidFaces);
5199  else if(_options.postCoarsestSweeps>1)
5200  doSweeps(_options.postCoarsestSweeps,1,solidFaces);
5201  }
5202  }
void computeIBFaceDsf(const StorageSite &solidFaces, const int method, const int RelaxDistribution=0)
T updateResid(const bool addFAS)
void computeSolidFaceDsf(const StorageSite &solidFaces, const int method, const int RelaxDistribution=0)
COMETModelOptions< T > _options
void ComputeCollisionfrequency()
void initializeMaxwellianEq()
void ComputeCOMETMacroparameters()
void EquilibriumDistributionESBGK()
void EquilibriumDistributionBGK()
void doSweeps(const int sweeps, const int num)
void ConservationofMFSolid(const StorageSite &solidFaces) const
template<class T >
void COMETModel< T >::doSweeps ( const int  sweeps)
inline

Definition at line 2800 of file phononbase/COMETModel.h.

References COMETModel< T >::smooth().

2801  {
2802  for(int sweepNo=0;sweepNo<sweeps;sweepNo++)
2803  {
2804  smooth(1);
2805  smooth(-1);
2806  }
2807  //applyTemperatureBoundaries();
2808  }
void smooth(const int num, const StorageSite &solidFaces)
template<class T >
void COMETModel< T >::doSweeps ( const int  sweeps,
const int  num 
)
inline

Definition at line 4915 of file esbgkbase/COMETModel.h.

References COMETModel< T >::smooth().

Referenced by COMETModel< T >::cycle().

4916  {
4917  for(int sweepNo=0;sweepNo<sweeps;sweepNo++)
4918  smooth(num);
4919  }
void smooth(const int num, const StorageSite &solidFaces)
template<class T >
void COMETModel< T >::doSweeps ( const int  sweeps,
const int  num,
const StorageSite solidFaces 
)
inline

Definition at line 4921 of file esbgkbase/COMETModel.h.

References COMETModel< T >::smooth().

4922  {
4923  for(int sweepNo=0;sweepNo<sweeps;sweepNo++)
4924  smooth(num,solidFaces);
4925  }
void smooth(const int num, const StorageSite &solidFaces)
template<class T >
void COMETModel< T >::EntropyGeneration ( )
inline

Definition at line 1567 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfEqPtr, COMETModel< T >::_dsfEqPtrES, COMETModel< T >::_dsfPtr, COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_options, COMETModel< T >::_quadrature, MacroFields::collisionFrequency, MacroFields::Entropy, MacroFields::EntropyGenRate_Collisional, Mesh::getCells(), and StorageSite::getCount().

1567  {
1568  const int numMeshes = _meshes.size();
1569  for (int n=0; n<numMeshes; n++)
1570  {
1571  const T rho_init=_options["rho_init"];
1572  const T T_init= _options["T_init"];
1573  const T molwt=_options["molecularWeight"]*1E-26/6.023;
1574  const T R=8314.0/_options["molecularWeight"];
1575  const T u_init=pow(2.0*R*T_init,0.5);
1576  const T Planck=_options.Planck;
1577  const T h3bm4u3=pow(Planck,3)/ pow(molwt,4)*rho_init/pow(u_init,3);
1578  //cout << "h3bm4u3 " << h3bm4u3 <<endl;
1579  //cout <<" u_init "<<u_init<<" rho_init "<<rho_init<<endl;
1580  const Mesh& mesh = *_meshes[n];
1581  const StorageSite& cells = mesh.getCells();
1582  const int nCells = cells.getCount();
1583  const TArray& wts= dynamic_cast<const TArray&>(*_quadrature.dcxyzPtr);
1584  TArray& Entropy = dynamic_cast<TArray&>(_macroFields.Entropy[cells]);
1585  TArray& EntropyGenRate_Collisional = dynamic_cast<TArray&>(_macroFields.EntropyGenRate_Collisional[cells]);
1586  TArray& collisionFrequency = dynamic_cast<TArray&>(_macroFields.collisionFrequency[cells]);
1587  for(int c=0; c<nCells;c++){
1588  Entropy[c]=0.0;EntropyGenRate_Collisional[c]=0.0;
1589  }
1590  const int num_directions = _quadrature.getDirCount();
1591  if (_options.fgamma ==2){
1592  for(int j=0;j<num_directions;j++){
1593  Field& fnd = *_dsfPtr.dsf[j];
1594  Field& feqES = *_dsfEqPtrES.dsf[j]; //for fgamma_2
1595  const TArray& f = dynamic_cast<const TArray&>(fnd[cells]);
1596  const TArray& fgam = dynamic_cast<const TArray&>(feqES[cells]);
1597  for(int c=0; c<nCells;c++){
1598  Entropy[c]=Entropy[c]+f[c]*wts[j]*(1-log(h3bm4u3*f[c]));
1599  EntropyGenRate_Collisional[c]+= (f[c]-fgam[c])*collisionFrequency[c]*log(h3bm4u3*f[c])*wts[j];
1600  }
1601  }
1602  }
1603  else{
1604  for(int j=0;j<num_directions;j++){
1605  Field& fnd = *_dsfPtr.dsf[j];
1606  Field& feq = *_dsfEqPtr.dsf[j];
1607  const TArray& f = dynamic_cast<const TArray&>(fnd[cells]);
1608  const TArray& fgam = dynamic_cast<const TArray&>(feq[cells]);
1609  for(int c=0; c<nCells;c++){
1610  Entropy[c]=Entropy[c]+f[c]*wts[j]*(1-log(h3bm4u3*f[c]));
1611  EntropyGenRate_Collisional[c]+=(f[c]-fgam[c])*collisionFrequency[c]*(log(h3bm4u3*f[c]))*wts[j];
1612  }
1613  }
1614  }
1615 
1616 
1617  }
1618  }
Quadrature< T > & _quadrature
Array< T > TArray
Definition: Field.h:14
Field EntropyGenRate_Collisional
Definition: MacroFields.h:35
Definition: Mesh.h:49
COMETModelOptions< T > _options
Field Entropy
Definition: MacroFields.h:33
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
DistFunctFields< T > _dsfEqPtrES
DistFunctFields< T > _dsfPtr
int getCount() const
Definition: StorageSite.h:39
Field collisionFrequency
Definition: MacroFields.h:24
DistFunctFields< T > _dsfEqPtr
template<class T >
void COMETModel< T >::equilibrate ( )
inline

Definition at line 3606 of file phononbase/COMETModel.h.

References COMETModel< T >::_kspaces, COMETModel< T >::_macro, Model::_meshes, COMETModel< T >::_MeshKspaceMap, pmode< T >::calce0(), Mesh::getCells(), StorageSite::getCount(), pmode< T >::getfield(), Kspace< T >::getkvol(), Kspace< T >::getlength(), kvol< T >::getmode(), kvol< T >::getmodenum(), and PhononMacro::temperature.

3607  {
3608  const int numMeshes = _meshes.size();
3609  for (int n=0; n<numMeshes; n++)
3610  {
3611  const Mesh& mesh=*_meshes[n];
3612  Tkspace& kspace=*_kspaces[_MeshKspaceMap[n]];
3613  const StorageSite& cells=mesh.getCells();
3614  const int numcells=cells.getCount();
3615  const TArray& Tl=dynamic_cast<const TArray&>(_macro.temperature[cells]);
3616  const int len=kspace.getlength();
3617 
3618  for(int k=0;k<len;k++)
3619  {
3620  Tkvol& kvol=kspace.getkvol(k);
3621  const int modes=kvol.getmodenum();
3622  for(int m=0;m<modes;m++)
3623  {
3624  Tmode& mode=kvol.getmode(m);
3625  Field& eField=mode.getfield();
3626  TArray& eArray=dynamic_cast<TArray&>(eField[cells]);
3627  for(int c=0;c<numcells;c++)
3628  eArray[c]=mode.calce0(Tl[c]);
3629  }
3630  }
3631  }
3632  }
Array< T > TArray
Definition: Field.h:14
Field temperature
Definition: PhononMacro.h:21
Definition: Mesh.h:49
int getmodenum()
Definition: kvol.h:43
PhononMacro & _macro
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
MeshKspaceMap _MeshKspaceMap
int getCount() const
Definition: StorageSite.h:39
Kspace< T > Tkspace
Definition: kvol.h:14
template<class T >
void COMETModel< T >::EquilibriumDistributionBGK ( )
inline

Definition at line 1748 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfEqPtr, COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_options, COMETModel< T >::_quadrature, MacroFields::coeff, Mesh::getCells(), StorageSite::getCount(), COMETModel< T >::NewtonsMethodBGK(), and MacroFields::velocity.

Referenced by COMETModel< T >::cycle(), and COMETModel< T >::smooth().

1749  {
1750  const int ktrial=_options.NewtonsMethod_ktrial;
1751  const int numMeshes = _meshes.size();
1752  for (int n=0; n<numMeshes; n++)
1753  {
1754  const Mesh& mesh = *_meshes[n];
1755  const StorageSite& cells = mesh.getCells();
1756  const int nCells = cells.getCount();
1757 
1758  //const double pi=_options.pi;
1759  //const TArray& density = dynamic_cast<const TArray&>(_macroFields.density[cells]);
1760  //const TArray& temperature = dynamic_cast<const TArray&>(_macroFields.temperature[cells]);
1761 
1762  //initialize coeff
1763  VectorT5Array& coeff = dynamic_cast<VectorT5Array&>(_macroFields.coeff[cells]);
1764 
1765  /*
1766  for(int c=0; c<nCells;c++){
1767  coeff[c][0]=density[c]/pow((pi*temperature[c]),1.5);
1768  coeff[c][1]=1/temperature[c];
1769  coeff[c][2]=0.0;
1770  coeff[c][3]=0.0;
1771  coeff[c][4]=0.0;
1772  }
1773  */
1774  const VectorT3Array& v = dynamic_cast<const VectorT3Array&>(_macroFields.velocity[cells]);
1775  const TArray& cx = dynamic_cast<const TArray&>(*_quadrature.cxPtr);
1776  const TArray& cy = dynamic_cast<const TArray&>(*_quadrature.cyPtr);
1777  const TArray& cz = dynamic_cast<const TArray&>(*_quadrature.czPtr);
1778  const int numFields= _quadrature.getDirCount();
1779 
1780  //call Newtons Method
1781 
1782  NewtonsMethodBGK(ktrial);
1783 
1784  //calculate perturbed maxwellian for BGK
1785  for(int j=0;j< numFields;j++){
1786  Field& fndEq = *_dsfEqPtr.dsf[j];
1787  TArray& fEq = dynamic_cast< TArray&>(fndEq[cells]);
1788  for(int c=0; c<nCells;c++){
1789  fEq[c]=coeff[c][0]*exp(-coeff[c][1]*(pow(cx[j]-v[c][0],2)+pow(cy[j]-v[c][1],2)
1790  +pow(cz[j]-v[c][2],2))+coeff[c][2]*(cx[j]-v[c][0])
1791  +coeff[c][3]*(cy[j]-v[c][1])+coeff[c][4]*(cz[j]-v[c][2]));
1792  }
1793 
1794  }
1795  }
1796  }
Quadrature< T > & _quadrature
Array< T > TArray
Definition: Field.h:14
Definition: Mesh.h:49
COMETModelOptions< T > _options
Field coeff
Definition: MacroFields.h:31
void NewtonsMethodBGK(const int ktrial)
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
Field velocity
Definition: MacroFields.h:15
int getCount() const
Definition: StorageSite.h:39
DistFunctFields< T > _dsfEqPtr
Array< VectorT5 > VectorT5Array
template<class T >
void COMETModel< T >::EquilibriumDistributionESBGK ( )
inline

Definition at line 1953 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfEqPtrES, COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_options, COMETModel< T >::_quadrature, MacroFields::coeffg, COMETModel< T >::ComputeMacroparametersESBGK(), Mesh::getCells(), StorageSite::getCount(), COMETModel< T >::NewtonsMethodESBGK(), and MacroFields::velocity.

Referenced by COMETModel< T >::cycle(), and COMETModel< T >::smooth().

1954  {
1956  const int ktrial=_options.NewtonsMethod_ktrial;
1957  const int numMeshes = _meshes.size();
1958  for (int n=0; n<numMeshes; n++)
1959  {
1960  const Mesh& mesh = *_meshes[n];
1961  const StorageSite& cells = mesh.getCells();
1962  const int nCells = cells.getCount();
1963 
1964 
1965  //const VectorT5Array& coeff = dynamic_cast<const VectorT5Array&>(_macroFields.coeff[cells]);
1966  //initialize coeffg
1967  VectorT10Array& coeffg = dynamic_cast<VectorT10Array&>(_macroFields.coeffg[cells]);
1968  /*
1969  for(int c=0; c<nCells;c++){
1970  coeffg[c][0]=coeff[c][0];
1971  coeffg[c][1]=coeff[c][1];
1972  coeffg[c][2]=coeff[c][2];
1973  coeffg[c][3]=coeff[c][1];
1974  coeffg[c][4]=coeff[c][3];
1975  coeffg[c][5]=coeff[c][1];
1976  coeffg[c][6]=coeff[c][4];
1977  coeffg[c][7]=0.0;
1978  coeffg[c][8]=0.0;
1979  coeffg[c][9]=0.0;
1980  }
1981  */
1982  const VectorT3Array& v = dynamic_cast<const VectorT3Array&>(_macroFields.velocity[cells]);
1983  const TArray& cx = dynamic_cast<const TArray&>(*_quadrature.cxPtr);
1984  const TArray& cy = dynamic_cast<const TArray&>(*_quadrature.cyPtr);
1985  const TArray& cz = dynamic_cast<const TArray&>(*_quadrature.czPtr);
1986  const int numFields= _quadrature.getDirCount();
1987 
1988  NewtonsMethodESBGK(ktrial);
1989 
1990  for(int j=0;j< numFields;j++){
1991  Field& fndEqES = *_dsfEqPtrES.dsf[j];
1992  TArray& fEqES = dynamic_cast< TArray&>(fndEqES[cells]);
1993  for(int c=0; c<nCells;c++){
1994  T Cc1=(cx[j]-v[c][0]);
1995  T Cc2=(cy[j]-v[c][1]);
1996  T Cc3=(cz[j]-v[c][2]);
1997  fEqES[c]=coeffg[c][0]*exp(-coeffg[c][1]*pow(Cc1,2)+coeffg[c][2]*Cc1
1998  -coeffg[c][3]*pow(Cc2,2)+coeffg[c][4]*Cc2
1999  -coeffg[c][5]*pow(Cc3,2)+coeffg[c][6]*Cc3
2000  +coeffg[c][7]*cx[j]*cy[j]+coeffg[c][8]*cy[j]*cz[j]
2001  +coeffg[c][9]*cz[j]*cx[j]);
2002  }
2003 
2004  }
2005  }
2006  }
Field coeffg
Definition: MacroFields.h:32
Quadrature< T > & _quadrature
Array< T > TArray
Definition: Field.h:14
Definition: Mesh.h:49
COMETModelOptions< T > _options
void NewtonsMethodESBGK(const int ktrial)
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
void ComputeMacroparametersESBGK()
DistFunctFields< T > _dsfEqPtrES
Array< VectorT10 > VectorT10Array
Field velocity
Definition: MacroFields.h:15
int getCount() const
Definition: StorageSite.h:39
template<class T >
int COMETModel< T >::FinishCoarseMesh ( const MeshList inMeshes,
GeomFields inGeomFields,
MeshList outMeshes,
IntArray CoarseCounts,
map< const StorageSite *, IntArray * > &  PreFacePairMap,
IntArray coarseGhost 
)
inline

needs to be changed

Definition at line 1663 of file phononbase/COMETModel.h.

References COMETModel< T >::_bcMap, Field::addArray(), GeomFields::area, GeomFields::areaMag, GeomFields::coordinate, Mesh::createBoundaryFaceGroup(), Mesh::createInterfaceGroup(), Mesh::createInteriorFaceGroup(), GeomFields::fineToCoarse, Mesh::getBoundaryFaceGroups(), Mesh::getCells(), StorageSite::getCount(), Mesh::getFaceCells(), Mesh::getFaces(), StorageSite::getGatherMap(), StorageSite::getGatherProcID(), Array< T >::getLength(), StorageSite::getOffset(), StorageSite::getSelfCount(), FaceGroup::groupType, FaceGroup::id, Mesh::setConnectivity(), StorageSite::setCount(), FaceGroup::site, sqrt(), GeomFields::volume, and Array< T >::zero().

Referenced by COMETModel< T >::MakeCoarseModel().

1667  {
1668 
1669  const int numMeshes=inMeshes.size();
1670 
1671  int smallestMesh=-1;
1672 
1673  for(int n=0;n<numMeshes;n++)
1674  {
1675  const Mesh& mesh=*inMeshes[n];
1676  Mesh* newMeshPtr=outMeshes[n];
1677  //int coarseCount=CoarseCounts[n];
1678  const StorageSite& inCells=mesh.getCells();
1679  IntArray& FineToCoarse=dynamic_cast<IntArray&>(inGeomFields.fineToCoarse[inCells]);
1680  StorageSite& outCells=newMeshPtr->getCells();
1681  StorageSite& outFaces=newMeshPtr->getFaces();
1682  const StorageSite& inFaces=mesh.getFaces();
1683  const int inCellTotal=inCells.getCount();
1684  const int inFaceCount=inFaces.getCount();
1685 
1686  const CRConnectivity& inFaceinCells=mesh.getFaceCells(inFaces);
1687  Field& areaMagField=inGeomFields.areaMag;
1688  const TArray& areaMagArray=
1689  dynamic_cast<const TArray&>(areaMagField[inFaces]);
1690 
1691  Field& FaceAreaField=inGeomFields.area;
1692  const VectorT3Array& inFA=
1693  dynamic_cast<const VectorT3Array&>(FaceAreaField[inFaces]);
1694 
1695  //make the coarse cell to fine cell connectivity.
1696  outCells.setCount(CoarseCounts[n],coarseGhost[n]-CoarseCounts[n]);
1697  CRPtr CoarseToFineCells=CRPtr(new CRConnectivity(outCells,inCells));
1698  CoarseToFineCells->initCount();
1699 
1700  for(int c=0;c<inCellTotal;c++)
1701  CoarseToFineCells->addCount(FineToCoarse[c],1);
1702 
1703  CoarseToFineCells->finishCount();
1704 
1705  for(int c=0;c<inCellTotal;c++)
1706  CoarseToFineCells->add(FineToCoarse[c],c);
1707 
1708  CoarseToFineCells->finishAdd();
1709 
1710  //connectivity between itself (cells) and its finer mesh cells.
1711  newMeshPtr->setConnectivity(outCells,inCells,CoarseToFineCells);
1712 
1713  CRPtr FineFacesCoarseCells=CRPtr(new CRConnectivity(inFaces,outCells));
1714  FineFacesCoarseCells->initCount();
1715 
1716  //count surviving faces
1717  for(int f=0;f<inFaceCount;f++)
1718  {
1719  int coarse0=FineToCoarse[inFaceinCells(f,0)];
1720  int coarse1=FineToCoarse[inFaceinCells(f,1)];
1721  if(coarse0!=coarse1)
1722  FineFacesCoarseCells->addCount(f,2);
1723  }
1724 
1725  FineFacesCoarseCells->finishCount();
1726 
1727  //make non-zero's
1728  for(int f=0;f<inFaceCount;f++)
1729  {
1730  int fc0=inFaceinCells(f,0);
1731  int fc1=inFaceinCells(f,1);
1732  int cc0=FineToCoarse[fc0];
1733  int cc1=FineToCoarse[fc1];
1734  if(cc0!=cc1)
1735  {
1736  FineFacesCoarseCells->add(f,cc0);
1737  FineFacesCoarseCells->add(f,cc1);
1738  }
1739  }
1740 
1741  FineFacesCoarseCells->finishAdd();
1742 
1743  CRPtr CoarseCellsFineFaces=FineFacesCoarseCells->getTranspose();
1744  CRPtr CellCellCoarse=CoarseCellsFineFaces->multiply(*FineFacesCoarseCells,true);
1745 
1746  int counter=0; //coarse face counter
1747  BArray counted(outCells.getCount());
1748  counted=false;
1749  for(int c=0;c<outCells.getCount();c++)
1750  {
1751  counted[c]=true;
1752  const int neibs=CellCellCoarse->getCount(c);
1753 
1754  for(int n=0;n<neibs;n++)
1755  {
1756  const int c1=(*CellCellCoarse)(c,n);
1757  if(neibs>1)
1758  {
1759  if(!counted[c1])
1760  {
1761  counter++;
1762  }
1763  }
1764  else //gives two faces to cells with 1 neighbor
1765  {
1766  if(c>=outCells.getSelfCount())
1767  {
1768  if(!counted[c1])
1769  counter++;
1770  }
1771  else //interior cells
1772  {
1773  if(counted[c1])
1774  counter++;
1775  else
1776  counter+=2;
1777  }
1778  }
1779  }
1780  }
1781 
1782  outFaces.setCount(counter);
1783 
1784  CRPtr CoarseCellCoarseFace=CRPtr(new CRConnectivity(outCells,outFaces));
1785  CoarseCellCoarseFace->initCount();
1786 
1787  int tempCount(0);
1788  for(int c=0;c<outCells.getCount();c++)
1789  {
1790  const int neibs=CellCellCoarse->getCount(c);
1791  CoarseCellCoarseFace->addCount(c,neibs);
1792  tempCount+=neibs;
1793  if((neibs==1) && (c<outCells.getSelfCount())) //adding 2 faces to cells with one neighbor
1794  {
1795  CoarseCellCoarseFace->addCount(c,neibs);
1796  tempCount+=neibs;
1797  }
1798  }
1799 
1800  CoarseCellCoarseFace->finishCount();
1801 
1802  //make cell connectivity to interior faces.
1803  counter=0;
1804  counted=false;
1805  for(int c=0;c<outCells.getSelfCount();c++)
1806  {
1807  counted[c]=true;
1808  const int neibs=CellCellCoarse->getCount(c);
1809  for(int n=0;n<neibs;n++)
1810  {
1811  const int c1=(*CellCellCoarse)(c,n);
1812  if(neibs>1)
1813  {
1814  if(!counted[c1] && c1<outCells.getSelfCount())
1815  {
1816  CoarseCellCoarseFace->add(c,counter);
1817  CoarseCellCoarseFace->add(c1,counter);
1818  counter++;
1819  }
1820  }
1821  else
1822  {
1823  if(counted[c1] && c1<outCells.getSelfCount())
1824  {
1825  CoarseCellCoarseFace->add(c,counter);
1826  CoarseCellCoarseFace->add(c1,counter);
1827  counter++;
1828  }
1829  else if(!counted[c1] && c1<outCells.getSelfCount())
1830  {
1831  CoarseCellCoarseFace->add(c,counter);
1832  CoarseCellCoarseFace->add(c1,counter);
1833  counter++;
1834  CoarseCellCoarseFace->add(c,counter);
1835  CoarseCellCoarseFace->add(c1,counter);
1836  counter++;
1837  }
1838  }
1839  }
1840  }
1841 
1842  const int coarseInteriorCount=counter;
1843 
1844  //cell connectivity to boundary faces
1845  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
1846  {
1847  const FaceGroup& fg=*fgPtr;
1848  //const int faceCount=fg.site.getCount();
1849  const CRConnectivity& inBfaceCells=mesh.getFaceCells(fg.site);
1850 
1851  if(fg.id>0)
1852  {
1853  int faceCount(0);
1854  if(_bcMap[fg.id]->bcType == "Interface")
1855  {
1856  IntArray& FaceFine2Coarse=*PreFacePairMap[&fg.site];
1857  int coarseFaces(0);
1858  for(int i=0;i<fg.site.getCount();i++)
1859  if(FaceFine2Coarse[i]>coarseFaces)
1860  coarseFaces=FaceFine2Coarse[i];
1861  faceCount=coarseFaces+1;
1862 
1863  BArray countedFaces(faceCount);
1864  countedFaces=false;
1865  for(int i=0;i<fg.site.getCount();i++)
1866  {
1867  const int coarseFace=FaceFine2Coarse[i];
1868  if(!countedFaces[coarseFace])
1869  {
1870  const int globFace=i+fg.site.getOffset();
1871  const int cc1=(*FineFacesCoarseCells)(globFace,0);
1872  const int cc2=(*FineFacesCoarseCells)(globFace,1);
1873  CoarseCellCoarseFace->add(cc1,counter);
1874  CoarseCellCoarseFace->add(cc2,counter);
1875  counter++;
1876  countedFaces[coarseFace]=true;
1877  }
1878  }
1879 
1880  }
1881  else
1882  {
1883  faceCount=fg.site.getCount();
1884  for(int i=0;i<faceCount;i++)
1885  {
1886  const int c1=inBfaceCells(i,1); //fine ghost cell
1887  const int cc1=FineToCoarse[c1]; //coarse ghost cell
1888  const int cc2=(*CellCellCoarse)(cc1,0); //coarse interior cell
1889  CoarseCellCoarseFace->add(cc1,counter);
1890  CoarseCellCoarseFace->add(cc2,counter);
1891  counter++;
1892  }
1893  }
1894  }
1895  }
1896 
1897  // have to count coarse interfaces (parallel) -- !!
1898 
1899  foreach(const StorageSite::GatherMap::value_type pos, outCells.getGatherMap())
1900  {
1901  const StorageSite& oSite = *pos.first;
1902  const Array<int>& toIndices = *pos.second;
1903 
1904  int to_where = oSite.getGatherProcID();
1905  if ( to_where != -1 )
1906  {
1907  const int fgCount=toIndices.getLength();
1908 
1909  for(int i=0;i<fgCount;i++)
1910  {
1911  const int c1=toIndices[i];
1912  const int c1neibs=CellCellCoarse->getCount(c1);
1913  for(int j=0;j<c1neibs;j++)
1914  {
1915  const int c2=(*CellCellCoarse)(toIndices[i],j);
1916  CoarseCellCoarseFace->add(c2,counter);
1917  CoarseCellCoarseFace->add(toIndices[i],counter);
1918  counter++;
1919  }
1920  }
1921  }
1922  }
1923 
1924  CoarseCellCoarseFace->finishAdd();
1925 
1926  CRPtr CoarseFaceCoarseCell=CoarseCellCoarseFace->getTranspose();
1927 
1928  newMeshPtr->setConnectivity(outCells,outFaces,CoarseCellCoarseFace);
1929  newMeshPtr->setConnectivity(outFaces,outCells,CoarseFaceCoarseCell);
1930 
1931  CRPtr CoarseFacesFineFaces=CRPtr(new CRConnectivity(outFaces,inFaces));
1932  CoarseFacesFineFaces->initCount();
1933 
1934  VectorT3Array areaSum(outFaces.getCount());
1935  areaSum.zero();
1936 
1937  for(int f=0;f<inFaceCount;f++)
1938  {
1939  int fc0=inFaceinCells(f,0);
1940  int fc1=inFaceinCells(f,1);
1941  const int cc0=FineToCoarse[fc0];
1942  const int cc1=FineToCoarse[fc1];
1943 
1944  int cc0neibs=CellCellCoarse->getCount(cc0);
1945  int cc1neibs=CellCellCoarse->getCount(cc1);
1946 
1947  if(cc0>=outCells.getSelfCount())
1948  cc0neibs++;
1949  if(cc1>=outCells.getSelfCount())
1950  cc1neibs++;
1951 
1952  if(cc1!=cc0)
1953  {
1954  const int cfaces=CoarseCellCoarseFace->getCount(cc0);
1955 
1956  for(int cf=0;cf<cfaces;cf++)
1957  {
1958  const int face=(*CoarseCellCoarseFace)(cc0,cf);
1959  const int tempc0=(*CoarseFaceCoarseCell)(face,0);
1960  const int tempc1=(*CoarseFaceCoarseCell)(face,1);
1961 
1962  if(((cc0==tempc0)&&(cc1==tempc1))||((cc1==tempc0)&&(cc0==tempc1)))
1963  {
1964  T sign(0);
1965 
1966  if(cc1==tempc0)
1967  sign*=-1.;
1968 
1969  areaSum[face]+=inFA[f]*sign;
1970 
1971  if(cc1neibs>1 && cc0neibs>1)
1972  {
1973  CoarseFacesFineFaces->addCount(face,1);
1974  break;
1975  }
1976  else
1977  {
1978  T sumMag=sqrt(areaSum[face][0]*areaSum[face][0]+
1979  areaSum[face][1]*areaSum[face][1]+
1980  areaSum[face][2]*areaSum[face][2]);
1981 
1982  T partMag=sqrt(inFA[f][0]*inFA[f][0]+
1983  inFA[f][1]*inFA[f][1]+
1984  inFA[f][2]*inFA[f][2]);
1985 
1986  if(sumMag/partMag>.75)
1987  {
1988  CoarseFacesFineFaces->addCount(face,1);
1989  break;
1990  }
1991  else
1992  areaSum[face]-=inFA[f]*sign;
1993 
1994  }
1995  }
1996  }
1997  }
1998  }
1999 
2000  CoarseFacesFineFaces->finishCount();
2001 
2002  areaSum.zero();
2003 
2004  for(int f=0;f<inFaceCount;f++)
2005  {
2006  int fc0=inFaceinCells(f,0);
2007  int fc1=inFaceinCells(f,1);
2008  const int cc0=FineToCoarse[fc0];
2009  const int cc1=FineToCoarse[fc1];
2010 
2011  int cc0neibs=CellCellCoarse->getCount(cc0);
2012  int cc1neibs=CellCellCoarse->getCount(cc1);
2013 
2014  if(cc0>=outCells.getSelfCount())
2015  cc0neibs++;
2016  if(cc1>=outCells.getSelfCount())
2017  cc1neibs++;
2018 
2019  if(cc1!=cc0)
2020  {
2021  const int cfaces=CoarseCellCoarseFace->getCount(cc0);
2022 
2023  for(int cf=0;cf<cfaces;cf++)
2024  {
2025  const int face=(*CoarseCellCoarseFace)(cc0,cf);
2026  const int tempc0=(*CoarseFaceCoarseCell)(face,0);
2027  const int tempc1=(*CoarseFaceCoarseCell)(face,1);
2028 
2029  if(((cc0==tempc0)&&(cc1==tempc1))||((cc1==tempc0)&&(cc0==tempc1)))
2030  {
2031 
2032  T sign(1);
2033  if(cc1==tempc0)
2034  sign*=-1.;
2035 
2036  areaSum[face]+=inFA[f]*sign;
2037 
2038  if(cc1neibs>1 && cc0neibs>1)
2039  {
2040  CoarseFacesFineFaces->add(face,f);
2041  break;
2042  }
2043  else
2044  {
2045  T sumMag=sqrt(areaSum[face][0]*areaSum[face][0]+
2046  areaSum[face][1]*areaSum[face][1]+
2047  areaSum[face][2]*areaSum[face][2]);
2048 
2049  T partMag=sqrt(inFA[f][0]*inFA[f][0]+
2050  inFA[f][1]*inFA[f][1]+
2051  inFA[f][2]*inFA[f][2]);
2052 
2053  if(sumMag/partMag>.75)
2054  {
2055  CoarseFacesFineFaces->add(face,f);
2056  break;
2057  }
2058  else
2059  areaSum[face]-=inFA[f]*sign;
2060  }
2061  }
2062  }
2063  }
2064  }
2065 
2066  CoarseFacesFineFaces->finishAdd();
2067 
2068  //const StorageSite& interiorFaces=
2069  newMeshPtr->createInteriorFaceGroup(coarseInteriorCount);
2070 
2071  int inOffset=coarseInteriorCount;
2072  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
2073  {
2074  const FaceGroup& fg=*fgPtr;
2075  const int faceCount=fg.site.getCount();
2076  if(fg.id>0)
2077  {
2078  if(_bcMap[fg.id]->bcType == "Interface")
2079  {
2080  IntArray& FaceFine2Coarse=*PreFacePairMap[&fg.site];
2081  int coarseFaces(0);
2082  for(int i=0;i<faceCount;i++)
2083  if(FaceFine2Coarse[i]>coarseFaces)
2084  coarseFaces=FaceFine2Coarse[i];
2085 
2086  coarseFaces+=1;
2087 
2088  //const StorageSite& newBoundarySite=
2089  newMeshPtr->createBoundaryFaceGroup(coarseFaces,inOffset,fg.id,fg.groupType);
2090  inOffset+=coarseFaces;
2091  }
2092  else
2093  {
2094  const int size=fg.site.getCount();
2095  const StorageSite& newBoundarySite=newMeshPtr->createBoundaryFaceGroup(
2096  size,inOffset,fg.id,fg.groupType);
2097  const VectorT3Array& oldFgCoords=dynamic_cast<const VectorT3Array&>(inGeomFields.coordinate[fg.site]);
2098  VT3Ptr newFgCoordsPtr=VT3Ptr(new VectorT3Array(size));
2099  (*newFgCoordsPtr)=oldFgCoords;
2100  inGeomFields.coordinate.addArray(newBoundarySite,newFgCoordsPtr);
2101  inOffset+=size;
2102  }
2103  }
2104  }
2105 
2106  // have to make coarse interface face groups -- !!
2107 
2108  const StorageSite::GatherMap& coarseGatherMap = outCells.getGatherMap();
2109 
2110  foreach(const StorageSite::GatherMap::value_type pos, coarseGatherMap)
2111  {
2112  const StorageSite& oSite = *pos.first;
2113  const Array<int>& toIndices = *pos.second;
2114 
2115  int to_where = oSite.getGatherProcID();
2116  if ( to_where != -1 )
2117  {
2118  const int cellCount=toIndices.getLength();
2119  int faceCount(0);
2120 
2121  for(int i=0;i<cellCount;i++)
2122  {
2123  const int c1=toIndices[i];
2124  faceCount+=CellCellCoarse->getCount(c1);
2125  }
2126 
2127 
2128  newMeshPtr->createInterfaceGroup(faceCount,inOffset,to_where);
2129  inOffset+=faceCount;
2130  }
2131  }
2132 
2133  //now make the geom fields
2134  const int outCellsCount=outCells.getSelfCount();
2135  const int outCellsTotCount=outCells.getCount();
2136  VT3Ptr outCellCoordsPtr=VT3Ptr(new VectorT3Array(outCellsTotCount));
2137  TArrptr outCellVolumePtr=TArrptr(new TArray(outCellsTotCount));
2138  TArray& outCV=*outCellVolumePtr;
2139  VectorT3Array& outCoords=*outCellCoordsPtr;
2140  outCV=0.;
2141 
2142  Field& VolumeField=inGeomFields.volume;
2143  const TArray& inCV=dynamic_cast<const TArray&>(VolumeField[inCells]);
2144  const VectorT3Array& inCoords=dynamic_cast<const VectorT3Array&>(inGeomFields.coordinate[inCells]);
2145 
2146  for(int c=0;c<outCellsCount;c++)
2147  {
2148  const int fineCount=CoarseToFineCells->getCount(c);
2149  VectorT3 newCoord;
2150  newCoord[0]=0.;
2151  newCoord[1]=0.;
2152  newCoord[2]=0.;
2153  for(int i=0;i<fineCount;i++)
2154  {
2155  int fc=(*CoarseToFineCells)(c,i);
2156  outCV[c]+=inCV[fc];
2157  newCoord+=inCoords[fc]*inCV[fc];
2158  }
2159  outCoords[c]=newCoord/outCV[c];
2160  }
2161 
2162  for(int c=outCellsCount;c<outCellsTotCount;c++)
2163  {
2164  const int fineCount=CoarseToFineCells->getCount(c);
2165  VectorT3 newCoord;
2166  newCoord[0]=0.;
2167  newCoord[1]=0.;
2168  newCoord[2]=0.;
2169  for(int i=0;i<fineCount;i++)
2170  {
2171  int fc=(*CoarseToFineCells)(c,i);
2172  newCoord+=inCoords[fc];
2173  }
2174  outCoords[c]=newCoord;
2175  }
2176 
2177  VolumeField.addArray(outCells,outCellVolumePtr);
2178  inGeomFields.coordinate.addArray(outCells,outCellCoordsPtr);
2179 
2180  const int outFacesCount=outFaces.getCount();
2181  VT3Ptr outFaceAreaPtr=VT3Ptr(new VectorT3Array(outFacesCount));
2182  VectorT3Array& outFA=*outFaceAreaPtr;
2183  TArrptr outFaceAreaMagPtr=TArrptr(new TArray(outFacesCount));
2184  TArray& outFAMag=*outFaceAreaMagPtr;
2185 
2186  VectorT3 myZero;
2187  myZero[0]=0.;
2188  myZero[1]=0.;
2189  myZero[2]=0.;
2190 
2191  outFA=myZero;
2192  outFAMag=0.;
2193  for(int f=0;f<outFacesCount;f++)
2194  {
2195  const int fineCount=CoarseFacesFineFaces->getCount(f);
2196  const int cCell0=(*CoarseFaceCoarseCell)(f,0);
2197  for(int i=0;i<fineCount;i++)
2198  {
2199  const int fFace=(*CoarseFacesFineFaces)(f,i);
2200  const int fCell0=inFaceinCells(fFace,0);
2201  const int CCell0=FineToCoarse[fCell0];
2202 
2203  //must make sure the area vector is pointing
2204  //from c0 to c1
2205  if(CCell0==cCell0)
2206  outFA[f]+=inFA[fFace];
2207  else
2208  outFA[f]-=inFA[fFace];
2209  outFAMag[f]+=areaMagArray[fFace];
2210  }
2211  }
2212 
2213  FaceAreaField.addArray(outFaces,outFaceAreaPtr);
2214  areaMagField.addArray(outFaces,outFaceAreaMagPtr);
2215  //cout<<"Level: "<<_level+1<<" Mesh: "<<n<<" Cells: "<<outCells.getSelfCount()<<endl;
2216 
2217  if(smallestMesh<0)
2218  smallestMesh=outCells.getSelfCount();
2219  else
2220  {
2221  if(outCells.getSelfCount()<smallestMesh)
2222  smallestMesh=outCells.getSelfCount();
2223  }
2224 
2225  /*
2226  //This is for checking purposes only
2227  cout<<"Coarse Faces to Fine Faces"<<endl;
2228  for(int f=0;f<outFaces.getCount();f++)
2229  {
2230  const int neibs=CoarseFacesFineFaces->getCount(f);
2231  for(int n=0;n<neibs;n++)
2232  cout<<f<<" "<<(*CoarseFacesFineFaces)(f,n)<<endl;
2233  cout<<endl;
2234  }
2235  cout<<"Coarse Cells to Coarse Faces"<<endl;
2236  for(int c=0;c<outCells.getCount();c++)
2237  {
2238  const int neibs=CoarseCellCoarseFace->getCount(c);
2239  for(int n=0;n<neibs;n++)
2240  cout<<c<<" "<<(*CoarseCellCoarseFace)(c,n)<<endl;
2241  cout<<endl;
2242  }
2243  */
2244  }
2245 
2246  return smallestMesh;
2247  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
virtual void zero()
Definition: Array.h:281
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
int getSelfCount() const
Definition: StorageSite.h:40
Field coordinate
Definition: GeomFields.h:19
Definition: Mesh.h:28
shared_ptr< TArray > TArrptr
Array< T > TArray
Definition: Field.h:14
const StorageSite & createInteriorFaceGroup(const int size)
Definition: Mesh.cpp:259
Definition: Mesh.h:49
void setCount(const int selfCount, const int nGhost=0)
Definition: StorageSite.h:42
void setConnectivity(const StorageSite &rowSite, const StorageSite &colSite, shared_ptr< CRConnectivity > conn)
Definition: Mesh.cpp:352
const StorageSite & createBoundaryFaceGroup(const int size, const int offset, const int id, const string &boundaryType)
Definition: Mesh.cpp:278
string groupType
Definition: Mesh.h:42
Field fineToCoarse
Definition: GeomFields.h:41
Tangent sqrt(const Tangent &a)
Definition: Tangent.h:317
const int id
Definition: Mesh.h:41
Array< VectorT3 > VectorT3Array
const StorageSite & createInterfaceGroup(const int size, const int offset, const int id)
Definition: Mesh.cpp:268
int getGatherProcID() const
Definition: StorageSite.h:83
const StorageSite & getFaces() const
Definition: Mesh.h:108
const StorageSite & getCells() const
Definition: Mesh.h:109
Field volume
Definition: GeomFields.h:26
shared_ptr< CRConnectivity > CRPtr
void addArray(const StorageSite &, shared_ptr< ArrayBase > a)
Definition: Field.cpp:72
const CRConnectivity & getFaceCells(const StorageSite &site) const
Definition: Mesh.cpp:388
Array< bool > BArray
shared_ptr< VectorT3Array > VT3Ptr
int getOffset() const
Definition: StorageSite.h:87
const GatherMap & getGatherMap() const
Definition: StorageSite.h:59
int getCount() const
Definition: StorageSite.h:39
Array< int > IntArray
Field area
Definition: GeomFields.h:23
map< const StorageSite *, shared_ptr< Array< int > > > GatherMap
Definition: StorageSite.h:24
Field areaMag
Definition: GeomFields.h:25
StorageSite site
Definition: Mesh.h:40
int getLength() const
Definition: Array.h:87
template<class T >
T COMETModel< T >::getAverageTemperature ( )
inline

Definition at line 4197 of file phononbase/COMETModel.h.

References COMETModel< T >::_geomFields, COMETModel< T >::_macro, Model::_meshes, Mesh::getCells(), StorageSite::getSelfCount(), PhononMacro::temperature, and GeomFields::volume.

4198  {
4199  const int numMeshes = _meshes.size();
4200  T r(0);
4201  T volTot(0);
4202  for (int n=0; n<numMeshes; n++)
4203  {
4204  const Mesh& mesh=*_meshes[n];
4205  const StorageSite& cells=mesh.getCells();
4206  const int numcells=cells.getSelfCount();
4207  const TArray& Tl=dynamic_cast<const TArray&>(_macro.temperature[cells]);
4208  const TArray& cv=dynamic_cast<const TArray&>(_geomFields.volume[cells]);
4209  for(int c=0;c<numcells;c++)
4210  {
4211  r+=Tl[c]*cv[c];
4212  volTot+=cv[c];
4213  }
4214  }
4215  return r/volTot;
4216  }
GeomFields & _geomFields
int getSelfCount() const
Definition: StorageSite.h:40
Array< T > TArray
Field temperature
Definition: PhononMacro.h:21
Definition: Mesh.h:49
PhononMacro & _macro
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
Field volume
Definition: GeomFields.h:26
template<class T >
COMETBCMap& COMETModel< T >::getBCMap ( )
inline
template<class T >
COMETBCMap& COMETModel< T >::getBCs ( )
inline

Definition at line 127 of file phononbase/COMETModel.h.

References COMETModel< T >::_bcMap.

Referenced by COMETModel< T >::MakeCoarseModel().

127 {return _bcMap;}
template<class T >
DistFunctFields<T>& COMETModel< T >::getdsf ( )
inline
template<class T >
DistFunctFields<T>& COMETModel< T >::getdsf0 ( )
inline

Definition at line 5632 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfPtr0.

Referenced by COMETModel< T >::correctSolution(), and COMETModel< T >::injectResid().

5632 { return _dsfPtr0;}
DistFunctFields< T > _dsfPtr0
template<class T >
const DistFunctFields<T>& COMETModel< T >::getdsf1 ( ) const
inline

Definition at line 5628 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfPtr1.

5628 { return _dsfPtr1;}
DistFunctFields< T > _dsfPtr1
template<class T >
const DistFunctFields<T>& COMETModel< T >::getdsf2 ( ) const
inline

Definition at line 5629 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfPtr2.

5629 { return _dsfPtr2;}
DistFunctFields< T > _dsfPtr2
template<class T >
const DistFunctFields<T>& COMETModel< T >::getdsfEq ( ) const
inline

Definition at line 5630 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfEqPtr.

5630 { return _dsfEqPtr;}
DistFunctFields< T > _dsfEqPtr
template<class T >
const DistFunctFields<T>& COMETModel< T >::getdsfEqES ( ) const
inline

Definition at line 5631 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfEqPtrES.

5631 { return _dsfEqPtrES;}
DistFunctFields< T > _dsfEqPtrES
template<class T >
DistFunctFields<T>& COMETModel< T >::getdsfFAS ( )
inline

Definition at line 5635 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfPtrFAS.

Referenced by COMETModel< T >::injectResid().

5635 { return _dsfPtrFAS;}
DistFunctFields< T > _dsfPtrFAS
template<class T >
DistFunctFields<T>& COMETModel< T >::getdsfInj ( )
inline

Definition at line 5633 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfPtrInj.

5633 { return _dsfPtrInj;}
DistFunctFields< T > _dsfPtrInj
template<class T >
DistFunctFields<T>& COMETModel< T >::getdsfRes ( )
inline

Definition at line 5634 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfPtrRes.

5634 { return _dsfPtrRes;}
DistFunctFields< T > _dsfPtrRes
template<class T >
const map<int, vector<int> >& COMETModel< T >::getFaceReflectionArrayMap ( ) const
inline

Definition at line 2262 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_faceReflectionArrayMap.

2262 { return _faceReflectionArrayMap;}
map< int, vector< int > > _faceReflectionArrayMap
template<class T >
TCOMET* COMETModel< T >::getFinerModel ( )
inline

Definition at line 4241 of file phononbase/COMETModel.h.

References COMETModel< T >::_finerLevel.

Referenced by COMETModel< T >::makeFinestToCoarseConn().

4241 {return _finerLevel;}
template<class T >
GeomFields& COMETModel< T >::getGeomFields ( )
inline

Definition at line 4244 of file phononbase/COMETModel.h.

References COMETModel< T >::_geomFields.

4244 {return _geomFields;}
GeomFields & _geomFields
template<class T >
GeomFields& COMETModel< T >::getGeomFields ( )
inline
template<class T >
IClist& COMETModel< T >::getIClist ( )
inline

Definition at line 4258 of file phononbase/COMETModel.h.

References COMETModel< T >::_IClist.

Referenced by COMETModel< T >::MakeCoarseModel().

4258 {return _IClist;}
template<class T >
Tkspace& COMETModel< T >::getKspace ( const int  i)
inline

Definition at line 4246 of file phononbase/COMETModel.h.

References COMETModel< T >::_kspaces.

Referenced by COMETModel< T >::correctSolution(), and COMETModel< T >::injectResid().

4246 {return *_kspaces[i];}
template<class T >
TkspList& COMETModel< T >::getKspaces ( )
inline

Definition at line 4245 of file phononbase/COMETModel.h.

References COMETModel< T >::_kspaces.

Referenced by COMETModel< T >::MakeCoarseModel().

4245 {return _kspaces;}
template<class T >
ArrayBase& COMETModel< T >::getLatticeTemp ( const Mesh mesh)
inline

Definition at line 3634 of file phononbase/COMETModel.h.

References COMETModel< T >::_macro, Mesh::getCells(), and PhononMacro::temperature.

3635  {
3636  const StorageSite& cells=mesh.getCells();
3637  TArray& Tl=dynamic_cast<TArray&>(_macro.temperature[cells]);
3638  return Tl;
3639  }
Array< T > TArray
Field temperature
Definition: PhononMacro.h:21
PhononMacro & _macro
const StorageSite & getCells() const
Definition: Mesh.h:109
template<class T >
int COMETModel< T >::getLevel ( )
inline

Definition at line 4242 of file phononbase/COMETModel.h.

References COMETModel< T >::_level.

4242 {return _level;}
template<class T >
int COMETModel< T >::getLevel ( )
inline
template<class T >
PhononMacro& COMETModel< T >::getMacro ( )
inline

Definition at line 4247 of file phononbase/COMETModel.h.

References COMETModel< T >::_macro.

4247 {return _macro;}
PhononMacro & _macro
template<class T >
MacroFields& COMETModel< T >::getMacro ( )
inline

Definition at line 5643 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_macroFields.

Referenced by COMETModel< T >::correctSolution(), and COMETModel< T >::injectResid().

5643 {return _macroFields;}
MacroFields & _macroFields
template<class T >
MeshICmap& COMETModel< T >::getMeshICmap ( )
inline

Definition at line 4259 of file phononbase/COMETModel.h.

References COMETModel< T >::_MeshToIC.

Referenced by COMETModel< T >::MakeCoarseModel().

4259 {return _MeshToIC;}
template<class T >
const MeshList& COMETModel< T >::getMeshList ( )
inline

Definition at line 4243 of file phononbase/COMETModel.h.

References Model::_meshes.

4243 {return _meshes;}
const MeshList _meshes
Definition: Model.h:29
template<class T >
MeshKspaceMap& COMETModel< T >::getMKMap ( )
inline

Definition at line 128 of file phononbase/COMETModel.h.

References COMETModel< T >::_MeshKspaceMap.

Referenced by COMETModel< T >::MakeCoarseModel().

128 {return _MeshKspaceMap;}
MeshKspaceMap _MeshKspaceMap
template<class T >
TCOMET* COMETModel< T >::getModelPointer ( const int  level)
inline
template<class T >
TCModOpts& COMETModel< T >::getOptions ( )
inline

Definition at line 126 of file phononbase/COMETModel.h.

References COMETModel< T >::_options.

126 {return _options;}
COMETModelOptions< T > _options
template<class T >
COMETModelOptions<T>& COMETModel< T >::getOptions ( )
inline

Definition at line 2261 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_options.

Referenced by COMETModel< T >::MakeCoarseModel(), and COMETModel< T >::MakeIBCoarseModel().

2261 {return _options;}
COMETModelOptions< T > _options
template<class T >
map<string,shared_ptr<ArrayBase> >& COMETModel< T >::getPersistenceData ( )
inlinevirtual

Reimplemented from Model.

Definition at line 2268 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfPtr, COMETModel< T >::_initialKmodelNorm, COMETModel< T >::_niters, COMETModel< T >::_persistenceData, and Array< T >::zero().

2269  {
2270  _persistenceData.clear();
2271 
2272  Array<int>* niterArray = new Array<int>(1);
2273  (*niterArray)[0] = _niters;
2274  _persistenceData["niters"]=shared_ptr<ArrayBase>(niterArray);
2275 
2276  if (_initialKmodelNorm)
2277  {
2278  // _persistenceData["initialKmodelNorm"] =_initialKmodelNorm->getArrayPtr(_macroFields.pressure);
2279  const Field& dsfField = *_dsfPtr.dsf[0];
2280  _persistenceData["initialKmodelNorm"] =_initialKmodelNorm->getArrayPtr(dsfField);
2281 
2282  }
2283  else
2284  {
2285  Array<T>* xArray = new Array<T>(1);
2286  xArray->zero();
2287  _persistenceData["initialKmodelNorm"]=shared_ptr<ArrayBase>(xArray);
2288 
2289  }
2290  return _persistenceData;
2291  }
virtual void zero()
Definition: Array.h:281
Definition: Field.h:14
map< string, shared_ptr< ArrayBase > > _persistenceData
DistFunctFields< T > _dsfPtr
template<class T >
TQuad& COMETModel< T >::getQuadrature ( )
inline

Definition at line 5642 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_quadrature.

Referenced by COMETModel< T >::MakeCoarseModel(), and COMETModel< T >::MakeIBCoarseModel().

5642 {return _quadrature;}
Quadrature< T > & _quadrature
template<class T >
T COMETModel< T >::getResidual ( )
inline

Definition at line 4248 of file phononbase/COMETModel.h.

References COMETModel< T >::_residual.

4249  {
4250 #ifdef FVM_PARALLEL
4251  int one=1;
4252  double tempResid=_residual;
4253  MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &tempResid, one, MPI::DOUBLE, MPI::SUM);
4254  _residual=tempResid;
4255 #endif
4256  return _residual;
4257  }
template<class T >
T COMETModel< T >::getResidual ( )
inline

Definition at line 5644 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_residual.

5644 {return _residual;}
template<class T >
ArrayBase* COMETModel< T >::getValueArray ( const Mesh mesh,
const int  cell 
)
inline

Definition at line 3580 of file phononbase/COMETModel.h.

References COMETModel< T >::_kspaces, COMETModel< T >::_MeshKspaceMap, Mesh::getCells(), pmode< T >::getfield(), Mesh::getID(), Kspace< T >::getkvol(), Kspace< T >::getlength(), kvol< T >::getmode(), kvol< T >::getmodenum(), and Kspace< T >::gettotmodes().

3581  {
3582  //only returns the e" values, not the lattice temperature
3583  const int n=mesh.getID();
3584  Tkspace& kspace=*_kspaces[_MeshKspaceMap[n]];
3585  const int allModes=kspace.gettotmodes();
3586  TArray* vals=new TArray(allModes);
3587  const StorageSite& cells=mesh.getCells();
3588  const int len=kspace.getlength();
3589  int count=0;
3590  for(int k=0;k<len;k++)
3591  {
3592  Tkvol& kvol=kspace.getkvol(k);
3593  const int modes=kvol.getmodenum();
3594  for(int m=0;m<modes;m++)
3595  {
3596  Tmode& mode=kvol.getmode(m);
3597  Field& eField=mode.getfield();
3598  const TArray& eArray=dynamic_cast<const TArray&>(eField[cells]);
3599  (*vals)[count]=eArray[cell];
3600  count++;
3601  }
3602  }
3603  return vals;
3604  }
Array< T > TArray
Definition: Field.h:14
int getmodenum()
Definition: kvol.h:43
const StorageSite & getCells() const
Definition: Mesh.h:109
MeshKspaceMap _MeshKspaceMap
Kspace< T > Tkspace
Definition: kvol.h:14
int getID() const
Definition: Mesh.h:106
template<class T >
COMETVCMap& COMETModel< T >::getVCMap ( )
inline
template<class T >
T COMETModel< T >::getWallArea ( const Mesh mesh,
const int  faceGroupId 
)
inline

Definition at line 3513 of file phononbase/COMETModel.h.

References COMETModel< T >::_geomFields, GeomFields::areaMag, Mesh::getBoundaryFaceGroups(), StorageSite::getCount(), FaceGroup::id, and FaceGroup::site.

3514  {
3515  T r(0.);
3516  bool found = false;
3517  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
3518  {
3519  const FaceGroup& fg = *fgPtr;
3520  if (fg.id == faceGroupId)
3521  {
3522  const StorageSite& faces = fg.site;
3523  const int nFaces = faces.getCount();
3524  const Field& areaMagField=_geomFields.areaMag;
3525  const TArray& faceArea=dynamic_cast<const TArray&>(areaMagField[faces]);
3526 
3527  for(int f=0; f<nFaces; f++)
3528  r += faceArea[f];
3529 
3530  found=true;
3531  break;
3532  }
3533  }
3534 
3535  if (!found)
3536  throw CException("getwallArea: invalid faceGroupID");
3537  return r;
3538  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
GeomFields & _geomFields
Definition: Mesh.h:28
Array< T > TArray
Definition: Field.h:14
const int id
Definition: Mesh.h:41
int getCount() const
Definition: StorageSite.h:39
Field areaMag
Definition: GeomFields.h:25
StorageSite site
Definition: Mesh.h:40
template<class T >
VectorT3 COMETModel< T >::getWallAreaVector ( const Mesh mesh,
const int  faceGroupId 
)
inline

Definition at line 3540 of file phononbase/COMETModel.h.

References COMETModel< T >::_geomFields, GeomFields::area, Mesh::getBoundaryFaceGroups(), StorageSite::getCount(), FaceGroup::id, and FaceGroup::site.

3541  {
3542  VectorT3 An;
3543  An=0.;
3544  bool found = false;
3545  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
3546  {
3547  const FaceGroup& fg = *fgPtr;
3548  if (fg.id == faceGroupId)
3549  {
3550  const StorageSite& faces = fg.site;
3551  const int nFaces = faces.getCount();
3552  const Field& areaField=_geomFields.area;
3553  const VectorT3Array& faceArea=dynamic_cast<const VectorT3Array&>(areaField[faces]);
3554  for(int f=0; f<nFaces; f++)
3555  An+=faceArea[f];
3556  found=true;
3557  break;
3558  }
3559  }
3560 
3561 #ifdef FVM_PARALLEL
3562  found=true;
3563  int one=1;
3564  double tempR=An[0];
3565  MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &tempR, one, MPI::DOUBLE, MPI::SUM);
3566  An[0]=tempR;
3567  tempR=An[1];
3568  MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &tempR, one, MPI::DOUBLE, MPI::SUM);
3569  An[1]=tempR;
3570  tempR=An[2];
3571  MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &tempR, one, MPI::DOUBLE, MPI::SUM);
3572  An[2]=tempR;
3573 #endif
3574 
3575  if (!found)
3576  throw CException("getwallArea: invalid faceGroupID");
3577  return An;
3578  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
GeomFields & _geomFields
Definition: Mesh.h:28
Definition: Field.h:14
const int id
Definition: Mesh.h:41
int getCount() const
Definition: StorageSite.h:39
Field area
Definition: GeomFields.h:23
StorageSite site
Definition: Mesh.h:40
template<class T >
T COMETModel< T >::HeatFluxIntegral ( const Mesh mesh,
const int  faceGroupId 
)
inline

Definition at line 3291 of file phononbase/COMETModel.h.

References COMETModel< T >::_geomFields, COMETModel< T >::_kspaces, COMETModel< T >::_MeshKspaceMap, GeomFields::area, Mesh::getBoundaryFaceGroups(), StorageSite::getCount(), kvol< T >::getdk3(), Kspace< T >::getDK3(), Kspace< T >::geteArray(), Mesh::getFaceCells(), Kspace< T >::getGlobalIndex(), Mesh::getID(), Kspace< T >::getkvol(), Kspace< T >::getlength(), kvol< T >::getmode(), kvol< T >::getmodenum(), pmode< T >::getv(), FaceGroup::id, and FaceGroup::site.

3292  {
3293  T r(0.);
3294  bool found = false;
3295  const int n=mesh.getID();
3296  Tkspace& kspace=*_kspaces[_MeshKspaceMap[n]];
3297  TArray& eArray=kspace.geteArray();
3298  const T DK3=kspace.getDK3();
3299 
3300  const T hbar=6.582119e-16; // (eV s)
3301 
3302  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
3303  {
3304  const FaceGroup& fg = *fgPtr;
3305  if (fg.id == faceGroupId)
3306  {
3307  const StorageSite& faces = fg.site;
3308  const int nFaces = faces.getCount();
3309  //const StorageSite& cells = mesh.getCells();
3310  const CRConnectivity& faceCells=mesh.getFaceCells(faces);
3311  const Field& areaField=_geomFields.area;
3312  const VectorT3Array& faceArea=dynamic_cast<const VectorT3Array&>(areaField[faces]);
3313 
3314  for(int f=0; f<nFaces; f++)
3315  {
3316  const VectorT3 An=faceArea[f];
3317  const int c1=faceCells(f,1);
3318  int cellIndex=kspace.getGlobalIndex(c1,0);
3319  for(int k=0;k<kspace.getlength();k++)
3320  {
3321  Tkvol& kv=kspace.getkvol(k);
3322  int modenum=kv.getmodenum();
3323  for(int m=0;m<modenum;m++)
3324  {
3325  VectorT3 vg=kv.getmode(m).getv();
3326  T dk3=kv.getdk3();
3327  //T energy=hbar*kv.getmode(m).getomega();
3328  const T vgdotAn=An[0]*vg[0]+An[1]*vg[1]+An[2]*vg[2];
3329  r += eArray[cellIndex]*vgdotAn*(dk3/DK3);//*energy;
3330  cellIndex++;
3331  }
3332  }
3333  }
3334  found=true;
3335  }
3336  }
3337 
3338 #ifdef FVM_PARALLEL
3339  found=true;
3340  int one=1;
3341  double tempR=r;
3342  MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &tempR, one, MPI::DOUBLE, MPI::SUM);
3343  r=tempR;
3344 #endif
3345 
3346  if (!found)
3347  throw CException("getHeatFluxIntegral: invalid faceGroupID");
3348  return r*DK3;
3349  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
GeomFields & _geomFields
Definition: Mesh.h:28
Array< T > TArray
Definition: Field.h:14
const int id
Definition: Mesh.h:41
MeshKspaceMap _MeshKspaceMap
const CRConnectivity & getFaceCells(const StorageSite &site) const
Definition: Mesh.cpp:388
int getCount() const
Definition: StorageSite.h:39
Field area
Definition: GeomFields.h:23
Kspace< T > Tkspace
int getID() const
Definition: Mesh.h:106
StorageSite site
Definition: Mesh.h:40
template<class T >
T COMETModel< T >::HeatFluxIntegralFace ( const Mesh mesh,
const int  f 
)
inline

Definition at line 3351 of file phononbase/COMETModel.h.

References COMETModel< T >::_geomFields, COMETModel< T >::_kspaces, COMETModel< T >::_MeshKspaceMap, GeomFields::area, kvol< T >::getdk3(), Kspace< T >::getDK3(), Kspace< T >::geteArray(), Mesh::getFaceCells(), Kspace< T >::getGlobalIndex(), Mesh::getID(), Mesh::getInteriorFaceGroup(), Kspace< T >::getkvol(), Kspace< T >::getlength(), kvol< T >::getmode(), kvol< T >::getmodenum(), pmode< T >::getv(), and FaceGroup::site.

3352  {
3353  T r(0.);
3354  //bool found = false;
3355  const int n=mesh.getID();
3356  Tkspace& kspace=*_kspaces[_MeshKspaceMap[n]];
3357  TArray& eArray=kspace.geteArray();
3358  const T DK3=kspace.getDK3();
3359 
3360  const T hbar=6.582119e-16; // (eV s)
3361  //const FaceGroupPtr fgPtr=mesh.getInteriorFaceGroup();
3362 
3363  const FaceGroup& fg = mesh.getInteriorFaceGroup();
3364 
3365  const StorageSite& faces = fg.site;
3366  //const int nFaces = faces.getCount();
3367  //const StorageSite& cells = mesh.getCells();
3368  const CRConnectivity& faceCells=mesh.getFaceCells(faces);
3369  const Field& areaField=_geomFields.area;
3370  const VectorT3Array& faceArea=dynamic_cast<const VectorT3Array&>(areaField[faces]);
3371 
3372 
3373  const VectorT3 An=faceArea[f];
3374  const int c1=faceCells(f,1);
3375  const int c0=faceCells(f,0);
3376  int cellIndex=kspace.getGlobalIndex(c1,0);
3377  int cellIndex0=kspace.getGlobalIndex(c0,0);
3378  for(int k=0;k<kspace.getlength();k++)
3379  {
3380  Tkvol& kv=kspace.getkvol(k);
3381  int modenum=kv.getmodenum();
3382  for(int m=0;m<modenum;m++)
3383  {
3384  VectorT3 vg=kv.getmode(m).getv();
3385  T dk3=kv.getdk3();
3386  //T energy=hbar*kv.getmode(m).getomega();
3387  const T vgdotAn=An[0]*vg[0]+An[1]*vg[1]+An[2]*vg[2];
3388  if(vgdotAn>0)
3389  r += eArray[cellIndex0]*vgdotAn*(dk3/DK3);//*energy;
3390  else
3391  r += eArray[cellIndex]*vgdotAn*(dk3/DK3);
3392  cellIndex++;
3393  cellIndex0++;
3394  }
3395  }
3396 
3397  return r*DK3;
3398  }
const FaceGroup & getInteriorFaceGroup() const
Definition: Mesh.h:181
GeomFields & _geomFields
Definition: Mesh.h:28
Array< T > TArray
Definition: Field.h:14
MeshKspaceMap _MeshKspaceMap
const CRConnectivity & getFaceCells(const StorageSite &site) const
Definition: Mesh.cpp:388
Field area
Definition: GeomFields.h:23
Kspace< T > Tkspace
int getID() const
Definition: Mesh.h:106
StorageSite site
Definition: Mesh.h:40
template<class T >
void COMETModel< T >::init ( )
inlinevirtual

Implements Model.

Definition at line 130 of file phononbase/COMETModel.h.

References COMETModel< T >::_BCells, COMETModel< T >::_bcMap, COMETModel< T >::_BFaces, COMETModel< T >::_geomFields, COMETModel< T >::_IClist, COMETModel< T >::_kspaces, COMETModel< T >::_macro, Model::_meshes, COMETModel< T >::_MeshKspaceMap, COMETModel< T >::_MeshToIC, COMETModel< T >::_options, COMETModel< T >::_rank, COMETModel< T >::_residual, Field::addArray(), GeomFields::area, GeomFields::areaMag, PhononMacro::BranchTemperatures, COMETModel< T >::calcDomainStats(), pmode< T >::calce0(), Mesh::COMETfindCommonFaces(), PhononMacro::deltaT, COMETIC< T >::FgID1, Kspace< T >::findSpecs(), GeomFields::fineToCoarse, Mesh::getBoundaryFaceGroups(), Mesh::getCells(), StorageSite::getCount(), Mesh::getFaceCells(), Kspace< T >::getGlobalIndex(), Mesh::getID(), Mesh::getInterfaceGroups(), Kspace< T >::getkvol(), Kspace< T >::getlength(), kvol< T >::getmode(), kvol< T >::getmodenum(), StorageSite::getOffset(), pmode< T >::getreflmap(), pmode< T >::gettau(), Kspace< T >::gettotmodes(), pmode< T >::getv(), PhononMacro::heatFlux, FaceGroup::id, COMETModel< T >::initializeTemperatureBoundaries(), COMETIC< T >::InterfaceModel, PhononMacro::lam, COMETModel< T >::MakeCoarseModel(), COMETInterface< T >::makeDMMcoeffs(), COMETInterface< T >::makeNoInterfaceCoeffs(), COMETIC< T >::MeshID0, COMETIC< T >::MeshID1, Kspace< T >::sete0Array(), Kspace< T >::seteArray(), COMETModel< T >::setFinestLevel(), COMETModel< T >::setLocalScatterMaps(), Kspace< T >::setResArray(), Kspace< T >::setSourceArray(), Kspace< T >::setTauArray(), FaceGroup::site, sqrt(), PhononMacro::temperature, PhononMacro::TlResidual, COMETInterface< T >::updateOtherGhost(), COMETModel< T >::updateResid(), Kspace< T >::updateTau(), Vector< T, N >::zero(), and Array< T >::zero().

131  {
132  const int numMeshes=_meshes.size();
133  const T Tinit=_options["initialTemperature"];
134 
135  for (int n=0;n<numMeshes;n++)
136  {
137  Mesh& mesh=*_meshes[n];
138  if(_MeshKspaceMap[n]==-1)
139  throw CException("Have not set the Kspace for this Mesh!!");
140  Tkspace& kspace=*_kspaces[_MeshKspaceMap[n]];
141  const int kcount=kspace.gettotmodes();
142  BCfaceArray& BCfArray=*(_BFaces[n]);
143  BCcellArray& BCArray=*(_BCells[n]);
144  const int numK=kspace.getlength();
145  const StorageSite& cells=mesh.getCells();
146  const int numcells=cells.getCount();
147  VectorT3 lamTemp;
148 
149  // set micro parameters
150  //cout<<"Allocating Arrays..."<<endl;
151  shared_ptr<TArray> eArray(new TArray(numcells*kcount));
152  shared_ptr<TArray> e0Array(new TArray(numcells*kcount));
153  shared_ptr<TArray> ResidArray(new TArray(numcells*kcount));
154  shared_ptr<TArray> tauArray(new TArray(numcells*kcount));
155  kspace.seteArray(eArray);
156  kspace.sete0Array(e0Array);
157  kspace.setResArray(ResidArray);
158  kspace.setTauArray(tauArray);
159 
160  if(_options.Source)
161  {
162  shared_ptr<TArray> SrcArray(new TArray(numcells*kcount));
163  SrcArray->zero();
164  kspace.setSourceArray(SrcArray);
165  }
166 
167  shared_ptr<TArray> TLcell(new TArray(numcells));
168  shared_ptr<TArray> deltaTcell(new TArray(numcells));
169  shared_ptr<VectorT3Array> lamArray(new VectorT3Array(numcells));
170  shared_ptr<VectorT3Array> q(new VectorT3Array(numcells));
171  lamTemp.zero();
172  q->zero();
173  *lamArray=lamTemp;
174  *deltaTcell=0.;
175  *TLcell=Tinit;
176  _macro.temperature.addArray(cells,TLcell);
177  _macro.deltaT.addArray(cells,deltaTcell);
178  _macro.lam.addArray(cells,lamArray);
179  _macro.heatFlux.addArray(cells,q);
180 
181  shared_ptr<IntArray> f2c(new IntArray(numcells));
182  *f2c=-1;
183  _geomFields.fineToCoarse.addArray(cells, f2c);
184 
185  int modeCount=kspace.getkvol(0).getmodenum();
186  FieldVector* FieldVecPtr=new FieldVector();
187 
188  for(int mode=0;mode<modeCount;mode++)
189  {
190  shared_ptr<Field> modeField(new Field("mode"));
191  shared_ptr<TArray> modeTemp(new TArray(numcells));
192  *modeTemp=Tinit;
193  modeField->addArray(cells,modeTemp);
194  FieldVecPtr->push_back(modeField);
195  }
196 
197  _macro.BranchTemperatures[n]=FieldVecPtr;
198 
199  //cout<<"Arrays Allocated...Initializing Values..."<<endl;
200 
201  for(int c=0;c<numcells;c++)
202  {
203  int cellIndex=kspace.getGlobalIndex(c,0);
204  for (int k=0;k<numK;k++)
205  {
206  Tkvol& kv=kspace.getkvol(k);
207  const int numM=kv.getmodenum();
208  //const T dk3=kv.getdk3();
209 
210  for (int m=0;m<numM;m++)
211  {
212  Tmode& mode=kv.getmode(m);
213  T tau=mode.gettau();
214  const T einit=mode.calce0(Tinit);
215  /*
216  if(m==0 && k==0)
217  (*eArray)[cellIndex]=1.1*einit;
218  else*/
219 
220  (*eArray)[cellIndex]=einit;
221  (*e0Array)[cellIndex]=einit;
222  (*ResidArray)[cellIndex]=0.;
223  (*tauArray)[cellIndex]=tau;
224  cellIndex++;
225  }
226  }
227  kspace.updateTau(c,Tinit);
228  }
229 
230 
231  shared_ptr<TArray> TlResidCell(new TArray(numcells));
232  *TlResidCell=0.;
233  _macro.TlResidual.addArray(cells,TlResidCell);
234 
235  //cout<<"Values Initialized...Setting Facegroups..."<<endl;
236 
237  //setting facegroups
238 
239  foreach(const FaceGroupPtr fgPtr, mesh.getInterfaceGroups())
240  {
241  FaceGroup& fg = *fgPtr;
242  const StorageSite& faces = fg.site;
243  //const CRConnectivity& BfaceCells=mesh.getFaceCells(faces);
244 
245  const int faceCount=faces.getCount();
246  const int offSet=faces.getOffset();
247 
248  for(int i=offSet;i<offSet+faceCount;i++)
249  BCfArray[i]=-1; //implicit boundary
250  }
251 
252 
253  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
254  {
255  FaceGroup& fg = *fgPtr;
256  if(fg.id>0)
257  {
258  if(_bcMap[fg.id]->bcType == "reflecting")
259  {
260  const StorageSite& faces = fg.site;
261  const CRConnectivity& BfaceCells=mesh.getFaceCells(faces);
262  const int faceCount=faces.getCount();
263  const int offSet=faces.getOffset();
264  const bool Imp=(*(_bcMap[fg.id]))["FullyImplicit"];
265  const T ref=(*(_bcMap[fg.id]))["specifiedReflection"];
266  const Field& AreaMagField=_geomFields.areaMag;
267  const TArray& AreaMag=
268  dynamic_cast<const TArray&>(AreaMagField[faces]);
269  const Field& AreaDirField=_geomFields.area;
270  const VectorT3Array& AreaDir=
271  dynamic_cast<const VectorT3Array&>(AreaDirField[faces]);
272 
273  const VectorT3 norm=AreaDir[0]/AreaMag[0];
274 
275  if(ref==1.)
276  {
277  for (int k=0;k<numK;k++)
278  {
279  Tkvol& kv=kspace.getkvol(k);
280  const int numM=kv.getmodenum();
281  //const T dk3=kv.getdk3();
282  for (int m=0;m<numM;m++)
283  {
284 
285  Tmode& mode=kv.getmode(m);
286  const VectorT3 vg=mode.getv();
287  const T vmag=sqrt(pow(vg[0],2)+pow(vg[1],2)+pow(vg[2],2));
288  VectorT3 si=vg/vmag;
289  VectorT3 so;
290  const T sidotn=si[0]*norm[0]+si[1]*norm[1]+si[2]*norm[2];
291  Refl_Map& rmap=mode.getreflmap();
292 
293  if (sidotn > T_Scalar(0.0))
294  {
295  so=si-2.*(si[0]*norm[0]+si[1]*norm[1]+si[2]*norm[2])*norm;
296  T soMag=sqrt(pow(so[0],2)+pow(so[1],2)+pow(so[2],2));
297  so/=soMag;
298  so*=vmag;
299  Refl_pair refls;
300  Refl_pair reflsFrom;
301  kspace.findSpecs(norm,m,k,refls);
302  rmap[fg.id]=refls;
303  const int k1=refls.first.second;
304  Tmode& mode2=kspace.getkvol(k1).getmode(m);
305  Refl_Map& rmap2=mode2.getreflmap();
306  reflsFrom.first.second=-1;
307  reflsFrom.second.second=k;
308  rmap2[fg.id]=reflsFrom;
309  }
310  }
311  }
312  }
313 
314  if(Imp)
315  {
316  for(int i=offSet;i<offSet+faceCount;i++)
317  BCfArray[i]=2; //implicit boundary
318  }
319  else
320  {
321  for(int i=offSet;i<offSet+faceCount;i++)
322  BCfArray[i]=3; //explicit boundary
323  }
324 
325  if(Imp)
326  {
327  for(int i=0;i<faceCount;i++)
328  {
329  int cell1=BfaceCells(i,0);
330  if(BCArray[cell1]==0)
331  BCArray[cell1]=1; //implicit boundary only
332  else if(BCArray[cell1]==2)
333  BCArray[cell1]=3; //mix implicit/explicit boundary
334  }
335  }
336  else
337  {
338  for(int i=0;i<faceCount;i++)
339  {
340  int cell1=BfaceCells(i,0);
341  if(BCArray[cell1]==0)
342  BCArray[cell1]=2; //explicit boundary only
343  else if (BCArray[cell1]==1)
344  BCArray[cell1]=3; //mix implicit/explicit boundary
345  }
346  }
347  }
348  else if(_bcMap[fg.id]->bcType == "temperature")
349  {
350  const StorageSite& faces = fg.site;
351  const int faceCount=faces.getCount();
352  const int offSet=faces.getOffset();
353 
354  for(int i=offSet;i<offSet+faceCount;i++)
355  BCfArray[i]=1;
356  }
357  else if(_bcMap[fg.id]->bcType == "Interface")
358  {
359  StorageSite& faces0 = fg.site;
360  const CRConnectivity& BfaceCells=mesh.getFaceCells(faces0);
361  const int faceCount=faces0.getCount();
362  const int offSet=faces0.getOffset();
363 
364  for(int i=offSet;i<offSet+faceCount;i++)
365  {
366  BCfArray[i]=4; //Interface boundary
367  int cell0=BfaceCells(i-offSet,0);
368  int cell1=BfaceCells(i-offSet,1);
369  BCArray[cell0]=2; //always treated explicitly
370  BCArray[cell1]=4; //interface ghost cells need to be labeled
371  }
372 
373  bool doneAlready=false;
374  foreach(const COMETIC<T>* icPtr, _IClist)
375  {
376  if(icPtr->FgID1==fg.id && icPtr->MeshID1==mesh.getID())
377  {
378  doneAlready=true;
379  break;
380  }
381  }
382 
383  bool foundMatch=false;
384  if(!doneAlready)
385  {
386  StorageSite* faces1Ptr=NULL;
387  int otherFgID,otherMid;
388  for(int otherMeshID=n+1;otherMeshID<numMeshes;otherMeshID++)
389  {
390  const Mesh& otherMesh=*_meshes[otherMeshID];
391  foreach(const FaceGroupPtr otherfgPtr, otherMesh.getBoundaryFaceGroups())
392  {
393  foundMatch=mesh.COMETfindCommonFaces(faces0, otherfgPtr->site, _geomFields);
394  if(foundMatch)
395  {
396  otherFgID=otherfgPtr->id;
397  otherMid=otherMeshID;
398  faces1Ptr=&(otherfgPtr->site);
399  break;
400  }
401  }
402  if(foundMatch)
403  break;
404  }
405 
406  if(foundMatch)
407  {
408  StorageSite& faces1=*faces1Ptr;
409  const Mesh& mesh1=*_meshes[otherMid];
410  COMETIC<T>* icPtr(new COMETIC<T>(n,fg.id,mesh1.getID(),
411  otherFgID, faces1.getCount()));
412 
413  icPtr->InterfaceModel=_bcMap[fg.id]->InterfaceModel;
414 
415  setLocalScatterMaps(mesh, faces0, mesh1, faces1);
416 
417  _IClist.push_back(icPtr);
418  }
419  else if(!doneAlready && !foundMatch)
420  {
421  cout<<"Face Group: "<<fg.id<<" MeshID: "<<mesh.getID()<<endl;
422  throw CException("Could not find a matching face group!");
423  }
424  }
425  }// end if interface
426  }
427  }//end facegroup loop
428 
429  //cout<<"Facegroups Set...Mesh "<<n<<" Complete."<<endl;
430 
431  }//end meshes loop
432 
433  //cout<<"Mesh Loop Complete...Creating Interfaces (if any)..."<<endl;
434 
435  //Make map from mesh to IC
436  IntArray ICcount(numMeshes);
437  ICcount.zero();
438 
439  foreach(const COMETIC<T>* icPtr, _IClist)
440  {
441  ICcount[icPtr->MeshID0]++;
442  ICcount[icPtr->MeshID1]++;
443  }
444 
445  if(!_IClist.empty())
446  {
447  for(int i=0;i<numMeshes;i++)
448  {
449  IntArrPtr MeshToIC(new IntArray(ICcount[i]));
450  _MeshToIC.push_back(MeshToIC);
451  }
452  }
453 
454  ICcount.zero();
455  const int listSize=_IClist.size();
456  for(int ic=0;ic<listSize;ic++)
457  {
458  const COMETIC<T>* icPtr=_IClist[ic];
459  (*(_MeshToIC[icPtr->MeshID0]))[ICcount[icPtr->MeshID0]]=ic;
460  (*(_MeshToIC[icPtr->MeshID1]))[ICcount[icPtr->MeshID1]]=ic;
461  ICcount[icPtr->MeshID0]++;
462  ICcount[icPtr->MeshID1]++;
463  }
464 
465  COMETInterface<T> ComInt(_meshes,_kspaces,_MeshKspaceMap,_macro,_geomFields);
466 
467  for(int ic=0;ic<listSize;ic++)
468  {
469  COMETIC<T>* icPtr=_IClist[ic];
470  const int mid0=icPtr->MeshID0;
471  const int mid1=icPtr->MeshID1;
472  if(icPtr->InterfaceModel=="DMM")
473  ComInt.makeDMMcoeffs(*icPtr);
474  else if(icPtr->InterfaceModel=="NoInterface")
475  ComInt.makeNoInterfaceCoeffs(*icPtr);
476  ComInt.updateOtherGhost(*icPtr,mid0,false);
477  ComInt.updateOtherGhost(*icPtr,mid1,false);
478  }
479 
480  //cout<<"Interfaces Complete..."<<endl;
481 
483  _residual=updateResid(false);
484 
485  if(_options.DomainStats=="Loud")
486  {
487  cout<<"Creating Coarse Levels on rank "<<_rank<<"..."<<endl;
488  cout<<"Level: 0, rank: "<<_rank<<endl<<endl;
489  calcDomainStats();
490  cout<<endl;
491  }
492 
493  MakeCoarseModel(this);
494  setFinestLevel(this);
495  if(_options.DomainStats=="Loud")
496  cout<<"Coarse Levels Completed on rank "<<_rank<<"."<<endl;
497  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
Array< int > BCcellArray
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
GeomFields & _geomFields
T updateResid(const bool addFAS)
Definition: Mesh.h:28
Tmode::Refl_Map Refl_Map
Array< T > TArray
bool COMETfindCommonFaces(StorageSite &faces, StorageSite &otherFaces, const GeomFields &geomFields)
Definition: Mesh.cpp:1053
NumTypeTraits< T >::T_Scalar T_Scalar
Definition: Field.h:14
Field deltaT
Definition: PhononMacro.h:22
Field temperature
Definition: PhononMacro.h:21
Definition: Mesh.h:49
vector< shared_ptr< Field > > FieldVector
COMETModelOptions< T > _options
void setLocalScatterMaps(const Mesh &mesh0, StorageSite &faces0, const Mesh &mesh1, StorageSite &faces1)
Field fineToCoarse
Definition: GeomFields.h:41
Tangent sqrt(const Tangent &a)
Definition: Tangent.h:317
const int id
Definition: Mesh.h:41
Array< VectorT3 > VectorT3Array
Field TlResidual
Definition: PhononMacro.h:24
shared_ptr< IntArray > IntArrPtr
void setFinestLevel(TCOMET *finest)
PhononMacro & _macro
string InterfaceModel
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
MeshKspaceMap _MeshKspaceMap
void addArray(const StorageSite &, shared_ptr< ArrayBase > a)
Definition: Field.cpp:72
const CRConnectivity & getFaceCells(const StorageSite &site) const
Definition: Mesh.cpp:388
int getOffset() const
Definition: StorageSite.h:87
int getCount() const
Definition: StorageSite.h:39
void initializeTemperatureBoundaries()
Array< int > IntArray
Field area
Definition: GeomFields.h:23
FieldVectorMap BranchTemperatures
Definition: PhononMacro.h:29
const FaceGroupList & getInterfaceGroups() const
Definition: Mesh.h:190
Kspace< T > Tkspace
void zero()
Definition: Vector.h:156
Tmode::Refl_pair Refl_pair
Field areaMag
Definition: GeomFields.h:25
Field heatFlux
Definition: PhononMacro.h:27
int getID() const
Definition: Mesh.h:106
void MakeCoarseModel(TCOMET *finerModel)
Array< int > BCfaceArray
StorageSite site
Definition: Mesh.h:40
template<class T >
void COMETModel< T >::init ( )
inlinevirtual

Implements Model.

Definition at line 185 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_BCells, COMETModel< T >::_bcMap, COMETModel< T >::_BFaces, COMETModel< T >::_faceReflectionArrayMap, COMETModel< T >::_finestGeomFields, COMETModel< T >::_finestMeshes, COMETModel< T >::_geomFields, COMETModel< T >::_ibm, COMETModel< T >::_initialKmodelNorm, COMETModel< T >::_level, COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_niters, COMETModel< T >::_options, COMETModel< T >::_quadrature, COMETModel< T >::_vcMap, COMETModel< T >::_ZCells, Field::addArray(), GeomFields::area, GeomFields::areaMag, MacroFields::coeff, MacroFields::coeffg, MacroFields::collisionFrequency, MacroFields::density, MacroFields::Entropy, MacroFields::EntropyGenRate, MacroFields::EntropyGenRate_Collisional, GeomFields::finestToCoarse, GeomFields::fineToCoarse, Mesh::getBoundaryFaceGroups(), Mesh::getCells(), StorageSite::getCount(), StorageSite::getCountLevel1(), Mesh::getFaceCells(), Mesh::getFaces(), Mesh::getID(), Mesh::getInterfaceGroups(), StorageSite::getOffset(), StorageSite::getSelfCount(), FaceGroup::groupType, GeomFields::ibType, Mesh::IBTYPE_BOUNDARY, Mesh::IBTYPE_FLUID, FaceGroup::id, MacroFields::InterfaceDensity, MacroFields::InterfacePressure, MacroFields::InterfaceStress, MacroFields::InterfaceVelocity, MacroFields::Knq, MacroFields::pressure, FaceGroup::site, MacroFields::Stress, Field::syncLocal(), MacroFields::temperature, MacroFields::Txx, MacroFields::Txy, MacroFields::Tyy, MacroFields::Tyz, MacroFields::Tzx, MacroFields::Tzz, MacroFields::velocity, and MacroFields::viscosity.

Referenced by COMETModel< T >::COMETModel(), and COMETModel< T >::MakeIBCoarseModel().

187  {
188  const int numMeshes = _meshes.size();
189  for (int n=0; n<numMeshes; n++)
190  {
191  const Mesh& mesh = *_meshes[n];
192  const Mesh& fMesh = *_finestMeshes[n];
193 
194  const COMETVC<T>& vc = *_vcMap[mesh.getID()];
195 
196  const StorageSite& cells = mesh.getCells();
197  const StorageSite& fCells = fMesh.getCells();
198 
199  const int nCells = cells.getCountLevel1();
200  shared_ptr<VectorT3Array> vCell(new VectorT3Array(nCells));
201 
202  VectorT3 initialVelocity;
203  initialVelocity[0] = _options["initialXVelocity"];
204  initialVelocity[1] = _options["initialYVelocity"];
205  initialVelocity[2] = _options["initialZVelocity"];
206  *vCell = initialVelocity;
207  _macroFields.velocity.addArray(cells,vCell);
208 
209  shared_ptr<IntArray> fineToCoarseCell(new IntArray(nCells));
210  *fineToCoarseCell = -1;
211  _geomFields.fineToCoarse.addArray(cells,fineToCoarseCell);
212 
213  if((_ibm==1)&&(_level==0))
214  {
216  shared_ptr<Array<Vector<int,25> > >finestToCoarseCell(new Array<Vector<int,25> >(fCells.getCountLevel1()));
217  Vector<int,25> initialIndex;
218  for(int k=0;k<25;k++)
219  initialIndex[k]=-1;
220  *finestToCoarseCell = initialIndex;
221  _finestGeomFields.finestToCoarse.addArray(fCells,finestToCoarseCell);
222  Field& FinestToCoarseField=_finestGeomFields.finestToCoarse;
223  Array<Vector<int,25> >& FinestToCoarse=dynamic_cast<Array<Vector<int,25> >&>(FinestToCoarseField[fCells]);
224  for(int c=0;c<nCells;c++)
225  FinestToCoarse[c][_level]=c;
226  }
227 
228  shared_ptr<TArray> pCell(new TArray(nCells));
229  *pCell = _options["operatingPressure"];
230  _macroFields.pressure.addArray(cells,pCell);
231 
232  shared_ptr<TArray> rhoCell(new TArray(nCells));
233  *rhoCell = 0.;
234  //*rhoCell = vc["density"];
235  _macroFields.density.addArray(cells,rhoCell);
236 
237  shared_ptr<TArray> muCell(new TArray(nCells));
238  *muCell = 0.;
239  //*muCell = vc["viscosity"];
240  _macroFields.viscosity.addArray(cells,muCell);
241 
242  shared_ptr<TArray> tempCell(new TArray(nCells));
243  *tempCell = _options["operatingTemperature"];
244  _macroFields.temperature.addArray(cells,tempCell);
245 
246  shared_ptr<TArray> collFreqCell(new TArray(nCells));
247  *collFreqCell = 0.;
248  //*collFreqCell = vc["viscosity"];
249  _macroFields.collisionFrequency.addArray(cells,collFreqCell);
250 
251  //coeffs for perturbed BGK distribution function
252  shared_ptr<VectorT5Array> coeffCell(new VectorT5Array(nCells));
253  VectorT5 initialCoeff;
254  initialCoeff[0] = 1.0;
255  initialCoeff[1] = 1.0;
256  initialCoeff[2] = 0.0;
257  initialCoeff[3] = 0.0;
258  initialCoeff[4] = 0.0;
259  *coeffCell = initialCoeff;
260  _macroFields.coeff.addArray(cells,coeffCell);
261 
262  //coeffs for perturbed BGK distribution function
263  shared_ptr<VectorT10Array> coeffgCell(new VectorT10Array(nCells));
264  VectorT10 initialCoeffg;
265  initialCoeffg[0] = 1.0;
266  initialCoeffg[1] = 1.0;
267  initialCoeffg[2] = 0.0;
268  initialCoeffg[3] = 1.0;
269  initialCoeffg[4] = 0.0;
270  initialCoeffg[5] = 1.0;
271  initialCoeffg[6] = 0.0;
272  initialCoeffg[7] = 0.0;
273  initialCoeffg[8] = 0.0;
274  initialCoeffg[9] = 0.0;
275  *coeffgCell = initialCoeffg;
276  _macroFields.coeffg.addArray(cells,coeffgCell);
277 
278  // used for ESBGK equilibrium distribution function
279  shared_ptr<TArray> tempxxCell(new TArray(cells.getCountLevel1()));
280  *tempxxCell = _options["operatingTemperature"]/3;
281  _macroFields.Txx.addArray(cells,tempxxCell);
282 
283  shared_ptr<TArray> tempyyCell(new TArray(cells.getCountLevel1()));
284  *tempyyCell = _options["operatingTemperature"]/3;
285  _macroFields.Tyy.addArray(cells,tempyyCell);
286 
287  shared_ptr<TArray> tempzzCell(new TArray(cells.getCountLevel1()));
288  *tempzzCell = _options["operatingTemperature"]/3;
289  _macroFields.Tzz.addArray(cells,tempzzCell);
290 
291  shared_ptr<TArray> tempxyCell(new TArray(cells.getCountLevel1()));
292  *tempxyCell = 0.0;
293  _macroFields.Txy.addArray(cells,tempxyCell);
294 
295  shared_ptr<TArray> tempyzCell(new TArray(cells.getCountLevel1()));
296  *tempyzCell = 0.0;
297  _macroFields.Tyz.addArray(cells,tempyzCell);
298 
299  shared_ptr<TArray> tempzxCell(new TArray(cells.getCountLevel1()));
300  *tempzxCell = 0.0;
301  _macroFields.Tzx.addArray(cells,tempzxCell);
302 
303  //Entropy and Entropy Generation Rate for switching
304  shared_ptr<TArray> EntropyCell(new TArray(cells.getCountLevel1()));
305  *EntropyCell = 0.0;
306  _macroFields.Entropy.addArray(cells,EntropyCell);
307 
308  shared_ptr<TArray> EntropyGenRateCell(new TArray(cells.getCountLevel1()));
309  *EntropyGenRateCell = 0.0;
310  _macroFields.EntropyGenRate.addArray(cells,EntropyGenRateCell);
311 
312  shared_ptr<TArray> EntropyGenRateColl(new TArray(cells.getCountLevel1()));
313  *EntropyGenRateColl = 0.0;
314  _macroFields.EntropyGenRate_Collisional.addArray(cells,EntropyGenRateColl);
315 
316  //Pxx,Pyy,Pzz,Pxy,Pxz,Pyz
317  shared_ptr<VectorT6Array> stressCell(new VectorT6Array(nCells));
318  VectorT6 initialstress;
319  initialstress[0] = 1.0;
320  initialstress[1] = 1.0;
321  initialstress[2] = 1.0;
322  initialstress[3] = 0.0;
323  initialstress[4] = 0.0;
324  initialstress[5] = 0.0;
325  *stressCell = initialstress;
326  _macroFields.Stress.addArray(cells,stressCell);
327 
328  //Knq=M300+M120+M102 for Couette with uy
329  shared_ptr<TArray> KnqCell(new TArray(cells.getCountLevel1()));
330  *KnqCell = 0.0;
331  _macroFields.Knq.addArray(cells,KnqCell);
332 
333 
334  //higher order moments of distribution function
335  /*
336  shared_ptr<VectorT3Array> M300Cell(new VectorT3Array(cells.getCount()));
337  VectorT3 initialM300;
338  initialM300[0] = 0.0;
339  initialM300[1] = 0.0;
340  initialM300[2] = 0.0;
341  *M300Cell = initialM300;
342  _macroFields.M300.addArray(cells,M300Cell);
343 
344  shared_ptr<VectorT3Array> M030Cell(new VectorT3Array(cells.getCount()));
345  VectorT3 initialM030;
346  initialM030[0] = 0.0;
347  initialM030[1] = 0.0;
348  initialM030[2] = 0.0;
349  *M300Cell = initialM030;
350  _macroFields.M030.addArray(cells,M030Cell);
351  */
352  //if(MPI::COMM_WORLD.Get_rank()==0)
353  //cout<<"array for fields created"<<endl;
354  const int numDirections = _quadrature.getDirCount();
355  const TArray& cx = dynamic_cast<const TArray&>(*_quadrature.cxPtr);
356  const TArray& cy = dynamic_cast<const TArray&>(*_quadrature.cyPtr);
357  const TArray& cz = dynamic_cast<const TArray&>(*_quadrature.czPtr);
358  //FILE * pFile;
359  //pFile=fopen("ref_incMEMOSA.txt","w");
360  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups()){
361  const FaceGroup& fg = *fgPtr;
362 
363  if((_bcMap[fg.id]->bcType == "SymmetryBC")||(_bcMap[fg.id]->bcType == "RealWallBC")||(_bcMap[fg.id]->bcType == "VelocityInletBC")){
364 
365  const StorageSite& faces = fg.site;
366 
367  const Field& areaMagField = _geomFields.areaMag;
368  const TArray& faceAreaMag = dynamic_cast<const TArray &>(areaMagField[faces]);
369  const Field& areaField = _geomFields.area;
370  const VectorT3Array& faceArea=dynamic_cast<const VectorT3Array&>(areaField[faces]);
371 
372  const VectorT3 en = faceArea[0]/faceAreaMag[0];
373  vector<int> tempVec(numDirections);
374 
375  for (int j=0; j<numDirections; j++){
376  const T c_dot_en = cx[j]*en[0]+cy[j]*en[1]+cz[j]*en[2];
377  const T cx_incident = cx[j] - 2.0*c_dot_en*en[0];
378  const T cy_incident = cy[j] - 2.0*c_dot_en*en[1];
379  const T cz_incident = cz[j] - 2.0*c_dot_en*en[2];
380  int direction_incident=0;
381  T Rdotprod=1e54;
382  T dotprod=0.0;
383  for (int js=0; js<numDirections; js++){
384  dotprod=pow(cx_incident-cx[js],2)+pow(cy_incident-cy[js],2)+pow(cz_incident-cz[js],2);
385  if (dotprod< Rdotprod){
386  Rdotprod =dotprod;
387  direction_incident=js;}
388  }
389  tempVec[j] = direction_incident;
390  //fprintf(pFile,"%d %d %d \n",fg.id, j,direction_incident);
391 
392  }
393  const int fgid=fg.id;
394  _faceReflectionArrayMap[fgid] = tempVec; //add to map
395 
396  }
397  }
398 
399  foreach(const FaceGroupPtr fgPtr, mesh.getInterfaceGroups()){
400  const FaceGroup& fg = *fgPtr;
401  if(fg.groupType == "NSinterface"){
402  const StorageSite& Intfaces = fg.site;
403 
404  shared_ptr<VectorT3Array> InterfaceVelFace(new VectorT3Array(Intfaces.getCount()));
405  InterfaceVelFace ->zero();
406  _macroFields.InterfaceVelocity.addArray(Intfaces,InterfaceVelFace);
407 
408  shared_ptr<StressTensorArray> InterfaceStressFace(new StressTensorArray(Intfaces.getCount()));
409  InterfaceStressFace ->zero();
410  _macroFields.InterfaceStress.addArray(Intfaces,InterfaceStressFace);
411 
412  shared_ptr<TArray> InterfacePressFace(new TArray(Intfaces.getCount()));
413  *InterfacePressFace = _options["operatingPressure"];
414  _macroFields.InterfacePressure.addArray(Intfaces,InterfacePressFace);
415 
416  shared_ptr<TArray> InterfaceDensityFace(new TArray(Intfaces.getCount()));
417  *InterfaceDensityFace =vc["density"];
418  _macroFields.InterfaceDensity.addArray(Intfaces,InterfaceDensityFace);
419 
420 
421  }
422 
423  //fclose(pFile);
424 
425 
426  } //end of loop through meshes
427 
428  BCcellArray& BCArray=*(_BCells[n]);
429  BCfaceArray& BCfArray=*(_BFaces[n]);
430  BCcellArray& ZCArray=*(_ZCells[n]);
431  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
432  {
433  const FaceGroup& fg = *fgPtr;
434  if((_bcMap[fg.id]->bcType == "WallBC")||(_bcMap[fg.id]->bcType == "RealWallBC"))
435  {
436  const StorageSite& faces = fg.site;
437  const CRConnectivity& BfaceCells=mesh.getFaceCells(faces);
438  const int faceCount=faces.getCount();
439  const int offSet=faces.getOffset();
440 
441  for(int i=offSet;i<offSet+faceCount;i++)
442  BCfArray[i]=2;
443 
444  for(int i=0;i<faceCount;i++)
445  {
446  int cell1=BfaceCells(i,0);
447  BCArray[cell1]=1;
448  }
449  }
450  else if(_bcMap[fg.id]->bcType == "VelocityInletBC")
451  {
452  const StorageSite& faces = fg.site;
453  const CRConnectivity& BfaceCells=mesh.getFaceCells(faces);
454  const int faceCount=faces.getCount();
455  const int offSet=faces.getOffset();
456 
457  for(int i=offSet;i<offSet+faceCount;i++)
458  BCfArray[i]=3;
459 
460  for(int i=0;i<faceCount;i++)
461  {
462  int cell1=BfaceCells(i,0);
463  BCArray[cell1]=1;
464  }
465  }
466  else if(_bcMap[fg.id]->bcType == "ZeroGradBC")
467  {
468  const StorageSite& faces = fg.site;
469  const CRConnectivity& BfaceCells=mesh.getFaceCells(faces);
470  const int faceCount=faces.getCount();
471  const int offSet=faces.getOffset();
472 
473  for(int i=offSet;i<offSet+faceCount;i++)
474  BCfArray[i]=4;
475 
476  for(int i=0;i<faceCount;i++)
477  {
478  int cell1=BfaceCells(i,0);
479  ZCArray[cell1]=1;
480  }
481  }
482  else if((_bcMap[fg.id]->bcType == "PressureInletBC")||(_bcMap[fg.id]->bcType == "PressureOutletBC"))
483  {
484  const StorageSite& faces = fg.site;
485  const CRConnectivity& BfaceCells=mesh.getFaceCells(faces);
486  const int faceCount=faces.getCount();
487  const int offSet=faces.getOffset();
488 
489  for(int i=offSet;i<offSet+faceCount;i++)
490  BCfArray[i]=5;
491  }
492  else if(_bcMap[fg.id]->bcType == "SymmetryBC")
493  {
494  const StorageSite& faces = fg.site;
495  const CRConnectivity& BfaceCells=mesh.getFaceCells(faces);
496  const int faceCount=faces.getCount();
497  const int offSet=faces.getOffset();
498 
499  for(int i=offSet;i<offSet+faceCount;i++)
500  BCfArray[i]=6;
501 
502  for(int i=0;i<faceCount;i++)
503  {
504  int cell1=BfaceCells(i,0);
505  BCArray[cell1]=1;
506  }
507  }
508  else
509  {
510  const StorageSite& faces = fg.site;
511  const int faceCount=faces.getCount();
512  const int offSet=faces.getOffset();
513 
514  for(int i=offSet;i<offSet+faceCount;i++)
515  BCfArray[i]=0;
516  }
517  }
518  foreach(const FaceGroupPtr fgPtr, mesh.getInterfaceGroups())
519  {
520  const FaceGroup& fg = *fgPtr;
521  const StorageSite& faces = fg.site;
522  const CRConnectivity& BfaceCells=mesh.getFaceCells(faces);
523  const int faceCount=faces.getCount();
524  const int offSet=faces.getOffset();
525 
526  for(int i=offSet;i<offSet+faceCount;i++)
527  BCfArray[i]=-1;
528  /*
529  if(MPI::COMM_WORLD.Get_rank()==1)
530  {
531  int fC = (mesh.getFaces()).getCount();
532  cout<<"level,rank,facecount,iID,offSet,ISize = "<<_level<<" "<<MPI::COMM_WORLD.Get_rank()<<" "<<fC<<" "<<fg.id<<" "<<offSet<<" "<<(offSet+faceCount)<<endl;
533  }
534  */
535  }
536 
537  const StorageSite& faces = mesh.getFaces();
538  const int faceCount = faces.getCount();
539  const CRConnectivity& faceCells=mesh.getFaceCells(faces);
540  const IntArray& ibType = dynamic_cast<const IntArray&>(_geomFields.ibType[cells]);
541  for(int i=0;i<faceCount;i++)
542  {
543  const int c0 = faceCells(i,0);
544  const int c1 = faceCells(i,1);
545  if (((ibType[c0] == Mesh::IBTYPE_FLUID) && (ibType[c1] == Mesh::IBTYPE_BOUNDARY)) ||
546  ((ibType[c1] == Mesh::IBTYPE_FLUID) && (ibType[c0] == Mesh::IBTYPE_BOUNDARY)))
547  {
548  BCfArray[i]=7;
549  }
550  }
551 
552  int count = 0;
553  for(int c=0;c<cells.getSelfCount();c++)
554  {
555  if(ibType[c] != Mesh::IBTYPE_FLUID)
556  count++;
557  }
558 #ifdef FVM_PARALLEL
559  MPI::COMM_WORLD.Allreduce( MPI::IN_PLACE, &count, 1, MPI::INT, MPI::SUM);
560  if((MPI::COMM_WORLD.Get_rank()==0)&&(_level==0))
561  cout<<"number of non-fluid cells in mesh at level "<<_level<<" = "<<count<<endl;
562 #endif
563 
564 #ifndef FVM_PARALLEL
565  if(_level==0)
566  cout<<"number of non-fluid cells in mesh at level "<<_level<<" = "<<count<<endl;
567 #endif
568  _niters =0;
570  //_initialKmodelvNorm = MFRPtr();
571 
572  }
573  }
const MeshList & _finestMeshes
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
Array< int > BCcellArray
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
GeomFields & _geomFields
int getSelfCount() const
Definition: StorageSite.h:40
Field coeffg
Definition: MacroFields.h:32
Definition: Mesh.h:28
Quadrature< T > & _quadrature
Array< T > TArray
Definition: Field.h:14
Field Stress
Definition: MacroFields.h:37
Field EntropyGenRate_Collisional
Definition: MacroFields.h:35
Definition: Mesh.h:49
Field InterfaceVelocity
Definition: MacroFields.h:39
COMETModelOptions< T > _options
Field EntropyGenRate
Definition: MacroFields.h:34
Field Entropy
Definition: MacroFields.h:33
Vector< T, 6 > VectorT6
Field InterfacePressure
Definition: MacroFields.h:40
string groupType
Definition: Mesh.h:42
Field ibType
Definition: GeomFields.h:38
Field viscosity
Definition: MacroFields.h:20
Field fineToCoarse
Definition: GeomFields.h:41
Field temperature
Definition: MacroFields.h:22
const int id
Definition: Mesh.h:41
map< int, vector< int > > _faceReflectionArrayMap
Array< VectorT3 > VectorT3Array
GeomFields & _finestGeomFields
Field coeff
Definition: MacroFields.h:31
const StorageSite & getFaces() const
Definition: Mesh.h:108
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
Array< StressTensorT6 > StressTensorArray
const StorageSite & getCells() const
Definition: Mesh.h:109
Array< VectorT6 > VectorT6Array
int getCountLevel1() const
Definition: StorageSite.h:72
void addArray(const StorageSite &, shared_ptr< ArrayBase > a)
Definition: Field.cpp:72
Vector< T, 5 > VectorT5
const CRConnectivity & getFaceCells(const StorageSite &site) const
Definition: Mesh.cpp:388
Array< VectorT10 > VectorT10Array
Definition: Array.h:14
Field velocity
Definition: MacroFields.h:15
int getOffset() const
Definition: StorageSite.h:87
Field pressure
Definition: MacroFields.h:19
Field InterfaceStress
Definition: MacroFields.h:41
Field finestToCoarse
Definition: GeomFields.h:42
int getCount() const
Definition: StorageSite.h:39
Vector< T, 10 > VectorT10
shared_ptr< MultiFieldReduction > MFRPtr
Array< int > IntArray
Field area
Definition: GeomFields.h:23
const FaceGroupList & getInterfaceGroups() const
Definition: Mesh.h:190
Field collisionFrequency
Definition: MacroFields.h:24
Field areaMag
Definition: GeomFields.h:25
void syncLocal()
Definition: Field.cpp:334
int getID() const
Definition: Mesh.h:106
Field density
Definition: MacroFields.h:21
Array< int > BCfaceArray
Array< VectorT5 > VectorT5Array
StorageSite site
Definition: Mesh.h:40
Field InterfaceDensity
Definition: MacroFields.h:42
template<class T >
void COMETModel< T >::initCoarse ( )
inline

Definition at line 685 of file phononbase/COMETModel.h.

References COMETModel< T >::_BCells, COMETModel< T >::_bcMap, COMETModel< T >::_BFaces, COMETModel< T >::_geomFields, COMETModel< T >::_IClist, COMETModel< T >::_kspaces, COMETModel< T >::_macro, Model::_meshes, COMETModel< T >::_MeshKspaceMap, COMETModel< T >::_options, Field::addArray(), COMETModel< T >::applyTemperatureBoundaries(), pmode< T >::calce0(), PhononMacro::deltaT, COMETIC< T >::FgID0, COMETIC< T >::FgID1, GeomFields::fineToCoarse, Mesh::getBoundaryFaceGroups(), Mesh::getCells(), StorageSite::getCount(), Mesh::getFaceCells(), Mesh::getFaceGroup(), Kspace< T >::getGlobalIndex(), Mesh::getInterfaceGroups(), Kspace< T >::getkvol(), Kspace< T >::getlength(), kvol< T >::getmode(), kvol< T >::getmodenum(), StorageSite::getOffset(), pmode< T >::gettau(), Kspace< T >::gettotmodes(), FaceGroup::id, COMETIC< T >::MeshID0, COMETIC< T >::MeshID1, Kspace< T >::sete0Array(), Kspace< T >::seteArray(), Kspace< T >::setFASArray(), Kspace< T >::setInjArray(), COMETModel< T >::setLocalScatterMaps(), Kspace< T >::setResArray(), Kspace< T >::setSourceArray(), Kspace< T >::setTauArray(), FaceGroup::site, PhononMacro::temperature, PhononMacro::TlFASCorrection, PhononMacro::TlInjected, PhononMacro::TlResidual, and Kspace< T >::updateTau().

686  {
687  const int numMeshes=_meshes.size();
688  const T Tinit=_options["initialTemperature"];
689 
690  for (int n=0;n<numMeshes;n++)
691  {
692  Mesh& mesh=*_meshes[n];
693  Tkspace& kspace=*_kspaces[_MeshKspaceMap[n]];
694  const int numK=kspace.getlength();
695  const StorageSite& cells=mesh.getCells();
696  const int numcells=cells.getCount();
697  const int kcount=kspace.gettotmodes();
698 
699  shared_ptr<TArray> eArray(new TArray(numcells*kcount));
700  shared_ptr<TArray> e0Array(new TArray(numcells*kcount));
701  shared_ptr<TArray> ResidArray(new TArray(numcells*kcount));
702  shared_ptr<TArray> InjArray(new TArray(numcells*kcount));
703  shared_ptr<TArray> FASArray(new TArray(numcells*kcount));
704  shared_ptr<TArray> tauArray(new TArray(numcells*kcount));
705  kspace.seteArray(eArray);
706  kspace.sete0Array(e0Array);
707  kspace.setResArray(ResidArray);
708  kspace.setInjArray(InjArray);
709  kspace.setFASArray(FASArray);
710  kspace.setTauArray(tauArray);
711 
712  if(_options.Source)
713  {
714  shared_ptr<TArray> SrcArray(new TArray(numcells*kcount));
715  SrcArray->zero();
716  kspace.setSourceArray(SrcArray);
717  }
718 
719  shared_ptr<TArray> TLcell(new TArray(numcells));
720  shared_ptr<TArray> deltaTcell(new TArray(numcells));
721  *deltaTcell=0.;
722  *TLcell=Tinit;
723  _macro.temperature.addArray(cells,TLcell);
724  _macro.deltaT.addArray(cells,deltaTcell);
725 
726  shared_ptr<IntArray> f2c(new IntArray(numcells));
727  *f2c=-1;
728  _geomFields.fineToCoarse.addArray(cells, f2c);
729 
730  for(int c=0;c<numcells;c++)
731  {
732  int cellIndex=kspace.getGlobalIndex(c,0);
733  for (int k=0;k<numK;k++)
734  {
735  Tkvol& kv=kspace.getkvol(k);
736  const int numM=kv.getmodenum();
737 
738  for (int m=0;m<numM;m++)
739  {
740  Tmode& mode=kv.getmode(m);
741  const T einit=mode.calce0(Tinit);
742  T tau=mode.gettau();
743  (*eArray)[cellIndex]=einit;
744  (*e0Array)[cellIndex]=einit;
745  (*ResidArray)[cellIndex]=0.;
746  (*InjArray)[cellIndex]=0.;
747  (*FASArray)[cellIndex]=0.;
748  (*tauArray)[cellIndex]=tau;
749  cellIndex++;
750 
751  }
752  }
753  kspace.updateTau(c,Tinit);
754  }
755 
756  BCfaceArray& BCfArray=*(_BFaces[n]);
757  BCcellArray& BCArray=*(_BCells[n]);
758 
759  foreach(const FaceGroupPtr fgPtr, mesh.getInterfaceGroups())
760  {
761  FaceGroup& fg = *fgPtr;
762  const StorageSite& faces = fg.site;
763  //const CRConnectivity& BfaceCells=mesh.getFaceCells(faces);
764 
765  const int faceCount=faces.getCount();
766  const int offSet=faces.getOffset();
767 
768  for(int i=offSet;i<offSet+faceCount;i++)
769  BCfArray[i]=-1;
770  }
771 
772  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
773  {
774  FaceGroup& fg = *fgPtr;
775  if(fg.id>0)
776  {
777  if(_bcMap[fg.id]->bcType == "reflecting")
778  {
779  const StorageSite& faces = fg.site;
780  const CRConnectivity& BfaceCells=mesh.getFaceCells(faces);
781  const int faceCount=faces.getCount();
782  const int offSet=faces.getOffset();
783  const bool Imp=(*(_bcMap[fg.id]))["FullyImplicit"];
784 
785  if(Imp)
786  {
787  for(int i=offSet;i<offSet+faceCount;i++)
788  BCfArray[i]=2; //implicit boundary
789  }
790  else
791  {
792  for(int i=offSet;i<offSet+faceCount;i++)
793  BCfArray[i]=3; //explicit boundary
794  }
795 
796  if(Imp)
797  {
798  for(int i=0;i<faceCount;i++)
799  {
800  int cell1=BfaceCells(i,0);
801  if(BCArray[cell1]==0)
802  BCArray[cell1]=1; //implicit boundary only
803  else if(BCArray[cell1]==2)
804  BCArray[cell1]=3; //mix implicit/explicit boundary
805  }
806  }
807  else
808  {
809  for(int i=0;i<faceCount;i++)
810  {
811  int cell1=BfaceCells(i,0);
812  if(BCArray[cell1]==0)
813  BCArray[cell1]=2; //explicit boundary only
814  else if (BCArray[cell1]==1)
815  BCArray[cell1]=3; //mix implicit/explicit boundary
816  }
817  }
818  }
819  else if(_bcMap[fg.id]->bcType == "temperature")
820  {
821  const StorageSite& faces = fg.site;
822  const int faceCount=faces.getCount();
823  const int offSet=faces.getOffset();
824 
825  for(int i=offSet;i<offSet+faceCount;i++)
826  BCfArray[i]=1;
827  }
828  else if(_bcMap[fg.id]->bcType == "Interface")
829  {
830  StorageSite& faces0 = fg.site;
831  const CRConnectivity& BfaceCells=mesh.getFaceCells(faces0);
832  const int faceCount=faces0.getCount();
833  const int offSet=faces0.getOffset();
834 
835  for(int i=offSet;i<offSet+faceCount;i++)
836  {
837  BCfArray[i]=4; //Interface boundary
838  int cell0=BfaceCells(i-offSet,0);
839  BCArray[cell0]=2; //always treated explicitly
840  }
841 
842 
843 
844  /*
845  bool doneAlready=false;
846  foreach(const COMETIC<T>* icPtr, _IClist)
847  {
848  if(icPtr->FgID1==fg.id && icPtr->MeshID1==mesh.getID())
849  {
850  doneAlready=true;
851  break;
852  }
853  }
854 
855  if(!doneAlready)
856  {
857  bool foundMatch=false;
858  StorageSite* faces1Ptr=NULL;
859  int otherFgID,otherMid;
860  for(int otherMeshID=n+1;otherMeshID<numMeshes;otherMeshID++)
861  {
862  const Mesh& otherMesh=*_meshes[otherMeshID];
863  foreach(const FaceGroupPtr otherfgPtr, otherMesh.getAllFaceGroups())
864  {
865  foundMatch=mesh.COMETfindCommonFaces(faces0, otherfgPtr->site, _geomFields);
866  if(foundMatch)
867  {
868  otherFgID=otherfgPtr->id;
869  otherMid=otherMeshID;
870  faces1Ptr=&(otherfgPtr->site);
871  break;
872  }
873  }
874  if(foundMatch)
875  break;
876  }
877 
878  if(foundMatch)
879  {
880  StorageSite& faces1=*faces1Ptr;
881  const Mesh& mesh1=*_meshes[otherMid];
882  COMETIC<T>* icPtr(new COMETIC<T>(n,fg.id,mesh1.getID(),
883  otherFgID, faces1.getCount()));
884 
885  if(_bcMap[fg.id]->InterfaceModel!="DMM")
886  icPtr->InterfaceModel=_bcMap[fg.id]->InterfaceModel;
887 
888  setLocalScatterMaps(mesh, faces0, mesh1, faces1);
889 
890  _IClist.push_back(icPtr);
891  }
892  else
893  {
894  cout<<"Face Group: "<<fg.id<<" MeshID: "<<mesh.getID()<<endl;
895  throw CException("Could not find a matching face group!");
896  }
897  }
898 */
899  }
900  }
901  }
902 
903  TArrptr TlResidCell(new TArray(numcells));
904  *TlResidCell=0.;
905  _macro.TlResidual.addArray(cells,TlResidCell);
906  TArrptr TlInj(new TArray(numcells));
907  *TlInj=0.;
908  _macro.TlInjected.addArray(cells,TlInj);
909  TArrptr TlFAS(new TArray(numcells));
910  *TlFAS=0.;
911  _macro.TlFASCorrection.addArray(cells,TlFAS);
912  }
913 
914  /*
915  const int listSize=_IClist.size();
916  for(int ic=0;ic<listSize;ic++)
917  {
918  //finer level interface condition
919  COMETIC<T>* icPtr=_IClist[ic];
920  const int meshID0=icPtr->MeshID0;
921  const int meshID1=icPtr->MeshID1;
922  const int fgid0=icPtr->FgID0;
923  const int fgid1=icPtr->FgID1;
924 
925  //this level's interface condition
926  Mesh& mesh0this=*_meshes[meshID0];
927  const FaceGroup& fg0=mesh0this.getFaceGroup(fgid0);
928  const StorageSite& faces0=fg0.site;
929  const int faceCount=faces0.getCount();
930  COMETIC<T>* icPtr2(new COMETIC<T>(meshID0,fgid0,meshID1,
931  fgid1, faceCount));
932  _IClist[ic]=icPtr2;
933 
934  }
935 
936 
937  //Make map from mesh to IC
938  IntArray ICcount(numMeshes);
939  ICcount.zero();
940 
941  foreach(const COMETIC<T>* icPtr, _IClist)
942  {
943  ICcount[icPtr->MeshID0]++;
944  ICcount[icPtr->MeshID1]++;
945  }
946 
947  for(int i=0;i<numMeshes;i++)
948  {
949  IntArrPtr MeshToIC(new IntArray(ICcount[i]));
950  _MeshToIC.push_back(MeshToIC);
951  }
952 
953  ICcount.zero();
954  */
955  const int listSize=_IClist.size();
956  for(int i=0;i<listSize;i++)
957  {
958  COMETIC<T> ic=*_IClist[i];
959  const int m0=ic.MeshID0;
960  const int m1=ic.MeshID1;
961  const int fgid0=ic.FgID0;
962  const int fgid1=ic.FgID1;
963 
964  Mesh& mesh0=*_meshes[m0];
965  Mesh& mesh1=*_meshes[m1];
966 
967  FaceGroup& fg0=const_cast<FaceGroup&>(mesh0.getFaceGroup(fgid0));
968  FaceGroup& fg1=const_cast<FaceGroup&>(mesh1.getFaceGroup(fgid1));
969 
970  setLocalScatterMaps(mesh0,fg0.site,mesh1,fg1.site);
971  }
972 
973  /*
974  COMETInterface<T> ComInt(_meshes,_kspaces,_MeshKspaceMap,_macro,_geomFields);
975 
976  for(int ic=0;ic<listSize;ic++)
977  {
978  COMETIC<T>* icPtr=_IClist[ic];
979  if(icPtr->InterfaceModel=="DMM")
980  ComInt.makeDMMcoeffs(*icPtr);
981 
982  }
983  */
984 
986  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
Array< int > BCcellArray
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
GeomFields & _geomFields
Definition: Mesh.h:28
shared_ptr< TArray > TArrptr
Array< T > TArray
Field deltaT
Definition: PhononMacro.h:22
Field temperature
Definition: PhononMacro.h:21
const FaceGroup & getFaceGroup(const int fgId) const
Definition: Mesh.cpp:1570
Definition: Mesh.h:49
COMETModelOptions< T > _options
void setLocalScatterMaps(const Mesh &mesh0, StorageSite &faces0, const Mesh &mesh1, StorageSite &faces1)
Field fineToCoarse
Definition: GeomFields.h:41
const int id
Definition: Mesh.h:41
void applyTemperatureBoundaries()
Field TlResidual
Definition: PhononMacro.h:24
Field TlFASCorrection
Definition: PhononMacro.h:26
PhononMacro & _macro
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
MeshKspaceMap _MeshKspaceMap
Field TlInjected
Definition: PhononMacro.h:25
void addArray(const StorageSite &, shared_ptr< ArrayBase > a)
Definition: Field.cpp:72
const CRConnectivity & getFaceCells(const StorageSite &site) const
Definition: Mesh.cpp:388
int getOffset() const
Definition: StorageSite.h:87
int getCount() const
Definition: StorageSite.h:39
Array< int > IntArray
const FaceGroupList & getInterfaceGroups() const
Definition: Mesh.h:190
Kspace< T > Tkspace
Array< int > BCfaceArray
StorageSite site
Definition: Mesh.h:40
template<class T >
void COMETModel< T >::initFromOld ( )
inline

Definition at line 499 of file phononbase/COMETModel.h.

References COMETModel< T >::_BCells, COMETModel< T >::_bcMap, COMETModel< T >::_BFaces, COMETModel< T >::_geomFields, COMETModel< T >::_IClist, COMETModel< T >::_kspaces, COMETModel< T >::_macro, Model::_meshes, COMETModel< T >::_MeshKspaceMap, COMETModel< T >::_MeshToIC, COMETModel< T >::_residual, Mesh::COMETfindCommonFaces(), COMETIC< T >::FgID1, Mesh::getBoundaryFaceGroups(), StorageSite::getCount(), Mesh::getFaceCells(), Mesh::getID(), StorageSite::getOffset(), FaceGroup::id, COMETModel< T >::initializeTemperatureBoundaries(), COMETIC< T >::InterfaceModel, COMETModel< T >::MakeCoarseModel(), COMETInterface< T >::makeDMMcoeffs(), COMETIC< T >::MeshID0, COMETIC< T >::MeshID1, FaceGroup::site, COMETModel< T >::updateResid(), and Array< T >::zero().

500  {
501  const int numMeshes=_meshes.size();
502 
503  for (int n=0;n<numMeshes;n++)
504  {
505  Mesh& mesh=*_meshes[n];
506 
507  BCfaceArray& BCfArray=*(_BFaces[n]);
508  BCcellArray& BCArray=*(_BCells[n]);
509  //const StorageSite& cells=mesh.getCells();
510  //const int numcells=cells.getCount();
511 
512  //setting facegroups
513  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
514  {
515  FaceGroup& fg = *fgPtr;
516  if(fg.id>0)
517  {
518  if(_bcMap[fg.id]->bcType == "reflecting")
519  {
520  const StorageSite& faces = fg.site;
521  const CRConnectivity& BfaceCells=mesh.getFaceCells(faces);
522  const int faceCount=faces.getCount();
523  const int offSet=faces.getOffset();
524  const bool Imp=(*(_bcMap[fg.id]))["FullyImplicit"];
525 
526  if(Imp)
527  {
528  for(int i=offSet;i<offSet+faceCount;i++)
529  BCfArray[i]=2; //implicit boundary
530  }
531  else
532  {
533  for(int i=offSet;i<offSet+faceCount;i++)
534  BCfArray[i]=3; //explicit boundary
535  }
536 
537  if(Imp)
538  {
539  for(int i=0;i<faceCount;i++)
540  {
541  int cell1=BfaceCells(i,0);
542  if(BCArray[cell1]==0)
543  BCArray[cell1]=1; //implicit boundary only
544  else if(BCArray[cell1]==2)
545  BCArray[cell1]=3; //mix implicit/explicit boundary
546  }
547  }
548  else
549  {
550  for(int i=0;i<faceCount;i++)
551  {
552  int cell1=BfaceCells(i,0);
553  if(BCArray[cell1]==0)
554  BCArray[cell1]=2; //explicit boundary only
555  else if (BCArray[cell1]==1)
556  BCArray[cell1]=3; //mix implicit/explicit boundary
557  }
558  }
559  }
560  else if(_bcMap[fg.id]->bcType == "temperature")
561  {
562  const StorageSite& faces = fg.site;
563  const int faceCount=faces.getCount();
564  const int offSet=faces.getOffset();
565 
566  for(int i=offSet;i<offSet+faceCount;i++)
567  BCfArray[i]=1;
568  }
569  else if(_bcMap[fg.id]->bcType == "Interface")
570  {
571  StorageSite& faces0 = fg.site;
572  const CRConnectivity& BfaceCells=mesh.getFaceCells(faces0);
573  const int faceCount=faces0.getCount();
574  const int offSet=faces0.getOffset();
575 
576  for(int i=offSet;i<offSet+faceCount;i++)
577  {
578  BCfArray[i]=4; //Interface boundary
579  int cell0=BfaceCells(i-offSet,0);
580  int cell1=BfaceCells(i-offSet,1);
581  BCArray[cell0]=2; //always treated explicitly
582  BCArray[cell1]=4; //interface ghost cells need to be labeled
583  }
584 
585  bool doneAlready=false;
586  foreach(const COMETIC<T>* icPtr, _IClist)
587  {
588  if(icPtr->FgID1==fg.id && icPtr->MeshID1==mesh.getID())
589  {
590  doneAlready=true;
591  break;
592  }
593  }
594 
595  bool foundMatch=false;
596  if(!doneAlready)
597  {
598  StorageSite* faces1Ptr=NULL;
599  int otherFgID,otherMid;
600  for(int otherMeshID=n+1;otherMeshID<numMeshes;otherMeshID++)
601  {
602  const Mesh& otherMesh=*_meshes[otherMeshID];
603  foreach(const FaceGroupPtr otherfgPtr, otherMesh.getBoundaryFaceGroups())
604  {
605  foundMatch=mesh.COMETfindCommonFaces(faces0, otherfgPtr->site, _geomFields);
606  if(foundMatch)
607  {
608  otherFgID=otherfgPtr->id;
609  otherMid=otherMeshID;
610  faces1Ptr=&(otherfgPtr->site);
611  break;
612  }
613  }
614  if(foundMatch)
615  break;
616  }
617 
618  if(foundMatch)
619  {
620  StorageSite& faces1=*faces1Ptr;
621  const Mesh& mesh1=*_meshes[otherMid];
622  COMETIC<T>* icPtr(new COMETIC<T>(n,fg.id,mesh1.getID(),
623  otherFgID, faces1.getCount()));
624 
625  if(_bcMap[fg.id]->InterfaceModel!="DMM")
626  icPtr->InterfaceModel=_bcMap[fg.id]->InterfaceModel;
627 
628  _IClist.push_back(icPtr);
629  }
630  else if(!doneAlready && !foundMatch)
631  {
632  cout<<"Face Group: "<<fg.id<<" MeshID: "<<mesh.getID()<<endl;
633  throw CException("Could not find a matching face group!");
634  }
635  }
636  }// end if interface
637  }
638  }//end facegroup loop
639 
640  }//end meshes loop
641 
642  //Make map from mesh to IC
643  IntArray ICcount(numMeshes);
644  ICcount.zero();
645 
646  foreach(const COMETIC<T>* icPtr, _IClist)
647  {
648  ICcount[icPtr->MeshID0]++;
649  ICcount[icPtr->MeshID1]++;
650  }
651 
652  for(int i=0;i<numMeshes;i++)
653  {
654  IntArrPtr MeshToIC(new IntArray(ICcount[i]));
655  _MeshToIC.push_back(MeshToIC);
656  }
657 
658  ICcount.zero();
659  const int listSize=_IClist.size();
660  for(int ic=0;ic<listSize;ic++)
661  {
662  const COMETIC<T>* icPtr=_IClist[ic];
663  (*(_MeshToIC[icPtr->MeshID0]))[ICcount[icPtr->MeshID0]]=ic;
664  (*(_MeshToIC[icPtr->MeshID1]))[ICcount[icPtr->MeshID1]]=ic;
665  ICcount[icPtr->MeshID0]++;
666  ICcount[icPtr->MeshID1]++;
667  }
668 
670 
671  for(int ic=0;ic<listSize;ic++)
672  {
673  COMETIC<T>* icPtr=_IClist[ic];
674  if(icPtr->InterfaceModel=="DMM")
675  ComInt.makeDMMcoeffs(*icPtr);
676  }
677 
679  _residual=updateResid(false);
680  //cout<<"Creating Coarse Levels..."<<endl;
681  MakeCoarseModel(this);
682  //cout<<"Coarse Levels Completed."<<endl;
683  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
Array< int > BCcellArray
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
GeomFields & _geomFields
T updateResid(const bool addFAS)
Definition: Mesh.h:28
bool COMETfindCommonFaces(StorageSite &faces, StorageSite &otherFaces, const GeomFields &geomFields)
Definition: Mesh.cpp:1053
Definition: Mesh.h:49
const int id
Definition: Mesh.h:41
shared_ptr< IntArray > IntArrPtr
PhononMacro & _macro
string InterfaceModel
const MeshList _meshes
Definition: Model.h:29
MeshKspaceMap _MeshKspaceMap
const CRConnectivity & getFaceCells(const StorageSite &site) const
Definition: Mesh.cpp:388
int getOffset() const
Definition: StorageSite.h:87
int getCount() const
Definition: StorageSite.h:39
void initializeTemperatureBoundaries()
Array< int > IntArray
int getID() const
Definition: Mesh.h:106
void MakeCoarseModel(TCOMET *finerModel)
Array< int > BCfaceArray
StorageSite site
Definition: Mesh.h:40
template<class T >
void COMETModel< T >::initializeCoarseMaxwellian ( )
inline

Definition at line 2146 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfPtr0, COMETModel< T >::_dsfPtrFAS, COMETModel< T >::_dsfPtrRes, Model::_meshes, COMETModel< T >::_quadrature, Mesh::getCells(), and StorageSite::getCount().

Referenced by COMETModel< T >::MakeIBCoarseModel().

2147  {
2148  const int numMeshes = _meshes.size();
2149  const T zero(0.);
2150  for (int n=0; n<numMeshes; n++)
2151  {
2152  const Mesh& mesh = *_meshes[n];
2153  const StorageSite& cells = mesh.getCells();
2154  const int nCells = cells.getCount();
2155  const int numFields= _quadrature.getDirCount();
2156 
2157  for(int j=0;j< numFields;j++){
2158  Field& fnd0 = *_dsfPtr0.dsf[j];
2159  Field& fndFAS = *_dsfPtrFAS.dsf[j];
2160  Field& fndRes = *_dsfPtrRes.dsf[j];
2161  TArray& f0 = dynamic_cast< TArray&>(fnd0[cells]);
2162  TArray& fFAS = dynamic_cast< TArray&>(fndFAS[cells]);
2163  TArray& fRes = dynamic_cast< TArray&>(fndRes[cells]);
2164  for(int c=0; c<nCells;c++){
2165  f0[c]=zero;
2166  fFAS[c]=zero;
2167  fRes[c]=zero;
2168 
2169  }
2170  }
2171  }
2172  }
Quadrature< T > & _quadrature
Array< T > TArray
Definition: Field.h:14
Definition: Mesh.h:49
DistFunctFields< T > _dsfPtrFAS
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
DistFunctFields< T > _dsfPtr0
DistFunctFields< T > _dsfPtrRes
int getCount() const
Definition: StorageSite.h:39
template<class T >
void COMETModel< T >::InitializeFgammaCoefficients ( )
inline

Definition at line 1089 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_options, MacroFields::coeff, MacroFields::coeffg, MacroFields::density, Mesh::getCells(), StorageSite::getCount(), MacroFields::temperature, MacroFields::Txx, MacroFields::Txy, MacroFields::Tyy, MacroFields::Tyz, MacroFields::Tzx, and MacroFields::Tzz.

1090  {
1091  const int numMeshes =_meshes.size();
1092  for (int n=0; n<numMeshes; n++)
1093  {
1094  const Mesh& mesh = *_meshes[n];
1095  const StorageSite& cells = mesh.getCells();
1096  const int nCells = cells.getCount();
1097  // const double pi(3.14159);
1098  const double pi=_options.pi;
1099 
1100  TArray& density = dynamic_cast<TArray&>(_macroFields.density[cells]);
1101  TArray& temperature = dynamic_cast<TArray&>(_macroFields.temperature[cells]);
1102  VectorT5Array& coeff = dynamic_cast<VectorT5Array&>(_macroFields.coeff[cells]);
1103  VectorT10Array& coeffg = dynamic_cast<VectorT10Array&>(_macroFields.coeffg[cells]);
1104  TArray& Txx = dynamic_cast<TArray&>(_macroFields.Txx[cells]);
1105  TArray& Tyy = dynamic_cast<TArray&>(_macroFields.Tyy[cells]);
1106  TArray& Tzz = dynamic_cast<TArray&>(_macroFields.Tzz[cells]);
1107  TArray& Txy = dynamic_cast<TArray&>(_macroFields.Txy[cells]);
1108  TArray& Tyz = dynamic_cast<TArray&>(_macroFields.Tyz[cells]);
1109  TArray& Tzx = dynamic_cast<TArray&>(_macroFields.Tzx[cells]);
1110 
1111  for(int c=0; c<nCells;c++)
1112  {
1113 
1114  //BGK
1115  coeff[c][0]=density[c]/pow((pi*temperature[c]),1.5);
1116  coeff[c][1]=1/temperature[c];
1117  coeff[c][2]=0.0;coeff[c][3]=0.0;coeff[c][4]=0.0;
1118 
1119  if(_options.fgamma ==2){
1120  //ESBGK
1121  coeffg[c][0]=coeff[c][0];
1122  coeffg[c][1]=coeff[c][1];
1123  coeffg[c][2]=coeff[c][2];
1124  coeffg[c][3]=coeff[c][1];
1125  coeffg[c][4]=coeff[c][3];
1126  coeffg[c][5]=coeff[c][1];
1127  coeffg[c][6]=coeff[c][4];
1128  coeffg[c][7]=0.0;
1129  coeffg[c][8]=0.0;
1130  coeffg[c][9]=0.0;
1131 
1132  Txx[c]=0.5*temperature[c];
1133  Tyy[c]=0.5*temperature[c];
1134  Tzz[c]=0.5*temperature[c];
1135  Txy[c]=0.0;
1136  Tyz[c]=0.0;
1137  Tzx[c]=0.0;
1138  }
1139  }
1140  }
1141  }
Field coeffg
Definition: MacroFields.h:32
Array< T > TArray
Definition: Mesh.h:49
COMETModelOptions< T > _options
Field temperature
Definition: MacroFields.h:22
Field coeff
Definition: MacroFields.h:31
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
Array< VectorT10 > VectorT10Array
int getCount() const
Definition: StorageSite.h:39
Field density
Definition: MacroFields.h:21
Array< VectorT5 > VectorT5Array
template<class T >
void COMETModel< T >::initializeFineMaxwellian ( )
inline

Definition at line 2110 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfPtr0, COMETModel< T >::_dsfPtrRes, COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_options, COMETModel< T >::_quadrature, MacroFields::density, Mesh::getCells(), StorageSite::getCount(), MacroFields::temperature, and MacroFields::velocity.

Referenced by COMETModel< T >::COMETModel().

2111  {
2112  const int numMeshes = _meshes.size();
2113  const T zero(0.);
2114  for (int n=0; n<numMeshes; n++)
2115  {
2116  const Mesh& mesh = *_meshes[n];
2117  const StorageSite& cells = mesh.getCells();
2118  const int nCells = cells.getCount();
2119 
2120  const double pi=_options.pi;
2121  const TArray& density = dynamic_cast<const TArray&>(_macroFields.density[cells]);
2122  const TArray& temperature = dynamic_cast<const TArray&>(_macroFields.temperature[cells]);
2123  const VectorT3Array& v = dynamic_cast<const VectorT3Array&>(_macroFields.velocity[cells]);
2124 
2125  const TArray& cx = dynamic_cast<const TArray&>(*_quadrature.cxPtr);
2126  const TArray& cy = dynamic_cast<const TArray&>(*_quadrature.cyPtr);
2127  const TArray& cz = dynamic_cast<const TArray&>(*_quadrature.czPtr);
2128  const int numFields= _quadrature.getDirCount();
2129 
2130  for(int j=0;j< numFields;j++){
2131  Field& fnd0 = *_dsfPtr0.dsf[j];
2132  Field& fndRes = *_dsfPtrRes.dsf[j];
2133  TArray& f0 = dynamic_cast< TArray&>(fnd0[cells]);
2134  TArray& fRes = dynamic_cast< TArray&>(fndRes[cells]);
2135  for(int c=0; c<nCells;c++){
2136  f0[c]=density[c]/pow((pi*temperature[c]),1.5)*
2137  exp(-(pow((cx[j]-v[c][0]),2.0)+pow((cy[j]-v[c][1]),2.0)+
2138  pow((cz[j]-v[c][2]),2.0))/temperature[c]);
2139  fRes[c]=zero;
2140 
2141  }
2142  }
2143  }
2144  }
Quadrature< T > & _quadrature
Array< T > TArray
Definition: Field.h:14
Definition: Mesh.h:49
COMETModelOptions< T > _options
Field temperature
Definition: MacroFields.h:22
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
Field velocity
Definition: MacroFields.h:15
DistFunctFields< T > _dsfPtr0
DistFunctFields< T > _dsfPtrRes
int getCount() const
Definition: StorageSite.h:39
Field density
Definition: MacroFields.h:21
template<class T >
void COMETModel< T >::InitializeMacroparameters ( )
inline

Definition at line 1021 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_options, MacroFields::coeff, MacroFields::coeffg, MacroFields::density, MacroFields::Entropy, Mesh::getCells(), StorageSite::getCount(), MacroFields::Knq, MacroFields::pressure, MacroFields::temperature, MacroFields::Txx, MacroFields::Txy, MacroFields::Tyy, MacroFields::Tyz, MacroFields::Tzx, MacroFields::Tzz, and MacroFields::velocity.

Referenced by COMETModel< T >::COMETModel(), and COMETModel< T >::MakeIBCoarseModel().

1022  { const int numMeshes =_meshes.size();
1023  for (int n=0; n<numMeshes; n++)
1024  {
1025  const Mesh& mesh = *_meshes[n];
1026  const StorageSite& cells = mesh.getCells();
1027  const int nCells = cells.getCount();
1028  // const double pi(3.14159);
1029  const double pi=_options.pi;
1030  TArray& Entropy = dynamic_cast<TArray&>(_macroFields.Entropy[cells]);
1031  TArray& density = dynamic_cast<TArray&>(_macroFields.density[cells]);
1032  VectorT3Array& v = dynamic_cast<VectorT3Array&>(_macroFields.velocity[cells]);
1033 
1034  TArray& temperature = dynamic_cast<TArray&>(_macroFields.temperature[cells]);
1035  TArray& pressure = dynamic_cast<TArray&>(_macroFields.pressure[cells]);
1036 
1037  VectorT5Array& coeff = dynamic_cast<VectorT5Array&>(_macroFields.coeff[cells]);
1038  VectorT10Array& coeffg = dynamic_cast<VectorT10Array&>(_macroFields.coeffg[cells]);
1039  TArray& Txx = dynamic_cast<TArray&>(_macroFields.Txx[cells]);
1040  TArray& Tyy = dynamic_cast<TArray&>(_macroFields.Tyy[cells]);
1041  TArray& Tzz = dynamic_cast<TArray&>(_macroFields.Tzz[cells]);
1042  TArray& Txy = dynamic_cast<TArray&>(_macroFields.Txy[cells]);
1043  TArray& Tyz = dynamic_cast<TArray&>(_macroFields.Tyz[cells]);
1044  TArray& Tzx = dynamic_cast<TArray&>(_macroFields.Tzx[cells]);
1045  //if ( MPI::COMM_WORLD.Get_rank() == 0 ) {cout << "ncells="<<nCells<<endl;}
1046 
1047  TArray& Knq = dynamic_cast<TArray&>(_macroFields.Knq[cells]);
1048  //initialize density,velocity
1049  for(int c=0; c<nCells;c++)
1050  {
1051  density[c] =1.0;
1052  v[c][0]=0.0;
1053  v[c][1]=0.0;
1054  v[c][2]=0.0;
1055  temperature[c]=1.0;
1056  pressure[c]=temperature[c]*density[c];
1057 
1058  //BGK
1059  coeff[c][0]=density[c]/pow((pi*temperature[c]),1.5);
1060  coeff[c][1]=1/temperature[c];
1061  coeff[c][2]=0.0;coeff[c][3]=0.0;coeff[c][4]=0.0;
1062 
1063  Entropy[c]=0.0;
1064  if(_options.fgamma ==2){
1065  //ESBGK
1066  coeffg[c][0]=coeff[c][0];
1067  coeffg[c][1]=coeff[c][1];
1068  coeffg[c][2]=coeff[c][2];
1069  coeffg[c][3]=coeff[c][1];
1070  coeffg[c][4]=coeff[c][3];
1071  coeffg[c][5]=coeff[c][1];
1072  coeffg[c][6]=coeff[c][4];
1073  coeffg[c][7]=0.0;
1074  coeffg[c][8]=0.0;
1075  coeffg[c][9]=0.0;
1076  }
1077 
1078  Txx[c]=0.5;
1079  Tyy[c]=0.5;
1080  Tzz[c]=0.5;
1081  Txy[c]=0.0;
1082  Tyz[c]=0.0;
1083  Tzx[c]=0.0;
1084 
1085  Knq[c]=0.0;
1086  }
1087  }
1088  }
Field coeffg
Definition: MacroFields.h:32
Array< T > TArray
Definition: Mesh.h:49
COMETModelOptions< T > _options
Field Entropy
Definition: MacroFields.h:33
Field temperature
Definition: MacroFields.h:22
Field coeff
Definition: MacroFields.h:31
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
Array< VectorT10 > VectorT10Array
Field velocity
Definition: MacroFields.h:15
Field pressure
Definition: MacroFields.h:19
int getCount() const
Definition: StorageSite.h:39
Field density
Definition: MacroFields.h:21
Array< VectorT5 > VectorT5Array
template<class T >
void COMETModel< T >::initializeMaxwellian ( )
inline

Definition at line 2057 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfPtr, COMETModel< T >::_dsfPtr1, COMETModel< T >::_dsfPtr2, COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_options, COMETModel< T >::_quadrature, MacroFields::density, Mesh::getCells(), StorageSite::getCount(), MacroFields::temperature, and MacroFields::velocity.

Referenced by COMETModel< T >::COMETModel(), and COMETModel< T >::MakeIBCoarseModel().

2058  {
2059  const int numMeshes = _meshes.size();
2060  for (int n=0; n<numMeshes; n++)
2061  {
2062  const Mesh& mesh = *_meshes[n];
2063  const StorageSite& cells = mesh.getCells();
2064  const int nCells = cells.getCount();
2065 
2066  const double pi=_options.pi;
2067  const TArray& density = dynamic_cast<const TArray&>(_macroFields.density[cells]);
2068  const TArray& temperature = dynamic_cast<const TArray&>(_macroFields.temperature[cells]);
2069  const VectorT3Array& v = dynamic_cast<const VectorT3Array&>(_macroFields.velocity[cells]);
2070 
2071  const TArray& cx = dynamic_cast<const TArray&>(*_quadrature.cxPtr);
2072  const TArray& cy = dynamic_cast<const TArray&>(*_quadrature.cyPtr);
2073  const TArray& cz = dynamic_cast<const TArray&>(*_quadrature.czPtr);
2074  const int numFields= _quadrature.getDirCount();
2075 
2076  for(int j=0;j< numFields;j++){
2077  Field& fnd = *_dsfPtr.dsf[j];
2078  TArray& f = dynamic_cast< TArray&>(fnd[cells]);
2079  for(int c=0; c<nCells;c++){
2080  f[c]=density[c]/pow((pi*temperature[c]),1.5)*
2081  exp(-(pow((cx[j]-v[c][0]),2.0)+pow((cy[j]-v[c][1]),2.0)+
2082  pow((cz[j]-v[c][2]),2.0))/temperature[c]);
2083 
2084 
2085  }
2086 
2087  if (_options.transient)
2088  //updateTime();
2089 
2090  {
2091  Field& fnd1 = *_dsfPtr1.dsf[j];
2092  TArray& f1 = dynamic_cast< TArray&>(fnd1[cells]);
2093  for (int c=0;c<nCells;c++)
2094  f1[c] = f[c];
2095  //cout << "discretization order " << _options.timeDiscretizationOrder << endl ;
2096  if (_options.timeDiscretizationOrder > 1)
2097  {
2098  Field& fnd2 = *_dsfPtr2.dsf[j];
2099  TArray& f2 = dynamic_cast< TArray&>(fnd2[cells]);
2100  for (int c=0;c<nCells;c++)
2101  f2[c] = f[c];
2102  }
2103  }
2104 
2105 
2106  }
2107  }
2108  }
DistFunctFields< T > _dsfPtr2
Quadrature< T > & _quadrature
Array< T > TArray
Definition: Field.h:14
Definition: Mesh.h:49
COMETModelOptions< T > _options
Field temperature
Definition: MacroFields.h:22
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
Field velocity
Definition: MacroFields.h:15
DistFunctFields< T > _dsfPtr
int getCount() const
Definition: StorageSite.h:39
DistFunctFields< T > _dsfPtr1
Field density
Definition: MacroFields.h:21
template<class T >
void COMETModel< T >::initializeMaxwellianEq ( )
inline

Definition at line 1620 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfEqPtr, COMETModel< T >::_dsfEqPtrES, COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_options, COMETModel< T >::_quadrature, MacroFields::coeff, MacroFields::coeffg, Mesh::getCells(), StorageSite::getCount(), and MacroFields::velocity.

Referenced by COMETModel< T >::COMETModel(), COMETModel< T >::cycle(), COMETModel< T >::MakeIBCoarseModel(), and COMETModel< T >::smooth().

1621  {
1622  const int numMeshes = _meshes.size();
1623  for (int n=0; n<numMeshes; n++)
1624  {
1625  const Mesh& mesh = *_meshes[n];
1626  const StorageSite& cells = mesh.getCells();
1627  const int nCells = cells.getCount();
1628  const VectorT3Array& v = dynamic_cast<const VectorT3Array&>(_macroFields.velocity[cells]);
1629  const VectorT5Array& coeff = dynamic_cast<VectorT5Array&>(_macroFields.coeff[cells]);
1630  const VectorT10Array& coeffg = dynamic_cast<VectorT10Array&>(_macroFields.coeffg[cells]);
1631 
1632  const TArray& cx = dynamic_cast<const TArray&>(*_quadrature.cxPtr);
1633  const TArray& cy = dynamic_cast<const TArray&>(*_quadrature.cyPtr);
1634  const TArray& cz = dynamic_cast<const TArray&>(*_quadrature.czPtr);
1635  const int numFields= _quadrature.getDirCount();
1636 
1637  for(int j=0;j< numFields;j++){
1638  Field& fndEq = *_dsfEqPtr.dsf[j];
1639  TArray& fEq = dynamic_cast< TArray&>(fndEq[cells]);
1640  for(int c=0; c<nCells;c++){
1641  fEq[c]=coeff[c][0]*exp(-coeff[c][1]*(pow(cx[j]-v[c][0],2)+pow(cy[j]-v[c][1],2)
1642  +pow(cz[j]-v[c][2],2))+coeff[c][2]*(cx[j]-v[c][0])
1643  +coeff[c][3]*(cy[j]-v[c][1])+coeff[c][4]*(cz[j]-v[c][2]));
1644  }
1645  }
1646 
1647  if(_options.fgamma==2){
1648 
1649  for(int j=0;j< numFields;j++){
1650  Field& fndEqES = *_dsfEqPtrES.dsf[j];
1651  TArray& fEqES = dynamic_cast< TArray&>(fndEqES[cells]);
1652  for(int c=0; c<nCells;c++){
1653  T Cc1=(cx[j]-v[c][0]);
1654  T Cc2=(cy[j]-v[c][1]);
1655  T Cc3=(cz[j]-v[c][2]);
1656  fEqES[c]=coeffg[c][0]*exp(-coeffg[c][1]*pow(Cc1,2)+coeffg[c][2]*Cc1
1657  -coeffg[c][3]*pow(Cc2,2)+coeffg[c][4]*Cc2
1658  -coeffg[c][5]*pow(Cc3,2)+coeffg[c][6]*Cc3
1659  +coeffg[c][7]*cx[j]*cy[j]+coeffg[c][8]*cy[j]*cz[j]
1660  +coeffg[c][9]*cz[j]*cx[j]);
1661  }
1662  }
1663  }
1664 
1665 
1666 
1667  }
1668  }
Field coeffg
Definition: MacroFields.h:32
Quadrature< T > & _quadrature
Array< T > TArray
Definition: Field.h:14
Definition: Mesh.h:49
COMETModelOptions< T > _options
Field coeff
Definition: MacroFields.h:31
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
DistFunctFields< T > _dsfEqPtrES
Array< VectorT10 > VectorT10Array
Field velocity
Definition: MacroFields.h:15
int getCount() const
Definition: StorageSite.h:39
DistFunctFields< T > _dsfEqPtr
Array< VectorT5 > VectorT5Array
template<class T >
void COMETModel< T >::initializeTemperatureBoundaries ( )
inline

Definition at line 1045 of file phononbase/COMETModel.h.

References COMETModel< T >::_bcMap, COMETModel< T >::_geomFields, COMETModel< T >::_kspaces, Model::_meshes, COMETModel< T >::_MeshKspaceMap, COMETModel< T >::_options, COMETBoundary< T >::applyTemperatureWallCoarse(), COMETBoundary< T >::applyTemperatureWallFine(), COMETBC< T >::bcType, Mesh::getBoundaryFaceGroups(), FloatVarDict< T >::getVal(), FaceGroup::id, and FaceGroup::site.

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

1046  {
1047  const int numMeshes=_meshes.size();
1048 
1049  for(int n=0;n<numMeshes;n++)
1050  {
1051  const Mesh& mesh=*_meshes[n];
1052  Tkspace& kspace=*_kspaces[_MeshKspaceMap[n]];
1053  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
1054  {
1055  const FaceGroup& fg = *fgPtr;
1056  if(fg.id>0)
1057  {
1058  const StorageSite& faces = fg.site;
1059  const COMETBC<T>& bc = *_bcMap[fg.id];
1060 
1061  COMETBoundary<T> cbc(faces, mesh,_geomFields,kspace,_options,fg.id);
1062 
1063  if(bc.bcType=="temperature")
1064  {
1066  bTemperature(bc.getVal("specifiedTemperature"),faces);
1067 
1068 
1069  cbc.applyTemperatureWallCoarse(bTemperature);
1070 
1071  if(_options.Convection=="SecondOrder")
1072  cbc.applyTemperatureWallFine(bTemperature);
1073 
1074  }
1075  }
1076  }
1077  }
1078  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
GeomFields & _geomFields
Definition: Mesh.h:28
Definition: Mesh.h:49
COMETModelOptions< T > _options
FloatVal< T > getVal(const string varName) const
Definition: FloatVarDict.h:85
const int id
Definition: Mesh.h:41
string bcType
const MeshList _meshes
Definition: Model.h:29
MeshKspaceMap _MeshKspaceMap
Kspace< T > Tkspace
StorageSite site
Definition: Mesh.h:40
template<class T >
void COMETModel< T >::injectResid ( )
inline

Definition at line 2988 of file phononbase/COMETModel.h.

References COMETModel< T >::_coarserLevel, COMETModel< T >::_geomFields, COMETModel< T >::_kspaces, COMETModel< T >::_macro, Model::_meshes, COMETModel< T >::_MeshKspaceMap, Mesh::getCells(), Mesh::getConnectivity(), StorageSite::getCount(), CRConnectivity::getCount(), Kspace< T >::geteArray(), Kspace< T >::getFASArray(), Kspace< T >::getGlobalIndex(), Kspace< T >::getInjArray(), COMETModel< T >::getKspace(), Kspace< T >::getkvol(), Kspace< T >::getlength(), COMETModel< T >::getMacro(), COMETModel< T >::getMeshList(), kvol< T >::getmodenum(), Kspace< T >::getResArray(), StorageSite::getSelfCount(), PhononMacro::temperature, PhononMacro::TlFASCorrection, PhononMacro::TlInjected, PhononMacro::TlResidual, GeomFields::volume, and Array< T >::zero().

2989  {
2990  const int numMeshes = _meshes.size();
2991 
2992  for (int n=0; n<numMeshes; n++)
2993  {
2994  const Mesh& finerMesh=*_meshes[n];
2995  int Knum=_MeshKspaceMap[n];
2996  Tkspace& finerKspace=*_kspaces[Knum];
2997  const Mesh& coarserMesh=*(_coarserLevel->getMeshList())[n];
2998  Tkspace& coarserKspace=_coarserLevel->getKspace(Knum);
2999  PhononMacro& coarserMacro=_coarserLevel->getMacro();
3000  const StorageSite& finerCells=finerMesh.getCells();
3001  const StorageSite& coarserCells=coarserMesh.getCells();
3002  const CRConnectivity& CoarserToFiner=coarserMesh.getConnectivity(coarserCells,finerCells);
3003  const TArray& coarserVol=dynamic_cast<TArray&>(_geomFields.volume[coarserCells]);
3004  const TArray& finerVol=dynamic_cast<TArray&>(_geomFields.volume[finerCells]);
3005 
3006  TArray& coarserVar=coarserKspace.geteArray();
3007  TArray& coarserInj=coarserKspace.getInjArray();
3008  TArray& coarserFAS=coarserKspace.getFASArray();
3009  TArray& finerVar=finerKspace.geteArray();
3010  TArray& finerRes=finerKspace.getResArray();
3011 
3012  const int cellCount=coarserCells.getSelfCount();
3013  const int cellTotCount=coarserCells.getCount();
3014  coarserVar.zero();
3015  coarserFAS.zero();
3016 
3017  for(int c=0;c<cellCount;c++)
3018  {
3019  const int fineCount=CoarserToFiner.getCount(c);
3020 
3021  //sum up contributions from fine cells
3022  for(int fc=0;fc<fineCount;fc++)
3023  {
3024  const int cell=CoarserToFiner(c,fc);
3025  const int klen=finerKspace.getlength();
3026  int coarserCellIndex=coarserKspace.getGlobalIndex(c,0);
3027  int finerCellIndex=finerKspace.getGlobalIndex(cell,0);
3028 
3029  for(int k=0;k<klen;k++)
3030  {
3031  Tkvol& kvol=finerKspace.getkvol(k);
3032  const int numModes=kvol.getmodenum();
3033  for(int m=0;m<numModes;m++)
3034  {
3035  coarserVar[coarserCellIndex]+=finerVar[finerCellIndex]*finerVol[cell];
3036  coarserFAS[coarserCellIndex]+=finerRes[finerCellIndex];
3037  finerCellIndex++;
3038  coarserCellIndex++;
3039  }
3040  }
3041  }
3042 
3043  //make volume average
3044  int coarserCellIndex=coarserKspace.getGlobalIndex(c,0);
3045  const int klen=finerKspace.getlength();
3046  for(int k=0;k<klen;k++)
3047  {
3048  Tkvol& kvol=finerKspace.getkvol(k);
3049  //Tkvol& ckvol=coarserKspace.getkvol(k);
3050  const int numModes=kvol.getmodenum();
3051  for(int m=0;m<numModes;m++)
3052  {
3053  coarserVar[coarserCellIndex]/=coarserVol[c];
3054  coarserInj[coarserCellIndex]=coarserVar[coarserCellIndex];
3055  coarserCellIndex++;
3056  }
3057  }
3058  }
3059 
3060  for(int c=cellCount;c<cellTotCount;c++)
3061  {
3062  const int cell=CoarserToFiner(c,0);
3063  int coarserCellIndex=coarserKspace.getGlobalIndex(c,0);
3064  int finerCellIndex=finerKspace.getGlobalIndex(cell,0);
3065  const int klen=finerKspace.getlength();
3066  for(int k=0;k<klen;k++)
3067  {
3068  Tkvol& kvol=finerKspace.getkvol(k);
3069  const int numModes=kvol.getmodenum();
3070  for(int m=0;m<numModes;m++)
3071  {
3072  coarserVar[coarserCellIndex]=0.;
3073  coarserFAS[coarserCellIndex]=0.;
3074  coarserVar[coarserCellIndex]+=finerVar[finerCellIndex];
3075  coarserFAS[coarserCellIndex]+=finerRes[finerCellIndex];
3076  coarserInj[coarserCellIndex]=coarserVar[coarserCellIndex];
3077  coarserCellIndex++;
3078  finerCellIndex++;
3079  }
3080  }
3081  }
3082 
3083  TArray& coarserVarM=dynamic_cast<TArray&>(coarserMacro.temperature[coarserCells]);
3084  TArray& coarserInjM=dynamic_cast<TArray&>(coarserMacro.TlInjected[coarserCells]);
3085  TArray& coarserFASM=dynamic_cast<TArray&>(coarserMacro.TlFASCorrection[coarserCells]);
3086  TArray& finerVarM=dynamic_cast<TArray&>(_macro.temperature[finerCells]);
3087  TArray& finerResM=dynamic_cast<TArray&>(_macro.TlResidual[finerCells]);
3088 
3089  for(int c=0;c<cellCount;c++)
3090  {
3091  const int fineCount=CoarserToFiner.getCount(c);
3092  coarserVarM[c]=0.;
3093  coarserFASM[c]=0.;
3094 
3095  for(int fc=0;fc<fineCount;fc++)
3096  {
3097  const int cell=CoarserToFiner(c,fc);
3098  coarserVarM[c]+=finerVarM[cell]*finerVol[cell];
3099  coarserFASM[c]+=finerResM[cell];
3100  }
3101  coarserVarM[c]/=coarserVol[c];
3102  coarserInjM[c]=coarserVarM[c];
3103  }
3104  }
3105  }
Tkspace & getKspace(const int i)
int getCount(const int i) const
GeomFields & _geomFields
int getSelfCount() const
Definition: StorageSite.h:40
const CRConnectivity & getConnectivity(const StorageSite &from, const StorageSite &to) const
Definition: Mesh.cpp:416
Array< T > TArray
Field temperature
Definition: PhononMacro.h:21
Definition: Mesh.h:49
int getmodenum()
Definition: kvol.h:43
Field TlResidual
Definition: PhononMacro.h:24
Field TlFASCorrection
Definition: PhononMacro.h:26
PhononMacro & _macro
const MeshList _meshes
Definition: Model.h:29
MacroFields & getMacro()
const StorageSite & getCells() const
Definition: Mesh.h:109
MeshKspaceMap _MeshKspaceMap
Field volume
Definition: GeomFields.h:26
Field TlInjected
Definition: PhononMacro.h:25
const MeshList & getMeshList()
int getCount() const
Definition: StorageSite.h:39
Kspace< T > Tkspace
Definition: kvol.h:14
template<class T >
void COMETModel< T >::injectResid ( )
inline

Definition at line 5204 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_coarserLevel, COMETModel< T >::_dsfPtr, COMETModel< T >::_dsfPtrRes, COMETModel< T >::_geomFields, COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_quadrature, DistFunctFields< T >::dsf, Mesh::getCells(), Mesh::getConnectivity(), CRConnectivity::getCount(), COMETModel< T >::getdsf(), COMETModel< T >::getdsf0(), COMETModel< T >::getdsfFAS(), COMETModel< T >::getGeomFields(), COMETModel< T >::getMacro(), COMETModel< T >::getMeshList(), StorageSite::getSelfCount(), MacroFields::velocity, MacroFields::velocityFASCorrection, MacroFields::velocityInjected, MacroFields::velocityResidual, and GeomFields::volume.

Referenced by COMETModel< T >::cycle().

5205  {
5206  const int numMeshes = _meshes.size();
5207 
5208  for (int n=0; n<numMeshes; n++)
5209  {
5210  const Mesh& finerMesh=*_meshes[n];
5211  const Mesh& coarserMesh=*(_coarserLevel->getMeshList())[n];
5212  MacroFields& coarserMacro=_coarserLevel->getMacro();
5213  GeomFields& coarserGeomFields=_coarserLevel->getGeomFields();
5214  DistFunctFields<T>& coarserdsf = _coarserLevel->getdsf();
5215  DistFunctFields<T>& coarserdsf0 = _coarserLevel->getdsf0();
5216  DistFunctFields<T>& coarserdsfFAS = _coarserLevel->getdsfFAS();
5217  const StorageSite& finerCells=finerMesh.getCells();
5218  const StorageSite& coarserCells=coarserMesh.getCells();
5219  const CRConnectivity& CoarserToFiner=coarserMesh.getConnectivity(coarserCells,finerCells);
5220  //const TArray& coarserVol=dynamic_cast<TArray&>(_geomFields.volume[coarserCells]);
5221  const TArray& coarserVol=dynamic_cast<TArray&>(coarserGeomFields.volume[coarserCells]);
5222  const TArray& finerVol=dynamic_cast<TArray&>(_geomFields.volume[finerCells]);
5223 
5224  const int cellCount=coarserCells.getSelfCount();
5225  const int numDir=_quadrature.getDirCount();
5226  for(int dir=0;dir<numDir;dir++)
5227  {
5228  Field& fnd = *_dsfPtr.dsf[dir];
5229  Field& fndRes = *_dsfPtrRes.dsf[dir];
5230  Field& cfnd = *coarserdsf.dsf[dir];
5231  Field& cfndInj = *coarserdsf0.dsf[dir];
5232  Field& cfndFAS = *coarserdsfFAS.dsf[dir];
5233  TArray& coarserVar=dynamic_cast<TArray&>(cfnd[coarserCells]);
5234  TArray& coarserInj=dynamic_cast<TArray&>(cfndInj[coarserCells]);
5235  TArray& coarserFAS=dynamic_cast<TArray&>(cfndFAS[coarserCells]);
5236  TArray& finerVar=dynamic_cast<TArray&>(fnd[finerCells]);
5237  TArray& finerRes=dynamic_cast<TArray&>(fndRes[finerCells]);
5238 
5239  for(int c=0;c<cellCount;c++)
5240  {
5241  const int fineCount=CoarserToFiner.getCount(c);
5242  coarserVar[c]=0.;
5243  coarserFAS[c]=0.;
5244 
5245  for(int fc=0;fc<fineCount;fc++)
5246  {
5247  const int cell=CoarserToFiner(c,fc);
5248  coarserVar[c]+=finerVar[cell]*finerVol[cell];
5249  coarserFAS[c]+=finerRes[cell];
5250  }
5251  coarserVar[c]/=coarserVol[c];
5252  coarserInj[c]=coarserVar[c];
5253  }
5254  }
5255 
5256  VectorT3Array& coarserVar=dynamic_cast<VectorT3Array&>(coarserMacro.velocity[coarserCells]);
5257  VectorT3Array& coarserInj=dynamic_cast<VectorT3Array&>(coarserMacro.velocityInjected[coarserCells]);
5258  VectorT3Array& coarserFAS=dynamic_cast<VectorT3Array&>(coarserMacro.velocityFASCorrection[coarserCells]);
5259  VectorT3Array& finerVar=dynamic_cast<VectorT3Array&>(_macroFields.velocity[finerCells]);
5260  VectorT3Array& finerRes=dynamic_cast<VectorT3Array&>(_macroFields.velocityResidual[finerCells]);
5261 
5262  for(int c=0;c<cellCount;c++)
5263  {
5264  const int fineCount=CoarserToFiner.getCount(c);
5265  coarserVar[c]=0.;
5266  coarserFAS[c]=0.;
5267 
5268  for(int fc=0;fc<fineCount;fc++)
5269  {
5270  const int cell=CoarserToFiner(c,fc);
5271  coarserVar[c]+=finerVar[cell]*finerVol[cell];
5272  coarserFAS[c]+=finerRes[cell];
5273  }
5274  coarserVar[c]/=coarserVol[c];
5275  coarserInj[c]=coarserVar[c];
5276  }
5277  }
5278  }
int getCount(const int i) const
GeomFields & _geomFields
int getSelfCount() const
Definition: StorageSite.h:40
const CRConnectivity & getConnectivity(const StorageSite &from, const StorageSite &to) const
Definition: Mesh.cpp:416
Quadrature< T > & _quadrature
Array< T > TArray
GeomFields & getGeomFields()
Definition: Field.h:14
Field velocityInjected
Definition: MacroFields.h:17
Definition: Mesh.h:49
Field velocityResidual
Definition: MacroFields.h:16
DistFunctFields< T > & getdsfFAS()
DistFunctFields< T > & getdsf()
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
MacroFields & getMacro()
const StorageSite & getCells() const
Definition: Mesh.h:109
Field volume
Definition: GeomFields.h:26
const MeshList & getMeshList()
Field velocity
Definition: MacroFields.h:15
Field velocityFASCorrection
Definition: MacroFields.h:18
std::vector< Field * > dsf
DistFunctFields< T > _dsfPtrRes
DistFunctFields< T > _dsfPtr
DistFunctFields< T > & getdsf0()
template<class T >
void COMETModel< T >::makeCellColors ( const int  level)
inline

Definition at line 4018 of file phononbase/COMETModel.h.

References COMETModel< T >::_macro, Field::addArray(), PhononMacro::CellColors, Mesh::getCellCells(), Mesh::getCells(), StorageSite::getCount(), CRConnectivity::getCount(), COMETModel< T >::getMeshList(), COMETModel< T >::getModelPointer(), and StorageSite::getSelfCount().

4019  {
4020 
4021  TCOMET* thismodel=getModelPointer(level);
4022  MeshList& meshes=const_cast<MeshList&>(thismodel->getMeshList());
4023  const int numMeshes = meshes.size();
4024  shared_ptr<Field> colorFieldPtr(new Field("Colors"));
4025  _macro.CellColors.push_back(colorFieldPtr);
4026  Field& colorField=*colorFieldPtr;
4027  for (int n=0; n<numMeshes; n++)
4028  {
4029  const Mesh& mesh=*meshes[n];
4030  const StorageSite& cells=mesh.getCells();
4031  const int cellCount=cells.getSelfCount();
4032  const int cellTotCount=cells.getCount();
4033  const CRConnectivity& cellCells=mesh.getCellCells();
4034 
4035  TArrptr colorPtr(new TArray(cellTotCount));
4036  colorField.addArray(cells, colorPtr);
4037  TArray& colorArray=(*colorPtr);
4038  colorArray=-1;
4039 
4040  for(int c=0;c<cellCount;c++)
4041  {
4042  T color=0.;
4043  const int neibs=cellCells.getCount(c);
4044 
4045  while(colorArray[c]==-1)
4046  {
4047 
4048  bool same(false);
4049 
4050  for(int j=0;j<neibs;j++)
4051  {
4052  if(color==colorArray[cellCells(c,j)])
4053  {
4054  same=true;
4055  break;
4056  }
4057  }
4058 
4059  if(same)
4060  color++;
4061  else
4062  colorArray[c]=color;
4063 
4064  }
4065 
4066  }
4067  }
4068 
4069  //if(_coarserLevel!=NULL)
4070  //_coarserLevel->makeCellColors();
4071 
4072  }
int getCount(const int i) const
int getSelfCount() const
Definition: StorageSite.h:40
shared_ptr< TArray > TArrptr
Array< T > TArray
Definition: Field.h:14
Definition: Mesh.h:49
TCOMET * getModelPointer(const int level)
COMETModel< T > TCOMET
PhononMacro & _macro
const CRConnectivity & getCellCells() const
Definition: Mesh.cpp:480
FieldVector CellColors
Definition: PhononMacro.h:34
const StorageSite & getCells() const
Definition: Mesh.h:109
void addArray(const StorageSite &, shared_ptr< ArrayBase > a)
Definition: Field.cpp:72
int getCount() const
Definition: StorageSite.h:39
vector< Mesh * > MeshList
Definition: Mesh.h:439
template<class T >
void COMETModel< T >::MakeCoarseIndex ( const StorageSite solidFaces)
inline

Definition at line 970 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_coarserLevel, COMETModel< T >::_dsfPtr, COMETModel< T >::_finestGeomFields, COMETModel< T >::_finestMeshes, COMETModel< T >::_geomFields, COMETModel< T >::_level, Model::_meshes, COMETModel< T >::_options, COMETModel< T >::_quadrature, Field::addArray(), GeomFields::finestToCoarse, GeomFields::fineToCoarse, Mesh::getCells(), StorageSite::getCount(), COMETModel< T >::MakeCoarseIndex(), and COMETModel< T >::MakeParallel().

Referenced by COMETModel< T >::MakeCoarseIndex().

971  {
972 
973  const int maxLevs=_options.maxLevels;
974  int thisLevel=_level+1;
975 
976  const Mesh& mesh = *_meshes[0];
977  const StorageSite& cells = mesh.getCells();
978  const int nCells = cells.getCount();
979  const Mesh& fMesh = *_finestMeshes[0];
980  const StorageSite& fCells = fMesh.getCells();
981  const int nFCells = fCells.getCount();
982  Field& FineToCoarseField=_geomFields.fineToCoarse;
983  const IntArray& FineToCoarse=dynamic_cast<const IntArray&>(FineToCoarseField[cells]);
984  Field& FinestToCoarseField=_finestGeomFields.finestToCoarse;
985  Array<Vector<int,25> >& FinestToCoarse=dynamic_cast<Array<Vector<int,25> >&>(FinestToCoarseField[fCells]);
986 
987  if(_level==0)
988  MakeParallel();
989  else
990  {
991  for(int dir=0;dir<_quadrature.getDirCount();dir++)
992  {
993  Field& fnd = *_dsfPtr.dsf[dir];
994  shared_ptr<TArray> cSV(new TArray(solidFaces.getCount()));
995  cSV->zero();
996  fnd.addArray(solidFaces,cSV);
997  }
998  }
999 
1000  if(thisLevel<maxLevs) //assumes # of levels will always work for the mesh
1001  {
1002  for(int c=0;c<nFCells;c++)
1003  FinestToCoarse[c][_level+1]=FineToCoarse[FinestToCoarse[c][_level]];
1004 
1005  _coarserLevel->MakeCoarseIndex(solidFaces);
1006  }
1007  }
const MeshList & _finestMeshes
GeomFields & _geomFields
Quadrature< T > & _quadrature
Array< T > TArray
Definition: Field.h:14
Definition: Mesh.h:49
COMETModelOptions< T > _options
Field fineToCoarse
Definition: GeomFields.h:41
GeomFields & _finestGeomFields
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
Definition: Array.h:14
Field finestToCoarse
Definition: GeomFields.h:42
DistFunctFields< T > _dsfPtr
int getCount() const
Definition: StorageSite.h:39
Array< int > IntArray
void MakeCoarseIndex(const StorageSite &solidFaces)
template<class T >
void COMETModel< T >::MakeCoarseMesh1 ( const MeshList inMeshes,
GeomFields inGeomFields,
MeshList outMeshes 
)
inline

Definition at line 2545 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_BFaces, COMETModel< T >::_coarseSizes, COMETModel< T >::_siteMap, GeomFields::area, GeomFields::areaMag, GeomFields::fineToCoarse, Mesh::getBoundaryFaceGroups(), Mesh::getCellFaces(), Mesh::getCells(), StorageSite::getCount(), CRConnectivity::getCount(), Mesh::getDimension(), Mesh::getFaceCells(), Mesh::getFaces(), StorageSite::getSelfCount(), GeomFields::ibType, Mesh::IBTYPE_FLUID, mag(), and FaceGroup::site.

Referenced by COMETModel< T >::MakeCoarseModel(), and COMETModel< T >::MakeIBCoarseModel().

2547  {
2548 
2549  int smallestMesh=-1;
2550  const int numMeshes=inMeshes.size();
2551 
2552  for(int n=0;n<numMeshes;n++)
2553  {
2554  const Mesh& mesh=*inMeshes[n];
2555  const int dim=mesh.getDimension();
2556  Mesh* newMeshPtr=new Mesh(dim);
2557 
2558  outMeshes.push_back(newMeshPtr);
2559 
2560  const StorageSite& inCells=mesh.getCells();
2561  StorageSite& outCells=newMeshPtr->getCells();
2562  StorageSite& outFaces=newMeshPtr->getFaces();
2563  const StorageSite& inFaces=mesh.getFaces();
2564  const int inCellCount=inCells.getSelfCount();
2565  const int inCellTotal=inCells.getCount();
2566  const int inFaceCount=inFaces.getCount();
2567  const int inGhost=inCellTotal-inCellCount;
2568  int coarseCount=0;
2569  _siteMap[&inCells]=&outCells;
2570  Field& FineToCoarseField=inGeomFields.fineToCoarse;
2571  IntArray& FineToCoarse=dynamic_cast<IntArray&>(FineToCoarseField[inCells]);
2572 
2573  const CRConnectivity& inCellinFaces=mesh.getCellFaces();
2574  const CRConnectivity& inFaceinCells=mesh.getFaceCells(inFaces);
2575  Field& areaMagField=inGeomFields.areaMag;
2576  Field& areaField=inGeomFields.area;
2577  const TArray& areaMagArray=dynamic_cast<const TArray&>(areaMagField[inFaces]);
2578  const VectorT3Array& areaArray=dynamic_cast<const VectorT3Array&>(areaField[inFaces]);
2579  const BCfaceArray& inBCfArray=*(_BFaces[n]);
2580 
2581  const IntArray& ibType = dynamic_cast<const IntArray&>(inGeomFields.ibType[inCells]);
2582 
2583  //first sweep to make initial pairing
2584  int pairWith;
2585  Array<bool> marker(inFaceCount);
2586  Array<bool> marked(inCellCount);
2587  const T zero(0.);
2588  for(int c=0;c<inCellCount;c++)
2589  {
2590  if((FineToCoarse[c]<0)&&(ibType[c] == Mesh::IBTYPE_FLUID)) //dont bother if im already paired
2591  {
2592  //loop through all neighbors to find pairing
2593  const int neibCount=inCellinFaces.getCount(c);
2594  pairWith=-1;
2595  T maxArea=0.;
2596  int c2;
2597  for(int i=0; i<inFaceCount; i++)
2598  {
2599  marker[i] = false;
2600  }
2601  for(int i=0; i<inCellCount; i++)
2602  {
2603  marked[i] = false;
2604  }
2605  for(int neib=0;neib<neibCount;neib++)
2606  {
2607  const int f=inCellinFaces(c,neib);
2608 
2609  if(inBCfArray[f]==0) //not a boundary face
2610  {
2611  if(c==inFaceinCells(f,1))
2612  c2=inFaceinCells(f,0);
2613  else
2614  c2=inFaceinCells(f,1);
2615 
2616  VectorT3 tempArea;
2617  tempArea[0]=zero;
2618  tempArea[1]=zero;
2619  tempArea[2]=zero;
2620  if((FineToCoarse[c2]==-1)&&(!marked[c2]))
2621  {
2622  marker[f]=true;
2623  marked[c2]=true;
2624  for(int face=0;face<inFaceCount;face++)
2625  {
2626  if((c==inFaceinCells(face,0))&&(c2==inFaceinCells(face,1)))
2627  tempArea+=areaArray[face];
2628  else if((c2==inFaceinCells(face,0))&&(c==inFaceinCells(face,1)))
2629  tempArea-=areaArray[face];
2630  }
2631  }
2632 
2633  if((FineToCoarse[c2]==-1)&&(marker[f]))
2634  if(mag(tempArea)>maxArea)
2635  {
2636  pairWith=c2;
2637  maxArea=mag(tempArea);
2638  }
2639 
2640  /*
2641  if(FineToCoarse[c2]==-1)
2642  if(areaMagArray[f]>maxArea)
2643  {
2644  pairWith=c2;
2645  maxArea=areaMagArray[f];
2646  }
2647  */
2648  }
2649  }
2650 
2651  if(pairWith!=-1)
2652  {
2653  FineToCoarse[c]=coarseCount;
2654  FineToCoarse[pairWith]=coarseCount;
2655  coarseCount++;
2656  }
2657  }
2658  }
2659 
2660  //second sweep to group stragglers, or group with self
2661  for(int c=0;c<inCellCount;c++)
2662  {
2663  if((FineToCoarse[c]==-1)&&(ibType[c] == Mesh::IBTYPE_FLUID))
2664  {
2665  const int neibCount=inCellinFaces.getCount(c);
2666  T maxArea=0.;
2667  int c2,c2perm;
2668  pairWith=-2;
2669  for(int i=0; i<inFaceCount; i++)
2670  {
2671  marker[i] = false;
2672  }
2673  for(int i=0; i<inCellCount; i++)
2674  {
2675  marked[i] = false;
2676  }
2677 
2678  for(int neib=0;neib<neibCount;neib++)
2679  {
2680  const int f=inCellinFaces(c,neib);
2681 
2682  if(inBCfArray[f]==0) //not a boundary face
2683  {
2684  if(c==inFaceinCells(f,1))
2685  c2=inFaceinCells(f,0);
2686  else
2687  c2=inFaceinCells(f,1);
2688 
2689  VectorT3 tempArea;
2690  tempArea[0]=zero;
2691  tempArea[1]=zero;
2692  tempArea[2]=zero;
2693  if(!marked[c2])
2694  {
2695  marker[f]=true;
2696  marked[c2]=true;
2697  for(int face=0;face<inFaceCount;face++)
2698  {
2699  if((c==inFaceinCells(face,0))&&(c2==inFaceinCells(face,1)))
2700  tempArea+=areaArray[face];
2701  else if((c2==inFaceinCells(face,0))&&(c==inFaceinCells(face,1)))
2702  tempArea-=areaArray[face];
2703  }
2704  }
2705 
2706  if(marker[f])
2707  if(mag(tempArea)>maxArea)
2708  {
2709  pairWith=FineToCoarse[c2]; //coarse level cell
2710  c2perm=c2; //fine level cell
2711  maxArea=mag(tempArea);
2712  }
2713 
2714  /*
2715  if(areaMagArray[f]>maxArea)
2716  {
2717  pairWith=FineToCoarse[c2]; //coarse level cell
2718  c2perm=c2; //fine level cell
2719  maxArea=areaMagArray[f];
2720  }
2721  */
2722  }
2723  }
2724 
2725  if(pairWith==-2)
2726  {
2727  FineToCoarse[c]=coarseCount;
2728  coarseCount++;
2729  }
2730  else
2731  {
2732  if(FineToCoarse[c2perm]==-1)
2733  {
2734  FineToCoarse[c]=coarseCount;
2735  FineToCoarse[c2perm]=coarseCount;
2736  coarseCount++;
2737  }
2738  else
2739  FineToCoarse[c]=pairWith;
2740  }
2741  }
2742  }
2743 
2744  for(int c=0;c<inCellCount;c++)
2745  {
2746  if(ibType[c] != Mesh::IBTYPE_FLUID)
2747  {
2748  FineToCoarse[c]=coarseCount;
2749  coarseCount++;
2750  }
2751  }
2752 
2753  int coarseGhost=coarseCount;
2754  _coarseSizes[&mesh]=coarseCount;
2755 
2756  /*
2757  if(MPI::COMM_WORLD.Get_rank()==1)
2758  for(int c=0;c<inCells.getCount();c++)
2759  cout<<" in makecoarsemesh1 before boundary, rank,level,cell,index = "<<MPI::COMM_WORLD.Get_rank()<<" "<<_level<<" "<<c<<" "<<FineToCoarse[c]<<endl;
2760  */
2761 
2762  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
2763  {
2764  const FaceGroup& fg = *fgPtr;
2765  const StorageSite& faces = fg.site;
2766  const int nFaces = faces.getCount();
2767 
2768  const CRConnectivity& faceCells = mesh.getFaceCells(faces);
2769 
2770  for(int f=0; f< nFaces; f++)
2771  {
2772  const int c1= faceCells(f,1);// boundary cell
2773  FineToCoarse[c1]=coarseGhost;
2774  coarseGhost++;
2775  }
2776  }
2777 
2778  /*
2779  if(MPI::COMM_WORLD.Get_rank()==1)
2780  for(int c=0;c<inCells.getCount();c++)
2781  cout<<" in makecoarsemesh1, rank, level,cell,index = "<<MPI::COMM_WORLD.Get_rank()<<" "<<_level<<" "<<c<<" "<<FineToCoarse[c]<<endl;
2782  */
2783  }
2784  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
int getCount(const int i) const
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
int getSelfCount() const
Definition: StorageSite.h:40
Definition: Mesh.h:28
Array< T > TArray
Definition: Field.h:14
Definition: Mesh.h:49
T mag(const Vector< T, 3 > &a)
Definition: Vector.h:260
Field ibType
Definition: GeomFields.h:38
Field fineToCoarse
Definition: GeomFields.h:41
const CRConnectivity & getCellFaces() const
Definition: Mesh.cpp:454
const StorageSite & getFaces() const
Definition: Mesh.h:108
const StorageSite & getCells() const
Definition: Mesh.h:109
const CRConnectivity & getFaceCells(const StorageSite &site) const
Definition: Mesh.cpp:388
int getCount() const
Definition: StorageSite.h:39
Array< int > IntArray
Field area
Definition: GeomFields.h:23
int getDimension() const
Definition: Mesh.h:105
Field areaMag
Definition: GeomFields.h:25
Array< int > BCfaceArray
StorageSite site
Definition: Mesh.h:40
template<class T >
int COMETModel< T >::MakeCoarseMesh2 ( const MeshList inMeshes,
GeomFields inGeomFields,
GeomFields coarseGeomFields,
MeshList outMeshes 
)
inline

Definition at line 2786 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_BFaces, COMETModel< T >::_coarseGhostSizes, COMETModel< T >::_coarseSizes, COMETModel< T >::_siteMap, Field::addArray(), GeomFields::area, GeomFields::areaMag, Mesh::createBoundaryFaceGroup(), Mesh::createInterfaceGroup(), Mesh::createInteriorFaceGroup(), GeomFields::fineToCoarse, Mesh::getBoundaryFaceGroups(), Mesh::getCellFaces(), Mesh::getCells(), StorageSite::getCount(), StorageSite::getCountLevel1(), Mesh::getDimension(), Mesh::getFaceCells(), Mesh::getFaces(), Mesh::getIBFaces(), Mesh::getInterfaceGroups(), StorageSite::getSelfCount(), FaceGroup::groupType, GeomFields::ibFaceIndex, GeomFields::ibType, Mesh::IBTYPE_FLUID, FaceGroup::id, Mesh::setConnectivity(), StorageSite::setCount(), StorageSite::setCountLevel1(), FaceGroup::site, and GeomFields::volume.

Referenced by COMETModel< T >::MakeCoarseModel(), and COMETModel< T >::MakeIBCoarseModel().

2788  {
2789 
2790  int smallestMesh=-1;
2791  const int numMeshes=inMeshes.size();
2792  for(int n=0;n<numMeshes;n++)
2793  {
2794  const Mesh& mesh=*inMeshes[n];
2795  const int dim=mesh.getDimension();
2796  //Mesh* newMeshPtr=new Mesh(dim);
2797 
2798  //outMeshes.push_back(newMeshPtr);
2799  Mesh& newMeshPtr=*outMeshes[n];
2800 
2801  const StorageSite& inCells=mesh.getCells();
2802  StorageSite& outCells=newMeshPtr.getCells();
2803  StorageSite& outFaces=newMeshPtr.getFaces();
2804  StorageSite& outIBFaces=newMeshPtr.getIBFaces();
2805  const IntArray& ibType = dynamic_cast<const IntArray&>(inGeomFields.ibType[inCells]);
2806  const StorageSite& inFaces=mesh.getFaces();
2807  const StorageSite& inIBFaces=mesh.getIBFaces();
2808  const int inCellCount=inCells.getSelfCount();
2809  const int inCellTotal=inCells.getCount();
2810  const int inFaceCount=inFaces.getCount();
2811  const int inGhost=inCellTotal-inCellCount;
2812  int outGhost = 0;
2813  int coarseCount=0;
2814  Field& FineToCoarseField=inGeomFields.fineToCoarse;
2815  const IntArray& FineToCoarse=dynamic_cast<const IntArray&>(FineToCoarseField[inCells]);
2816  const CRConnectivity& inCellinFaces=mesh.getCellFaces();
2817  const CRConnectivity& inFaceinCells=mesh.getFaceCells(inFaces);
2818  Field& areaMagField=inGeomFields.areaMag;
2819  const TArray& areaMagArray=dynamic_cast<const TArray&>(areaMagField[inFaces]);
2820  const BCfaceArray& inBCfArray=*(_BFaces[n]);
2821 
2822  /*** creating coarse level cells ***/
2823  coarseCount = _coarseSizes[&mesh];
2824  int interfaceCellsLevel0 = _coarseGhostSizes[&mesh];
2825 
2826  int boundaryCell=0;
2827  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
2828  {
2829  const FaceGroup& fg = *fgPtr;
2830  const StorageSite& faces = fg.site;
2831  const int nFaces = faces.getCount();
2832 
2833  const CRConnectivity& faceCells = mesh.getFaceCells(faces);
2834 
2835  for(int f=0; f< nFaces; f++)
2836  {
2837  const int c1= faceCells(f,1);// boundary cell
2838  if(boundaryCell<FineToCoarse[c1])
2839  boundaryCell=FineToCoarse[c1];
2840  }
2841  }
2842  boundaryCell++;
2843  if(boundaryCell!=1)
2844  boundaryCell-=coarseCount;
2845  else
2846  boundaryCell=0;
2847 
2848  for(int c=0; c< inCells.getCountLevel1(); c++)
2849  {
2850  if(outGhost<FineToCoarse[c])
2851  outGhost=FineToCoarse[c];
2852  }
2853  outGhost++;
2854  outGhost-=coarseCount;
2855 
2856  int interfaceCells = outGhost - boundaryCell;
2857 
2858  /*
2859  if(MPI::COMM_WORLD.Get_rank()==1)
2860  cout<<"rank,level,inCellinternal, incelltotal,outCellInternal, outCellExternal, outInterface ="<<MPI::COMM_WORLD.Get_rank()<<" "<<_level<<" "<<inCellCount<<" and "<<inCellTotal<<" and "<<coarseCount<<" and "<<outGhost<<" "<<interfaceCells<<endl;
2861  */
2862 
2863  /*
2864  if(MPI::COMM_WORLD.Get_rank()==1)
2865  for(int c=0;c<inCellTotal;c++)
2866  cout<<" in makecoarsemesh2, rank,level, cell,index = "<<MPI::COMM_WORLD.Get_rank()<<" "<<_level<<" "<<c<<" and "<<FineToCoarse[c]<<endl;
2867  */
2868 
2869  outCells.setCount(coarseCount,boundaryCell+interfaceCellsLevel0);
2870  outCells.setCountLevel1(coarseCount+outGhost);
2871 
2872  /*** created coarse level cells ***/
2873 
2874  //make the coarse cell to fine cell connectivity.
2875  CRPtr CoarseToFineCells=CRPtr(new CRConnectivity(outCells,inCells));
2876  CoarseToFineCells->initCount();
2877 
2878  for(int c=0;c<inCells.getCountLevel1();c++)
2879  CoarseToFineCells->addCount(FineToCoarse[c],1);
2880 
2881  CoarseToFineCells->finishCount();
2882 
2883  for(int c=0;c<inCells.getCountLevel1();c++)
2884  CoarseToFineCells->add(FineToCoarse[c],c);
2885 
2886  CoarseToFineCells->finishAdd();
2887 
2888  /*** connectivity between itself (cells) and its finer mesh cells ***/
2889  newMeshPtr.setConnectivity(outCells,inCells,CoarseToFineCells);
2890 
2891  CRPtr FineFacesCoarseCells=CRPtr(new CRConnectivity(inFaces,outCells));
2892  FineFacesCoarseCells->initCount();
2893 
2894  //count surviving faces
2895  int survivingFaces=0;
2896  int coarse0, coarse1;
2897  for(int f=0;f<inFaceCount;f++)
2898  {
2899  coarse0=FineToCoarse[inFaceinCells(f,0)];
2900  coarse1=FineToCoarse[inFaceinCells(f,1)];
2901  if(coarse0!=coarse1)
2902  {
2903  survivingFaces++;
2904  FineFacesCoarseCells->addCount(f,2);
2905  }
2906  }
2907 
2908  FineFacesCoarseCells->finishCount();
2909 
2910  //make non-zero's
2911  int fc0,fc1,cc0,cc1;
2912  for(int f=0;f<inFaceCount;f++)
2913  {
2914  fc0=inFaceinCells(f,0);
2915  fc1=inFaceinCells(f,1);
2916  cc0=FineToCoarse[fc0];
2917  cc1=FineToCoarse[fc1];
2918  if(cc0!=cc1)
2919  {
2920  FineFacesCoarseCells->add(f,cc0);
2921  FineFacesCoarseCells->add(f,cc1);
2922  }
2923  }
2924 
2925  FineFacesCoarseCells->finishAdd();
2926 
2927  CRPtr CoarseCellsFineFaces=FineFacesCoarseCells->getTranspose();
2928  CRPtr CellCellCoarse=CoarseCellsFineFaces->multiply(*FineFacesCoarseCells,true);
2929 
2930  /*** coarse level cellcell connectivity created ***/
2931 
2932  /*
2933  int counter=0;
2934  BArray counted(outCells.getCount());
2935  counted=false;
2936  for(int c=0;c<outCells.getCount();c++)
2937  {
2938  counted[c]=true;
2939  const int neibs=CellCellCoarse->getCount(c);
2940  for(int n=0;n<neibs;n++)
2941  {
2942  const int c1=(*CellCellCoarse)(c,n);
2943  if(!counted[c1])
2944  counter++;
2945  }
2946  }
2947 
2948  //outFaces.setCount(counter);
2949  */
2950 
2951  int countFaces=0;
2952  int cCell0, cCell1;
2953  for(int f=0;f<inFaceCount;f++)
2954  {
2955  cCell0=FineToCoarse[inFaceinCells(f,0)];
2956  cCell1=FineToCoarse[inFaceinCells(f,1)];
2957  if(cCell0!=cCell1)
2958  {
2959  countFaces++;
2960  }
2961  }
2962 
2963  outFaces.setCount(countFaces);
2964 
2965  int inFaceGhost = 0;
2966  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
2967  inFaceGhost+=(*fgPtr).site.getCount();
2968  foreach(const FaceGroupPtr fgPtr, mesh.getInterfaceGroups())
2969  inFaceGhost+=(*fgPtr).site.getCount();
2970  const int inInteriorFaces = inFaceCount - inFaceGhost;
2971 
2972  const int del = inFaceCount - outFaces.getCount();
2973 
2974  //const int interiorCount=outFaces.getCount()-inGhost;
2975  const int interiorCount=inInteriorFaces-del;
2976  //if(MPI::COMM_WORLD.Get_rank()==1)
2977  //cout<<"level,outfaces, outghost, totalfaces = "<<_level<<" "<<interiorCount<<" "<<inGhost<<" "<<countFaces<<endl;
2978  const StorageSite& interiorFaces=newMeshPtr.createInteriorFaceGroup(interiorCount);
2979 
2980  int inOffset=interiorCount;
2981  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
2982  {
2983  const FaceGroup& fg=*fgPtr;
2984  const int size=fg.site.getCount();
2985  newMeshPtr.createBoundaryFaceGroup(size,inOffset,fg.id,fg.groupType);
2986  inOffset+=size;
2987  }
2988 
2989  foreach(const FaceGroupPtr fgPtr, mesh.getInterfaceGroups())
2990  {
2991  const FaceGroup& fg=*fgPtr;
2992  const int size=fg.site.getCount();
2993  newMeshPtr.createInterfaceGroup(size,inOffset,fg.id);
2994  inOffset+=size;
2995  }
2996 
2997  CRPtr CoarseFaceCoarseCell=CRPtr(new CRConnectivity(outFaces,outCells));
2998  CoarseFaceCoarseCell->initCount();
2999 
3000  survivingFaces=0;
3001  for(int f=0;f<inFaceCount;f++)
3002  {
3003  coarse0=FineToCoarse[inFaceinCells(f,0)];
3004  coarse1=FineToCoarse[inFaceinCells(f,1)];
3005  if(coarse0!=coarse1)
3006  {
3007  CoarseFaceCoarseCell->addCount(survivingFaces,2);
3008  survivingFaces++;
3009  }
3010  }
3011 
3012  CoarseFaceCoarseCell->finishCount();
3013 
3014  //make non-zero's
3015  survivingFaces=0;
3016  for(int f=0;f<inFaceCount;f++)
3017  {
3018  fc0=inFaceinCells(f,0);
3019  fc1=inFaceinCells(f,1);
3020  cc0=FineToCoarse[fc0];
3021  cc1=FineToCoarse[fc1];
3022  if(cc0!=cc1)
3023  {
3024  CoarseFaceCoarseCell->add(survivingFaces,cc0);
3025  CoarseFaceCoarseCell->add(survivingFaces,cc1);
3026  survivingFaces++;
3027  }
3028  }
3029 
3030  CoarseFaceCoarseCell->finishAdd();
3031 
3032  CRPtr CoarseCellCoarseFace=CoarseFaceCoarseCell->getTranspose();
3033 
3034  newMeshPtr.setConnectivity(outCells,outFaces,CoarseCellCoarseFace);
3035  newMeshPtr.setConnectivity(outFaces,outCells,CoarseFaceCoarseCell);
3036 
3037  Field& coarseIbTypeField=coarseGeomFields.ibType;
3038  shared_ptr<IntArray> ibTypePtr(new IntArray(outCells.getCountLevel1()));
3039  *ibTypePtr = Mesh::IBTYPE_FLUID;
3040  coarseIbTypeField.addArray(outCells,ibTypePtr);
3041 
3042  IntArray& coarseIBType = dynamic_cast<IntArray&>(coarseGeomFields.ibType[outCells]);
3043 
3044  for(int c=0;c<inCellCount;c++)
3045  if(ibType[c] != Mesh::IBTYPE_FLUID)
3046  coarseIBType[FineToCoarse[c]]=ibType[c];
3047 
3048  outIBFaces.setCount(inIBFaces.getCount());
3049  _siteMap[&inIBFaces]=&outIBFaces;
3050 
3051  shared_ptr<IntArray> ibFaceIndexPtr(new IntArray(outFaces.getCount()));
3052  *ibFaceIndexPtr = -1;
3053  coarseGeomFields.ibFaceIndex.addArray(outFaces,ibFaceIndexPtr);
3054 
3055  const IntArray& fineIBFaceIndex=dynamic_cast<const IntArray&>(inGeomFields.ibFaceIndex[inFaces]);
3056  IntArray& coarseIBFaceIndex=dynamic_cast<IntArray&>(coarseGeomFields.ibFaceIndex[outFaces]);
3057 
3058  CRPtr CoarseFacesFineFaces=CRPtr(new CRConnectivity(outFaces,inFaces));
3059  CoarseFacesFineFaces->initCount();
3060 
3061  survivingFaces=0;
3062  for(int f=0;f<inFaceCount;f++)
3063  {
3064  int fc0=inFaceinCells(f,0);
3065  int fc1=inFaceinCells(f,1);
3066  const int cc0=FineToCoarse[fc0];
3067  const int cc1=FineToCoarse[fc1];
3068 
3069  if(cc1!=cc0)
3070  {
3071  CoarseFacesFineFaces->addCount(survivingFaces,1);
3072  survivingFaces++;
3073  }
3074  }
3075  //cout<<"hello 3 rank "<<MPI::COMM_WORLD.Get_rank()<<endl;
3076  CoarseFacesFineFaces->finishCount();
3077 
3078  survivingFaces=0;
3079  for(int f=0;f<inFaceCount;f++)
3080  {
3081  int fc0=inFaceinCells(f,0);
3082  int fc1=inFaceinCells(f,1);
3083  const int cc0=FineToCoarse[fc0];
3084  const int cc1=FineToCoarse[fc1];
3085  if(cc1!=cc0)
3086  {
3087  CoarseFacesFineFaces->add(survivingFaces,f);
3088  coarseIBFaceIndex[survivingFaces]=fineIBFaceIndex[f];
3089  survivingFaces++;
3090  }
3091  }
3092  //cout<<"hello 4 rank "<<MPI::COMM_WORLD.Get_rank()<<endl;
3093  CoarseFacesFineFaces->finishAdd();
3094 
3095  /*
3096  if(MPI::COMM_WORLD.Get_rank()==1)
3097  {
3098  for(int f=0;f<outFaces.getCount();f++)
3099  {
3100  cout<<"level,rank,face,neighbor = "<<_level<<" "<<MPI::COMM_WORLD.Get_rank()<<" "<<f<<" "<<(*CoarseFaceCoarseCell)(f,0)<<" "<<(*CoarseFaceCoarseCell)(f,1)<<endl;
3101  }
3102  }
3103  */
3104 
3105  //cout<<"hello 5 rank "<<MPI::COMM_WORLD.Get_rank()<<endl;
3106 
3107  //now make the geom fields
3108  const int outCellsCount=outCells.getSelfCount();
3109  TArrptr outCellVolumePtr=TArrptr(new TArray(outCellsCount));
3110  TArray& outCV=*outCellVolumePtr;
3111  outCV=0.;
3112 
3113  Field& VolumeField=inGeomFields.volume;
3114  Field& coarseVolumeField=coarseGeomFields.volume;
3115  const TArray& inCV=dynamic_cast<const TArray&>(VolumeField[inCells]);
3116 
3117  for(int c=0;c<outCellsCount;c++)
3118  {
3119  const int fineCount=CoarseToFineCells->getCount(c);
3120  for(int i=0;i<fineCount;i++)
3121  {
3122  int fc=(*CoarseToFineCells)(c,i);
3123  outCV[c]+=inCV[fc];
3124  }
3125  }
3126 
3127  coarseVolumeField.addArray(outCells,outCellVolumePtr);
3128 
3129  //cout<<"hello 6"<<endl;
3130 
3131  const int outFacesCount=outFaces.getCount();
3132  VT3Ptr outFaceAreaPtr=VT3Ptr(new VectorT3Array(outFacesCount));
3133  VectorT3Array& outFA=*outFaceAreaPtr;
3134  TArrptr outFaceAreaMagPtr=TArrptr(new TArray(outFacesCount));
3135  TArray& outFAMag=*outFaceAreaMagPtr;
3136 
3137  Field& FaceAreaField=inGeomFields.area;
3138  Field& coarseFaceAreaField=coarseGeomFields.area;
3139  Field& coarseAreaMagField=coarseGeomFields.areaMag;
3140  const VectorT3Array& inFA=
3141  dynamic_cast<const VectorT3Array&>(FaceAreaField[inFaces]);
3142 
3143  VectorT3 myZero;
3144  myZero[0]=0.;
3145  myZero[1]=0.;
3146  myZero[2]=0.;
3147 
3148  outFA=myZero;
3149  outFAMag=0.;
3150  for(int f=0;f<outFacesCount;f++)
3151  {
3152  const int fineCount=CoarseFacesFineFaces->getCount(f);
3153  const int cCell0=(*CoarseFaceCoarseCell)(f,0);
3154  for(int i=0;i<fineCount;i++)
3155  {
3156  const int fFace=(*CoarseFacesFineFaces)(f,i);
3157  const int fCell0=inFaceinCells(fFace,0);
3158  const int CCell0=FineToCoarse[fCell0];
3159 
3160  //must make sure the area vector is pointing
3161  //from c0 to c1
3162  if(CCell0==cCell0)
3163  outFA[f]+=inFA[fFace];
3164  else
3165  outFA[f]-=inFA[fFace];
3166  outFAMag[f]+=areaMagArray[fFace];
3167  }
3168  }
3169 
3170  coarseFaceAreaField.addArray(outFaces,outFaceAreaPtr);
3171  coarseAreaMagField.addArray(outFaces,outFaceAreaMagPtr);
3172 
3173  //cout<<"hello 7"<<endl;
3174  /*
3175  Field& ibTypeField=inGeomFields.ibType;
3176  Field& coarseIbTypeField=coarseGeomFields.ibType;
3177  shared_ptr<IntArray> ibTypePtr(new IntArray(outCells.getSelfCount()));
3178  *ibTypePtr = Mesh::IBTYPE_FLUID;
3179  coarseIbTypeField.addArray(outCells,ibTypePtr);
3180  */
3181  if(smallestMesh<0)
3182  smallestMesh=outCells.getSelfCount();
3183  else
3184  {
3185  if(outCells.getSelfCount()<smallestMesh)
3186  smallestMesh=outCells.getSelfCount();
3187  }
3188  //cout<<"hello 8"<<endl;
3189  /*
3190  //This is for checking purposes only
3191  cout<<"Coarse Faces to Fine Faces"<<endl;
3192  for(int f=0;f<outFaces.getCount();f++)
3193  {
3194  const int neibs=CoarseFacesFineFaces->getCount(f);
3195  for(int n=0;n<neibs;n++)
3196  cout<<f<<" "<<(*CoarseFacesFineFaces)(f,n)<<endl;
3197  cout<<endl;
3198  }
3199  cout<<"Coarse Cells to Coarse Faces"<<endl;
3200  for(int c=0;c<outCells.getCount();c++)
3201  {
3202  const int neibs=CoarseCellCoarseFace->getCount(c);
3203  for(int n=0;n<neibs;n++)
3204  cout<<c<<" "<<(*CoarseCellCoarseFace)(c,n)<<endl;
3205  cout<<endl;
3206  }
3207  */
3208  }
3209  //cout<<"hello 6"<<endl;
3210  return smallestMesh;
3211  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
int getSelfCount() const
Definition: StorageSite.h:40
const StorageSite & getIBFaces() const
Definition: Mesh.h:111
Definition: Mesh.h:28
shared_ptr< TArray > TArrptr
Array< T > TArray
Definition: Field.h:14
const StorageSite & createInteriorFaceGroup(const int size)
Definition: Mesh.cpp:259
Definition: Mesh.h:49
void setCount(const int selfCount, const int nGhost=0)
Definition: StorageSite.h:42
void setConnectivity(const StorageSite &rowSite, const StorageSite &colSite, shared_ptr< CRConnectivity > conn)
Definition: Mesh.cpp:352
const StorageSite & createBoundaryFaceGroup(const int size, const int offset, const int id, const string &boundaryType)
Definition: Mesh.cpp:278
string groupType
Definition: Mesh.h:42
Field ibType
Definition: GeomFields.h:38
Field fineToCoarse
Definition: GeomFields.h:41
const CRConnectivity & getCellFaces() const
Definition: Mesh.cpp:454
const int id
Definition: Mesh.h:41
Array< VectorT3 > VectorT3Array
const StorageSite & createInterfaceGroup(const int size, const int offset, const int id)
Definition: Mesh.cpp:268
const StorageSite & getFaces() const
Definition: Mesh.h:108
Field ibFaceIndex
Definition: GeomFields.h:40
const StorageSite & getCells() const
Definition: Mesh.h:109
Field volume
Definition: GeomFields.h:26
int getCountLevel1() const
Definition: StorageSite.h:72
shared_ptr< CRConnectivity > CRPtr
void addArray(const StorageSite &, shared_ptr< ArrayBase > a)
Definition: Field.cpp:72
const CRConnectivity & getFaceCells(const StorageSite &site) const
Definition: Mesh.cpp:388
shared_ptr< VectorT3Array > VT3Ptr
int getCount() const
Definition: StorageSite.h:39
Array< int > IntArray
Field area
Definition: GeomFields.h:23
const FaceGroupList & getInterfaceGroups() const
Definition: Mesh.h:190
int getDimension() const
Definition: Mesh.h:105
void setCountLevel1(const int countLevel1)
Definition: StorageSite.h:69
Field areaMag
Definition: GeomFields.h:25
Array< int > BCfaceArray
StorageSite site
Definition: Mesh.h:40
template<class T >
void COMETModel< T >::MakeCoarseModel ( TCOMET finerModel)
inline

Definition at line 575 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_coarseGatherMaps, COMETModel< T >::_coarseGeomFields, COMETModel< T >::_coarseScatterMaps, COMETModel< T >::_geomFields, Model::_meshes, COMETModel< T >::_options, COMETModel< T >::_sharedSiteMap, COMETModel< T >::_siteMap, COMETModel< T >::COMETModel(), Quadrature< T >::CopyQuad(), GeomFields::fineToCoarse, COMETModel< T >::getBCMap(), Mesh::getCells(), StorageSite::getCount(), StorageSite::getGatherMap(), StorageSite::getGatherMapLevel1(), StorageSite::getGatherProcID(), COMETModel< T >::getGeomFields(), COMETModel< T >::getLevel(), COMETModel< T >::getMeshList(), COMETModel< T >::getOptions(), COMETModel< T >::getQuadrature(), StorageSite::getScatterMap(), StorageSite::getScatterMapLevel1(), StorageSite::getScatterProcID(), StorageSite::getTag(), COMETModel< T >::getVCMap(), COMETModel< T >::MakeCoarseMesh1(), COMETModel< T >::MakeCoarseMesh2(), COMETModel< T >::setCoarserLevel(), COMETModel< T >::syncGhostCoarsening(), and Field::syncLocal().

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

576  {
577 
578  if(_options.AgglomerationMethod=="FaceArea")
579  {
580  int maxLevs=finerModel->getOptions().maxLevels;
581  int thisLevel=(finerModel->getLevel())+1;
582 
583  if(thisLevel<maxLevs) //assumes # of levels will always work for the mesh
584  {
585  MeshList* newMeshesPtr=new MeshList;
586  TQuad* newQuadPtr=new TQuad();
587  MacroFields* newMacroPtr=new MacroFields("coarse");
588 
589  newQuadPtr->CopyQuad(finerModel->getQuadrature());
590 
591  MakeCoarseMesh1(finerModel->getMeshList(),
592  finerModel->getGeomFields(),
593  *newMeshesPtr);
594 
596  const Mesh& mesh = *_meshes[0];
597  const StorageSite& cells = mesh.getCells();
598  const int nCells = cells.getCount();
599  Field& FineToCoarseField=(finerModel->getGeomFields()).fineToCoarse;
600  const IntArray& coarseIndex=dynamic_cast<const IntArray&>(FineToCoarseField[cells]);
601 
602  /*
603  if(MPI::COMM_WORLD.Get_rank()==1)
604  for(int c=0;c<nCells;c++)
605  cout<<" after sync, rank, level, cell no and finetocoarse = "<<MPI::COMM_WORLD.Get_rank()<<" "<<_level<<" "<<c<<" "<<coarseIndex[c]<<endl;
606  */
607 
608  syncGhostCoarsening(finerModel->getMeshList(),
609  finerModel->getGeomFields(),
610  *newMeshesPtr);
611  const int numMeshes =_meshes.size();
612  for (int n=0; n<numMeshes; n++)
613  {
614  const Mesh& mesh = *_meshes[n];
615  const StorageSite& fineSite = mesh.getCells();
616  StorageSite& coarseSite = *_siteMap[&fineSite];
617  const StorageSite::ScatterMap& fineScatterMap = fineSite.getScatterMap();
618  const StorageSite::ScatterMap& fineScatterMapLevel1 = fineSite.getScatterMapLevel1();
619  StorageSite::ScatterMap& coarseScatterMap = coarseSite.getScatterMap();
620 
621  foreach(const StorageSite::ScatterMap::value_type& pos, fineScatterMap)
622  {
623  const StorageSite& fineOSite = *pos.first;
624 
625 #ifdef FVM_PARALLEL
626  // the ghost site will not have its corresponding coarse
627  // site created yet so we create it here
628  if (_siteMap.find(&fineOSite) == _siteMap.end())
629  {
630  shared_ptr<StorageSite> ghostSite
631  (new StorageSite(-1));
632  ghostSite->setGatherProcID ( fineOSite.getGatherProcID() );
633  ghostSite->setScatterProcID( fineOSite.getScatterProcID() );
634  ghostSite->setTag( fineOSite.getTag() );
635  StorageSite& coarseOSite = *ghostSite;
636  _siteMap[&fineOSite]=&coarseOSite;
637  _sharedSiteMap[&fineOSite]=ghostSite;
638  }
639 #endif
640 
641  StorageSite& coarseOSite = *_siteMap[&fineOSite];
642 
643  SSPair sskey(&fineSite,&fineOSite);
644  coarseScatterMap[&coarseOSite] = _coarseScatterMaps[sskey];
645  }
646 
647  foreach(const StorageSite::ScatterMap::value_type& pos, fineScatterMapLevel1)
648  {
649  const StorageSite& fineOSite = *pos.first;
650  SSPair sskey(&fineSite,&fineOSite);
651  if (_coarseScatterMaps.find(sskey) != _coarseScatterMaps.end())
652  {
653 
654 #ifdef FVM_PARALLEL
655  // the ghost site will not have its corresponding coarse
656  // site created yet so we create it here
657  if (_siteMap.find(&fineOSite) == _siteMap.end())
658  {
659  shared_ptr<StorageSite> ghostSite
660  (new StorageSite(-1));
661  ghostSite->setGatherProcID ( fineOSite.getGatherProcID() );
662  ghostSite->setScatterProcID( fineOSite.getScatterProcID() );
663  ghostSite->setTag( fineOSite.getTag() );
664  StorageSite& coarseOSite = *ghostSite;
665  _siteMap[&fineOSite]=&coarseOSite;
666  _sharedSiteMap[&fineOSite]=ghostSite;
667  }
668 #endif
669 
670  StorageSite& coarseOSite = *_siteMap[&fineOSite];
671 
672  coarseScatterMap[&coarseOSite] = _coarseScatterMaps[sskey];
673  }
674  }
675 
676  const StorageSite::GatherMap& fineGatherMap = fineSite.getGatherMap();
677  const StorageSite::GatherMap& fineGatherMapLevel1 = fineSite.getGatherMapLevel1();
678  StorageSite::GatherMap& coarseGatherMap = coarseSite.getGatherMap();
679  foreach(const StorageSite::GatherMap::value_type& pos, fineGatherMap)
680  {
681  const StorageSite& fineOSite = *pos.first;
682  StorageSite& coarseOSite = *_siteMap[&fineOSite];
683  SSPair sskey(&fineSite,&fineOSite);
684 
685  coarseGatherMap[&coarseOSite] = _coarseGatherMaps[sskey];
686  }
687 
688  foreach(const StorageSite::GatherMap::value_type& pos, fineGatherMapLevel1)
689  {
690  const StorageSite& fineOSite = *pos.first;
691  SSPair sskey(&fineSite,&fineOSite);
692  if (_coarseGatherMaps.find(sskey) != _coarseGatherMaps.end())
693  {
694  foreach(SiteMap::value_type tempPos, _siteMap)
695  {
696  const StorageSite& tempOSite = *tempPos.first;
697  if(fineOSite.getTag()==tempOSite.getTag())
698  {
699  //StorageSite& coarseOSite = *_siteMap[&fineOSite];
700  StorageSite& coarseOSite = *_siteMap[&tempOSite];
701  coarseGatherMap[&coarseOSite] = _coarseGatherMaps[sskey];
702  }
703  }
704  }
705  }
706 
707  }
708 
709  int newCount= MakeCoarseMesh2(finerModel->getMeshList(),
710  finerModel->getGeomFields(),_coarseGeomFields,
711  *newMeshesPtr);
712 
713  TCOMET* newModelPtr=new COMETModel(*newMeshesPtr,thisLevel,
715  *newMacroPtr,*newQuadPtr);
716 #ifdef FVM_PARALLEL
717  MPI::COMM_WORLD.Allreduce( MPI::IN_PLACE, &newCount, 1, MPI::INT, MPI::SUM);
718  if(MPI::COMM_WORLD.Get_rank()==0)
719  cout<<"Number of cells in level "<<thisLevel<<" is "<<newCount<<endl;
720 #endif
721 
722 #ifndef FVM_PARALLEL
723  cout<<"Number of cells in level "<<thisLevel<<" is "<<newCount<<endl;
724 #endif
725 
726  newModelPtr->setFinerLevel(finerModel);
727  finerModel->setCoarserLevel(newModelPtr);
728  newModelPtr->getOptions()=finerModel->getOptions();
729  newModelPtr->getBCMap()=finerModel->getBCMap();
730  newModelPtr->getVCMap()=finerModel->getVCMap();
731 
732  newModelPtr->init();
733  newModelPtr->InitializeMacroparameters();
734  newModelPtr->initializeMaxwellian();
735  newModelPtr->initializeCoarseMaxwellian();
736  newModelPtr->ComputeMacroparameters();
737  newModelPtr->ComputeCoarseMacroparameters();
738  newModelPtr->ComputeCollisionfrequency();
739  newModelPtr->initializeMaxwellianEq();
740 
741  if(newCount>_options.minCells)
742  newModelPtr->MakeCoarseModel(newModelPtr);
743  else
744  _options.maxLevels=newModelPtr->getLevel();
745  }
746  }
747  else if(_options.AgglomerationMethod=="AMG")
748  throw CException("Have not implemented AMG agglomeration method.");
749  else
750  throw CException("Unknown agglomeration method.");
751  }
GeomFields & _geomFields
COMETModel(const MeshList &meshes, const int level, GeomFields &geomFields, MacroFields &macroFields, Quadrature< T > &quad, const int ibm=0, GeomFields *finestGeomFields=NULL, const MeshList *finestMeshes=NULL, MacroFields *finestMacroFields=NULL)
MatrixMappersMap _coarseGatherMaps
Definition: Field.h:14
pair< const StorageSite *, const StorageSite * > SSPair
const GatherMap & getGatherMapLevel1() const
Definition: StorageSite.h:74
const ScatterMap & getScatterMapLevel1() const
Definition: StorageSite.h:73
Definition: Mesh.h:49
COMETModelOptions< T > _options
COMETModel< T > TCOMET
Field fineToCoarse
Definition: GeomFields.h:41
void syncGhostCoarsening(const MeshList &inMeshes, GeomFields &inGeomFields, MeshList &outMeshes)
int getTag() const
Definition: StorageSite.h:84
int getScatterProcID() const
Definition: StorageSite.h:82
int getGatherProcID() const
Definition: StorageSite.h:83
GhostStorageSiteMap _sharedSiteMap
const MeshList _meshes
Definition: Model.h:29
void MakeCoarseMesh1(const MeshList &inMeshes, GeomFields &inGeomFields, MeshList &outMeshes)
const StorageSite & getCells() const
Definition: Mesh.h:109
const ScatterMap & getScatterMap() const
Definition: StorageSite.h:58
map< const StorageSite *, shared_ptr< Array< int > > > ScatterMap
Definition: StorageSite.h:23
const GatherMap & getGatherMap() const
Definition: StorageSite.h:59
int MakeCoarseMesh2(const MeshList &inMeshes, GeomFields &inGeomFields, GeomFields &coarseGeomFields, MeshList &outMeshes)
int getCount() const
Definition: StorageSite.h:39
Array< int > IntArray
map< const StorageSite *, shared_ptr< Array< int > > > GatherMap
Definition: StorageSite.h:24
GeomFields _coarseGeomFields
MatrixMappersMap _coarseScatterMaps
void syncLocal()
Definition: Field.cpp:334
Quadrature< T > TQuad
vector< Mesh * > MeshList
Definition: Mesh.h:439
template<class T >
void COMETModel< T >::MakeCoarseModel ( TCOMET finerModel)
inline

Definition at line 1080 of file phononbase/COMETModel.h.

References COMETModel< T >::_geomFields, COMETModel< T >::_kspaces, COMETModel< T >::_macro, Model::_meshes, COMETModel< T >::_MeshKspaceMap, COMETModel< T >::_options, COMETModel< T >::COMETModel(), GeomFields::fineToCoarse, COMETModel< T >::FinishCoarseMesh(), COMETModel< T >::getBCs(), COMETModel< T >::getGeomFields(), COMETModel< T >::getIClist(), COMETModel< T >::getKspaces(), COMETModel< T >::getLevel(), COMETModel< T >::getMeshICmap(), COMETModel< T >::getMeshList(), COMETModel< T >::getMKMap(), COMETModel< T >::getOptions(), COMETInterface< T >::makeCoarseCoeffs(), COMETModel< T >::makeCoarseScatGath(), COMETModel< T >::MakeInteriorCoarseMesh(), COMETModel< T >::MakeNewKspaces(), COMETModel< T >::setCoarserLevel(), COMETModel< T >::syncGhostCoarsening(), and Field::syncLocal().

1081  {
1082 
1083  if(_options.AgglomerationMethod=="FaceArea")
1084  {
1085  int maxLevs=finerModel->getOptions().maxLevels;
1086  int thisLevel=(finerModel->getLevel())+1;
1087 
1088  if(thisLevel<maxLevs) //assumes # of levels will always work for the mesh
1089  {
1090  MeshList* newMeshesPtr=new MeshList;
1091  TkspList* newKspacesPtr=new TkspList;
1092  PhononMacro* newMacroPtr=new PhononMacro("coarse");
1093 
1094  MakeNewKspaces(finerModel->getKspaces(),*newKspacesPtr);
1095 
1096  IntArray CoarseCounts(_meshes.size());
1097  IntArray CoarseGhost(_meshes.size());
1098  map<const StorageSite*, IntArray*> PreFacePairMap;
1099  SiteMap siteMap;
1100 
1101  MakeInteriorCoarseMesh(finerModel->getMeshList(), finerModel->getGeomFields(),
1102  *newMeshesPtr, CoarseCounts, PreFacePairMap, CoarseGhost, siteMap);
1103 
1104 #ifdef FVM_PARALLEL
1106  ScatGathMaps coarseScatterMaps;
1107  ScatGathMaps coarseGatherMaps;
1108 
1109  syncGhostCoarsening(finerModel->getMeshList(), finerModel->getGeomFields(),
1110  *newMeshesPtr, coarseScatterMaps, coarseGatherMaps, CoarseCounts,
1111  CoarseGhost);
1112 
1113  makeCoarseScatGath(finerModel->getMeshList(), siteMap, coarseScatterMaps, coarseGatherMaps);
1114 #endif
1115 
1116  int newCount=FinishCoarseMesh(finerModel->getMeshList(), finerModel->getGeomFields(),
1117  *newMeshesPtr, CoarseCounts, PreFacePairMap, CoarseGhost);
1118 
1119  TCOMET* newModelPtr=new COMETModel(*newMeshesPtr,thisLevel,
1120  finerModel->getGeomFields(),
1121  *newKspacesPtr,*newMacroPtr);
1122 
1123  newModelPtr->setFinerLevel(finerModel);
1124  finerModel->setCoarserLevel(newModelPtr);
1125  newModelPtr->getOptions()=finerModel->getOptions();
1126  newModelPtr->getBCs()=finerModel->getBCs();
1127  newModelPtr->getMKMap()=finerModel->getMKMap();
1128  newModelPtr->getIClist()=finerModel->getIClist();
1129  newModelPtr->getMeshICmap()=finerModel->getMeshICmap();
1131  ComInt.makeCoarseCoeffs(finerModel->getIClist(),newModelPtr->getIClist(),*newMeshesPtr);
1132  newModelPtr->initCoarse();
1133 
1134  if(_options.DomainStats=="Loud")
1135  {
1136  cout<<"Level: "<<newModelPtr->getLevel()<<endl<<endl;
1137  newModelPtr->calcDomainStats();
1138  cout<<endl;
1139  }
1140 
1141  if(newCount>3)
1142  newModelPtr->MakeCoarseModel(newModelPtr);
1143  else
1144  _options.maxLevels=newModelPtr->getLevel();
1145  }
1146  }
1147  else if(_options.AgglomerationMethod=="AMG")
1148  throw CException("Have not implemented AMG agglomeration method.");
1149  else
1150  throw CException("Unknown agglomeration method.");
1151  }
GeomFields & _geomFields
int FinishCoarseMesh(const MeshList &inMeshes, GeomFields &inGeomFields, MeshList &outMeshes, IntArray &CoarseCounts, map< const StorageSite *, IntArray * > &PreFacePairMap, IntArray &coarseGhost)
COMETModel(const MeshList &meshes, const int level, GeomFields &geomFields, MacroFields &macroFields, Quadrature< T > &quad, const int ibm=0, GeomFields *finestGeomFields=NULL, const MeshList *finestMeshes=NULL, MacroFields *finestMacroFields=NULL)
void MakeNewKspaces(TkspList &inList, TkspList &outList)
void MakeInteriorCoarseMesh(const MeshList &inMeshes, GeomFields &inGeomFields, MeshList &outMeshes, IntArray &CoarseCounts, map< const StorageSite *, IntArray * > &PreFacePairMap, IntArray &CoarseGhost, SiteMap &siteMap)
COMETModelOptions< T > _options
map< const StorageSite *, StorageSite * > SiteMap
COMETModel< T > TCOMET
Field fineToCoarse
Definition: GeomFields.h:41
void syncGhostCoarsening(const MeshList &inMeshes, GeomFields &inGeomFields, MeshList &outMeshes)
PhononMacro & _macro
const MeshList _meshes
Definition: Model.h:29
MeshKspaceMap _MeshKspaceMap
void makeCoarseScatGath(const MeshList &inMeshes, SiteMap &siteMap, ScatGathMaps &coarseScatMaps, ScatGathMaps &coarseGathMaps)
vector< Tkspace * > TkspList
Array< int > IntArray
map< SSPair, shared_ptr< Array< int > > > ScatGathMaps
void syncLocal()
Definition: Field.cpp:334
vector< Mesh * > MeshList
Definition: Mesh.h:439
template<class T >
void COMETModel< T >::makeCoarseScatGath ( const MeshList inMeshes,
SiteMap siteMap,
ScatGathMaps coarseScatMaps,
ScatGathMaps coarseGathMaps 
)
inline

Definition at line 1614 of file phononbase/COMETModel.h.

References Model::_meshes, Mesh::getCells(), StorageSite::getGatherMap(), StorageSite::getGatherProcID(), StorageSite::getScatterMap(), StorageSite::getScatterProcID(), StorageSite::getTag(), StorageSite::setGatherProcID(), StorageSite::setScatterProcID(), and StorageSite::setTag().

Referenced by COMETModel< T >::MakeCoarseModel().

1616  {
1617  const int numMeshes =_meshes.size();
1618  for (int n=0; n<numMeshes; n++)
1619  {
1620  const Mesh& mesh = *_meshes[n];
1621  const StorageSite& fineSite = mesh.getCells();
1622  StorageSite& coarseSite = *siteMap[&fineSite];
1623  const StorageSite::ScatterMap& fineScatterMap = fineSite.getScatterMap();
1624  StorageSite::ScatterMap& coarseScatterMap = coarseSite.getScatterMap();
1625 
1626  foreach(const StorageSite::ScatterMap::value_type& pos, fineScatterMap)
1627  {
1628  const StorageSite& fineOSite = *pos.first;
1629 
1630  // the ghost site will not have its corresponding coarse
1631  // site created yet so we create it here
1632  if (siteMap.find(&fineOSite) == siteMap.end())
1633  {
1634  StorageSite* ghostSite=new StorageSite(-1);
1635  ghostSite->setGatherProcID (fineOSite.getGatherProcID());
1636  ghostSite->setScatterProcID(fineOSite.getScatterProcID());
1637  ghostSite->setTag( fineOSite.getTag() );
1638  siteMap[&fineOSite]=ghostSite;
1639  }
1640 
1641  StorageSite* coarseOSite = siteMap[&fineOSite];
1642 
1643  SSPair sskey(&fineSite,&fineOSite);
1644  coarseScatterMap[coarseOSite] = coarseScatMaps[sskey];
1645 
1646  }
1647 
1648  const StorageSite::GatherMap& fineGatherMap = fineSite.getGatherMap();
1649  StorageSite::GatherMap& coarseGatherMap = coarseSite.getGatherMap();
1650 
1651  foreach(const StorageSite::GatherMap::value_type& pos, fineGatherMap)
1652  {
1653  const StorageSite& fineOSite = *pos.first;
1654  StorageSite& coarseOSite = *siteMap[&fineOSite];
1655  SSPair sskey(&fineSite,&fineOSite);
1656 
1657  coarseGatherMap[&coarseOSite] = coarseGathMaps[sskey];
1658  }
1659 
1660  }
1661  }
void setScatterProcID(int proc_id)
Definition: StorageSite.h:51
pair< const StorageSite *, const StorageSite * > SSPair
void setTag(int tag)
Definition: StorageSite.h:53
Definition: Mesh.h:49
int getTag() const
Definition: StorageSite.h:84
int getScatterProcID() const
Definition: StorageSite.h:82
int getGatherProcID() const
Definition: StorageSite.h:83
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
const ScatterMap & getScatterMap() const
Definition: StorageSite.h:58
map< const StorageSite *, shared_ptr< Array< int > > > ScatterMap
Definition: StorageSite.h:23
void setGatherProcID(int proc_id)
Definition: StorageSite.h:52
const GatherMap & getGatherMap() const
Definition: StorageSite.h:59
map< const StorageSite *, shared_ptr< Array< int > > > GatherMap
Definition: StorageSite.h:24
template<class T >
void COMETModel< T >::makeFAS ( )
inline

Definition at line 3107 of file phononbase/COMETModel.h.

References COMETModel< T >::_kspaces, COMETModel< T >::_macro, Model::_meshes, COMETModel< T >::_MeshKspaceMap, Mesh::getCells(), Kspace< T >::makeFAS(), PhononMacro::TlFASCorrection, PhononMacro::TlResidual, and COMETModel< T >::updateResid().

3108  {
3109  updateResid(false);
3110 
3111  const int numMeshes = _meshes.size();
3112  for (int n=0; n<numMeshes; n++)
3113  {
3114  const Mesh& mesh=*_meshes[n];
3115  Tkspace& kspace=*_kspaces[_MeshKspaceMap[n]];
3116  const StorageSite& cells=mesh.getCells();
3117  kspace.makeFAS();
3118 
3119  TArray& resArray=dynamic_cast<TArray&>(_macro.TlResidual[cells]);
3120  TArray& fasArray=dynamic_cast<TArray&>(_macro.TlFASCorrection[cells]);
3121  fasArray-=resArray;
3122  }
3123  }
T updateResid(const bool addFAS)
Array< T > TArray
Definition: Mesh.h:49
Field TlResidual
Definition: PhononMacro.h:24
Field TlFASCorrection
Definition: PhononMacro.h:26
PhononMacro & _macro
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
MeshKspaceMap _MeshKspaceMap
Kspace< T > Tkspace
template<class T >
void COMETModel< T >::makeFAS ( )
inline

Definition at line 5280 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfPtrFAS, COMETModel< T >::_dsfPtrRes, COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_quadrature, Mesh::getCells(), COMETModel< T >::updateResid(), MacroFields::velocityFASCorrection, and MacroFields::velocityResidual.

Referenced by COMETModel< T >::cycle().

5281  {
5282  updateResid(false);
5283 
5284  const int numMeshes = _meshes.size();
5285  for (int n=0; n<numMeshes; n++)
5286  {
5287  const Mesh& mesh=*_meshes[n];
5288  const StorageSite& cells=mesh.getCells();
5289 
5290  const int numDir = _quadrature.getDirCount();
5291  for(int dir=0;dir<numDir;dir++)
5292  {
5293  Field& fndRes = *_dsfPtrRes.dsf[dir];
5294  Field& fndFAS = *_dsfPtrFAS.dsf[dir];
5295  TArray& fRes = dynamic_cast<TArray&>(fndRes[cells]);
5296  TArray& fFAS = dynamic_cast<TArray&>(fndFAS[cells]);
5297 
5298  fFAS-=fRes;
5299  }
5300 
5301  VectorT3Array& vR = dynamic_cast<VectorT3Array&>(_macroFields.velocityResidual[cells]);
5302  VectorT3Array& vF = dynamic_cast<VectorT3Array&>(_macroFields.velocityFASCorrection[cells]);
5303 
5304  vF-=vR;
5305  }
5306  }
T updateResid(const bool addFAS)
Quadrature< T > & _quadrature
Array< T > TArray
Definition: Field.h:14
Definition: Mesh.h:49
Field velocityResidual
Definition: MacroFields.h:16
DistFunctFields< T > _dsfPtrFAS
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
Field velocityFASCorrection
Definition: MacroFields.h:18
DistFunctFields< T > _dsfPtrRes
template<class T >
void COMETModel< T >::makeFAS ( const StorageSite solidFaces)
inline

Definition at line 5308 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfPtrFAS, COMETModel< T >::_dsfPtrRes, COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_quadrature, Mesh::getCells(), COMETModel< T >::updateResid(), MacroFields::velocityFASCorrection, and MacroFields::velocityResidual.

5309  {
5310  updateResid(false,solidFaces);
5311 
5312  const int numMeshes = _meshes.size();
5313  for (int n=0; n<numMeshes; n++)
5314  {
5315  const Mesh& mesh=*_meshes[n];
5316  const StorageSite& cells=mesh.getCells();
5317 
5318  const int numDir = _quadrature.getDirCount();
5319  for(int dir=0;dir<numDir;dir++)
5320  {
5321  Field& fndRes = *_dsfPtrRes.dsf[dir];
5322  Field& fndFAS = *_dsfPtrFAS.dsf[dir];
5323  TArray& fRes = dynamic_cast<TArray&>(fndRes[cells]);
5324  TArray& fFAS = dynamic_cast<TArray&>(fndFAS[cells]);
5325 
5326  fFAS-=fRes;
5327  }
5328 
5329  VectorT3Array& vR = dynamic_cast<VectorT3Array&>(_macroFields.velocityResidual[cells]);
5330  VectorT3Array& vF = dynamic_cast<VectorT3Array&>(_macroFields.velocityFASCorrection[cells]);
5331 
5332  vF-=vR;
5333  }
5334  }
T updateResid(const bool addFAS)
Quadrature< T > & _quadrature
Array< T > TArray
Definition: Field.h:14
Definition: Mesh.h:49
Field velocityResidual
Definition: MacroFields.h:16
DistFunctFields< T > _dsfPtrFAS
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
Field velocityFASCorrection
Definition: MacroFields.h:18
DistFunctFields< T > _dsfPtrRes
template<class T >
void COMETModel< T >::makeFinestToCoarseConn ( )
inline

Definition at line 4139 of file phononbase/COMETModel.h.

References COMETModel< T >::_coarserLevel, Model::_meshes, COMETModel< T >::_options, Mesh::getCells(), Mesh::getConnectivity(), COMETModel< T >::getFinerModel(), COMETModel< T >::getMeshList(), COMETModel< T >::getModelPointer(), CRConnectivity::getTranspose(), and Mesh::setConnectivity().

Referenced by COMETModel< T >::makePlotColors().

4140  {
4141  const int numMeshes = _meshes.size();
4142  for (int n=0; n<numMeshes; n++)
4143  {
4144  Mesh& mesh=*_meshes[n];
4145  const StorageSite& cells=mesh.getCells();
4146 
4147  Mesh& mesh1=*(_coarserLevel->getMeshList()[n]);
4148  const StorageSite& cells1=mesh1.getCells();
4149 
4150  const CRConnectivity& firstCRC=mesh1.getConnectivity(cells1,cells);
4151  CRPtr FineToCoarseOld=firstCRC.getTranspose();
4152 
4153  mesh.setConnectivity(cells,cells1,FineToCoarseOld);
4154 
4155  for(int lvl=2;lvl<_options.maxLevels;lvl++)
4156  {
4157  TCOMET* coarseModel=getModelPointer(lvl);
4158  Mesh& coarseMesh=*(coarseModel->getMeshList()[n]);
4159  const StorageSite& coarseCells=coarseMesh.getCells();
4160  TCOMET* finerModel=coarseModel->getFinerModel();
4161  Mesh& finerMesh=*(finerModel->getMeshList()[n]);
4162  const StorageSite& finerCells=finerMesh.getCells();
4163  const CRConnectivity& coarseToFine=coarseMesh.getConnectivity(coarseCells, finerCells);
4164  CRPtr FineToCoarseNew=coarseToFine.getTranspose();
4165  FineToCoarseNew=FineToCoarseOld->multiply(*FineToCoarseNew,true);
4166  mesh.setConnectivity(cells, coarseCells,FineToCoarseNew);
4167  FineToCoarseOld=FineToCoarseNew;
4168  }
4169 
4170  }
4171  }
const CRConnectivity & getConnectivity(const StorageSite &from, const StorageSite &to) const
Definition: Mesh.cpp:416
Definition: Mesh.h:49
COMETModelOptions< T > _options
void setConnectivity(const StorageSite &rowSite, const StorageSite &colSite, shared_ptr< CRConnectivity > conn)
Definition: Mesh.cpp:352
TCOMET * getModelPointer(const int level)
COMETModel< T > TCOMET
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
shared_ptr< CRConnectivity > CRPtr
const MeshList & getMeshList()
shared_ptr< CRConnectivity > getTranspose() const
template<class T >
void COMETModel< T >::MakeIBCoarseModel ( TCOMET finerModel,
const StorageSite solidFaces 
)
inline

Definition at line 753 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_coarseGatherMaps, COMETModel< T >::_coarseGeomFields, COMETModel< T >::_coarserLevel, COMETModel< T >::_coarseScatterMaps, COMETModel< T >::_dsfPtr, COMETModel< T >::_finestGeomFields, COMETModel< T >::_finestMacroFields, COMETModel< T >::_finestMeshes, COMETModel< T >::_geomFields, COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_options, COMETModel< T >::_quadrature, COMETModel< T >::_sharedSiteMap, COMETModel< T >::_siteMap, Field::addArray(), COMETModel< T >::COMETModel(), COMETModel< T >::ComputeCoarseMacroparameters(), COMETModel< T >::ComputeCollisionfrequency(), COMETModel< T >::ComputeMacroparameters(), Quadrature< T >::CopyQuad(), MacroFields::density, DistFunctFields< T >::dsf, GeomFields::fineToCoarse, COMETModel< T >::getBCMap(), Mesh::getCells(), StorageSite::getCount(), COMETModel< T >::getdsf(), StorageSite::getGatherMap(), StorageSite::getGatherMapLevel1(), StorageSite::getGatherProcID(), COMETModel< T >::getGeomFields(), Mesh::getIBFaces(), COMETModel< T >::getLevel(), COMETModel< T >::getMeshList(), COMETModel< T >::getOptions(), COMETModel< T >::getQuadrature(), StorageSite::getScatterMap(), StorageSite::getScatterMapLevel1(), StorageSite::getScatterProcID(), StorageSite::getTag(), COMETModel< T >::getVCMap(), GeomFields::ibType, COMETModel< T >::init(), COMETModel< T >::initializeCoarseMaxwellian(), COMETModel< T >::InitializeMacroparameters(), COMETModel< T >::initializeMaxwellian(), COMETModel< T >::initializeMaxwellianEq(), COMETModel< T >::MakeCoarseMesh1(), COMETModel< T >::MakeCoarseMesh2(), COMETModel< T >::MakeIBCoarseModel(), COMETModel< T >::setCoarserLevel(), COMETModel< T >::setFinerLevel(), COMETModel< T >::syncGhostCoarsening(), Field::syncLocal(), MacroFields::temperature, and MacroFields::velocity.

Referenced by COMETModel< T >::MakeIBCoarseModel().

754  {
755 
756  if(_options.AgglomerationMethod=="FaceArea")
757  {
758  int maxLevs=finerModel->getOptions().maxLevels;
759  int thisLevel=(finerModel->getLevel())+1;
760 
761  if(thisLevel<maxLevs) //assumes # of levels will always work for the mesh
762  {
763  MeshList* newMeshesPtr=new MeshList;
764  TQuad* newQuadPtr=new TQuad();
765  MacroFields* newMacroPtr=new MacroFields("coarse");
766 
767  newQuadPtr->CopyQuad(finerModel->getQuadrature());
768 
769  MakeCoarseMesh1(finerModel->getMeshList(),
770  finerModel->getGeomFields(),
771  *newMeshesPtr);
772 
774  const Mesh& mesh = *_meshes[0];
775  const StorageSite& cells = mesh.getCells();
776  const int nCells = cells.getCount();
777  Field& FineToCoarseField=(finerModel->getGeomFields()).fineToCoarse;
778  const IntArray& coarseIndex=dynamic_cast<const IntArray&>(FineToCoarseField[cells]);
779 
780  /*
781  if(MPI::COMM_WORLD.Get_rank()==1)
782  for(int c=0;c<nCells;c++)
783  cout<<" after sync, rank, level, cell no and finetocoarse = "<<MPI::COMM_WORLD.Get_rank()<<" "<<_level<<" "<<c<<" "<<coarseIndex[c]<<endl;
784  */
785 
786  syncGhostCoarsening(finerModel->getMeshList(),
787  finerModel->getGeomFields(),
788  *newMeshesPtr);
789  const int numMeshes =_meshes.size();
790  for (int n=0; n<numMeshes; n++)
791  {
792  const Mesh& mesh = *_meshes[n];
793  const StorageSite& fineSite = mesh.getCells();
794  StorageSite& coarseSite = *_siteMap[&fineSite];
795  const StorageSite::ScatterMap& fineScatterMap = fineSite.getScatterMap();
796  const StorageSite::ScatterMap& fineScatterMapLevel1 = fineSite.getScatterMapLevel1();
797  StorageSite::ScatterMap& coarseScatterMap = coarseSite.getScatterMap();
798 
799  foreach(const StorageSite::ScatterMap::value_type& pos, fineScatterMap)
800  {
801  const StorageSite& fineOSite = *pos.first;
802 
803 #ifdef FVM_PARALLEL
804  // the ghost site will not have its corresponding coarse
805  // site created yet so we create it here
806  if (_siteMap.find(&fineOSite) == _siteMap.end())
807  {
808  shared_ptr<StorageSite> ghostSite
809  (new StorageSite(-1));
810  ghostSite->setGatherProcID ( fineOSite.getGatherProcID() );
811  ghostSite->setScatterProcID( fineOSite.getScatterProcID() );
812  ghostSite->setTag( fineOSite.getTag() );
813  StorageSite& coarseOSite = *ghostSite;
814  _siteMap[&fineOSite]=&coarseOSite;
815  _sharedSiteMap[&fineOSite]=ghostSite;
816  }
817 #endif
818 
819  StorageSite& coarseOSite = *_siteMap[&fineOSite];
820 
821  SSPair sskey(&fineSite,&fineOSite);
822  coarseScatterMap[&coarseOSite] = _coarseScatterMaps[sskey];
823  }
824 
825  foreach(const StorageSite::ScatterMap::value_type& pos, fineScatterMapLevel1)
826  {
827  const StorageSite& fineOSite = *pos.first;
828  SSPair sskey(&fineSite,&fineOSite);
829  if (_coarseScatterMaps.find(sskey) != _coarseScatterMaps.end())
830  {
831 
832 #ifdef FVM_PARALLEL
833  // the ghost site will not have its corresponding coarse
834  // site created yet so we create it here
835  if (_siteMap.find(&fineOSite) == _siteMap.end())
836  {
837  shared_ptr<StorageSite> ghostSite
838  (new StorageSite(-1));
839  ghostSite->setGatherProcID ( fineOSite.getGatherProcID() );
840  ghostSite->setScatterProcID( fineOSite.getScatterProcID() );
841  ghostSite->setTag( fineOSite.getTag() );
842  StorageSite& coarseOSite = *ghostSite;
843  _siteMap[&fineOSite]=&coarseOSite;
844  _sharedSiteMap[&fineOSite]=ghostSite;
845  }
846 #endif
847 
848  StorageSite& coarseOSite = *_siteMap[&fineOSite];
849 
850  coarseScatterMap[&coarseOSite] = _coarseScatterMaps[sskey];
851  }
852  }
853 
854  const StorageSite::GatherMap& fineGatherMap = fineSite.getGatherMap();
855  const StorageSite::GatherMap& fineGatherMapLevel1 = fineSite.getGatherMapLevel1();
856  StorageSite::GatherMap& coarseGatherMap = coarseSite.getGatherMap();
857  foreach(const StorageSite::GatherMap::value_type& pos, fineGatherMap)
858  {
859  const StorageSite& fineOSite = *pos.first;
860  StorageSite& coarseOSite = *_siteMap[&fineOSite];
861  SSPair sskey(&fineSite,&fineOSite);
862 
863  coarseGatherMap[&coarseOSite] = _coarseGatherMaps[sskey];
864  }
865  foreach(const StorageSite::GatherMap::value_type& pos, fineGatherMapLevel1)
866  {
867  const StorageSite& fineOSite = *pos.first;
868  SSPair sskey(&fineSite,&fineOSite);
869  if (_coarseGatherMaps.find(sskey) != _coarseGatherMaps.end())
870  {
871  foreach(SiteMap::value_type tempPos, _siteMap)
872  {
873  const StorageSite& tempOSite = *tempPos.first;
874  if(fineOSite.getTag()==tempOSite.getTag())
875  {
876  //StorageSite& coarseOSite = *_siteMap[&fineOSite];
877  StorageSite& coarseOSite = *_siteMap[&tempOSite];
878  coarseGatherMap[&coarseOSite] = _coarseGatherMaps[sskey];
879  }
880  }
881  }
882  }
883 
884  }
885 
886  int newCount= MakeCoarseMesh2(finerModel->getMeshList(),
887  finerModel->getGeomFields(),_coarseGeomFields,
888  *newMeshesPtr);
889 
891 
892  TCOMET* newModelPtr=new COMETModel(*newMeshesPtr,thisLevel,
894  *newMacroPtr,*newQuadPtr,1,&_finestGeomFields,&_finestMeshes,&_finestMacroFields);
895 #ifdef FVM_PARALLEL
896  MPI::COMM_WORLD.Allreduce( MPI::IN_PLACE, &newCount, 1, MPI::INT, MPI::SUM);
897  if(MPI::COMM_WORLD.Get_rank()==0)
898  cout<<"Number of cells in level "<<thisLevel<<" is "<<newCount<<endl;
899 #endif
900 
901 #ifndef FVM_PARALLEL
902  cout<<"Number of cells in level "<<thisLevel<<" is "<<newCount<<endl;
903 #endif
904 
905  newModelPtr->setFinerLevel(finerModel);
906  finerModel->setCoarserLevel(newModelPtr);
907  newModelPtr->getOptions()=finerModel->getOptions();
908  newModelPtr->getBCMap()=finerModel->getBCMap();
909  newModelPtr->getVCMap()=finerModel->getVCMap();
910 
911  for (int n=0; n<numMeshes; n++)
912  {
913  const Mesh& mesh = *_meshes[n];
914  const StorageSite& fineIBFaces = mesh.getIBFaces();
915  if(fineIBFaces.getCount()>0)
916  {
917  StorageSite& coarseIBFaces = *_siteMap[&fineIBFaces];
918  for(int dir=0;dir<_quadrature.getDirCount();dir++)
919  {
920  Field& fnd = *_dsfPtr.dsf[dir];
921  const TArray& fIB = dynamic_cast<const TArray&>(fnd[fineIBFaces]);
922  shared_ptr<TArray> cIBV(new TArray(coarseIBFaces.getCount()));
923  cIBV->zero();
924  DistFunctFields<T>& coarserdsf = _coarserLevel->getdsf();
925  Field& cfnd = *coarserdsf.dsf[dir];
926  cfnd.addArray(coarseIBFaces,cIBV);
927  TArray& cIB = dynamic_cast<TArray&>(cfnd[coarseIBFaces]);
928  for(int i=0;i<coarseIBFaces.getCount();i++)
929  cIB[i]=fIB[i];
930  }
931  }
932 
933  shared_ptr<VectorT3Array> coarseSolidVel(new VectorT3Array(solidFaces.getCount()));
934  const VectorT3Array& fineSolidVel = dynamic_cast<const VectorT3Array&>(_macroFields.velocity[solidFaces]);
935  *coarseSolidVel = fineSolidVel;
936  newMacroPtr->velocity.addArray(solidFaces,coarseSolidVel);
937 
938  shared_ptr<TArray> coarseSolidDensity(new TArray(solidFaces.getCount()));
939  const TArray& fineSolidDensity = dynamic_cast<const TArray&>(_macroFields.density[solidFaces]);
940  *coarseSolidDensity = fineSolidDensity;
941  newMacroPtr->density.addArray(solidFaces,coarseSolidDensity);
942 
943  shared_ptr<TArray> coarseSolidTemperature(new TArray(solidFaces.getCount()));
944  const TArray& fineSolidTemperature = dynamic_cast<const TArray&>(_macroFields.temperature[solidFaces]);
945  *coarseSolidTemperature = fineSolidTemperature;
946  newMacroPtr->temperature.addArray(solidFaces,coarseSolidTemperature);
947  }
948 
949  newModelPtr->init();
950  newModelPtr->InitializeMacroparameters();
951  newModelPtr->initializeMaxwellian();
952  newModelPtr->initializeCoarseMaxwellian();
953  newModelPtr->ComputeMacroparameters();
954  newModelPtr->ComputeCoarseMacroparameters();
955  newModelPtr->ComputeCollisionfrequency();
956  newModelPtr->initializeMaxwellianEq();
957 
958  if(newCount>_options.minCells)
959  newModelPtr->MakeIBCoarseModel(newModelPtr,solidFaces);
960  else
961  _options.maxLevels=newModelPtr->getLevel();
962  }
963  }
964  else if(_options.AgglomerationMethod=="AMG")
965  throw CException("Have not implemented AMG agglomeration method.");
966  else
967  throw CException("Unknown agglomeration method.");
968  }
const MeshList & _finestMeshes
GeomFields & _geomFields
const StorageSite & getIBFaces() const
Definition: Mesh.h:111
COMETModel(const MeshList &meshes, const int level, GeomFields &geomFields, MacroFields &macroFields, Quadrature< T > &quad, const int ibm=0, GeomFields *finestGeomFields=NULL, const MeshList *finestMeshes=NULL, MacroFields *finestMacroFields=NULL)
Quadrature< T > & _quadrature
Array< T > TArray
MatrixMappersMap _coarseGatherMaps
Definition: Field.h:14
pair< const StorageSite *, const StorageSite * > SSPair
const GatherMap & getGatherMapLevel1() const
Definition: StorageSite.h:74
const ScatterMap & getScatterMapLevel1() const
Definition: StorageSite.h:73
Definition: Mesh.h:49
COMETModelOptions< T > _options
Field ibType
Definition: GeomFields.h:38
COMETModel< T > TCOMET
Field fineToCoarse
Definition: GeomFields.h:41
Field temperature
Definition: MacroFields.h:22
void syncGhostCoarsening(const MeshList &inMeshes, GeomFields &inGeomFields, MeshList &outMeshes)
Array< VectorT3 > VectorT3Array
int getTag() const
Definition: StorageSite.h:84
int getScatterProcID() const
Definition: StorageSite.h:82
GeomFields & _finestGeomFields
int getGatherProcID() const
Definition: StorageSite.h:83
GhostStorageSiteMap _sharedSiteMap
DistFunctFields< T > & getdsf()
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
void MakeCoarseMesh1(const MeshList &inMeshes, GeomFields &inGeomFields, MeshList &outMeshes)
const StorageSite & getCells() const
Definition: Mesh.h:109
const ScatterMap & getScatterMap() const
Definition: StorageSite.h:58
void addArray(const StorageSite &, shared_ptr< ArrayBase > a)
Definition: Field.cpp:72
map< const StorageSite *, shared_ptr< Array< int > > > ScatterMap
Definition: StorageSite.h:23
MacroFields & _finestMacroFields
Field velocity
Definition: MacroFields.h:15
const GatherMap & getGatherMap() const
Definition: StorageSite.h:59
std::vector< Field * > dsf
int MakeCoarseMesh2(const MeshList &inMeshes, GeomFields &inGeomFields, GeomFields &coarseGeomFields, MeshList &outMeshes)
DistFunctFields< T > _dsfPtr
int getCount() const
Definition: StorageSite.h:39
Array< int > IntArray
map< const StorageSite *, shared_ptr< Array< int > > > GatherMap
Definition: StorageSite.h:24
GeomFields _coarseGeomFields
MatrixMappersMap _coarseScatterMaps
void syncLocal()
Definition: Field.cpp:334
Field density
Definition: MacroFields.h:21
Quadrature< T > TQuad
vector< Mesh * > MeshList
Definition: Mesh.h:439
template<class T >
void COMETModel< T >::MakeInteriorCoarseMesh ( const MeshList inMeshes,
GeomFields inGeomFields,
MeshList outMeshes,
IntArray CoarseCounts,
map< const StorageSite *, IntArray * > &  PreFacePairMap,
IntArray CoarseGhost,
SiteMap siteMap 
)
inline

break up face agglomeration if summed area is zero-ish

Definition at line 1176 of file phononbase/COMETModel.h.

References COMETModel< T >::_bcMap, COMETModel< T >::_IClist, Model::_meshes, GeomFields::area, COMETModel< T >::coarsenInterfaceCells(), COMETModel< T >::coarsenInterior(), COMETModel< T >::correctSingleNeighbor(), COMETIC< T >::FgID0, COMETIC< T >::FgID1, GeomFields::fineToCoarse, COMETIC< T >::FineToCoarse0, COMETIC< T >::FineToCoarse1, Mesh::getBoundaryFaceGroups(), Mesh::getCells(), StorageSite::getCommonMap(), StorageSite::getCount(), CRConnectivity::getCount(), Mesh::getDimension(), Mesh::getFaceCells(), Mesh::getFaceGroup(), Mesh::getFaces(), StorageSite::getOffset(), StorageSite::getSelfCount(), CRConnectivity::getTranspose(), FaceGroup::id, COMETIC< T >::MeshID0, COMETIC< T >::MeshID1, CRConnectivity::multiply(), Mesh::setID(), FaceGroup::site, sqrt(), and Array< T >::zero().

Referenced by COMETModel< T >::MakeCoarseModel().

1180  {
1181 
1182  const int numMeshes=inMeshes.size();
1183  CoarseCounts=0;
1184 
1185  //coarsen interfaces first
1186 
1187  foreach(COMETIC<T>* icPtr, _IClist)
1188  {
1189  COMETIC<T>& ic=*icPtr;
1190  coarsenInterfaceCells(ic, CoarseCounts, inGeomFields, inMeshes);
1191  }
1192 
1193  //coarsen interiors
1194  for(int m=0;m<numMeshes;m++)
1195  {
1196  const Mesh& mesh=*inMeshes[m];
1197  const int dim=mesh.getDimension();
1198  Mesh* newMeshPtr=new Mesh(dim);
1199  outMeshes.push_back(newMeshPtr);
1200  newMeshPtr->setID(m);
1201  siteMap[&(mesh.getCells())]=&(newMeshPtr->getCells());
1202  int coarseCount=coarsenInterior(m, mesh, inGeomFields, CoarseCounts[m]);
1203  }
1204 
1205  foreach(COMETIC<T>* icPtr, _IClist)
1206  {
1207  COMETIC<T>& ic=*icPtr;
1208  const int Mid0=ic.MeshID0;
1209  const int Mid1=ic.MeshID1;
1210  const int Fid0=ic.FgID0;
1211  const int Fid1=ic.FgID1;
1212  const Mesh& mesh0=*inMeshes[Mid0];
1213  const Mesh& mesh1=*inMeshes[Mid1];
1214  const StorageSite& faces0=mesh0.getFaceGroup(Fid0).site;
1215  const StorageSite& faces1=mesh1.getFaceGroup(Fid1).site;
1216  const StorageSite::CommonMap& ComMap = faces0.getCommonMap();
1217  const IntArray& common01=*(ComMap.find(&faces1)->second);
1218  const StorageSite& cells0=mesh0.getCells();
1219  const StorageSite& cells1=mesh1.getCells();
1220  //const int f1Offset=faces1.getOffset();
1221  const StorageSite& allFaces0=mesh0.getFaces();
1222  const CRConnectivity& faceCells0=mesh0.getFaceCells(faces0);
1223  //const CRConnectivity& cellCells0=mesh0.getCellCells();
1224  //const CRConnectivity& cellCells1=mesh1.getCellCells();
1225  const CRPtr cellFaces0Ptr=faceCells0.getTranspose();
1226  const CRConnectivity& cellFaces0=*cellFaces0Ptr;
1227  const CRConnectivity& faceCells1=mesh1.getFaceCells(faces1);
1228  const CRPtr cellFaces1Ptr=faceCells1.getTranspose();
1229  //const CRConnectivity& cellFaces1=*cellFaces1Ptr;
1230  const int faceCount=faces0.getCount();
1231  IntArray& FineToCoarse0=dynamic_cast<IntArray&>(inGeomFields.fineToCoarse[cells0]);
1232  IntArray& FineToCoarse1=dynamic_cast<IntArray&>(inGeomFields.fineToCoarse[cells1]);
1233  const int cCount0=CoarseCounts[Mid0];
1234  //const int cCount1=CoarseCounts[Mid1];
1235 
1236  const CRPtr cellsIntGhost0Ptr=cellFaces0.multiply(faceCells0,true);
1237  const CRConnectivity& cellsIntGhost0=*cellsIntGhost0Ptr;
1238 
1239  Field& FaceAreaField=inGeomFields.area;
1240  const VectorT3Array& FArea0=
1241  dynamic_cast<const VectorT3Array&>(FaceAreaField[allFaces0]); //global ordering
1242 
1243  IntArray* FaceFine2CoarsePtr0=new IntArray(faceCount);
1244  *FaceFine2CoarsePtr0=-1;
1245  IntArray& FaceFine2Coarse0=*FaceFine2CoarsePtr0;
1246  ic.FineToCoarse0=FaceFine2CoarsePtr0;
1247 
1248  IntArray* FaceFine2CoarsePtr1=new IntArray(faceCount);
1249  *FaceFine2CoarsePtr1=-1;
1250  IntArray& FaceFine2Coarse1=*FaceFine2CoarsePtr1;
1251  ic.FineToCoarse1=FaceFine2CoarsePtr1;
1252 
1253  StorageSite preCoarse0(cCount0);
1254 
1255  CRPtr preCoarseToFineCells0=CRPtr(new CRConnectivity(preCoarse0,cells0));
1256 
1257  preCoarseToFineCells0->initCount();
1258 
1259  for(int c=0;c<cells0.getSelfCount();c++)
1260  preCoarseToFineCells0->addCount(FineToCoarse0[c],1);
1261 
1262  preCoarseToFineCells0->finishCount();
1263 
1264  for(int c=0;c<cells0.getSelfCount();c++)
1265  preCoarseToFineCells0->add(FineToCoarse0[c],c);
1266 
1267  preCoarseToFineCells0->finishAdd();
1268 
1269  //initial pairing, no regard to zero summed area
1270  int coarseFace(0);
1271  for(int f=0;f<faceCount;f++)
1272  {
1273 
1274  if(FaceFine2Coarse0[f]==-1)
1275  {
1276  const int c00=faceCells0(f,0); //interior cells
1277  const int f01=common01[f];
1278  const int c01=faceCells1(f01,0);
1279  const int coarseC00=FineToCoarse0[c00]; //coarse indices
1280  const int coarseC01=FineToCoarse1[c01];
1281 
1282  const int cC00fineCnt=preCoarseToFineCells0->getCount(coarseC00);
1283  for(int cC00fine=0;cC00fine<cC00fineCnt;cC00fine++)
1284  {
1285  const int fineCell=(*preCoarseToFineCells0)(coarseC00,cC00fine);
1286  if(fineCell!=c00)
1287  {
1288  const int fineGhostCount=cellsIntGhost0.getCount(fineCell);
1289  for(int fineGhostNum=0;fineGhostNum<fineGhostCount;fineGhostNum++)
1290  {
1291  const int fineGhost=cellsIntGhost0(fineCell,fineGhostNum);
1292  const int f10=cellFaces0(fineGhost,0);
1293  const int f11=common01[f10];
1294  const int c11=faceCells1(f11,0);
1295 
1296  if(FineToCoarse1[c11]==coarseC01)
1297  {
1298  if(FaceFine2Coarse0[f10]==-1 && FaceFine2Coarse0[f]==-1)
1299  {
1300  FaceFine2Coarse0[f10]=coarseFace;
1301  FaceFine2Coarse0[f]=coarseFace;
1302  FaceFine2Coarse1[f11]=coarseFace;
1303  FaceFine2Coarse1[f01]=coarseFace;
1304  coarseFace++;
1305  }
1306  else if(FaceFine2Coarse0[f10]==-1 && FaceFine2Coarse0[f]!=-1)
1307  {
1308  FaceFine2Coarse0[f10]=FaceFine2Coarse0[f];
1309  FaceFine2Coarse1[f11]=FaceFine2Coarse0[f01];
1310  }
1311  else if(FaceFine2Coarse0[f10]!=-1 && FaceFine2Coarse0[f]==-1)
1312  {
1313  FaceFine2Coarse0[f]=FaceFine2Coarse0[f10];
1314  FaceFine2Coarse1[f01]=FaceFine2Coarse1[f11];
1315  }
1316  }
1317 
1318  }
1319  }
1320  }
1321 
1322  if(FaceFine2Coarse0[f]==-1)
1323  {
1324  FaceFine2Coarse0[f]=coarseFace;
1325  FaceFine2Coarse1[f01]=coarseFace;
1326  coarseFace++;
1327  }
1328  }
1329 
1330  //FOR NO AGGLOMERATION OF INTERFACE FACES
1331  //FaceFine2Coarse0[f]=coarseFace;
1332  //FaceFine2Coarse1[f]=coarseFace;
1333  //coarseFace++;
1334 
1335 
1336  }
1337 
1338 
1339 
1340  //must check for zero summed area
1341  VectorT3Array summedArea(coarseFace);
1342  summedArea.zero();
1343  for(int f=0;f<faceCount;f++)
1344  {
1345  const int offset=faces0.getOffset();
1346  summedArea[FaceFine2Coarse0[f]]+=FArea0[f+offset];
1347  }
1348 
1349  for(int f=0;f<faceCount;f++)
1350  {
1351  const int f01=common01[f];
1352  const int offset=faces0.getOffset();
1353  VectorT3& sumVec=summedArea[FaceFine2Coarse0[f]];
1354  const VectorT3& partVec=FArea0[f+offset];
1355  T sumMag=sqrt(sumVec[0]*sumVec[0]+sumVec[1]*sumVec[1]+
1356  sumVec[2]*sumVec[2]);
1357  T partMag=sqrt(partVec[0]*partVec[0]+partVec[1]*partVec[1]+
1358  partVec[2]*partVec[2]);
1359 
1361  if(sumMag/partMag<1.0)
1362  {
1363  sumVec-=partVec;
1364  FaceFine2Coarse0[f]=coarseFace;
1365  FaceFine2Coarse1[f01]=coarseFace;
1366  coarseFace++;
1367  }
1368 
1369  }
1370 
1371  PreFacePairMap[&faces0]=FaceFine2CoarsePtr0;
1372  PreFacePairMap[&faces1]=FaceFine2CoarsePtr1;
1373 
1374  }
1375 
1376  for(int n=0;n<numMeshes;n++)
1377  {
1378  const Mesh& mesh=*_meshes[n];
1379 
1380  if(!_IClist.empty())
1381  {
1382  CoarseCounts[n]=correctSingleNeighbor(n, mesh, inGeomFields,
1383  CoarseCounts[n], PreFacePairMap);
1384  }
1385 
1386  IntArray& FineToCoarse=dynamic_cast<IntArray&>(
1387  inGeomFields.fineToCoarse[mesh.getCells()]);
1388 
1389  CoarseGhost[n]=CoarseCounts[n];
1390  int outGhost(0);
1391 
1392  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
1393  {
1394  const FaceGroup& fg=*fgPtr;
1395  if(fg.id>0)
1396  {
1397  const CRConnectivity& faceCells=mesh.getFaceCells(fg.site);
1398  const int faceCount=fg.site.getCount();
1399 
1400  if(_bcMap[fg.id]->bcType == "Interface")
1401  {
1402  IntArray& FaceFine2Coarse=*PreFacePairMap[&fg.site];
1403 
1404  int coarseFaces(0);
1405  for(int i=0;i<faceCount;i++)
1406  {
1407  const int cghost=faceCells(i,1);
1408  FineToCoarse[cghost]=FaceFine2Coarse[i]+CoarseGhost[n];
1409  if(FaceFine2Coarse[i]>coarseFaces)
1410  coarseFaces=FaceFine2Coarse[i];
1411  }
1412  CoarseGhost[n]+=coarseFaces+1;
1413  outGhost+=coarseFaces+1;
1414  }
1415  else if(_bcMap[fg.id]->bcType == "temperature" ||
1416  _bcMap[fg.id]->bcType == "reflecting" )
1417  {
1418  for(int i=0;i<faceCount;i++)
1419  {
1420  const int cghost=faceCells(i,1);
1421  FineToCoarse[cghost]=CoarseGhost[n];
1422  CoarseGhost[n]++;
1423  outGhost++;
1424  }
1425  }
1426  }
1427  }
1428 
1429  }
1430 
1431  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
int getCount(const int i) const
void setID(const int id)
Definition: Mesh.h:321
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
int getSelfCount() const
Definition: StorageSite.h:40
Definition: Mesh.h:28
void coarsenInterfaceCells(COMETIC< T > &ic, IntArray &coarseCounts, GeomFields &inGeomFields, const MeshList &inMeshes)
Definition: Field.h:14
const FaceGroup & getFaceGroup(const int fgId) const
Definition: Mesh.cpp:1570
Definition: Mesh.h:49
int correctSingleNeighbor(const int m, const Mesh &mesh, GeomFields &inGeomFields, int coarseCount, map< const StorageSite *, IntArray * > PreFacePairMap)
const CommonMap & getCommonMap() const
Definition: StorageSite.h:60
Array< int > * FineToCoarse1
Field fineToCoarse
Definition: GeomFields.h:41
Tangent sqrt(const Tangent &a)
Definition: Tangent.h:317
const int id
Definition: Mesh.h:41
map< const StorageSite *, shared_ptr< Array< int > > > CommonMap
Definition: StorageSite.h:25
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< CRConnectivity > CRPtr
const CRConnectivity & getFaceCells(const StorageSite &site) const
Definition: Mesh.cpp:388
int getOffset() const
Definition: StorageSite.h:87
shared_ptr< CRConnectivity > multiply(const CRConnectivity &b, const bool implicitDiagonal) const
shared_ptr< CRConnectivity > getTranspose() const
int getCount() const
Definition: StorageSite.h:39
Array< int > * FineToCoarse0
Array< int > IntArray
Field area
Definition: GeomFields.h:23
int coarsenInterior(const int m, const Mesh &mesh, GeomFields &inGeomFields, int &coarseCount)
int getDimension() const
Definition: Mesh.h:105
StorageSite site
Definition: Mesh.h:40
template<class T >
void COMETModel< T >::MakeNewKspaces ( TkspList inList,
TkspList outList 
)
inline

Definition at line 1160 of file phononbase/COMETModel.h.

References Kspace< T >::CopyKspace().

Referenced by COMETModel< T >::MakeCoarseModel().

1161  {
1162  const int len=inList.size();
1163  for(int i=0;i<len;i++)
1164  {
1165  TkspPtr newKspacePtr=TkspPtr(new Tkspace());
1166  newKspacePtr->CopyKspace(*inList[i]);
1167  inList[i]->setCoarseKspace(newKspacePtr);
1168  outList.push_back(newKspacePtr);
1169  }
1170 
1171  for(int i=0;i<len;i++)
1172  inList[i]->giveTransmissions();
1173 
1174  }
Kspace< T > Tkspace
template<class T >
void COMETModel< T >::makeNonEqTemp ( )
inline

Definition at line 4218 of file phononbase/COMETModel.h.

References COMETModel< T >::_kspaces, COMETModel< T >::_macro, Model::_meshes, COMETModel< T >::_MeshKspaceMap, Kspace< T >::calcLatTemp(), Mesh::getCells(), StorageSite::getSelfCount(), and PhononMacro::temperature.

4219  {
4220  const int numMeshes = _meshes.size();
4221  for (int n=0; n<numMeshes; n++)
4222  {
4223  const Mesh& mesh=*_meshes[n];
4224  const StorageSite& cells=mesh.getCells();
4225  const int numcells=cells.getSelfCount();
4226  TArray& Tl=dynamic_cast<TArray&>(_macro.temperature[cells]);
4227  Tkspace& kspace=*_kspaces[_MeshKspaceMap[n]];
4228  //const TArray& e=kspace.geteArray();
4229 
4230  //const int len=kspace.getlength();
4231 
4232  for(int c=0;c<numcells;c++)
4233  Tl[c]=kspace.calcLatTemp(c);
4234 
4235  }
4236  }
int getSelfCount() const
Definition: StorageSite.h:40
Array< T > TArray
Field temperature
Definition: PhononMacro.h:21
Definition: Mesh.h:49
PhononMacro & _macro
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
MeshKspaceMap _MeshKspaceMap
Kspace< T > Tkspace
template<class T >
void COMETModel< T >::MakeParallel ( )
inline

Definition at line 1009 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfPtr, COMETModel< T >::_quadrature, Field::syncLocal(), and Field::syncLocalVectorFields().

Referenced by COMETModel< T >::cycle(), COMETModel< T >::MakeCoarseIndex(), COMETModel< T >::smooth(), and COMETModel< T >::updateResid().

1010  {
1012 #if 0
1013  for(int dir=0;dir<_quadrature.getDirCount();dir++)
1014  {
1015  Field& fnd = *_dsfPtr.dsf[dir];
1016  fnd.syncLocal();
1017  }
1018 #endif
1019  }
Quadrature< T > & _quadrature
Definition: Field.h:14
static void syncLocalVectorFields(std::vector< Field * > &dsf)
Definition: Field.cpp:702
DistFunctFields< T > _dsfPtr
void syncLocal()
Definition: Field.cpp:334
template<class T >
void COMETModel< T >::makePlotColors ( const int  level)
inline

Definition at line 4074 of file phononbase/COMETModel.h.

References COMETModel< T >::_macro, Model::_meshes, COMETModel< T >::_options, Field::addArray(), Mesh::getCells(), PhononMacro::getColorField(), Mesh::getConnectivity(), StorageSite::getCount(), COMETModel< T >::getMeshList(), COMETModel< T >::getModelPointer(), StorageSite::getSelfCount(), COMETModel< T >::makeFinestToCoarseConn(), and PhononMacro::plottingCellColors.

4075  {
4076 
4077  if(level==0)
4078  {
4079  if(_options.maxLevels>1)
4081  shared_ptr<Field> field0ptr(new Field("plotColor"));
4082  _macro.plottingCellColors.push_back(field0ptr);
4083  Field& field0=*field0ptr;
4084  Field& colorField=_macro.getColorField(0);
4085 
4086  const int numMeshes = _meshes.size();
4087  for (int n=0; n<numMeshes; n++)
4088  {
4089  const Mesh& mesh=*_meshes[n];
4090  const StorageSite& cells=mesh.getCells();
4091  //const int cellCount=cells.getSelfCount();
4092  const int cellTotCount=cells.getCount();
4093  //const CRConnectivity& cellCells=mesh.getCellCells();
4094  TArray& colorArray=dynamic_cast<TArray&>(colorField[cells]);
4095 
4096  TArrptr colorPtr(new TArray(cellTotCount));
4097  (*colorPtr)=colorArray;
4098  field0.addArray(cells, colorPtr);
4099  }
4100  //if(_coarserLevel!=NULL)
4101  // _coarserLevel->makePlotColors();
4102  }
4103  else
4104  {
4105  shared_ptr<Field> fieldptr(new Field("plotColor"));
4106  _macro.plottingCellColors.push_back(fieldptr);
4107  Field& field=*fieldptr;
4108 
4109  Field& colorField=_macro.getColorField(level);
4110 
4111  TCOMET* coarseModel=getModelPointer(level);
4112  const MeshList& coarseMeshes=coarseModel->getMeshList();
4113  const int numMeshes = _meshes.size();
4114  for(int n=0;n<numMeshes;n++)
4115  {
4116  const Mesh& finestMesh=*_meshes[n];
4117  const Mesh& coarseMesh=*coarseMeshes[n];
4118  const StorageSite& coarseCells=coarseMesh.getCells();
4119  const StorageSite& finestCells=finestMesh.getCells();
4120  const int finestCellTotCount=finestCells.getCount();
4121  const int finestCellCount=finestCells.getSelfCount();
4122  const CRConnectivity& finestToCoarse=finestMesh.getConnectivity(finestCells,coarseCells);
4123 
4124  TArrptr plotColorPtr(new TArray(finestCellTotCount));
4125  TArray& plotColorArray=*plotColorPtr;
4126  field.addArray(finestCells, plotColorPtr);
4127 
4128  TArray& colorArray=dynamic_cast<TArray&>(colorField[coarseCells]);
4129 
4130  for(int c=0;c<finestCellCount;c++)
4131  plotColorArray[c]=colorArray[finestToCoarse(c,0)];
4132  }
4133 
4134  //if(_coarserLevel!=NULL)
4135  // _coarserLevel->makePlotColors();
4136  }
4137  }
int getSelfCount() const
Definition: StorageSite.h:40
const CRConnectivity & getConnectivity(const StorageSite &from, const StorageSite &to) const
Definition: Mesh.cpp:416
shared_ptr< TArray > TArrptr
Array< T > TArray
Definition: Field.h:14
Definition: Mesh.h:49
COMETModelOptions< T > _options
TCOMET * getModelPointer(const int level)
COMETModel< T > TCOMET
PhononMacro & _macro
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
FieldVector plottingCellColors
Definition: PhononMacro.h:35
int getCount() const
Definition: StorageSite.h:39
Field & getColorField(int level)
vector< Mesh * > MeshList
Definition: Mesh.h:439
template<class T >
ArrayBase* COMETModel< T >::modewiseHeatFluxIntegral ( const Mesh mesh,
const int  faceGroupId 
)
inline

Definition at line 3460 of file phononbase/COMETModel.h.

References COMETModel< T >::_geomFields, COMETModel< T >::_kspaces, COMETModel< T >::_MeshKspaceMap, GeomFields::area, Mesh::getBoundaryFaceGroups(), StorageSite::getCount(), kvol< T >::getdk3(), Kspace< T >::geteArray(), Mesh::getFaceCells(), Kspace< T >::getGlobalIndex(), Mesh::getID(), pmode< T >::getIndex(), Kspace< T >::getkvol(), Kspace< T >::getlength(), kvol< T >::getmode(), kvol< T >::getmodenum(), Kspace< T >::gettotmodes(), pmode< T >::getv(), FaceGroup::id, FaceGroup::site, and Array< T >::zero().

3461  {
3462  //bool found = false;
3463  const int n=mesh.getID();
3464  Tkspace& kspace=*_kspaces[_MeshKspaceMap[n]];
3465  TArray& eArray=kspace.geteArray();
3466  //const T DK3=kspace.getDK3();
3467  TArray* qptr(new TArray(kspace.gettotmodes()));
3468  TArray& q(*qptr);
3469  q.zero();
3470 
3471  const T hbar=6.582119e-16; // (eV s)
3472 
3473  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
3474  {
3475  const FaceGroup& fg = *fgPtr;
3476  if (fg.id == faceGroupId)
3477  {
3478  const StorageSite& faces = fg.site;
3479  const int nFaces = faces.getCount();
3480  //const StorageSite& cells = mesh.getCells();
3481  const CRConnectivity& faceCells=mesh.getFaceCells(faces);
3482  const Field& areaField=_geomFields.area;
3483  const VectorT3Array& faceArea=dynamic_cast<const VectorT3Array&>(areaField[faces]);
3484 
3485  for(int f=0; f<nFaces; f++)
3486  {
3487  const VectorT3 An=faceArea[f];
3488  const int c1=faceCells(f,1);
3489  int cellIndex=kspace.getGlobalIndex(c1,0);
3490  for(int k=0;k<kspace.getlength();k++)
3491  {
3492  Tkvol& kv=kspace.getkvol(k);
3493  int modenum=kv.getmodenum();
3494  for(int m=0;m<modenum;m++)
3495  {
3496  VectorT3 vg=kv.getmode(m).getv();
3497  const int index=kv.getmode(m).getIndex()-1;
3498  T dk3=kv.getdk3();
3499  //T energy=hbar*kv.getmode(m).getomega();
3500  const T vgdotAn=An[0]*vg[0]+An[1]*vg[1]+An[2]*vg[2];
3501  q[index]+= eArray[cellIndex]*vgdotAn*dk3;//*energy;
3502  cellIndex++;
3503  }
3504  }
3505  }
3506 
3507  }
3508  }
3509 
3510  return qptr;
3511  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
GeomFields & _geomFields
Definition: Mesh.h:28
Array< T > TArray
Definition: Field.h:14
const int id
Definition: Mesh.h:41
MeshKspaceMap _MeshKspaceMap
const CRConnectivity & getFaceCells(const StorageSite &site) const
Definition: Mesh.cpp:388
int getCount() const
Definition: StorageSite.h:39
Field area
Definition: GeomFields.h:23
Kspace< T > Tkspace
int getID() const
Definition: Mesh.h:106
StorageSite site
Definition: Mesh.h:40
template<class T >
void COMETModel< T >::MomentHierarchy ( )
inline

Definition at line 1525 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfPtr, COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_options, COMETModel< T >::_quadrature, Mesh::getCells(), StorageSite::getCount(), MacroFields::Knq, and MacroFields::velocity.

1525  {
1526  const int numMeshes = _meshes.size();
1527  for (int n=0; n<numMeshes; n++)
1528  {
1529  const int Knq_dir=_options.Knq_direction;
1530  const Mesh& mesh = *_meshes[n];
1531  const StorageSite& cells = mesh.getCells();
1532  const int nCells = cells.getCount();
1533  const TArray& cx = dynamic_cast<const TArray&>(*_quadrature.cxPtr);
1534  const TArray& cy = dynamic_cast<const TArray&>(*_quadrature.cyPtr);
1535  const TArray& cz = dynamic_cast<const TArray&>(*_quadrature.czPtr);
1536  const TArray& wts= dynamic_cast<const TArray&>(*_quadrature.dcxyzPtr);
1537  VectorT3Array& v = dynamic_cast<VectorT3Array&>(_macroFields.velocity[cells]);
1538  TArray& Knq = dynamic_cast<TArray&>(_macroFields.Knq[cells]);
1539  const int num_directions = _quadrature.getDirCount();
1540  if (Knq_dir ==0){
1541  for(int j=0;j<num_directions;j++){
1542  Field& fnd = *_dsfPtr.dsf[j];
1543  const TArray& f = dynamic_cast<const TArray&>(fnd[cells]);
1544  for(int c=0; c<nCells;c++){
1545  Knq[c]=Knq[c]+0.5*f[c]*wts[j]*(pow(cx[j]-v[c][0],3.0)+(cx[j]-v[c][0])*pow(cy[j]-v[c][1],2.0)+(cx[j]-v[c][0])*pow(cz[j]-v[c][2],2.0));
1546  }
1547  }}
1548  else if(Knq_dir ==1){
1549  for(int j=0;j<num_directions;j++){
1550  Field& fnd = *_dsfPtr.dsf[j];
1551  const TArray& f = dynamic_cast<const TArray&>(fnd[cells]);
1552  for(int c=0; c<nCells;c++){
1553  Knq[c]=Knq[c]+0.5*f[c]*wts[j]*(pow(cy[j]-v[c][1],3.0)+(cy[j]-v[c][1])*pow(cx[j]-v[c][0],2.0)+(cy[j]-v[c][1])*pow(cz[j]-v[c][2],2.0));
1554  }
1555  }}
1556 
1557  else if(Knq_dir ==2){
1558  for(int j=0;j<num_directions;j++){
1559  Field& fnd = *_dsfPtr.dsf[j];
1560  const TArray& f = dynamic_cast<const TArray&>(fnd[cells]);
1561  for(int c=0; c<nCells;c++){
1562  Knq[c]=Knq[c]+0.5*f[c]*wts[j]*(pow(cz[j]-v[c][2],3.0)+(cz[j]-v[c][2])*pow(cx[j]-v[c][0],2.0)+(cz[j]-v[c][2])*pow(cy[j]-v[c][1],2.0));
1563  }
1564  }}
1565  }
1566  }
Quadrature< T > & _quadrature
Array< T > TArray
Definition: Field.h:14
Definition: Mesh.h:49
COMETModelOptions< T > _options
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
Field velocity
Definition: MacroFields.h:15
DistFunctFields< T > _dsfPtr
int getCount() const
Definition: StorageSite.h:39
template<class T >
void COMETModel< T >::NewtonsMethodBGK ( const int  ktrial)
inline

Definition at line 1670 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_options, MacroFields::coeff, MacroFields::density, fabs(), Mesh::getCells(), StorageSite::getCount(), inverseGauss(), COMETModel< T >::setJacobianBGK(), MacroFields::temperature, and MacroFields::velocity.

Referenced by COMETModel< T >::EquilibriumDistributionBGK().

1671  {
1672  const int numMeshes = _meshes.size();
1673  for (int n=0; n<numMeshes; n++)
1674  {
1675  //cout << " NewtonsMethod" <<endl;
1676  const T tolx=_options["ToleranceX"];
1677  const T tolf=_options["ToleranceF"];
1678  const int sizeC=5;
1679  const Mesh& mesh = *_meshes[n];
1680  const StorageSite& cells = mesh.getCells();
1681  const int nCells = cells.getCount();
1682 
1683  const TArray& density = dynamic_cast<const TArray&>(_macroFields.density[cells]);
1684  const TArray& temperature = dynamic_cast<const TArray&>(_macroFields.temperature[cells]);
1685  const VectorT3Array& v = dynamic_cast<const VectorT3Array&>(_macroFields.velocity[cells]);
1686 
1687  VectorT5Array& coeff = dynamic_cast<VectorT5Array&>(_macroFields.coeff[cells]);
1688 
1689  for(int c=0; c<nCells;c++){
1690 
1691  for (int trial=0;trial<ktrial;trial ++){
1692  SquareMatrix<T,sizeC> fjac(0);
1693  SquareMatrix<T,sizeC> fjacinv(0);
1694  VectorT5 fvec;
1695 
1696 
1697  fvec[0]=density[c];
1698  fvec[1]=density[c]*v[c][0];
1699  fvec[2]=density[c]*v[c][1];
1700  fvec[3]=density[c]*v[c][2];
1701  fvec[4]=1.5*density[c]*temperature[c]+density[c]*(pow(v[c][0],2)+pow(v[c][1],2)+pow(v[c][2],2.0));
1702 
1703 
1704  setJacobianBGK(fjac,fvec,coeff[c],v[c],c);
1705 
1706  //solve using GE or inverse
1707  T errf=0.;
1708  for (int row=0;row<sizeC;row++){errf+=fabs(fvec[row]);}
1709 
1710  if(errf <= tolf)
1711  break;
1712  VectorT5 pvec;
1713  for (int row=0;row<sizeC;row++){pvec[row]=-fvec[row];}//rhs
1714 
1715 
1716  //solve Ax=b for x
1717  //p=GE_elim(fjac,p,3);
1718  VectorT5 xvec;
1719  fjacinv=inverseGauss(fjac,sizeC);
1720 
1721 
1722 
1723  for (int row=0;row<sizeC;row++){
1724  xvec[row]=0.0;
1725  for (int col=0;col<sizeC;col++){
1726  xvec[row]+=fjacinv(row,col)*pvec[col];}
1727  }
1728  //check for convergence, update
1729 
1730  T errx=0.;
1731  for (int row=0;row<sizeC;row++){
1732  errx +=fabs(xvec[row]);
1733  coeff[c][row]+= xvec[row];
1734  }
1735 
1736 
1737  if(errx <= tolx)
1738  break;
1739 
1740  }
1741 
1742 
1743  }
1744  }
1745 
1746  }
void setJacobianBGK(SquareMatrix< T, 5 > &fjac, VectorT5 &fvec, const VectorT5 &xn, const VectorT3 &v, const int c)
Array< T > TArray
Definition: Mesh.h:49
COMETModelOptions< T > _options
Field temperature
Definition: MacroFields.h:22
SquareMatrix< T, N > inverseGauss(SquareMatrix< T, N > &a, int size)
Field coeff
Definition: MacroFields.h:31
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
Vector< T, 5 > VectorT5
Tangent fabs(const Tangent &a)
Definition: Tangent.h:312
Field velocity
Definition: MacroFields.h:15
int getCount() const
Definition: StorageSite.h:39
Field density
Definition: MacroFields.h:21
Array< VectorT5 > VectorT5Array
template<class T >
void COMETModel< T >::NewtonsMethodESBGK ( const int  ktrial)
inline

Definition at line 1840 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_options, MacroFields::coeffg, MacroFields::density, fabs(), Mesh::getCells(), StorageSite::getCount(), inverseGauss(), COMETModel< T >::setJacobianESBGK(), MacroFields::Txx, MacroFields::Txy, MacroFields::Tyy, MacroFields::Tyz, MacroFields::Tzx, MacroFields::Tzz, and MacroFields::velocity.

Referenced by COMETModel< T >::EquilibriumDistributionESBGK().

1841  {
1842  // cout<< "Inside Newtons Method" <<endl;
1843  const int numMeshes = _meshes.size();
1844  for (int n=0; n<numMeshes; n++)
1845  {
1846  const T tolx=_options["ToleranceX"];
1847  const T tolf=_options["ToleranceF"];
1848  const int sizeC=10;
1849  const Mesh& mesh = *_meshes[n];
1850  const StorageSite& cells = mesh.getCells();
1851  const int nCells = cells.getCount();
1852 
1853  const TArray& density = dynamic_cast<const TArray&>(_macroFields.density[cells]);
1854 
1855  const TArray& Txx = dynamic_cast<const TArray&>(_macroFields.Txx[cells]);
1856  const TArray& Tyy = dynamic_cast<const TArray&>(_macroFields.Tyy[cells]);
1857  const TArray& Tzz = dynamic_cast<const TArray&>(_macroFields.Tzz[cells]);
1858  const TArray& Txy = dynamic_cast<const TArray&>(_macroFields.Txy[cells]);
1859  const TArray& Tyz = dynamic_cast<const TArray&>(_macroFields.Tyz[cells]);
1860  const TArray& Tzx = dynamic_cast<const TArray&>(_macroFields.Tzx[cells]);
1861 
1862  const VectorT3Array& v = dynamic_cast<const VectorT3Array&>(_macroFields.velocity[cells]);
1863 
1864  VectorT10Array& coeffg = dynamic_cast<VectorT10Array&>(_macroFields.coeffg[cells]);
1865 
1866  for(int c=0; c<nCells;c++){
1867  // {cout <<"NM:ES" <<c <<endl;}
1868  for (int trial=0;trial<ktrial;trial ++){
1869  SquareMatrix<T,sizeC> fjac(0);
1870  SquareMatrix<T,sizeC> fjacinv(0);
1871  Vector<T,sizeC> fvec;
1872  // if (c==_options.printCellNumber){cout <<"trial" <<trial <<endl;}
1873 
1874  fvec[0]=density[c];
1875  fvec[1]=density[c]*v[c][0];
1876  fvec[2]=density[c]*v[c][1];
1877  fvec[3]=density[c]*v[c][2];
1878  fvec[4]=density[c]*(pow(v[c][0],2)+Txx[c]);
1879  fvec[5]=density[c]*(pow(v[c][1],2)+Tyy[c]);
1880  fvec[6]=density[c]*(pow(v[c][2],2)+Tzz[c]);
1881  fvec[7]=density[c]*(v[c][0]*v[c][1]+Txy[c]);
1882  fvec[8]=density[c]*(v[c][1]*v[c][2]+Tyz[c]);
1883  fvec[9]=density[c]*(v[c][2]*v[c][0]+Tzx[c]);
1884 
1885  //calculate Jacobian
1886  setJacobianESBGK(fjac,fvec,coeffg[c],v[c],c);
1887 
1888 
1889  //solve using GaussElimination
1890  T errf=0.; //and Jacobian matrix in fjac.
1891  for (int row=0;row<sizeC;row++){errf+=fabs(fvec[row]);}
1892  if(errf <= tolf)
1893  break;
1894  Vector<T,sizeC> pvec;
1895  for (int row=0;row<sizeC;row++){pvec[row]=-fvec[row];}
1896 
1897 
1898  //solve Ax=b for x
1899  //p=GE_elim(fjac,p,3);
1900  Vector<T,sizeC> xvec;
1901  fjacinv=inverseGauss(fjac,sizeC);
1902  for (int row=0;row<sizeC;row++){
1903  xvec[row]=0.0;
1904  for (int col=0;col<sizeC;col++){
1905  xvec[row]+=fjacinv(row,col)*pvec[col];
1906 
1907  }
1908  }
1909  /*
1910  if (c==_options.printCellNumber){
1911  cout << " cg0 "<<coeffg[c][0]<<" cg1 "<<coeffg[c][1]<<" cg2 "<<coeffg[c][2] << endl;
1912  cout <<" cg3 " <<coeffg[c][3]<< " cg4 "<<coeffg[c][4]<<" cg5 "<<coeffg[c][5]<<" cg6 "<<coeffg[c][6] << endl;
1913  cout <<" cg7 " <<coeffg[c][7]<< " cg8 "<<coeffg[c][8]<<" cg9 "<<coeffg[c][9]<<endl;
1914 
1915 
1916  //cout << " fvec-ESBGK " << fvec[4] <<fvec[5]<<fvec[6]<<fvec[7]<<fvec[8]<<fvec[9] <<endl;
1917  FILE * pFile;
1918  pFile = fopen("fvecfjac.dat","wa");
1919  //fprintf(pFile,"%s %d \n","trial",trial);
1920  for (int mat_col=0;mat_col<sizeC;mat_col++){fprintf(pFile,"%12.4E",fvec[mat_col]);}
1921  fprintf(pFile,"\n");
1922  for (int mat_row=0;mat_row<sizeC;mat_row++){
1923  for (int mat_col=0;mat_col<sizeC;mat_col++){
1924  fprintf(pFile,"%12.4E",fjac(mat_row,mat_col));}
1925  fprintf(pFile,"\n");}
1926  // fprintf(pFile,"done \n");
1927  //inverse
1928  for (int mat_row=0;mat_row<sizeC;mat_row++){
1929  for (int mat_col=0;mat_col<sizeC;mat_col++){
1930  fprintf(pFile,"%12.4E",fjacinv(mat_row,mat_col));}
1931  fprintf(pFile,"\n");}
1932  //solution
1933  for (int mat_col=0;mat_col<sizeC;mat_col++){
1934  fprintf(pFile,"%12.4E",pvec[mat_col]);}
1935  }
1936  */
1937 
1938  //check for convergence, update
1939  T errx=0.;//%Check root convergence.
1940  for (int row=0;row<sizeC;row++){
1941  errx +=fabs(xvec[row]);
1942  coeffg[c][row]+= xvec[row];
1943  }
1944  //if (c==_options.printCellNumber){cout <<"errx "<<errx<<endl;}
1945  if(errx <= tolx)
1946  break;
1947 
1948  }
1949 
1950  }
1951  }
1952  }
Field coeffg
Definition: MacroFields.h:32
void setJacobianESBGK(SquareMatrix< T, 10 > &fjac, VectorT10 &fvec, const VectorT10 &xn, const VectorT3 &v, const int c)
Array< T > TArray
Definition: Vector.h:19
Definition: Mesh.h:49
COMETModelOptions< T > _options
SquareMatrix< T, N > inverseGauss(SquareMatrix< T, N > &a, int size)
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
Array< VectorT10 > VectorT10Array
Tangent fabs(const Tangent &a)
Definition: Tangent.h:312
Field velocity
Definition: MacroFields.h:15
int getCount() const
Definition: StorageSite.h:39
Field density
Definition: MacroFields.h:21
template<class T >
void COMETModel< T >::OutputDsfBLOCK ( const char *  filename)
inline

Definition at line 2493 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfEqPtr, COMETModel< T >::_dsfEqPtrES, COMETModel< T >::_dsfPtr, Model::_meshes, COMETModel< T >::_options, COMETModel< T >::_quadrature, and Mesh::getCells().

2494  {
2495  FILE * pFile;
2496  pFile = fopen(filename,"w");
2497  int N1=_quadrature.getNVCount();
2498  int N2=_quadrature.getNthetaCount();
2499  int N3=_quadrature.getNphiCount();
2500  fprintf(pFile,"%s \n", "VARIABLES= cx, cy, cz, f,fEq,fES");
2501  fprintf(pFile, "%s %i %s %i %s %i \n","ZONE I=", N3,",J=",N2,",K=",N1);
2502  fprintf(pFile, "%s \n","F=BLOCK, VARLOCATION=(NODAL,NODAL,NODAL,NODAL,NODAL,NODAL)");
2503  const int numMeshes = _meshes.size();
2504  const int cellno=_options.printCellNumber;
2505  for (int n=0; n<numMeshes; n++){
2506  const TArray& cx = dynamic_cast<const TArray&>(*_quadrature.cxPtr);
2507  const TArray& cy = dynamic_cast<const TArray&>(*_quadrature.cyPtr);
2508  const TArray& cz = dynamic_cast<const TArray&>(*_quadrature.czPtr);
2509  const int numFields= _quadrature.getDirCount();
2510  for(int j=0;j< numFields;j++){fprintf(pFile,"%E \n",cx[j]);}
2511  for(int j=0;j< numFields;j++){fprintf(pFile,"%E \n",cy[j]);}
2512  for(int j=0;j< numFields;j++){fprintf(pFile,"%E \n",cz[j]);}
2513 
2514  const Mesh& mesh = *_meshes[n];
2515  const StorageSite& cells = mesh.getCells();
2516  for(int j=0;j< numFields;j++){
2517  Field& fnd = *_dsfPtr.dsf[j];
2518  TArray& f = dynamic_cast< TArray&>(fnd[cells]);
2519  fprintf(pFile,"%E\n",f[cellno]);
2520  }
2521  for(int j=0;j< numFields;j++){
2522  Field& fEqnd = *_dsfEqPtr.dsf[j];
2523  TArray& fEq = dynamic_cast< TArray&>(fEqnd[cells]);
2524  fprintf(pFile,"%E\n",fEq[cellno]);
2525  }
2526  if(_options.fgamma==2){
2527  for(int j=0;j< numFields;j++){
2528 
2529  Field& fndEqES = *_dsfEqPtrES.dsf[j];
2530  TArray& fEqES = dynamic_cast< TArray&>(fndEqES[cells]);
2531  fprintf(pFile,"%E\n",fEqES[cellno]);
2532  }}
2533  else{
2534  for(int j=0;j< numFields;j++){
2535 
2536  Field& fndEq = *_dsfEqPtr.dsf[j];
2537  TArray& fEq = dynamic_cast< TArray&>(fndEq[cells]);
2538  fprintf(pFile,"%E\n",fEq[cellno]);
2539  }}
2540 
2541  }
2542  fclose(pFile);
2543  }
Quadrature< T > & _quadrature
Array< T > TArray
Definition: Field.h:14
Definition: Mesh.h:49
COMETModelOptions< T > _options
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
DistFunctFields< T > _dsfEqPtrES
DistFunctFields< T > _dsfPtr
DistFunctFields< T > _dsfEqPtr
template<class T >
void COMETModel< T >::OutputDsfPOINT ( )
inline

Definition at line 5595 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfEqPtr, COMETModel< T >::_dsfPtr, Model::_meshes, COMETModel< T >::_options, COMETModel< T >::_quadrature, and Mesh::getCells().

5596  {
5597  FILE * pFile;
5598  pFile = fopen("cxyz0.plt","w");
5599  int N1=_quadrature.getNVCount();
5600  int N2=_quadrature.getNthetaCount();
5601  int N3=_quadrature.getNphiCount();
5602  fprintf(pFile,"%s \n", "VARIABLES= cx, cy, cz, f,");
5603  fprintf(pFile, "%s %i %s %i %s %i \n","ZONE I=", N3,",J=",N2,"K=",N1);
5604  fprintf(pFile,"%s\n","F=POINT");
5605  const int numMeshes = _meshes.size();
5606  const int cellno=_options.printCellNumber;
5607  for (int n=0; n<numMeshes; n++)
5608  {
5609  const TArray& cx = dynamic_cast<const TArray&>(*_quadrature.cxPtr);
5610  const TArray& cy = dynamic_cast<const TArray&>(*_quadrature.cyPtr);
5611  const TArray& cz = dynamic_cast<const TArray&>(*_quadrature.czPtr);
5612  const int numFields= _quadrature.getDirCount();
5613 
5614  const Mesh& mesh = *_meshes[n];
5615  const StorageSite& cells = mesh.getCells();
5616  for(int j=0;j< numFields;j++)
5617  {
5618  Field& fnd = *_dsfPtr.dsf[j];
5619  TArray& f = dynamic_cast< TArray&>(fnd[cells]);
5620  Field& fEqnd = *_dsfEqPtr.dsf[j];
5621  TArray& fEq = dynamic_cast< TArray&>(fEqnd[cells]);
5622  fprintf(pFile,"%E %E %E %E %E\n",cx[j],cy[j],cz[j],f[cellno],fEq[cellno]);
5623  }
5624  }
5625  }
Quadrature< T > & _quadrature
Array< T > TArray
Definition: Field.h:14
Definition: Mesh.h:49
COMETModelOptions< T > _options
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
DistFunctFields< T > _dsfPtr
DistFunctFields< T > _dsfEqPtr
template<class T >
void COMETModel< T >::restart ( )
inlinevirtual

Reimplemented from Model.

Definition at line 2293 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfPtr, COMETModel< T >::_initialKmodelNorm, COMETModel< T >::_niters, and COMETModel< T >::_persistenceData.

2294  {
2295  if (_persistenceData.find("niters") != _persistenceData.end())
2296  {
2297  shared_ptr<ArrayBase> rp = _persistenceData["niters"];
2298  ArrayBase& r = *rp;
2299  Array<int>& niterArray = dynamic_cast<Array<int>& >(r);
2300  _niters = niterArray[0];
2301  }
2302 
2303  if (_persistenceData.find("initialKmodelNorm") != _persistenceData.end())
2304  {
2305  shared_ptr<ArrayBase> r = _persistenceData["initialKmodelNorm"];
2307  Field& dsfField = *_dsfPtr.dsf[0];
2308  _initialKmodelNorm->addArray(dsfField,r);
2309  //_initialKmodelNorm->addArray(_dsfPtr,r);
2310  }
2311  }
Definition: Field.h:14
map< string, shared_ptr< ArrayBase > > _persistenceData
DistFunctFields< T > _dsfPtr
shared_ptr< MultiFieldReduction > MFRPtr
template<class T >
bool COMETModel< T >::sameFaceGroup ( const Mesh mesh,
const int  f0,
const int  f1 
)
inline

Definition at line 4181 of file phononbase/COMETModel.h.

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

4182  {
4183  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
4184  {
4185  const FaceGroup& fg=*fgPtr;
4186  const int off=fg.site.getOffset();
4187  const int cnt=fg.site.getCount();
4188  const int fin=off+cnt;
4189 
4190  if(f0<fin && f0>=off)
4191  if(f1<fin && f1>=off)
4192  return true;
4193  }
4194  return false;
4195  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
Definition: Mesh.h:28
int getOffset() const
Definition: StorageSite.h:87
int getCount() const
Definition: StorageSite.h:39
StorageSite site
Definition: Mesh.h:40
template<class T >
void COMETModel< T >::setBCMap ( COMETBCMap bcMap)
inline

Definition at line 4238 of file phononbase/COMETModel.h.

References COMETModel< T >::_bcMap.

4238 {_bcMap=*bcMap;}
template<class T >
void COMETModel< T >::setBCMap ( COMETBCMap bcMap)
inline

Definition at line 5636 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_bcMap.

5636 {_bcMap=*bcMap;}
template<class T >
void COMETModel< T >::SetBoundaryConditions ( )
inline

Definition at line 2313 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_bcMap, Model::_meshes, COMETModel< T >::_vcMap, COMETBC< T >::bcType, Mesh::getBoundaryFaceGroups(), Mesh::getID(), FaceGroup::groupType, FaceGroup::id, and COMETVC< T >::vcType.

Referenced by COMETModel< T >::COMETModel().

2314  {
2315  const int numMeshes = _meshes.size();
2316  for (int n=0; n<numMeshes; n++)
2317  {
2318  const Mesh& mesh = *_meshes[n];
2319 
2320  COMETVC<T> *vc(new COMETVC<T>());
2321  vc->vcType = "flow";
2322  _vcMap[mesh.getID()] = vc;
2323  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
2324  {
2325  const FaceGroup& fg = *fgPtr;
2326  if (_bcMap.find(fg.id) == _bcMap.end())
2327  {
2328  COMETBC<T> *bc(new COMETBC<T>());
2329 
2330  _bcMap[fg.id] = bc;
2331  if((fg.groupType == "wall"))
2332  {
2333  bc->bcType = "WallBC";
2334  }
2335  else if((fg.groupType == "realwall"))
2336  {
2337  bc->bcType = "RealWallBC";
2338  }
2339  else if (fg.groupType == "velocity-inlet")
2340  {
2341  bc->bcType = "VelocityInletBC";
2342  }
2343  else if (fg.groupType == "pressure-inlet")
2344  {
2345  bc->bcType = "PressureInletBC";
2346  }
2347  else if (fg.groupType == "pressure-outlet")
2348  {
2349  bc->bcType = "PressureOutletBC";
2350  }
2351  else if ((fg.groupType == "symmetry"))
2352  {
2353  bc->bcType = "SymmetryBC";
2354  }
2355 
2356  else if((fg.groupType =="zero-gradient "))
2357  {
2358  bc->bcType = "ZeroGradBC";
2359  }
2360  else
2361  throw CException("COMETModel: unknown face group type "
2362  + fg.groupType);
2363  }
2364  }
2365  /*
2366  foreach(const FaceGroupPtr fgPtr, mesh.getInterfaceGroups())
2367  {
2368  const FaceGroup& fg = *fgPtr;
2369  if (_bcMap.find(fg.id) == _bcMap.end())
2370  { COMETBC<T> *bc(new COMETBC<T>());
2371 
2372  _bcMap[fg.id] = bc;
2373 
2374  if ((fg.groupType == "NSinterface"))
2375  {
2376  bc->bcType = "NSInterfaceBC";
2377  }
2378  }
2379  }
2380  */
2381  }
2382  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
Definition: Mesh.h:28
Definition: Mesh.h:49
string groupType
Definition: Mesh.h:42
const int id
Definition: Mesh.h:41
const MeshList _meshes
Definition: Model.h:29
int getID() const
Definition: Mesh.h:106
template<class T >
void COMETModel< T >::setCoarserLevel ( TCOMET cl)
inline

Definition at line 4239 of file phononbase/COMETModel.h.

References COMETModel< T >::_coarserLevel.

4239 {_coarserLevel=cl;}
template<class T >
void COMETModel< T >::setCoarserLevel ( TCOMET cl)
inline
template<class T >
void COMETModel< T >::sete0 ( )
inline

Definition at line 3125 of file phononbase/COMETModel.h.

References COMETModel< T >::_kspaces, COMETModel< T >::_macro, Model::_meshes, COMETModel< T >::_MeshKspaceMap, pmode< T >::calce0(), Mesh::getCells(), Kspace< T >::gete0Array(), Kspace< T >::getGlobalIndex(), Kspace< T >::getkvol(), Kspace< T >::getlength(), kvol< T >::getmode(), kvol< T >::getmodenum(), StorageSite::getSelfCount(), PhononMacro::temperature, and Kspace< T >::updateTau().

Referenced by COMETModel< T >::cycle().

3126  {
3127  const int numMeshes = _meshes.size();
3128  for (int n=0; n<numMeshes; n++)
3129  {
3130  const Mesh& mesh=*_meshes[n];
3131  Tkspace& kspace=*_kspaces[_MeshKspaceMap[n]];
3132  const StorageSite& cells=mesh.getCells();
3133  const int cellCount=cells.getSelfCount();
3134  TArray& Tl=dynamic_cast<TArray&>(_macro.temperature[cells]);
3135  TArray& e0Array=kspace.gete0Array();
3136  const int klen=kspace.getlength();
3137 
3138  for(int c=0;c<cellCount;c++)
3139  {
3140  const T Tlat=Tl[c];
3141  int cellIndex=kspace.getGlobalIndex(c,0);
3142  for(int k=0;k<klen;k++)
3143  {
3144  Tkvol& kvol=kspace.getkvol(k);
3145  const int numModes=kvol.getmodenum();
3146  for(int m=0;m<numModes;m++)
3147  {
3148  Tmode& mode=kvol.getmode(m);
3149  e0Array[cellIndex]=mode.calce0(Tlat);
3150  kspace.updateTau(c,Tl[c]);
3151  cellIndex++;
3152  }
3153  }
3154  }
3155  }
3156  }
int getSelfCount() const
Definition: StorageSite.h:40
Array< T > TArray
Field temperature
Definition: PhononMacro.h:21
Definition: Mesh.h:49
int getmodenum()
Definition: kvol.h:43
PhononMacro & _macro
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
MeshKspaceMap _MeshKspaceMap
Kspace< T > Tkspace
Definition: kvol.h:14
template<class T >
void COMETModel< T >::setFinerLevel ( TCOMET fl)
inline

Definition at line 4240 of file phononbase/COMETModel.h.

References COMETModel< T >::_finerLevel.

4240 {_finerLevel=fl;}
template<class T >
void COMETModel< T >::setFinerLevel ( TCOMET fl)
inline

Definition at line 5638 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_finerLevel.

Referenced by COMETModel< T >::MakeIBCoarseModel().

5638 {_finerLevel=fl;}
template<class T >
void COMETModel< T >::setFinestLevel ( TCOMET finest)
inline

Definition at line 1153 of file phononbase/COMETModel.h.

References COMETModel< T >::_coarserLevel, COMETModel< T >::_finestLevel, and COMETModel< T >::setFinestLevel().

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

1154  {
1155  _finestLevel=finest;
1156  if(_coarserLevel!=NULL)
1157  _coarserLevel->setFinestLevel(finest);
1158  }
void setFinestLevel(TCOMET *finest)
template<class T >
void COMETModel< T >::setJacobianBGK ( SquareMatrix< T, 5 > &  fjac,
VectorT5 fvec,
const VectorT5 xn,
const VectorT3 v,
const int  c 
)
inline

Definition at line 1799 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_quadrature.

Referenced by COMETModel< T >::NewtonsMethodBGK().

1800  {
1801 
1802 
1803  const TArray& cx = dynamic_cast<const TArray&>(*_quadrature.cxPtr);
1804  const TArray& cy = dynamic_cast<const TArray&>(*_quadrature.cyPtr);
1805  const TArray& cz = dynamic_cast<const TArray&>(*_quadrature.czPtr);
1806  const TArray& wts = dynamic_cast<const TArray&>(*_quadrature.dcxyzPtr);
1807 
1808  const TArray2D& malphaBGK = dynamic_cast<const TArray2D&>(*_quadrature.malphaBGKPtr);
1809  const int numFields= _quadrature.getDirCount();
1810  VectorT5 mexp;
1811 
1812  for(int j=0;j< numFields;j++){
1813  T Cconst=pow(cx[j]-v[0],2.0)+pow(cy[j]-v[1],2.0)+pow(cz[j]-v[2],2.0);
1814  T Econst=xn[0]*exp(-xn[1]*Cconst+xn[2]*(cx[j]-v[0])+xn[3]*(cy[j]-v[1])+xn[4]*(cz[j]-v[2]))*wts[j];
1815 
1816  for (int row=0;row<5;row++){
1817  fvec[row]+= -Econst*malphaBGK(j,row); //smm
1818 
1819  //fvec[row]=tvec[row]+fvec[row]; //mma
1820  }
1821 
1822  mexp[0]=-Econst/xn[0];
1823  mexp[1]=Econst*Cconst;
1824  mexp[2]=-Econst*(cx[j]-v[0]);
1825  mexp[3]=-Econst*(cy[j]-v[1]);
1826  mexp[4]=-Econst*(cz[j]-v[2]);
1827  for (int row=0;row<5;row++){
1828  for (int col=0;col<5;col++){
1829  fjac(row,col)+=malphaBGK(j,row)*mexp[col]; //new
1830  }
1831  }
1832 
1833 
1834  }
1835 
1836 
1837 
1838  }
Quadrature< T > & _quadrature
Array< T > TArray
Array2D< T > TArray2D
Vector< T, 5 > VectorT5
template<class T >
void COMETModel< T >::setJacobianESBGK ( SquareMatrix< T, 10 > &  fjac,
VectorT10 fvec,
const VectorT10 xn,
const VectorT3 v,
const int  c 
)
inline

Definition at line 2008 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_quadrature.

Referenced by COMETModel< T >::NewtonsMethodESBGK().

2009  {
2010  const TArray& cx = dynamic_cast<const TArray&>(*_quadrature.cxPtr);
2011  const TArray& cy = dynamic_cast<const TArray&>(*_quadrature.cyPtr);
2012  const TArray& cz = dynamic_cast<const TArray&>(*_quadrature.czPtr);
2013  const TArray& wts = dynamic_cast<const TArray&>(*_quadrature.dcxyzPtr);
2014 
2015  const TArray2D& malphaESBGK = dynamic_cast<const TArray2D&>(*_quadrature.malphaESBGKPtr);
2016  const int numFields= _quadrature.getDirCount();
2017  VectorT10 mexp;
2018 
2019  for(int j=0;j< numFields;j++){
2020  T Cc1=cx[j]-v[0];
2021  T Cc2=cy[j]-v[1];
2022  T Cc3=cz[j]-v[2];
2023  T Econst=xn[0]*exp(-xn[1]*pow(Cc1,2)+xn[2]*Cc1-xn[3]*pow(Cc2,2)+ xn[4]*Cc2
2024  -xn[5]*pow(Cc3,2)+xn[6]*Cc3
2025  +xn[7]*cx[j]*cy[j]+xn[8]*cy[j]*cz[j]+xn[9]*cz[j]*cx[j])*wts[j];
2026 
2027  for (int row=0;row<10;row++){
2028  fvec[row]+= -Econst*malphaESBGK(j,row); //smm
2029  }
2030 
2031  mexp[0]=-Econst/xn[0];
2032  mexp[1]=Econst*pow(Cc1,2);
2033  mexp[2]=-Econst*Cc1;
2034  mexp[3]=Econst*pow(Cc2,2);
2035  mexp[4]=-Econst*Cc2;
2036  mexp[5]=Econst*pow(Cc3,2);
2037  mexp[6]=-Econst*Cc3;
2038 
2039  mexp[7]=-Econst*cx[j]*cy[j];
2040  mexp[8]=-Econst*cy[j]*cz[j];
2041  mexp[9]=-Econst*cz[j]*cx[j];
2042 
2043  for (int row=0;row<10;row++){
2044  for (int col=0;col<10;col++){
2045  fjac(row,col)+=malphaESBGK(j,row)*mexp[col]; //new
2046  }
2047  }
2048 
2049 
2050 
2051 
2052  }
2053 
2054 
2055  }
Quadrature< T > & _quadrature
Array< T > TArray
Array2D< T > TArray2D
Vector< T, 10 > VectorT10
template<class T >
void COMETModel< T >::setLocalScatterMaps ( const Mesh mesh0,
StorageSite faces0,
const Mesh mesh1,
StorageSite faces1 
)
inline

Definition at line 988 of file phononbase/COMETModel.h.

References StorageSite::getCommonMap(), StorageSite::getCount(), Mesh::getFaceCells(), and StorageSite::getScatterMap().

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

989  {//makes the IntArray for the indices of the cells1 to which the cells0 scatter
990 
991  const IntArray& common01=*(faces0.getCommonMap()[&faces1]);
992  IntArrPtr scatter01(new IntArray(faces0.getCount()));
993  IntArrPtr scatter10(new IntArray(faces0.getCount()));
994  const CRConnectivity& faceCells0=mesh0.getFaceCells(faces0);
995  const CRConnectivity& faceCells1=mesh1.getFaceCells(faces1);
996 
997  for(int i=0;i<faces0.getCount();i++)
998  {
999  const int f01=common01[i];
1000  const int c01=faceCells1(f01,1);
1001  const int c10=faceCells0(i,1);
1002  (*scatter01)[i]=c01;
1003  (*scatter10)[f01]=c10;
1004  }
1005 
1006  faces0.getScatterMap()[&faces1]=scatter01;
1007  faces1.getScatterMap()[&faces0]=scatter10;
1008 
1009  }
const CommonMap & getCommonMap() const
Definition: StorageSite.h:60
shared_ptr< IntArray > IntArrPtr
const ScatterMap & getScatterMap() const
Definition: StorageSite.h:58
const CRConnectivity & getFaceCells(const StorageSite &site) const
Definition: Mesh.cpp:388
int getCount() const
Definition: StorageSite.h:39
Array< int > IntArray
template<class T >
void COMETModel< T >::setStraightLine ( const T  T1,
const T  T2 
)
inline

Definition at line 3641 of file phononbase/COMETModel.h.

References COMETModel< T >::_geomFields, COMETModel< T >::_macro, Model::_meshes, GeomFields::coordinate, Mesh::getCells(), StorageSite::getCount(), StorageSite::getSelfCount(), and PhononMacro::temperature.

3642  {
3643  const int numMeshes = _meshes.size();
3644 
3645  T xmax(0.);
3646  T xmin(0.);
3647 
3648  for (int n=0; n<numMeshes; n++)
3649  {
3650  const Mesh& mesh=*_meshes[n];
3651  const StorageSite& cells=mesh.getCells();
3652  const int numcells=cells.getCount();
3653  const VectorT3Array& coords=dynamic_cast<const VectorT3Array&>(_geomFields.coordinate[cells]);
3654 
3655  for(int c=0;c<numcells;c++)
3656  {
3657  T x=coords[c][0];
3658  if(x>xmax)
3659  xmax=x;
3660  if(x<xmin)
3661  xmin=x;
3662  }
3663 
3664  }
3665 
3666  for (int n=0; n<numMeshes; n++)
3667  {
3668  const Mesh& mesh=*_meshes[n];
3669  const StorageSite& cells=mesh.getCells();
3670  //const int numcells=cells.getCount();
3671  const int selfcells=cells.getSelfCount();
3672  TArray& Tl=dynamic_cast<TArray&>(_macro.temperature[cells]);
3673  const VectorT3Array& coords=dynamic_cast<const VectorT3Array&>(_geomFields.coordinate[cells]);
3674 
3675  for(int c=0;c<selfcells;c++)
3676  {
3677  T factor=(coords[c][0]-xmin)/(xmax-xmin);
3678  Tl[c]=T1+factor*(T2-T1);
3679  }
3680 
3681  }
3682 
3683  }
GeomFields & _geomFields
int getSelfCount() const
Definition: StorageSite.h:40
Field coordinate
Definition: GeomFields.h:19
Array< T > TArray
Field temperature
Definition: PhononMacro.h:21
Definition: Mesh.h:49
PhononMacro & _macro
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
int getCount() const
Definition: StorageSite.h:39
template<class T >
void COMETModel< T >::smooth ( int  dir)
inline

Definition at line 2810 of file phononbase/COMETModel.h.

References COMETModel< T >::_BCells, COMETModel< T >::_bcMap, COMETModel< T >::_BFaces, COMETModel< T >::_geomFields, COMETModel< T >::_IClist, COMETModel< T >::_kspaces, COMETModel< T >::_level, COMETModel< T >::_macro, Model::_meshes, COMETModel< T >::_MeshKspaceMap, COMETModel< T >::_MeshToIC, COMETModel< T >::_options, COMETModel< T >::applyTemperatureBoundaries(), COMETDiscretizer< T >::COMETSolveCoarse(), COMETDiscretizer< T >::COMETSolveFine(), COMETDiscretizer< T >::COMETSolveFull(), COMETIC< T >::getKConnectivity(), Array< T >::getLength(), COMETIC< T >::getSelfFaceID(), COMETDiscretizer< T >::setfgFinder(), COMETModel< T >::swapGhostInfo(), and COMETInterface< T >::updateOtherGhost().

2811  {
2812 
2813  const int numMeshes=_meshes.size();
2814  int start;
2815  if(dir==1)
2816  start=0;
2817  else
2818  start=numMeshes-1;
2819 
2821 
2822  for(int msh=start;((msh<numMeshes)&&(msh>-1));msh+=dir)
2823  {
2824  const Mesh& mesh=*_meshes[msh];
2825  Tkspace& kspace=*_kspaces[_MeshKspaceMap[msh]];
2826  FgTKClistMap FgToKsc;
2827 
2828  if(!_MeshToIC.empty())
2829  {
2830  IntArray& ICs=*_MeshToIC[msh];
2831  const int totIC=ICs.getLength();
2832  for(int i=0;i<totIC;i++)
2833  {
2834  COMETIC<T>& ic=*_IClist[ICs[i]];
2835  int fgid=ic.getSelfFaceID(msh);
2836  FgToKsc[fgid]=ic.getKConnectivity(fgid);
2837  }
2838  }
2839 
2840  const BCcellArray& BCArray=*(_BCells[msh]);
2841  const BCfaceArray& BCfArray=*(_BFaces[msh]);
2842 
2844  kspace,_bcMap,BCArray,BCfArray,_options,
2845  FgToKsc);
2846 
2847  CDisc.setfgFinder();
2848 
2849 #ifdef FVM_PARALLEL
2850  swapGhostInfo();
2851 #endif
2852 
2853  if(_options.Scattering=="Full")
2854  {
2856  if(_level==0)
2857  {
2858  CDisc.COMETSolveFull(dir,_level);
2859  //CDisc.COMETSolveFull(-dir,_level);
2860  }
2861  else
2862  {
2863  CDisc.COMETSolveCoarse(dir,_level);
2864  CDisc.COMETSolveCoarse(-dir,_level);
2865  }
2866  }
2867  else
2868  {
2869  if(_level>0 || _options.Convection=="FirstOrder")
2870  {
2872  CDisc.COMETSolveCoarse(dir,_level);
2873  CDisc.COMETSolveCoarse(-dir,_level);
2874  }
2875  else
2876  {
2877  //applyTemperatureBoundaries();
2878  CDisc.COMETSolveFine(dir,_level);
2879  CDisc.COMETSolveFine(-dir,_level);
2880  }
2881  }
2882 
2883  if(!_MeshToIC.empty())
2884  {
2885  IntArray& ICs=*_MeshToIC[msh];
2886  const int totIC=ICs.getLength();
2887  for(int i=0;i<totIC;i++)
2888  {
2889  COMETIC<T>& ic=*_IClist[ICs[i]];
2890  ComInt.updateOtherGhost(ic,msh,_level!=0);
2891  }
2892  }
2893 
2894  }
2895 
2896  }
Array< int > BCcellArray
GeomFields & _geomFields
Definition: Mesh.h:49
COMETModelOptions< T > _options
int getSelfFaceID(const int mesh)
void applyTemperatureBoundaries()
map< int, TKClist > FgTKClistMap
PhononMacro & _macro
const MeshList _meshes
Definition: Model.h:29
MeshKspaceMap _MeshKspaceMap
Array< int > IntArray
Kspace< T > Tkspace
Array< int > BCfaceArray
const TKClist & getKConnectivity(const int fgid) const
template<class T >
void COMETModel< T >::smooth ( const int  num,
const StorageSite solidFaces 
)
inline

Definition at line 4927 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_BCells, COMETModel< T >::_bcMap, COMETModel< T >::_BFaces, COMETModel< T >::_dsfEqPtrES, COMETModel< T >::_dsfPtr, COMETModel< T >::_dsfPtr1, COMETModel< T >::_dsfPtr2, COMETModel< T >::_dsfPtrFAS, COMETModel< T >::_dsfPtrRes, COMETModel< T >::_faceReflectionArrayMap, COMETModel< T >::_geomFields, COMETModel< T >::_level, COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_options, COMETModel< T >::_quadrature, COMETModel< T >::_ZCells, COMETESBGKDiscretizer< T >::COMETSolve(), COMETModel< T >::ComputeCollisionfrequency(), COMETModel< T >::ComputeCOMETMacroparameters(), COMETModel< T >::computeIBFaceDsf(), COMETModel< T >::computeSolidFaceDsf(), COMETModel< T >::ConservationofMFSolid(), COMETModel< T >::EquilibriumDistributionBGK(), COMETModel< T >::EquilibriumDistributionESBGK(), COMETModel< T >::initializeMaxwellianEq(), COMETModel< T >::MakeParallel(), and COMETESBGKDiscretizer< T >::setfgFinder().

Referenced by COMETModel< T >::doSweeps().

4928  {
4929  const int numDir=_quadrature.getDirCount();
4930  const int numMeshes=_meshes.size();
4931  for(int msh=0;msh<numMeshes;msh++)
4932  {
4933  const Mesh& mesh=*_meshes[msh];
4934  const BCcellArray& BCArray=*(_BCells[msh]);
4935  const BCfaceArray& BCfArray=*(_BFaces[msh]);
4936  const BCcellArray& ZCArray=*(_ZCells[msh]);
4939  _options["timeStep"],_options.timeDiscretizationOrder,
4940  _options.transient,_options.underRelaxation,_options["rho_init"],
4941  _options["T_init"],_options["molecularWeight"],_options.conOrder,
4942  _bcMap,_faceReflectionArrayMap,BCArray,BCfArray,ZCArray);
4943 
4944  CDisc.setfgFinder();
4945 
4946  MakeParallel();
4947 
4948  CDisc.COMETSolve(1,_level); //forward
4949 
4950  MakeParallel();
4951 
4952  //callCOMETBoundaryConditions();
4955  //update equilibrium distribution function 0-maxwellian, 1-BGK,2-ESBGK
4956  if (_options.fgamma==0){initializeMaxwellianEq();}
4957  else{ EquilibriumDistributionBGK();}
4958  if (_options.fgamma==2){EquilibriumDistributionESBGK();}
4959  computeSolidFaceDsf(solidFaces,_options.method,_options.relaxDistribution);
4960  ConservationofMFSolid(solidFaces);
4961  computeIBFaceDsf(solidFaces,_options.method,_options.relaxDistribution);
4962 
4963  CDisc.COMETSolve(-1,_level); //reverse
4964  if((num==1)||(num==0&&_level==0))
4965  {
4966  MakeParallel();
4967  //callCOMETBoundaryConditions();
4970  //update equilibrium distribution function 0-maxwellian, 1-BGK,2-ESBGK
4971  if (_options.fgamma==0){initializeMaxwellianEq();}
4972  else{ EquilibriumDistributionBGK();}
4973  if (_options.fgamma==2){EquilibriumDistributionESBGK();}
4974  computeSolidFaceDsf(solidFaces,_options.method,_options.relaxDistribution);
4975  ConservationofMFSolid(solidFaces);
4976  computeIBFaceDsf(solidFaces,_options.method,_options.relaxDistribution);
4977  }
4978  }
4979  }
Array< int > BCcellArray
void computeIBFaceDsf(const StorageSite &solidFaces, const int method, const int RelaxDistribution=0)
GeomFields & _geomFields
DistFunctFields< T > _dsfPtr2
Quadrature< T > & _quadrature
void computeSolidFaceDsf(const StorageSite &solidFaces, const int method, const int RelaxDistribution=0)
Definition: Mesh.h:49
COMETModelOptions< T > _options
void ComputeCollisionfrequency()
DistFunctFields< T > _dsfPtrFAS
void initializeMaxwellianEq()
void ComputeCOMETMacroparameters()
map< int, vector< int > > _faceReflectionArrayMap
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
void EquilibriumDistributionESBGK()
DistFunctFields< T > _dsfEqPtrES
DistFunctFields< T > _dsfPtrRes
DistFunctFields< T > _dsfPtr
DistFunctFields< T > _dsfPtr1
void EquilibriumDistributionBGK()
Array< int > BCfaceArray
void ConservationofMFSolid(const StorageSite &solidFaces) const
template<class T >
void COMETModel< T >::smooth ( const int  num)
inline

Definition at line 4981 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_BCells, COMETModel< T >::_bcMap, COMETModel< T >::_BFaces, COMETModel< T >::_dsfEqPtrES, COMETModel< T >::_dsfPtr, COMETModel< T >::_dsfPtr1, COMETModel< T >::_dsfPtr2, COMETModel< T >::_dsfPtrFAS, COMETModel< T >::_dsfPtrRes, COMETModel< T >::_faceReflectionArrayMap, COMETModel< T >::_geomFields, COMETModel< T >::_level, COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_options, COMETModel< T >::_quadrature, COMETModel< T >::_ZCells, COMETModel< T >::callCOMETBoundaryConditions(), COMETESBGKDiscretizer< T >::COMETSolve(), COMETESBGKDiscretizer< T >::COMETSolveFine(), COMETModel< T >::ComputeCollisionfrequency(), COMETModel< T >::ComputeCOMETMacroparameters(), COMETModel< T >::EquilibriumDistributionBGK(), COMETModel< T >::EquilibriumDistributionESBGK(), COMETModel< T >::initializeMaxwellianEq(), COMETModel< T >::MakeParallel(), and COMETESBGKDiscretizer< T >::setfgFinder().

4982  {
4983  const int numDir=_quadrature.getDirCount();
4984  const int numMeshes=_meshes.size();
4985  for(int msh=0;msh<numMeshes;msh++)
4986  {
4987  const Mesh& mesh=*_meshes[msh];
4988  const BCcellArray& BCArray=*(_BCells[msh]);
4989  const BCfaceArray& BCfArray=*(_BFaces[msh]);
4990  const BCcellArray& ZCArray=*(_ZCells[msh]);
4991  shared_ptr<StorageSite> solidFaces(new StorageSite(-1));
4994  _options["timeStep"],_options.timeDiscretizationOrder,
4995  _options.transient,_options.underRelaxation,_options["rho_init"],
4996  _options["T_init"],_options["molecularWeight"],_options.conOrder,
4997  _bcMap,_faceReflectionArrayMap,BCArray,BCfArray,ZCArray);
4998 
4999  CDisc.setfgFinder();
5000 
5002  MakeParallel();
5003 
5004  if(_level==0)
5005  CDisc.COMETSolveFine(1,_level); //forward
5006  else
5007  CDisc.COMETSolve(1,_level); //forward
5008  //callCOMETBoundaryConditions();
5011  //update equilibrium distribution function 0-maxwellian, 1-BGK,2-ESBGK
5012  if (_options.fgamma==0){initializeMaxwellianEq();}
5013  else{ EquilibriumDistributionBGK();}
5014  if (_options.fgamma==2){EquilibriumDistributionESBGK();}
5015 
5017  MakeParallel();
5018 
5019 
5020  if(_level==0)
5021  CDisc.COMETSolveFine(-1,_level); //reverse
5022  else
5023  CDisc.COMETSolve(-1,_level); //forward
5024  if((num==1)||(num==0&&_level==0))
5025  {
5026  //callCOMETBoundaryConditions();
5029  //update equilibrium distribution function 0-maxwellian, 1-BGK,2-ESBGK
5030  if (_options.fgamma==0){initializeMaxwellianEq();}
5031  else{ EquilibriumDistributionBGK();}
5032  if (_options.fgamma==2){EquilibriumDistributionESBGK();}
5033  }
5034 
5035  }
5036  }
Array< int > BCcellArray
GeomFields & _geomFields
DistFunctFields< T > _dsfPtr2
Quadrature< T > & _quadrature
Definition: Mesh.h:49
COMETModelOptions< T > _options
void ComputeCollisionfrequency()
DistFunctFields< T > _dsfPtrFAS
void initializeMaxwellianEq()
void ComputeCOMETMacroparameters()
map< int, vector< int > > _faceReflectionArrayMap
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
void EquilibriumDistributionESBGK()
void callCOMETBoundaryConditions()
DistFunctFields< T > _dsfEqPtrES
DistFunctFields< T > _dsfPtrRes
DistFunctFields< T > _dsfPtr
DistFunctFields< T > _dsfPtr1
void EquilibriumDistributionBGK()
Array< int > BCfaceArray
template<class T >
void COMETModel< T >::swapGhostInfo ( )
inline

Definition at line 2959 of file phononbase/COMETModel.h.

References COMETModel< T >::_kspaces, Model::_meshes, COMETModel< T >::_MeshKspaceMap, Mesh::getCells(), and Kspace< T >::syncLocal().

Referenced by COMETModel< T >::smooth(), and COMETModel< T >::updateResid().

2960  {
2961  const int numMeshes=_meshes.size();
2962  for(int msh=0;msh<numMeshes;msh++)
2963  {
2964  const Mesh& mesh=*_meshes[msh];
2965  const StorageSite& cells=mesh.getCells();
2966  Tkspace& kspace=*_kspaces[_MeshKspaceMap[msh]];
2967  kspace.syncLocal(cells);
2968  }
2969  }
Definition: Mesh.h:49
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
MeshKspaceMap _MeshKspaceMap
Kspace< T > Tkspace
template<class T >
void COMETModel< T >::syncGhostCoarsening ( const MeshList inMeshes,
GeomFields inGeomFields,
MeshList outMeshes,
ScatGathMaps coarseScatMaps,
ScatGathMaps coarseGathMaps,
IntArray coarseSizes,
IntArray CoarseGhost 
)
inline

Definition at line 1433 of file phononbase/COMETModel.h.

References GeomFields::fineToCoarse, Mesh::getCells(), StorageSite::getCountLevel1(), UnorderedSet::getData(), StorageSite::getGatherMap(), Array< T >::getLength(), StorageSite::getScatterMap(), UnorderedSet::insert(), and UnorderedSet::size().

1437  {
1438 
1439  const int numMeshes=inMeshes.size();
1440  for(int n=0;n<numMeshes;n++)
1441  {
1442  const Mesh& mesh=*inMeshes[n];
1443 
1444  const StorageSite& inCells=mesh.getCells();
1445  const StorageSite& site=mesh.getCells();
1446  //const int inCellCount=inCells.getSelfCount();
1447  //const int inCellTotal=inCells.getCount();
1448 
1449  Field& FineToCoarseField=inGeomFields.fineToCoarse;
1450  IntArray& coarseIndex=dynamic_cast<IntArray&>(FineToCoarseField[inCells]);
1451  IntArray tempIndex(inCells.getCountLevel1());
1452  for(int c=0;c<inCells.getCountLevel1();c++)
1453  tempIndex[c]=coarseIndex[c];
1454 
1455  //int coarseGhostSize=0;
1456  //int tempGhostSize=0;
1457  //int coarseSize= CoarseGhost[n];
1458 
1459  const StorageSite::GatherMap& gatherMap = site.getGatherMap();
1460 
1461  // collect all the toIndices arrays for each storage site from
1462  // gatherMap
1463 
1464  typedef map<const StorageSite*, vector<const Array<int>* > > IndicesMap;
1465  IndicesMap toIndicesMap;
1466  //IndicesMap tempIndicesMap;
1467 
1468  foreach(const StorageSite::GatherMap::value_type pos, gatherMap)
1469  {
1470  const StorageSite& oSite = *pos.first;
1471  //const Array<int>& tempIndices = *pos.second;
1472  const Array<int>& toIndices = *pos.second;
1473 
1474  //tempIndicesMap[&oSite].push_back(&tempIndices);
1475  toIndicesMap[&oSite].push_back(&toIndices);
1476  }
1477 
1478  /*
1479  foreach(IndicesMap::value_type pos, tempIndicesMap)
1480  {
1481  const StorageSite& oSite = *pos.first;
1482  const vector<const Array<int>* > tempIndicesArrays = pos.second;
1483 
1484  map<int,int> otherToMyMapping;
1485  UnorderedSet gatherSet;
1486 
1487  foreach(const Array<int>* tempIndicesPtr, tempIndicesArrays)
1488  {
1489  const Array<int>& tempIndices = *tempIndicesPtr;
1490  const int nGhostRows = tempIndices.getLength();
1491  for(int ng=0; ng<nGhostRows; ng++)
1492  {
1493  const int fineIndex = tempIndices[ng];
1494  const int coarseOtherIndex = tempIndex[fineIndex];
1495 
1496  if (coarseOtherIndex < 0)
1497  continue;
1498 
1499  if (otherToMyMapping.find(coarseOtherIndex) !=
1500  otherToMyMapping.end())
1501  {
1502 
1503  tempIndex[fineIndex] = otherToMyMapping[coarseOtherIndex];
1504  }
1505  else
1506  {
1507  tempIndex[fineIndex] = tempGhostSize+coarseSize;
1508  otherToMyMapping[coarseOtherIndex] = tempIndex[fineIndex];
1509  gatherSet.insert( tempIndex[fineIndex] );
1510  tempGhostSize++;
1511  }
1512  }
1513  }
1514  }*/
1515 
1516  foreach(IndicesMap::value_type pos, toIndicesMap)
1517  {
1518  const StorageSite& oSite = *pos.first;
1519  const vector<const Array<int>* > toIndicesArrays = pos.second;
1520 
1521 
1522  map<int,int> otherToMyMapping;
1523  UnorderedSet gatherSet;
1524 
1525  foreach(const Array<int>* toIndicesPtr, toIndicesArrays)
1526  {
1527  const Array<int>& toIndices = *toIndicesPtr;
1528  const int nGhostRows = toIndices.getLength();
1529  for(int ng=0; ng<nGhostRows; ng++)
1530  {
1531  const int fineIndex = toIndices[ng];
1532  const int coarseOtherIndex = coarseIndex[fineIndex];
1533 
1534  if (coarseOtherIndex < 0)
1535  continue;
1536 
1537  if (otherToMyMapping.find(coarseOtherIndex) !=
1538  otherToMyMapping.end())
1539  {
1540  coarseIndex[fineIndex] = otherToMyMapping[coarseOtherIndex];
1541  }
1542  else
1543  {
1544  coarseIndex[fineIndex] = CoarseGhost[n];
1545  otherToMyMapping[coarseOtherIndex] = coarseIndex[fineIndex];
1546  gatherSet.insert( coarseIndex[fineIndex] );
1547  CoarseGhost[n]++;
1548  }
1549 
1550  }
1551 
1552  }
1553 
1554  const int coarseMappersSize = otherToMyMapping.size();
1555 
1556  shared_ptr<Array<int> > coarseToIndices(new Array<int>(coarseMappersSize));
1557 
1558  for(int n = 0; n < gatherSet.size(); n++)
1559  (*coarseToIndices)[n] = gatherSet.getData().at(n);
1560 
1561  SSPair sskey(&site,&oSite);
1562  coarseGathMaps [sskey] = coarseToIndices;
1563 
1564  }
1565 
1566  const StorageSite::ScatterMap& scatterMap = site.getScatterMap();
1567 
1568  IndicesMap fromIndicesMap;
1569 
1570  foreach(const StorageSite::GatherMap::value_type pos, scatterMap)
1571  {
1572  const StorageSite& oSite = *pos.first;
1573  const Array<int>& fromIndices = *pos.second;
1574 
1575  fromIndicesMap[&oSite].push_back(&fromIndices);
1576  }
1577 
1578  foreach(IndicesMap::value_type pos, fromIndicesMap)
1579  {
1580  const StorageSite& oSite = *pos.first;
1581  const vector<const Array<int>* > fromIndicesArrays = pos.second;
1582 
1583  UnorderedSet scatterSet;
1584 
1585  foreach(const Array<int>* fromIndicesPtr, fromIndicesArrays)
1586  {
1587  const Array<int>& fromIndices = *fromIndicesPtr;
1588  const int nGhostRows = fromIndices.getLength();
1589  for(int ng=0; ng<nGhostRows; ng++)
1590  {
1591  const int fineIndex = fromIndices[ng];
1592  const int coarseOtherIndex = coarseIndex[fineIndex];
1593  if (coarseOtherIndex >= 0)
1594  scatterSet.insert( coarseOtherIndex );
1595  }
1596 
1597  }
1598 
1599  const int coarseMappersSize = scatterSet.size();
1600 
1601  shared_ptr<Array<int> > coarseFromIndices(new Array<int>(coarseMappersSize));
1602 
1603  for(int n = 0; n < scatterSet.size(); n++ )
1604  (*coarseFromIndices)[n] = scatterSet.getData().at(n);
1605 
1606  SSPair sskey(&site,&oSite);
1607  coarseScatMaps[sskey] = coarseFromIndices;
1608 
1609  }
1610 
1611  }
1612  }
Definition: Field.h:14
pair< const StorageSite *, const StorageSite * > SSPair
Definition: Mesh.h:49
void insert(int x)
Field fineToCoarse
Definition: GeomFields.h:41
int size() const
const StorageSite & getCells() const
Definition: Mesh.h:109
int getCountLevel1() const
Definition: StorageSite.h:72
const ScatterMap & getScatterMap() const
Definition: StorageSite.h:58
map< const StorageSite *, shared_ptr< Array< int > > > ScatterMap
Definition: StorageSite.h:23
const vector< int > & getData() const
const GatherMap & getGatherMap() const
Definition: StorageSite.h:59
Array< int > IntArray
map< const StorageSite *, shared_ptr< Array< int > > > GatherMap
Definition: StorageSite.h:24
int getLength() const
Definition: Array.h:87
template<class T >
void COMETModel< T >::syncGhostCoarsening ( const MeshList inMeshes,
GeomFields inGeomFields,
MeshList outMeshes 
)
inline

Definition at line 3214 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_coarseGatherMaps, COMETModel< T >::_coarseGhostSizes, COMETModel< T >::_coarseScatterMaps, COMETModel< T >::_coarseSizes, GeomFields::fineToCoarse, Mesh::getBoundaryFaceGroups(), Mesh::getCells(), StorageSite::getCount(), StorageSite::getCountLevel1(), UnorderedSet::getData(), Mesh::getDimension(), Mesh::getFaceCells(), StorageSite::getGatherMap(), StorageSite::getGatherMapLevel1(), Array< T >::getLength(), StorageSite::getScatterMap(), StorageSite::getScatterMapLevel1(), StorageSite::getSelfCount(), StorageSite::getTag(), UnorderedSet::insert(), FaceGroup::site, and UnorderedSet::size().

Referenced by COMETModel< T >::MakeCoarseModel(), and COMETModel< T >::MakeIBCoarseModel().

3216  {
3217  //const int xLen = coarseIndexField.getLength();
3218 
3219  //#pragma omp parallel for
3220  const int numMeshes=inMeshes.size();
3221  for(int n=0;n<numMeshes;n++)
3222  {
3223  const Mesh& mesh=*inMeshes[n];
3224  const int dim=mesh.getDimension();
3225  Mesh& newMeshPtr=*outMeshes[n];
3226 
3227  const StorageSite& inCells=mesh.getCells();
3228  const StorageSite& site=mesh.getCells();
3229  //const StorageSite& site=newMeshPtr.getCells();
3230  const int inCellCount=inCells.getSelfCount();
3231  const int inCellTotal=inCells.getCount();
3232 
3233  Field& FineToCoarseField=inGeomFields.fineToCoarse;
3234  IntArray& coarseIndex=dynamic_cast<IntArray&>(FineToCoarseField[inCells]);
3235  IntArray tempIndex(inCells.getCountLevel1());
3236  for(int c=0;c<inCells.getCountLevel1();c++)
3237  tempIndex[c]=coarseIndex[c];
3238 
3239  int coarseGhostSize=0;
3240  int tempGhostSize=0;
3241  //const int coarseSize = _coarseSizes.find(rowIndex)->second;
3242  //const int coarseSize = _coarseSizes[&mesh];
3243  int coarseSize = -1;
3244  coarseSize = _coarseSizes[&mesh];
3245 
3246  int boundaryCell=0;
3247  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
3248  {
3249  const FaceGroup& fg = *fgPtr;
3250  const StorageSite& faces = fg.site;
3251  const int nFaces = faces.getCount();
3252 
3253  const CRConnectivity& faceCells = mesh.getFaceCells(faces);
3254 
3255  for(int f=0; f< nFaces; f++)
3256  {
3257  const int c1= faceCells(f,1);// boundary cell
3258  //if(MPI::COMM_WORLD.Get_rank()==1)
3259  //cout<<"fgid, boundarycell, boundary coarse index = "<<fg.id<<" "<<c1<<" "<<coarseIndex[c1]<<endl;
3260  if(boundaryCell<coarseIndex[c1])
3261  boundaryCell=coarseIndex[c1];
3262  }
3263  }
3264  boundaryCell++;
3265  if(boundaryCell!=1)
3266  coarseSize = boundaryCell;
3267 
3268  //const StorageSite& site = *rowIndex.second;
3269 
3270  const StorageSite::GatherMap& gatherMap = site.getGatherMap();
3271  const StorageSite::GatherMap& gatherMapLevel1 = site.getGatherMapLevel1();
3272 
3273  // collect all the toIndices arrays for each storage site from
3274  // both gatherMap and gatherMapLevel1
3275 
3276  typedef map<const StorageSite*, vector<const Array<int>* > > IndicesMap;
3277  IndicesMap toIndicesMap;
3278  IndicesMap tempIndicesMap;
3279 
3280  foreach(const StorageSite::GatherMap::value_type pos, gatherMap)
3281  {
3282  const StorageSite& oSite = *pos.first;
3283  const Array<int>& tempIndices = *pos.second;
3284  const Array<int>& toIndices = *pos.second;
3285 
3286  tempIndicesMap[&oSite].push_back(&tempIndices);
3287  toIndicesMap[&oSite].push_back(&toIndices);
3288  }
3289 
3290  foreach(const StorageSite::GatherMap::value_type pos, gatherMapLevel1)
3291  {
3292  const StorageSite& oSite = *pos.first;
3293  const Array<int>& toIndices = *pos.second;
3294 
3295  int found=0;
3296  foreach(const StorageSite::GatherMap::value_type posLevel0, gatherMap)
3297  {
3298  const StorageSite& oSiteLevel0 = *posLevel0.first;
3299  if(oSite.getTag()==oSiteLevel0.getTag())
3300  {
3301  toIndicesMap[&oSiteLevel0].push_back(&toIndices);
3302  found=1;
3303  }
3304  }
3305 
3306  if(found==0)
3307  toIndicesMap[&oSite].push_back(&toIndices);
3308  }
3309 
3310  foreach(IndicesMap::value_type pos, tempIndicesMap)
3311  {
3312  const StorageSite& oSite = *pos.first;
3313  const vector<const Array<int>* > tempIndicesArrays = pos.second;
3314 
3315 
3316  map<int,int> otherToMyMapping;
3317  UnorderedSet gatherSet;
3318 
3319  foreach(const Array<int>* tempIndicesPtr, tempIndicesArrays)
3320  {
3321  const Array<int>& tempIndices = *tempIndicesPtr;
3322  const int nGhostRows = tempIndices.getLength();
3323  for(int ng=0; ng<nGhostRows; ng++)
3324  {
3325  const int fineIndex = tempIndices[ng];
3326  const int coarseOtherIndex = tempIndex[fineIndex];
3327 
3328  if (coarseOtherIndex < 0)
3329  continue;
3330 
3331 
3332  if (otherToMyMapping.find(coarseOtherIndex) !=
3333  otherToMyMapping.end())
3334  {
3335 
3336  tempIndex[fineIndex] = otherToMyMapping[coarseOtherIndex];
3337  }
3338  else
3339  {
3340  tempIndex[fineIndex] = tempGhostSize+coarseSize;
3341  otherToMyMapping[coarseOtherIndex] = tempIndex[fineIndex];
3342  gatherSet.insert( tempIndex[fineIndex] );
3343  tempGhostSize++;
3344  }
3345  }
3346  }
3347  }
3348 
3349  foreach(IndicesMap::value_type pos, toIndicesMap)
3350  {
3351  const StorageSite& oSite = *pos.first;
3352  const vector<const Array<int>* > toIndicesArrays = pos.second;
3353 
3354 
3355  map<int,int> otherToMyMapping;
3356  UnorderedSet gatherSet;
3357 
3358  foreach(const Array<int>* toIndicesPtr, toIndicesArrays)
3359  {
3360  const Array<int>& toIndices = *toIndicesPtr;
3361  const int nGhostRows = toIndices.getLength();
3362  for(int ng=0; ng<nGhostRows; ng++)
3363  {
3364  const int fineIndex = toIndices[ng];
3365  const int coarseOtherIndex = coarseIndex[fineIndex];
3366 
3367  if (coarseOtherIndex < 0)
3368  continue;
3369 
3370  if (otherToMyMapping.find(coarseOtherIndex) !=
3371  otherToMyMapping.end())
3372  {
3373  coarseIndex[fineIndex] = otherToMyMapping[coarseOtherIndex];
3374  }
3375  else
3376  {
3377  coarseIndex[fineIndex] = coarseGhostSize+coarseSize;
3378  otherToMyMapping[coarseOtherIndex] = coarseIndex[fineIndex];
3379  gatherSet.insert( coarseIndex[fineIndex] );
3380  coarseGhostSize++;
3381  }
3382  //if(MPI::COMM_WORLD.Get_rank()==1)
3383  //cout<<"level,fineIndex, coarseIndex = "<<_level<<" "<<fineIndex<<" "<<coarseIndex[fineIndex]<<endl;
3384  }
3385  //if(MPI::COMM_WORLD.Get_rank()==1)
3386  //cout<<endl<<endl;
3387  }
3388 
3389  const int coarseMappersSize = otherToMyMapping.size();
3390 
3391  shared_ptr<Array<int> > coarseToIndices(new Array<int>(coarseMappersSize));
3392 
3393  for(int n = 0; n < gatherSet.size(); n++)
3394  {
3395  (*coarseToIndices)[n] = gatherSet.getData().at(n);
3396  }
3397 
3398  SSPair sskey(&site,&oSite);
3399  _coarseGatherMaps [sskey] = coarseToIndices;
3400  }
3401 
3402  const StorageSite::ScatterMap& scatterMap = site.getScatterMap();
3403  const StorageSite::ScatterMap& scatterMapLevel1 = site.getScatterMapLevel1();
3404 
3405  IndicesMap fromIndicesMap;
3406 
3407  foreach(const StorageSite::GatherMap::value_type pos, scatterMap)
3408  {
3409  const StorageSite& oSite = *pos.first;
3410  const Array<int>& fromIndices = *pos.second;
3411 
3412  fromIndicesMap[&oSite].push_back(&fromIndices);
3413  }
3414 
3415  foreach(const StorageSite::GatherMap::value_type pos, scatterMapLevel1)
3416  {
3417  const StorageSite& oSite = *pos.first;
3418  const Array<int>& fromIndices = *pos.second;
3419 
3420  int found=0;
3421  foreach(const StorageSite::ScatterMap::value_type posLevel0, scatterMap)
3422  {
3423  const StorageSite& oSiteLevel0 = *posLevel0.first;
3424  if(oSite.getTag()==oSiteLevel0.getTag())
3425  {
3426  fromIndicesMap[&oSiteLevel0].push_back(&fromIndices);
3427  found=1;
3428  }
3429  }
3430 
3431  if(found==0)
3432  fromIndicesMap[&oSite].push_back(&fromIndices);
3433  }
3434 
3435  foreach(IndicesMap::value_type pos, fromIndicesMap)
3436  {
3437  const StorageSite& oSite = *pos.first;
3438  const vector<const Array<int>* > fromIndicesArrays = pos.second;
3439 
3440  UnorderedSet scatterSet;
3441 
3442  foreach(const Array<int>* fromIndicesPtr, fromIndicesArrays)
3443  {
3444  const Array<int>& fromIndices = *fromIndicesPtr;
3445  const int nGhostRows = fromIndices.getLength();
3446  for(int ng=0; ng<nGhostRows; ng++)
3447  {
3448  const int fineIndex = fromIndices[ng];
3449  const int coarseOtherIndex = coarseIndex[fineIndex];
3450  if (coarseOtherIndex >= 0)
3451  scatterSet.insert( coarseOtherIndex );
3452  }
3453 
3454  }
3455 
3456  const int coarseMappersSize = scatterSet.size();
3457 
3458  shared_ptr<Array<int> > coarseFromIndices(new Array<int>(coarseMappersSize));
3459 
3460  for(int n = 0; n < scatterSet.size(); n++ ) {
3461  (*coarseFromIndices)[n] = scatterSet.getData().at(n);
3462  }
3463 
3464  SSPair sskey(&site,&oSite);
3465  _coarseScatterMaps[sskey] = coarseFromIndices;
3466 
3467  }
3468  //_coarseGhostSizes[rowIndex]=coarseGhostSize;
3469  _coarseGhostSizes[&mesh]=coarseGhostSize;
3470  }
3471  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
int getSelfCount() const
Definition: StorageSite.h:40
Definition: Mesh.h:28
MatrixMappersMap _coarseGatherMaps
Definition: Field.h:14
pair< const StorageSite *, const StorageSite * > SSPair
const GatherMap & getGatherMapLevel1() const
Definition: StorageSite.h:74
const ScatterMap & getScatterMapLevel1() const
Definition: StorageSite.h:73
Definition: Mesh.h:49
void insert(int x)
Field fineToCoarse
Definition: GeomFields.h:41
int getTag() const
Definition: StorageSite.h:84
int size() const
const StorageSite & getCells() const
Definition: Mesh.h:109
int getCountLevel1() const
Definition: StorageSite.h:72
const ScatterMap & getScatterMap() const
Definition: StorageSite.h:58
const CRConnectivity & getFaceCells(const StorageSite &site) const
Definition: Mesh.cpp:388
map< const StorageSite *, shared_ptr< Array< int > > > ScatterMap
Definition: StorageSite.h:23
const vector< int > & getData() const
const GatherMap & getGatherMap() const
Definition: StorageSite.h:59
int getCount() const
Definition: StorageSite.h:39
Array< int > IntArray
map< const StorageSite *, shared_ptr< Array< int > > > GatherMap
Definition: StorageSite.h:24
int getDimension() const
Definition: Mesh.h:105
MatrixMappersMap _coarseScatterMaps
StorageSite site
Definition: Mesh.h:40
int getLength() const
Definition: Array.h:87
template<class T >
T COMETModel< T >::updateResid ( const bool  addFAS)
inline

Definition at line 2898 of file phononbase/COMETModel.h.

References COMETModel< T >::_BCells, COMETModel< T >::_bcMap, COMETModel< T >::_BFaces, COMETModel< T >::_geomFields, COMETModel< T >::_IClist, COMETModel< T >::_kspaces, COMETModel< T >::_level, COMETModel< T >::_macro, Model::_meshes, COMETModel< T >::_MeshKspaceMap, COMETModel< T >::_options, COMETDiscretizer< T >::findResidCoarse(), COMETDiscretizer< T >::findResidFine(), COMETDiscretizer< T >::findResidFull(), COMETDiscretizer< T >::getAveResid(), COMETDiscretizer< T >::setfgFinder(), COMETModel< T >::swapGhostInfo(), and COMETInterface< T >::updateResid().

2899  {
2900  const int numMeshes=_meshes.size();
2901 
2903 
2904  const int listSize=_IClist.size();
2905  for(int ic=0;ic<listSize;ic++)
2906  {
2907  COMETIC<T>* icPtr=_IClist[ic];
2908  //if(icPtr->InterfaceModel=="DMM" && _level==0)
2909  // ComInt.makeDMMcoeffs(*icPtr);
2910  ComInt.updateResid(*icPtr,addFAS);
2911  }
2912 
2913  T highResid=-1.;
2914  T currentResid;
2915 
2916 #ifdef FVM_PARALLEL
2917  swapGhostInfo();
2918 #endif
2919 
2920  for(int msh=0;msh<numMeshes;msh++)
2921  {
2922  const Mesh& mesh=*_meshes[msh];
2923  Tkspace& kspace=*_kspaces[_MeshKspaceMap[msh]];
2924  const BCcellArray& BCArray=*(_BCells[msh]);
2925  const BCfaceArray& BCfArray=*(_BFaces[msh]);
2926  FgTKClistMap FgToKsc;
2928  kspace,_bcMap,BCArray,BCfArray,_options,
2929  FgToKsc);
2930 
2931  CDisc.setfgFinder();
2932  if(_options.Scattering=="Full")
2933  {
2934  if(_level==0)
2935  CDisc.findResidFull();
2936  else
2937  CDisc.findResidCoarse(addFAS);
2938  }
2939  else
2940  {
2941  if(_level>0 || _options.Convection=="FirstOrder")
2942  CDisc.findResidCoarse(addFAS);
2943  else
2944  CDisc.findResidFine();
2945  }
2946 
2947  currentResid=CDisc.getAveResid();
2948 
2949  if(highResid<0)
2950  highResid=currentResid;
2951  else
2952  if(currentResid>highResid)
2953  highResid=currentResid;
2954  }
2955 
2956  return highResid;
2957  }
Array< int > BCcellArray
GeomFields & _geomFields
Definition: Mesh.h:49
COMETModelOptions< T > _options
map< int, TKClist > FgTKClistMap
PhononMacro & _macro
const MeshList _meshes
Definition: Model.h:29
MeshKspaceMap _MeshKspaceMap
Kspace< T > Tkspace
Array< int > BCfaceArray
template<class T >
T COMETModel< T >::updateResid ( const bool  addFAS)
inline

Definition at line 5038 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_BCells, COMETModel< T >::_bcMap, COMETModel< T >::_BFaces, COMETModel< T >::_dsfEqPtrES, COMETModel< T >::_dsfPtr, COMETModel< T >::_dsfPtr1, COMETModel< T >::_dsfPtr2, COMETModel< T >::_dsfPtrFAS, COMETModel< T >::_dsfPtrRes, COMETModel< T >::_faceReflectionArrayMap, COMETModel< T >::_geomFields, COMETModel< T >::_level, COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_options, COMETModel< T >::_quadrature, COMETModel< T >::_ZCells, COMETModel< T >::callCOMETBoundaryConditions(), COMETESBGKDiscretizer< T >::findResid(), COMETESBGKDiscretizer< T >::findResidFine(), COMETESBGKDiscretizer< T >::getAveResid(), COMETModel< T >::MakeParallel(), and COMETESBGKDiscretizer< T >::setfgFinder().

Referenced by COMETModel< T >::advance(), COMETModel< T >::cycle(), COMETModel< T >::init(), COMETModel< T >::initFromOld(), and COMETModel< T >::makeFAS().

5039  {
5040  const int numMeshes=_meshes.size();
5041  T lowResid=-1.;
5042  T currentResid;
5043  for(int msh=0;msh<numMeshes;msh++)
5044  {
5045  const Mesh& mesh=*_meshes[msh];
5046  const BCcellArray& BCArray=*(_BCells[msh]);
5047  const BCfaceArray& BCfArray=*(_BFaces[msh]);
5048  const BCcellArray& ZCArray=*(_ZCells[msh]);
5049  shared_ptr<StorageSite> solidFaces(new StorageSite(-1));
5052  _options["timeStep"],_options.timeDiscretizationOrder,
5053  _options.transient,_options.underRelaxation,_options["rho_init"],
5054  _options["T_init"],_options["molecularWeight"], _options.conOrder,
5055  _bcMap,_faceReflectionArrayMap,BCArray,BCfArray,ZCArray);
5056 
5057  CDisc.setfgFinder();
5058  const int numDir=_quadrature.getDirCount();
5059 
5061  MakeParallel();
5062 
5063  if(_level==0)
5064  CDisc.findResidFine(addFAS);
5065  else
5066  CDisc.findResid(addFAS);
5067  currentResid=CDisc.getAveResid();
5068 
5069  if(lowResid<0)
5070  lowResid=currentResid;
5071  else
5072  if(currentResid<lowResid)
5073  lowResid=currentResid;
5074  }
5075  return lowResid;
5076  }
Array< int > BCcellArray
GeomFields & _geomFields
DistFunctFields< T > _dsfPtr2
Quadrature< T > & _quadrature
Definition: Mesh.h:49
COMETModelOptions< T > _options
DistFunctFields< T > _dsfPtrFAS
map< int, vector< int > > _faceReflectionArrayMap
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
void callCOMETBoundaryConditions()
DistFunctFields< T > _dsfEqPtrES
DistFunctFields< T > _dsfPtrRes
DistFunctFields< T > _dsfPtr
DistFunctFields< T > _dsfPtr1
Array< int > BCfaceArray
template<class T >
T COMETModel< T >::updateResid ( const bool  addFAS,
const StorageSite solidFaces 
)
inline

Definition at line 5078 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_BCells, COMETModel< T >::_bcMap, COMETModel< T >::_BFaces, COMETModel< T >::_dsfEqPtrES, COMETModel< T >::_dsfPtr, COMETModel< T >::_dsfPtr1, COMETModel< T >::_dsfPtr2, COMETModel< T >::_dsfPtrFAS, COMETModel< T >::_dsfPtrRes, COMETModel< T >::_faceReflectionArrayMap, COMETModel< T >::_geomFields, COMETModel< T >::_macroFields, Model::_meshes, COMETModel< T >::_options, COMETModel< T >::_quadrature, COMETModel< T >::_ZCells, COMETESBGKDiscretizer< T >::findResid(), COMETESBGKDiscretizer< T >::getAveResid(), COMETModel< T >::MakeParallel(), and COMETESBGKDiscretizer< T >::setfgFinder().

5079  {
5080  const int numMeshes=_meshes.size();
5081  T lowResid=-1.;
5082  T currentResid;
5083  for(int msh=0;msh<numMeshes;msh++)
5084  {
5085  const Mesh& mesh=*_meshes[msh];
5086  const BCcellArray& BCArray=*(_BCells[msh]);
5087  const BCfaceArray& BCfArray=*(_BFaces[msh]);
5088  const BCcellArray& ZCArray=*(_ZCells[msh]);
5091  _options["timeStep"],_options.timeDiscretizationOrder,
5092  _options.transient,_options.underRelaxation,_options["rho_init"],
5093  _options["T_init"],_options["molecularWeight"],_options.conOrder,
5094  _bcMap,_faceReflectionArrayMap,BCArray,BCfArray,ZCArray);
5095 
5096  CDisc.setfgFinder();
5097  const int numDir=_quadrature.getDirCount();
5098 
5099  MakeParallel();
5100 
5101  CDisc.findResid(addFAS);
5102  currentResid=CDisc.getAveResid();
5103 
5104  if(lowResid<0)
5105  lowResid=currentResid;
5106  else
5107  if(currentResid<lowResid)
5108  lowResid=currentResid;
5109  }
5110  return lowResid;
5111  }
Array< int > BCcellArray
GeomFields & _geomFields
DistFunctFields< T > _dsfPtr2
Quadrature< T > & _quadrature
Definition: Mesh.h:49
COMETModelOptions< T > _options
DistFunctFields< T > _dsfPtrFAS
map< int, vector< int > > _faceReflectionArrayMap
MacroFields & _macroFields
const MeshList _meshes
Definition: Model.h:29
DistFunctFields< T > _dsfEqPtrES
DistFunctFields< T > _dsfPtrRes
DistFunctFields< T > _dsfPtr
DistFunctFields< T > _dsfPtr1
Array< int > BCfaceArray
template<class T >
void COMETModel< T >::updateTime ( )
inline

Definition at line 2384 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfPtr, COMETModel< T >::_dsfPtr1, COMETModel< T >::_dsfPtr2, Model::_meshes, COMETModel< T >::_options, COMETModel< T >::_quadrature, and Mesh::getCells().

2385  {
2386  const int numMeshes = _meshes.size();
2387  for (int n=0;n<numMeshes;n++)
2388  {
2389  const Mesh& mesh = *_meshes[n];
2390 
2391  const StorageSite& cells = mesh.getCells();
2392  const int numFields= _quadrature.getDirCount();
2393  //callBoundaryConditions(); //new
2394  for (int direction = 0; direction < numFields; direction++)
2395  {
2396  Field& fnd = *_dsfPtr.dsf[direction];
2397  Field& fndN1 = *_dsfPtr1.dsf[direction];
2398  TArray& f = dynamic_cast<TArray&>(fnd[cells]);
2399  TArray& fN1 = dynamic_cast<TArray&>(fndN1[cells]);
2400  if (_options.timeDiscretizationOrder > 1)
2401  {
2402  Field& fndN2 = *_dsfPtr2.dsf[direction];
2403  TArray& fN2 = dynamic_cast<TArray&>(fndN2[cells]);
2404  fN2 = fN1;
2405  }
2406  fN1 = f;
2407  }
2408 #ifdef FVM_PARALLEL
2409  if ( MPI::COMM_WORLD.Get_rank() == 0 )
2410  {cout << "updated time" <<endl;}
2411 
2412 #endif
2413 #ifndef FVM_PARALLEL
2414  cout << "updated time" <<endl;
2415 #endif
2416  //ComputeMacroparameters(); //update macroparameters
2417  //ComputeCollisionfrequency();
2418  //if (_options.fgamma==0){initializeMaxwellianEq();}
2419  //else{ EquilibriumDistributionBGK();}
2420  //if (_options.fgamma==2){EquilibriumDistributionESBGK();}
2421 
2422  }
2423  }
DistFunctFields< T > _dsfPtr2
Quadrature< T > & _quadrature
Array< T > TArray
Definition: Field.h:14
Definition: Mesh.h:49
COMETModelOptions< T > _options
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
DistFunctFields< T > _dsfPtr
DistFunctFields< T > _dsfPtr1
template<class T >
void COMETModel< T >::updateTL ( )
inline

Definition at line 3252 of file phononbase/COMETModel.h.

References COMETModel< T >::_kspaces, COMETModel< T >::_macro, Model::_meshes, COMETModel< T >::_MeshKspaceMap, Kspace< T >::calcTauTot(), PhononMacro::e0, Mesh::getCells(), StorageSite::getCount(), Kspace< T >::NewtonSolve(), and PhononMacro::temperature.

3253  {
3254  const int numMeshes=_meshes.size();
3255  for(int n=0;n<numMeshes;n++)
3256  {
3257  const Mesh& mesh=*_meshes[n];
3258  Tkspace& kspace=*_kspaces[_MeshKspaceMap[n]];
3259  const StorageSite& cells = mesh.getCells();
3260  const int numcells = cells.getCount();
3261  const T tauTot=kspace.calcTauTot();
3262  TArray& TL=dynamic_cast<TArray&>(_macro.temperature[cells]);
3263  TArray& e0Array=dynamic_cast<TArray&>(_macro.e0[cells]);
3264 
3265  for(int c=0;c<numcells;c++)
3266  kspace.NewtonSolve(TL[c],e0Array[c]*tauTot);
3267  }
3268  }
Array< T > TArray
Field temperature
Definition: PhononMacro.h:21
Definition: Mesh.h:49
PhononMacro & _macro
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
MeshKspaceMap _MeshKspaceMap
int getCount() const
Definition: StorageSite.h:39
Kspace< T > Tkspace
template<class T >
void COMETModel< T >::weightedMaxwellian ( double  weight1,
double  uvel1,
double  vvel1,
double  wvel1,
double  uvel2,
double  vvel2,
double  wvel2,
double  temp1,
double  temp2 
)
inline

Definition at line 2174 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfPtr, COMETModel< T >::_dsfPtr1, COMETModel< T >::_dsfPtr2, Model::_meshes, COMETModel< T >::_options, COMETModel< T >::_quadrature, Mesh::getCells(), and StorageSite::getCount().

2175  {
2176  const int numMeshes = _meshes.size();
2177  for (int n=0; n<numMeshes; n++)
2178  {
2179  const Mesh& mesh = *_meshes[n];
2180  const StorageSite& cells = mesh.getCells();
2181  const int nCells = cells.getCount();
2182  //double pi(acos(-1.0));
2183  const double pi=_options.pi;
2184  const TArray& cx = dynamic_cast<const TArray&>(*_quadrature.cxPtr);
2185  const TArray& cy = dynamic_cast<const TArray&>(*_quadrature.cyPtr);
2186  const TArray& cz = dynamic_cast<const TArray&>(*_quadrature.czPtr);
2187  const int numFields= _quadrature.getDirCount();
2188 
2189  for(int j=0;j< numFields;j++){
2190  Field& fnd = *_dsfPtr.dsf[j];
2191  TArray& f = dynamic_cast< TArray&>(fnd[cells]);
2192  for(int c=0; c<nCells;c++){
2193  f[c]=weight1*1.0/pow((pi*1.0),1.5)*exp(-(pow((cx[j]-uvel1),2.0)+pow((cy[j]-vvel1),2.0)+pow((cz[j]-wvel1),2.0))/temp1)
2194  +(1-weight1)*1.0/pow((pi*1.0),1.5)*exp(-(pow((cx[j]-uvel2),2.0)+pow((cy[j]-vvel2),2.0)+pow((cz[j]-wvel2),2.0))/temp2);
2195  }
2196  if (_options.transient)
2197  {
2198  Field& fnd1 = *_dsfPtr1.dsf[j];
2199  TArray& f1 = dynamic_cast< TArray&>(fnd1[cells]);
2200  for (int c=0;c<nCells;c++)
2201  f1[c] = f[c];
2202  //cout << "discretization order " << _options.timeDiscretizationOrder << endl ;
2203  if (_options.timeDiscretizationOrder > 1)
2204  {
2205  Field& fnd2 = *_dsfPtr2.dsf[j];
2206  TArray& f2 = dynamic_cast< TArray&>(fnd2[cells]);
2207  for (int c=0;c<nCells;c++)
2208  f2[c] = f[c];
2209  }
2210  }
2211  }
2212  }
2213  }
DistFunctFields< T > _dsfPtr2
Quadrature< T > & _quadrature
Array< T > TArray
Definition: Field.h:14
Definition: Mesh.h:49
COMETModelOptions< T > _options
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
DistFunctFields< T > _dsfPtr
int getCount() const
Definition: StorageSite.h:39
DistFunctFields< T > _dsfPtr1
template<class T >
void COMETModel< T >::weightedMaxwellian ( double  weight1,
double  uvel1,
double  uvel2,
double  temp1,
double  temp2 
)
inline

Definition at line 2214 of file esbgkbase/COMETModel.h.

References COMETModel< T >::_dsfPtr, COMETModel< T >::_dsfPtr1, COMETModel< T >::_dsfPtr2, Model::_meshes, COMETModel< T >::_options, COMETModel< T >::_quadrature, Mesh::getCells(), and StorageSite::getCount().

2215  {
2216  const double vvel1=0.0;
2217  const double wvel1=0.0;
2218  const double vvel2=0.0;
2219  const double wvel2=0.0;
2220  const int numMeshes = _meshes.size();
2221  for (int n=0; n<numMeshes; n++)
2222  {
2223  const Mesh& mesh = *_meshes[n];
2224  const StorageSite& cells = mesh.getCells();
2225  const int nCells = cells.getCount();
2226  //double pi(acos(-1.0));
2227  const double pi=_options.pi;
2228  const TArray& cx = dynamic_cast<const TArray&>(*_quadrature.cxPtr);
2229  const TArray& cy = dynamic_cast<const TArray&>(*_quadrature.cyPtr);
2230  const TArray& cz = dynamic_cast<const TArray&>(*_quadrature.czPtr);
2231  const int numFields= _quadrature.getDirCount();
2232 
2233  for(int j=0;j< numFields;j++){
2234  Field& fnd = *_dsfPtr.dsf[j];
2235  TArray& f = dynamic_cast< TArray&>(fnd[cells]);
2236  for(int c=0; c<nCells;c++){
2237  f[c]=weight1*1.0/pow((pi*1.0),1.5)*exp(-(pow((cx[j]-uvel1),2.0)+pow((cy[j]-vvel1),2.0)+pow((cz[j]-wvel1),2.0))/temp1)
2238  +(1-weight1)*1.0/pow((pi*1.0),1.5)*exp(-(pow((cx[j]-uvel2),2.0)+pow((cy[j]-vvel2),2.0)+pow((cz[j]-wvel2),2.0))/temp2);
2239  }
2240  if (_options.transient)
2241  {
2242  Field& fnd1 = *_dsfPtr1.dsf[j];
2243  TArray& f1 = dynamic_cast< TArray&>(fnd1[cells]);
2244  for (int c=0;c<nCells;c++)
2245  f1[c] = f[c];
2246  //cout << "discretization order " << _options.timeDiscretizationOrder << endl ;
2247  if (_options.timeDiscretizationOrder > 1)
2248  {
2249  Field& fnd2 = *_dsfPtr2.dsf[j];
2250  TArray& f2 = dynamic_cast< TArray&>(fnd2[cells]);
2251  for (int c=0;c<nCells;c++)
2252  f2[c] = f[c];
2253  }
2254  }
2255  }
2256  }
2257  }
DistFunctFields< T > _dsfPtr2
Quadrature< T > & _quadrature
Array< T > TArray
Definition: Field.h:14
Definition: Mesh.h:49
COMETModelOptions< T > _options
const MeshList _meshes
Definition: Model.h:29
const StorageSite & getCells() const
Definition: Mesh.h:109
DistFunctFields< T > _dsfPtr
int getCount() const
Definition: StorageSite.h:39
DistFunctFields< T > _dsfPtr1

Member Data Documentation

template<class T >
MatrixMappersMap COMETModel< T >::_coarseGatherMaps
private
template<class T >
GeomFields COMETModel< T >::_coarseGeomFields
private
template<class T >
SizeMap COMETModel< T >::_coarseGhostSizes
private
template<class T >
MatrixMappersMap COMETModel< T >::_coarseScatterMaps
private
template<class T >
SizeMap COMETModel< T >::_coarseSizes
private
template<class T >
DistFunctFields<T> COMETModel< T >::_dsfPtrInj
private

Definition at line 5670 of file esbgkbase/COMETModel.h.

Referenced by COMETModel< T >::getdsfInj().

template<class T >
map<int, vector<int> > COMETModel< T >::_faceReflectionArrayMap
private
template<class T >
TCOMET * COMETModel< T >::_finerLevel
private
template<class T >
TCOMET * COMETModel< T >::_finestLevel
private

Definition at line 5661 of file esbgkbase/COMETModel.h.

Referenced by COMETModel< T >::setFinestLevel().

template<class T >
MacroFields& COMETModel< T >::_finestMacroFields
private
template<class T >
const int COMETModel< T >::_ibm
private

Definition at line 5657 of file esbgkbase/COMETModel.h.

Referenced by COMETModel< T >::init().

template<class T >
MFRPtr COMETModel< T >::_initialKmodelNorm
private
template<class T >
T COMETModel< T >::_initialResidual
private

Definition at line 5679 of file esbgkbase/COMETModel.h.

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

template<class T >
int COMETModel< T >::_niters
private
template<class T >
TCModOpts COMETModel< T >::_options
private

Definition at line 4271 of file phononbase/COMETModel.h.

template<class T >
map<string,shared_ptr<ArrayBase> > COMETModel< T >::_persistenceData
private
template<class T >
int COMETModel< T >::_rank
private

Definition at line 4278 of file phononbase/COMETModel.h.

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

template<class T >
T COMETModel< T >::_residual
private
template<class T >
GhostStorageSiteMap COMETModel< T >::_sharedSiteMap
private

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