Chombo + EB + MF  3.2
FourthOrderUtil.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 _FOURTHORDERUTIL_H_
12 #define _FOURTHORDERUTIL_H_
13 
14 #include "REAL.H"
15 #include "DisjointBoxLayout.H"
16 #include "LevelData.H"
17 #include "FArrayBox.H"
18 #include "FluxBox.H"
19 #include "MayDay.H"
20 
21 #include "NamespaceHeader.H"
22 
23 /// utility functions for 4th-order computations
24 
25 ///
26 /** convert from cell centers to face centers:
27  phi[i+1/2] = 9/16*(phi[i] + phi[i+1]) - 1/16*(phi[i-1] + phi[i+2])
28  */
30  const LevelData<FArrayBox>& a_cellData);
31 
32 
33 ///
34 /** convert from cell centers to face centers:
35  phi[i+1/2] = 9/16*(phi[i] + phi[i+1]) - 1/16*(phi[i-1] + phi[i+2])
36  */
37 void fourthOrderCellToFaceCenters(FluxBox& a_faceData,
38  const FArrayBox& a_cellData);
39 
40 
41 ///
42 /** convert from cell centers to face centers:
43  phi[i+1/2] = 9/16*(phi[i] + phi[i+1]) - 1/16*(phi[i-1] + phi[i+2])
44  */
46  const FArrayBox& a_cellData,
47  const Box& a_faceBox,
48  int a_dir);
49 
50 ///
51 /** convert from cell averages to face averages:
52  phi[i+1/2] = 7/12*(phi[i] + phi[i+1]) - 1/12*(phi[i-1] + phi[i+2])
53  */
55  const LevelData<FArrayBox>& a_cellData);
56 
57 
58 ///
59 /** convert from cell averages to face averages:
60  phi[i+1/2] = 7/12*(phi[i] + phi[i+1]) - 1/12*(phi[i-1] + phi[i+2])
61  */
62 void fourthOrderCellToFace(FluxBox& a_faceData,
63  const FArrayBox& a_cellData);
64 
65 
66 ///
67 /** convert from cell averages to face averages:
68  phi[i+1/2] = 7/12*(phi[i] + phi[i+1]) - 1/12*(phi[i-1] + phi[i+2])
69  */
70 void fourthOrderCellToFace(FArrayBox& a_faceData,
71  const FArrayBox& a_cellData,
72  const Box& a_faceBox,
73  int a_dir);
74 
75 ///
76 /** given face-centered phi, increment with Laplacian(phi) correction
77  in place to compute 4th-order face averages of phi
78  (or decrement, a_sgn = -1, to compute face-centered from face-averaged)
79 */
81  int a_sgn = 1);
82 
83 ///
84 /** given cell-centered phi, increment with Laplacian(phi) correction
85  in place to compute 4th-order cell averages of phi
86  (or decrement, a_sgn = -1, to compute cell-centered from cell-averaged)
87 */
89  int a_sgn = 1);
90 
91 
92 ///
93 /** given cell-centered phi, increment with Laplacian(phi) correction
94  in place to compute 4th-order cell averages of phi
95  (or decrement, a_sgn = -1, to compute cell-centered from cell-averaged)
96  using one-sided corrections at domain boundaries
97 */
99  const ProblemDomain& a_domain,
100  int a_sgn = 1);
101 
102 
103 ///
104 /** given cell-centered phi, increment with Laplacian(phi) correction
105  in place to compute 4th-order cell averages of phi
106  (or decrement, a_sgn = -1, to compute cell-centered from cell-averaged)
107 */
109  int a_sgn = 1);
110 
111 ///
112 /** given cell-centered phi, increment with Laplacian(phi) correction
113  in place to compute 4th-order cell averages of phi
114  (or decrement, a_sgn = -1, to compute cell-centered from cell-averaged)
115  using one-sided corrections at domain boundaries
116 */
118  const ProblemDomain& a_domain,
119  const Box& a_bx,
120  int a_sgn = 1);
121 
122 ///
123 /** given face-centered phi, increment with Laplacian(phi) correction
124  in place to compute 4th-order face averages of phi
125  (or decrement, a_sgn = -1, to compute face-centered from face-averaged)
126 */
127 void fourthOrderAverageFace(FluxBox& a_phi,
128  int a_sgn = 1);
129 
130 ///
131 /** replace a_phiAvg by
132  a_phiCen + a_sgn * D^2_(a_dir)(a_phiAvg)
133  */
135  const FArrayBox& a_phiCen,
136  int a_dir,
137  int a_sgn = 1);
138 
139 /// compute fourth-order approximation to u*v
140 /**
141  u and v are assumed to already be fourth-order face-averages
142  */
143 void
144 fourthOrderMultFace(FluxBox& a_uTimesV,
145  const FluxBox& a_u,
146  const FluxBox& a_v,
147  int a_sgn = 1);
148 
149 /// compute fourth-order approximation to u*v
150 /**
151  u and v are assumed to already be fourth-order face-averages
152  */
153 void
154 fourthOrderMultFace(FArrayBox& a_uTimesV,
155  const FArrayBox& a_u,
156  const FArrayBox& a_uForDx,
157  const FArrayBox& a_v,
158  const FArrayBox& a_vForDx,
159  int a_faceDir,
160  int a_sgn = 1);
161 
162 /// compute fourth-order approximation to u*v
163 /**
164  u and v are assumed to already be fourth-order face-averages
165  */
166 void
168  const LevelData<FluxBox>& a_u,
169  const LevelData<FluxBox>& a_v,
170  int a_sgn = 1);
171 
172 /// compute fourth-order approximation to u*v
173 /**
174  u and v are assumed to already be fourth-order cell-averages
175  */
176 void
178  const LevelData<FArrayBox>& a_u,
179  const LevelData<FArrayBox>& a_v);
180 
181 /// Computes <FG> from <F> and <G> using 1-sided derivatives at boundaries
182 void fourthOrderCellProd(FArrayBox& a_FG,
183  const FArrayBox& a_F,
184  const FArrayBox& a_G,
185  const Box& a_box,
186  const ProblemDomain& a_domain,
187  const bool a_oneSidedDG = false,
188  Interval a_fixedDims = Interval() );
189 
190 /// this is just a basic wrapper around the INCREMENTGRADPROD fortran
191 void
192 incrementGradProduct(FArrayBox& a_gradProduct,
193  const FArrayBox& a_u,
194  const FArrayBox& a_v,
195  const Box& a_region,
196  Real a_dx,
197  Real a_factor,
198  int a_dir);
199 
200 /// Fourth-order extrapolate cell-averaged interior data to two ghost cell layers at the domain boundary
201 /**
202  * At the domain boundary, perform a fourth-order extrapolation of cell-averaged interior data
203  * to fill two layers of ghost cells (we assume an exchange will be performed elsewhere
204  * to fill interior ghost cells). Among other possible uses, this enables the
205  * fourthOrderCellToFace utility to then be called without worrying about boundaries.
206  */
207 void
209  const ProblemDomain& a_domain,
210  const Box& a_interiorbox);
211 
212 /// Fill interior ghost cells and boundary ghost cell via extrapolation of cell-averaged data
213 /**
214  * Fill interior ghost cells by copying and boundary ghost cells by extrapolation of cell-averaged data
215  */
216 void
218  const ProblemDomain& a_domain);
219 
220 // Fill width-two boxes on low and high sides of a_srcbox (in all directions)
221 // with cell-averaged values extrapolated to fourth-order from values in a_srcbox.
222 /**
223  * Perform a fourth-order extrapolation of cell-averaged a_data values in a_srcbox to set
224  * the values of a_data in the adjacent width-two boxes on the low and high
225  * sides of a_srcbox.
226  */
227 void
229  const Box& a_srcbox);
230 
231 // Fill width-one boxes on low and high sides of a_srcbox (in all directions)
232 // with values extrapolated to second-order from values in a_srcbox.
233 /**
234  * Perform a second-order extrapolation of a_data values in a_srcbox to set
235  * the values of a_data in the adjacent width-one boxes on the low and high
236  * sides of a_srcbox in all dimensions.
237  */
238 void
240  const Box& a_srcbox);
241 
242 // Fill width-one boxes on low and high sides of a_srcbox in dimension a_dir
243 // with values extrapolated to second-order from values in a_srcbox.
244 /**
245  * Perform a second-order extrapolation of a_data values in a_srcbox to set
246  * the values of a_data in the adjacent width-one boxes on the low and high
247  * sides of a_srcbox in dimension a_dir.
248  */
249 void
251  const Box& a_srcbox,
252  int a_dir);
253 
254 /// Second-order extrapolate at domain boundary (in all directions)
255 /**
256  * Perform a second-order extrapolation of a_data values in a_srcbox to set
257  * the values of a_data in the adjacent width-one boxes on the low and high
258  * sides of a_srcbox. The extrapolation is only performed if the adjacent
259  * width-one boxes lie outside the domain box (i.e., are physical
260  * boundary ghost cells).
261  */
262 void
264  const Box& a_interiorbox,
265  const ProblemDomain& a_domain);
266 
267 /// Second-order extrapolate data in transverse directions
268 /**
269  * Perform a second-order extrapolation of the input a_data from
270  * the a_srcbox box to adjacent destination boxes of width one on
271  * the low and high sides of srcbox in the directions transverse
272  * to a_dir. This can be used, for example, to fill ghost cells
273  * prior to computing the transverse gradients (relative to the
274  * a_dir direction) on cell faces via the product formula (for
275  * computing the fourth-order average of a product in terms of
276  * the averages of each factor).
277  */
278 void
280  const int a_dir,
281  const Box& a_srcbox);
282 
283 /// Second-order extrapolate data in transverse directions at domain boundary
284 /**
285  * Perform a second-order extrapolation of the input a_data from
286  * the a_interiorbox box to adjacent destination boxes of width one on
287  * the low and high sides of a_interiorbox in the directions transverse
288  * to dir. The extrapolation is only performed if the adjacent
289  * width-one boxes lie outside the domain box (i.e., are physical
290  * boundary ghost cells). This can be used to fill ghost cells
291  * prior to computing the transverse gradients (relative to the
292  * a_dir direction) on cell faces via the product formula (for
293  * computing the fourth-order average of a product in terms of
294  * the averages of each factor).
295  */
296 void
298  const int a_dir,
299  const Box& a_interiorbox,
300  const ProblemDomain& a_domain);
301 
302 /// Second-order extrapolate data to faces in transverse directions at domain boundary
303 /**
304  * Perform a second-order extrapolation of the input a_data from
305  * faces of a_interiorbox to adjacent destination boxes of width one on
306  * the low and high sides of a_interiorbox in the directions transverse
307  * to dir. The extrapolation is only performed if the adjacent
308  * width-one boxes lie outside the domain box (i.e., are physical
309  * boundary ghost faces).
310  */
311 void
313  const int a_dir,
314  const Box& a_interiorbox,
315  const ProblemDomain& a_domain);
316 
317 /// Zeroth-order extrapolate at domain boundary (in all directions)
318 /**
319  * Perform a zeroth-order extrapolation of a_data values in a_srcbox to set
320  * the values of a_data in the adjacent width-one boxes on the low and high
321  * sides of a_srcbox. The extrapolation is only performed if the adjacent
322  * width-one boxes lie outside the domain box (i.e., are physical
323  * boundary ghost cells).
324  */
325 void
327  const Box& a_interiorbox,
328  const ProblemDomain& a_domain);
329 
330 /// Determine transverse components of N by averaging from nearby faces
331 void averageTransverseN(FArrayBox& a_Nface,
332  const FArrayBox& a_NtransverseFace,
333  const Box& a_box,
334  const int a_faceDir,
335  const int a_transverseDir);
336 
337 /// Convert from <FG> and <G> to <F>.
338 /**
339  */
340 void cellFGToCellF(FArrayBox& a_F,
341  const FArrayBox& a_FG, // may have multiple components
342  const FArrayBox& a_G, // 1 component
343  const Box& a_box); // where we want to compute F
344 
345 /// Computes <F> from <FG> and <G> using 1-sided derivatives at boundaries
346 void cellFGToCellF(FArrayBox& a_F,
347  const FArrayBox& a_FG,
348  const FArrayBox& a_G,
349  const Box& a_box,
350  const ProblemDomain& a_domain,
351  const bool a_oneSidedDG = false,
352  Interval a_fixedDims = Interval() );
353 
354 #include "NamespaceFooter.H"
355 
356 #endif
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
void fourthOrderAverageCell(FArrayBox &a_phi, int a_sgn=1)
void zerothOrderCellExtrapAtDomainBdry(FArrayBox &a_data, const Box &a_interiorbox, const ProblemDomain &a_domain)
Zeroth-order extrapolate at domain boundary (in all directions)
void fourthOrderCellGhostFill(LevelData< FArrayBox > &a_data, const ProblemDomain &a_domain)
Fill interior ghost cells and boundary ghost cell via extrapolation of cell-averaged data...
void fourthOrderCellToFaceCenters(LevelData< FluxBox > &a_faceData, const LevelData< FArrayBox > &a_cellData)
utility functions for 4th-order computations
void averageTransverseN(FArrayBox &a_Nface, const FArrayBox &a_NtransverseFace, const Box &a_box, const int a_faceDir, const int a_transverseDir)
Determine transverse components of N by averaging from nearby faces.
void fourthOrderCellToFace(LevelData< FluxBox > &a_faceData, const LevelData< FArrayBox > &a_cellData)
A FArrayBox-like container for face-centered fluxes.
Definition: FluxBox.H:22
void fourthOrderCellProd(LevelData< FArrayBox > &a_uTimesV, const LevelData< FArrayBox > &a_u, const LevelData< FArrayBox > &a_v)
compute fourth-order approximation to u*v
Structure for passing component ranges in code.
Definition: Interval.H:23
double Real
Definition: REAL.H:33
void fourthOrderCellExtrapAtDomainBdry(FArrayBox &a_data, const ProblemDomain &a_domain, const Box &a_interiorbox)
Fourth-order extrapolate cell-averaged interior data to two ghost cell layers at the domain boundary...
void secondOrderTransExtrap(FArrayBox &a_data, const int a_dir, const Box &a_srcbox)
Second-order extrapolate data in transverse directions.
void cellFGToCellF(FArrayBox &a_F, const FArrayBox &a_FG, const FArrayBox &a_G, const Box &a_box)
Convert from <FG> and <G> to <F>.
void fourthOrderAverageCenterFace(FArrayBox &a_phiAvg, const FArrayBox &a_phiCen, int a_dir, int a_sgn=1)
void secondOrderTransExtrapAtDomainBdry(FArrayBox &a_data, const int a_dir, const Box &a_interiorbox, const ProblemDomain &a_domain)
Second-order extrapolate data in transverse directions at domain boundary.
void fourthOrderMult(LevelData< FluxBox > &a_uTimesV, const LevelData< FluxBox > &a_u, const LevelData< FluxBox > &a_v, int a_sgn=1)
compute fourth-order approximation to u*v
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:469
void fourthOrderMultFace(FluxBox &a_uTimesV, const FluxBox &a_u, const FluxBox &a_v, int a_sgn=1)
compute fourth-order approximation to u*v
Definition: FArrayBox.H:45
void secondOrderCellExtrapAtDomainBdry(FArrayBox &a_data, const Box &a_interiorbox, const ProblemDomain &a_domain)
Second-order extrapolate at domain boundary (in all directions)
void secondOrderTransExtrapFacesAtDomainBdry(FArrayBox &a_data, const int a_dir, const Box &a_interiorbox, const ProblemDomain &a_domain)
Second-order extrapolate data to faces in transverse directions at domain boundary.
void secondOrderCellExtrap(FArrayBox &a_data, const Box &a_srcbox)
void fourthOrderAverage(LevelData< FluxBox > &a_phi, int a_sgn=1)
void fourthOrderAverageFace(FluxBox &a_phi, int a_sgn=1)
void incrementGradProduct(FArrayBox &a_gradProduct, const FArrayBox &a_u, const FArrayBox &a_v, const Box &a_region, Real a_dx, Real a_factor, int a_dir)
this is just a basic wrapper around the INCREMENTGRADPROD fortran
void fourthOrderCellExtrap(FArrayBox &a_data, const Box &a_srcbox)