00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011 #ifndef _AMRPOISSONOP_H_
00012 #define _AMRPOISSONOP_H_
00013
00014 #include "REAL.H"
00015 #include "Box.H"
00016 #include "FArrayBox.H"
00017 #include "FluxBox.H"
00018 #include "QuadCFInterp.H"
00019 #include "LevelFluxRegister.H"
00020 #include "LevelDataOps.H"
00021 #include "AMRMultiGrid.H"
00022 #include "BCFunc.H"
00023 #include "BaseLevelTGA.H"
00024 #include "CFRegion.H"
00025 #include "AMRIO.H"
00026
00027 #include "NamespaceHeader.H"
00028
00030
00034 class AMRPoissonOp : public LevelTGAHelmOp<LevelData<FArrayBox> , FluxBox>
00035 {
00036 public:
00040
00042
00044 AMRPoissonOp() { ; }
00045
00047
00049 virtual ~AMRPoissonOp() { ; }
00050
00052
00053 void define(const DisjointBoxLayout& a_grids,
00054 const DisjointBoxLayout& a_gridsFiner,
00055 const DisjointBoxLayout& a_gridsCoarser,
00056 const Real& a_dxLevel,
00057 int a_refRatio,
00058 int a_refRatioFiner,
00059 const ProblemDomain& a_domain,
00060 BCHolder a_bc,
00061 const Copier& a_exchange,
00062 const CFRegion& a_cfregion);
00063
00065 void define(const DisjointBoxLayout& a_grids,
00066 const DisjointBoxLayout& a_gridsFiner,
00067 const Real& a_dxLevel,
00068 int a_refRatio,
00069 int a_refRatioFiner,
00070 const ProblemDomain& a_domain,
00071 BCHolder a_bc,
00072 const Copier& a_exchange,
00073 const CFRegion& a_cfregion);
00074
00076
00079 void define(const DisjointBoxLayout& a_grids,
00080 const DisjointBoxLayout& a_baseBAPtr,
00081 const Real& a_dxLevel,
00082 int a_refRatio,
00083 const ProblemDomain& a_domain,
00084 BCHolder a_bc,
00085 const Copier& a_exchange,
00086 const CFRegion& a_cfregion);
00087
00089
00092 void define(const DisjointBoxLayout& a_grids,
00093 const Real& a_dx,
00094 const ProblemDomain& a_domain,
00095 BCHolder a_bc,
00096 const Copier& a_exchange,
00097 const CFRegion& a_cfregion);
00098
00100
00103 void define(const DisjointBoxLayout& a_grids,
00104 const Real& a_dx,
00105 const ProblemDomain& a_domain,
00106 BCHolder a_bc);
00107
00109
00112 void define(const DisjointBoxLayout& a_grids,
00113 const DisjointBoxLayout* a_baseBAPtr,
00114 Real a_dxLevel,
00115 int a_refRatio,
00116 const ProblemDomain& a_domain,
00117 BCHolder a_bc);
00118
00119 virtual void residual(LevelData<FArrayBox>& a_lhs,
00120 const LevelData<FArrayBox>& a_phi,
00121 const LevelData<FArrayBox>& a_rhs,
00122 bool a_homogeneous = false);
00123
00125 virtual void residualI(LevelData<FArrayBox>& a_lhs,
00126 const LevelData<FArrayBox>& a_phi,
00127 const LevelData<FArrayBox>& a_rhs,
00128 bool a_homogeneous = false);
00129
00130 virtual void preCond(LevelData<FArrayBox>& a_correction,
00131 const LevelData<FArrayBox>& a_residual);
00132
00133 virtual void applyOp(LevelData<FArrayBox>& a_lhs,
00134 const LevelData<FArrayBox>& a_phi,
00135 bool a_homogeneous = false);
00136
00138 virtual void applyOpI(LevelData<FArrayBox>& a_lhs,
00139 const LevelData<FArrayBox>& a_phi,
00140 bool a_homogeneous = false);
00141
00142 virtual void applyOpNoBoundary(LevelData<FArrayBox>& a_lhs,
00143 const LevelData<FArrayBox>& a_rhs) ;
00144
00145 virtual void create(LevelData<FArrayBox>& a_lhs,
00146 const LevelData<FArrayBox>& a_rhs);
00147
00148 virtual void createCoarsened(LevelData<FArrayBox>& a_lhs,
00149 const LevelData<FArrayBox>& a_rhs,
00150 const int& a_refRat);
00151
00152 virtual void assign(LevelData<FArrayBox>& a_lhs,
00153 const LevelData<FArrayBox>& a_rhs);
00154
00155 virtual void assignLocal(LevelData<FArrayBox>& a_lhs,
00156 const LevelData<FArrayBox>& a_rhs);
00157
00158 virtual void buildCopier(Copier& a_copier,
00159 const LevelData<FArrayBox>& a_lhs,
00160 const LevelData<FArrayBox>& a_rhs);
00161
00162 virtual void assignCopier(LevelData<FArrayBox>& a_lhs,
00163 const LevelData<FArrayBox>& a_rhs,
00164 const Copier& a_copier);
00165
00166 virtual void zeroCovered(LevelData<FArrayBox>& a_lhs,
00167 LevelData<FArrayBox>& a_rhs,
00168 const Copier& a_copier);
00169
00170 virtual Real dotProduct(const LevelData<FArrayBox>& a_1,
00171 const LevelData<FArrayBox>& a_2);
00172
00173 virtual void incr(LevelData<FArrayBox>& a_lhs,
00174 const LevelData<FArrayBox>& a_x,
00175 Real a_scale);
00176
00177 virtual void axby(LevelData<FArrayBox>& a_lhs,
00178 const LevelData<FArrayBox>& a_x,
00179 const LevelData<FArrayBox>& a_y,
00180 Real a_a,
00181 Real a_b);
00182
00183 virtual void scale(LevelData<FArrayBox>& a_lhs,
00184 const Real& a_scale);
00185
00186 virtual Real norm(const LevelData<FArrayBox>& a_x,
00187 int a_ord);
00188
00189 virtual Real localMaxNorm(const LevelData<FArrayBox>& a_x);
00190
00191 virtual void setToZero( LevelData<FArrayBox>& a_x);
00197
00198 virtual void relax(LevelData<FArrayBox>& a_e,
00199 const LevelData<FArrayBox>& a_residual,
00200 int a_iterations);
00201
00202 virtual void createCoarser(LevelData<FArrayBox>& a_coarse,
00203 const LevelData<FArrayBox>& a_fine,
00204 bool a_ghosted);
00209 virtual void restrictResidual(LevelData<FArrayBox>& a_resCoarse,
00210 LevelData<FArrayBox>& a_phiFine,
00211 const LevelData<FArrayBox>& a_rhsFine);
00212
00217 virtual void prolongIncrement(LevelData<FArrayBox>& a_phiThisLevel,
00218 const LevelData<FArrayBox>& a_correctCoarse);
00219
00225
00227 virtual int refToCoarser(){ return m_refToCoarser; }
00228
00230 virtual void AMRResidual(LevelData<FArrayBox>& a_residual,
00231 const LevelData<FArrayBox>& a_phiFine,
00232 const LevelData<FArrayBox>& a_phi,
00233 const LevelData<FArrayBox>& a_phiCoarse,
00234 const LevelData<FArrayBox>& a_rhs,
00235 bool a_homogeneousPhysBC,
00236 AMRLevelOp<LevelData<FArrayBox> >* a_finerOp);
00237
00240 virtual void AMRResidualNC(LevelData<FArrayBox>& a_residual,
00241 const LevelData<FArrayBox>& a_phiFine,
00242 const LevelData<FArrayBox>& a_phi,
00243 const LevelData<FArrayBox>& a_rhs,
00244 bool a_homogeneousPhysBC,
00245 AMRLevelOp<LevelData<FArrayBox> >* a_finerOp);
00246
00248 virtual void AMRResidualNF(LevelData<FArrayBox>& a_residual,
00249 const LevelData<FArrayBox>& a_phi,
00250 const LevelData<FArrayBox>& a_phiCoarse,
00251 const LevelData<FArrayBox>& a_rhs,
00252 bool a_homogeneousPhysBC);
00253
00255
00258 virtual void AMROperator(LevelData<FArrayBox>& a_LofPhi,
00259 const LevelData<FArrayBox>& a_phiFine,
00260 const LevelData<FArrayBox>& a_phi,
00261 const LevelData<FArrayBox>& a_phiCoarse,
00262 bool a_homogeneousDomBC,
00263 AMRLevelOp<LevelData<FArrayBox> >* a_finerOp);
00264
00266
00270 virtual void AMROperatorNC(LevelData<FArrayBox>& a_LofPhi,
00271 const LevelData<FArrayBox>& a_phiFine,
00272 const LevelData<FArrayBox>& a_phi,
00273 bool a_homogeneousBC,
00274 AMRLevelOp<LevelData<FArrayBox> >* a_finerOp);
00275
00276
00278
00282 virtual void AMROperatorNF(LevelData<FArrayBox>& a_LofPhi,
00283 const LevelData<FArrayBox>& a_phi,
00284 const LevelData<FArrayBox>& a_phiCoarse,
00285 bool a_homogeneousBC);
00286
00293 virtual void AMRRestrict(LevelData<FArrayBox>& a_resCoarse,
00294 const LevelData<FArrayBox>& a_residual,
00295 const LevelData<FArrayBox>& a_correction,
00296 const LevelData<FArrayBox>& a_coarseCorrection);
00297
00298 virtual void AMRRestrictS(LevelData<FArrayBox>& a_resCoarse,
00299 const LevelData<FArrayBox>& a_residual,
00300 const LevelData<FArrayBox>& a_correction,
00301 const LevelData<FArrayBox>& a_coarseCorrection,
00302 LevelData<FArrayBox>& a_scratch);
00303
00307 virtual void AMRProlong(LevelData<FArrayBox>& a_correction,
00308 const LevelData<FArrayBox>& a_coarseCorrection);
00309
00313 virtual void AMRProlongS(LevelData<FArrayBox>& a_correction,
00314 const LevelData<FArrayBox>& a_coarseCorrection,
00315 LevelData<FArrayBox>& a_temp,
00316 const Copier& a_copier);
00317
00321 virtual void AMRUpdateResidual(LevelData<FArrayBox>& a_residual,
00322 const LevelData<FArrayBox>& a_correction,
00323 const LevelData<FArrayBox>& a_coarseCorrection);
00324
00326
00329 virtual Real AMRNorm(const LevelData<FArrayBox>& a_coarseResid,
00330 const LevelData<FArrayBox>& a_fineResid,
00331 const int& a_refRat,
00332 const int& a_ord);
00333
00334
00336
00338 virtual void setAlphaAndBeta(const Real& a_alpha,
00339 const Real& a_beta);
00340
00342 virtual void setBC(const BCHolder& a_bc);
00343
00345 virtual void diagonalScale(LevelData<FArrayBox>& a_rhs) { ; }
00346
00347 virtual void fillGrad(const LevelData<FArrayBox>& a_phi)
00348 {
00349 ;
00350 }
00351
00352 virtual void reflux(const LevelData<FArrayBox>& a_phiFine,
00353 const LevelData<FArrayBox>& a_phi,
00354 LevelData<FArrayBox>& a_residual,
00355 AMRLevelOp<LevelData<FArrayBox> >* a_finerOp);
00356
00357 virtual void getFlux(FluxBox& a_flux,
00358 const LevelData<FArrayBox>& a_data,
00359 const Box& a_grid,
00360 const DataIndex& a_dit,
00361 Real a_scale)
00362 {
00363 const FArrayBox& data = a_data[a_dit];
00364 a_flux.define(a_grid, a_data.nComp());
00365 for (int idir = 0; idir < SpaceDim; idir++)
00366 {
00367 getFlux(a_flux[idir], data, a_flux[idir].box(), idir, 1);
00368 a_flux[idir] *= a_scale;
00369 }
00370 }
00371
00372 virtual void write(const LevelData<FArrayBox>* a_data,
00373 const char* a_filename);
00374
00377
00378 Real m_alpha, m_beta, m_aCoef, m_bCoef;
00379
00380
00381
00382 Real m_dxCrse;
00383
00384 Vector<IntVect> m_colors;
00385 static int s_exchangeMode;
00386 static int s_relaxMode;
00387 static int s_maxCoarse;
00388
00389 protected:
00390 Real m_dx;
00391 ProblemDomain m_domain;
00392
00393 LevelDataOps<FArrayBox> m_levelOps;
00394
00395 BCHolder m_bc;
00396
00397 CFRegion m_cfregion;
00398 Copier m_exchangeCopier;
00399 QuadCFInterp m_interpWithCoarser;
00400
00401 LevelFluxRegister m_levfluxreg;
00402
00403 DisjointBoxLayout m_coarsenedMGrids;
00404
00405 int m_refToCoarser;
00406 int m_refToFiner;
00407
00408 virtual void levelGSRB(LevelData<FArrayBox>& a_phi,
00409 const LevelData<FArrayBox>& a_rhs);
00410
00411 virtual void levelMultiColor(LevelData<FArrayBox>& a_phi,
00412 const LevelData<FArrayBox>& a_rhs);
00413
00414 virtual void looseGSRB(LevelData<FArrayBox>& a_phi,
00415 const LevelData<FArrayBox>& a_rhs);
00416
00417 virtual void overlapGSRB(LevelData<FArrayBox>& a_phi,
00418 const LevelData<FArrayBox>& a_rhs);
00419
00420 virtual void levelGSRBLazy(LevelData<FArrayBox>& a_phi,
00421 const LevelData<FArrayBox>& a_rhs);
00422
00423 virtual void levelJacobi(LevelData<FArrayBox>& a_phi,
00424 const LevelData<FArrayBox>& a_rhs);
00425
00426 virtual void homogeneousCFInterp(LevelData<FArrayBox>& a_phif);
00427
00428 virtual void homogeneousCFInterp(LevelData<FArrayBox>& a_phif,
00429 const DataIndex& a_datInd,
00430 int a_idir,
00431 Side::LoHiSide a_hiorlo);
00432
00433 virtual void singleBoxCFInterp(FArrayBox& a_phi);
00434
00435 virtual void interpOnIVSHomo(LevelData<FArrayBox>& a_phif,
00436 const DataIndex& a_datInd,
00437 const int a_idir,
00438 const Side::LoHiSide a_hiorlo,
00439 const IntVectSet& a_interpIVS);
00440
00441 virtual void getFlux(FArrayBox& a_flux,
00442 const FArrayBox& a_data,
00443 const Box& a_edgebox,
00444 int a_dir,
00445 int a_ref = 1) const ;
00446
00447 virtual void getFlux(FArrayBox& a_flux,
00448 const FArrayBox& a_data,
00449 int a_dir,
00450 int a_ref = 1) const ;
00451 };
00452
00454
00457 class AMRPoissonOpFactory: public AMRLevelOpFactory<LevelData<FArrayBox> >
00458 {
00459 public:
00460 virtual ~AMRPoissonOpFactory() { ; }
00461
00463
00474 void define(const ProblemDomain& a_coarseDomain,
00475 const Vector<DisjointBoxLayout>& a_grids,
00476 const Vector<int>& a_refRatios,
00477 const Real& a_coarsedx,
00478 BCHolder a_bc,
00479 Real a_alpha = 0.0,
00480 Real a_beta = 1.0);
00481
00482
00483 void define(const ProblemDomain& a_domain,
00484 const DisjointBoxLayout& a_grid,
00485 const Real& a_dx,
00486 BCHolder a_bc,
00487 int a_maxDepth = -1,
00488 Real a_alpha = 0.0,
00489 Real a_beta = 1.0);
00490
00492 virtual MGLevelOp<LevelData<FArrayBox> >* MGnewOp(const ProblemDomain& a_FineindexSpace,
00493 int a_depth,
00494 bool a_homoOnly = true);
00495
00497 virtual AMRLevelOp<LevelData<FArrayBox> >* AMRnewOp(const ProblemDomain& a_indexSpace);
00498
00500 virtual int refToFiner(const ProblemDomain& a_domain) const;
00501
00502 private:
00503 Vector<ProblemDomain> m_domains;
00504 Vector<DisjointBoxLayout> m_boxes;
00505
00506 Vector<Real> m_dx;
00507 Vector<int> m_refRatios;
00508
00509 BCHolder m_bc;
00510
00511 Real m_alpha;
00512 Real m_beta;
00513
00514 Vector<Copier> m_exchangeCopiers;
00515 Vector<CFRegion> m_cfregion;
00516 };
00517
00518 #include "NamespaceFooter.H"
00519 #endif