G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsAPALMDataContainer.h
Go to the documentation of this file.
1 
14 #pragma once
15 
16 #include <gsCore/gsLinearAlgebra.h>
17 #include <gsNurbs/gsKnotVector.h>
18 #include <gsIO/gsOptionList.h>
19 #include <gsHSplines/gsKdNode.h>
20 #include <queue>
21 
22 namespace gismo
23 {
24 
25 template<class T, class solution_t >
26 class gsAPALMDataContainer
27 {
28 
29 public:
30 
31  ~gsAPALMDataContainer() { }
32 
33  gsAPALMDataContainer() { }
34 
35  gsAPALMDataContainer(const gsAPALMData<T,solution_t> & data)
36  {
37  this->add(data);
38  }
39 
40  bool empty()
41  {
42  bool result = true;
43  for (typename std::vector<gsAPALMData<T,solution_t>>::iterator it=m_container.begin(); it!=m_container.end(); it++)
44  result &= it->empty();
45  return result;
46  }
47 
48  index_t nBranches()
49  {
50  return m_container.size();
51  }
52 
53  // std::tuple<std::vector<T>,std::vector<solution_t>,std::vector<index_t>> getFlatSolution(index_t level=-1);
54 
55  index_t add(const gsAPALMData<T,solution_t> & data)
56  {
57  m_container.push_back(data);
58  return m_container.size()-1;
59  }
60 
61  gsAPALMData<T,solution_t> & branch(index_t k)
62  {
63  return m_container.at(k);
64  }
65 
66  index_t getFirstNonEmptyBranch()
67  {
68  index_t k=0;
69  while (m_container[k].empty() && (size_t)k < m_container.size())
70  k++;
71  return k;
72  }
73 
74  void print()
75  {
76  index_t k=0;
77  for (typename std::vector<gsAPALMData<T,solution_t>>::iterator it=m_container.begin(); it!=m_container.end(); it++, k++)
78  {
79  gsInfo<<"-------------------------------------------\n";
80  gsInfo<<"Branch "<<k<<"\n";
81  it->print();
82  }
83  }
84 
85  void printQueue()
86  {
87  index_t k=0;
88  for (typename std::vector<gsAPALMData<T,solution_t>>::iterator it=m_container.begin(); it!=m_container.end(); it++, k++)
89  {
90  gsInfo<<"-------------------------------------------\n";
91  gsInfo<<"Branch "<<k<<"\n";
92  it->printQueue();
93  }
94  }
95 
96  void printKnots()
97  {
98  index_t k=0;
99  for (typename std::vector<gsAPALMData<T,solution_t>>::iterator it=m_container.begin(); it!=m_container.end(); it++, k++)
100  {
101  gsInfo<<"-------------------------------------------\n";
102  gsInfo<<"Branch "<<k<<"\n";
103  it->printKnots();
104  }
105  }
106 
107  size_t nActive()
108  {
109  index_t k=0;
110  for (typename std::vector<gsAPALMData<T,solution_t>>::iterator it=m_container.begin(); it!=m_container.end(); it++)
111  k+= it->nActive();
112  return k;
113  }
114  size_t nWaiting()
115  {
116  index_t k=0;
117  for (typename std::vector<gsAPALMData<T,solution_t>>::iterator it=m_container.begin(); it!=m_container.end(); it++)
118  k+= it->nWaiting();
119  return k;
120  }
121 
122  size_t maxLevel()
123  {
124  size_t k=0;
125  for (typename std::vector<gsAPALMData<T,solution_t>>::iterator it=m_container.begin(); it!=m_container.end(); it++)
126  k = it->maxLevel() > k ? it->maxLevel() : k;
127  return k;
128  }
129 
130 protected:
131  std::vector<gsAPALMData<T,solution_t>> m_container;
132 
133 };
134 
135 }
136 
137 #ifndef GISMO_BUILD_LIB
138 #include GISMO_HPP_HEADER(gsAPALMDataContainer.hpp)
139 #endif
Knot vector for B-splines.
#define index_t
Definition: gsConfig.h:32
Provides a list of labeled parameters/options that can be set and accessed easily.
#define gsInfo
Definition: gsDebug.h:43
This is the main header file that collects wrappers of Eigen for linear algebra.
Provides declaration of the tree node.