21template <
short_t d,
class T>
22gsHBoxContainer<d, T>::gsHBoxContainer()
27template <
short_t d,
class T>
28gsHBoxContainer<d, T>::gsHBoxContainer(
const gsHBox<d,T> & box)
30 this->_makeLevel(box.level());
31 m_boxes[box.level()].push_back(box);
42template <
short_t d,
class T>
45 for (cIterator it=boxes.begin(); it!=boxes.end(); it++)
47 this->_makeLevel(it->level());
48 m_boxes[it->level()].push_back(*it);
54template <
short_t d,
class T>
63 for (cHIterator hit = boxes.begin(); hit!=boxes.end(); hit++)
65 for (cIterator it = hit->begin(); it!=hit->end(); it++)
67 this->_makeLevel(it->level());
68 m_boxes[it->level()].push_back(*it);
73 m_NHtype = gsHNeighborhood::None;
74 for (cHIterator hit = boxes.begin(); hit!=boxes.end(); hit++)
85template <
short_t d,
class T>
88 std::function<size_t(
const size_t &,
const Container &)> size_sum = [](
const size_t & sum,
const Container & a)
92 return std::accumulate(m_boxes.begin(), m_boxes.end(), 0, size_sum);
95template <
short_t d,
class T>
96void gsHBoxContainer<d, T>::clear()
98 for (HIterator hit = m_boxes.begin(); hit!=m_boxes.end(); hit++)
109template <
short_t d,
class T>
113 for (
size_t l = 0; l!=boxes.size(); l++)
114 for (cIterator it = boxes[l].begin(); it!=boxes[l].end(); it++)
115 result &= ( (
size_t) it->level()==l);
120template <
short_t d,
class T>
123 this->_makeLevel(box.
level());
124 m_boxes[box.
level()].push_back(box);
126 if (m_NHtype==gsHNeighborhood::None)
130template <
short_t d,
class T>
133 for (cIterator it = boxes.begin(); it!=boxes.end(); it++)
137template <
short_t d,
class T>
140 for (cHIterator hit = boxes.begin(); hit!=boxes.end(); hit++)
144template <
short_t d,
class T>
147 this->add(boxes.
boxes());
150template <
short_t d,
class T>
154 for (cHIterator hit = m_boxes.begin(); hit!=m_boxes.end(); hit++)
155 for (cIterator it = hit->begin(); it!=hit->end(); it++)
156 if (it->patch()==patchID || it->patch()==-1)
271template <
short_t d,
class T>
277template <
short_t d,
class T>
283template <
short_t d,
class T>
290 GISMO_ASSERT(m_boxes[0].size()==0,
"Boxes at level 0 cannot have a parent. Did something go wrong? You can run check() to see if the boxes are allocated coorectly");
292 for (cHIterator hit = std::next(m_boxes.begin()); hit!=m_boxes.end(); hit++)
293 for (cIterator it=hit->begin(); it!=hit->end(); it++)
294 result.push_back(it->getParent());
299template <
short_t d,
class T>
302 Container result, children;
304 for (cHIterator hit = m_boxes.begin(); hit!=m_boxes.end(); hit++)
305 for (cIterator it=hit->begin(); it!=hit->end(); it++)
307 children = it->getChildren();
308 for (cIterator cit=children.begin(); cit!=children.end(); cit++)
309 result.push_back(*cit);
315template <
short_t d,
class T>
321template <
short_t d,
class T>
327template <
short_t d,
class T>
330 if (m_NHtype==gsHNeighborhood::T)
332 else if (m_NHtype==gsHNeighborhood::H)
338template <
short_t d,
class T>
341 if (m_boxes.size() <
static_cast<unsigned>(lvl + 1))
342 m_boxes.resize(lvl+1);
345template <
short_t d,
class T>
348 for (cHIterator hit = m_boxes.begin(); hit!=m_boxes.end(); hit++)
349 for (cIterator it = hit->begin(); it!=hit->end(); it++)
354template <
short_t d,
class T>
357 size_t N = this->totalSize();
359 result.reserve(( N * (2*d+1) ));
362 for (cHIterator hit = patchBoxes.begin(); hit!=patchBoxes.end(); hit++)
363 for (cIterator it = hit->begin(); it!=hit->end(); it++)
366 for (
typename RefBox::const_iterator boxIt = box.begin(); boxIt != box.end(); boxIt++)
367 result.push_back(*boxIt);
373template <
short_t d,
class T>
379 result.reserve(( N * (2*d+1) ));
381 for (cHIterator hit = patchBoxes.begin(); hit!=patchBoxes.end(); hit++)
382 for (cIterator it = hit->begin(); it!=hit->end(); it++)
384 box = it->toRefBox();
385 for (
typename RefBox::const_iterator boxIt = box.begin(); boxIt != box.end(); boxIt++)
386 result.push_back(*boxIt);
392template <
short_t d,
class T>
398 result.reserve(( N * (2*d+1) ));
400 for (cHIterator hit = patchBoxes.begin(); hit!=patchBoxes.end(); hit++)
401 for (cIterator it = hit->begin(); it!=hit->end(); it++)
403 box = it->toCrsBox();
404 for (
typename RefBox::const_iterator boxIt = box.begin(); boxIt != box.end(); boxIt++)
405 result.push_back(*boxIt);
411template <
short_t d,
class T>
418 for (HIterator hit = patchBoxes.begin(); hit!=patchBoxes.end(); hit++)
419 for (Iterator it = hit->begin(); it!=hit->end(); it++)
421 boxes.block(0,2*boxCount,d,2) = it->getCoordinates();
428template <
short_t d,
class T>
431 this->m_boxes = this->toUnitHBoxes();
438template<
short_t d,
class T>
443 typedef gsHBoxContainer<d,T> Object;
445 GSXML_COMMON_FUNCTIONS(Object);
446 static std::string tag () {
return "HBoxContainer"; }
447 static std::string type () {
return "HBoxContainer"+std::to_string(d); }
449 GSXML_GET_POINTER(Object);
451 static void get_into (gsXmlNode * node, Object & obj)
454 for (boxNode = node->first_node(
"HBox");
455 boxNode; boxNode = boxNode->next_sibling(
"HBox"))
457 gsHBox<d,T> * box = gsXml<gsHBox<d,T> >::get(boxNode);
462 static gsXmlNode * put (
const Object & obj,
465 gsXmlNode * container =
makeNode(
"HBoxContainer", data);
466 container->append_attribute(
makeAttribute(
"type",internal::gsXml<Object>::type().c_str(), data) );
467 container->append_attribute(
makeAttribute(
"size", obj.totalSize(), data));
469 for (
typename Object::cHIterator hit = obj.cbegin(); hit!=obj.cend(); hit++)
470 for (
typename Object::cIterator it = hit->begin(); it!=hit->end(); it++)
472 gsXmlNode * box = gsXml< gsHBox<d,T> >::put(*it,data);
473 container->append_node(box);
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
size_t totalSize() const
Returns the total number of boxes.
Definition gsHBoxContainer.hpp:86
size_t size(index_t level) const
Returns the size of the container on level.
Definition gsHBoxContainer.h:68
HContainer & boxes()
Returns a heirarchical container with the boxes stored in the container.
Definition gsHBoxContainer.h:123
This class provides a Hierarchical Box (gsHBox)
Definition gsHBox.h:55
index_t level() const
Gets the level of the object.
Definition gsHBox.hpp:287
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
#define index_t
Definition gsConfig.h:32
#define GISMO_ERROR(message)
Definition gsDebug.h:118
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
Provides declaration of input/output XML utilities struct.
gsXmlNode * makeNode(const std::string &name, gsXmlTree &data)
Helper to allocate XML node.
Definition gsXml.cpp:54
gsXmlAttribute * makeAttribute(const std::string &name, const std::string &value, gsXmlTree &data)
Helper to allocate XML attribute.
Definition gsXml.cpp:37
The G+Smo namespace, containing all definitions for the library.
gsHNeighborhood
The gsHNeighborhood is a struct that classifies the type of admissible refinement.
Definition gsHBoxUtils.h:26
The gsHBoxUtils provide basic utilities to modify HBoxes.
Definition gsHBoxUtils.h:46