Chombo + EB + MF  3.2
BackwardEuler.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 _BACKWARDEULER_H_
12 #define _BACKWARDEULER_H_
13 
14 #include <cmath>
15 #include <cstdlib>
16 #include <cstdio>
17 #include <iostream>
18 #include <iomanip>
19 #include <fstream>
20 #include <string>
21 #include "AMRMultiGrid.H"
22 #include "LevelData.H"
23 #include "FArrayBox.H"
24 #include "AMRTGA.H"
25 #include "NamespaceHeader.H"
26 
27 ///
28 /**
29  Solves dphi/dt = L phi + rho
30  using backward euler.
31  Uses TGAHelmOp functionaltity.
32  **/
34 {
35 public:
36  ///
38 
39  ///
40  /**
41  **/
43  const AMRLevelOpFactory<LevelData<FArrayBox> >& a_factory,
44  const ProblemDomain& a_level0Domain,
45  const Vector<int>& a_refRat,
46  int a_numLevels = -1, int a_verbosity = 3);
47 
48  ///
49  /**
50  This advances a parabolic pde from a_phiOld to a_phiNew using TGA on a non-moving domain with source term a_source
51  **/
52  void oneStep(Vector<LevelData<FArrayBox>*>& a_phiNew,
53  Vector<LevelData<FArrayBox>*>& a_phiOld,
54  Vector<LevelData<FArrayBox>*>& a_source,
55  const Real& a_dt,
56  int a_lbase,
57  int a_lmax,
58  bool a_zeroPhi = true);
59 
60  ///
61  void resetAlphaAndBeta(const Real& a_alpha,
62  const Real& a_beta);
63 
64  void
65  computeDiffusion(Vector< LevelData<FArrayBox>* >& a_diffusiveTerm,
66  Vector< LevelData<FArrayBox>* >& a_phiOld,
67  Vector< LevelData<FArrayBox>* >& a_src,
68  Real a_oldTime, Real a_dt,
69  int a_lbase, int a_lmax, bool a_zeroPhi);
70 
71 
72 protected:
73  void solveHelm(Vector<LevelData<FArrayBox>* >& a_ans,
74  Vector<LevelData<FArrayBox>* >& a_rhs,
75  int a_lbase,
76  int a_lmax,
77  Real a_dt,
78  bool a_zeroPhi);
79 
80  //fills a_ans = dt*kappa*a_source + dt*phiOld
82  Vector<LevelData<FArrayBox>* >& a_source,
83  Vector<LevelData<FArrayBox>* >& a_phiOld,
84  int a_lbase,
85  int a_lmax,
86  Real a_dt);
87  void createData(Vector<LevelData<FArrayBox>* >& a_source,
88  int a_lbase,
89  int a_lmax);
90 
92  newOp(const ProblemDomain& a_indexSpace,
93  const AMRLevelOpFactory<LevelData<FArrayBox> >& a_opFact);
94 
95 private:
96  //You do not own these operators!! don't delete it. the memory is
97  //owned by the solver
105 
106  //copy constructor and operator= disallowed for all the usual reasons
108  {
109  MayDay::Error("invalid operator");
110  }
111 
112  void operator=(const BackwardEuler& a_opin)
113  {
114  MayDay::Error("invalid operator");
115  }
116 
117  /// weak construction is bad. Ref Counted pointers are your friends.
119  {
120  MayDay::Error("invalid operator");
121  }
122 };
123 
124 #include "NamespaceFooter.H"
125 
126 #endif
BackwardEuler()
weak construction is bad. Ref Counted pointers are your friends.
Definition: BackwardEuler.H:118
void solveHelm(Vector< LevelData< FArrayBox > * > &a_ans, Vector< LevelData< FArrayBox > * > &a_rhs, int a_lbase, int a_lmax, Real a_dt, bool a_zeroPhi)
A reference-counting handle class.
Definition: RefCountedPtr.H:173
TGAHelmOp< LevelData< FArrayBox > > * newOp(const ProblemDomain &a_indexSpace, const AMRLevelOpFactory< LevelData< FArrayBox > > &a_opFact)
ProblemDomain m_level0Domain
Definition: BackwardEuler.H:100
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
void oneStep(Vector< LevelData< FArrayBox > *> &a_phiNew, Vector< LevelData< FArrayBox > *> &a_phiOld, Vector< LevelData< FArrayBox > *> &a_source, const Real &a_dt, int a_lbase, int a_lmax, bool a_zeroPhi=true)
void operator=(const BackwardEuler &a_opin)
Definition: BackwardEuler.H:112
void createData(Vector< LevelData< FArrayBox > * > &a_source, int a_lbase, int a_lmax)
Vector< TGAHelmOp< LevelData< FArrayBox > > *> m_ops
Definition: BackwardEuler.H:98
Definition: AMRMultiGrid.H:308
Definition: AMRTGA.H:31
int m_numLevels
Definition: BackwardEuler.H:103
Vector< int > m_refRat
Definition: BackwardEuler.H:101
void computeDiffusion(Vector< LevelData< FArrayBox > * > &a_diffusiveTerm, Vector< LevelData< FArrayBox > * > &a_phiOld, Vector< LevelData< FArrayBox > * > &a_src, Real a_oldTime, Real a_dt, int a_lbase, int a_lmax, bool a_zeroPhi)
void createEulerRHS(Vector< LevelData< FArrayBox > * > &a_ans, Vector< LevelData< FArrayBox > * > &a_source, Vector< LevelData< FArrayBox > * > &a_phiOld, int a_lbase, int a_lmax, Real a_dt)
double Real
Definition: REAL.H:33
RefCountedPtr< AMRMultiGrid< LevelData< FArrayBox > > > m_solver
Definition: BackwardEuler.H:102
Definition: BackwardEuler.H:33
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.
BackwardEuler(const BackwardEuler &a_opin)
Definition: BackwardEuler.H:107
void resetAlphaAndBeta(const Real &a_alpha, const Real &a_beta)
Vector< LevelData< FArrayBox > *> m_rhst
Definition: BackwardEuler.H:99
int m_verbosity
Definition: BackwardEuler.H:103
Definition: AMRMultiGrid.H:233
bool m_dataCreated
Definition: BackwardEuler.H:104