G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsBasisFun.h
Go to the documentation of this file.
1 
14 #pragma once
15 
16 #include <gsCore/gsFunction.h>
17 
18 namespace gismo
19 {
20 
21 template<class T> class gsBasis;
22 
35 template<class T>
36 class gsBasisFun : public gsFunction<T>
37 {
38 private:
40  gsBasisFun() { }
41 
42 public:
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 
56 public:
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
99 private:
100  const gsBasis<T> & m_basis;
101  unsigned m_index;
102 
103 }; // class gsBasisFun
104 
105 
106 template<class T>
107 gsBasisFun<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 
113 template<class T> void
114 gsBasisFun<T>::setFunction( unsigned const & i )
115 {
116  GISMO_ASSERT( i<unsigned(m_basis.size()),"Invalid basis function index" );
117  m_index = i;
118 }
119 
120 template<class T> void
122 {
123  m_index = 0;
124 }
125 
126 template<class T> bool
128 {
129  return ( ++m_index < static_cast<unsigned>(m_basis.size()) );
130 }
131 
132 template<class T> bool
134 {
135  return ( m_index < static_cast<unsigned>(m_basis.size()) );
136 }
137 
138 template<class T> gsMatrix<T>
140 {
141  return m_basis.support(m_index);
142 }
143 
144 template<class T> void
146 {
147  m_basis.evalSingle_into(m_index, u, result);
148 }
149 
150 template<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
memory::shared_ptr< gsBasisFun > Ptr
Shared pointer for gsBasisFun.
Definition: gsBasisFun.h:44
void first()
Point to the first basis function of the basis.
Definition: gsBasisFun.h:121
#define short_t
Definition: gsConfig.h:35
bool valid()
Return false if the the function iteration is invalidated.
Definition: gsBasisFun.h:133
short_t domainDim() const
Dimension of the (source) domain.
Definition: gsBasisFun.h:65
#define index_t
Definition: gsConfig.h:32
A function from a n-dimensional domain to an m-dimensional image.
Definition: gsFunction.h:59
short_t targetDim() const
Dimension of the target space.
Definition: gsBasisFun.h:67
bool next()
Definition: gsBasisFun.h:127
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
void setFunction(unsigned const &i)
Definition: gsBasisFun.h:114
memory::unique_ptr< gsBasisFun > uPtr
Unique pointer for gsBasisFun.
Definition: gsBasisFun.h:47
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
gsBasisFun()
Default empty constructor.
Definition: gsBasisFun.h:40
virtual const gsBasisFun & piece(const index_t) const
Returns the piece(s) of the function(s) at subdomain k.
Definition: gsBasisFun.h:92
Represents an individual function in a function set, or a certain component of a vector-valued functi...
Definition: gsBasisFun.h:36
void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate the function at points u into result.
Definition: gsBasisFun.h:145
virtual std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition: gsBasisFun.h:59
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
Provides declaration of Function abstract interface.
A basis represents a family of scalar basis functions defined over a common parameter domain...
Definition: gsBasis.h:78