SheafSystem  0.0.0.0
sec_tp.cc
Go to the documentation of this file.
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
20 
21 #include "SheafSystem/sec_tp.h"
22 
23 #include "SheafSystem/assert_contract.h"
24 #include "SheafSystem/binary_section_space_schema_member.impl.h"
25 #include "SheafSystem/binary_section_space_schema_poset.h"
26 #include "SheafSystem/fiber_bundles_namespace.h"
27 #include "SheafSystem/section_space_schema_member.impl.h"
28 #include "SheafSystem/section_space_schema_poset.h"
29 #include "SheafSystem/sec_at1.h"
30 #include "SheafSystem/sec_at1_space.h"
31 #include "SheafSystem/sec_tuple_space.impl.h"
32 #include "SheafSystem/tp.h"
33 #include "SheafSystem/tp_space.h"
34 
35 
36 using namespace std;
37 using namespace fiber_bundle; // Workaround for MS C++ bug.
38 
39 //==============================================================================
40 // CLASS SEC_TP
41 //==============================================================================
42 // ===========================================================
43 // HOST FACTORY FACET
44 // ===========================================================
45 
46 // PUBLIC MEMBER FUNCTIONS
47 
51  const poset_path& xhost_path,
52  const poset_path& xschema_path,
53  const poset_path& xvector_space_path,
54  bool xauto_access)
55 {
56  // cout << endl << "Entering sec_tp::new_host." << endl;
57 
58  // Preconditions:
59 
60  require(xns.state_is_auto_read_write_accessible(xauto_access));
61 
62  require(!xhost_path.empty());
63  require(!xns.contains_path(xhost_path, xauto_access));
64 
65  require(xschema_path.full());
66  require(xns.path_is_auto_read_accessible<schema_type::host_type>(xschema_path, xauto_access));
67  require(host_type::fiber_space_conforms<fiber_type::host_type>(xns, xschema_path, xauto_access));
68 
69  require(xns.path_is_auto_read_accessible<vector_space_type::host_type>(xvector_space_path, xauto_access));
70 
71  require(host_type::same_vector_fiber_space(xns, xschema_path, xvector_space_path, xauto_access));
72 
73  // Body:
74 
75  host_type& result = host_type::new_table(xns, xhost_path, xschema_path, xvector_space_path, xauto_access);
76 
77  // Postconditions:
78 
79  ensure(xns.owns(result, xauto_access));
80  ensure(result.path(true) == xhost_path);
81  ensure(result.state_is_not_read_accessible());
82  ensure(result.schema(true).path(xauto_access) == xschema_path);
83 
84  ensure(result.factor_ct(true) == result.schema(true).fiber_space<fiber_type::host_type>().factor_ct(xauto_access));
85  ensure(result.d(true) == result.schema(true).fiber_space<fiber_type::host_type>().d(xauto_access));
86  ensure(result.scalar_space_path(true) ==
87  xns.member_poset<vector_space_type::host_type>(xvector_space_path, xauto_access).scalar_space_path(xauto_access));
88  ensure(result.p(true) == result.schema(true).fiber_space<fiber_type::host_type>().p(xauto_access));
89  ensure(result.dd(true) == result.schema(true).fiber_space<fiber_type::host_type>().dd(xauto_access));
90  ensure(result.vector_space_path(true) == xvector_space_path);
91 
92  // Exit:
93 
94  // cout << "Leaving sec_tp::new_host." << endl;
95  return result;
96 }
97 
98 // PROTECTED MEMBER FUNCTIONS
99 
100 // PRIVATE MEMBER FUNCTIONS
101 
102 
103 //==============================================================================
104 // TP FACET OF CLASS SEC_TP
105 //==============================================================================
106 
107 // PUBLIC MEMBER FUNCTIONS
108 
111 {
112  // Preconditions:
113 
114  // Body:
115 
116  // Postconditions:
117 
118  // Exit:
119 }
120 
122 sec_tp(const sec_rep_space* xhost, pod_index_type xhub_id)
123 {
124  // Preconditions:
125 
126  require(xhost != 0);
127  require(xhost->state_is_read_accessible());
128  require(xhost->contains_member(xhub_id));
129 
130  // Body:
131 
132  attach_to_state(xhost, xhub_id);
133 
134  // Postconditions:
135 
136  ensure(invariant());
137  ensure(host() == xhost);
138  ensure(index() == xhub_id);
139  ensure(is_attached());
140  ensure(!is_restricted());
141 }
142 
144 sec_tp(const sec_rep_space* xhost, const scoped_index& xid)
145 {
146  // Preconditions:
147 
148  require(xhost != 0);
149  require(xhost->state_is_read_accessible());
150  require(xhost->contains_member(xid));
151 
152  // Body:
153 
154  attach_to_state(xhost, xid.hub_pod());
155 
156  // Postconditions:
157 
158  ensure(invariant());
159  ensure(host() == xhost);
160  ensure(index() ==~ xid);
161  ensure(is_attached());
162  ensure(!is_restricted());
163 }
164 
166 sec_tp(const sec_rep_space* xhost, const std::string& xname)
167 {
168  // Preconditions:
169 
170  require(xhost != 0);
171  require(xhost->state_is_read_accessible());
172  require(!xname.empty());
173  require(xhost->contains_member(xname));
174 
175  // Body:
176 
177  attach_to_state(xhost, xname);
178 
179  // Postconditions:
180 
181  ensure(invariant());
182  ensure(host() == xhost);
183  ensure(name() == xname);
184  ensure(is_attached());
185  ensure(!is_restricted());
186 
187 }
188 
190 sec_tp(const namespace_poset* xnamespace,
191  const poset_path& xpath,
192  bool xauto_access)
193 {
194  // Preconditions:
195 
196  require(precondition_of(attach_to_state(same args)));
197 
198  // Body:
199 
200  attach_to_state(xnamespace, xpath, xauto_access);
201 
202  // Postconditions:
203 
204  ensure(postcondition_of(attach_to_state(same args)));
205 
206  // Exit:
207 
208  return;
209 }
210 
213 {
214  // Preconditions:
215 
216  require(xother != 0);
217 
218  // Body:
219 
220  attach_to_state(xother);
221 
222  // Postconditions:
223 
224  ensure(invariant());
225  ensure(is_attached());
226  ensure(is_same_state(xother));
227  ensure(is_same_restriction(xother));
228 
229 }
230 
232 sec_tp(sec_rep_space* xhost, section_dof_map* xdof_map, bool xauto_access)
233 {
234 
235  // Preconditions:
236 
237  require(precondition_of(new_jim_state(xhost, xdof_map, false, xauto_access)));
238 
239  // Body:
240 
241  new_jim_state(xhost, xdof_map, false, xauto_access);
242 
243  // Postconditions:
244 
245  ensure(postcondition_of(new_jim_state(xhost, xdof_map, false, xauto_access)));
246 
247  // Exit:
248 
249  return;
250 }
251 
254  abstract_poset_member& xbase_mbr,
255  int xbase_version, bool xauto_access)
256 {
257  // Preconditions:
258 
259  require(precondition_of(new_jim_state(xhost, xbase_mbr, xbase_version, xauto_access)));
260 
261  // Body:
262 
263  new_jim_state(xhost, xbase_mbr, xbase_version, xauto_access);
264 
265  // Postconditions:
266 
267  ensure(postcondition_of(new_jim_state(xhost, xbase_mbr, xbase_version, xauto_access)));
268 
269  // Exit:
270 
271  return;
272 }
273 
277 {
278  // Preconditions:
279 
280  require(is_ancestor_of(&xother));
281  require(precondition_of(attach_to_state(&xother)));
282 
283  // Body:
284 
285  attach_to_state(&xother);
286 
287  // Postconditions:
288 
289  ensure(postcondition_of(attach_to_state(&xother)));
290 
291  // Exit:
292 
293  return *this;
294 }
295 
298 operator=(const sec_tp& xother)
299 {
300  // Preconditions:
301 
302  require(precondition_of(attach_to_state(&xother)));
303 
304  // Body:
305 
306  attach_to_state(&xother);
307 
308  // Postconditions:
309 
310  ensure(postcondition_of(attach_to_state(&xother)));
311 
312  // Exit:
313 
314  return *this;
315 }
316 
319 operator=(const tp& xfiber)
320 {
321  // Preconditions:
322 
323  require(precondition_of(sec_vd::operator=(xfiber)));
324 
325  // Body:
326 
327  sec_vd::operator=(xfiber);
328 
329  // Postconditions:
330 
331  ensure(postcondition_of(sec_vd::operator=(xfiber)));
332 
333  // Exit:
334 
335  return *this;
336 }
337 
340 operator=(const tp_lite& xfiber)
341 {
342  // Preconditions:
343 
344  require(precondition_of(sec_vd::operator=(xfiber)));
345 
346  // Body:
347 
348  sec_vd::operator=(xfiber);
349 
350  // Postconditions:
351 
352  ensure(postcondition_of(sec_vd::operator=(xfiber)));
353 
354  // Exit:
355 
356  return *this;
357 }
358 
361 {
362  // Preconditions:
363 
364  // Body:
365 
366  // Postconditions:
367 
368  // Exit:
369 
370 }
371 
375 {
376  // Preconditions:
377 
378  // Body:
379 
380  static const fiber_type result;
381 
382  // Postconditions:
383 
384  // Exit:
385 
386  return result;
387 }
388 
389 int
391 p() const
392 {
393  // Preconditions:
394 
395  require(state_is_read_accessible());
396 
397  // Body:
398 
399  int result = host()->p();
400 
401  // Postconditions:
402 
403  ensure(result >= 0);
404 
405  // Exit:
406 
407  return result;
408 }
409 
410 int
412 p(bool xauto_access) const
413 {
414  // Preconditions:
415 
416  require(state_is_auto_read_accessible(xauto_access));
417 
418  // Body:
419 
420  int result = host()->p(xauto_access);
421 
422  // Postconditions:
423 
424  ensure(result >= 0);
425 
426  // Exit:
427 
428  return result;
429 }
430 
431 int
433 dd() const
434 {
435  // Preconditions:
436 
437  require(state_is_read_accessible());
438 
439  // Body:
440 
441  int result = host()->dd();
442 
443  // Postconditions:
444 
445  ensure(result >= 0);
446 
447  // Exit:
448 
449  return result;
450 }
451 
452 int
454 dd(bool xauto_access) const
455 {
456  // Preconditions:
457 
458  require(state_is_auto_read_accessible(xauto_access));
459 
460  // Body:
461 
462  int result = host()->dd(xauto_access);
463 
464  // Postconditions:
465 
466  ensure(result >= 0);
467 
468  // Exit:
469 
470  return result;
471 }
472 
476 {
477  // Preconditions:
478 
479  require(state_is_read_accessible());
480 
481  // Body:
482 
483  poset_path result(host()->vector_space_path());
484 
485  // Postconditions:
486 
487  ensure(!result.empty());
488 
489  // Exit:
490 
491  return result;
492 }
493 
496 vector_space_path(bool xauto_access) const
497 {
498  // Preconditions:
499 
500  require(state_is_auto_read_accessible(xauto_access));
501 
502  // Body:
503 
504  poset_path result(host()->vector_space_path(xauto_access));
505 
506  // Postconditions:
507 
508  ensure(!result.empty());
509 
510  // Exit:
511 
512  return result;
513 }
514 
518 {
519  // Preconditions:
520 
521  require(state_is_read_accessible());
522  require(name_space()->state_is_read_accessible());
523 
524  // Body:
525 
526  poset_state_handle& lpsh = name_space()->member_poset(vector_space_path(), false);
527 
528  sec_tp_space& result = reinterpret_cast<host_type&>(lpsh);
529 
530  // Postconditions:
531 
532  // Exit:
533 
534  return result;
535 
536 }
537 
540 vector_space(bool xauto_access) const
541 {
542  // Preconditions:
543 
544  require(state_is_auto_read_accessible(xauto_access));
545  require(name_space()->state_is_auto_read_accessible(xauto_access));
546 
547  // Body:
548 
549  if(xauto_access)
550  {
551  name_space()->get_read_access();
552  get_read_access();
553  }
554 
555  sec_tp_space& result = vector_space();
556 
557  if(xauto_access)
558  {
559  release_access();
560  name_space()->release_access();
561  }
562 
563  // Postconditions:
564 
565  // Exit:
566 
567  return result;
568 }
569 
570 const std::string
572 create_tensor_space_name(const std::string& xvector_space_name, const std::string& xname)
573 {
574  // Preconditions:
575 
576  // Body:
577 
578  const string result = xvector_space_name + "_" + xname;
579 
580  // Postconditions:
581 
582  // Exit:
583 
584  return result;
585 }
586 
589 variance(bool xauto_access) const
590 {
591  // Preconditions:
592 
593  require(state_is_auto_read_accessible(xauto_access));
594 
595  // Body:
596 
597  tensor_variance result = host()->variance(_index, xauto_access);
598 
599  // Postconditions:
600 
601  // Exit:
602 
603  return result;
604 }
605 
606 bool
608 variance(int xi, bool xauto_access) const
609 {
610  // Preconditions:
611 
612  require(state_is_auto_read_accessible(xauto_access));
613 
614  // Body:
615 
616  bool result = host()->variance(_index, xi, xauto_access);
617 
618  // Postconditions:
619 
620  // Exit:
621 
622  return result;
623 }
624 
625 void
627 put_variance(const tensor_variance& xvariance, bool xauto_access)
628 {
629  // Preconditions:
630 
631  require(state_is_auto_read_write_accessible(xauto_access));
632 
633  // Body:
634 
635  host()->put_variance(_index, xvariance, xauto_access);
636 
637  // Postconditions:
638 
639  // Exit:
640 
641  return;
642 }
643 
644 void
646 put_variance(int xi, bool xvariance, bool xauto_access)
647 {
648  // Preconditions:
649 
650  require(state_is_auto_read_write_accessible(xauto_access));
651  require((0 <= xi) && (xi < p(xauto_access)));
652 
653  // Body:
654 
655  host()->put_variance(_index, xi, xvariance, xauto_access);
656 
657  // Postconditions:
658 
659  // Exit:
660 
661  return;
662 }
663 
664 bool
666 is_covariant(bool xauto_access) const
667 {
668  // Preconditions:
669 
670  require(state_is_auto_read_accessible(xauto_access));
671 
672  // Body:
673 
674  bool result = host()->is_covariant(_index, xauto_access);
675 
676  // Postconditions:
677 
678  // Exit:
679 
680  return result;
681 }
682 
683 bool
685 is_covariant(int xi, bool xauto_access) const
686 {
687  // Preconditions:
688 
689  require(state_is_auto_read_accessible(xauto_access));
690  require((0 <= xi) && (xi < p(xauto_access)));
691 
692  // Body:
693 
694  bool result = host()->is_covariant(_index, xi, xauto_access);
695 
696  // Postconditions:
697 
698  // Exit:
699 
700  return result;
701 }
702 
703 void
705 put_is_covariant(bool xauto_access)
706 {
707  // Preconditions:
708 
709  require(state_is_auto_read_accessible(xauto_access));
710 
711  // Body:
712 
713  host()->put_is_covariant(_index, xauto_access);
714 
715  // Postconditions:
716 
717  ensure(is_covariant(xauto_access));
718 
719  // Exit:
720 
721  return;
722 }
723 
724 void
726 put_is_covariant(int xi, bool xauto_access)
727 {
728  // Preconditions:
729 
730  require(state_is_auto_read_write_accessible(xauto_access));
731  require((0 <= xi) && (xi < p(xauto_access)));
732 
733  // Body:
734 
735  host()->put_is_covariant(_index, xi, xauto_access);
736 
737  // Postconditions:
738 
739  ensure(is_covariant(xi, xauto_access));
740 
741  // Exit:
742 
743  return;
744 }
745 
746 bool
748 is_contravariant(bool xauto_access) const
749 {
750  // Preconditions:
751 
752  require(state_is_auto_read_accessible(xauto_access));
753 
754  // Body:
755 
756  bool result = host()->is_contravariant(_index, xauto_access);
757 
758  // Postconditions:
759 
760  // Can not ensure result == !is_covariant because at0 is both co- and contra-vairant.
761 
762  // Exit:
763 
764  return result;
765 }
766 
767 bool
769 is_contravariant(int xi, bool xauto_access) const
770 {
771  // Preconditions:
772 
773  require(state_is_auto_read_accessible(xauto_access));
774  require((0 <= xi) && (xi < p(xauto_access)));
775 
776  // Body:
777 
778  bool result = host()->is_contravariant(_index, xi, xauto_access);
779 
780  // Postconditions:
781 
782  // Exit:
783 
784  return result;
785 }
786 
787 void
789 put_is_contravariant(bool xauto_access)
790 {
791  // Preconditions:
792 
793  require(state_is_auto_read_accessible(xauto_access));
794 
795  // Body:
796 
797  host()->put_is_contravariant(_index, xauto_access);
798 
799  // Postconditions:
800 
801  ensure(is_contravariant(xauto_access));
802 
803  // Exit:
804 
805  return;
806 }
807 
808 void
810 put_is_contravariant(int xi, bool xauto_access)
811 {
812  // Preconditions:
813 
814  require(state_is_auto_read_write_accessible(xauto_access));
815  require((0 <= xi) && (xi < p(xauto_access)));
816 
817  // Body:
818 
819  host()->put_is_contravariant(_index, xi, xauto_access);
820 
821  // Postconditions:
822 
823  ensure(is_contravariant(xi, xauto_access));
824 
825  // Exit:
826 
827  return;
828 }
829 
830 // PROTECTED MEMBER FUNCTIONS
831 
832 // PRIVATE MEMBER FUNCTIONS
833 
834 
835 //==============================================================================
836 // VD FACET OF CLASS SEC_TP
837 //==============================================================================
838 
839 // PUBLIC MEMBER FUNCTIONS
840 
841 // PROTECTED MEMBER FUNCTIONS
842 
843 // PRIVATE MEMBER FUNCTIONS
844 
845 
846 //==============================================================================
847 // TUPLE FACET OF CLASS SEC_TP
848 //==============================================================================
849 
850 // PUBLIC MEMBER FUNCTIONS
851 
852 // PROTECTED MEMBER FUNCTIONS
853 
854 // PRIVATE MEMBER FUNCTIONS
855 
856 
857 //==============================================================================
858 // ABSTRACT POSET MEMBER FACET OF CLASS SEC_TP
859 //==============================================================================
860 
861 // PUBLIC MEMBER FUNCTIONS
862 
863 const std::string&
865 class_name() const
866 {
867  // Preconditions:
868 
869  // Body:
870 
871  const string& result = static_class_name();
872 
873  // Postconditions:
874 
875  ensure(!result.empty());
876 
877  // Exit:
878 
879  return result;
880 }
881 
882 const std::string&
885 {
886  // Preconditions:
887 
888  // Body:
889 
890  static const string result("sec_tp");
891 
892  // Postconditions:
893 
894  ensure(!result.empty());
895 
896  // Exit:
897 
898  return result;
899 }
900 
903 clone() const
904 {
905  // Preconditions:
906 
907  // Body:
908 
909  sec_tp* result = 0;
910 
911  // Create new handle of the current class.
912 
913  result = new sec_tp();
914 
915  // Postconditions:
916 
917  ensure(result != 0);
918  ensure(result->invariant());
919 
920  // Exit:
921 
922  return result;
923 
924 }
925 
926 // PROTECTED MEMBER FUNCTIONS
927 
928 // PRIVATE MEMBER FUNCTIONS
929 
930 
931 // ===========================================================
932 // POSET_COMPONENT FACET
933 // ===========================================================
934 
935 // PUBLIC MEMBER FUNCTIONS
936 
939 host() const
940 {
941  return reinterpret_cast<host_type*>(_host);
942 }
943 
944 bool
947 {
948  return dynamic_cast<const host_type*>(xother) != 0;
949 }
950 
951 // PROTECTED MEMBER FUNCTIONS
952 
953 // PRIVATE MEMBER FUNCTIONS
954 
955 
956 //==============================================================================
957 // ANY FACET OF CLASS SEC_TP
958 //==============================================================================
959 
960 // PUBLIC MEMBER FUNCTIONS
961 
962 bool
964 fiber_is_ancestor_of(const any* xother) const
965 {
966  // Preconditions:
967 
968  require(xother != 0);
969 
970  // Body:
971 
972  // If xother may be dynamically cast to the type of this fiber then this
973  // fiber is an ancestor of xother.
974 
975  bool result = dynamic_cast<const tp*>(xother) != 0;
976 
977  // Postconditions:
978 
979  ensure(invariant());
980  ensure(xother->invariant());
981 
982  // Exit:
983 
984  return result;
985 
986 }
987 
988 bool
990 is_ancestor_of(const any* xother) const
991 {
992  // Preconditions:
993 
994  require(xother != 0);
995 
996  // Body:
997 
998  // If other may be dynamically cast to the type of this then this is an
999  // ancestor of other.
1000 
1001  bool result = dynamic_cast<const sec_tp*>(xother) != 0;
1002 
1003  // Postconditions:
1004 
1005  //ensure(invariant());
1006 
1007  // Exit:
1008 
1009  return result;
1010 
1011 }
1012 
1013 bool
1015 invariant() const
1016 {
1017  bool result = true;
1018 
1019  // Preconditions:
1020 
1021  // Body:
1022 
1023  // Must satisfy base class invariant.
1024 
1025  invariance(sec_vd::invariant());
1026 
1027  if (invariant_check())
1028  {
1029  // Prevent recursive calls to invariant.
1030 
1031  disable_invariant_check();
1032 
1033  invariance(is_attached() ? (p() >= 0) : true);
1034 
1035  // Finished, turn invariant checking back on.
1036 
1037  enable_invariant_check();
1038  }
1039 
1040  // Postconditions:
1041 
1042  ensure(is_derived_query);
1043 
1044  // Exit:
1045 
1046  return result;
1047 }
1048 
1049 // PROTECTED MEMBER FUNCTIONS
1050 
1051 // PRIVATE MEMBER FUNCTIONS
1052 
1053 
1054 //==============================================================================
1055 // NON-MEMBER FUNCTIONS
1056 //==============================================================================
1057 
1058 #include "SheafSystem/error_message.h"
1059 #include "SheafSystem/sec_at0.h"
1060 #include "SheafSystem/sec_at1.h"
1061 #include "SheafSystem/sec_at2.h"
1062 #include "SheafSystem/sec_at3_e3.h"
1063 #include "SheafSystem/sec_atp.h"
1064 #include "SheafSystem/sec_st2.h"
1065 #include "SheafSystem/sec_st3.h"
1066 #include "SheafSystem/sec_st3_e3.h"
1067 #include "SheafSystem/sec_st4_e2.h"
1068 #include "SheafSystem/sec_st4_e3.h"
1069 #include "SheafSystem/sec_stp.h"
1070 #include "SheafSystem/sec_t2.h"
1071 #include "SheafSystem/sec_t3.h"
1072 #include "SheafSystem/sec_t3_e3.h"
1073 #include "SheafSystem/sec_t4_e2.h"
1074 #include "SheafSystem/sec_t4_e3.h"
1075 
1076 void
1078 alt(const sec_tp& x0, sec_atp& xresult, bool xauto_access)
1079 {
1080  // Preconditions:
1081 
1082  require(x0.state_is_auto_read_accessible(xauto_access));
1083  require(xresult.state_is_auto_read_write_accessible(xauto_access));
1084  require(x0.dd(xauto_access) == xresult.dd(xauto_access));
1085  require(!x0.variance(xauto_access).is_mixed());
1086 
1087  // Body:
1088 
1089  // Downcast implementation of multi dispatching.
1090 
1091  const sec_t2* t2_x0 = dynamic_cast<const sec_t2*>(&x0);
1092  const sec_t3* t3_x0 = dynamic_cast<const sec_t3*>(&x0);
1093  const sec_t3_e3* t3_e3_x0 = dynamic_cast<const sec_t3_e3*>(&x0);
1094 
1095  sec_at2* at2_xresult = dynamic_cast<sec_at2*>(&xresult);
1096  sec_t2* t2_xresult = dynamic_cast<sec_t2*>(&xresult);
1097  sec_at3_e3* at3_e3_xresult = dynamic_cast<sec_at3_e3*>(&xresult);
1098  sec_at3* at3_xresult = dynamic_cast<sec_at3*>(&xresult);
1099  sec_t3* t3_xresult = dynamic_cast<sec_t3*>(&xresult);
1100 
1101  if(t2_x0 && at2_xresult)
1102  {
1103  alt(*t2_x0, *at2_xresult, xauto_access);
1104  }
1105  else if(t2_x0 && t2_xresult)
1106  {
1107  alt(*t2_x0, *t2_xresult, xauto_access);
1108  }
1109  else if(t3_e3_x0 && at3_e3_xresult)
1110  {
1111  alt(*t3_e3_x0, *at3_e3_xresult, xauto_access);
1112  }
1113  else if(t3_x0 && t3_xresult)
1114  {
1115  alt(*t3_x0, *t3_xresult, xauto_access);
1116  }
1117  else if(t3_x0 && at3_xresult)
1118  {
1119  alt(*t3_x0, *at3_xresult, xauto_access);
1120  }
1121  else
1122  {
1123  post_fatal_error_message(\
1124  "Unsupported argument types in call to tensor(...)");
1125  }
1126 
1127  // Postconditions:
1128 
1129  // Exit:
1130 
1131  return;
1132 }
1133 
1134 void
1136 sym(const sec_tp& x0, sec_stp& xresult, bool xauto_access)
1137 {
1138  // Preconditions:
1139 
1140  require(x0.state_is_auto_read_accessible(xauto_access));
1141  require(xresult.state_is_auto_read_write_accessible(xauto_access));
1142  require(x0.dd(xauto_access) == xresult.dd(xauto_access));
1143  require(!x0.variance(xauto_access).is_mixed());
1144 
1145  // Body:
1146 
1147  // Downcast implementation of multi dispatching.
1148 
1149  const sec_t2* t2_x0 = dynamic_cast<const sec_t2*>(&x0);
1150  const sec_t3* t3_x0 = dynamic_cast<const sec_t3*>(&x0);
1151  const sec_t3_e3* t3_e3_x0 = dynamic_cast<const sec_t3_e3*>(&x0);
1152  const sec_t4_e2* t4_e2_x0 = dynamic_cast<const sec_t4_e2*>(&x0);
1153  const sec_t4_e3* t4_e3_x0 = dynamic_cast<const sec_t4_e3*>(&x0);
1154 
1155  sec_st2* st2_xresult = dynamic_cast<sec_st2*>(&xresult);
1156  sec_st3* st3_xresult = dynamic_cast<sec_st3*>(&xresult);
1157  sec_st3_e3* st3_e3_xresult = dynamic_cast<sec_st3_e3*>(&xresult);
1158  sec_t2* t2_xresult = dynamic_cast<sec_t2*>(&xresult);
1159  sec_t3* t3_xresult = dynamic_cast<sec_t3*>(&xresult);
1160  sec_st4_e2* st4_e2_xresult = dynamic_cast<sec_st4_e2*>(&xresult);
1161  sec_st4_e3* st4_e3_xresult = dynamic_cast<sec_st4_e3*>(&xresult);
1162 
1163  if(t2_x0 && st2_xresult)
1164  {
1165  sym(*t2_x0, *st2_xresult, xauto_access);
1166  }
1167  else if(t2_x0 && t2_xresult)
1168  {
1169  sym(*t2_x0, *t2_xresult, xauto_access);
1170  }
1171  else if(t3_e3_x0 && st3_e3_xresult)
1172  {
1173  sym(*t3_e3_x0, *st3_e3_xresult, xauto_access);
1174  }
1175  else if(t3_x0 && t3_xresult)
1176  {
1177  sym(*t3_x0, *t3_xresult, xauto_access);
1178  }
1179  else if(t3_x0 && st3_xresult)
1180  {
1181  sym(*t3_x0, *st3_xresult, xauto_access);
1182  }
1183  else if(t4_e2_x0 && st4_e2_xresult)
1184  {
1185  sym(*t4_e2_x0, *st4_e2_xresult, xauto_access);
1186  }
1187  else if(t4_e3_x0 && st4_e3_xresult)
1188  {
1189  sym(*t4_e3_x0, *st4_e3_xresult, xauto_access);
1190  }
1191  else
1192  {
1193  post_fatal_error_message(\
1194  "Unsupported argument types in call to tensor(...)");
1195  }
1196 
1197  // Postconditions:
1198 
1199  // Exit:
1200 
1201  return;
1202 }
1203 
1204 void
1206 contract(const sec_tp& x0, int xp, int xq, sec_tp& xresult, bool xauto_access)
1207 {
1208  // Preconditions:
1209 
1210  require(x0.state_is_auto_read_accessible(xauto_access));
1211  require(xresult.state_is_auto_read_write_accessible(xauto_access));
1212  require(xp != xq);
1213  require(xp >= 0 && xp < x0.p(xauto_access));
1214  require(xq >= 0 && xq < x0.p(xauto_access));
1215  require(x0.is_contravariant(xp, xauto_access) != \
1216  x0.is_contravariant(xq, xauto_access));
1217 
1218  // Body:
1219 
1220  // Downcast implementation of multi dispatching.
1221 
1222  const sec_t2* t2_x0 = dynamic_cast<const sec_t2*>(&x0);
1223  const sec_t3* t3_x0 = dynamic_cast<const sec_t3*>(&x0);
1224 
1225  sec_at0* at0_xresult = dynamic_cast<sec_at0*>(&xresult);
1226  sec_at1* at1_xresult = dynamic_cast<sec_at1*>(&xresult);
1227 
1228  if(t2_x0 && at0_xresult)
1229  {
1230  contract(*t2_x0, xp, xq, *at0_xresult, xauto_access);
1231  }
1232  else if(t3_x0 && at1_xresult)
1233  {
1234  contract(*t3_x0, xp, xq, *at1_xresult, xauto_access);
1235  }
1236  else
1237  {
1238  post_fatal_error_message(\
1239  "Unsupported argument types in call to tensor(...)");
1240  }
1241 
1242  // Postconditions:
1243 
1244  //ensure();
1245 
1246  // Exit:
1247 
1248  return;
1249 }
1250 
1251 void
1253 tensor(const sec_tp& x0, const sec_tp& x1, sec_tp& xresult, bool xauto_access)
1254 {
1255  // Preconditions:
1256 
1257  require(x0.state_is_auto_read_accessible(xauto_access));
1258  require(x1.state_is_auto_read_accessible(xauto_access));
1259  require(xresult.state_is_auto_read_write_accessible(xauto_access));
1260  require(x1.dd(xauto_access) == x0.dd(xauto_access));
1261  require(xresult.dd(xauto_access) == x0.dd(xauto_access));
1262 
1263  // Body:
1264 
1265  // Downcast implementation of multi dispatch.
1266 
1267  const sec_at1* at1_x0 = dynamic_cast<const sec_at1*>(&x0);
1268  const sec_at2* at2_x0 = dynamic_cast<const sec_at2*>(&x0);
1269  const sec_st2* st2_x0 = dynamic_cast<const sec_st2*>(&x0);
1270  const sec_t2* t2_x0 = dynamic_cast<const sec_t2*>(&x0);
1271 
1272  const sec_at1* at1_x1 = dynamic_cast<const sec_at1*>(&x1);
1273  const sec_at2* at2_x1 = dynamic_cast<const sec_at2*>(&x1);
1274  const sec_st2* st2_x1 = dynamic_cast<const sec_st2*>(&x1);
1275  const sec_t2* t2_x1 = dynamic_cast<const sec_t2*>(&x1);
1276 
1277  sec_t2* t2_xresult = dynamic_cast<sec_t2*>(&xresult);
1278  sec_t3* t3_xresult = dynamic_cast<sec_t3*>(&xresult);
1279 
1280  if(at1_x0 && at1_x1 && t2_xresult)
1281  {
1282  tensor(*at1_x0, *at1_x1, *t2_xresult, xauto_access);
1283  }
1284  else if(t2_x0 && at1_x1 && t3_xresult)
1285  {
1286  tensor(*t2_x0, *at1_x1, *t3_xresult, xauto_access);
1287  }
1288  else if(at1_x0 && t2_x1 && t3_xresult)
1289  {
1290  tensor(*at1_x0, *t2_x1, *t3_xresult, xauto_access);
1291  }
1292  else if(at2_x0 && at1_x1 && t3_xresult)
1293  {
1294  tensor(*at2_x0, *at1_x1, *t3_xresult, xauto_access);
1295  }
1296  else if(at1_x0 && at2_x1 && t3_xresult)
1297  {
1298  tensor(*at1_x0, *at2_x1, *t3_xresult, xauto_access);
1299  }
1300  else if(st2_x0 && at1_x1 && t3_xresult)
1301  {
1302  tensor(*st2_x0, *at1_x1, *t3_xresult, xauto_access);
1303  }
1304  else if(at1_x0 && st2_x1 && t3_xresult)
1305  {
1306  tensor(*at1_x0, *st2_x1, *t3_xresult, xauto_access);
1307  }
1308  else
1309  {
1310  post_fatal_error_message(\
1311  "Unsupported argument types in call to tensor(...)");
1312  }
1313 
1314  // Postconditions:
1315 
1316  // Exit:
1317 
1318  return;
1319 }
1320 
virtual bool invariant() const
Class invariant, intended to be redefined in each descendant. See below for template for invariant in...
Definition: any.cc:153
static int factor_ct(int xd)
Factor_ct() as a function of dimension xd.
static const std::string create_tensor_space_name(const std::string &xvector_space_name, const std::string &xname)
Create a standard tensor space name.
Definition: sec_tp.cc:572
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 ...
A section of a bundle with fiber type st3_e3.
Definition: sec_st3_e3.h:48
sec_tp()
Default constructor.
Definition: sec_tp.cc:110
SHEAF_DLL_SPEC void sym(const sec_t2 &x0, sec_st2 &xresult, bool xauto_access)
The symmetric part of tensor x0 (pre-allocated version).
Definition: sec_t2.cc:737
SHEAF_DLL_SPEC void alt(const t2_lite &x0, at2_lite &xresult)
The alternating (antisymmetric) part of tensor x0 (pre-allocated version for volatile types)...
Definition: t2.cc:1176
virtual void put_is_contravariant(bool xauto_access)
Sets all tensor index positions to contravariant.
Definition: sec_tp.cc:789
bool full() const
True if both poset name and member name are not empty.
Definition: poset_path.cc:311
The "type" of a tensor; specifies the degree and the co- or contra-variance for each index of a tenso...
The abstract map from section dof ids to section dof values of heterogeneous type.
A section of a bundle with fiber type at3_e3.
Definition: sec_at3_e3.h:48
A space of scalars viewed as an antisymmetric tensor section space of degree 1.
Definition: sec_at1_space.h:48
virtual sec_tp & operator=(const abstract_poset_member &xother)
Assignment operator; synonym for attach_to_state(&xother).
Definition: sec_tp.cc:276
poset_path path(bool xauto_access=true) const
A path to this component.
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...
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.
The standard fiber bundles name space; extends the standard sheaves namespace by defining base space...
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.
bool fiber_is_ancestor_of(const any *xother) const
True if xother conforms to an instance of the fiber of current.
Definition: sec_tp.cc:964
SHEAF_DLL_SPEC void sym(const t2_lite &x0, st2_lite &xresult)
The symmetric part of tensor x0 (pre-allocated version for volatile types).
Definition: t2.cc:1301
virtual const std::string & class_name() const
The name of this class.
Definition: sec_tp.cc:865
SHEAF_DLL_SPEC void alt(const sec_t2 &x0, sec_at2 &xresult, bool xauto_access)
The alternating (antisymmetric) part of tensor x0 (pre-allocated version).
Definition: sec_t2.cc:679
static const std::string & static_class_name()
The name of this class.
Definition: sec_tp.cc:884
A path defined by a poset name and a member name separated by a forward slash (&#39;/&#39;). For example: "cell_definitions/triangle".
Definition: poset_path.h:48
A member of a sec_rep_space; a section.
poset_path vector_space_path() const
The path of the underlying vector space.
STL namespace.
A schema poset for a section space. A binary Cartesian product subspace of the binary tensor product ...
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.
A section of a bundle with fiber type at1.
Definition: sec_at1.h:48
virtual void put_is_covariant(bool xauto_access)
Sets all tensor index positions to covariant.
Definition: sec_tp.cc:705
virtual tensor_variance variance(bool xauto_access) const
The variance.
Definition: sec_tp.cc:589
void put_variance(const tensor_variance &xvariance, bool xauto_access)
Sets the variance to xvariance.
Definition: sec_tp.cc:627
virtual int p() const
The degree of the tensors in host(); the sum of the contravariant and covariant degrees.
Definition: sec_tp.cc:391
bool is_mixed() const
True if and only if there exists at least one index that is covariant and at least one that is contra...
A section of a bundle with fiber type t3_e3.
Definition: sec_t3_e3.h:48
A general tensor of "degree" p and given "variance" over an abstract vector space.
Definition: tp.h:253
A section of a bundle with fiber type t3.
Definition: sec_t3.h:46
Abstract base class with useful features for all objects.
Definition: any.h:39
int p() const
The tensor degree of this space.
virtual section_space_schema_member & schema()
The schema for this poset (mutable version)
virtual bool is_contravariant(bool xauto_access) const
True if and only if all tensor index positions are contravariant.
Definition: sec_tp.cc:748
A section of a bundle with fiber type st4_e3.
Definition: sec_st4_e3.h:48
~sec_tp()
Destructor.
Definition: sec_tp.cc:360
An abstract tensor section space of degree p.
Definition: sec_tp_space.h:53
bool is_ancestor_of(const any *xother) const
True if xother conforms to current.
Definition: sec_tp.cc:990
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)
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
static host_type & new_host(namespace_type &xns, const poset_path &xhost_path, const poset_path &xschema_path, const poset_path &xvector_space_path, bool xauto_access)
Creates a new host table for members of this type. The poset is created in namespace xns with path xh...
Definition: sec_tp.cc:50
A section of a bundle with fiber type at2.
Definition: sec_at2.h:46
A section of a bundle with fiber type atp.
Definition: sec_atp.h:48
host_type * host() const
The poset this is a member of.
Definition: sec_tp.cc:939
virtual int dd() const
Dimension of the underlying vector space.
Definition: sec_tp.cc:433
A section of a bundle with fiber type st2.
Definition: sec_st2.h:46
bool contains_path(const poset_path &xpath, bool xauto_access=true) const
True if this contains the poset or poset member specified by xpath.
A section of a bundle with fiber type stp.
Definition: sec_stp.h:48
virtual bool contains_member(pod_index_type xmbr_hub_id, bool xauto_access=true) const
True if some version of this poset contains poset member with hub id xmbr_hub_id. ...
A section of a bundle with fiber type at3.
Definition: sec_at3.h:46
int dd() const
The dimension of the underlying ("domain") vector space.
virtual sec_tp_space & vector_space() const
The underlying vector space.
Definition: sec_tp.cc:517
bool empty() const
True if both poset name and member name are empty.
Definition: poset_path.cc:291
A section of a bundle with fiber type st3.
Definition: sec_st3.h:46
A general tensor of degree p over an abstract vector space (volatile version). Volatile version does ...
Definition: tp.h:59
virtual sec_tp * clone() const
Make a new handle, no state instance of current.
Definition: sec_tp.cc:903
A section of a bundle with fiber type st4_e2.
Definition: sec_st4_e2.h:48
A section of a bundle with fiber type t4_e2.
Definition: sec_t4_e2.h:48
virtual const fiber_type & fiber_prototype() const
Virtual constructor for the associated fiber type.
Definition: sec_tp.cc:374
A section of a bundle with fiber type tp.
Definition: sec_t2.h:46
A section of a bundle with fiber type t4_e3.
Definition: sec_t4_e3.h:48
SHEAF_DLL_SPEC void contract(const sec_t2 &x0, int xp, int xq, sec_at0 &xresult, bool xauto_access)
Contraction on contravariant index xp and covariant index xq (pre-allocated version).
Definition: sec_t2.cc:795
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
poset_path scalar_space_path() const
The path of the underlying space of scalars.
poset & fiber_space()
The fiber space for section spaces on this schema (mutable version).
SHEAF_DLL_SPEC void tensor(const sec_at1 &x0, const sec_at1 &x1, sec_t2 &xresult, bool xauto_access)
Definition: sec_t2.cc:824
poset_path vector_space_path() const
The path of the underlying vector space.
Definition: sec_tp.cc:475
bool variance(int xi) const
The variance of the xi-th index; covariant if true, contravariant if false.
virtual int d(int xp, int xdd) const
Dimension d() as a function of degree xp and domain dimension xdd.
virtual bool host_is_ancestor_of(const poset_state_handle *other) const
True if other conforms to host.
Definition: sec_tp.cc:946
virtual bool is_covariant(bool xauto_access) const
True if and only if all tensor index positions are covariant.
Definition: sec_tp.cc:666
bool invariant() const
Class invariant.
Definition: sec_tp.cc:1015
An abstract client handle for a member of a poset.
An abstract tensor space of degree p.
Definition: tp_space.h:47
SHEAF_DLL_SPEC void tensor(const at1_lite &x0, const at1_lite &x1, t2_lite &xresult)
Tensor product (pre-allocated version for volatile types).
Definition: t2.cc:1488
Namespace for the fiber_bundles component of the sheaf system.
Antisymetric tensor of degree 0. As the degree is 0 there is nothing to be symmetric or antisymmetric...
Definition: sec_at0.h:51
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...
SHEAF_DLL_SPEC void contract(const t2_lite &x0, int xp, int xq, at0_lite &xresult)
Contraction on contravariant index xp and covariant index xq (pre-allocated version for volatime type...
Definition: t2.cc:1091
A section of a bundle with fiber type tp.
Definition: sec_tp.h:49
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.
Definition: scoped_index.h:710
A handle for a poset whose members are numerical representations of sections of a fiber bundle...
Definition: sec_rep_space.h:61