G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsHBSplineBasis.h
Go to the documentation of this file.
1 
14 #pragma once
15 
17 #include <gsHSplines/gsHBSpline.h>
18 
19 namespace gismo
20 {
34 template<short_t d, class T>
35 class gsHBSplineBasis : public gsHTensorBasis<d,T>
36 {
37 public:
40 
41  typedef typename gsHTensorBasis<d,T>::CMatrix CMatrix;
42 
44 
45  typedef typename
46  util::conditional<d==1, gsConstantBasis<T>, gsHBSplineBasis<static_cast<short_t>(d-1),T>
47  >::type BoundaryBasisType;
48 
50  typedef memory::shared_ptr< gsHBSplineBasis > Ptr;
51 
53  typedef memory::unique_ptr< gsHBSplineBasis > uPtr;
54 
55 public:
56 
57  gsHBSplineBasis() { }
58 
60  gsHBSplineBasis(gsBasis<T> const& tbasis, bool manualLevels=false )
61  : gsHTensorBasis<d,T>(tbasis, manualLevels)
62  {
63  // initialize(); // is done in the base constructor
64  }
65 
67  std::vector<index_t> & boxes)
68  : gsHTensorBasis<d,T>(tbasis, boxes)
69  {
70  // initialize(); // is done in the base constructor
71  }
72 
73  gsHBSplineBasis( gsTensorBSplineBasis<d,T> const& tbasis,
74  gsMatrix<T> const & boxes)
75  : gsHTensorBasis<d,T>(tbasis, boxes)
76  {
77  // initialize(); // is done in the base constructor
78  }
79 
80 #ifdef __DOXYGEN__
81  typename BoundaryBasisType::uPtr boundaryBasis(boxSide const & s);
83 #endif
84  GISMO_UPTR_FUNCTION_DEF(BoundaryBasisType, boundaryBasis, boxSide const &)
85  {
86  return basisSlice(n1.direction(),n1.parameter());
87  }
88 
89 public:
91  BoundaryBasisType * basisSlice(index_t dir_fixed,T par ) const;
92 
93  short_t domainDim() const { return d; }
94 
95  void eval_into(const gsMatrix<T> & u, gsMatrix<T>& result) const;
96 
97  void deriv_into(const gsMatrix<T> & u, gsMatrix<T>& result) const;
98 
99  void deriv2_into(const gsMatrix<T> & u, gsMatrix<T>& result) const;
100 
101  void evalSingle_into(index_t i, const gsMatrix<T> & u, gsMatrix<T>& result) const;
102 
103  void derivSingle_into(index_t i, const gsMatrix<T> & u, gsMatrix<T>& result) const;
104 
105  void deriv2Single_into(index_t i, const gsMatrix<T> & u, gsMatrix<T>& result) const;
106 
107  GISMO_CLONE_FUNCTION(gsHBSplineBasis)
108 
109 
110  std::ostream &print(std::ostream &os) const;
112  void transferbyLvl(std::vector<gsSparseMatrix<T> >& result);
113 
114  GISMO_MAKE_GEOMETRY_NEW
115 
116 private:
117 
120  void initialize();
121 
122  gsSparseMatrix<T> coarsening(const std::vector<gsSortedVector<index_t> >& old, const std::vector<gsSortedVector<index_t> >& n, const gsSparseMatrix<T,RowMajor> & transfer) const;
123  gsSparseMatrix<T> coarsening_direct( const std::vector<gsSortedVector<index_t> >& old, const std::vector<gsSortedVector<index_t> >& n, const std::vector<gsSparseMatrix<T,RowMajor> >& transfer) const;
124 
125  gsSparseMatrix<T> coarsening_direct2( const std::vector<gsSortedVector<index_t> >& old, const std::vector<gsSortedVector<index_t> >& n, const std::vector<gsSparseMatrix<T,RowMajor> >& transfer) const;
126 
127  using gsHTensorBasis<d,T>::m_bases;
128  using gsHTensorBasis<d,T>::m_xmatrix;
129  using gsHTensorBasis<d,T>::m_xmatrix_offset;
130  using gsHTensorBasis<d,T>::m_deg;
131 
132 }; // class gsHBSplineBasis
133 
134 #ifdef GISMO_WITH_PYBIND11
135 
139  void pybind11_init_gsHBSplineBasis2(pybind11::module &m);
140  void pybind11_init_gsHBSplineBasis3(pybind11::module &m);
141  void pybind11_init_gsHBSplineBasis4(pybind11::module &m);
142 
143 #endif // GISMO_WITH_PYBIND11
144 
145 } // namespace gismo
146 
147 #ifndef GISMO_BUILD_LIB
148 #include GISMO_HPP_HEADER(gsHBSplineBasis.hpp)
149 #endif
Provides definition of HTensorBasis abstract interface.
bool manualLevels() const
Returns true if levels are assigned manually.
Definition: gsHTensorBasis.h:332
gsHBSpline< d, T > GeometryType
Associated geometry type.
Definition: gsHBSplineBasis.h:39
void deriv2Single_into(index_t i, const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate the (partial) derivatives of the i-th basis function at points u into result.
Definition: gsHBSplineBasis.hpp:93
gsHBSplineBasis(gsBasis< T > const &tbasis, bool manualLevels=false)
Constructor out of a tensor BSpline Basis.
Definition: gsHBSplineBasis.h:60
void deriv2_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate the second derivatives of all active basis function at points u.
Definition: gsHBSplineBasis.hpp:155
#define short_t
Definition: gsConfig.h:35
memory::shared_ptr< gsHBSplineBasis > Ptr
Shared pointer for gsHBSplineBasis.
Definition: gsHBSplineBasis.h:50
A hierarchical B-spline basis of parametric dimension d.
Definition: gsHBSplineBasis.h:35
gsSparseMatrix< T > coarsening(const std::vector< gsSortedVector< index_t > > &old, const std::vector< gsSortedVector< index_t > > &n, const gsSparseMatrix< T, RowMajor > &transfer) const
returns a transfer matrix using the characteristic matrix of the old and new basis ...
Definition: gsHBSplineBasis.hpp:228
std::vector< tensorBasis * > m_bases
The list of nested spaces.
Definition: gsHTensorBasis.h:361
gsHTensorBasis()
Default empty constructor.
Definition: gsHTensorBasis.h:113
#define index_t
Definition: gsConfig.h:32
This class is derived from std::vector, and adds sort tracking.
Definition: gsSortedVector.h:109
void derivSingle_into(index_t i, const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates the (partial) derivatives of the i-th basis function at points u into result.
Definition: gsHBSplineBasis.hpp:85
void deriv_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates the first partial derivatives of the nonzero basis function.
Definition: gsHBSplineBasis.hpp:128
A tensor product B-spline basis.
Definition: gsTensorBSplineBasis.h:36
BoundaryBasisType * basisSlice(index_t dir_fixed, T par) const
Gives back the basis at a slice in dir_fixed at par.
Definition: gsHBSplineBasis.hpp:39
Sparse matrix class, based on gsEigen::SparseMatrix.
Definition: gsSparseMatrix.h:140
Provides declaration of THBSplineBasis class.
std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition: gsHBSplineBasis.hpp:60
void transferbyLvl(std::vector< gsSparseMatrix< T > > &result)
returns transfer matrices betweend the levels of the given hierarchical spline
Definition: gsHBSplineBasis.hpp:188
std::vector< CMatrix > m_xmatrix
The characteristic matrices for each level.
Definition: gsHTensorBasis.h:377
Class representing a (scalar) hierarchical tensor basis of functions .
Definition: gsHTensorBasis.h:74
void initialize()
Initialize the characteristic and coefficient matrices and the internal bspline representations.
Definition: gsHBSplineBasis.hpp:70
std::vector< index_t > m_xmatrix_offset
Stores the offsets of active functions for all levels.
Definition: gsHTensorBasis.h:411
void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates nonzero basis functions at point u into result.
Definition: gsHBSplineBasis.hpp:101
A hierarchical B-Spline function, in d dimensions.
Definition: gsHBSpline.h:37
memory::unique_ptr< gsHBSplineBasis > uPtr
Unique pointer for gsHBSplineBasis.
Definition: gsHBSplineBasis.h:53
void evalSingle_into(index_t i, const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate the i-th basis function at points u into result.
Definition: gsHBSplineBasis.hpp:77
short_t domainDim() const
Dimension of the (source) domain.
Definition: gsHBSplineBasis.h:93
BoundaryBasisType::uPtr boundaryBasis(boxSide const &s)
Gives back the boundary basis at boxSide s.
void transfer(const std::vector< gsSortedVector< index_t > > &old, gsSparseMatrix< T > &result)
Returns transfer matrix between the hirarchical spline given by the characteristic matrix &quot;old&quot; and t...
Definition: gsHTensorBasis.hpp:1735
A basis represents a family of scalar basis functions defined over a common parameter domain...
Definition: gsBasis.h:78