Chombo + EB  3.0
VCAMRPoissonOp2.H
Go to the documentation of this file.
1 #ifdef CH_LANG_CC
2 /*
3  * _______ __
4  * / ___/ / ___ __ _ / / ___
5  * / /__/ _ \/ _ \/ V \/ _ \/ _ \
6  * \___/_//_/\___/_/_/_/_.__/\___/
7  * Please refer to Copyright.txt, in Chombo's root directory.
8  */
9 #endif
10 
11 #ifndef _VCAMRPOISSONOP2_H_
12 #define _VCAMRPOISSONOP2_H_
13 
14 #include "AMRPoissonOp.H"
16 
17 #include "NamespaceHeader.H"
18 
19 ///
20 /**
21  Operator for solving variable-coefficient
22  (alpha * aCoef(x) * I - beta * Div(bCoef(x) . Grad)) phi = rho
23  over an AMR hierarchy.
24 */
26 {
27 public:
28  /**
29  \name VCAMRPoissonOp2 functions */
30  /*@{*/
31 
32  ///
33  /**
34  */
36  {
38  }
39 
40  ///
41  /**
42  */
43  virtual ~VCAMRPoissonOp2()
44  {
45  }
46 
47  ///
48  virtual void residualI(LevelData<FArrayBox>& a_lhs,
49  const LevelData<FArrayBox>& a_phi,
50  const LevelData<FArrayBox>& a_rhs,
51  bool a_homogeneous = false);
52 
53  ///
54  virtual void preCond(LevelData<FArrayBox>& a_correction,
55  const LevelData<FArrayBox>& a_residual);
56 
57  ///
58  virtual void applyOpI(LevelData<FArrayBox>& a_lhs,
59  const LevelData<FArrayBox>& a_phi,
60  bool a_homogeneous = false);
61 
62  virtual void applyOpNoBoundary(LevelData<FArrayBox>& a_lhs,
63  const LevelData<FArrayBox>& a_phi);
64 
65  /*@}*/
66 
67  /**
68 <<<<<<< VCAMRPoissonOp2.H
69 =======
70  \name MGLevelOp functions */
71  /*@{*/
72 
73  /**
74 >>>>>>> 1.6
75  calculate restricted residual
76  a_resCoarse[2h] = I[h->2h] (rhsFine[h] - L[h](phiFine[h])
77  */
78  virtual void restrictResidual(LevelData<FArrayBox>& a_resCoarse,
79  LevelData<FArrayBox>& a_phiFine,
80  const LevelData<FArrayBox>& a_rhsFine);
81 
82  /*@}*/
83 
84  /**
85  \name VCAMRPoissonOp2 functions */
86  /*@{*/
87 
88  /// For tga stuff
89  virtual void setAlphaAndBeta(const Real& a_alpha,
90  const Real& a_beta);
91 
92  /// Also calls reset lambda
93  virtual void setCoefs(const RefCountedPtr<LevelData<FArrayBox> >& a_aCoef,
94  const RefCountedPtr<LevelData<FluxBox> >& a_bCoef,
95  const Real& a_alpha,
96  const Real& a_beta);
97 
98  /// Should be called before the relaxation parameter is needed.
99  virtual void resetLambda();
100 
101  /// Compute lambda once alpha, aCoef, beta, bCoef are defined
102  virtual void computeLambda();
103 
104  virtual void reflux(const LevelData<FArrayBox>& a_phiFine,
105  const LevelData<FArrayBox>& a_phi,
106  LevelData<FArrayBox>& a_residual,
107  AMRLevelOp<LevelData<FArrayBox> >* a_finerOp);
108 
109  /*@}*/
110 
111  //! This is called on multigrid operators when their AMR operators
112  //! are altered.
113  void finerOperatorChanged(const MGLevelOp<LevelData<FArrayBox> >& a_operator,
114  int a_coarseningFactor);
115 
116  //! Returns identity coefficient data.
118  {
119  return *m_aCoef;
120  }
121 
122  //! Sets up a model that modifies b coefficient data when the operator's
123  //! time is set.
124  //! \param a_bCoefInterpolator A CoefficientInterpolator that will be used
125  //! to compute the b coefficient at specific
126  //! times.
128  {
129  m_bCoefInterpolator = a_bCoefInterpolator;
130  }
131 
132  //! Returns the B coefficient.
134  {
135  return *m_bCoef;
136  }
137 
138  // Allows access to the B coefficient interpolator.
140  {
141  return m_bCoefInterpolator;
142  }
143 
144  //! Sets the time centering of the operator. This interpolates b coefficient
145  //! data at the given time if an interpolator is set.
146  void setTime(Real a_time);
147 
148  /// Identity operator spatially varying coefficient storage (cell-centered) --- if you change this call resetLambda()
150 
151  /// Laplacian operator spatially varying coefficient storage (face-centered) --- if you change this call resetLambda()
153 
154  /// Reciprocal of the diagonal entry of the operator matrix
156 
157 protected:
160 
161  // Interpolator for b coefficient data.
163 
164  // Current time.
166 
167  // Does the relaxation coefficient need to be reset?
169 
170  virtual void levelGSRB(LevelData<FArrayBox>& a_phi,
171  const LevelData<FArrayBox>& a_rhs);
172 
173  virtual void levelMultiColor(LevelData<FArrayBox>& a_phi,
174  const LevelData<FArrayBox>& a_rhs);
175 
176  virtual void looseGSRB(LevelData<FArrayBox>& a_phi,
177  const LevelData<FArrayBox>& a_rhs);
178 
179  virtual void overlapGSRB(LevelData<FArrayBox>& a_phi,
180  const LevelData<FArrayBox>& a_rhs);
181 
182  virtual void levelGSRBLazy(LevelData<FArrayBox>& a_phi,
183  const LevelData<FArrayBox>& a_rhs);
184 
185  virtual void levelJacobi(LevelData<FArrayBox>& a_phi,
186  const LevelData<FArrayBox>& a_rhs);
187 
188  /// computes flux over face-centered a_facebox.
189  virtual void getFlux(FArrayBox& a_flux,
190  const FArrayBox& a_data,
191  const FluxBox& a_bCoef,
192  const Box& a_facebox,
193  int a_dir,
194  int a_ref = 1) const ;
195 #if 0
196  /// utility function which computes operator after all bc's have been set
197  void computeOperatorNoBCs(LevelData<FArrayBox>& a_lhs,
198  const LevelData<FArrayBox>& a_phi);
199 #endif
200 };
201 
202 ///
203 /**
204  Factory to create VCAMRPoissonOp2s
205 */
206 class VCAMRPoissonOp2Factory: public AMRLevelOpFactory<LevelData<FArrayBox> >
207 {
208 public:
210 
212  {
213  }
214 
215  ///
216  /**
217  a_coarseDomain is the domain at the coarsest level.
218  a_grids is the AMR hierarchy.
219  a_refRatios are the refinement ratios between levels. The ratio lives
220  with the coarser level so a_refRatios[ilev] is the ratio between
221  ilev and ilev+1
222  a_coarseDx is the grid spacing at the coarsest level.
223  a_bc holds the boundary conditions.
224  a_alpha is the identity constant coefficient
225  a_beta is the laplacian constant coefficient.
226  a_aCoef is the identity spatially varying coefficient
227  a_bCoef is the laplacian spatially varying coefficient.
228  */
229  void define(const ProblemDomain& a_coarseDomain,
230  const Vector<DisjointBoxLayout>& a_grids,
231  const Vector<int>& a_refRatios,
232  const Real& a_coarsedx,
233  BCHolder a_bc,
234  const Real& a_alpha,
236  const Real& a_beta,
238 
239  //! Defines a factory for VCAMRPoissonOp2 which allows the operators to
240  //! allocate their own coefficient data. \f$\alpha\f$ and \f$\beta\f$
241  //! coefficients are initialized to 1.
242  //! \param a_coarseDomain The domain at the coarsest level.
243  //! \param a_grids The disjoint box layouts for the various refinement levels.
244  //! \param a_refRatios The refinement ratios between levels.
245  //! \param a_coarsedx The grid spacing at the coarsest level.
246  //! \param a_bc The boundary condition imposed on the solution.
247  //! \param a_ghostVect The ghost stencil to use in the created coefficient data.
248  void define(const ProblemDomain& a_coarseDomain,
249  const Vector<DisjointBoxLayout>& a_grids,
250  const Vector<int>& a_refRatios,
251  const Real& a_coarsedx,
252  BCHolder a_bc,
253  const IntVect& a_ghostVect);
254 
255  ///
256  virtual MGLevelOp<LevelData<FArrayBox> >* MGnewOp(const ProblemDomain& a_FineindexSpace,
257  int a_depth,
258  bool a_homoOnly = true);
259 
260  ///
261  virtual AMRLevelOp<LevelData<FArrayBox> >* AMRnewOp(const ProblemDomain& a_indexSpace);
262 
263  ///
264  virtual int refToFiner(const ProblemDomain& a_domain) const;
265 
267 
268 private:
269  void setDefaultValues();
270 
273 
275  Vector<int> m_refRatios; // refinement to next coarser level
276 
278 
281 
284 
286 
289 };
290 
291 #include "NamespaceFooter.H"
292 #endif
RefCountedPtr< LevelData< FArrayBox > > m_aCoef
Identity operator spatially varying coefficient storage (cell-centered) — if you change this call res...
Definition: VCAMRPoissonOp2.H:149
LevelData< FArrayBox > & identityCoef()
Returns identity coefficient data.
Definition: VCAMRPoissonOp2.H:117
virtual void preCond(LevelData< FArrayBox > &a_correction, const LevelData< FArrayBox > &a_residual)
Vector< CFRegion > m_cfregion
Definition: VCAMRPoissonOp2.H:288
Real m_time
Definition: VCAMRPoissonOp2.H:165
virtual ~VCAMRPoissonOp2Factory()
Definition: VCAMRPoissonOp2.H:211
A reference-counting handle class.
Definition: RefCountedPtr.H:66
Vector< RefCountedPtr< LevelData< FArrayBox > > > m_aCoef
Definition: VCAMRPoissonOp2.H:282
Definition: BCFunc.H:138
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:130
RefCountedPtr< CoefficientInterpolator< LevelData< FluxBox >, LevelData< FArrayBox > > > m_bCoefInterpolator
Definition: VCAMRPoissonOp2.H:162
virtual void overlapGSRB(LevelData< FArrayBox > &a_phi, const LevelData< FArrayBox > &a_rhs)
void finerOperatorChanged(const MGLevelOp< LevelData< FArrayBox > > &a_operator, int a_coarseningFactor)
virtual void levelJacobi(LevelData< FArrayBox > &a_phi, const LevelData< FArrayBox > &a_rhs)
Real m_beta
Definition: VCAMRPoissonOp2.H:280
VCAMRPoissonOp2()
Definition: VCAMRPoissonOp2.H:35
const int SpaceDim
Definition: SPACE.H:39
Definition: AMRMultiGrid.H:35
Vector< Copier > m_exchangeCopiers
Definition: VCAMRPoissonOp2.H:287
Definition: AMRPoissonOp.H:34
A FArrayBox-like container for face-centered fluxes.
Definition: FluxBox.H:22
Real m_alpha
Definition: VCAMRPoissonOp2.H:279
LevelData< FArrayBox > m_lambda
Reciprocal of the diagonal entry of the operator matrix.
Definition: VCAMRPoissonOp2.H:155
Definition: CoefficientInterpolator.H:29
virtual ~VCAMRPoissonOp2()
Definition: VCAMRPoissonOp2.H:43
virtual void getFlux(FArrayBox &a_flux, const FArrayBox &a_data, const FluxBox &a_bCoef, const Box &a_facebox, int a_dir, int a_ref=1) const
computes flux over face-centered a_facebox.
Vector< ProblemDomain > m_domains
Definition: VCAMRPoissonOp2.H:271
double Real
Definition: REAL.H:33
void define(const ProblemDomain &a_coarseDomain, const Vector< DisjointBoxLayout > &a_grids, const Vector< int > &a_refRatios, const Real &a_coarsedx, BCHolder a_bc, const Real &a_alpha, Vector< RefCountedPtr< LevelData< FArrayBox > > > &a_aCoef, const Real &a_beta, Vector< RefCountedPtr< LevelData< FluxBox > > > &a_bCoef)
virtual void residualI(LevelData< FArrayBox > &a_lhs, const LevelData< FArrayBox > &a_phi, const LevelData< FArrayBox > &a_rhs, bool a_homogeneous=false)
despite what you might think, the "I" here means "Ignore the coarse-fine boundary" ...
Definition: VCAMRPoissonOp2.H:206
Definition: MultiGrid.H:30
Definition: VCAMRPoissonOp2.H:25
Vector< Real > m_dx
Definition: VCAMRPoissonOp2.H:274
BCHolder m_bc
Definition: VCAMRPoissonOp2.H:277
bool m_lambdaNeedsResetting
Definition: VCAMRPoissonOp2.H:168
virtual void looseGSRB(LevelData< FArrayBox > &a_phi, const LevelData< FArrayBox > &a_rhs)
int m_coefficient_average_type
Definition: VCAMRPoissonOp2.H:266
virtual void applyOpI(LevelData< FArrayBox > &a_lhs, const LevelData< FArrayBox > &a_phi, bool a_homogeneous=false)
despite what you might think, the "I" here means "Ignore the coarse-fine boundary" ...
LayoutData< CFIVS > m_hiCFIVS[SpaceDim]
Definition: VCAMRPoissonOp2.H:159
virtual void levelGSRBLazy(LevelData< FArrayBox > &a_phi, const LevelData< FArrayBox > &a_rhs)
Vector< RefCountedPtr< LevelData< FArrayBox > > > m_lambda
Definition: VCAMRPoissonOp2.H:285
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:465
virtual void setCoefs(const RefCountedPtr< LevelData< FArrayBox > > &a_aCoef, const RefCountedPtr< LevelData< FluxBox > > &a_bCoef, const Real &a_alpha, const Real &a_beta)
Also calls reset lambda.
Vector< RefCountedPtr< LevelData< FluxBox > > > m_bCoef
Definition: VCAMRPoissonOp2.H:283
virtual void reflux(const LevelData< FArrayBox > &a_phiFine, const LevelData< FArrayBox > &a_phi, LevelData< FArrayBox > &a_residual, AMRLevelOp< LevelData< FArrayBox > > *a_finerOp)
virtual AMRLevelOp< LevelData< FArrayBox > > * AMRnewOp(const ProblemDomain &a_indexSpace)
virtual void levelGSRB(LevelData< FArrayBox > &a_phi, const LevelData< FArrayBox > &a_rhs)
RefCountedPtr< LevelData< FluxBox > > m_bCoef
Laplacian operator spatially varying coefficient storage (face-centered) — if you change this call re...
Definition: VCAMRPoissonOp2.H:152
void setBCoefInterpolator(RefCountedPtr< CoefficientInterpolator< LevelData< FluxBox >, LevelData< FArrayBox > > > &a_bCoefInterpolator)
Definition: VCAMRPoissonOp2.H:127
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
Definition: FArrayBox.H:44
virtual void setAlphaAndBeta(const Real &a_alpha, const Real &a_beta)
For tga stuff.
LayoutData< CFIVS > m_loCFIVS[SpaceDim]
Definition: VCAMRPoissonOp2.H:158
void setTime(Real a_time)
Vector< int > m_refRatios
Definition: VCAMRPoissonOp2.H:275
virtual void restrictResidual(LevelData< FArrayBox > &a_resCoarse, LevelData< FArrayBox > &a_phiFine, const LevelData< FArrayBox > &a_rhsFine)
virtual void applyOpNoBoundary(LevelData< FArrayBox > &a_lhs, const LevelData< FArrayBox > &a_phi)
Definition: AMRMultiGrid.H:231
virtual void levelMultiColor(LevelData< FArrayBox > &a_phi, const LevelData< FArrayBox > &a_rhs)
LevelData< FluxBox > & BCoef()
Returns the B coefficient.
Definition: VCAMRPoissonOp2.H:133
virtual MGLevelOp< LevelData< FArrayBox > > * MGnewOp(const ProblemDomain &a_FineindexSpace, int a_depth, bool a_homoOnly=true)
virtual int refToFiner(const ProblemDomain &a_domain) const
virtual void computeLambda()
Compute lambda once alpha, aCoef, beta, bCoef are defined.
virtual void resetLambda()
Should be called before the relaxation parameter is needed.
Vector< DisjointBoxLayout > m_boxes
Definition: VCAMRPoissonOp2.H:272
RefCountedPtr< CoefficientInterpolator< LevelData< FluxBox >, LevelData< FArrayBox > > > BCoefInterpolator()
Definition: VCAMRPoissonOp2.H:139