Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

ParticleAMRNS.H

Go to the documentation of this file.
00001 /* _______              __
00002   / ___/ /  ___  __ _  / /  ___
00003  / /__/ _ \/ _ \/  ' \/ _ \/ _ \
00004  \___/_//_/\___/_/_/_/_.__/\___/ 
00005 */
00006 
00007 // ParticleAMRNS.H
00008 
00009 //
00010 // This software is copyright (C) by the Lawrence Berkeley
00011 // National Laboratory.  Permission is granted to reproduce
00012 // this software for non-commercial purposes provided that
00013 // this notice is left intact.
00014 // 
00015 // It is acknowledged that the U.S. Government has rights to
00016 // this software under Contract DE-AC03-765F00098 between
00017 // the U.S.  Department of Energy and the University of
00018 // California.
00019 //
00020 // This software is provided as a professional and academic
00021 // contribution for joint exchange. Thus it is experimental,
00022 // is provided ``as is'', with no warranties of any kind
00023 // whatsoever, no support, no promise of updates, or printed
00024 // documentation. By using this software, you acknowledge
00025 // that the Lawrence Berkeley National Laboratory and
00026 // Regents of the University of California shall have no
00027 // liability with respect to the infringement of other
00028 // copyrights by any part of this software.
00029 //
00030 // Dan Martin, Fri, Jan 14, 2000
00031 
00032 #ifndef _ParticleAMRNS_H_
00033 #define _ParticleAMRNS_H_
00034 
00035 #include "AMRLevel.H"
00036 #include "LevelFluxRegister.H"
00037 #include "CoarseAverage.H"
00038 #include "PiecewiseLinearFillPatch.H"
00039 #include "BinFab.H"
00040 #include "DragParticle.H"
00041 #include "ParticleProjector.H"
00042 #include "CCProjector.H"
00043 #include "LevelHelmholtzSolver.H"
00044 #include "PoissonOp.H"
00045 #include "VelocityPoissonOp.H"
00046 #include "PhysBCUtil.H"
00047 
00048 
00049 #ifdef NEW_ADVECTION
00050 #include "PatchAdvection.H"
00051 #include "PhysIBC.H"
00052 #endif
00053 
00054 
00056 enum viscousSolverTypes {
00058   backwardEuler = 0,
00060   CrankNicolson,
00062   TGA, 
00064   NUM_SOLVER_TYPES};
00065 
00066 
00067 
00069 enum scalTypes {
00071   xMarker = 0,
00073   yMarker,
00074 #if CH_SPACEDIM >= 3
00075 
00076   zMarker,
00077 #endif
00078 
00079   NUM_SCAL_TYPES};
00080 
00081 
00082 
00083 
00085 class ParticleAMRNS: public AMRLevel
00086 {
00087 public:
00088   
00090   ParticleAMRNS();
00091   
00093   ParticleAMRNS(AMRLevel* a_coarser_level_ptr, 
00094            const Box& a_prob_domain,
00095            int a_level, int a_ref_ratio);
00096 
00098   ParticleAMRNS(AMRLevel* a_coarser_level_ptr, 
00099            const ProblemDomain& a_prob_domain,
00100            int a_level, int a_ref_ratio);
00101 
00103   virtual ~ParticleAMRNS();
00104 
00105 
00107   virtual AMRLevel* makeAMRLevel(AMRLevel* a_coarser_level_ptr,
00108                                  const Box& a_problem_domain,
00109                                  int a_level, int a_ref_ratio) const;
00110 
00112   virtual AMRLevel* makeAMRLevel(AMRLevel* a_coarser_level_ptr,
00113                                  const ProblemDomain& a_problem_domain,
00114                                  int a_level, int a_ref_ratio) const;
00115 
00117   virtual void define(AMRLevel* a_coarse_level_ptr, 
00118                       const Box& a_problem_domain,
00119                       int a_level, int a_ref_ratio);
00120 
00122   virtual void define(AMRLevel* a_coarse_level_ptr, 
00123                       const ProblemDomain& a_problem_domain,
00124                       int a_level, int a_ref_ratio);
00125 
00127   virtual Real advance();
00128 
00130   virtual void postTimeStep();
00131 
00133   virtual void tagCells(IntVectSet& a_tags);
00134 
00136   virtual void tagCellsInit(IntVectSet& a_tags);
00137 
00139   virtual void regrid(const Vector<Box>& a_new_grids);
00140 
00141 
00142 
00144   virtual void postRegrid(int a_lBase);
00145 
00146 
00148   virtual void initialGrid(const Vector<Box>& a_new_grids);
00149 
00151   virtual void initialData();
00152 
00154   virtual void postInitialize();
00155 
00156 #ifdef HDF5
00157 
00158   virtual void writeCheckpointHeader(HDF5Handle& a_handle) const;
00159 
00161   virtual void writeCheckpointLevel(HDF5Handle& a_handle) const;
00162 
00164   virtual void readCheckpointHeader(HDF5Handle& a_handle);
00165 
00167   virtual void readCheckpointLevel(HDF5Handle& a_handle);
00168 
00170   virtual void writePlotHeader(HDF5Handle& a_handle) const;
00171 
00173   virtual void writePlotLevel(HDF5Handle& a_handle) const;
00174 
00176   virtual void writeParticleData(HDF5Handle& a_handle) const;  
00177 
00179   virtual int writeParticlesHDF5(HDF5Handle& a_handle,
00180                                  const List<DragParticle>& a_particles) const;
00181 #endif
00182 
00184   virtual Real computeDt();
00185 
00187   virtual Real computeInitialDt();
00188 
00190   virtual void CFL(Real a_cfl);
00191 
00193   virtual void particleCFL(Real a_particle_cfl);
00194 
00195 
00197   virtual void refinementThreshold(Real a_refine_threshold);
00198 
00200   void limitSolverCoarsening(bool a_limitSolverCoarsening);
00201 
00203   bool finestLevel() const;
00204   
00206   bool isEmpty() const;
00207   
00208   // compute vorticity
00209   void computeVorticity(LevelData<FArrayBox>& a_vorticity) const;
00210 
00211   // compute kinetic energy (only on interior cells)
00212   void computeKineticEnergy(LevelData<FArrayBox>& a_energy) const;
00213 
00214   // returns kinetic energy of all the particles in valid cells 
00215   Real particleKineticEnergy() const;
00216 
00217   // dumps ASCII list of particles
00218   void dumpParticlesASCII(std::ostream& os ) const;
00219 
00221 
00223   Real Dx() const;
00224   
00226   Real Nu() const;
00227 
00229   ParticleAMRNS* finerNSPtr() const;
00230 
00232   ParticleAMRNS* crseNSPtr() const;
00233 
00235   LevelData<FArrayBox>& newVel();
00236 
00238   const LevelData<FArrayBox>& newVel() const;
00239 
00241   LevelData<FArrayBox>& oldVel();
00242 
00244   const LevelData<FArrayBox>& oldVel() const;
00245 
00247   void velocity(LevelData<FArrayBox>& a_vel, Real a_time) const;
00248 
00250   LevelData<BinFab<DragParticle> >& particles();
00251 
00253   const LevelData<BinFab<DragParticle> >& particles() const;
00254 
00256   int numParticles() const;
00257 
00259   LevelData<FArrayBox>& newLambda();
00260 
00262   const LevelData<FArrayBox>& newLambda() const;
00263 
00265   LevelData<FArrayBox>& oldLambda();
00266 
00268   const LevelData<FArrayBox>& oldLambda() const;
00269 
00271   void lambda(LevelData<FArrayBox>& a_lambda, Real a_time) const;
00272   
00274   LevelData<FArrayBox>& newScal(const int a_comp);
00275 
00277   const LevelData<FArrayBox>& newScal(const int a_comp) const;
00278 
00280   LevelData<FArrayBox>& oldScal(const int a_comp);
00281 
00283   const LevelData<FArrayBox>& oldScal(const int a_comp) const;
00284 
00286   void scalars(LevelData<FArrayBox>& a_scalars, const Real a_time, 
00287                const int a_comp) const;
00288 
00289   
00291   void setPhysBC(const PhysBCUtil& a_BC);
00292 
00294   PhysBCUtil* getPhysBCPtr() const;
00295 
00296 
00297 protected:
00299   DisjointBoxLayout loadBalance(const Vector<Box>& a_grids);
00300 
00302   void levelSetup (const DisjointBoxLayout& level_domain);
00303 
00305 
00308   void defineParticles(List<DragParticle>& a_particles) const;
00309 
00311   void readParameters();
00312 
00314   void finestLevel(bool a_finest_level);
00315 
00317   void swapOldAndNewStates();
00318 
00320   void resetStates(const Real a_time);
00321 
00323   void computeAdvectionVelocities(LevelData<FluxBox>& a_adv_vel,
00324                                   LevelData<FArrayBox>& a_dragForce);
00325 
00326 
00327   /*@ManMemo: do predictor -- returns approx. to (U dot del)U.
00328     Also updates flux registers with momentum fluxes and
00329     part of viscous fluxes which contains the old-time velocity.
00330   */
00331   void predictVelocities(LevelData<FArrayBox>& a_uDelU,
00332                          LevelData<FluxBox>& a_advVel,
00333                          LevelData<FArrayBox>& a_dragForce);
00334 
00335   /*@ManMemo: This function computes uStar -- the approximation
00336     of the new-time velocity which will be projected.  The
00337     advection term (u-dot-del-U) is passed in in a_uStar, which 
00338     is modified in place to contain uStar. Note that both viscous
00339     and inviscid cases, this returns the approximation to 
00340     u^{n+1} + dt*gradPi.  a_dragForce is the old-time drag force
00341   */
00342   void computeUStar(LevelData<FArrayBox>& a_uStar,
00343                     LevelData<FArrayBox>& a_dragForce);
00344 
00345 
00347 
00356   void updateParticlePositions(LevelData<FArrayBox>& a_newDrag,
00357                                LevelData<BinFab<DragParticle> >& a_particles,
00358                                const LevelData<FArrayBox>& a_fluidVel,
00359                                bool a_completeUpdate);
00360 
00361 
00363   void updateParticleForces(LevelData<BinFab<DragParticle> >& a_particles);
00364 
00366   void interpVelToParticles(LevelData<BinFab<DragParticle> >& a_particles,
00367                             const LevelData<FArrayBox>& a_velocity);
00368   
00370   void advectScalar(LevelData<FArrayBox>& a_new_scal,
00371                     LevelData<FArrayBox>& a_old_scal,
00372                     LevelData<FluxBox>& a_adv_vel,
00373                     LevelFluxRegister* a_crseFluxRegPtr,
00374                     LevelFluxRegister& a_fineFluxReg,
00375 #ifdef NEW_ADVECTION
00376                     PhysIBC* a_scalIBC,
00377 #endif
00378                     Real a_dt);
00379 
00381   void advectDiffuseScalar(LevelData<FArrayBox>& a_new_scal,
00382                            LevelData<FArrayBox>& a_old_scal,
00383                            LevelData<FluxBox>& a_adv_vel,
00384                            const Real& a_diffusive_coeff,
00385                            const LevelData<FArrayBox>* a_crse_scal_old,
00386                            const LevelData<FArrayBox>* a_crse_scal_new,
00387                            const Real a_old_crse_time,
00388                            const Real a_new_crse_time,
00389                            LevelFluxRegister* a_crseFluxRegPtr,
00390                            LevelFluxRegister& a_fineFluxReg,
00391                            DomainGhostBC& a_scalPhysBC,
00392 #ifdef NEW_ADVECTION
00393                     PhysIBC* a_scalIBC,
00394 #endif
00395                            Real a_dt);
00396 
00398   void initializeGlobalPressure();
00399 
00401   void initializeLevelPressure(Real a_currentTime, Real a_dtInit);
00402 
00404   void smoothVelocityField(int lbase);
00405 
00407   void computeLapVel(LevelData<FArrayBox>& a_lapVel,
00408                      LevelData<FArrayBox>& a_vel,
00409                      const LevelData<FArrayBox>* a_crseVelPtr);
00410 
00412   void computeLapScal(LevelData<FArrayBox>& a_lapScal,
00413                       LevelData<FArrayBox>& a_scal,
00414                       DomainGhostBC& a_physBC,
00415                       const LevelData<FArrayBox>* a_crseScalPtr);
00416 
00418   void fillVelocity(LevelData<FArrayBox>& a_vel, Real a_time);
00419 
00421   void fillVelocity(LevelData<FArrayBox>& a_vel, Real a_time,  
00422                     int vel_comp, int dest_comp, int num_comp);
00423 
00426   void fillLambda(LevelData<FArrayBox>& a_lambda, Real a_time) const;
00427 
00429   void fillScalars(LevelData<FArrayBox>& a_scal, Real a_time,
00430                    const int a_comp) const;
00431 
00432 
00434   virtual int numPlotComps() const;
00435 
00437   virtual void getPlotData(LevelData<FArrayBox>& a_plot_data) const;
00438 
00440   void  defineRegridAMRSolver(AMRSolver& a_solver, 
00441                               const Vector<DisjointBoxLayout>& a_grids,
00442                               const Vector<ProblemDomain>& a_domains,
00443                               const Vector<Real>& a_amrDx,
00444                               const Vector<int>& a_refRatios,
00445                               const int& a_lBase);
00446   
00447 
00448 
00449 
00450 
00451 protected:
00453   LevelData<FArrayBox>* m_vel_old_ptr;
00454 
00456   LevelData<FArrayBox>* m_vel_new_ptr;
00457 
00458 #ifdef DEBUG
00459 
00460   LevelData<FArrayBox>* m_vel_save_ptr;  
00461 
00462   Real m_saved_time;
00463 
00464 #endif
00465 
00467   LevelData<BinFab<DragParticle> > m_particles;
00468 
00470   LevelData<FArrayBox>* m_lambda_old_ptr;
00471   
00473   LevelData<FArrayBox>* m_lambda_new_ptr;
00474 
00475 #ifdef DEBUG
00476 
00477   LevelData<FArrayBox>* m_lambda_save_ptr;  
00478 #endif
00479 
00481   Vector<LevelData<FArrayBox>*> m_scal_old;
00482   
00484   Vector<LevelData<FArrayBox>*> m_scal_new;
00485 
00486 #ifdef DEBUG
00487 
00488   Vector<LevelData<FArrayBox>*> m_scal_save;
00489 #endif
00490 
00492   static const int s_num_vel_comps = SpaceDim;
00493 
00495   static int s_num_scal_comps;
00496 
00498   static const int s_max_scal_comps=SpaceDim;
00499 
00501   static const char* s_vel_names[s_num_vel_comps];
00502 
00504   static const char* s_scal_names[s_max_scal_comps];
00505 
00507   static Vector<Real> s_scal_coeffs;
00508 
00510   static Vector<Real> s_domLength;
00511   
00513   static bool s_ppInit;
00514 
00516   static Real s_init_shrink;
00517 
00519   static Real s_max_dt;
00520 
00521   static Real s_prescribedDt;
00522 
00524   static bool s_project_initial_vel;
00525 
00527   static bool s_initialize_pressures;
00528 
00530   static bool s_smooth_after_regrid;
00531 
00533   static bool s_dump_smoothing_plots;
00534 
00536   static Real s_regrid_smoothing_coeff;
00537 
00539   static int s_num_init_passes;
00540 
00542   static bool s_reflux_momentum;
00543 
00545   static bool s_reflux_normal_momentum;
00546 
00548   static bool s_set_bogus_values;
00549 
00551   static Real s_bogus_value;
00552 
00554   static bool s_tag_vorticity;
00555 
00557   static Real s_vort_factor;
00558 
00560   static int s_tags_grow;
00561 
00563   static bool s_implicit_reflux;
00564 
00566   static bool s_applyFreestreamCorrection;
00567 
00569   static bool s_reflux_scal;
00570 
00572   static bool s_implicit_scal_reflux;
00573 
00575   static int s_viscous_solver_type;
00576 
00578   static Real s_viscous_solver_tol;
00579   
00581   static int s_viscous_num_smooth_up;
00582 
00584   static int s_viscous_num_smooth_down;
00585 
00587   static Real s_nu;
00588 
00590   static bool s_do_particles;
00591 
00593   static bool s_read_particles_from_file;
00594 
00596   static string s_particle_file;
00597 
00599   static Real s_particle_drag_coeff;
00600 
00602   static RealVect s_particle_body_force;
00603 
00605   static Real s_delta_epsilon;
00606 
00608   static bool s_use_image_particles;
00609 
00611   static int s_order_vel_interp;
00612 
00614   static bool s_specifyInitialGrids;
00615 
00617   static string s_initialGridFile;
00618 
00620   static bool s_init_vel_from_vorticity;
00621   
00623   static Real s_backgroundVel;
00624 
00626 
00628   static bool s_write_particles;
00629   
00631   static bool s_write_divergence;
00632 
00634   static bool s_write_lambda;
00635 
00637   static bool s_write_time_derivatives;
00638 
00640   static bool s_write_vorticity;
00641 
00643   static bool s_write_scalars;
00644 
00646   static bool s_write_dScalar_dt;
00647 
00649   static bool s_write_strains;
00650 
00652   static bool s_write_grad_eLambda;  
00653 
00655   static bool s_write_error;
00656 
00658   //static bool s_write_curl_error;
00659 
00661   static bool s_write_proc_ids;
00662 
00664   static bool s_compute_scal_err;
00665 
00667   static bool s_write_initial_solve_rhs;
00668 
00670   static bool s_write_grids;
00671 
00672 
00674   Vector<Tuple<Real, SpaceDim> > m_dataPoints;
00675 
00677   Real m_dx;
00678 
00680   Real m_cfl;
00681 
00683   Real m_particleCFL;
00684 
00686   bool m_limitSolverCoarsening;
00687 
00688 
00690   Real m_dt_save;
00691 
00693   int m_level_steps;
00694 
00696   CoarseAverage m_coarse_average;
00697 
00699   CoarseAverage m_coarse_average_lambda;
00700 
00701 #if 0
00702 
00703   CoarseAverage m_coarse_average_scal;
00704 #endif
00705 
00707   CCProjector m_projection;
00708   
00710   ParticleProjector m_particle_projector;
00711 
00713   LevelFluxRegister m_flux_register;
00714 
00716   LevelFluxRegister m_lambda_flux_reg;
00717 
00719   Vector<LevelFluxRegister*> m_scal_fluxreg_ptrs;
00720 
00722   QuadCFInterp m_velCFInterp; 
00723 
00725   VelocityPoissonOp m_velocityPoissonOp;
00726 
00728   PoissonOp m_scalarsPoissonOp;
00729 
00731   LevelHelmholtzSolver m_viscous_solver;
00732 
00733 #ifdef NEW_ADVECTION
00734   PatchAdvection m_patchGod;
00735 #endif
00736 
00738   Real m_refine_threshold;
00739 
00741   bool m_finest_level;
00742 
00744   bool m_is_empty;
00745 
00747   bool m_regrid_smoothing_done;
00748 
00750   PhysBCUtil* m_physBCPtr;
00751 
00752 
00753 
00754 };
00755 
00756 #endif
00757 
00758 

Generated on Wed Jun 2 13:53:34 2004 for Chombo&INSwithParticles by doxygen 1.3.2