Chombo + EB + MF  3.2
TimeInterpolatorRK4.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 _TIMEINTERPOLATORRK4_H_
12 #define _TIMEINTERPOLATORRK4_H_
13 
14 #include "FArrayBox.H"
15 #include "DisjointBoxLayout.H"
16 #include "LevelData.H"
17 #include "ProblemDomain.H"
18 #include "NamespaceHeader.H"
19 
20 /// Time interpolator class using 4th-order Runge-Kutta
21 
22 /**
23  */
25 {
26 public:
27  /// Default constructor
28  /**
29  Object requires define() to be called before all other functions.
30  */
32 
33  /// Destructor
34  /**
35  Destroys all objects created by define(). Passed in data references
36  of define() are left alone.
37  */
39 
40  /// Actual constructor.
41  /**
42  Set up object.
43  */
44  void define(/// layout at this level
45  const DisjointBoxLayout& a_thisDisjointBoxLayout,
46  /// layout at next coarser level
47  const DisjointBoxLayout& a_coarserDisjointBoxLayout,
48  /// problem domain on this level
49  const ProblemDomain& a_domain,
50  /// refinement ratio between this level and next coarser level
51  const int& a_refineCoarse,
52  /// number of variables
53  const int& a_numStates,
54  /// layers of ghost cells to be filled in on the coarsened layout at this level
55  const int& a_ghosts);
56 
57  /// Set coarse timestep.
58  void setDt(const Real& a_dt);
59 
60  /// Update Taylor polynomial coefficients with the coarse solution.
61  /**
62  Update Taylor polynomial coefficients with coarse solution a_soln.
63  Ghost cells, too.
64 
65  This function must be called after setDt() and before saveRHS().
66  */
67  void saveInitialSoln(const LevelData<FArrayBox>& a_soln);
68 
69  /// Update Taylor polynomial coefficients with coarse right-hand side.
70  /**
71  Update Taylor polynomial coefficients with coarse right-hand side.
72  Ghost cells, too.
73 
74  This function must be called exactly four times, after saveInitialSoln()
75  and before any calls to interpolate().
76 
77  The counter m_countRHS keeps track of how many times this is called.
78  */
79  void saveRHS(const LevelData<FArrayBox>& a_rhs);
80 
81  /// Interpolate in time using the Taylor polynomial.
82  /**
83  Interpolate in time to a_U on interval a_intvl using the Taylor polynomial.
84  Ghost cells, too.
85  */
86  void interpolate(/// interpolated solution on this level coarsened
88  /// time interpolation coefficient in range [0:1]
89  const Real& a_timeInterpCoeff,
90  /// interval of a_U to fill in
91  const Interval& a_intvl);
92 
93  /// Set RK4 intermediate values in time using the Taylor polynomial.
94  /**
95  Set RK4 intermediate values to a_U on interval a_intvl
96  using the Taylor polynomial.
97  Ghost cells, too.
98  */
99  void intermediate(/// interpolated solution on this level coarsened
101  /// time interpolation coefficient in range [0:1]
102  const Real& a_timeInterpCoeff,
103  /// which RK4 stage: 0, 1, 2, 3
104  const int& a_stage,
105  /// interval of a_U to fill in
106  const Interval& a_intvl) const;
107 
108 protected:
109 
110  /// Reset this object to use with new data
111  void resetData();
112 
113  /// Set a_vec = m_dt * (a_c0, a_c1, a_c2, a_c3).
114  void setVectorDt(Vector<Real>& a_vec, Real a_c0, Real a_c1, Real a_c2, Real a_c3);
115 
117 
118  /// layout for this level, coarsened by m_refToCoarse
120 
121  /// layout for the coarse level
123 
124  /// For copying from rhs on m_coarseLayout to m_rhsCopy on m_thisCoarsenedLayout
126 
127  /// layers of ghost cells around m_thisCoarsenedLayout for m_rhsCopy and m_taylorCoeffs
128  int m_ghosts;
129 
130  /// number of coefficients in Taylor polynomial: this is 4
132 
133  /// ghost vector around m_thisCoarsenedLayout for m_rhsCopy and m_taylorCoeffs
135 
136  /// coarse timestep
138 
139  /// Copy of rhs on m_thisCoarsenedLayout, to be used within saveRHS
141 
142  /// coefficients of the third-degree Taylor polynomial on m_thisCoarsenedLayout with ghost vector m_ghostVect; m_numCoeffs*m_numStates components
144 
145  /// difference between f(U1) and f(U2), used for intermediate-value calculations, on m_thisCoarsenedLayout with ghost vector m_ghostVect; m_numCoeffs*m_numStates components
147 
148  /// whether m_dt has been set
149  bool m_gotDt;
150 
151  /// whether initial solution has been saved
153 
154  /// whether we have the full Taylor polynomial
156 
157  /// number of times saveRHS function has been called
159 
160  /// Problem domain - index space for next coarser level
162 
163  /// Refinement ratio between this level and the next coarser
165 
166  /// Number of variables
168 
169  /// define() has been called
170  bool m_defined;
171 
172 private:
173 
174  // Disallowed for all the usual reasons
175  void operator=(const TimeInterpolatorRK4&);
177 };
178 
179 #include "NamespaceFooter.H"
180 #endif
int m_refineCoarse
Refinement ratio between this level and the next coarser.
Definition: TimeInterpolatorRK4.H:164
Real m_dt
coarse timestep
Definition: TimeInterpolatorRK4.H:137
int m_numCoeffs
number of coefficients in Taylor polynomial: this is 4
Definition: TimeInterpolatorRK4.H:131
bool m_gotDt
whether m_dt has been set
Definition: TimeInterpolatorRK4.H:149
bool m_gotFullTaylorPoly
whether we have the full Taylor polynomial
Definition: TimeInterpolatorRK4.H:155
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
IntVect m_ghostVect
ghost vector around m_thisCoarsenedLayout for m_rhsCopy and m_taylorCoeffs
Definition: TimeInterpolatorRK4.H:134
void operator=(const TimeInterpolatorRK4 &)
void saveRHS(const LevelData< FArrayBox > &a_rhs)
Update Taylor polynomial coefficients with coarse right-hand side.
A strange but true thing to make copying from one boxlayoutdata to another fast.
Definition: Copier.H:152
Copier m_copier
For copying from rhs on m_coarseLayout to m_rhsCopy on m_thisCoarsenedLayout.
Definition: TimeInterpolatorRK4.H:125
void setDt(const Real &a_dt)
Set coarse timestep.
ProblemDomain m_coarseDomain
Problem domain - index space for next coarser level.
Definition: TimeInterpolatorRK4.H:161
LevelData< FArrayBox > m_rhsCopy
Copy of rhs on m_thisCoarsenedLayout, to be used within saveRHS.
Definition: TimeInterpolatorRK4.H:140
void saveInitialSoln(const LevelData< FArrayBox > &a_soln)
Update Taylor polynomial coefficients with the coarse solution.
void resetData()
Reset this object to use with new data.
Structure for passing component ranges in code.
Definition: Interval.H:23
void define(const DisjointBoxLayout &a_thisDisjointBoxLayout, const DisjointBoxLayout &a_coarserDisjointBoxLayout, const ProblemDomain &a_domain, const int &a_refineCoarse, const int &a_numStates, const int &a_ghosts)
Actual constructor.
LevelData< FArrayBox > m_taylorCoeffs
coefficients of the third-degree Taylor polynomial on m_thisCoarsenedLayout with ghost vector m_ghost...
Definition: TimeInterpolatorRK4.H:143
void interpolate(LevelData< FArrayBox > &a_U, const Real &a_timeInterpCoeff, const Interval &a_intvl)
Interpolate in time using the Taylor polynomial.
double Real
Definition: REAL.H:33
Vector< Vector< Real > > m_coeffs
Definition: TimeInterpolatorRK4.H:116
DisjointBoxLayout m_coarseLayout
layout for the coarse level
Definition: TimeInterpolatorRK4.H:122
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:30
Time interpolator class using 4th-order Runge-Kutta.
Definition: TimeInterpolatorRK4.H:24
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
~TimeInterpolatorRK4()
Destructor.
TimeInterpolatorRK4()
Default constructor.
int m_numStates
Number of variables.
Definition: TimeInterpolatorRK4.H:167
DisjointBoxLayout m_thisCoarsenedLayout
layout for this level, coarsened by m_refToCoarse
Definition: TimeInterpolatorRK4.H:119
int m_ghosts
layers of ghost cells around m_thisCoarsenedLayout for m_rhsCopy and m_taylorCoeffs ...
Definition: TimeInterpolatorRK4.H:128
LevelData< FArrayBox > m_diff12
difference between f(U1) and f(U2), used for intermediate-value calculations, on m_thisCoarsenedLayou...
Definition: TimeInterpolatorRK4.H:146
bool m_gotInitialSoln
whether initial solution has been saved
Definition: TimeInterpolatorRK4.H:152
bool m_defined
define() has been called
Definition: TimeInterpolatorRK4.H:170
void intermediate(LevelData< FArrayBox > &a_U, const Real &a_timeInterpCoeff, const int &a_stage, const Interval &a_intvl) const
Set RK4 intermediate values in time using the Taylor polynomial.
int m_countRHS
number of times saveRHS function has been called
Definition: TimeInterpolatorRK4.H:158
void setVectorDt(Vector< Real > &a_vec, Real a_c0, Real a_c1, Real a_c2, Real a_c3)
Set a_vec = m_dt * (a_c0, a_c1, a_c2, a_c3).