Nektar++
kernel.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File kernel.h
4 //
5 // For more information, please see: http://www.nektar.info
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Scientific Computing and Imaging Institute,
10 // University of Utah (USA) and Department of Aeronautics, Imperial
11 // College London (UK).
12 //
13 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description:
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef NEKTAR_LIB_UTILIITIES_KERNEL_KERNEL_H
37 #define NEKTAR_LIB_UTILIITIES_KERNEL_KERNEL_H
38 
42 
43 namespace Nektar
44 {
45  namespace LibUtilities
46  {
47  class Kernel
48  {
49  public:
50  /**
51  * \brief The default constructor
52  */
54 
55  LIB_UTILITIES_EXPORT Kernel(int order);
56 
57  /**
58  * \brief The default destructor
59  */
60  //~Kernel();
61 
62  /**
63  * \brief This funciton updates the bspline to the appropriate order.
64  */
66 
67  /**
68  * \brief This funciton updates the kernel coefficients.
69  */
71 
72  /**
73  * \brief This funciton updates the kernel breaks.
74  * \param h represents the mesh spacing
75  */
77 
78  /**
79  * \brief This funciton returns a 2D array representing the bspline
80  * of the appropriate order.
81  */
83  {
84  return b_spline;
85  }
86 
87  /**
88  * \brief This funciton returns a 1D array representing the kernel coefficients
89  */
91  {
92  return k_coeffs;
93  }
94 
95  /**
96  * \brief This funciton returns a 1D array representing the kernel breaks
97  */
99  {
100  return k_breaks;
101  }
102 
103  /**
104  * \brief This funciton sets the k_order variable
105  */
106  void UpdateKernelOrder(int order)
107  {
108  k_order = order;
109  }
110 
111  /**
112  * \brief This funciton sets the k_ncoeffs variable
113  */
115  {
116  k_ncoeffs = 2*(k_order-1)+1;
117  }
118 
119  /**
120  * \brief This funciton sets the kernel width size
121  */
123  {
124  k_width = 3*(k_order-1)+1;
125  }
126 
127  /**
128  * \brief This funciton returns the order of the kernel
129  */
131  {
132  return k_order;
133  }
134 
135  /**
136  * \brief This funciton returns the number of kernel coefficients
137  */
139  {
140  return k_ncoeffs;
141  }
142 
143  /**
144  * \brief This funciton returns the size of the kernel width
145  */
147  {
148  return k_width;
149  }
150 
151  /**
152  * \brief This funciton moves the center of the kernel to the
153  \param x_value.
154  \param outarray is used to store the result
155  */
157 
158  /**
159  * \brief This funciton calculates the mesh breaks under the kernel support
160  \param inarray contains the local kernel breaks
161  \param h is the mesh spacing
162  \param outarray contains the coordinate of the mesh breaks under the kernel support
163  */
165  Array<OneD,NekDouble> &outarray);
166 
167  /**
168  * \brief This funciton evaluates the kernel at input values
169  \param inarray.
170  \param h is the mesh spacing.
171  \param outarray contains the kernel values
172  */
174  Array<OneD,NekDouble> &outarray);
175 
176  /**
177  * \brief This function evaluates the bspline at input values
178  \param inarray input values.
179  \param h the mesh spacing.
180  \param offset
181  \param outarray contains the bspline values.
182  */
184  NekDouble offset, Array<OneD,NekDouble> &outarray);
185 
186 
187  /**
188  * \brief This funciton performs the ordered merge of \param inarray1
189  * and \param inarray2 and puts the result in \param outarray
190  */
192  Array<OneD,NekDouble> &outarray);
193 
194  protected:
195 
196  int k_order; /**< bsplines are obtained by convolving the characteristic
197  fucntion with itself (k_order - 1) times */
198  int k_ncoeffs; /**< Represents the number of kernel coefficients */
199  int k_width; /**< Represents the width of the kernel */
200  NekDouble k_center; /**< holds the center of the kernel */
201  Array<TwoD,NekDouble> b_spline; /**< 2D array representing the bspline */
202  Array<OneD,NekDouble> k_coeffs; /**< 1D array representing the kernel coefficients */
203  Array<OneD,NekDouble> k_breaks; /**< 1D array representing the kernel breaks */
204 
205  /**
206  * \brief This funciton evaluates the piecewise bspline polynomial
207  \param interval \param interval at point \param x_value.
208  */
209  NekDouble EvaluateBsplinePoly(NekDouble x_value,int interval);
210 
211  private:
212 
213  };
214 
215  typedef boost::shared_ptr<Kernel> KernelSharedPtr;
216 
217  }//end of namespace
218 }// end of namespace
219 
220 #endif //NEKTAR_LIB_UTILIITIES_KERNEL_KERNEL_H
void EvaluateKernel(Array< OneD, NekDouble > inarray, NekDouble h, Array< OneD, NekDouble > &outarray)
This funciton evaluates the kernel at input values.
Definition: kernel.cpp:279
Kernel()
The default constructor.
Array< OneD, NekDouble > GetKernelCoeffs()
This funciton returns a 1D array representing the kernel coefficients.
Definition: kernel.h:90
int GetKernelOrder()
This funciton returns the order of the kernel.
Definition: kernel.h:130
Array< TwoD, NekDouble > b_spline
Definition: kernel.h:201
void UpdateKernelNumOfCoeffs()
This funciton sets the k_ncoeffs variable.
Definition: kernel.h:114
int GetKernelNumeOfCoeffs()
This funciton returns the number of kernel coefficients.
Definition: kernel.h:138
int GetKernelWidth()
This funciton returns the size of the kernel width.
Definition: kernel.h:146
NekDouble EvaluateBsplinePoly(NekDouble x_value, int interval)
This funciton evaluates the piecewise bspline polynomial.
Definition: kernel.cpp:342
void EvaluateBspline(Array< OneD, NekDouble > inarray, NekDouble h, NekDouble offset, Array< OneD, NekDouble > &outarray)
This function evaluates the bspline at input values.
Definition: kernel.cpp:307
void FindMeshUnderKernel(Array< OneD, NekDouble > &inarray, NekDouble h, Array< OneD, NekDouble > &outarray)
This funciton calculates the mesh breaks under the kernel support.
Definition: kernel.cpp:261
#define LIB_UTILITIES_EXPORT
void UpdateKernelOrder(int order)
This funciton sets the k_order variable.
Definition: kernel.h:106
Array< OneD, NekDouble > k_coeffs
Definition: kernel.h:202
boost::shared_ptr< Kernel > KernelSharedPtr
Definition: kernel.h:215
double NekDouble
Array< OneD, NekDouble > GetKernelBreaks()
This funciton returns a 1D array representing the kernel breaks.
Definition: kernel.h:98
void UpdateKernelCoeffs()
This funciton updates the kernel coefficients.
Definition: kernel.cpp:176
void MoveKernelCenter(NekDouble x_value, Array< OneD, NekDouble > &outarray)
This funciton moves the center of the kernel to the.
Definition: kernel.cpp:249
void UpdateKernelBreaks(NekDouble h)
This funciton updates the kernel breaks.
Definition: kernel.cpp:237
Array< OneD, NekDouble > k_breaks
Definition: kernel.h:203
void Sort(Array< OneD, NekDouble > &inarray1, Array< OneD, NekDouble > &inarray2, Array< OneD, NekDouble > &outarray)
This funciton performs the ordered merge of.
Definition: kernel.cpp:357
void UpdateKernelWidth()
This funciton sets the kernel width size.
Definition: kernel.h:122
void UpdateKernelBspline()
The default destructor.
Definition: kernel.cpp:52
Array< TwoD, NekDouble > GetKernelBspline()
This funciton returns a 2D array representing the bspline of the appropriate order.
Definition: kernel.h:82