00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef AMROC_PROBLEM_H
00012 #define AMROC_PROBLEM_H
00013
00014 #define DIM 2
00015
00016 #include "LBMProblem.h"
00017 #include "LBMD2Q9Thermal.h"
00018
00019 typedef double DataType;
00020 typedef LBMD2Q9Thermal<DataType> LBMType;
00021
00022 #define OWN_LBMSCHEME
00023 #define OWN_AMRSOLVER
00024 #include "LBMStdProblem.h"
00025 #include "AMRGFMSolver.h"
00026 #include "LBMGFMBoundary.h"
00027 #include "Interfaces/SchemeGFMFileOutput.h"
00028
00029 DataType p0 = 1.;
00030 DataType rd, xs[2], rs, T, Tr,TempS;
00031 DataType pi=4.0*std::atan(1.0);
00032
00033 class LBMSpecific : public LBMType {
00034 typedef LBMType base;
00035 public:
00036 LBMSpecific() : base(), Tmp(1.), deltaTp(1.), gp(1.), betap(1.), Diffp(1.),GasRho(1.), Gasnu(1.), Gasp0(1.), Ra(1.) {}
00037
00038 virtual void register_at(ControlDevice& Ctrl, const std::string& prefix) {
00039 base::register_at(Ctrl,prefix);
00040 RegisterAt(base::LocCtrl,"Tm",Tmp);
00041 RegisterAt(base::LocCtrl,"deltaT",deltaTp);
00042 RegisterAt(base::LocCtrl,"g",gp);
00043 RegisterAt(base::LocCtrl,"beta",betap);
00044 RegisterAt(base::LocCtrl,"Diff",Diffp);
00045 RegisterAt(base::LocCtrl,"Gas_rho",GasRho);
00046 RegisterAt(base::LocCtrl,"Gas_nu",Gasnu);
00047 RegisterAt(base::LocCtrl,"Gas_p0",Gasp0);
00048 RegisterAt(base::LocCtrl,"Ra",Ra);
00049 }
00050
00051 virtual void SetupData(GridHierarchy* gh, const int& ghosts) {
00052 base::SetupData(gh,ghosts);
00053
00054 BBox wb = base::GH().wholebbox();
00055 DCoords lc = base::GH().worldCoords(wb.lower(),wb.stepsize());
00056 DCoords uc = base::GH().worldCoords(wb.upper()+wb.stepsize(),wb.stepsize());
00057
00058
00059
00060 DataType Hp=uc(1)-lc(1);
00061
00062 DataType Speed = base::SpeedUp();
00063
00064 DataType viscp = Gasnu;
00065 DataType Pr = viscp/Diffp;
00066
00067 DataType tScale = base::TimeScale();
00068 DataType lScale = base::LengthScale();
00069 DataType THp = Tmp+deltaTp/DataType(2.);
00070 DataType TCp = Tmp-deltaTp/DataType(2.);
00071
00072
00073
00074
00075 DataType GasCsp = base::LatticeSpeedOfSound();
00076
00077 base::SetGas(Gasp0,GasRho,viscp,GasCsp);
00078
00079 base::SetThermalGas(TCp,THp,Diffp,gp,betap);
00080
00081 std::cout << "D2Q19Thermal: Gas_rho=" << base::GasDensity() << " Gas_Cs=" << base::GasSpeedofSound()
00082 << " Gas_nu=" << base::GasViscosity() << " Gas_nut=" << base::GasViscosityT() << std::endl;
00083 std::cout << "\nControl Parameters : " << std::endl;
00084 std::cout << "Ra = " << Ra << " Pr = " << Pr << std::endl;
00085 std::cout << "\nTemperature : " << std::endl;
00086 std::cout << "TH = " << THp << " TC = " << TCp << std::endl;
00087 std::cout << "\nFluid values : " << std::endl;
00088 std::cout << "visc = " << viscp << " Diff = " << Diffp << " g = " << gp << " betap = " << betap << std::endl;
00089 std::cout << "\nGeometry : " << std::endl;
00090 std::cout << "Channel Width = " << Hp << std::endl;
00091 std::cout << "\nLattice Units : " << std::endl;
00092 std::cout << "(Amroc) Omega = " << base::Omega(base::TimeScale()) << " (Amroc) OmegaT = " << base::OmegaT(base::TimeScale()) << std::endl;
00093 std::cout << "(Amroc) Lattice_nu = " << base::LatticeViscosity(base::Omega(base::TimeScale())) << " (Amroc) Lattice_nuT = " << base::LatticeViscosityT(base::OmegaT(base::TimeScale())) << std::endl;
00094 std::cout << "(Amroc) gbeta = " << base::gbeta << std::endl;
00095
00096
00097
00098 std::cout << "\nScaling Factors: " << std::endl;
00099 std::cout << "LengthScale = " << base::LengthScale() << std::endl;
00100 std::cout << "TimeScale = " << base::TimeScale() << std::endl;
00101 std::cout << "VelocityScale = " << base::VelocityScale() << std::endl;
00102 std::cout << "SpeedUp = " << base::SpeedUp() << std::endl;
00103
00104 }
00105
00106
00107 protected:
00108 DataType Tmp, deltaTp, gp, betap, Diffp;
00109 DataType GasRho, Gasnu, Gasp0, Ra;
00110 };
00111
00112 class GFMBoundarySpecific : public LBMGFMBoundary<LBMType,DIM> {
00113 typedef LBMGFMBoundary<LBMType,DIM> base;
00114 public:
00115 GFMBoundarySpecific(LBMType &lbm) : base(lbm) {}
00116
00117 virtual void SetBndry(vec_grid_data_type& gdu, const int& nc, const int* idx,
00118 const MicroType* u, const point_type* xc, const DataType* distance,
00119 const point_type* normal, DataType* aux, const int naux, const double t)
00120 { LBM().GFMBCStandard(gdu,base::Type,nc,idx,u,xc,distance,normal,aux,naux,LBMType::Lattice); }
00121
00122 virtual void SetBndryAux(vec_grid_data_type& gdu, grid_data_type& gdphi,
00123 const MicroType* u, DataType* aux, const int& Level,
00124 double t, const int& nc, const int* idx,
00125 const point_type* xc, const DataType* distance,
00126 const point_type* normal) {
00127 DataType vc[2];
00128 vc[0] = 0.;
00129 vc[1] = 0.;
00130
00131 for (register int i=0; i<nc; i++) {
00132 aux[i*base::NAux()] = vc[0];
00133 aux[i*base::NAux()+1] = vc[1];
00134 aux[i*base::NAux()+2] = TempS;
00135 }
00136 }
00137 };
00138
00139
00140 class GFMLevelSetSpecific : public GFMLevelSet<DataType,DIM> {
00141 typedef GFMLevelSet<DataType,DIM> base;
00142
00143 public:
00144 typedef base::grid_fct_type grid_fct_type;
00145 typedef base::grid_data_type grid_data_type;
00146
00147 GFMLevelSetSpecific() {}
00148 virtual ~GFMLevelSetSpecific() {}
00149
00150 virtual void SetGrid(grid_data_type& gdphi, const int& Level, const double& t) {
00151 int Nx = gdphi.extents(0), Ny = gdphi.extents(1);
00152 DCoords lb = base::GH().worldCoords(gdphi.lower(), gdphi.stepsize());
00153 DCoords dx = base::GH().worldStep(gdphi.stepsize());
00154 DataType *phi = (DataType *)gdphi.databuffer();
00155
00156 DataType xsc[2];
00157 xsc[0] = xs[0]; xsc[1] = xs[1];
00158
00159 for (register int j=0; j<Ny; j++) {
00160 DataType yd = (DataType(j)+static_cast<DataType>(0.5))*dx(1) + lb(1) - xsc[1];
00161 for (register int i=0; i<Nx; i++) {
00162 DataType xd = (DataType(i)+static_cast<DataType>(0.5))*dx(0) + lb(0) - xsc[0];
00163 phi[i+Nx*j] = std::sqrt(xd*xd+yd*yd) - rd;
00164 }
00165 }
00166 }
00167 };
00168
00169
00170 class GhostFluidMethodSpecific : public GhostFluidMethod<MicroType,DIM> {
00171 typedef GhostFluidMethod<MicroType,DIM> base;
00172 public:
00173 GhostFluidMethodSpecific(boundary_type* boundary, levelset_type* levelset) :
00174 base(boundary,levelset) {
00175 xs[0]=0.; xs[1]=0.; rd=1.; TempS=0.;
00176 }
00177
00178 virtual void register_at(ControlDevice& Ctrl, const std::string& prefix) {
00179 base::register_at(Ctrl,prefix);
00180 RegisterAt(base::LocCtrl,"Center(1)",xs[0]);
00181 RegisterAt(base::LocCtrl,"Center(2)",xs[1]);
00182 RegisterAt(base::LocCtrl,"RadiusSphere",rd);
00183 RegisterAt(base::LocCtrl,"TemperatureSphere",TempS);
00184 }
00185 };
00186
00187
00188 class SolverSpecific :
00189 public AMRGFMSolver<MicroType,FixupType,FlagType,DIM> {
00190 typedef AMRGFMSolver<MicroType,FixupType,FlagType,DIM> base;
00191 public:
00192 SolverSpecific(IntegratorSpecific& integ,
00193 base::initial_condition_type& init,
00194 base::boundary_conditions_type& bc) : base(integ, init, bc) {
00195 SetLevelTransfer(new LBMF77LevelTransfer<LBMType,DIM>(integ.Scheme(), f_prolong, f_restrict));
00196 SetFileOutput(new SchemeGFMFileOutput<LBMType,FixupType,FlagType,DIM>(*this,integ.Scheme()));
00197 SetFixup(new FixupSpecific(integ.Scheme()));
00198 SetFlagging(new FlaggingSpecific(*this,integ.Scheme()));
00199 AddGFM(new GhostFluidMethodSpecific(new GFMBoundarySpecific(integ.LBM()),
00200 new GFMLevelSetSpecific()));
00201 }
00202
00203 ~SolverSpecific() {
00204 DeleteGFM(_GFM[0]);
00205 delete _LevelTransfer;
00206 delete _Flagging;
00207 delete _Fixup;
00208 delete _FileOutput;
00209 }
00210
00211 virtual void SetupData() {
00212 base::SetupData();
00213 base::NAMRTimeSteps = 1;
00214 base::AdaptBndTimeInterpolate = 0;
00215 base::Step[0].LastTime = 1.e37;
00216 base::Step[0].VariableTimeStepping = -1;
00217 base::Step[0].dtv[0] = ((LBMIntegrator<LBMType,DIM> &)Integrator_()).LBM().TimeScale();
00218 }
00219 };