Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
FunctionData.h
1 /*
2 Copyright (c) 2006, Michael Kazhdan and Matthew Bolitho
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without modification,
6 are permitted provided that the following conditions are met:
7 
8 Redistributions of source code must retain the above copyright notice, this list of
9 conditions and the following disclaimer. Redistributions in binary form must reproduce
10 the above copyright notice, this list of conditions and the following disclaimer
11 in the documentation and/or other materials provided with the distribution.
12 
13 Neither the name of the Johns Hopkins University nor the names of its contributors
14 may be used to endorse or promote products derived from this software without specific
15 prior written permission.
16 
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
18 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES
19 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
20 SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
22 TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
25 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
26 DAMAGE.
27 */
28 
29 #ifndef FUNCTION_DATA_INCLUDED
30 #define FUNCTION_DATA_INCLUDED
31 
32 #define BOUNDARY_CONDITIONS 1
33 
34 
35 #include "PPolynomial.h"
36 
37 template<int Degree,class Real>
39  bool useDotRatios;
40  int normalize;
41 #if BOUNDARY_CONDITIONS
42  bool reflectBoundary;
43 #endif // BOUNDARY_CONDITIONS
44 public:
45  const static int DOT_FLAG = 1;
46  const static int D_DOT_FLAG = 2;
47  const static int D2_DOT_FLAG = 4;
48  const static int VALUE_FLAG = 1;
49  const static int D_VALUE_FLAG = 2;
50 
51  int depth , res , res2;
52  Real *dotTable , *dDotTable , *d2DotTable;
53  Real *valueTables , *dValueTables;
54 #if BOUNDARY_CONDITIONS
55  PPolynomial<Degree> baseFunction , leftBaseFunction , rightBaseFunction;
56  PPolynomial<Degree-1> dBaseFunction , dLeftBaseFunction , dRightBaseFunction;
57 #else // !BOUNDARY_CONDITIONS
58  PPolynomial<Degree> baseFunction;
59  PPolynomial<Degree-1> dBaseFunction;
60 #endif // BOUNDARY_CONDITIONS
61  PPolynomial<Degree+1>* baseFunctions;
62 
63  FunctionData(void);
64  ~FunctionData(void);
65 
66  virtual void setDotTables(const int& flags);
67  virtual void clearDotTables(const int& flags);
68 
69  virtual void setValueTables(const int& flags,const double& smooth=0);
70  virtual void setValueTables(const int& flags,const double& valueSmooth,const double& normalSmooth);
71  virtual void clearValueTables(void);
72 
73  /********************************************************
74  * Sets the translates and scales of the basis function
75  * up to the prescribed depth
76  * <maxDepth> the maximum depth
77  * <F> the basis function
78  * <normalize> how the functions should be scaled
79  * 0] Value at zero equals 1
80  * 1] Integral equals 1
81  * 2] L2-norm equals 1
82  * <useDotRatios> specifies if dot-products of derivatives
83  * should be pre-divided by function integrals
84  * <reflectBoundary> spcifies if function space should be
85  * forced to be reflectively symmetric across the boundary
86  ********************************************************/
87 #if BOUNDARY_CONDITIONS
88  void set( const int& maxDepth , const PPolynomial<Degree>& F , const int& normalize , bool useDotRatios=true , bool reflectBoundary=false );
89 #else // !BOUNDARY_CONDITIONS
90  void set(const int& maxDepth,const PPolynomial<Degree>& F,const int& normalize , bool useDotRatios=true );
91 #endif // BOUNDARY_CONDITIONS
92 
93 #if BOUNDARY_CONDITIONS
94  Real dotProduct( const double& center1 , const double& width1 , const double& center2 , const double& width2 , int boundary1 , int boundary2 ) const;
95  Real dDotProduct( const double& center1 , const double& width1 , const double& center2 , const double& width2 , int boundary1 , int boundary2 ) const;
96  Real d2DotProduct( const double& center1 , const double& width1 , const double& center2 , const double& width2 , int boundary1 , int boundary2 ) const;
97 #else // !BOUNDARY_CONDITIONS
98  Real dotProduct( const double& center1 , const double& width1 , const double& center2 , const double& width2 ) const;
99  Real dDotProduct( const double& center1 , const double& width1 , const double& center2 , const double& width2 ) const;
100  Real d2DotProduct( const double& center1 , const double& width1 , const double& center2 , const double& width2 ) const;
101 #endif // BOUNDARY_CONDITIONS
102 
103  static inline int SymmetricIndex( const int& i1 , const int& i2 );
104  static inline int SymmetricIndex( const int& i1 , const int& i2 , int& index );
105 };
106 
107 
108 #include "FunctionData.inl"
109 #endif // FUNCTION_DATA_INCLUDED