SheafSystem  0.0.0.0
sparse_section_dof_map.h
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
18 // Interface for class sparse_section_dof_map;
19 // map from client dof id to dof value.
20 // The section_dof_map interface assumes dofs
21 // are indexed by (base id, fiber id) pairs.
22 // This representation uses contiguous storage with
23 // the fiber index varying most rapidly
24 
25 #ifndef SPARSE_SECTION_DOF_MAP_H
26 #define SPARSE_SECTION_DOF_MAP_H
27 
28 #ifndef SHEAF_DLL_SPEC_H
29 #include "SheafSystem/sheaf_dll_spec.h"
30 #endif
31 
32 #ifndef SECTION_DOF_MAP_H
33 #include "SheafSystem/section_dof_map.h"
34 #endif
35 
36 #ifndef STD_UNORDERED_MAP_H
37 #include "SheafSystem/std_unordered_map.h"
38 #endif
39 
40 namespace fiber_bundle
41 {
42 
43 class sec_rep_space;
44 
53 class SHEAF_DLL_SPEC sparse_section_dof_map : public section_dof_map
54 {
55 
56  friend class fiber_bundles_namespace;
57 
58 public:
59 
63  virtual const std::string& class_name() const;
64 
68  static const std::string& static_class_name();
69 
70  // ===========================================================
71  // CANONICAL FACET
72  // ===========================================================
73 
78 
83 
87  sparse_section_dof_map(sec_rep_space* xhost, double xdefault_value = 0.0);
88 
92  virtual sparse_section_dof_map* clone() const;
93 
97  virtual sparse_section_dof_map* copy() const;
98 
102  sparse_section_dof_map& operator=(const sparse_section_dof_map& xother);
103 
107  virtual ~sparse_section_dof_map();
108 
112  inline double default_value()
113  {
114  return _def_val;
115  };
116 
120  virtual bool invariant() const;
121 
122  // ===========================================================
123  // MAP FACET
124  // ===========================================================
125 
129  virtual dof_tuple_type type_id() const
130  {
131  return SPARSE_SECTION_DOF_TUPLE_ID;
132  };
133 
136 
137  // ===========================================================
139  // ===========================================================
141 
142 public:
143 
147  virtual void get_dof(pod_index_type xdof_id, void* xdof, size_type xdof_size) const;
148 
152  virtual void put_dof(pod_index_type xdof_id, const void* xdof, size_type xdof_size);
153 
157 
161  virtual void get_dof(pod_index_type xdisc_id,
162  pod_index_type xfiber_dof_id,
163  void* xdof,
164  size_type xdof_size) const;
165 
169  virtual void put_dof(pod_index_type xdisc_id,
170  pod_index_type xfiber_dof_id,
171  const void* xdof,
172  size_type xdof_size);
173 
177  virtual void get_fiber(pod_index_type xdisc_id, void* xfiber, size_type xfiber_size) const;
178 
182  virtual void put_fiber(pod_index_type xdisc_id, const void* xfiber, size_type xfiber_size);
183 
187  virtual void get_component(pod_index_type xfiber_dof_id, void* xcomponent, size_type xcomponent_size) const;
188 
192  virtual void put_component(pod_index_type xfiber_dof_id, const void* xcomponent, size_type xcomponent_size);
193 
194 protected:
195 
196 private:
197 
201  typedef unordered::unordered_map<pod_index_type, double> val_map_type;
202 
206  val_map_type _val_map;
207 
211  double _def_val;
212 
214 
215 public:
216 
220  virtual void* dof_tuple();
221 
225  virtual const void* dof_tuple() const;
226 
230  virtual void get_dof_tuple(void* xbuf, size_t xbuflen) const;
231 
235  virtual void put_dof_tuple(const void* xbuf, size_t xbuflen);
236 
237 
238  // ===========================================================
239  // I/O SUPPORT FACET
240  // ===========================================================
241 
246  virtual bool supports_xfr_opt() const;
247 
248 
249 protected:
250 
251 /* /// */
252 /* /// Copies the values of the dofs referred to by the client ids in */
253 /* /// xclient_base_ids x xclient_fiber_ids to or from */
254 /* /// the buffer of length xbuf_len bytes starting at xbuf. */
255 /* /// */
256 /* void copy_dofs(client_index* xclient_base_ids, int xclient_base_id_ct, */
257 /* client_index* xclient_fiber_ids, int xclient_fiber_id_ct, */
258 /* void* xbuf, size_t xbuf_len, bool to_client); */
259 
263  virtual void allocate_dofs();
264 
265 private:
266 
270  static bool make_prototype();
271 
272 };
273 
274 } // namespace fiber_bundle
275 
276 #endif // ifndef SPARSE_SECTION_DOF_MAP_H
The abstract map from section dof ids to section dof values of heterogeneous type.
virtual void get_dof(pod_index_type xdisc_id, pod_index_type xfiber_dof_id, void *xdof, size_type xdof_size) const =0
Copies the dof referred to by xdisc_id, xfiber_dof_id into xdof.
The standard fiber bundles name space; extends the standard sheaves namespace by defining base space...
virtual dof_tuple_type type_id() const
An identifer for the type of dof tuple this is.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
dof_tuple_type
Identifiers for dof tuple types.
A discontiguous tuple, discontiguous fiber representation of the abstract map from section dof ids to...
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
virtual void put_dof(pod_index_type xdisc_id, pod_index_type xfiber_dof_id, const void *xdof, size_type xdof_size)=0
Sets the dof referred to by xdof_id to the value at xdof.
double default_value()
The default value; the value for dofs that are not stored in _val_map.
Namespace for the fiber_bundles component of the sheaf system.
A handle for a poset whose members are numerical representations of sections of a fiber bundle...
Definition: sec_rep_space.h:61