SheafSystem  0.0.0.0
sec_rep_space.cc
Go to the documentation of this file.
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 
20 
21 #include "SheafSystem/sec_rep_space.h"
22 #include "SheafSystem/arg_list.h"
23 #include "SheafSystem/assert_contract.h"
24 #include "SheafSystem/array_index_space_handle.h"
25 #include "SheafSystem/array_index_space_state.h"
26 #include "SheafSystem/array_section_dof_map.h"
27 #include "SheafSystem/binary_section_space_schema_member.impl.h"
28 #include "SheafSystem/binary_section_space_schema_poset.h"
29 #include "SheafSystem/index_space_iterator.h"
30 #include "SheafSystem/namespace_poset.impl.h"
31 #include "SheafSystem/poset.h"
32 #include "SheafSystem/poset_type.h"
33 #include "SheafSystem/poset_handle_factory.h"
34 #include "SheafSystem/poset_member.h"
35 #include "SheafSystem/poset_state.h"
36 #include "SheafSystem/postorder_iterator.h"
37 #include "SheafSystem/std_string.h"
38 #include "SheafSystem/sec_rep_descriptor.h"
39 #include "SheafSystem/sec_rep_space_member.h"
40 #include "SheafSystem/tern.h"
41 
42 using namespace std;
43 using namespace fiber_bundle; // Workaround for MS C++ bug.
44 
45 // =============================================================================
46 // SEC_REP_SPACE FACET
47 // =============================================================================
48 
49 // PUBLIC MEMBER FUNCTIONS
50 
51 const std::string&
54 {
55  // Preconditions:
56 
57  // Body:
58 
59  static const string result("sec_rep_space");
60 
61  // Postconditions:
62 
63  ensure(!result.empty());
64 
65  // Exit:
66 
67  return result;
68 }
69 
73 {
74  // Preconditions:
75 
76  require(state_is_read_accessible());
77 
78  // Body:
79 
80  // Postconditions:
81 
82  // Exit
83 
84  return schema().base_space();
85 }
86 
89 base() const
90 {
91  // Preconditions:
92 
93  require(state_is_read_accessible());
94 
95  // Body:
96 
97  // Postconditions:
98 
99  // Exit
100 
101  return schema().base_space();
102 }
103 
104 int
106 db() const
107 {
108  int result;
109 
110  // Preconditions:
111 
112  require(state_is_read_accessible());
113 
114  // Body:
115 
116  result = schema().db();
117 
118  // Postconditions:
119 
120  ensure(result >= 0);
121 
122  // Exit
123 
124  return result;
125 }
126 
127 
128 int
130 df() const
131 {
132  int result;
133 
134  // Preconditions:
135 
136  require(state_is_read_accessible());
137 
138  // Body:
139 
140  result = schema().df();
141 
142  // Postconditions:
143 
144  ensure(result >= 0);
145 
146  // Exit
147 
148  return result;
149 }
150 
151 
155 {
156  // Preconditions:
157 
158  require(state_is_read_accessible());
159 
160  // Body:
161 
162  // Postconditions:
163 
164  // Exit
165 
166  return schema().fiber_schema();
167 }
168 
172 {
173  // Preconditions:
174 
175  require(state_is_read_accessible());
176 
177  // Body:
178 
179  // Postconditions:
180 
181  // Exit
182 
183  return schema().fiber_schema();
184 }
185 
188 fiber_schema(bool xauto_access)
189 {
190  // Preconditions:
191 
192  require(xauto_access || state_is_read_accessible());
193 
194  // Body:
195 
196  // Postconditions:
197 
198  // Exit
199 
200  return schema(xauto_access).fiber_schema();
201 }
202 
205 fiber_schema(bool xauto_access) const
206 {
207  // Preconditions:
208 
209  require(xauto_access || state_is_read_accessible());
210 
211  // Body:
212 
213  // Postconditions:
214 
215  // Exit
216 
217  return schema(xauto_access).fiber_schema();
218 }
219 
223 {
224 
225  // Preconditions:
226 
227  require(state_is_read_accessible());
228 
229  // Body:
230 
231  // Postconditions:
232 
233  // Exit
234 
235  return schema().rep();
236 }
237 
240 rep() const
241 {
242 
243  // Preconditions:
244 
245  require(state_is_read_accessible());
246 
247  // Body:
248 
249  // Postconditions:
250 
251  // Exit
252 
253  return schema().rep();
254 }
255 
256 bool
259 {
260  bool result = true;
261 
262  // Preconditions:
263 
264  require(xbase != 0);
265  require(xbase->state_is_read_accessible());
266  require(xrep != 0);
267  require(xrep->state_is_read_accessible());
268 
269  // Body:
270 
271  result = section_space_schema_poset::rep_is_valid(*xrep, *(xbase->host()));
272 
273  // Postconditions:
274 
275  // Exit
276 
277  return result;
278 }
279 
283 {
284  // Preconditions:
285 
286  require(state_is_read_accessible());
287 
288  // Body:
289 
290  // Postconditions:
291 
292  // Exit
293 
294  return schema().discretization();
295 }
296 
297 const sheaf::subposet&
300 {
301  // Preconditions:
302 
303  require(state_is_read_accessible());
304 
305  // Body:
306 
307  // Postconditions:
308 
309  // Exit
310 
311  return schema().discretization();
312 }
313 
314 int
317 {
318  // Preconditions:
319 
320  require(state_is_read_accessible());
321 
322  // Body:
323 
324  // Postconditions:
325 
326  // Exit
327 
328  return schema().discretization_ct();
329 }
330 
331 int
334 {
335  // Preconditions:
336 
337  require(state_is_read_accessible());
338 
339  // Body:
340 
341  // Postconditions:
342 
343  // Exit
344 
345  return schema().rep().multiplicity();
346 }
347 
351 {
352  // Preconditions:
353 
354  require(state_is_read_accessible());
355 
356  // Body:
357 
358  // Postconditions:
359 
360 
361  // Exit
362 
363  return schema().evaluation();
364 }
365 
366 const sheaf::subposet&
368 evaluation() const
369 {
370  // Preconditions:
371 
372  require(state_is_read_accessible());
373 
374  // Body:
375 
376  // Postconditions:
377 
378 
379  // Exit
380 
381  return schema().evaluation();
382 }
383 
384 std::string
387 {
388  // Preconditions:
389 
390  require(state_is_read_accessible());
391 
392  // Body:
393 
394  // Postconditions:
395 
396  // Exit
397 
398  return schema().rep().evaluator_family_name();
399 }
400 
401 std::string
403 url() const
404 {
405  // Preconditions:
406 
407  require(state_is_read_accessible());
408 
409  // Body:
410 
411  // Postconditions:
412 
413  // Exit
414 
415  return schema().rep().url();
416 }
417 
418 // PROTECTED MEMBER FUNCTIONS
419 
423 {
424 
425  // Preconditions:
426 
427  // Body:
428 
429  // Postconditions:
430 
431  ensure(!is_attached());
432  ensure(!top().is_attached());
433  ensure(!bottom().is_attached());
434 }
435 
438  : poset_state_handle(xtop, xbottom)
439 {
440  // Preconditions:
441 
442  require(xtop != 0);
443  require(xbottom != 0);
444 
445  // Body:
446 
447  // Nothing to do.
448 
449  // Postconditions:
450 
451  ensure(postcondition_of(poset_state_handle::poset_state_handle(xtop, xbottom)));
452 
453  // Exit:
454 
455  return;
456 }
457 
460 {
461 
462  // Preconditions:
463 
464  // Body:
465 
466  // Nothing to do; base class does it all
467 
468  // Postconditions:
469 
470  // Exit:
471 
472  return;
473 }
474 
475 // PRIVATE MEMBER FUNCTIONS
476 
477 bool
478 fiber_bundle::sec_rep_space::
479 make_prototype()
480 {
481  // Preconditions:
482 
483 
484  // Body:
485 
486  poset_type ltype = SEC_REP_SPACE_ID;
487 
488  sec_rep_space* lproto = new sec_rep_space;
489 
490  factory().insert_prototype(lproto);
491  factory().insert_prototype(ltype, lproto);
492 
493  // Postconditions:
494 
495 
496  // Exit:
497 
498  return true;
499 }
500 
501 
502 // =============================================================================
503 // MULTISECTION FACET
504 // =============================================================================
505 
506 // PUBLIC MEMBER FUNCTIONS
507 
508 bool
510 is_multisection(pod_index_type xhub_id, bool xauto_access) const
511 {
512  bool result;
513 
514  // Preconditions:
515 
516  require(xauto_access || state_is_read_accessible());
517  require(contains_member(xhub_id, xauto_access));
518 
519  // Body:
520 
521  if(xauto_access)
522  {
523  get_read_access();
524  }
525 
526  result = !is_jim(xhub_id, true);
527 
528  if(xauto_access)
529  {
530  release_access();
531  }
532 
533  // Postconditions:
534 
535 
536  // Exit:
537 
538  return result;
539 }
540 
541 bool
543 is_multisection(const scoped_index& xid, bool xauto_access) const
544 {
545  bool result;
546 
547  // Preconditions:
548 
549  require(xauto_access || state_is_read_accessible());
550  require(contains_member(xid, xauto_access));
551 
552  // Body:
553 
554  return is_multisection(xid.hub_pod(), xauto_access);
555 }
556 
557 std::string
559 branch_id_space_name(pod_index_type xhub_id, bool xauto_access) const
560 {
561  string result;
562 
563  // Preconditions:
564 
565  require(xauto_access || state_is_read_accessible());
566 
567  // Body:
568 
569  pod_index_type lseq_id = multisection_id_space(xauto_access).pod(xhub_id);
570 
571  result = poset_path::make_reserved_name("", lseq_id, "_branch_ids");
572 
573  // Postconditions:
574 
575  ensure(!result.empty());
576 
577  // Exit:
578 
579  return result;
580 }
581 
582 std::string
584 branch_id_space_name(const scoped_index& xid, bool xauto_access) const
585 {
586  string result;
587 
588  // Preconditions:
589 
590  require(xauto_access || state_is_read_accessible());
591 
592  // Body:
593 
594  result = branch_id_space_name(xid.hub_pod(), xauto_access);
595 
596  // Postconditions:
597 
598  ensure(!result.empty());
599 
600  // Exit:
601 
602  return result;
603 }
604 
607 multisection_id_space(bool xauto_access) const
608 {
609  // Preconditions:
610 
611  require(xauto_access || state_is_read_accessible());
612 
613  // Body:
614 
615  if(xauto_access)
616  {
617  get_read_access();
618  }
619 
620  static const string multisection_id_space_name("__multisections");
621 
623 
625  {
626  sec_rep_space* cthis = const_cast<sec_rep_space*>(this);
627 
628  array_index_space_handle lmultisection_id_space =
630  multisection_id_space_name,
631  true, 0);
632 
633  _multisection_id_space.attach_to(lmultisection_id_space);
634  }
635 
637 
638  if(xauto_access)
639  {
640  release_access();
641  }
642 
643  // Postconditions:
644 
645  ensure(result.is_attached());
646 
647  // Exit:
648 
649  return result;
650 }
651 
654 multisection_id_space(bool xauto_access)
655 {
656  // Preconditions:
657 
658  require(xauto_access || state_is_read_accessible());
659 
660  // Body:
661 
662  if(xauto_access)
663  {
664  get_read_access();
665  }
666 
667  static const string multisection_id_space_name("__multisections");
668 
670 
672  {
673  sec_rep_space* cthis = const_cast<sec_rep_space*>(this);
674 
675  array_index_space_handle lmultisection_id_space =
677  multisection_id_space_name,
678  true, 0);
679 
680  _multisection_id_space.attach_to(lmultisection_id_space);
681  }
682 
684 
685  if(xauto_access)
686  {
687  release_access();
688  }
689 
690  // Postconditions:
691 
692  ensure(result.is_attached());
693 
694  // Exit:
695 
696  return result;
697 }
698 
701 get_branch_id_space(pod_index_type xhub_id, bool xauto_access)
702 {
703  // Preconditions:
704 
705  require(xauto_access || state_is_read_accessible());
706  require(contains_member(xhub_id, xauto_access));
707  require(is_multisection(xhub_id, xauto_access));
708  require(member_id_spaces(xauto_access).contains(branch_id_space_name(xhub_id, xauto_access)));
709 
710 
711  // Body:
712 
713  if(xauto_access)
714  {
715  get_read_access();
716  }
717 
720 
721  if(xauto_access)
722  {
723  release_access();
724  }
725 
726  // Postconditions:
727 
728  ensure(result.is_attached());
729 
730  // Exit:
731 
732  return result;
733 }
734 
737 get_branch_id_space(const scoped_index& xid, bool xauto_access)
738 {
739  // Preconditions:
740 
741  require(xauto_access || state_is_read_accessible());
742  require(contains_member(xid, xauto_access));
743  require(is_multisection(xid, xauto_access));
744  require(member_id_spaces(xauto_access).contains(branch_id_space_name(xid, xauto_access)));
745 
746  // Body:
747 
749  get_branch_id_space(xid.hub_pod(), xauto_access);
750 
751  // Postconditions:
752 
753  ensure(result.is_attached());
754 
755  // Exit:
756 
757  return result;
758 }
759 
760 void
762 release_branch_id_space(index_space_handle& xid_space, bool xauto_access) const
763 {
764  // Preconditions:
765 
766  require(xauto_access || state_is_read_accessible());
767  require(allocated_branch_handle(xid_space, xauto_access));
768 
769  // Body:
770 
771  member_id_spaces(xauto_access).release_id_space(xid_space);
772 
773  // Postconditions:
774 
775  ensure(is_basic_query);
776 
777  // Exit:
778 
779  return;
780 }
781 
782 bool
784 allocated_branch_handle(index_space_handle& xid_space, bool xauto_access) const
785 {
786  // Preconditions:
787 
788  require(xauto_access || state_is_read_accessible());
789 
790  // Body:
791 
792  bool result = member_id_spaces(xauto_access).allocated_id_space(xid_space);
793 
794  // Postconditions:
795 
796  ensure(is_basic_query);
797 
798  // Exit:
799 
800  return result;
801 }
802 
805 get_branch_id_space_iterator(pod_index_type xhub_id, bool xauto_access) const
806 {
807  // Preconditions:
808 
809  require(xauto_access || state_is_read_accessible());
810  require(contains_member(xhub_id, xauto_access));
811  require(is_multisection(xhub_id, xauto_access));
812  require(member_id_spaces(xauto_access).contains(branch_id_space_name(xhub_id, xauto_access)));
813 
814 
815  // Body:
816 
817  if(xauto_access)
818  {
819  get_read_access();
820  }
821 
822  index_space_iterator& result =
824 
825  if(xauto_access)
826  {
827  release_access();
828  }
829 
830  // Postconditions:
831 
832  ensure(result.is_attached());
833 
834  // Exit:
835 
836  return result;
837 }
838 
841 get_branch_id_space_iterator(const scoped_index& xid, bool xauto_access) const
842 {
843  // Preconditions:
844 
845  require(xauto_access || state_is_read_accessible());
846  require(contains_member(xid, xauto_access));
847  require(is_multisection(xid, xauto_access));
848  require(member_id_spaces(xauto_access).contains(branch_id_space_name(xid, xauto_access)));
849 
850  // Body:
851 
852  index_space_iterator& result =
853  get_branch_id_space_iterator(xid.hub_pod(), xauto_access);
854 
855  // Postconditions:
856 
857  ensure(result.is_attached());
858 
859  // Exit:
860 
861  return result;
862 }
863 
864 void
867 {
868  // Preconditions:
869 
870  require(xauto_access || state_is_read_accessible());
871  require(allocated_branch_iterator(xitr, xauto_access));
872 
873  // Body:
874 
875  member_id_spaces(xauto_access).release_id_space_iterator(xitr);
876 
877  // Postconditions:
878 
879  ensure(is_basic_query);
880 
881  // Exit:
882 
883  return;
884 }
885 
886 bool
888 allocated_branch_iterator(index_space_iterator& xitr, bool xauto_access) const
889 {
890  // Preconditions:
891 
892  require(xauto_access || state_is_read_accessible());
893 
894  // Body:
895 
896  bool result = member_id_spaces(xauto_access).allocated_id_space_iterator(xitr);
897 
898  // Postconditions:
899 
900  ensure(is_basic_query);
901 
902  // Exit:
903 
904  return result;
905 }
906 
907 // PROTECTED MEMBER FUNCTIONS
908 
909 // PRIVATE MEMBER FUNCTIONS
910 
911 
912 // =============================================================================
913 // STATE FACET
914 // =============================================================================
915 
916 // PUBLIC MEMBER FUNCTIONS
917 
920 type_id() const
921 {
922  return SEC_REP_SPACE_ID;
923 }
924 
925 const char*
927 class_name() const
928 {
929  // Preconditions:
930 
931  // Body:
932 
933  static const char* result = "sec_rep_space";
934 
935  // Postconditions:
936 
937  // Exit:
938 
939  return result;
940 }
941 
942 void
944 begin_jim_edit_mode(bool xauto_access)
945 {
946  // Preconditions:
947 
948  require(!xauto_access ? state_is_read_write_accessible() : true);
949 
950  // Body:
951 
952  if(xauto_access)
953  get_read_write_access(true);
954 
955  // Redefinition here is only to change visibility.
956 
958 
959  // Postconditions:
960 
962  ensure(in_jim_edit_mode());
963 
964  // Exit
965 
966  return;
967 }
968 
969 void
971 end_jim_edit_mode(bool xensure_lattice_invariant, bool xauto_access)
972 {
973  // Preconditions:
974 
975  require(in_jim_edit_mode());
977 
978  // Body:
979 
980  // Redefinition here is only to change visibility
981 
982  poset_state_handle::end_jim_edit_mode(xensure_lattice_invariant, xauto_access);
983 
984  // Postconditions:
985 
986  // Exit
987 
988  return;
989 }
990 
991 // PROTECTED MEMBER FUNCTIONS
992 
993 void
995 new_state(const poset_path& xpath, const schema_poset_member& xschema, array_poset_dof_map& xdof_map)
996 {
997 
998  // Preconditions:
999 
1000  require(schema_is_ancestor_of(&xschema));
1001  require(xschema.state_is_read_accessible());
1002 
1005 
1007 
1008  require(unexecutable("xschema.is_same_state(xdof_map.schema())"));
1009 
1010  // Body:
1011 
1012  // Disable invariant checking in
1013  // member functions until construction finished
1014 
1016 
1017  // Create the state object;
1018  // Allocates the data structures but does not (fully) initialize them
1019 
1020  _state = new poset_state(&xschema, type_id(), xpath.poset_name());
1021 
1022  // Get write access
1023 
1025 
1026  // Initialize the table dofs ("class variables")
1027 
1028  initialize_table_dof_tuple(&xdof_map);
1029 
1030  // Initialize the row structure
1031 
1034 
1035  // Set the standard id spaces.
1036 
1038 
1039  // Now invariant should be satisfied
1040 
1042 
1043  // Postconditions:
1044 
1045  ensure(invariant());
1046  ensure(is_attached());
1047  ensure(!in_jim_edit_mode());
1048  ensure(schema().is_same_state(&xschema));
1049  ensure(has_standard_member_ct());
1051  ensure(has_standard_subposet_ct());
1052  ensure(member_id_spaces(false).has_only_standard_id_spaces());
1053  ensure(base().is_same_state(&(reinterpret_cast<const section_space_schema_member&>(xschema).base_space())));
1054  ensure(schema().fiber_space().is_same_state(&(reinterpret_cast<const section_space_schema_member&>(xschema).host()->fiber_space())));
1055  ensure(rep().is_same_state(&(reinterpret_cast<const section_space_schema_member&>(xschema).rep())));
1056 
1057  // Now we're finished, release all access
1058 
1059  release_access();
1060 
1061  // One final postcondition
1062 
1063  ensure(state_is_not_read_accessible());
1064 }
1065 
1066 // PRIVATE MEMBER FUNCTIONS
1067 
1068 
1069 // =============================================================================
1070 // MEMBERSHIP FACET
1071 // =============================================================================
1072 
1073 // PUBLIC MEMBER FUNCTIONS
1074 
1078 {
1079  // Preconditions:
1080 
1081  // Body:
1082 
1083  // Postconditions:
1084 
1085  // Exit
1086 
1087  return *(static_cast<sec_rep_space_member*>(_top));
1088 }
1089 
1092 top() const
1093 {
1094  // Preconditions:
1095 
1096  // Body:
1097 
1098  // Postconditions:
1099 
1100  // Exit
1101 
1102  return *(static_cast<sec_rep_space_member*>(_top));
1103 }
1104 
1108 {
1109  // Preconditions:
1110 
1111  // Body:
1112 
1113  // Postconditions:
1114 
1115  // Exit
1116 
1117  return *(static_cast<sec_rep_space_member*>(_bottom));
1118 }
1119 
1122 bottom() const
1123 {
1124  // Preconditions:
1125 
1126  // Body:
1127 
1128  // Postconditions:
1129 
1130  // Exit
1131 
1132  return *(static_cast<const sec_rep_space_member*>(_bottom));
1133 }
1134 
1135 // PROTECTED MEMBER FUNCTIONS
1136 
1137 // PRIVATE MEMBER FUNCTIONS
1138 
1139 
1140 // =============================================================================
1141 // SCHEMA FACET
1142 // =============================================================================
1143 
1144 // PUBLIC MEMBER FUNCTIONS
1145 
1149 {
1150 
1151  // Preconditions:
1152 
1153  require(state_is_read_accessible());
1154 
1155  // Body:
1156 
1157  section_space_schema_member& result =
1159 
1160  // Postconditions:
1161 
1162  // Exit
1163 
1164  return result;
1165 }
1166 
1169 schema() const
1170 {
1171 
1172  // Preconditions:
1173 
1174  require(state_is_read_accessible());
1175 
1176  // Body:
1177 
1178  const section_space_schema_member& result =
1180 
1181  // Postconditions:
1182 
1183  // Exit
1184 
1185  return result;
1186 }
1187 
1190 schema(bool xauto_access)
1191 {
1192 
1193  // Preconditions:
1194 
1195  require(xauto_access || state_is_read_accessible());
1196 
1197  // Body:
1198 
1199  if(xauto_access)
1200  {
1201  get_read_access();
1202  }
1203 
1204  section_space_schema_member& result = schema();
1205 
1206  if(xauto_access)
1207  {
1208  release_access();
1209  }
1210 
1211  // Postconditions:
1212 
1213  // Exit
1214 
1215  return result;
1216 }
1217 
1220 schema(bool xauto_access) const
1221 {
1222 
1223  // Preconditions:
1224 
1225  require(xauto_access || state_is_read_accessible());
1226 
1227  // Body:
1228 
1229  if(xauto_access)
1230  {
1231  get_read_access();
1232  }
1233 
1234  const section_space_schema_member& result = schema();
1235 
1236  if(xauto_access)
1237  {
1238  release_access();
1239  }
1240 
1241  // Postconditions:
1242 
1243  // Exit
1244 
1245  return result;
1246 }
1247 
1248 bool
1250 schema_is_ancestor_of(const schema_poset_member* xother_schema) const
1251 {
1252  bool result;
1253 
1254  // Preconditions:
1255 
1256  // Body:
1257 
1258  result = dynamic_cast<const section_space_schema_member*>(xother_schema) != 0;
1259 
1260 
1261  // Postconditions:
1262 
1263  // Exit
1264 
1265  return result;
1266 }
1267 
1268 int
1270 dof_ct(bool xis_table_dof) const
1271 {
1272  int result;
1273 
1274  // Preconditions:
1275 
1276  require(state_is_read_accessible());
1277  // need access to dof subposet, which is in schema().host()
1278 
1279  // Body:
1280 
1281  result = schema().dof_ct(xis_table_dof);
1282 
1283  // Postconditions:
1284 
1285  ensure(result >= 0);
1286 
1287  // Exit
1288 
1289  return result;
1290 }
1291 
1292 bool
1294 row_dof_map_conforms(const poset_dof_map* xdof_map) const
1295 {
1296  bool result;
1297 
1298  // Preconditions:
1299 
1300  require(xdof_map != 0);
1301 
1302  // Body:
1303 
1304  // Row dofs, map must be a section_dof_map
1305 
1306  result = (dynamic_cast<const section_dof_map*>(xdof_map) != 0);
1307 
1308  // Postconditions:
1309 
1310  ensure(result ? (dynamic_cast<const section_dof_map*>(xdof_map) != 0) : true);
1311 
1312  // Exit
1313 
1314  return result;
1315 }
1316 
1317 
1318 size_t
1320 dof_tuple_ub(bool xis_table_dof) const
1321 {
1322  int result;
1323 
1324  // Preconditions:
1325 
1326  require(state_is_read_accessible());
1327 
1328  // Body:
1329 
1330  result = schema().dof_tuple_ub(xis_table_dof);
1331 
1332  // Postconditions:
1333 
1334  ensure(result >= 0);
1335 
1336  // Exit
1337 
1338  return result;
1339 }
1340 
1341 const sheaf::scoped_index&
1344 {
1345  // Preconditions:
1346 
1347  require(state_is_read_write_accessible());
1348 
1349  // Body:
1350 
1351  define_old_variable(int old_row_dof_tuple_ct = row_dof_tuple_ct());
1352 
1353  // Create a new dof map using contiguous array rep
1354 
1355  poset_dof_map* lmap = new array_section_dof_map(this);
1356  state_obj()->table()->put_row_dof_tuple(lmap);
1357  const scoped_index& result = lmap->index();
1358 
1359  // Postconditions:
1360 
1361  ensure(row_dof_tuple_ct() == old_row_dof_tuple_ct+1);
1362  ensure(contains_row_dof_tuple(result));
1363 
1364  // Exit
1365 
1366  return result;
1367 }
1368 
1369 const sheaf::scoped_index&
1371 new_row_dof_map(pod_index_type xbase_id, int xbase_version)
1372 {
1373  // Preconditions:
1374 
1375  require(state_is_read_write_accessible());
1376  require(schema().base_space().host()->contains_member(xbase_id));
1377  require(schema().base_space().geqv(xbase_id));
1378  require(schema().base_space().has_version(xbase_version));
1379 
1380  // Body:
1381 
1382  define_old_variable(int old_row_dof_tuple_ct = row_dof_tuple_ct());
1383 
1384  // Create a new dof map using contiguous array rep
1385 
1386  poset_dof_map* lmap = new array_section_dof_map(this, xbase_id, xbase_version);
1387  state_obj()->table()->put_row_dof_tuple(lmap);
1388  const scoped_index& result = lmap->index();
1389 
1390  // Postconditions:
1391 
1392  ensure(row_dof_tuple_ct() == old_row_dof_tuple_ct+1);
1393  ensure(contains_row_dof_tuple(result));
1394 
1395  // Exit
1396 
1397  return result;
1398 }
1399 
1400 const sheaf::scoped_index&
1402 new_row_dof_map(const scoped_index& xbase_id, int xbase_version)
1403 {
1404  // Preconditions:
1405 
1406  require(state_is_read_write_accessible());
1407  require(schema().base_space().host()->contains_member(xbase_id));
1408  require(schema().base_space().geqv(xbase_id));
1409  require(schema().base_space().has_version(xbase_version));
1410 
1411  // Body:
1412 
1413  define_old_variable(int old_row_dof_tuple_ct = row_dof_tuple_ct());
1414 
1415  const scoped_index& result = new_row_dof_map(xbase_id.hub_pod(),
1416  xbase_version);
1417 
1418  // Postconditions:
1419 
1420  ensure(row_dof_tuple_ct() == old_row_dof_tuple_ct+1);
1421  ensure(contains_row_dof_tuple(result));
1422 
1423  // Exit
1424 
1425  return result;
1426 }
1427 
1430 member_dof_map(pod_index_type xmbr_index, bool xrequire_write_access)
1431 {
1432  // Preconditions:
1433 
1434  require(xrequire_write_access ? state_is_read_write_accessible() : state_is_read_accessible());
1435  require(contains_member(xmbr_index));
1436  require(is_jim(xmbr_index, false));
1437 
1438  // Body:
1439 
1440  poset_dof_map& ldof_map =
1441  row_dof_map(member_dof_tuple_id(xmbr_index, false), xrequire_write_access);
1442 
1443  section_dof_map& result = reinterpret_cast<section_dof_map&>(ldof_map);
1444 
1445  // Postconditions:
1446 
1447  // Exit:
1448 
1449  return result;
1450 }
1451 
1454 member_dof_map(const scoped_index& xmbr_index, bool xrequire_write_access)
1455 {
1456  // Preconditions:
1457 
1458  require(xrequire_write_access ? state_is_read_write_accessible() : state_is_read_accessible());
1459  require(contains_member(xmbr_index));
1460  require(is_jim(xmbr_index, false));
1461 
1462  // Body:
1463 
1464  return member_dof_map(xmbr_index.hub_pod(), xrequire_write_access);
1465 }
1466 
1469 member_dof_map(pod_index_type xmbr_index, bool xrequire_write_access) const
1470 {
1471  // Preconditions:
1472 
1473  require(xrequire_write_access ? state_is_read_write_accessible() : state_is_read_accessible());
1474  require(contains_member(xmbr_index));
1475  require(is_jim(xmbr_index, false));
1476 
1477  // Body:
1478 
1479  poset_dof_map& ldof_map =
1480  row_dof_map(member_dof_tuple_id(xmbr_index, false), xrequire_write_access);
1481 
1482  section_dof_map& result = reinterpret_cast<section_dof_map&>(ldof_map);
1483 
1484  // Postconditions:
1485 
1486  // Exit:
1487 
1488  return result;
1489 }
1490 
1493 member_dof_map(const scoped_index& xmbr_index, bool xrequire_write_access) const
1494 {
1495  // Preconditions:
1496 
1497  require(xrequire_write_access ? state_is_read_write_accessible() : state_is_read_accessible());
1498  require(contains_member(xmbr_index));
1499  require(is_jim(xmbr_index, false));
1500 
1501  // Body:
1502 
1503  return member_dof_map(xmbr_index.hub_pod(), xrequire_write_access);
1504 }
1505 
1506 // PROTECTED MEMBER FUNCTIONS
1507 
1508 // PRIVATE MEMBER FUNCTIONS
1509 
1510 
1511 // =============================================================================
1512 // ANY FACET
1513 // =============================================================================
1514 
1515 // PUBLIC MEMBER FUNCTIONS
1516 
1519 clone() const
1520 {
1521  sec_rep_space* result;
1522 
1523  // Preconditions:
1524 
1525  // Body:
1526 
1527  result = new sec_rep_space;
1528 
1529  // Postconditions:
1530 
1531  ensure(result != 0);
1532  ensure(is_same_type(result));
1533 
1534  // Exit
1535 
1536  return result;
1537 }
1538 
1539 bool
1541 invariant() const
1542 {
1543  bool result = true;
1544 
1545  // Preconditions:
1546 
1547  // Body:
1548 
1550  if(invariant_check())
1551  {
1553 
1555 
1557  }
1558 
1559  // Postconditions:
1560 
1561  // Exit
1562 
1563  return result;
1564 }
1565 
1566 bool
1568 is_ancestor_of(const any* xother) const
1569 {
1570  bool result;
1571 
1572  // Preconditions:
1573 
1574  // Body:
1575 
1576  result = dynamic_cast<const sec_rep_space*>(xother) != 0;
1577 
1578  // Postconditions:
1579 
1580  // Exit
1581 
1582  return result;
1583 }
1584 
1585 // PROTECTED MEMBER FUNCTIONS
1586 
1587 // PRIVATE MEMBER FUNCTIONS
1588 
1589 
static bool rep_is_valid(const abstract_poset_member *xbase, const sec_rep_descriptor *xrep)
True if xrep is a valid rep descriptor for sec rep spaces over xbase,.
virtual void get_read_write_access(bool xrelease_read_only_access=false)
Get read write access to the state associated with this. If release_read_only_access is requested...
poset_state_handle * host() const
The poset which this is a handle to a component of.
bool allocated_id_space_iterator(const index_space_iterator &xitr) const
True if and only if id space iterator xitr was allocated by the iterator pool.
bool allocated_branch_handle(index_space_handle &xid_space, bool xauto_access) const
True if the handle pool allocated xid_space.
A client handle for a subposet.
Definition: subposet.h:86
void insert_prototype(const poset_state_handle *xprototype)
Sets xprototype as the prototype for its client class.
int db() const
The dimension of the base space.
bool has_standard_member_ct() const
True if poset is in its initial state, that is, it contains just the standard members.
virtual void attach_to(pod_type xindex)
Attach to the state with index xindex in the id space family id_spaces().
The private state of a partially ordered set.
Definition: poset_state.h:49
int discretization_ct() const
The number of members of the intersection of discretization with the down set of base.
The abstract map from section dof ids to section dof values of heterogeneous type.
An abstract iterator over the ids of an id space.
void release_id_space(index_space_handle &xid_space) const
Returns the id space handle xid_space to the handle pool.
virtual poset_state * state_obj() const
State object for this poset.
void put_row_dof_tuple(poset_dof_map *xdof_tuple)
Sets the dof tuple at index xindex to xdof_tuple.
void initialize_table_dof_tuple(array_poset_dof_map *xdof_tuple)
Installs xdof_tuple as the table dof tuple.
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
bool allocated_branch_iterator(index_space_iterator &xitr, bool xauto_access) const
True if the iterator pool allocated xitr.
poset_type
Identifiers for poset types.
Definition: poset_type.h:41
pod_index_type member_dof_tuple_id(pod_index_type xmbr_hub_id, bool xauto_access) const
The dof tuple hub id of the member with hub id xmbr_hub_id.
std::string evaluator_family() const
The name of the evaluator family used by this section space.
virtual void initialize_standard_members()
Creates the members common to every poset, for instance, top() and bottom().
A client handle for a general, abstract partially order set.
index_space_handle & get_id_space(const std::string &xname) const
Allocates an id space handle from the handle pool attached to state with name xname.
static int dof_ct(const namespace_poset &xns, const poset_path &xpath, bool xis_table_dof, bool xauto_access=true)
The number of table dofs (xis_table_dof true) or row dofs defined by the schema specified by xns and ...
A path defined by a poset name and a member name separated by a forward slash (&#39;/&#39;). For example: "cell_definitions/triangle".
Definition: poset_path.h:48
A member of a sec_rep_space; a section.
const index_space_family & member_id_spaces(bool xauto_access) const
Collection of member id spaces for this (const version).
virtual void initialize_standard_subposets(const std::string &xname)
Creates the subposets common to every poset (e.g. whole() and jims()).
virtual size_t dof_tuple_ub(bool xis_table_dof) const
The size in bytes of the table/row dof tuple.
STL namespace.
abstract_poset_member * _top
Top member of poset.
An abstract handle to a space of alternate integer identifiers (aliases) for a subset of a hub set of...
int df() const
The dimension of the fiber space.
The general, abstract map from dof ids to dof values.
Definition: poset_dof_map.h:59
namespace_poset * host() const
The namespace this poset resides in. Obsolete; use name_space() instead.
poset_table_state * table() const
Table (dof tuples).
Definition: poset_state.cc:260
index_space_iterator & get_id_space_iterator(const std::string &xname) const
Allocates an id space iterator from the iterator pool attached to state with name xname...
abstract_poset_member & base()
The base space for this section space (mutable version)
bool has_version(int xversion) const
True if xversion is a valid version.
abstract_poset_member * _bottom
Bottom members of poset.
virtual pod_type pod(pod_type xid) const
The pod index in this space equivalent to xid in the hub id space.
sec_rep_space_member & top()
The top of member of the lattice (mutable version)
Abstract base class with useful features for all objects.
Definition: any.h:39
bool invariant() const
The class invariant.
sec_rep_descriptor & rep()
A representation descriptor for this sec rep space (mutable version).
virtual section_space_schema_member & schema()
The schema for this poset (mutable version)
std::string url() const
The url for a description of the representation.
virtual bool schema_is_ancestor_of(const schema_poset_member *xother_schema) const
True if xother_schema conforms to the type of schema required by this.
virtual schema_poset_member & schema()
The schema for this poset (mutable version).
section_dof_map & member_dof_map(pod_index_type xmbr_index, bool xrequire_write_access=false)
The dof map associated with the member identified by xmbr_id (mutable version).
const scattered_insertion_index_space_handle & multisection_id_space(bool xauto_access) const
The sequence id space for multisections (const version).
void release_branch_id_space(index_space_handle &xid_space, bool xauto_access) const
Returns the id space handle xid_space to the handle pool.
bool has_standard_subposet_ct() const
True if poset is in its initial state, that is, it contains just the standard subposets.
void update_standard_member_id_spaces()
Update the initially allocated id spaces.
bool state_is_read_write_accessible() const
True if this is attached and if the state is accessible for read and write or access control is disab...
A contiguous tuple, contiguous fiber representation of the abstract map from section dof ids to secti...
subposet & discretization()
The subposet on which the degrees of freedom are defined (mutable version).
bool has_standard_row_dof_tuple_ct() const
True if poset is in its initial state, that is, it contains just the standard row_dof_tuples.
virtual int dof_ct(bool xis_table_dof) const
The number of dofs in the table/row dof tuple of this sec_rep_space;.
void release_id_space_iterator(index_space_iterator &xitr) const
Returns the id space iterator xitr to the iterator pool.
virtual const scoped_index & new_row_dof_map()
Creates a new row dof map for total sections of this.
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
virtual bool is_attached() const
True if this handle is attached to a state.
An array implementation of class scattered_insertion_index_space_handle. This representation is inten...
std::string poset_name() const
The poset name part of the path.
Definition: poset_path.cc:473
size_type row_dof_tuple_ct() const
The number of row_dof_tuples of this poset.
schema_poset_member & fiber_schema()
The schema of the fiber space, i.e. fiber().schema() (mutable version).
virtual bool contains_member(pod_index_type xmbr_hub_id, bool xauto_access=true) const
True if some version of this poset contains poset member with hub id xmbr_hub_id. ...
virtual void begin_jim_edit_mode(bool xauto_access=true)
allow editing of jims and jim order relation
virtual void begin_jim_edit_mode(bool xauto_access=true)
Allow editing of jims and jim order relation.
scattered_insertion_index_space_handle _multisection_id_space
The sequence id space for multisections.
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
Definition: any.h:97
virtual void release_access(bool xall=false) const
Release access. If xall is true, release all levels of access. Otherwise, release one level of access...
std::string branch_id_space_name(pod_index_type xhub_id, bool xauto_access) const
The name of the sequence id space for the branches of the multisection with hub id xhub_id...
poset_state_handle()
Default constructor.
scattered_insertion_index_space_handle & get_branch_id_space(pod_index_type xhub_id, bool xauto_access)
Allocate an id space handle from the handle pool attached to the branch id space of the multisection ...
virtual bool is_ancestor_of(const any *other) const
True if other conforms to this.
sec_rep_space_member & bottom()
The bottom of member of the lattice (mutable version)
static poset_handle_factory & factory()
The poset handle factory.
virtual ~sec_rep_space()
Destructor.
static const std::string & static_class_name()
The name of this class.
virtual poset_dof_map & row_dof_map(pod_index_type xtuple_hub_id, bool xrequire_write_access=false) const
The map from row dof client_ids to row dof values for dof tuple hub id xtuple_hub_id.
virtual bool is_attached() const
True if this is attached to a state.
int multiplicity() const
The number of degrees of freedom associated with each member of the discretization.
bool is_multisection(pod_index_type xhub_id, bool xauto_access) const
True if the section with hub id xhub_id is a multisection.
poset_state * _state
State object for this poset.
virtual poset_type type_id() const
Identifier for the type of this poset.
virtual bool is_attached() const =0
True if this iterator is attached to a state.
bool invariant_check() const
True if invariant checking is enabled.
Definition: any.h:79
bool allocated_id_space(const index_space_handle &xid_space) const
True if and only if id space handle xid_space was allocated by the handle pool.
size_t dof_tuple_ub(bool xis_table_dof) const
The size in bytes of the table dof tuple (xis_table_dof true) or the row dof tuple defined by this sc...
virtual bool row_dof_map_conforms(const poset_dof_map *xdof_map) const
True if xdof_map conforms to (i.e. is derived from) the type of row_dof map required by this poset...
virtual const char * class_name() const
The name of this class.
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
virtual void new_state(const poset_path &xpath, const schema_poset_member &xschema, array_poset_dof_map &xdof_map)
Creates a new poset state with path xpath, schema xschema and table dof map xdof_map, attaches this to the state.
A handle for a scattered_insertion_index_space_state.
A client handle for a poset member which has been prepared for use as a schema for a section space...
virtual void end_jim_edit_mode(bool xensure_lattice_invariant=true, bool xauto_access=true)
prevent editing of jims and jim order relation
sec_rep_space()
Default constructor; creates an unattached handle.
static array_index_space_handle new_space(index_space_family &xid_spaces, const std::string &xname, bool xis_persistent, size_type xcapacity)
Create a new array id space in the id space family xid_spaces at the next available id space index wi...
virtual bool is_jim(pod_index_type xmbr_hub_id, bool xin_current_version=true) const
True if the member with hub id xmbr_hub_id is a jim in the current version (xin_current_version == tr...
virtual void end_jim_edit_mode(bool xensure_lattice_invariant=true, bool xauto_access=true)
Prevent editing of jims and jim order relation.
bool is_same_state(const poset_state_handle *xother) const
True if this is attached to the same state as xother.
void release_branch_id_space_iterator(index_space_iterator &xitr, bool xauto_access) const
Returns the id space iterator xitr to the iterator pool.
virtual void get_read_access() const
Get read access to the state associated with this.
An abstract client handle for a member of a poset.
bool in_jim_edit_mode() const
True if editing jims and jim order relation is allowed.
An array representation of abstract class poset_dof_map.
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 sec_rep_space * clone() const
Virtual constructor.
void enable_invariant_check() const
Enable invariant checking.
Definition: any.h:87
bool contains_row_dof_tuple(pod_index_type xtuple_hub_id) const
True if this contains a tuple with hub id xtuple_hub_id.
bool state_is_not_read_accessible() const
True if this is attached and if the state is accessible for read or if access control is disabled...
virtual bool invariant() const
Class invariant.
A client handle for a poset member which has been prepared for use as a schema.
const scoped_index & index() const
The index of this in host() dof tuple table.
index_space_iterator & get_branch_id_space_iterator(pod_index_type xhub_id, bool xauto_access) const
Allocate an id space iterator from the iterator pool attached to the branch id space of the multisect...
subposet & evaluation()
The subposet on which the evaluation method is defined (mutable version).
static std::string make_reserved_name(const std::string &xprefix, const size_t &xindex, const std::string &xsuffix)
Creates a string reserved_prefix()_xprefix_xindex_xsuffix.
Definition: poset_path.cc:733
A description for a section representation scheme.
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.
Definition: scoped_index.h:710
A handle for a poset whose members are numerical representations of sections of a fiber bundle...
Definition: sec_rep_space.h:61