11 #ifndef _COEFFICIENTINTERPOLATOR_H__ 12 #define _COEFFICIENTINTERPOLATOR_H__ 18 #include "NamespaceHeader.H" 28 template <
typename LevelData_,
typename SolutionLevelData_ = LevelData_>
61 const SolutionLevelDataType& a_solution,
76 const SolutionLevelDataType& a_solution,
87 virtual void solve(SolutionLevelDataType& a_phi,
88 const SolutionLevelDataType& a_f,
90 const SolutionLevelDataType& a_phi0,
104 const SolutionLevelDataType& a_f,
106 const SolutionLevelDataType& a_phi0,
125 template <
typename LevelData_,
typename SolutionLevelData_>
135 template <
typename LevelData_,
typename SolutionLevelData_>
143 template <
typename LevelData_,
typename SolutionLevelData_>
153 template <
typename LevelData_,
typename SolutionLevelData_>
163 template <
typename LevelData_,
typename SolutionLevelData_>
171 MayDay::Error(
"The solution must be passed to this interpolator!");
175 MayDay::Error(
"Neither the solution-independent nor -dependent interpolate method has\n" 176 "been defined for this subclass.");
181 SolutionLevelData_ phoneyBaloney(a_result.disjointBoxLayout(), 1, a_result.ghostVect());
188 template <
typename LevelData_,
typename SolutionLevelData_>
192 const SolutionLevelData_& a_solution,
197 MayDay::Error(
"Neither the solution-independent nor -dependent interpolate method has\n" 198 "been defined for this subclass.");
208 MayDay::Error(
"The solution-dependent interpolate method has not been defined for this subclass.");
214 template <
typename LevelData_,
typename SolutionLevelData_>
218 const SolutionLevelData_& a_solution,
223 for (
DataIterator dit = a_prime.disjointBoxLayout().dataIterator(); dit.
ok(); ++dit)
224 a_prime[dit()].setVal(0.0);
227 MayDay::Error(
"The derivative w.r.t. the solution has not been implemented for this subclass.");
232 template <
typename LevelData_,
typename SolutionLevelData_>
236 const SolutionLevelData_& a_f,
238 const SolutionLevelData_& a_phi0,
241 MayDay::Error(
"CoefficientInterpolator::solve() must be implemented for this subclass!");
246 template <
typename LevelData_,
typename SolutionLevelData_>
250 const SolutionLevelData_& a_f,
252 const SolutionLevelData_& a_phi0,
256 Real maxError = -FLT_MAX;
257 LevelData_ F(a_phi0.disjointBoxLayout(), a_phi0.nComp()),
258 A(a_phi0.disjointBoxLayout(), a_phi0.nComp());
262 a_phi[dit()].copy(a_phi0[dit()]);
263 F[dit()].copy(A[dit()]);
264 F[dit()] *= a_phi[dit()];
265 F[dit()] -= a_f[dit()];
268 if (maxError < a_tolerance)
271 LevelData_ Aprime(a_phi.disjointBoxLayout(), a_phi.nComp());
272 while (maxError > a_tolerance)
279 Box box = a_phi.disjointBoxLayout().get(dit());
287 for (
int n = 0; n < F.nComp(); ++n)
289 if (
Abs(f(i, n)) > a_tolerance)
291 Real fprime = aprime(i, n) * phi(i, n) + a(i, n);
292 phi(i, n) -= f(i, n) / fprime;
303 F[dit()].copy(A[dit()]);
304 F[dit()] *= a_phi[dit()];
305 F[dit()] -= a_f[dit()];
314 #include "NamespaceFooter.H" bool ok()
Definition: BoxIterator.H:215
LevelData_ LevelDataType
Definition: CoefficientInterpolator.H:33
CoefficientInterpolator()
IndexTM< T, N > min(const IndexTM< T, N > &a_p1, const IndexTM< T, N > &a_p2)
Definition: IndexTMI.H:396
virtual bool ok() const
return true if this iterator is still in its Layout
Definition: LayoutIterator.H:110
Definition: DataIterator.H:140
iterates through the IntVects of a Box
Definition: BoxIterator.H:37
Definition: EBInterface.H:45
Definition: CoefficientInterpolator.H:29
double Real
Definition: REAL.H:33
virtual void interpolate(LevelDataType &a_result, Real a_time)
Definition: CoefficientInterpolator.H:166
int m_numComps
Definition: CoefficientInterpolator.H:112
IndexTM< T, N > max(const IndexTM< T, N > &a_p1, const IndexTM< T, N > &a_p2)
Definition: IndexTMI.H:403
T Abs(const T &a_a)
Definition: Misc.H:53
static void Error(const char *const a_msg=m_nullString, int m_exitCode=CH_DEFAULT_ERROR_CODE)
Print out message to cerr and exit with the specified exit code.
virtual bool dependsUponSolution() const
Definition: CoefficientInterpolator.H:156
int numComps() const
Returns the number of components in the interpolated coefficient.
Definition: CoefficientInterpolator.H:146
bool m_inCall
Definition: CoefficientInterpolator.H:115
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:465
SolutionLevelData_ SolutionLevelDataType
Definition: CoefficientInterpolator.H:34
virtual ~CoefficientInterpolator()
Destructor.
Definition: CoefficientInterpolator.H:137
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
Definition: FArrayBox.H:44
virtual void solve(SolutionLevelDataType &a_phi, const SolutionLevelDataType &a_f, Real a_time, const SolutionLevelDataType &a_phi0, Real a_tolerance)
Definition: CoefficientInterpolator.H:235
T Max(const T &a_a, const T &a_b)
Definition: Misc.H:39
virtual void interpolatePrime(LevelDataType &a_prime, const SolutionLevelDataType &a_solution, Real a_time)
Definition: CoefficientInterpolator.H:217
void NewtonRaphson(SolutionLevelDataType &a_phi, const SolutionLevelDataType &a_f, Real a_time, const SolutionLevelDataType &a_phi0, Real a_tolerance)
Definition: CoefficientInterpolator.H:249
CoefficientInterpolator & operator=(const CoefficientInterpolator &)