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