Chombo + EB  3.0
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 
37 
38  ///
40 
41  ///
42  /**
43  **/
45  const AMRLevelOpFactory<LevelData<FArrayBox> >& a_factory,
46  const ProblemDomain& a_level0Domain,
47  const Vector<int>& a_refRat,
48  int a_numLevels = -1, int a_verbosity = 3);
49 
50 
51  ///
52  /**
53  This advances a parabolic pde from a_phiOld to a_phiNew using TGA on a non-moving domain with source term a_source
54  **/
55  void oneStep(Vector<LevelData<FArrayBox>*>& a_phiNew,
56  Vector<LevelData<FArrayBox>*>& a_phiOld,
57  Vector<LevelData<FArrayBox>*>& a_source,
58  const Real& a_dt,
59  int a_lbase,
60  int a_lmax,
61  bool a_zeroPhi = true);
62 
63  ///
64  void resetAlphaAndBeta(const Real& a_alpha,
65  const Real& a_beta);
66 
67  void
68  computeDiffusion(Vector< LevelData<FArrayBox>* >& a_diffusiveTerm,
69  Vector< LevelData<FArrayBox>* >& a_phiOld,
70  Vector< LevelData<FArrayBox>* >& a_src,
71  Real a_oldTime, Real a_dt,
72  int a_lbase, int a_lmax, bool a_zeroPhi);
73 
74 
75 protected:
76  void solveHelm(Vector<LevelData<FArrayBox>* >& a_ans,
77  Vector<LevelData<FArrayBox>* >& a_rhs,
78  int a_lbase,
79  int a_lmax,
80  Real a_dt,
81  bool a_zeroPhi);
82 
83  //fills a_ans = dt*kappa*a_source + dt*phiOld
85  Vector<LevelData<FArrayBox>* >& a_source,
86  Vector<LevelData<FArrayBox>* >& a_phiOld,
87  int a_lbase,
88  int a_lmax,
89  Real a_dt);
90  void createData(Vector<LevelData<FArrayBox>* >& a_source,
91  int a_lbase,
92  int a_lmax);
93 
95  newOp(const ProblemDomain& a_indexSpace,
96  const AMRLevelOpFactory<LevelData<FArrayBox> >& a_opFact);
97 
98 private:
99  //You do not own these operators!! don't delete it. the memory is
100  //owned by the solver
108 
109  //copy constructor and operator= disallowed for all the usual reasons
111  {
112  MayDay::Error("invalid operator");
113  }
114 
115  void operator=(const BackwardEuler& a_opin)
116  {
117  MayDay::Error("invalid operator");
118  }
119 
120  /// weak construction is bad. Ref Counted pointers are your friends.
122  {
123  MayDay::Error("invalid operator");
124  }
125 
126 
127 };
128 
129 #include "NamespaceFooter.H"
130 #endif
BackwardEuler()
weak construction is bad. Ref Counted pointers are your friends.
Definition: BackwardEuler.H:121
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:66
TGAHelmOp< LevelData< FArrayBox > > * newOp(const ProblemDomain &a_indexSpace, const AMRLevelOpFactory< LevelData< FArrayBox > > &a_opFact)
ProblemDomain m_level0Domain
Definition: BackwardEuler.H:103
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:130
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:115
void createData(Vector< LevelData< FArrayBox > * > &a_source, int a_lbase, int a_lmax)
Vector< TGAHelmOp< LevelData< FArrayBox > > *> m_ops
Definition: BackwardEuler.H:101
Definition: AMRMultiGrid.H:306
Definition: AMRTGA.H:31
int m_numLevels
Definition: BackwardEuler.H:106
Vector< int > m_refRat
Definition: BackwardEuler.H:104
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:105
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:110
void resetAlphaAndBeta(const Real &a_alpha, const Real &a_beta)
Vector< LevelData< FArrayBox > *> m_rhst
Definition: BackwardEuler.H:102
int m_verbosity
Definition: BackwardEuler.H:106
Definition: AMRMultiGrid.H:231
bool m_dataCreated
Definition: BackwardEuler.H:107