G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
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
20namespace gismo
21{
22
46template<class SrcT>
47class gsRationalBasis : public gsBasis< typename SrcT::Scalar_t >
48{
49public:
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
66public:
67
69 gsRationalBasis() : Base(), m_src(nullptr) { }
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().release();
107 m_weights = o.weights() ;
108 }
109 return *this;
110 }
111
112 // Destructor
113 virtual ~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
129public:
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 index_t size(index_t 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
148 gsMatrix<T> elementInSupportOf(index_t j) const { return m_src->elementInSupportOf(j); }
149
150 void active_into(const gsMatrix<T> & u, gsMatrix<index_t>& result) const
151 { m_src->active_into(u, result); }
152
153 virtual const gsBasis<T> & component(short_t i) const { return m_src->component(i); }
154 using Base::component;
155
156 gsMatrix<index_t> allBoundary( ) const {return m_src->allBoundary(); }
157
159 { return m_src->boundaryOffset(s,offset); }
160
161 virtual index_t functionAtCorner(boxCorner const & c) const
162 { return m_src->functionAtCorner(c); }
163
164 // Look at gsBasis class for a description
165 short_t degree(short_t i = 0) const {return m_src->degree(i); }
166
167 // Look at gsBasis class for a description
168 short_t maxDegree() const {return m_src->maxDegree(); }
169
170 // Look at gsBasis class for a description
171 short_t minDegree() const {return m_src->minDegree(); }
172
173 // Look at gsBasis class for a description
174 short_t totalDegree() const {return m_src->totalDegree(); }
175
176 void uniformRefine(int numKnots = 1, int mul = 1, short_t dir = -1)
177 {
178 m_src->uniformRefine_withCoefs(m_weights, numKnots, mul, dir);
179 }
180
181 void uniformRefine_withCoefs(gsMatrix<T>& coefs, int numKnots = 1, int mul = 1, short_t const dir = -1);
182
183 void uniformRefine_withTransfer(gsSparseMatrix<T,RowMajor> & transfer, int numKnots = 1, int mul = 1);
184
186 void refine(gsMatrix<T> const & boxes, int refExt = 0)
187 {
188 GISMO_UNUSED(refExt);
189 m_src->refine_withCoefs( m_weights, boxes );
190 }
191
198 void refineElements( std::vector<index_t> const & boxes)
199 {
200 // call the refineElements_withCoefs-function of the underlying
201 // basis, where the weights are used as coefficients
202 m_src->refineElements_withCoefs( m_weights, boxes );
203 }
204
205
215 void refineElements_withCoefs(gsMatrix<T> & coefs,std::vector<index_t> const & boxes);
216
217 void degreeElevate(short_t const& i = 1, short_t const dir = -1)
218 {
219 memory::unique_ptr<gsGeometry<T> > tmp = m_src->makeGeometry(give(m_weights));
220 tmp->degreeElevate(i,dir);
221 tmp->coefs().swap(m_weights);
222 delete m_src;
223 m_src = static_cast<SrcT*>(tmp->basis().clone().release());
224 }
225
226 void degreeIncrease(short_t const& i = 1, short_t const dir = -1)
227 {
228 memory::unique_ptr<gsGeometry<T> > tmp = m_src->makeGeometry(give(m_weights));
229 tmp->degreeIncrease(i,dir);
230 tmp->coefs().swap(m_weights);
231 delete m_src;
232 m_src = static_cast<SrcT*>(tmp->basis().clone().release());
233 }
234
235 void degreeReduce(short_t const& i = 1, short_t const dir = -1)
236 {
237 memory::unique_ptr<gsGeometry<T> > tmp = m_src->makeGeometry(give(m_weights));
238 tmp->degreeReduce(i,dir);
239 tmp->coefs().swap(m_weights);
240 delete m_src;
241 m_src = static_cast<SrcT*>(tmp->basis().clone().release());
242 }
243
244 void degreeDecrease(short_t const& i = 1, short_t const dir = -1)
245 {
246 memory::unique_ptr<gsGeometry<T> > tmp = m_src->makeGeometry(give(m_weights));
247 tmp->degreeDecrease(i,dir);
248 tmp->coefs().swap(m_weights);
249 }
250
251 /*
252 GISMO_UPTR_FUNCTION_DEF(gsBasis<T>, boundaryBasis, boxSide const &)
253 {
254 typename SrcT::BoundaryBasisType * bb = m_src->boundaryBasis(s);
255 gsMatrix<index_t> ind = m_src->boundary(s);
256 gsMatrix<T> ww( ind.size(),1);
257 for ( index_t i=0; i<ind.size(); ++i)
258 ww(i,0) = m_weights( ind(i,0), 0);
259 return new BoundaryBasisType(bb.release(), give(ww));// note: constructor consumes the pointer
260 }
261 */
262
263 gsDomain<T> * domain() const { return m_src->domain(); }
264
265 void anchors_into(gsMatrix<T> & result) const
266 { return m_src->anchors_into(result); }
267
268 void anchor_into(index_t i, gsMatrix<T> & result) const
269 { return m_src->anchor_into(i,result); }
270
271 // Look at gsBasis class for documentation
272 void connectivity(const gsMatrix<T> & nodes, gsMesh<T> & mesh) const
273 { return m_src->connectivity(nodes, mesh); }
274
275 gsMatrix<T> support() const {return m_src->support(); }
276
277 gsMatrix<T> support(const index_t & i) const {return m_src->support(i); }
278
279 void eval_into(const gsMatrix<T> & u, gsMatrix<T>& result) const;
280
281 void evalSingle_into(index_t i, const gsMatrix<T> & u, gsMatrix<T>& result) const ;
282
283 void evalFunc_into(const gsMatrix<T> & u, const gsMatrix<T> & coefs, gsMatrix<T>& result) const;
284
285 //void evalAllDers_into(const gsMatrix<T> & u, int n,
286 // std::vector<gsMatrix<T> >& result, bool sameElement = false) const;
287
288 void deriv_into(const gsMatrix<T> & u, gsMatrix<T>& result ) const ;
289
290 void deriv2_into(const gsMatrix<T> & u, gsMatrix<T>& result ) const;
291
293 const SrcT & source () const
294 { return *m_src; }
295
296 SrcT & source ()
297 { return *m_src; }
298
300 const gsMatrix<T> & weights() const { return m_weights; }
301
303 gsMatrix<T> & weights() { return m_weights; }
304
305
307 virtual bool isRational() const { return true;}
308
310 T & weight(int i) { return m_weights(i); }
311
313 const T & weight(int i) const { return m_weights(i); }
314
316 void setWeights(gsMatrix<T> const & w)
317 {
318 GISMO_ASSERT( w.cols() == 1, "Weights should be scalars" ) ;
319 m_weights = w;
320 }
321
322 virtual void matchWith(const boundaryInterface & bi, const gsBasis<T> & other,
323 gsMatrix<index_t> & bndThis, gsMatrix<index_t> & bndOther,
324 index_t offset = 0) const
325 {
326 if ( const gsRationalBasis * _other = dynamic_cast<const gsRationalBasis*>(&other) )
327 m_src->matchWith(bi,*_other->m_src,bndThis,bndOther, offset);
328 else
329 m_src->matchWith(bi,other,bndThis,bndOther, offset);
330 }
331
335 { return projectiveCoefs(coefs, m_weights); }
336
340 {
341 GISMO_ASSERT(coefs.rows() == weights.rows(),
342 "Invalid basis/coefficients ("<<coefs.rows()<<"/"<<weights.rows());
343 const index_t n = coefs.cols();
344 gsMatrix<T> rvo(coefs.rows(), n + 1);
345 // switch from control points (n-dimensional) to
346 // "projective control points" ((n+1)-dimensional),
347 // where the last coordinate is the weight.
348 rvo.leftCols(n).noalias() = weights.asDiagonal() * coefs;
349 rvo.col(n) = weights;
350 return rvo;
351 }
352
356 static void setFromProjectiveCoefs(const gsMatrix<T> & pr_coefs,
358 {
359 const index_t n = pr_coefs.cols() - 1;
360 weights = pr_coefs.col( n );
361 coefs = pr_coefs.leftCols(n).array().colwise() / weights.col(0).array();
362 // equiv: coefs = pr_coefs.leftCols(n).array() / weights.replicate(1,n).array();
363 }
364
365
366 typename gsBasis<T>::domainIter makeDomainIterator() const
367 {
368// gsWarn<< "rational domain iterator with evaluate the source.\n";
369 return m_src->makeDomainIterator();
370 }
371
372 typename gsBasis<T>::domainIter makeDomainIterator(const boxSide & s) const
373 {
374// gsWarn<< "rational domain boundary iterator with evaluate the source.\n";
375 return m_src->makeDomainIterator(s);
376 }
377
378// Data members
379protected:
380
381 // Source basis
382 SrcT * m_src;
383
384 // Weight vector of size: size() x 1
385 gsMatrix<T> m_weights;
386
387}; // class gsRationalBasis
388
389
390template<class SrcT>
391void gsRationalBasis<SrcT>::evalSingle_into(index_t i, const gsMatrix<T> & u, gsMatrix<T>& result) const
392{
393 m_src->evalSingle_into(i, u, result);
394 result.array() *= m_weights.at(i);
395 gsMatrix<T> denom;
396 m_src->evalFunc_into(u, m_weights, denom);
397
398 result.array() /= denom.array();
399}
400
401
402template<class SrcT>
403void gsRationalBasis<SrcT>::eval_into(const gsMatrix<T> & u, gsMatrix<T>& result) const
404{
405 m_src->eval_into(u, result);
406 const gsMatrix<index_t> act = m_src->active(u);
407
408 gsMatrix<T> denom;
409 m_src->evalFunc_into(u, m_weights, denom);
410
411 for ( index_t j=0; j< act.cols(); ++j)
412 {
413 result.col(j) /= denom(j);
414 for ( index_t i=0; i< act.rows(); ++i)
415 result(i,j) *= m_weights( act(i,j) ) ;
416 }
417}
418
419
420// For non-specialized version (e.g. tensor product)
421template<class SrcT>
422void gsRationalBasis<SrcT>::evalFunc_into(const gsMatrix<T> & u, const gsMatrix<T> & coefs, gsMatrix<T>& result) const
423{
424 assert( coefs.rows() == m_weights.rows() ) ;
425
426 // Compute projective coefficients
427 const gsMatrix<T> tmp = m_weights.asDiagonal() * coefs;
428
429 gsMatrix<T> denom;
430
431 // Evaluate the projective numerator and the denominator
432 m_src->evalFunc_into( u, tmp, result);
433 m_src->evalFunc_into( u, m_weights, denom);
434
435 // Divide numerator by denominator
436 result.array().rowwise() /= denom.row(0).array();
437 // equivalent:
438 //for ( index_t j=0; j < u.cols(); j++ ) // for all points (columns of u)
439 // result.col(j) /= denom(0,j);
440}
441
442
443/* TODO
444template<class SrcT>
445void gsRationalBasis<SrcT>::evalAllDers_into(const gsMatrix<T> & u, int n,
446 std::vector<gsMatrix<T> >& result, bool sameElement = false) const
447{
448 result.resize(n+1);
449
450 std::vector<gsMatrix<T> > ev(n+1);
451
452 m_src->evalAllDers_into(u, n, ev, sameElement);
453
454 // find active basis functions
455 gsMatrix<index_t> act;
456 m_src->active_into(u,act);
457
458 const int numAct = act.rows();
459
460 // evaluate weights and their derivatives
461 gsMatrix<T> Wval, Wder;
462 m_src->evalFunc_into (u, m_weights, Wval);
463 m_src->derivFunc_into(u, m_weights, Wder);
464
465 for (index_t i = 0; i < u.cols(); ++i)// for all parametric points
466 {
467 const T & Wval_i = Wval(0,i);
468 // compute derivatives first since they depend on the function
469 // values of the source basis
470 der.col(i) *= Wval_i;
471
472 for (index_t k = 0; k < numAct; ++k)
473 {
474 der.template block<Dim,1>(k*Dim,i).noalias() -=
475 ev(k,i) * Wder.col(i);
476
477 der.template block<Dim,1>(k*Dim,i) *=
478 m_weights( act(k,i), 0 ) / (Wval_i*Wval_i);
479 }
480
481 // compute function values
482 ev.col(i) /= Wval_i;
483
484 for (index_t k = 0; k < numAct; ++k)
485 ev(k,i) *= m_weights( act(k,i), 0 ) ;
486 }
487}
488*/
489
490template<class SrcT>
491void gsRationalBasis<SrcT>::deriv_into(const gsMatrix<T> & u,
492 gsMatrix<T>& result) const
493{
494 // Formula:
495 // R_i' = (w_i N_i / W)' = w_i ( N_i'W - N_i W' ) / W^2
496
497 gsMatrix<index_t> act;
498 m_src->active_into(u,act);
499
500 result.resize( act.rows()*Dim, u.cols() );
501
502 std::vector<gsMatrix<T> > ev(2);
503 m_src->evalAllDers_into(u, 1, ev);
504
505 T W;
506 gsMatrix<T> dW(Dim,1);
507
508 for ( index_t i = 0; i!= result.cols(); ++i )// for all parametric points
509 {
510 // Start weight function computation
511 W = 0.0;
512 dW.setZero();
513 for ( index_t k = 0; k != act.rows(); ++k ) // for all basis functions
514 {
515 const T curw = m_weights.at(act(k,i));
516 W += curw * ev[0](k,i);
517 dW += curw * ev[1].template block<Dim,1>(k*Dim,i);
518 }
519 // End weight function computation
520
521 result.col(i) = W * ev[1].col(i); // N_i'W
522
523 for ( index_t k = 0; k != act.rows() ; ++k) // for all basis functions
524 {
525 const index_t kd = k * Dim;
526
527 result.template block<Dim,1>(kd,i).noalias() -=
528 ev[0](k,i) * dW; // - N_i W'
529
530 result.template block<Dim,1>(kd,i) *= m_weights.at( act(k,i) ) / (W * W);
531 }
532 }
533}
534
535template<class SrcT>
536void gsRationalBasis<SrcT>::deriv2_into(const gsMatrix<T> & u, gsMatrix<T>& result ) const
537{
538 // Formula:
539 // ( W^2 / w_k) * R_k'' = ( N_k'' W - N_k W'' ) - 2 N_k' W' + 2 N_k (W')^2 / W
540 // ( W^2 / w_k) * d_ud_vR_k = ( d_ud_vN_k W - N_k d_ud_vW )
541 // - d_uN_k d_vW - d_vN_k d_uW + 2 N_k d_uW d_vW / W
542
543 static const int str = Dim * (Dim+1) / 2;
544
545 gsMatrix<index_t> act;
546 m_src->active_into(u,act);
547
548 result.resize( act.rows()*str, u.cols() );
549
550 T W;
551 gsMatrix<T> dW(Dim,1), ddW(str,1);
552 std::vector<gsMatrix<T> > ev(3);
553 m_src->evalAllDers_into(u, 2, ev);
554
555 for ( index_t i = 0; i!= u.cols(); ++i ) // for all points
556 {
557 // Start weight function computation
558 W = 0.0;
559 dW .setZero();
560 ddW.setZero();
561 for ( index_t k = 0; k != act.rows(); ++k ) // for all basis functions
562 {
563 //to do with lweights (local weights)
564 const T curw = m_weights.at(act(k,i));
565 W += curw * ev[0](k,i);
566 dW += curw * ev[1].template block<Dim,1>(k*Dim,i);
567 ddW += curw * ev[2].template block<str,1>(k*str,i);
568 }
569 // End weight function computation
570
571 result.col(i) = W * ev[2].col(i); // N_k'' W
572
573 for ( index_t k=0; k != act.rows() ; ++k ) // for all basis functions
574 {
575 const index_t kstr = k * str;
576 const index_t kd = k * Dim;
577
578 result.template block<str,1>(kstr,i) -=
579 ev[0](k,i) * ddW; // - N_k * W''
580
581 result.template block<Dim,1>(kstr,i) +=
582 // - 2 N_k' W' + 2 N_k (W')^2 / W
583 ( (T)(2) * ev[0](k,i) / W ) * dW.cwiseProduct(dW)
584 - (T)(2) * ev[1].template block<Dim,1>(kd,i).cwiseProduct(dW);
585
586 int m = Dim;
587 for ( int _u=0; _u != Dim; ++_u ) // for all mixed derivatives
588 for ( int _v=_u+1; _v != Dim; ++_v )
589 {
590 result(kstr + m++, i) +=
591 - ev[1](kd+_u,i) * dW.at(_v) // - du N_k * dv W
592 - ev[1](kd+_v,i) * dW.at(_u) // - dv N_k * du W
593 // + (T)(2) * N_k * du W * dv W / W
594 + (T)(2) * ev[0](k,i) * dW.at(_u) * dW.at(_v) / W;
595 }
596
597 result.template block<str,1>(kstr,i) *=
598 m_weights.at( act(k,i) ) / (W*W); // * (w_k / W^2)
599 }
600 }
601}
602
603
604template<class SrcT>
605void gsRationalBasis<SrcT>::uniformRefine_withCoefs(gsMatrix<T>& coefs, int numKnots, int mul, int dir)
606{
607 GISMO_ASSERT( coefs.rows() == this->size() && m_weights.rows() == this->size(),
608 "Invalid dimensions" );
609 /* // Using uniformRefine_withTransfer
610 gsSparseMatrix<T, RowMajor> transfer;
611 GISMO_ENSURE(-1==dir, "!!");
612 m_src->uniformRefine_withTransfer(transfer, numKnots, mul);
613
614 coefs = transfer * ( m_weights.asDiagonal() * coefs);
615 m_weights = transfer * m_weights;
616 */
617
618 // Using uniformRefine_withCoefs
619 auto tmp = m_src->clone();
620 coefs *= m_weights.asDiagonal();
621 tmp->uniformRefine_withCoefs(coefs, numKnots);
622 m_src->uniformRefine_withCoefs(m_weights, numKnots,mul,dir);
623
624 // back to affine coefs
625 coefs.array().colwise() /= m_weights.col(0).array();
626 // equiv:
627 // for (int i = 0; i < coefs.rows(); ++i)
628 // coefs.row(i) /= m_weights.at(i);
629}
630
631template<class SrcT>
632void gsRationalBasis<SrcT>::uniformRefine_withTransfer(gsSparseMatrix<T,RowMajor> & transfer, int numKnots, int mul)
633{
634 // 1. Get source transfer matrix (while refining m_src)
635 m_src->uniformRefine_withTransfer(transfer, numKnots, mul);
636
637 // 2. Compute rational basis transfer matrix
638 // To be applied on affine coefficients, as usual.
639 // Transfer matrix for rational bases. Formula:
640 //
641 // ( (T*m_weights)'*I )^{-1} * T*W
642 //
643 // Where ' denotes transpose, W is a diagonal matrix with
644 // diagonal=m_weights, I is the identity and T the source
645 // transfer matrix.
646 // i.e. apply weight transform ( to compute weighted coefs),
647 // apply T, return to affine by the inverse weight transform
648 // (T*W)'*I )^{-1}.
649 // In Eigen this could be something like
650 // (transfer * m_weights).asDiagonal().inverse() * transfer * m_weights.asDiagonal() ;
651 // but that has troubles with the sparse/diagonal expressions etc.
652 // So we do it by using a temporary.
653
654 const gsVector<T> tmp = m_weights ;
655 m_weights.noalias() = transfer * tmp; // Refine the weights as well
656
657 transfer = m_weights.cwiseInverse().asDiagonal() * transfer * tmp.asDiagonal();
658}
659
660
661template<class SrcT>
663 std::vector<index_t> const & boxes)
664{
665 // switch from control points (n-dimensional) to
666 // "projective control points" ((n+1)-dimensional),
667 // where the last coordinate is the weight.
668 gsMatrix<T> rw = projectiveCoefs(coefs, m_weights);
669
670 // refine with these projective control points as coefficients.
671 m_src->refineElements_withCoefs( rw, boxes );
672
673 // Regain the new n-dimensional control points and the new
674 // weights.
675 setFromProjectiveCoefs(rw, coefs, m_weights);
676}
677
678} // namespace gismo
Struct which represents a certain side of a box.
Definition gsBoundary.h:85
A basis represents a family of scalar basis functions defined over a common parameter domain.
Definition gsBasis.h:79
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:563
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.
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
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
Class that creates a rational counterpart for a given basis.
Definition gsRationalBasis.h:48
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:153
gsRationalBasis(const gsRationalBasis &o)
Copy Constructor.
Definition gsRationalBasis.h:94
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 gsRationalBasis.h:176
memory::unique_ptr< gsBasis< T > > makeNonRational() const
Definition gsRationalBasis.h:126
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:265
short_t maxDegree() const
If the basis is of polynomial or piecewise polynomial type, then this function returns the maximum po...
Definition gsRationalBasis.h:168
gsRationalBasis(const SrcT &basis)
Construct a rational counterpart of basis.
Definition gsRationalBasis.h:79
static void setFromProjectiveCoefs(const gsMatrix< T > &pr_coefs, gsMatrix< T > &coefs, gsMatrix< T > &weights)
Definition gsRationalBasis.h:356
gsRationalBasis(SrcT *basis)
Construct a rational counterpart of basis.
Definition gsRationalBasis.h:72
gsMatrix< index_t > allBoundary() const
Returns the indices of the basis functions that are nonzero at the domain boundary.
Definition gsRationalBasis.h:156
T & weight(int i)
Access to i-th weight.
Definition gsRationalBasis.h:310
gsRationalBasis(SrcT *basis, gsMatrix< T > w)
Construct a rational counterpart of basis.
Definition gsRationalBasis.h:86
void setWeights(gsMatrix< T > const &w)
Set weights.
Definition gsRationalBasis.h:316
void connectivity(const gsMatrix< T > &nodes, gsMesh< T > &mesh) const
Definition gsRationalBasis.h:272
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:244
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:366
short_t totalDegree() const
If the basis is of polynomial or piecewise polynomial type, then this function returns the total poly...
Definition gsRationalBasis.h:174
const T & weight(int i) const
Const access to i-th weight.
Definition gsRationalBasis.h:313
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:235
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:226
bool check() const
Check the rational basis for consistency.
Definition gsRationalBasis.h:119
index_t size() const
size
Definition gsRationalBasis.h:137
const gsMatrix< T > & weights() const
Returns the weights of the rational basis.
Definition gsRationalBasis.h:300
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:150
gsMatrix< index_t > boundaryOffset(boxSide const &s, index_t offset) const
Definition gsRationalBasis.h:158
short_t domainDim() const
Dimension of the (source) domain.
Definition gsRationalBasis.h:135
SrcT & source()
Definition gsRationalBasis.h:296
SrcT SourceBasis
Associated source basis type.
Definition gsRationalBasis.h:64
void anchor_into(index_t i, gsMatrix< T > &result) const
Returns the anchor point for member i of the basis.
Definition gsRationalBasis.h:268
gsMatrix< T > support(const index_t &i) const
Returns (a bounding box for) the support of the i-th basis function.
Definition gsRationalBasis.h:277
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:217
gsMatrix< T > projectiveCoefs(const gsMatrix< T > &coefs) const
Definition gsRationalBasis.h:334
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:165
gsMatrix< T > support() const
Returns (a bounding box for) the domain of the whole basis.
Definition gsRationalBasis.h:275
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:322
static gsMatrix< T > projectiveCoefs(const gsMatrix< T > &coefs, const gsMatrix< T > &weights)
Definition gsRationalBasis.h:339
gsRationalBasis()
Default empty constructor.
Definition gsRationalBasis.h:69
void refineElements_withCoefs(gsMatrix< T > &coefs, std::vector< index_t > const &boxes)
Refines specified areas or boxes, depending on underlying basis.
Definition gsRationalBasis.h:662
gsDomain< T > * domain() const
Definition gsRationalBasis.h:263
gsMatrix< T > & weights()
Returns the weights of the rational basis.
Definition gsRationalBasis.h:303
size_t numElements(boxSide const &s=0) const
The number of elements on side s.
Definition gsRationalBasis.h:141
const SrcT & source() const
Returns the source basis of the rational basis.
Definition gsRationalBasis.h:293
short_t minDegree() const
If the basis is of polynomial or piecewise polynomial type, then this function returns the minimum po...
Definition gsRationalBasis.h:171
gsMatrix< T > elementInSupportOf(index_t j) const
See gsBasis for a description.
Definition gsRationalBasis.h:148
gsRationalBasis & operator=(const gsRationalBasis &o)
Assignment operator.
Definition gsRationalBasis.h:101
void refine(gsMatrix< T > const &boxes, int refExt=0)
See gsBasis.
Definition gsRationalBasis.h:186
void refineElements(std::vector< index_t > const &boxes)
Refines specified areas or boxes, depending on underlying basis.
Definition gsRationalBasis.h:198
size_t elementIndex(const gsVector< T > &u) const
See gsBasis for a description.
Definition gsRationalBasis.h:145
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:372
virtual bool isRational() const
Returns true, since by definition a gsRationalBasis is rational.
Definition gsRationalBasis.h:307
Sparse matrix class, based on gsEigen::SparseMatrix.
Definition gsSparseMatrix.h:139
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
Provides declaration of Basis abstract interface.
Provides structs and classes related to interfaces and boundaries.
#define short_t
Definition gsConfig.h:35
#define index_t
Definition gsConfig.h:32
#define GISMO_UNUSED(x)
Definition gsDebug.h:112
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
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