G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsBSplineBasis.h
Go to the documentation of this file.
1 
15 #pragma once
16 
18 #include <gsCore/gsConstantBasis.h>
19 
20 #include <gsTensor/gsTensorBasis.h>
23 
24 #include <gsNurbs/gsKnotVector.h>
25 
26 namespace gismo
27 {
28 
30 template<short_t d, class T>
32 {
33  typedef gsKnotVector<T> KnotVectorType;
34 
39 };
40 template<class T>
41 struct 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 };
49 template<class T>
50 struct 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 
68 template<class T>
69 class gsTensorBSplineBasis<1,T> : public gsTensorBasis<1,T>
70 {
71 public:
72  typedef gsKnotVector<T> KnotVectorType;
73 
74  typedef gsTensorBasis<1,T> Base;
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 
99 public:
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 
146 public:
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 
181  void elementSupport_into(const index_t i, gsMatrix<index_t,1,2>& result) const
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
201  TensorSelf_t & component(short_t i) = 0;
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
227  gsMatrix<index_t> allBoundary( ) const ;
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__
233  typename BoundaryBasisType::uPtr boundaryBasis(boxSide const & s);
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
318  virtual void evalAllDersSingle_into(index_t i, const gsMatrix<T> & u,
319  int n, gsMatrix<T>& result) const;
320 
321  // Look at gsBasis class for a description
323  {
324  GISMO_UNUSED(i);
325  GISMO_ASSERT(i==0,"Asked for degree(i) in 1D basis.");
326  return m_p;
327  }
328 
329  short_t degree() const {return m_p;}
330 
331  // Look at gsBasis class for a description
332  short_t maxDegree() const { return m_p; }
333 
334  // Look at gsBasis class for a description
335  short_t minDegree() const { return m_p; }
336 
337  // Look at gsBasis class for a description
338  short_t totalDegree() const { return m_p; }
339 
341  inline unsigned order() const { return m_p+1; }
342 
344  inline bool inDomain(T const & pp) const
345  { return ( (pp >= *(m_knots.begin()+m_p)) && (pp <= *(m_knots.end()-m_p-1) ) ); }
346 
348  T domainStart() const { return *(m_knots.begin()+m_p); }
349 
351  T domainEnd() const { return *(m_knots.end()-m_p-1); }
352 
354  T _activeLength() const { return domainEnd() - domainStart(); }
355 
358  inline index_t firstActive(T u) const {
359  return ( inDomain(u) ? (m_knots.iFind(u)-m_knots.begin()) - m_p : 0 );
360  }
361 
362  // Number of active functions at any point of the domain
363  inline index_t numActive() const { return m_p + 1; }
364 
365  // Look at gsBasis class for a description
366  gsDomain<T> * domain() const { return const_cast<KnotVectorType *>(&m_knots); }
367 
369  const KnotVectorType & knots (int i = 0) const
370  {
371  GISMO_ENSURE(i==0, "Invalid knots requested");
372  return m_knots;
373  }
374  KnotVectorType & knots (int i = 0)
375  {
376  GISMO_ENSURE(i==0, "Invalid knots requested");
377  return m_knots;
378  }
379 
380  T knot(index_t const & i) const { return m_knots[i];}
381 
383  void insertKnot(T knot, int mult=1)
384  { m_knots.insert( knot, mult); }
385 
387  void removeKnot(T knot, int mult=1)
388  { m_knots.remove( knot, mult); }
389 
390  // compatibility with tensor-bsplines
391  void insertKnots(const std::vector< std::vector<T> >& refineKnots)
392  {
393  GISMO_ASSERT( refineKnots.size() == 1, "refineKnots vector has wrong size" );
394  this->knots().insert(refineKnots.front());
395  }
396 
397  // Look at gsBasis class for a description
398  void refineElements(std::vector<index_t> const & elements)
399  { m_knots.refineSpans(elements); }
400 
401  // Look at gsBasis class for a description
402  void uniformRefine(int numKnots = 1, int mul=1, int dir=-1)
403  { GISMO_UNUSED(dir); m_knots.uniformRefine(numKnots,mul); }
404 
405  // Look at gsBasis class for a description
406  void uniformRefine_withCoefs(gsMatrix<T>& coefs, int numKnots = 1, int mul=1, int dir=-1);
407 
408  // Look at gsBasis class for a description
409  void uniformRefine_withTransfer(gsSparseMatrix<T,RowMajor> & transfer, int numKnots = 1, int mul=1);
410 
411  // Look at gsBasis class for a description
412  void uniformCoarsen(int numKnots = 1)
413  { m_knots.coarsen(numKnots); }
414 
415  // Look at gsBasis class for a description
416  void uniformCoarsen_withTransfer(gsSparseMatrix<T,RowMajor> & transfer, int numKnots = 1);
417 
420  void refine_withCoefs(gsMatrix<T>& coefs, const std::vector<T>& knots);
421 
422  // compatibility with tensor-bsplines
423  void refine_withCoefs(gsMatrix<T> & coefs,
424  const std::vector< std::vector<T> >& refineKnots)
425  {
426  refine_withCoefs(coefs,refineKnots.front() );
427  }
428 
430  void refine_withTransfer(gsSparseMatrix<T,RowMajor> & transfer, const std::vector<T>& knots);
431 
432  void refine_withTransfer(gsSparseMatrix<T,RowMajor> & transfer,
433  const std::vector<std::vector<T> >& knots)
434  {
435  GISMO_ASSERT(knots.size()==1, "the knots you want to insert do not have the right dimension");
436  refine_withTransfer(transfer,knots.front());
437  //GISMO_NO_IMPLEMENTATION
438  }
439 
454  void refine_k(const TensorSelf_t & other, int const & i = 1)
455  {
456  GISMO_ASSERT( m_p >= other.m_p, "Degree of other knot-vector should be lower.");
457  //for (typename std::vector<T>::iterator it =
458  // m_knots.begin(); it != m_knots.end(); ++it)
459  // GISMO_ASSERT( has(*it), "Knot "<< *it<<" is not in the knot vector.");
460 
461  // grab unique knots
462  const std::vector<T> knots = other.m_knots.unique();
463 
464  // Increase the degree without adjusting any knot
465  m_p += i;
466  m_knots.set_degree(m_p);
467  // Adjust (reduce) smoothness to satisfy initial constraint knots
468  m_knots.insert(knots,i);
469  }
470 
472  void refine_p(short_t const & i = 1)
473  { degreeElevate(i); }
474 
476  void refine_h(short_t const & i = 1)
477  { uniformRefine(i); }
478 
480  void degreeElevate(short_t const & i = 1, short_t const dir = -1)
481  {
482  GISMO_UNUSED(dir);
483  GISMO_ASSERT( dir == -1 || dir == 0, "Invalid direction");
484  m_p+=i; m_knots.degreeElevate(i);
485  }
486 
487  // Look at gsBasis for documentation
488  void degreeReduce (short_t const & i = 1, short_t const dir = -1)
489  {
490  GISMO_UNUSED(dir);
491  GISMO_ASSERT( dir == -1 || dir == 0, "Invalid direction");
492  GISMO_ASSERT( i<=m_p, "Cannot reduce degree to negative");
493  m_p-=i; m_knots.degreeReduce(i);
494  //m_periodic =
495  }
496 
497  // Look at gsBasis for documentation
498  void degreeIncrease(short_t const & i = 1, short_t const dir = -1)
499  {
500  GISMO_UNUSED(dir);
501  GISMO_ASSERT( dir == -1 || dir == 0, "Invalid direction");
502  m_p+=i; m_knots.degreeIncrease(i);
503  }
504 
505  // Look at gsBasis for documentation
506  void degreeDecrease(short_t const & i = 1, short_t const dir = -1)
507  {
508  GISMO_UNUSED(dir);
509  GISMO_ASSERT( dir == -1 || dir == 0, "Invalid direction");
510  m_p-=i; m_knots.degreeDecrease(i);
511  }
512 
514  void elevateContinuity(int const & i = 1)
515  {
516  GISMO_ASSERT( i>=0 && ( m_knots.size()>static_cast<size_t>(2*(m_p+1)) || i<=m_p ),
517  "Cannot achieve continuity less than C^{-1} at interior knots.");
518  m_knots.reduceMultiplicity(i);
519  }
520 
522  void reduceContinuity(int const & i = 1)
523  {
524  GISMO_ASSERT( i>=0 && ( m_knots.size()>static_cast<size_t>(2*(m_p+1)) || i<=m_p ),
525  "Cannot achieve continuity less than C^{-1} at interior knots.");
526  // TODO check: max interior mult + i <= m_p+1
527  m_knots.increaseMultiplicity(i);
528  }
529 
531  bool isPeriodic() const
532  {
533  return (m_periodic > 0);
534  }
535 
536  // Look at gsBasis class for a description
537  index_t functionAtCorner(boxCorner const & c) const;
538 
540  int numCrossingFunctions () const
541  {
542  return m_periodic;
543  }
544 
546  bool isClamped() const
547  {
548  if( m_knots[0] != m_knots[m_p])
549  return false;
550 
551  else if( m_knots[m_knots.size() - m_p -1] != m_knots[m_knots.size()-1])
552  return false;
553 
554  else
555  return true;
556  }
557 
560  void setPeriodic(bool flag = true)
561  {
562  if ( flag )
563  _convertToPeriodic();
564  else
565  m_periodic = 0;
566  }
567 
568  // Compatible with tensor B-spline basis
569  void setPeriodic(int dir)
570  {
571  GISMO_UNUSED(dir);
572  GISMO_ASSERT(dir==0, "Invalid direction");
573  _convertToPeriodic();
574  }
575 
579  int borderKnotMult() const;
580 
581  typename gsBasis<T>::domainIter makeDomainIterator() const
582  {
583  return typename gsBasis<T>::domainIter(new gsTensorDomainIterator<T,1>(*this));
584  }
585 
586  typename gsBasis<T>::domainIter makeDomainIterator(const boxSide & s) const
587  {
588  return ( s == boundary::none ?
589  typename gsBasis<T>::domainIter(new gsTensorDomainIterator<T,1>(*this)) :
590  typename gsBasis<T>::domainIter(new gsTensorDomainBoundaryIterator<T,1>(*this, s))
591  );
592  }
593 
595  void enforceOuterKnotsPeriodic();
596 
597  // Look at gsBasis class for a description
598  void reverse() { m_knots.reverse(); }
599 
600  void matchWith(const boundaryInterface &, const gsBasis<T> &,
602 
603 
604  void matchWith(const boundaryInterface & bi,
605  const gsBasis<T> & other,
606  gsMatrix<index_t> & bndThis,
607  gsMatrix<index_t> & bndOther) const;
608 
609 protected:
610 
612  void _convertToPeriodic();
613 
615  void _stretchEndKnots();
616 
617 public:
618 
626  gsMatrix<T> perCoefs( const gsMatrix<T>& coefs ) const
627  {
628  gsMatrix<T> per_coefs = coefs;
629  per_coefs.bottomRows( m_periodic ) = coefs.topRows( m_periodic );
630  return per_coefs;
631  }
632 
633  gsMatrix<T> perCoefs(const gsMatrix<T>& coefs, int dir) const
634  {
635  GISMO_UNUSED(dir);
636  GISMO_ASSERT(dir==0, "Error");
637  return perCoefs(coefs);
638  }
639 
642  void expandCoefs(gsMatrix<T> & coefs) const
643  {
644  const index_t sz = coefs.rows();
645  coefs.conservativeResize(sz+m_periodic, gsEigen::NoChange);
646  coefs.bottomRows( m_periodic ) = coefs.topRows( m_periodic );
647  }
648 
651  void trimCoefs(gsMatrix<T> & coefs) const
652  {
653  const index_t sz = coefs.rows();
654  coefs.conservativeResize(sz-m_periodic, gsEigen::NoChange);
655  }
656 
659  int trueSize() const
660  { return this->size() + m_periodic; }
661 
662 // Data members
663 protected:
664 
667 
669  KnotVectorType m_knots;
670 
673 
674  /*/// @brief Multiplicity of the p+1st knot from the beginning and from the end.
675  int m_bordKnotMulti;*/
676 
677 }; // class gsTensorBSplineBasis<1>
678 
679 
680 //Using C++11 alias:
681 // template<class T, class KnotVectorType>
682 // using gsBSplineBasis = gsTensorBSplineBasis<1,T>
683 
693 template<class T>
695 {
696 public:
697  typedef memory::shared_ptr< gsBSplineBasis > Ptr;
698  typedef memory::unique_ptr< gsBSplineBasis > uPtr;
699 
700  typedef gsKnotVector<T> KnotVectorType;
702  typedef gsBSplineBasis<T> Self_t;
703 
706 
709 
710 public:
711 
712  // Default empty constructor
713  explicit gsBSplineBasis(const bool periodic = false )
714  {
715  m_p = 0;
716  m_knots.initClamped(0);
717  m_periodic = 0;
718 
719  if( periodic )
720  this->_convertToPeriodic();
721 
722  if( ! this->check() )
723  gsWarn << "Warning: Inconsistent "<< *this<< "\n";
724  }
725 
727  explicit gsBSplineBasis(KnotVectorType KV, const bool periodic = false)
728  {
729  m_p = KV.degree();
730  m_knots.swap(KV);
731  m_periodic = 0;
732 
733  if( periodic )
734  this->_convertToPeriodic();
735 
736  if( ! this->check() )
737  gsWarn << "Warning: Insconsistent "<< *this<< "\n";
738  }
739 
742  explicit gsBSplineBasis(std::vector<KnotVectorType> KV)
743  {
744  GISMO_ASSERT(1 == KV.size(), "Expecting a single knotvector." );
745 
746  m_p = KV.front().degree();
747  m_knots.swap(KV.front());
748  m_periodic = 0;
749  }
750 
758  gsBSplineBasis(const T u0, const T u1, const unsigned interior,
759  const int degree, const unsigned mult_interior=1,
760  const bool periodic = false )
761  {
762  m_p = degree;
763  m_knots.initUniform(u0, u1, interior, m_p+1, mult_interior, m_p);
764  m_periodic = 0;
765 
766  if( periodic )
767  this->_convertToPeriodic();
768 
769  if( ! this->check() )
770  gsWarn << "Warning: Insconsistent "<< *this<< "\n";
771  }
772 
773 /*
775  gsBSplineBasis( const gsBSplineBasis & o)
776  : Base(o)
777  { }
778 */
779 
780  // Look at gsBasis class for a description
781  GISMO_CLONE_FUNCTION(gsBSplineBasis)
782 
783  // Look at gsBasis class for a description
784  Self_t & component(short_t i);
785 
786  // Look at gsBasis class for a description
787  const Self_t & component(short_t i) const;
788 
789  memory::unique_ptr<gsGeometry<T> > makeGeometry( gsMatrix<T> coefs ) const;
790 
791 private:
792 
793  using Base::m_p;
794  using Base::m_knots;
795  using Base::m_periodic;
796 };
797 
798 #ifdef GISMO_WITH_PYBIND11
799 
803  void pybind11_init_gsBSplineBasis(pybind11::module &m);
804 
805 #endif // GISMO_WITH_PYBIND11
806 
807 } // namespace gismo
808 
809 
810 // *****************************************************************
811 #ifndef GISMO_BUILD_LIB
812 #include GISMO_HPP_HEADER(gsBSplineBasis.hpp)
813 #else
814 #ifdef gsBSplineBasis_EXPORT
815 #include GISMO_HPP_HEADER(gsBSplineBasis.hpp) // needed on thebrain?
816 #undef EXTERN_CLASS_TEMPLATE
817 #define EXTERN_CLASS_TEMPLATE CLASS_TEMPLATE_INST
818 #endif
819 namespace gismo
820 {
821 template<class T> const short_t gsTensorBSplineBasis<1,T>::Dim; //-O3 (SLE11) fix
822 EXTERN_CLASS_TEMPLATE gsTensorBSplineBasis<1,real_t>;
823 EXTERN_CLASS_TEMPLATE gsBSplineBasis<real_t>;
824 }
825 #endif
826 // *****************************************************************
index_t size() const
size
Definition: gsBSplineBasis.h:165
Class representing a domain. i.e. a collection of elements (triangles, rectangles, cubes, simplices.
Definition: gsDomain.h:31
void _convertToPeriodic()
Tries to convert the basis into periodic.
Definition: gsBSplineBasis.hpp:1136
Re-implements gsDomainIterator for iteration over all elements of a tensor product parameter domain...
Definition: gsTensorDomainIterator.h:35
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:498
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:488
Iterator over the elements of a tensor-structured grid.
short_t degree(short_t i) const
Returns the degree of the basis wrt variable i.
Definition: gsTensorBasis.h:465
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
void anchors_into(gsMatrix< T > &result) const
Returns the anchors (greville points) of the basis.
Definition: gsBSplineBasis.h:204
Knot vector for B-splines.
Abstract base class representing a geometry map.
Definition: gsGeometry.h:92
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:480
bool inDomain(T const &pp) const
True iff the point pp is in the domain of the basis.
Definition: gsBSplineBasis.h:344
short_t totalDegree() const
If the basis is of polynomial or piecewise polynomial type, then this function returns the total poly...
Definition: gsBSplineBasis.h:338
Class defining a dummy basis of constant functions. This is used for compatibility reasons...
Definition: gsConstantBasis.h:34
virtual void evalAllDersSingle_into(index_t i, const gsMatrix< T > &u, int n, gsMatrix< T > &result) const
Evaluate the basis function i and its derivatives up to order n at points u into result.
Definition: gsBasis.hpp:471
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:358
A NURBS function of one argument, with arbitrary target dimension.
Definition: gsNurbs.h:39
KnotVectorType m_knots
Knot vector.
Definition: gsBSplineBasis.h:669
Traits for BSplineBasis in more dimensions.
Definition: gsBSplineBasis.h:31
index_t size() const
Returns the number of elements in the basis.
Definition: gsTensorBasis.h:108
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:166
gsBSplineTraits< 0, T >::Basis BoundaryBasisType
Associated Boundary basis type.
Definition: gsBSplineBasis.h:708
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
void refine_p(short_t const &i=1)
p-refinement (essentially degree elevation)
Definition: gsBSplineBasis.h:472
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
size_t numElements(boxSide const &s=0) const
The number of elements on side s.
Definition: gsBSplineBasis.h:168
gsVector< index_t > numActive(const gsMatrix< T > &u) const
Number of active basis functions at an arbitrary parameter value.
Definition: gsBasis.h:151
#define short_t
Definition: gsConfig.h:35
A tensor product of d B-spline functions, with arbitrary target dimension.
Definition: gsTensorBSpline.h:44
gsBSplineBasis(KnotVectorType KV, const bool periodic=false)
Construct BSpline basis of a knot vector.
Definition: gsBSplineBasis.h:727
T _activeLength() const
Returns length of the ``active" part of the knot vector.
Definition: gsBSplineBasis.h:354
short_t degree(short_t i) const
Degree with respect to the i-th variable. If the basis is a tensor product of (piecewise) polynomial ...
Definition: gsBSplineBasis.h:322
short_t m_p
Degree.
Definition: gsBSplineBasis.h:666
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:476
A tensor product Non-Uniform Rational B-spline function (NURBS) of parametric dimension d...
Definition: gsTensorNurbs.h:40
void expandCoefs(gsMatrix< T > &coefs) const
Helper function for transforming periodic coefficients to full coefficients.
Definition: gsBSplineBasis.h:642
gsBSplineBasis(std::vector< KnotVectorType > KV)
Compatibility constructor with input an std::vector containing a single knotvector.
Definition: gsBSplineBasis.h:742
virtual void connectivity(const gsMatrix< T > &nodes, gsMesh< T > &mesh) const
Definition: gsTensorBasis.hpp:163
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
bool check() const
Check the BSplineBasis for consistency.
Definition: gsBSplineBasis.h:283
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:560
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
#define index_t
Definition: gsConfig.h:32
size_t elementIndex(const gsVector< T > &u) const
Returns an index for the element which contains point u.
Definition: gsTensorBasis.h:141
#define GISMO_ENSURE(cond, message)
Definition: gsDebug.h:102
gsTensorBSplineBasis()
Default constructor.
Definition: gsTensorBSplineBasis.h:74
virtual void uniformRefine(int numKnots=1, int mul=1, int dir=-1)
Refine the basis uniformly by inserting numKnots new knots with multiplicity mul on each knot span...
Definition: gsTensorBasis.h:315
void reverse()
Reverse the basis.
Definition: gsBSplineBasis.h:598
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:581
std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition: gsTensorBSplineBasis.h:223
Provides declaration of a basis of constant functions, consisting of one constant function...
A tensor product B-spline basis.
Definition: gsTensorBSplineBasis.h:36
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
memory::shared_ptr< Self_t > Ptr
Smart pointer for gsTensorBSplineBasis.
Definition: gsBSplineBasis.h:94
A B-spline function of one argument, with arbitrary target dimension.
Definition: gsBSpline.h:50
void refineElements(std::vector< index_t > const &elements)
Refinement function, with different sytax for different basis.
Definition: gsBSplineBasis.h:398
A univariate B-spline basis.
Definition: gsBSplineBasis.h:694
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 eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates nonzero basis functions at point u into result.
Definition: gsTensorBasis.hpp:502
Class Representing a triangle mesh with 3D vertices.
Definition: gsMesh.h:31
T at(index_t i) const
Returns the i-th element of the vectorization of the matrix.
Definition: gsMatrix.h:211
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
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
void refine_h(short_t const &i=1)
Uniform h-refinement (placing i new knots inside each knot-span.
Definition: gsBSplineBasis.h:476
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:758
void setPeriodic(const int dir)
Converts.
Definition: gsTensorBSplineBasis.h:439
#define gsWarn
Definition: gsDebug.h:50
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
const KnotVectorType & knots(int i=0) const
Returns the knot vector of the basis.
Definition: gsBSplineBasis.h:369
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:306
bool isClamped() const
Checks, if both endknots have multiplicity m_p + 1.
Definition: gsBSplineBasis.h:546
memory::shared_ptr< gsBasis > Ptr
Shared pointer for gsBasis.
Definition: gsBasis.h:86
Re-implements gsDomainIterator for iteration over all elements of the boundary of a tensor product pa...
Definition: gsTensorDomainBoundaryIterator.h:37
gsMatrix< T > perCoefs(const gsMatrix< T > &coefs) const
Helper function for evaluation with periodic basis.
Definition: gsBSplineBasis.h:626
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
void elevateContinuity(int const &i=1)
Elevate spline continuity at interior knots by i.
Definition: gsBSplineBasis.h:514
static const short_t Dim
Dimension of the parameter domain.
Definition: gsBSplineBasis.h:91
Interface for the set of functions defined on a domain (the total number of functions in the set equa...
Definition: gsFuncData.h:23
gsBSplineTraits< 0, T >::Basis BoundaryBasisType
Associated Boundary basis type.
Definition: gsBSplineBasis.h:88
Provides forward declarations of types and structs.
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:454
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
T Scalar_t
Coefficient type.
Definition: gsBSplineBasis.h:82
Abstract base class for tensor product bases.
Definition: gsTensorBasis.h:33
Struct which represents a certain side of a box.
Definition: gsBoundary.h:84
int m_periodic
Denotes whether the basis is periodic, ( 0 – non-periodic, &gt;0 – number of ``crossing" functions) ...
Definition: gsBSplineBasis.h:672
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
int numCrossingFunctions() const
Returns number of functions crossing the boundary of the knot vector.
Definition: gsBSplineBasis.h:540
gsMatrix< T > support() const
Returns (a bounding box for) the domain of the whole basis.
Definition: gsTensorBasis.hpp:390
A tensor product Non-Uniform Rational B-spline (NURBS) basis.
Definition: gsTensorNurbsBasis.h:38
gsBSplineTraits< 1, T >::Geometry GeometryType
Associated geometry type.
Definition: gsBSplineBasis.h:705
short_t maxDegree() const
If the basis is of polynomial or piecewise polynomial type, then this function returns the maximum po...
Definition: gsBSplineBasis.h:332
uPtr clone()
Clone methode. Produceds a deep copy inside a uPtr.
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
void insertKnot(T knot, int mult=1)
Inserts the knot knot in the underlying knot vector.
Definition: gsBSplineBasis.h:383
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:447
gsTensorBasis< d, T > Base
Base type.
Definition: gsTensorBSplineBasis.h:42
memory::unique_ptr< gsBasis > uPtr
Unique pointer for gsBasis.
Definition: gsBasis.h:89
virtual gsBasis::uPtr tensorize(const gsBasis &other) const
Return a tensor basis of this and other.
Definition: gsBasis.hpp:488
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
T domainStart() const
Returns the starting value of the domain of the basis.
Definition: gsBSplineBasis.h:348
A univariate NURBS basis.
Definition: gsNurbsBasis.h:39
memory::unique_ptr< Self_t > uPtr
Smart pointer for gsTensorBSplineBasis.
Definition: gsTensorBSplineBasis.h:69
void trimCoefs(gsMatrix< T > &coefs) const
Helper function for transforming full coefficients to periodic coefficients.
Definition: gsBSplineBasis.h:651
A univariate B-spline basis.
Definition: gsBSplineBasis.h:69
static const short_t Dim
Dimension of the parameter domain.
Definition: gsTensorBasis.h:49
void anchor_into(index_t i, gsMatrix< T > &result) const
Returns the anchors (greville points) of the basis.
Definition: gsBSplineBasis.h:210
short_t domainDim() const
Dimension of the (source) domain.
Definition: gsBSplineBasis.h:158
gsDomain< T > * domain() const
Definition: gsBSplineBasis.h:366
unsigned order() const
Returns the order of the B-spline basis.
Definition: gsBSplineBasis.h:341
short_t minDegree() const
If the basis is of polynomial or piecewise polynomial type, then this function returns the minimum po...
Definition: gsBSplineBasis.h:335
gsMatrix< index_t > boundaryOffset(boxSide const &s, index_t offset) const
Definition: gsTensorBasis.hpp:304
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
#define GISMO_UNUSED(x)
Definition: gsDebug.h:112
virtual std::string detail() const
Prints the object as a string with extended details.
Definition: gsBasis.h:727
gsMatrix< index_t > allBoundary() const
Definition: gsTensorBasis.hpp:283
Class for representing a knot vector.
Definition: gsKnotVector.h:79
Iterator over the boundary elements of a tensor-structured grid.
void uniformRefine(int numKnots=1, int mul=1, int dir=-1)
Refine the basis uniformly by inserting numKnots new knots with multiplicity mul on each knot span...
Definition: gsBSplineBasis.h:402
void uniformRefine_withCoefs(gsMatrix< T > &coefs, int numKnots=1, int mul=1, int dir=-1)
Definition: gsTensorBasis.hpp:824
Struct which represents an interface between two patches.
Definition: gsBoundary.h:649
void uniformRefine_withTransfer(gsSparseMatrix< T, RowMajor > &transfer, int numKnots=1, int mul=1)
Definition: gsTensorBasis.hpp:861
void uniformCoarsen(int numKnots=1)
Coarsen the basis uniformly by removing groups of numKnots consecutive knots, each knot removed mul t...
Definition: gsBSplineBasis.h:412
bool isPeriodic() const
Tells, whether the basis is periodic.
Definition: gsBSplineBasis.h:531
int trueSize() const
Returns the size of the basis ignoring the bureaucratic way of turning the basis into periodic...
Definition: gsBSplineBasis.h:659
void removeKnot(T knot, int mult=1)
Removes the knot knot in the underlying knot vector.
Definition: gsBSplineBasis.h:387
Provides declaration of TensorBasis class.
memory::unique_ptr< Self_t > uPtr
Smart pointer for gsTensorBSplineBasis.
Definition: gsBSplineBasis.h:97
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
gsBSplineTraits< static_cast< short_t >d-1), T >::Basis::uPtr boundaryBasis(boxSide const &s)
Returns the boundary basis for side s.
const Basis_t & component(short_t dir) const
For a tensor product basis, return the (const) 1-d basis for the i-th parameter component.
Definition: gsTensorBSplineBasis.h:202
Struct which represents a certain corner of a hyper-cube.
Definition: gsBoundary.h:291
T domainEnd() const
Returns the ending value of the domain of the basis.
Definition: gsBSplineBasis.h:351
virtual gsMatrix< T > laplacian(const gsMatrix< T > &u) const
Compute the Laplacian of all nonzero basis functions at points u.
Definition: gsBasis.hpp:184
A basis represents a family of scalar basis functions defined over a common parameter domain...
Definition: gsBasis.h:78
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:586
gsBSplineTraits< 1, T >::Geometry GeometryType
Associated geometry type.
Definition: gsBSplineBasis.h:85
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:506
void reduceContinuity(int const &i=1)
Reduces spline continuity at interior knots by i.
Definition: gsBSplineBasis.h:522
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:600