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 Box& a_domain,
00077               const Real  a_dx,
00078               CCProjector* a_finerProj,
00079               CCProjector* a_crseProj,
00080               int a_nRefCrse,
00081               int a_level,
00082               const PhysBCUtil& a_physBC);
00083 
00085   CCProjector(const DisjointBoxLayout& a_grids,
00086               const ProblemDomain& a_domain,
00087               const Real  a_dx,
00088               CCProjector* a_finerProj,
00089               CCProjector* a_crseProj,
00090               int a_nRefCrse,
00091               int a_level,
00092               const PhysBCUtil& a_physBC);
00093 
00095   ~CCProjector();
00096 
00098   void define(const DisjointBoxLayout& a_grids,
00099               const Box& a_domain,
00100               const Real  a_dx,
00101               CCProjector* a_finerProj,
00102               CCProjector* a_crseProj,
00103               int a_nRefCrse,
00104               int a_level,
00105               const PhysBCUtil& a_physBC);
00106 
00108   void define(const DisjointBoxLayout& a_grids,
00109               const ProblemDomain& a_domain,
00110               const Real  a_dx,
00111               CCProjector* a_finerProj,
00112               CCProjector* a_crseProj,
00113               int a_nRefCrse,
00114               int a_level,
00115               const PhysBCUtil& a_physBC);
00116 
00117 
00119   void init(const CCProjector& a_oldProj);
00120 
00122   void variableSetUp();
00123 
00125   void setCrseProj(CCProjector* a_crseProj, int nRefCrse);
00126   
00128   void setFineProj(CCProjector* a_fineProj);
00129 
00131   void writeCheckpointHeader(HDF5Handle& a_handle) const;
00132 
00134   void  writeCheckpointLevel(HDF5Handle& a_handle) const;
00135 
00137   void readCheckpointHeader(HDF5Handle& a_handle);
00138 
00140   void readCheckpointLevel(HDF5Handle& a_handle);
00141 
00142 
00143   /*@ManMemo: do level MAC projection, correct uEdge.  a_oldTime is
00144     old-time on AMRLevel which is calling the projection.  assumes
00145     BC's already set on uEdge values */
00146   void levelMacProject(LevelData<FluxBox>& uEdge,
00147                        Real a_oldTime, Real a_dt);
00148 
00149   /*@ManMemo: do level projection and correct (cell-centered)
00150     velocities; assumes physical and exchange (copy) boundary
00151     conditions already set.    
00152   */
00153   void LevelProject(LevelData<FArrayBox>& a_velocity, 
00154                     LevelData<FArrayBox>* a_crseVelPtr,
00155                     const Real a_newTime, const Real a_dt);
00156 
00157 
00158   /*@ManMemo: defines AMRSolver and calls sync projection
00159     and freestream preservation solve. assumes all physical
00160     and copy BC's already set (does C/F BC's however) */
00161   void doSyncOperations(Vector<LevelData<FArrayBox>* >& a_velocity,
00162                         Vector<LevelData<FArrayBox>* >& a_lambda,
00163                         const Real a_newTime, const Real a_dtSync);
00164                         
00165 
00168   void initialLevelProject(LevelData<FArrayBox>& a_velocity,
00169                            LevelData<FArrayBox>* a_crseVelPtr,
00170                            const Real a_oldTime, const Real a_newTime);
00171 
00172   
00173   /*@ManMemo: defines AMRSolver and calls initial sync projection and
00174     freestream preservation solves */
00175   void doInitialSyncOperations(Vector<LevelData<FArrayBox>* >& a_vel,
00176                                Vector<LevelData<FArrayBox>* >& a_lambda,
00177                                const Real a_newTime, const Real a_dtSync);
00178                 
00179   /*@ManMemo: performs multilevel projection on velocity, modifies velocity
00180     in place. dtSync is used as a scaling factor for coarse-level BC's,
00181     not used in actual projection.  if homogeneousCFBC is false, C/F bc 
00182     for l_base is taken from coarse-level eSync, o/w use l_base-1 
00183     correction field = 0.  if applyCorrection == false, then correction
00184     is computed, but not applied (can be useful as a diagnostic).
00185     physical and copy BC's should already be set before this is called.
00186   */
00187     
00188   void initialVelocityProject(Vector<LevelData<FArrayBox>* >& a_velocity,
00189                               bool a_homogeneousCFBC = true);
00190 
00191   /*@ManMemo: same as other initialVelocityProject function,
00192     except uses a pre-defined AMRSolver */
00193   void initialVelocityProject(Vector<LevelData<FArrayBox>* >& a_velocity,
00194                               AMRSolver& a_solver,
00195                               bool a_homogeneousCFBC = true);
00196 
00197 
00198   /*@ManMemo: This function performs the necessary re-initialization
00199     after regridding -- does composite projection on new velocity field
00200     and also recomputes e_lambda and grad_eLambda */
00201 
00202   void doPostRegridOps(Vector<LevelData<FArrayBox>* >& a_velocity,
00203                        Vector<LevelData<FArrayBox>* >& a_lambda,
00204                        const Real a_dt, const Real a_time);
00205 
00207 
00209   int getLevel() const;
00210 
00212   const ProblemDomain& dProblem() const;
00213 
00215   const DisjointBoxLayout& getBoxes() const;
00216 
00218   int nRefCrse() const;
00219   
00221   Real dx() const;
00222 
00224   Real etaLambda() const;
00225 
00227   CCProjector* fineProjPtr() const;
00228   
00230   CCProjector* crseProjPtr() const;
00231 
00233   LevelData<FArrayBox>& phi();
00234   
00236   const LevelData<FArrayBox>& phi() const;
00237 
00239   void gradPhi(LevelData<FArrayBox>& a_gradPhi, int a_dir) const;
00240 
00242   void gradPhi(LevelData<FluxBox>& a_gradPhi) const;
00243 
00245   LevelData<FArrayBox>& Pi();
00246 
00248   void gradPi(LevelData<FArrayBox>& a_gradPi, int a_dir) const;
00249 
00250   /*@ManMemo: returns grad(pi) in all directions into 
00251     SpaceDim-dimensioned gradPi 
00252   */ 
00253   void gradPi(LevelData<FArrayBox>& a_gradPi) const;
00254 
00256   LevelData<FArrayBox>& eSync();
00257 
00259   const LevelData<FArrayBox>& eSync() const;
00260   
00262   void grad_eSync(LevelData<FArrayBox>& a_grad_eSync, int a_dir) const;
00263 
00265   void grad_eSync(LevelData<FArrayBox>& a_grad_eSync) const;
00266 
00267 
00269   LevelData<FArrayBox>& eLambda();
00270 
00272   const LevelData<FArrayBox>& eLambda() const;
00273 
00275   void grad_eLambda(LevelData<FArrayBox>& a_grad_eLambda, int a_dir) const;
00276 
00277   /*@ManMemo: returns edge-centered grad(eLambda) in all directions;
00278     non-constant reference returned because of need to rescale. */ 
00279   LevelData<FluxBox>&  grad_eLambda();
00280 
00282   const LevelData<FluxBox>& grad_eLambda() const;
00283     
00285   bool doSyncProjection() const;
00286 
00288   bool doMacSync() const;
00289   
00291   bool isInitialized() const;
00292 
00294   bool doQuadInterp() const;
00295   
00297   QuadCFInterp& quadCFInterpolator();
00298 
00300   bool isFinestLevel() const;
00301 
00303   void isFinestLevel(bool a_finest_level);
00304 
00306   void verbosity(int a_verbosity);
00307 
00309   int verbosity() const;
00310 
00312   void setPhysBC(const PhysBCUtil& a_bc);
00313 
00315   PhysBCUtil* getPhysBCPtr() const;
00316 
00317 protected:
00319   void applyMacCorrection(LevelData<FluxBox>& a_uEdge, Real CFscale);
00320   
00322   void correctCCVelocities(LevelData<FArrayBox>& a_velocity,
00323                            const Real scale) const;
00324   
00325   
00326   /*@ManMemo: do sync projection, with this level as lBase;
00327     corrects velocity in place*/
00328   void doSyncProjection(Vector<LevelData<FArrayBox>* >& a_velocity,
00329                         const Real a_newTime, const Real a_dtSync,
00330                         AMRSolver& solver);
00331   
00333   void initialSyncProjection(Vector<LevelData<FArrayBox>* >& a_velocity,
00334                              const Real a_newTime, const Real a_dtSync,
00335                              AMRSolver& a_solver);
00336 
00337 
00338   /*@ManMemo: do volume discrepancy solve, with this level as lBase
00339    */
00340   void computeVDCorrection(Vector<LevelData<FArrayBox>* >& a_lambda,
00341                            const Real a_newTime, const Real
00342                            a_dtSync, AMRSolver& solver);
00343   
00344   
00345 /*@ManMemo: apply sync correction vel = vel - scale*G^{comp} eSync 
00346   (recursively applies correction to all finer levels) */
00347   void applySyncCorrection(Vector<LevelData<FArrayBox>* >& a_velocity,
00348                            const Real scale, 
00349                            LevelData<FArrayBox>* crseCorr);
00350 
00351 
00353   void computeGrad_eLambda();
00354 
00356 
00360   void rescaleGrad_eLambda(Real a_dx_lbase);
00361 
00362 
00363   /*@ManMemo: defines Multilevel AMRSolver used for composite 
00364     projections -- uses grids in vel, lBase is this level.
00365     a_freestream solver is true if solver will be used for
00366     freestream preservation solve. */
00367   void defineSolver(AMRSolver& a_solver, 
00368                     const Vector<LevelData<FArrayBox>* >& a_vel,
00369                     bool a_freestreamSolver);
00370 
00372   void postRestart();
00373 
00374 private:
00375 
00377   int m_level;
00378   
00380   Real m_dx;
00381 
00383   ProblemDomain m_domain;
00384   
00385 
00387   QuadCFInterp m_cfInterp;
00388 
00390   CCProjector* m_fineProjPtr;
00392   CCProjector* m_crseProjPtr;
00393 
00395   int m_nRefCrse;
00396 
00398   LevelData<FArrayBox> m_Pi;
00399 
00401   LevelData<FArrayBox> m_phi;
00402 
00404   LevelData<FArrayBox> m_eSync;
00406   LevelData<FArrayBox> m_eLambda;
00407 
00409   LevelData<FluxBox> m_grad_eLambda;
00410 
00412   LevelSolver m_levelSolver;
00413 
00415   static bool m_doSyncProjection;
00416   
00418   static bool m_applySyncCorrection;
00419 
00421   bool m_isInitialized;
00422 
00424   static bool m_doQuadInterp;
00425  
00427   static Real m_etaLambda;
00428 
00430   static bool pp_init;
00431 
00433   static int s_verbosity;
00434 
00436   static bool s_applyVDCorrection;
00437 
00439   bool m_finest_level;
00440 
00442   PhysBCUtil* m_physBCPtr;
00443 
00444 };
00445 
00446 #endif
00447 
00448 

Generated on Thu Aug 29 11:05:44 2002 for Chombo&INS by doxygen1.2.16