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

CCProjector.H

Go to the documentation of this file.
00001 /* _______              __
00002   / ___/ /  ___  __ _  / /  ___
00003  / /__/ _ \/ _ \/  ' \/ _ \/ _ \
00004  \___/_//_/\___/_/_/_/_.__/\___/ 
00005 */
00006 
00007 // CCProjector.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 _CCProjector_H_
00033 #define _CCProjector_H_
00034 
00035 
00036 #include <cstdlib>
00037 #include <cmath>
00038 #include <cassert>
00039 
00040 #include <iostream>
00041 using std::istream;
00042 using std::cout;
00043 using std::cerr;
00044 
00045 
00046 #include "REAL.H"
00047 #include "IntVect.H"
00048 #include "Box.H"
00049 #include "FArrayBox.H"
00050 #include "Vector.H"
00051 #include "IntVectSet.H"
00052 #include "DisjointBoxLayout.H"
00053 #include "LevelData.H"
00054 #include "LevelSolver.H"
00055 #include "AMRSolver.H"
00056 #include "QuadCFInterp.H"
00057 #include "GhostBC.H"
00058 #include "PhysBCUtil.H"
00059 
00060 #include "FluxBox.H"
00061 
00063 class CCProjector
00068 {
00069 
00070 public:
00072   CCProjector();
00073 
00075   CCProjector(const DisjointBoxLayout& a_grids,
00076               const DisjointBoxLayout* a_crseGridsPtr,
00077               const Box& a_domain,
00078               const Real  a_dx,
00079               CCProjector* a_finerProj,
00080               CCProjector* a_crseProj,
00081               int a_nRefCrse,
00082               int a_level,
00083               const PhysBCUtil& a_physBC);
00084 
00086   CCProjector(const DisjointBoxLayout& a_grids,
00087               const DisjointBoxLayout* a_crseGridsPtr,
00088               const ProblemDomain& a_domain,
00089               const Real  a_dx,
00090               CCProjector* a_finerProj,
00091               CCProjector* a_crseProj,
00092               int a_nRefCrse,
00093               int a_level,
00094               const PhysBCUtil& a_physBC);
00095 
00097   ~CCProjector();
00098 
00100   void define(const DisjointBoxLayout& a_grids,
00101               const DisjointBoxLayout* a_crseGridsPtr,
00102               const Box& a_domain,
00103               const Real  a_dx,
00104               CCProjector* a_finerProj,
00105               CCProjector* a_crseProj,
00106               int a_nRefCrse,
00107               int a_level,
00108               const PhysBCUtil& a_physBC);
00109 
00111   void define(const DisjointBoxLayout& a_grids,
00112               const DisjointBoxLayout* a_crseGridsPtr,
00113               const ProblemDomain& a_domain,
00114               const Real  a_dx,
00115               CCProjector* a_finerProj,
00116               CCProjector* a_crseProj,
00117               int a_nRefCrse,
00118               int a_level,
00119               const PhysBCUtil& a_physBC);
00120 
00121 
00123   void init(const CCProjector& a_oldProj);
00124 
00126   void variableSetUp();
00127 
00129   void setCrseProj(CCProjector* a_crseProj, int nRefCrse);
00130   
00132   void setFineProj(CCProjector* a_fineProj);
00133 
00135   void limitSolverCoarsening(bool a_limitSolverCoarsening);
00136 
00137 
00139   void writeCheckpointHeader(HDF5Handle& a_handle) const;
00140 
00142   void  writeCheckpointLevel(HDF5Handle& a_handle) const;
00143 
00145   void readCheckpointHeader(HDF5Handle& a_handle);
00146 
00148   void readCheckpointLevel(HDF5Handle& a_handle);
00149 
00150 
00151   /*@ManMemo: do level MAC projection, correct uEdge.  a_oldTime is
00152     old-time on AMRLevel which is calling the projection.  assumes
00153     BC's already set on uEdge values */
00154   void levelMacProject(LevelData<FluxBox>& uEdge,
00155                        Real a_oldTime, Real a_dt);
00156 
00157   /*@ManMemo: do level projection and correct (cell-centered)
00158     velocities; assumes physical and exchange (copy) boundary
00159     conditions already set.    
00160   */
00161   void LevelProject(LevelData<FArrayBox>& a_velocity, 
00162                     LevelData<FArrayBox>* a_crseVelPtr,
00163                     const Real a_newTime, const Real a_dt);
00164 
00165 
00166   /*@ManMemo: defines AMRSolver and calls sync projection
00167     and freestream preservation solve. assumes all physical
00168     and copy BC's already set (does C/F BC's however) */
00169   void doSyncOperations(Vector<LevelData<FArrayBox>* >& a_velocity,
00170                         Vector<LevelData<FArrayBox>* >& a_lambda,
00171                         const Real a_newTime, const Real a_dtSync);
00172                         
00173 
00176   void initialLevelProject(LevelData<FArrayBox>& a_velocity,
00177                            LevelData<FArrayBox>* a_crseVelPtr,
00178                            const Real a_oldTime, const Real a_newTime);
00179 
00180   
00181   /*@ManMemo: defines AMRSolver and calls initial sync projection and
00182     freestream preservation solves */
00183   void doInitialSyncOperations(Vector<LevelData<FArrayBox>* >& a_vel,
00184                                Vector<LevelData<FArrayBox>* >& a_lambda,
00185                                const Real a_newTime, const Real a_dtSync);
00186                 
00187   /*@ManMemo: performs multilevel projection on velocity, modifies velocity
00188     in place. dtSync is used as a scaling factor for coarse-level BC's,
00189     not used in actual projection.  if homogeneousCFBC is false, C/F bc 
00190     for l_base is taken from coarse-level eSync, o/w use l_base-1 
00191     correction field = 0.  if applyCorrection == false, then correction
00192     is computed, but not applied (can be useful as a diagnostic).
00193     physical and copy BC's should already be set before this is called.
00194   */
00195     
00196   void initialVelocityProject(Vector<LevelData<FArrayBox>* >& a_velocity,
00197                               bool a_homogeneousCFBC = true);
00198 
00199   /*@ManMemo: same as other initialVelocityProject function,
00200     except uses a pre-defined AMRSolver */
00201   void initialVelocityProject(Vector<LevelData<FArrayBox>* >& a_velocity,
00202                               AMRSolver& a_solver,
00203                               bool a_homogeneousCFBC = true);
00204 
00205 
00206   /*@ManMemo: This function performs the necessary re-initialization
00207     after regridding -- does composite projection on new velocity field
00208     and also recomputes e_lambda and grad_eLambda */
00209 
00210   void doPostRegridOps(Vector<LevelData<FArrayBox>* >& a_velocity,
00211                        Vector<LevelData<FArrayBox>* >& a_lambda,
00212                        const Real a_dt, const Real a_time);
00213 
00215 
00217   int getLevel() const;
00218 
00220   const ProblemDomain& dProblem() const;
00221 
00223   const DisjointBoxLayout& getBoxes() const;
00224 
00226   int nRefCrse() const;
00227   
00229   Real dx() const;
00230 
00232   Real etaLambda() const;
00233 
00235   CCProjector* fineProjPtr() const;
00236   
00238   CCProjector* crseProjPtr() const;
00239 
00241   LevelData<FArrayBox>& phi();
00242   
00244   const LevelData<FArrayBox>& phi() const;
00245 
00247   void gradPhi(LevelData<FArrayBox>& a_gradPhi, int a_dir) const;
00248 
00250   void gradPhi(LevelData<FluxBox>& a_gradPhi) const;
00251 
00253   LevelData<FArrayBox>& Pi();
00254 
00256   void gradPi(LevelData<FArrayBox>& a_gradPi, int a_dir) const;
00257 
00258   /*@ManMemo: returns grad(pi) in all directions into 
00259     SpaceDim-dimensioned gradPi 
00260   */ 
00261   void gradPi(LevelData<FArrayBox>& a_gradPi) const;
00262 
00264   LevelData<FArrayBox>& eSync();
00265 
00267   const LevelData<FArrayBox>& eSync() const;
00268   
00270   void grad_eSync(LevelData<FArrayBox>& a_grad_eSync, int a_dir) const;
00271 
00273   void grad_eSync(LevelData<FArrayBox>& a_grad_eSync) const;
00274 
00275 
00277   LevelData<FArrayBox>& eLambda();
00278 
00280   const LevelData<FArrayBox>& eLambda() const;
00281 
00283   void grad_eLambda(LevelData<FArrayBox>& a_grad_eLambda, int a_dir) const;
00284 
00285   /*@ManMemo: returns edge-centered grad(eLambda) in all directions;
00286     non-constant reference returned because of need to rescale. */ 
00287   LevelData<FluxBox>&  grad_eLambda();
00288 
00290   const LevelData<FluxBox>& grad_eLambda() const;
00291     
00293   bool doSyncProjection() const;
00294 
00296   bool doMacSync() const;
00297   
00299   bool isInitialized() const;
00300 
00302   bool doQuadInterp() const;
00303   
00305   QuadCFInterp& quadCFInterpolator();
00306 
00308   bool isFinestLevel() const;
00309 
00311   void isFinestLevel(bool a_finest_level);
00312 
00314   void verbosity(int a_verbosity);
00315 
00317   int verbosity() const;
00318 
00320   void setPhysBC(const PhysBCUtil& a_bc);
00321 
00323   PhysBCUtil* getPhysBCPtr() const;
00324 
00325 protected:
00327   void applyMacCorrection(LevelData<FluxBox>& a_uEdge, Real CFscale);
00328   
00330   void correctCCVelocities(LevelData<FArrayBox>& a_velocity,
00331                            const Real scale) const;
00332   
00333   
00334   /*@ManMemo: do sync projection, with this level as lBase;
00335     corrects velocity in place*/
00336   void doSyncProjection(Vector<LevelData<FArrayBox>* >& a_velocity,
00337                         const Real a_newTime, const Real a_dtSync,
00338                         AMRSolver& solver);
00339   
00341   void initialSyncProjection(Vector<LevelData<FArrayBox>* >& a_velocity,
00342                              const Real a_newTime, const Real a_dtSync,
00343                              AMRSolver& a_solver);
00344 
00345 
00346   /*@ManMemo: do volume discrepancy solve, with this level as lBase
00347    */
00348   void computeVDCorrection(Vector<LevelData<FArrayBox>* >& a_lambda,
00349                            const Real a_newTime, const Real
00350                            a_dtSync, AMRSolver& solver);
00351   
00352   
00353 /*@ManMemo: apply sync correction vel = vel - scale*G^{comp} eSync 
00354   (recursively applies correction to all finer levels) */
00355   void applySyncCorrection(Vector<LevelData<FArrayBox>* >& a_velocity,
00356                            const Real scale, 
00357                            LevelData<FArrayBox>* crseCorr);
00358 
00359 
00361   void computeGrad_eLambda();
00362 
00364 
00368   void rescaleGrad_eLambda(Real a_dx_lbase);
00369 
00370 
00371   /*@ManMemo: defines Multilevel AMRSolver used for composite 
00372     projections -- uses grids in vel, lBase is this level.
00373     a_freestream solver is true if solver will be used for
00374     freestream preservation solve. */
00375   void defineSolver(AMRSolver& a_solver, 
00376                     const Vector<LevelData<FArrayBox>* >& a_vel,
00377                     bool a_freestreamSolver);
00378 
00380   void postRestart();
00381 
00382 private:
00383 
00385   int m_level;
00386   
00388   Real m_dx;
00389 
00391   ProblemDomain m_domain;
00392   
00393 
00395   QuadCFInterp m_cfInterp;
00396 
00398   CCProjector* m_fineProjPtr;
00400   CCProjector* m_crseProjPtr;
00401 
00403   int m_nRefCrse;
00404 
00406   LevelData<FArrayBox> m_Pi;
00407 
00409   LevelData<FArrayBox> m_phi;
00410 
00412   LevelData<FArrayBox> m_eSync;
00414   LevelData<FArrayBox> m_eLambda;
00415 
00417   LevelData<FluxBox> m_grad_eLambda;
00418 
00420   LevelSolver m_levelSolver;
00421 
00423   static bool m_doSyncProjection;
00424   
00426   static bool m_applySyncCorrection;
00427 
00429   bool m_isInitialized;
00430 
00432   static bool m_doQuadInterp;
00433  
00435   bool m_limitSolverCoarsening;
00436 
00438   static Real m_etaLambda;
00439 
00441   static int s_num_smooth_up;
00442 
00444   static int s_num_smooth_down;
00445 
00447   static bool s_constantLambdaScaling;
00448 
00450   static Real s_lambda_timestep;
00451 
00453   static bool pp_init;
00454 
00456   static int s_verbosity;
00457 
00459   static bool s_applyVDCorrection;
00460 
00462   bool m_finest_level;
00463 
00465   PhysBCUtil* m_physBCPtr;
00466 
00467 };
00468 
00469 #endif
00470 
00471 

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