00001
00002
00003
00004
00005
00006
00007 #ifndef AMROC_PROBLEM_H
00008 #define AMROC_PROBLEM_H
00009
00010 #define DIM 3
00011
00012 #include "LBMProblem.h"
00013 #include "LBMD3Q19Thermal.h"
00014
00015 typedef double DataType;
00016 typedef LBMD3Q19Thermal<DataType> LBMType;
00017
00018 #define OWN_LBMSCHEME
00019 #define OWN_AMRSOLVER
00020
00021 #include "LBMStdProblem.h"
00022 #include "AMRGFMSolver.h"
00023 #include "AMRGFMInterpolation.h"
00024 #include "Interfaces/SchemeGFMFileOutput.h"
00025
00026
00027 class LBMSpecific : public LBMType {
00028 typedef LBMType base;
00029 public:
00030 LBMSpecific() : base(), Tmp(1.), deltaTp(1.), gp(1.), betap(1.), Diffp(1.),GasRho(1.), Gasnu(1.), Gasp0(1.) {}
00031
00032 virtual void register_at(ControlDevice& Ctrl, const std::string& prefix) {
00033 base::register_at(Ctrl,prefix);
00034 RegisterAt(base::LocCtrl,"Tm",Tmp);
00035 RegisterAt(base::LocCtrl,"deltaT",deltaTp);
00036 RegisterAt(base::LocCtrl,"g",gp);
00037 RegisterAt(base::LocCtrl,"beta",betap);
00038 RegisterAt(base::LocCtrl,"Diff",Diffp);
00039 RegisterAt(base::LocCtrl,"Gas_rho",GasRho);
00040 RegisterAt(base::LocCtrl,"Gas_nu",Gasnu);
00041 RegisterAt(base::LocCtrl,"Gas_p0",Gasp0);
00042 }
00043
00044
00045 virtual void SetupData(GridHierarchy* gh, const int& ghosts) {
00046 base::SetupData(gh,ghosts);
00047
00048 BBox wb = base::GH().wholebbox();
00049 DCoords lc = base::GH().worldCoords(wb.lower(),wb.stepsize());
00050 DCoords uc = base::GH().worldCoords(wb.upper()+wb.stepsize(),wb.stepsize());
00051
00052
00053 DataType Hp=uc(1)-lc(1);
00054
00055 DataType Speed = base::SpeedUp();
00056
00057 DataType viscp = Gasnu;
00058 DataType Pr = viscp/Diffp;
00059
00060 DataType tScale = base::TimeScale();
00061 DataType lScale = base::LengthScale();
00062 DataType THp = Tmp+deltaTp/DataType(2.);
00063 DataType TCp = Tmp-deltaTp/DataType(2.);
00064
00065
00066 DataType GasCsp = base::LatticeSpeedOfSound();
00067
00068 base::SetGas(Gasp0,GasRho,viscp,GasCsp);
00069 base::SetThermalGas(TCp,THp,Diffp,gp,betap);
00070
00071
00072 std::cout << "D3Q19Thermal: Gas_rho=" << base::GasDensity() << " Gas_Cs=" << base::GasSpeedofSound()
00073 << " Gas_nu=" << base::GasViscosity() << " Gas_nut=" << base::GasViscosityT() << std::endl;
00074 std::cout << "\nControl Parameters : " << std::endl;
00075 std::cout << "Pr = " << Pr << std::endl;
00076 std::cout << "\nTemperature : " << std::endl;
00077 std::cout << "TH = " << THp << " TC = " << TCp << std::endl;
00078 std::cout << "\nFluid values : " << std::endl;
00079 std::cout << "viscp = " << viscp << " Diffp = " << Diffp << " gp = " << gp << " betap = " << betap << std::endl;
00080 std::cout << "\nGeometry : " << std::endl;
00081 std::cout << "Channel Width = " << Hp << std::endl;
00082 std::cout << "\nLattice Units : " << std::endl;
00083 std::cout << "(Amroc) Omega = " << base::Omega(base::TimeScale()) << " (Amroc) OmegaT = " << base::OmegaT(base::TimeScale()) << std::endl;
00084 std::cout << "(Amroc) Gas_nu = " << base::LatticeViscosity(base::Omega(base::TimeScale())) << " (Amroc) Gas_nuT = " << base::LatticeViscosityT(base::OmegaT(base::TimeScale())) << std::endl;
00085
00086
00087
00088 std::cout << "\nScaling Factors: " << std::endl;
00089 std::cout << "LengthScale = " << base::LengthScale() << std::endl;
00090 std::cout << "TimeScale = " << base::TimeScale() << std::endl;
00091 std::cout << "VelocityScale = " << base::VelocityScale() << std::endl;
00092 std::cout << "SpeedUp = " << base::SpeedUp() << std::endl;
00093
00094 }
00095
00096 protected:
00097 DataType Tmp, deltaTp, gp, betap, Diffp;
00098 DataType GasRho, Gasnu, Gasp0;
00099 };
00100
00101
00102 class LBMExactSolutionSpecific : public LBMExactSolution<LBMType,DIM> {
00103 typedef LBMExactSolution<LBMType,DIM> base;
00104 typedef AMRGFMSolver<MicroType,FixupType,FlagType,DIM> solver_type;
00105 public:
00106 typedef base::vec_grid_fct_type vec_grid_fct_type;
00107 typedef base::vec_grid_data_type vec_grid_data_type;
00108 typedef LBMType::MicroType MicroType;
00109 typedef LBMType::MacroType MacroType;
00110
00111 LBMExactSolutionSpecific(LBMType &lbm) : base(lbm) {
00112
00113 u0=0., TH0=0., TC0=0.;
00114
00115 }
00116
00117 virtual void register_at(ControlDevice& Ctrl, const std::string& prefix) {
00118 base::register_at(Ctrl,prefix);
00119 RegisterAt(base::LocCtrl,"u0",u0);
00120 RegisterAt(base::LocCtrl,"TC0",TC0);
00121 RegisterAt(base::LocCtrl,"TH0",TH0);
00122 }
00123
00124 virtual void SetGrid(vec_grid_data_type& fvec, grid_data_type& workvec, const int& level, const double& t) {
00125
00126 int Nx = fvec.extents(0), Ny = fvec.extents(1), Nz = fvec.extents(2);
00127 int mxs = base::NGhosts(), mys = base::NGhosts(), mzs = base::NGhosts();
00128 int mxe = Nx-base::NGhosts()-1, mye = Ny-base::NGhosts()-1, mze = Nz-base::NGhosts()-1;
00129
00130
00131 MicroType *f = (base::MicroType *)fvec.databuffer();
00132
00133
00134
00135
00136
00137 DCoords lbcorner = base::GH().worldCoords(fvec.lower(), fvec.stepsize());
00138 DCoords dx = base::GH().worldStep(fvec.stepsize());
00139
00140 BBox wb = base::GH().wholebbox();
00141 DCoords lc = base::GH().worldCoords(wb.lower(),wb.stepsize());
00142 DCoords uc = base::GH().worldCoords(wb.upper()+wb.stepsize(),wb.stepsize());
00143
00144 DataType L0 = uc(1)-lc(1);
00145
00146 for (register int j=mys; j<=mye; j++){
00147 for (register int i=mxs; i<=mxe; i++){
00148 for (register int k=mzs; k<=mze; k++){
00149
00150
00151 double xc = (i+0.5)*dx(0)+lbcorner(0);
00152 double yc = (j+0.5)*dx(1)+lbcorner(1);
00153 double zc = (k+0.5)*dx(2)+lbcorner(2);
00154
00155
00156
00157
00158 MacroType q = LBM().MacroVariables(f[LBM().idx(i,j,k,Nx,Ny)]);
00159 MacroType qr = q;
00160
00161
00162 qr(1) = u0*yc/L0;
00163 qr(4) = (TC0-TH0)*(yc/L0)+TH0;
00164
00165
00166 for (register int l=0; l<LBM().NMacroVar(); l++)
00167 f[LBM().idx(i,j,k,Nx,Ny)](l) += std::abs(q(l)-qr(l));
00168 }
00169 }
00170 }
00171
00172 }
00173
00174 inline LBMType& LBM() { return base::Scheme(); }
00175 inline const LBMType& LBM() const { return base::Scheme(); }
00176
00177 protected:
00178 double u0,TH0,TC0;
00179 };
00180
00181
00182 class SolverSpecific :
00183 public AMRGFMSolver<MicroType,FixupType,FlagType,DIM> {
00184 typedef AMRGFMSolver<MicroType,FixupType,FlagType,DIM> base;
00185 typedef AMRGFMInterpolation<MicroType,FixupType,FlagType,DIM> interpolation_type;
00186 typedef MicroType::InternalDataType DataType;
00187 typedef SchemeGFMFileOutput<LBMType,FixupType,FlagType,DIM> output_type;
00188 typedef interpolation_type::point_type point_type;
00189 public:
00190 SolverSpecific(IntegratorSpecific& integ,
00191 InitialConditionSpecific& init,
00192 base::boundary_conditions_type& bc) : base(integ, init, bc) {
00193 SetLevelTransfer(new LBMF77LevelTransfer<LBMType,DIM>(integ.Scheme(), f_prolong, f_restrict));
00194 SetFileOutput(new SchemeGFMFileOutput<LBMType,FixupType,FlagType,DIM>(*this,integ.Scheme()));
00195 SetFixup(new FixupSpecific(integ.Scheme()));
00196 SetFlagging(new FlaggingSpecific(*this,integ.Scheme()));
00197 _Interpolation = new interpolation_type(*this);
00198 SetExactSolution(new LBMExactSolutionSpecific(integ.Scheme()));
00199
00200
00201
00202 }
00203
00204 ~SolverSpecific() {
00205 DeleteGFM(_GFM[0]);
00206 delete _LevelTransfer;
00207 delete _Flagging;
00208 delete _Fixup;
00209 delete _FileOutput;
00210 delete _Interpolation;
00211 delete _ExactSolution;
00212 }
00213
00214 virtual void SetupData() {
00215 base::SetupData();
00216 base::NAMRTimeSteps = 1;
00217 base::AdaptBndTimeInterpolate = 0;
00218 base::Step[0].LastTime = 1.e37;
00219 base::Step[0].VariableTimeStepping = -1;
00220 base::Step[0].dtv[0] = ((LBMIntegrator<LBMType,DIM> &)Integrator_()).LBM().TimeScale();
00221 _Interpolation->SetupData(base::PGH(), base::NGhosts());
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237 }
00238
00239 virtual void register_at(ControlDevice& Ctrl, const std::string& prefix) {
00240 base::register_at(Ctrl,prefix);
00241
00242
00243
00244 }
00245 virtual void register_at(ControlDevice& Ctrl) {
00246 base::register_at(Ctrl);
00247 }
00248
00249
00250 protected:
00251
00252 interpolation_type* _Interpolation;
00253
00254 };
00255
00256 #endif