G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsMvLegandreBasis.h
1 #pragma once
2 #include <cmath>
3 
4 //#include <gismo.h>
6 //#include "gsMvLegendreBasis.hpp"
8 
9 namespace gismo
10 {
11 
12 // forward declaration
13 template< class T> class gsMvLegendreBasis;
14 template <class T> class gsMvLegendrePoly;
15 
23 template<class T>
24 class gsMvLegendreBasis : public gsBasis<T>
25 {
26 public:
27  typedef gsBasis<T> Base;
28 
30  typedef T Scalar_t;
31 
33  typedef gsMvLegendrePoly<T> GeometryType;
34 
37 
39  static const int Dim = 1;
40 
42  typedef memory::shared_ptr< gsMvLegendreBasis > Ptr;
43 
45  typedef memory::unique_ptr< gsMvLegendreBasis > uPtr;
46 
47  static Ptr Make ( const gsVector<T> & vec, const T & start, const T & end) // TODO: remove?
48  { return Ptr( new gsMvLegendreBasis(vec,start,end) ); }
49 
50 public:
52  explicit gsMvLegendreBasis (const index_t deg, const T & start = 1, const T & end = 1) :
53  m_ubasis(deg,start, m_end)
54  { }
55 
56 public:
57 
59  int dim() const { return Dim; }
60 
63  void active_into(const gsMatrix<T> & u, gsMatrix<index_t>& result) const;
64 
66  void numActive_into(const gsMatrix<T> & u, gsVector<index_t>& result) const
67  {
68  result.setConstant(1, u.cols(), m_p+1);
69  }
70 
73  {
74  gsMatrix<T> res(1,2);
75  res << m_start , m_end ;
76  return res;
77  }
78 
80  gsMatrix<T> support(const index_t & i) const
81  {
82  return support();
83  }
84 
86  void eval_into(const gsMatrix<T> & u, gsMatrix<T>& result) const;
87 
89  void deriv_into(const gsMatrix<T> & u, gsMatrix<T>& result ) const;
90 
93  void deriv2_into(const gsMatrix<T> & u, gsMatrix<T>& result ) const;
94 
95  GISMO_CLONE_FUNCTION(gsMvLegendreBasis)
96 
97  GISMO_MAKE_GEOMETRY_NEW
98 
100  std::ostream &print(std::ostream &os) const
101  {
102  os << "MvLegendre Basis: deg=" << this->degree()
103  << ", size="<< this->size()
104  << ", interval= [" << m_start << "," << m_end << "].\n";
105  return os;
106  }
107 
109  int size() const { return m_p+1; }
110 
113  gsDomain<T> * domain() const
115 
117  short_t degree() const
118  {
119  return m_p;
120  }
121 
122 private:
123 
124  inline T _getA(const index_t j)
125  {
126  return (T)(2*j-1)/j;
127  return math::sqrt((T)(2*j-1)) * math::sqrt((T)(2*j+1)) / (j*math::sqrt((T)3));
128  }
129 
130  inline T _getB(const index_t j)
131  {
132  return 0;
133  }
134 
135  inline T _getC(const index_t j)
136  {
137  return (T)(j-1)/j;
138  return _getA(j) / _getA(j-1);
139  }
140 
141 private:
142  gsLegendreBasis<T> m_ubasis;
143 }; // class gsMvLegendreBasis
144 
145 } // namespace gismo
146 
147 
148 //include the hpp file that contains the file definitions
149 //#include "gsMvLegendreBasis.hpp"
150 
Class representing a domain. i.e. a collection of elements (triangles, rectangles, cubes, simplices.
Definition: gsDomain.h:31
int size() const
Returns the number of basis functions in the basis.
Definition: gsMvLegandreBasis.h:109
#define GISMO_NO_IMPLEMENTATION
Definition: gsDebug.h:129
GISMO_MAKE_GEOMETRY_NEW std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition: gsMvLegandreBasis.h:100
void active_into(const gsMatrix< T > &u, gsMatrix< index_t > &result) const
#define short_t
Definition: gsConfig.h:35
memory::shared_ptr< gsMvLegendreBasis > Ptr
Shared pointer for gsMvLegendreBasis.
Definition: gsMvLegandreBasis.h:42
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: gsMvLegandreBasis.h:66
#define index_t
Definition: gsConfig.h:32
Provides combinatorial unitilies.
gsMvLegendreBasis< T > BoundaryBasisType
Associated Boundary basis type.
Definition: gsMvLegandreBasis.h:36
static const int Dim
Dimension of the parameter domain.
Definition: gsMvLegandreBasis.h:39
gsMvLegendrePoly< T > GeometryType
Associated geometry type.
Definition: gsMvLegandreBasis.h:33
A multivariate Legendre basis.
Definition: gsMvLegandreBasis.h:13
memory::shared_ptr< gsBasis > Ptr
Shared pointer for gsBasis.
Definition: gsBasis.h:86
int dim() const
Returns the dimension d of the parameter space.
Definition: gsMvLegandreBasis.h:59
Interface for the set of functions defined on a domain (the total number of functions in the set equa...
Definition: gsFuncData.h:23
Provides forward declarations of types and structs.
gsDomain< T > * domain() const
Definition: gsMvLegandreBasis.h:113
gsMvLegendreBasis(const index_t deg, const T &start=1, const T &end=1)
Construct MvLegendre basis along the parameter pars and Interval [start,end].
Definition: gsMvLegandreBasis.h:52
T Scalar_t
Coefficient type.
Definition: gsMvLegandreBasis.h:30
void deriv2_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates the non-zero basis functions at value u.
short_t degree() const
Returns the polynomial degree.
Definition: gsMvLegandreBasis.h:117
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...
gsMatrix< T > support() const
Returns a bounding box for the basis&#39; domain.
Definition: gsMvLegandreBasis.h:72
gsMatrix< T > support(const index_t &i) const
Returns a bounding box for the basis&#39; domain.
Definition: gsMvLegandreBasis.h:80
A basis represents a family of scalar basis functions defined over a common parameter domain...
Definition: gsBasis.h:78
memory::unique_ptr< gsMvLegendreBasis > uPtr
Unique pointer for gsMvLegendreBasis.
Definition: gsMvLegandreBasis.h:45