SheafSystem  0.0.0.0
array_section_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_section_dof_map
19 
20 #include "SheafSystem/array_section_dof_map.h"
21 
22 #include "SheafSystem/assert_contract.h"
23 #include "SheafSystem/discretization_iterator.h"
24 #include "SheafSystem/error_message.h"
25 #include "SheafSystem/dof_map_factory.h"
26 #include "SheafSystem/postorder_iterator.h"
27 #include "SheafSystem/sec_rep_space.h"
28 #include "SheafSystem/primitive_type.h"
29 
30 using namespace std;
31 using namespace fiber_bundle; // Workaround for MS C++ bug.
32 
33 //#define DIAGNOSTIC_OUTPUT
34 #define BOUNDS_CHECK
35 
36 // PUBLIC MEMBER FUNCTIONS
37 
39 const std::string&
41 class_name() const
42 {
43  // Preconditions:
44 
45  // Body:
46 
47  const string& result = static_class_name();
48 
49  // Postconditions:
50 
51  ensure(!result.empty());
52 
53  // Exit:
54 
55  return result;
56 }
57 
59 const std::string&
62 {
63  // Preconditions:
64 
65  // Body:
66 
67  static const string result("array_section_dof_map");
68 
69  // Postconditions:
70 
71  ensure(!result.empty());
72  ensure(result == "array_section_dof_map");
73 
74  // Exit:
75 
76  return result;
77 }
78 
79 // CANONICAL MEMBERS
80 
84  : section_dof_map()
85 {
86 
87  // Preconditions:
88 
89 
90  // Body:
91 
92  _local_ct = 0;
93  _fiber_dof_ct = 0;
94  _dofs = 0;
95  _this_owns_dofs = false;
96 
97  // Postconditions:
98 
99  ensure(invariant());
100  ensure(!is_initialized());
101 
102 
103  // Exit
104 
105  return;
106 }
107 
111 clone() const
112 {
113  array_section_dof_map* result;
114 
115  // Preconditions:
116 
117 
118  // Body:
119 
120  result = new array_section_dof_map();
121 
122  // Postconditions:
123 
124  ensure(result != 0);
125  ensure(result->is_same_type(this));
126  ensure(postcondition_of(array_section_dof_map()));
127 
128  // Exit:
129 
130  return result;
131 }
132 
133 
137  : section_dof_map(xother)
138 {
139 
140  // Preconditions:
141 
142 
143  // Body:
144 
145  _local_ct = 0;
146  _fiber_dof_ct = 0;
147  _dofs = 0;
148  _this_owns_dofs = false;
149 
150  *this = xother;
151 
152  // Postconditions:
153 
154  ensure(invariant());
155 
156  // Exit
157 
158  return;
159 }
160 
164 copy() const
165 {
166  array_section_dof_map* result;
167 
168  // Preconditions:
169 
170 
171  // Body:
172 
173  result = new array_section_dof_map(*this);
174 
175  // Postconditions:
176 
177  ensure(result != 0);
178  ensure(result->is_same_type(this));
179  ensure(postcondition_of(array_section_dof_map(*this)));
180 
181  // Exit:
182 
183  return result;
184 }
185 
186 
191 {
192 
193  // Preconditions:
194 
195  require(xother.is_initialized());
196 
197  // Body:
198 
200 
201  if(_dofs != 0)
202  {
203  delete[] _dofs;
204  }
205 
206  if(xother._dofs != 0)
207  {
208  // Copy the counts
209 
210  _fiber_dof_ct = xother._fiber_dof_ct;
211  _local_ct = xother._local_ct;
212 
213  // Allocate and copy the dof storage
214 
215  _this_owns_dofs = xother._this_owns_dofs;
216 
217  if(_this_owns_dofs)
218  {
219  _dofs = new char[dof_tuple_ub()];
220  memcpy(_dofs, xother._dofs, dof_tuple_ub());
221  }
222  else
223  {
224  _dofs = xother._dofs;
225  }
226  }
227  else
228  {
229  _fiber_dof_ct = 0;
230  _local_ct = 0;
231 
232  _dofs = 0;
233  _this_owns_dofs = false;
234  }
235 
236  // Postconditions:
237 
238  ensure(invariant());
239 
240  // Exit
241 
242  return *this;
243 }
244 
245 
249 {
250  // Preconditions:
251 
252 
253  // Body:
254 
255  if(_this_owns_dofs)
256  delete[] _dofs;
257 
258  // Postconditions:
259 
260  // Exit:
261 
262  return;
263 }
264 
265 
267 bool
269 invariant() const
270 {
271  bool result = true;
272 
273  // Preconditions:
274 
275  // Body:
276 
278 
279  // Postconditions:
280 
281  // Exit
282 
283  return result;
284 }
285 
286 
287 // ===========================================================
288 // MAP FACET
289 // ===========================================================
290 
292 array_section_dof_map(sec_rep_space* xhost, void* xdofs, size_t xdofs_ub)
293  : section_dof_map(xhost, xhost->base().index().pod(), xhost->version())
294 {
295 
296  // Preconditions:
297 
298  require(xhost != 0);
299  require(xhost->state_is_read_accessible());
300  require(xdofs != 0 ? xdofs_ub >= xhost->schema().row_dof_tuple_ub(): true);
301  require(unexecutable("if xdofs != 0 it points to buffer of length xdofs_ub"));
302 
303  // Body:
304 
305  init_dofs(xdofs, xdofs_ub);
306 
307  // Postconditions:
308 
309  ensure(_local_ct > 0);
310  ensure(dof_ct() == schema().row_dof_ct());
311  ensure(dof_tuple_ub() == schema().row_dof_tuple_ub());
312  ensure(_dofs != 0);
313  ensure(xdofs != 0 ? _dofs == xdofs : true);
314 
315 }
316 
319  pod_index_type xbase_id,
320  int xversion,
321  void* xdofs,
322  size_t xdofs_ub)
323  : section_dof_map(xhost, xbase_id, xversion)
324 {
325 
326  // Preconditions:
327 
328  require(precondition_of(sec_dof_map::sec_dof_map(xhost, xbase_id, xversion)));
329  require(unexecutable("if xdofs != 0 it points to buffer of length xdofs_ub"));
331  require(unexecutable("if xdofs != 0 xdofs_ub is large enough"));
332 
333  // Body:
334 
335  init_dofs(xdofs, xdofs_ub);
336 
337  // Private "postconditions"
338 
339  assertion(_local_ct > 0);
340  assertion(_dofs != 0);
341  assertion(xdofs != 0 ? _dofs == xdofs : true);
342 
343  // Postconditions:
344 
345  ensure(postcondition_of(sec_dof_map::sec_dof_map(xhost, xbase_id, xversion)));
346  ensure(is_initialized());
347  ensure(dof_tuple() != 0);
348  ensure(xdofs != 0 ? dof_tuple() == xdofs : true);
349 
350 }
351 
354  const scoped_index& xbase_id,
355  int xversion,
356  void* xdofs,
357  size_t xdofs_ub)
358  : section_dof_map(xhost, xbase_id.hub_pod(), xversion)
359 {
360 
361  // Preconditions:
362 
363  require(precondition_of(sec_dof_map::sec_dof_map(xhost, xbase_id, xversion)));
364  require(unexecutable("if xdofs != 0 it points to buffer of length xdofs_ub"));
366  require(unexecutable("if xdofs != 0 xdofs_ub is large enough"));
367 
368  // Body:
369 
370  init_dofs(xdofs, xdofs_ub);
371 
372  // Private "postconditions"
373 
374  assertion(_local_ct > 0);
375  assertion(_dofs != 0);
376  assertion(xdofs != 0 ? _dofs == xdofs : true);
377 
378  // Postconditions:
379 
380  ensure(postcondition_of(sec_dof_map::sec_dof_map(xhost, xbase_id, xversion)));
381  ensure(is_initialized());
382  ensure(dof_tuple() != 0);
383  ensure(xdofs != 0 ? dof_tuple() == xdofs : true);
384 
385 }
386 
387 
388 
389 // ===========================================================
390 // NEW DOF ACCESS FACET
391 // ===========================================================
392 
393 bool
395 dof_in_bounds(pod_index_type xdof_id, bool xis_table_dofs) const
396 {
397  // Preconditions:
398 
399 
400  // Body:
401 
402  size_type loffset = schema().offset(xdof_id, xis_table_dofs);
403  size_type lsize = schema().size(xdof_id, xis_table_dofs);
404  size_type lub = loffset + lsize;
405 
406  bool result = (lub <= _dof_tuple_ub);
407 
408 #ifdef DIAGNOSTIC_OUTPUT
409  cout << " xdof_id: " << xdof_id
410  << " offset: " << loffset
411  << " size: " << lsize
412  << " ub: " << lub
413  << " dofs ub: " << _dof_tuple_ub
414  << " result: " << boolalpha << result << noboolalpha
415  << endl;
416 #endif
417 
418  // Postconditions:
419 
420 
421  // Exit:
422 
423  return result;
424 }
425 
426 bool
428 dof_in_bounds(pod_index_type xdisc_id, pod_index_type xfiber_id, bool xis_table_dofs) const
429 {
430  // Preconditions:
431 
432 
433  // Body:
434 
435  size_type loffset = schema().offset(xdisc_id, xfiber_id, xis_table_dofs);
436  size_type lsize = schema().size(xdisc_id, xfiber_id, xis_table_dofs);
437  size_type lub = loffset + lsize;
438 
439  bool result = (lub <= _dof_tuple_ub);
440 
441 #ifdef DIAGNOSTIC_OUTPUT
442  cout << " xdisc_id: " << xdisc_id
443  << " xfiber_id: " << xfiber_id
444  << " offset: " << loffset
445  << " size: " << lsize
446  << " ub: " << lub
447  << " dofs ub: " << _dof_tuple_ub
448  << " result: " << boolalpha << result << noboolalpha
449  << endl;
450 #endif
451 
452  // Postconditions:
453 
454 
455  // Exit:
456 
457  return result;
458 }
459 
461 void
463 get_dof(pod_index_type xdof_id, void* xdof, size_type xdof_size) const
464 {
465  // Preconditions:
466 
467  require(schema().state_is_read_accessible());
468  require(schema().dof_id_space(is_table_dof_map()).contains(xdof_id));
469  require(unexecutable("xdof points to buffer of size xdof_size"));
470  require(xdof_size >= schema().size(xdof_id, is_table_dof_map()));
471 
472 #ifdef BOUNDS_CHECK
473  require(dof_in_bounds(xdof_id, is_table_dof_map()));
474 #endif
475 
476  // Body:
477 
478 
479  memcpy(xdof, dof_ptr(xdof_id, is_table_dof_map()), schema().size(xdof_id, is_table_dof_map()));
480 
481  // Postconditions:
482 
483  // Exit
484 
485  return;
486 }
487 
488 
490 void
492 put_dof(pod_index_type xdof_id, const void* xdof, size_type xdof_size)
493 {
494  // Preconditions:
495 
496  require(schema().state_is_read_accessible());
497  require(schema().dof_id_space(is_table_dof_map()).contains(xdof_id));
498  require(unexecutable("xdof points to buffer of size xdof_size"));
499  require(xdof_size >= schema().size(xdof_id, is_table_dof_map()));
500 
501 #ifdef BOUNDS_CHECK
502  require(dof_in_bounds(xdof_id, is_table_dof_map()));
503 #endif
504 
505  // Body:
506 
507  memcpy(dof_ptr(xdof_id, is_table_dof_map()), xdof, schema().size(xdof_id, is_table_dof_map()));
508 
509 
510  // Postconditions:
511 
512  ensure(unexecutable(internal storage holds dof referred to by xdof_id and xis_poset_id));
513 
514  // Exit
515 
516  return;
517 }
518 
519 
520 
521 void
523 get_dof(pod_index_type xdisc_id, pod_index_type xfiber_dof_id, void* xdof, size_type xdof_size) const
524 {
525  // Preconditions:
526 
527  require(schema().state_is_read_accessible());
528  require(schema().discretization_id_space().contains(xdisc_id));
529  require(schema().fiber_schema_id_space(false).contains(xfiber_dof_id));
530  require(unexecutable("xdof points to buffer of size xdof_size"));
531  require(xdof_size >= schema().size(xdisc_id, xfiber_dof_id));
532 
533 #ifdef BOUNDS_CHECK
534  require(dof_in_bounds(xdisc_id, xfiber_dof_id, is_table_dof_map()));
535 #endif
536 
537 
538  // Body:
539 
540  memcpy(xdof,
541  dof_ptr(xdisc_id, xfiber_dof_id, is_table_dof_map()),
542  schema().size(xdisc_id, xfiber_dof_id, is_table_dof_map()));
543 
544 
545  // Postconditions:
546 
547 
548  // Exit:
549 
550  return;
551 }
552 
553 void
555 put_dof(pod_index_type xdisc_id, pod_index_type xfiber_dof_id, const void* xdof, size_type xdof_size)
556 {
557  // Preconditions:
558 
559  require(schema().state_is_read_accessible());
560  require(schema().discretization_id_space().contains(xdisc_id));
561  require(schema().fiber_schema_id_space(false).contains(xfiber_dof_id));
562  require(unexecutable("xdof points to buffer of size xdof_size"));
563  require(xdof_size >= schema().size(xdisc_id, xfiber_dof_id));
564 
565 #ifdef BOUNDS_CHECK
566  require(dof_in_bounds(xdisc_id, xfiber_dof_id, is_table_dof_map()));
567 #endif
568 
569 
570  // Body:
571 
572  memcpy(dof_ptr(xdisc_id, xfiber_dof_id, is_table_dof_map()),
573  xdof,
574  schema().size(xdisc_id, xfiber_dof_id, is_table_dof_map()));
575 
576 
577  // Postconditions:
578 
579 
580  // Exit:
581 
582  return;
583 }
584 
585 bool
587 fiber_in_bounds(pod_index_type xdisc_id, bool xis_table_dofs) const
588 {
589  // Preconditions:
590 
591 
592  // Body:
593 
594  size_type loffset = schema().offset(xdisc_id, 0, xis_table_dofs);
595  size_type lsize = schema().fiber_size();
596  size_type lub = loffset + lsize;
597 
598  bool result = (lub <= _dof_tuple_ub);
599 
600 #ifdef DIAGNOSTIC_OUTPUT
601  cout << " xdisc_id: " << xdisc_id
602  << " offset: " << loffset
603  << " size: " << lsize
604  << " ub: " << lub
605  << " dofs ub: " << _dof_tuple_ub
606  << " result: " << boolalpha << result << noboolalpha
607  << endl;
608 #endif
609 
610  // Postconditions:
611 
612 
613  // Exit:
614 
615  return result;
616 }
617 
618 void
621 {
622  // Preconditions:
623 
624  // The following precondition seems reasonable, but it is
625  // not actually necessary and it triggers an update of the
626  // schema row cache, which can be a performance problem.
627  // ensure(schema().discretization_id_space().contains(xdisc_id));
628 
629  // Body:
630 
631  size_t ltuple_size = schema().fiber_schema().row_dof_tuple_ub();
632 
633  size_t ldof_tuple_ub = (xdisc_id+1)*ltuple_size;
634 
635  reserve(ldof_tuple_ub);
636 
637 #ifdef DIAGNOSTIC_OUTPUT
638  cout << " xdisc_id: " << xdisc_id
639  << " ltuple_size: " << ltuple_size
640  << " ldof_tuple_ub: " << ldof_tuple_ub
641  << " dof_tuple_ub: " << dof_tuple_ub()
642  << endl;
643 #endif
644 
645  // Postconditions:
646 
647  ensure(dof_tuple_ub() >= (xdisc_id+1)*schema().fiber_schema().row_dof_tuple_ub());
648 
649  // Exit:
650 
651  return;
652 }
653 
654 void
656 get_fiber(pod_index_type xdisc_id, void* xfiber, size_type xfiber_size) const
657 {
658  // Preconditions:
659 
660  require(schema().state_is_read_accessible());
661  require(schema().discretization_id_space().contains(xdisc_id));
662  require(unexecutable("xfiber points to buffer of size xfiber_size"));
663  require(xfiber_size >= schema().fiber_size());
664 
665 #ifdef BOUNDS_CHECK
666  require(fiber_in_bounds(xdisc_id, is_table_dof_map()));
667 #endif
668 
669 
670  // Body:
671 
672  memcpy(xfiber, dof_ptr(xdisc_id, 0, is_table_dof_map()), schema().fiber_size());
673 
674  // Postconditions:
675 
676 
677  // Exit:
678 
679  return;
680 }
681 
682 void
684 put_fiber(pod_index_type xdisc_id, const void* xfiber, size_type xfiber_size)
685 {
686  // Preconditions:
687 
688  require(schema().state_is_read_accessible());
689  require(schema().discretization_id_space().contains(xdisc_id));
690  require(unexecutable("xfiber points to buffer of size xfiber_size"));
691  require(xfiber_size >= schema().fiber_size());
692 
693 #ifdef BOUNDS_CHECK
694  require(fiber_in_bounds(xdisc_id, is_table_dof_map()));
695 #endif
696 
697 
698  // Body:
699 
700  memcpy(dof_ptr(xdisc_id, 0, is_table_dof_map()), xfiber, schema().fiber_size());
701 
702  // Postconditions:
703 
704 
705  // Exit:
706 
707  return;
708 }
709 
710 void
712 force_fiber(pod_index_type xdisc_id, const void* xfiber, size_type xfiber_size)
713 {
714  // Preconditions:
715 
716  require(schema().state_is_read_accessible());
717  require(schema().discretization_id_space().contains(xdisc_id));
718  require(unexecutable("xfiber points to buffer of size xfiber_size"));
719  require(xfiber_size >= schema().fiber_size());
720 
721 
722  // Body:
723 
724  reserve_fiber(xdisc_id);
725 
726  memcpy(dof_ptr(xdisc_id, 0, is_table_dof_map()), xfiber, schema().fiber_size());
727 
728  // Postconditions:
729 
730 
731  // Exit:
732 
733  return;
734 }
735 
736 void
738 get_component(pod_index_type xfiber_dof_id, void* xcomponent, size_type xcomponent_size) const
739 {
740  // Preconditions:
741 
742  require(schema().state_is_read_accessible());
743  require(schema().fiber_schema_id_space(false).contains(xfiber_dof_id));
744  require(unexecutable("xcomponent points to buffer of size xcomponent_size"));
745  require(xcomponent_size >= schema().component_size(xfiber_dof_id));
746 
747 
748  // Body:
749 
750  char* lcomponent = reinterpret_cast<char*>(xcomponent);
751  char* ldof = reinterpret_cast<char*>(dof_ptr(0, xfiber_dof_id, is_table_dof_map()));
752  size_type ldof_size = schema().size(0, xfiber_dof_id, false);
753  size_type lfiber_size = schema().fiber_size();
754  size_type ldisc_ct = schema().discretization_ct();
755 
756  for(pod_index_type i=0; i<ldisc_ct; ++i)
757  {
758  memcpy(lcomponent, ldof, ldof_size);
759  lcomponent += ldof_size;
760  ldof += lfiber_size;
761  }
762 
763  // Postconditions:
764 
765 
766  // Exit:
767 
768  return;
769 }
770 
771 void
773 put_component(pod_index_type xfiber_dof_id, const void* xcomponent, size_type xcomponent_size)
774 {
775  // Preconditions:
776 
777  require(schema().state_is_read_accessible());
778  require(schema().fiber_schema_id_space(false).contains(xfiber_dof_id));
779  require(unexecutable("xcomponent points to buffer of size xcomponent_size"));
780  require(xcomponent_size >= schema().component_size(xfiber_dof_id));
781 
782 
783  // Body:
784 
785  const char* lcomponent = reinterpret_cast<const char*>(xcomponent);
786  char* ldof = reinterpret_cast<char*>(dof_ptr(0, xfiber_dof_id, is_table_dof_map()));
787  size_type ldof_size = schema().size(0, xfiber_dof_id, false);
788  size_type lfiber_size = schema().fiber_size();
789  size_type ldisc_ct = schema().discretization_ct();
790 
791  for(pod_index_type i=0; i<ldisc_ct; ++i)
792  {
793  memcpy(ldof, lcomponent, ldof_size);
794  lcomponent += ldof_size;
795  ldof += lfiber_size;
796  }
797 
798  // Postconditions:
799 
800 
801  // Exit:
802 
803  return;
804 }
805 
806 
807 // ===========================================================
808 // END NEW DOF ACCESS FACET
809 // ===========================================================
810 
812 void*
815 {
816  void* result;
817 
818  // Preconditions:
819 
820  // Body:
821 
822  result = _dofs;
823 
824  // Postconditions:
825 
826  ensure(invariant());
827 
828  // Exit
829 
830  return result;
831 }
832 
834 const void*
836 dof_tuple() const
837 {
838  const void* result;
839 
840  // Preconditions:
841 
842  // Body:
843 
844  result = _dofs;
845 
846  // Postconditions:
847 
848  ensure(invariant());
849 
850  // Exit
851 
852  return result;
853 }
854 
856 void
858 get_dof_tuple(void* xbuf, size_t xbuflen) const
859 {
860  // Preconditions:
861 
862  require(xbuf != 0);
863  require(dof_tuple_ub() <= xbuflen);
864 
865  // Body:
866 
867  memcpy(xbuf, static_cast<void*>(_dofs), dof_tuple_ub());
868 
869  // Postconditions:
870 
871  ensure(invariant());
872  ensure(unexecutable(dof tuple copied to xbuf));
873 
874  // Exit
875 
876  return;
877 }
878 
879 
881 void
883 put_dof_tuple(const void* xbuf, size_t xbuflen)
884 {
885  // Preconditions:
886 
887  require(xbuf != 0);
888  require(dof_tuple_ub() <= xbuflen);
889 
890  // Body:
891 
892  memcpy(static_cast<void*>(_dofs), xbuf, dof_tuple_ub());
893 
894  // Postconditions:
895 
896  ensure(invariant());
897  ensure(unexecutable(xbuf copied to dof tuple));
898 
899  // Exit
900 
901  return ;
902 }
903 
904 // PROTECTED MEMBER FUNCTIONS
905 
906 void
907 fiber_bundle::array_section_dof_map::
908 init_dofs(void* xdofs, size_t xdofs_ub)
909 {
910 
911  // Preconditions:
912 
913  require(xdofs != 0 ? xdofs_ub >= schema().row_dof_tuple_ub(): true);
914  require(unexecutable("if xdofs != 0 it points to buffer of length xdofs_ub"));
915 
916  // Body:
917 
918  _fiber_dof_ct = schema().fiber_schema().row_dof_ct();
919  _local_ct = host()->multiplicity();
920 
921  // Initialize dof storage
922 
923  _dofs = static_cast<char*>(xdofs);
924 
925  if(_dofs == 0)
926  {
927  _dofs = new char[_dof_tuple_ub];
928  _this_owns_dofs = true;
929  }
930  else
931  {
932  _this_owns_dofs = false;
933  }
934 
935  // Postconditions:
936 
937  ensure(_local_ct > 0);
938  ensure(_dofs != 0);
939  ensure(xdofs != 0 ? _dofs == xdofs : true);
940 
941  // Exit:
942 
943  return;
944 }
945 
947 void
950 {
951  // Preconditions:
952 
953 
954  // Body:
955 
956  init_dofs(0,0);
957 
958  // Postconditions:
959 
960 
961  // Exit:
962 
963  return;
964 }
965 
966 bool
967 fiber_bundle::array_section_dof_map::
968 make_prototype()
969 {
970  bool result = false;
971 
972  // Preconditions:
973 
974 
975  // Body:
976 
977  dof_tuple_type ltype = ARRAY_SECTION_DOF_TUPLE_ID;
978 
979  poset_dof_map* lproto = new array_section_dof_map;
980 
981  factory().insert_prototype(lproto);
982  factory().insert_prototype(ltype, lproto);
983 
984  // Postconditions:
985 
986 
987  // Exit:
988 
989  return result;
990 }
991 
992 
994 void
995 fiber_bundle::array_section_dof_map::
996 reserve(size_t xdof_tuple_ub)
997 {
998 
999  // Preconditions:
1000 
1001  require(_dofs != 0);
1002  require(_this_owns_dofs);
1003 
1004  // Body:
1005 
1006  define_old_variable(int old_dof_tuple_ub = _dof_tuple_ub);
1007 
1008  if(xdof_tuple_ub > _dof_tuple_ub)
1009  {
1010  size_t new_ub = _dof_tuple_ub*2;
1011  if(new_ub < xdof_tuple_ub)
1012  {
1013  new_ub = xdof_tuple_ub;
1014  }
1015 
1016  // Allocate a new dofs array
1017 
1018  char* new_dofs = new char[new_ub];
1019 
1020  // Copy the old contents to the new array
1021  // and delete the old array.
1022 
1023  memcpy(new_dofs, _dofs, _dof_tuple_ub);
1024  delete [] _dofs;
1025 
1026  // Update base and bound.
1027 
1028  _dofs = new_dofs;
1029  _dof_tuple_ub = new_ub;
1030  }
1031 
1032  // Postconditions:
1033 
1034  ensure(invariant());
1035  ensure(_dof_tuple_ub >= old_dof_tuple_ub);
1036  ensure(_dof_tuple_ub >= xdof_tuple_ub);
1037 
1038  // Exit:
1039 
1040  return;
1041 }
bool is_table_dof_map() const
True if this is a table dof map.
static const std::string & static_class_name()
The name of this class.
virtual void allocate_dofs()
Allocates dof storage.
The abstract map from section dof ids to section dof values of heterogeneous type.
virtual void force_fiber(pod_index_type xdisc_id, const void *xfiber, size_type xfiber_size)
Sets the fiber referred to by discretization id xdisc_id to xfiber; allocates memory if necessary...
schema_poset_member & fiber_schema()
The fiber schema component of this (mutable version).
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
virtual void get_fiber(pod_index_type xdisc_id, void *xfiber, size_type xfiber_size) const
Sets xfiber to the fiber referred to by discretization id xdisc_id.
virtual size_t size() const =0
The number of bytes in this dof.
primitive_value dof(pod_index_type xdof_id) const
The dof referred to by xdof_id.
int version() const
The version of the host of the schema this is defined on.
virtual void * dof_tuple()
The dof tuple (mutable version).
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...
STL namespace.
virtual array_section_dof_map * copy() const
Virtual copy constructor.
The general, abstract map from dof ids to dof values.
Definition: poset_dof_map.h:59
virtual const std::string & class_name() const
The name of the actual (possibly derived) class of this instance.
size_t _dof_tuple_ub
The size of the dof tuple.
virtual section_space_schema_member & schema()
The schema for this poset (mutable version)
static dof_map_factory & factory()
The dof map factory.
virtual bool invariant() const
The class invariant.
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...
size_t dof_tuple_ub() const
The size of the dof tuple in bytes.
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 dof_in_bounds(pod_index_type xdof_id, bool xis_table_dofs) const
True if and only if the dof asociated with id xdof_id is within the current capacity of the dofs stor...
int discretization_ct() const
The number of members in the intersection of the discretization subposet and the down set of the base...
virtual void get_dof_tuple(void *xbuf, size_t xbuflen) const
Copies the entire dof tuple from internal storage into xbuf.
dof_tuple_type
Identifiers for dof tuple types.
static int row_dof_ct(const namespace_poset &xns, const poset_path &xpath, bool xauto_access=true)
The number of row dofs defined by the schema specified by xns and xpath. Synonym for dof_ct(xns...
A member of a Cartesian product space; a tuple of attributes (persistent version).
Definition: tuple.h:191
section_dof_map & operator=(const section_dof_map &xother)
Assignment operator.
int dof_ct() const
The number of dofs in this map.
int multiplicity() const
The number of degrees of freedom associated with each member of the discretization.
size_type fiber_size() const
The number of bytes in the fiber.
virtual void put_dof(pod_index_type xdof_id, const void *xdof, size_type xdof_size)
Sets the dof referred to by xdof_id to the value at xdof.
size_t row_dof_tuple_ub() const
The size in bytes of the row dof tuple defined by this schema. Synonym for dof_tuple_ub(false).
virtual void put_fiber(pod_index_type xdisc_id, const void *xfiber, size_type xfiber_size)
Sets the fiber referred to by discretization id xdisc_id to xfiber.
void reserve_fiber(pod_index_type xdisc_id)
Ensures this has the capacity to store the fiber with discretization id xdisc_id. ...
virtual array_section_dof_map * clone() const
Virtual default constructor.
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
virtual bool fiber_in_bounds(pod_index_type xdisc_id, bool xis_table_dofs) const
True if and only if the fiber asociated with discretization id xdisc_id is within the current capacit...
virtual void put_dof_tuple(const void *xbuf, size_t xbuflen)
Copies the entire dof tuple from xbuf into internal storage.
virtual void get_component(pod_index_type xfiber_dof_id, void *xcomponent, size_type xcomponent_size) const
Sets xcomponent to the component referred to by fiber id xfiber_dof_id.
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.
void insert_prototype(const poset_dof_map *xprototype)
Sets xprototype as the prototype for its client class.
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 put_component(pod_index_type xfiber_dof_id, const void *xcomponent, size_type xcomponent_size)
Sets the component referred to by fiber id xfiber_dof_id to xcomponent.
virtual sec_rep_space * host() const
The poset which hosts member()
const scoped_index & index() const
The index of this in host() dof tuple table.
virtual size_type offset(pod_index_type xdof_id, bool xis_table_dof) const
The offset for the table dof (xis_table_dof true) or row dof referred to by xdof_id in the schema def...
A handle for a poset whose members are numerical representations of sections of a fiber bundle...
Definition: sec_rep_space.h:61