G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsRationalBasis.h
Go to the documentation of this file.
1 
14 #pragma once
15 
16 #include <gsCore/gsBasis.h>
17 #include <gsCore/gsBoundary.h>
18 
19 
20 namespace gismo
21 {
22 
46 template<class SrcT>
47 class gsRationalBasis : public gsBasis< typename SrcT::Scalar_t >
48 {
49 public:
50  typedef memory::shared_ptr< gsRationalBasis > Ptr;
51  typedef memory::unique_ptr< gsRationalBasis > uPtr;
52 
53  typedef typename SrcT::Scalar_t Scalar_t;
54  typedef Scalar_t T;
55 
56  // Obtain dimension from the source basis
57  static const int Dim = SrcT::Dim;
58 
59  static const bool IsRational = true;
60 
61  typedef gsBasis<T> Base;
62 
64  typedef SrcT SourceBasis;
65 
66 public:
67 
70 
73  : m_src(basis)
74  {
75  m_weights.setOnes(basis->size(), 1);
76  }
77 
79  gsRationalBasis(const SrcT & basis)
80  : m_src(basis.clone().release())
81  {
82  m_weights.setOnes(basis.size(), 1);
83  }
84 
87  : m_src (basis), m_weights(give(w))
88  {
89  GISMO_ASSERT(m_weights.rows() == m_src->size(),
90  "Invalid basis/weights ("<<m_weights.rows()<<"/"<<m_src->size());
91  }
92 
95  {
96  m_src= o.source().clone().release();
97  m_weights = o.weights() ;
98  }
99 
102  {
103  if ( this != &o )
104  {
105  delete m_src;
106  m_src = o.source().clone();
107  m_weights = o.weights() ;
108  }
109  return *this;
110  }
111 
112  // Destructor
113  ~gsRationalBasis()
114  {
115  delete m_src;
116  }
117 
119  bool check() const
120  {
121  return (
122  m_weights.size() == m_src->size()
123  );
124  }
125 
126  memory::unique_ptr<gsBasis<T> > makeNonRational() const
127  { return m_src->clone(); }
128 
129 public:
130 
131 // ***********************************************
132 // Virtual member functions overriding source basis
133 // ***********************************************
134 
135  short_t domainDim() const { return Dim; }
136 
137  index_t size() const { return m_src->size(); }
138 
139  int size(int const& k) const{ return m_src->size(k); }
140 
141  size_t numElements(boxSide const & s = 0) const { return m_src->numElements(s); }
142  //using Base::numElements; //unhide
143 
145  size_t elementIndex(const gsVector<T> & u ) const { return m_src->elementIndex(u); }
146 
147  void active_into(const gsMatrix<T> & u, gsMatrix<index_t>& result) const
148  { m_src->active_into(u, result); }
149 
150  virtual const gsBasis<T> & component(short_t i) const { return m_src->component(i); }
151  using Base::component;
152 
153  gsMatrix<index_t> allBoundary( ) const {return m_src->allBoundary(); }
154 
156  { return m_src->boundaryOffset(s,offset); }
157 
158  virtual index_t functionAtCorner(boxCorner const & c) const
159  { return m_src->functionAtCorner(c); }
160 
161  // Look at gsBasis class for a description
162  short_t degree(short_t i = 0) const {return m_src->degree(i); }
163 
164  // Look at gsBasis class for a description
165  short_t maxDegree() const {return m_src->maxDegree(); }
166 
167  // Look at gsBasis class for a description
168  short_t minDegree() const {return m_src->minDegree(); }
169 
170  // Look at gsBasis class for a description
171  short_t totalDegree() const {return m_src->totalDegree(); }
172 
173  void uniformRefine(int numKnots = 1, int mul=1, int dir=-1)
174  {
175  m_src->uniformRefine_withCoefs(m_weights, numKnots, mul, dir);
176  }
177 
178  void uniformRefine_withCoefs(gsMatrix<T>& coefs, int numKnots = 1, int mul=1, int dir=-1);
179 
180  void uniformRefine_withTransfer(gsSparseMatrix<T,RowMajor> & transfer, int numKnots = 1, int mul=1);
181 
188  void refineElements( std::vector<index_t> const & boxes)
189  {
190  // call the refineElements_withCoefs-function of the underlying
191  // basis, where the weights are used as coefficients
192  m_src->refineElements_withCoefs( m_weights, boxes );
193  }
194 
204  void refineElements_withCoefs(gsMatrix<T> & coefs,std::vector<index_t> const & boxes);
205 
206  void degreeElevate(short_t const& i = 1, short_t const dir = -1)
207  {
208  typename SourceBasis::GeometryType tmp(*m_src,give(m_weights));
209  tmp.degreeElevate(i,dir);
210  tmp.coefs().swap(m_weights);
211  std::swap(*m_src, tmp.basis() );
212  }
213 
214  // todo (HV): test!!
215  void degreeIncrease(short_t const& i = 1, short_t const dir = -1)
216  {
217  typename SourceBasis::GeometryType tmp(*m_src, give(m_weights));
218  tmp.degreeIncrease(i,dir);
219  tmp.coefs().swap(m_weights);
220  std::swap(*m_src, tmp.basis() );
221  }
222 
223  void degreeReduce(short_t const& i = 1, short_t const dir = -1)
224  {
225  typename SourceBasis::GeometryType tmp(*m_src, give(m_weights));
226  tmp.degreeReduce(i,dir);
227  tmp.coefs().swap(m_weights);
228  std::swap(*m_src, tmp.basis() );
229  }
230 
231  void degreeDecrease(short_t const& i = 1, short_t const dir = -1)
232  {
233  typename SourceBasis::GeometryType tmp(*m_src, give(m_weights));
234  tmp.degreeDecrease(i,dir);
235  tmp.coefs().swap(m_weights);
236  std::swap(*m_src, tmp.basis() );
237  }
238 
239  /* if ever be reused, change to actual and current GISMO_UPTR_FUNCTION stuff und uPtr
240  GISMO_UPTR_FUNCTION_DEF(gsBasis<T>, boundaryBasis, boxSide const &)
241  {
242  typename SrcT::BoundaryBasisType * bb = m_src->boundaryBasis(s);
243  gsMatrix<index_t> ind = m_src->boundary(s);
244  gsMatrix<T> ww( ind.size(),1);
245  for ( index_t i=0; i<ind.size(); ++i)
246  ww(i,0) = m_weights( (*ind)(i,0), 0);
247 
248  return new BoundaryBasisType(bb, give(ww));
249  return 0;
250  }
251  */
252 
253  gsDomain<T> * domain() const { return m_src->domain(); }
254 
255  void anchors_into(gsMatrix<T> & result) const
256  { return m_src->anchors_into(result); }
257 
258  void anchor_into(index_t i, gsMatrix<T> & result) const
259  { return m_src->anchor_into(i,result); }
260 
261  // Look at gsBasis class for documentation
262  void connectivity(const gsMatrix<T> & nodes, gsMesh<T> & mesh) const
263  { return m_src->connectivity(nodes, mesh); }
264 
265  gsMatrix<T> support() const {return m_src->support(); }
266 
267  gsMatrix<T> support(const index_t & i) const {return m_src->support(i); }
268 
269  void eval_into(const gsMatrix<T> & u, gsMatrix<T>& result) const;
270 
271  void evalSingle_into(index_t i, const gsMatrix<T> & u, gsMatrix<T>& result) const ;
272 
273  void evalFunc_into(const gsMatrix<T> & u, const gsMatrix<T> & coefs, gsMatrix<T>& result) const;
274 
275  //void evalAllDers_into(const gsMatrix<T> & u, int n,
276  // std::vector<gsMatrix<T> >& result, bool sameElement = false) const;
277 
278  void deriv_into(const gsMatrix<T> & u, gsMatrix<T>& result ) const ;
279 
280  void deriv2_into(const gsMatrix<T> & u, gsMatrix<T>& result ) const;
281 
283  const SrcT & source () const
284  { return *m_src; }
285 
286  SrcT & source ()
287  { return *m_src; }
288 
290  const gsMatrix<T> & weights() const { return m_weights; }
291 
293  gsMatrix<T> & weights() { return m_weights; }
294 
295 
297  virtual bool isRational() const { return true;}
298 
300  T & weight(int i) { return m_weights(i); }
301 
303  const T & weight(int i) const { return m_weights(i); }
304 
306  void setWeights(gsMatrix<T> const & w)
307  {
308  GISMO_ASSERT( w.cols() == 1, "Weights should be scalars" ) ;
309  m_weights = w;
310  }
311 
312  virtual void matchWith(const boundaryInterface & bi, const gsBasis<T> & other,
313  gsMatrix<index_t> & bndThis, gsMatrix<index_t> & bndOther,
314  index_t offset = 0) const
315  {
316  if ( const gsRationalBasis * _other = dynamic_cast<const gsRationalBasis*>(&other) )
317  m_src->matchWith(bi,*_other->m_src,bndThis,bndOther, offset);
318  else
319  m_src->matchWith(bi,other,bndThis,bndOther, offset);
320  }
321 
325  { return projectiveCoefs(coefs, m_weights); }
326 
330  {
331  GISMO_ASSERT(coefs.rows() == weights.rows(),
332  "Invalid basis/coefficients ("<<coefs.rows()<<"/"<<weights.rows());
333  const index_t n = coefs.cols();
334  gsMatrix<T> rvo(coefs.rows(), n + 1);
335  // switch from control points (n-dimensional) to
336  // "projective control points" ((n+1)-dimensional),
337  // where the last coordinate is the weight.
338  rvo.leftCols(n).noalias() = weights.asDiagonal() * coefs;
339  rvo.col(n) = weights;
340  return rvo;
341  }
342 
346  static void setFromProjectiveCoefs(const gsMatrix<T> & pr_coefs,
347  gsMatrix<T> & coefs, gsMatrix<T> & weights)
348  {
349  const index_t n = pr_coefs.cols() - 1;
350  weights = pr_coefs.col( n );
351  coefs = pr_coefs.leftCols(n).array().colwise() / weights.col(0).array();
352  // equiv: coefs = pr_coefs.leftCols(n).array() / weights.replicate(1,n).array();
353  }
354 
355 
356  typename gsBasis<T>::domainIter makeDomainIterator() const
357  {
358 // gsWarn<< "rational domain iterator with evaluate the source.\n";
359  return m_src->makeDomainIterator();
360  }
361 
362  typename gsBasis<T>::domainIter makeDomainIterator(const boxSide & s) const
363  {
364 // gsWarn<< "rational domain boundary iterator with evaluate the source.\n";
365  return m_src->makeDomainIterator(s);
366  }
367 
368 // Data members
369 protected:
370 
371  // Source basis
372  SrcT * m_src;
373 
374  // Weight vector of size: size() x 1
375  gsMatrix<T> m_weights;
376 
377 }; // class gsRationalBasis
378 
379 
380 template<class SrcT>
382 {
383  m_src->evalSingle_into(i, u, result);
384  result.array() *= m_weights.at(i);
385  gsMatrix<T> denom;
386  m_src->evalFunc_into(u, m_weights, denom);
387 
388  result.array() /= denom.array();
389 }
390 
391 
392 template<class SrcT>
394 {
395  m_src->eval_into(u, result);
396  const gsMatrix<index_t> act = m_src->active(u);
397 
398  gsMatrix<T> denom;
399  m_src->evalFunc_into(u, m_weights, denom);
400 
401  for ( index_t j=0; j< act.cols(); ++j)
402  {
403  result.col(j) /= denom(j);
404  for ( index_t i=0; i< act.rows(); ++i)
405  result(i,j) *= m_weights( act(i,j) ) ;
406  }
407 }
408 
409 
410 // For non-specialized version (e.g. tensor product)
411 template<class SrcT>
412 void gsRationalBasis<SrcT>::evalFunc_into(const gsMatrix<T> & u, const gsMatrix<T> & coefs, gsMatrix<T>& result) const
413 {
414  assert( coefs.rows() == m_weights.rows() ) ;
415 
416  // Compute projective coefficients
417  const gsMatrix<T> tmp = m_weights.asDiagonal() * coefs;
418 
419  gsMatrix<T> denom;
420 
421  // Evaluate the projective numerator and the denominator
422  m_src->evalFunc_into( u, tmp, result);
423  m_src->evalFunc_into( u, m_weights, denom);
424 
425  // Divide numerator by denominator
426  result.array().rowwise() /= denom.row(0).array();
427  // equivalent:
428  //for ( index_t j=0; j < u.cols(); j++ ) // for all points (columns of u)
429  // result.col(j) /= denom(0,j);
430 }
431 
432 
433 /* TODO
434 template<class SrcT>
435 void gsRationalBasis<SrcT>::evalAllDers_into(const gsMatrix<T> & u, int n,
436  std::vector<gsMatrix<T> >& result, bool sameElement = false) const
437 {
438  result.resize(n+1);
439 
440  std::vector<gsMatrix<T> > ev(n+1);
441 
442  m_src->evalAllDers_into(u, n, ev, sameElement);
443 
444  // find active basis functions
445  gsMatrix<index_t> act;
446  m_src->active_into(u,act);
447 
448  const int numAct = act.rows();
449 
450  // evaluate weights and their derivatives
451  gsMatrix<T> Wval, Wder;
452  m_src->evalFunc_into (u, m_weights, Wval);
453  m_src->derivFunc_into(u, m_weights, Wder);
454 
455  for (index_t i = 0; i < u.cols(); ++i)// for all parametric points
456  {
457  const T & Wval_i = Wval(0,i);
458  // compute derivatives first since they depend on the function
459  // values of the source basis
460  der.col(i) *= Wval_i;
461 
462  for (index_t k = 0; k < numAct; ++k)
463  {
464  der.template block<Dim,1>(k*Dim,i).noalias() -=
465  ev(k,i) * Wder.col(i);
466 
467  der.template block<Dim,1>(k*Dim,i) *=
468  m_weights( act(k,i), 0 ) / (Wval_i*Wval_i);
469  }
470 
471  // compute function values
472  ev.col(i) /= Wval_i;
473 
474  for (index_t k = 0; k < numAct; ++k)
475  ev(k,i) *= m_weights( act(k,i), 0 ) ;
476  }
477 }
478 */
479 
480 template<class SrcT>
482  gsMatrix<T>& result) const
483 {
484  // Formula:
485  // R_i' = (w_i N_i / W)' = w_i ( N_i'W - N_i W' ) / W^2
486 
487  gsMatrix<index_t> act;
488  m_src->active_into(u,act);
489 
490  result.resize( act.rows()*Dim, u.cols() );
491 
492  std::vector<gsMatrix<T> > ev(2);
493  m_src->evalAllDers_into(u, 1, ev);
494 
495  T W;
496  gsMatrix<T> dW(Dim,1);
497 
498  for ( index_t i = 0; i!= result.cols(); ++i )// for all parametric points
499  {
500  // Start weight function computation
501  W = 0.0;
502  dW.setZero();
503  for ( index_t k = 0; k != act.rows(); ++k ) // for all basis functions
504  {
505  const T curw = m_weights.at(act(k,i));
506  W += curw * ev[0](k,i);
507  dW += curw * ev[1].template block<Dim,1>(k*Dim,i);
508  }
509  // End weight function computation
510 
511  result.col(i) = W * ev[1].col(i); // N_i'W
512 
513  for ( index_t k = 0; k != act.rows() ; ++k) // for all basis functions
514  {
515  const index_t kd = k * Dim;
516 
517  result.template block<Dim,1>(kd,i).noalias() -=
518  ev[0](k,i) * dW; // - N_i W'
519 
520  result.template block<Dim,1>(kd,i) *= m_weights.at( act(k,i) ) / (W * W);
521  }
522  }
523 }
524 
525 template<class SrcT>
527 {
528  // Formula:
529  // ( W^2 / w_k) * R_k'' = ( N_k'' W - N_k W'' ) - 2 N_k' W' + 2 N_k (W')^2 / W
530  // ( W^2 / w_k) * d_ud_vR_k = ( d_ud_vN_k W - N_k d_ud_vW )
531  // - d_uN_k d_vW - d_vN_k d_uW + 2 N_k d_uW d_vW / W
532 
533  static const int str = Dim * (Dim+1) / 2;
534 
535  gsMatrix<index_t> act;
536  m_src->active_into(u,act);
537 
538  result.resize( act.rows()*str, u.cols() );
539 
540  T W;
541  gsMatrix<T> dW(Dim,1), ddW(str,1);
542  std::vector<gsMatrix<T> > ev(3);
543  m_src->evalAllDers_into(u, 2, ev);
544 
545  for ( index_t i = 0; i!= u.cols(); ++i ) // for all points
546  {
547  // Start weight function computation
548  W = 0.0;
549  dW .setZero();
550  ddW.setZero();
551  for ( index_t k = 0; k != act.rows(); ++k ) // for all basis functions
552  {
553  //to do with lweights (local weights)
554  const T curw = m_weights.at(act(k,i));
555  W += curw * ev[0](k,i);
556  dW += curw * ev[1].template block<Dim,1>(k*Dim,i);
557  ddW += curw * ev[2].template block<str,1>(k*str,i);
558  }
559  // End weight function computation
560 
561  result.col(i) = W * ev[2].col(i); // N_k'' W
562 
563  for ( index_t k=0; k != act.rows() ; ++k ) // for all basis functions
564  {
565  const index_t kstr = k * str;
566  const index_t kd = k * Dim;
567 
568  result.template block<str,1>(kstr,i) -=
569  ev[0](k,i) * ddW; // - N_k * W''
570 
571  result.template block<Dim,1>(kstr,i) +=
572  // - 2 N_k' W' + 2 N_k (W')^2 / W
573  ( (T)(2) * ev[0](k,i) / W ) * dW.cwiseProduct(dW)
574  - (T)(2) * ev[1].template block<Dim,1>(kd,i).cwiseProduct(dW);
575 
576  int m = Dim;
577  for ( int _u=0; _u != Dim; ++_u ) // for all mixed derivatives
578  for ( int _v=_u+1; _v != Dim; ++_v )
579  {
580  result(kstr + m++, i) +=
581  - ev[1](kd+_u,i) * dW.at(_v) // - du N_k * dv W
582  - ev[1](kd+_v,i) * dW.at(_u) // - dv N_k * du W
583  // + (T)(2) * N_k * du W * dv W / W
584  + (T)(2) * ev[0](k,i) * dW.at(_u) * dW.at(_v) / W;
585  }
586 
587  result.template block<str,1>(kstr,i) *=
588  m_weights.at( act(k,i) ) / (W*W); // * (w_k / W^2)
589  }
590  }
591 }
592 
593 
594 template<class SrcT>
595 void gsRationalBasis<SrcT>::uniformRefine_withCoefs(gsMatrix<T>& coefs, int numKnots, int mul, int dir)
596 {
597  GISMO_ASSERT( coefs.rows() == this->size() && m_weights.rows() == this->size(),
598  "Invalid dimensions" );
600  GISMO_ENSURE(-1==dir, "!!");
601  m_src->uniformRefine_withTransfer(transfer, numKnots, mul);
602 
603  coefs = transfer * ( m_weights.asDiagonal() * coefs);
604  m_weights = transfer * m_weights;
605  // Alternative way
606  // gsBasis<T> * tmp = m_src->clone();
607  // tmp->uniformRefine_withCoefs(coefs, numKnots);
608  // delete tmp;
609  // m_src->uniformRefine_withCoefs(m_weights, numKnots);
610 
611  // back to affine coefs
612  coefs.array().colwise() /= m_weights.col(0).array();
613  // equiv:
614  // for (int i = 0; i < coefs.rows(); ++i)
615  // coefs.row(i) /= m_weights.at(i);
616 }
617 
618 template<class SrcT>
620 {
621  // 1. Get source transfer matrix (while refining m_src)
622  m_src->uniformRefine_withTransfer(transfer, numKnots, mul);
623 
624  // 2. Compute rational basis transfer matrix
625  // To be applied on affine coefficients, as usual.
626  // Transfer matrix for rational bases. Formula:
627  //
628  // ( (T*m_weights)'*I )^{-1} * T*W
629  //
630  // Where ' denotes transpose, W is a diagonal matrix with
631  // diagonal=m_weights, I is the identity and T the source
632  // transfer matrix.
633  // i.e. apply weight transform ( to compute weighted coefs),
634  // apply T, return to affine by the inverse weight transform
635  // (T*W)'*I )^{-1}.
636  // In Eigen this could be something like
637  // (transfer * m_weights).asDiagonal().inverse() * transfer * m_weights.asDiagonal() ;
638  // but that has troubles with the sparse/diagonal expressions etc.
639  // So we do it by using a temporary.
640 
641  const gsVector<T> tmp = m_weights ;
642  m_weights.noalias() = transfer * tmp; // Refine the weights as well
643 
644  transfer = m_weights.cwiseInverse().asDiagonal() * transfer * tmp.asDiagonal();
645 }
646 
647 
648 template<class SrcT>
650  std::vector<index_t> const & boxes)
651 {
652  // switch from control points (n-dimensional) to
653  // "projective control points" ((n+1)-dimensional),
654  // where the last coordinate is the weight.
655  gsMatrix<T> rw = projectiveCoefs(coefs, m_weights);
656 
657  // refine with these projective control points as coefficients.
658  m_src->refineElements_withCoefs( rw, boxes );
659 
660  // Regain the new n-dimensional control points and the new
661  // weights.
662  setFromProjectiveCoefs(rw, coefs, m_weights);
663 }
664 
665 
666 } // namespace gismo
Class representing a domain. i.e. a collection of elements (triangles, rectangles, cubes, simplices.
Definition: gsDomain.h:31
const T & weight(int i) const
Const access to i-th weight.
Definition: gsRationalBasis.h:303
void refineElements(std::vector< index_t > const &boxes)
Refines specified areas or boxes, depending on underlying basis.
Definition: gsRationalBasis.h:188
void uniformRefine_withTransfer(gsSparseMatrix< T, RowMajor > &transfer, int numKnots=1, int mul=1)
Refine the basis uniformly.
Definition: gsRationalBasis.h:619
std::vector< T * > release(std::vector< unique_ptr< T > > &cont)
Takes a vector of smart pointers, releases them and returns the corresponding raw pointers...
Definition: gsMemory.h:228
size_t numElements(boxSide const &s=0) const
The number of elements on side s.
Definition: gsRationalBasis.h:141
SrcT & source()
Definition: gsRationalBasis.h:286
gsMatrix< index_t > allBoundary() const
Returns the indices of the basis functions that are nonzero at the domain boundary.
Definition: gsRationalBasis.h:153
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: gsRationalBasis.h:173
void refineElements_withCoefs(gsMatrix< T > &coefs, std::vector< index_t > const &boxes)
Refines specified areas or boxes, depending on underlying basis.
Definition: gsRationalBasis.h:649
index_t size() const
size
Definition: gsRationalBasis.h:137
T & weight(int i)
Access to i-th weight.
Definition: gsRationalBasis.h:300
gsMatrix< T > support() const
Returns (a bounding box for) the domain of the whole basis.
Definition: gsRationalBasis.h:265
#define short_t
Definition: gsConfig.h:35
Class that creates a rational counterpart for a given basis.
Definition: gsRationalBasis.h:47
Provides structs and classes related to interfaces and boundaries.
virtual const gsBasis< T > & component(short_t i) const
For a tensor product basis, return the (const) 1-d basis for the i-th parameter component.
Definition: gsRationalBasis.h:150
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: gsRationalBasis.h:223
void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates nonzero basis functions at point u into result.
Definition: gsRationalBasis.h:393
gsRationalBasis(SrcT *basis)
Construct a rational counterpart of basis.
Definition: gsRationalBasis.h:72
Provides declaration of Basis abstract interface.
S give(S &x)
Definition: gsMemory.h:266
void anchor_into(index_t i, gsMatrix< T > &result) const
Returns the anchor point for member i of the basis.
Definition: gsRationalBasis.h:258
#define index_t
Definition: gsConfig.h:32
#define GISMO_ENSURE(cond, message)
Definition: gsDebug.h:102
virtual const gsBasis< T > & component(short_t i) const
For a tensor product basis, return the (const) 1-d basis for the i-th parameter component.
Definition: gsBasis.hpp:514
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: gsRationalBasis.h:147
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: gsRationalBasis.h:215
gsBasis< T >::domainIter makeDomainIterator() const
Create a domain iterator for the computational mesh of this basis, that points to the first element o...
Definition: gsRationalBasis.h:356
gsMatrix< T > projectiveCoefs(const gsMatrix< T > &coefs) const
Definition: gsRationalBasis.h:324
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
short_t degree(short_t i=0) const
Degree with respect to the i-th variable. If the basis is a tensor product of (piecewise) polynomial ...
Definition: gsRationalBasis.h:162
SrcT SourceBasis
Associated source basis type.
Definition: gsRationalBasis.h:64
short_t maxDegree() const
If the basis is of polynomial or piecewise polynomial type, then this function returns the maximum po...
Definition: gsRationalBasis.h:165
memory::shared_ptr< gsFunctionSet > Ptr
Shared pointer for gsFunctionSet.
Definition: gsFunctionSet.h:223
bool check() const
Check the rational basis for consistency.
Definition: gsRationalBasis.h:119
void anchors_into(gsMatrix< T > &result) const
Returns the anchor points that represent the members of the basis in result. There is exactly one anc...
Definition: gsRationalBasis.h:255
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
gsRationalBasis(const SrcT &basis)
Construct a rational counterpart of basis.
Definition: gsRationalBasis.h:79
void deriv2_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate the second derivatives of all active basis function at points u.
Definition: gsRationalBasis.h:526
memory::unique_ptr< gsFunctionSet > uPtr
Unique pointer for gsFunctionSet.
Definition: gsFunctionSet.h:226
gsRationalBasis(SrcT *basis, gsMatrix< T > w)
Construct a rational counterpart of basis.
Definition: gsRationalBasis.h:86
size_t elementIndex(const gsVector< T > &u) const
See gsBasis for a description.
Definition: gsRationalBasis.h:145
const gsBasis< T > & basis(const index_t k) const
Helper which casts and returns the k-th piece of this function set as a gsBasis.
Definition: gsFunctionSet.hpp:33
gsDomain< T > * domain() const
Definition: gsRationalBasis.h:253
short_t domainDim() const
Dimension of the (source) domain.
Definition: gsRationalBasis.h:135
short_t minDegree() const
If the basis is of polynomial or piecewise polynomial type, then this function returns the minimum po...
Definition: gsRationalBasis.h:168
Interface for the set of functions defined on a domain (the total number of functions in the set equa...
Definition: gsFuncData.h:23
Struct which represents a certain side of a box.
Definition: gsBoundary.h:84
const SrcT & source() const
Returns the source basis of the rational basis.
Definition: gsRationalBasis.h:283
uPtr clone()
Clone methode. Produceds a deep copy inside a uPtr.
const gsMatrix< T > & weights() const
Returns the weights of the rational basis.
Definition: gsRationalBasis.h:290
void connectivity(const gsMatrix< T > &nodes, gsMesh< T > &mesh) const
Definition: gsRationalBasis.h:262
short_t totalDegree() const
If the basis is of polynomial or piecewise polynomial type, then this function returns the total poly...
Definition: gsRationalBasis.h:171
void deriv_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates the first partial derivatives of the nonzero basis function.
Definition: gsRationalBasis.h:481
memory::unique_ptr< gsBasis< T > > makeNonRational() const
Definition: gsRationalBasis.h:126
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: gsRationalBasis.h:412
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: gsRationalBasis.h:231
virtual void matchWith(const boundaryInterface &bi, const gsBasis< T > &other, gsMatrix< index_t > &bndThis, gsMatrix< index_t > &bndOther, index_t offset=0) const
Computes the indices of DoFs that match on the interface bi. The interface is assumed to be a common ...
Definition: gsRationalBasis.h:312
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: gsRationalBasis.h:362
gsRationalBasis(const gsRationalBasis &o)
Copy Constructor.
Definition: gsRationalBasis.h:94
void setWeights(gsMatrix< T > const &w)
Set weights.
Definition: gsRationalBasis.h:306
static void setFromProjectiveCoefs(const gsMatrix< T > &pr_coefs, gsMatrix< T > &coefs, gsMatrix< T > &weights)
Definition: gsRationalBasis.h:346
Struct which represents an interface between two patches.
Definition: gsBoundary.h:649
virtual bool isRational() const
Returns true, since by definition a gsRationalBasis is rational.
Definition: gsRationalBasis.h:297
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: gsRationalBasis.h:206
void uniformRefine_withCoefs(gsMatrix< T > &coefs, int numKnots=1, int mul=1, int dir=-1)
Refine the basis uniformly.
Definition: gsRationalBasis.h:595
gsMatrix< T > & weights()
Returns the weights of the rational basis.
Definition: gsRationalBasis.h:293
gsRationalBasis()
Default empty constructor.
Definition: gsRationalBasis.h:69
gsMatrix< T > support(const index_t &i) const
Returns (a bounding box for) the support of the i-th basis function.
Definition: gsRationalBasis.h:267
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: gsRationalBasis.h:381
gsRationalBasis & operator=(const gsRationalBasis &o)
Assignment operator.
Definition: gsRationalBasis.h:101
Struct which represents a certain corner of a hyper-cube.
Definition: gsBoundary.h:291
gsMatrix< index_t > boundaryOffset(boxSide const &s, index_t offset) const
Definition: gsRationalBasis.h:155
static gsMatrix< T > projectiveCoefs(const gsMatrix< T > &coefs, const gsMatrix< T > &weights)
Definition: gsRationalBasis.h:329
A basis represents a family of scalar basis functions defined over a common parameter domain...
Definition: gsBasis.h:78