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