G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsLagrangePoly.h
1// defined over a Lagrange basis
2
3#pragma once
4
5#include <ostream>
6
8#include <gsCore/gsGeometry.h>
9#include "gsLagrangeBasis.h"
10
11
12namespace gismo
13{
14
25template<class T>
26class gsLagrangePoly : public gsGeoTraits<1,T>::GeometryBase
27{
28
29public:
31 typedef typename gsGeoTraits<1,T>::GeometryBase Base;
32
34 typedef memory::shared_ptr< gsLagrangePoly > Ptr;
35
37 typedef memory::unique_ptr< gsLagrangePoly > uPtr;
38
41
45
47 gsLagrangePoly( const unsigned & p, const gsMatrix<T> & coefs, const T & u0=0, const T & u1= 1) : Base()
48 {
49 gsLagrangeBasis<T> * lagrange_basis = new Basis(u0,u1,p-1);
51 Base::m_basis=lagrange_basis;
52 GISMO_ASSERT( lagrange_basis->size() == this->m_coefs.rows(),
53 "The coefficient matrix of the geometry (rows="<<this->m_coefs.rows()<<") does not match the number of basis functions in its basis("<< lagrange_basis->size() <<").");
54 }
55
58 gsLagrangePoly( const gsBSpline<T> & bezier_curve, int part) : Base()
59 {
60 gsBSplineBasis<T> basis = bezier_curve.basis();
61 gsKnotVector<T> * bezier_knots = &basis.knots();
62 T start = (*bezier_knots)[part];
63 T end = (*bezier_knots)[part+1];
64 gsLagrangeBasis<T> * lagrange_basis = new gsLagrangeBasis<T>(0,1, basis.degree()-1);
65 gsMatrix<T> lagrange_coeffs;
66 const std::vector<T> * lagrange_breaks = lagrange_basis->get_m_breaks();
67 gsMatrix<T> u(1,lagrange_breaks->size());
68 for(unsigned i = 0;i<lagrange_breaks->size();i++)
69 {
70 u(0,i)=start+(end-start)*lagrange_breaks->at(i);
71 }
72 bezier_curve.eval_into(u,lagrange_coeffs);
73 Base::m_coefs=lagrange_coeffs.transpose();
74 Base::m_basis=lagrange_basis;
75 GISMO_ASSERT( lagrange_basis->size() == this->m_coefs.rows(),
76 "The coefficient matrix of the geometry (rows="<<this->m_coefs.rows()<<") does not match the number of basis functions in its basis("<< lagrange_basis->size() <<").");
77 }
78
79
80public:
81
82 GISMO_BASIS_ACCESSORS
83
84 GISMO_CLONE_FUNCTION(gsLagrangePoly)
85
86
87 std::ostream &print(std::ostream &os) const
88 {
89 os << "Lagrange curve of degree "<<
90 this->basis().degree()<< ", over [" << domainStart()
91 << " " << domainEnd() << "] with breaks ";
92 for ( typename std::vector<T>::const_iterator itr=
93 this->basis().get_m_breaks()->begin(); itr != this->basis().get_m_breaks()->end(); ++itr )
94 os << *itr << ", ";
95 return os;
96 }
97
98
100// Additional members for univariate B-Splines
102
104 T domainStart() const { return this->basis().get_m_start(); }
105
107 T domainEnd() const { return this->basis().get_m_end(); }
108
113 {
114 gsMatrix<T> transformMat;
115 this->basis().getTransformationLagrangeBezier(transformMat);
116 gsMatrix<T> newCoefs = transformMat*this->coefs();
117 unsigned deg = this->basis().degree();
118 gsBSpline<T> * bezCurve = new gsBSpline<T>(0.0,1.0,0,deg,newCoefs);
119 return bezCurve;
120 }
121
124 {
125 this->basis().reparameterizeToZeroOne();
126 }
127
128// Data members
129private:
130
131}; // class gsLagrangePoly
132
133
134
135}; // namespace gismo
A univariate B-spline basis.
Definition gsBSplineBasis.h:700
A B-spline function of one argument, with arbitrary target dimension.
Definition gsBSpline.h:51
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
Class for representing a knot vector.
Definition gsKnotVector.h:80
A univariate Lagrange basis.
Definition gsLagrangeBasis.h:46
const std::vector< T > * get_m_breaks() const
Returns the breaks vector of this basis.
Definition gsLagrangeBasis.h:325
short_t size() const
Returns the number of basis functions in the basis.
Definition gsLagrangeBasis.h:239
The geometry class of a Lagrange Polyomial curve.
Definition gsLagrangePoly.h:27
gsLagrangePoly(const gsBSpline< T > &bezier_curve, int part)
Definition gsLagrangePoly.h:58
gsLagrangePoly(const Basis &basis, gsMatrix< T > coefs)
Construct B-Spline by basis and coefficient matrix.
Definition gsLagrangePoly.h:43
gsLagrangePoly(const unsigned &p, const gsMatrix< T > &coefs, const T &u0=0, const T &u1=1)
Construct Lagrange curve by degree, coefficient matrix and domain.
Definition gsLagrangePoly.h:47
void reparameterizeToZeroOne()
reparameterize this curve to [0,1]
Definition gsLagrangePoly.h:123
gsBSpline< T > * transformToBezier()
Definition gsLagrangePoly.h:112
gsLagrangePoly()
Default empty constructor.
Definition gsLagrangePoly.h:40
T domainEnd() const
Returns the end value of the domain of the basis.
Definition gsLagrangePoly.h:107
memory::shared_ptr< gsLagrangePoly > Ptr
Shared pointer for gsLagrangePoly.
Definition gsLagrangePoly.h:34
memory::unique_ptr< gsLagrangePoly > uPtr
Unique pointer for gsLagrangePoly.
Definition gsLagrangePoly.h:37
GISMO_BASIS_ACCESSORS std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition gsLagrangePoly.h:87
T domainStart() const
Returns the starting value of the domain of the basis.
Definition gsLagrangePoly.h:104
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
Provides declaration of Geometry abstract interface.
This is the main header file that collects wrappers of Eigen for linear algebra.
The G+Smo namespace, containing all definitions for the library.
S give(S &x)
Definition gsMemory.h:266