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