21 template <
short_t d,
class T>
22 gsHBoxContainer<d, T>::gsHBoxContainer()
27 template <
short_t d,
class T>
28 gsHBoxContainer<d, T>::gsHBoxContainer(
const gsHBox<d,T> & box)
30 this->_makeLevel(box.level());
31 m_boxes[box.level()].push_back(box);
42 template <
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);
54 template <
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++)
78 m_NHtype = gsHBoxUtils<d,T>::neighborhoodType(hit->front());
85 template <
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);
95 template <
short_t d,
class T>
98 for (HIterator hit = m_boxes.begin(); hit!=m_boxes.end(); hit++)
109 template <
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);
120 template <
short_t d,
class T>
123 this->_makeLevel(box.
level());
124 m_boxes[box.
level()].push_back(box);
126 if (m_NHtype==gsHNeighborhood::None)
130 template <
short_t d,
class T>
133 for (cIterator it = boxes.begin(); it!=boxes.end(); it++)
137 template <
short_t d,
class T>
140 for (cHIterator hit = boxes.begin(); hit!=boxes.end(); hit++)
144 template <
short_t d,
class T>
147 this->add(boxes.
boxes());
150 template <
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)
271 template <
short_t d,
class T>
277 template <
short_t d,
class T>
283 template <
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());
299 template <
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++)
308 for (cIterator cit=children.begin(); cit!=children.end(); cit++)
309 result.push_back(*cit);
315 template <
short_t d,
class T>
321 template <
short_t d,
class T>
327 template <
short_t d,
class T>
330 if (m_NHtype==gsHNeighborhood::T)
332 else if (m_NHtype==gsHNeighborhood::H)
338 template <
short_t d,
class T>
341 if (m_boxes.size() <
static_cast<unsigned>(lvl + 1))
342 m_boxes.resize(lvl+1);
345 template <
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++)
354 template <
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);
373 template <
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);
392 template <
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);
411 template <
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();
428 template <
short_t d,
class T>
431 this->m_boxes = this->toUnitHBoxes();
438 template<
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);
size_t size(index_t level) const
Returns the size of the container on level.
Definition: gsHBoxContainer.h:68
This class provides a Hierarchical Box (gsHBox)
Definition: gsHBox.h:54
index_t level() const
Gets the level of the object.
Definition: gsHBox.hpp:287
#define index_t
Definition: gsConfig.h:32
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
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
size_t totalSize() const
Returns the total number of boxes.
Definition: gsHBoxContainer.hpp:86
std::string to_string(const unsigned &i)
Helper to convert small unsigned to string.
Definition: gsXml.cpp:74
gsXmlAttribute * makeAttribute(const std::string &name, const std::string &value, gsXmlTree &data)
Helper to allocate XML attribute.
Definition: gsXml.cpp:37
void add(const gsHBox< d, T > &box)
Adds a single box.
Definition: gsHBoxContainer.hpp:121
gsXmlNode * makeNode(const std::string &name, gsXmlTree &data)
Helper to allocate XML node.
Definition: gsXml.cpp:54
gsHNeighborhood
The gsHNeighborhood is a struct that classifies the type of admissible refinement.
Definition: gsHBoxUtils.h:25
Container getChildren() const
Gives a hierarchical container with all the children of the boxes stored in this. ...
Definition: gsHBoxContainer.hpp:300
#define GISMO_ERROR(message)
Definition: gsDebug.h:118
The gsHBoxUtils provide basic utilities to modify HBoxes.
Definition: gsHBoxUtils.h:45
Provides declaration of input/output XML utilities struct.