Chombo + EB  3.2
AMRNodeOp.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 _AMRNODEOP_H_
12 #define _AMRNODEOP_H_
13 
14 #include "AMRMultiGrid.H"
15 #include "REAL.H"
16 #include "Box.H"
17 #include "LevelDataOps.H"
18 #include "NodeBCFunc.H"
19 #include "NodeFArrayBox.H"
20 #include "NodeCFIVS.H"
21 #include "NodeQCFI.H"
22 #include "CoarseAverage.H"
23 #include "LevelFluxRegister.H"
24 #include "AMRNodeOpF_F.H"
25 #include "NodeCoarseAverage.H"
26 #include "NodeLevelDataOps.H"
27 #include "NamespaceHeader.H"
28 
29 ///
30 /**
31  */
32 class AMRNodeOp : public AMRLevelOp<LevelData<NodeFArrayBox> >
33 {
34 public:
35  ///
36  /**
37  */
38  AMRNodeOp();
39 
40  ///
41  /**
42  */
43  virtual ~AMRNodeOp()
44  {
45  }
46 
47  /**
48  \name LinearOp functions */
49  /*@{*/
50 
51  ///
52  /**
53  */
54  void define(const DisjointBoxLayout& a_grids,
55  const Real& a_dx,
56  const ProblemDomain& a_domain,
57  NodeBCFunc a_bc);
58 
59  ///
60  /**
61  define function for AMRLevelOp which has no finer AMR level
62  */
63  void define(const DisjointBoxLayout& a_grids,
64  const DisjointBoxLayout& a_baseBAPtr,
65  const Real& a_dxLevel,
66  int a_refRatio,
67  const ProblemDomain& a_domain,
68  NodeBCFunc a_bc);
69 
70  ///
71  /** full define function for AMRLevelOp with both coarser and finer levels */
72  void define(const DisjointBoxLayout& a_grids,
73  const DisjointBoxLayout& a_gridsFiner,
74  const DisjointBoxLayout& a_gridsCoarser,
75  const Real& a_dxLevel,
76  int a_refRatio,
77  int a_refRatioFiner,
78  const ProblemDomain& a_domain,
79  NodeBCFunc a_bc);
80 
81  ///
82  /** full define function for AMRLevelOp with finer levels, but no coarser */
83  void define(const DisjointBoxLayout& a_grids,
84  const DisjointBoxLayout& a_gridsFiner,
85  const Real& a_dxLevel,
86  int a_refRatio, // dummy argument, send in 1
87  int a_refRatioFiner,
88  const ProblemDomain& a_domain,
89  NodeBCFunc a_bc);
90 
92  const LevelData<NodeFArrayBox>& a_phiFine);
93 
94  virtual void residual( LevelData<NodeFArrayBox>& a_lhs,
95  const LevelData<NodeFArrayBox>& a_phi,
96  const LevelData<NodeFArrayBox>& a_rhs,
97  bool a_homogeneous = false);
98 
99  virtual void preCond( LevelData<NodeFArrayBox>& a_correction,
100  const LevelData<NodeFArrayBox>& a_residual);
101 
102  virtual void applyOpOnly( LevelData<NodeFArrayBox>& a_lhs,
103  const LevelData<NodeFArrayBox>& a_phi);
104 
105  virtual void applyOp( LevelData<NodeFArrayBox>& a_lhs,
106  const LevelData<NodeFArrayBox>& a_phi,
107  bool a_homogeneous = false);
108  virtual void create( LevelData<NodeFArrayBox>& a_lhs,
109  const LevelData<NodeFArrayBox>& a_rhs);
110  virtual void createCoarsened( LevelData<NodeFArrayBox>& a_lhs,
111  const LevelData<NodeFArrayBox>& a_rhs,
112  const int& a_refRat);
113 
114  virtual void assign( LevelData<NodeFArrayBox>& a_lhs,
115  const LevelData<NodeFArrayBox>& a_rhs) ;
116  virtual Real dotProduct(const LevelData<NodeFArrayBox>& a_1,
117  const LevelData<NodeFArrayBox>& a_2) ;
118  virtual void incr( LevelData<NodeFArrayBox>& a_lhs,
119  const LevelData<NodeFArrayBox>& a_x,
120  Real a_scale) ;
121  virtual void axby( LevelData<NodeFArrayBox>& a_lhs, const LevelData<NodeFArrayBox>& a_x,
122  const LevelData<NodeFArrayBox>& a_y,
123  Real a, Real b) ;
124  virtual void scale(LevelData<NodeFArrayBox>& a_lhs, const Real& a_scale) ;
125 
126  virtual Real norm(const LevelData<NodeFArrayBox>& a_x, int a_ord);
127 
128  virtual void setToZero( LevelData<NodeFArrayBox>& a_x);
129 
130  virtual void relax(LevelData<NodeFArrayBox>& a_e,
131  const LevelData<NodeFArrayBox>& a_residual,
132  int iterations);
133 
134  virtual void createCoarser(LevelData<NodeFArrayBox>& a_coarse,
135  const LevelData<NodeFArrayBox>& a_fine,
136  bool ghosted);
137 
138  ///
139  /**
140  calculate restricted residual
141  a_resCoarse[2h] = I[h->2h] (rhsFine[h] - L[h](phiFine[h])
142  */
143  virtual void restrictResidual(LevelData<NodeFArrayBox>& a_resCoarse,
144  LevelData<NodeFArrayBox>& a_phiFine,
145  const LevelData<NodeFArrayBox>& a_rhsFine);
146 
147  ///
148  /**
149  correct the fine solution based on coarse correction
150  a_phiThisLevel += I[2h->h](a_correctCoarse)
151  */
152  virtual void prolongIncrement(LevelData<NodeFArrayBox>& a_phiThisLevel,
153  const LevelData<NodeFArrayBox>& a_correctCoarse);
154 
155  ///
156  virtual int refToCoarser()
157  {
158  return m_refToCoarser;
159  }
160 
161  ///
162  /** a_residual = a_rhs - L(a_phi, a_phiFine, a_phiCoarse) */
163  virtual void AMRResidual(LevelData<NodeFArrayBox>& a_residual,
164  const LevelData<NodeFArrayBox>& a_phiFine,
165  const LevelData<NodeFArrayBox>& a_phi,
166  const LevelData<NodeFArrayBox>& a_phiCoarse,
167  const LevelData<NodeFArrayBox>& a_rhs,
168  bool a_homogeneousPhysBC,
169  AMRLevelOp<LevelData<NodeFArrayBox> >* a_finerOp);
170 
171  ///
172  /** residual assuming no more coarser AMR levels */
173  virtual void AMRResidualNC(LevelData<NodeFArrayBox>& a_residual,
174  const LevelData<NodeFArrayBox>& a_phiFine,
175  const LevelData<NodeFArrayBox>& a_phi,
176  const LevelData<NodeFArrayBox>& a_rhs,
177  bool a_homogeneousPhysBC,
178  AMRLevelOp<LevelData<NodeFArrayBox> >* a_finerOp);
179 
180  ///
181  /** a_residual = a_rhs - L(a_phi, a_phiCoarse) */
182  virtual void AMRResidualNF(LevelData<NodeFArrayBox>& a_residual,
183  const LevelData<NodeFArrayBox>& a_phi,
184  const LevelData<NodeFArrayBox>& a_phiCoarse,
185  const LevelData<NodeFArrayBox>& a_rhs,
186  bool a_homogeneousPhysBC);
187 
188  ///
189  /** apply AMR operator */
190  virtual void AMROperator(LevelData<NodeFArrayBox>& a_LofPhi,
191  const LevelData<NodeFArrayBox>& a_phiFine,
192  const LevelData<NodeFArrayBox>& a_phi,
193  const LevelData<NodeFArrayBox>& a_phiCoarse,
194  bool a_homogeneousPhysBC,
195  AMRLevelOp<LevelData<NodeFArrayBox> >* a_finerOp);
196 
197  ///
198  /** apply AMR operator, assuming no more coarser AMR levels */
199  virtual void AMROperatorNC(LevelData<NodeFArrayBox>& a_LofPhi,
200  const LevelData<NodeFArrayBox>& a_phiFine,
201  const LevelData<NodeFArrayBox>& a_phi,
202  bool a_homogeneousPhysBC,
203  AMRLevelOp<LevelData<NodeFArrayBox> >* a_finerOp);
204 
205  ///
206  /** AMR operator, assuming no finer AMR levels */
207  virtual void AMROperatorNF(LevelData<NodeFArrayBox>& a_LofPhi,
208  const LevelData<NodeFArrayBox>& a_phi,
209  const LevelData<NodeFArrayBox>& a_phiCoarse,
210  bool a_homogeneousPhysBC);
211 
212  ///
213  /** a_resCoarse = I[h-2h]( a_residual - L(a_correction, a_coarseCorrection))
214  it is assumed that a_resCoarse has already been filled in with the coarse
215  version of AMRResidualNF and that this operation is free to overwrite
216  in the overlap regions.
217  */
218  virtual void AMRRestrict(LevelData<NodeFArrayBox>& a_resCoarse,
219  const LevelData<NodeFArrayBox>& a_residual,
220  const LevelData<NodeFArrayBox>& a_correction,
221  const LevelData<NodeFArrayBox>& a_coarseCorrection,
222  bool a_skip_res = false);
223 
224  /** a_correction += I[h->h](a_coarseCorrection) */
225  virtual void AMRProlong(LevelData<NodeFArrayBox>& a_correction,
226  const LevelData<NodeFArrayBox>& a_coarseCorrection);
227 
228  /** a_residual = a_residual - L(a_correction, a_coarseCorrection) */
229  virtual void AMRUpdateResidual(LevelData<NodeFArrayBox>& a_residual,
230  const LevelData<NodeFArrayBox>& a_correction,
231  const LevelData<NodeFArrayBox>& a_coarseCorrection);
232 
233  ///
234  /**
235  compute norm over all cells on coarse not covered by finer
236  */
237  virtual Real AMRNorm(const LevelData<NodeFArrayBox>& a_coarseResid,
238  const LevelData<NodeFArrayBox>& a_fineResid,
239  const int& a_refRat,
240  const int& a_ord);
241 
242  /*@}*/
243 
245 
246 protected:
247  //internal--for code reuse
248  void prolongIncrement(LevelData<NodeFArrayBox>& a_phiThisLevel,
249  const LevelData<NodeFArrayBox>& a_correctCoarse,
250  int a_refRat);
251 
267 
269  const LevelData<NodeFArrayBox>& a_residual);
270 
273  const DataIndex& a_datInd,
274  int a_idir,
275  Side::LoHiSide a_hiorlo);
276 
277  /** interior boundary nodes
278  */
280 
281  /** whether each section of m_IVSV is a complete box
282  */
284 
285  // exterior boundary nodes
287 
288  /** interior boundary nodes of the coarsened grids at this level
289  */
291 
292  /** interior boundary nodes of the coarsened grids at next finer level
293  */
295 
296  void setCFIVS(const DisjointBoxLayout& a_grids);
297 };
298 
299 class AMRNodeOpFactory: public AMRLevelOpFactory<LevelData<NodeFArrayBox> >
300 {
301 public:
303  {
304  }
305 
306  /// full AMR definition function
307  void define(const ProblemDomain& a_coarseDomain,
308  const Vector<DisjointBoxLayout>& a_grids,
309  const Vector<int> a_refRatios,
310  const Real& a_coarsedx,
311  NodeBCFunc a_bc,
312  Real a_alpha = 0.,
313  Real a_beta = 1.);
314 
315  /// regular multigrid definition function
316  void define(const ProblemDomain& a_domain,
317  const DisjointBoxLayout& a_grid,
318  const Real& a_dx,
319  NodeBCFunc a_bc,
320  int maxDepth = -1,
321  Real a_alpha = 0.,
322  Real a_beta = 1.);
323 
324  /**
325  \name MGLevelOpFactory functions */
326  /*@{*/
327  virtual AMRNodeOp*
328  MGnewOp(const ProblemDomain& a_FineindexSpace,
329  int depth,
330  bool homoOnly = true);
331 
332  /*@}*/
333 
334  /**
335  \name AMRLevelOpFactory functions */
336  /*@{*/
337  virtual AMRNodeOp* AMRnewOp(const ProblemDomain& a_indexSpace);
338 
339  virtual int refToFiner(const ProblemDomain&) const;
340 
341 private:
345  Vector<int> m_refRatios; // refinement to next coarser level
348 
349 };
350 
351 #include "NamespaceFooter.H"
352 #endif
ProblemDomain m_domainInteriorNodes
Definition: AMRNodeOp.H:252
virtual void prolongIncrement(LevelData< NodeFArrayBox > &a_phiThisLevel, const LevelData< NodeFArrayBox > &a_correctCoarse)
NodeQCFI m_interpWithCoarser
Definition: AMRNodeOp.H:261
virtual void residual(LevelData< NodeFArrayBox > &a_lhs, const LevelData< NodeFArrayBox > &a_phi, const LevelData< NodeFArrayBox > &a_rhs, bool a_homogeneous=false)
virtual ~AMRNodeOp()
Definition: AMRNodeOp.H:43
virtual AMRNodeOp * MGnewOp(const ProblemDomain &a_FineindexSpace, int depth, bool homoOnly=true)
virtual void preCond(LevelData< NodeFArrayBox > &a_correction, const LevelData< NodeFArrayBox > &a_residual)
Definition: AMRNodeOp.H:32
virtual void relax(LevelData< NodeFArrayBox > &a_e, const LevelData< NodeFArrayBox > &a_residual, int iterations)
virtual void axby(LevelData< NodeFArrayBox > &a_lhs, const LevelData< NodeFArrayBox > &a_x, const LevelData< NodeFArrayBox > &a_y, Real a, Real b)
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
LayoutData< Vector< IntVectSet > > m_IVSVcoarsenedFine
Definition: AMRNodeOp.H:294
Class to interpolate quadratically at coarse/fine interface.
Definition: NodeQCFI.H:28
NodeCoarseAverage m_averageOpMG
Definition: AMRNodeOp.H:262
virtual void AMRUpdateResidual(LevelData< NodeFArrayBox > &a_residual, const LevelData< NodeFArrayBox > &a_correction, const LevelData< NodeFArrayBox > &a_coarseCorrection)
virtual void applyOp(LevelData< NodeFArrayBox > &a_lhs, const LevelData< NodeFArrayBox > &a_phi, bool a_homogeneous=false)
ProblemDomain m_domain
Definition: AMRNodeOp.H:255
DisjointBoxLayout m_coarsenedFineGrids
Definition: AMRNodeOp.H:265
Vector< DisjointBoxLayout > m_boxes
Definition: AMRNodeOp.H:343
A strange but true thing to make copying from one boxlayoutdata to another fast.
Definition: Copier.H:145
Definition: NodeLevelDataOps.H:31
virtual Real AMRNorm(const LevelData< NodeFArrayBox > &a_coarseResid, const LevelData< NodeFArrayBox > &a_fineResid, const int &a_refRat, const int &a_ord)
void define(const ProblemDomain &a_coarseDomain, const Vector< DisjointBoxLayout > &a_grids, const Vector< int > a_refRatios, const Real &a_coarsedx, NodeBCFunc a_bc, Real a_alpha=0., Real a_beta=1.)
full AMR definition function
Real m_alpha
Definition: AMRNodeOp.H:244
void levelGSRB(LevelData< NodeFArrayBox > &a_e, const LevelData< NodeFArrayBox > &a_residual)
Real m_dx
Definition: AMRNodeOp.H:253
Real m_dxCrse
Definition: AMRNodeOp.H:254
LayoutData< NodeCFIVS > m_loCFIVS[SpaceDim]
Definition: AMRNodeOp.H:258
Vector< ProblemDomain > m_domains
Definition: AMRNodeOp.H:342
virtual void AMRRestrict(LevelData< NodeFArrayBox > &a_resCoarse, const LevelData< NodeFArrayBox > &a_residual, const LevelData< NodeFArrayBox > &a_correction, const LevelData< NodeFArrayBox > &a_coarseCorrection, bool a_skip_res=false)
const int SpaceDim
Definition: SPACE.H:38
Definition: AMRMultiGrid.H:39
Vector< Real > m_dx
Definition: AMRNodeOp.H:344
int m_refToFiner
Definition: AMRNodeOp.H:264
int m_refToCoarser
Definition: AMRNodeOp.H:263
virtual void AMROperatorNF(LevelData< NodeFArrayBox > &a_LofPhi, const LevelData< NodeFArrayBox > &a_phi, const LevelData< NodeFArrayBox > &a_phiCoarse, bool a_homogeneousPhysBC)
virtual void AMRResidualNF(LevelData< NodeFArrayBox > &a_residual, const LevelData< NodeFArrayBox > &a_phi, const LevelData< NodeFArrayBox > &a_phiCoarse, const LevelData< NodeFArrayBox > &a_rhs, bool a_homogeneousPhysBC)
virtual Real norm(const LevelData< NodeFArrayBox > &a_x, int a_ord)
virtual int refToFiner(const ProblemDomain &) const
Real m_beta
Definition: AMRNodeOp.H:347
virtual AMRNodeOp * AMRnewOp(const ProblemDomain &a_indexSpace)
LayoutData< Vector< IntVectSet > > m_IVSV
Definition: AMRNodeOp.H:279
double Real
Definition: REAL.H:33
NodeBCFunc m_bc
Definition: AMRNodeOp.H:346
Real m_alpha
Definition: AMRNodeOp.H:347
virtual Real dotProduct(const LevelData< NodeFArrayBox > &a_1, const LevelData< NodeFArrayBox > &a_2)
virtual void incr(LevelData< NodeFArrayBox > &a_lhs, const LevelData< NodeFArrayBox > &a_x, Real a_scale)
LayoutData< NodeCFIVS > m_hiCFIVS[SpaceDim]
Definition: AMRNodeOp.H:259
LayoutData< Vector< IntVectSet > > m_IVSVcoarsened
Definition: AMRNodeOp.H:290
virtual void assign(LevelData< NodeFArrayBox > &a_lhs, const LevelData< NodeFArrayBox > &a_rhs)
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:30
LoHiSide
Definition: LoHiSide.H:27
void(* NodeBCFunc)(NodeFArrayBox &a_state, const Box &a_valid, const ProblemDomain &a_domain, Real a_dx, bool a_homogeneous)
Definition: NodeBCFunc.H:22
virtual void applyOpOnly(LevelData< NodeFArrayBox > &a_lhs, const LevelData< NodeFArrayBox > &a_phi)
virtual void scale(LevelData< NodeFArrayBox > &a_lhs, const Real &a_scale)
bool m_hasFiner
Definition: AMRNodeOp.H:266
NodeLevelDataOps m_levelOps
Definition: AMRNodeOp.H:256
LayoutData< BitSet > m_IVSVfull
Definition: AMRNodeOp.H:283
virtual void AMRProlong(LevelData< NodeFArrayBox > &a_correction, const LevelData< NodeFArrayBox > &a_coarseCorrection)
virtual void AMROperator(LevelData< NodeFArrayBox > &a_LofPhi, const LevelData< NodeFArrayBox > &a_phiFine, const LevelData< NodeFArrayBox > &a_phi, const LevelData< NodeFArrayBox > &a_phiCoarse, bool a_homogeneousPhysBC, AMRLevelOp< LevelData< NodeFArrayBox > > *a_finerOp)
virtual void createCoarsened(LevelData< NodeFArrayBox > &a_lhs, const LevelData< NodeFArrayBox > &a_rhs, const int &a_refRat)
void setCFIVS(const DisjointBoxLayout &a_grids)
virtual void AMROperatorNC(LevelData< NodeFArrayBox > &a_LofPhi, const LevelData< NodeFArrayBox > &a_phiFine, const LevelData< NodeFArrayBox > &a_phi, bool a_homogeneousPhysBC, AMRLevelOp< LevelData< NodeFArrayBox > > *a_finerOp)
void homogeneousCFInterp(LevelData< NodeFArrayBox > &a_phif)
Definition: DataIndex.H:112
Vector< int > m_refRatios
Definition: AMRNodeOp.H:345
virtual void create(LevelData< NodeFArrayBox > &a_lhs, const LevelData< NodeFArrayBox > &a_rhs)
void define(const DisjointBoxLayout &a_grids, const Real &a_dx, const ProblemDomain &a_domain, NodeBCFunc a_bc)
virtual void AMRResidual(LevelData< NodeFArrayBox > &a_residual, const LevelData< NodeFArrayBox > &a_phiFine, const LevelData< NodeFArrayBox > &a_phi, const LevelData< NodeFArrayBox > &a_phiCoarse, const LevelData< NodeFArrayBox > &a_rhs, bool a_homogeneousPhysBC, AMRLevelOp< LevelData< NodeFArrayBox > > *a_finerOp)
virtual ~AMRNodeOpFactory()
Definition: AMRNodeOp.H:302
virtual void restrictResidual(LevelData< NodeFArrayBox > &a_resCoarse, LevelData< NodeFArrayBox > &a_phiFine, const LevelData< NodeFArrayBox > &a_rhsFine)
Definition: AMRNodeOp.H:299
Real m_beta
Definition: AMRNodeOp.H:244
virtual void setToZero(LevelData< NodeFArrayBox > &a_x)
void projectFineInterior(LevelData< NodeFArrayBox > &a_phi, const LevelData< NodeFArrayBox > &a_phiFine)
Copier m_exchangeCopier
Definition: AMRNodeOp.H:260
Replaces coarse-level data with an average of fine-level data.
Definition: NodeCoarseAverage.H:25
virtual void AMRResidualNC(LevelData< NodeFArrayBox > &a_residual, const LevelData< NodeFArrayBox > &a_phiFine, const LevelData< NodeFArrayBox > &a_phi, const LevelData< NodeFArrayBox > &a_rhs, bool a_homogeneousPhysBC, AMRLevelOp< LevelData< NodeFArrayBox > > *a_finerOp)
Definition: AMRMultiGrid.H:233
NodeBCFunc m_bc
Definition: AMRNodeOp.H:257
virtual void createCoarser(LevelData< NodeFArrayBox > &a_coarse, const LevelData< NodeFArrayBox > &a_fine, bool ghosted)
virtual int refToCoarser()
Definition: AMRNodeOp.H:156
LayoutData< Vector< IntVectSet > > m_IVSVext
Definition: AMRNodeOp.H:286