G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsHFitting.h
Go to the documentation of this file.
1
14#pragma once
15
18#include <gsHSplines/gsHBox.h>
21
22namespace gismo {
23
33template <short_t d, class T>
34class gsHFitting : public gsFitting<T>
35{
36public:
37
39 typedef typename gsFitting<T>::tdm_method tdm_method;
40
41public:
44
54 gsHFitting(gsMatrix<T> const & param_values,
55 gsMatrix<T> const & points,
56 gsHTensorBasis<d,T> & basis,
57 T refin, const std::vector<unsigned> & extension,
58 T lambda = 0)
59 : gsFitting<T>(param_values, points, basis)
60 {
61 GISMO_ASSERT((refin >=0) && (refin <=1),
62 "Refinement percentage must be between 0 and 1." );
63 GISMO_ASSERT(extension.size() == d, "Extension is not of the right dimension");
64 GISMO_ASSERT( (gsAsConstVector<unsigned>(extension).array()>=0).all(),
65 "Extension must be a positive number.");
66
67 m_ref = refin; //how many % to refine
68
69 m_ext = extension;
70
71 m_lambda = lambda; // Smoothing parameter
72
74
75 m_pointErrors.reserve(m_param_values.cols());
76 }
77
78public:
79
89 void iterativeRefine(int iterations, T tolerance, T err_threshold = -1);
90
96 bool nextIteration(T tolerance, T err_threshold, index_t maxPcIter = 0);
97
102 bool nextIteration(T tolerance, T err_threshold,
103 const std::vector<boxSide>& fixedSides,
104 index_t maxPcIter = 0);
105
106
113 bool nextRefinement(T tolerance, T err_threshold, index_t maxPcIter = 0, bool admissibleRef = false);
114
119 bool nextRefinement(T tolerance, T err_threshold,
120 const std::vector<boxSide>& fixedSides,
121 index_t maxPcIter = 0,
122 bool admissibleRef = false);
123
131 bool nextIteration_tdm(T tolerance, T err_threshold, index_t maxPcIter, T mu, T sigma, const std::vector<index_t> & interpIdx, tdm_method method, bool admissibleRef = false);
132
137 bool nextIteration_tdm(T tolerance, T err_threshold,
138 const std::vector<boxSide>& fixedSides,
139 index_t maxPcIter,
140 T mu, T sigma,
141 const std::vector<index_t>& interpIdx,
142 tdm_method method,
143 bool admissibleRef);
144
152 bool nextIteration_pdm(T tolerance, T err_threshold, index_t maxPcIter, const std::vector<index_t> & interpIdx, bool admissibleRef = false);
153
158 bool nextIteration_pdm(T tolerance, T err_threshold,
159 const std::vector<boxSide>& fixedSides,
160 index_t maxPcIter,
161 const std::vector<index_t>& interpIdx,
162 bool admissibleRef);
163
166 {
167 return m_ref;
168 }
169
171 const std::vector<unsigned> & get_extension() const
172 {
173 return m_ext;
174 }
175
177 void setRefPercentage(double refPercent)
178 {
179 GISMO_ASSERT((refPercent >=0) && (refPercent <=1), "Invalid percentage" );
180 m_ref = refPercent;
181 }
182
184 void setExtension(std::vector<unsigned> const & extension)
185 {
186 GISMO_ASSERT( (gsAsConstVector<unsigned>(extension).array()>=0).all(),
187 "Extension must be a positive number.");
188 GISMO_ASSERT(extension.size()== static_cast<size_t>(this->m_basis.dim()),
189 "Error in dimension");
190 m_ext = extension;
191 }
192
194 std::vector<index_t> getBoxes(const std::vector<T>& errors,
195 const T threshold);
196
197protected:
199 virtual void appendBox(std::vector<index_t>& boxes,
200 std::vector<index_t>& cells,
201 const gsVector<T>& parameter);
202
204 T setRefineThreshold(const std::vector<T>& errors);
205
207 static bool isCellAlreadyInserted(const gsVector<index_t, d>& a_cell,
208 const std::vector<index_t>& cells);
209
211 static void append(std::vector<index_t>& boxes,
212 const gsVector<index_t>& box)
213 {
214 for (index_t col = 0; col != box.rows(); col++)
215 boxes.push_back(box[col]);
216 }
217
226 const std::vector<T>& errors,
227 const gsMatrix<T>& parameters,
228 T threshold,
229 T extension);
230
231protected:
232
235
238
240 std::vector<unsigned> m_ext;
241
243 using gsFitting<T>::m_points;
244 using gsFitting<T>::m_basis;
245 using gsFitting<T>::m_result;
246
247 using gsFitting<T>::m_pointErrors;
248 using gsFitting<T>::m_max_error;
249 using gsFitting<T>::m_min_error;
250};
251
252//perform one iterazion of adaptive refinement for PDM fitting, without boundary constraints
253template<short_t d, class T>
254bool gsHFitting<d, T>::nextIteration(T tolerance, T err_threshold,
255 index_t maxPcIter)
256{
257 std::vector<boxSide> dummy;
258 return nextIteration(tolerance, err_threshold, dummy, maxPcIter);
259}
260
261
262//perform one iterazion of adaptive refinement for HDM fitting with boundary constraints
263template<short_t d, class T>
264bool gsHFitting<d, T>::nextIteration_tdm(T tolerance, T err_threshold,
265 index_t maxPcIter, T mu, T sigma,
266 const std::vector<index_t>& interpIdx,
267 tdm_method method,
268 bool admissibleRef)
269{
270 std::vector<boxSide> dummy;
271 return nextIteration_tdm(tolerance, err_threshold, dummy, maxPcIter, mu, sigma, interpIdx, method, admissibleRef);
272}
273
274//perform one iterazion of adaptive refinement for PDM fitting with boundary constratints
275template<short_t d, class T>
276bool gsHFitting<d, T>::nextIteration_pdm(T tolerance, T err_threshold,
277 index_t maxPcIter,
278 const std::vector<index_t>& interpIdx,
279 bool admissibleRef)
280{
281 std::vector<boxSide> dummy;
282 return nextIteration_pdm(tolerance, err_threshold, dummy, maxPcIter, interpIdx, admissibleRef);
283}
284
285//One step of the refinement
286template<short_t d, class T>
287bool gsHFitting<d, T>::nextRefinement(T tolerance, T err_threshold, index_t maxPcIter, bool admissibleRef)
288{
289 std::vector<boxSide> dummy;
290 return nextRefinement(tolerance, err_threshold, dummy, maxPcIter, admissibleRef);
291}
292
293//perform one iterazion of adaptive refinement for PDM fitting, without boundary constraints
294template<short_t d, class T>
295bool gsHFitting<d, T>::nextIteration(T tolerance, T err_threshold,
296 const std::vector<boxSide>& fixedSides,
297 index_t maxPcIter)
298{
299 // INVARIANT
300 // look at iterativeRefine
301 if ( m_pointErrors.size() != 0 )
302 {
303
304 if ( m_max_error > tolerance )
305 {
306 // if err_treshold is -1 we refine the m_ref percent of the whole domain
307 T threshold = (err_threshold >= 0) ? err_threshold : setRefineThreshold(m_pointErrors);
308 std::vector<index_t> boxes = getBoxes(m_pointErrors, threshold);
309 if(boxes.size()==0)
310 return false;
311
312 gsHTensorBasis<d, T>* basis = static_cast<gsHTensorBasis<d,T> *> (this->m_basis);
313 basis->refineElements(boxes);
314
315 // If there are any fixed sides, prescribe the coefs in the finer basis.
316 if(m_result != NULL && fixedSides.size() > 0)
317 {
318 m_result->refineElements(boxes);
320 }
321 }
322 else
323 {
324 return false;
325 }
326 }
327
328 // SOLVE one fitting step and compute the errors
329 this->compute(m_lambda);
330
331 //parameter correction without boudary constraints
332 this->parameterCorrection(1e-7, maxPcIter, 1e-4);//closestPoint accuracy, orthogonality tolerance
333
334 // ESTIMATES the point-wise approximation error
335 this->computeErrors();
336
337 return true;
338}
339
340//perform one iterazion of adaptive refinement for PDM fitting with boundary constraints
341template<short_t d, class T>
342bool gsHFitting<d, T>::nextIteration_pdm(T tolerance, T err_threshold,
343 const std::vector<boxSide>& fixedSides,
344 index_t maxPcIter,
345 const std::vector<index_t>& interpIdx,
346 bool admissibleRef)
347{
348 // look at iterativeRefine
349 if ( m_pointErrors.size() != 0 )
350 {
351 if ( m_max_error > tolerance )
352 {
353 gsHBoxContainer<2> markedRef;
354 std::vector<index_t> boxes;
355
356 // if err_treshold is -1 we refine the m_ref percent of the whole domain
357 T threshold = (err_threshold >= 0) ? err_threshold : setRefineThreshold(m_pointErrors);
358
359 gsHTensorBasis<d, T>* basis = static_cast<gsHTensorBasis<d,T> *> (this->m_basis);
360
361 if (admissibleRef)
362 {
363 markedRef = getMarkedHBoxesFromBasis_max(*basis, m_pointErrors, m_param_values, threshold, 2.);
364 boxes = markedRef.toRefBoxes();
365 }
366 else
367 {
368 boxes = getBoxes(m_pointErrors, threshold);
369 }
370
371 if(boxes.size()==0)
372 return false;
373
374 basis->refineElements(boxes);
375 m_result->refineElements(boxes);
376
377 // If there are any fixed sides, prescribe the coefs in the finer basis.
378 if(m_result != NULL && fixedSides.size() > 0)
379 {
380 m_result->refineElements(boxes);
382 }
383 }
384 else
385 {
386 return false;
387 }
388 }
389
390 // SOLVE one PDM fitting step
391 this->compute(m_lambda);
392
393 //spply maxPcIter parameter correction steps separating interior and boundary points
394 this->parameterCorrectionSepBoundary_pdm(1e-6, maxPcIter,interpIdx);//closestPoint accuracy, orthogonality tolerance
395
396 // ESTIMATE the point-wise approximation error
397 this->computeErrors();
398
399 return true;
400}
401
402
403
404//perform one iterazion of adaptive refinement for HDM fitting with boundary constraints
405template<short_t d, class T>
406bool gsHFitting<d, T>::nextIteration_tdm(T tolerance, T err_threshold,
407 const std::vector<boxSide>& fixedSides,
408 index_t maxPcIter, T mu, T sigma,
409 const std::vector<index_t>& interpIdx,
410 tdm_method method,
411 bool admissibleRef)
412{
413 if ( m_pointErrors.size() != 0 )
414 {
415
416 gsHBoxContainer<2> markedRef;
417 std::vector<index_t> boxes;
418
419 if ( m_max_error > tolerance )
420 {
421 // if err_treshold is -1 we refine the m_ref percent of the whole domain
422 T threshold = (err_threshold >= 0) ? err_threshold : setRefineThreshold(m_pointErrors);
423
424 // MARK
425 gsHTensorBasis<d, T>* basis = static_cast<gsHTensorBasis<d,T> *> (this->m_basis);
426
427 // MARK-ADMISSIBLE
428 if (admissibleRef)
429 {
430 markedRef = getMarkedHBoxesFromBasis_max(*basis, m_pointErrors, m_param_values, threshold, 2.);
431 boxes = markedRef.toRefBoxes();
432 }
433 else
434 {
435 boxes = getBoxes(m_pointErrors, threshold);
436 }
437
438 if(boxes.size()==0)
439 return false;
440
441 basis->refineElements(boxes);
442 m_result->refineElements(boxes);
443
444 // If there are any fixed sides, prescribe the coefs in the finer basis.
445 if(m_result != NULL && fixedSides.size() > 0)
446 {
447 m_result->refineElements(boxes);
449 }
450 }
451 else
452 {
453 return false;
454 }
455 }
456
457 // SOLVE one HDM fitting step
458 this->compute_tdm(m_lambda, mu, sigma, interpIdx, method);
459
460
461 // apply maxPcIter parameter correction steps separating interior and boundary points
462 gsInfo << "Parameter correction: parameterCorrectionSepBoundary_tdm\n";
463 this->parameterCorrectionSepBoundary_tdm(1e-6, maxPcIter, mu, sigma, interpIdx, method); // refit
464
465 // ESTIMATE the point-wise approximation error
466 this->computeErrors();
467
468 return true;
469}
470
471//perform one iterazion of adaptive refinement for PDM fitting without boundary constraints
472template<short_t d, class T>
473bool gsHFitting<d, T>::nextRefinement(T tolerance, T err_threshold,
474 const std::vector<boxSide>& fixedSides,
475 index_t maxPcIter,
476 bool admissibleRef)
477{
478 // INVARIANT
479 // look at iterativeRefine
480 if ( m_pointErrors.size() != 0 )
481 {
482
483 if ( m_max_error > tolerance )
484 {
485 std::vector<index_t> boxes;
486 gsHBoxContainer<2> markedRef;
487 // if err_treshold is -1 we refine the m_ref percent of the whole domain
488 T threshold = (err_threshold >= 0) ? err_threshold : setRefineThreshold(m_pointErrors);
489
490 gsHTensorBasis<d, T>* basis = static_cast<gsHTensorBasis<d,T> *> (this->m_basis);
491
492 // MARK
493 if (admissibleRef)
494 {
495 markedRef = getMarkedHBoxesFromBasis_max(*basis, m_pointErrors, m_param_values, threshold, 2.);
496 boxes = markedRef.toRefBoxes();
497 }
498 else
499 {
500 boxes = getBoxes(m_pointErrors, threshold);
501 }
502
503 if(boxes.size()==0)
504 return false;
505
506 basis->refineElements(boxes);
507 m_result->refineElements(boxes);
508
509 if(m_result != NULL && fixedSides.size() > 0)
510 {
511 m_result->refineElements(boxes);
513 }
514 }
515 else
516 {
517 return false;
518 }
519 // const gsBasis<T> * bb = dynamic_cast<const gsBasis<T> *>(m_basis);
520 // m_result = bb->makeGeometry( give(this->m_result->coefs()) ).release();
521
522 }
523 else
524 {
525 this->compute(m_lambda);
526 }
527
528 this->parameterCorrection(1e-7, maxPcIter, 1e-4);
529 this->computeErrors();
530
531 return true;
532}
533
534
535// iteratively refine the basis
536template<short_t d, class T>
537void gsHFitting<d, T>::iterativeRefine(int numIterations, T tolerance, T err_threshold)
538{
539 // INVARIANT:
540 // m_pointErrors contains the point-wise errors of the fitting
541 // therefore: if the size of m_pointErrors is 0, there was no fitting up to this point
542
543 if ( m_pointErrors.size() == 0 )
544 {
545 this->compute(m_lambda);
546 this->computeErrors();
547 }
548
549 bool newIteration;
550 for( int i = 0; i < numIterations; i++ )
551 {
552 newIteration = nextIteration( tolerance, err_threshold );
553 if( m_max_error <= tolerance )
554 {
555 break;
556 }
557 if( !newIteration )
558 {
559 break;
560 }
561 }
562}
563
564// Returns boxes which define refinment area
565template <short_t d, class T>
566std::vector<index_t> gsHFitting<d, T>::getBoxes(const std::vector<T>& errors,
567 const T threshold)
568{
569 // cells contains lower corners of elements marked for refinment from maxLevel
570 std::vector<index_t> cells;
571
572 // boxes contains elements marked for refinement from differnet levels,
573 // format: { level lower-corners upper-corners ... }
574 std::vector<index_t> boxes;
575
576 for (size_t index = 0; index != errors.size(); index++)
577 {
578 if (threshold <= errors[index])
579 {
580 appendBox(boxes, cells, this->m_param_values.col(index));
581 }
582 }
583
584 return boxes;
585}
586
587// Appends a box around parameter to the boxes only if the box is not already in boxes
588template <short_t d, class T>
589void gsHFitting<d, T>::appendBox(std::vector<index_t>& boxes,
590 std::vector<index_t>& cells,
591 const gsVector<T>& parameter)
592{
593 gsTHBSplineBasis<d, T>* basis = static_cast< gsTHBSplineBasis<d,T>* > (this->m_basis);
594 const int maxLvl = basis->maxLevel();
595 const tensorBasis & tBasis = *(basis->getBases()[maxLvl]);
596
597 // get a cell
599
600 for (short_t dim = 0; dim != d; dim++)
601 {
602 const gsKnotVector<T> & kv = tBasis.component(dim).knots();
603 a_cell(dim) = kv.uFind(parameter(dim)).uIndex();
604 }
605
606 if (!isCellAlreadyInserted(a_cell, cells))
607 {
608 append(cells, a_cell);
609
610 // get level of a cell
611 gsVector<index_t, d> a_cell_upp = a_cell + gsVector<index_t, d>::Ones();
612 const int cell_lvl = basis->tree().query3(a_cell, a_cell_upp, maxLvl) + 1;
613
614 // get the box
615 gsVector<index_t> box(2 * d + 1);
616 box[0] = cell_lvl;
617 for (short_t dim = 0; dim != d; dim++)
618 {
619 const unsigned numBreaks = basis->numBreaks(cell_lvl, dim) - 1 ;
620
621 unsigned lowIndex = 0;
622 if (cell_lvl < maxLvl)
623 {
624 const unsigned shift = maxLvl - cell_lvl;
625 lowIndex = (a_cell(dim) >> shift);
626 }
627 else
628 {
629 const unsigned shift = cell_lvl - maxLvl;
630 lowIndex = (a_cell(dim) << shift);
631 }
632
633 // apply extensions
634 index_t low = ( (lowIndex > m_ext[dim]) ? (lowIndex - m_ext[dim]) : 0 );
635 index_t upp = ( (lowIndex + m_ext[dim] + 1 < numBreaks) ?
636 (lowIndex + m_ext[dim] + 1) : numBreaks );
637
638 box[1 + dim ] = low;
639 box[1 + d + dim] = upp;
640 }
641
642 append(boxes, box);
643 }
644}
645
646// Check if a cell is already inserted in (the refinement) container of cells
647template <short_t d, class T>
649 const std::vector<index_t>& cells)
650{
651
652 for (size_t i = 0; i != cells.size(); i += a_cell.rows())
653 {
654 index_t commonEntries = 0;
655 for (index_t col = 0; col != a_cell.rows(); col++)
656 {
657 if (cells[i + col] == a_cell[col])
658 {
659 commonEntries++;
660 }
661 }
662
663 if (commonEntries == a_cell.rows())
664 {
665 return true;
666 }
667 }
668
669 return false;
670}
671
672// Automatic set of the refinement threshold
673template<short_t d, class T>
674T gsHFitting<d, T>::setRefineThreshold(const std::vector<T>& errors )
675{
676 std::vector<T> errorsCopy = errors;
677 const size_t i = cast<T,size_t>(errorsCopy.size() * (1.0 - m_ref));
678 typename std::vector<T>::iterator pos = errorsCopy.begin() + i;
679 std::nth_element(errorsCopy.begin(), pos, errorsCopy.end());
680 return *pos;
681}
682
683
684// Check if a point is inside a cell
685template <class T>
686bool is_point_inside_cell(const gsMatrix<T>& parameter,
687 const gsMatrix<T>& element)
688{
689 const real_t x = parameter(0, 0);
690 const real_t y = parameter(1, 0);
691
692 return element(0, 0) <= x && x < element(0, 1) &&
693 element(1, 0) <= y && y < element(1, 1);
694}
695
696// Check if a point is inside a cell
697template <class T>
698bool is_point_inside_cell(const T x,
699 const T y,
700 const gsMatrix<T>& element)
701{
702 bool condition = (element(0, 0) <= x && x <= element(0, 1) && element(1, 0) <= y && y <= element(1, 1));
703 return condition;
704}
705
706
707// Returns the maximum error at the parameters inside the a cell
708template<class T>
709T getCellMaxError(const gsMatrix<T>& a_cell,
710 const std::vector<T>& errors,
711 const gsMatrix<T>& parameters){
712
713 std::vector<T> a_cellErrs;
714 T cell_max_err = 0;
715 for(index_t it=0; it < parameters.cols(); it++){
716 const T xx = parameters.col(it)(0);
717 const T yy = parameters.col(it)(1);
718 if (is_point_inside_cell(xx, yy, a_cell))
719 {
720 a_cellErrs.push_back(errors[it]);
721 }
722 }
723
724 for(typename std::vector<T>::iterator errIt = a_cellErrs.begin(); errIt != a_cellErrs.end(); ++errIt){
725 if (*errIt > cell_max_err){
726 cell_max_err = *errIt;
727 }
728 }
729 return cell_max_err;
730}
731
732// returns the markd cells to refine admissibiliy.
733template <short_t d, class T>
735 const std::vector<T>& errors,
736 const gsMatrix<T>& parameters,
737 T threshold,
738 T extension)
739{
740 gsHBoxContainer<d> markedHBoxes;
741 typename gsHTensorBasis<d, T>::domainIter domIt = basis.makeDomainIterator();
742 for (; domIt->good(); domIt->next() ) // loop over all elements
743 {
744 gsMatrix<T> elMatrix(d,d);
745 elMatrix.col(0)<< domIt->lowerCorner(); // first column = lower corner
746 elMatrix.col(1)<< domIt->upperCorner(); // second column = upper corner
747 T cellMaxError = getCellMaxError(elMatrix, errors, parameters);
748 if (cellMaxError >= threshold)
749 {
750 gsHDomainIterator<T,d> * domHIt = nullptr;
751 domHIt = dynamic_cast<gsHDomainIterator<T,2> *>(domIt.get());
752 gsHBox<d> a_box(domHIt);
754 markedHBoxes.add(tmp);
755 }
756 }
757 return markedHBoxes;
758}
759
760}// namespace gismo
761
762// #ifndef GISMO_BUILD_LIB
763// #include GISMO_HPP_HEADER(gsFitting.hpp)
764// #endif
Creates a mapped object or data pointer to a const vector without copying data.
Definition gsAsMatrix.h:285
Class for performing a fit of a parametrized point cloud with a gsGeometry.
Definition gsFitting.h:32
gsMatrix< T > m_param_values
the parameter values of the point cloud
Definition gsFitting.h:345
tdm_method
choose the method for computing the coefficients: TDM, PDM, HDM with different blending weights
Definition gsFitting.h:81
gsGeometry< T > * m_result
Pointer keeping the resulting geometry.
Definition gsFitting.h:357
T m_max_error
Maximum point-wise error.
Definition gsFitting.h:371
gsFunctionSet< T > * m_basis
Pointer keeping the basis.
Definition gsFitting.h:354
void setConstraints(const gsSparseMatrix< T > &lhs, const gsMatrix< T > &rhs)
Definition gsFitting.h:272
T m_min_error
Minimum point-wise error.
Definition gsFitting.h:374
T lambda() const
Returns the smoothing weight used in the last fitting.
Definition gsFitting.h:310
gsMatrix< T > m_points
the points of the point cloud
Definition gsFitting.h:348
The Hierarchical Box Container provides a container for gsHBox objects.
Definition gsHBoxContainer.h:40
void add(const gsHBox< d, T > &box)
Adds a single box.
Definition gsHBoxContainer.hpp:121
RefBox toRefBoxes(const index_t patchID=-1) const
Returns refinement box representation of the object.
Definition gsHBoxContainer.hpp:374
This class provides a Hierarchical Box (gsHBox)
Definition gsHBox.h:55
Re-implements gsDomainIterator for iteration over all boundary elements of a hierarchical parameter d...
Definition gsHDomainIterator.h:39
This class applies hierarchical fitting of parametrized point clouds.
Definition gsHFitting.h:35
void setExtension(std::vector< unsigned > const &extension)
Sets the cell extension.
Definition gsHFitting.h:184
T m_ref
How many % to refine - 0-1 interval.
Definition gsHFitting.h:234
bool nextIteration_tdm(T tolerance, T err_threshold, index_t maxPcIter, T mu, T sigma, const std::vector< index_t > &interpIdx, tdm_method method, bool admissibleRef=false)
nextIteration_tdm: perform one iterazion of adaptive refinement with HDM fitting and with boundary co...
Definition gsHFitting.h:264
T setRefineThreshold(const std::vector< T > &errors)
Automatic set the refinement threshold.
Definition gsHFitting.h:674
std::vector< unsigned > m_ext
Size of the extension.
Definition gsHFitting.h:240
bool nextRefinement(T tolerance, T err_threshold, index_t maxPcIter=0, bool admissibleRef=false)
nextRefinement: One step of the refinement of iterativeRefine;
Definition gsHFitting.h:287
gsHFitting()
Default constructor.
void iterativeRefine(int iterations, T tolerance, T err_threshold=-1)
iterativeRefine: iteratively refine the basis
Definition gsHFitting.h:537
gsHBoxContainer< d > getMarkedHBoxesFromBasis_max(const gsHTensorBasis< d, T > &basis, const std::vector< T > &errors, const gsMatrix< T > &parameters, T threshold, T extension)
getMarkedHBoxesFromBasis_max: returns the markd cells to refine admissibiliy.
Definition gsHFitting.h:734
gsHFitting(gsMatrix< T > const &param_values, gsMatrix< T > const &points, gsHTensorBasis< d, T > &basis, T refin, const std::vector< unsigned > &extension, T lambda=0)
gsHFitting: Main constructor of the h-fitting class
Definition gsHFitting.h:54
void setRefPercentage(double refPercent)
Sets the refinement percentage.
Definition gsHFitting.h:177
std::vector< index_t > getBoxes(const std::vector< T > &errors, const T threshold)
Returns boxes which define refinment area.
Definition gsHFitting.h:566
static bool isCellAlreadyInserted(const gsVector< index_t, d > &a_cell, const std::vector< index_t > &cells)
Checks if a_cell is already inserted in container cells.
Definition gsHFitting.h:648
T m_lambda
Smoothing parameter.
Definition gsHFitting.h:237
static void append(std::vector< index_t > &boxes, const gsVector< index_t > &box)
Appends a box to the end of boxes (This function also works for cells)
Definition gsHFitting.h:211
const std::vector< unsigned > & get_extension() const
Returns the chosen cell extension.
Definition gsHFitting.h:171
bool nextIteration_pdm(T tolerance, T err_threshold, index_t maxPcIter, const std::vector< index_t > &interpIdx, bool admissibleRef=false)
nextIteration_pdm: perform one iterazion of adaptive refinement with PDM fitting and with boundary co...
Definition gsHFitting.h:276
bool nextIteration(T tolerance, T err_threshold, index_t maxPcIter=0)
nextIteration: perform one iterazion of adaptive refinement with PDM fitting without boundary constra...
Definition gsHFitting.h:254
T getRefPercentage() const
Return the refinement percentage.
Definition gsHFitting.h:165
virtual void appendBox(std::vector< index_t > &boxes, std::vector< index_t > &cells, const gsVector< T > &parameter)
Appends a box around parameter to the boxes only if the box is not already in boxes.
Definition gsHFitting.h:589
Class representing a (scalar) hierarchical tensor basis of functions .
Definition gsHTensorBasis.h:75
Class for representing a knot vector.
Definition gsKnotVector.h:80
uiterator uFind(const T u) const
Returns the uiterator pointing to the knot at the beginning of the knot interval containing u....
Definition gsKnotVector.hpp:747
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
Truncated hierarchical B-spline basis.
Definition gsTHBSplineBasis.h:36
A tensor product B-spline basis.
Definition gsTensorBSplineBasis.h:37
const Basis_t & component(short_t dir) const
For a tensor product basis, return the (const) 1-d basis for the i-th parameter component.
Definition gsTensorBSplineBasis.h:202
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
#define short_t
Definition gsConfig.h:35
#define index_t
Definition gsConfig.h:32
#define gsInfo
Definition gsDebug.h:43
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
Provides declaration of data fitting algorithms by least squares approximation.
Provides a container for gsHBox.
Provides utility functions for gsHBox and gsHBoxContainer.
Provides gsHBox: smart boxes for HTensorBases.
Provides definition of HTensorBasis abstract interface.
The G+Smo namespace, containing all definitions for the library.
GISMO_DEPRECATED bool parameter(int s)
Returns the parameter value (false=0=start, true=1=end) that corresponds to side s.
Definition gsBoundary.h:1069
The gsHBoxUtils provide basic utilities to modify HBoxes.
Definition gsHBoxUtils.h:46