DataTransferKit - Multiphysics Solution Transfer Services  2.0
DTK_WendlandBasis_impl.hpp
Go to the documentation of this file.
1 //---------------------------------------------------------------------------//
2 /*
3  Copyright (c) 2012, Stuart R. Slattery
4  All rights reserved.
5 
6  Redistribution and use in source and binary forms, with or without
7  modification, are permitted provided that the following conditions are
8  met:
9 
10  *: Redistributions of source code must retain the above copyright
11  notice, this list of conditions and the following disclaimer.
12 
13  *: Redistributions in binary form must reproduce the above copyright
14  notice, this list of conditions and the following disclaimer in the
15  documentation and/or other materials provided with the distribution.
16 
17  *: Neither the name of the University of Wisconsin - Madison nor the
18  names of its contributors may be used to endorse or promote products
19  derived from this software without specific prior written permission.
20 
21  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33 //---------------------------------------------------------------------------//
39 //---------------------------------------------------------------------------//
40 
41 #ifndef DTK_WENDLANDBASIS_IMPL_HPP
42 #define DTK_WENDLANDBASIS_IMPL_HPP
43 
44 #include <cmath>
45 #include <limits>
46 
47 namespace DataTransferKit
48 {
49 //---------------------------------------------------------------------------//
54 //---------------------------------------------------------------------------//
55 template <>
56 inline double WendlandBasis<0>::evaluateValue( const double radius,
57  const double x ) const
58 {
59  double xval = x / radius;
60  double onemx = 1.0 - xval;
61  return ( xval < 1.0 ) ? onemx * onemx : 0.0;
62 }
63 
64 //---------------------------------------------------------------------------//
69 //---------------------------------------------------------------------------//
70 template <>
71 inline double WendlandBasis<0>::evaluateGradient( const double radius,
72  const double x ) const
73 {
74  double xval = x / radius;
75  return ( xval < 1.0 ) ? 2.0 * xval - 2.0 : 0.0;
76 }
77 
78 //---------------------------------------------------------------------------//
83 //---------------------------------------------------------------------------//
84 template <>
85 inline double WendlandBasis<2>::evaluateValue( const double radius,
86  const double x ) const
87 {
88  double xval = x / radius;
89  double onemx = 1.0 - xval;
90  double onemx2 = onemx * onemx;
91  return ( xval < 1.0 ) ? onemx2 * onemx2 * ( 4.0 * xval + 1.0 ) : 0.0;
92 }
93 
94 //---------------------------------------------------------------------------//
99 //---------------------------------------------------------------------------//
100 template <>
101 inline double WendlandBasis<2>::evaluateGradient( const double radius,
102  const double x ) const
103 {
104  double xval = x / radius;
105  double xmone = xval - 1.0;
106  return ( xval < 1.0 ) ? 20.0 * xval * xmone * xmone * xmone : 0.0;
107 }
108 
109 //---------------------------------------------------------------------------//
114 //---------------------------------------------------------------------------//
115 template <>
116 inline double WendlandBasis<4>::evaluateValue( const double radius,
117  const double x ) const
118 {
119  double xval = x / radius;
120  double onemx = 1.0 - xval;
121  double onemx2 = onemx * onemx;
122  return ( xval < 1.0 )
123  ? onemx2 * onemx2 * onemx2 *
124  ( 35.0 * xval * xval + 18.0 * xval + 3.0 )
125  : 0.0;
126 }
127 
128 //---------------------------------------------------------------------------//
133 //---------------------------------------------------------------------------//
134 template <>
135 inline double WendlandBasis<4>::evaluateGradient( const double radius,
136  const double x ) const
137 {
138  double xval = x / radius;
139  double xmone = xval - 1.0;
140  double xmone2 = xmone * xmone;
141  return ( xval < 1.0 )
142  ? 56.0 * xval * xmone2 * xmone2 * xmone * ( 5.0 * xval + 1 )
143  : 0.0;
144 }
145 
146 //---------------------------------------------------------------------------//
151 //---------------------------------------------------------------------------//
152 template <>
153 inline double WendlandBasis<6>::evaluateValue( const double radius,
154  const double x ) const
155 {
156  double xval = x / radius;
157  double onemx = 1.0 - xval;
158  double onemx2 = onemx * onemx;
159  double onemx4 = onemx2 * onemx2;
160  double xs = xval * xval;
161  return ( xval < 1.0 )
162  ? onemx4 * onemx4 *
163  ( 32.0 * xs * xval + 25.0 * xs + 8.0 * xval + 1.0 )
164  : 0.0;
165 }
166 
167 //---------------------------------------------------------------------------//
172 //---------------------------------------------------------------------------//
173 template <>
174 inline double WendlandBasis<6>::evaluateGradient( const double radius,
175  const double x ) const
176 {
177  double xval = x / radius;
178  double xmone = xval - 1.0;
179  double xmone2 = xmone * xmone;
180  double xmone4 = xmone2 * xmone2;
181  return ( xval < 1.0 )
182  ? 22.0 * xval * xmone4 * xmone2 * xmone *
183  ( 16.0 * xval * xval + 7.0 * xval + 1.0 )
184  : 0.0;
185 }
186 
187 //---------------------------------------------------------------------------//
188 
189 } // end namespace DataTransferKit
190 
191 //---------------------------------------------------------------------------//
192 
193 #endif // end DTK_WENDLANDBASIS_IMPL_HPP
194 
195 //---------------------------------------------------------------------------//
196 // end DTK_WendlandBasis_impl.hpp
197 //---------------------------------------------------------------------------//
Wendland compactly supported radial basis function.
DTK_BasicEntitySet.cpp.