SheafSystem  0.0.0.0
base_space_poset.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/base_space_poset.h"
22 
23 #include "SheafSystem/array_index_space_state.h"
24 #include "SheafSystem/array_poset_dof_map.h"
25 #include "SheafSystem/base_space_member.h"
26 #include "SheafSystem/index_space_handle.h"
27 #include "SheafSystem/index_space_iterator.h"
28 #include "SheafSystem/interval_index_space_state.h"
29 #include "SheafSystem/namespace_poset.impl.h"
30 #include "SheafSystem/namespace_poset_member.h"
31 #include "SheafSystem/poset_handle_factory.h"
32 #include "SheafSystem/poset_type.h"
33 #include "SheafSystem/preorder_iterator.h"
34 #include "SheafSystem/std_sstream.h"
35 #include "SheafSystem/zone_nodes_block_crg_interval.h"
36 
37 using namespace std;
38 using namespace fiber_bundle;
39 
40 // ===========================================================
41 // BASE_SPACE_POSET FACET
42 // ===========================================================
43 
44 // PUBLIC FUNCTIONS
45 
46 const sheaf::poset_path&
49 {
50  // Preconditions:
51 
52 
53  // Body:
54 
55  static const poset_path& result = base_space_member::standard_schema_path();
56 
57  // Postconditions:
58 
59  ensure(result.full());
60 
61  // Exit:
62 
63  return result;
64 }
65 
68 new_table(namespace_type& xns, const poset_path& xpath, const poset_path& xschema_path, int xmax_db, bool xauto_access)
69 {
70  // cout << endl << "Entering base_space_poset::new_table." << endl;
71 
72  // Preconditions:
73 
74  require(xns.state_is_auto_read_write_accessible(xauto_access));
75 
76  require(!xpath.empty());
77  require(!xns.contains_path(xpath, xauto_access));
78 
79  require(xschema_path.full());
80  require(xns.path_is_auto_read_accessible(xschema_path, xauto_access));
81  require(unexecutable("xschema_path conforms to standard_schema_path"));
82  // require(schema_poset_member::conforms_to(xns, xschema_path, standard_schema_path(), xauto_access));
83 
84  require(xmax_db >= 0);
85 
86  // Body:
87 
88  // Create the table; have to new it because namespace keeps a pointer.
89 
90  typedef base_space_poset table_type;
91 
92  table_type* ltable = new table_type();
93 
94  // Create a handle of the right type for the schema member.
95 
96  schema_poset_member lschema(&xns, xschema_path, xauto_access);
97 
98  if(xauto_access)
99  {
100  lschema.get_read_access();
101  }
102 
103  // Create the table dof map and set dof values;
104  // must be newed because poset_state::_table keep a pointer to it.
105 
106  array_poset_dof_map* lmap = new array_poset_dof_map(&lschema, true);
107  lmap->put_dof("max_db", xmax_db);
108 
109  // Create the state.
110 
111  ltable->new_state(xns, xpath, lschema, *lmap);
112 
113  if(xauto_access)
114  {
115  lschema.release_access();
116  }
117 
118  base_space_poset& result = *ltable;
119 
120  // Postconditions:
121 
122  ensure(xns.owns(result, xauto_access));
123  ensure(result.path(true) == xpath);
124  ensure(result.state_is_not_read_accessible());
125  ensure(result.schema(true).path(xauto_access) == xschema_path);
126 
127  ensure(result.max_db() == xmax_db);
128 
129  // Exit:
130 
131  // cout << "Leaving base_space_poset::new_table." << endl;
132  return result;
133 }
134 
135 // PROTECTED FUNCTIONS
136 
139 {
140  // Preconditions:
141 
142  // Body:
143 
144  // Nothing to do, handled by base class
145 
146  // Postconditions:
147 
148  ensure(postcondition_of(refinable_poset::refinable_poset()));
149 }
150 
153 {
154  // Preconditions:
155 
156  // Body:
157 
158  // Postconditions:
159 
160  // Exit
161 
162  return;
163 }
164 
165 // PRIVATE FUNCTIONS
166 
167 bool
168 fiber_bundle::base_space_poset::
169 make_prototype()
170 {
171  bool result = false;
172 
173  // Preconditions:
174 
175  // Body:
176 
177  poset_type ltype = POSET_ID;
178 
179  base_space_poset* lproto = new base_space_poset;
180 
181  factory().insert_prototype(lproto);
182  factory().insert_prototype(ltype, lproto);
183 
184  // Postconditions:
185 
186  // Exit:
187 
188  return result;
189 }
190 
191 // ===========================================================
192 // ZONE ID SPACE FACET
193 // ===========================================================
194 
195 // PUBLIC FUNCTIONS
196 
197 bool
199 contains_zone_id_space(pod_index_type xmbr_id, bool xauto_access) const
200 {
201  // Preconditions:
202 
203  require(state_is_auto_read_accessible(xauto_access));
204  require(contains_member(xmbr_id, xauto_access));
205 
206  // Body:
207 
208  if(xauto_access)
209  {
210  get_read_access();
211  }
212 
213  const homogeneous_block_crg_interval* linterval =
214  dynamic_cast<const homogeneous_block_crg_interval*>(&crg().interval(xmbr_id));
215 
216  bool result = (linterval != 0) && linterval->zones_initialized();
217 
218  if(xauto_access)
219  {
220  release_access();
221  }
222 
223  // Postconditions:
224 
225  ensure(is_basic_query);
226 
227  // Exit:
228 
229  return result;
230 }
231 
232 bool
234 contains_zone_id_space(const scoped_index& xmbr_id, bool xauto_access) const
235 {
236  // Preconditions:
237 
238  require(state_is_auto_read_accessible(xauto_access));
239  require(contains_member(xmbr_id, xauto_access));
240 
241  // Body:
242 
243  bool result = contains_zone_id_space(xmbr_id.hub_pod(), xauto_access);
244 
245  // Postconditions:
246 
247  ensure(is_basic_query);
248 
249  // Exit:
250 
251  return result;
252 }
253 
256 get_zone_id_space(pod_index_type xmbr_id, bool xauto_access) const
257 {
258  // Preconditions:
259 
260  require(state_is_auto_read_accessible(xauto_access));
261  require(contains_member(xmbr_id, xauto_access));
262  require(contains_zone_id_space(xmbr_id, xauto_access));
263 
264  // Body:
265 
266  if(xauto_access)
267  {
268  get_read_access();
269  }
270 
271  const homogeneous_block_crg_interval& linterval =
272  reinterpret_cast<const homogeneous_block_crg_interval&>(crg().interval(xmbr_id));
273 
274  index_space_handle& result = crg().id_spaces().get_id_space(linterval.zones_space_id());
275 
276  if(xauto_access)
277  {
278  release_access();
279  }
280 
281  // Postconditions:
282 
283  ensure(result.is_attached());
284  ensure(member_id_spaces(xauto_access).allocated_id_space(result));
285 
286  // Exit:
287 
288  return result;
289 }
290 
293 get_zone_id_space(const scoped_index& xmbr_id, bool xauto_access) const
294 {
295  // Preconditions:
296 
297  require(state_is_auto_read_accessible(xauto_access));
298  require(contains_member(xmbr_id, xauto_access));
299  require(contains_zone_id_space(xmbr_id, xauto_access));
300 
301  // Body:
302 
303  index_space_handle& result = get_zone_id_space(xmbr_id.hub_pod(), xauto_access);
304 
305  // Postconditions:
306 
307  ensure(result.is_attached());
308  ensure(member_id_spaces(xauto_access).allocated_id_space(result));
309 
310  // Exit:
311 
312  return result;
313 }
314 
315 void
317 release_zone_id_space(index_space_handle& xid_space, bool xauto_access) const
318 {
319  // Preconditions:
320 
321  require(state_is_auto_read_accessible(xauto_access));
322  require(member_id_spaces(xauto_access).allocated_id_space(xid_space));
323 
324  // Body:
325 
326  if(xauto_access)
327  {
328  get_read_access();
329  }
330 
331  crg().id_spaces().release_id_space(xid_space);
332 
333  if(xauto_access)
334  {
335  release_access();
336  }
337 
338  // Postconditions:
339 
340  ensure(!xid_space.is_attached());
341 
342  // Exit:
343 
344  return;
345 }
346 
349 get_zone_id_space_iterator(pod_index_type xmbr_id, bool xauto_access) const
350 {
351  // Preconditions:
352 
353  require(state_is_auto_read_accessible(xauto_access));
354  require(contains_member(xmbr_id, xauto_access));
355  require(contains_zone_id_space(xmbr_id, xauto_access));
356 
357  // Body:
358 
359  if(xauto_access)
360  {
361  get_read_access();
362  }
363 
364  const homogeneous_block_crg_interval& linterval =
365  reinterpret_cast<const homogeneous_block_crg_interval&>(crg().interval(xmbr_id));
366 
368 
369  if(xauto_access)
370  {
371  release_access();
372  }
373 
374  // Postconditions:
375 
376  ensure(result.is_attached());
377  ensure(member_id_spaces(xauto_access).allocated_id_space_iterator(result));
378 
379  // Exit:
380 
381  return result;
382 }
383 
386 get_zone_id_space_iterator(const scoped_index& xmbr_id, bool xauto_access) const
387 {
388  // Preconditions:
389 
390  require(state_is_auto_read_accessible(xauto_access));
391  require(contains_member(xmbr_id, xauto_access));
392  require(contains_zone_id_space(xmbr_id, xauto_access));
393 
394  // Body:
395 
396  index_space_iterator& result = get_zone_id_space_iterator(xmbr_id.hub_pod(), xauto_access);
397 
398  // Postconditions:
399 
400  ensure(result.is_attached());
401  ensure(member_id_spaces(xauto_access).allocated_id_space_iterator(result));
402 
403  // Exit:
404 
405  return result;
406 }
407 
408 void
411 {
412  // Preconditions:
413 
414  require(state_is_auto_read_accessible(xauto_access));
415  require(member_id_spaces(xauto_access).allocated_id_space_iterator(xitr));
416 
417  // Body:
418 
419  if(xauto_access)
420  {
421  get_read_access();
422  }
423 
424  crg().id_spaces().release_id_space_iterator(xitr);
425 
426  if(xauto_access)
427  {
428  release_access();
429  }
430 
431  // Postconditions:
432 
433  ensure(!xitr.is_attached());
434 
435  // Exit:
436 
437  return;
438 }
439 
440 // PROTECTED FUNCTIONS
441 
442 // PRIVATE FUNCTIONS
443 
444 
445 // ===========================================================
446 // VERTEX ID SPACE FACET
447 // ===========================================================
448 
449 // PUBLIC FUNCTIONS
450 
451 bool
453 contains_vertex_id_space(pod_index_type xmbr_id, bool xauto_access) const
454 {
455  // Preconditions:
456 
457  require(state_is_auto_read_accessible(xauto_access));
458  require(contains_member(xmbr_id, xauto_access));
459 
460  // Body:
461 
462  if(xauto_access)
463  {
464  get_read_access();
465  }
466 
467  const homogeneous_block_crg_interval* linterval =
468  dynamic_cast<const homogeneous_block_crg_interval*>(&crg().interval(xmbr_id));
469 
470  bool result = (linterval != 0) && linterval->vertices_initialized();
471 
472  if(xauto_access)
473  {
474  release_access();
475  }
476 
477  // Postconditions:
478 
479  ensure(is_basic_query);
480 
481  // Exit:
482 
483  return result;
484 }
485 
486 bool
488 contains_vertex_id_space(const scoped_index& xmbr_id, bool xauto_access) const
489 {
490  // Preconditions:
491 
492  require(state_is_auto_read_accessible(xauto_access));
493  require(contains_member(xmbr_id, xauto_access));
494 
495  // Body:
496 
497  bool result = contains_vertex_id_space(xmbr_id.hub_pod(), xauto_access);
498 
499  // Postconditions:
500 
501  ensure(is_basic_query);
502 
503  // Exit:
504 
505  return result;
506 }
507 
510 get_vertex_id_space(pod_index_type xmbr_id, bool xauto_access) const
511 {
512  // Preconditions:
513 
514  require(state_is_auto_read_accessible(xauto_access));
515  require(contains_member(xmbr_id, xauto_access));
516  require(contains_vertex_id_space(xmbr_id, xauto_access));
517 
518  // Body:
519 
520  if(xauto_access)
521  {
522  get_read_access();
523  }
524 
525  const homogeneous_block_crg_interval& linterval =
526  reinterpret_cast<const homogeneous_block_crg_interval&>(crg().interval(xmbr_id));
527 
528  index_space_handle& result = crg().id_spaces().get_id_space(linterval.vertices_space_id());
529 
530  if(xauto_access)
531  {
532  release_access();
533  }
534 
535  // Postconditions:
536 
537  ensure(result.is_attached());
538  ensure(member_id_spaces(xauto_access).allocated_id_space(result));
539 
540  // Exit:
541 
542  return result;
543 }
544 
547 get_vertex_id_space(const scoped_index& xmbr_id, bool xauto_access) const
548 {
549  // Preconditions:
550 
551  require(state_is_auto_read_accessible(xauto_access));
552  require(contains_member(xmbr_id, xauto_access));
553  require(contains_vertex_id_space(xmbr_id, xauto_access));
554 
555  // Body:
556 
557  index_space_handle& result = get_vertex_id_space(xmbr_id.hub_pod(), xauto_access);
558 
559  // Postconditions:
560 
561  ensure(result.is_attached());
562  ensure(member_id_spaces(xauto_access).allocated_id_space(result));
563 
564  // Exit:
565 
566  return result;
567 }
568 
569 void
571 release_vertex_id_space(index_space_handle& xid_space, bool xauto_access) const
572 {
573  // Preconditions:
574 
575  require(state_is_auto_read_accessible(xauto_access));
576  require(member_id_spaces(xauto_access).allocated_id_space(xid_space));
577 
578  // Body:
579 
580  if(xauto_access)
581  {
582  get_read_access();
583  }
584 
585  crg().id_spaces().release_id_space(xid_space);
586 
587  if(xauto_access)
588  {
589  release_access();
590  }
591 
592  // Postconditions:
593 
594  ensure(!xid_space.is_attached());
595 
596  // Exit:
597 
598  return;
599 }
600 
603 get_vertex_id_space_iterator(pod_index_type xmbr_id, bool xauto_access) const
604 {
605  // Preconditions:
606 
607  require(state_is_auto_read_accessible(xauto_access));
608  require(contains_member(xmbr_id, xauto_access));
609  require(contains_vertex_id_space(xmbr_id, xauto_access));
610 
611  // Body:
612 
613  if(xauto_access)
614  {
615  get_read_access();
616  }
617 
618  const homogeneous_block_crg_interval& linterval =
619  reinterpret_cast<const homogeneous_block_crg_interval&>(crg().interval(xmbr_id));
620 
622 
623  if(xauto_access)
624  {
625  release_access();
626  }
627 
628  // Postconditions:
629 
630  ensure(result.is_attached());
631  ensure(member_id_spaces(xauto_access).allocated_id_space_iterator(result));
632 
633  // Exit:
634 
635  return result;
636 }
637 
640 get_vertex_id_space_iterator(const scoped_index& xmbr_id, bool xauto_access) const
641 {
642  // Preconditions:
643 
644  require(state_is_auto_read_accessible(xauto_access));
645  require(contains_member(xmbr_id, xauto_access));
646  require(contains_vertex_id_space(xmbr_id, xauto_access));
647 
648  // Body:
649 
650  index_space_iterator& result = get_vertex_id_space_iterator(xmbr_id.hub_pod(), xauto_access);
651 
652  // Postconditions:
653 
654  ensure(result.is_attached());
655  ensure(member_id_spaces(xauto_access).allocated_id_space_iterator(result));
656 
657  // Exit:
658 
659  return result;
660 }
661 
662 void
665 {
666  // Preconditions:
667 
668  require(state_is_auto_read_accessible(xauto_access));
669  require(member_id_spaces(xauto_access).allocated_id_space_iterator(xitr));
670 
671  // Body:
672 
673  if(xauto_access)
674  {
675  get_read_access();
676  }
677 
678  crg().id_spaces().release_id_space_iterator(xitr);
679 
680  if(xauto_access)
681  {
682  release_access();
683  }
684 
685  // Postconditions:
686 
687  ensure(!xitr.is_attached());
688 
689  // Exit:
690 
691  return;
692 }
693 
694 // PROTECTED FUNCTIONS
695 
696 // PRIVATE FUNCTIONS
697 
698 
699 // ===========================================================
700 // VERTEX CLIENT ID SPACE FACET
701 // ===========================================================
702 
703 // PUBLIC FUNCTIONS
704 
705 bool
707 contains_vertex_client_id_space(pod_index_type xmbr_id, bool xauto_access) const
708 {
709  // Preconditions:
710 
711  require(state_is_auto_read_accessible(xauto_access));
712  require(contains_member(xmbr_id, xauto_access));
713 
714  // Body:
715 
716  if(xauto_access)
717  {
718  get_read_access();
719  }
720 
721  const zone_nodes_block_crg_interval* linterval =
722  dynamic_cast<const zone_nodes_block_crg_interval*>(&crg().interval(xmbr_id));
723 
724  bool result = (linterval != 0) && linterval->vertex_client_id_space_initialized();
725 
726  if(xauto_access)
727  {
728  release_access();
729  }
730 
731  // Postconditions:
732 
733  ensure(is_basic_query);
734 
735  // Exit:
736 
737  return result;
738 }
739 
740 bool
742 contains_vertex_client_id_space(const scoped_index& xmbr_id, bool xauto_access) const
743 {
744  // Preconditions:
745 
746  require(state_is_auto_read_accessible(xauto_access));
747  require(contains_member(xmbr_id, xauto_access));
748 
749  // Body:
750 
751  bool result = contains_vertex_client_id_space(xmbr_id.hub_pod(), xauto_access);
752 
753  // Postconditions:
754 
755  ensure(is_basic_query);
756 
757  // Exit:
758 
759  return result;
760 }
761 
764 get_vertex_client_id_space(pod_index_type xmbr_id, bool xauto_access) const
765 {
766  // Preconditions:
767 
768  require(state_is_auto_read_accessible(xauto_access));
769  require(contains_member(xmbr_id, xauto_access));
770  require(contains_vertex_client_id_space(xmbr_id, xauto_access));
771 
772  // Body:
773 
774  if(xauto_access)
775  {
776  get_read_access();
777  }
778 
779  const zone_nodes_block_crg_interval& linterval =
780  reinterpret_cast<const zone_nodes_block_crg_interval&>(crg().interval(xmbr_id));
781 
782  index_space_handle& result = crg().id_spaces().get_id_space(linterval.vertex_client_space_id());
783 
784  if(xauto_access)
785  {
786  release_access();
787  }
788 
789  // Postconditions:
790 
791  ensure(result.is_attached());
792  ensure(member_id_spaces(xauto_access).allocated_id_space(result));
793 
794  // Exit:
795 
796  return result;
797 }
798 
801 get_vertex_client_id_space(const scoped_index& xmbr_id, bool xauto_access) const
802 {
803  // Preconditions:
804 
805  require(state_is_auto_read_accessible(xauto_access));
806  require(contains_member(xmbr_id, xauto_access));
807  require(contains_vertex_client_id_space(xmbr_id, xauto_access));
808 
809  // Body:
810 
811  index_space_handle& result = get_vertex_client_id_space(xmbr_id.hub_pod(), xauto_access);
812 
813  // Postconditions:
814 
815  ensure(result.is_attached());
816  ensure(member_id_spaces(xauto_access).allocated_id_space(result));
817 
818  // Exit:
819 
820  return result;
821 }
822 
823 void
825 release_vertex_client_id_space(index_space_handle& xid_space, bool xauto_access) const
826 {
827  // Preconditions:
828 
829  require(state_is_auto_read_accessible(xauto_access));
830  require(member_id_spaces(xauto_access).allocated_id_space(xid_space));
831 
832  // Body:
833 
834  if(xauto_access)
835  {
836  get_read_access();
837  }
838 
839  crg().id_spaces().release_id_space(xid_space);
840 
841  if(xauto_access)
842  {
843  release_access();
844  }
845 
846  // Postconditions:
847 
848  ensure(!xid_space.is_attached());
849 
850  // Exit:
851 
852  return;
853 }
854 
857 get_vertex_client_id_space_iterator(pod_index_type xmbr_id, bool xauto_access) const
858 {
859  // Preconditions:
860 
861  require(state_is_auto_read_accessible(xauto_access));
862  require(contains_member(xmbr_id, xauto_access));
863  require(contains_vertex_client_id_space(xmbr_id, xauto_access));
864 
865  // Body:
866 
867  if(xauto_access)
868  {
869  get_read_access();
870  }
871 
872  const zone_nodes_block_crg_interval& linterval =
873  reinterpret_cast<const zone_nodes_block_crg_interval&>(crg().interval(xmbr_id));
874 
876 
877  if(xauto_access)
878  {
879  release_access();
880  }
881 
882  // Postconditions:
883 
884  ensure(result.is_attached());
885  ensure(member_id_spaces(xauto_access).allocated_id_space_iterator(result));
886 
887  // Exit:
888 
889  return result;
890 }
891 
894 get_vertex_client_id_space_iterator(const scoped_index& xmbr_id, bool xauto_access) const
895 {
896  // Preconditions:
897 
898  require(state_is_auto_read_accessible(xauto_access));
899  require(contains_member(xmbr_id, xauto_access));
900  require(contains_vertex_client_id_space(xmbr_id, xauto_access));
901 
902  // Body:
903 
904  index_space_iterator& result = get_vertex_client_id_space_iterator(xmbr_id.hub_pod(), xauto_access);
905 
906  // Postconditions:
907 
908  ensure(result.is_attached());
909  ensure(member_id_spaces(xauto_access).allocated_id_space_iterator(result));
910 
911  // Exit:
912 
913  return result;
914 }
915 
916 void
919 {
920  // Preconditions:
921 
922  require(state_is_auto_read_accessible(xauto_access));
923  require(member_id_spaces(xauto_access).allocated_id_space_iterator(xitr));
924 
925  // Body:
926 
927  if(xauto_access)
928  {
929  get_read_access();
930  }
931 
932  crg().id_spaces().release_id_space_iterator(xitr);
933 
934  if(xauto_access)
935  {
936  release_access();
937  }
938 
939  // Postconditions:
940 
941  ensure(!xitr.is_attached());
942 
943  // Exit:
944 
945  return;
946 }
947 
948 // PROTECTED FUNCTIONS
949 
950 // PRIVATE FUNCTIONS
951 
952 
953 
954 // ===========================================================
955 // CONNECTIVITY FACET
956 // ===========================================================
957 
958 // PUBLIC FUNCTIONS
959 
960 bool
962 contains_connectivity_id_space(pod_index_type xzone_id, bool xauto_access) const
963 {
964  // Preconditions:
965 
966  require(state_is_auto_read_accessible(xauto_access));
967  require(contains_member(xzone_id, xauto_access));
968 
969  // Body:
970 
971  if(xauto_access)
972  {
973  get_read_access();
974  }
975 
976  const homogeneous_block_crg_interval* linterval =
977  dynamic_cast<const homogeneous_block_crg_interval*>(&crg().interval(xzone_id));
978 
979  bool result =
980  (linterval != 0) &&
981  crg().id_spaces().contains_hub(linterval->zones_space_id(), xzone_id);
982 
983  if(xauto_access)
984  {
985  release_access();
986  }
987 
988  // Postconditions:
989 
990  ensure(is_basic_query);
991 
992  // Exit:
993 
994  return result;
995 }
996 
997 bool
999 contains_connectivity_id_space(const scoped_index& xzone_id, bool xauto_access) const
1000 {
1001  // Preconditions:
1002 
1003  require(state_is_auto_read_accessible(xauto_access));
1004  require(contains_member(xzone_id, xauto_access));
1005 
1006  // Body:
1007 
1008  bool result = contains_connectivity_id_space(xzone_id.hub_pod(), xauto_access);
1009 
1010  // Postconditions:
1011 
1012  ensure(is_basic_query);
1013 
1014  // Exit:
1015 
1016  return result;
1017 }
1018 
1021 get_connectivity_id_space(pod_index_type xzone_id, bool xauto_access) const
1022 {
1023  // Preconditions:
1024 
1025  require(state_is_auto_read_accessible(xauto_access));
1026  require(contains_member(xzone_id, xauto_access));
1027  require(contains_connectivity_id_space(xzone_id, xauto_access));
1028 
1029  // Body:
1030 
1031  if(xauto_access)
1032  {
1033  get_read_access();
1034  }
1035 
1036  const homogeneous_block_crg_interval& linterval =
1037  reinterpret_cast<const homogeneous_block_crg_interval&>(crg().interval(xzone_id));
1038 
1039  index_space_handle& result =
1040  crg().id_spaces().get_id_space(linterval.connectivity_space_id(xzone_id));
1041 
1042  if(xauto_access)
1043  {
1044  release_access();
1045  }
1046 
1047  // Postconditions:
1048 
1049  ensure(result.is_attached());
1050  ensure(member_id_spaces(xauto_access).allocated_id_space(result));
1051 
1052  // Exit:
1053 
1054  return result;
1055 }
1056 
1059 get_connectivity_id_space(const scoped_index& xzone_id, bool xauto_access) const
1060 {
1061  // Preconditions:
1062 
1063  require(state_is_auto_read_accessible(xauto_access));
1064  require(contains_member(xzone_id, xauto_access));
1065  require(contains_connectivity_id_space(xzone_id, xauto_access));
1066 
1067  // Body:
1068 
1069  index_space_handle& result = get_connectivity_id_space(xzone_id.hub_pod(), xauto_access);
1070 
1071  // Postconditions:
1072 
1073  ensure(result.is_attached());
1074  ensure(member_id_spaces(xauto_access).allocated_id_space(result));
1075 
1076  // Exit:
1077 
1078  return result;
1079 }
1080 
1081 void
1083 release_connectivity_id_space(index_space_handle& xid_space, bool xauto_access) const
1084 {
1085  // Preconditions:
1086 
1087  require(state_is_auto_read_accessible(xauto_access));
1088  require(member_id_spaces(xauto_access).allocated_id_space(xid_space));
1089 
1090  // Body:
1091 
1092  if(xauto_access)
1093  {
1094  get_read_access();
1095  }
1096 
1097  crg().id_spaces().release_id_space(xid_space);
1098 
1099  if(xauto_access)
1100  {
1101  release_access();
1102  }
1103 
1104  // Postconditions:
1105 
1106  ensure(!xid_space.is_attached());
1107 
1108  // Exit:
1109 
1110  return;
1111 }
1112 
1115 get_connectivity_id_space_iterator(pod_index_type xzone_id, bool xauto_access) const
1116 {
1117  // Preconditions:
1118 
1119  require(state_is_auto_read_accessible(xauto_access));
1120  require(contains_member(xzone_id, xauto_access));
1121  require(contains_connectivity_id_space(xzone_id, xauto_access));
1122 
1123  // Body:
1124 
1125  if(xauto_access)
1126  {
1127  get_read_access();
1128  }
1129 
1130  const homogeneous_block_crg_interval& linterval =
1131  reinterpret_cast<const homogeneous_block_crg_interval&>(crg().interval(xzone_id));
1132 
1133  index_space_iterator& result =
1134  crg().id_spaces().get_id_space_iterator(linterval.connectivity_space_id(xzone_id));
1135 
1136  if(xauto_access)
1137  {
1138  release_access();
1139  }
1140 
1141  // Postconditions:
1142 
1143  ensure(result.is_attached());
1144  ensure(member_id_spaces(xauto_access).allocated_id_space_iterator(result));
1145 
1146  // Exit:
1147 
1148  return result;
1149 }
1150 
1153 get_connectivity_id_space_iterator(const scoped_index& xzone_id, bool xauto_access) const
1154 {
1155  // Preconditions:
1156 
1157  require(state_is_auto_read_accessible(xauto_access));
1158  require(contains_member(xzone_id, xauto_access));
1159  require(contains_connectivity_id_space(xzone_id, xauto_access));
1160 
1161  // Body:
1162 
1163  index_space_iterator& result = get_connectivity_id_space_iterator(xzone_id.hub_pod(), xauto_access);
1164 
1165  // Postconditions:
1166 
1167  ensure(result.is_attached());
1168  ensure(member_id_spaces(xauto_access).allocated_id_space_iterator(result));
1169 
1170  // Exit:
1171 
1172  return result;
1173 }
1174 
1175 void
1178 {
1179  // Preconditions:
1180 
1181  require(state_is_auto_read_accessible(xauto_access));
1182  require(member_id_spaces(xauto_access).allocated_id_space_iterator(xitr));
1183 
1184  // Body:
1185 
1186  if(xauto_access)
1187  {
1188  get_read_access();
1189  }
1190 
1191  crg().id_spaces().release_id_space_iterator(xitr);
1192 
1193  if(xauto_access)
1194  {
1195  release_access();
1196  }
1197 
1198  // Postconditions:
1199 
1200  ensure(!xitr.is_attached());
1201 
1202  // Exit:
1203 
1204  return;
1205 }
1206 
1207 // PROTECTED FUNCTIONS
1208 
1209 // PRIVATE FUNCTIONS
1210 
1211 
1212 // ===========================================================
1213 // ADJACENCY FACET
1214 // ===========================================================
1215 
1216 // PUBLIC FUNCTIONS
1217 
1218 bool
1220 contains_adjacency_id_space(pod_index_type xvertex_id, bool xauto_access) const
1221 {
1222  // Preconditions:
1223 
1224  require(state_is_auto_read_accessible(xauto_access));
1225  require(contains_member(xvertex_id, xauto_access));
1226 
1227  // Body:
1228 
1229  if(xauto_access)
1230  {
1231  get_read_access();
1232  }
1233 
1234  const homogeneous_block_crg_interval* linterval =
1235  dynamic_cast<const homogeneous_block_crg_interval*>(&crg().interval(xvertex_id));
1236 
1237  bool result =
1238  (linterval != 0) &&
1239  crg().id_spaces().contains_hub(linterval->vertices_space_id(), xvertex_id);
1240 
1241  if(xauto_access)
1242  {
1243  release_access();
1244  }
1245 
1246  // Postconditions:
1247 
1248  ensure(is_basic_query);
1249 
1250  // Exit:
1251 
1252  return result;
1253 }
1254 
1255 bool
1257 contains_adjacency_id_space(const scoped_index& xvertex_id, bool xauto_access) const
1258 {
1259  // Preconditions:
1260 
1261  require(state_is_auto_read_accessible(xauto_access));
1262  require(contains_member(xvertex_id, xauto_access));
1263 
1264  // Body:
1265 
1266  bool result = contains_adjacency_id_space(xvertex_id.hub_pod(), xauto_access);
1267 
1268  // Postconditions:
1269 
1270  ensure(is_basic_query);
1271 
1272  // Exit:
1273 
1274  return result;
1275 }
1276 
1279 get_adjacency_id_space(pod_index_type xvertex_id, bool xauto_access) const
1280 {
1281  // Preconditions:
1282 
1283  require(state_is_auto_read_accessible(xauto_access));
1284  require(contains_member(xvertex_id, xauto_access));
1285  require(contains_adjacency_id_space(xvertex_id, xauto_access));
1286 
1287  // Body:
1288 
1289  if(xauto_access)
1290  {
1291  get_read_access();
1292  }
1293 
1294  const homogeneous_block_crg_interval& linterval =
1295  reinterpret_cast<const homogeneous_block_crg_interval&>(crg().interval(xvertex_id));
1296 
1297  index_space_handle& result =
1298  crg().id_spaces().get_id_space(linterval.adjacency_space_id(xvertex_id));
1299 
1300  if(xauto_access)
1301  {
1302  release_access();
1303  }
1304 
1305  // Postconditions:
1306 
1307  ensure(result.is_attached());
1308  ensure(member_id_spaces(xauto_access).allocated_id_space(result));
1309 
1310  // Exit:
1311 
1312  return result;
1313 }
1314 
1317 get_adjacency_id_space(const scoped_index& xvertex_id, bool xauto_access) const
1318 {
1319  // Preconditions:
1320 
1321  require(state_is_auto_read_accessible(xauto_access));
1322  require(contains_member(xvertex_id, xauto_access));
1323  require(contains_adjacency_id_space(xvertex_id, xauto_access));
1324 
1325  // Body:
1326 
1327  index_space_handle& result = get_adjacency_id_space(xvertex_id.hub_pod(), xauto_access);
1328 
1329  // Postconditions:
1330 
1331  ensure(result.is_attached());
1332  ensure(member_id_spaces(xauto_access).allocated_id_space(result));
1333 
1334  // Exit:
1335 
1336  return result;
1337 }
1338 
1339 void
1341 release_adjacency_id_space(index_space_handle& xid_space, bool xauto_access) const
1342 {
1343  // Preconditions:
1344 
1345  require(state_is_auto_read_accessible(xauto_access));
1346  require(member_id_spaces(xauto_access).allocated_id_space(xid_space));
1347 
1348  // Body:
1349 
1350  if(xauto_access)
1351  {
1352  get_read_access();
1353  }
1354 
1355  crg().id_spaces().release_id_space(xid_space);
1356 
1357  if(xauto_access)
1358  {
1359  release_access();
1360  }
1361 
1362  // Postconditions:
1363 
1364  ensure(!xid_space.is_attached());
1365 
1366  // Exit:
1367 
1368  return;
1369 }
1370 
1373 get_adjacency_id_space_iterator(pod_index_type xvertex_id, bool xauto_access) const
1374 {
1375  // Preconditions:
1376 
1377  require(state_is_auto_read_accessible(xauto_access));
1378  require(contains_member(xvertex_id, xauto_access));
1379  require(contains_adjacency_id_space(xvertex_id, xauto_access));
1380 
1381  // Body:
1382 
1383  if(xauto_access)
1384  {
1385  get_read_access();
1386  }
1387 
1388  const homogeneous_block_crg_interval& linterval =
1389  reinterpret_cast<const homogeneous_block_crg_interval&>(crg().interval(xvertex_id));
1390 
1391  index_space_iterator& result =
1392  crg().id_spaces().get_id_space_iterator(linterval.adjacency_space_id(xvertex_id));
1393 
1394  if(xauto_access)
1395  {
1396  release_access();
1397  }
1398 
1399  // Postconditions:
1400 
1401  ensure(result.is_attached());
1402  ensure(member_id_spaces(xauto_access).allocated_id_space_iterator(result));
1403 
1404  // Exit:
1405 
1406  return result;
1407 }
1408 
1411 get_adjacency_id_space_iterator(const scoped_index& xvertex_id, bool xauto_access) const
1412 {
1413  // Preconditions:
1414 
1415  require(state_is_auto_read_accessible(xauto_access));
1416  require(contains_member(xvertex_id, xauto_access));
1417  require(contains_adjacency_id_space(xvertex_id, xauto_access));
1418 
1419  // Body:
1420 
1421  index_space_iterator& result = get_adjacency_id_space_iterator(xvertex_id.hub_pod(), xauto_access);
1422 
1423  // Postconditions:
1424 
1425  ensure(result.is_attached());
1426  ensure(member_id_spaces(xauto_access).allocated_id_space_iterator(result));
1427 
1428  // Exit:
1429 
1430  return result;
1431 }
1432 
1433 void
1436 {
1437  // Preconditions:
1438 
1439  require(state_is_auto_read_accessible(xauto_access));
1440  require(member_id_spaces(xauto_access).allocated_id_space_iterator(xitr));
1441 
1442  // Body:
1443 
1444  if(xauto_access)
1445  {
1446  get_read_access();
1447  }
1448 
1449  crg().id_spaces().release_id_space_iterator(xitr);
1450 
1451  if(xauto_access)
1452  {
1453  release_access();
1454  }
1455 
1456  // Postconditions:
1457 
1458  ensure(!xitr.is_attached());
1459 
1460  // Exit:
1461 
1462  return;
1463 }
1464 
1465 // PROTECTED FUNCTIONS
1466 
1467 // PRIVATE FUNCTIONS
1468 
1469 
1470 // ===========================================================
1471 // MEMBER PROTOTYPES FACET
1472 // ===========================================================
1473 
1474 // PUBLIC FUNCTIONS
1475 
1476 const std::string&
1479 {
1480 
1481  // Preconditions:
1482 
1483  // Body:
1484 
1485  const string& result = base_space_member::prototypes_poset_name();
1486 
1487  // Postconditions:
1488 
1489  ensure(result == base_space_member::prototypes_poset_name());
1490 
1491  // Exit
1492 
1493  return result;
1494 }
1495 
1498 prototype_type_id(const std::string& xname, bool xauto_access) const
1499 {
1500 
1501  // Preconditions:
1502 
1503  require(xauto_access ? is_attached() : state_is_read_accessible());
1504  require(xauto_access || name_space()->state_is_read_accessible());
1505  require(xauto_access || name_space()->member_poset(prototypes_poset_name(), true).state_is_read_accessible());
1506  require(name_space()->contains_poset_member(prototypes_poset_name()+"/"+xname, true));
1507  require(unexecutable("!xauto_access ? prototypes poset is read accessible : true"));
1508 
1509 
1510  // Body:
1511 
1512  if(xauto_access)
1513  {
1514  get_read_access();
1515  name_space()->get_read_access();
1516  }
1517 
1518  poset_state_handle& lproto_host =
1519  name_space()->member_poset(prototypes_poset_name(), false);
1520 
1521  if(xauto_access)
1522  {
1523  lproto_host.get_read_access();
1524  }
1525 
1526  base_space_member lmbr(reinterpret_cast<poset*>(&lproto_host), xname);
1527  pod_index_type result = lmbr.type_id();
1528  lmbr.detach_from_state();
1529 
1530  if(xauto_access)
1531  {
1532  lproto_host.release_access();
1533  name_space()->release_access();
1534  release_access();
1535  }
1536 
1537  // Postconditions:
1538 
1539  // Exit:
1540 
1541  return result;
1542 }
1543 
1546 prototype_dof_tuple_id(const std::string& xname,
1547  int xdepth,
1548  bool xcreate,
1549  bool xauto_access) const
1550 {
1551  // Preconditions:
1552 
1553  require(is_attached());
1554  require(xauto_access || (xcreate ? state_is_read_write_accessible() : state_is_read_accessible()));
1555 
1556  // Body:
1557 
1558  base_space_poset* cthis = const_cast<base_space_poset*>(this);
1559 
1560  if(xauto_access)
1561  {
1562  xcreate ? cthis->get_read_write_access(true) : get_read_access();
1563  }
1564 
1565  scoped_index result;
1566 
1567  size_type ltuple_ct = row_dof_tuple_ct();
1568  for(pod_index_type ltuple_id = 0; ltuple_id < ltuple_ct; ++ltuple_id)
1569  {
1570  row_dof_tuple_type* ltuple = row_dof_tuple(ltuple_id);
1571  if((xname == ltuple->type_name) && xdepth == ltuple->refinement_depth)
1572  {
1573  result = dof_tuple_id(ltuple_id, false);
1574  break;
1575  }
1576  }
1577 
1578  if(!result.is_valid() && xcreate)
1579  {
1580  // Couldn't find a dof tuple, have to make one.
1581 
1582  result = cthis->new_row_dof_map(xname);
1583  row_dof_tuple(result, true)->refinement_depth = xdepth;
1584  }
1585 
1586  if(xauto_access)
1587  {
1588  release_access();
1589  }
1590 
1591  // Postconditions:
1592 
1593  ensure(!result.is_valid() || contains_row_dof_tuple(result));
1594  ensure(!result.is_valid() || (xname == row_dof_tuple(result)->type_name));
1595  ensure(!result.is_valid() || (xdepth == row_dof_tuple(result)->refinement_depth));
1596 
1597  // Exit:
1598 
1599  return result;
1600 }
1601 
1602 // PROTECTED FUNCTIONS
1603 
1604 // PRIVATE FUNCTIONS
1605 
1606 // ===========================================================
1607 // POSET_STATE_HANDLE FACET
1608 // ===========================================================
1609 
1610 // PUBLIC FUNCTIONS
1611 
1612 // PROTECTED FUNCTIONS
1613 
1614 // PRIVATE FUNCTIONS
1615 
1616 // ===========================================================
1617 // STATE FACET
1618 // ===========================================================
1619 
1620 // PUBLIC FUNCTIONS
1621 
1624 type_id() const
1625 {
1626  return BASE_SPACE_POSET_ID;
1627 }
1628 
1629 const char*
1631 class_name() const
1632 {
1633  // Preconditions:
1634 
1635  // Body:
1636 
1637  static const char* result = "base_space_poset";
1638 
1639  // Postconditions:
1640 
1641  // Exit:
1642 
1643  return result;
1644 }
1645 
1646 // PROTECTED FUNCTIONS
1647 
1648 void
1651 {
1652  // Preconditions:
1653 
1654  require(state_is_read_accessible());
1655 
1656  // Body:
1657 
1658  refinable_poset::attach_handle_data_members();
1659 
1660  // Attch the standard subposets.
1661 
1662  _blocks.attach_to_state(this, blocks_name());
1663  _block_vertices.attach_to_state(this, block_vertices_name());
1664 
1665  int lmax_db = max_db();
1666  _d_cells.reserve(lmax_db+1);
1667  _d_cells.set_ct(lmax_db+1);
1668 
1669  _d_cells_id_spaces.reserve(lmax_db+1);
1670  _d_cells_id_spaces.set_ct(lmax_db+1);
1671 
1672  for(int i=0; i<=lmax_db; i++)
1673  {
1674  _d_cells[i].attach_to_state(this, d_cells_name(i, lmax_db));
1675  _d_cells_id_spaces[i] = &_d_cells[i].id_space();
1676  }
1677 
1678  _cells.attach_to_state(this, cells_name());
1679 
1680  // Postconditions:
1681 
1682  // Exit:
1683 
1684  return;
1685 }
1686 
1687 // PRIVATE FUNCTIONS
1688 
1689 // ===========================================================
1690 // MEMBERSHIP FACET
1691 // ===========================================================
1692 
1693 // PUBLIC MEMBER FUNCTIONS
1694 
1697 new_member(const std::string& xprototype_name, bool xcopy_dof_map)
1698 {
1699  // cout << endl << "Entering base_space_poset::new_member." << endl;
1700 
1701  // Preconditions:
1702 
1703  require(in_jim_edit_mode());
1704  require(name_space()->state_is_read_accessible());
1705  require(name_space()->member_poset(prototypes_poset_name(), false).state_is_read_accessible());
1706  require(!xprototype_name.empty());
1707  require(name_space()->contains_poset_member(poset_path(prototypes_poset_name(), xprototype_name), false));
1708 
1709  // Body:
1710 
1711  scoped_index ltuple_id;
1712 
1713  if(xcopy_dof_map)
1714  {
1715  ltuple_id = new_row_dof_map(xprototype_name);
1716  }
1717  else
1718  {
1719  ltuple_id = prototype_dof_tuple_id(xprototype_name, 0, true, false);
1720  }
1721 
1722  pod_index_type result = new_member(true, ltuple_id.hub_pod());
1723 
1724  // Postconditions:
1725 
1726  ensure(invariant());
1727  ensure(contains_member(result, false));
1728  ensure(type_name(result) == xprototype_name);
1729  ensure(cover_is_empty(LOWER, result));
1730  ensure(cover_is_empty(UPPER, result));
1731 
1732  // Exit:
1733 
1734  // cout << "Leaving base_space_poset::new_member." << endl;
1735  return result;
1736 }
1737 
1740 new_member(const char* xprototype_name, bool xcopy_dof_map)
1741 {
1742  // cout << endl << "Entering base_space_poset::new_member." << endl;
1743 
1744  // Preconditions:
1745 
1746  require(precondition_of(new_member(string(xprototype_name), xcopy_dof_map)));
1747 
1748  // Body:
1749 
1750  string lprotoname(xprototype_name);
1751 
1752  pod_index_type result = new_member(lprotoname, xcopy_dof_map);
1753 
1754  // Postconditions:
1755 
1756  ensure(postcondition_of(new_member(string(xprototype_name), xcopy_dof_map)));
1757 
1758  // Exit:
1759 
1760  // cout << "Leaving base_space_poset::new_member." << endl;
1761  return result;
1762 }
1763 
1766 new_member(const std::string& xtype_name, int xdb, const std::string& xlocal_cell_name)
1767 {
1768  // cout << endl << "Entering base_space_poset::new_member." << endl;
1769 
1770  // Preconditions:
1771 
1772  require(in_jim_edit_mode());
1773  require(name_space()->state_is_read_accessible());
1774  require(poset_path::is_valid_name(xtype_name));
1775  require(!contains_member(xtype_name, true));
1776  require(member_id_spaces(false).contains("cell_types"));
1777  require(xlocal_cell_name.empty() || contains_member(xlocal_cell_name));
1778 
1779  // Body:
1780 
1781  // Create the dof map and set dofs to defaults.
1782 
1783  pod_index_type result = new_member(true, 0, false);
1784 
1785  // Set name to type name.
1786 
1787  put_member_name(result, xtype_name, true, false);
1788 
1789  // Get the row dof tuple.
1790 
1791  row_dof_tuple_type* ltuple = member_dof_tuple(result, true);
1792 
1793  // Set db.
1794 
1795  ltuple->db = xdb;
1796 
1797  // Set type id.
1798 
1799  scattered_insertion_index_space_handle& ltype_id_space =
1800  member_id_spaces(false).get_id_space<scattered_insertion_index_space_handle>("cell_types");
1801 
1802  ltype_id_space.push_back(result);
1803 
1804  ltuple->type_id = ltype_id_space.pod(result);
1805 
1806  ltype_id_space.release_id_space();
1807 
1808  // Set type name.
1809 
1811 
1812  ltuple->type_name = strdup(xtype_name.c_str());
1813 
1814  // Set the refinement depth.
1815 
1816  ltuple->refinement_depth = 0;
1817 
1818  // Set local cell type id and type name.
1819 
1820  if(xlocal_cell_name.empty())
1821  {
1823 
1825 
1826  ltuple->local_cell_type_name = strdup("");
1827  }
1828  else
1829  {
1830  base_space_member lcell(this, xlocal_cell_name);
1831  ltuple->local_cell_type_id = lcell.type_id();
1832 
1834 
1835  ltuple->local_cell_type_name = strdup(lcell.type_name());
1836  lcell.detach_from_state();
1837  }
1838 
1839  // Set the remaining dofs to default values.
1840 
1841  ltuple->size = 0;
1842  ltuple->i_size = 0;
1843  ltuple->j_size = 0;
1844  ltuple->k_size = 0;
1845 
1846  // Postconditions:
1847 
1848  ensure(invariant());
1849  ensure(contains_member(result, false));
1850  ensure(member_name(result, false) == xtype_name);
1851  ensure(db(result) == xdb);
1852  ensure(type_name(result) == xtype_name);
1853  ensure(unexecutable("local_cell_type_name(result) == xlocal_cell_name"));
1854  ensure(cover_is_empty(LOWER, result));
1855  ensure(cover_is_empty(UPPER, result));
1856 
1857  // Exit:
1858 
1859  // cout << "Leaving base_space_poset::new_member." << endl;
1860  return result;
1861 }
1862 
1863 // PROTECTED MEMBER FUNCTIONS
1864 
1865 // PRIVATE MEMBER FUNCTIONS
1866 
1867 
1868 // ===========================================================
1869 // POWERSET FACET
1870 // ===========================================================
1871 
1872 // PUBLIC FUNCTIONS
1873 
1877 {
1878  // Preconditions:
1879 
1880  // Body:
1881 
1882  subposet& result = _blocks;
1883 
1884  // Postconditions:
1885 
1886  // Exit:
1887 
1888  return result;
1889 }
1890 
1891 const sheaf::subposet&
1893 blocks() const
1894 {
1895  // Preconditions:
1896 
1897  // Body:
1898 
1899  const subposet& result = _blocks;
1900 
1901  // Postconditions:
1902 
1903  // Exit:
1904 
1905  return result;
1906 }
1907 
1908 std::string
1911 {
1912 
1913  // Preconditions:
1914 
1915  // Body:
1916 
1917  string result = poset_path::reserved_prefix() + "blocks";
1918 
1919  // Postconditions:
1920 
1921  // Exit:
1922 
1923  return result;
1924 }
1925 
1929 {
1930  // Preconditions:
1931 
1932  // Body:
1933 
1934  subposet& result = _block_vertices;
1935 
1936  // Postconditions:
1937 
1938  // Exit:
1939 
1940  return result;
1941 }
1942 
1943 const sheaf::subposet&
1946 {
1947  // Preconditions:
1948 
1949  // Body:
1950 
1951  const subposet& result = _block_vertices;
1952 
1953  // Postconditions:
1954 
1955  // Exit:
1956 
1957  return result;
1958 }
1959 
1960 std::string
1963 {
1964 
1965  // Preconditions:
1966 
1967  // Body:
1968 
1969  string result = poset_path::reserved_prefix() + "block_vertices";
1970 
1971  // Postconditions:
1972 
1973  // Exit:
1974 
1975  return result;
1976 }
1977 
1981 {
1982  // Preconditions:
1983 
1984  // Body:
1985 
1986  subposet& result = _d_cells[0];
1987 
1988  // Postconditions:
1989 
1990  // Exit:
1991 
1992  return result;
1993 }
1994 
1995 const sheaf::subposet&
1997 vertices() const
1998 {
1999  // Preconditions:
2000 
2001  // Body:
2002 
2003  subposet& result = _d_cells[0];
2004 
2005  // Postconditions:
2006 
2007  // Exit:
2008 
2009  return result;
2010 }
2011 
2015 {
2016  // Preconditions:
2017 
2018  // Body:
2019 
2020  subposet& result = _d_cells[max_db()];
2021 
2022  // Postconditions:
2023 
2024  // Exit:
2025 
2026  return result;
2027 }
2028 
2029 const sheaf::subposet&
2031 elements() const
2032 {
2033  // Preconditions:
2034 
2035  // Body:
2036 
2037  subposet& result = _d_cells[max_db()];
2038 
2039  // Postconditions:
2040 
2041  // Exit:
2042 
2043  return result;
2044 }
2045 
2048 d_cells(int xd)
2049 {
2050  // Preconditions:
2051 
2052  require(state_is_read_accessible());
2053  require((0 <= xd) && (xd <= max_db()));
2054 
2055  // Body:
2056 
2057  subposet& result = _d_cells[xd];
2058 
2059  // Postconditions:
2060 
2061  // Exit:
2062 
2063  return result;
2064 }
2065 
2066 const sheaf::subposet&
2068 d_cells(int xd) const
2069 {
2070  // Preconditions:
2071 
2072  require(state_is_read_accessible());
2073  require((0 <= xd) && (xd <= max_db()));
2074 
2075  // Body:
2076 
2077  subposet& result = _d_cells[xd];
2078 
2079  // Postconditions:
2080 
2081  // Exit:
2082 
2083  return result;
2084 }
2085 
2089 {
2090  // Preconditions:
2091 
2092  require(state_is_read_accessible());
2093  require((0 <= xd) && (xd <= max_db()));
2094 
2095  // Body:
2096 
2097  scattered_insertion_index_space_handle& result = *_d_cells_id_spaces[xd];
2098 
2099  // Postconditions:
2100 
2101  ensure(result.is_attached());
2102 
2103  // Exit:
2104 
2105  return result;
2106 }
2107 
2110 d_cells_id_space(int xd) const
2111 {
2112  // Preconditions:
2113 
2114  require(state_is_read_accessible());
2115  require((0 <= xd) && (xd <= max_db()));
2116 
2117  // Body:
2118 
2119  const scattered_insertion_index_space_handle& result = *_d_cells_id_spaces[xd];
2120 
2121  // Postconditions:
2122 
2123  ensure(result.is_attached());
2124 
2125  // Exit:
2126 
2127  return result;
2128 }
2129 
2130 std::string
2132 d_cells_name(int xdb, int xmax_db)
2133 {
2134  string result;
2135 
2136  // Preconditions:
2137 
2138  // Body:
2139 
2140  if(xdb == 0)
2141  {
2142  result = poset_path::reserved_prefix() + "vertices";
2143  }
2144  else if(xdb == xmax_db)
2145  {
2146  result = poset_path::reserved_prefix() + "elements";
2147  }
2148  else
2149  {
2150  stringstream lsp_name_stream;
2151  lsp_name_stream << poset_path::reserved_prefix() << xdb << "_cells";
2152  lsp_name_stream >> result;
2153  }
2154 
2155  // Postconditions:
2156 
2157  ensure(!result.empty());
2158 
2159  // Exit:
2160 
2161  return result;
2162 }
2163 
2167 {
2168  // Preconditions:
2169 
2170  // Body:
2171 
2172  subposet& result = _cells;
2173 
2174  // Postconditions:
2175 
2176  // Exit:
2177 
2178  return result;
2179 }
2180 
2181 const sheaf::subposet&
2183 cells() const
2184 {
2185  // Preconditions:
2186 
2187  // Body:
2188 
2189  const subposet& result = _cells;
2190 
2191  // Postconditions:
2192 
2193  // Exit:
2194 
2195  return result;
2196 }
2197 
2198 std::string
2201 {
2202 
2203  // Preconditions:
2204 
2205  // Body:
2206 
2207  string result = poset_path::reserved_prefix() + "cells";
2208 
2209  // Postconditions:
2210 
2211  // Exit:
2212 
2213  return result;
2214 }
2215 
2216 void
2219 {
2220  // Preconditions:
2221 
2222  require(state_is_read_write_accessible());
2223  require(contains_member(xinterval.interval_member()));
2224 
2225  // Body:
2226 
2227  // Insert the block in the blocks subposet.
2228 
2229  pod_index_type linterval_mbr = xinterval.interval_member();
2230  subposet& lblocks_sp = blocks();
2231  lblocks_sp.insert_member(linterval_mbr);
2232  lblocks_sp.id_space().push_back(linterval_mbr);
2233 
2234  // Insert the cells in the d-cells subposets.
2235 
2236  for(pod_index_type i = xinterval.cells_begin(); i < xinterval.cells_end(); ++i)
2237  {
2238  // Get the dimension directly from the interval member;
2239  // doesn't access dof tuples, which don't exist yet when
2240  // poset is being read from file.
2241 
2242  int ldb = xinterval.db(i);
2243  d_cells(ldb).insert_member(i);
2244 
2245  // Populate cells subposet as well.
2246 
2247  cells().insert_member(i);
2248  }
2249 
2250  // Populate the d-cells id spaces.
2251 
2252  for(int i = 0; i <= max_db(); ++i)
2253  {
2254  pod_index_type lspace_id = xinterval.d_cells_space_id(i);
2255 
2256  if(is_valid(lspace_id))
2257  {
2258  pod_index_type lbegin = member_id_spaces(false).hub_begin(lspace_id);
2259  pod_index_type lend = lbegin + member_id_spaces(false).ct(lspace_id) - 1;
2260 
2261  reinterpret_cast<interval_index_space_handle&>
2262  (d_cells_id_space(i)).push_interval(lbegin, lend);
2263  }
2264  }
2265 
2266  // Populate the cells id space.
2267 
2268  reinterpret_cast<interval_index_space_handle&>
2269  (cells().id_space()).push_interval(xinterval.cells_begin(),
2270  xinterval.cells_end());
2271 
2272  // Insert the block vertices, if any, in the block vertices subposet.
2273 
2274  scattered_insertion_index_space_handle& lvertices_id_space = block_vertices().id_space();
2275 
2276  index_space_iterator& lvertex_itr =
2277  member_id_spaces(false).get_id_space_iterator(xinterval.block_vertices_space_id());
2278  while(!lvertex_itr.is_done())
2279  {
2280  block_vertices().insert_member(lvertex_itr.hub_pod());
2281  lvertices_id_space.push_back(lvertex_itr.hub_pod());
2282  lvertex_itr.next();
2283  }
2284  member_id_spaces(false).release_id_space_iterator(lvertex_itr);
2285 
2286  // Postconditions:
2287 
2288  // Exit:
2289 
2290  return;
2291 }
2292 
2293 // PROTECTED FUNCTIONS
2294 
2295 void
2297 initialize_standard_subposets(const std::string& xname)
2298 {
2299  // Preconditions:
2300 
2301  require(poset_path::is_valid_name(xname));
2302  require(state_is_read_write_accessible());
2303 
2304  // Body:
2305 
2306  // Create the usual subposets
2307 
2308  refinable_poset::initialize_standard_subposets(xname);
2309 
2310  string lsp_name;
2311 
2312  // Make the blocks subposet.
2313 
2314  _blocks.new_state(this);
2315  lsp_name = blocks_name();
2316  _blocks.put_name(lsp_name, true, false);
2317  _blocks.new_id_space("array_index_space_state");
2318  _blocks.put_is_persistent(false);
2319 
2320  // Make the block vertices subposet.
2321 
2322  _block_vertices.new_state(this);
2323  lsp_name = block_vertices_name();
2324  _block_vertices.put_name(lsp_name, true, false);
2325  _block_vertices.new_id_space("array_index_space_state");
2326  _block_vertices.put_is_persistent(false);
2327 
2328  // Make the d-cells subposets.
2329 
2330  int lmax_db = max_db();
2331  _d_cells.reserve(lmax_db + 1);
2332  _d_cells_id_spaces.reserve(lmax_db + 1);
2333 
2334  for(int i=0; i<=lmax_db; i++)
2335  {
2336  _d_cells[i].new_state(this);
2337  lsp_name = d_cells_name(i, lmax_db);
2338  _d_cells[i].put_name(lsp_name, true, false);
2339  _d_cells[i].new_id_space("interval_index_space_state");
2340  _d_cells_id_spaces[i] = &_d_cells[i].id_space();
2341  _d_cells[i].put_is_persistent(false);
2342  }
2343 
2344  // Make the cells subposet.
2345 
2346  _cells.new_state(this);
2347  lsp_name = cells_name();
2348  _cells.put_name(lsp_name, true, false);
2349  _cells.new_id_space("interval_index_space_state");
2350  _cells.put_is_persistent(false);
2351 
2352  // Version subposets are not standard subposets;
2353  // don't change the standard subposet count.
2354 
2355  // // All the subposets are standard.
2356 
2357  // put_standard_subposet_ct(subposet_ct());
2358 
2359  // Postconditions:
2360 
2361  ensure(state_obj()->powerset()->invariant());
2362  ensure(jims().is_attached());
2363  ensure(whole().is_attached());
2364  ensure(resident().is_attached() && resident().index() == RESIDENT_INDEX);
2365  // ensure(has_standard_subposet_ct());
2366  ensure(includes_subposet(blocks_name()));
2367  ensure(includes_subposet(block_vertices_name()));
2368  ensure_for_all(i, 0, max_db(), includes_subposet(d_cells_name(i, max_db())));
2369  ensure(includes_subposet("__cells"));
2370 
2371  // Exit
2372 
2373  return;
2374 }
2375 
2376 // PRIVATE FUNCTIONS
2377 
2378 
2379 // ===========================================================
2380 // TABLE DOFS FACET
2381 // ===========================================================
2382 
2383 // PUBLIC FUNCTIONS
2384 
2385 int
2387 max_db() const
2388 {
2389  int result;
2390 
2391  // Preconditions:
2392 
2393  require(state_is_read_accessible());
2394 
2395  // Body:
2396 
2397  result = table_dof_tuple()->max_db;
2398 
2399  // Postconditions:
2400 
2401  // Exit:
2402 
2403  return result;
2404 }
2405 
2406 void
2408 put_max_db(int xmax_db)
2409 {
2410  // Preconditions:
2411 
2412  require(state_is_read_write_accessible());
2413 
2414  // Body:
2415 
2416  table_dof_tuple()->max_db = xmax_db;
2417 
2418  // Postconditions:
2419 
2420  ensure(max_db() == xmax_db);
2421 
2422  // Exit:
2423 
2424  return;
2425 }
2426 
2427 void
2429 update_max_db(int xmax_db)
2430 {
2431  // Preconditions:
2432 
2433  require(state_is_read_write_accessible());
2434 
2435  // Body:
2436 
2437  define_old_variable(int old_max_db = max_db());
2438 
2439  if(xmax_db > max_db())
2440  {
2441  table_dof_tuple()->max_db = xmax_db;
2442  }
2443 
2444  // Postconditions:
2445 
2446  ensure(max_db() == ((xmax_db > old_max_db) ? xmax_db : old_max_db));
2447 
2448  // Exit:
2449 
2450  return;
2451 }
2452 
2453 
2457 {
2458  const table_dof_tuple_type* result;
2459 
2460  // Preconditions:
2461 
2462 
2463  // Body:
2464 
2465  result = reinterpret_cast<const table_dof_tuple_type*>(table_dof_map().dof_tuple());
2466 
2467  // Postconditions:
2468 
2469 
2470  // Exit:
2471 
2472  return result;
2473 }
2474 
2478 {
2479  table_dof_tuple_type* result;
2480 
2481  // Preconditions:
2482 
2483 
2484  // Body:
2485 
2486  result = reinterpret_cast<table_dof_tuple_type*>(table_dof_map().dof_tuple());
2487 
2488  // Postconditions:
2489 
2490 
2491  // Exit:
2492 
2493  return result;
2494 }
2495 
2496 // PROTECTED FUNCTIONS
2497 
2498 // PRIVATE FUNCTIONS
2499 
2500 
2501 // ===========================================================
2502 // ROW DOFS FACET
2503 // ===========================================================
2504 
2505 // PUBLIC FUNCTIONS
2506 
2507 int
2509 db(pod_index_type xhub_id) const
2510 {
2511  int result = -1;
2512 
2513  // Preconditions:
2514 
2515  require(state_is_read_accessible());
2516  require(contains_member(xhub_id, false));
2517 
2518  // Body:
2519 
2520  if(is_jim(xhub_id, false))
2521  {
2522  // Dimension is a dof.
2523 
2524  result = member_dof_tuple(xhub_id)->db;
2525  }
2526  else
2527  {
2528  // Dimension is max dimension of maximal jims in downset.
2529 
2530  index_space_iterator& litr = get_cover_id_space_iterator(LOWER, xhub_id);
2531  while(!litr.is_done())
2532  {
2533  int lmbr_dim = db(litr.hub_pod());
2534  result = lmbr_dim > result ? lmbr_dim : result;
2535  litr.next();
2536  }
2537  release_cover_id_space_iterator(litr);
2538  }
2539 
2540  // Postconditions:
2541 
2542  ensure(result >= -1);
2543  ensure( (result == -1) == is_jem(xhub_id, bottom().index().pod()) );
2544 
2545  // Exit
2546 
2547  return result;
2548 }
2549 
2550 int
2552 db(const scoped_index& xid) const
2553 {
2554  int result = -1;
2555 
2556  // Preconditions:
2557 
2558  require(state_is_read_accessible());
2559  require(contains_member(xid, false));
2560 
2561  // Body:
2562 
2563  result = db(xid.hub_pod());
2564 
2565  // Postconditions:
2566 
2567  ensure(result >= -1);
2568  ensure( (result == -1) == is_jem(xid, bottom().index()) );
2569 
2570  // Exit
2571 
2572  return result;
2573 }
2574 
2577 type_id(pod_index_type xhub_id) const
2578 {
2579  // Preconditions:
2580 
2581  require(state_is_read_accessible());
2582  require(is_jim(xhub_id, false));
2583 
2584  // Body:
2585 
2586  pod_index_type result = member_dof_tuple(xhub_id)->type_id;
2587 
2588  // Postconditions:
2589 
2590  // Exit
2591 
2592  return result;
2593 }
2594 
2597 type_id(const scoped_index& xid) const
2598 {
2599  // Preconditions:
2600 
2601  require(state_is_read_accessible());
2602  require(is_jim(xid, false));
2603 
2604  // Body:
2605 
2606  return type_id(xid.hub_pod());
2607 }
2608 
2609 std::string
2612 {
2613  // Preconditions:
2614 
2615  require(state_is_read_accessible());
2616  require(is_jim(xhub_id, false));
2617 
2618  // Body:
2619 
2620  string result(member_dof_tuple(xhub_id)->type_name);
2621 
2622  // Postconditions:
2623 
2624  ensure(!result.empty());
2625 
2626  // Exit
2627 
2628  return result;
2629 }
2630 
2631 std::string
2633 type_name(const scoped_index& xid) const
2634 {
2635  // Preconditions:
2636 
2637  require(state_is_read_accessible());
2638  require(is_jim(xid, false));
2639 
2640  // Body:
2641 
2642  string result = type_name(xid.hub_pod());
2643 
2644  // Postconditions:
2645 
2646  ensure(!result.empty());
2647 
2648  // Exit
2649 
2650  return result;
2651 }
2652 
2653 int
2656 {
2657  // Preconditions:
2658 
2659  require(state_is_read_accessible());
2660  require(is_jim(xhub_id, false));
2661 
2662  // Body:
2663 
2664  int result = member_dof_tuple(xhub_id)->refinement_depth;
2665 
2666  // Postconditions:
2667 
2668  // Exit
2669 
2670  return result;
2671 }
2672 
2673 int
2676 {
2677  // Preconditions:
2678 
2679  require(state_is_read_accessible());
2680  require(is_jim(xid, false));
2681 
2682  // Body:
2683 
2684  return refinement_depth(xid.hub_pod());
2685 }
2686 
2687 void
2690 {
2691  // Preconditions:
2692 
2693  require(state_is_read_write_accessible());
2694  require(is_jim(xhub_id, false));
2695 
2696  // Body:
2697 
2698  member_dof_tuple(xhub_id)->refinement_depth = xdepth;
2699 
2700  // Postconditions:
2701 
2702  ensure(refinement_depth(xhub_id) == xdepth);
2703 
2704  // Exit:
2705 
2706  return;
2707 }
2708 
2709 void
2711 put_refinement_depth(const scoped_index& xid, int xdepth)
2712 {
2713  // Preconditions:
2714 
2715  require(state_is_read_write_accessible());
2716  require(is_jim(xid, false));
2717 
2718  // Body:
2719 
2720  put_refinement_depth(xid.hub_pod(), xdepth);
2721 
2722  // Postconditions:
2723 
2724  ensure(refinement_depth(xid) == xdepth);
2725 
2726  // Exit:
2727 
2728  return;
2729 }
2730 
2733 member_dof_tuple(pod_index_type xhub_id, bool xrequire_write_access) const
2734 {
2735  row_dof_tuple_type* result;
2736 
2737  // Preconditions:
2738 
2739  require(xrequire_write_access ?
2740  state_is_read_write_accessible() :
2741  state_is_read_accessible());
2742  require(contains_member(xhub_id));
2743  require(is_jim(xhub_id, false));
2744 
2745  // Body:
2746 
2747  result = row_dof_tuple(member_dof_tuple_id(xhub_id, false),
2748  xrequire_write_access);
2749 
2750  // Postconditions:
2751 
2752  ensure(result != 0);
2753 
2754  // Exit:
2755 
2756  return result;
2757 }
2758 
2761 member_dof_tuple(const scoped_index& xid, bool xrequire_write_access) const
2762 {
2763  row_dof_tuple_type* result;
2764 
2765  // Preconditions:
2766 
2767  require(xrequire_write_access ?
2768  state_is_read_write_accessible() :
2769  state_is_read_accessible());
2770  require(contains_member(xid));
2771  require(is_jim(xid, false));
2772 
2773  // Body:
2774 
2775  result = member_dof_tuple(xid.hub_pod(), xrequire_write_access);
2776 
2777  // Postconditions:
2778 
2779  ensure(result != 0);
2780 
2781  // Exit:
2782 
2783  return result;
2784 }
2785 
2788 row_dof_tuple(pod_index_type xtuple_hub_id, bool xrequire_write_access) const
2789 {
2790  row_dof_tuple_type* result;
2791 
2792  // Preconditions:
2793 
2794  require(xrequire_write_access ?
2795  state_is_read_write_accessible() :
2796  state_is_read_accessible());
2797  require(contains_row_dof_tuple(xtuple_hub_id));
2798 
2799  // Body:
2800 
2801  poset_dof_map& ldof_map = row_dof_map(xtuple_hub_id, xrequire_write_access);
2802  result = reinterpret_cast<row_dof_tuple_type*>(ldof_map.dof_tuple());
2803 
2804  // Postconditions:
2805 
2806  ensure(result != 0);
2807 
2808  // Exit:
2809 
2810  return result;
2811 }
2812 
2815 row_dof_tuple(const scoped_index& xtuple_id, bool xrequire_write_access) const
2816 {
2817  row_dof_tuple_type* result;
2818 
2819  // Preconditions:
2820 
2821  require(xrequire_write_access ?
2822  state_is_read_write_accessible() :
2823  state_is_read_accessible());
2824  require(contains_row_dof_tuple(xtuple_id));
2825 
2826  // Body:
2827 
2828  result = row_dof_tuple(xtuple_id.hub_pod(), xrequire_write_access);
2829 
2830  // Postconditions:
2831 
2832  ensure(result != 0);
2833 
2834  // Exit:
2835 
2836  return result;
2837 }
2838 
2839 const sheaf::scoped_index&
2841 new_row_dof_map(const std::string& xprototype_name)
2842 {
2843  // Preconditions:
2844 
2845  require(state_is_read_write_accessible());
2846  require(name_space()->member_poset(prototypes_poset_name()).state_is_auto_read_accessible(true));
2847  require(name_space()->contains_poset_member(prototypes_poset_name()+"/"+xprototype_name, false));
2848 
2849  // Body:
2850 
2851  define_old_variable(int old_row_dof_tuple_ct = row_dof_tuple_ct());
2852 
2853  // Create the dof map and set dofs to defaults.
2854 
2855  const scoped_index& result = new_row_dof_map();
2856  row_dof_tuple_type* ltuple = row_dof_tuple(result.pod(), true);
2857 
2858  // Get the prototype.
2859 
2860  poset_path lproto_path(prototypes_poset_name(), xprototype_name);
2861  base_space_member lproto(name_space(), lproto_path, false);
2862  lproto.get_read_access();
2863  row_dof_tuple_type* lproto_tuple = lproto.row_dof_tuple(false);
2864 
2865  // Copy its dofs.
2866 
2867  ltuple->db = lproto_tuple->db;
2868  ltuple->type_id = lproto_tuple->type_id;
2869  ltuple->type_name = strdup(lproto_tuple->type_name);
2870  ltuple->refinement_depth = lproto_tuple->refinement_depth;
2871  ltuple->local_cell_type_id = lproto_tuple->local_cell_type_id;
2872  ltuple->local_cell_type_name = strdup(lproto_tuple->local_cell_type_name);
2873  ltuple->size = lproto_tuple->size;
2874  ltuple->i_size = lproto_tuple->i_size;
2875  ltuple->j_size = lproto_tuple->j_size;
2876  ltuple->k_size = lproto_tuple->k_size;
2877 
2878  // Release the prototype.
2879 
2880  lproto.release_access();
2881 
2882  // Postconditions:
2883 
2884  ensure(row_dof_tuple_ct() == old_row_dof_tuple_ct+1);
2885  ensure(contains_row_dof_tuple(result));
2886 
2887  // Exit:
2888 
2889  return result;
2890 }
2891 
2892 // PROTECTED FUNCTIONS
2893 
2894 // PRIVATE FUNCTIONS
2895 
2896 
2897 // ===========================================================
2898 // I/O SUPPORT FACET
2899 // ===========================================================
2900 
2901 // PUBLIC FUNCTIONS
2902 
2903 bool
2906 {
2907  // Preconditions::
2908 
2909  // Body:
2910 
2911  bool result = crg().contains_explicit_member(xmbr_id);
2912 
2913  // Postconditions:
2914 
2915  // Exit:
2916 
2917  return result;
2918 }
2919 
2920 bool
2923 {
2924  // Preconditions::
2925 
2926  // Body:
2927 
2928  implicit_crg_interval* linterval = crg().implicit_member(xmbr_id);
2929 
2930  bool result = (linterval != 0) && linterval->is_interval_member(xmbr_id);
2931 
2932  // Postconditions:
2933 
2934  // Exit:
2935 
2936  return result;
2937 }
2938 
2939 // PROTECTED FUNCTIONS
2940 
2941 // PRIVATE FUNCTIONS
2942 
2943 
2944 // ===========================================================
2945 // ANY FACET
2946 // ===========================================================
2947 
2948 // PUBLIC FUNCTIONS
2949 
2950 bool
2952 is_ancestor_of(const any* xother) const
2953 {
2954  bool result;
2955 
2956  // Preconditions:
2957 
2958  // Body:
2959 
2960  result = dynamic_cast<const base_space_poset*>(xother) != 0;
2961 
2962  // Postconditions:
2963 
2964  // Exit
2965 
2966  return result;
2967 }
2968 
2969 bool
2971 invariant() const
2972 {
2973  bool result = true;
2974 
2975 
2976  if(invariant_check())
2977  {
2978  disable_invariant_check();
2979 
2980  invariance(refinable_poset::invariant());
2981 
2984 
2985  enable_invariant_check();
2986  }
2987 
2988  return result;
2989 }
2990 
2991 // PROTECTED FUNCTIONS
2992 
2995 clone() const
2996 {
2997  base_space_poset* result;
2998 
2999  // Preconditions:
3000 
3001  // Body:
3002 
3003  result = new base_space_poset;
3004 
3005  // Postconditions:
3006 
3007  ensure(result != 0);
3008  ensure(is_same_type(result));
3009  ensure(!result->is_attached());
3010 
3011  // Exit
3012 
3013  return result;
3014 }
3015 
3016 // PRIVATE FUNCTIONS
3017 
3018 
3019 // ===========================================================
3020 // NON-MEMBER FUNCTIONS
3021 // ===========================================================
3022 
3023 size_t
3024 fiber_bundle::deep_size(const base_space_poset& xp, bool xinclude_shallow, size_t xresults[4])
3025 {
3026  size_t result;
3027 
3028  // Preconditions:
3029 
3030  require(xp.state_is_read_accessible());
3031 
3032  // Body:
3033 
3034  result = xinclude_shallow ? sizeof(xp) : 0;
3035 
3036  // Add contributions of the parent class.
3037 
3038  const poset_state_handle& lxp =
3039  reinterpret_cast<const poset_state_handle&>(xp);
3040 
3041  result += deep_size(lxp, false, xresults);
3042 
3043  // Add contributions of _d_cells_id_spaces.
3044 
3047 
3048  for(pod_index_type i = 0; i < xp._d_cells_id_spaces.ub(); ++i)
3049  {
3050  result += sizeof(xp._d_cells_id_spaces[i]);
3051  }
3052 
3053  // Postconditions:
3054 
3055  ensure(result >= 0);
3056 
3057  // Exit
3058 
3059  return result;
3060 }
An implementation of class scattered_insertion_index_space_handle that has a interval id space state...
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...
void release_vertex_id_space_iterator(index_space_iterator &xitr, bool xauto_access) const
Returns the iterator to the vertex id space, xitr to the pool of id space iterators.
virtual const char * class_name() const
The name of this class.
virtual void initialize_standard_subposets(const std::string &xname)
Creates the subposets common to every poset (i.e._whole and _jims).
virtual poset_path path(bool xauto_access=true) const
The path of this poset.
bool state_is_auto_read_write_accessible(bool xauto_access) const
True if state is auto accessible for read and write, that is, if the state is already accessible for ...
virtual ~base_space_poset()
Destructor.
A client handle for a subposet.
Definition: subposet.h:86
bool is_valid() const
True if this is a valid id.
Definition: scoped_index.h:832
pod_index_type vertices_space_id() const
The index of the vertex id space.
bool full() const
True if both poset name and member name are not empty.
Definition: poset_path.cc:311
pod_index_type vertex_client_space_id() const
The index of the vertex client id space.
const pod_type & pod() const
The "plain old data" storage of this; the value in the external id space.
Definition: scoped_index.h:672
An abstract iterator over the ids of an id space.
size_type size
The number of local cells.
std::string type_name(pod_index_type xmbr_hub_id) const
The type id of the member with hub id xmbr_hub_id.
poset_path path(bool xauto_access=true) const
A path to this component.
row_dof_tuple_type * row_dof_tuple(pod_index_type xtuple_hub_id, bool xrequire_write_access=false) const
The row dof tuple with tuple hub id xtuple_hub_id.
The default name space; a poset which contains other posets as members.
int refinement_depth(pod_index_type xmbr_hub_id) const
The refinement depth of the member with hub id xmbr_hub_id.
index_space_iterator & get_vertex_id_space_iterator(pod_index_type xmbr_id, bool xauto_access) const
Allocates an vertex id space iterator for the block containing the member with index xmbr_id for the ...
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
The type of table dof tuple for base_space_poset.
bool contains_vertex_client_id_space(pod_index_type xmbr_id, bool xauto_access) const
True, if and only if the block containing the member with index xmbr_id has a vertex client id space...
subposet & d_cells(int xd)
The subposet containing the cells of dimension xd (mutable version).
subposet & blocks()
The subposet containing all the blocks, const ver (mutable version).
bool path_is_auto_read_accessible(const poset_path &xpath, bool xauto_access) const
True if the state referred to xpath exists and is auto read accessible.
void release_vertex_id_space(index_space_handle &xid_space, bool xauto_access) const
Returns the handle to the vertex id space, xid_space to the pool of id space handles.
poset_type
Identifiers for poset types.
Definition: poset_type.h:41
const char * local_cell_type_name
The local cell type name.
void update_max_db(int xmax_db)
Sets max_db() to the larger of old max_db() and xmax_db.
void release_adjacency_id_space(index_space_handle &xid_space, bool xauto_access) const
Returns the id space handle xid_space to the adjacency handle pool.
A client handle for a general, abstract partially order set.
const scoped_index & new_row_dof_map(const std::string &xprototype_name)
Creates a new dof map with dofs equal to those of the prototype with name xprototype_name.
void release_connectivity_id_space_iterator(index_space_iterator &xid_space, bool xauto_access) const
Returns the id space iterator xid_space to the connectivity iterator pool.
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.
virtual void * dof_tuple()=0
The dof tuple (mutable version).
virtual bool is_ancestor_of(const any *other) const
True if other conforms to this.
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
bool is_interval_member(pod_index_type xindex) const
True if xindex is the interval member.
STL namespace.
An abstract handle to a space of alternate integer identifiers (aliases) for a subset of a hub set of...
pod_index_type adjacency_space_id(pod_index_type xvertex_id) const
The index of the adjacency id space for vertex with id xvertex_id.
virtual void release_id_space() const
Returns this id space handle to the handle pool.
subposet & cells()
The subposet containing all the cells, of any dimension.
virtual base_space_poset * clone() const
Virtual constructor; creates a new handle of the same actual type as this, attached to the same state...
virtual const index_space_family & id_spaces() const =0
The id space family for this (const version).
void release_zone_id_space(index_space_handle &xid_space, bool xauto_access) const
Returns the handle to the zone id space, xid_space to the pool of id space handles.
virtual void get_read_access() const
Get read access to the state associated with this.
scoped_index prototype_dof_tuple_id(const std::string &xname, int xdepth, bool xcreate, bool xauto_access) const
The dof tuple id in this of the base space member prototype with name xname and refinememnt_depth xde...
virtual void next()=0
Makes id() the next id in the iteration.
void release_zone_id_space_iterator(index_space_iterator &xitr, bool xauto_access) const
Returns the iterator to the zone id space, xitr to the pool of id space iterators.
const pod_index_type & type_id() const
The cell type id of this. The id of the prototype of this in the "cell_types" id space of the prototy...
The general, abstract map from dof ids to dof values.
Definition: poset_dof_map.h:59
virtual bool is_attached() const =0
True if this handle is attached to a state.
pod_index_type prototype_type_id(const std::string &xname, bool xauto_access=true) const
The type id of the base space member prototype with name xname.
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...
static std::string blocks_name()
The name of the blocks subposet.
virtual pod_type pod(pod_type xid) const
The pod index in this space equivalent to xid in the hub id space.
A client handle for a member of a base space poset.
Abstract implementation of crg_interval for an interval of implicit cover relation graph members...
index_space_iterator & get_vertex_client_id_space_iterator(pod_index_type xmbr_id, bool xauto_access) const
Allocates an vertex client id space iterator for the block containing the member with index xmbr_id f...
virtual pod_index_type cells_begin() const =0
The beginning of the local cells interval.
bool contains_vertex_id_space(pod_index_type xmbr_id, bool xauto_access) const
True, if and only if the block containing the member with index xmbr_id has a vertex id space...
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...
static std::string cells_name()
The name of the cells subposet.
index_space_iterator & get_connectivity_id_space_iterator(pod_index_type xzone_id, bool xauto_access) const
Allocates an id space iterator from the connectivity iterator pool attached to the connectivity id sp...
Abstract base class with useful features for all objects.
Definition: any.h:39
The lattice of closed cells of a cellular space; a lattice representation of a computational mesh...
size_type k_size
The upper bound on the z direction index for structured blocks.
void put_max_db(int xmax_db)
Sets max_db() to xmax_db.
scattered_insertion_index_space_handle & d_cells_id_space(int xd)
The id space for the subposet containing the cells of dimension xd (mutable version).
virtual schema_poset_member & schema()
The schema for this poset (mutable version).
bool is_done() const
True if iteration is finished.
Emulator for a interval of implicit base space members representing a homogeneous collection of cells...
void insert_interval_in_standard_subposets(base_space_crg_interval &xinterval)
Inserts interval xinterval into the standard subposets.
A factory for instanting descendants of an abstract type T, given the class name of the descendant...
Definition: eval_family.h:49
size_type i_size
The upper bound on the x direction index for structured blocks.
const table_dof_tuple_type * table_dof_tuple() const
The table dof tuple for this (const version).
virtual index_space_handle & get_id_space() const
Allocates an id space handle from the handle pool.
const index_space_family & id_spaces() const
The id space family for this (const version).
virtual const scoped_index & new_row_dof_map()
Creates a new row dof map.
static const std::string & prototypes_poset_name()
The name of the prototypes poset; a synonym for bsae_space_member::prototypes_poset_name().
subposet & vertices()
The subposet containing all the vertices, that is, the cells of dimension 0 (mutable version)...
bool owns(const poset_state_handle &xposet, bool xauto_access) const
True if and only if this contains the poset xposet. synonym for contains_poset(xposet.poset_path(true), xauto_access)
pod_index_type interval_member() const
The index of the interval member itself; synonym for begin().
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.
void release_adjacency_id_space_iterator(index_space_iterator &xid_space, bool xauto_access) const
Returns the id space iterator xid_space to the adjacency iterator pool.
virtual void attach_handle_data_members()
Initializes the handle data members when this handle is attached to a state.
virtual poset_type type_id() const
Identifier for the type of this poset.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
virtual pod_index_type d_cells_space_id(int xd) const =0
The id space index for the cells of dimension xd. Returns invalid_pod_index() if there is no id space...
virtual void insert_member(pod_index_type xmbr_hub_id)
Inserts the member of host() with hub id xmbr_hub_id.
Definition: subposet.cc:1091
index_space_handle & get_vertex_client_id_space(pod_index_type xmbr_id, bool xauto_access) const
Allocates an vertex client id space handle for the block containing the member with index xmbr_id for...
bool contains_path(const poset_path &xpath, bool xauto_access=true) const
True if this contains the poset or poset member specified by xpath.
index_space_iterator & get_zone_id_space_iterator(pod_index_type xmbr_id, bool xauto_access) const
Allocates an zone id space iterator for the block containing the member with index xmbr_id for the po...
const bool UPPER
Selector for upper cover.
Definition: sheaf.h:72
pod_index_type zones_space_id() const
The index of the zone id space.
static std::string block_vertices_name()
The name of the block vertices subposet.
pod_index_type connectivity_space_id(pod_index_type xzone_id) const
The index of the connectivity id space for zone with id xzone_id.
int db(pod_index_type xmbr_hub_id) const
The base space dimension of the member with hub id xmbr_hub_id.
virtual pod_index_type cells_end() const =0
The end of the local cells interval.
void release_connectivity_id_space(index_space_handle &xid_space, bool xauto_access) const
Returns the id space handle xid_space to the connectivity handle pool.
virtual int db(pod_index_type xmbr_id) const =0
The dimension of the member with id xmbr_id. Does not require access to dof tuple.
pod_index_type block_vertices_space_id() const
The id space index of the block vertices id space.
bool empty() const
True if both poset name and member name are empty.
Definition: poset_path.cc:291
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...
pod_index_type new_member(const std::string &xprototype_name, bool xcopy_dof_map)
Creates a disconnected jim using the prototype with name xprototype_name. If xcopy_dof_map or if xhos...
static const poset_path & standard_schema_path()
The path to the standard schema for this class.
bool contains_zone_id_space(pod_index_type xmbr_id, bool xauto_access) const
True, if and only if the block containing the member with index xmbr_id has a zone id space...
index_space_handle & get_vertex_id_space(pod_index_type xmbr_id, bool xauto_access) const
Allocates an vertex id space handle for the block containing the member with index xmbr_id for the po...
index_space_handle & get_connectivity_id_space(pod_index_type xzone_id, bool xauto_access) const
Allocates an id space handle from the connectivity handle pool attached to the connectivity id space ...
const index_space_family & id_spaces() const
The id space family for this interval.
const char * type_name() const
The cell type name.
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
size_type j_size
The upper bound on the y direction index for structured blocks.
static base_space_poset & new_table(namespace_type &xhost, const poset_path &xpath, const poset_path &xschema_path, int xmax_db, bool xauto_access)
Creates a new base_space_poset in namespace xns with path xpath, schema specified by xschema_path...
bool contains_adjacency_id_space(pod_index_type xvertex_id, bool xauto_access) const
True if this poset contains the adjacency for a vertex with id xvertex_id.
block< scattered_insertion_index_space_handle * > _d_cells_id_spaces
The id spaces for the subposets containing the cells of dimension 0 <= d <= db(). ...
Emulator for a interval of implicit base space members representing an unstructured block...
const bool LOWER
Selector for lower cover.
Definition: sheaf.h:67
const scattered_insertion_index_space_handle & id_space() const
The id space for the members of with this (const version).
Definition: subposet.cc:508
void release_vertex_client_id_space(index_space_handle &xid_space, bool xauto_access) const
Returns the handle to the vertex client id space, xid_space to the pool of id space handles...
virtual void detach_from_state()
Detach this handle from its state, if any.
virtual bool is_attached() const
True if this is attached to a state.
virtual bool invariant() const
Class invariant.
bool is_block_member(pod_index_type xmbr_id) const
True if the member with hub id xmbr_id is a block member.
bool is_explicit_member(pod_index_type xmbr_id) const
True if the member with hub id xmbr_id is an explicit member.
virtual bool is_attached() const =0
True if this iterator is attached to a state.
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.
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
A handle for a scattered_insertion_index_space_state.
static std::string d_cells_name(int xdb, int xmax_db)
The name of the xdb-cell subposet.
Abstract emulator for a interval of implicit base space members.
void push_back(const scoped_index &xhub_id)
Make the next id in this space equivalent to xhub_id in the hub id space. synonym for push_back(xhub_...
subposet & elements()
The subposet containing the elements or zones, that is, the cells of maximal dimension.
void insert_prototype(T *xprototype)
Sets xprototype as the prototype for its client class.
Definition: factory.impl.h:144
bool contains_connectivity_id_space(pod_index_type xzone_id, bool xauto_access) const
True if this poset contains the connectivity for a zone with id xzone_id.
index_space_iterator & get_adjacency_id_space_iterator(pod_index_type xvertex_id, bool xauto_access) const
Allocates an id space iterator from the adjacency iterator pool attached to the adjacency id space st...
base_space_poset()
Default constructor; creates a new base_space_poset handle not attached to any state.
virtual void get_read_access() const
Get read access to the state associated with this.
int max_db() const
The maximum dimension of the members of this base space.
bool vertices_initialized() const
True if the vertex id space has been initialized.
The type of row dof tuple for base_space_member.
bool vertex_client_id_space_initialized() const
True if and only if the vertex client id space has been initialized.
subposet & block_vertices()
The subposet containing the vertices associated with blocks (mutable version).
row_dof_tuple_type * member_dof_tuple(pod_index_type xmbr_hub_id, bool xrequire_write_access=false) const
The row dof tuple for the member with member hub id xmbr_hub_id.
An array representation of abstract class poset_dof_map.
bool zones_initialized() const
True if the zone id space has been initialized.
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.
SHEAF_DLL_SPEC pod_index_type invalid_pod_index()
The invalid pod index value.
Definition: pod_types.cc:31
void release_vertex_client_id_space_iterator(index_space_iterator &xitr, bool xauto_access) const
Returns the iterator to the vertex client id space, xitr to the pool of id space iterators.
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...
void put_refinement_depth(pod_index_type xmbr_hub_id, int xdepth)
Sets the refinement depth of the member with hub id xmbr_hub_id to xdepth.
A client handle for a poset member which has been prepared for use as a schema.
bool contains_hub(const std::string &xname, pod_type xid) const
True if the space with name xname contains an id equivalent to xid in the unglued hub id space...
row_dof_tuple_type * row_dof_tuple(bool xrequire_write_access=false)
The row dof tuple for this.
pod_type hub_pod() const
The current unglued hub id in the iteration. synonym for unglued_hub_pod().
index_space_handle & get_adjacency_id_space(pod_index_type xvertex_id, bool xauto_access) const
Allocates an id space handle from the adjacency handle pool attached to the adjacency id space state ...
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.
Definition: scoped_index.h:710
index_space_handle & get_zone_id_space(pod_index_type xmbr_id, bool xauto_access) const
Allocates an zone id space handle for the block containing the member with index xmbr_id from the poo...