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,
124 template <
typename LevelData_,
typename SolutionLevelData_>
134 template <
typename LevelData_,
typename SolutionLevelData_>
142 template <
typename LevelData_,
typename SolutionLevelData_>
152 template <
typename LevelData_,
typename SolutionLevelData_>
162 template <
typename LevelData_,
typename SolutionLevelData_>
170 MayDay::Error(
"The solution must be passed to this interpolator!");
174 MayDay::Error(
"Neither the solution-independent nor -dependent interpolate method has\n" 175 "been defined for this subclass.");
180 SolutionLevelData_ phoneyBaloney(a_result.disjointBoxLayout(), 1, a_result.ghostVect());
187 template <
typename LevelData_,
typename SolutionLevelData_>
191 const SolutionLevelData_& a_solution,
196 MayDay::Error(
"Neither the solution-independent nor -dependent interpolate method has\n" 197 "been defined for this subclass.");
207 MayDay::Error(
"The solution-dependent interpolate method has not been defined for this subclass.");
213 template <
typename LevelData_,
typename SolutionLevelData_>
217 const SolutionLevelData_& a_solution,
222 for (
DataIterator dit = a_prime.disjointBoxLayout().dataIterator(); dit.
ok(); ++dit)
223 a_prime[dit()].setVal(0.0);
226 MayDay::Error(
"The derivative w.r.t. the solution has not been implemented for this subclass.");
231 template <
typename LevelData_,
typename SolutionLevelData_>
235 const SolutionLevelData_& a_f,
237 const SolutionLevelData_& a_phi0,
240 MayDay::Error(
"CoefficientInterpolator::solve() must be implemented for this subclass!");
245 template <
typename LevelData_,
typename SolutionLevelData_>
249 const SolutionLevelData_& a_f,
251 const SolutionLevelData_& a_phi0,
255 Real maxError = -FLT_MAX;
256 LevelData_ F(a_phi0.disjointBoxLayout(), a_phi0.nComp()),
257 A(a_phi0.disjointBoxLayout(), a_phi0.nComp());
261 a_phi[dit()].copy(a_phi0[dit()]);
262 F[dit()].copy(
A[dit()]);
263 F[dit()] *= a_phi[dit()];
264 F[dit()] -= a_f[dit()];
267 if (maxError < a_tolerance)
270 LevelData_ Aprime(a_phi.disjointBoxLayout(), a_phi.nComp());
271 while (maxError > a_tolerance)
278 Box box = a_phi.disjointBoxLayout().get(dit());
286 for (
int n = 0; n < F.nComp(); ++n)
288 if (
Abs(f(i, n)) > a_tolerance)
290 Real fprime = aprime(i, n) * phi(i, n) + a(i, n);
291 phi(i, n) -= f(i, n) / fprime;
302 F[dit()].copy(
A[dit()]);
303 F[dit()] *= a_phi[dit()];
304 F[dit()] -= a_f[dit()];
313 #include "NamespaceFooter.H" bool ok()
Definition: BoxIterator.H:281
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:394
virtual bool ok() const
return true if this iterator is still in its Layout
Definition: LayoutIterator.H:117
Definition: DataIterator.H:190
iterates through the IntVects of a Box
Definition: BoxIterator.H:37
Definition: EBInterface.H:45
void const char const int const int const int const Real const Real * A
Definition: Lapack.H:83
Definition: CoefficientInterpolator.H:29
double Real
Definition: REAL.H:33
virtual void interpolate(LevelDataType &a_result, Real a_time)
Definition: CoefficientInterpolator.H:165
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:401
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:155
int numComps() const
Returns the number of components in the interpolated coefficient.
Definition: CoefficientInterpolator.H:145
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:136
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
Definition: FArrayBox.H:45
virtual void solve(SolutionLevelDataType &a_phi, const SolutionLevelDataType &a_f, Real a_time, const SolutionLevelDataType &a_phi0, Real a_tolerance)
Definition: CoefficientInterpolator.H:234
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:216
void NewtonRaphson(SolutionLevelDataType &a_phi, const SolutionLevelDataType &a_f, Real a_time, const SolutionLevelDataType &a_phi0, Real a_tolerance)
Definition: CoefficientInterpolator.H:248
CoefficientInterpolator & operator=(const CoefficientInterpolator &)