G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsAPALMData.h
Go to the documentation of this file.
1
14#pragma once
15
18#include <gsIO/gsOptionList.h>
19#include <gsHSplines/gsKdNode.h>
20#include <deque>
21
22namespace gismo
23{
24
25template<class T, class solution_t >
26class gsAPALMData
27{
28
29public:
30
31 ~gsAPALMData()
32 {
33
34 }
35
42 gsAPALMData(const std::vector<T> & times, const std::vector<solution_t> & solutions);
43
49 gsAPALMData(const std::vector<T> & times);
50
51 gsAPALMData();
52
53private:
54
55 void _defaultOptions();
56
57 void _applyOptions();
58
59public:
60
61 void addStartPoint(const T & time, const solution_t & solution, bool priority = false);
62
63 void appendPoint(bool priority = false);
64
65 void appendData(const T & time, const solution_t & solution, bool priority=false);
66
67 void setData(const std::vector<T> & times, const std::vector<solution_t> & solutions);
68
69 void init(const std::vector<T> & times, const std::vector<solution_t> & solutions);
70
71 void init();
72
73 gsOptionList & options() { return m_options; }
74
75 // ID, dt, start , prev
76 std::tuple<index_t, T , solution_t, solution_t> pop();
77
78 bool getReferenceByTime(T time, solution_t & result);
79
80 bool getReferenceByPar(T xi, solution_t & result);
81
82 bool getReferenceByID(index_t ID, solution_t & result);
83
93 void submit(index_t ID, const std::vector<T> & distances, std::vector<solution_t> solutions, const T & upperError, const T & lowerError = 0);
94
95 void finishJob(index_t ID);
96
97 T jobStartTime(index_t ID);
98 T jobStartPar(index_t ID);
99
100 std::pair<T,T> jobTimes(index_t ID);
101 std::pair<T,T> jobPars(index_t ID);
102 index_t jobLevel(index_t ID);
103
104 void printActiveJobs();
105
106 bool empty();
107
108 std::tuple<std::vector<T>,std::vector<solution_t>,std::vector<index_t>> getFlatSolution(index_t level=-1);
109
110 void print();
111
112 void printQueue();
113
114 void printKnots();
115
116 size_t nActive() { return m_jobs.size(); }
117 size_t nWaiting() { return m_queue.size(); }
118
119 size_t maxLevel() { return m_maxLevel; }
120
121 void setLength(T dt) { m_dt = dt; }
122 T getLength() { return m_dt; }
123
124protected:
125 std::tuple<T,T,index_t> _activeJob(index_t ID);
126
127 void _buildMap();
128
129
130protected:
131 index_t m_points;
132 index_t m_maxLevel;
133 index_t m_verbose;
134 bool m_initialized;
135
136 // Default arc-length
137 T m_dt;
138
139 T m_tolerance;
140
141 // solution map, stores the solution per parametric value
142 std::map<T,std::shared_ptr<solution_t>> m_solutions;
143 std::map<T,std::shared_ptr<solution_t>> m_prevs;
144 // map that maps GIVEN a parametric value TO a level
145 std::map<T,index_t> m_levels;
146
147 // map that maps GIVEN a parametric value TO a time
148 std::map<T,T> m_tmap;
149 // map that maps GIVEN a time TO a parametric value
150 std::map<T,T> m_ximap;
151
152 // Parametric domain
153 gsKnotVector<T> m_xi;
154 // Temporal domain
155 gsKnotVector<T> m_t;
156
157 // Stores [xi_i,xi_i+1,level]
158 std::deque<std::tuple<T,T,index_t>> m_queue;
159
160 // Stores ID, [xi_i,xi_i+1,level]
161 // map that maps GIVEN an ID TO a parametric interval
162 std::map<index_t,std::tuple<T,T,index_t>> m_jobs;
163
164 mutable index_t m_ID = (0);
165
166 gsOptionList m_options;
167
168};
169
170}
171
172#ifndef GISMO_BUILD_LIB
173#include GISMO_HPP_HEADER(gsAPALMData.hpp)
174#endif
#define index_t
Definition gsConfig.h:32
Provides declaration of the tree node.
Knot vector for B-splines.
This is the main header file that collects wrappers of Eigen for linear algebra.
Provides a list of labeled parameters/options that can be set and accessed easily.
The G+Smo namespace, containing all definitions for the library.