G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsBSplineBasis.h
Go to the documentation of this file.
1
15#pragma once
16
19
23
25
26namespace gismo
27{
28
30template<short_t d, class T>
32{
33 typedef gsKnotVector<T> KnotVectorType;
34
39};
40template<class T>
41struct gsBSplineTraits<1,T>
42{
43 typedef gsKnotVector<T> KnotVectorType;
44 typedef gsBSplineBasis<T> Basis;
45 typedef gsNurbsBasis<T> RatBasis;
46 typedef gsBSpline<T> Geometry;
47 typedef gsNurbs<T> RatGeometry;
48};
49template<class T>
50struct gsBSplineTraits<0,T>
51{
52 typedef gsKnotVector<T> KnotVectorType;
53 typedef gsConstantBasis<T> Basis;
54 typedef gsConstantBasis<T> RatBasis;
55 typedef gsConstantFunction<T> Geometry;
56 typedef gsConstantFunction<T> RatGeometry;
57};
58
68template<class T>
69class gsTensorBSplineBasis<1,T> : public gsTensorBasis<1,T>
70{
71public:
72 typedef gsKnotVector<T> KnotVectorType;
73
75
76 typedef gsBSplineBasis<T> Self_t;
77
80
82 typedef T Scalar_t;
83
86
89
91 static const short_t Dim = 1;
92
94 typedef memory::shared_ptr< Self_t > Ptr;
95
97 typedef memory::unique_ptr< Self_t > uPtr;
98
99public:
100
101 // Look at gsBasis class for a description
102 // Note: Specializing pointer type at return
103 //GISMO_UPTR_FUNCTION_PURE(TensorSelf_tt, clone)
104 private: virtual gsTensorBSplineBasis * clone_impl() const = 0;
105 public: uPtr clone() const { return uPtr(dynamic_cast<Self_t*>(clone_impl())); }
106
107 // gsTensorBSplineBasis( const Base & o)
108 // {
109 // const gsTensorBSplineBasis * a;
110 // if ( ( a = dynamic_cast<const gsTensorBSplineBasis *>( &o )) )
111 // {
112 // m_p = a->degree() ;
113 // m_knots = KnotVectorType( a->knots() );
114 // m_periodic = a->m_periodic;
115 // }
116 // else
117 // GISMO_ERROR("Cannot convert "<<o<<" to gsTensorBSplineBasis\n");
118 // }
119
120 static Self_t * New(std::vector<gsBasis<T>*> & bb );
121
122 static Self_t * New(std::vector<Self_t*> & bb )
123 {
124 return new Self_t(*bb.front());
125 }
126
127 static uPtr make(std::vector<gsBasis<T>*> & bb )
128 {
129 return uPtr(New(bb));
130 }
131
132 static uPtr make(std::vector<Self_t*> & bb )
133 {
134 return uPtr(new Self_t(*bb.front()));
135 }
136
137 static uPtr make( const KnotVectorType & KV )
138 {
139 return uPtr(new Self_t(KV));
140 }
141
142 // Note: these casts can be dangerous
143 // operator Self_t &() { return dynamic_cast<Self_t&>(*this);}
144 // operator const Self_t &() const { return dynamic_cast<const Self_t&>(*this);}
145
146public:
147
148 void swap(gsTensorBSplineBasis& other)
149 {
150 std::swap(m_p, other.m_p);
151 std::swap(m_periodic, other.m_periodic);
152 m_knots.swap(other.m_knots);
153 }
154
155/* Virtual member functions required by the base class */
156
157 // Look at gsBasis class for a description
158 short_t domainDim() const { return Dim; }
159
160 // Unhide/forward gsTensorBasis<1,T>::size(k), since the overload
161 // with size() automatically hides it in this class
162 using Base::size;
163
164 // Look at gsBasis class for a description
165 index_t size() const { return m_knots.size() - m_p - 1 - m_periodic; }
166
167 // Look at gsBasis class for a description
168 size_t numElements(boxSide const & s = 0) const { return (0==s?m_knots.numElements():1); }
169
170 // Look at gsBasis class for a description
171 size_t elementIndex(const gsVector<T> & u ) const;
172
173 // Same as gsBasis::elementIndex but argument is a value instead of a vector
174 size_t elementIndex(T u ) const;
175
176 // Look at gsBasis class for a description
178
182 {
183 gsMatrix<index_t> tmp_vec;
184 m_knots.supportIndex_into(i, tmp_vec);
185 result = tmp_vec.cwiseMax(0).cwiseMin(m_knots.numElements());
186 }
187
188 template <int _Rows>
189 gsMatrix<T> elementDom(const gsMatrix<index_t,_Rows,2> & box) const
190 {
191 gsMatrix<T> rvo(1,2);
192 rvo.at(0) = m_knots.uValue(box.at(0));
193 rvo.at(1) = m_knots.uValue(box.at(1));
194 return rvo;
195 }
196
197 // Look at gsBasis class for a description
198 const TensorSelf_t & component(short_t i) const = 0;
199
200 // Look at gsBasis class for a description
202
204 void anchors_into(gsMatrix<T> & result) const
205 {
206 m_knots.greville_into(result);
207 }
208
210 void anchor_into(index_t i, gsMatrix<T> & result) const
211 {
212 result.resize(1,1);
213 result(0,0) = m_knots.greville(i);
214 }
215
216 // Look at gsBasis class for a description
217 void connectivity(const gsMatrix<T> & nodes,
218 gsMesh<T> & mesh) const;
219
220 // Look at gsBasis class for a description
221 void active_into(const gsMatrix<T> & u, gsMatrix<index_t>& result) const;
222
223 // Look at gsBasis class for a description
224 bool isActive(const index_t i, const gsVector<T> & u) const;
225
226 // Look at gsBasis class for a description
228
229 // Look at gsBasis class for a description
230 gsMatrix<index_t> boundaryOffset(boxSide const & s,index_t offset) const;
231
232#ifdef __DOXYGEN__
235#endif
236 GISMO_UPTR_FUNCTION_DEC(gsConstantBasis<T>, boundaryBasis, boxSide const &)
237
238 // Look at gsBasis class for a description
239 gsMatrix<T> support() const ;
240
241 // Look at gsBasis class for a description
242 gsMatrix<T> support(const index_t & i ) const ;
243
247 index_t twin(index_t i) const ;
248
249 // Look at gsBasis class for a description
250 virtual void eval_into(const gsMatrix<T> & u, gsMatrix<T>& result) const;
251
252 // Look at gsBasis class for a description
253 virtual void evalSingle_into(index_t i, const gsMatrix<T> & u, gsMatrix<T>& result) const;
254
255 // Look at gsBasis class for a description
256 virtual void evalFunc_into(const gsMatrix<T> & u, const gsMatrix<T> & coefs, gsMatrix<T>& result) const;
257
258 // Look at gsBasis class for a description
259 void deriv_into(const gsMatrix<T> & u, gsMatrix<T>& result ) const ;
260
261 // Look at gsBasis class for a description
262 void derivSingle_into(index_t i, const gsMatrix<T> & u, gsMatrix<T>& result ) const ;
263
264 // Look at gsBasis class for a description
265 void deriv_into(const gsMatrix<T> & u, const gsMatrix<T> & coefs, gsMatrix<T>& result ) const ;
266
267 // Look at gsBasis class for a description
268 void deriv2_into(const gsMatrix<T> & u, gsMatrix<T>& result ) const ;
269
270 // Look at gsBasis class for a description
271 void deriv2Single_into(index_t i, const gsMatrix<T> & u, gsMatrix<T>& result ) const ;
272
273 // Look at gsBasis class for a description
274 void deriv2_into(const gsMatrix<T> & u, const gsMatrix<T> & coefs, gsMatrix<T>& result ) const ;
275
276 // Look at gsBasis class for a description
277 gsMatrix<T> laplacian(const gsMatrix<T> & u ) const ;
278
279 // Look at gsBasis class for a description
280 typename gsBasis<T>::uPtr tensorize(const gsBasis<T> & other) const;
281
283 bool check() const
284 {
285 if ( m_periodic > 0 )
286 {
287 // Periodicity check wrt knot values
288 return (
289 m_knots.degree() == m_p &&
290 (int)m_knots.size() > 2*m_p+1
291 );
292 }
293 else
294 {
295 return (
296 m_knots.degree() == m_p &&
297 (int)m_knots.size() > 2*m_p+1
298 );
299 }
300 }
301
303 std::ostream &print(std::ostream &os) const;
304
306 std::string detail() const;
307
308 // Look at gsBasis class for a description
309 virtual void evalDerSingle_into(index_t i, const gsMatrix<T> & u,
310 int n, gsMatrix<T>& result) const;
311
312 // Look at gsBasis class for a description
313 virtual void evalAllDers_into(const gsMatrix<T> & u, int n,
314 std::vector<gsMatrix<T> >& result,
315 bool sameElement = false) const;
316
317 // Look at gsBasis class for a description
319 GISMO_DEPRECATED
320 virtual void evalAllDersSingle_into(index_t i, const gsMatrix<T> & u,
321 int n, gsMatrix<T>& result) const;
322
323 // Look at gsBasis class for a description
325 {
326 GISMO_UNUSED(i);
327 GISMO_ASSERT(i==0,"Asked for degree(i) in 1D basis.");
328 return m_p;
329 }
330
331 short_t degree() const {return m_p;}
332
333 // Look at gsBasis class for a description
334 short_t maxDegree() const { return m_p; }
335
336 // Look at gsBasis class for a description
337 short_t minDegree() const { return m_p; }
338
339 // Look at gsBasis class for a description
340 short_t totalDegree() const { return m_p; }
341
343 inline unsigned order() const { return m_p+1; }
344
346 inline bool inDomain(T const & pp) const
347 { return ( (pp >= *(m_knots.begin()+m_p)) && (pp <= *(m_knots.end()-m_p-1) ) ); }
348
350 T domainStart() const { return *(m_knots.begin()+m_p); }
351
353 T domainEnd() const { return *(m_knots.end()-m_p-1); }
354
356 T _activeLength() const { return domainEnd() - domainStart(); }
357
360 inline index_t firstActive(T u) const {
361 return ( inDomain(u) ? (m_knots.iFind(u)-m_knots.begin()) - m_p : 0 );
362 }
363
364 // Number of active functions at any point of the domain
365 inline index_t numActive() const { return m_p + 1; }
366
367 // Look at gsBasis class for a description
368 gsDomain<T> * domain() const { return const_cast<KnotVectorType *>(&m_knots); }
369
371 const KnotVectorType & knots (int i = 0) const
372 {
373 GISMO_ENSURE(i==0, "Invalid knots requested");
374 return m_knots;
375 }
376 KnotVectorType & knots (int i = 0)
377 {
378 GISMO_ENSURE(i==0, "Invalid knots requested");
379 return m_knots;
380 }
381
382 T knot(index_t const & i) const { return m_knots[i];}
383
385 void insertKnot(T knot, int mult=1)
386 { m_knots.insert( knot, mult); }
387
389 void removeKnot(T knot, int mult=1)
390 { m_knots.remove( knot, mult); }
391
392 // compatibility with tensor-bsplines
393 void insertKnots(const std::vector< std::vector<T> >& refineKnots)
394 {
395 GISMO_ASSERT( refineKnots.size() == 1, "refineKnots vector has wrong size" );
396 this->knots().insert(refineKnots.front());
397 }
398
399 // Look at gsBasis class for a description
400 void refineElements(std::vector<index_t> const & elements)
401 { m_knots.refineSpans(elements); }
402
403 // Look at gsBasis class for a description
404 void uniformRefine(int numKnots = 1, int mul=1, int dir=-1)
405 { GISMO_UNUSED(dir); m_knots.uniformRefine(numKnots,mul); }
406
407 // Look at gsBasis class for a description
408 void uniformRefine_withCoefs(gsMatrix<T>& coefs, int numKnots = 1, int mul = 1, short_t const dir = -1);
409
410 // Look at gsBasis class for a description
411 void uniformRefine_withTransfer(gsSparseMatrix<T,RowMajor> & transfer, int numKnots = 1, int mul = 1);
412
413 // Look at gsBasis class for a description
414 void uniformCoarsen(int numKnots = 1)
415 { m_knots.coarsen(numKnots); }
416
417 // Look at gsBasis class for a description
418 void uniformCoarsen_withTransfer(gsSparseMatrix<T,RowMajor> & transfer, int numKnots = 1);
419
422 void refine_withCoefs(gsMatrix<T>& coefs, const std::vector<T>& knots);
423 void refine_withCoefs(gsMatrix<T>& /* coefs */, const gsMatrix<T> & /* boxes */)
425
426 // compatibility with tensor-bsplines
427 void refine_withCoefs(gsMatrix<T> & coefs,
428 const std::vector< std::vector<T> >& refineKnots)
429 {
430 refine_withCoefs(coefs,refineKnots.front() );
431 }
432
434 void refine_withTransfer(gsSparseMatrix<T,RowMajor> & transfer, const std::vector<T>& knots);
435 void refine_withTransfer(gsMatrix<T>& /* coefs */, const gsMatrix<T> & /* boxes */)
437 void refine_withTransfer(gsSparseMatrix<T,RowMajor> & transfer,
438 const std::vector<std::vector<T> >& knots)
439 {
440 GISMO_ASSERT(knots.size()==1, "the knots you want to insert do not have the right dimension");
441 refine_withTransfer(transfer,knots.front());
442 //GISMO_NO_IMPLEMENTATION
443 }
444
459 void refine_k(const TensorSelf_t & other, int const & i = 1)
460 {
461 GISMO_ASSERT( m_p >= other.m_p, "Degree of other knot-vector should be lower.");
462 //for (typename std::vector<T>::iterator it =
463 // m_knots.begin(); it != m_knots.end(); ++it)
464 // GISMO_ASSERT( has(*it), "Knot "<< *it<<" is not in the knot vector.");
465
466 // grab unique knots
467 const std::vector<T> knots = other.m_knots.unique();
468
469 // Increase the degree without adjusting any knot
470 m_p += i;
471 m_knots.set_degree(m_p);
472 // Adjust (reduce) smoothness to satisfy initial constraint knots
473 m_knots.insert(knots,i);
474 }
475
477 void refine_p(short_t const & i = 1)
478 { degreeElevate(i); }
479
481 void refine_h(short_t const & i = 1)
482 { uniformRefine(i); }
483
485 void degreeElevate(short_t const & i = 1, short_t const dir = -1)
486 {
487 GISMO_UNUSED(dir);
488 GISMO_ASSERT( dir == -1 || dir == 0, "Invalid direction");
489 m_p+=i; m_knots.degreeElevate(i);
490 }
491
492 // Look at gsBasis for documentation
493 void degreeReduce (short_t const & i = 1, short_t const dir = -1)
494 {
495 GISMO_UNUSED(dir);
496 GISMO_ASSERT( dir == -1 || dir == 0, "Invalid direction");
497 GISMO_ASSERT( i<=m_p, "Cannot reduce degree to negative");
498 m_p-=i; m_knots.degreeReduce(i);
499 //m_periodic =
500 }
501
502 // Look at gsBasis for documentation
503 void degreeIncrease(short_t const & i = 1, short_t const dir = -1)
504 {
505 GISMO_UNUSED(dir);
506 GISMO_ASSERT( dir == -1 || dir == 0, "Invalid direction");
507 m_p+=i; m_knots.degreeIncrease(i);
508 }
509
510 // Look at gsBasis for documentation
511 void degreeDecrease(short_t const & i = 1, short_t const dir = -1)
512 {
513 GISMO_UNUSED(dir);
514 GISMO_ASSERT( dir == -1 || dir == 0, "Invalid direction");
515 m_p-=i; m_knots.degreeDecrease(i);
516 }
517
519 void elevateContinuity(int const & i = 1)
520 {
521 GISMO_ASSERT( i>=0 && ( m_knots.size()>static_cast<size_t>(2*(m_p+1)) || i<=m_p ),
522 "Cannot achieve continuity less than C^{-1} at interior knots.");
523 m_knots.reduceMultiplicity(i);
524 }
525
527 void reduceContinuity(int const & i = 1)
528 {
529 GISMO_ASSERT( i>=0 && ( m_knots.size()>static_cast<size_t>(2*(m_p+1)) || i<=m_p ),
530 "Cannot achieve continuity less than C^{-1} at interior knots.");
531 // TODO check: max interior mult + i <= m_p+1
532 m_knots.increaseMultiplicity(i);
533 }
534
536 bool isPeriodic() const
537 {
538 return (m_periodic > 0);
539 }
540
541 // Look at gsBasis class for a description
542 index_t functionAtCorner(boxCorner const & c) const;
543
546 {
547 return m_periodic;
548 }
549
551 bool isClamped() const
552 {
553 if( m_knots[0] != m_knots[m_p])
554 return false;
555
556 else if( m_knots[m_knots.size() - m_p -1] != m_knots[m_knots.size()-1])
557 return false;
558
559 else
560 return true;
561 }
562
565 void setPeriodic(bool flag = true)
566 {
567 if ( flag )
568 _convertToPeriodic();
569 else
570 m_periodic = 0;
571 }
572
573 // Compatible with tensor B-spline basis
574 void setPeriodic(int dir)
575 {
576 GISMO_UNUSED(dir);
577 GISMO_ASSERT(dir==0, "Invalid direction");
578 _convertToPeriodic();
579 }
580
584 int borderKnotMult() const;
585
586 typename gsBasis<T>::domainIter makeDomainIterator() const
587 {
588 return typename gsBasis<T>::domainIter(new gsTensorDomainIterator<T,1>(*this));
589 }
590
591 typename gsBasis<T>::domainIter makeDomainIterator(const boxSide & s) const
592 {
593 return ( s == boundary::none ?
594 typename gsBasis<T>::domainIter(new gsTensorDomainIterator<T,1>(*this)) :
595 typename gsBasis<T>::domainIter(new gsTensorDomainBoundaryIterator<T,1>(*this, s))
596 );
597 }
598
600 void enforceOuterKnotsPeriodic();
601
602 // Look at gsBasis class for a description
603 void reverse() { m_knots.reverse(); }
604
607
608
609 void matchWith(const boundaryInterface & bi,
610 const gsBasis<T> & other,
611 gsMatrix<index_t> & bndThis,
612 gsMatrix<index_t> & bndOther) const;
613
614protected:
615
617 void _convertToPeriodic();
618
620 void _stretchEndKnots();
621
622public:
623
631 gsMatrix<T> perCoefs( const gsMatrix<T>& coefs ) const
632 {
633 gsMatrix<T> per_coefs = coefs;
634 per_coefs.bottomRows( m_periodic ) = coefs.topRows( m_periodic );
635 return per_coefs;
636 }
637
638 gsMatrix<T> perCoefs(const gsMatrix<T>& coefs, int dir) const
639 {
640 GISMO_UNUSED(dir);
641 GISMO_ASSERT(dir==0, "Error");
642 return perCoefs(coefs);
643 }
644
647 void expandCoefs(gsMatrix<T> & coefs) const
648 {
649 const index_t sz = coefs.rows();
650 coefs.conservativeResize(sz+m_periodic, gsEigen::NoChange);
651 coefs.bottomRows( m_periodic ) = coefs.topRows( m_periodic );
652 }
653
656 void trimCoefs(gsMatrix<T> & coefs) const
657 {
658 const index_t sz = coefs.rows();
659 coefs.conservativeResize(sz-m_periodic, gsEigen::NoChange);
660 }
661
664 int trueSize() const
665 { return this->size() + m_periodic; }
666
667// Data members
668protected:
669
672
674 KnotVectorType m_knots;
675
678
679 /*/// @brief Multiplicity of the p+1st knot from the beginning and from the end.
680 int m_bordKnotMulti;*/
681
682}; // class gsTensorBSplineBasis<1>
683
684
685//Using C++11 alias:
686// template<class T, class KnotVectorType>
687// using gsBSplineBasis = gsTensorBSplineBasis<1,T>
688
698template<class T>
700{
701public:
702 typedef memory::shared_ptr< gsBSplineBasis > Ptr;
703 typedef memory::unique_ptr< gsBSplineBasis > uPtr;
704
705 typedef gsKnotVector<T> KnotVectorType;
707 typedef gsBSplineBasis<T> Self_t;
708
711
714
715public:
716
717 // Default empty constructor
718 explicit gsBSplineBasis(const bool periodic = false )
719 {
720 m_p = 0;
721 m_knots.initClamped(0);
722 m_periodic = 0;
723
724 if( periodic )
725 this->_convertToPeriodic();
726
727 if( ! this->check() )
728 gsWarn << "Warning: Inconsistent "<< *this<< "\n";
729 }
730
732 explicit gsBSplineBasis(KnotVectorType KV, const bool periodic = false)
733 {
734 m_p = KV.degree();
735 m_knots.swap(KV);
736 m_periodic = 0;
737
738 if( periodic )
739 this->_convertToPeriodic();
740
741 if( ! this->check() )
742 gsWarn << "Warning: Insconsistent "<< *this<< "\n";
743 }
744
747 explicit gsBSplineBasis(std::vector<KnotVectorType> KV)
748 {
749 GISMO_ASSERT(1 == KV.size(), "Expecting a single knotvector." );
750
751 m_p = KV.front().degree();
752 m_knots.swap(KV.front());
753 m_periodic = 0;
754 }
755
763 gsBSplineBasis(const T u0, const T u1, const unsigned interior,
764 const int degree, const unsigned mult_interior=1,
765 const bool periodic = false )
766 {
767 m_p = degree;
768 m_knots.initUniform(u0, u1, interior, m_p+1, mult_interior, m_p);
769 m_periodic = 0;
770
771 if( periodic )
772 this->_convertToPeriodic();
773
774 if( ! this->check() )
775 gsWarn << "Warning: Insconsistent "<< *this<< "\n";
776 }
777
778 using gsBasis<T>::create; //unhide from gsBasis
779
780 static typename gsBasis<T>::uPtr create(KnotVectorType KV, short_t dim)
781 {
782 typedef typename gsBasis<T>::uPtr basisPtr;
783
784 switch (dim)
785 {
786 case 1:
787 return basisPtr(new gsBSplineBasis<T>(give(KV)));
788 break;
789 case 2:
790 return basisPtr(new gsTensorBSplineBasis<2,T>(KV,KV));
791 break;
792 case 3:
793 return basisPtr(new gsTensorBSplineBasis<3,T>(KV,KV,KV));
794 break;
795 case 4:
796 return basisPtr(new gsTensorBSplineBasis<4,T>(KV,KV,KV,KV));
797 break;
798 }
799 GISMO_ERROR("Dimension should be between 1 and 4.");
800 }
801
802 static typename gsBasis<T>::uPtr create(std::vector<KnotVectorType> cKV);
803
804/*
806 gsBSplineBasis( const gsBSplineBasis & o)
807 : Base(o)
808 { }
809*/
810
811 // Look at gsBasis class for a description
812 GISMO_CLONE_FUNCTION(gsBSplineBasis)
813
814 // Look at gsBasis class for a description
815 Self_t & component(short_t i);
816
817 // Look at gsBasis class for a description
818 const Self_t & component(short_t i) const;
819
820 memory::unique_ptr<gsGeometry<T> > makeGeometry( gsMatrix<T> coefs ) const;
821
822private:
823
824 using Base::m_p;
825 using Base::m_knots;
826 using Base::m_periodic;
827};
828
829#ifdef GISMO_WITH_PYBIND11
830
834 void pybind11_init_gsBSplineBasis(pybind11::module &m);
835
836#endif // GISMO_WITH_PYBIND11
837
838} // namespace gismo
839
840
841// *****************************************************************
842#ifndef GISMO_BUILD_LIB
843#include GISMO_HPP_HEADER(gsBSplineBasis.hpp)
844#else
845#ifdef gsBSplineBasis_EXPORT
846#include GISMO_HPP_HEADER(gsBSplineBasis.hpp) // needed on thebrain?
847#undef EXTERN_CLASS_TEMPLATE
848#define EXTERN_CLASS_TEMPLATE CLASS_TEMPLATE_INST
849#endif
850namespace gismo
851{
852template<class T> const short_t gsTensorBSplineBasis<1,T>::Dim; //-O3 (SLE11) fix
853EXTERN_CLASS_TEMPLATE gsTensorBSplineBasis<1,real_t>;
854EXTERN_CLASS_TEMPLATE gsBSplineBasis<real_t>;
855}
856#endif
857// *****************************************************************
Struct which represents a certain side of a box.
Definition gsBoundary.h:85
A univariate B-spline basis.
Definition gsBSplineBasis.h:700
gsBSplineBasis(KnotVectorType KV, const bool periodic=false)
Construct BSpline basis of a knot vector.
Definition gsBSplineBasis.h:732
gsBSplineBasis(std::vector< KnotVectorType > KV)
Compatibility constructor with input an std::vector containing a single knotvector.
Definition gsBSplineBasis.h:747
gsBSplineTraits< 0, T >::Basis BoundaryBasisType
Associated Boundary basis type.
Definition gsBSplineBasis.h:713
KnotVectorType m_knots
Knot vector.
Definition gsBSplineBasis.h:674
memory::unique_ptr< gsGeometry< T > > makeGeometry(gsMatrix< T > coefs) const
Create a gsGeometry of proper type for this basis with the given coefficient matrix.
Definition gsBSplineBasis.hpp:857
short_t m_p
Degree.
Definition gsBSplineBasis.h:671
gsBSplineBasis(const T u0, const T u1, const unsigned interior, const int degree, const unsigned mult_interior=1, const bool periodic=false)
Construct a BSpline basis.
Definition gsBSplineBasis.h:763
gsBSplineTraits< 1, T >::Geometry GeometryType
Associated geometry type.
Definition gsBSplineBasis.h:710
Self_t & component(short_t i)
For a tensor product basis, return the 1-d basis for the i-th parameter component.
Definition gsBSplineBasis.hpp:1225
int m_periodic
Denotes whether the basis is periodic, ( 0 – non-periodic, >0 – number of ``crossing" functions)
Definition gsBSplineBasis.h:677
A B-spline function of one argument, with arbitrary target dimension.
Definition gsBSpline.h:51
A basis represents a family of scalar basis functions defined over a common parameter domain.
Definition gsBasis.h:79
virtual gsMatrix< T > laplacian(const gsMatrix< T > &u) const
Compute the Laplacian of all nonzero basis functions at points u.
Definition gsBasis.hpp:183
virtual gsBasis::uPtr tensorize(const gsBasis &other) const
Return a tensor basis of this and other.
Definition gsBasis.hpp:537
virtual void evalFunc_into(const gsMatrix< T > &u, const gsMatrix< T > &coefs, gsMatrix< T > &result) const
Evaluate the function described by coefs at points u, i.e., evaluates a linear combination of coefs x...
Definition gsBasis.hpp:37
virtual void evalAllDersSingle_into(index_t i, const gsMatrix< T > &u, int n, std::vector< gsMatrix< T > > &result) const
Evaluate the basis function i and its derivatives up to order n at points u into result.
Definition gsBasis.hpp:494
virtual gsBasis::uPtr create() const
Create an empty basis of the derived type and return a pointer to it.
Definition gsBasis.hpp:532
memory::unique_ptr< gsBasis > uPtr
Unique pointer for gsBasis.
Definition gsBasis.h:89
gsVector< index_t > numActive(const gsMatrix< T > &u) const
Number of active basis functions at an arbitrary parameter value.
Definition gsBasis.h:151
virtual void evalDerSingle_into(index_t i, const gsMatrix< T > &u, int n, gsMatrix< T > &result) const
Evaluate the (partial) derivative(s) of order n the i-th basis function at points u into result.
Definition gsBasis.hpp:525
virtual std::string detail() const
Prints the object as a string with extended details.
Definition gsBasis.h:733
Class defining a dummy basis of constant functions. This is used for compatibility reasons.
Definition gsConstantBasis.h:35
Class representing a domain. i.e. a collection of elements (triangles, rectangles,...
Definition gsDomain.h:32
uPtr clone()
Clone methode. Produceds a deep copy inside a uPtr.
Class for representing a knot vector.
Definition gsKnotVector.h:80
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
T at(index_t i) const
Returns the i-th element of the vectorization of the matrix.
Definition gsMatrix.h:211
Class Representing a triangle mesh with 3D vertices.
Definition gsMesh.h:32
A univariate NURBS basis.
Definition gsNurbsBasis.h:40
A NURBS function of one argument, with arbitrary target dimension.
Definition gsNurbs.h:40
Sparse matrix class, based on gsEigen::SparseMatrix.
Definition gsSparseMatrix.h:139
A univariate B-spline basis.
Definition gsBSplineBasis.h:70
void refine_k(const TensorSelf_t &other, int const &i=1)
Increases the degree without adjusting the smoothness at inner knots, except from the knot values in ...
Definition gsBSplineBasis.h:459
void refineElements(std::vector< index_t > const &elements)
Refine elements defined by their tensor-index.
Definition gsBSplineBasis.h:400
void anchors_into(gsMatrix< T > &result) const
Returns the anchors (greville points) of the basis.
Definition gsBSplineBasis.h:204
short_t maxDegree() const
If the basis is of polynomial or piecewise polynomial type, then this function returns the maximum po...
Definition gsBSplineBasis.h:334
void uniformCoarsen(int numKnots=1)
Coarsen the basis uniformly by removing groups of numKnots consecutive knots, each knot removed mul t...
Definition gsBSplineBasis.h:414
void expandCoefs(gsMatrix< T > &coefs) const
Helper function for transforming periodic coefficients to full coefficients.
Definition gsBSplineBasis.h:647
void reduceContinuity(int const &i=1)
Reduces spline continuity at interior knots by i.
Definition gsBSplineBasis.h:527
void reverse()
Reverse the basis.
Definition gsBSplineBasis.h:603
TensorSelf_t & component(short_t i)=0
For a tensor product basis, return the 1-d basis for the i-th parameter component.
gsMatrix< T > perCoefs(const gsMatrix< T > &coefs) const
Helper function for evaluation with periodic basis.
Definition gsBSplineBasis.h:631
gsBSplineTraits< 0, T >::Basis BoundaryBasisType
Associated Boundary basis type.
Definition gsBSplineBasis.h:88
void elevateContinuity(int const &i=1)
Elevate spline continuity at interior knots by i.
Definition gsBSplineBasis.h:519
void removeKnot(T knot, int mult=1)
Removes the knot knot in the underlying knot vector.
Definition gsBSplineBasis.h:389
void elementSupport_into(const index_t i, gsMatrix< index_t, 1, 2 > &result) const
Returns span (element) indices of the beginning and end of the support of the i-th basis function.
Definition gsBSplineBasis.h:181
KnotVectorType m_knots
Knot vector.
Definition gsBSplineBasis.h:674
short_t m_p
Degree.
Definition gsBSplineBasis.h:671
void degreeDecrease(short_t const &i=1, short_t const dir=-1)
Lower the degree of the basis by the given amount, preserving knots multiplicity.
Definition gsBSplineBasis.h:511
gsBasis< T >::domainIter makeDomainIterator() const
Create a domain iterator for the computational mesh of this basis, that points to the first element o...
Definition gsBSplineBasis.h:586
short_t totalDegree() const
If the basis is of polynomial or piecewise polynomial type, then this function returns the total poly...
Definition gsBSplineBasis.h:340
bool inDomain(T const &pp) const
True iff the point pp is in the domain of the basis.
Definition gsBSplineBasis.h:346
const KnotVectorType & knots(int i=0) const
Returns the knot vector of the basis.
Definition gsBSplineBasis.h:371
index_t firstActive(T u) const
Returns the index of the first active (ie. non-zero) basis function at point u Takes into account non...
Definition gsBSplineBasis.h:360
void degreeReduce(short_t const &i=1, short_t const dir=-1)
Reduce the degree of the basis by the given amount, preserve smoothness.
Definition gsBSplineBasis.h:493
memory::unique_ptr< Self_t > uPtr
Smart pointer for gsTensorBSplineBasis.
Definition gsBSplineBasis.h:97
short_t degree(short_t i) const
Returns the degree of the basis wrt variable i.
Definition gsBSplineBasis.h:324
void degreeIncrease(short_t const &i=1, short_t const dir=-1)
Elevate the degree of the basis by the given amount, preserve knots multiplicity.
Definition gsBSplineBasis.h:503
T Scalar_t
Coefficient type.
Definition gsBSplineBasis.h:82
bool check() const
Check the BSplineBasis for consistency.
Definition gsBSplineBasis.h:283
index_t size() const
Returns the number of elements in the basis.
Definition gsBSplineBasis.h:165
BoundaryBasisType::uPtr boundaryBasis(boxSide const &s)
Gives back the boundary basis at boxSide s.
gsBSplineTraits< 1, T >::Geometry GeometryType
Associated geometry type.
Definition gsBSplineBasis.h:85
T _activeLength() const
Returns length of the ``active" part of the knot vector.
Definition gsBSplineBasis.h:356
bool isClamped() const
Checks, if both endknots have multiplicity m_p + 1.
Definition gsBSplineBasis.h:551
void matchWith(const boundaryInterface &, const gsBasis< T > &, gsMatrix< index_t > &, gsMatrix< index_t > &, index_t) const
Computes the indices of DoFs that match on the interface bi. The interface is assumed to be a common ...
Definition gsBSplineBasis.h:605
void insertKnot(T knot, int mult=1)
Inserts the knot knot in the underlying knot vector.
Definition gsBSplineBasis.h:385
void refine_p(short_t const &i=1)
p-refinement (essentially degree elevation)
Definition gsBSplineBasis.h:477
void _convertToPeriodic()
Tries to convert the basis into periodic.
Definition gsBSplineBasis.hpp:1136
void trimCoefs(gsMatrix< T > &coefs) const
Helper function for transforming full coefficients to periodic coefficients.
Definition gsBSplineBasis.h:656
T domainEnd() const
Returns the ending value of the domain of the basis.
Definition gsBSplineBasis.h:353
int trueSize() const
Returns the size of the basis ignoring the bureaucratic way of turning the basis into periodic.
Definition gsBSplineBasis.h:664
short_t domainDim() const
Dimension of the (source) domain.
Definition gsBSplineBasis.h:158
void anchor_into(index_t i, gsMatrix< T > &result) const
Returns the anchors (greville points) of the basis.
Definition gsBSplineBasis.h:210
const TensorSelf_t & component(short_t i) const =0
For a tensor product basis, return the (const) 1-d basis for the i-th parameter component.
memory::shared_ptr< Self_t > Ptr
Smart pointer for gsTensorBSplineBasis.
Definition gsBSplineBasis.h:94
void setPeriodic(bool flag=true)
If flag is true, tries to convert the basis to periodic (succeeds only if the knot vector is suitable...
Definition gsBSplineBasis.h:565
void degreeElevate(short_t const &i=1, short_t const dir=-1)
Elevate the degree of the basis and preserve the smoothness.
Definition gsBSplineBasis.h:485
int numCrossingFunctions() const
Returns number of functions crossing the boundary of the knot vector.
Definition gsBSplineBasis.h:545
void refine_h(short_t const &i=1)
Uniform h-refinement (placing i new knots inside each knot-span.
Definition gsBSplineBasis.h:481
gsDomain< T > * domain() const
Definition gsBSplineBasis.h:368
size_t numElements(boxSide const &s=0) const
The number of elements on side s.
Definition gsBSplineBasis.h:168
short_t minDegree() const
If the basis is of polynomial or piecewise polynomial type, then this function returns the minimum po...
Definition gsBSplineBasis.h:337
int m_periodic
Denotes whether the basis is periodic, ( 0 – non-periodic, >0 – number of ``crossing" functions)
Definition gsBSplineBasis.h:677
gsBasis< T >::domainIter makeDomainIterator(const boxSide &s) const
Create a boundary domain iterator for the computational mesh this basis, that points to the first ele...
Definition gsBSplineBasis.h:591
T domainStart() const
Returns the starting value of the domain of the basis.
Definition gsBSplineBasis.h:350
bool isPeriodic() const
Tells, whether the basis is periodic.
Definition gsBSplineBasis.h:536
unsigned order() const
Returns the order of the B-spline basis.
Definition gsBSplineBasis.h:343
A tensor product B-spline basis.
Definition gsTensorBSplineBasis.h:37
gsBSplineTraits< static_cast< short_t >(d-1), T >::Basis::uPtr boundaryBasis(boxSide const &s)
Returns the boundary basis for side s.
void setPeriodic(const int dir)
Converts.
Definition gsTensorBSplineBasis.h:446
gsTensorBSplineBasis()
Default constructor.
Definition gsTensorBSplineBasis.h:74
void insertKnots(const std::vector< std::vector< T > > &refineKnots)
Takes a vector of coordinate wise knot values and inserts these values to the basis.
Definition gsTensorBSplineBasis.h:313
void refine_withCoefs(gsMatrix< T > &coefs, const std::vector< std::vector< T > > &refineKnots)
Takes a vector of coordinate wise knot values and inserts these values to the basis.
Definition gsTensorBSplineBasis.hpp:83
gsMatrix< T > perCoefs(const gsMatrix< T > &originalCoefs, short_t dir) const
Sets the coefficients so that the resulting TensorBSpline is periodic in direction dir.
Definition gsTensorBSplineBasis.h:454
memory::unique_ptr< Self_t > uPtr
Smart pointer for gsTensorBSplineBasis.
Definition gsTensorBSplineBasis.h:69
void active_into(const gsMatrix< T > &u, gsMatrix< index_t > &result) const
Returns the indices of active basis functions at points u, as a list of indices, in result....
Definition gsTensorBSplineBasis.hpp:176
void refine_withTransfer(gsSparseMatrix< T, RowMajor > &transfer, const std::vector< std::vector< T > > &refineKnots)
Takes a vector of coordinate wise knot values and inserts these values to the basis.
Definition gsTensorBSplineBasis.hpp:66
gsTensorBasis< d, T > Base
Base type.
Definition gsTensorBSplineBasis.h:42
std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition gsTensorBSplineBasis.h:223
A tensor product of d B-spline functions, with arbitrary target dimension.
Definition gsTensorBSpline.h:45
Abstract base class for tensor product bases.
Definition gsTensorBasis.h:34
virtual void deriv2_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate the second derivatives of all active basis function at points u.
Definition gsTensorBasis.hpp:731
void uniformCoarsen_withTransfer(gsSparseMatrix< T, RowMajor > &transfer, int numKnots=1)
Coarsen the basis uniformly and produce a sparse matrix which maps coarse coefficient vectors to refi...
Definition gsTensorBasis.hpp:876
virtual void uniformRefine(int numKnots=1, int mul=1, short_t dir=-1)
Refine the basis uniformly by inserting numKnots new knots with multiplicity mul on each knot span.
Definition gsTensorBasis.h:315
void uniformRefine_withTransfer(gsSparseMatrix< T, RowMajor > &transfer, int numKnots=1, int mul=1)
Definition gsTensorBasis.hpp:861
gsMatrix< index_t > allBoundary() const
Definition gsTensorBasis.hpp:283
virtual 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 gsTensorBasis.hpp:410
virtual void connectivity(const gsMatrix< T > &nodes, gsMesh< T > &mesh) const
Definition gsTensorBasis.hpp:163
void uniformRefine_withCoefs(gsMatrix< T > &coefs, int numKnots=1, int mul=1, short_t const dir=-1)
Definition gsTensorBasis.hpp:824
short_t degree(short_t i) const
Returns the degree of the basis wrt variable i.
Definition gsTensorBasis.h:465
virtual void evalAllDers_into(const gsMatrix< T > &u, int n, std::vector< gsMatrix< T > > &result, bool sameElement=false) const
Evaluate the nonzero functions and their derivatives up to order n at points u into result.
Definition gsTensorBasis.hpp:634
virtual void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates nonzero basis functions at point u into result.
Definition gsTensorBasis.hpp:502
index_t size() const
Returns the number of elements in the basis.
Definition gsTensorBasis.h:108
static const short_t Dim
Dimension of the parameter domain.
Definition gsTensorBasis.h:49
gsMatrix< index_t > boundaryOffset(boxSide const &s, index_t offset) const
Definition gsTensorBasis.hpp:304
bool isActive(const index_t i, const gsVector< T > &u) const
Returns true if there the point u with non-zero value or derivatives when evaluated at the basis func...
Definition gsTensorBasis.hpp:239
virtual void deriv_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates the first partial derivatives of the nonzero basis function.
Definition gsTensorBasis.hpp:594
gsMatrix< T > support() const
Returns (a bounding box for) the domain of the whole basis.
Definition gsTensorBasis.hpp:390
virtual void degreeElevate(short_t const &i=1, short_t const dir=-1)
Elevate the degree of the basis by the given amount, preserve smoothness.
Definition gsTensorBasis.h:359
gsMatrix< T > elementInSupportOf(index_t j) const
Returns (the coordinates of) an element in the support of basis function j.
Definition gsTensorBasis.hpp:1066
virtual 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 gsTensorBasis.hpp:454
size_t elementIndex(const gsVector< T > &u) const
Returns an index for the element which contains point u.
Definition gsTensorBasis.h:141
virtual 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 gsTensorBasis.hpp:429
Re-implements gsDomainIterator for iteration over all elements of the boundary of a tensor product pa...
Definition gsTensorDomainBoundaryIterator.h:38
Re-implements gsDomainIterator for iteration over all elements of a tensor product parameter domain....
Definition gsTensorDomainIterator.h:36
A tensor product Non-Uniform Rational B-spline (NURBS) basis.
Definition gsTensorNurbsBasis.h:38
A tensor product Non-Uniform Rational B-spline function (NURBS) of parametric dimension d,...
Definition gsTensorNurbs.h:41
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
#define short_t
Definition gsConfig.h:35
#define index_t
Definition gsConfig.h:32
Provides declaration of a basis of constant functions, consisting of one constant function.
#define GISMO_NO_IMPLEMENTATION
Definition gsDebug.h:129
#define GISMO_ERROR(message)
Definition gsDebug.h:118
#define gsWarn
Definition gsDebug.h:50
#define GISMO_UNUSED(x)
Definition gsDebug.h:112
#define GISMO_ENSURE(cond, message)
Definition gsDebug.h:102
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
Provides forward declarations of types and structs.
Knot vector for B-splines.
Provides declaration of TensorBasis class.
Iterator over the boundary elements of a tensor-structured grid.
Iterator over the elements of a tensor-structured grid.
The G+Smo namespace, containing all definitions for the library.
S give(S &x)
Definition gsMemory.h:266
Struct which represents an interface between two patches.
Definition gsBoundary.h:650
Struct which represents a certain corner of a hyper-cube.
Definition gsBoundary.h:292
Traits for BSplineBasis in more dimensions.
Definition gsBSplineBasis.h:32