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