G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
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
12namespace gismo
13{
14
15// forward declaration
16template< class T> class gsLegendreBasis;
17template <class T> class gsLegendrePoly;
18
26template<class T>
27class gsLegendreBasis : public gsBasis<T>
28{
29public:
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
53public:
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
63public:
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
122
125 {
126 return m_p;
127 }
128
129private:
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
148private:
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
A basis represents a family of scalar basis functions defined over a common parameter domain.
Definition gsBasis.h:79
Class representing a domain. i.e. a collection of elements (triangles, rectangles,...
Definition gsDomain.h:32
A univariate Legendre basis.
Definition gsLegendreBasis.h:28
void deriv2_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Definition gsLegendreBasis.hpp:62
memory::unique_ptr< gsLegendreBasis > uPtr
Unique pointer for gsLegendreBasis.
Definition gsLegendreBasis.h:48
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
memory::shared_ptr< gsLegendreBasis > Ptr
Shared pointer for gsLegendreBasis.
Definition gsLegendreBasis.h:45
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
T Scalar_t
Coefficient type.
Definition gsLegendreBasis.h:33
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 active_into(const gsMatrix< T > &u, gsMatrix< index_t > &result) const
Definition gsLegendreBasis.hpp:8
gsLegendrePoly< T > GeometryType
Associated geometry type.
Definition gsLegendreBasis.h:36
short_t domainDim() const
Returns the dimension d of the parameter space.
Definition gsLegendreBasis.h:66
gsMatrix< T > support(const index_t &i) const
Returns a bounding box for the basis' domain.
Definition gsLegendreBasis.h:87
short_t size() const
Returns the number of basis functions in the basis.
Definition gsLegendreBasis.h:116
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
gsMatrix< T > support() const
Returns a bounding box for the basis' domain.
Definition gsLegendreBasis.h:79
gsDomain< T > * domain() const
Definition gsLegendreBasis.h:120
std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition gsLegendreBasis.h:107
static const int Dim
Dimension of the parameter domain.
Definition gsLegendreBasis.h:42
short_t degree() const
Returns the polynomial degree.
Definition gsLegendreBasis.h:124
gsLegendreBasis< T > BoundaryBasisType
Associated Boundary basis type.
Definition gsLegendreBasis.h:39
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
Provides declaration of Basis abstract interface.
Provides structs and classes related to interfaces and boundaries.
Provides combinatorial unitilies.
#define short_t
Definition gsConfig.h:35
#define index_t
Definition gsConfig.h:32
#define GISMO_NO_IMPLEMENTATION
Definition gsDebug.h:129
Provides forward declarations of types and structs.
The G+Smo namespace, containing all definitions for the library.