SheafSystem  0.0.0.0
t4_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/t4_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/wsv_block.h"
30 
31 #include "SheafSystem/tp_space.h"
32 #include "SheafSystem/std_sstream.h"
33 
34 using namespace std;
35 using namespace fiber_bundle; // Workaround for MS C++ bug.
36 
37 
38 //==============================================================================
39 // CLASS T4_E3_LITE
40 //==============================================================================
41 
42 //==============================================================================
43 // T4_E3 FACET OF CLASS T4_E3_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 t4_e3_lite(const t4_e3_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 t4_e3_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_for_all(i, 0, d(), component(i) == xother[i]);
97 
98  // Exit:
99 
100  return *this;
101 }
102 
105 {
106  // Preconditions:
107 
108  // Body:
109 
110  // Postconditions:
111 
112  // Exit:
113 
114 }
115 
117 t4_e3_lite(const row_dofs_type& xrow_dofs)
118 {
119  // Preconditions:
120 
121  // Body:
122 
123  *this = xrow_dofs;
124 
125  // Postconditions:
126 
127  ensure(invariant());
128 
129  // Exit:
130 }
131 
134 operator=(const row_dofs_type& xrow_dofs)
135 {
136  // Preconditions:
137 
138  // Body:
139 
140  _row_dofs = xrow_dofs;
141 
142  // Postconditions:
143 
144  ensure(invariant());
145 
146  // Exit:
147 
148  return *this;
149 
150 }
151 
152 fiber_bundle::t4_e3_lite::
154 {
155  // Preconditions:
156 
157  // Body:
158 
159  row_dofs_type& result = _row_dofs;
160 
161  // Postconditions:
162 
163  // Exit:
164 
165  return result;
166 }
167 
168 fiber_bundle::t4_e3_lite::
169 operator const t4_e3_lite::row_dofs_type& () const
170 {
171  // Preconditions:
172 
173  // Body:
174 
175  const row_dofs_type& result = _row_dofs;
176 
177  // Postconditions:
178 
179  // Exit:
180 
181  return result;
182 }
183 
184 // PROTECTED MEMBER FUNCTIONS
185 
186 // PRIVATE MEMBER FUNCTIONS
187 
188 
189 //==============================================================================
190 // T4 FACET OF CLASS T4_E3_LITE
191 //==============================================================================
192 
193 // PUBLIC MEMBER FUNCTIONS
194 
195 // PROTECTED MEMBER FUNCTIONS
196 
197 // PRIVATE MEMBER FUNCTIONS
198 
199 
200 //==============================================================================
201 // TENSOR ALGEBRA (TP) FACET OF CLASS T4_E3_LITE
202 //==============================================================================
203 
204 // PUBLIC MEMBER FUNCTIONS
205 
206 int
208 dd() const
209 {
210  // Preconditions:
211 
212  // Body:
213 
214  int result = 3;
215 
216  // Postconditions:
217 
218  ensure(invariant());
219  ensure(result == 3);
220 
221  // Exit:
222 
223  return result;
224 }
225 
226 // PROTECTED MEMBER FUNCTIONS
227 
228 // PRIVATE MEMBER FUNCTIONS
229 
230 
231 //==============================================================================
232 // VECTOR ALGEBRA (VD) FACET OF CLASS T4_E3_LITE
233 //==============================================================================
234 
235 // PUBLIC MEMBER FUNCTIONS
236 
239 tp_prototype(int xp) const
240 {
241  // Preconditions:
242 
243  require(precondition_of(e3_lite::static_tp_prototype(xp)));
244 
245  // Body:
246 
247  const tp_lite& result = e3_lite::static_tp_prototype(xp);
248 
249  // Postconditions:
250 
251  ensure(postcondition_of(e3_lite::static_tp_prototype(xp)));
252 
253  // Exit:
254 
255  return result;
256 }
257 
260 atp_prototype(int xp) const
261 {
262  // Preconditions:
263 
264  require(precondition_of(e3_lite::static_atp_prototype(xp)));
265 
266  // Body:
267 
268  const atp_lite& result = e3_lite::static_atp_prototype(xp);
269 
270  // Postconditions:
271 
272  ensure(postcondition_of(e3_lite::static_atp_prototype(xp)));
273 
274  // Exit:
275 
276  return result;
277 }
278 
281 stp_prototype(int xp) const
282 {
283  // Preconditions:
284 
285  require(precondition_of(e3_lite::static_stp_prototype(xp)));
286 
287  // Body:
288 
289  const stp_lite& result = e3_lite::static_stp_prototype(xp);
290 
291  // Postconditions:
292 
293  ensure(postcondition_of(e3_lite::static_stp_prototype(xp)));
294 
295  // Exit:
296 
297  return result;
298 }
299 
300 // PROTECTED MEMBER FUNCTIONS
301 
302 // PRIVATE MEMBER FUNCTIONS
303 
304 
305 //==============================================================================
306 // CARTESIAN ALGEBRA (TUPLE) FACET OF CLASS T4_E3_LITE
307 //==============================================================================
308 
309 // PUBLIC MEMBER FUNCTIONS
310 
311 // PROTECTED MEMBER FUNCTIONS
312 
313 // PRIVATE MEMBER FUNCTIONS
314 
315 
316 //==============================================================================
317 // ABSTRACT POSET MEMBER FACET OF CLASS T4_E3_LITE
318 //==============================================================================
319 
320 // PUBLIC MEMBER FUNCTIONS
321 
322 const std::string&
324 class_name() const
325 {
326  // Preconditions:
327 
328  // Body:
329 
330  const string& result = static_class_name();
331 
332  // Postconditions:
333 
334  ensure(!result.empty());
335 
336  // Exit:
337 
338  return result;
339 }
340 
341 const std::string&
344 {
345  // Preconditions:
346 
347  // Body:
348 
349  static const string result("t4_e3_lite");
350 
351  // Postconditions:
352 
353  ensure(!result.empty());
354 
355  // Exit:
356 
357  return result;
358 }
359 
362 clone() const
363 {
364  t4_e3_lite* result = 0;
365 
366  // Preconditions:
367 
368  // Body:
369 
370  result = new t4_e3_lite();
371 
372  // Postconditions:
373 
374  ensure(result != 0);
375  ensure(is_same_type(*result));
376 
377  // Exit:
378 
379  return result;
380 }
381 
382 // PROTECTED MEMBER FUNCTIONS
383 
384 // PRIVATE MEMBER FUNCTIONS
385 
386 
387 //==============================================================================
388 // ANY FACET OF CLASS T4_E3_LITE
389 //==============================================================================
390 
391 // PUBLIC MEMBER FUNCTIONS
392 
393 bool
395 is_ancestor_of(const any_lite& xother) const
396 {
397  // Preconditions:
398 
399  require(&xother != 0);
400 
401  // Body:
402 
403  // True if other conforms to this.
404 
405  bool result = dynamic_cast<const t4_e3_lite*>(&xother) != 0;
406 
407  // Postconditions:
408 
409  return result;
410 }
411 
412 bool
414 invariant() const
415 {
416  bool result = true;
417 
418  if(invariant_check())
419  {
420  // Prevent recursive calls to invariant.
421 
422  disable_invariant_check();
423 
424  // Must satisfy base class invariant.
425 
426  invariance(t4_lite::invariant());
427 
428  // Invariances for this class:
429 
430  // Finished, turn invariant checking back on.
431 
432  enable_invariant_check();
433  }
434 
435  // Exit
436 
437  return result;
438 }
439 
440 void*
443 {
444  return &_row_dofs;
445 }
446 
447 const void*
449 row_dofs() const
450 {
451  return &_row_dofs;
452 }
453 
454 // PROTECTED MEMBER FUNCTIONS
455 
456 // PRIVATE MEMBER FUNCTIONS
457 
458 
459 //==============================================================================
460 // CLASS T4_E3
461 //==============================================================================
462 
463 // ===========================================================
464 // HOST FACTORY FACET OF CLASS T4_E3
465 // ===========================================================
466 
467 // PUBLIC MEMBER FUNCTIONS
468 
469 const sheaf::poset_path&
472 {
473  // Preconditions:
474 
475 
476  // Body:
477 
478  static const poset_path result(standard_schema_poset_name(), "t4_e3_schema");
479 
480  // Postconditions:
481 
482  // Exit:
483 
484  return result;
485 }
486 
487 void
490 {
491  // Preconditions:
492 
493  require(xns.state_is_read_write_accessible());
494  require(xns.contains_poset(standard_schema_poset_name()));
495  require(!xns.contains_poset_member(standard_schema_path()));
496 
497  // Body:
498 
499  string lcomp_names[81] = {
500  "xxxx","xxxy","xxxz","xxyx","xxyy","xxyz","xxzx","xxzy","xxzz",
501  "xyxx","xyxy","xyxz","xyyx","xyyy","xyyz","xyzx","xyzy","xyzz",
502  "xzxx","xzxy","xzxz","xzyx","xzyy","xzyz","xzzx","xzzy","xzzz",
503  "yxxx","yxxy","yxxz","yxyx","yxyy","yxyz","yxzx","yxzy","yxzz",
504  "yyxx","yyxy","yyxz","yyyx","yyyy","yyyz","yyzx","yyzy","yyzz",
505  "yzxx","yzxy","yzxz","yzyx","yzyy","yzyz","yzzx","yzzy","yzzz",
506  "zxxx","zxxy","zxxz","zxyx","zxyy","zxyz","zxzx","zxzy","zxzz",
507  "zyxx","zyxy","zyxz","zyyx","zyyy","zyyz","zyzx","zyzy","zyzz",
508  "zzxx","zzxy","zzxz","zzyx","zzyy","zzyz","zzzx","zzzy","zzzz"};
509 
510  ostringstream los;
511  for(int i=0; i<81; ++i)
512  {
513  los << lcomp_names[i] << " DOUBLE false ";
514  }
515 
516  string lmember_names = los.str();
517 
518  schema_poset_member lschema(xns,
519  standard_schema_path().member_name(),
520  t4::standard_schema_path(),
521  lmember_names,
522  false);
523 
524  lschema.detach_from_state();
525 
526  // Postconditions:
527 
528  ensure(xns.contains_poset_member(standard_schema_path()));
529 
530  // Exit:
531 
532  return;
533 }
534 
538  const poset_path& xhost_path,
539  const poset_path& xschema_path,
540  const poset_path& xvector_space_path,
541  bool xauto_access)
542 {
543  // cout << endl << "Entering t4_e3::new_host." << endl;
544 
545  // Preconditions:
546 
547  require(xns.state_is_auto_read_write_accessible(xauto_access));
548 
549  require(!xhost_path.empty());
550  require(!xns.contains_path(xhost_path, xauto_access));
551 
552  require(xschema_path.full());
553  require(xns.path_is_auto_read_accessible(xschema_path, xauto_access));
554  require(schema_poset_member::conforms_to(xns, xschema_path, standard_schema_path()));
555  require(schema_poset_member::row_dof_ct(xns, xschema_path, xauto_access) == 81);
556 
557  require(xns.path_is_auto_read_accessible(xvector_space_path, xauto_access));
558  require(xns.contains_poset<vector_space_type::host_type>(xvector_space_path, xauto_access));
559  require(xns.member_poset(xvector_space_path, xauto_access).schema(xauto_access).conforms_to(vector_space_type::standard_schema_path()));
560  require(xns.member_poset<vector_space_type::host_type>(xvector_space_path, xauto_access).d(xauto_access) == 3);
561 
562  require(host_type::d(xns, xschema_path, xauto_access) == host_type::d(xns, 4, xvector_space_path, xauto_access));
563 
564  // Body:
565 
566  host_type& result =
567  host_type::new_table(xns, xhost_path, xschema_path, 4, xvector_space_path, xauto_access);
568 
569  // Postconditions:
570 
571  ensure(xns.owns(result, xauto_access));
572  ensure(result.path(true) == xhost_path);
573  ensure(result.state_is_not_read_accessible());
574  ensure(result.schema(true).path(xauto_access) == xschema_path);
575 
576  ensure(result.factor_ct(true) == 81);
577  ensure(result.d(true) == 81);
578  ensure(result.scalar_space_path(true) == xns.member_poset<vector_space_type::host_type>(xvector_space_path, xauto_access).scalar_space_path());
579  ensure(result.p(true) == 4);
580  ensure(result.dd(true) == 3);
581  ensure(result.vector_space_path(true) == xvector_space_path);
582 
583  // Exit:
584 
585  // cout << "Leaving t4_e3::new_host." << endl;
586  return result;
587 }
588 
591 standard_host(namespace_type& xns, const std::string& xsuffix, bool xauto_access)
592 {
593  // cout << endl << "Entering t4_e3::new_host." << endl;
594 
595  // Preconditions:
596 
597  require(xns.state_is_auto_read_write_accessible(xauto_access));
598 
599  require(xsuffix.empty() || poset_path::is_valid_name(xsuffix));
600  require(standard_host_is_available<t4_e3>(xns, xsuffix, xauto_access));
601 
602  require(xns.path_is_auto_read_accessible(standard_schema_path(), xauto_access));
603 
604  require(xns.path_is_auto_read_available(standard_host_path<vector_space_type>(xsuffix), xauto_access));
605 
606  // Body:
607 
608  // Create the vector space if necessary.
609 
610  poset_path lvector_space_path = vector_space_type::standard_host(xns, xsuffix, xauto_access).path(true);
611 
612  poset_path lpath(standard_host_path<t4_e3>(xsuffix));
613 
614  host_type* result_ptr;
615  if(xns.contains_path(lpath, xauto_access))
616  {
617  result_ptr = &xns.member_poset<host_type>(lpath, xauto_access);
618  }
619  else
620  {
621  result_ptr = &new_host(xns, lpath, standard_schema_path(), lvector_space_path, xauto_access);
622  }
623 
624  host_type& result = *result_ptr;
625 
626  // Postconditions:
627 
628  ensure(xns.owns(result, xauto_access));
629  ensure(result.path(true) == standard_host_path<t4_e3>(xsuffix));
630  ensure(result.state_is_not_read_accessible());
631  ensure(result.schema(true).path(xauto_access) == standard_schema_path());
632 
633  ensure(result.factor_ct(true) == 81);
634  ensure(result.d(true) == 81);
635  ensure(result.scalar_space_path(true) == standard_host_path<vector_space_type::scalar_type>(xsuffix) );
636  ensure(result.p(true) == 4);
637  ensure(result.dd(true) == 3);
638  ensure(result.vector_space_path(true) == standard_host_path<vector_space_type>(xsuffix) );
639 
640  // Exit:
641 
642  // cout << "Leaving t4_e3::new_host." << endl;
643  return result;
644 }
645 
646 // PROTECTED MEMBER FUNCTIONS
647 
648 // PRIVATE MEMBER FUNCTIONS
649 
650 
651 //==============================================================================
652 // T4_E3 FACET OF CLASS T4_E3
653 //==============================================================================
654 
655 // PUBLIC MEMBER FUNCTIONS
656 
659 {
660  // Preconditions:
661 
662  // Body:
663 
664  // Postconditions:
665 
666  ensure(invariant());
667 
668  // Exit:
669 
670  return;
671 }
672 
674 t4_e3(const t4_e3& xother)
675 {
676 
677  // Preconditions:
678 
679 
680  // Body:
681 
682  attach_to_state(&xother);
683 
684  // Postconditions:
685 
686  ensure(invariant());
687 
688  // Exit:
689 
690  return;
691 }
692 
697 {
698  // Preconditions:
699 
700  require(is_ancestor_of(&xother));
701  require(precondition_of(attach_to_state(&xother)));
702 
703  // Body:
704 
705  attach_to_state(&xother);
706 
707  // Postconditions:
708 
709  ensure(postcondition_of(attach_to_state(&xother)));
710 
711  // Exit:
712 
713  return *this;
714 }
715 
719 operator=(const t4_e3& xother)
720 {
721  // Preconditions:
722 
723  require(precondition_of(attach_to_state(&xother)));
724 
725  // Body:
726 
727  attach_to_state(&xother);
728 
729  // Postconditions:
730 
731  ensure(postcondition_of(attach_to_state(&xother)));
732 
733  // Exit:
734 
735  return *this;
736 }
737 
740 {
741 
742  // Preconditions:
743 
744  // Body:
745 
746  // Postconditions:
747 
748  // Exit:
749 
750  return;
751 }
752 
756 {
757  // Preconditions:
758 
759  // Body:
760 
761  static const volatile_type result;
762 
763  // Postconditions:
764 
765  // Exit:
766 
767  return result;
768 }
769 
773 lite_type() const
774 {
775  // Preconditions:
776 
777  // Body:
778 
779  volatile_type* result = new volatile_type(sheaf::row_dofs(*this));
780 
781  // Postconditions:
782 
783  // Exit:
784 
785  return result;
786 }
787 
788 
790 t4_e3(poset* xhost, bool xauto_access)
791 {
792 
793  // Preconditions:
794 
795  require(precondition_of(new_jim_state(xhost, 0, false, xauto_access)));
796 
797  // Body:
798 
799  new_jim_state(xhost, 0, false, xauto_access);
800 
801  // Postconditions:
802 
803  ensure(postcondition_of(new_jim_state(xhost, 0, false, xauto_access)));
804 
805  // Exit:
806 
807  return;
808 }
809 
812  const row_dofs_type& xrdt,
813  bool xauto_access)
814 {
815 
816  // Preconditions:
817 
818  require(precondition_of(new_jim_state(&xhost, 0, false, xauto_access)));
819 
820  // Body:
821 
822  new_jim_state(&xhost, 0, false, xauto_access);
823 
824  if(xauto_access)
825  {
826  xhost.get_read_write_access();
827  }
828 
829  *this = xrdt;
830 
831  if(xauto_access)
832  {
833  xhost.release_access();
834  }
835 
836  // Postconditions:
837 
838  ensure(postcondition_of(new_jim_state(&xhost, 0, false, xauto_access)));
839 
840  // Exit:
841 
842  return;
843 }
844 
848 {
849  // Preconditions:
850 
851  require(state_is_read_write_accessible());
852 
853  // Body:
854 
855  sheaf::row_dofs(*this) = xrdt;
856 
857  // Postconditions:
858 
859  ensure_for_all(i, 0, d(), component(i) == xrdt.components[i]);
860 
861  // Exit:
862 
863  return *this;
864 
865 }
866 
868 t4_e3(const poset* xhost, pod_index_type xhub_id)
869 {
870  // Preconditions:
871 
872  require(xhost != 0);
873  require(xhost->state_is_read_accessible());
874  require(xhost->contains_member(xhub_id));
875 
876  // Body:
877 
878  attach_to_state(xhost, xhub_id);
879 
880  // Postconditions:
881 
882  ensure(invariant());
883  ensure(is_attached());
884  // ensure(host() == xhost);
885  ensure(index() == xhub_id);
886 }
887 
889 t4_e3(const poset* xhost, const scoped_index& xid)
890 {
891  // Preconditions:
892 
893  require(xhost != 0);
894  require(xhost->state_is_read_accessible());
895  require(xhost->contains_member(xid));
896 
897  // Body:
898 
899  attach_to_state(xhost, xid.hub_pod());
900 
901  // Postconditions:
902 
903  ensure(invariant());
904  ensure(is_attached());
905  // ensure(host() == xhost);
906  ensure(index() ==~ xid);
907 }
908 
910 t4_e3(const poset* xhost, const std::string& xname)
911 {
912 
913  // Preconditions:
914 
915  require(xhost != 0);
916  require(xhost->state_is_read_accessible());
917  require(!xname.empty());
918  require(xhost->contains_member(xname));
919 
920  // Body:
921 
922  attach_to_state(xhost, xname);
923 
924  // Postconditions:
925 
926  ensure(invariant());
927  ensure(is_attached());
928  // ensure(host() == xhost);
929  ensure(name() == xname);
930 
931 }
932 
933 fiber_bundle::t4_e3::
935 {
936  // Preconditions:
937 
938  require(state_is_read_write_accessible());
939 
940  // Body:
941 
942  row_dofs_type& result = sheaf::row_dofs(*this);
943 
944  // Postconditions:
945 
946  // Exit:
947 
948  return result;
949 }
950 
951 fiber_bundle::t4_e3::
952 operator const t4_e3::row_dofs_type& () const
953 {
954  // Preconditions:
955 
956  require(state_is_read_accessible());
957 
958  // Body:
959 
960  const row_dofs_type& result = sheaf::row_dofs(*this);
961 
962  // Postconditions:
963 
964  // Exit:
965 
966  return result;
967 }
968 
969 // PROTECTED MEMBER FUNCTIONS
970 
971 // PRIVATE MEMBER FUNCTIONS
972 
973 
974 //==============================================================================
975 // T4 FACET OF CLASS T4_E3
976 //==============================================================================
977 
978 // PUBLIC MEMBER FUNCTIONS
979 
980 // PROTECTED MEMBER FUNCTIONS
981 
982 // PRIVATE MEMBER FUNCTIONS
983 
984 
985 //==============================================================================
986 // TP FACET OF CLASS T4_E3
987 //==============================================================================
988 
989 // PUBLIC MEMBER FUNCTIONS
990 
991 // PROTECTED MEMBER FUNCTIONS
992 
993 // PRIVATE MEMBER FUNCTIONS
994 
995 
996 //==============================================================================
997 // VD FACET OF CLASS T4_E3
998 //==============================================================================
999 
1000 // PUBLIC MEMBER FUNCTIONS
1001 
1002 // PROTECTED MEMBER FUNCTIONS
1003 
1004 // PRIVATE MEMBER FUNCTIONS
1005 
1006 
1007 //==============================================================================
1008 // TUPLE FACET OF CLASS T4_E3
1009 //==============================================================================
1010 
1011 // PUBLIC MEMBER FUNCTIONS
1012 
1015 new_tp(int xp, bool xauto_access) const
1016 {
1017  // Preconditions:
1018 
1019  require(precondition_of(e3::new_tp(vector_space(xauto_access), xp)));
1020 
1021  // Body:
1022 
1023  tp* result = e3::new_tp(vector_space(xauto_access), xp);
1024 
1025  // Postconditions:
1026 
1027  ensure(postcondition_of(e3::new_tp(vector_space(xauto_access), xp)));
1028 
1029  // Exit:
1030 
1031  return result;
1032 }
1033 
1036 new_atp(int xp, bool xauto_access) const
1037 {
1038  // Preconditions:
1039 
1040  require(precondition_of(e3::new_atp(vector_space(xauto_access), xp)));
1041 
1042  // Body:
1043 
1044  atp* result = e3::new_atp(vector_space(xauto_access), xp);
1045 
1046  // Postconditions:
1047 
1048  ensure(postcondition_of(e3::new_atp(vector_space(xauto_access), xp)));
1049 
1050  // Exit:
1051 
1052  return result;
1053 }
1054 
1057 new_stp(int xp, bool xauto_access) const
1058 {
1059  // Preconditions:
1060 
1061  require(precondition_of(e3::new_stp(vector_space(xauto_access), xp)));
1062 
1063  // Body:
1064 
1065  stp* result = e3::new_stp(vector_space(xauto_access), xp);
1066 
1067  // Postconditions:
1068 
1069  ensure(postcondition_of(e3::new_stp(vector_space(xauto_access), xp)));
1070 
1071  // Exit:
1072 
1073  return result;
1074 }
1075 
1076 // PROTECTED MEMBER FUNCTIONS
1077 
1078 // PRIVATE MEMBER FUNCTIONS
1079 
1080 
1081 //==============================================================================
1082 // ABSTRACT POSET MEMBER FACET OF CLASS T4_E3
1083 //==============================================================================
1084 
1085 // PUBLIC MEMBER FUNCTIONS
1086 
1087 const std::string&
1089 class_name() const
1090 {
1091  // Preconditions:
1092 
1093  // Body:
1094 
1095  const string& result = static_class_name();
1096 
1097  // Postconditions:
1098 
1099  ensure(!result.empty());
1100 
1101  // Exit:
1102 
1103  return result;
1104 }
1105 
1106 const std::string&
1109 {
1110  // Preconditions:
1111 
1112  // Body:
1113 
1114  static const string result("t4_e3");
1115 
1116  // Postconditions:
1117 
1118  ensure(!result.empty());
1119 
1120  // Exit:
1121 
1122  return result;
1123 }
1124 
1127 clone() const
1128 {
1129 
1130  // Preconditions:
1131 
1132  // Body:
1133 
1134  // Create new handle of the current class.
1135 
1136  t4_e3 *result = new t4_e3();
1137 
1138  // Postconditions:
1139 
1140  ensure(result != 0);
1141  ensure(result->invariant());
1142 
1143  // Exit:
1144 
1145  return result;
1146 
1147 }
1148 
1149 // PROTECTED MEMBER FUNCTIONS
1150 
1151 // PRIVATE MEMBER FUNCTIONS
1152 
1153 
1154 //==============================================================================
1155 // ANY FACET OF CLASS T4_E3
1156 //==============================================================================
1157 
1158 // PUBLIC MEMBER FUNCTIONS
1159 
1160 
1161 bool
1163 invariant() const
1164 {
1165  bool result = true;
1166 
1167  // Body:
1168 
1169  if(invariant_check())
1170  {
1171  // Prevent recursive calls to invariant.
1172 
1173  disable_invariant_check();
1174 
1175  // Must satisfy base class invariant.
1176 
1177  invariance(t4::invariant());
1178 
1179  // Invariances for this class:
1180 
1181  invariance(state_is_read_accessible() ? dd() == 3 : true);
1182 
1183  // Finished, turn invariant checking back on.
1184 
1185  enable_invariant_check();
1186  }
1187 
1188  // Exit:
1189 
1190  return result;
1191 }
1192 
1193 bool
1195 is_ancestor_of(const any* xother) const
1196 {
1197  // Preconditions:
1198 
1199  require(xother != 0);
1200 
1201  // Body:
1202 
1203  // True if xother conforms to this.
1204 
1205  bool result = dynamic_cast<const t4_e3*>(xother) != 0;
1206 
1207  // Postconditions:
1208 
1209  ensure(invariant());
1210 
1211  // Exit:
1212 
1213  return result;
1214 
1215 }
1216 
1217 // PROTECTED MEMBER FUNCTIONS
1218 
1219 // PRIVATE MEMBER FUNCTIONS
1220 
1221 
1222 //==============================================================================
1223 // NON-MEMBER FUNCTIONS
1224 //==============================================================================
1225 
1226 #include "SheafSystem/st4_e3.h"
1227 
1228 void
1230 sym(const t4_e3_lite& x0, st4_e3_lite& xresult)
1231 {
1232  // Preconditions:
1233 
1234  // Body:
1235 
1236  //@todo Implement a more efficient version using knowledge
1237  // about the components.
1238 
1239  int ldd = x0.dd();
1240 
1241  for(int i=0; i<ldd; ++i)
1242  {
1243  for(int j=i; j<ldd; ++j)
1244  {
1245  for(int k=j; k<ldd; ++k)
1246  {
1247  for(int l=k; l<ldd; ++l)
1248  {
1249  vd_value_type lvalue = x0.component(i,j,k,l)
1250  + x0.component(i,j,l,k)
1251  + x0.component(i,k,j,l)
1252  + x0.component(i,l,j,k)
1253  + x0.component(i,k,l,j)
1254  + x0.component(i,l,k,j)
1255  + x0.component(j,i,k,l)
1256  + x0.component(j,i,l,k)
1257  + x0.component(k,i,j,l)
1258  + x0.component(l,i,j,k)
1259  + x0.component(k,i,l,j)
1260  + x0.component(l,i,k,j)
1261  + x0.component(j,k,i,l)
1262  + x0.component(j,l,i,k)
1263  + x0.component(k,j,i,l)
1264  + x0.component(l,j,i,k)
1265  + x0.component(k,l,i,j)
1266  + x0.component(l,k,i,j)
1267  + x0.component(j,k,l,i)
1268  + x0.component(j,l,k,i)
1269  + x0.component(k,j,l,i)
1270  + x0.component(l,j,k,i)
1271  + x0.component(k,l,j,i)
1272  + x0.component(l,k,j,i);
1273 
1274  lvalue /= 24.0; // 4!
1275  xresult.put_component(i, j, k, l, lvalue);
1276  }
1277  }
1278  }
1279  }
1280 
1281  // Postconditions:
1282 
1283  ensure(unexecutable("xresult is equal to the symmetric part of x0"));
1284 
1285  // Exit:
1286 
1287  return;
1288 }
1289 
1290 void
1292 sym(const t4_e3& x0, st4_e3& xresult, bool xauto_access)
1293 {
1294  // Preconditions:
1295 
1296  require(x0.state_is_auto_read_accessible(xauto_access));
1297  require(xresult.state_is_auto_read_accessible(xauto_access));
1298  require(!x0.variance(xauto_access).is_mixed());
1299 
1300  // Body:
1301 
1302  if(xauto_access)
1303  {
1304  x0.get_read_access();
1305  xresult.get_read_write_access(true);
1306  }
1307 
1308  int ldd = x0.dd();
1309 
1310  for(int i=0; i<ldd; ++i)
1311  {
1312  for(int j=i; j<ldd; ++j)
1313  {
1314  for(int k=j; k<ldd; ++k)
1315  {
1316  for(int l=k; l<ldd; ++l)
1317  {
1318  vd_value_type lvalue = x0.component(i,j,k,l)
1319  + x0.component(i,j,l,k)
1320  + x0.component(i,k,j,l)
1321  + x0.component(i,l,j,k)
1322  + x0.component(i,k,l,j)
1323  + x0.component(i,l,k,j)
1324  + x0.component(j,i,k,l)
1325  + x0.component(j,i,l,k)
1326  + x0.component(k,i,j,l)
1327  + x0.component(l,i,j,k)
1328  + x0.component(k,i,l,j)
1329  + x0.component(l,i,k,j)
1330  + x0.component(j,k,i,l)
1331  + x0.component(j,l,i,k)
1332  + x0.component(k,j,i,l)
1333  + x0.component(l,j,i,k)
1334  + x0.component(k,l,i,j)
1335  + x0.component(l,k,i,j)
1336  + x0.component(j,k,l,i)
1337  + x0.component(j,l,k,i)
1338  + x0.component(k,j,l,i)
1339  + x0.component(l,j,k,i)
1340  + x0.component(k,l,j,i)
1341  + x0.component(l,k,j,i);
1342 
1343  lvalue /= 24.0; // 4!
1344  xresult.put_component(i, j, k, l, lvalue);
1345  }
1346  }
1347  }
1348  }
1349 
1350  // Set the variance of the result.
1351  // Variance of result is same as variance of x0.
1352 
1353  xresult.put_variance(x0.variance(false), false);
1354 
1355  if(xauto_access)
1356  {
1357  x0.release_access();
1358  xresult.release_access();
1359  }
1360 
1361  // Postconditions:
1362 
1363  ensure(xresult.variance(xauto_access) == x0.variance(xauto_access));
1364  ensure(unexecutable("xresult is equal to the antisymmetric part of x0"));
1365 
1366  // Exit:
1367 
1368  return;
1369 }
1370 
virtual const std::string & class_name() const
The name of this class.
Definition: t4_e3.cc:324
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 int dd() const
Dimension of the underlying vector space.
Definition: t4_e3.cc:208
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 volatile_type * lite_type() const
Virtual conversion to the associated volatile type.
Definition: t4_e3.cc:773
virtual void put_component(int xi, int xj, int xk, int xl, value_type xvalue)
Sets the component with indices xi, xj, xk, xl to xvalue.
Definition: st4.cc:851
virtual t4_e3 & operator=(const abstract_poset_member &xother)
Assignment operator; synonym for attach_to_state(&xother).
Definition: t4_e3.cc:696
virtual void put_component(int xi, int xj, int xk, int xl, value_type xvalue)
Sets the component with indices xi, xj, xk, xl to xvalue.
Definition: st4.cc:214
A symmetric tensor of degree p over an abstract vector space.
Definition: stp.h:190
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 void * row_dofs()
The row dofs for this instance (mutable version).
Definition: t4_e3.cc:442
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
virtual value_type component(int xi, int xj, int xk, int xl) const
The component with indices xi, xj, xk, xl.
Definition: t4.cc:209
poset_path path(bool xauto_access=true) const
A path to this component.
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...
poset_path vector_space_path() const
The path of the underlying vector space.
Definition: tp_space.cc:365
t4_e3_lite & operator=(const t4_e3_lite &xother)
Assignment operator.
Definition: t4_e3.cc:81
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 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 const std::string & static_class_name()
The name of this class.
Definition: t4_e3.cc:1108
STL namespace.
T components[81]
The dofs are in the following order:
Definition: t4_e3.h:192
static void make_standard_schema(namespace_poset &xns)
Creates the standard schema for this class in namespace xns.
Definition: t4_e3.cc:489
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 ~t4_e3_lite()
Destructor.
Definition: t4_e3.cc:104
virtual const std::string & class_name() const
The name of this class.
Definition: t4_e3.cc:1089
A symmetric rank 4 tensor over a Euclidean vector space of dimension 3. (volatile version)...
Definition: st4_e3.h:134
t4_e3_lite()
Default constructor.
Definition: t4_e3.cc:49
T::row_dofs_type & row_dofs(T &x0)
The row dofs pod type for x0 (mutable version).
A tensor of degree 4 over a Euclidean vector space of dimension 3 (persistent version).
Definition: t4_e3.h:438
virtual bool is_ancestor_of(const any *other) const
Conformance test; true if other conforms to this.
Definition: t4_e3.cc:1195
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
static const std::string & static_class_name()
The name of this class.
Definition: t4_e3.cc:343
A general tensor of "degree" p and given "variance" over an abstract vector space.
Definition: tp.h:253
virtual const volatile_type & lite_prototype() const
Virtual constructor for the associated volatile type.
Definition: t4_e3.cc:755
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...
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
virtual const stp_lite & stp_prototype(int xp) const
Prototype for symmetric tensors of degree xp over this vector space.
Definition: t4_e3.cc:281
virtual t4_e3_lite * clone() const
Virtual constructor, makes a new instance of the same type as this.
Definition: t4_e3.cc:362
virtual schema_poset_member & schema()
The schema for this poset (mutable version).
t4_e3()
Default constructor.
Definition: t4_e3.cc:658
bool invariant() const
Class invariant.
Definition: t4_e3.cc:414
virtual const atp_lite & atp_prototype(int xp) const
Prototype for antisymmetric tensors of degree xp over this vector space.
Definition: t4_e3.cc:260
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...
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
A tensor of degree 4 over a Euclidean vector space of dimension 3 (volatile version).
Definition: t4_e3.h:210
virtual stp * new_stp(int xp, bool xauto_access) const
Virtual constructor for symmetric tensors of degree xp over vector space xvector_space.
Definition: t4_e3.cc:1057
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 t4_e3 * clone() const
Make a new handle, no state instance of current.
Definition: t4_e3.cc:1127
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 atp * new_atp(int xp, bool xauto_access) const
Virtual constructor for antisymmetric tensors of degree xp over vector space xvector_space.
Definition: t4_e3.cc:1036
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...
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: t4_e3.cc:537
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.
A tensor of degree 4 over an abstract vector space (volatile version).
Definition: t4.h:43
virtual value_type component(int xi, int xj, int xk, int xl) const
The component with indices xi, xj, xk, xl.
Definition: t4.cc:788
poset_path scalar_space_path() const
The path of the underlying space of scalars.
Definition: vd_space.cc:250
virtual ~t4_e3()
Destructor.
Definition: t4_e3.cc:739
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 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
static int factor_ct(int xd)
Factor_ct() as a function of dimension xd.
Definition: vd_space.cc:167
row_dofs_type _row_dofs
Row_dofs_type.
Definition: t4_e3.h:274
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
virtual bool invariant() const
Class invariant.
Definition: t4_e3.cc:1163
int dd() const
The dimension of the underlying ("domain") vector space.
Definition: tp_space.cc:317
virtual bool is_ancestor_of(const any_lite &xother) const
Conformance test; true if other conforms to this.
Definition: t4_e3.cc:395
A symmetric rank 3 tensor over a 3D Euclidean vector space (persistent version).
Definition: st4_e3.h:386
virtual tensor_variance variance(bool xauto_access) const
The variance.
Definition: tp.cc:1001
static const poset_path & standard_schema_path()
The path to the standard schema for this class.
Definition: t4_e3.cc:471
static host_type & standard_host(namespace_type &xns, const std::string &xsuffix, bool xauto_access)
The host with path standard_host_path<t4_e3>(xsuffix). Returns the host if it already exists...
Definition: t4_e3.cc:591
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.
virtual const tp_lite & tp_prototype(int xp) const
Prototype for general tensors of degree xp over this vector space.
Definition: t4_e3.cc:239
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
virtual tp * new_tp(int xp, bool xauto_access) const
Virtual constructor for general tensors of degree xp over vector space xvector_space.
Definition: t4_e3.cc:1015