G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsGeometry.hpp
Go to the documentation of this file.
1
14#pragma once
15
16#include <gsCore/gsBasis.h>
18#include <gsCore/gsFuncData.h>
20
22
23//#include <gsCore/gsMinimizer.h>
24#include <gsUtils/gsPointGrid.h>
25
26namespace gismo
27{
28
30template<class T>
31class gsSquaredDistance GISMO_FINAL : public gsFunction<T>
32{
33public:
34 gsSquaredDistance(const gsGeometry<T> & g, const gsVector<T> & pt)
35 : m_g(&g), m_pt(&pt), m_gd(2) { }
36
37 // f = (1/2)*||x-pt||^2
38 void eval_into(const gsMatrix<T>& u, gsMatrix<T>& result) const
39 {
40 m_g->eval_into(u, m_gd[0]);
41 result.resize(1, u.cols());
42 result.at(0) = 0.5 * (m_gd[0]-*m_pt).squaredNorm();
43 }
44
45 void evalAllDers_into(const gsMatrix<T> & u, int n,
46 std::vector<gsMatrix<T> > & result,
47 bool sameElement = false) const
48 {
49 GISMO_ASSERT(1==u.cols(), "Single argument assumed");
50 result.resize(n+1);
51 m_g->evalAllDers_into(u, n, m_gd, sameElement);
52
53 // f = (1/2)*||x-pt||^2
54 result[0].resize(1, 1);
55 result[0].at(0) = 0.5 * (m_gd[0]-*m_pt).squaredNorm();
56 if (n==0) return;
57
58 // f' = x'*(x-pt)
59 auto jacT = m_gd[1].reshaped(u.rows(),m_pt->rows());
60 result[1].noalias() = jacT * (m_gd[0] - *m_pt);
61 if (n==1) return;
62
63 // f'' = tr(x')*x' + sum_i[ (x_i-pt_i) * x_i'']
64 tmp.noalias() = jacT * jacT.transpose();
65 index_t d2 = u.rows() * (u.rows()+1) / 2;
66 gsMatrix<T> hm;
67 for ( index_t k=0; k < m_g->coefs().cols(); ++k )
68 {
69 hm = util::secDerToHessian(m_gd[2].block(k*d2,0,d2,1),u.rows()).reshaped(u.rows(),u.rows());
70 tmp += (m_gd[0].at(k)-m_pt->at(k)) * hm;
71 }
72 util::hessianToSecDer(tmp,u.rows(),result[2]);
73 }
74
75 // f' = x'*(x-pt)
76 void deriv_into(const gsMatrix<T>& u, gsMatrix<T>& result) const
77 {
78 result.resize(u.rows(), u.cols());
79 for ( index_t i=0; i != u.cols(); i++ )
80 {
81 tmp = u.col(i);
82 m_g->eval_into(tmp,m_gd[0]);
83 m_g->jacobian_into(tmp,m_gd[1]);
84 result.col(i).noalias() = m_gd[1].transpose() * (m_gd[0] - *m_pt);
85 }
86 }
87
88 // f'' = tr(x')*x' + sum_i[ (x_i-pt_i) * x_i'']
89 void hessian_into(const gsMatrix<T>& u, gsMatrix<T>& result,
90 index_t) const
91 {
92 m_g->eval_into(u,m_gd[0]);
93 m_g->jacobian_into(u,m_gd[1]);
94 result.noalias() = m_gd[1].transpose() * m_gd[1];
95 for ( index_t k=0; k < m_g->coefs().cols(); ++k )
96 {
97 tmp = m_g->hessian(u,k);
98 result.noalias() += (m_gd[0].at(k)-m_pt->at(k))*tmp;
99 }
100 }
101
102 gsMatrix<T> support() const {return m_g->support() ;}
103 short_t domainDim () const {return m_g->domainDim();}
104 short_t targetDim () const {return 1;}
105
106private:
107 const gsGeometry<T> * m_g;
108 const gsVector<T> * m_pt;
109 mutable std::vector<gsMatrix<T> > m_gd;
110 mutable gsMatrix<T> tmp;
111};
112
113 /*
114template<class T>
115boxSide gsGeometry<T>::sideOf( const gsVector<T> & u, )
116{
117 // get the indices of the coefficients which lie on the boundary
118 gsMatrix<index_t > allBnd = m_basis->allBoundary();
119 gsMatrix<T> bndCoeff(allBnd.rows(), m_coefs.rows());
120
121 // extract the indices of the boundary coefficients
122 for(index_t r = 0; r < allBnd.rows(); r++)
123 bndCoeff.row(r) = m_coefs.row(allBnd(r,0));
124
125
126 for(size_t size = 0; size < allBnd.rows(); size++)
127 if(boundaryPatch1[size] == 1)
128 interfaceIndicesPatch1.push_back(allBnd(size, 0)); // get the indices of the coefficients on patch 1 which lie on the common interface
129
130 boxSide side;
131
132 for(unsigned index = 1; index <= nBoundaries; index++) {
133 int contained = 0;
134 side.m_index = index;
135
136 gsMatrix<index_t> bnd = m_basis->boundary(side);
137
138 for(size_t i = 0; i < interfaceIndicesPatch1.size(); i++)
139 {
140 gsInfo << "index: " << interfaceIndicesPatch1[i] << "\n";
141 for (int j = 0; j < bnd.rows(); j++)
142 {
143 if(bnd(j, 0) == interfaceIndicesPatch1[i])
144 contained++;
145 }
146 }
147
148 if(contained == bnd.rows())
149 break;
150
151 //gsInfo << "indices of boundary : " << bnd << "\n";
152 }
153}
154 */
155
156template<class T>
157gsGeometry<T>::gsGeometry(const gsGeometry<T> & o)
158: m_coefs(o.m_coefs), m_basis(o.m_basis != NULL ? o.basis().clone().release() : NULL), m_id(o.m_id)
159{ }
160
161template<class T>
162gsGeometry<T>::~gsGeometry()
163{ delete m_basis; }
164
165template<class T>
167{ this->basis().evalFunc_into(u, m_coefs, result); }
168
169template<class T>
171{ this->basis().derivFunc_into(u, m_coefs, result); }
172
173template<class T>
175{ this->basis().deriv2Func_into(u, m_coefs, result); }
176
177template<class T>
179 std::vector<gsMatrix<T> > & result,
180 bool sameElement) const
181{ this->basis().evalAllDersFunc_into(u, m_coefs, n, result, sameElement); }
182
183template<class T>
184short_t gsGeometry<T>::domainDim() const { return this->basis().domainDim(); }
185
186template<class T>
187short_t gsGeometry<T>::coDim() const { return coefDim()-this->basis().domainDim(); }
188
189template<class T>
190short_t gsGeometry<T>::parDim() const { return this->basis().domainDim(); }
191
192template<class T>
194{ return this->basis().support(); }
195
196template<class T>
199{ return this->basis().support(); }
200
201template<class T>
203{
204 if ( this != &o )
205 {
206 m_coefs = o.m_coefs;
207 delete m_basis;
208 m_basis = o.basis().clone().release() ;
209 m_id = o.m_id;
210 }
211 return *this;
212}
213
214template<class T>
215typename gsGeometry<T>::uPtr
217{
218 gsMatrix<index_t> ind = this->basis().boundary(s); // get indices of the boundary DOF
219 gsMatrix<T> coeffs (ind.size(), geoDim()); // create matrix for boundary coefficients
220
221 for (index_t i=0; i != ind.size(); i++ )
222 {
223 coeffs.row(i) = m_coefs.row( ind(i,0) );
224 }
225
226 typename gsBasis<T>::uPtr Bs = this->basis().boundaryBasis(s); // Basis for boundary side s
227 return Bs->makeGeometry( give(coeffs) );
228}
229
230template<class T>
231typename gsGeometry<T>::uPtr
237
238template<class T>
239typename gsGeometry<T>::uPtr
241{
243 typename gsBasis<T>::uPtr Bs = this->basis().componentBasis_withIndices(bc, ind, false);
244 gsMatrix<T> coefs (ind.size(), geoDim());
245
246 for (index_t i=0; i != ind.size(); i++ )
247 {
248 coefs.row(i) = m_coefs.row( ind(i,0) );
249 }
250
251 return Bs->makeGeometry( coefs );
252}
253
254template<class T>
256{
257 const int pDim = parDim();
258 const int gDim = geoDim();
259
260 gsMatrix<T> tmp;
261
262 // For all vertices of the mesh, push forward the value by the
263 // geometry mapping
264 if (1==gDim && 3>pDim) // Plot a graph
265 for (size_t i = 0; i!= mesh.numVertices(); ++i)
266 {
267 eval_into( mesh.vertex(i).topRows(pDim), tmp );
268 mesh.vertex(i).middleRows(pDim, gDim) = tmp;
269 }
270 else // Plot mesh on a mapping
271 for (size_t i = 0; i!= mesh.numVertices(); ++i)
272 {
273 eval_into( mesh.vertex(i).topRows(pDim), tmp );
274 const index_t gd = math::min(3,gDim);
275 mesh.vertex(i).topRows(gd) = tmp.topRows(gd);
276 }
277
278}
279template<class T>
280std::vector<gsGeometry<T>* > gsGeometry<T>::uniformSplit(index_t) const
281{
283}
284
285template<class T>
287{
288 return gsGeometrySlice<T>(this,dir_fixed,par);
289}
290
291template<class T>
292typename gsMatrix<T>::RowXpr
294{
295 return this->m_coefs.row(this->basis().functionAtCorner(c));
296}
297
298template<class T>
301{
302 return this->m_coefs.row(this->basis().functionAtCorner(c));
303}
304
305template<class T>
306void gsGeometry<T>::uniformRefine(int numKnots, int mul, short_t const dir)
307{
308 this->basis().uniformRefine_withCoefs( m_coefs, numKnots, mul, dir);
309}
310
311template<class T>
312void gsGeometry<T>::uniformCoarsen(int numKnots) // todo: int dir = -1
313{
314 this->basis().uniformCoarsen_withCoefs( m_coefs, numKnots);
315}
316
317template<class T>
318void gsGeometry<T>::refineElements( std::vector<index_t> const & boxes )
319{
320 this->basis().refineElements_withCoefs(this->m_coefs, boxes );
321}
322
323template<class T>
324void gsGeometry<T>::unrefineElements( std::vector<index_t> const & boxes )
325{
326 this->basis().unrefineElements_withCoefs(this->m_coefs, boxes );
327}
328
329template<class T>
330inline typename gsGeometry<T>::uPtr gsGeometry<T>::coord(const index_t c) const {return this->basis().makeGeometry( this->coefs().col(c) ); }
331
332template<class T>
334 //{ return this->basisComponent(i).degree(); };
335 { return this->basis().degree(i); }
336
337
338template<class T>
340 gsVector<T> & result,
341 const T accuracy,
342 const bool useInitialPoint) const
343{
344 GISMO_ASSERT( pt.rows() == targetDim(), "Invalid input point." <<
345 pt.rows() <<"!="<< targetDim() );
346#if false
347 gsSquaredDistance<T> dist2(*this, pt);
348 gsMinimizer<T> fmin(dist2);
349 fmin.solve();
350 result = fmin.currentDesign();
351#else
352 gsSquaredDistance<T> dist2(*this, pt);
353 result = useInitialPoint ? dist2.argMin(accuracy*accuracy, 100, result)
354 : dist2.argMin(accuracy*accuracy, 100) ;
355#endif
356 return math::sqrt( dist2.eval(result).value() );
357}
358
359template<class T>
360T gsGeometry<T>::directedHausdorffDistance(const gsGeometry & other, const index_t nsamples, const T accuracy) const
361{
362 // Sample points on *this
363 gsMatrix<T> uv = gsPointGrid<T>(this->support(),nsamples);
364 gsMatrix<T> pts;
365 this->eval_into(uv,pts);
366 // Find the maximum of the closest point on *other from the set of pts
367 T maxDist=std::numeric_limits<T>::min();
368 gsVector<T> tmp;
369 for (index_t k=0; k!=pts.cols(); k++)
370 {
371 maxDist = std::max(maxDist,other.closestPointTo(pts.col(k),tmp,accuracy,false));
372 }
373 return math::sqrt(2*maxDist); // euclidean distance since closestPointTo uses 1/2*||x-y||^2, see gsSquaredDistance
374}
375
376template<class T>
377T gsGeometry<T>::HausdorffDistance(const gsGeometry & other, const index_t nsamples, const T accuracy, bool directed) const
378{
379 T this2other, other2this;
380 this2other = this->directedHausdorffDistance(other,nsamples,accuracy);
381 if (directed)
382 return this2other;
383 else
384 {
385 other2this = other.directedHausdorffDistance(*this,nsamples,accuracy);
386 return std::max(other2this,this2other);
387 }
388}
389
390
391// Recovers the points of the geometry from the given points and parameters
392template<class T>
394 const T accuracy) const
395{
396 gsVector<index_t> ind(xyz.rows()-1);
397 for (index_t i = 0; i!= xyz.rows(); ++i)
398 if (i<k) ind[i]=i;
399 else if (i>k) ind[i-1]=i;
400
401 gsMatrix<T> pt = xyz(ind,gsEigen::all);
402 gsFuncCoordinate<T> fc(*this, give(ind));
403 fc.invertPoints(pt,uv,accuracy,false);
404 xyz = this->eval(uv);
405 //possible check: pt close to xyz
406}
407
408
409template<class T>
410std::ostream & gsGeometry<T>::print(std::ostream &os) const
411{
412 os << "Geometry "<< "R^"<< this->parDim() <<
413 " --> R^"<< this->geoDim()<< ", #control pnts= "<< coefsSize() <<
414 ": "<< coef(0) <<" ... "<< coef(this->coefsSize()-1);
415 os<<"\nBasis:\n" << this->basis();
416 return os;
417}
418
419template<class T>
422
423template<class T>
424void gsGeometry<T>::toMesh(gsMesh<T> &, int) const
426
427template<class T>
428typename gsGeometry<T>::uPtr
429gsGeometry<T>::approximateLinearly() const
431
432template<class T>
435
436template<class T>
437std::vector<gsGeometry<T> *> gsGeometry<T>::boundary() const
438{
439 // TO DO: get boundary curves, using basis().boundary();
441}
442
443template<class T>
448
449template<class T>
451{
452 typename gsBasis<T>::uPtr b = m_basis->clone();
453 b->degreeElevate(i, dir);
454 gsMatrix<T> iVals, iPts = b->anchors();
455 this->eval_into(iPts, iVals);
456 typename gsGeometry<T>::uPtr g = b->interpolateData(iVals, iPts);
457
458 std::swap(m_basis, g->m_basis);
459 g->coefs().swap(this->coefs());
460}
461
462template<class T>
464{
465 typename gsBasis<T>::uPtr b = m_basis->clone();
466 b->degreeReduce(i, dir);
467 gsMatrix<T> iVals, iPts = b->anchors();
468 this->eval_into(iPts, iVals);
469 typename gsGeometry<T>::uPtr g = b->interpolateData(iVals, iPts);
470
471 std::swap(m_basis, g->m_basis);
472 g->coefs().swap(this->coefs());
473}
474
475template<class T>
477{
478 typename gsBasis<T>::uPtr b = m_basis->clone();
479 b->degreeIncrease(i, dir);
480 gsMatrix<T> iVals, iPts = b->anchors();
481 this->eval_into(iPts, iVals);
482 typename gsGeometry<T>::uPtr g = b->interpolateData(iVals, iPts);
483
484 std::swap(m_basis, g->m_basis);
485 g->coefs().swap(this->coefs());
486}
487
488template<class T>
490{
491 typename gsBasis<T>::uPtr b = m_basis->clone();
492 b->degreeDecrease(i, dir);
493 gsMatrix<T> iVals, iPts = b->anchors();
494 this->eval_into(iPts, iVals);
495 typename gsGeometry<T>::uPtr g = b->interpolateData(iVals, iPts);
496
497 std::swap(m_basis, g->m_basis);
498 g->coefs().swap(this->coefs());
499}
500
501template<class T> void
503 index_t coord) const
504{
505 const unsigned d = this->domainDim();
506 GISMO_ASSERT( coord<targetDim(),"Invalid coordinate function "<<coord);
507
508 gsMatrix<T> B, tmp(d,d);
510
511 // coefficient matrix row k = coef. of basis function k
512 const gsMatrix<T>& C = this->m_coefs;
513 // col j = nonzero second derivatives at column point u(..,j)
514 m_basis->deriv2_into(u, B) ;
515 // col j = indices of active functions at column point u(..,j)
516 m_basis->active_into(u, ind);
517
518 result.setZero(d,d);
519 static const index_t j = 0;// just one column
520 //for ( unsigned j=0; j< u.cols(); j++ ) // for all points (columns of u)
521
522 for ( index_t i=0; i< ind.rows() ; i++ ) // for all non-zero basis functions)
523 {
524 unsigned r = i*d*(d+1)/2;
525 unsigned m = d;
526 //construct the Hessian of basis function ind(i,0)
527 for (unsigned k=0; k<d; ++k ) // for all rows
528 {
529 tmp(k,k) = B(r+k,j);
530 for (unsigned l=k+1; l<d; ++l ) // for all cols
531 tmp(k,l) = tmp(l,k) = B(r + m++,0);
532 }
533 result += C(ind(i,j), coord) * tmp;
534 }
535}
536
537template<class T>
539{ basis().connectivity(m_coefs, mesh); }
540
541
542
543template <typename T>
544void extractRows( const gsMatrix<T> &in, typename gsMatrix<index_t>::constColumn actives, gsMatrix<T> &out)
545{
546 out.resize(actives.rows(), in.cols());
547 for (index_t r=0; r<actives.rows();++r)
548 out.row(r)=in.row(actives(r,0));
549}
550
551template <class T>
552void
553gsGeometry<T>::compute(const gsMatrix<T> & in, gsFuncData<T> & out) const
554{
555 const unsigned flags = out.flags | NEED_ACTIVE;
556 const index_t numPt = in.cols();
557 const index_t numCo = m_coefs.cols();
558
559 gsFuncData<T> tmp(flags);
560 this->basis().compute(in, tmp);
561
562 out.values.resize(out.maxDeriv()+1);
563 out.dim.first = tmp.dim.first;
564 out.dim.second = numCo;
565 if ( flags & SAME_ELEMENT )
566 {
567 gsMatrix<T> coefM;
568 extractRows(m_coefs,tmp.active(0),coefM);
569
570 if (flags & NEED_VALUE)
571 out.values[0].noalias()=coefM.transpose()*tmp.values[0];
572 if (flags & NEED_DERIV)
573 {
574 const index_t derS = tmp.derivSize();
575 out.values[1].resize(derS*numCo,numPt);
576 for (index_t p=0; p< numPt; ++p)
577 out.values[1].reshapeCol(p, derS, numCo).noalias() = tmp.deriv(p)*coefM;
578 }
579 if (flags & NEED_DERIV2)
580 {
581 const index_t derS = tmp.deriv2Size();
582 out.values[2].resize(derS*numCo,numPt);
583 for (index_t p=0; p< numPt; ++p)
584 out.values[2].reshapeCol(p, derS, numCo).noalias() = tmp.deriv2(p)*coefM;
585 }
586 if (flags & NEED_ACTIVE)
587 this->active_into(in.col(0), out.actives);
588 }
589 else
590 {
591 gsMatrix<T> coefM;
592 const index_t derS = tmp.derivSize();
593 const index_t der2S = tmp.deriv2Size();
594
595 if (flags & NEED_VALUE) out.values[0].resize(numCo,numPt);
596 if (flags & NEED_DERIV) out.values[1].resize(numCo*derS,numPt);
597 if (flags & NEED_DERIV2) out.values[2].resize(numCo*der2S,numPt);
598 if (flags & NEED_ACTIVE) this->active_into(in, out.actives);
599
600 for (index_t p=0; p<numPt;++p)
601 {
602 extractRows(m_coefs,tmp.active(p),coefM);
603 if (flags & NEED_VALUE)
604 out.values[0].reshapeCol(p,1,numCo).noalias() = tmp.eval(p)*coefM;
605 if (flags & NEED_DERIV)
606 out.values[1].reshapeCol(p, derS, numCo).noalias() = tmp.deriv(p)*coefM;
607 if (flags & NEED_DERIV2)
608 out.values[2].reshapeCol(p, der2S, numCo).noalias() = tmp.deriv2(p)*coefM;
609 }
610 }
611}
612
613template<class T>
615{
617}
618
619template<class T>
620std::vector<boxSide> gsGeometry<T>::locateOn(const gsMatrix<T> & u, gsVector<bool> & onGeo, gsMatrix<T> & preIm, bool lookForBoundary, real_t tol) const
621{
622 onGeo.resize(u.cols());
623 std::vector<boxSide> sides(u.cols());
624
625 for(index_t i = 0; i < onGeo.size(); i++)
626 onGeo(i) = false;
627
628 preIm.resize(geoDim(), u.cols());
629 gsMatrix<T> pr = this->parameterRange(), tmp;
630
631 for(index_t i = 0; i < u.cols(); i++)
632 {
633 this->invertPoints(u.col(i), tmp, tol);
634 pr = this->parameterRange();
635 //if ((tmp.array() >= pr.col(0).array()).all()
636 // && (tmp.array() <= pr.col(1).array()).all())
637 if ((tmp.array() >= pr.col(0).array() - 1.e-4).all()
638 && (tmp.array() <= pr.col(1).array() + 1.e-4).all()) // be careful! if u is on the boundary then we may get a wrong result
639 // the tolerance is due to imprecisions in the geometry map. E.g. If a circle is rotated then the corner need
640 // not to lie exactly on the interface of the neighbour patch since we use only B-splines for the modelling
641 // TODO: Maybe find a better solution!
642 {
643 onGeo(i) = true;
644 preIm.col(i) = tmp;
645
646 if (lookForBoundary == true)
647 {
648 boxSide s;
649 for (int d = 0; d < geoDim(); d++) {
650 if ((math::abs(tmp(d, 0) - pr(d, 0)) < tol))
651 {
652 s.m_index = 2*d+1; // lower
653 break;
654 }
655
656 if ((math::abs(tmp(d, 0) - pr(d, 1)) < tol))
657 {
658 s.m_index = 2 * d + 2; // upper
659 break;
660 }
661 }
662 sides[i] = s;
663 }
664 }
665 }
666
667 return sides;
668}
669
670
671} // namespace gismo
Struct which represents a certain side of a box.
Definition gsBoundary.h:85
short_t m_index
Index of the side.
Definition gsBoundary.h:92
virtual 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 gsBasis.hpp:641
memory::unique_ptr< gsGeometry< T > > interpolateData(gsMatrix< T > const &vals, gsMatrix< T > const &pts) const
Applies interpolation given the parameter values pts and values vals.
Definition gsBasis.hpp:240
virtual 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 gsBasis.hpp:633
virtual 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 gsBasis.hpp:637
memory::unique_ptr< gsBasis > uPtr
Unique pointer for gsBasis.
Definition gsBasis.h:89
gsMatrix< T > anchors() const
Returns the anchor points that represent the members of the basis. There is exactly one anchor point ...
Definition gsBasis.h:437
virtual memory::unique_ptr< gsGeometry< T > > makeGeometry(gsMatrix< T > coefs) const =0
Create a gsGeometry of proper type for this basis with the given coefficient matrix.
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 gsBasis.hpp:629
Represents a certain component of a vector-valued function.
Definition gsFuncCoordinate.h:35
uPtr clone()
Clone methode. Produceds a deep copy inside a uPtr.
gsMatrix< T > eval(const gsMatrix< T > &u) const
Evaluate the function,.
Definition gsFunctionSet.hpp:120
A function from a n-dimensional domain to an m-dimensional image.
Definition gsFunction.h:60
virtual void invertPoints(const gsMatrix< T > &points, gsMatrix< T > &result, const T accuracy=1e-6, const bool useInitialPoint=false) const
Definition gsFunction.hpp:199
gsGeometrySlice is a class representing an iso parametric slice of a geometry object....
Definition gsGeometrySlice.h:28
Abstract base class representing a geometry map.
Definition gsGeometry.h:93
virtual void deriv2_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate second derivatives of the function at points u into result.
Definition gsGeometry.hpp:174
gsMatrix< T > & coefs()
Definition gsGeometry.h:340
T HausdorffDistance(const gsGeometry &other, const index_t nsamples=1000, const T accuracy=1e-6, const bool directed=false) const
Computes the Hausdorff distance between *this to other.
Definition gsGeometry.hpp:377
std::vector< gsGeometry * > boundary() const
Get boundary of this geometry as a vector of new gsGeometry instances.
Definition gsGeometry.hpp:437
virtual void uniformCoarsen(int numKnots=1)
Coarsen the geometry uniformly, removing numKnots new knots into each knot span.
Definition gsGeometry.hpp:312
gsMatrix< T >::RowXpr coefAtCorner(boxCorner const &c)
Returns the control point at corner c.
Definition gsGeometry.hpp:293
virtual void degreeElevate(short_t const i=1, short_t const dir=-1)
Elevate the degree by the given amount i for the direction dir. If dir is -1 then degree elevation is...
Definition gsGeometry.hpp:450
virtual void degreeIncrease(short_t const i=1, short_t const dir=-1)
Elevate the degree by the given amount i for the direction dir. If dir is -1 then degree elevation is...
Definition gsGeometry.hpp:476
short_t degree(const short_t &i) const
Returns the degree wrt direction i.
Definition gsGeometry.hpp:333
short_t coDim() const
Co-dimension of the geometric object.
Definition gsGeometry.hpp:187
void evaluateMesh(gsMesh< T > &mesh) const
Definition gsGeometry.hpp:255
memory::unique_ptr< gsGeometry > uPtr
Unique pointer for gsGeometry.
Definition gsGeometry.h:100
std::vector< boxSide > locateOn(const gsMatrix< T > &u, gsVector< bool > &onG2, gsMatrix< T > &preIm, bool lookForBoundary=false, real_t tol=1.e-6) const
Get back the side of point u.
Definition gsGeometry.hpp:620
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 gsGeometry.hpp:178
void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate the function at points u into result.
Definition gsGeometry.hpp:166
virtual void merge(gsGeometry *other)
Merge the given other geometry into this one.
Definition gsGeometry.hpp:420
gsGeometry()
Default constructor. Note: Derived constructors (except for the default) should assign m_basis to a v...
Definition gsGeometry.h:111
virtual void hessian_into(const gsMatrix< T > &u, gsMatrix< T > &result, index_t coord) const
Definition gsGeometry.hpp:502
virtual void compute(const gsMatrix< T > &in, gsFuncData< T > &out) const
Computes function data.
Definition gsGeometry.hpp:553
virtual std::vector< gsGeometry< T > * > uniformSplit(index_t dir=-1) const
Definition gsGeometry.hpp:280
void outerNormal_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Computes the outer normals at parametric points u.
Definition gsGeometry.hpp:433
void recoverPoints(gsMatrix< T > &xyz, gsMatrix< T > &uv, index_t k, const T accuracy) const
Recovers the points of the geometry from the given points xyz and parameters uv.
Definition gsGeometry.hpp:393
virtual void degreeReduce(short_t const i=1, short_t const dir=-1)
Reduces the degree by the given amount i for the direction dir. If dir is -1 then degree reduction is...
Definition gsGeometry.hpp:463
T directedHausdorffDistance(const gsGeometry &other, const index_t nsamples=1000, const T accuracy=1e-6) const
Definition gsGeometry.hpp:360
virtual short_t domainDim() const
Dimension d of the parameter domain (overriding gsFunction::domainDim()).
Definition gsGeometry.hpp:184
virtual const gsBasis< T > & basis() const =0
Returns a const reference to the basis of the geometry.
virtual gsGeometry::uPtr iface(const boundaryInterface &bi, const gsGeometry &other) const
Computes and returns the interface with other as a new geometry.
Definition gsGeometry.hpp:232
gsGeometry::uPtr component(boxComponent const &bc) const
Get parametrization of box component bc as a new gsGeometry uPtr.
Definition gsGeometry.hpp:240
virtual void uniformRefine(int numKnots=1, int mul=1, short_t const dir=-1)
Refine the geometry uniformly, inserting numKnots new knots into each knot span.
Definition gsGeometry.hpp:306
short_t parDim() const
Dimension d of the parameter domain (same as domainDim()).
Definition gsGeometry.hpp:190
virtual void deriv_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate derivatives of the function at points u into result.
Definition gsGeometry.hpp:170
gsBasis< T > * m_basis
Pointer to the basis of this geometry.
Definition gsGeometry.h:632
gsMatrix< T > support() const
Returns the range of parameters (same as parameterRange())
Definition gsGeometry.hpp:193
T closestPointTo(const gsVector< T > &pt, gsVector< T > &result, const T accuracy=1e-6, const bool useInitialPoint=false) const
Definition gsGeometry.hpp:339
gsMatrix< T > m_coefs
Coefficient matrix of size coefsSize() x geoDim()
Definition gsGeometry.h:629
size_t m_id
Definition gsGeometry.h:636
virtual std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition gsGeometry.hpp:410
void controlNet(gsMesh< T > &mesh) const
Return the control net of the geometry.
Definition gsGeometry.hpp:538
gsGeometrySlice< T > getIsoParametricSlice(index_t dir_fixed, T par) const
Definition gsGeometry.hpp:286
void refineElements(std::vector< index_t > const &boxes)
Refines the basis and adjusts the coefficients to keep the geometry the same.
Definition gsGeometry.hpp:318
virtual void insertKnot(T knot, index_t dir, index_t i=1)
Inserts knot knot at direction dir, i times.
Definition gsGeometry.hpp:444
virtual void degreeDecrease(short_t const i=1, short_t const dir=-1)
Reduces the degree by the given amount i for the direction dir. If dir is -1 then degree reduction is...
Definition gsGeometry.hpp:489
gsMatrix< T > parameterRange() const
Returns the range of parameters as a matrix with two columns, [lower upper].
Definition gsGeometry.hpp:198
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
gsAsMatrix< T, Dynamic, Dynamic > reshapeCol(index_t c, index_t n, index_t m)
Returns column c of the matrix resized to n x m matrix This function assumes that the matrix is size ...
Definition gsMatrix.h:231
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
Squared distance function from a fixed point to a gsGeometry.
Definition gsGeometry.hpp:32
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 gsGeometry.hpp:45
short_t targetDim() const
Dimension of the target space.
Definition gsGeometry.hpp:104
void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate the function at points u into result.
Definition gsGeometry.hpp:38
short_t domainDim() const
Dimension of the (source) domain.
Definition gsGeometry.hpp:103
void deriv_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate derivatives of the function at points u into result.
Definition gsGeometry.hpp:76
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
T at(index_t i) const
Returns the i-th element of the vector.
Definition gsVector.h:177
Provides declaration of Basis abstract interface.
#define short_t
Definition gsConfig.h:35
#define index_t
Definition gsConfig.h:32
#define GISMO_NO_IMPLEMENTATION
Definition gsDebug.h:129
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
Provides definition of the FuncCoordinate class.
This object is a cache for computed values from an evaluator.
Provides declaration of the gsGeometrySlice class.
Provides declaration of the Mesh class.
Provides functions to generate structured point data.
The G+Smo namespace, containing all definitions for the library.
@ SAME_ELEMENT
Enable optimizations based on the assumption that all evaluation points are in the same bezier domain...
Definition gsForwardDeclarations.h:89
@ NEED_VALUE
Value of the object.
Definition gsForwardDeclarations.h:72
@ NEED_DERIV2
Second derivatives.
Definition gsForwardDeclarations.h:80
@ NEED_DERIV
Gradient of the object.
Definition gsForwardDeclarations.h:73
@ NEED_ACTIVE
Active function ids.
Definition gsForwardDeclarations.h:84
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 component (interior, face, egde, corner).
Definition gsBoundary.h:445
Struct which represents a certain corner of a hyper-cube.
Definition gsBoundary.h:292