00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011 #ifndef _VCAMRPOISSONOP_H_
00012 #define _VCAMRPOISSONOP_H_
00013
00014 #include "AMRMultiGrid.H"
00015 #include "REAL.H"
00016 #include "Box.H"
00017 #include "LevelDataOps.H"
00018 #include "BCFunc.H"
00019 #include "FArrayBox.H"
00020 #include "FluxBox.H"
00021 #include "CFIVS.H"
00022 #include "QuadCFInterp.H"
00023 #include "CoarseAverage.H"
00024 #include "LevelFluxRegister.H"
00025 #include "AMRTGA.H"
00026
00027 #include "NamespaceHeader.H"
00028
00030
00035 class VCAMRPoissonOp : public TGAHelmOp<LevelData<FArrayBox> >
00036 {
00037 public:
00038
00040 void setAlphaAndBeta(const Real& a_alpha,
00041 const Real& a_beta);
00042
00044 void diagonalScale(LevelData<FArrayBox> & a_rhs)
00045 {
00046 for(DataIterator dit = a_rhs.dataIterator(); dit.ok(); ++dit)
00047 {
00048 a_rhs[dit()] *= (*m_aCoef)[dit()];
00049 }
00050 }
00052 void setCoefs(const RefCountedPtr<LevelData<FArrayBox> >& a_aCoef,
00053 const RefCountedPtr<LevelData<FluxBox> >& a_bCoef,
00054 const Real& a_alpha,
00055 const Real& a_beta);
00056
00058 void resetLambda();
00059
00061
00063 VCAMRPoissonOp()
00064 {
00065 ;
00066 }
00067
00069
00071 virtual ~VCAMRPoissonOp()
00072 {
00073 ;
00074 }
00075
00077
00080 void define(const DisjointBoxLayout& a_grids,
00081 const Real& a_dx,
00082 const ProblemDomain& a_domain,
00083 BCHolder a_bc);
00084
00086
00089 void define(const DisjointBoxLayout& a_grids,
00090 const DisjointBoxLayout& a_baseBAPtr,
00091 const Real& a_dxLevel,
00092 int a_refRatio,
00093 const ProblemDomain& a_domain,
00094 BCHolder a_bc);
00095
00097
00098 void define(const DisjointBoxLayout& a_grids,
00099 const DisjointBoxLayout& a_gridsFiner,
00100 const DisjointBoxLayout& a_gridsCoarser,
00101 const Real& a_dxLevel,
00102 int a_refRatio,
00103 int a_refRatioFiner,
00104 const ProblemDomain& a_domain,
00105 BCHolder a_bc);
00106
00108
00109 void define(const DisjointBoxLayout& a_grids,
00110 const DisjointBoxLayout& a_gridsFiner,
00111 const Real& a_dxLevel,
00112 int a_refRatio,
00113 int a_refRatioFiner,
00114 const ProblemDomain& a_domain,
00115 BCHolder a_bc);
00116
00118 void computeLambda();
00119
00121 virtual void residual(LevelData<FArrayBox>& a_lhs,
00122 const LevelData<FArrayBox>& a_phi,
00123 const LevelData<FArrayBox>& a_rhs,
00124 bool a_homogeneous = false);
00125
00127 virtual void preCond(LevelData<FArrayBox>& a_correction,
00128 const LevelData<FArrayBox>& a_residual);
00129
00131 virtual void applyOp(LevelData<FArrayBox>& a_lhs,
00132 const LevelData<FArrayBox>& a_phi,
00133 bool a_homogeneous = false);
00135 virtual void applyOpNoBoundary(LevelData<FArrayBox>& a_lhs,
00136 const LevelData<FArrayBox>& a_phi);
00137
00138
00140 virtual void create(LevelData<FArrayBox>& a_lhs,
00141 const LevelData<FArrayBox>& a_rhs);
00142
00144 virtual void createCoarsened(LevelData<FArrayBox>& a_lhs,
00145 const LevelData<FArrayBox>& a_rhs,
00146 const int& a_refRat);
00147
00149 virtual void assign(LevelData<FArrayBox>& a_lhs,
00150 const LevelData<FArrayBox>& a_rhs);
00152 virtual Real dotProduct(const LevelData<FArrayBox>& a_1,
00153 const LevelData<FArrayBox>& a_2);
00154
00156 virtual void incr(LevelData<FArrayBox>& a_lhs,
00157 const LevelData<FArrayBox>& a_x,
00158 Real a_scale);
00159
00161 virtual void axby(LevelData<FArrayBox>& a_lhs,
00162 const LevelData<FArrayBox>& a_x,
00163 const LevelData<FArrayBox>& a_y,
00164 Real a_a,
00165 Real a_b);
00166
00168 virtual void scale(LevelData<FArrayBox>& a_lhs,
00169 const Real& a_scale);
00170
00172 virtual Real norm(const LevelData<FArrayBox>& a_x,
00173 int a_ord);
00174
00176 virtual void setToZero( LevelData<FArrayBox>& a_x);
00177
00183
00185 virtual void relax(LevelData<FArrayBox>& a_e,
00186 const LevelData<FArrayBox>& a_residual,
00187 int a_iterations);
00188
00190 virtual void createCoarser(LevelData<FArrayBox>& a_coarse,
00191 const LevelData<FArrayBox>& a_fine,
00192 bool a_ghosted);
00193
00198 virtual void restrictResidual(LevelData<FArrayBox>& a_resCoarse,
00199 LevelData<FArrayBox>& a_phiFine,
00200 const LevelData<FArrayBox>& a_rhsFine);
00201
00206 virtual void prolongIncrement(LevelData<FArrayBox>& a_phiThisLevel,
00207 const LevelData<FArrayBox>& a_correctCoarse);
00208
00214
00216 virtual int refToCoarser()
00217 {
00218 return m_refToCoarser;
00219 }
00220
00222 virtual void AMRResidual(LevelData<FArrayBox>& a_residual,
00223 const LevelData<FArrayBox>& a_phiFine,
00224 const LevelData<FArrayBox>& a_phi,
00225 const LevelData<FArrayBox>& a_phiCoarse,
00226 const LevelData<FArrayBox>& a_rhs,
00227 bool a_homogeneousPhysBC,
00228 AMRLevelOp<LevelData<FArrayBox> >* a_finerOp);
00229
00231 virtual void AMRResidualNC(LevelData<FArrayBox>& a_residual,
00232 const LevelData<FArrayBox>& a_phiFine,
00233 const LevelData<FArrayBox>& a_phi,
00234 const LevelData<FArrayBox>& a_rhs,
00235 bool a_homogeneousPhysBC,
00236 AMRLevelOp<LevelData<FArrayBox> >* a_finerOp);
00237
00239 virtual void AMRResidualNF(LevelData<FArrayBox>& a_residual,
00240 const LevelData<FArrayBox>& a_phi,
00241 const LevelData<FArrayBox>& a_phiCoarse,
00242 const LevelData<FArrayBox>& a_rhs,
00243 bool a_homogeneousPhysBC);
00244
00245
00247 virtual void AMROperator(LevelData<FArrayBox>& a_LofPhi,
00248 const LevelData<FArrayBox>& a_phiFine,
00249 const LevelData<FArrayBox>& a_phi,
00250 const LevelData<FArrayBox>& a_phiCoarse,
00251 bool a_homogeneousPhysBC,
00252 AMRLevelOp<LevelData<FArrayBox> >* a_finerOp);
00253
00255 virtual void AMROperatorNC(LevelData<FArrayBox>& a_LofPhi,
00256 const LevelData<FArrayBox>& a_phiFine,
00257 const LevelData<FArrayBox>& a_phi,
00258 bool a_homogeneousPhysBC,
00259 AMRLevelOp<LevelData<FArrayBox> >* a_finerOp);
00260
00262 virtual void AMROperatorNF(LevelData<FArrayBox>& a_LofPhi,
00263 const LevelData<FArrayBox>& a_phi,
00264 const LevelData<FArrayBox>& a_phiCoarse,
00265 bool a_homogeneousPhysBC);
00266
00273 virtual void AMRRestrict(LevelData<FArrayBox>& a_resCoarse,
00274 const LevelData<FArrayBox>& a_residual,
00275 const LevelData<FArrayBox>& a_correction,
00276 const LevelData<FArrayBox>& a_coarseCorrection);
00277
00279 virtual void AMRProlong(LevelData<FArrayBox>& a_correction,
00280 const LevelData<FArrayBox>& a_coarseCorrection);
00281
00283 virtual void AMRUpdateResidual(LevelData<FArrayBox>& a_residual,
00284 const LevelData<FArrayBox>& a_correction,
00285 const LevelData<FArrayBox>& a_coarseCorrection);
00286
00288
00291 virtual Real AMRNorm(const LevelData<FArrayBox>& a_coarseResid,
00292 const LevelData<FArrayBox>& a_fineResid,
00293 const int& a_refRat,
00294 const int& a_ord);
00295
00296 virtual void write(const LevelData<FArrayBox>* a_data,
00297 const char* a_filename);
00298
00301
00302 Real m_alpha;
00303
00305 RefCountedPtr<LevelData<FArrayBox> > m_aCoef;
00306
00308 Real m_beta;
00309
00311 RefCountedPtr<LevelData<FluxBox> > m_bCoef;
00312
00314 LevelData<FArrayBox> m_lambda;
00315
00316 Real m_dxCrse;
00317
00318 Real m_dx;
00319 ProblemDomain m_domain;
00320
00321 protected:
00322 LevelDataOps<FArrayBox> m_levelOps;
00323
00324 BCHolder m_bc;
00325
00326 LayoutData<CFIVS> m_loCFIVS[SpaceDim];
00327 LayoutData<CFIVS> m_hiCFIVS[SpaceDim];
00328
00329 Copier m_exchangeCopier;
00330 QuadCFInterp m_interpWithCoarser;
00331
00332 int m_refToCoarser;
00333 int m_refToFiner;
00334
00335 void levelGSRB(LevelData<FArrayBox>& a_e,
00336 const LevelData<FArrayBox>& a_residual);
00337
00338 void levelJacobi(LevelData<FArrayBox>& a_phi,
00339 const LevelData<FArrayBox>& a_rhs);
00340
00341 void homogeneousCFInterp(LevelData<FArrayBox>& a_phif);
00342
00343 void homogeneousCFInterp(LevelData<FArrayBox>& a_phif,
00344 const DataIndex& a_datInd,
00345 int a_idir,
00346 Side::LoHiSide a_hiorlo);
00347
00348 void interpOnIVSHomo(LevelData<FArrayBox>& a_phif,
00349 const DataIndex& a_datInd,
00350 const int a_idir,
00351 const Side::LoHiSide a_hiorlo,
00352 const IntVectSet& a_interpIVS);
00353
00355 void getFlux(FArrayBox& a_flux,
00356 const FArrayBox& a_data,
00357 const FluxBox& a_bCoef,
00358 const Box& a_facebox,
00359 int a_dir,
00360 int a_ref = 1) const ;
00361
00362 void reflux(const LevelData<FArrayBox>& a_phiFine,
00363 const LevelData<FArrayBox>& a_phi,
00364 LevelData<FArrayBox>& a_residual,
00365 AMRLevelOp<LevelData<FArrayBox> >* a_finerOp);
00366
00368 void computeOperatorNoBCs(LevelData<FArrayBox>& a_lhs,
00369 const LevelData<FArrayBox>& a_phi);
00370
00371 };
00372
00374
00377 class VCAMRPoissonOpFactory: public AMRLevelOpFactory<LevelData<FArrayBox> >
00378 {
00379 public:
00380 VCAMRPoissonOpFactory();
00381
00382 virtual ~VCAMRPoissonOpFactory()
00383 {
00384 ;
00385 }
00386
00388
00401 void define(const ProblemDomain& a_coarseDomain,
00402 const Vector<DisjointBoxLayout>& a_grids,
00403 const Vector<int>& a_refRatios,
00404 const Real& a_coarsedx,
00405 BCHolder a_bc,
00406 const Real& a_alpha,
00407 Vector<RefCountedPtr<LevelData<FArrayBox> > >& a_aCoef,
00408 const Real& a_beta,
00409 Vector<RefCountedPtr<LevelData<FluxBox> > >& a_bCoef);
00410
00412 virtual VCAMRPoissonOp* MGnewOp(const ProblemDomain& a_FineindexSpace,
00413 int a_depth,
00414 bool a_homoOnly = true);
00415
00417 virtual VCAMRPoissonOp* AMRnewOp(const ProblemDomain& a_indexSpace);
00418
00420 virtual int refToFiner(const ProblemDomain& a_domain) const;
00421
00422 void setDefaultValues();
00423
00424 int m_coefficient_average_type;
00425
00426 private:
00427 Vector<ProblemDomain> m_domains;
00428 Vector<DisjointBoxLayout> m_boxes;
00429
00430 Vector<Real> m_dx;
00431 Vector<int> m_refRatios;
00432
00433 BCHolder m_bc;
00434
00435 Real m_alpha;
00436 Real m_beta;
00437
00438 Vector<RefCountedPtr<LevelData<FArrayBox> > > m_aCoef;
00439 Vector<RefCountedPtr<LevelData<FluxBox> > > m_bCoef;
00440
00441 Vector<RefCountedPtr<LevelData<FArrayBox> > > m_lambda;
00442 };
00443
00444 #include "NamespaceFooter.H"
00445 #endif