SheafSystem  0.0.0.0
array_sec_vd_dof_map.cc
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 // Implementation for class array_sec_vd_dof_map
19 
20 #include "SheafSystem/array_sec_vd_dof_map.h"
21 
22 #include "SheafSystem/assert_contract.h"
23 #include "SheafSystem/discretization_iterator.h"
24 #include "SheafSystem/dof_map_factory.h"
25 #include "SheafSystem/id_map.h"
26 #include "SheafSystem/postorder_iterator.h"
27 #include "SheafSystem/sec_rep_space.h"
28 #include "SheafSystem/primitive_type.h"
29 
30 using namespace fiber_bundle; // Workaround for MS C++ bug.
31 
32 // PUBLIC MEMBER FUNCTIONS
33 
35 const std::string&
38 {
39  // Preconditions:
40 
41  // Body:
42 
43  const string& result = static_class_name();
44 
45  // Postconditions:
46 
47  ensure(!result.empty());
48 
49  // Exit:
50 
51  return result;
52 }
53 
55 const std::string&
58 {
59  // Preconditions:
60 
61  // Body:
62 
63  static const string result("array_sec_vd_dof_map");
64 
65  // Postconditions:
66 
67  ensure(!result.empty());
68  ensure(result == "array_sec_vd_dof_map");
69 
70  // Exit:
71 
72  return result;
73 }
74 
75 // CANONICAL MEMBERS
76 
81 {
82 
83  // Preconditions:
84 
85 
86  // Body:
87 
88  // Postconditions:
89 
90  ensure(invariant());
91  ensure(!is_initialized());
92 
93 
94  // Exit
95 
96  return;
97 }
98 
102 clone() const
103 {
104  array_sec_vd_dof_map* result;
105 
106  // Preconditions:
107 
108 
109  // Body:
110 
111  result = new array_sec_vd_dof_map();
112 
113  // Postconditions:
114 
115  ensure(result != 0);
116  ensure(result->is_same_type(this));
117  ensure(postcondition_of(array_sec_vd_dof_map()));
118 
119  // Exit:
120 
121  return result;
122 }
123 
124 
128  : array_section_dof_map(xother)
129 {
130 
131  // Preconditions:
132 
133 
134  // Body:
135 
136  // Postconditions:
137 
138  ensure(invariant());
139 
140  // Exit
141 
142  return;
143 }
144 
148 copy() const
149 {
150  array_sec_vd_dof_map* result;
151 
152  // Preconditions:
153 
154 
155  // Body:
156 
157  result = new array_sec_vd_dof_map(*this);
158 
159  // Postconditions:
160 
161  ensure(result != 0);
162  ensure(result->is_same_type(this));
163  ensure(postcondition_of(array_sec_vd_dof_map(*this)));
164 
165  // Exit:
166 
167  return result;
168 }
169 
170 
175 {
176 
177  // Preconditions:
178 
179  require(xother.is_initialized());
180 
181  // Body:
182 
184 
185  // Postconditions:
186 
187  ensure(invariant());
188 
189  // Exit
190 
191  return *this;
192 }
193 
194 
198 {
199  // Preconditions:
200 
201 
202  // Body:
203 
204  // Postconditions:
205 
206  // Exit:
207 
208  return;
209 }
210 
211 
213 bool
215 invariant() const
216 {
217  bool result = true;
218 
219  // Preconditions:
220 
221  // Body:
222 
224 
225  // Postconditions:
226 
227  // Exit
228 
229  return result;
230 }
231 
232 
233 // ===========================================================
234 // MAP FACET
235 // ===========================================================
236 
239 array_sec_vd_dof_map(sec_rep_space* xhost, void* xdofs, size_t xdofs_ub)
240  : array_section_dof_map(xhost, xdofs, xdofs_ub)
241 {
242 
243  // Preconditions:
244 
245  require(precondition_of(array_section_dof_map(xhost, xdofs, xdofs_ub)));
246 
247  // Body:
248 
249 
250  // Postconditions:
251 
252  require(postcondition_of(array_section_dof_map(xhost, xdofs, xdofs_ub)));
253 
254 }
255 
259  const scoped_index& xbase_id,
260  int xversion,
261  void* xdofs,
262  size_t xdofs_ub)
263  : array_section_dof_map(xhost, xbase_id, xversion, xdofs, xdofs_ub)
264 {
265 
266  // Preconditions:
267 
268  require(precondition_of(array_section_dof_map(xhost, xbase_id, xversion, xdofs, xdofs_ub)));
269 
270  // Body:
271 
272  // Postconditions:
273 
274  ensure(postcondition_of(array_section_dof_map(xhost, xbase_id, xversion, xdofs, xdofs_ub)));
275 
276 }
277 
278 // ===========================================================
279 // NEW DOF ACCESS FACET
280 // ===========================================================
281 
283 void
285 get_dof(pod_index_type xdof_id, void* xdof, size_type xdof_size) const
286 {
287  // Preconditions:
288 
289  require(schema().state_is_read_accessible());
290  require(schema().dof_id_space().contains_range_id(xdof_id));
291  require(unexecutable("xdof points to buffer of size xdof_size"));
292  require(xdof_size >= schema().size(xdof_id));
293 
294  // Body:
295 
296  *reinterpret_cast<sec_vd_dof_type*>(xdof) = *dof_ptr(xdof_id);
297 
298 
299  // Postconditions:
300 
301  // Exit
302 
303  return;
304 }
305 
306 
308 void
310 put_dof(pod_index_type xdof_id, bool xis_poset_id, const void* xdof, size_type xdof_size)
311 {
312  // Preconditions:
313 
314  require(schema().state_is_read_accessible());
315  require(schema().dof_id_space().contains_range_id(xdof_id));
316  require(unexecutable("xdof points to buffer of size xdof_size"));
317  require(xdof_size >= schema().size(xdof_id));
318 
319  // Body:
320 
321  *dof_ptr(xdof_id) = *reinterpret_cast<sec_vd_dof_type*>(xdof);
322 
323  // Postconditions:
324 
325  ensure(unexecutable(internal storage holds dof referred to by xdof_id and xis_poset_id));
326 
327  // Exit
328 
329  return;
330 }
331 
332 
333 void
335 get_dof(pod_index_type xdisc_id, pod_index_type xfiber_dof_id, void* xdof, size_type xdof_size) const
336 {
337  // Preconditions:
338 
339  require(schema().state_is_read_accessible());
340  require(schema().discretization_id_space().contains_range_id(xdisc_id));
341  require(schema().fiber_id_space().contains_range_id(xfiber_dof_id));
342  require(unexecutable("xdof points to buffer of size xdof_size"));
343  require(xdof_size >= schema().size(xdisc_id, xfiber_dof_id));
344 
345 
346  // Body:
347 
348  pod_index_type ldof_id;
349  row_dof_id_space().simple(xdisc_id, xfiber_id, ldof_id);
350 
351  *reinterpret_cast<sec_vd_dof_type*>(xdof) = *dof_ptr(ldof_id);
352 
353 
354  // Postconditions:
355 
356 
357  // Exit:
358 
359  return;
360 }
361 
362 void
364 put_dof(pod_index_type xdisc_id, pod_index_type xfiber_dof_id, const void* xdof, size_type xdof_size)
365 {
366  // Preconditions:
367 
368  require(schema().state_is_read_accessible());
369  require(schema().discretization_id_space().contains_range_id(xdisc_id));
370  require(schema().fiber_id_space().contains_range_id(xfiber_dof_id));
371  require(unexecutable("xdof points to buffer of size xdof_size"));
372  require(xdof_size >= schema().size(xdisc_id, xfiber_dof_id));
373 
374 
375  // Body:
376 
377  pod_index_type ldof_id;
378  row_dof_id_space().simple(xdisc_id, xfiber_id, ldof_id);
379 
380  *dof_ptr(ldof_id) = *reinterpret_cast<sec_vd_dof_type*>(xdof);
381 
382 
383  // Postconditions:
384 
385 
386  // Exit:
387 
388  return;
389 }
390 
391 
392 // ===========================================================
393 // END NEW DOF ACCESS FACET
394 // ===========================================================
395 
396 
397 
398 
399 
400 bool
401 fiber_bundle::array_sec_vd_dof_map::
402 _has_prototype = make_prototype();
403 
405 bool
406 fiber_bundle::array_sec_vd_dof_map::
407 make_prototype()
408 {
409  bool result = false;
410 
411  // Preconditions:
412 
413 
414  // Body:
415 
416  dof_tuple_type ltype = ARRAY_SECTION_DOF_TUPLE_ID;
417 
418  poset_dof_map* lproto = new array_sec_vd_dof_map;
419 
420  factory().insert_prototype(lproto);
421  factory().insert_prototype(ltype, lproto);
422 
423  // Postconditions:
424 
425 
426  // Exit:
427 
428  return result;
429 }
430 
431 
array_sec_vd_dof_map()
Default constructor.
primitive_value dof(pod_index_type xdof_id) const
The dof referred to by xdof_id.
virtual section_space_schema_member & schema()
The schema on which this is allocated (mutable version).
bool is_initialized() const
True if this has been initialized, that is, if the schema has been set and the dof map storage alloca...
The general, abstract map from dof ids to dof values.
Definition: poset_dof_map.h:59
static dof_map_factory & factory()
The dof map factory.
array_section_dof_map & operator=(const array_section_dof_map &xother)
Assignment operator.
A contiguous tuple, contiguous fiber representation of the abstract map from section dof ids to secti...
A contiguous tuple, contiguous fiber representation of the abstract map from section dof ids to secti...
static const std::string & static_class_name()
The name of this class.
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
virtual bool invariant() const
The class invariant.
dof_tuple_type
Identifiers for dof tuple types.
virtual void put_dof(pod_index_type xdof_id, bool xis_poset_id, const void *xdof, size_type xdof_size)
Sets the dof referred to by xdof_id to the value at xdof.
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
virtual const std::string & class_name()
The name of the actual (possibly derived) class of this instance.
virtual array_sec_vd_dof_map * clone() const
Virtual default constructor.
array_sec_vd_dof_map & operator=(const array_sec_vd_dof_map &xother)
Assignment operator.
void insert_prototype(const poset_dof_map *xprototype)
Sets xprototype as the prototype for its client class.
virtual array_sec_vd_dof_map * copy() const
Virtual copy constructor.
double sec_vd_dof_type
The type of degree of freedom in the section space.
Definition: fiber_bundle.h:78
Namespace for the fiber_bundles component of the sheaf system.
bool is_same_type(const any *other) const
True if other is the same type as this.
Definition: any.cc:79
virtual void get_dof(pod_index_type xdof_id, void *xdof, size_type xdof_size) const
Copies the dof referred to by xdof_id into xdof.
A handle for a poset whose members are numerical representations of sections of a fiber bundle...
Definition: sec_rep_space.h:61