00001
00002
00003
00004
00005
00006 #ifndef AMROC_PROBLEM_H
00007 #define AMROC_PROBLEM_H
00008
00009 #define DIM 3
00010
00011 #include "LBMProblem.h"
00012 #include "LBMD3Q19Thermal.h"
00013
00014 typedef double DataType;
00015 typedef LBMD3Q19Thermal<DataType> LBMType;
00016
00017 #define OWN_LBMSCHEME
00018 #define OWN_AMRSOLVER
00019 #include "LBMStdProblem.h"
00020 #include "AMRGFMSolver.h"
00021 #include "LBMGFMBoundary.h"
00022 #include "Interfaces/SchemeGFMFileOutput.h"
00023
00024 DataType rd, xs[DIM], TempS;
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 DataType Ra = gp*betap*deltaTp*std::pow(Hp,3)/viscp/Diffp;
00066
00067
00068 DataType GasCsp = base::LatticeSpeedOfSound();
00069
00070 base::SetGas(Gasp0,GasRho,viscp,GasCsp);
00071 base::SetThermalGas(TCp,THp,Diffp,gp,betap);
00072
00073
00074 std::cout << "D3Q19Thermal: Gas_rho=" << base::GasDensity() << " Gas_Cs=" << base::GasSpeedofSound()
00075 << " Gas_nu=" << base::GasViscosity() << " Gas_nut=" << base::GasViscosityT() << std::endl;
00076 std::cout << "\nControl Parameters : " << std::endl;
00077 std::cout << "Ra = " << Ra << " Pr = " << Pr << std::endl;
00078 std::cout << "\nTemperature : " << std::endl;
00079 std::cout << "TH = " << THp << " TC = " << TCp << std::endl;
00080 std::cout << "\nFluid values : " << std::endl;
00081 std::cout << "visc = " << viscp << " Diff = " << Diffp << " g = " << gp << " betap = " << betap << std::endl;
00082 std::cout << "\nGeometry : " << std::endl;
00083 std::cout << "Channel Width = " << Hp << std::endl;
00084 std::cout << "\nLattice Units : " << std::endl;
00085 std::cout << "(Amroc) Omega = " << base::Omega(base::TimeScale()) << " (Amroc) OmegaT = " << base::OmegaT(base::TimeScale()) << std::endl;
00086 std::cout << "(Amroc) Gas_nu = " << base::LatticeViscosity(base::Omega(base::TimeScale())) << " (Amroc) Gas_nuT = " << base::LatticeViscosityT(base::OmegaT(base::TimeScale())) << std::endl;
00087
00088
00089
00090 std::cout << "\nScaling Factors: " << std::endl;
00091 std::cout << "LengthScale = " << base::LengthScale() << std::endl;
00092 std::cout << "TimeScale = " << base::TimeScale() << std::endl;
00093 std::cout << "VelocityScale = " << base::VelocityScale() << std::endl;
00094 std::cout << "SpeedUp = " << base::SpeedUp() << std::endl;
00095
00096 }
00097
00098 protected:
00099 DataType Tmp, deltaTp, gp, betap, Diffp;
00100 DataType GasRho, Gasnu, Gasp0, Ra;
00101 };
00102
00103 class GFMBoundarySpecific : public LBMGFMBoundary<LBMType,DIM> {
00104 typedef LBMGFMBoundary<LBMType,DIM> base;
00105 public:
00106 GFMBoundarySpecific(LBMType &lbm) : base(lbm) {}
00107
00108 virtual void SetBndry(vec_grid_data_type& gdu, const int& nc, const int* idx,
00109 const MicroType* u, const point_type* xc, const DataType* distance,
00110 const point_type* normal, DataType* aux, const int naux, const double t)
00111 { LBM().GFMBCStandard(gdu,base::Type,nc,idx,u,xc,distance,normal,aux,naux,LBMType::Lattice); }
00112
00113 virtual void SetBndryAux(vec_grid_data_type& gdu, grid_data_type& gdphi,
00114 const MicroType* u, DataType* aux, const int& Level,
00115 double t, const int& nc, const int* idx,
00116 const point_type* xc, const DataType* distance,
00117 const point_type* normal) {
00118 DataType vc[3];
00119 vc[0] = 0.;
00120 vc[1] = 0.;
00121 vc[2] = 0.;
00122
00123 for (register int i=0; i<nc; i++) {
00124 aux[i*base::NAux()] = vc[0];
00125 aux[i*base::NAux()+1] = vc[1];
00126 aux[i*base::NAux()+2] = vc[2];
00127 aux[i*base::NAux()+3] = TempS;
00128 }
00129 }
00130 };
00131
00132
00133 class GFMLevelSetSpecific : public GFMLevelSet<DataType,DIM> {
00134 typedef GFMLevelSet<DataType,DIM> base;
00135
00136 public:
00137 typedef base::grid_fct_type grid_fct_type;
00138 typedef base::grid_data_type grid_data_type;
00139
00140 GFMLevelSetSpecific() {}
00141 virtual ~GFMLevelSetSpecific() {}
00142
00143 virtual void SetGrid(grid_data_type& gdphi, const int& Level, const double& t) {
00144 int Nx = gdphi.extents(0), Ny = gdphi.extents(1), Nz = gdphi.extents(2);
00145 DCoords lb = base::GH().worldCoords(gdphi.lower(), gdphi.stepsize());
00146 DCoords dx = base::GH().worldStep(gdphi.stepsize());
00147 DataType *phi = (DataType *)gdphi.databuffer();
00148
00149 DataType xsc[3];
00150 xsc[0] = xs[0]; xsc[1] = xs[1]; xsc[2] = xs[2];
00151 for (register int k=0; k<Nz; k++) {
00152 DataType zd = (DataType(k)+static_cast<DataType>(0.5))*dx(2) + lb(2) - xsc[2];
00153 for (register int j=0; j<Ny; j++) {
00154 DataType yd = (DataType(j)+static_cast<DataType>(0.5))*dx(1) + lb(1) - xsc[1];
00155 for (register int i=0; i<Nx; i++) {
00156 DataType xd = (DataType(i)+static_cast<DataType>(0.5))*dx(0) + lb(0) - xsc[0];
00157 phi[i+Nx*j+(Nx*Ny)*k] = std::sqrt(xd*xd+yd*yd+zd*zd) - rd;
00158 }
00159 }
00160 }
00161 }
00162 };
00163
00164
00165
00166
00167 class GhostFluidMethodSpecific : public GhostFluidMethod<MicroType,DIM> {
00168 typedef GhostFluidMethod<MicroType,DIM> base;
00169 public:
00170 GhostFluidMethodSpecific(boundary_type* boundary, levelset_type* levelset) :
00171 base(boundary,levelset) {
00172 xs[0]=0.; xs[1]=0.; xs[2]=0.; rd=0.; TempS=0.;
00173 }
00174
00175 virtual void register_at(ControlDevice& Ctrl, const std::string& prefix) {
00176 base::register_at(Ctrl,prefix);
00177 RegisterAt(base::LocCtrl,"Center(1)",xs[0]);
00178 RegisterAt(base::LocCtrl,"Center(2)",xs[1]);
00179 RegisterAt(base::LocCtrl,"Center(3)",xs[2]);
00180 RegisterAt(base::LocCtrl,"RadiusSphere",rd);
00181 RegisterAt(base::LocCtrl,"TemperatureSphere",TempS);
00182 }
00183 };
00184
00185
00186 class SolverSpecific :
00187 public AMRGFMSolver<MicroType,FixupType,FlagType,DIM> {
00188 typedef AMRGFMSolver<MicroType,FixupType,FlagType,DIM> base;
00189 public:
00190 SolverSpecific(IntegratorSpecific& integ,
00191 base::initial_condition_type& 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 AddGFM(new GhostFluidMethodSpecific(new GFMBoundarySpecific(integ.LBM()),
00198 new GFMLevelSetSpecific()));
00199 }
00200
00201 ~SolverSpecific() {
00202 DeleteGFM(_GFM[0]);
00203 delete _LevelTransfer;
00204 delete _Flagging;
00205 delete _Fixup;
00206 delete _FileOutput;
00207 }
00208
00209 virtual void SetupData() {
00210 base::SetupData();
00211 base::NAMRTimeSteps = 1;
00212 base::AdaptBndTimeInterpolate = 0;
00213 base::Step[0].LastTime = 1.e37;
00214 base::Step[0].VariableTimeStepping = -1;
00215 base::Step[0].dtv[0] = ((LBMIntegrator<LBMType,DIM> &)Integrator_()).LBM().TimeScale();
00216 }
00217 };
00218 #endif