SheafSystem  0.0.0.0
ijk_adjacency_index_space_interval.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/ijk_adjacency_index_space_interval.h"
22 
23 #include "SheafSystem/abstract_product_structure.h"
24 #include "SheafSystem/assert_contract.h"
25 #include "SheafSystem/ijk_adjacency_implicit_index_space_iterator.h"
26 #include "SheafSystem/ijk_product_structure.h"
27 #include "SheafSystem/forwarding_index_space_handle.h"
28 #include "SheafSystem/explicit_index_space_state.h"
29 #include "SheafSystem/hub_index_space_handle.h"
30 #include "SheafSystem/index_space_family.h"
31 
32 using namespace std;
33 using namespace fiber_bundle; // Workaround for MS C++ bug.
34 
35 // ===========================================================
36 // SPACE FACTORY FACET
37 // ===========================================================
38 
39 // PUBLIC MEMBER FUNCTIONS
40 
44  size_type xub,
45  pod_type xzone_hub_begin,
46  size_type xi_size,
47  size_type xj_size,
48  size_type xk_size)
49 {
50  // Preconditions:
51 
52  require(xub > 0);
53  require(xid_spaces.hub_id_space().contains(xzone_hub_begin));
54  require(xi_size > 0);
55  require(xj_size > 0);
56  require(xk_size > 0);
57 
58  // Body:
59 
60  define_old_variable(size_type old_id_spaces_end = xid_spaces.end());
61 
63  result_ptr->new_state(xid_spaces, xub);
64 
65  result_ptr->_zone_hub_begin = xzone_hub_begin;
66  result_ptr->_i_size = xi_size;
67  result_ptr->_j_size = xj_size;
68  result_ptr->_k_size = xk_size;
69 
70  result_ptr->_i_vertex_size = result_ptr->_i_size+1;
71  result_ptr->_j_vertex_size = result_ptr->_j_size+1;
72  result_ptr->_k_vertex_size = result_ptr->_k_size+1;
73 
74  const ijk_adjacency_index_space_interval& result = *result_ptr;
75 
76  // Postconditions:
77 
78  ensure(&result.id_spaces() == &xid_spaces);
79  ensure(result.begin() == old_id_spaces_end);
80  ensure(result.end() == xid_spaces.end());
81  ensure(result.end() == result.begin() + xub);
82 
83  ensure(result.zone_hub_begin() == xzone_hub_begin);
84  ensure(result.i_size() == xi_size);
85  ensure(result.j_size() == xj_size);
86  ensure(result.k_size() == xk_size);
87 
88  // Exit:
89 
90  return result;
91 }
92 
93 // PROTECTED MEMBER FUNCTIONS
94 
95 // PRIVATE MEMBER FUNCTIONS
96 
97 
98 // ===========================================================
99 // IJK_ADJACENCY_INDEX_SPACE_INTERVAL FACET
100 // ===========================================================
101 
102 // PUBLIC MEMBER FUNCTIONS
103 
106 {
107  // Preconditions:
108 
109  // Body:
110 
111  // Nothing to do.
112 
113  // Postconditions:
114 
115  // Exit:
116 
117  return;
118 }
119 
123 {
124  // Preconditions:
125 
126  // Body:
127 
128  // Postconditions:
129 
130  ensure(is_basic_query);
131 
132  // Exit:
133 
134  return _zone_hub_begin;
135 }
136 
139 zone_hub_begin(pod_type xlocal_id) const
140 {
141  // Preconditions:
142 
143  // Body:
144 
145  // xlocal_id is the vertex id, compute the i, j indices.
146 
147  pod_type i, j, k;
148  sheaf::tuple(xlocal_id, _j_vertex_size, _k_vertex_size, i, j, k);
149 
150  // Calculate the first adjacent zone id.
151 
152  pod_type result = ordinal(i, j, k, _j_size, _k_size) + _zone_hub_begin;
153 
154  if(i > 0)
155  {
156  result -= _j_size*_k_size;
157  }
158 
159  if(j > 0)
160  {
161  result -= _k_size;
162  }
163 
164  if(k > 0)
165  {
166  result -= 1;
167  }
168 
169  // Postconditions:
170 
171  ensure(result >= zone_hub_begin());
172 
173  // Exit:
174 
175  return result;
176 }
177 
178 void
181  pod_type& xzone_hub_begin,
182  size_type& xi_ct,
183  size_type& xj_ct,
184  size_type& xk_ct) const
185 {
186  // Preconditions:
187 
188  require(contains(xlocal_id));
189 
190  // Body:
191 
192  // xlocal_id is the vertex id, compute the i, j, k indices.
193 
194  pod_type i, j, k;
195  sheaf::tuple(xlocal_id, _j_vertex_size, _k_vertex_size, i, j, k);
196 
197  // Calculate the first adjacent zone id and the number of adjacent
198  // zones in the i and j directions.
199 
200  xi_ct = 0;
201  xj_ct = 0;
202  xk_ct = 0;
203  xzone_hub_begin = ordinal(i, j, k, _j_size, _k_size) + _zone_hub_begin;
204 
205  if(i > 0)
206  {
207  xi_ct++;
208  xzone_hub_begin -= _j_size*_k_size;
209  }
210 
211  if(i < _i_size)
212  {
213  xi_ct++;
214  }
215 
216  if(j > 0)
217  {
218  xj_ct++;
219  xzone_hub_begin -= _k_size;
220  }
221 
222  if(j < _j_size)
223  {
224  xj_ct++;
225  }
226 
227  if(k > 0)
228  {
229  xk_ct++;
230  xzone_hub_begin--;
231  }
232 
233  if(k < _k_size)
234  {
235  xk_ct++;
236  }
237 
238  // Postconditions:
239 
240  ensure(xzone_hub_begin >= zone_hub_begin());
241  ensure((0 < xi_ct) && (xi_ct <= 2));
242  ensure((0 < xj_ct) && (xj_ct <= 2));
243  ensure((0 < xk_ct) && (xk_ct <= 2));
244 
245  // Exit:
246 
247  return;
248 }
249 
252 i_size() const
253 {
254  // Preconditions:
255 
256  // Body:
257 
258  // Postconditions:
259 
260  ensure(is_basic_query);
261 
262  // Exit:
263 
264  return _i_size;
265 }
266 
269 j_size() const
270 {
271  // Preconditions:
272 
273  // Body:
274 
275  // Postconditions:
276 
277  ensure(is_basic_query);
278 
279  // Exit:
280 
281  return _j_size;
282 }
283 
286 k_size() const
287 {
288  // Preconditions:
289 
290  // Body:
291 
292  // Postconditions:
293 
294  ensure(is_basic_query);
295 
296  // Exit:
297 
298  return _k_size;
299 }
300 
304 {
305  // Preconditions:
306 
307  // Body:
308 
309  // Postconditions:
310 
311  ensure(is_basic_query);
312 
313  // Exit:
314 
315  return _i_vertex_size;
316 }
317 
321 {
322  // Preconditions:
323 
324  // Body:
325 
326  // Postconditions:
327 
328  ensure(is_basic_query);
329 
330  // Exit:
331 
332  return _j_vertex_size;
333 }
334 
338 {
339  // Preconditions:
340 
341  // Body:
342 
343  // Postconditions:
344 
345  ensure(is_basic_query);
346 
347  // Exit:
348 
349  return _k_vertex_size;
350 }
351 
352 // PROTECTED MEMBER FUNCTIONS
353 
357 {
358  // Preconditions:
359 
360  // Body:
361 
362  // Postconditions:
363 
364  ensure(invariant());
365 
366  // Exit:
367 
368  return;
369 }
370 
371 // PRIVATE MEMBER FUNCTIONS
372 
373 
374 // ===========================================================
375 // INDEX_SPACE_INTERVAL FACET
376 // ===========================================================
377 
378 // PUBLIC MEMBER FUNCTIONS
379 
380 // PROTECTED MEMBER FUNCTIONS
381 
382 // PRIVATE MEMBER FUNCTIONS
383 
384 
385 // ===========================================================
386 // FACTORY FACET
387 // ===========================================================
388 
389 // PUBLIC MEMBER FUNCTIONS
390 
391 const std::string&
393 class_name() const
394 {
395  static const string result("ijk_adjacency_index_space_interval");
396  return result;
397 }
398 
401 clone() const
402 {
403  // Preconditions:
404 
405  // Body:
406 
409 
410  // Postconditions:
411 
412  ensure(result != 0);
413  ensure(is_same_type(result));
414 
415  // Exit:
416 
417  return result;
418 }
419 
420 // PROTECTED MEMBER FUNCTIONS
421 
422 // PRIVATE MEMBER FUNCTIONS
423 
424 bool
425 fiber_bundle::ijk_adjacency_index_space_interval::
426 make_prototype()
427 {
428  // Preconditions:
429 
430  // Body:
431 
433 
434  id_space_interval_factory().insert_prototype(lproto);
435 
436  // Postconditions:
437 
438  // Exit:
439 
440  return true;
441 }
442 
443 
444 // ===========================================================
445 // INDEX_SPACE_COLLECTION FACET
446 // ===========================================================
447 
448 // PUBLIC MEMBER FUNCTIONS
449 
450 bool
452 operator==(const index_space_collection& xother) const
453 {
454  // Preconditions:
455 
456  require(is_ancestor_of(&xother));
457 
458  // Body:
459 
460  const ijk_adjacency_index_space_interval& lother =
461  dynamic_cast<const ijk_adjacency_index_space_interval&>(xother);
462 
463  bool result = index_space_interval::operator==(xother);
464 
465  result = result && (_zone_hub_begin == lother._zone_hub_begin);
466  result = result && (_i_size == lother._i_size);
467  result = result && (_j_size == lother._j_size);
468  result = result && (_k_size == lother._k_size);
469  result = result && (_i_vertex_size == lother._i_vertex_size);
470  result = result && (_j_vertex_size == lother._j_vertex_size);
471  result = result && (_k_vertex_size == lother._k_vertex_size);
472 
473  // Postconditions:
474 
475  // Exit
476 
477  return result;
478 }
479 
482 deep_size(bool xinclude_shallow) const
483 {
484  // Preconditions:
485 
486  // Body:
487 
488  size_type result = fiber_bundle::deep_size(*this, xinclude_shallow);
489 
490  // Postconditions:
491 
492  ensure(result >= 0);
493 
494  // Exit:
495 
496  return result;
497 }
498 
499 // PROTECTED MEMBER FUNCTIONS
500 
504 {
505  // Preconditions:
506 
507  require(is_ancestor_of(&xother));
508 
509  // Body:
510 
511  const ijk_adjacency_index_space_interval& lother =
512  dynamic_cast<const ijk_adjacency_index_space_interval&>(xother);
513 
515  _i_size = lother._i_size;
516  _j_size = lother._j_size;
517  _k_size = lother._k_size;
521 
523 
524  // Postconditions:
525 
526  ensure(invariant());
527  ensure((*this) == xother);
528 
529  // Exit:
530 
531  return *this;
532 }
533 
536 explicit_state(pod_type xlocal_id) const
537 {
538  // Preconditions:
539 
540  // Body:
541 
543 
544  explicit_index_space_state* result = 0;
545 
546  // Postconditions:
547 
548  ensure(is_basic_query);
549 
550  // Exit:
551 
552  return result;
553 }
554 
555 // PRIVATE MEMBER FUNCTIONS
556 
557 
558 // ===========================================================
559 // INDEX SPACE FACET
560 // ===========================================================
561 
562 // PUBLIC MEMBER FUNCTIONS
563 
564 void
566 remove(pod_type xlocal_id)
567 {
568  // Preconditions:
569 
570  // Body:
571 
573 
574  not_implemented();
575 
576  // Postconditions:
577 
578  ensure(!contains(xlocal_id));
579 
580  // Exit:
581 
582  return;
583 }
584 
587 ct(pod_type xlocal_id) const
588 {
589  // Preconditions:
590 
591  require(contains(xlocal_id));
592 
593  // Body:
594 
595  // xlocal_id is the zone id, compute the i, j, k indices.
596 
597  pod_type i, j, k;
598  sheaf::tuple(xlocal_id, _j_vertex_size, _k_vertex_size, i, j, k);
599 
600  // Compute the count in each direction.
601 
602  pod_type result = 1;
603 
604  // Factor the adjacent zones in the i direction.
605 
606  if(i > 0 && i < _i_size)
607  {
608  // Not the first or last vertex in the i direction,
609  // this vertex is adjacent to 2 zones in the i direction.
610 
611  result *= 2;
612  }
613 
614  // Factor the adjacent zones in the j direction.
615 
616  if(j > 0 && i < _j_size)
617  {
618  // Not the first or last vertex in the j direction,
619  // this vertex is adjacent to 2 zones in the j direction.
620 
621  result *= 2;
622  }
623 
624  // Factor the adjacent zones in the k direction.
625 
626  if(k > 0 && i < _k_size)
627  {
628  // Not the first or last vertex in the k direction,
629  // this vertex is adjacent to 2 zones in the k direction.
630 
631  result *= 2;
632  }
633 
634  // Postconditions:
635 
636  ensure(is_basic_query);
637 
638  // Exit:
639 
640  return result;
641 }
642 
645 begin(pod_type xlocal_id) const
646 {
647  // Preconditions:
648 
649  require(contains(xlocal_id));
650 
651  // Body:
652 
653  pod_type result = 0;
654 
655  // Postconditions:
656 
657  ensure(is_basic_query);
658 
659  // Exit:
660 
661  return result;
662 }
663 
666 end(pod_type xlocal_id) const
667 {
668  // Preconditions:
669 
670  require(contains(xlocal_id));
671 
672  // Body:
673 
674  pod_type result = ct(xlocal_id);
675 
676  // Postconditions:
677 
678  ensure(is_basic_query);
679 
680  // Exit:
681 
682  return result;
683 }
684 
685 bool
687 contains(pod_type xlocal_id, pod_type xid) const
688 {
689  // Preconditions:
690 
691  require(contains(xlocal_id));
692 
693  // Body:
694 
695  bool result = (0 <= xid) && (xid < end(xlocal_id));
696 
697  // Postconditions:
698 
699  ensure(is_basic_query);
700 
701  // Exit:
702 
703  return result;
704 }
705 
706 bool
709 {
710  // Preconditions:
711 
712  require(contains(xlocal_id));
713 
714  // Body:
715 
716  // Compute the adjacent values.
717 
718  pod_type lzone_hub_begin;
719  size_type li_ct, lj_ct, lk_ct;
720 
721  adjacent_zones(xlocal_id, lzone_hub_begin, li_ct, lj_ct, lk_ct);
722 
723  // Factor the zone id relative to the first adjacent zone
724  // adjacent to vertex xlocal_id.
725 
726  pod_type i, j, k;
727  sheaf::tuple(xid - lzone_hub_begin, _j_size, _k_size, i, j, k);
728 
729  bool result = ((0 <= i) && (i < li_ct) &&
730  (0 <= j) && (j < lj_ct) &&
731  (0 <= k) && (k < lk_ct));
732 
733  // Postconditions:
734 
735  ensure(is_basic_query);
736 
737  // Exit:
738 
739  return result;
740 }
741 
742 bool
744 contains(pod_type xlocal_id, pod_type xid, pod_type xhub_id) const
745 {
746  // Preconditions:
747 
748  require(contains(xlocal_id));
749 
750  // Body:
751 
752  bool result = is_valid(xhub_id) && (hub_pod(xlocal_id, xid) == xhub_id);
753 
754  // Postconditions:
755 
756  ensure(is_basic_query);
757 
758  // Exit:
759 
760  return result;
761 }
762 
765 pod(pod_type xlocal_id, pod_type xid) const
766 {
767  // Preconditions:
768 
769  require(contains(xlocal_id));
770 
771  // Body:
772 
773  pod_type result;
774 
775  // Compute the adjacent values.
776 
777  pod_type lzone_hub_begin;
778  size_type li_ct, lj_ct, lk_ct;
779 
780  adjacent_zones(xlocal_id, lzone_hub_begin, li_ct, lj_ct, lk_ct);
781 
782  // Factor the zone id relative to the first adjacent zone
783  // adjacent to vertex xlocal_id.
784 
785  pod_type i, j, k;
786  sheaf::tuple(xid - lzone_hub_begin, _j_size, _k_size, i, j, k);
787 
788  // Compute pod.
789 
790  if((0 <= i) && (i < li_ct) &&
791  (0 <= j) && (j < lj_ct) &&
792  (0 <= k) && (k < lk_ct))
793  {
794  result = ordinal(i, j, k, lj_ct, lk_ct);
795  }
796  else
797  {
798  result = invalid_pod_index();
799  }
800 
801  // Postconditions:
802 
803  ensure(!is_valid(result) || contains(xlocal_id, result));
804 
805  // Exit:
806 
807  return result;
808 }
809 
812 unglued_hub_pod(pod_type xlocal_id, pod_type xid) const
813 {
814  // Preconditions:
815 
816  require(contains(xlocal_id));
817 
818  // Body:
819 
820  pod_type result;
821 
822  // Compute the adjacent values.
823 
824  pod_type lzone_hub_begin;
825  size_type li_ct, lj_ct, lk_ct;
826 
827  adjacent_zones(xlocal_id, lzone_hub_begin, li_ct, lj_ct, lk_ct);
828 
829  // Factor the pod.
830 
831  pod_type i, j, k;
832  sheaf::tuple(xid, lj_ct, lk_ct, i, j, k);
833 
834  // Calculate the hub pod.
835 
836  if((0 <= i) && (i < li_ct) &&
837  (0 <= j) && (j < lj_ct) &&
838  (0 <= k) && (k < lk_ct))
839  {
840  result = ordinal(i, j, k, _j_size, _k_size) + lzone_hub_begin;
841  }
842  else
843  {
844  result = invalid_pod_index();
845  }
846 
847  // Postconditions:
848 
849  ensure(!is_valid(result) || contains_unglued_hub(xlocal_id, result));
850 
851  // Exit:
852 
853  return result;
854 }
855 
856 bool
858 is_persistent(pod_type xlocal_id) const
859 {
860  // Preconditions:
861 
862  require(contains(xlocal_id));
863 
864  // Body:
865 
866  bool result = false;
867 
868  // Postconditions:
869 
870  ensure(is_basic_query);
871 
872  // Exit:
873 
874  return result;
875 }
876 
877 // PROTECTED MEMBER FUNCTIONS
878 
879 // PRIVATE MEMBER FUNCTIONS
880 
881 
882 // ===========================================================
883 // PRODUCT STRUCTURE FACET
884 // ===========================================================
885 
886 // PUBLIC MEMBER FUNCTIONS
887 
888 void
891  const abstract_product_structure& xproduct)
892 {
893  // Preconditions:
894 
895  require(contains(xlocal_id));
896 
897  // Body:
898 
900 
901  not_implemented();
902 
903  // Postconditions:
904 
905  ensure(has_product_structure(xlocal_id));
906 
907  // Exit:
908 
909  return;
910 }
911 
912 void
915 {
916  // Preconditions:
917 
918  require(contains(xlocal_id));
919 
920  // Body:
921 
923 
924  not_implemented();
925 
926  // Postconditions:
927 
928  ensure(!has_product_structure(xlocal_id));
929 
930  // Exit:
931 
932  return;
933 }
934 
937 product_structure(pod_type xlocal_id) const
938 {
939  // Preconditions:
940 
941  require(contains(xlocal_id));
942  require(has_product_structure(xlocal_id));
943 
944  // Body:
945 
947 
948  const abstract_product_structure* result = 0; // Just to silence compiler warnings.
949 
950  not_implemented();
951 
952  // Postconditions:
953 
954  ensure(is_basic_query);
955 
956  // Exit:
957 
958  return *result;
959 }
960 
964 {
965  // Preconditions:
966 
967  require(contains(xlocal_id));
968  require(has_product_structure(xlocal_id));
969 
970  // Body:
971 
973 
974  abstract_product_structure* result = 0; // Just to silence compiler warnings.
975 
976  not_implemented();
977 
978  // Postconditions:
979 
980  ensure(is_basic_query);
981 
982  // Exit:
983 
984  return *result;
985 }
986 
987 bool
990 {
991  // Preconditions:
992 
993  require(contains(xlocal_id));
994 
995  // Body:
996 
998 
999  bool result = false; // Just to silence compiler warnings.
1000 
1001  not_implemented();
1002 
1003  // Postconditions:
1004 
1005  ensure(is_basic_query);
1006 
1007  // Exit:
1008 
1009  return result;
1010 }
1011 
1012 // PROTECTED MEMBER FUNCTIONS
1013 
1014 // PRIVATE MEMBER FUNCTIONS
1015 
1016 
1017 // ===========================================================
1018 // HANDLE POOL FACET
1019 // ===========================================================
1020 
1021 // PUBLIC MEMBER FUNCTIONS
1022 
1025 get_id_space(pod_type xlocal_id) const
1026 {
1027  // Preconditions:
1028 
1029  require(contains(xlocal_id));
1030 
1031  // Body:
1032 
1033  index_space_handle& result = _handles.get();
1034  result.attach_to(*this, xlocal_id);
1035 
1036  // Postconditions:
1037 
1038  ensure(result.is_attached());
1039 
1040  // Exit:
1041 
1042  return result;
1043 }
1044 
1045 void
1048 {
1049  // Preconditions:
1050 
1051  require(allocated_id_space(xid_space));
1052 
1053  // Body:
1054 
1055  // Detach the handle.
1056 
1057  xid_space.detach();
1058 
1059  // Release the handle to the pool.
1060 
1061  _handles.release(reinterpret_cast<forwarding_index_space_handle&>(xid_space));
1062 
1063  // Postconditions:
1064 
1065  ensure(is_basic_query);
1066 
1067  // Exit:
1068 
1069  return;
1070 }
1071 
1072 bool
1075 {
1076  // Preconditions:
1077 
1078  // Body:
1079 
1080  const forwarding_index_space_handle* lid_space =
1081  dynamic_cast<const forwarding_index_space_handle*>(&xid_space);
1082 
1083  bool result = (lid_space != 0) && _handles.allocated(*lid_space);
1084 
1085  // Postconditions:
1086 
1087  ensure(is_basic_query);
1088 
1089  // Exit:
1090 
1091  return result;
1092 }
1093 
1094 // PROTECTED MEMBER FUNCTIONS
1095 
1096 // PRIVATE MEMBER FUNCTIONS
1097 
1098 
1099 // ===========================================================
1100 // ITERATOR POOL FACET
1101 // ===========================================================
1102 
1103 // PUBLIC MEMBER FUNCTIONS
1104 
1108 {
1109  // Preconditions:
1110 
1111  require(contains(xlocal_id));
1112 
1113  // Body:
1114 
1115  index_space_iterator& result = _iterators.get();
1116  result.attach_to(*this, xlocal_id);
1117 
1118  // Postconditions:
1119 
1120  ensure(result.is_attached());
1121 
1122  // Exit:
1123 
1124  return result;
1125 }
1126 
1127 void
1130 {
1131  // Preconditions:
1132 
1133  require(allocated_id_space_iterator(xitr));
1134 
1135  // Body:
1136 
1137  // Detach the iterator.
1138 
1139  xitr.detach();
1140 
1141  // Release the iterator to the pool.
1142 
1143  _iterators.release(reinterpret_cast<ijk_adjacency_implicit_index_space_iterator&>(xitr));
1144 
1145  // Postconditions:
1146 
1147  ensure(is_basic_query);
1148 
1149  // Exit:
1150 
1151  return;
1152 }
1153 
1154 bool
1157 {
1158  // Preconditions:
1159 
1160  // Body:
1161 
1163  dynamic_cast<const ijk_adjacency_implicit_index_space_iterator*>(&xitr);
1164 
1165  bool result = (litr != 0) && _iterators.allocated(*litr);
1166 
1167  // Postconditions:
1168 
1169  ensure(is_basic_query);
1170 
1171  // Exit:
1172 
1173  return result;
1174 }
1175 
1176 // PROTECTED MEMBER FUNCTIONS
1177 
1178 // PRIVATE MEMBER FUNCTIONS
1179 
1180 
1181 // ===========================================================
1182 // ANY FACET
1183 // ===========================================================
1184 
1185 // PUBLIC MEMBER FUNCTIONS
1186 
1187 bool
1189 is_ancestor_of(const any *other) const
1190 {
1191  // Preconditions:
1192 
1193  require(other != 0);
1194 
1195  // Body:
1196 
1197  // True if other conforms to this
1198 
1199  bool result = dynamic_cast<const ijk_adjacency_index_space_interval*>(other) != 0;
1200 
1201  // Postconditions:
1202 
1203  // Exit:
1204 
1205  return result;
1206 }
1207 
1208 bool
1210 invariant() const
1211 {
1212  bool result = true;
1213 
1214  if(invariant_check())
1215  {
1216  // Prevent recursive calls to invariant
1217 
1219 
1220  // Must satisfy base class invariant
1221 
1222  invariance(index_space_interval::invariant());
1223 
1224  // Invariances for this class:
1225 
1226  // Finished, turn invariant checking back on.
1227 
1229  }
1230 
1231  // Exit
1232 
1233  return result;
1234 }
1235 
1236 // PROTECTED MEMBER FUNCTIONS
1237 
1238 // PRIVATE MEMBER FUNCTIONS
1239 
1240 
1241 // ===========================================================
1242 // NON-MEMBER FUNCTIONS
1243 // ===========================================================
1244 
1245 size_t
1246 fiber_bundle::
1247 deep_size(const ijk_adjacency_index_space_interval& xn, bool xinclude_shallow)
1248 {
1249  // Preconditions:
1250 
1251  // Body:
1252 
1253  size_t result = xinclude_shallow ? sizeof(xn) : 0;
1254 
1255  // Add contributions for _handles.
1256 
1257  result += deep_size(xn._handles, false);
1258 
1259  // Add contributions for _iterators.
1260 
1261  result += deep_size(xn._iterators, false);
1262 
1263  // Postconditions:
1264 
1265  ensure(result >= 0);
1266 
1267  // Exit
1268 
1269  return result;
1270 }
size_type j_size() const
The number of zones in the j direction.
virtual ijk_adjacency_index_space_interval * clone() const
Virtual constructor; create a new instance of the same type at this.
virtual bool contains(pod_type xlocal_id, pod_type xid) const
True if the space with id xlocal_id contains id xid.
virtual explicit_index_space_state * explicit_state(pod_type xlocal_id) const
The explicit id space state for id xlocal_id. Returns null if there is no explicit id space for xloca...
pod_type end() const
The ending index of the id spaces.
size_type _j_size
The number of zones in the j direction.
An abstract class that defines the product structure for an id space.
virtual const std::string & class_name() const
The name of this class.
virtual const index_space_family & id_spaces() const
The id space family for this (const version).
An abstract iterator over the ids of an id space.
size_type _i_size
The number of zones in the i direction.
virtual bool is_ancestor_of(const any *other) const
Conformance test; true if other conforms to this.
size_type j_vertex_size() const
The number of vertices in the j direction.
pod_index_type ordinal(pod_index_type xi, pod_index_type xj, size_type xj_ub)
2-tuple to ordinal conversion.
virtual index_space_interval & operator=(const index_space_collection &xother)
Assignment operator.
virtual bool invariant() const
Class invariant.
friend SHEAF_DLL_SPEC size_t deep_size(const ijk_adjacency_index_space_interval &xn, bool xinclude_shallow)
The deep size of ijk_adjacency_index_space_interval& xn.
virtual pod_type begin(pod_type xlocal_id) const
Beginning id of this space with id xlocal_id.
void adjacent_zones(pod_type xlocal_id, pod_type &xzone_hub_begin, size_type &xi_ct, size_type &xj_ct, size_type &xk_ct) const
Compute the hub id of the fist adjacent zone and the number of adjacent zones in each direction for i...
STL namespace.
virtual bool contains_unglued_hub(pod_type xlocal_id, pod_type xid) const
True if the space with id xlocal_id contains an id equivalent to xid in the unglued hub id space...
virtual void detach()=0
Detach this handle form its state, if any.
An abstract handle to a space of alternate integer identifiers (aliases) for a subset of a hub set of...
virtual bool operator==(const index_space_collection &xother) const
True if this is equivalent to xother.
pod_index_type pod_type
The "plain old data" index type for this.
static const ijk_adjacency_index_space_interval & new_space(index_space_family &xid_spaces, size_type xub, pod_type xzone_hub_begin, size_type xi_size, size_type xj_size, size_type xk_size)
Create a new interval of id spaces for 3D structured block adjacency in the id space family xid_space...
virtual size_type ct(pod_type xlocal_id) const
The number of members for the id space with id xlocal_id.
virtual bool is_attached() const =0
True if this handle is attached to a state.
virtual void detach()=0
Detach this handle form its state, if any.
virtual void release_id_space_iterator(index_space_iterator &xitr) const
Returns the id space iterator xitr to the iterator pool.
size_type _i_vertex_size
The number of vertices in the i direction.
virtual void new_product_structure(pod_type xlocal_id, const abstract_product_structure &xproduct)
Creates a new product structure for the id space with id xlocal_id by cloning the product structure...
virtual index_space_handle & get_id_space(pod_type xlocal_id) const
Allocates an id space handle from the handle pool attached to state with id xlocal_id.
An implementation of implicit_index_space_iterator for an implicit id space in an ijk_adjacency_index...
size_type k_size() const
The number of zones in the k direction.
Abstract base class with useful features for all objects.
Definition: any.h:39
virtual ijk_adjacency_index_space_interval & operator=(const index_space_collection &xother)
Assignment operator.
An implemenation of index_space_collection that adds an interface for the interval [begin()...
size_type _k_vertex_size
The number of vertices in the k direction.
An immutable abstract state for a space of alternate integer identifiers (aliases) for a subset of th...
size_type k_vertex_size() const
The number of vertices in the k direction.
size_type _k_size
The number of zones in the k direction.
list_pool< forwarding_index_space_handle > _handles
The handle pool.
pod_type zone_hub_begin() const
The hub id of the beginning of the zone id space.
virtual void remove(pod_type xlocal_id)
Remove the id space with id xlocal_id.
An implementation of class index_space_handle for an forwarding_index_space_state.
virtual const abstract_product_structure & product_structure(pod_type xlocal_id) const
The product structure for the id space with id xlocal_id (const version).
void attach_to(const index_space_family &xid_spaces, pod_type xindex)
Attach to the state with index xindex in the id space family xid_spaces.
virtual 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.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
An implementation of index_space_interval for an interval of implicit id spaces for the adjacency of ...
virtual void release_id_space(index_space_handle &xid_space) const
Returns the id space handle xid_space to the handle pool.
virtual pod_type end(pod_type xlocal_id) const
Ending id of this space with id xlocal_id.
size_type i_vertex_size() const
The number of vertices in the i direction.
A collection of id space states. This is a virtual class with provides an interface for accessing the...
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
Definition: any.h:97
void attach_to(const index_space_family &xid_spaces, pod_type xindex)
Attach to the state with index xindex in the id space family xid_spaces.
static factory< index_space_interval > & id_space_interval_factory()
A factory for making descendants of this class.
SHEAF_DLL_SPEC size_t deep_size(const sec_vd &x0, bool xinclude_shallow=true)
The deep size of the referenced object of type sec_vd. if xinclude_shallow, add the sizeof x0 to the ...
Definition: sec_vd.cc:1448
virtual 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_type i_size() const
The number of zones in the i direction.
virtual pod_type pod(pod_type xlocal_id, pod_type xid) const
The pod index in the space with id xlocal_id equivalent to xid in the hub id space.
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
pod_type _zone_hub_begin
The hub id of the beginning of the zone id space.
size_type _j_vertex_size
The number of vertices in the j direction.
pod_type end() const
Ending space id of this interval in the id space family scope.
void tuple(pod_index_type x, size_type xj_ub, pod_index_type &xi, pod_index_type &xj)
Ordinal to 2-tuple conversion.
virtual void delete_product_structure(pod_type xlocal_id)
Deletes the product structure for the id space with id xlocal_id.
virtual pod_type unglued_hub_pod(pod_type xlocal_id, pod_type xid) const
The pod index in the unglued_hub id space equivalent to xid in the id space with id xlocal_id...
Factory and container for a family of id spaces.
pod_type hub_pod(pod_type xlocal_id, pod_type xid) const
The pod index in the glued hub id space equivalent to xid in the id space with id xlocal_id...
virtual bool operator==(const index_space_collection &xother) const
True if this is equivalent to xother.
virtual bool is_persistent(pod_type xlocal_id) const
True if the id space with id xlocal_id should be written to disk.
SHEAF_DLL_SPEC bool is_valid(pod_index_type xpod_index)
True if an only if xpod_index is valid.
Definition: pod_types.cc:37
Namespace for the fiber_bundles component of the sheaf system.
pod_type begin() const
Beginning space id of this interval in the id space family scope.
SHEAF_DLL_SPEC pod_index_type invalid_pod_index()
The invalid pod index value.
Definition: pod_types.cc:31
bool is_same_type(const any *other) const
True if other is the same type as this.
Definition: any.cc:79
void enable_invariant_check() const
Enable invariant checking.
Definition: any.h:87
virtual bool has_product_structure(pod_type xlocal_id) const
True if the id space with id xlocal_id has a product structure.
const hub_index_space_handle & hub_id_space() const
The hub id space of this family.
virtual bool contains(pod_type xid) const
True if this space contains id xid.
list_pool< ijk_adjacency_implicit_index_space_iterator > _iterators
The iterator pool.
virtual index_space_iterator & get_id_space_iterator(pod_type xlocal_id) const
Allocates an id space iterator from the iterator pool attached to state with id xlocal_id.