G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsGeometry.hpp
Go to the documentation of this file.
1 
14 #pragma once
15 
16 #include <gsCore/gsBasis.h>
17 #include <gsUtils/gsMesh/gsMesh.h>
18 #include <gsCore/gsFuncData.h>
20 
21 #include <gsCore/gsGeometrySlice.h>
22 
23 //#include <gsCore/gsMinimizer.h>
24 #include <gsUtils/gsPointGrid.h>
25 
26 namespace gismo
27 {
28 
30 template<class T>
31 class gsSquaredDistance GISMO_FINAL : public gsFunction<T>
32 {
33 public:
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 
106 private:
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  /*
114 template<class T>
115 boxSide 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 
156 template<class T>
157 gsGeometry<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 
161 template<class T>
162 gsGeometry<T>::~gsGeometry()
163 { delete m_basis; }
164 
165 template<class T>
166 void gsGeometry<T>::eval_into(const gsMatrix<T>& u, gsMatrix<T>& result) const
167 { this->basis().evalFunc_into(u, m_coefs, result); }
168 
169 template<class T>
170 void gsGeometry<T>::deriv_into(const gsMatrix<T>& u, gsMatrix<T>& result) const
171 { this->basis().derivFunc_into(u, m_coefs, result); }
172 
173 template<class T>
175 { this->basis().deriv2Func_into(u, m_coefs, result); }
176 
177 template<class T>
179  std::vector<gsMatrix<T> > & result,
180  bool sameElement) const
181 { this->basis().evalAllDersFunc_into(u, m_coefs, n, result, sameElement); }
182 
183 template<class T>
184 short_t gsGeometry<T>::domainDim() const { return this->basis().domainDim(); }
185 
186 template<class T>
187 short_t gsGeometry<T>::coDim() const { return coefDim()-this->basis().domainDim(); }
188 
189 template<class T>
190 short_t gsGeometry<T>::parDim() const { return this->basis().domainDim(); }
191 
192 template<class T>
194 { return this->basis().support(); }
195 
196 template<class T>
199 { return this->basis().support(); }
200 
201 template<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 
214 template<class T>
215 typename 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 
230 template<class T>
231 typename gsGeometry<T>::uPtr
233  const gsGeometry &) const
234 {
236 }
237 
238 template<class T>
239 typename gsGeometry<T>::uPtr
241 {
242  gsMatrix<index_t> ind;
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 
254 template<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 }
279 template<class T>
280 std::vector<gsGeometry<T>* > gsGeometry<T>::uniformSplit(index_t) const
281 {
283 }
284 
285 template<class T>
287 {
288  return gsGeometrySlice<T>(this,dir_fixed,par);
289 }
290 
291 template<class T>
292 typename gsMatrix<T>::RowXpr
294 {
295  return this->m_coefs.row(this->basis().functionAtCorner(c));
296 }
297 
298 template<class T>
301 {
302  return this->m_coefs.row(this->basis().functionAtCorner(c));
303 }
304 
305 template<class T>
306 void gsGeometry<T>::uniformRefine(int numKnots, int mul, int dir) // todo: int dir = -1
307 {
308  this->basis().uniformRefine_withCoefs( m_coefs, numKnots, mul, dir);
309 }
310 
311 template<class T>
312 void gsGeometry<T>::uniformCoarsen(int numKnots) // todo: int dir = -1
313 {
314  this->basis().uniformCoarsen_withCoefs( m_coefs, numKnots);
315 }
316 
317 template<class T>
318 void gsGeometry<T>::refineElements( std::vector<index_t> const & boxes )
319 {
320  this->basis().refineElements_withCoefs(this->m_coefs, boxes );
321 }
322 
323 template<class T>
324 void gsGeometry<T>::unrefineElements( std::vector<index_t> const & boxes )
325 {
326  this->basis().unrefineElements_withCoefs(this->m_coefs, boxes );
327 }
328 
329 template<class T>
330 inline typename gsGeometry<T>::uPtr gsGeometry<T>::coord(const index_t c) const {return this->basis().makeGeometry( this->coefs().col(c) ); }
331 
332 template<class T>
334  //{ return this->basisComponent(i).degree(); };
335  { return this->basis().degree(i); }
336 
337 
338 template<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 
359 template<class T>
360 T 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 
376 template<class T>
377 T 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 // template<class T>
391 // T gsGeometry<T>::hausdorffDistance() const
392 
393 
394 
395 template<class T>
396 std::ostream & gsGeometry<T>::print(std::ostream &os) const
397 {
398  os << "Geometry "<< "R^"<< this->parDim() <<
399  " --> R^"<< this->geoDim()<< ", #control pnts= "<< coefsSize() <<
400  ": "<< coef(0) <<" ... "<< coef(this->coefsSize()-1);
401  os<<"\nBasis:\n" << this->basis();
402  return os;
403 }
404 
405 template<class T>
408 
409 template<class T>
410 void gsGeometry<T>::toMesh(gsMesh<T> &, int) const
412 
413 template<class T>
414 typename gsGeometry<T>::uPtr
415 gsGeometry<T>::approximateLinearly() const
417 
418 template<class T>
421 
422 template<class T>
423 std::vector<gsGeometry<T> *> gsGeometry<T>::boundary() const
424 {
425  // TO DO: get boundary curves, using basis().boundary();
427 }
428 
429 template<class T>
431 {
433 }
434 
435 template<class T>
437 {
438  typename gsBasis<T>::uPtr b = m_basis->clone();
439  b->degreeElevate(i, dir);
440  gsMatrix<T> iVals, iPts = b->anchors();
441  this->eval_into(iPts, iVals);
442  typename gsGeometry<T>::uPtr g = b->interpolateData(iVals, iPts);
443 
444  std::swap(m_basis, g->m_basis);
445  g->coefs().swap(this->coefs());
446 }
447 
448 template<class T>
450 {
451  typename gsBasis<T>::uPtr b = m_basis->clone();
452  b->degreeReduce(i, dir);
453  gsMatrix<T> iVals, iPts = b->anchors();
454  this->eval_into(iPts, iVals);
455  typename gsGeometry<T>::uPtr g = b->interpolateData(iVals, iPts);
456 
457  std::swap(m_basis, g->m_basis);
458  g->coefs().swap(this->coefs());
459 }
460 
461 template<class T>
463 {
464  typename gsBasis<T>::uPtr b = m_basis->clone();
465  b->degreeIncrease(i, dir);
466  gsMatrix<T> iVals, iPts = b->anchors();
467  this->eval_into(iPts, iVals);
468  typename gsGeometry<T>::uPtr g = b->interpolateData(iVals, iPts);
469 
470  std::swap(m_basis, g->m_basis);
471  g->coefs().swap(this->coefs());
472 }
473 
474 template<class T>
476 {
477  typename gsBasis<T>::uPtr b = m_basis->clone();
478  b->degreeDecrease(i, dir);
479  gsMatrix<T> iVals, iPts = b->anchors();
480  this->eval_into(iPts, iVals);
481  typename gsGeometry<T>::uPtr g = b->interpolateData(iVals, iPts);
482 
483  std::swap(m_basis, g->m_basis);
484  g->coefs().swap(this->coefs());
485 }
486 
487 template<class T> void
489  index_t coord) const
490 {
491  const unsigned d = this->domainDim();
492  GISMO_ASSERT( coord<targetDim(),"Invalid coordinate function "<<coord);
493 
494  gsMatrix<T> B, tmp(d,d);
495  gsMatrix<index_t> ind;
496 
497  // coefficient matrix row k = coef. of basis function k
498  const gsMatrix<T>& C = this->m_coefs;
499  // col j = nonzero second derivatives at column point u(..,j)
500  m_basis->deriv2_into(u, B) ;
501  // col j = indices of active functions at column point u(..,j)
502  m_basis->active_into(u, ind);
503 
504  result.setZero(d,d);
505  static const index_t j = 0;// just one column
506  //for ( unsigned j=0; j< u.cols(); j++ ) // for all points (columns of u)
507 
508  for ( index_t i=0; i< ind.rows() ; i++ ) // for all non-zero basis functions)
509  {
510  unsigned r = i*d*(d+1)/2;
511  unsigned m = d;
512  //construct the Hessian of basis function ind(i,0)
513  for (unsigned k=0; k<d; ++k ) // for all rows
514  {
515  tmp(k,k) = B(r+k,j);
516  for (unsigned l=k+1; l<d; ++l ) // for all cols
517  tmp(k,l) = tmp(l,k) = B(r + m++,0);
518  }
519  result += C(ind(i,j), coord) * tmp;
520  }
521 }
522 
523 template<class T>
525 { basis().connectivity(m_coefs, mesh); }
526 
527 
528 
529 template <typename T>
530 void extractRows( const gsMatrix<T> &in, typename gsMatrix<index_t>::constColumn actives, gsMatrix<T> &out)
531 {
532  out.resize(actives.rows(), in.cols());
533  for (index_t r=0; r<actives.rows();++r)
534  out.row(r)=in.row(actives(r,0));
535 }
536 
537 template <class T>
538 void
539 gsGeometry<T>::compute(const gsMatrix<T> & in, gsFuncData<T> & out) const
540 {
541  const unsigned flags = out.flags | NEED_ACTIVE;
542  const index_t numPt = in.cols();
543  const index_t numCo = m_coefs.cols();
544 
545  gsFuncData<T> tmp(flags);
546  this->basis().compute(in, tmp);
547 
548  out.values.resize(out.maxDeriv()+1);
549  out.dim.first = tmp.dim.first;
550  out.dim.second = numCo;
551  if ( flags & SAME_ELEMENT )
552  {
553  gsMatrix<T> coefM;
554  extractRows(m_coefs,tmp.active(0),coefM);
555 
556  if (flags & NEED_VALUE)
557  out.values[0].noalias()=coefM.transpose()*tmp.values[0];
558  if (flags & NEED_DERIV)
559  {
560  const index_t derS = tmp.derivSize();
561  out.values[1].resize(derS*numCo,numPt);
562  for (index_t p=0; p< numPt; ++p)
563  out.values[1].reshapeCol(p, derS, numCo).noalias() = tmp.deriv(p)*coefM;
564  }
565  if (flags & NEED_DERIV2)
566  {
567  const index_t derS = tmp.deriv2Size();
568  out.values[2].resize(derS*numCo,numPt);
569  for (index_t p=0; p< numPt; ++p)
570  out.values[2].reshapeCol(p, derS, numCo).noalias() = tmp.deriv2(p)*coefM;
571  }
572  if (flags & NEED_ACTIVE)
573  this->active_into(in.col(0), out.actives);
574  }
575  else
576  {
577  gsMatrix<T> coefM;
578  const index_t derS = tmp.derivSize();
579  const index_t der2S = tmp.deriv2Size();
580 
581  if (flags & NEED_VALUE) out.values[0].resize(numCo,numPt);
582  if (flags & NEED_DERIV) out.values[1].resize(numCo*derS,numPt);
583  if (flags & NEED_DERIV2) out.values[2].resize(numCo*der2S,numPt);
584  if (flags & NEED_ACTIVE) this->active_into(in, out.actives);
585 
586  for (index_t p=0; p<numPt;++p)
587  {
588  extractRows(m_coefs,tmp.active(p),coefM);
589  if (flags & NEED_VALUE)
590  out.values[0].reshapeCol(p,1,numCo).noalias() = tmp.eval(p)*coefM;
591  if (flags & NEED_DERIV)
592  out.values[1].reshapeCol(p, derS, numCo).noalias() = tmp.deriv(p)*coefM;
593  if (flags & NEED_DERIV2)
594  out.values[2].reshapeCol(p, der2S, numCo).noalias() = tmp.deriv2(p)*coefM;
595  }
596  }
597 }
598 
599 template<class T>
601 {
603 }
604 
605 template<class T>
606 std::vector<boxSide> gsGeometry<T>::locateOn(const gsMatrix<T> & u, gsVector<bool> & onGeo, gsMatrix<T> & preIm, bool lookForBoundary, real_t tol) const
607 {
608  onGeo.resize(u.cols());
609  std::vector<boxSide> sides(u.cols());
610 
611  for(index_t i = 0; i < onGeo.size(); i++)
612  onGeo(i) = false;
613 
614  preIm.resize(geoDim(), u.cols());
615  gsMatrix<T> pr = this->parameterRange(), tmp;
616 
617  for(index_t i = 0; i < u.cols(); i++)
618  {
619  this->invertPoints(u.col(i), tmp, tol);
620  pr = this->parameterRange();
621  //if ((tmp.array() >= pr.col(0).array()).all()
622  // && (tmp.array() <= pr.col(1).array()).all())
623  if ((tmp.array() >= pr.col(0).array() - 1.e-4).all()
624  && (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
625  // the tolerance is due to imprecisions in the geometry map. E.g. If a circle is rotated then the corner need
626  // not to lie exactly on the interface of the neighbour patch since we use only B-splines for the modelling
627  // TODO: Maybe find a better solution!
628  {
629  onGeo(i) = true;
630  preIm.col(i) = tmp;
631 
632  if (lookForBoundary == true)
633  {
634  boxSide s;
635  for (int d = 0; d < geoDim(); d++) {
636  if ((math::abs(tmp(d, 0) - pr(d, 0)) < tol))
637  {
638  s.m_index = 2*d+1; // lower
639  break;
640  }
641 
642  if ((math::abs(tmp(d, 0) - pr(d, 1)) < tol))
643  {
644  s.m_index = 2 * d + 2; // upper
645  break;
646  }
647  }
648  sides[i] = s;
649  }
650  }
651  }
652 
653  return sides;
654 }
655 
656 
657 } // namespace gismo
virtual void compute(const gsMatrix< T > &in, gsFuncData< T > &out) const
Computes function data.
Definition: gsGeometry.hpp:539
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:606
virtual std::vector< gsGeometry< T > * > uniformSplit(index_t dir=-1) const
Definition: gsGeometry.hpp:280
gsGeometry()
Default constructor. Note: Derived constructors (except for the default) should assign m_basis to a v...
Definition: gsGeometry.h:111
void evaluateMesh(gsMesh< T > &mesh) const
Definition: gsGeometry.hpp:255
Abstract base class representing a geometry map.
Definition: gsGeometry.h:92
gsMatrix< T > m_coefs
Coefficient matrix of size coefsSize() x geoDim()
Definition: gsGeometry.h:624
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
void controlNet(gsMesh< T > &mesh) const
Return the control net of the geometry.
Definition: gsGeometry.hpp:524
#define GISMO_NO_IMPLEMENTATION
Definition: gsDebug.h:129
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
Gradient of the object.
Definition: gsForwardDeclarations.h:73
gsMatrix< T > parameterRange() const
Returns the range of parameters as a matrix with two columns, [lower upper].
Definition: gsGeometry.hpp:198
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
gsBasis< T > * m_basis
Pointer to the basis of this geometry.
Definition: gsGeometry.h:627
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:588
short_t domainDim() const
Dimension of the (source) domain.
Definition: gsGeometry.hpp:103
#define short_t
Definition: gsConfig.h:35
void outerNormal_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Computes the outer normals at parametric points u.
Definition: gsGeometry.hpp:419
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
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:436
short_t degree(const short_t &i) const
Returns the degree wrt direction i.
Definition: gsGeometry.hpp:333
Provides declaration of Basis abstract interface.
S give(S &x)
Definition: gsMemory.h:266
gsMatrix< T > eval(const gsMatrix< T > &u) const
Evaluate the function,.
Definition: gsFunctionSet.hpp:120
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:449
Second derivatives.
Definition: gsForwardDeclarations.h:80
#define index_t
Definition: gsConfig.h:32
A function from a n-dimensional domain to an m-dimensional image.
Definition: gsFunction.h:59
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 deriv_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate derivatives of the function at points u into result.
Definition: gsGeometry.hpp:76
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:462
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
virtual void insertKnot(T knot, index_t dir, index_t i=1)
Inserts knot knot at direction dir, i times.
Definition: gsGeometry.hpp:430
virtual void merge(gsGeometry *other)
Merge the given other geometry into this one.
Definition: gsGeometry.hpp:406
Squared distance function from a fixed point to a gsGeometry.
Definition: gsGeometry.hpp:31
Class Representing a triangle mesh with 3D vertices.
Definition: gsMesh.h:31
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:217
T at(index_t i) const
Returns the i-th element of the vectorization of the matrix.
Definition: gsMatrix.h:211
virtual std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition: gsGeometry.hpp:396
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
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:592
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 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
short_t coDim() const
Co-dimension of the geometric object.
Definition: gsGeometry.hpp:187
virtual short_t domainDim() const
Dimension d of the parameter domain (overriding gsFunction::domainDim()).
Definition: gsGeometry.hpp:184
std::vector< gsGeometry * > boundary() const
Get boundary of this geometry as a vector of new gsGeometry instances.
Definition: gsGeometry.hpp:423
Active function ids.
Definition: gsForwardDeclarations.h:84
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.
gsGeometrySlice is a class representing an iso parametric slice of a geometry object. It stores a pointer to the geometry object, which is only valid as long as this object is alive. Methods for printing to paraview are available in gsWriteToParaview.h
Definition: gsGeometrySlice.h:27
virtual void uniformRefine(int numKnots=1, int mul=1, int dir=-1)
Refine the geometry uniformly, inserting numKnots new knots into each knot span.
Definition: gsGeometry.hpp:306
T at(index_t i) const
Returns the i-th element of the vector.
Definition: gsVector.h:177
Struct which represents a certain side of a box.
Definition: gsBoundary.h:84
short_t parDim() const
Dimension d of the parameter domain (same as domainDim()).
Definition: gsGeometry.hpp:190
gsGeometry & operator=(const gsGeometry &o)
Definition: gsGeometry.hpp:202
Provides declaration of the Mesh class.
memory::unique_ptr< gsGeometry > uPtr
Unique pointer for gsGeometry.
Definition: gsGeometry.h:100
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
Enable optimizations based on the assumption that all evaluation points are in the same bezier domain...
Definition: gsForwardDeclarations.h:89
memory::unique_ptr< gsBasis > uPtr
Unique pointer for gsBasis.
Definition: gsBasis.h:89
Provides definition of the FuncCoordinate class.
T closestPointTo(const gsVector< T > &pt, gsVector< T > &result, const T accuracy=1e-6, const bool useInitialPoint=false) const
Definition: gsGeometry.hpp:339
short_t m_index
Index of the side.
Definition: gsBoundary.h:92
gsMatrix< T > support() const
Returns the range of parameters (same as parameterRange())
Definition: gsGeometry.hpp:193
Value of the object.
Definition: gsForwardDeclarations.h:72
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 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:475
Provides functions to generate structured point data.
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 targetDim() const
Dimension of the target space.
Definition: gsGeometry.hpp:104
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:580
EIGEN_STRONG_INLINE abs_expr< E > abs(const E &u)
Absolute value.
Definition: gsExpressions.h:4488
gsGeometry::uPtr component(boxComponent const &bc) const
Get parametrization of box component bc as a new gsGeometry uPtr.
Definition: gsGeometry.hpp:240
gsGeometrySlice< T > getIsoParametricSlice(index_t dir_fixed, T par) const
Definition: gsGeometry.hpp:286
Struct which represents an interface between two patches.
Definition: gsBoundary.h:649
virtual void hessian_into(const gsMatrix< T > &u, gsMatrix< T > &result, index_t coord) const
Definition: gsGeometry.hpp:488
virtual const gsBasis< T > & basis() const =0
Returns a const reference to the basis of the geometry.
This object is a cache for computed values from an evaluator.
size_t m_id
Definition: gsGeometry.h:631
Struct which represents a certain corner of a hyper-cube.
Definition: gsBoundary.h:291
T directedHausdorffDistance(const gsGeometry &other, const index_t nsamples=1000, const T accuracy=1e-6) const
Definition: gsGeometry.hpp:360
Provides declaration of the gsGeometrySlice class.
virtual void uniformCoarsen(int numKnots=1)
Coarsen the geometry uniformly, removing numKnots new knots into each knot span.
Definition: gsGeometry.hpp:312
gsMatrix< T > & coefs()
Definition: gsGeometry.h:340
Struct which represents a certain component (interior, face, egde, corner).
Definition: gsBoundary.h:445
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:584