G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsHBoxUtils.hpp
Go to the documentation of this file.
1 
14 #pragma once
15 #include <gsHSplines/gsHBox.h>
18 
19 namespace gismo {
20 
21 template <short_t d, class T>
22 typename gsHBox<d, T>::SortedContainer gsHBoxUtils<d,T>::Sort(const Container & container)
23 {
24  SortedContainer scontainer(container.begin(), container.end());
25 
26  // First sort (otherwise unique is wrong)
27  std::sort(scontainer.begin(),scontainer.end(),gsHBoxCompare<d,T>());
28 
29  return scontainer;
30 }
31 
32 template <short_t d, class T>
33 typename gsHBox<d, T>::Container gsHBoxUtils<d,T>::Unique(const Container & container)
34 {
35  SortedContainer scontainer = gsHBoxUtils<d,T>::Sort(container);
36 
37  // Get unique entries
38  typename SortedContainer::iterator it = std::unique(scontainer.begin(),scontainer.end(),gsHBoxEqual<d,T>());
39  scontainer.resize(std::distance(scontainer.begin(), it));
40  Container result(scontainer.begin(),scontainer.end());
41  return result;
42 }
43 
44 template <short_t d, class T>
45 typename gsHBox<d, T>::HContainer gsHBoxUtils<d,T>::Unique(const HContainer & container)
46 {
47  HContainer result(container.size());
48  for (size_t k=0; k!=container.size(); k++)
49  result[k] = gsHBoxUtils<d,T>::Unique(container[k]);
50  return result;
51 }
52 
53 template <short_t d, class T>
54 gsHBoxContainer<d, T> gsHBoxUtils<d,T>::Unique(const gsHBoxContainer<d,T> & container)
55 {
56  HContainer result = gsHBoxUtils<d,T>::Unique(container.boxes());
57  return gsHBoxContainer<d,T>(result);
58 }
59 
60 template <short_t d, class T>
61 typename gsHBox<d, T>::Container gsHBoxUtils<d,T>::Union(const Container & container1, const Container & container2)
62 {
63  SortedContainer sortedResult;
64 
65  SortedContainer scontainer1 = gsHBoxUtils<d,T>::Sort(container1);
66  SortedContainer scontainer2 = gsHBoxUtils<d,T>::Sort(container2);
67 
68  sortedResult.reserve(scontainer1.size() + scontainer2.size());
69  if (scontainer1.size()!=0 && scontainer2.size()!=0)
70  {
71  std::set_union( scontainer1.begin(),scontainer1.end(),
72  scontainer2.begin(),scontainer2.end(),
73  std::inserter(sortedResult,sortedResult.begin()),
74  gsHBoxCompare<d,T>());
75  }
76  else if (scontainer1.size()!=0 && container2.size()==0)
77  sortedResult.insert(sortedResult.end(),scontainer1.begin(),scontainer1.end());
78  else if (scontainer1.size()==0 && container2.size()!=0)
79  sortedResult.insert(sortedResult.end(),scontainer2.begin(),scontainer2.end());
80  else { /* Do nothing */ }
81 
82  Container result(sortedResult.begin(),sortedResult.end());
83 
84  return result;
85 }
86 
87 template <short_t d, class T>
88 typename gsHBox<d, T>::HContainer gsHBoxUtils<d,T>::Union(const HContainer & container1, const HContainer & container2)
89 {
90  HContainer result, region1, region2;
91 
92  region1 = container1;
93  region2 = container2;
94 
95  index_t lmax = std::max(region1.size(),region2.size());
96  region1.resize(lmax);
97  region2.resize(lmax);
98  result.resize(lmax);
99 
100  for (index_t l = 0; l!=lmax; l++)
101  result[l] = gsHBoxUtils<d,T>::Union(region1[l],region2[l]);
102 
103  return result;
104 }
105 
106 template <short_t d, class T>
107 gsHBoxContainer<d, T> gsHBoxUtils<d,T>::Union(const gsHBoxContainer<d,T> & container1, const gsHBoxContainer<d,T> & container2)
108 {
109  HContainer result;
110  HContainer region1(container1.boxes());
111  HContainer region2(container2.boxes());
112 
113  index_t lmax = std::max(region1.size(),region2.size());
114  region1.resize(lmax);
115  region2.resize(lmax);
116  result.resize(lmax);
117 
118  for (index_t l = 0; l!=lmax; l++)
119  result[l] = gsHBoxUtils<d,T>::Union(region1[l],region2[l]);
120 
121  return gsHBoxContainer<d,T>(result);
122 }
123 
124 // Takes the difference container1 \ container2
125 template <short_t d, class T>
126 typename gsHBox<d, T>::Container gsHBoxUtils<d,T>::Difference(const Container & container1, const Container & container2)
127 {
128  SortedContainer sortedResult;
129 
130  SortedContainer scontainer1 = gsHBoxUtils<d,T>::Sort(container1);
131  SortedContainer scontainer2 = gsHBoxUtils<d,T>::Sort(container2);
132 
133  sortedResult.reserve(scontainer1.size());
134  // if (scontainer1.size()!=0 && scontainer2.size()!=0)
135  // {
136  std::set_difference(scontainer1.begin(),scontainer1.end(),
137  scontainer2.begin(),scontainer2.end(),
138  std::inserter(sortedResult,sortedResult.begin()),
139  gsHBoxCompare<d,T>());
140  // }
141  // else if (scontainer1.size()!=0 && container2.size()==0)
142  // sortedResult.insert(sortedResult.end(),scontainer1.begin(),scontainer1.end());
143  // else if (scontainer1.size()==0 && container2.size()!=0)
144  // sortedResult.insert(sortedResult.end(),scontainer2.begin(),scontainer2.end());
145  // else { /* Do nothing */ }
146 
147  Container result(sortedResult.begin(),sortedResult.end());
148 
149  // Container result;
150 
151  // bool intersects;
152  // for (cIterator it1=container1.begin(); it1!=container1.end(); it1++)
153  // for (cIterator it2=container2.begin(); it2!=container2.end(); it2++)
154  // {
155  // intersects = it1->contains(*it2) || it2->contains(*it1);
156  // if (!intersects)
157  // result.push_back(*it1);
158  // else
159  // {}
160  // }
161 
162  return result;
163 }
164 
165 template <short_t d, class T>
166 typename gsHBox<d, T>::HContainer gsHBoxUtils<d,T>::Difference(const HContainer & container1, const HContainer & container2)
167 {
168  HContainer result, region1, region2;
169 
170  region1 = container1;
171  region2 = container2;
172 
173  index_t lmax = std::max(region1.size(),region2.size());
174  region1.resize(lmax);
175  region2.resize(lmax);
176  result.resize(lmax);
177 
178  for (index_t l = 0; l!=lmax; l++)
179  result[l] = gsHBoxUtils<d,T>::Difference(region1[l],region2[l]);
180 
181  return result;
182 }
183 
184 template <short_t d, class T>
185 gsHBoxContainer<d, T> gsHBoxUtils<d,T>::Difference(const gsHBoxContainer<d,T> & container1, const gsHBoxContainer<d,T> & container2)
186 {
187  HContainer result;
188  HContainer region1(container1.boxes());
189  HContainer region2(container2.boxes());
190 
191  index_t lmax = std::max(region1.size(),region2.size());
192  region1.resize(lmax);
193  region2.resize(lmax);
194  result.resize(lmax);
195 
196  for (index_t l = 0; l!=lmax; l++)
197  result[l] = gsHBoxUtils<d,T>::Difference(region1[l],region2[l]);
198 
199  return gsHBoxContainer<d,T>(result);
200 }
201 
213 template <short_t d, class T>
214 typename gsHBox<d, T>::Container gsHBoxUtils<d,T>::Intersection(const Container & container1, const Container & container2)
215 {
216  Container result;
217 
218  bool b1in2, b2in1;
219  for (cIterator it1=container1.begin(); it1!=container1.end(); it1++)
220  for (cIterator it2=container2.begin(); it2!=container2.end(); it2++)
221  {
222  b1in2 = it1->contains(*it2);
223  b2in1 = it2->contains(*it1);
224 
225  if (b1in2 && b2in1)
226  result.push_back(*it1);
227  else if (b1in2 && !b2in1)
228  result.push_back(*it2);
229  else if (!b1in2 && b2in1)
230  result.push_back(*it1);
231  else
232  {}
233  // continue;
234  // GISMO_ERROR("Something went wrong");
235  }
236 
237  return result;
238 }
239 
240 template <short_t d, class T>
241 typename gsHBox<d, T>::Container gsHBoxUtils<d,T>::ContainedIntersection(const Container & container1, const Container & container2)
242 {
243  Container result;
244 
245  bool b1in2;
246  for (cIterator it1=container1.begin(); it1!=container1.end(); it1++)
247  for (cIterator it2=container2.begin(); it2!=container2.end(); it2++)
248  {
249  b1in2 = it1->contains(*it2);
250 
251  if (b1in2)
252  result.push_back(*it2);
253  else
254  {}
255  }
256 
257  return result;
258 }
259 
260 
272 template <short_t d, class T>
273 typename gsHBox<d, T>::Container gsHBoxUtils<d,T>::ExactIntersection(const Container & container1, const Container & container2)
274 {
275  SortedContainer sortedResult;
276 
277  SortedContainer scontainer1 = gsHBoxUtils<d,T>::Sort(container1);
278  SortedContainer scontainer2 = gsHBoxUtils<d,T>::Sort(container2);
279 
280  sortedResult.reserve(scontainer1.size());
281  // if (scontainer1.size()!=0 && scontainer2.size()!=0)
282  // {
283  std::set_intersection( scontainer1.begin(),scontainer1.end(),
284  scontainer2.begin(),scontainer2.end(),
285  std::inserter(sortedResult,sortedResult.begin()),
286  gsHBoxCompare<d,T>());
287  // }
288  // else if (scontainer1.size()!=0 && container2.size()==0)
289  // sortedResult.insert(sortedResult.end(),scontainer1.begin(),scontainer1.end());
290  // else if (scontainer1.size()==0 && container2.size()!=0)
291  // sortedResult.insert(sortedResult.end(),scontainer2.begin(),scontainer2.end());
292  // else { /* Do nothing */ }
293 
294  Container result(sortedResult.begin(),sortedResult.end());
295  return result;
296 }
297 
298 // template <short_t d, class T>
299 // typename gsHBox<d, T>::Container gsHBoxUtils<d,T>::gsHBoxIntersection(const gsHBox<d,T> & box1, const gsHBox<d,T> & box2)
300 // {
301 // Container result, container1, container2;
302 
303 // container1 = box1.toUnitBoxes();
304 // container2 = box2.toUnitBoxes();
305 
306 // bool b1in2, b2in1;
307 // for (cIterator it1=container1.begin(); it1!=container1.end(); it1++)
308 // for (cIterator it2=container2.begin(); it2!=container2.end(); it2++)
309 // {
310 // bool b1in2 = it1->contains(*it2);
311 // bool b2in1 = it2->contains(*it1);
312 
313 // if (b1in2 && b2in1)
314 // result.push_back(*it1);
315 // else if (b1in2 && !b2in1)
316 // result.push_back(*it1);
317 // else if (!b1in2 && b2in1)
318 // result.push_back(*it2);
319 // else
320 // GISMO_ERROR("Something went wrong");
321 // }
322 
323 // return result;
324 // }
325 
326 template <short_t d, class T>
327 typename gsHBox<d,T>::Container gsHBoxUtils<d,T>::HContainer2Container( const HContainer & container )
328 {
329  Container result;
330  for (cHIterator hit = container.begin(); hit!=container.end(); hit++)
331  for (cIterator it=hit->begin(); it!=hit->end(); it++)
332  result.push_back(*it);
333 
334  return result;
335 }
336 
337 template <short_t d, class T>
338 typename gsHBox<d,T>::HContainer gsHBoxUtils<d,T>::Container2HContainer( const Container & container )
339 {
340  HContainer result(1);
341  for (cIterator it=container.begin(); it!=container.end(); it++)
342  {
343  if (result.size() < static_cast<unsigned>(it->level() + 1))
344  result.resize(it->level()+1);
345 
346  result[it->level()].push_back(*it);
347  }
348  return result;
349 }
350 
351 template <short_t d, class T>
352 typename gsHBox<d,T>::Container gsHBoxUtils<d, T>::toContainer(const HContainer & container)
353 {
354  Container result;
355 
356  for (cHIterator hit = container.begin(); hit!=container.end(); hit++)
357  for (cIterator it = hit->begin(); it!=hit->end(); it++)
358  {
359  result.push_back(*it);
360  }
361 
362  return result;
363 }
364 
365 template <short_t d, class T>
366 typename gsHBox<d,T>::Container gsHBoxUtils<d, T>::toUnitBoxes(const HContainer & container)
367 {
368  Container result;
369  Container boxes;
370 
371  for (cHIterator hit = container.begin(); hit!=container.end(); hit++)
372  for (cIterator it = hit->begin(); it!=hit->end(); it++)
373  {
374  boxes = it->toUnitBoxes();
375  for (cIterator boxIt = boxes.begin(); boxIt != boxes.end(); boxIt++)
376  result.push_back(*boxIt);
377  }
378 
379  return result;
380 }
381 
382 template <short_t d, class T>
383 typename gsHBox<d,T>::HContainer gsHBoxUtils<d, T>::toUnitHBoxes(const HContainer & container)
384 {
385  HContainer result(container.size());
386  HIterator resIt = result.begin();
387  Container boxes;
388 
389  for (cHIterator hit = container.begin(); hit!=container.end(); hit++, resIt++)
390  for (cIterator it = hit->begin(); it!=hit->end(); it++)
391  {
392  boxes = it->toUnitBoxes();
393  for (cIterator boxIt = boxes.begin(); boxIt != boxes.end(); boxIt++)
394  resIt->push_back(*boxIt);
395  }
396 
397  return result;
398 }
399 
400 template <short_t d, class T>
401 typename gsHBoxUtils<d,T>::HContainer gsHBoxUtils<d, T>::markTadmissible(const HContainer & marked, index_t m)
402 {
403  return gsHBoxUtils<d,T>::markAdmissible<gsHNeighborhood::T>(marked,m);
404 }
405 
406 template <short_t d, class T>
407 typename gsHBoxUtils<d,T>::HContainer gsHBoxUtils<d, T>::markTadmissible(const gsHBox<d,T> & marked, index_t m)
408 {
409  return gsHBoxUtils<d,T>::markAdmissible<gsHNeighborhood::T>(marked,m);
410 }
411 
412 
413 template <short_t d, class T>
414 typename gsHBoxUtils<d,T>::HContainer gsHBoxUtils<d, T>::markHadmissible(const HContainer & marked, index_t m)
415 {
416  return gsHBoxUtils<d,T>::markAdmissible<gsHNeighborhood::H>(marked,m);
417 }
418 
419 template <short_t d, class T>
420 typename gsHBoxUtils<d,T>::HContainer gsHBoxUtils<d, T>::markHadmissible(const gsHBox<d,T> & marked, index_t m)
421 {
422  return gsHBoxUtils<d,T>::markAdmissible<gsHNeighborhood::H>(marked,m);
423 }
424 
425 
426 template <short_t d, class T>
427 template<gsHNeighborhood _mode>
428 typename std::enable_if<_mode==gsHNeighborhood::T || _mode==gsHNeighborhood::H, typename gsHBoxUtils<d, T>::HContainer>::type
429 gsHBoxUtils<d, T>::_markRecursive(const HContainer & marked, index_t lvl, index_t m)
430 {
431  HContainer marked_copy = marked;
432  Container marked_l = marked[lvl];
433  Container marked_k;
434 
435  gsHBoxContainer<d,T> neighbors;
436  for (Iterator it = marked_l.begin(); it!=marked_l.end(); it++)
437  {
438  neighbors.add(it->template getNeighborhood<_mode>(m));
439  }
440 
441  index_t k = lvl - m + 1;
442  if (neighbors.boxes().size()!=0)
443  {
444  marked_k = marked_copy[k];
445  gsHBoxContainer<d,T> boxUnion = gsHBoxUtils<d,T>::Union(neighbors,gsHBoxContainer<d,T>(marked_k));
446  marked_copy[k] = boxUnion.getActivesOnLevel(k);
447  marked_copy = gsHBoxUtils<d,T>::_markRecursive<_mode>(marked_copy,k,m);
448  }
449  return marked_copy;
450 }
451 
452 template <short_t d, class T>
453 template<gsHNeighborhood _mode>
454 typename std::enable_if<_mode!=gsHNeighborhood::T && _mode!=gsHNeighborhood::H, typename gsHBoxUtils<d, T>::HContainer>::type
455 gsHBoxUtils<d, T>::_markRecursive(const HContainer & marked, index_t lvl, index_t m)
456 {
457  GISMO_ERROR("Mode must be T or H");
458 }
459 
460 template <short_t d, class T>
461 template<gsHNeighborhood _mode>
462 typename gsHBoxUtils<d,T>::HContainer gsHBoxUtils<d, T>::markAdmissible(const HContainer & marked, index_t m)
463 {
464  HContainer unitBoxes = gsHBoxUtils<d,T>::toUnitHBoxes(marked);
465  for (size_t l = 0; l!=unitBoxes.size(); l++)
466  unitBoxes = gsHBoxUtils<d,T>::_markRecursive<_mode>(unitBoxes,l,m);
467 
468  unitBoxes = gsHBoxUtils<d,T>::Unique(unitBoxes);
469  return unitBoxes;
470 }
471 
472 template <short_t d, class T>
473 template<gsHNeighborhood _mode>
474 typename gsHBoxUtils<d,T>::HContainer gsHBoxUtils<d, T>::markAdmissible(const gsHBox<d,T> & marked, index_t m)
475 {
476  HContainer unitBoxes = gsHBoxUtils<d,T>::Container2HContainer(marked.toUnitBoxes());
477  return gsHBoxUtils<d,T>::markAdmissible<_mode>(unitBoxes,m);
478 }
479 
480 // template <short_t d, class T>
481 // typename gsHBoxUtils<d,T>::HContainer gsHBoxUtils<d, T>::markAdmissible(const gsHBox<d,T> & marked, index_t m)
482 // {
483 // HContainer result;
484 // if (dynamic_cast<const gsTHBSplineBasis<d,T>*>(marked.basis()))
485 // result = gsHBoxUtils<d,T>::getNeighborhood<gsHNeighborhood::T>(m);
486 // else if (dynamic_cast<const gsHBSplineBasis<d,T>*>(marked.basis()))
487 // result = gsHBoxUtils<d,T>::getNeighborhood<gsHNeighborhood::T>(m);
488 // else
489 // GISMO_ERROR("Basis type should be gsTHBSplineBasis or gsHBSplineBasis");
490 // return result;
491 // }
492 
493 template <short_t d, class T>
494 typename gsHBoxUtils<d,T>::HContainer gsHBoxUtils<d, T>::markAdmissible(const HContainer & marked, index_t m)
495 {
496  gsHNeighborhood NHtype = gsHNeighborhood::None;
497  // Find the basis type of the neighborhood in the first non-empty level
498  for (cHIterator hit = marked.begin(); hit!=marked.end(); hit++)
499  {
500  if (hit->size()!=0)
501  {
502  NHtype = gsHBoxUtils<d,T>::neighborhoodType(hit->front());
503  break;
504  }
505  }
506 
507  HContainer result;
508  if (NHtype==gsHNeighborhood::T)
509  result = gsHBoxUtils<d,T>::markAdmissible<gsHNeighborhood::T>(marked,m);
510  else if (NHtype==gsHNeighborhood::H)
511  result = gsHBoxUtils<d,T>::markAdmissible<gsHNeighborhood::H>(marked,m);
512  else
513  GISMO_ERROR("Basis type should be gsTHBSplineBasis or gsHBSplineBasis");
514  return result;
515 }
516 
517 template <short_t d, class T>
518 typename gsHBoxUtils<d,T>::HContainer gsHBoxUtils<d, T>::markAdmissible(const gsHBox<d,T> & marked, index_t m)
519 {
520  HContainer result;
521  if (dynamic_cast<const gsTHBSplineBasis<d,T>*>(&marked.basis()))
522  result = gsHBoxUtils<d,T>::markAdmissible<gsHNeighborhood::T>(marked,m);
523  else if (dynamic_cast<const gsHBSplineBasis<d,T>*>(&marked.basis()))
524  result = gsHBoxUtils<d,T>::markAdmissible<gsHNeighborhood::H>(marked,m);
525  else
526  GISMO_ERROR("Basis type should be gsTHBSplineBasis or gsHBSplineBasis");
527  return result;
528 }
529 
530 template <short_t d, class T>
531 bool gsHBoxUtils<d, T>::allActive(const Container & elements)
532 {
533  bool check = true;
534  for (cIterator it=elements.begin(); it!=elements.end() && check; it++)
535  {
536  check &= it->isActive();
537  }
538  return check;
539 }
540 
541 template <short_t d, class T>
542 bool gsHBoxUtils<d, T>::allActive(const HContainer & elements)
543 {
544  bool check = true;
545  for (cHIterator hit = elements.begin(); hit!=elements.end() && check; hit++)
546  check &= allActive(*hit);
547  return check;
548 }
549 
550 template <short_t d, class T>
551 gsHNeighborhood gsHBoxUtils<d, T>::neighborhoodType( const gsHBox<d,T> & box )
552 {
553  if (dynamic_cast<const gsTHBSplineBasis<d,T>*>(&box.basis()))
554  return gsHNeighborhood::T;
555  else if (dynamic_cast<const gsHBSplineBasis<d,T>*>(&box.basis()))
556  return gsHNeighborhood::H;
557  else
558  GISMO_ERROR("Neighborhood type cannot be inferred. Is the basis related to the HBox a gsHTensorBasis?");
559 }
560 
561 template <short_t d, class T>
562 bool gsHBoxCompare<d,T>::operator()(const gsHBox<d,T> & a, const gsHBox<d,T> & b) const
563 {
564  return
565  (a.patch() < b.patch())
566  ||
567  ((a.patch() == b.patch()) &&
568  (a.level() < b.level()) )
569  ||
570  ((a.patch() == b.patch()) &&
571  (a.level() == b.level()) &&
572  std::lexicographical_compare( a.lowerIndex().begin(), a.lowerIndex().end(),
573  b.lowerIndex().begin(), b.lowerIndex().end()) )
574  ||
575  ((a.patch() == b.patch()) &&
576  (a.level() == b.level()) &&
577  (a.lowerIndex() == b.lowerIndex()) &&
578  std::lexicographical_compare( a.upperIndex().begin(), a.upperIndex().end(),
579  b.upperIndex().begin(), b.upperIndex().end()) );
580 };
581 
582 template <short_t d, class T>
583 bool gsHBoxEqual<d,T>::operator()(const gsHBox<d,T> & a, const gsHBox<d,T> & b) const
584 {
585  return a.isSame(b);
586 };
587 
588 // template <short_t d, class T>
589 // bool gsHBoxOverlaps<d,T>::operator()(const gsHBox<d,T> & a, const gsHBox<d,T> & b) const
590 // {
591 // bool res = true;
592 // if (a.level() <= b.level())
593 // {
594 // // Check if the indices of the ancestor are contained. If yes, the indices of the original box should be contained
595 // for (index_t i=0; i!=d && res; i++)
596 // {
597 // res |= a.lowerIndex().at(i) >= b.getAncestor(a.level()).lowerIndex().at(i);
598 // res |= a.upperIndex().at(i) <= b.getAncestor(a.level()).upperIndex().at(i);
599 // }
600 // }
601 // else //a.level() > b.level()
602 // {
603 // // Check if the indices of the ancestor are contained. If yes, the indices of the original box should be contained
604 // for (index_t i=0; i!=d && res; i++)
605 // {
606 // res |= b.lowerIndex().at(i) >= a.getAncestor(b.level()).lowerIndex().at(i);
607 // res |= b.upperIndex().at(i) <= a.getAncestor(b.level()).upperIndex().at(i);
608 // }
609 // }
610 
611 // return res;
612 // };
613 
614 template <short_t d, class T>
615 bool gsHBoxContains<d,T>::operator()(const gsHBox<d,T> & a, const gsHBox<d,T> & b) const
616 {
617  bool res = true;
618  res &= a.level() <= b.level();
619  if (res)
620  {
621  // Check if the indices of the ancestor are contained. If yes, the indices of the original box should be contained
622  for (index_t i=0; i!=d && res; i++)
623  {
624  res &= a.lowerIndex().at(i) >= b.getAncestor(a.level()).lowerIndex().at(i);
625  res &= a.upperIndex().at(i) <= b.getAncestor(a.level()).upperIndex().at(i);
626  }
627  }
628  return res;
629 };
630 
631 // template <short_t d, class T>
632 // bool gsHBoxIsContained<d,T>::operator()(const gsHBox<d,T> & a, const gsHBox<d,T> & b) const
633 // {
634 // bool res = true;
635 // res &= a.level() <= b.level();
636 // if (res)
637 // {
638 // for (index_t i=0; i!=d && res; i++)
639 // {
640 // res &= a.lowerIndex().at(i) >= b.getAncestor(a.level()).lowerIndex().at(i);
641 // res &= a.upperIndex().at(i) <= b.getAncestor(a.level()).upperIndex().at(i);
642 // }
643 // }
644 // return res;
645 // };
646 
647 template <short_t d, class T>
648 bool gsHBoxIsContained<d,T>::operator()(const gsHBox<d,T> & a, const gsHBox<d,T> & b) const
649 {
650  bool res = true;
651  res &= a.level() >= b.level();
652  if (res)
653  {
654  // Check if the indices of the ancestor are contained. If yes, the indices of the original box should be contained
655  for (index_t i=0; i!=d && res; i++)
656  {
657  res &= a.getAncestor(b.level()).lowerIndex().at(i) >= b.lowerIndex().at(i);
658  res &= a.getAncestor(b.level()).upperIndex().at(i) <= b.upperIndex().at(i);
659  }
660  }
661  return res;
662 };
663 
664 
665 } // gismo
T distance(gsMatrix< T > const &A, gsMatrix< T > const &B, index_t i=0, index_t j=0, bool cols=false)
compute a distance between the point number in the set and the point number &lt;j&gt; in the set ; by def...
static std::enable_if< _mode==gsHNeighborhood::T||_mode==gsHNeighborhood::H, HContainer >::type _markRecursive(const HContainer &marked, index_t lvl, index_t m)
Marks Recursively.
static Container toUnitBoxes(const HContainer &container)
Transforms the boxes in container as unit boxes.
Definition: gsHBoxUtils.hpp:366
static Container toContainer(const HContainer &container)
Returns a container representation of the object.
Definition: gsHBoxUtils.hpp:352
This class provides a Hierarchical Box (gsHBox)
Definition: gsHBox.h:54
#define index_t
Definition: gsConfig.h:32
static HContainer markTadmissible(const HContainer &marked, index_t m)
Performs T-admissible refinement.
Definition: gsHBoxUtils.hpp:401
HContainer & boxes()
Returns a heirarchical container with the boxes stored in the container.
Definition: gsHBoxContainer.h:123
The Hierarchical Box Container provides a container for gsHBox objects.
Definition: gsHBoxContainer.h:39
Provides declaration of THBSplineBasis class.
static gsHBox< d, T >::Container Intersection(const Container &container1, const Container &container2)
Performs an intersection. Keeps the smallest boxes in overlapping regions, can also intersect partial...
Definition: gsHBoxUtils.hpp:214
void add(const gsHBox< d, T > &box)
Adds a single box.
Definition: gsHBoxContainer.hpp:121
static HContainer markAdmissible(const gsHBox< d, T > &marked, index_t m)
Performs H-admissible refinement.
static HContainer markHadmissible(const HContainer &marked, index_t m)
Performs H-admissible refinement.
Definition: gsHBoxUtils.hpp:414
static gsHBox< d, T >::Container ExactIntersection(const Container &container1, const Container &container2)
Performs an intersection; only keeps the boxes that are EXACTLY the same (also level is the same) ...
Definition: gsHBoxUtils.hpp:273
gsHNeighborhood
The gsHNeighborhood is a struct that classifies the type of admissible refinement.
Definition: gsHBoxUtils.h:25
#define GISMO_ERROR(message)
Definition: gsDebug.h:118
static HContainer toUnitHBoxes(const HContainer &container)
Transforms the boxes in container as unit boxes.
Definition: gsHBoxUtils.hpp:383
The gsHBoxUtils provide basic utilities to modify HBoxes.
Definition: gsHBoxUtils.h:45
Provides declaration of HBSplineBasis class.
Provides gsHBox: smart boxes for HTensorBases.