Chombo + EB  3.2
BaseIF.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 _BASEIF_H_
12 #define _BASEIF_H_
13 
14 #include "RealVect.H"
15 #include "ProblemDomain.H"
16 #include "IndexTM.H"
17 #include "EB_TYPEDEFS.H"
18 #include "VolIndex.H"
19 #include "FaceIndex.H"
20 #include "Notation.H"
21 #include "GeometryService.H"
22 #include "IndexedMoments.H"
23 #include "NamespaceHeader.H"
24 
25 ///
26 /**
27  This is the base class for an implicit function specification of geometry.
28  All that is needed is a constructor/destructor, a method to give the value
29  of the function at any point in space (in 2D or 3D), and a factory method
30  (these will probably all be very similar).
31  */
32 class BaseIF
33 {
34 
35 public:
36 
37  /// Default constructor
39  {
40  }
41 
42  /// Default destructor
43  virtual ~BaseIF()
44  {
45  }
46 
47  ///return int x^p dV for the vof
49  const Real & a_dx) const
50  {
51  IndMomSpaceDim retval;
52  retval.setToZero();
53  MayDay::Error("not implemented");
54  return retval;
55  }
56 
57 
58  ///return int_eb x^p dA for the eb
59  virtual IndMomSpaceDim getExactEBMoments(const VolIndex & a_vof,
60  const Real & a_dx) const
61  {
62  IndMomSpaceDim retval;
63  retval.setToZero();
64  MayDay::Error("not implemented");
65  return retval;
66  }
67 
68 
69  ///return int_eb x^p n_i dA for the eb
71  const Real & a_dx,
72  const int & a_ni) const
73  {
74  IndMomSpaceDim retval;
75  retval.setToZero();
76  MayDay::Error("not implemented");
77  return retval;
78  }
79 
80  ///
82  const Real & a_dx,
83  const int & a_ni) const
84  {
85  IndMomSpaceDim retval;
86  retval.setToZero();
87  MayDay::Error("not implemented");
88  return retval;
89  }
90 
91  ///return int x^p dA for the face
93  const Real & a_dx) const
94  {
95  IndMomSDMinOne retval;
96  retval.setToZero();
97  MayDay::Error("not implemented");
98  return retval;
99  }
100 
101 
102 
103  ///
104  /**
105  Return the value of the function at a_point. When delineating a domain,
106  the level set value=0 represents the boundary and value<0 is inside the
107  fluid.
108  */
109  virtual Real value(const RealVect& a_point) const = 0;
110 
111  ///return the partial derivative at the point
112  virtual Real derivative(const IntVect& a_deriv,
113  const RealVect& a_point) const
114  {
115  MayDay::Error("not implemented");
116  return 0.;
117  }
118 
119  virtual Real value(const IndexTM<int,GLOBALDIM> & a_partialDerivative,
120  const IndexTM<Real,GLOBALDIM>& a_point) const
121  {
122  Real retval= 0;
123  if (a_partialDerivative == IndexTM<int,GLOBALDIM>::Zero)
124  {
125  retval = value(a_point);
126  }
127  else
128  {
129  retval = derivative(a_partialDerivative, a_point);
130  }
131  return retval;
132  }
133 
134 
135  virtual Real value(const IntVect & a_deriv,
136  const RealVect & a_point) const
137  {
140  for(int idir = 0; idir < SpaceDim; idir ++)
141  {
142  deriv[idir] = a_deriv[idir];
143  point[idir] = a_point[idir];
144  }
145  return value(deriv, point);
146  }
147 
148  virtual bool fastIntersection(const Box& a_region,
149  const ProblemDomain& a_domain,
150  const RealVect& a_origin,
151  const Real& a_dx) const
152  {
153  RealVect low, high;
154  corners(a_region, a_origin, a_dx, low, high);
155  return fastIntersection(low, high);
156  }
157 
158  virtual bool fastIntersection(const RealVect& a_low,
159  const RealVect& a_high) const
160  {return false;}
161 
162  virtual GeometryService::InOut InsideOutside(const Box& a_region,
163  const ProblemDomain& a_domain,
164  const RealVect& a_origin,
165  const Real& a_dx) const
166  {
167  RealVect low, high;
168  corners(a_region, a_origin, a_dx, low, high);
169  return InsideOutside(low, high);
170  }
171 
173  const RealVect& a_high) const
174 
175  {
176  MayDay::Abort("This class has not implemented a fastIntersection operation");
178  }
179 
180  ///
181  /**
182  Return the value of the function at a_point (of type INdexTM).
183  */
184  virtual Real value(const IndexTM<Real,GLOBALDIM>& a_point) const
185  {
187  RealVect rvpoint;
188  for(int idir = 0; idir < SpaceDim; idir++)
189  {
190  rvpoint[idir] = a_point[idir];
191  }
192  return value(rvpoint);
193  };
194 
195  ///
196  /**
197  Return the derivative of the function at a_point (of type INdexTM).
198  */
199  virtual Real derivative(const IndexTM< int,GLOBALDIM>& a_deriv,
200  const IndexTM<Real,GLOBALDIM>& a_point
201  ) const
202  {
204  RealVect rvpoint;
205  IntVect ivderiv;
206  for(int idir = 0; idir < SpaceDim; idir++)
207  {
208  rvpoint[idir] = a_point[idir];
209  ivderiv[idir] = a_deriv[idir];
210  }
211  return derivative(ivderiv, rvpoint);
212  };
213  ///
214  /**
215  Return a newly allocated derived class. The responsibility
216  for deleting the memory is left to the calling function.
217  */
218  virtual BaseIF* newImplicitFunction() const = 0;
219 
220  virtual void print(ostream& out) const
221  {
222  MayDay::Abort("Print function not implemented");
223  };
224 
225  ///
226  /**
227  An Implicit Function has three options for implementing this function
228  1) do nothing, allow the empty base implementation to remain in place as a null-op
229  2) take the makeGrids call as a directive: Here are the grids EBIndexSpace is wanting to use, configure
230  yourself accordingly to make this efficient for you.
231  3) discard the DisjointBoxLayout EBIndexSpace would like and insert your own implementation of layout
232  EBIndexSpace will faithfully use a_grids returned from this function, including it's load balance.
233  */
234  virtual void makeGrids( const ProblemDomain& a_domain,
235  DisjointBoxLayout& a_grids,
236  const int& a_maxGridSize,
237  const int& a_maxIrregGridSize )
238  {
239  //default operation: Implicit Function and EBIndexSpace do not know about each other's data layout.
240  }
241 
242  static void corners(const Box& a_region, const RealVect& a_origin, const Real& a_dx,
243  RealVect& a_lo, RealVect& a_hi)
244  {
245  a_lo = a_origin + RealVect(a_region.smallEnd())*a_dx;
246  a_hi = a_origin + RealVect(a_region.bigEnd()+IntVect::Unit)*a_dx;
247  }
248 
249  ///
250  /**
251  Inform the implicit function, IF, of a BoxLayout change in the
252  application that is using it. If the implicit function uses
253  distributed data, this gives it a chance to react to the spatial
254  layout of the application that is using it.
255 
256  This is a empty implementation for IFs that don't need this
257  functionality.
258  */
259  virtual void boxLayoutChanged(const DisjointBoxLayout & a_newBoxLayout,
260  const RealVect & a_dx)
261  {
262  }
263 };
264 
265 #include "NamespaceFooter.H"
266 
267 #endif
virtual Real value(const IndexTM< int, GLOBALDIM > &a_partialDerivative, const IndexTM< Real, GLOBALDIM > &a_point) const
Definition: BaseIF.H:119
virtual Real derivative(const IndexTM< int, GLOBALDIM > &a_deriv, const IndexTM< Real, GLOBALDIM > &a_point) const
Definition: BaseIF.H:199
virtual void makeGrids(const ProblemDomain &a_domain, DisjointBoxLayout &a_grids, const int &a_maxGridSize, const int &a_maxIrregGridSize)
Definition: BaseIF.H:234
#define CH_assert(cond)
Definition: CHArray.H:37
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
void setToZero()
Definition: IndexedMoments.H:173
Definition: FaceIndex.H:28
virtual IndMomSpaceDim getExactEBNormalPartialDerivs(const VolIndex &a_vof, const Real &a_dx, const int &a_ni) const
Definition: BaseIF.H:81
BaseIF()
Default constructor.
Definition: BaseIF.H:38
virtual void boxLayoutChanged(const DisjointBoxLayout &a_newBoxLayout, const RealVect &a_dx)
Definition: BaseIF.H:259
const int SpaceDim
Definition: SPACE.H:38
InOut
Definition: GeometryService.H:41
Definition: IndexTM.H:36
virtual GeometryService::InOut InsideOutside(const Box &a_region, const ProblemDomain &a_domain, const RealVect &a_origin, const Real &a_dx) const
Definition: BaseIF.H:162
virtual IndMomSpaceDim getExactEBNormalMoments(const VolIndex &a_vof, const Real &a_dx, const int &a_ni) const
return int_eb x^p n_i dA for the eb
Definition: BaseIF.H:70
const IntVect & bigEnd() const
Definition: Box.H:1768
virtual IndMomSpaceDim getExactEBMoments(const VolIndex &a_vof, const Real &a_dx) const
return int_eb x^p dA for the eb
Definition: BaseIF.H:59
virtual Real value(const IndexTM< Real, GLOBALDIM > &a_point) const
Definition: BaseIF.H:184
Definition: BaseIF.H:32
static const IntVect Unit
Definition: IntVect.H:659
virtual ~BaseIF()
Default destructor.
Definition: BaseIF.H:43
const IntVect & smallEnd() const
{ Accessors}
Definition: Box.H:1754
virtual Real value(const RealVect &a_point) const =0
double Real
Definition: REAL.H:33
virtual bool fastIntersection(const RealVect &a_low, const RealVect &a_high) const
Definition: BaseIF.H:158
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:30
virtual bool fastIntersection(const Box &a_region, const ProblemDomain &a_domain, const RealVect &a_origin, const Real &a_dx) const
Definition: BaseIF.H:148
virtual IndMomSpaceDim getExactVolumeMoments(const VolIndex &a_vof, const Real &a_dx) const
return int x^p dV for the vof
Definition: BaseIF.H:48
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.
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:465
A Real vector in SpaceDim-dimensional space.
Definition: RealVect.H:41
Definition: GeometryService.H:45
virtual GeometryService::InOut InsideOutside(const RealVect &a_low, const RealVect &a_high) const
Definition: BaseIF.H:172
virtual Real derivative(const IntVect &a_deriv, const RealVect &a_point) const
return the partial derivative at the point
Definition: BaseIF.H:112
virtual IndMomSDMinOne getExactFaceMoments(const FaceIndex &a_face, const Real &a_dx) const
return int x^p dA for the face
Definition: BaseIF.H:92
virtual void print(ostream &out) const
Definition: BaseIF.H:220
virtual Real value(const IntVect &a_deriv, const RealVect &a_point) const
Definition: BaseIF.H:135
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
Volume of Fluid Index.
Definition: VolIndex.H:31
static void corners(const Box &a_region, const RealVect &a_origin, const Real &a_dx, RealVect &a_lo, RealVect &a_hi)
Definition: BaseIF.H:242
virtual BaseIF * newImplicitFunction() const =0
#define GLOBALDIM
Definition: Notation.H:35
static void Abort(const char *const a_msg=m_nullString)
Print out message to cerr and exit via abort() (if serial) or MPI_Abort() (if parallel).