DataTransferKit - Multiphysics Solution Transfer Services  2.0
DTK_WuBasis_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_WUBASIS_IMPL_HPP
42 #define DTK_WUBASIS_IMPL_HPP
43 
44 #include <cmath>
45 #include <limits>
46 
48 
49 namespace DataTransferKit
50 {
51 //---------------------------------------------------------------------------//
56 //---------------------------------------------------------------------------//
57 template <>
58 inline double WuBasis<2>::evaluateValue( const double radius,
59  const double x ) const
60 {
61  double xval = x / radius;
62  double onemx = 1.0 - xval;
63  double onemx2 = onemx * onemx;
64  double xp2 = xval * xval;
65  return ( xval < 1.0 )
66  ? onemx * onemx2 * onemx2 *
67  ( 5.0 * xp2 * xp2 + 25.0 * xval * xp2 + 48.0 * xp2 +
68  40.0 * xval + 8.0 )
69  : 0.0;
70 }
71 
72 //---------------------------------------------------------------------------//
77 //---------------------------------------------------------------------------//
78 template <>
79 inline double WuBasis<2>::evaluateGradient( const double radius,
80  const double x ) const
81 {
82  double xval = x / radius;
83  double xmone = xval - 1.0;
84  double xmone2 = xmone * xmone;
85  double xp2 = x * x;
86  return ( xval < 1.0 )
87  ? -9.0 * xmone2 * xmone2 * xval *
88  ( 5.0 * xp2 * xval + 20.0 * xp2 + 29.0 * xval + 16.0 )
89  : 0.0;
90 }
91 
92 //---------------------------------------------------------------------------//
97 //---------------------------------------------------------------------------//
98 template <>
99 inline double WuBasis<4>::evaluateValue( const double radius,
100  const double x ) const
101 {
102  double xval = x / radius;
103  double onemx = 1.0 - xval;
104  double onemx3 = onemx * onemx * onemx;
105  double xp2 = xval * xval;
106  double xp4 = xp2 * xp2;
107  return ( xval < 1.0 )
108  ? onemx3 * onemx3 *
109  ( 5.0 * xp4 * xval + 30.0 * xp4 + 72.0 * xp2 * xval +
110  82.0 * xp2 + 36.0 * xval + 6.0 )
111  : 0.0;
112 }
113 
114 //---------------------------------------------------------------------------//
119 //---------------------------------------------------------------------------//
120 template <>
121 inline double WuBasis<4>::evaluateGradient( const double radius,
122  const double x ) const
123 {
124  double xval = x / radius;
125  double xmone = xval - 1.0;
126  double xmone2 = xmone * xmone;
127  double xp2 = xval * xval;
128  return ( xval < 1.0 )
129  ? 11.0 * xmone2 * xmone2 * xmone * xval *
130  ( 5.0 * xp2 * xp2 + 25.0 * xp2 * xval + 48.0 * xp2 +
131  40.0 * xval + 8.0 )
132  : 0.0;
133 }
134 
135 //---------------------------------------------------------------------------//
136 
137 } // end namespace DataTransferKit
138 
139 //---------------------------------------------------------------------------//
140 
141 #endif // end DTK_WUBASIS_IMPL_HPP
142 
143 //---------------------------------------------------------------------------//
144 // end DTK_WuBasis_impl.hpp
145 //---------------------------------------------------------------------------//
Euclidean distance function.
DTK_BasicEntitySet.cpp.
Wu compactly supported radial basis function.
Definition: DTK_WuBasis.hpp:58