Chombo + EB  3.0
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 
131  virtual void relax(LevelData<NodeFArrayBox>& a_e,
132  const LevelData<NodeFArrayBox>& a_residual,
133  int iterations);
134 
135  virtual void createCoarser(LevelData<NodeFArrayBox>& a_coarse,
136  const LevelData<NodeFArrayBox>& a_fine,
137  bool ghosted);
138 
139  ///
140  /**
141  calculate restricted residual
142  a_resCoarse[2h] = I[h->2h] (rhsFine[h] - L[h](phiFine[h])
143  */
144  virtual void restrictResidual(LevelData<NodeFArrayBox>& a_resCoarse,
145  LevelData<NodeFArrayBox>& a_phiFine,
146  const LevelData<NodeFArrayBox>& a_rhsFine);
147 
148  ///
149  /**
150  correct the fine solution based on coarse correction
151  a_phiThisLevel += I[2h->h](a_correctCoarse)
152  */
153  virtual void prolongIncrement(LevelData<NodeFArrayBox>& a_phiThisLevel,
154  const LevelData<NodeFArrayBox>& a_correctCoarse);
155 
156 
157  ///
158  virtual int refToCoarser()
159  {
160  return m_refToCoarser;
161  }
162 
163  ///
164  /** a_residual = a_rhs - L(a_phi, a_phiFine, a_phiCoarse) */
165  virtual void AMRResidual(LevelData<NodeFArrayBox>& a_residual,
166  const LevelData<NodeFArrayBox>& a_phiFine,
167  const LevelData<NodeFArrayBox>& a_phi,
168  const LevelData<NodeFArrayBox>& a_phiCoarse,
169  const LevelData<NodeFArrayBox>& a_rhs,
170  bool a_homogeneousPhysBC,
171  AMRLevelOp<LevelData<NodeFArrayBox> >* a_finerOp);
172 
173 
174  ///
175  /** residual assuming no more coarser AMR levels */
176  virtual void AMRResidualNC(LevelData<NodeFArrayBox>& a_residual,
177  const LevelData<NodeFArrayBox>& a_phiFine,
178  const LevelData<NodeFArrayBox>& a_phi,
179  const LevelData<NodeFArrayBox>& a_rhs,
180  bool a_homogeneousPhysBC,
181  AMRLevelOp<LevelData<NodeFArrayBox> >* a_finerOp);
182 
183  ///
184  /** a_residual = a_rhs - L(a_phi, a_phiCoarse) */
185  virtual void AMRResidualNF(LevelData<NodeFArrayBox>& a_residual,
186  const LevelData<NodeFArrayBox>& a_phi,
187  const LevelData<NodeFArrayBox>& a_phiCoarse,
188  const LevelData<NodeFArrayBox>& a_rhs,
189  bool a_homogeneousPhysBC);
190 
191 
192  ///
193  /** apply AMR operator */
194  virtual void AMROperator(LevelData<NodeFArrayBox>& a_LofPhi,
195  const LevelData<NodeFArrayBox>& a_phiFine,
196  const LevelData<NodeFArrayBox>& a_phi,
197  const LevelData<NodeFArrayBox>& a_phiCoarse,
198  bool a_homogeneousPhysBC,
199  AMRLevelOp<LevelData<NodeFArrayBox> >* a_finerOp);
200 
201 
202  ///
203  /** apply AMR operator, assuming no more coarser AMR levels */
204  virtual void AMROperatorNC(LevelData<NodeFArrayBox>& a_LofPhi,
205  const LevelData<NodeFArrayBox>& a_phiFine,
206  const LevelData<NodeFArrayBox>& a_phi,
207  bool a_homogeneousPhysBC,
208  AMRLevelOp<LevelData<NodeFArrayBox> >* a_finerOp);
209 
210  ///
211  /** AMR operator, assuming no finer AMR levels */
212  virtual void AMROperatorNF(LevelData<NodeFArrayBox>& a_LofPhi,
213  const LevelData<NodeFArrayBox>& a_phi,
214  const LevelData<NodeFArrayBox>& a_phiCoarse,
215  bool a_homogeneousPhysBC);
216 
217 
218 
219 
220  ///
221  /** a_resCoarse = I[h-2h]( a_residual - L(a_correction, a_coarseCorrection))
222  it is assumed that a_resCoarse has already been filled in with the coarse
223  version of AMRResidualNF and that this operation is free to overwrite
224  in the overlap regions.
225  */
226  virtual void AMRRestrict(LevelData<NodeFArrayBox>& a_resCoarse,
227  const LevelData<NodeFArrayBox>& a_residual,
228  const LevelData<NodeFArrayBox>& a_correction,
229  const LevelData<NodeFArrayBox>& a_coarseCorrection);
230 
231  /** a_correction += I[h->h](a_coarseCorrection) */
232  virtual void AMRProlong(LevelData<NodeFArrayBox>& a_correction,
233  const LevelData<NodeFArrayBox>& a_coarseCorrection);
234 
235  /** a_residual = a_residual - L(a_correction, a_coarseCorrection) */
236  virtual void AMRUpdateResidual(LevelData<NodeFArrayBox>& a_residual,
237  const LevelData<NodeFArrayBox>& a_correction,
238  const LevelData<NodeFArrayBox>& a_coarseCorrection);
239 
240  ///
241  /**
242  compute norm over all cells on coarse not covered by finer
243  */
244  virtual Real AMRNorm(const LevelData<NodeFArrayBox>& a_coarseResid,
245  const LevelData<NodeFArrayBox>& a_fineResid,
246  const int& a_refRat,
247  const int& a_ord);
248 
249 
250  /*@}*/
251 
253 
254 protected:
255  //internal--for code reuse
256  void prolongIncrement(LevelData<NodeFArrayBox>& a_phiThisLevel,
257  const LevelData<NodeFArrayBox>& a_correctCoarse,
258  int a_refRat);
259 
260 
276 
278  const LevelData<NodeFArrayBox>& a_residual);
279 
282  const DataIndex& a_datInd,
283  int a_idir,
284  Side::LoHiSide a_hiorlo);
285 
286  /** interior boundary nodes
287  */
289 
290  /** whether each section of m_IVSV is a complete box
291  */
293 
294  // exterior boundary nodes
296 
297  /** interior boundary nodes of the coarsened grids at this level
298  */
300 
301  /** interior boundary nodes of the coarsened grids at next finer level
302  */
304 
305  void setCFIVS(const DisjointBoxLayout& a_grids);
306 };
307 
308 class AMRNodeOpFactory: public AMRLevelOpFactory<LevelData<NodeFArrayBox> >
309 {
310 public:
312  {
313  }
314 
315  /// full AMR definition function
316  void define(const ProblemDomain& a_coarseDomain,
317  const Vector<DisjointBoxLayout>& a_grids,
318  const Vector<int> a_refRatios,
319  const Real& a_coarsedx,
320  NodeBCFunc a_bc,
321  Real a_alpha = 0.,
322  Real a_beta = 1.);
323 
324  /// regular multigrid definition function
325  void define(const ProblemDomain& a_domain,
326  const DisjointBoxLayout& a_grid,
327  const Real& a_dx,
328  NodeBCFunc a_bc,
329  int maxDepth = -1,
330  Real a_alpha = 0.,
331  Real a_beta = 1.);
332 
333  /**
334  \name MGLevelOpFactory functions */
335  /*@{*/
336  virtual AMRNodeOp*
337  MGnewOp(const ProblemDomain& a_FineindexSpace,
338  int depth,
339  bool homoOnly = true);
340 
341  /*@}*/
342 
343  /**
344  \name AMRLevelOpFactory functions */
345  /*@{*/
346  virtual AMRNodeOp* AMRnewOp(const ProblemDomain& a_indexSpace);
347 
348  virtual int refToFiner(const ProblemDomain&) const;
349 
350 private:
354  Vector<int> m_refRatios; // refinement to next coarser level
357 
358 };
359 
360 #include "NamespaceFooter.H"
361 #endif
ProblemDomain m_domainInteriorNodes
Definition: AMRNodeOp.H:261
virtual void prolongIncrement(LevelData< NodeFArrayBox > &a_phiThisLevel, const LevelData< NodeFArrayBox > &a_correctCoarse)
NodeQCFI m_interpWithCoarser
Definition: AMRNodeOp.H:270
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:130
LayoutData< Vector< IntVectSet > > m_IVSVcoarsenedFine
Definition: AMRNodeOp.H:303
Class to interpolate quadratically at coarse/fine interface.
Definition: NodeQCFI.H:28
NodeCoarseAverage m_averageOpMG
Definition: AMRNodeOp.H:271
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:264
DisjointBoxLayout m_coarsenedFineGrids
Definition: AMRNodeOp.H:274
Vector< DisjointBoxLayout > m_boxes
Definition: AMRNodeOp.H:352
A strange but true thing to make copying from one boxlayoutdata to another fast.
Definition: Copier.H:137
Definition: NodeLevelDataOps.H:32
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:252
void levelGSRB(LevelData< NodeFArrayBox > &a_e, const LevelData< NodeFArrayBox > &a_residual)
Real m_dx
Definition: AMRNodeOp.H:262
Real m_dxCrse
Definition: AMRNodeOp.H:263
LayoutData< NodeCFIVS > m_loCFIVS[SpaceDim]
Definition: AMRNodeOp.H:267
Vector< ProblemDomain > m_domains
Definition: AMRNodeOp.H:351
const int SpaceDim
Definition: SPACE.H:39
Definition: AMRMultiGrid.H:35
Vector< Real > m_dx
Definition: AMRNodeOp.H:353
int m_refToFiner
Definition: AMRNodeOp.H:273
virtual void AMRRestrict(LevelData< NodeFArrayBox > &a_resCoarse, const LevelData< NodeFArrayBox > &a_residual, const LevelData< NodeFArrayBox > &a_correction, const LevelData< NodeFArrayBox > &a_coarseCorrection)
int m_refToCoarser
Definition: AMRNodeOp.H:272
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:356
virtual AMRNodeOp * AMRnewOp(const ProblemDomain &a_indexSpace)
LayoutData< Vector< IntVectSet > > m_IVSV
Definition: AMRNodeOp.H:288
double Real
Definition: REAL.H:33
NodeBCFunc m_bc
Definition: AMRNodeOp.H:355
Real m_alpha
Definition: AMRNodeOp.H:356
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:268
LayoutData< Vector< IntVectSet > > m_IVSVcoarsened
Definition: AMRNodeOp.H:299
virtual void assign(LevelData< NodeFArrayBox > &a_lhs, const LevelData< NodeFArrayBox > &a_rhs)
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:31
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:23
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:275
NodeLevelDataOps m_levelOps
Definition: AMRNodeOp.H:265
LayoutData< BitSet > m_IVSVfull
Definition: AMRNodeOp.H:292
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:354
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:311
virtual void restrictResidual(LevelData< NodeFArrayBox > &a_resCoarse, LevelData< NodeFArrayBox > &a_phiFine, const LevelData< NodeFArrayBox > &a_rhsFine)
Definition: AMRNodeOp.H:308
Real m_beta
Definition: AMRNodeOp.H:252
virtual void setToZero(LevelData< NodeFArrayBox > &a_x)
void projectFineInterior(LevelData< NodeFArrayBox > &a_phi, const LevelData< NodeFArrayBox > &a_phiFine)
Copier m_exchangeCopier
Definition: AMRNodeOp.H:269
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:231
NodeBCFunc m_bc
Definition: AMRNodeOp.H:266
virtual void createCoarser(LevelData< NodeFArrayBox > &a_coarse, const LevelData< NodeFArrayBox > &a_fine, bool ghosted)
virtual int refToCoarser()
Definition: AMRNodeOp.H:158
LayoutData< Vector< IntVectSet > > m_IVSVext
Definition: AMRNodeOp.H:295