G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsLegendreBasis.h
1 
2 #pragma once
3 #include <cmath>
4 
5 //#include <gismo.h>
7 //#include "gsLegendreBasis.hpp"
9 #include <gsCore/gsBoundary.h>
10 #include <gsCore/gsBasis.h>
11 
12 namespace gismo
13 {
14 
15 // forward declaration
16 template< class T> class gsLegendreBasis;
17 template <class T> class gsLegendrePoly;
18 
26 template<class T>
27 class gsLegendreBasis : public gsBasis<T>
28 {
29 public:
30  typedef gsBasis<T> Base;
31 
33  typedef T Scalar_t;
34 
36  typedef gsLegendrePoly<T> GeometryType;
37 
40 
42  static const int Dim = 1;
43 
45  typedef memory::shared_ptr< gsLegendreBasis > Ptr;
46 
48  typedef memory::unique_ptr< gsLegendreBasis > uPtr;
49 
50 // static Ptr Make ( const gsVector<T> & vec, const T & start, const T & end) // TODO: remove?
51 // { return Ptr( new gsLegendreBasis(vec,start,end) ); }
52 
53 public:
54 
55  // Default empty constructor
56  //gsLegendreBasis() : Base() { }
57 
59  explicit gsLegendreBasis (const index_t deg, const T & start = 1, const T & end = 1) :
60  m_p(deg), m_start(start), m_end(end)
61  { }
62 
63 public:
64 
66  short_t domainDim() const { return Dim; }
67 
70  void active_into(const gsMatrix<T> & u, gsMatrix<index_t>& result) const;
71 
73  void numActive_into(const gsMatrix<T> & u, gsVector<index_t>& result) const
74  {
75  result.setConstant(1, u.cols(), m_p+1);
76  }
77 
80  {
81  gsMatrix<T> res(1,2);
82  res << m_start , m_end ;
83  return res;
84  }
85 
87  gsMatrix<T> support(const index_t & i) const
88  {
89  return support();
90  }
91 
93  void eval_into(const gsMatrix<T> & u, gsMatrix<T>& result) const;
94 
96  void deriv_into(const gsMatrix<T> & u, gsMatrix<T>& result ) const;
97 
100  void deriv2_into(const gsMatrix<T> & u, gsMatrix<T>& result ) const;
101 
102  GISMO_CLONE_FUNCTION(gsLegendreBasis)
103 
104  // GISMO_MAKE_GEOMETRY_NEW
105 
106 
107  std::ostream &print(std::ostream &os) const
108  {
109  os << "Legendre Basis: deg=" << this->degree()
110  << ", size="<< this->size()
111  << ", interval= [" << m_start << "," << m_end << "].\n";
112  return os;
113  }
114 
116  short_t size() const { return m_p+1; }
117 
120  gsDomain<T> * domain() const
122 
124  short_t degree() const
125  {
126  return m_p;
127  }
128 
129 private:
130 
131  static inline T _getA(const index_t j)
132  {
133  return (T)(2*j-1)/j;
134  return math::sqrt((T)(2*j-1)) * math::sqrt((T)(2*j+1)) / (j*math::sqrt((T)3));
135  }
136 
137  static inline T _getB(const index_t j)
138  {
139  return 0;
140  }
141 
142  static inline T _getC(const index_t j)
143  {
144  return (T)(j-1)/j;
145  return _getA(j) / _getA(j-1);
146  }
147 
148 private:
149  // Degree
150  short_t m_p;
151  // Interval
152  T m_start;
153  T m_end ;
154 }; // class gsLegendreBasis
155 
156 } // namespace gismo
157 
158 
159 //include the hpp file that contains the file definitions
160 #include "gsLegendreBasis.hpp"
161 
162 //#ifndef GISMO_HEADERS_ONLY
163 //#include GISMO_HPP_HEADER(gsLegendreBasis.hpp)
164 //#endif
165 
166 
167 
168 
169 
Class representing a domain. i.e. a collection of elements (triangles, rectangles, cubes, simplices.
Definition: gsDomain.h:31
short_t size() const
Returns the number of basis functions in the basis.
Definition: gsLegendreBasis.h:116
short_t degree() const
Returns the polynomial degree.
Definition: gsLegendreBasis.h:124
short_t domainDim() const
Returns the dimension d of the parameter space.
Definition: gsLegendreBasis.h:66
static const int Dim
Dimension of the parameter domain.
Definition: gsLegendreBasis.h:42
#define GISMO_NO_IMPLEMENTATION
Definition: gsDebug.h:129
#define short_t
Definition: gsConfig.h:35
Provides structs and classes related to interfaces and boundaries.
gsMatrix< T > support(const index_t &i) const
Returns a bounding box for the basis&#39; domain.
Definition: gsLegendreBasis.h:87
memory::unique_ptr< gsLegendreBasis > uPtr
Unique pointer for gsLegendreBasis.
Definition: gsLegendreBasis.h:48
T Scalar_t
Coefficient type.
Definition: gsLegendreBasis.h:33
Provides declaration of Basis abstract interface.
#define index_t
Definition: gsConfig.h:32
void deriv_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates the (partial) derivatives of non-zero basis functions at (the columns of) u...
Definition: gsLegendreBasis.hpp:36
Provides combinatorial unitilies.
A univariate Legendre basis.
Definition: gsLegendreBasis.h:16
gsDomain< T > * domain() const
Definition: gsLegendreBasis.h:120
void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates the non-zero basis functions at value u.
Definition: gsLegendreBasis.hpp:15
void numActive_into(const gsMatrix< T > &u, gsVector< index_t > &result) const
Returns the number of active (nonzero) basis functions at points u in result.
Definition: gsLegendreBasis.h:73
Interface for the set of functions defined on a domain (the total number of functions in the set equa...
Definition: gsFuncData.h:23
gsLegendreBasis< T > BoundaryBasisType
Associated Boundary basis type.
Definition: gsLegendreBasis.h:39
Provides forward declarations of types and structs.
gsLegendrePoly< T > GeometryType
Associated geometry type.
Definition: gsLegendreBasis.h:36
gsMatrix< T > support() const
Returns a bounding box for the basis&#39; domain.
Definition: gsLegendreBasis.h:79
std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition: gsLegendreBasis.h:107
memory::shared_ptr< gsLegendreBasis > Ptr
Shared pointer for gsLegendreBasis.
Definition: gsLegendreBasis.h:45
void active_into(const gsMatrix< T > &u, gsMatrix< index_t > &result) const
Definition: gsLegendreBasis.hpp:8
gsLegendreBasis(const index_t deg, const T &start=1, const T &end=1)
Construct Legendre basis along the parameter pars and Interval [start,end].
Definition: gsLegendreBasis.h:59
A basis represents a family of scalar basis functions defined over a common parameter domain...
Definition: gsBasis.h:78
void deriv2_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Definition: gsLegendreBasis.hpp:62