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
88  * 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  NekDouble x_value, Array<OneD, NekDouble> &outarray);
158 
159  /**
160  * \brief This funciton calculates the mesh breaks under the kernel support
161  \param inarray contains the local kernel breaks
162  \param h is the mesh spacing
163  \param outarray contains the coordinate of the mesh breaks under the
164  kernel support
165  */
167  Array<OneD, NekDouble> &inarray, NekDouble h,
168  Array<OneD, NekDouble> &outarray);
169 
170  /**
171  * \brief This funciton evaluates the kernel at input values
172  \param inarray.
173  \param h is the mesh spacing.
174  \param outarray contains the kernel values
175  */
177  NekDouble h,
178  Array<OneD, NekDouble> &outarray);
179 
180  /**
181  * \brief This function evaluates the bspline at input values
182  \param inarray input values.
183  \param h the mesh spacing.
184  \param offset
185  \param outarray contains the bspline values.
186  */
188  NekDouble h, NekDouble offset,
189  Array<OneD, NekDouble> &outarray);
190 
191  /**
192  * \brief This funciton performs the ordered merge of \param inarray1
193  * and \param inarray2 and puts the result in \param outarray
194  */
196  Array<OneD, NekDouble> &inarray2,
197  Array<OneD, NekDouble> &outarray);
198 
199 protected:
200  int k_order; /**< bsplines are obtained by convolving the characteristic
201  fucntion with itself (k_order - 1)
202  times */
203  int k_ncoeffs; /**< Represents the number of kernel coefficients */
204  int k_width; /**< Represents the width of the kernel */
205  NekDouble k_center; /**< holds the center of the kernel */
206  Array<TwoD, NekDouble> b_spline; /**< 2D array representing the bspline */
208  k_coeffs; /**< 1D array representing the kernel coefficients */
210  k_breaks; /**< 1D array representing the kernel breaks */
211 
212  /**
213  * \brief This funciton evaluates the piecewise bspline polynomial
214  \param interval \param interval at point \param x_value.
215  */
216  NekDouble EvaluateBsplinePoly(NekDouble x_value, int interval);
217 
218 private:
219 };
220 
221 typedef std::shared_ptr<Kernel> KernelSharedPtr;
222 
223 } // namespace LibUtilities
224 } // namespace Nektar
225 
226 #endif // NEKTAR_LIB_UTILIITIES_KERNEL_KERNEL_H
#define LIB_UTILITIES_EXPORT
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:351
void UpdateKernelCoeffs()
This funciton updates the kernel coefficients.
Definition: kernel.cpp:185
Array< OneD, NekDouble > GetKernelBreaks()
This funciton returns a 1D array representing the kernel breaks.
Definition: kernel.h:98
void EvaluateKernel(Array< OneD, NekDouble > inarray, NekDouble h, Array< OneD, NekDouble > &outarray)
This funciton evaluates the kernel at input values.
Definition: kernel.cpp:324
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:306
void UpdateKernelBspline()
The default destructor.
Definition: kernel.cpp:51
void MoveKernelCenter(NekDouble x_value, Array< OneD, NekDouble > &outarray)
This funciton moves the center of the kernel to the.
Definition: kernel.cpp:293
NekDouble EvaluateBsplinePoly(NekDouble x_value, int interval)
This funciton evaluates the piecewise bspline polynomial.
Definition: kernel.cpp:388
int GetKernelWidth()
This funciton returns the size of the kernel width.
Definition: kernel.h:146
Array< OneD, NekDouble > GetKernelCoeffs()
This funciton returns a 1D array representing the kernel coefficients.
Definition: kernel.h:90
void UpdateKernelBreaks(NekDouble h)
This funciton updates the kernel breaks.
Definition: kernel.cpp:281
Array< OneD, NekDouble > k_breaks
Definition: kernel.h:210
void UpdateKernelOrder(int order)
This funciton sets the k_order variable.
Definition: kernel.h:106
int GetKernelOrder()
This funciton returns the order of the kernel.
Definition: kernel.h:130
Array< TwoD, NekDouble > b_spline
Definition: kernel.h:206
Array< TwoD, NekDouble > GetKernelBspline()
This funciton returns a 2D array representing the bspline of the appropriate order.
Definition: kernel.h:81
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
void Sort(Array< OneD, NekDouble > &inarray1, Array< OneD, NekDouble > &inarray2, Array< OneD, NekDouble > &outarray)
This funciton performs the ordered merge of.
Definition: kernel.cpp:402
Array< OneD, NekDouble > k_coeffs
Definition: kernel.h:208
void UpdateKernelWidth()
This funciton sets the kernel width size.
Definition: kernel.h:122
Kernel()
The default constructor.
std::shared_ptr< Kernel > KernelSharedPtr
Definition: kernel.h:221
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
double NekDouble