SheafSystem  0.0.0.0
e4.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/e4.impl.h"
22 
23 #include "SheafSystem/abstract_poset_member.impl.h"
24 #include "SheafSystem/assert_contract.h"
25 #include "SheafSystem/at0.h"
26 #include "SheafSystem/at0_space.h"
27 #include "SheafSystem/at1_space.h"
28 #include "SheafSystem/fiber_bundles_namespace.h"
29 #include "SheafSystem/schema_poset_member.h"
30 #include "SheafSystem/stp.h"
31 #include "SheafSystem/wsv_block.h"
32 
33 using namespace std;
34 using namespace fiber_bundle; // Workaround for MS C++ bug.
35 
36 
37 //==============================================================================
38 // CLASS E4_LITE
39 //==============================================================================
40 
41 
42 //==============================================================================
43 // EUCLIDEAN VECTOR ALGEBRA (E4) FACET OF CLASS E4_LITE
44 //==============================================================================
45 
46 // PUBLIC MEMBER FUNCTIONS
47 
50 {
51 
52  // Preconditions:
53 
54  // Body:
55 
56  // Postconditions:
57 
58  ensure(invariant());
59 
60  // Exit:
61 }
62 
64 e4_lite(const e4_lite& xother)
65 {
66  // Preconditions:
67 
68  // Body:
69 
70  *this = xother;
71 
72  // Postconditions:
73 
74  ensure(invariant());
75 
76  // Exit:
77 }
78 
81 operator=(const e4_lite& xother)
82 {
83 
84  // Preconditions:
85 
86  // Body:
87 
88  if(this == &xother)
89  return *this;
90 
91  _row_dofs = xother._row_dofs;
92 
93  // Postconditions:
94 
95  ensure(invariant());
96  ensure(unexecutable(*this == xother));
97 
98  // Exit:
99 
100  return *this;
101 }
102 
105 {
106  // Preconditions:
107 
108  // Body:
109 
110  // Postconditions:
111 
112  // Exit:
113 }
114 
116 e4_lite(const row_dofs_type& xrow_dofs)
117 {
118  // Preconditions:
119 
120  // Body:
121 
122  *this = xrow_dofs;
123 
124  // Postconditions:
125 
126  // Exit:
127 }
128 
131 operator=(const row_dofs_type& xrow_dofs)
132 {
133  // Preconditions:
134 
135  // Body:
136 
137  _row_dofs = xrow_dofs;
138 
139  // Postconditions:
140 
141  ensure(invariant());
142  ensure(unexecutable(row_dofs() == xrow_dofs));
143  //ensure_for_all(i, 0, d(), component(i) == xrow_dofs[i]);
144 
145  // Exit:
146 
147  return *this;
148 
149 }
150 
152 e4_lite(const value_type& x0,
153  const value_type& x1,
154  const value_type& x2,
155  const value_type& x3)
156 {
157  // Preconditions:
158 
159  // Body:
160 
161  put_components(x0, x1, x2, x3);
162 
163  // Postconditions:
164 
165  ensure(invariant());
166  ensure(isunordered_or_equals(component(0), x0));
167  ensure(isunordered_or_equals(component(1), x1));
168  ensure(isunordered_or_equals(component(2), x2));
169  ensure(isunordered_or_equals(component(3), x3));
170 
171  // Exit:
172 }
173 
174 fiber_bundle::e4_lite::
176 {
177  // Preconditions:
178 
179  // Body:
180 
181  row_dofs_type& result = _row_dofs;
182 
183  // Postconditions:
184 
185  ensure(invariant());
186 
187  // Exit:
188 
189  return result;
190 }
191 
192 fiber_bundle::e4_lite::
193 operator const e4_lite::row_dofs_type& () const
194 {
195  // Preconditions:
196 
197  // Body:
198 
199  const row_dofs_type& result = _row_dofs;
200 
201  // Postconditions:
202 
203  ensure(invariant());
204 
205  // Exit:
206 
207  return result;
208 }
209 
210 void
213  const value_type& x1,
214  const value_type& x2,
215  const value_type& x3)
216 {
217  // Preconditions:
218 
219  // Body:
220 
221  put_component(0, x0);
222  put_component(1, x1);
223  put_component(2, x2);
224  put_component(3, x3);
225 
226  // Postconditions:
227 
228  ensure(invariant());
229  ensure(isunordered_or_equals(component(0), x0));
230  ensure(isunordered_or_equals(component(1), x1));
231  ensure(isunordered_or_equals(component(2), x2));
232  ensure(isunordered_or_equals(component(3), x3));
233 
234 
235  // Exit:
236 }
237 
238 // PROTECTED MEMBER FUNCTIONS
239 
240 // PRIVATE MEMBER FUNCTIONS
241 
242 
243 //==============================================================================
244 // EUCLIDEAN VECTOR ALGEBRA (ED) FACET OF CLASS E4_LITE
245 //==============================================================================
246 
247 // PUBLIC MEMBER FUNCTIONS
248 
249 // PROTECTED MEMBER FUNCTIONS
250 
251 // PRIVATE MEMBER FUNCTIONS
252 
253 
254 //==============================================================================
255 // EXTERIOR ALGEBRA (AT1) FACET OF CLASS E4_LITE
256 //==============================================================================
257 
258 // PUBLIC MEMBER FUNCTIONS
259 
260 // PROTECTED MEMBER FUNCTIONS
261 
262 // PRIVATE MEMBER FUNCTIONS
263 
264 
265 //==============================================================================
266 // EXTERIOR ALGEBRA (ATP) FACET OF CLASS E4_LITE
267 //==============================================================================
268 
269 // PUBLIC MEMBER FUNCTIONS
270 
271 // PROTECTED MEMBER FUNCTIONS
272 
273 // PRIVATE MEMBER FUNCTIONS
274 
275 
276 //==============================================================================
277 // TENSOR ALGEBRA (TP) FACET OF CLASS E4_LITE
278 //==============================================================================
279 
280 // PUBLIC MEMBER FUNCTIONS
281 
282 int
284 dd() const
285 {
286  // Preconditions:
287 
288  // Body:
289 
290  int result = 4;
291 
292  // Postconditions:
293 
294  ensure(invariant());
295  ensure(result == 4);
296 
297  // Exit:
298 
299  return result;
300 }
301 
302 bool
304 operator==(const e4_lite& xother) const
305 {
306  // cout << endl << "Entering e4_lite::operator==." << endl;
307 
308  // Preconditions:
309 
310  // Body:
311 
312  bool result =
313  (_row_dofs.components[0] == xother._row_dofs.components[0]) &&
314  (_row_dofs.components[1] == xother._row_dofs.components[1]) &&
315  (_row_dofs.components[2] == xother._row_dofs.components[2]) &&
316  (_row_dofs.components[3] == xother._row_dofs.components[3]);
317 
318  // Postconditions:
319 
320 
321  // Exit:
322 
323  // cout << "Leaving e4_lite::operator==." << endl;
324  return result;
325 }
326 
327 // PROTECTED MEMBER FUNCTIONS
328 
329 // PRIVATE MEMBER FUNCTIONS
330 
331 
332 //==============================================================================
333 // VECTOR ALGEBRA (VD) FACET OF CLASS E4_LITE
334 //==============================================================================
335 
336 // PUBLIC MEMBER FUNCTIONS
337 
341 {
342  // Preconditions:
343 
344  require((0 <= xp) && (xp <= 1));
345 
346  // Body:
347 
348  switch(xp)
349  {
350  case 0:
351  {
352  static const at0_lite lat0_lite;
353  return lat0_lite;
354  }
355  case 1:
356  {
357  static const e4_lite le4_lite;
358  return le4_lite;
359  }
360  default:
361  {
362  // Can't get here because of the precondition.
363  static const tp_lite ltp_lite;
364  return ltp_lite;
365  }
366  }
367 
368  // Postconditions:
369 
370  ensure(unexecutable("result.p() == xp"));
371 
372  // Exit:
373 }
374 
377 tp_prototype(int xp) const
378 {
379  // Preconditions:
380 
381  require(precondition_of(static_tp_prototype(xp)));
382 
383  // Body:
384 
385  const tp_lite& result = static_tp_prototype(xp);
386 
387  // Postconditions:
388 
389  ensure(postcondition_of(static_tp_prototype(xp)));
390 
391  // Exit:
392 
393  return result;
394 }
395 
399 {
400  // Preconditions:
401 
402  require((0 <= xp) && (xp <= 1));
403 
404  // Body:
405 
406  switch(xp)
407  {
408  case 0:
409  {
410  static const at0_lite lat0_lite;
411  return lat0_lite;
412  }
413  case 1:
414  {
415  static const e4_lite le4_lite;
416  return le4_lite;
417  }
418  default:
419  {
420  // Can't get here because of the precondition.
421  static const atp_lite latp_lite;
422  return latp_lite;
423  }
424  }
425 
426  // Postconditions:
427 
428  ensure(unexecutable("result.p() == xp"));
429 
430  // Exit:
431 }
432 
435 atp_prototype(int xp) const
436 {
437  // Preconditions:
438 
439  require(precondition_of(static_atp_prototype(xp)));
440 
441  // Body:
442 
443  const atp_lite& result = static_atp_prototype(xp);
444 
445  // Postconditions:
446 
447  ensure(postcondition_of(static_atp_prototype(xp)));
448 
449  // Exit:
450 
451  return result;
452 }
453 
457 {
458  // Preconditions:
459 
460  require((2 <= xp) && (xp <= 4));
461 
462  // Body:
463 
464  static const stp_lite lstp_lite;
465  return lstp_lite;
466 
467  // Postconditions:
468 
469  ensure(unexecutable("result.p() == xp"));
470 
471  // Exit:
472 }
473 
476 stp_prototype(int xp) const
477 {
478  // Preconditions:
479 
480  require(precondition_of(static_stp_prototype(xp)));
481 
482  // Body:
483 
484  const stp_lite& result = static_stp_prototype(xp);
485 
486  // Postconditions:
487 
488  ensure(postcondition_of(static_stp_prototype(xp)));
489 
490  // Exit:
491 
492  return result;
493 }
494 
495 // PROTECTED MEMBER FUNCTIONS
496 
497 // PRIVATE MEMBER FUNCTIONS
498 
499 
500 //==============================================================================
501 // CARTESIAN ALGEBRA (TUPLE) FACET OF CLASS E4_LITE
502 //==============================================================================
503 
504 // PUBLIC MEMBER FUNCTIONS
505 
506 // PROTECTED MEMBER FUNCTIONS
507 
508 // PRIVATE MEMBER FUNCTIONS
509 
510 
511 //==============================================================================
512 // ABSTRACT POSET MEMBER FACET OF CLASS E4_LITE
513 //==============================================================================
514 
515 // PUBLIC MEMBER FUNCTIONS
516 
517 const std::string&
519 class_name() const
520 {
521  // Preconditions:
522 
523  // Body:
524 
525  const string& result = static_class_name();
526 
527  // Postconditions:
528 
529  ensure(!result.empty());
530 
531  // Exit:
532 
533  return result;
534 }
535 
536 const std::string&
539 {
540  // Preconditions:
541 
542  // Body:
543 
544  static const string result("e4_lite");
545 
546  // Postconditions:
547 
548  ensure(!result.empty());
549 
550  // Exit:
551 
552  return result;
553 }
554 
557 clone() const
558 {
559  e4_lite* result = 0;
560 
561  // Preconditions:
562 
563  // Body:
564 
565  result = new e4_lite();
566 
567  // Postconditions:
568 
569  ensure(result != 0);
570  ensure(is_same_type(*result));
571 
572  // Exit:
573 
574  return result;
575 }
576 
577 // PROTECTED MEMBER FUNCTIONS
578 
579 // PRIVATE MEMBER FUNCTIONS
580 
581 
582 //==============================================================================
583 // ANY FACET OF CLASS E4_LITE
584 //==============================================================================
585 
586 // PUBLIC MEMBER FUNCTIONS
587 
588 bool
590 is_ancestor_of(const any_lite& xother) const
591 {
592  // Preconditions:
593 
594  require(&xother != 0);
595 
596  // Body:
597 
598  // True if other conforms to this.
599 
600  bool result = dynamic_cast<const e4_lite*>(&xother) != 0;
601 
602  // Postconditions:
603 
604  return result;
605 }
606 
607 bool
609 invariant() const
610 {
611  bool result = true;
612 
613  if(invariant_check())
614  {
615  // Prevent recursive calls to invariant.
616 
617  disable_invariant_check();
618 
619  // Must satisfy base class invariant.
620 
621  invariance(ed_lite::invariant());
622 
623  // Invariances for this class:
624 
625  // Finished, turn invariant checking back on.
626 
627  enable_invariant_check();
628  }
629 
630  // Exit
631 
632  return result;
633 }
634 
635 void*
638 {
639  return &_row_dofs;
640 }
641 
642 const void*
644 row_dofs() const
645 {
646  return &_row_dofs;
647 }
648 
649 // PROTECTED MEMBER FUNCTIONS
650 
651 // PRIVATE MEMBER FUNCTIONS
652 
653 
654 //==============================================================================
655 // CLASS E4
656 //==============================================================================
657 
658 // ===========================================================
659 // HOST FACTORY FACET OF CLASS E4
660 // ===========================================================
661 
662 // PUBLIC MEMBER FUNCTIONS
663 
664 const sheaf::poset_path&
667 {
668  // Preconditions:
669 
670 
671  // Body:
672 
673  static const poset_path result(standard_schema_poset_name(), "e4_schema");
674 
675  // Postconditions:
676 
677  // Exit:
678 
679  return result;
680 }
681 
682 void
685 {
686  // Preconditions:
687 
688  require(xns.state_is_read_write_accessible());
689  require(xns.contains_poset(standard_schema_poset_name()));
690  require(!xns.contains_poset_member(standard_schema_path()));
691 
692  // Body:
693 
694  string lmember_names = "x DOUBLE false ";
695  lmember_names += "y DOUBLE false ";
696  lmember_names += "z DOUBLE false";
697  lmember_names += "t DOUBLE false";
698 
699  schema_poset_member lschema(xns,
700  standard_schema_path().member_name(),
701  ed::standard_schema_path(),
702  lmember_names,
703  false);
704 
705  lschema.detach_from_state();
706 
707  // Postconditions:
708 
709  ensure(xns.contains_poset_member(standard_schema_path()));
710 
711  // Exit:
712 
713  return;
714 }
715 
719  const poset_path& xhost_path,
720  const poset_path& xschema_path,
721  const poset_path& xscalar_space_path,
722  bool xauto_access)
723 {
724  // cout << endl << "Entering e4::new_host." << endl;
725 
726  // Preconditions:
727 
728  require(xns.state_is_auto_read_write_accessible(xauto_access));
729 
730  require(!xhost_path.empty());
731  require(!xns.contains_path(xhost_path, xauto_access));
732 
733  require(xschema_path.full());
734  require(xns.path_is_auto_read_accessible(xschema_path, xauto_access));
735  require(schema_poset_member::conforms_to(xns, xschema_path, standard_schema_path()));
736  require(schema_poset_member::row_dof_ct(xns, xschema_path, xauto_access) == 4);
737 
738  require(xns.path_is_auto_read_accessible(xscalar_space_path, xauto_access));
739  require(xns.contains_poset<scalar_type::host_type>(xscalar_space_path, xauto_access));
740 
741  // Body:
742 
743  host_type& result =
744  host_type::new_table(xns, xhost_path, xschema_path, xscalar_space_path, xauto_access);
745 
746  // Postconditions:
747 
748  ensure(xns.owns(result, xauto_access));
749  ensure(result.path(true) == xhost_path);
750  ensure(result.state_is_not_read_accessible());
751  ensure(result.schema(true).path(xauto_access) == xschema_path);
752 
753  ensure(result.factor_ct(true) == 4);
754  ensure(result.d(true) == 4);
755  ensure(result.scalar_space_path(true) == xscalar_space_path );
756  ensure(result.p(true) == 1);
757  ensure(result.dd(true) == 4);
758  ensure(result.vector_space_path(true) == xhost_path );
759 
760  // Exit:
761 
762  // cout << "Leaving e4::new_host." << endl;
763  return result;
764 }
765 
768 standard_host(namespace_type& xns, const std::string& xsuffix, bool xauto_access)
769 {
770  // cout << endl << "Entering e4::new_host." << endl;
771 
772  // Preconditions:
773 
774  require(xns.state_is_auto_read_write_accessible(xauto_access));
775 
776  require(xsuffix.empty() || poset_path::is_valid_name(xsuffix));
777  require(standard_host_is_available<e4>(xns, xsuffix, xauto_access));
778 
779  require(xns.path_is_auto_read_accessible(standard_schema_path(), xauto_access));
780 
781  require(xns.path_is_auto_read_available(standard_host_path<scalar_type>(xsuffix), xauto_access));
782 
783  // Body:
784 
785  // Create the scalar space if necessary.
786 
787  poset_path lscalar_space_path = scalar_type::standard_host(xns, xsuffix, xauto_access).path(true);
788 
789  poset_path lpath(standard_host_path<e4>(xsuffix));
790 
791  host_type* result_ptr;
792  if(xns.contains_path(lpath, xauto_access))
793  {
794  result_ptr = &xns.member_poset<host_type>(lpath, xauto_access);
795  }
796  else
797  {
798  result_ptr = &new_host(xns, lpath, standard_schema_path(), lscalar_space_path, xauto_access);
799  }
800 
801  host_type& result = *result_ptr;
802 
803  // Postconditions:
804 
805  ensure(xns.owns(result, xauto_access));
806  ensure(result.path(true) == standard_host_path<e4>(xsuffix));
807  ensure(result.state_is_not_read_accessible());
808  ensure(result.schema(true).path(xauto_access) == standard_schema_path());
809 
810  ensure(result.factor_ct(true) == 4);
811  ensure(result.d(true) == 4);
812  ensure(result.scalar_space_path(true) ==
813  standard_host_path<scalar_type>(xsuffix) );
814  ensure(result.p(true) == 1);
815  ensure(result.dd(true) == 4);
816  ensure(result.vector_space_path(true) == result.path(true) );
817 
818  // Exit:
819 
820  // cout << "Leaving e4::new_host." << endl;
821  return result;
822 }
823 
824 // PROTECTED MEMBER FUNCTIONS
825 
826 // PRIVATE MEMBER FUNCTIONS
827 
828 
829 //==============================================================================
830 // EUCLIDEAN VECTOR ALGEBRA (E4) FACET OF CLASS E4
831 //==============================================================================
832 
833 // PUBLIC MEMBER FUNCTIONS
834 
836 e4()
837 {
838  // Preconditions:
839 
840  // Body:
841 
842  // Postconditions:
843 
844  ensure(invariant());
845 
846  // Exit:
847 }
848 
850 e4(const poset_state_handle* xhost, pod_index_type xhub_id)
851 {
852  // Preconditions:
853 
854  require(xhost != 0);
855  require(xhost->state_is_read_accessible());
856  require(xhost->contains_member(xhub_id));
857 
858  // Body:
859 
860  attach_to_state(xhost, xhub_id);
861 
862  // Postconditions:
863 
864  ensure(invariant());
865  // ensure(host() == xhost);
866  ensure(index() == xhub_id);
867  ensure(is_attached());
868 }
869 
871 e4(const poset_state_handle* xhost, const scoped_index& xid)
872 {
873 
874  // Preconditions:
875 
876  require(xhost != 0);
877  require(xhost->state_is_read_accessible());
878  require(xhost->contains_member(xid));
879 
880  // Body:
881 
882  attach_to_state(xhost, xid.hub_pod());
883 
884  // Postconditions:
885 
886  ensure(invariant());
887  // ensure(host() == xhost);
888  ensure(index() ==~ xid);
889  ensure(is_attached());
890 }
891 
893 e4(const poset_state_handle* xhost, const std::string& xname)
894 {
895 
896  // Preconditions:
897 
898  require(xhost != 0);
899  require(xhost->state_is_read_accessible());
900  require(!xname.empty());
901  require(xhost->contains_member(xname));
902 
903  // Body:
904 
905  attach_to_state(xhost, xname);
906 
907  // Postconditions:
908 
909  ensure(invariant());
910  // ensure(host() == xhost);
911  ensure(name() == xname);
912  ensure(is_attached());
913 
914 }
915 
918 {
919 
920  // Preconditions:
921 
922  require(xother != 0);
923 
924  // Body:
925 
926  attach_to_state(xother);
927 
928  // Postconditions:
929 
930  ensure(invariant());
931  ensure(is_attached());
932  ensure(is_same_state(xother));
933 
934  // Exit:
935 
936 }
937 
939 e4(poset_state_handle* xhost, bool xauto_access)
940 {
941 
942  // Preconditions:
943 
944  require(precondition_of(new_jim_state(xhost, 0, false, xauto_access)));
945 
946  // Body:
947 
948  new_jim_state(xhost, 0, false, xauto_access);
949 
950  // Postconditions:
951 
952  ensure(postcondition_of(new_jim_state(xhost, 0, false, xauto_access)));
953 
954  // Exit:
955 
956  return;
957 }
958 
961  const row_dofs_type& xrdt,
962  bool xauto_access)
963 {
964 
965  // Preconditions:
966 
967  require(precondition_of(new_jim_state(&xhost, 0, false, xauto_access)));
968 
969  // Body:
970 
971  new_jim_state(&xhost, 0, false, xauto_access);
972 
973  if(xauto_access)
974  {
975  xhost.get_read_write_access();
976  }
977 
978  *this = xrdt;
979 
980  if(xauto_access)
981  {
982  xhost.release_access();
983  }
984 
985  // Postconditions:
986 
987  ensure(postcondition_of(new_jim_state(&xhost, 0, false, xauto_access)));
988 
989  // Exit:
990 
991  return;
992 }
993 
997 {
998  // Preconditions:
999 
1000  require(state_is_read_write_accessible());
1001 
1002  // Body:
1003 
1004  sheaf::row_dofs(*this) = xrdt;
1005 
1006  // Postconditions:
1007 
1008  ensure_for_all(i, 0, d(), component(i) == xrdt.components[i]);
1009 
1010  // Exit:
1011 
1012  return *this;
1013 
1014 }
1015 
1020 {
1021  // Preconditions:
1022 
1023  require(is_ancestor_of(&xother));
1024  require(precondition_of(attach_to_state(&xother)));
1025 
1026  // Body:
1027 
1028  attach_to_state(&xother);
1029 
1030  // Postconditions:
1031 
1032  ensure(postcondition_of(attach_to_state(&xother)));
1033 
1034  // Exit:
1035 
1036  return *this;
1037 }
1038 
1042 operator=(const e4& xother)
1043 {
1044  // Preconditions:
1045 
1046  require(precondition_of(attach_to_state(&xother)));
1047 
1048  // Body:
1049 
1050  attach_to_state(&xother);
1051 
1052  // Postconditions:
1053 
1054  ensure(postcondition_of(attach_to_state(&xother)));
1055 
1056  // Exit:
1057 
1058  return *this;
1059 }
1060 
1063 {
1064  // Preconditions:
1065 
1066  // Body:
1067 
1068  // Postconditions:
1069 }
1070 
1074 {
1075  // Preconditions:
1076 
1077  // Body:
1078 
1079  static const volatile_type result;
1080 
1081  // Postconditions:
1082 
1083  // Exit:
1084 
1085  return result;
1086 }
1087 
1091 lite_type() const
1092 {
1093  // Preconditions:
1094 
1095  // Body:
1096 
1097  volatile_type* result = new volatile_type(sheaf::row_dofs(*this));
1098 
1099  // Postconditions:
1100 
1101  // Exit:
1102 
1103  return result;
1104 }
1105 
1106 
1107 // PROTECTED MEMBER FUNCTIONS
1108 
1109 // PRIVATE MEMBER FUNCTIONS
1110 
1111 
1112 //==============================================================================
1113 // EUCLIDEAN VECTOR ALGEBRA (ED) FACET OF CLASS E4
1114 //==============================================================================
1115 
1116 // PUBLIC MEMBER FUNCTIONS
1117 
1118 // PROTECTED MEMBER FUNCTIONS
1119 
1120 // PRIVATE MEMBER FUNCTIONS
1121 
1122 
1123 //==============================================================================
1124 // EXTERIOR ALGEBRA (AT1) FACET OF CLASS E4
1125 //==============================================================================
1126 
1127 // PUBLIC MEMBER FUNCTIONS
1128 
1129 // PROTECTED MEMBER FUNCTIONS
1130 
1131 // PRIVATE MEMBER FUNCTIONS
1132 
1133 
1134 //==============================================================================
1135 // EXTERIOR ALGEBRA (ATP) FACET OF CLASS E4
1136 //==============================================================================
1137 
1138 // PUBLIC MEMBER FUNCTIONS
1139 
1140 // PROTECTED MEMBER FUNCTIONS
1141 
1142 // PRIVATE MEMBER FUNCTIONS
1143 
1144 
1145 //==============================================================================
1146 // TENSOR ALGEBRA (TP) FACET OF CLASS E4
1147 //==============================================================================
1148 
1149 // PUBLIC MEMBER FUNCTIONS
1150 
1151 // PROTECTED MEMBER FUNCTIONS
1152 
1153 // PRIVATE MEMBER FUNCTIONS
1154 
1155 
1156 //==============================================================================
1157 // VECTOR ALGEBRA (VD) FACET OF CLASS E4
1158 //==============================================================================
1159 
1160 // PUBLIC MEMBER FUNCTIONS
1161 
1162 void
1165 {
1166  // Preconditions:
1167 
1168  require(state_is_read_write_accessible());
1169 
1170  // Body:
1171 
1172  put_component(0, x0);
1173  put_component(1, x1);
1174  put_component(2, x2);
1175  put_component(3, x3);
1176 
1177  // Postconditions:
1178 
1179  ensure(invariant());
1180  ensure(isunordered_or_equals(component(0), x0));
1181  ensure(isunordered_or_equals(component(1), x1));
1182  ensure(isunordered_or_equals(component(2), x2));
1183  ensure(isunordered_or_equals(component(3), x3));
1184 
1185  // Exit:
1186 
1187  return;
1188 }
1189 
1190 fiber_bundle::e4::
1191 operator e4::row_dofs_type& ()
1192 {
1193  // Preconditions:
1194 
1195  // Body:
1196 
1197  row_dofs_type& result = sheaf::row_dofs(*this);
1198 
1199  // Postconditions:
1200 
1201  // Exit:
1202 
1203  return result;
1204 }
1205 
1206 fiber_bundle::e4::
1207 operator const e4::row_dofs_type& () const
1208 {
1209  // Preconditions:
1210 
1211  // Body:
1212 
1213  const row_dofs_type& result = sheaf::row_dofs(*this);
1214 
1215  // Postconditions:
1216 
1217  // Exit:
1218 
1219  return result;
1220 }
1221 
1222 // PROTECTED MEMBER FUNCTIONS
1223 
1224 // PRIVATE MEMBER FUNCTIONS
1225 
1226 
1227 //==============================================================================
1228 // CARTESIAN ALGEBRA (TUPLE) FACET OF CLASS E4
1229 //==============================================================================
1230 
1231 // PUBLIC MEMBER FUNCTIONS
1232 
1235 new_tp(tp_space& xvector_space, int xp)
1236 {
1237  // Preconditions:
1238 
1239  require(xvector_space.state_is_read_accessible());
1240  require((0 <= xp) && (xp <= 1));
1241 
1242  // Body:
1243 
1244  namespace_poset* lns = xvector_space.name_space();
1245  const string& lvector_space_name = xvector_space.name();
1246 
1247  switch(xp)
1248  {
1249  case 0:
1250  {
1251  const string lname =
1252  create_tensor_space_name(lvector_space_name, "at0");
1253  tp_space& lhost = lns->member_poset<tp_space>(lname, false);
1254  at0* result = new at0(&lhost);
1255  return result;
1256  }
1257 
1258  case 1:
1259  {
1260  const string lname =
1261  create_tensor_space_name(lvector_space_name, "e4");
1262  tp_space& lhost = lns->member_poset<tp_space>(lname, false);
1263  e4* result = new e4(&lhost);
1264  return result;
1265  }
1266 
1267  default:
1268  // Can't get here because of the precondition.
1269  return 0;
1270  }
1271 
1272  // Postconditions:
1273 
1274  ensure(unexecutable("result.p() == xp"));
1275 
1276  // Exit:
1277 
1278 }
1279 
1280 
1283 new_atp(tp_space& xvector_space, int xp)
1284 {
1285  // Preconditions:
1286 
1287  require(xvector_space.state_is_read_accessible());
1288  require((0 <= xp) && (xp <= 1));
1289 
1290  // Body:
1291 
1292  namespace_poset* lns = xvector_space.name_space();
1293  const string& lvector_space_name = xvector_space.name();
1294 
1295  switch(xp)
1296  {
1297  case 0:
1298  {
1299  const string lname =
1300  create_tensor_space_name(lvector_space_name, "at0");
1301  tp_space& lhost = lns->member_poset<tp_space>(lname, false);
1302  at0* result = new at0(&lhost);
1303  return result;
1304  }
1305 
1306  case 1:
1307  {
1308  const string lname =
1309  create_tensor_space_name(lvector_space_name, "e4");
1310  tp_space& lhost = lns->member_poset<tp_space>(lname, false);
1311  e4* result = new e4(&lhost);
1312  return result;
1313  }
1314 
1315  default:
1316  // Can't get here because of the precondition.
1317  return 0;
1318  }
1319 
1320  // Postconditions:
1321 
1322  ensure(unexecutable("result.p() == xp"));
1323 
1324  // Exit:
1325 }
1326 
1327 
1330 new_stp(tp_space& xvector_space, int xp)
1331 {
1332  // Preconditions:
1333 
1334  require(xvector_space.state_is_read_accessible());
1335  require( xp == 0 );
1336 
1337  // Body:
1338 
1339  return 0;
1340 
1341  // Postconditions:
1342 
1343  ensure(unexecutable("result.p() == xp"));
1344 
1345  // Exit:
1346 
1347 }
1348 
1349 //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
1350 
1353 new_tp(int xp, bool xauto_access) const
1354 {
1355  // Preconditions:
1356 
1357  require(precondition_of(e4::new_tp(vector_space(xauto_access), xp)));
1358 
1359  // Body:
1360 
1361  tp* result = e4::new_tp(vector_space(xauto_access), xp);
1362 
1363  // Postconditions:
1364 
1365  ensure(postcondition_of(e4::new_tp(vector_space(xauto_access), xp)));
1366 
1367  // Exit:
1368 
1369  return result;
1370 }
1371 
1374 new_atp(int xp, bool xauto_access) const
1375 {
1376  // Preconditions:
1377 
1378  require(precondition_of(e4::new_atp(vector_space(xauto_access), xp)));
1379 
1380  // Body:
1381 
1382  atp* result = e4::new_atp(vector_space(xauto_access), xp);
1383 
1384  // Postconditions:
1385 
1386  ensure(postcondition_of(e4::new_atp(vector_space(xauto_access), xp)));
1387 
1388  // Exit:
1389 
1390  return result;
1391 }
1392 
1395 new_stp(int xp, bool xauto_access) const
1396 {
1397  // Preconditions:
1398 
1399  require(precondition_of(e4::new_stp(vector_space(xauto_access), xp)));
1400 
1401  // Body:
1402 
1403  stp* result = e4::new_stp(vector_space(xauto_access), xp);
1404 
1405  // Postconditions:
1406 
1407  ensure(postcondition_of(e4::new_stp(vector_space(xauto_access), xp)));
1408 
1409  // Exit:
1410 
1411  return result;
1412 }
1413 
1414 // PROTECTED MEMBER FUNCTIONS
1415 
1416 // PRIVATE MEMBER FUNCTIONS
1417 
1418 
1419 //==============================================================================
1420 // ABSTRACT POSET MEMBER FACET OF CLASS E4
1421 //==============================================================================
1422 
1423 // PUBLIC MEMBER FUNCTIONS
1424 
1425 const std::string&
1427 class_name() const
1428 {
1429  // Preconditions:
1430 
1431  // Body:
1432 
1433  const string& result = static_class_name();
1434 
1435  // Postconditions:
1436 
1437  ensure(!result.empty());
1438 
1439  // Exit:
1440 
1441  return result;
1442 }
1443 
1444 const std::string&
1447 {
1448  // Preconditions:
1449 
1450  // Body:
1451 
1452  static const string result("e4");
1453 
1454  // Postconditions:
1455 
1456  ensure(!result.empty());
1457 
1458  // Exit:
1459 
1460  return result;
1461 }
1462 
1465 clone() const
1466 {
1467 
1468  // Preconditions:
1469 
1470  // Body:
1471 
1472  // Create new handle of the current class.
1473 
1474  e4* result = new e4();
1475 
1476  // Postconditions:
1477 
1478  ensure(result != 0);
1479  ensure(result->invariant());
1480 
1481  // Exit:
1482 
1483  return result;
1484 
1485 }
1486 
1487 // PROTECTED MEMBER FUNCTIONS
1488 
1489 // PRIVATE MEMBER FUNCTIONS
1490 
1491 
1492 //==============================================================================
1493 // ANY FACET OF CLASS E4
1494 //==============================================================================
1495 
1496 // PUBLIC MEMBER FUNCTIONS
1497 
1498 bool
1500 is_ancestor_of(const any* xother) const
1501 {
1502 
1503  // Preconditions:
1504 
1505  require(xother != 0);
1506 
1507  // Body:
1508 
1509  // If other may be dynamically cast to the type of this then this is an
1510  // ancestor of other.
1511 
1512  bool result = dynamic_cast<const e4*>(xother) != 0;
1513 
1514  // Postconditions:
1515 
1516  // ensure(invariant());
1517 
1518  // Exit:
1519 
1520  return result;
1521 
1522 }
1523 
1524 bool
1526 invariant() const
1527 {
1528  bool result = true;
1529 
1530  // Preconditions:
1531 
1532  // Body:
1533 
1534  // Must satisfy base class invariant.
1535 
1536  invariance(ed::invariant());
1537 
1538  if(invariant_check())
1539  {
1540  // Prevent recursive calls to invariant.
1541 
1542  disable_invariant_check();
1543 
1544  invariance((is_attached() ? d() == 4 : true));
1545 
1546  // Finished, turn invariant checking back on.
1547 
1548  enable_invariant_check();
1549  }
1550 
1551  // Postconditions:
1552 
1553  ensure(is_derived_query);
1554 
1555  // Exit:
1556 
1557  return result;
1558 }
1559 
1560 // PROTECTED MEMBER FUNCTIONS
1561 
1562 // PRIVATE MEMBER FUNCTIONS
1563 
1564 
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...
virtual e4_lite * clone() const
Virtual constructor, makes a new instance of the same type as this.
Definition: e4.cc:557
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 ...
~e4()
Destructor.
Definition: e4.cc:1062
e4()
Default constructor.
Definition: e4.cc:836
virtual void put_components(dof_type x0, dof_type x1, dof_type x2, dof_type x3)
Set values of the components to the given arguments.
Definition: e4.cc:1164
A symmetric tensor of degree p over an abstract vector space.
Definition: stp.h:190
vd_value_type value_type
The type of component in the fiber; the scalar type in the fiber vector space.
Definition: vd.h:129
bool full() const
True if both poset name and member name are not empty.
Definition: poset_path.cc:311
static const std::string & static_class_name()
The name of this class.
Definition: e4.cc:1446
An antisymmetric tensor of degree p.
Definition: atp.h:190
Euclidean vector space of dimension 4 (persistent version).
Definition: e4.h:410
virtual volatile_type * lite_type() const
Virtual conversion to the associated volatile type.
Definition: e4.cc:1091
static int d(const namespace_poset &xns, int xp, const poset_path &xvector_space_path, bool xauto_access)
The tensor dimension implied by tensor degree xp and the dimension of the domain vector space specifi...
Definition: atp_space.cc:86
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...
poset_path vector_space_path() const
The path of the underlying vector space.
Definition: tp_space.cc:365
A general antisymmetric tensor of degree 1 over an abstract vector space (volatile version)...
Definition: at1.h:44
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...
A client handle for a general, abstract partially order set.
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
virtual const volatile_type & lite_prototype() const
Virtual constructor for the associated volatile type.
Definition: e4.cc:1073
STL namespace.
static atp * new_atp(tp_space &xvector_space, int xp)
Static prototype for antisymmetric tensors of degree xp over this vector space.
Definition: e4.cc:1283
bool is_ancestor_of(const any *xother) const
True if other conforms to current.
Definition: e4.cc:1500
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.
T::row_dofs_type & row_dofs(T &x0)
The row dofs pod type for x0 (mutable version).
static const poset_path & standard_schema_path()
The path to the standard schema for this class.
Definition: e4.cc:666
An antisymmetric tensor of degree p over an abstract vector space (volatile version).
Definition: atp.h:44
A general tensor of "degree" p and given "variance" over an abstract vector space.
Definition: tp.h:253
Abstract base class with useful features for all volatile objects.
Definition: any_lite.h:48
Abstract base class with useful features for all objects.
Definition: any.h:39
static host_type & new_host(namespace_type &xns, const poset_path &xhost_path, const poset_path &xschema_path, const poset_path &xscalar_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: e4.cc:718
T components[4]
The components (row_dofs).
Definition: e4.h:96
virtual const atp_lite & atp_prototype(int xp) const
Prototype for antisymmetric tensors of degree xp over this vector space.
Definition: e4.cc:435
virtual schema_poset_member & schema()
The schema for this poset (mutable version).
e4_lite()
Default constructor.
Definition: e4.cc:49
bool operator==(const e4_lite &xother) const
True if this has the same components as xother.
Definition: e4.cc:304
A space of scalars viewed as an antisymmetric tensor space of degree 0.
Definition: at0_space.h:42
e4 & operator=(const row_dofs_type &xrdt)
Assignment to an instance of the associated row dofs type.
Definition: e4.cc:996
static const stp_lite & static_stp_prototype(int xp)
Static prototype for symmetric tensors of degree xp over this vector space.
Definition: e4.cc:456
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...
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)
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
virtual void * row_dofs()
The row dofs for this instance (mutable version).
Definition: e4.cc:637
bool invariant() const
Class invariant.
Definition: e4.cc:1526
A scalar viewed as an antisymmetric tensor of degree 0. As the degree is 0 there is nothing to be sym...
Definition: at0.h:424
bool contains_path(const poset_path &xpath, bool xauto_access=true) const
True if this contains the poset or poset member specified by xpath.
Antisymetric tensor of degree 0 (volatile version).
Definition: at0.h:127
static void make_standard_schema(namespace_poset &xns)
Creates the standard schema for this class in namespace xns.
Definition: e4.cc:684
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. ...
int p(int xd, int xdd) const
Tensor degree as a function of tensor dimension xd and domain dimension xdd.
Definition: tp_space.cc:235
virtual ~e4_lite()
Destructor.
Definition: e4.cc:104
static const atp_lite & static_atp_prototype(int xp)
Static prototype for antisymmetric tensors of degree xp over this vector space.
Definition: e4.cc:398
Euclidean vector space of dimension 4 (volatile version).
Definition: e4.h:111
virtual std::string name() const
The name of this poset.
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...
e4_lite & operator=(const e4_lite &xother)
Assignment operator.
Definition: e4.cc:81
A general tensor of degree p over an abstract vector space (volatile version). Volatile version does ...
Definition: tp.h:59
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 path_is_auto_read_available(const poset_path &xpath, bool xauto_access) const
True if the state referred to xpath does not exist or exists and is auto read accessible.
row_dofs_type _row_dofs
Row_dofs_type.
Definition: e4.h:193
poset_path scalar_space_path() const
The path of the underlying space of scalars.
Definition: vd_space.cc:250
virtual const tp_lite & tp_prototype(int xp) const
Prototype for general tensors of degree xp over this vector space.
Definition: e4.cc:377
namespace_poset * name_space() const
The namespace this poset resides in.
virtual int dd() const
Dimension of the underlying vector space.
Definition: e4.cc:284
An abstract vector space viewed as an antisymmetric tensor space of degree 1.
Definition: at1_space.h:42
static stp * new_stp(tp_space &xvector_space, int xp)
Static prototype for symmetric tensors of degree xp over this vector space.
Definition: e4.cc:1330
static int factor_ct(int xd)
Factor_ct() as a function of dimension xd.
Definition: vd_space.cc:167
virtual bool is_ancestor_of(const any_lite &xother) const
Conformance test; true if other conforms to this.
Definition: e4.cc:590
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
int dd() const
The dimension of the underlying ("domain") vector space.
Definition: tp_space.cc:317
virtual e4 * clone() const
Make a new handle, no state instance of current.
Definition: e4.cc:1465
bool invariant() const
Class invariant.
Definition: e4.cc:609
virtual const std::string & class_name() const
The name of this class.
Definition: e4.cc:1427
virtual void put_components(const value_type &x0, const value_type &x1, const value_type &x2, const value_type &x3)
Set values of the components to the given arguments.
Definition: e4.cc:212
static tp * new_tp(tp_space &xvector_space, int xp)
Static prototype for general tensors of degree xp over this vector space.
Definition: e4.cc:1235
An abstract client handle for a member of a poset.
static const tp_lite & static_tp_prototype(int xp)
Static prototype for general tensors of degree xp over this vector space.
Definition: e4.cc:340
static const std::string & static_class_name()
The name of this class.
Definition: e4.cc:538
std::string path() const
The full path as a string.
Definition: poset_path.cc:450
vd_dof_type dof_type
The type of the degrees of freedom. Note that although dof_type == value_type in this implementation...
Definition: vd.h:431
static host_type & standard_host(namespace_type &xns, const std::string &xsuffix, bool xauto_access)
The host with path standard_host_path<e4>(xsuffix). Returns the host if it already exists...
Definition: e4.cc:768
An abstract tensor space of degree p.
Definition: tp_space.h:47
A symmetric tensor of degree p over an abstract vector space (volatile version).
Definition: stp.h:44
Namespace for the fiber_bundles component of the sheaf system.
virtual const stp_lite & stp_prototype(int xp) const
Prototype for symmetric tensors of degree xp over this vector space.
Definition: e4.cc:476
bool state_is_not_read_accessible() const
True if this is attached and if the state is accessible for read or if access control is disabled...
virtual const std::string & class_name() const
The name of this class.
Definition: e4.cc:519
A client handle for a poset member which has been prepared for use as a schema.
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.
Definition: scoped_index.h:710
SHEAF_DLL_SPEC bool isunordered_or_equals(float x1, float x2)
True if isunordered(x1, x2) or x1 == x2.
Definition: sheaf.cc:102