00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
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
00152
00153
00154 void levelMacProject(LevelData<FluxBox>& uEdge,
00155 Real a_oldTime, Real a_dt);
00156
00157
00158
00159
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
00167
00168
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
00182
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
00188
00189
00190
00191
00192
00193
00194
00195
00196 void initialVelocityProject(Vector<LevelData<FArrayBox>* >& a_velocity,
00197 bool a_homogeneousCFBC = true);
00198
00199
00200
00201 void initialVelocityProject(Vector<LevelData<FArrayBox>* >& a_velocity,
00202 AMRSolver& a_solver,
00203 bool a_homogeneousCFBC = true);
00204
00205
00206
00207
00208
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
00259
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
00286
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
00335
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
00347
00348 void computeVDCorrection(Vector<LevelData<FArrayBox>* >& a_lambda,
00349 const Real a_newTime, const Real
00350 a_dtSync, AMRSolver& solver);
00351
00352
00353
00354
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
00372
00373
00374
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