Chombo + EB  3.2
EBLevelRedist.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 // dtgraves mon oct 15 2001
12 
13 #ifndef _EBLEVELREDIST_H_
14 #define _EBLEVELREDIST_H_
15 
16 #include "REAL.H"
17 #include "FArrayBox.H"
18 #include "LevelData.H"
19 #include "DisjointBoxLayout.H"
20 #include "EBISLayout.H"
21 #include "EBCellFAB.H"
22 #include "EBLevelGrid.H"
23 #include "Interval.H"
24 #include "Stencils.H"
25 #include "BaseIVFAB.H"
26 #include "IrregFAB.H"
27 #include "RedistStencil.H"
28 #include "NamespaceHeader.H"
29 
30 ///
31 /**
32  */
34 {
35 public:
36  ///
37  /**
38  Default constructor. User must subsequently call define().
39  */
40  EBLevelRedist();
41 
42  ///
44 
45  ///
46  /**
47  Defining constructor. Constructs a valid object.
48  Equivalent to default construction followed by define().
49  ebisl needs ghost cells out to 3*redistradius of the stencil.
50  This sets the stencil to volume-weighted.
51  Use resetWeights to set to mass weighted or whatever.
52  */
53  EBLevelRedist(const DisjointBoxLayout& a_dbl,
54  const EBISLayout& a_ebisl,
55  const ProblemDomain& a_domain,
56  const int& a_ncomp,
57  int a_redistRad = 1,
58  bool a_do2DStencil = false);
59 
60  ///
61  /**
62  Defines this object. Existing information is overriden.
63  ebisl needs ghost cells out to 3*redistradius
64  */
65  void define(const DisjointBoxLayout& a_dbl,
66  const EBISLayout& a_ebisl,
67  const ProblemDomain& a_domain,
68  const int& a_ncomp,
69  int a_redistRad = 1,
70  bool a_do2DStencil = false);
71 
72  EBLevelRedist(const EBLevelGrid& a_eblg,
73  const int& a_ncomp,
74  int a_redistRad = 1,
75  bool a_do2DStencil = false)
76  {
77  define(a_eblg, a_ncomp, a_redistRad, a_do2DStencil);
78  }
79 
80  void define(const EBLevelGrid& a_eblg,
81  const int& a_ncomp,
82  int a_redistRad = 1,
83  bool a_do2DStencil = false)
84 
85  {
86  define(a_eblg.getDBL(),
87  a_eblg.getEBISL(),
88  a_eblg.getDomain(),
89  a_ncomp, a_redistRad, a_do2DStencil);
90  }
91 
92  ///
93  /**
94  Modify the weights in the stencil by multiplying by
95  the inputs in a normalized way.
96  If you want mass
97  weighting, send in the density.
98  */
99  void resetWeights(const LevelData<EBCellFAB>& modifier,
100  const int& ivar);
101 
102  ///
103  /**
104  Store the input mass difference in the buffers of the class
105  by INCREMENTING the buffer. \\
106  dm += massDiff
107  */
108  void increment(const BaseIVFAB<Real>& massDiff,
109  const DataIndex& datInd,
110  const Interval& variables);
111 
112  void increment(const LevelData<IrregFAB >& a_dm,
113  const Interval& a_variables)
114  {
115  for(DataIterator dit = a_dm.dataIterator(); dit.ok(); ++dit)
116  {
117  const BaseIVFAB<Real>& dmfab = static_cast<const BaseIVFAB<Real>& >(a_dm[dit()]);
118  increment(dmfab, dit(), a_variables);
119  }
120  }
121  ///
122  /**
123  Redistribute the data contained in the internal buffers. \\
124  solution += weight*dm
125  */
126  void redistribute(LevelData<EBCellFAB>& solution,
127  const Interval& variables);
128 
129  ///
130  /**
131  version where solution is not necessarily ncomp long.
132  intervals have to be the same length.
133  srcVar can be up to m_ncomp long.
134  dstVar can be up to solution.nComp().
135  */
136  void redistribute(LevelData<EBCellFAB>& a_solution,
137  const Interval& a_srcVar,
138  const Interval& a_dstVar);
139 
140  ///
141  /**
142  Adjusts an explicit Laplacian calculation so that:
143  a_solution_i =
144  kappa_i*lap_i + (1-kappa_i)*sum_s(kappa_s*lap_s)/(sum_s kappa_s)
145  where s is the set of cells neighboring, but not including i
146  NOTE: a_solution must be passed in equal to a_kappaLap
147  */
148  void fixExplicitLap(const LevelData<EBCellFAB>& a_kappaLap,
149  LevelData<EBCellFAB>& a_solution,
150  const Interval& variables);
151 
152  ///
153  /**
154  Returns true if this object was created with the defining
155  constructor or if define() has been called.
156  */
157  bool isDefined() const;
158 
159  ///
160  /**
161  Reset the mass buffers of the class.
162  */
163  void setToZero();
164 
165 protected:
168  int m_ncomp;
176 private:
177 
178  //forbidden for all the usual reasons
179  void operator=(const EBLevelRedist& a_stenin)
180  {
181  MayDay::Error("Invalid operator");
182  }
183 
184  EBLevelRedist(const EBLevelRedist& a_stenin)
185  {
186  MayDay::Error("Invalid operator");
187  }
188 };
189 
190 #include "NamespaceFooter.H"
191 #endif
EBISLayout getEBISL() const
Definition: EBLevelGrid.H:93
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
RedistStencil m_stencil
Definition: EBLevelRedist.H:167
const ProblemDomain & getDomain() const
Definition: EBLevelGrid.H:132
Definition: EBLevelGrid.H:30
void resetWeights(const LevelData< EBCellFAB > &modifier, const int &ivar)
DataIterator dataIterator() const
Definition: LayoutDataI.H:78
void increment(const LevelData< IrregFAB > &a_dm, const Interval &a_variables)
Definition: EBLevelRedist.H:112
DisjointBoxLayout getDBL() const
Definition: EBLevelGrid.H:86
virtual bool ok() const
return true if this iterator is still in its Layout
Definition: LayoutIterator.H:117
Definition: DataIterator.H:190
void increment(const BaseIVFAB< Real > &massDiff, const DataIndex &datInd, const Interval &variables)
void define(const DisjointBoxLayout &a_dbl, const EBISLayout &a_ebisl, const ProblemDomain &a_domain, const int &a_ncomp, int a_redistRad=1, bool a_do2DStencil=false)
ProblemDomain m_domain
Definition: EBLevelRedist.H:171
Structure for passing component ranges in code.
Definition: Interval.H:23
DisjointBoxLayout m_grids
Definition: EBLevelRedist.H:170
void redistribute(LevelData< EBCellFAB > &solution, const Interval &variables)
int m_ncomp
Definition: EBLevelRedist.H:168
void fixExplicitLap(const LevelData< EBCellFAB > &a_kappaLap, LevelData< EBCellFAB > &a_solution, const Interval &variables)
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:30
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.
void setToZero()
EBISLayout m_ebisl
Definition: EBLevelRedist.H:172
LayoutData< IntVectSet > m_sets
Definition: EBLevelRedist.H:175
void define(const EBLevelGrid &a_eblg, const int &a_ncomp, int a_redistRad=1, bool a_do2DStencil=false)
Definition: EBLevelRedist.H:80
Definition: DataIndex.H:112
stencil for mass redistribution
Definition: RedistStencil.H:38
int m_redistRad
Definition: EBLevelRedist.H:169
int redistRad
Definition: EBLevelRedist.H:166
EBLevelRedist(const EBLevelRedist &a_stenin)
Definition: EBLevelRedist.H:184
bool m_isDefined
Definition: EBLevelRedist.H:173
void operator=(const EBLevelRedist &a_stenin)
Definition: EBLevelRedist.H:179
EBLevelRedist(const EBLevelGrid &a_eblg, const int &a_ncomp, int a_redistRad=1, bool a_do2DStencil=false)
Definition: EBLevelRedist.H:72
Definition: EBISLayout.H:39
bool isDefined() const
LevelData< BaseIVFAB< Real > > m_buffer
Definition: EBLevelRedist.H:174
Definition: EBLevelRedist.H:33