G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsHBSpline.h
Go to the documentation of this file.
1
14#pragma once
15
16#include <ostream>
17
19#include <gsCore/gsGeometry.h>
21
22namespace gismo
23{
24
36template<short_t d, class T>
37class gsHBSpline : public gsGeoTraits<d,T>::GeometryBase
38{
39public:
40 typedef typename gsGeoTraits<d,T>::GeometryBase Base;
41
43
45 typedef memory::shared_ptr< gsHBSpline > Ptr;
46
48 typedef memory::unique_ptr< gsHBSpline > uPtr;
49
50 typedef typename
51 util::conditional<d==1, gsConstantFunction<T>, gsHBSpline<static_cast<short_t>(d-1),T>
52 >::type BoundaryGeometryType;
53
54 typedef typename gsHBSplineBasis<d,T>::BoundaryBasisType BoundaryBasisType;
55
56public:
57
60
62 gsHBSpline( const Basis * basis, const gsMatrix<T> * coefs ) :
63 Base( basis, coefs ) { }
64
66 gsHBSpline( const Basis & basis, const gsMatrix<T> & coefs ) :
67 Base( basis, coefs ) { }
68
70 explicit gsHBSpline( const gsTensorBSpline<d,T> & tbsp )
71 {
72 this->m_basis = new Basis( tbsp.basis() );
73 this->m_coefs = tbsp.coefs();
74 }
75
76 GISMO_CLONE_FUNCTION(gsHBSpline)
77
78 GISMO_BASIS_ACCESSORS
79
80public:
81
85 void slice(index_t dir_fixed,T par,BoundaryGeometryType & result) const
86 {
87 GISMO_ASSERT(d-1>=0,"d must be greater or equal than 1");
88 GISMO_ASSERT(dir_fixed>=0 && static_cast<unsigned>(dir_fixed)<d,"cannot fix a dir greater than dim or smaller than 0");
89 const BoundaryBasisType * bBasis = this->basis().basisSlice(dir_fixed,par);
90 if(d==1)
91 {
92 gsMatrix<T> val(1,1),point;
93 val(0,0)=par;
94 this->eval_into(val,point);
95 result=BoundaryGeometryType(*bBasis,point);
96 }
97 else
98 {
99 gsMatrix<T> vals,anchorsSlice,anchorsInGeom;
100 bBasis->anchors_into(anchorsSlice);
101 anchorsInGeom.resize(anchorsSlice.rows()+1,anchorsSlice.cols());
102 anchorsInGeom.topRows(dir_fixed)=anchorsSlice.topRows(dir_fixed);
103 anchorsInGeom.row(dir_fixed)=gsVector<T>::Constant(anchorsSlice.cols(),par);
104 anchorsInGeom.bottomRows(anchorsSlice.rows()-dir_fixed)=anchorsSlice.bottomRows(anchorsSlice.rows()-dir_fixed);
105 this->eval_into(anchorsInGeom,vals);
106 BoundaryGeometryType* geom =
107 dynamic_cast<BoundaryGeometryType *>(bBasis->interpolateAtAnchors(vals).release()); //todo make it better
108 GISMO_ASSERT(geom!=NULL,"bBasis should have BoundaryGeometryType.");
109 result = *geom;
110 delete geom;
111 }
112 delete bBasis;
113 }
114}; // class gsHBSpline
115
116#ifdef GISMO_WITH_PYBIND11
117
121 void pybind11_init_gsHBSpline2(pybind11::module &m);
122 void pybind11_init_gsHBSpline3(pybind11::module &m);
123 void pybind11_init_gsHBSpline4(pybind11::module &m);
124
125#endif // GISMO_WITH_PYBIND11
126
127} // namespace gismo
128
129#ifndef GISMO_BUILD_LIB
130#include GISMO_HPP_HEADER(gsHBSpline.hpp)
131#endif
Abstract base class representing a geometry map.
Definition gsGeometry.h:93
gsMatrix< T > & coefs()
Definition gsGeometry.h:340
void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate the function at points u into result.
Definition gsGeometry.hpp:166
virtual const gsBasis< T > & basis() const =0
Returns a const reference to the basis of the geometry.
gsBasis< T > * m_basis
Pointer to the basis of this geometry.
Definition gsGeometry.h:632
gsMatrix< T > m_coefs
Coefficient matrix of size coefsSize() x geoDim()
Definition gsGeometry.h:629
A hierarchical B-spline basis of parametric dimension d.
Definition gsHBSplineBasis.h:36
A hierarchical B-Spline function, in d dimensions.
Definition gsHBSpline.h:38
gsHBSpline(const Basis *basis, const gsMatrix< T > *coefs)
Construct HB-Spline by basis functions and coefficient matrix.
Definition gsHBSpline.h:62
memory::unique_ptr< gsHBSpline > uPtr
Unique pointer for gsHBSpline.
Definition gsHBSpline.h:48
gsHBSpline(const Basis &basis, const gsMatrix< T > &coefs)
Construct HB-Spline by basis functions and coefficient matrix.
Definition gsHBSpline.h:66
memory::shared_ptr< gsHBSpline > Ptr
Shared pointer for gsHBSpline.
Definition gsHBSpline.h:45
gsHBSpline()
Default empty constructor.
Definition gsHBSpline.h:59
void slice(index_t dir_fixed, T par, BoundaryGeometryType &result) const
Definition gsHBSpline.h:85
gsHBSpline(const gsTensorBSpline< d, T > &tbsp)
Construct B-Spline from a Tensor B-Spline.
Definition gsHBSpline.h:70
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
A tensor product of d B-spline functions, with arbitrary target dimension.
Definition gsTensorBSpline.h:45
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
#define index_t
Definition gsConfig.h:32
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
Provides declaration of Geometry abstract interface.
Provides declaration of HBSplineBasis class.
This is the main header file that collects wrappers of Eigen for linear algebra.
The G+Smo namespace, containing all definitions for the library.