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

PAmrNS.H

Go to the documentation of this file.
00001 /* _______              __
00002   / ___/ /  ___  __ _  / /  ___
00003  / /__/ _ \/ _ \/  ' \/ _ \/ _ \
00004  \___/_//_/\___/_/_/_/_.__/\___/ 
00005 */
00006 
00007 // PAmrNS.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, Sept 13, 2004
00031 
00032 #ifndef _PAmrNS_H_
00033 #define _PAmrNS_H_
00034 
00035 #include "AMRLevel.H"
00036 #include "CoarseAverage.H"
00037 #include "PiecewiseLinearFillPatch.H"
00038 #include "BinFab.H"
00039 #include "DragParticle.H"
00040 #include "AMRParticleProjector.H"
00041 #include "AmrProjector.H"
00042 #include "PoissonOp.H"
00043 #include "VelocityPoissonOp.H"
00044 #include "PhysBCUtil.H"
00045 
00046 
00047 #include "PatchAdvection.H"
00048 #include "OldPhysIBC.H"
00049 
00050 #define ADVECT_GROW 4
00051 
00052 #ifdef CH_USE_DOUBLE
00053 #define TIME_EPS 1.0e-10
00054 #else
00055 #define TIME_EPS 1.0e-5
00056 #endif
00057 
00058 // small parameter used in defining TGA constants for viscous solves
00059 #define TGA_EPS 1.0e-8
00060 
00061 
00063 enum viscousSolverTypes {
00065   backwardEuler = 0,
00067   CrankNicolson,
00069   TGA, 
00071   NUM_SOLVER_TYPES};
00072 
00073 
00075 enum particleUpdateTypes {
00077   predictorCorrector = 0,
00079   forwardEuler,
00081   betterPredictorCorrector,
00083   betterForwardEuler, 
00085   NUM_UPDATE_TYPES};
00086 
00087 
00089 enum scalTypes {
00091   xMarker = 0,
00093   yMarker,
00094 #if CH_SPACEDIM >= 3
00095 
00096   zMarker,
00097 #endif
00098 
00099   NUM_SCAL_TYPES};
00100 
00101 
00102 // number to use to compare real numbers
00103 #define REALSMALL 1.0e-10
00104 
00105 
00107 
00112 class PAmrNS
00113 {
00114 public:
00115   
00117   PAmrNS();
00118   
00120 
00122   PAmrNS(const ProblemDomain& a_vectDomain,
00123          const Vector<int>& a_vectRefRatio,
00124          const RealVect& a_domainLength,
00125          int a_maxLevel);
00126 
00127 
00129   ~PAmrNS();
00130 
00131   
00132 
00134   void define(const ProblemDomain& a_baseDomain,
00135               const Vector<int>& a_vectRefRatio,
00136               const RealVect& a_domainLength, 
00137               int a_maxLevel);
00138          
00140   void setupForFixedHierarchyRun(Vector<Vector<Box> >& a_vectBoxes);
00141 
00143   void setupForAmrRun();
00144 
00146   void setupForRestart(const string& a_restartFile);
00147 
00149   void setupForRestart(const HDF5Handle& a_restartFile);
00150 
00152   Real doRun(Real a_maxTime, int a_maxStep);
00153 
00155   void conclude();
00156 
00157 #ifdef HDF5
00158 
00159   int writeCheckpointFile();
00160   
00162   int writeCheckpointFile(const string& a_fname);
00163 
00165   int writeCheckpointFileHDF5(HDF5Handle& a_handle);
00166   
00168   int readCheckpointFile(const string& a_fname);
00169 
00171   int readCheckpointFile(HDF5Handle& a_handle);
00172 
00174   int writePlotFile();
00175 
00177   int writePlotFileName(const string& a_fname);
00178 
00180   int writePlotFileHDF5(HDF5Handle& a_handle);
00181 #endif
00182 
00184 
00186   void checkpointInterval(int a_checkpointInterval);
00187   
00189   void plotInterval(int a_plotInterval);
00190 
00192   void checkpointPrefix(const string& a_prefix);
00193 
00195   void plotPrefix(const string& a_prefix);
00196   
00198   void maxGridSize(int a_maxGridSize);
00199 
00201   void maxBaseGridSize(int a_maxBaseGridSize);
00202 
00204   void fillRatio(Real a_fillRatio);
00205 
00207   void blockFactor(int a_blockFactor);
00208 
00210   void regridInterval(int a_regridInterval);
00211 
00213   void maxDtGrow(Real& a_maxDtGrow);
00214 
00216   void fixedDt(Real a_dt); 
00217     
00219   void CFL(Real a_cfl);
00220   
00222   void particleCFL(Real a_particle_cfl);
00223   
00224   
00226   void refinementThreshold(Real a_refine_threshold);
00227   
00229   void limitSolverCoarsening(bool a_limitSolverCoarsening);
00230 
00232   void verbosity(int a_verbosity); 
00233 
00234   
00236   
00238   int finestLevel() const {return m_finestLevel;};
00239   
00241   int maxLevel() const {return m_maxLevel;};
00242   
00244   bool isEmpty(int a_level) const {return (a_level > m_finestLevel);};
00245   
00246 
00248   Real Dx(int a_level) const {return m_vectDx[a_level];};
00249   
00251   Real Nu() const {return m_nu;};
00252 
00254   void setPhysBC(const PhysBCUtil& a_BC);
00255 
00256 
00258   bool isDefined() const;
00259 
00260 
00261 protected:
00262 
00263 
00265   void advance(Real a_dt);
00266   
00268   void postTimeStep();
00269   
00271   void tagCells(Vector<IntVectSet>& a_tags);
00272   
00274   void tagCellsLevel(IntVectSet& a_tags, int a_level);
00275   
00277   void tagCellsInit(Vector<IntVectSet>& a_tags);
00278   
00279 
00281   void regrid();
00282 
00283   
00285   void postRegrid();
00286   
00287   
00289 
00293   void initialGrid(const Vector<Vector<Box> >& a_new_grids,
00294                    int a_baseLevel,
00295                    bool a_clearStorage = false);
00296 
00297 
00299 
00303   void initialGrid(const Vector<DisjointBoxLayout>& a_new_grids,
00304                    const Vector<DisjointBoxLayout>& a_new_particle_grids,
00305                    int a_baseLevel,
00306                    bool a_clearStorage = false);
00307   
00309   void initialData();
00310   
00312   void postInitialize();
00313   
00314 #ifdef HDF5
00315 
00316   void writeParticleData(HDF5Handle& a_handle) const;  
00317   
00319   int writeParticlesHDF5(HDF5Handle& a_handle,
00320                          const List<DragParticle>& a_particles) const;
00321 #endif
00322   
00324   Real computeDt();
00325   
00327   Real computeInitialDt();
00328   
00330   void computeVorticity(LevelData<FArrayBox>& a_vorticity, int a_level) const;
00331 
00333   void computeKineticEnergy(LevelData<FArrayBox>& a_energy,
00334                             int a_level) const;
00335 
00337   Real particleKineticEnergy() const;
00338 
00340   void dumpParticlesASCII(std::ostream& os ) const;
00341 
00343 
00346   void dumpLoadBalanceInfo() const;
00347 
00349   LevelData<FArrayBox>& newVel(int a_level);
00350 
00352   const LevelData<FArrayBox>& newVel(int a_level) const;
00353 
00355   LevelData<FArrayBox>& oldVel(int a_level);
00356 
00358   const LevelData<FArrayBox>& oldVel(int a_level) const;
00359 
00361   void velocity(LevelData<FArrayBox>& a_vel, Real a_time, int a_level) const;
00362 
00364   LevelData<BinFab<DragParticle> >& particles(int a_level);
00365 
00367   const LevelData<BinFab<DragParticle> >& particles(int a_level) const;
00368 
00370   int numParticles(int a_level) const;
00371   
00373   LevelData<FArrayBox>& newScal(const int a_comp, int a_level);
00374 
00376   const LevelData<FArrayBox>& newScal(const int a_comp, int a_level) const;
00377 
00379   LevelData<FArrayBox>& oldScal(const int a_comp, int a_level);
00380 
00382   const LevelData<FArrayBox>& oldScal(const int a_comp, int a_level) const;
00383 
00385   void scalars(LevelData<FArrayBox>& a_scalars, const Real a_time, 
00386                const int a_comp, int a_level) const;
00387 
00388   
00390   PhysBCUtil* getPhysBCPtr() const;
00391 
00392   
00393 
00394 protected:
00396   void loadBalance(Vector<DisjointBoxLayout>& a_vectGrids,
00397                    Vector<DisjointBoxLayout>& a_vectParticleGrids,
00398                    const Vector<Vector<Box> >& a_vectBoxes,
00399                    int a_lbase); 
00400 
00402   void setup ();
00403 
00405   void regrid(const Vector<Vector<Box> >& a_new_grids);
00406   
00407 
00409 
00412   void defineParticles(List<DragParticle>& a_particles) const;
00413 
00415   void readParameters();
00416 
00418   void finestLevel(int a_finest_level);
00419 
00421   void swapOldAndNewStates();
00422 
00424   void resetStates(const Real a_time);
00425 
00427 
00430   void computeAdvectionVelocities(Vector<LevelData<FluxBox>*> & a_adv_vel,
00431                                   Vector<LevelData<FArrayBox>* >& a_phi,
00432                                   Vector<LevelData<FArrayBox>* >& a_dragForce);
00433 
00434 
00435   /*@ManMemo: do predictor -- returns approx. to (U dot del)U.
00436     Also updates flux registers with momentum fluxes and
00437     part of viscous fluxes which contains the old-time velocity.
00438     a_phi is the correction from the MAC projection
00439   */
00440   void predictVelocities(Vector<LevelData<FArrayBox>* >& a_uDelU,
00441                          Vector<LevelData<FluxBox>* >& a_advVel,
00442                          Vector<LevelData<FArrayBox>* >& a_phi,
00443                          Vector<LevelData<FArrayBox>* >& a_dragForce);
00444   
00445   /*@ManMemo: This function computes uStar -- the approximation
00446     of the new-time velocity which will be projected.  The
00447     advection term (u-dot-del-U) is passed in in a_uStar, which 
00448     is modified in place to contain uStar. Note that both viscous
00449     and inviscid cases, this returns the approximation to 
00450     u^{n+1} + dt*gradPi.  a_dragForce is the old-time drag force
00451   */
00452   void computeUStar(Vector<LevelData<FArrayBox>* >& a_uStar,
00453                     Vector<LevelData<FArrayBox>* >& a_dragForce,
00454                     Vector<LevelData<FArrayBox>* >& a_Pi);
00455 
00456 
00458 
00467   void updateParticlePositions(Vector<LevelData<FArrayBox>*>& a_newDrag,
00468                                Vector<LevelData<BinFab<DragParticle> >* >& a_particles,
00469                                const Vector<LevelData<FArrayBox>*>& a_fluidVel,
00470                                bool a_completeUpdate);
00471 
00472 
00474   void updateParticleForces(Vector<LevelData<BinFab<DragParticle> >* >& a_particles);
00475   
00477   void interpVelToParticles(Vector<LevelData<BinFab<DragParticle> >* >& a_particles,
00478                             const Vector<LevelData<FArrayBox>* >& a_velocity);
00479   
00481   void advectScalar(Vector<LevelData<FArrayBox>* >& a_new_scal,
00482                     Vector<LevelData<FArrayBox>* >& a_old_scal,
00483                     Vector<LevelData<FluxBox>* >& a_adv_vel,
00484                     OldPhysIBC* a_scalIBC,
00485                     Real a_dt);
00486 
00488   void advectDiffuseScalar(Vector<LevelData<FArrayBox>* >& a_new_scal,
00489                            Vector<LevelData<FArrayBox>* >& a_old_scal,
00490                            Vector<LevelData<FluxBox>* >& a_adv_vel,
00491                            const Real& a_diffusive_coeff,
00492                            DomainGhostBC& a_scalPhysBC,
00493                            OldPhysIBC* a_scalIBC,
00494                            Real a_dt);
00495 
00497   void initializePressure();
00498 
00500   void computeLapVel(Vector<LevelData<FArrayBox>* >& a_lapVel,
00501                      Vector<LevelData<FArrayBox>* >& a_vel);
00502 
00504   void computeLapScal(Vector<LevelData<FArrayBox>* >& a_lapScal,
00505                       Vector<LevelData<FArrayBox>* >& a_scal,
00506                       DomainGhostBC& a_physBC);
00507 
00508 
00510   void fillVelocity(Vector<LevelData<FArrayBox>* >& a_vel, Real a_time);
00511 
00513   void fillVelocity(Vector<LevelData<FArrayBox>* >& a_vel, Real a_time,  
00514                     int vel_comp, int dest_comp, int num_comp);
00515 
00517   void fillScalars(Vector<LevelData<FArrayBox>* >& a_scal, Real a_time,
00518                    const int a_comp) const;
00519 
00520 
00522   int numPlotComps() const;
00523   
00525   void getPlotDataNames(Vector<string>& a_vectNames);
00526   
00528   void getPlotData(Vector<LevelData<FArrayBox>* >& a_plot_data);
00529 
00531   void fillCheckpointData(Vector<LevelData<FArrayBox>* >& a_vectData,
00532                           Vector<string>& a_checkDataNames);
00533 
00535   void setDefaultValues();
00536 
00537 
00538 protected:
00540   Vector<int> m_vectRefRatio;
00541   
00543   Vector<ProblemDomain> m_vectDomain;
00544 
00546   Vector<Real> m_vectDx;
00547 
00549   Vector<DisjointBoxLayout> m_vectGrids;
00550 
00552   Vector<DisjointBoxLayout> m_vectParticleGrids;
00553 
00555   Vector<Vector<Box> > m_vectBoxes;
00556 
00557 
00559   int m_maxLevel;
00560 
00562   int m_finestLevel;
00563 
00565   int m_regrid_interval;
00566 
00568   int m_block_factor;
00569 
00571   Real m_fill_ratio;
00572   
00574   int m_nesting_radius;
00575   
00577   int m_max_box_size;
00578 
00580   int m_max_base_box_size;
00581 
00583   Real m_time;
00584 
00586   int m_cur_step;
00587 
00589   Real m_dt;
00590 
00592   Vector<LevelData<FArrayBox>* > m_vectOldVel;
00593 
00595   Vector<LevelData<FArrayBox>* > m_vectNewVel;
00596 
00598   Vector<LevelData<FArrayBox>* > m_vectPi;
00599 
00601   Vector<LevelData<BinFab<DragParticle> >* > m_vectParticles;
00602 
00603 
00605   Vector<Vector<LevelData<FArrayBox>* > > m_vectOldScal;
00606   
00608   Vector<Vector<LevelData<FArrayBox>* > > m_vectNewScal;
00609 
00610 
00612   int m_num_vel_comps;
00613   
00615   int m_num_scal_comps;
00616 
00618   int m_max_scal_comps;
00619 
00621   static const char* s_vel_names[CH_SPACEDIM];
00622 
00624   static const char* s_scal_names[NUM_SCAL_TYPES];
00625   
00627   Vector<Real> m_scal_coeffs;
00628   
00630   RealVect m_domLength;
00631     
00633   Real m_init_shrink;
00634 
00636   Real m_max_dt;
00637 
00639   Real m_min_dt;
00640   
00642   Real m_prescribedDt;
00643 
00645   Real m_max_dt_grow;
00646 
00648   int m_verbosity;
00649 
00651   bool m_project_initial_vel;
00652 
00654   bool m_update_velocity;
00655   
00657   bool m_initialize_pressures;
00658   
00659 
00661   int m_num_init_passes;
00662   
00664   bool m_set_bogus_values;
00665 
00667   Real m_bogus_value;
00668 
00670   bool m_tag_vorticity;
00671 
00673   Real m_vort_factor;
00674 
00676   bool m_tag_particles;
00677   
00679   int m_tags_grow;
00680 
00682   int m_viscous_solver_type;
00683 
00685   Real m_viscous_solver_tol;
00686   
00688   int m_viscous_num_smooth_up;
00689 
00691   int m_viscous_num_smooth_down;
00692 
00694   bool m_limitSolverCoarsening; 
00695 
00697   Real m_nu;
00698 
00700   bool m_doRestart;
00701 
00703   bool m_do_particles;
00704 
00706   bool m_read_particles_from_file;
00707 
00709   string m_particle_file;
00710   
00712   Real m_particle_drag_coeff;
00713 
00715   RealVect m_particle_body_force;
00716 
00718   Real m_particle_epsilon;
00719 
00721   Real m_spreading_radius;
00722 
00724   Real m_correction_radius;
00725 
00727 
00731   int m_particle_grids_buffer;
00732 
00734   bool m_use_image_particles;
00735 
00737   int m_order_vel_interp;
00738 
00740   bool m_limit_vel_interp;
00741 
00743   int m_particle_update_type;
00744   
00746   bool m_specifyInitialGrids;
00747 
00749   string m_initialGridFile;
00750 
00752   bool m_init_vel_from_vorticity;
00753   
00755   Real m_backgroundVel;
00756 
00758   
00760   bool m_write_particles;
00761   
00763   bool m_write_divergence;
00764 
00766   bool m_write_time_derivatives;
00767   
00769   bool m_write_vorticity;
00770 
00772   bool m_write_scalars;
00773 
00775   bool m_write_dScalar_dt;
00776   
00778   bool m_write_error;
00779 
00781   // bool m_write_curl_error;
00782 
00784   bool m_write_proc_ids;
00785 
00787   bool m_compute_scal_err;
00788 
00790   bool m_write_initial_solve_rhs;
00791   
00793   bool m_write_grids;
00794 
00796   Real m_cfl;
00797 
00799   Real m_particleCFL;
00800 
00801 
00803   Vector<CoarseAverage*> m_coarse_average;
00804   
00806   Vector<CoarseAverage*> m_coarse_average_scal;
00807 
00809   AmrProjector m_projection;
00810   
00812   AMRParticleProjector m_particle_projector;
00813  
00815   int m_particleProjCoarsening;
00816 
00818   Vector<QuadCFInterp*> m_velCFInterp_ptrs;     
00819 
00821   Vector<PoissonOp*> m_scalarsPoissonOp_ptrs;
00822   
00823   Vector<PatchAdvection*> m_patchGod;
00824 
00826   Real m_refine_threshold;
00827   
00829   PhysBCUtil* m_physBCPtr;
00830 
00831 
00833   int m_plot_interval;
00834   
00836   int m_check_interval;
00837 
00839 
00841   int m_lastcheck_step;
00842 
00844 
00847   int m_restart_step;      
00848 
00850   Vector<int> m_cell_updates;
00851 
00852   bool m_ppInit;
00853 
00855   bool m_isDefined;
00856   
00857 
00858   std::string m_plotfile_prefix;
00859   std::string m_checkpointfile_prefix;
00860 
00861 };
00862 
00863 #endif
00864 
00865 
00866 
00867 

Generated on Wed Jan 19 17:51:26 2005 for Chombo&INSwithParticles by doxygen1.2.16