G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsHBoxContainer.h
Go to the documentation of this file.
1 
14 #pragma once
15 
16 #include <gsHSplines/gsHBox.h>
17 #include <gsIO/gsXml.h>
18 
19 namespace gismo
20 {
21 
38 template<short_t d, class T>
40 {
41 public:
42  // std::list does not provide .at(k) but it provides iterators
43  typedef typename gsHBox<d,T>::RefBox RefBox;
44  typedef typename gsHBox<d,T>::Container Container;
45  typedef typename gsHBox<d,T>::SortedContainer SortedContainer;
46  typedef typename gsHBox<d,T>::HContainer HContainer;
47  typedef typename gsHBox<d,T>::Iterator Iterator;
48  typedef typename gsHBox<d,T>::cIterator cIterator;
49  typedef typename gsHBox<d,T>::rIterator rIterator;
50  typedef typename gsHBox<d,T>::HIterator HIterator;
51  typedef typename gsHBox<d,T>::cHIterator cHIterator;
52  typedef typename gsHBox<d,T>::rHIterator rHIterator;
53 
55  typedef memory::shared_ptr< gsHBoxContainer > Ptr;
56 
58  typedef memory::unique_ptr< gsHBoxContainer > uPtr;
59 
60 public:
62 
63  gsHBoxContainer(const gsHBox<d,T> & box );
64  gsHBoxContainer(const Container & boxes);
65  gsHBoxContainer(const HContainer & boxes);
66 
68  size_t size(index_t level) const { return m_boxes[level].size(); }
70  size_t nLevels() const { return m_boxes.size(); }
72  size_t totalSize() const;
73 
75  bool check() { return _check(this->boxes()); };
76 
77  void clear();
78 
80  void add(const gsHBox<d,T> & box );
82  void add(const Container & boxes);
84  void add(const HContainer & boxes);
86  void add(const gsHBoxContainer<d,T> & boxes);
87 
89  std::ostream& print( std::ostream& os ) const;
90 
98  gsHBoxContainer<d,T> patch(const index_t patchID) const;
99 
101  void makeUnique();
102 
104  Container & getActivesOnLevel(index_t lvl);
106  const Container & getActivesOnLevel(index_t lvl) const;
108  Container getParents() const;
109 
111  Container getChildren() const;
112 
114  void markHadmissible(index_t m);
115 
117  void markTadmissible(index_t m);
118 
120  void markAdmissible(index_t m);
121 
123  HContainer & boxes() { return m_boxes; }
125  const HContainer & boxes() const { return m_boxes; }
126 
128  index_t maxLevel() {return m_boxes.size()-1; }
129 
135  RefBox toBoxes(const index_t patchID=-1) const;
136 
142  RefBox toRefBoxes(const index_t patchID=-1) const;
143 
149  RefBox toCrsBoxes(const index_t patchID=-1) const;
150 
156  gsMatrix<T> toCoords(const index_t patchID=-1) const;
157 
163  Container toUnitBoxes() const {return gsHBoxUtils<d,T>::toUnitBoxes(this->m_boxes);}
164 
170  HContainer toUnitHBoxes() const {return gsHBoxUtils<d,T>::toUnitHBoxes(this->m_boxes);}
171 
177  Container toContainer() const {return gsHBoxUtils<d,T>::toContainer(m_boxes);}
178 
182  void makeUnitBoxes();
183 
187  HIterator begin() {return m_boxes.begin();}
188  HIterator end() {return m_boxes.end();}
189 
190  cHIterator cbegin() const {return m_boxes.begin();}
191  cHIterator cend() const {return m_boxes.end();}
192 
193  rHIterator rbegin() {return m_boxes.rbegin();}
194  rHIterator rend() {return m_boxes.rend();}
195 
196 
197  // /**
198  // * @brief Returns the basis of the underlying basis
199  // *
200  // * NOTE: Assumes that the basis of all boxes is the same
201  // *
202  // * @return { description_of_the_return_value }
203  // */
204  // const gsHTensorBasis<d,T> & basis() { return this->begin()->front().basis(); }
205 
206  gsHNeighborhood NHtype() const { return m_NHtype;}
207 
208 protected:
209  // /// Helper to take the box union
210  // Container _boxUnion(const Container & container1, const Container & container2) const;
211 
212  // /**
213  // * @brief Takes the union of two \ref gsHBoxContainer
214  // *
215  // * @param[in] container1 The container 1
216  // * @param[in] container2 The container 2
217  // *
218  // * @return The gsHBoxContainer with the union.
219  // */
220  // gsHBoxContainer<d,T> _boxUnion(const gsHBoxContainer<d,T> & container1, const gsHBoxContainer<d,T> & container2) const;
221 
222  // /**
223  // * @brief Takes the union of two hierarchical containers
224  // *
225  // * @param[in] container1 The container 1
226  // * @param[in] container2 The container 2
227  // *
228  // * @return The hierarchical container with the union.
229  // */
230  // HContainer _boxUnion(const HContainer & container1, const HContainer & container2) const;
231 
233  void _makeLevel(index_t lvl);
234 
236  bool _check(const HContainer & boxes);
237 
247  HContainer _markHrecursive(HContainer & marked, index_t lvl, index_t m) const;
249  void _markHrecursive(index_t lvl, index_t m);
259  HContainer _markTrecursive(HContainer & marked, index_t lvl, index_t m) const;
260 
270  HContainer _markRecursive(HContainer & marked, index_t lvl, index_t m) const;
272  void _markRecursive(index_t lvl, index_t m);
273 
282  void _markTadmissible(HContainer & marked, index_t m) const;
283 
292  void _markHadmissible(HContainer & marked, index_t m) const;
293 
302  void _markAdmissible(HContainer & marked, index_t m) const;
303 
304 
305 protected:
306  HContainer m_boxes;
307  gsHNeighborhood m_NHtype;
308 
309 // public:
310 // EIGEN_MAKE_ALIGNED_OPERATOR_NEW
311 
312 }; // class gsHBoxContainer
313 
314 template<short_t d, class T>
315 std::ostream& operator<<( std::ostream& os, const gsHBoxContainer<d,T>& b )
316 {
317  return b.print( os );
318 }
319 
320 } // namespace gismo
321 
322 // *****************************************************************
323 #ifndef GISMO_BUILD_LIB
324 #include GISMO_HPP_HEADER(gsHBoxContainer.hpp)
325 #else
326 #ifdef gsHBoxContainer_EXPORT
327 #include GISMO_HPP_HEADER(gsHBoxContainer.hpp)
328 #undef EXTERN_CLASS_TEMPLATE
329 #define EXTERN_CLASS_TEMPLATE CLASS_TEMPLATE_INST
330 #endif
331 namespace gismo
332 {
333 EXTERN_CLASS_TEMPLATE gsHBoxContainer<1,real_t>;
334 EXTERN_CLASS_TEMPLATE gsHBoxContainer<2,real_t>;
335 EXTERN_CLASS_TEMPLATE gsHBoxContainer<3,real_t>;
336 EXTERN_CLASS_TEMPLATE gsHBoxContainer<4,real_t>;
337 
338 EXTERN_CLASS_TEMPLATE internal::gsXml< gsHBoxContainer<1,real_t> >;
339 EXTERN_CLASS_TEMPLATE internal::gsXml< gsHBoxContainer<2,real_t> >;
340 EXTERN_CLASS_TEMPLATE internal::gsXml< gsHBoxContainer<3,real_t> >;
341 EXTERN_CLASS_TEMPLATE internal::gsXml< gsHBoxContainer<4,real_t> >;
342 }
343 #endif
344 // *****************************************************************
void markAdmissible(index_t m)
Applies _markAdmissible on this.
Definition: gsHBoxContainer.hpp:328
gsHBoxContainer< d, T > patch(const index_t patchID) const
Returns all the boxes of patchID.
Definition: gsHBoxContainer.hpp:151
Container getParents() const
Gives a hierarchical container with all the parents of the boxes stored in this.
Definition: gsHBoxContainer.hpp:284
bool check()
Checks if the hierarchical container is correctly defined.
Definition: gsHBoxContainer.h:75
const HContainer & boxes() const
Returns a heirarchical container with the boxes stored in the container.
Definition: gsHBoxContainer.h:125
void markHadmissible(index_t m)
Applies _markHadmissible on this.
Definition: gsHBoxContainer.hpp:322
size_t size(index_t level) const
Returns the size of the container on level.
Definition: gsHBoxContainer.h:68
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
void makeUnique()
Removes duplicate boxes.
void markTadmissible(index_t m)
Applies _markTadmissible on this.
Definition: gsHBoxContainer.hpp:316
Container & getActivesOnLevel(index_t lvl)
Returns the actives on level.
Definition: gsHBoxContainer.hpp:272
#define index_t
Definition: gsConfig.h:32
void makeUnitBoxes()
Transforms/splits the boxes inside the container to unit boxes.
Definition: gsHBoxContainer.hpp:429
gsMatrix< T > toCoords(const index_t patchID=-1) const
Returns box coordinate represenation of the object.
Definition: gsHBoxContainer.hpp:412
void _markHadmissible(HContainer &marked, index_t m) const
Performs H-admissible refinement.
HContainer & boxes()
Returns a heirarchical container with the boxes stored in the container.
Definition: gsHBoxContainer.h:123
void _markTadmissible(HContainer &marked, index_t m) const
Performs T-admissible refinement.
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
size_t nLevels() const
Returns the number of levels stored in the container.
Definition: gsHBoxContainer.h:70
memory::unique_ptr< gsHBoxContainer > uPtr
Unique pointer for gsHTensorBasis.
Definition: gsHBoxContainer.h:58
bool _check(const HContainer &boxes)
Checks the container.
Definition: gsHBoxContainer.hpp:110
memory::shared_ptr< gsHBoxContainer > Ptr
Shared pointer for gsHTensorBasis.
Definition: gsHBoxContainer.h:55
RefBox toCrsBoxes(const index_t patchID=-1) const
Returns coarsening box representation of the object.
Definition: gsHBoxContainer.hpp:393
index_t maxLevel()
Returns the maximum level in the container.
Definition: gsHBoxContainer.h:128
HContainer toUnitHBoxes() const
Transforms the boxes in container as unit boxes.
Definition: gsHBoxContainer.h:170
HContainer _markHrecursive(HContainer &marked, index_t lvl, index_t m) const
Marks H-recursively.
std::ostream & print(std::ostream &os) const
Prints the container.
Definition: gsHBoxContainer.hpp:346
RefBox toRefBoxes(const index_t patchID=-1) const
Returns refinement box representation of the object.
Definition: gsHBoxContainer.hpp:374
void _makeLevel(index_t lvl)
Takes the union of two gsHBoxContainer.
Definition: gsHBoxContainer.hpp:339
void add(const gsHBox< d, T > &box)
Adds a single box.
Definition: gsHBoxContainer.hpp:121
HContainer _markTrecursive(HContainer &marked, index_t lvl, index_t m) const
Marks T-recursively.
HContainer _markRecursive(HContainer &marked, index_t lvl, index_t m) const
Marks T-recursively.
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
gsHNeighborhood NHtype() const
Returns the basis of the underlying basis.
Definition: gsHBoxContainer.h:206
static HContainer toUnitHBoxes(const HContainer &container)
Transforms the boxes in container as unit boxes.
Definition: gsHBoxUtils.hpp:383
RefBox toBoxes(const index_t patchID=-1) const
Returns boxes representation of the object.
Definition: gsHBoxContainer.hpp:355
Provides declaration of input/output XML utilities struct.
void _markAdmissible(HContainer &marked, index_t m) const
Performs T/H-admissible refinement.
Provides gsHBox: smart boxes for HTensorBases.
Container toUnitBoxes() const
Transforms the boxes in container as unit boxes.
Definition: gsHBoxContainer.h:163
Container toContainer() const
Returns a container representation of the object.
Definition: gsHBoxContainer.h:177