Chombo + EB  3.0
NormalDerivative.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 _NORMALDERIVATIVE_H_
12 #define _NORMALDERIVATIVE_H_
13 
14 #include "MayDay.H"
15 
16 #include "Notation.H"
17 #include "IFSlicer.H"
18 
19 #include "NamespaceHeader.H"
20 
21 /// This computes the derivatives of the normal of a sliced implicit function
22 /**
23  This computes the derivatives of the normal of a sliced implicit function
24  */
25 template <int dim> class NormalDerivative
26 {
27 public:
30 
31  // This represents a product of partial derivatives of a function. Each
32  // unique partial derivative is represented by a "IvDim" which specifies the
33  // number of partial derivatives taken in each coordinate direction. Each
34  // entry in the map is one such term and the map's value for the entry is
35  // the exponent of the entry. The product is simply the product of all the
36  // entries each with this exponent.
37  typedef map<IvDim,int,LexLT<IvDim> > DerivativeProduct;
38 
39  // This represents the product of partial derivatives of a function (given
40  // by the first term) times another function to a power (given by the second
41  // term). The second function is the reciprocal of the magnitude of the
42  // gradient of the original function. This second function (to various
43  // powers) appears in the normal and all it's derivatives. Further, the
44  // normal and all its derivatives can be written as a sum of terms of this
45  // form.
46  typedef pair<DerivativeProduct,int> PartialDerivativeTerm;
47 
48  /// Null constructor
49  /**
50  Null constructor
51  */
53 
54  /// Destructor
55  /**
56  Destructor
57  */
58  virtual ~NormalDerivative();
59 
60  /// Evaluate derivatives of the normal of an IFSlicer class
61  /**
62  Evaluate a derivative of the normal, a_multiIndex specifies how many
63  derivatives to take in each coordinate direction, a_direction specifies
64  which component of the normal use, a_point is the point in space to
65  evaluate the derivative, and a_ifSlicer is a sliced function whose
66  gradient is the normal.
67  */
68  virtual Real evaluate(const IvDim & a_multiIndex,
69  const int & a_direction,
70  const RvDim & a_point,
71  const IFSlicer<dim> * a_ifSlicer);
72 
74 
75 protected:
76  // Expand and evaluate the multi-index partial derivative of a
77  // PartialDerivativeTerm recursively. If the multi-index is zero (i.e., no
78  // further derivatives) then simply evaluate the PartialDerivateTerm at
79  // "a_point" using the implicit function. If the multi-index isn't zerom,
80  // explicitly compute one partial derivative which is a sum of
81  // PartialDerivativeTerm's and call "expand" with each of these terms and a
82  // reduced multi-index (which will eventually be zero). The sum the results
83  // and return that sum.
84  Real expand(const IvDim & a_multiIndex,
85  const PartialDerivativeTerm & a_term,
86  const RvDim & a_point,
87  const IFSlicer<dim> * a_ifSlicer) const;
88 
89  // The value of the magnitude of the gradient of the function at "a_point"
91 
92 
93 private:
95  {
96  MayDay::Abort("NormalDerivativeIF doesn't allow copy construction");
97  }
98 
99  void operator=(const NormalDerivative& a_input)
100  {
101  MayDay::Abort("NormalDerivativeIF doesn't allow assignment");
102  }
103 };
104 
105 /// This computes the derivatives of the normal of a sliced implicit function
106 /**
107  This computes the derivatives of the normal of a sliced implicit function.
108  Specialization so an additional method can be defined.
109  */
110 template <> class NormalDerivative<GLOBALDIM>
111 {
112 public:
115 
116  // This represents a product of partial derivatives of a function. Each
117  // unique partial derivative is represented by a "IvDim" which specifies the
118  // number of partial derivatives taken in each coordinate direction. Each
119  // entry in the map is one such term and the map's value for the entry is
120  // the exponent of the entry. The product is simply the product of all the
121  // entries each with this exponent.
122  typedef map<IvDim,int,LexLT<IvDim> > DerivativeProduct;
123 
124  // This represents the product of partial derivatives of a function (given
125  // by the first term) times another function to a power (given by the second
126  // term). The second function is the reciprocal of the magnitude of the
127  // gradient of the original function. This second function (to various
128  // powers) appears in the normal and all it's derivatives. Further, the
129  // normal and all its derivatives can be written as a sum of terms of this
130  // form.
131  typedef pair<DerivativeProduct,int> PartialDerivativeTerm;
132 
133  /// Null constructor
134  /**
135  Null constructor
136  */
138 
139  /// Destructor
140  /**
141  Destructor
142  */
143  virtual ~NormalDerivative();
144 
145  /// Evaluate derivatives of the normal of a BaseIF subclass
146  /**
147  Evaluate a derivative of the normal, a_multiIndex specifies how many
148  derivatives to take in each coordinate direction, a_direction specifies
149  which component of the normal use, a_point is the point in space to
150  evaluate the derivative, and a_impFunc is a function whose gradient
151  is the normal.
152  */
153  virtual Real evaluate(const IvDim & a_multiIndex,
154  const int & a_direction,
155  const RvDim & a_point,
156  const BaseIF & a_impFunc);
157 
158  /// Evaluate derivatives of the normal of an IFSlicer class
159  /**
160  Evaluate a derivative of the normal, a_multiIndex specifies how many
161  derivatives to take in each coordinate direction, a_direction specifies
162  which component of the normal use, a_point is the point in space to
163  evaluate the derivative, and a_ifSlicer is a sliced function whose
164  gradient is the normal.
165  */
166  virtual Real evaluate(const IvDim & a_multiIndex,
167  const int & a_direction,
168  const RvDim & a_point,
169  const IFSlicer<GLOBALDIM> * a_ifSlicer);
170 
172 protected:
173  // Expand and evaluate the multi-index partial derivative of a
174  // PartialDerivativeTerm recursively. If the multi-index is zero (i.e., no
175  // further derivatives) then simply evaluate the PartialDerivateTerm at
176  // "a_point" using the implicit function. If the multi-index isn't zerom,
177  // explicitly compute one partial derivative which is a sum of
178  // PartialDerivativeTerm's and call "expand" with each of these terms and a
179  // reduced multi-index (which will eventually be zero). The sum the results
180  // and return that sum.
181  Real expand(const IvDim & a_multiIndex,
182  const PartialDerivativeTerm & a_term,
183  const RvDim & a_point,
184  const IFSlicer<GLOBALDIM> * a_ifSlicer) const;
185 
186  // The value of the magnitude of the gradient of the function at "a_point"
188 
189 
190 private:
192  {
193  MayDay::Abort("NormalDerivativeIF doesn't allow copy construction");
194  }
195 
196  void operator=(const NormalDerivative& a_input)
197  {
198  MayDay::Abort("NormalDerivativeIF doesn't allow assignment");
199  }
200 };
201 
202 #include "NamespaceFooter.H"
203 
204 #include "NormalDerivativeImplem.H"
205 
206 #endif
IndexTM< int, dim > IvDim
Definition: NormalDerivative.H:28
Real m_magnitudeOfGradient
Definition: NormalDerivative.H:90
virtual Real evaluate(const IvDim &a_multiIndex, const int &a_direction, const RvDim &a_point, const IFSlicer< dim > *a_ifSlicer)
Evaluate derivatives of the normal of an IFSlicer class.
Definition: NormalDerivativeImplem.H:27
pair< DerivativeProduct, int > PartialDerivativeTerm
Definition: NormalDerivative.H:46
IndexTM< Real, GLOBALDIM > RvDim
Definition: NormalDerivative.H:114
IndexTM< Real, dim > RvDim
Definition: NormalDerivative.H:29
This computes the derivatives of the normal of a sliced implicit function.
Definition: NormalDerivative.H:25
Definition: IndexTM.H:36
map< IvDim, int, LexLT< IvDim > > DerivativeProduct
Definition: NormalDerivative.H:122
NormalDerivative()
Null constructor.
Definition: NormalDerivativeImplem.H:17
IndexTM< int, GLOBALDIM > IvDim
Definition: NormalDerivative.H:113
Definition: BaseIF.H:30
double Real
Definition: REAL.H:33
NormalDerivative(const NormalDerivative &a_input)
Definition: NormalDerivative.H:94
Definition: IFSlicer.H:92
virtual ~NormalDerivative()
Destructor.
Definition: NormalDerivativeImplem.H:22
void operator=(const NormalDerivative &a_input)
Definition: NormalDerivative.H:99
Definition: IFSlicer.H:27
Real getMagnitudeOfGradient()
Definition: NormalDerivativeImplem.H:64
NormalDerivative(const NormalDerivative &a_input)
Definition: NormalDerivative.H:191
map< IvDim, int, LexLT< IvDim > > DerivativeProduct
Definition: NormalDerivative.H:37
Real expand(const IvDim &a_multiIndex, const PartialDerivativeTerm &a_term, const RvDim &a_point, const IFSlicer< dim > *a_ifSlicer) const
Definition: NormalDerivativeImplem.H:77
Real m_magnitudeOfGradient
Definition: NormalDerivative.H:187
#define GLOBALDIM
Definition: Notation.H:35
pair< DerivativeProduct, int > PartialDerivativeTerm
Definition: NormalDerivative.H:131
void operator=(const NormalDerivative &a_input)
Definition: NormalDerivative.H:196
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).