G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsBasisFun.h
Go to the documentation of this file.
1
14#pragma once
15
16#include <gsCore/gsFunction.h>
17
18namespace gismo
19{
20
21template<class T> class gsBasis;
22
35template<class T>
36class gsBasisFun : public gsFunction<T>
37{
38private:
41
42public:
44 typedef memory::shared_ptr< gsBasisFun > Ptr;
45
47 typedef memory::unique_ptr< gsBasisFun > uPtr;
48
50 gsBasisFun(const gsBasis<T> & basis, unsigned const i);
51
52 ~gsBasisFun() { } //destructor
53
54 GISMO_CLONE_FUNCTION(gsBasisFun)
55
56public:
57
59 virtual std::ostream &print(std::ostream &os) const
60 {
61 os << "gsBasisFun"; return os;
62 }
63
64
65 short_t domainDim () const {return m_basis.domainDim();}
66
67 short_t targetDim () const {return m_basis.targetDim();}
68
69 gsMatrix<T> support() const;
70
71 void eval_into (const gsMatrix<T>& u, gsMatrix<T>& result ) const;
72
73 void deriv_into(const gsMatrix<T>& u, gsMatrix<T>& result ) const;
74
77 void setFunction( unsigned const & i );
78
80 void first();
81
84 bool next();
85
87 bool valid();
88
89 unsigned index() const { return m_index; }
90
91 // temporary hack
92 virtual const gsBasisFun & piece(const index_t) const
93 {
94 return *this;
95 }
96
97
98// Data members
99private:
100 const gsBasis<T> & m_basis;
101 unsigned m_index;
102
103}; // class gsBasisFun
104
105
106template<class T>
107gsBasisFun<T>::gsBasisFun(const gsBasis<T> & basis, const unsigned i )
108: m_basis(basis), m_index(i)
109{
110 GISMO_ASSERT( i<unsigned(m_basis.size()),"Invalid basis function index" );
111}
112
113template<class T> void
114gsBasisFun<T>::setFunction( unsigned const & i )
115{
116 GISMO_ASSERT( i<unsigned(m_basis.size()),"Invalid basis function index" );
117 m_index = i;
118}
119
120template<class T> void
122{
123 m_index = 0;
124}
125
126template<class T> bool
128{
129 return ( ++m_index < static_cast<unsigned>(m_basis.size()) );
130}
131
132template<class T> bool
134{
135 return ( m_index < static_cast<unsigned>(m_basis.size()) );
136}
137
138template<class T> gsMatrix<T>
140{
141 return m_basis.support(m_index);
142}
143
144template<class T> void
146{
147 m_basis.evalSingle_into(m_index, u, result);
148}
149
150template<class T> void
152{
153 m_basis.derivSingle_into(m_index, u, result);
154}
155
156#ifdef GISMO_WITH_PYBIND11
157
161 void pybind11_init_gsBasisFun(pybind11::module &m);
162
163#endif // GISMO_WITH_PYBIND11
164
165} // namespace gismo
Represents an individual function in a function set, or a certain component of a vector-valued functi...
Definition gsBasisFun.h:37
bool valid()
Return false if the the function iteration is invalidated.
Definition gsBasisFun.h:133
void first()
Point to the first basis function of the basis.
Definition gsBasisFun.h:121
memory::shared_ptr< gsBasisFun > Ptr
Shared pointer for gsBasisFun.
Definition gsBasisFun.h:44
memory::unique_ptr< gsBasisFun > uPtr
Unique pointer for gsBasisFun.
Definition gsBasisFun.h:47
short_t targetDim() const
Dimension of the target space.
Definition gsBasisFun.h:67
void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate the function at points u into result.
Definition gsBasisFun.h:145
bool next()
Definition gsBasisFun.h:127
virtual std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition gsBasisFun.h:59
virtual const gsBasisFun & piece(const index_t) const
Returns the piece(s) of the function(s) at subdomain k.
Definition gsBasisFun.h:92
gsBasisFun()
Default empty constructor.
Definition gsBasisFun.h:40
short_t domainDim() const
Dimension of the (source) domain.
Definition gsBasisFun.h:65
void deriv_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate derivatives of the function at points u into result.
Definition gsBasisFun.h:151
void setFunction(unsigned const &i)
Definition gsBasisFun.h:114
A basis represents a family of scalar basis functions defined over a common parameter domain.
Definition gsBasis.h:79
const gsBasis< T > & basis(const index_t k) const
Helper which casts and returns the k-th piece of this function set as a gsBasis.
Definition gsFunctionSet.hpp:33
A function from a n-dimensional domain to an m-dimensional image.
Definition gsFunction.h:60
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
#define short_t
Definition gsConfig.h:35
#define index_t
Definition gsConfig.h:32
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
Provides declaration of Function abstract interface.
The G+Smo namespace, containing all definitions for the library.