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