SheafSystem  0.0.0.0
section_space_schema_poset_2.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/section_space_schema_poset.h"
22 
23 #include "SheafSystem/abstract_poset_member.impl.h"
24 #include "SheafSystem/arg_list.h"
25 #include "SheafSystem/array_poset_dof_map.h"
26 #include "SheafSystem/index_iterator.h"
27 #include "SheafSystem/index_space_iterator.h"
28 #include "SheafSystem/list_cover_set.h"
29 #include "SheafSystem/error_message.h"
30 #include "SheafSystem/namespace_poset.impl.h"
31 #include "SheafSystem/namespace_poset_member.h"
32 #include "SheafSystem/pod_types.h"
33 #include "SheafSystem/poset_member_iterator.h"
34 #include "SheafSystem/poset_state.h"
35 #include "SheafSystem/schema_descriptor.h"
36 #include "SheafSystem/section_space_schema_member.impl.h"
37 #include "SheafSystem/section_space_schema_table_dofs_type.h"
38 #include "SheafSystem/std_limits.h"
39 #include "SheafSystem/tern.h"
40 #include "SheafSystem/wsv_block.h"
41 
42 using namespace std;
43 using namespace fiber_bundle; // Workaround for MS C++ bug.
44 
45 // ===========================================================
46 // SECTION_SPACE_SCHEMA_POSET FACET
47 // ===========================================================
48 
49 // PUBLIC FUNCTIONS
50 
51 const std::string&
54 {
55 
56  // Preconditions:
57 
58 
59  // Body:
60 
61  static const string result("section_space_schema_schema");
62 
63  // Postconditions:
64 
65  ensure(!result.empty());
66 
67  // Exit:
68 
69  return result;
70 }
71 
72 const sheaf::poset_path&
75 {
76  // Preconditions:
77 
78 
79  // Body:
80 
81  static const poset_path
82  result(standard_schema_poset_name(), "section_space_schema_schema");
83 
84  // Postconditions:
85 
86  ensure(result.full());
87  ensure(result.poset_name() == standard_schema_poset_name());
88 
89  // Exit:
90 
91  return result;
92 }
93 
94 void
97 {
98  // Preconditions:
99 
100  require(xns.state_is_read_write_accessible());
101  require(xns.contains_poset(standard_schema_poset_name(), false));
102  require(xns.member_poset(standard_schema_poset_name(), false)->state_is_read_write_accessible());
103  require(!xns.contains_poset_member(standard_schema_path(), false));
104 
105  // Body:
106 
107  string ldof_specs;
108 
109  // Row dofs are same as row dofs of primitives:
110 
111  ldof_specs = "size SIZE_TYPE false";
112  ldof_specs += " alignment SIZE_TYPE false";
113  ldof_specs += " type POD_INDEX_TYPE false";
114 
115  // Table dofs:
116 
117  ldof_specs += " rep_path C_STRING true";
118  ldof_specs += " base_space_path C_STRING true";
119  ldof_specs += " fiber_space_path C_STRING true";
120 
121  schema_poset_member lschema(xns,
122  standard_schema_path().member_name(),
123  poset_path(standard_schema_poset_name(), "bottom"),
124  ldof_specs,
125  false,
126  false);
127 
128  lschema.detach_from_state();
129 
130  // Postconditions:
131 
132  ensure(xns.contains_poset_member(standard_schema_path()));
133 
134  // Exit
135 
136  return;
137 }
138 
141 rep()
142 {
143  return _rep;
144 }
145 
148 rep() const
149 {
150  return _rep;
151 }
152 
153 bool
155 rep_is_valid(const sec_rep_descriptor& xrep, const poset_state_handle& xbase_space)
156 {
157  bool result;
158 
159  // Preconditions:
160 
161  require(xrep.state_is_read_accessible());
162  require(xbase_space.state_is_read_accessible());
163 
164  // Body:
165 
166  // Discretization subposet must exist.
167 
168  result = xbase_space.includes_subposet(xrep.discretization_subposet_name());
169 
170  // Discretization must have a non-empty id space;
171  // see section_space_schems_index_map - doesn't support empty factors.
172 
173  subposet ldisc_sp(&xbase_space, xrep.discretization_subposet_name());
174  result = result && ldisc_sp.has_id_space() && !ldisc_sp.id_space().is_empty();
175  ldisc_sp.detach_from_state();
176 
177  // Evaluation subposets must exist.
178 
179  result = result && xbase_space.includes_subposet(xrep.evaluation_subposet_name());
180 
184 
185  // Postconditions:
186 
187  // Exit
188 
189  return result;
190 }
191 
192 bool
194 rep_is_valid(const namespace_poset& xns, const arg_list& xargs, bool xauto_access) const
195 {
196  bool result;
197 
198  // Preconditions:
199 
200  require(xargs.conforms_to(xns, standard_schema_path(), true, xauto_access));
201 
202  require(xns.contains_poset_member(poset_path(xargs.value("rep_path")), xauto_access));
203  require(xns.member_poset(poset_path(xargs.value("rep_path")), xauto_access)->state_is_auto_read_accessible(xauto_access));
204 
205  require(xns.contains_poset(poset_path(xargs.value("base_space_path")), xauto_access));
206  require(xns.member_poset(poset_path(xargs.value("base_space_path")), xauto_access)->state_is_auto_read_accessible(xauto_access));
207 
208  // Body:
209 
210  poset_state_handle& lbase_space = *xns.member_poset(poset_path(xargs.value("base_space_path")), xauto_access);
211  sec_rep_descriptor lrep(&xns, xargs.value("rep_path"), xauto_access);
212 
213  if(xauto_access)
214  {
215  lbase_space.get_read_access();
216  lrep.get_read_access();
217  }
218 
219  result = rep_is_valid(lrep, lbase_space);
220 
221  if(xauto_access)
222  {
223  lrep.release_access();
224  lbase_space.release_access();
225  }
226 
227  lrep.detach_from_state();
228 
229  // Postconditions:
230 
231  // Exit
232 
233  return result;
234 }
235 
236 int
238 db() const
239 {
240  int result;
241 
242  // Preconditions:
243 
244  require(state_is_read_accessible());
245 
246  // Body:
247 
248  result = _base_space->max_db();
249 
250  // Postconditions:
251 
252  ensure(result >= 0);
253 
254  // Exit
255 
256  return result;
257 }
258 
261 base_space()
262 {
263  return *_base_space;
264 }
265 
268 base_space() const
269 {
270  return *_base_space;
271 }
272 
273 int
275 df() const
276 {
277  int result;
278 
279  // Preconditions:
280 
281  require(state_is_read_accessible());
282 
283  // Body:
284 
288 
289  result = _fiber_space->schema().row_dof_ct();
290 
291  // Postconditions:
292 
293  ensure(result >= 0);
294 
295  // Exit
296 
297  return result;
298 }
299 
302 fiber_schema()
303 {
304  require(state_is_read_accessible());
305 
306  return *_fiber_space->schema().host();
307 }
308 
311 fiber_schema() const
312 {
313  require(state_is_read_accessible());
314 
315  return *_fiber_space->schema().host();
316 }
317 
320 fiber_space()
321 {
322  return *_fiber_space;
323 }
324 
325 const sheaf::poset&
327 fiber_space() const
328 {
329  return *_fiber_space;
330 }
331 
335 {
336  return _discretization;
337 }
338 
339 const sheaf::subposet&
341 discretization() const
342 {
343  return _discretization;
344 }
345 
348 evaluation()
349 {
350  return _evaluation;
351 }
352 
353 const sheaf::subposet&
355 evaluation() const
356 {
357  return _evaluation;
358 }
359 
360 string
362 evaluator_family_name() const
363 {
364  // Preconditions:
365 
366  require(rep().state_is_read_accessible());
367 
368  // Body:
369 
370  string result = _rep.evaluator_family_name();
371 
372  // Postconditions:
373 
374  // Exit:
375 
376  return result;
377 }
378 
379 void
381 tuple(const scoped_index& xindex,
382  scoped_index& xbase_space_id,
383  scoped_index& xfiber_schema_id) const
384 {
385  // Preconditions:
386 
387  require(state_is_read_accessible());
388  require(is_homogeneous(xindex));
389 
390  // Body:
391 
392  pod_index_type lbase_space_id, lfiber_schema_id;
393  tuple(xindex.hub_pod(), lbase_space_id, lfiber_schema_id);
394 
395  xbase_space_id.put(base_space().member_hub_id_space(false), lbase_space_id);
396  xfiber_schema_id.put(fiber_schema().member_hub_id_space(false), lfiber_schema_id);
397 
398  // Postconditions:
399 
400  ensure(contains_range_member(xbase_space_id, xfiber_schema_id, false));
401 
402  // Exit:
403 
404  return;
405 }
406 
407 void
410  pod_index_type& xbase_space_id,
411  pod_index_type& xfiber_schema_id) const
412 {
413  // Preconditions:
414 
415  require(state_is_read_accessible());
416  require(is_homogeneous(xindex));
417 
418  // Body:
419 
420  is_abstract();
421 
422  // Postconditions:
423 
424  ensure(contains_range_member(xbase_space_id, xfiber_schema_id, false));
425 
426  // Exit:
427 
428  return;
429 }
430 
431 void
433 ordinal(const scoped_index& xbase_space_id,
434  const scoped_index& xfiber_schema_id,
435  scoped_index& xindex) const
436 {
437  // Preconditions:
438 
439  require(contains_range_member(xbase_space_id, xfiber_schema_id, false));
440 
441  // Body:
442 
443  pod_index_type lindex;
444  ordinal(xbase_space_id.hub_pod(), xfiber_schema_id.hub_pod(), lindex);
445 
446  xindex.put(member_hub_id_space(false), lindex);
447 
448  // Postconditions:
449 
450  ensure(is_homogeneous(xindex));
451 
452  // Exit:
453 
454  return;
455 }
456 
457 void
459 ordinal(pod_index_type xbase_space_id,
460  pod_index_type xfiber_schema_id,
461  pod_index_type& xindex) const
462 {
463  // Preconditions:
464 
465  require(contains_range_member(xbase_space_id, xfiber_schema_id, false));
466 
467  // Body:
468 
469  is_abstract();
470 
471  // Postconditions:
472 
473  ensure(is_homogeneous(xindex));
474 
475  // Exit:
476 
477  return;
478 }
479 
480 bool
482 is_homogeneous(const scoped_index& xindex) const
483 {
484  // Preconditions:
485 
486  // Body:
487 
488  // Postconditions:
489 
490  ensure(is_basic_query);
491 
492  // Exit:
493 
494  return is_homogeneous(xindex.hub_pod());
495 }
496 
497 bool
500 {
501  // Preconditions:
502 
503  // Body:
504 
505  bool result = false; // Just to silence compiler
506 
507  is_abstract();
508 
509  // Postconditions:
510 
511  ensure(is_basic_query);
512 
513  // Exit:
514 
515  return result;
516 }
517 
518 bool
520 contains_range_member(const scoped_index& xbase_space_id,
521  const scoped_index& xfiber_schema_id,
522  bool xauto_access) const
523 {
524  // Preconditions:
525 
526  require(state_is_auto_read_accessible(xauto_access));
527 
528  // Body:
529 
530  bool result = contains_range_member(xbase_space_id.hub_pod(),
531  xfiber_schema_id.hub_pod(),
532  xauto_access);
533 
534  // Postconditions:
535 
536  ensure(is_basic_query);
537 
538  // Exit:
539 
540  return result;
541 }
542 
543 bool
546  pod_index_type xfiber_schema_id,
547  bool xauto_access) const
548 {
549  // Preconditions:
550 
551  require(state_is_auto_read_accessible(xauto_access));
552 
553  // Body:
554 
555  bool result = false; // Just to silence compiler
556 
557  is_abstract();
558 
559  // Postconditions:
560 
561  ensure(is_basic_query);
562 
563  // Exit:
564 
565  return result;
566 }
567 
568 void
570 update_hub_id_space(bool xauto_access)
571 {
572  // Preconditions:
573 
574  require(state_is_auto_read_write_accessible(xauto_access));
575 
576  // Body:
577 
578  is_abstract();
579 
580  // Postconditions:
581 
582  // Exit:
583 
584  return;
585 }
586 
587 // PROTECTED FUNCTIONS
588 
591 {
592  // Preconditions:
593 
594  // Body:
595 
596  _rep.detach_from_state();
597  _discretization.detach_from_state();
598  _evaluation.detach_from_state();
599 
600  // Postconditions:
601 
602  // Exit
603 
604  return;
605 }
606 
609  : poset(xtop, xbottom),
610  _base_space(0),
611  _fiber_space(0)
612 {
613  // Preconditions:
614 
615  // Body:
616 
617  // Postconditions:
618 
619  // Exit
620 
621  return;
622 }
623 
624 void
627 {
628  // Preconditions:
629 
630  require(state_is_read_write_accessible());
631  require(fiber_schema().is_attached());
632 
633  // Body:
634 
635  // Create the table dof subposet.
636 
637  table_dof_subposet().new_state(this);
638  table_dof_subposet().put_name(schema_poset_member::table_dof_subposet_name("top"), true, false);
639 
640  // Enter jim edit mode.
641 
642  begin_jim_edit_mode(false);
643 
644  // Create members for the table dofs.
645 
646  pod_index_type lid;
647 
648  index_space_iterator& litr =
649  fiber_schema().table_dof_subposet().id_space().get_iterator();
650  while(!litr.is_done())
651  {
653 // // Construct a member at the same hub id as the fiber schema table
654 // // dof member.
655 
656 // new_member(litr.hub_pod(), true, 0, false);
657 
658 // // Link member to top and bottom (table dof is an atom).
659 
660 // new_link(TOP_INDEX, litr.hub_pod());
661 // new_link(litr.hub_pod(), BOTTOM_INDEX);
662 
663  // Insert member into the subposets.
664 
665  ordinal(BOTTOM_INDEX, litr.hub_pod(), lid);
666  table_dof_subposet().insert_member(lid);
667 
668  litr.next();
669  }
670  fiber_schema().table_dof_subposet().id_space().release_iterator(litr);
671 
672  // Initialize the table dof subposet id space.
673 
674  initialize_dof_id_space(table_dof_subposet());
675 
676  end_jim_edit_mode(false, false);
677 
678  // Now the cover relation graph invariant is satisfied
679 
680  crg().enable_invariant_check();
681 
682  // Postconditions:
683 
684  ensure(crg().invariant());
685  ensure(table_dof_subposet().is_attached());
686 
687  // Exit:
688 
689  return;
690 }
691 
692 // PRIVATE FUNCTIONS
693 
694 
695 // ===========================================================
696 // STATE FACET
697 // ===========================================================
698 
699 // PUBLIC FUNCTIONS
700 
703 type_id() const
704 {
705  return SECTION_SPACE_SCHEMA_POSET_ID;
706 }
707 
708 const char*
710 class_name() const
711 {
712  // Preconditions:
713 
714  // Body:
715 
716  static const char* result = "section_space_schema_poset";
717 
718  // Postconditions:
719 
720  // Exit:
721 
722  return result;
723 }
724 
725 void
727 get_read_access() const
728 {
729  // Preconditions:
730 
731  require(is_attached());
732 
733  // Body:
734 
735  int old_access_request_depth = access_request_depth();
736 
737  rep().get_read_access();
738  base_space().get_read_access();
739  fiber_space().get_read_access();
740  poset::get_read_access();
741 
742  // Postconditions:
743 
744  ensure(state_is_read_accessible());
745  ensure(access_request_depth() == old_access_request_depth + 1);
746  ensure(rep().state_is_read_accessible());
747  ensure(base_space().state_is_read_accessible());
748  ensure(fiber_space().state_is_read_accessible());
749  ensure(fiber_schema().state_is_read_accessible());
750 
751  // Exit
752 
753  return;
754 }
755 
756 void
758 get_read_write_access(bool xrelease_read_only_access)
759 {
760  // Preconditions:
761 
762  require(is_attached());
763  require(!xrelease_read_only_access ? state_is_not_read_only_accessible() : true);
764 
765 
766  // Body:
767 
768  int old_access_request_depth = access_request_depth();
769 
770  rep().get_read_access();
771  base_space().get_read_access();
772  fiber_space().get_read_access();
773  poset::get_read_write_access(xrelease_read_only_access);
774 
775  // Postconditions:
776 
777  ensure(state_is_read_write_accessible());
778  ensure(access_request_depth() == old_access_request_depth + 1);
779  ensure(rep().state_is_read_accessible());
780  ensure(base_space().state_is_read_accessible());
781  ensure(fiber_space().state_is_read_accessible());
782  ensure(fiber_schema().state_is_read_accessible());
783 
784  // Exit
785 
786  return;
787 }
788 
789 void
791 release_access(bool xall) const
792 {
793  // Preconditions:
794 
795  require(state_is_read_accessible());
796 
797  // Body:
798 
799  int old_access_request_depth = access_request_depth();
800 
801  // Release at least one level of access for this. If xall, release all levels
802  // of access for this. Since each level of access to this also
803  // acquired a level of access to the rep, the base space, and the fiber space,
804  // release the same number of levels of access to each of these.
805  // Note that this may not be all the levels of access of these.
806 
807  do
808  {
809  // Release one level of access.
810 
811  rep().release_access(false);
812  base_space().release_access(false);
813  fiber_space().release_access(false);
814  poset::release_access(false);
815  }
816  while(xall && state_is_read_accessible());
817 
818  // Postconditions:
819 
820  ensure(!xall ? access_request_depth() == old_access_request_depth - 1 :
821  access_request_depth() == 0);
822  ensure(access_request_depth() == 0 ? state_is_not_read_accessible() : true);
823  ensure(unexecutable("schema, rep, base, base schema, fiber, and fiber schema access released"));
824 
825  // Exit
826 
827  return;
828 }
829 
830 // PROTECTED FUNCTIONS
831 
832 void
835 {
836  // Preconditions:
837 
838  require(state_is_read_accessible());
839 
840  // Body:
841 
842  // Attach the handle data members that depend on the table dofs
843  // and are required to get access.
844 
845  table_dofs_type& ldofs = sheaf::table_dofs(*this);
846 
847  // Attach the rep handle to the current state.
848 
852 
853  poset_path lrep_path(ldofs.rep_path);
854  rep().attach_to_state(&xns, lrep_path, true);
855 
856  // Attach the component handles to the current state.
857 
858  poset_path lbase_space_path(ldofs.base_space_path);
859  _base_space = xns.member_poset<base_space_poset>(lbase_space_path, true);
860 
861  poset_path lfiber_space_path(ldofs.fiber_space_path);
862  _fiber_space = xns.member_poset<poset>(lfiber_space_path, true);
863 
864  // Attach the subposet handles to the current state.
865 
866  base_space().get_read_access();
867  rep().get_read_access();
868  discretization().attach_to_state(&(base_space()), rep().discretization_subposet_name());
869  evaluation().attach_to_state(&(base_space()), rep().evaluation_subposet_name());
870 
871  // Postconditions:
872 
873  ensure(rep().is_attached());
874  ensure(base_space().is_attached());
875  ensure(fiber_space().is_attached());
876  ensure(discretization().is_attached());
877  ensure(evaluation().is_attached());
878 
879  rep().release_access();
880  base_space().release_access();
881 
882  // Postconditions:
883 
884 
885  // Exit
886 
887  return;
888 }
889 
890 void
893 {
894  // Preconditions:
895 
896  require(state_is_read_accessible());
897 
898  // Body:
899 
900  poset::attach_handle_data_members();
901 
902  table_dofs_type& ldofs = sheaf::table_dofs(*this);
903  namespace_poset* lns = name_space();
904 
905  // Attach the rep handle to the current state.
906 
910 
911  rep().attach_to_state(lns, ldofs.rep_path, true);
912 
913  // Attach the component handles to the current state.
914 
915  poset_path lbase_space_path(ldofs.base_space_path);
916  _base_space = lns->member_poset<base_space_poset>(lbase_space_path, true);
917 
918  poset_path lfiber_space_path(ldofs.fiber_space_path);
919  _fiber_space = lns->member_poset<poset>(lfiber_space_path, true);
920 
921  // Attach the subposet handles to the current state.
922 
923  discretization().attach_to_state(&(base_space()), rep().discretization_subposet_name());
924  evaluation().attach_to_state(&(base_space()), rep().evaluation_subposet_name());
925 
926  // Postconditions:
927 
928  ensure(rep().is_attached());
929  ensure(base_space().is_attached());
930  // ensure(fiber_schema().is_attached());
931  ensure(fiber_space().is_attached());
932  ensure(discretization().is_attached());
933  ensure(evaluation().is_attached());
934 
935 
936  // Exit
937 
938  return;
939 }
940 
941 void
944 {
945  // Preconditions:
946 
947  require(state_is_read_write_accessible());
948 
949  // Body:
950 
951  define_old_variable(int old_rep_access_request_depth = rep().access_request_depth());
952  define_old_variable(int old_base_space_access_request_depth = base_space().access_request_depth());
953  define_old_variable(int old_fiber_space_access_request_depth = fiber_space().access_request_depth());
954 
955  // Release all levels of access this poset has to its various parts,
956  // but do not release access to the state of this because
957  // we are going to delete the state and don't want another
958  // client able to sneak in and get access before we do.
959 
963 
964  string rep_name(rep().name());
965  string base_space_name(base_space().name());
966  string fiber_space_name(fiber_space().name());
967 
968 #ifdef DIAGNOSTIC_OUTPUT
969  cout << "poset: " << name() << endl
970  << "\trep: " << rep_name
971  << " old lvl:" << old_rep_access_request_depth << endl
972  << "\tbase_space: " << base_space_name
973  << " old lvl:" << old_base_space_access_request_depth << endl
974  << "\tfiber_space: " << fiber_space_name
975  << " old lvl:" << old_fiber_space_access_request_depth << endl;
976 #endif
977 
978  int old_access_request_depth = access_request_depth();
979  for(size_type i=0; i<old_access_request_depth; ++i)
980  {
981  rep().release_access(false);
982  base_space().release_access(false);
983  fiber_space().release_access(false);
984  }
985 
986  define_old_variable(int rep_access_request_depth = rep().access_request_depth());
987  define_old_variable(int base_space_access_request_depth = base_space().access_request_depth());
988  define_old_variable(int fiber_space_access_request_depth = fiber_space().access_request_depth());
989 
990 #ifdef DIAGNOSTIC_OUTPUT
991  cout << " \trep lvl:" << rep_access_request_depth
992  << " base_space lvl:" << base_space_access_request_depth
993  << " fiber_space lvl:" << fiber_space_access_request_depth
994  << endl;
995 #endif
996 
997  // Detach and delete the state.
998 
999  poset::terminate_access();
1000 
1001  // Postconditions:
1002 
1003  ensure(!is_attached());
1004  ensure(unexecutable("state has been deleted"));
1005  ensure(rep_access_request_depth == (old_rep_access_request_depth - old_access_request_depth));
1006  ensure(base_space_access_request_depth == (old_base_space_access_request_depth - old_access_request_depth));
1007  ensure(fiber_space_access_request_depth == (old_fiber_space_access_request_depth - old_access_request_depth));
1008 
1009  // Exit
1010 
1011  return;
1012 }
1013 
1014 // PRIVATE FUNCTIONS
1015 
1016 
1017 // ===========================================================
1018 // SCHEMA FACET
1019 // ===========================================================
1020 
1021 // PUBLIC FUNCTIONS
1022 
1023 // PROTECTED FUNCTIONS
1024 
1025 // PRIVATE FUNCTIONS
1026 
1027 
1028 // ===========================================================
1029 // SCHEMATIZATION FACET
1030 // ===========================================================
1031 
1032 // PUBLIC FUNCTIONS
1033 
1034 // PROTECTED FUNCTIONS
1035 
1036 // PRIVATE FUNCTIONS
1037 
1038 
1039 // ===========================================================
1040 // MEMBERSHIP FACET
1041 // ===========================================================
1042 
1043 // PUBLIC FUNCTIONS
1044 
1047 new_member(bool xis_jim, const scoped_index& xdof_tuple_id)
1048 {
1049  // Preconditions:
1050 
1051  require(precondition_of(poset_state_handle::new_member(xis_jim, xdof_tuple_id)));
1052  require(is_new_member_available());
1053 
1054  // Body:
1055 
1056  pod_index_type result =
1057  poset_state_handle::new_member(xis_jim, xdof_tuple_id);
1058 
1059  // Postconditions:
1060 
1061  ensure(postcondition_of(poset_state_handle::new_member(xis_jim, xdof_tuple_id)));
1062 
1063  // Exit:
1064 
1065  return result;
1066 }
1067 
1070 new_member(bool xis_jim, poset_dof_map* xdof_map, bool xcopy_dof_map)
1071 {
1072  // Preconditions:
1073 
1074  require(precondition_of(poset_state_handle::new_member(xis_jim, xdof_map, xcopy_dof_map)));
1075  require(is_new_member_available());
1076 
1077  // Body:
1078 
1079  pod_index_type result =
1080  poset_state_handle::new_member(xis_jim, xdof_map, xcopy_dof_map);
1081 
1082  // Postconditions:
1083 
1084  ensure(postcondition_of(poset_state_handle::new_member(xis_jim, xdof_map, xcopy_dof_map)));
1085 
1086  // Exit:
1087 
1088  return result;
1089 }
1090 
1093 new_member_range(const std::string& xrange_type,
1094  size_type xsize,
1095  const block<scoped_index>& xdof_tuple_ids,
1096  const block<pod_index_type>& xdata)
1097 {
1099 
1100  not_implemented();
1101 }
1102 
1105 top()
1106 {
1107  // Preconditions:
1108 
1109  // Body:
1110 
1111  // Postconditions:
1112 
1113  // Exit
1114 
1115  return *(static_cast<section_space_schema_member*>(_top));
1116 }
1117 
1120 top() const
1121 {
1122  // Preconditions:
1123 
1124  // Body:
1125 
1126  // Postconditions:
1127 
1128  // Exit
1129 
1130  return *(static_cast<const section_space_schema_member*>(_top));
1131 }
1132 
1135 bottom()
1136 {
1137  // Preconditions:
1138 
1139  // Body:
1140 
1141  // Postconditions:
1142 
1143  // Exit
1144 
1145  return *(static_cast<section_space_schema_member*>(_bottom));
1146 }
1147 
1150 bottom() const
1151 {
1152  // Preconditions:
1153 
1154  // Body:
1155 
1156  // Postconditions:
1157 
1158  // Exit
1159 
1160  return *(static_cast<const section_space_schema_member*>(_bottom));
1161 }
1162 
1165 member_id(const std::string& xbase_space_name, const std::string& xfiber_schema_name) const
1166 {
1167  // Preconditions:
1168 
1169  require(state_is_read_accessible());
1170  require(base_space().contains_member(xbase_space_name, false));
1171  require(fiber_schema().contains_member(xfiber_schema_name, false));
1172 
1173  // Body:
1174 
1175  pod_index_type lbase_space_id =
1176  base_space().member_id(xbase_space_name, false);
1177  pod_index_type lfiber_schema_id =
1178  fiber_schema().member_id(xfiber_schema_name, false);
1179 
1180  pod_index_type result;
1181  ordinal(lbase_space_id, lfiber_schema_id, result);
1182 
1183  // Postconditions:
1184 
1185  ensure(contains_member(result, false));
1186 
1187  // Exit:
1188 
1189  return result;
1190 }
1191 
1192 void
1194 member_id(const std::string& xbase_space_name,
1195  const std::string& xfiber_schema_name,
1196  scoped_index& result) const
1197 {
1198  // Postconditions:
1199 
1200  require(state_is_read_accessible());
1201  require(base_space().contains_member(xbase_space_name, false));
1202  require(fiber_schema().contains_member(xfiber_schema_name, false));
1203 
1204  // Body:
1205 
1206  result.put(member_hub_id_space(false),
1207  member_id(xbase_space_name, xfiber_schema_name));
1208 
1209  // Postconditions:
1210 
1211  ensure(contains_member(result, false));
1212 
1213  // Exit:
1214 
1215  return;
1216 }
1217 
1218 bool
1221 {
1222  // Preconditions:
1223 
1224  require(state_is_read_accessible());
1225 
1226  // Body:
1227 
1228  bool result =
1229  member_hub_id_space(false).is_empty() || // For the construction of bottom
1230  !member_id_spaces(false).is_reserved_term_full(); // Can't expand past the first reserved term
1231 
1232  // Postconditions:
1233 
1234  ensure(is_basic_query);
1235 
1236  // Exit:
1237 
1238  return result;
1239 }
1240 
1241 // PROTECTED FUNCTIONS
1242 
1243 // PRIVATE FUNCTIONS
1244 
1245 
1246 // ===========================================================
1247 // COVER RELATION FACET
1248 // ===========================================================
1249 
1250 // PUBLIC FUNCTIONS
1251 
1252 // PROTECTED FUNCTIONS
1253 
1254 // PRIVATE FUNCTIONS
1255 
1256 
1257 // ===========================================================
1258 // POWERSET FACET
1259 // ===========================================================
1260 
1261 // PUBLIC FUNCTIONS
1262 
1264 // $$SCRIBBLE: Remove version hack.
1265 
1266 // int
1267 // fiber_bundle::section_space_schema_poset::
1268 // version_ct() const
1269 // {
1270 // int result = 0;
1271 
1272 // // Preconditions:
1273 
1274 // require(state_is_read_accessible());
1275 // require(base_space().state_is_read_accessible());
1276 
1277 // // Body:
1278 
1279 // result = base_space().version_ct();
1280 
1281 // ensure(result >= 0);
1282 
1283 // // Exit
1284 
1285 // return result;
1286 // }
1287 
1288 // int
1289 // fiber_bundle::section_space_schema_poset::
1290 // version() const
1291 // {
1292 // int result = 0;
1293 
1294 // // Preconditions:
1295 
1296 // require(state_is_read_accessible());
1297 // require(base_space().state_is_read_accessible());
1298 
1299 // // Body:
1300 
1301 // /// @hack section_space_schema version hack:
1302 // /// version of this is same as version of base space.
1303 
1304 // result = base_space().version();
1305 
1306 // // Postconditions:
1307 
1308 // ensure( has_version(result) );
1309 
1310 // // Exit
1311 
1312 // return result;
1313 // }
1314 
1315 // sheaf::pod_index_type
1316 // fiber_bundle::section_space_schema_poset::
1317 // version_index(int xversion) const
1318 // {
1319 // // Preconditions:
1320 
1321 // require(state_is_read_accessible());
1322 // require(base_space().state_is_read_accessible());
1323 // require(has_version(xversion));
1324 
1325 // // Body:
1326 
1327 // pod_index_type result = base_space().version_index(xversion);
1328 
1329 // // Postconditions:
1330 
1331 // ensure(base_space().includes_subposet(result));
1332 
1333 // // Exit
1334 
1335 // return result;
1336 // }
1337 
1338 // sheaf::pod_index_type
1339 // fiber_bundle::section_space_schema_poset::
1340 // version_jims_index(int xversion) const
1341 // {
1342 // // Preconditions:
1343 
1344 // require(state_is_read_accessible());
1345 // require(base_space().state_is_read_accessible());
1346 // require(has_version(xversion));
1347 
1348 // // Body:
1349 
1350 // pod_index_type result = base_space().version_jims_index(xversion);
1351 
1352 // // Postconditions:
1353 
1354 // ensure(base_space().includes_subposet(result));
1355 
1356 // // Exit
1357 
1358 // return result;
1359 // }
1360 
1361 // PROTECTED FUNCTIONS
1362 
1363 // PRIVATE FUNCTIONS
1364 
1365 
1366 // ===========================================================
1367 // I/O SUPPORT FACET
1368 // ===========================================================
1369 
1370 // PUBLIC FUNCTIONS
1371 
1374 get_decomposition(pod_index_type xindex) const
1375 {
1378 
1379  // Preconditions:
1380 
1381  require(state_is_read_accessible());
1382 
1383  // It is precisely because we can't support product subposets
1384  // that we can't require the following here.
1385 
1386  // require(includes_subposet(xindex));
1387 
1388  // Body:
1389 
1390  // This routine should only be called for writing or reading row decompositions,
1391  // which is not supported for section_space_schema_posets.
1392 
1393  post_fatal_error_message("Product subposet hack, ver 2. Row decomposition i/o not supported for section space schema.");
1394 
1395  // Postconditions:
1396 
1397  // Exit:
1398 
1399  return 0;
1400 }
1401 
1404 prereq_id(int xi) const
1405 {
1406  pod_index_type result;
1407 
1408  // Preconditions:
1409 
1410  // Body:
1411 
1412  switch(xi)
1413  {
1414  case 0: // schema
1415  result = schema().host()->index().pod();
1416  break;
1417  case 1: // rep
1418  result = _rep.host()->index().pod();
1419  break;
1420  case 2: // fiber space
1421  result = _fiber_space->index().pod();
1422  break;
1423  case 3: // base
1424  result = _base_space->index().pod();
1425  break;
1426  default:
1427  result = invalid_pod_index();
1428  break;
1429  }
1430 
1431  // Postconditions:
1432 
1433  // Exit:
1434 
1435  return result;
1436 }
1437 
1438 // PROTECTED FUNCTIONS
1439 
1440 // PRIVATE FUNCTIONS
1441 
1442 
1443 // ===========================================================
1444 // ANY FACET
1445 // ===========================================================
1446 
1447 // PUBLIC FUNCTIONS
1448 
1449 bool
1451 is_ancestor_of(const any* xother) const
1452 {
1453  bool result;
1454 
1455  // Preconditions:
1456 
1457  // Body:
1458 
1459  result = dynamic_cast<const section_space_schema_poset*>(xother) != 0;
1460 
1461  // Postconditions:
1462 
1463  // Exit
1464 
1465  return result;
1466 }
1467 
1468 bool
1470 invariant() const
1471 {
1472  bool result = true;
1473 
1474  invariance(poset::invariant());
1475 
1476  if(invariant_check())
1477  {
1478  disable_invariant_check();
1479 
1480  invariance(state_is_read_accessible() ? rep().state_is_read_accessible() : true);
1481 
1482  invariance(state_is_read_accessible() ? base_space().state_is_read_accessible() : true);
1483 
1484  invariance(state_is_read_accessible() ? fiber_space().state_is_read_accessible() : true);
1485 
1487 
1488  invariance(unexecutable("rep.evaluator_family_name is compatible with base_space"));
1489 
1492 
1493  enable_invariant_check();
1494  }
1495 
1496  return result;
1497 }
1498 
1499 // PROTECTED FUNCTIONS
1500 
1503 operator=(const poset_state_handle& xother)
1504 {
1505  // Preconditions:
1506 
1507  require(is_ancestor_of(&xother));
1508 
1509  // Body:
1510 
1511  poset::operator=(xother);
1512 
1513  // Postconditions:
1514 
1515  ensure(is_same_state(&xother));
1516 
1517  // Exit:
1518 
1519  return *this;
1520 }
1521 
1522 // PRIVATE FUNCTIONS
1523 
1524 
1525 // ===========================================================
1526 // EXPLICIT INSTANTIATIONS FOR CLASS SECTION_SPACE_SCHEMA_POSET
1527 // ===========================================================
1528 
1529 #ifndef DOXYGEN_SKIP_INSTANTIATIONS
1530 
1531 template
1532 SHEAF_DLL_SPEC
1534 sheaf::namespace_poset::
1535 member_poset<fiber_bundle::section_space_schema_poset>(const poset_path& xpath, bool xauto_access) const;
1536 
1537 template
1538 SHEAF_DLL_SPEC
1539 bool
1540 sheaf::namespace_poset::
1541 contains_poset<fiber_bundle::section_space_schema_poset>(const poset_path& xpath, bool xauto_access) const;
1542 
1543 template
1544 SHEAF_DLL_SPEC
1545 bool
1546 sheaf::namespace_poset::
1547 contains_path<fiber_bundle::section_space_schema_poset>(const poset_path& xpath, bool xauto_access) const;
1548 
1549 template
1550 SHEAF_DLL_SPEC
1551 bool
1552 sheaf::namespace_poset::
1553 path_is_auto_read_accessible<fiber_bundle::section_space_schema_poset>(const poset_path& xpath, bool xauto_access) const;
1554 
1555 template
1556 SHEAF_DLL_SPEC
1557 bool
1558 sheaf::namespace_poset::
1559 path_is_auto_read_available<fiber_bundle::section_space_schema_poset>(const poset_path& xpath, bool xauto_access) const;
1560 
1561 #endif // ifndef DOXYGEN_SKIP_INSTANTIATIONS
A client handle for a subposet.
Definition: subposet.h:86
virtual void terminate_access()
Release all access to posets this depends on, then detach and delete the state.
virtual void attach_handle_data_members()
Initializes the handle data members when this handle is attached to a state.
static bool rep_is_valid(const sec_rep_descriptor &xrep, const poset_state_handle &xbase_space)
True if the discretization and evaluation subposets named in xrep are included in xbase_space and the...
int df() const
The dimension of the fiber space.
void initialize_table_dof_subposet()
Create the table dof members with the same ids as the table dofs in the fiber schema id space and ini...
bool full() const
True if both poset name and member name are not empty.
Definition: poset_path.cc:311
virtual pod_index_type new_member(bool xis_jim, pod_index_type xdof_tuple_id)
Create a disconnected member with is_jim == xis_jim. Redefined here only to trap attempts to make a n...
virtual index_iterator * get_decomposition(pod_index_type xindex) const
An iterator over the members of the decomposition identified by xindex.
An abstract iterator over the ids of an id space.
virtual const char * class_name() const
The name of this class.
virtual bool has_id_space() const
True if this already has an id space.
Definition: subposet.cc:622
static const poset_path & standard_schema_path()
The path to the standard schema for this class.
The default name space; a poset which contains other posets as members.
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
std::string discretization_subposet_name() const
The name of the discretization subposet.
poset_type
Identifiers for poset types.
Definition: poset_type.h:41
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...
pod_index_type ordinal(pod_index_type xi, pod_index_type xj, size_type xj_ub)
2-tuple to ordinal conversion.
bool contains_poset_member(pod_index_type xposet_hub_id, pod_index_type xmember_hub_id, bool xauto_access=true) const
True if this contains a poset with hub id xposet_hub_id which contains a member with hub id xmember_h...
bool state_is_auto_read_accessible(bool xauto_access) const
True if the state is auto accessible for read, that is, if the state is already accessible for read o...
A client handle for a general, abstract partially order set.
virtual bool includes_subposet(pod_index_type xsubposet_hub_id, bool xauto_access=true) const
True if this poset includes subposet with hub id xsubposet_hub_id.
bool contains_range_member(const scoped_index &xbase_space_id, const scoped_index &xfiber_schema_id, bool xauto_access) const
True if this poset contains a member with base space id xbase_space_id and fiber schema id xfiber_sch...
static const std::string & standard_schema_poset_name()
The name of the standard schema poset for this class.
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
section_space_schema_member & top()
The top of member of the lattice (mutable version)
subposet & discretization()
The discretization subposet for section spaces on this schema.
virtual void get_read_access() const
Get read access to the state associated with this.
STL namespace.
int db() const
The dimension of the base space.
virtual void get_read_access() const
Get read access to the state associated with this.
poset_state_handle & member_poset(pod_index_type xhub_id, bool xauto_access=true) const
The poset_state_handle object referred to by hub id xhub_id.
pod_index_type member_id(const std::string &xbase_space_name, const std::string &xfiber_schema_name) const
The member id for base space member with name xbase_space_namd, and fiber schema member with name xfi...
virtual void next()=0
Makes id() the next id in the iteration.
The general, abstract map from dof ids to dof values.
Definition: poset_dof_map.h:59
subposet & evaluation()
The evaluation subposet for section spaces on this schema.
virtual bool invariant() const
Class invariant.
Table dofs type for class section_space_schema_poset.
Abstract base class with useful features for all objects.
Definition: any.h:39
section_space_schema_poset()
Default constructor; disabled.
poset & fiber_space()
The fiber space for section spaces on this schema.
The lattice of closed cells of a cellular space; a lattice representation of a computational mesh...
A whitespace separated list of arguments. Insertion operaters are used to insert arguments into the l...
Definition: arg_list.h:63
bool is_done() const
True if iteration is finished.
A client handle for a mutable partially ordered set.
Definition: poset.h:40
bool state_is_read_write_accessible() const
True if this is attached and if the state is accessible for read and write or access control is disab...
primitive_value & value(int xi)
The value of the xi-th argument.
Definition: arg_list.cc:267
virtual void detach_from_state()
Detach this handle from its state, if any.
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
static void make_standard_schema(namespace_poset &xns)
Creates the standard schema for this class in namespace xns.
virtual pod_index_type prereq_id(int xi) const
The id of the xi-th prerequisite poset for this.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
std::string poset_name() const
The poset name part of the path.
Definition: poset_path.cc:473
sec_rep_descriptor & rep()
The representation for section spaces on this schema.
virtual void initialize_handle_data_members(const namespace_poset &xns)
Initializes the handle data members that depend on the table dofs and are required to get access when...
std::string evaluator_family_name() const
The name of the evaluator family for section spaces on this schema.
void put(const index_space_handle &xid_space, pod_type xpod)
Set the scope to id space, xid_space and pod() to xpod.
Definition: scoped_index.h:332
void attach_to_state(const poset_state_handle *xother)
Attach this handle to the same state as xother.
bool contains_poset(pod_index_type xhub_id, bool xauto_access=true) const
True if this contains a poset with hub id xhub_id..
bool is_homogeneous(const scoped_index &xindex) const
True if xindex is in the homogeneous member id space.
Iterates over the subset of Zn defined by the characteristic function host().
virtual pod_index_type new_member_range(const std::string &xrange_type, size_type xsize, const block< scoped_index > &xdof_tuple_ids, const block< pod_index_type > &xdata)
Create a disconnected member range of type xrange_type with size xsize, dof tuple ids xdof_tuple_ids...
bool conforms_to(const namespace_poset &xns, const poset_path &xschema_path, bool xuse_table_schema, bool xauto_access) const
True if the values in this conform to the table schema (xuse_table_schema true) or row schema (xuse_t...
Definition: arg_list.cc:529
section_space_schema_poset & operator=(const poset_state_handle &xother)
Assignment operator; disabled.
section_space_schema_member & bottom()
The bottom of member of the lattice (mutable version)
An abstract schema poset for a section space. A Cartesian product subspace of the tensor product of a...
virtual poset_type type_id() const
Identifier for the type of this poset.
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...
poset_state_handle & fiber_schema()
The fiber schema for section spaces on this schema (mutable version).
void ordinal(const scoped_index &xbase_space_id, const scoped_index &xfiber_schema_id, scoped_index &xindex) const
The ordinal conversion from base space id xbase_space_id and fiber schema id xfiber_schema_id to sect...
T::table_dofs_type & table_dofs(T &x0)
The table dofs pod type for x0 (mutable version).
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
bool is_new_member_available() const
True if and only if a member can be created.
std::string evaluation_subposet_name() const
The name of the evaluation subposet.
A client handle for a poset member which has been prepared for use as a schema for a section space...
virtual bool is_ancestor_of(const any *other) const
True if other conforms to this.
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 get_read_access() const
Get read access to the state associated with this.
void tuple(const scoped_index &xindex, scoped_index &xbase_space_id, scoped_index &xfiber_schema_id) const
The tuple conversion from section space schema id xindex to the base space id xbase_space_id and fibe...
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 update_hub_id_space(bool xauto_access)
Extends the hub id space to match extension of the base space.
A client handle for a poset member which has been prepared for use as a schema.
pod_type hub_pod() const
The current unglued hub id in the iteration. synonym for unglued_hub_pod().
base_space_poset & base_space()
The base space for section spaces on this schema.
A description for a section representation scheme.
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.
Definition: scoped_index.h:710