00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011 #ifndef _VCAMRPOISSONOP2_H_
00012 #define _VCAMRPOISSONOP2_H_
00013
00014 #include "AMRPoissonOp.H"
00015 #include "CoefficientInterpolator.H"
00016
00017 #include "NamespaceHeader.H"
00018
00019
00020
00021
00022
00023
00024
00025 class VCAMRPoissonOp2 : public AMRPoissonOp
00026 {
00027 public:
00028
00029
00030
00031
00032
00033
00034
00035 VCAMRPoissonOp2()
00036 {
00037 m_lambdaNeedsResetting = true;
00038 }
00039
00040
00041
00042
00043 virtual ~VCAMRPoissonOp2()
00044 {
00045 }
00046
00047
00048 virtual void residualI(LevelData<FArrayBox>& a_lhs,
00049 const LevelData<FArrayBox>& a_phi,
00050 const LevelData<FArrayBox>& a_rhs,
00051 bool a_homogeneous = false);
00052
00053
00054 virtual void preCond(LevelData<FArrayBox>& a_correction,
00055 const LevelData<FArrayBox>& a_residual);
00056
00057
00058 virtual void applyOpI(LevelData<FArrayBox>& a_lhs,
00059 const LevelData<FArrayBox>& a_phi,
00060 bool a_homogeneous = false);
00061
00062 virtual void applyOpNoBoundary(LevelData<FArrayBox>& a_lhs,
00063 const LevelData<FArrayBox>& a_phi);
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 virtual void restrictResidual(LevelData<FArrayBox>& a_resCoarse,
00076 LevelData<FArrayBox>& a_phiFine,
00077 const LevelData<FArrayBox>& a_rhsFine);
00078
00079
00080
00081
00082
00083
00084
00085
00086 virtual void setAlphaAndBeta(const Real& a_alpha,
00087 const Real& a_beta);
00088
00089
00090 virtual void setCoefs(const RefCountedPtr<LevelData<FArrayBox> >& a_aCoef,
00091 const RefCountedPtr<LevelData<FluxBox> >& a_bCoef,
00092 const Real& a_alpha,
00093 const Real& a_beta);
00094
00095
00096 virtual void resetLambda();
00097
00098
00099 virtual void computeLambda();
00100
00101 virtual void reflux(const LevelData<FArrayBox>& a_phiFine,
00102 const LevelData<FArrayBox>& a_phi,
00103 LevelData<FArrayBox>& a_residual,
00104 AMRLevelOp<LevelData<FArrayBox> >* a_finerOp);
00105
00106
00107
00108
00109
00110 void finerOperatorChanged(const MGLevelOp<LevelData<FArrayBox> >& a_operator,
00111 int a_coarseningFactor);
00112
00113
00114 LevelData<FArrayBox>& identityCoef()
00115 {
00116 return *m_aCoef;
00117 }
00118
00119
00120 virtual void diagonalScale(LevelData<FArrayBox>& a_rhs,
00121 bool a_kappaWeighted)
00122 {
00123 DisjointBoxLayout grids = a_rhs.disjointBoxLayout();
00124 for (DataIterator dit = grids.dataIterator(); dit.ok(); ++dit)
00125 {
00126 a_rhs[dit()].mult((*m_aCoef)[dit()]);
00127 }
00128 }
00129
00130 virtual void divideByIdentityCoef(LevelData<FArrayBox>& a_rhs)
00131 {
00132 DisjointBoxLayout grids = a_rhs.disjointBoxLayout();
00133 for (DataIterator dit = grids.dataIterator(); dit.ok(); ++dit)
00134 {
00135 a_rhs[dit()].divide((*m_aCoef)[dit()]);
00136 }
00137 }
00138
00139
00140
00141
00142
00143
00144
00145 void setBCoefInterpolator(RefCountedPtr<CoefficientInterpolator<LevelData<FluxBox>, LevelData<FArrayBox> > >& a_bCoefInterpolator)
00146 {
00147 m_bCoefInterpolator = a_bCoefInterpolator;
00148 }
00149
00150
00151 LevelData<FluxBox>& BCoef()
00152 {
00153 return *m_bCoef;
00154 }
00155
00156
00157 RefCountedPtr<CoefficientInterpolator<LevelData<FluxBox>, LevelData<FArrayBox> > > BCoefInterpolator()
00158 {
00159 return m_bCoefInterpolator;
00160 }
00161
00162
00163
00164 void setTime(Real a_time);
00165
00166
00167 RefCountedPtr<LevelData<FArrayBox> > m_aCoef;
00168
00169
00170 RefCountedPtr<LevelData<FluxBox> > m_bCoef;
00171
00172
00173 LevelData<FArrayBox> m_lambda;
00174
00175
00176
00177
00178 virtual void getFlux(FluxBox& a_flux,
00179 const LevelData<FArrayBox>& a_data,
00180 const Box& a_grid,
00181 const DataIndex& a_dit,
00182 Real a_scale)
00183 {
00184 const FluxBox& bCoef = (*m_bCoef)[a_dit];
00185 getFlux(a_flux,a_data,bCoef,a_grid,a_dit,a_scale);
00186 }
00187
00188
00189 virtual void getFlux(FluxBox& a_flux,
00190 const LevelData<FArrayBox>& a_data,
00191 const FluxBox& a_bCoef,
00192 const Box& a_grid,
00193 const DataIndex& a_dit,
00194 Real a_scale)
00195 {
00196 const FArrayBox& data = a_data[a_dit];
00197 a_flux.define(a_grid, a_data.nComp());
00198 for (int idir=0; idir<SpaceDim; idir++)
00199 {
00200 getFlux(a_flux[idir], data, a_bCoef, a_flux[idir].box(), idir, 1);
00201 a_flux[idir] *= a_scale;
00202 }
00203
00204 }
00205
00206 protected:
00207 LayoutData<CFIVS> m_loCFIVS[SpaceDim];
00208 LayoutData<CFIVS> m_hiCFIVS[SpaceDim];
00209
00210
00211 RefCountedPtr<CoefficientInterpolator<LevelData<FluxBox>, LevelData<FArrayBox> > > m_bCoefInterpolator;
00212
00213
00214 Real m_time;
00215
00216
00217 bool m_lambdaNeedsResetting;
00218
00219 virtual void levelGSRB(LevelData<FArrayBox>& a_phi,
00220 const LevelData<FArrayBox>& a_rhs);
00221
00222 virtual void levelMultiColor(LevelData<FArrayBox>& a_phi,
00223 const LevelData<FArrayBox>& a_rhs);
00224
00225 virtual void looseGSRB(LevelData<FArrayBox>& a_phi,
00226 const LevelData<FArrayBox>& a_rhs);
00227
00228 virtual void overlapGSRB(LevelData<FArrayBox>& a_phi,
00229 const LevelData<FArrayBox>& a_rhs);
00230
00231 virtual void levelGSRBLazy(LevelData<FArrayBox>& a_phi,
00232 const LevelData<FArrayBox>& a_rhs);
00233
00234 virtual void levelJacobi(LevelData<FArrayBox>& a_phi,
00235 const LevelData<FArrayBox>& a_rhs);
00236
00237
00238 virtual void getFlux(FArrayBox& a_flux,
00239 const FArrayBox& a_data,
00240 const FluxBox& a_bCoef,
00241 const Box& a_facebox,
00242 int a_dir,
00243 int a_ref = 1) const ;
00244 #if 0
00245
00246 void computeOperatorNoBCs(LevelData<FArrayBox>& a_lhs,
00247 const LevelData<FArrayBox>& a_phi);
00248 #endif
00249 };
00250
00251
00252
00253
00254
00255 class VCAMRPoissonOp2Factory: public AMRLevelOpFactory<LevelData<FArrayBox> >
00256 {
00257 public:
00258 VCAMRPoissonOp2Factory();
00259
00260 virtual ~VCAMRPoissonOp2Factory()
00261 {
00262 }
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278 void define(const ProblemDomain& a_coarseDomain,
00279 const Vector<DisjointBoxLayout>& a_grids,
00280 const Vector<int>& a_refRatios,
00281 const Real& a_coarsedx,
00282 BCHolder a_bc,
00283 const Real& a_alpha,
00284 Vector<RefCountedPtr<LevelData<FArrayBox> > >& a_aCoef,
00285 const Real& a_beta,
00286 Vector<RefCountedPtr<LevelData<FluxBox> > >& a_bCoef);
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297 void define(const ProblemDomain& a_coarseDomain,
00298 const Vector<DisjointBoxLayout>& a_grids,
00299 const Vector<int>& a_refRatios,
00300 const Real& a_coarsedx,
00301 BCHolder a_bc,
00302 const IntVect& a_ghostVect);
00303
00304
00305 virtual MGLevelOp<LevelData<FArrayBox> >* MGnewOp(const ProblemDomain& a_FineindexSpace,
00306 int a_depth,
00307 bool a_homoOnly = true);
00308
00309
00310 virtual AMRLevelOp<LevelData<FArrayBox> >* AMRnewOp(const ProblemDomain& a_indexSpace);
00311
00312
00313 virtual int refToFiner(const ProblemDomain& a_domain) const;
00314
00315 int m_coefficient_average_type;
00316
00317 private:
00318 void setDefaultValues();
00319
00320 Vector<ProblemDomain> m_domains;
00321 Vector<DisjointBoxLayout> m_boxes;
00322
00323 Vector<Real> m_dx;
00324 Vector<int> m_refRatios;
00325
00326 BCHolder m_bc;
00327
00328 Real m_alpha;
00329 Real m_beta;
00330
00331 Vector<RefCountedPtr<LevelData<FArrayBox> > > m_aCoef;
00332 Vector<RefCountedPtr<LevelData<FluxBox> > > m_bCoef;
00333
00334 Vector<RefCountedPtr<LevelData<FArrayBox> > > m_lambda;
00335
00336 Vector<Copier> m_exchangeCopiers;
00337 Vector<CFRegion> m_cfregion;
00338 };
00339
00340 #include "NamespaceFooter.H"
00341 #endif