Chombo + EB  3.0
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 
18 #include "Notation.H"
19 #include "GeometryService.H"
20 
21 #include "NamespaceHeader.H"
22 
23 ///
24 /**
25  This is the base class for an implicit function specification of geometry.
26  All that is needed is a constructor/destructor, a method to give the value
27  of the function at any point in space (in 2D or 3D), and a factory method
28  (these will probably all be very similar).
29  */
30 class BaseIF
31 {
32 
33 public:
34 
35  /// Default constructor
37  {
38  }
39 
40  /// Default destructor
41  virtual ~BaseIF()
42  {
43  }
44 
45  ///
46  /**
47  Return the value of the function at a_point. When delineating a domain,
48  the level set value=0 represents the boundary and value<0 is inside the
49  fluid.
50  */
51  virtual Real value(const RealVect& a_point) const = 0;
52 
53  virtual Real value(const IndexTM<int,GLOBALDIM> & a_partialDerivative,
54  const IndexTM<Real,GLOBALDIM>& a_point) const
55  {
56  Real retval= LARGEREALVAL;
57  if (a_partialDerivative == IndexTM<int,GLOBALDIM>::Zero)
58  {
59  retval = value(a_point);
60  }
61  else
62  {
63  MayDay::Abort("Not implemented");
64  }
65  return retval;
66  }
67 
68  virtual bool fastIntersection(const Box& a_region,
69  const ProblemDomain& a_domain,
70  const RealVect& a_origin,
71  const Real& a_dx) const
72  {
73  RealVect low, high;
74  corners(a_region, a_origin, a_dx, low, high);
75  return fastIntersection(low, high);
76  }
77 
78  virtual bool fastIntersection(const RealVect& a_low,
79  const RealVect& a_high) const
80  {return false;}
81 
82  virtual GeometryService::InOut InsideOutside(const Box& a_region,
83  const ProblemDomain& a_domain,
84  const RealVect& a_origin,
85  const Real& a_dx) const
86  {
87  RealVect low, high;
88  corners(a_region, a_origin, a_dx, low, high);
89  return InsideOutside(low, high);
90  }
91 
93  const RealVect& a_high) const
94 
95  {
96  MayDay::Abort("This class has not implemented a fastIntersection operation");
98  }
99 
100  ///
101  /**
102  Return the value of the function at a_point (of type INdexTM).
103  */
104  virtual Real value(const IndexTM<Real,GLOBALDIM>& a_point) const
105  {
106  MayDay::Abort("'value' called with 'IndexTM' not implemented in BaseIF");
107  Real retval = LARGEREALVAL;
108  return retval;
109  };
110 
111  ///
112  /**
113  Return a newly allocated derived class. The responsibility
114  for deleting the memory is left to the calling function.
115  */
116  virtual BaseIF* newImplicitFunction() const = 0;
117 
118  virtual void print(ostream& out) const
119  {
120  MayDay::Abort("Print function not implemented");
121  };
122 
123  static void corners(const Box& a_region, const RealVect& a_origin, const Real& a_dx,
124  RealVect& a_lo, RealVect& a_hi)
125  {
126  a_lo = a_origin + RealVect(a_region.smallEnd())*a_dx;
127  a_hi = a_origin + RealVect(a_region.bigEnd()+IntVect::Unit)*a_dx;
128  }
129 
130  ///
131  /**
132  Inform the implicit function, IF, of a BoxLayout change in the
133  application that is using it. If the implicit function uses
134  distributed data, this gives it a chance to react to the spatial
135  layout of the application that is using it.
136 
137  This is a empty implementation for IFs that don't need this
138  functionality.
139  */
140  virtual void boxLayoutChanged(const DisjointBoxLayout & a_newBoxLayout,
141  const RealVect & a_dx)
142  {
143  }
144 };
145 
146 #include "NamespaceFooter.H"
147 
148 #endif
virtual Real value(const IndexTM< int, GLOBALDIM > &a_partialDerivative, const IndexTM< Real, GLOBALDIM > &a_point) const
Definition: BaseIF.H:53
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:130
#define LARGEREALVAL
Definition: Notation.H:77
BaseIF()
Default constructor.
Definition: BaseIF.H:36
virtual void boxLayoutChanged(const DisjointBoxLayout &a_newBoxLayout, const RealVect &a_dx)
Definition: BaseIF.H:140
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:82
const IntVect & bigEnd() const
Definition: Box.H:1779
virtual Real value(const IndexTM< Real, GLOBALDIM > &a_point) const
Definition: BaseIF.H:104
Definition: BaseIF.H:30
static const IntVect Unit
Definition: IntVect.H:632
virtual ~BaseIF()
Default destructor.
Definition: BaseIF.H:41
const IntVect & smallEnd() const
{ Accessors}
Definition: Box.H:1765
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:78
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:31
virtual bool fastIntersection(const Box &a_region, const ProblemDomain &a_domain, const RealVect &a_origin, const Real &a_dx) const
Definition: BaseIF.H:68
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:92
virtual void print(ostream &out) const
Definition: BaseIF.H:118
static void corners(const Box &a_region, const RealVect &a_origin, const Real &a_dx, RealVect &a_lo, RealVect &a_hi)
Definition: BaseIF.H:123
virtual BaseIF * newImplicitFunction() const =0
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).