SheafSystem  0.0.0.0
jcb_e13.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/jcb_e13.impl.h"
22 
23 #include "SheafSystem/abstract_poset_member.impl.h"
24 #include "SheafSystem/assert_contract.h"
25 #include "SheafSystem/at1.h"
26 #include "SheafSystem/at1_space.h"
27 #include "SheafSystem/jcb_space.h"
28 #include "SheafSystem/fiber_bundles_namespace.h"
29 #include "SheafSystem/schema_poset_member.h"
30 #include "SheafSystem/wsv_block.h"
31 
32 using namespace std;
33 using namespace fiber_bundle; // Workaround for MS C++ bug.
34 
35 
36 //==============================================================================
37 // CLASS JCB_E13_LITE
38 //==============================================================================
39 
40 
41 //============================================================================
42 // JCB_E13 FACET OF CLASS JCB_E13_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 jcb_e13_lite(const jcb_e13_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 jcb_e13_lite& xother)
81 {
82 
83  // Preconditions:
84 
85  // Body:
86 
87  if(this == &xother)
88  return *this;
89 
90  int ld = d();
91  for(int i=0; i<ld; ++i)
92  {
93  put_component(i, xother[i]);
94  }
95 
96  // Postconditions:
97 
98  ensure(invariant());
99  ensure_for_all(i, 0, d(), component(i) == xother[i]);
100 
101  // Exit:
102 
103  return *this;
104 }
105 
108 {
109  // Preconditions:
110 
111  // Body:
112 
113  // Postconditions:
114 
115  // Exit:
116 
117 }
118 
120 jcb_e13_lite(const row_dofs_type& xrow_dofs)
121 {
122  // Preconditions:
123 
124  // Body:
125 
126  *this = xrow_dofs;
127 
128  // Postconditions:
129 
130  ensure(invariant());
131 
132  // Exit:
133 }
134 
137 operator=(const row_dofs_type& xrow_dofs)
138 {
139  // Preconditions:
140 
141  // Body:
142 
143  _row_dofs = xrow_dofs;
144 
145  // Postconditions:
146 
147  ensure(invariant());
148 
149  // Exit:
150 
151  return *this;
152 
153 }
154 
156 jcb_e13_lite(const matrix_type& xmatrix)
157 {
158  // Preconditions:
159 
160  // Body:
161 
162  *this = xmatrix;
163 
164  // Postconditions:
165 
166  ensure(invariant());
167 
168  // Exit:
169 }
170 
173 operator=(const matrix_type& xmatrix)
174 {
175  // Preconditions:
176 
177  // Body:
178 
179  //_row_dofs = xmatrix;
180  _row_dofs = reinterpret_cast<const row_dofs_type&>(xmatrix);
181 
182  // Postconditions:
183 
184  ensure(invariant());
185 
186  // Exit:
187 
188  return *this;
189 
190 }
191 
192 fiber_bundle::jcb_e13_lite::
194 {
195  // Preconditions:
196 
197  // Body:
198 
199  matrix_type& result = _row_dofs;
200 
201  // Postconditions:
202 
203  // Exit:
204 
205  return result;
206 }
207 
208 fiber_bundle::jcb_e13_lite::
209 operator const jcb_e13_lite::matrix_type& () const
210 {
211  // Preconditions:
212 
213  // Body:
214 
215  const matrix_type& result = _row_dofs;
216 
217  // Postconditions:
218 
219  // Exit:
220 
221  return result;
222 }
223 
224 fiber_bundle::jcb_e13_lite::
226 {
227  // Preconditions:
228 
229  // Body:
230 
231  row_dofs_type& result = _row_dofs;
232 
233  // Postconditions:
234 
235  // Exit:
236 
237  return result;
238 }
239 
240 fiber_bundle::jcb_e13_lite::
241 operator const jcb_e13_lite::row_dofs_type& () const
242 {
243  // Preconditions:
244 
245  // Body:
246 
247  const row_dofs_type& result = _row_dofs;
248 
249  // Postconditions:
250 
251  // Exit:
252 
253  return result;
254 }
255 
256 
259  const value_type& dydu,
260  const value_type& dzdu)
261 {
262  // Preconditions:
263 
264  // Body:
265 
266  put_components(dxdu, dydu, dzdu);
267 
268  // Postconditions:
269 
270  ensure(invariant());
271  ensure(isunordered_or_equals(component(0), dxdu));
272  ensure(isunordered_or_equals(component(1), dydu));
273  ensure(isunordered_or_equals(component(2), dzdu));
274 
275  // Exit:
276 }
277 
278 void
281  const value_type& dydu,
282  const value_type& dzdu)
283 {
284  // Preconditions:
285 
286  // Body:
287 
288  put_component(0, dxdu);
289  put_component(1, dydu);
290  put_component(2, dzdu);
291 
292  // Postconditions:
293 
294  ensure(invariant());
295 
296  ensure(isunordered_or_equals(component(0), dxdu));
297  ensure(isunordered_or_equals(component(1), dydu));
298  ensure(isunordered_or_equals(component(2), dzdu));
299 
300  // Exit:
301 }
302 
303 // PROTECTED MEMBER FUNCTIONS
304 
305 // PRIVATE MEMBER FUNCTIONS
306 
307 
308 //============================================================================
309 // JCB_ED FACET OF CLASS JCB_E13_LITE
310 //============================================================================
311 
312 // PUBLIC MEMBER FUNCTIONS
313 
314 // PROTECTED MEMBER FUNCTIONS
315 
316 // PRIVATE MEMBER FUNCTIONS
317 
318 
319 //============================================================================
320 // JACOBIAN (JCB) FACET OF CLASS JCB_E13_LITE
321 //============================================================================
322 
323 // PUBLIC MEMBER FUNCTIONS
324 
325 int
327 dd() const
328 {
329  // Preconditions:
330 
331  // Body:
332 
333  int result = 1;
334 
335  // Postconditions:
336 
337  ensure(invariant());
338  ensure(result == 1);
339 
340  // Exit:
341 
342  return result;
343 }
344 
345 int
347 dr() const
348 {
349  // Preconditions:
350 
351  // Body:
352 
353  int result = 3;
354 
355  // Postconditions:
356 
357  ensure(invariant());
358  ensure(result == 3);
359 
360  // Exit:
361 
362  return result;
363 }
364 
365 // PROTECTED MEMBER FUNCTIONS
366 
367 // PRIVATE MEMBER FUNCTIONS
368 
369 
370 //============================================================================
371 // VECTOR ALGEBRA (VD) FACET OF CLASS JCB_E13_LITE
372 //============================================================================
373 
374 // PUBLIC MEMBER FUNCTIONS
375 
376 
377 // PROTECTED MEMBER FUNCTIONS
378 
379 // PRIVATE MEMBER FUNCTIONS
380 
381 
382 //============================================================================
383 // CARTESIAN ALGEBRA (TUPLE) FACET OF CLASS JCB_E13_LITE
384 //============================================================================
385 
386 // PUBLIC MEMBER FUNCTIONS
387 
388 // PROTECTED MEMBER FUNCTIONS
389 
390 // PRIVATE MEMBER FUNCTIONS
391 
392 
393 //============================================================================
394 // ABSTRACT POSET MEMBER FACET OF CLASS JCB_E13_LITE
395 //============================================================================
396 
397 // PUBLIC MEMBER FUNCTIONS
398 
399 const std::string&
401 class_name() const
402 {
403  // Preconditions:
404 
405  // Body:
406 
407  const string& result = static_class_name();
408 
409  // Postconditions:
410 
411  ensure(!result.empty());
412 
413  // Exit:
414 
415  return result;
416 }
417 
418 const std::string&
421 {
422  // Preconditions:
423 
424  // Body:
425 
426  static const string result("jcb_e13_lite");
427 
428  // Postconditions:
429 
430  ensure(!result.empty());
431 
432  // Exit:
433 
434  return result;
435 }
436 
439 clone() const
440 {
441  jcb_e13_lite* result = 0;
442 
443  // Preconditions:
444 
445  // Body:
446 
447  result = new jcb_e13_lite();
448 
449  // Postconditions:
450 
451  ensure(result != 0);
452  ensure(is_same_type(*result));
453 
454  // Exit:
455 
456  return result;
457 }
458 
459 // PROTECTED MEMBER FUNCTIONS
460 
461 // PRIVATE MEMBER FUNCTIONS
462 
463 
464 //============================================================================
465 // ANY FACET OF CLASS JCB_E13_LITE
466 //============================================================================
467 
468 // PUBLIC MEMBER FUNCTIONS
469 
470 bool
472 is_ancestor_of(const any_lite& xother) const
473 {
474  // Preconditions:
475 
476  require(&xother != 0);
477 
478  // Body:
479 
480  // True if other conforms to this.
481 
482  bool result = dynamic_cast<const jcb_e13_lite*>(&xother) != 0;
483 
484  // Postconditions:
485 
486  return result;
487 }
488 
489 bool
491 invariant() const
492 {
493  bool result = true;
494 
495  if(invariant_check())
496  {
497  // Prevent recursive calls to invariant.
498 
499  disable_invariant_check();
500 
501  // Must satisfy base class invariant.
502 
503  invariance(jcb_ed_lite::invariant());
504 
505  // Invariances for this class:
506 
507  // Finished, turn invariant checking back on.
508 
509  enable_invariant_check();
510  }
511 
512  // Exit
513 
514  return result;
515 }
516 
517 void*
520 {
521  return &_row_dofs;
522 }
523 
524 const void*
526 row_dofs() const
527 {
528  return &_row_dofs;
529 }
530 
531 // PROTECTED MEMBER FUNCTIONS
532 
533 // PRIVATE MEMBER FUNCTIONS
534 
535 
536 //==============================================================================
537 // CLASS JCB_E13
538 //==============================================================================
539 
540 // ===========================================================
541 // HOST FACTORY FACET
542 // ===========================================================
543 
544 // PUBLIC MEMBER FUNCTIONS
545 
546 const sheaf::poset_path&
549 {
550  // Preconditions:
551 
552 
553  // Body:
554 
555  static const poset_path result(standard_schema_poset_name(), "jcb_e13_schema");
556 
557  // Postconditions:
558 
559  // Exit:
560 
561  return result;
562 }
563 
564 void
567 {
568  // Preconditions:
569 
570  require(xns.state_is_read_write_accessible());
571  require(xns.contains_poset(standard_schema_poset_name()));
572  require(!xns.contains_poset_member(standard_schema_path()));
573 
574  // Body:
575 
576  string lmember_names = "dxdu DOUBLE false ";
577  lmember_names += "dydu DOUBLE false ";
578  lmember_names += "dzdu DOUBLE false";
579 
580  schema_poset_member lschema(xns,
581  standard_schema_path().member_name(),
582  jcb_ed::standard_schema_path(),
583  lmember_names,
584  false);
585 
586  lschema.detach_from_state();
587 
588  // Postconditions:
589 
590  ensure(xns.contains_poset_member(standard_schema_path()));
591 
592  // Exit:
593 
594  return;
595 }
596 
600  const poset_path& xhost_path,
601  const poset_path& xschema_path,
602  const poset_path& xdomain_path,
603  const poset_path& xrange_path,
604  bool xauto_access)
605 {
606  // cout << endl << "Entering jcb_e13::new_host." << endl;
607 
608  // Preconditions:
609 
610  require(xns.state_is_auto_read_write_accessible(xauto_access));
611 
612  require(!xhost_path.empty());
613  require(!xns.contains_path(xhost_path, xauto_access));
614 
615  require(xschema_path.full());
616  require(xns.path_is_auto_read_accessible(xschema_path, xauto_access));
617  require(schema_poset_member::conforms_to(xns, xschema_path, standard_schema_path()));
618  require(schema_poset_member::row_dof_ct(xns, xschema_path, xauto_access) == 3);
619 
620  require(xns.path_is_auto_read_accessible(xdomain_path, xauto_access));
621  require(xns.contains_poset<domain_type::host_type>(xdomain_path, xauto_access));
622  require(xns.member_poset(xdomain_path, xauto_access).schema(xauto_access).conforms_to(domain_type::standard_schema_path()));
623  require(xns.member_poset<domain_type::host_type>(xdomain_path, xauto_access).d(xauto_access) == 1);
624 
625  require(xns.path_is_auto_read_accessible(xrange_path, xauto_access));
626  require(xns.contains_poset<range_type::host_type>(xrange_path, xauto_access));
627  require(xns.member_poset(xrange_path, xauto_access).schema(xauto_access).conforms_to(range_type::standard_schema_path()));
628  require(xns.member_poset<range_type::host_type>(xrange_path, xauto_access).d(xauto_access) == 3);
629 
630  require(host_type::d(xns, xschema_path, xauto_access) == host_type::d(xns, xdomain_path, xrange_path, xauto_access));
631 
632  require(xns.member_poset<domain_type::host_type>(xdomain_path, xauto_access).scalar_space_path(xauto_access) ==
633  xns.member_poset<range_type::host_type>(xrange_path, xauto_access).scalar_space_path(xauto_access));
634 
635  // Body:
636 
637  host_type& result =
638  host_type::new_table(xns, xhost_path, xschema_path, xdomain_path, xrange_path, xauto_access);
639 
640  // Postconditions:
641 
642  ensure(xns.owns(result, xauto_access));
643  ensure(result.path(true) == xhost_path);
644  ensure(result.state_is_not_read_accessible());
645  ensure(result.schema(true).path(xauto_access) == xschema_path);
646 
647  ensure(result.factor_ct(true) == 3);
648  ensure(result.d(true) == 3);
649  ensure(result.dd(true) == 1);
650  ensure(result.dr(true) == 3);
651  ensure(result.domain_path(true) == xdomain_path);
652  ensure(result.range_path(true) == xrange_path);
653 
654  ensure(result.scalar_space_path(true) ==
655  xns.member_poset<domain_type::host_type>(xdomain_path, xauto_access).scalar_space_path(xauto_access) );
656  ensure(result.scalar_space_path(true) ==
657  xns.member_poset<range_type::host_type>(xrange_path, xauto_access).scalar_space_path(xauto_access) );
658 
659  // Exit:
660 
661  // cout << "Leaving jcb_e13::new_host." << endl;
662  return result;
663 }
664 
667 standard_host(namespace_type& xns, const std::string& xsuffix, bool xauto_access)
668 {
669  // cout << endl << "Entering jcb_e13::new_host." << endl;
670 
671  // Preconditions:
672 
673  require(xns.state_is_auto_read_write_accessible(xauto_access));
674 
675  require(xsuffix.empty() || poset_path::is_valid_name(xsuffix));
676  require(standard_host_is_available<jcb_e13>(xns, xsuffix, xauto_access));
677 
678  require(xns.path_is_auto_read_accessible(standard_schema_path(), xauto_access));
679 
680  require(xns.path_is_auto_read_available(standard_host_path<domain_type>(xsuffix), xauto_access));
681  require(xns.path_is_auto_read_available(standard_host_path<range_type>(xsuffix), xauto_access));
682 
683  // Body:
684 
685  // Create the domain space if necessary.
686 
687  poset_path ldomain_space_path = domain_type::standard_host(xns, xsuffix, xauto_access).path(true);
688 
689  // Create the range space if necessary.
690 
691  poset_path lrange_space_path = range_type::standard_host(xns, xsuffix, xauto_access).path(true);
692 
693  poset_path lpath(standard_host_path<jcb_e13>(xsuffix));
694 
695  host_type* result_ptr;
696  if(xns.contains_path(lpath, xauto_access))
697  {
698  result_ptr = &xns.member_poset<host_type>(lpath, xauto_access);
699  }
700  else
701  {
702  result_ptr = &new_host(xns, lpath, standard_schema_path(), ldomain_space_path, lrange_space_path, xauto_access);
703  }
704 
705  host_type& result = *result_ptr;
706 
707  // Postconditions:
708 
709  ensure(xns.owns(result, xauto_access));
710  ensure(result.path(true) == standard_host_path<jcb_e13>(xsuffix));
711  ensure(result.state_is_not_read_accessible());
712  ensure(result.schema(true).path(xauto_access) == standard_schema_path());
713 
714  ensure(result.factor_ct(true) == 3);
715  ensure(result.d(true) == 3);
716  ensure(result.dd(true) == 1);
717  ensure(result.dr(true) == 3);
718  ensure(result.domain_path(true) == standard_host_path<domain_type>(xsuffix));
719  ensure(result.range_path(true) == standard_host_path<range_type>(xsuffix));
720 
721  ensure(result.scalar_space_path(true) == standard_host_path<domain_type::scalar_type>(xsuffix));
722  ensure(result.scalar_space_path(true) == standard_host_path<range_type::scalar_type>(xsuffix));
723 
724  // Exit:
725 
726  // cout << "Leaving jcb_e13::new_host." << endl;
727  return result;
728 }
729 
730 // PROTECTED MEMBER FUNCTIONS
731 
732 // PRIVATE MEMBER FUNCTIONS
733 
734 
735 
736 //============================================================================
737 // JCB_E13 FACET OF CLASS JCB_E13
738 //============================================================================
739 
740 // PUBLIC MEMBER FUNCTIONS
741 
744 {
745 
746  // Preconditions:
747 
748  // Body:
749 
750  // Postconditions:
751 
752  ensure(invariant());
753 }
754 
757 {
758  // Preconditions:
759 
760  require(xhost != 0);
761  require(xhost->state_is_read_accessible());
762  require(xhost->contains_member(xhub_id));
763 
764  // Body:
765 
766  attach_to_state(xhost, xhub_id);
767 
768  // Postconditions:
769 
770  ensure(invariant());
771  // ensure(host() == xhost);
772  ensure(index() == xhub_id);
773  ensure(is_attached());
774 }
775 
777 jcb_e13(const poset_state_handle* xhost, const scoped_index& xid)
778 {
779  // Preconditions:
780 
781  require(xhost != 0);
782  require(xhost->state_is_read_accessible());
783  require(xhost->contains_member(xid));
784 
785  // Body:
786 
787  attach_to_state(xhost, xid.hub_pod());
788 
789  // Postconditions:
790 
791  ensure(invariant());
792  // ensure(host() == xhost);
793  ensure(index() ==~ xid);
794  ensure(is_attached());
795 }
796 
798 jcb_e13(const poset_state_handle* xhost, const std::string& xname)
799 {
800 
801  // Preconditions:
802 
803  require(xhost != 0);
804  require(xhost->state_is_read_accessible());
805  require(!xname.empty());
806  require(xhost->contains_member(xname));
807 
808  // Body:
809 
810  attach_to_state(xhost, xname);
811 
812  // Postconditions:
813 
814  ensure(invariant());
815  // ensure(host() == xhost);
816  ensure(name() == xname);
817  ensure(is_attached());
818 
819 }
820 
823 {
824 
825  // Preconditions:
826 
827  require(xother != 0);
828 
829  // Body:
830 
831  attach_to_state(xother);
832 
833  // Postconditions:
834 
835  ensure(invariant());
836  ensure(is_attached());
837  ensure(is_same_state(xother));
838 
839 }
840 
842 jcb_e13(poset_state_handle* xhost, bool xauto_access)
843 {
844 
845  // Preconditions:
846 
847  require(precondition_of(new_jim_state(xhost, 0, false, xauto_access)));
848 
849  // Body:
850 
851  new_jim_state(xhost, 0, false, xauto_access);
852 
853  // Postconditions:
854 
855  ensure(postcondition_of(new_jim_state(xhost, 0, false, xauto_access)));
856 
857  // Exit:
858 
859  return;
860 }
861 
864  const row_dofs_type& xrdt,
865  bool xauto_access)
866 {
867 
868  // Preconditions:
869 
870  require(precondition_of(new_jim_state(&xhost, 0, false, xauto_access)));
871 
872  // Body:
873 
874  new_jim_state(&xhost, 0, false, xauto_access);
875 
876  if(xauto_access)
877  {
878  xhost.get_read_write_access();
879  }
880 
881  *this = xrdt;
882 
883  if(xauto_access)
884  {
885  xhost.release_access();
886  }
887 
888  // Postconditions:
889 
890  ensure(postcondition_of(new_jim_state(&xhost, 0, false, xauto_access)));
891 
892  // Exit:
893 
894  return;
895 }
896 
900 {
901  // Preconditions:
902 
903  require(state_is_read_write_accessible());
904 
905  // Body:
906 
907  int ld = d();
908  for(int i=0; i<ld; ++i)
909  {
910  put_component(i, xrdt.components[i]);
911  }
912 
913  // Postconditions:
914 
915  ensure_for_all(i, 0, d(), component(i) == xrdt.components[i]);
916 
917  // Exit:
918 
919  return *this;
920 
921 }
922 
927 {
928  // Preconditions:
929 
930  require(is_ancestor_of(&xother));
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 
949 operator=(const jcb_e13& xother)
950 {
951  // Preconditions:
952 
953  require(precondition_of(attach_to_state(&xother)));
954 
955  // Body:
956 
957  attach_to_state(&xother);
958 
959  // Postconditions:
960 
961  ensure(postcondition_of(attach_to_state(&xother)));
962 
963  // Exit:
964 
965  return *this;
966 }
967 
970 {
971 
972  // Preconditions:
973 
974  // Body:
975 
976  // Postconditions:
977 
978 }
979 
983 {
984  // Preconditions:
985 
986  // Body:
987 
988  static const volatile_type result;
989 
990  // Postconditions:
991 
992  // Exit:
993 
994  return result;
995 }
996 
1000 lite_type() const
1001 {
1002  // Preconditions:
1003 
1004  // Body:
1005 
1006  volatile_type* result = new volatile_type(sheaf::row_dofs(*this));
1007 
1008  // Postconditions:
1009 
1010  // Exit:
1011 
1012  return result;
1013 }
1014 
1015 //============================================================================
1016 // ROW DOF RELATED MEMBER FUNCTIONS
1017 //============================================================================
1018 
1019 void
1022  dof_type dydu_comp,
1023  dof_type dzdu_comp)
1024 {
1025  // Preconditions:
1026 
1027  require(state_is_read_write_accessible());
1028 
1029  // Body:
1030 
1031  (*this)[0] = dxdu_comp;
1032  (*this)[1] = dydu_comp;
1033  (*this)[2] = dzdu_comp;
1034 
1035  // Postconditions:
1036 
1037  ensure(invariant());
1038 
1039  ensure(isunordered_or_equals(component(0), dxdu_comp));
1040  ensure(isunordered_or_equals(component(1), dydu_comp));
1041  ensure(isunordered_or_equals(component(2), dzdu_comp));
1042 
1043  // Exit:
1044 
1045  return;
1046 }
1047 
1048 fiber_bundle::jcb_e13::
1050 {
1051  // Preconditions:
1052 
1053  // Body:
1054 
1055  row_dofs_type& result = sheaf::row_dofs(*this);
1056 
1057  // Postconditions:
1058 
1059  // Exit:
1060 
1061  return result;
1062 }
1063 
1064 fiber_bundle::jcb_e13::
1065 operator const jcb_e13::row_dofs_type& () const
1066 {
1067  // Preconditions:
1068 
1069  // Body:
1070 
1071  const row_dofs_type& result = sheaf::row_dofs(*this);
1072 
1073  // Postconditions:
1074 
1075  // Exit:
1076 
1077  return result;
1078 }
1079 
1080 // PROTECTED MEMBER FUNCTIONS
1081 
1082 // PRIVATE MEMBER FUNCTIONS
1083 
1084 
1085 //============================================================================
1086 // JCB_ED FACET OF CLASS JCB_E13
1087 //============================================================================
1088 
1089 // PUBLIC MEMBER FUNCTIONS
1090 
1091 // PROTECTED MEMBER FUNCTIONS
1092 
1093 // PRIVATE MEMBER FUNCTIONS
1094 
1095 
1096 //============================================================================
1097 // JCB FACET OF CLASS JCB_E13
1098 //============================================================================
1099 
1100 // PUBLIC MEMBER FUNCTIONS
1101 
1102 // PROTECTED MEMBER FUNCTIONS
1103 
1104 // PRIVATE MEMBER FUNCTIONS
1105 
1106 
1107 //============================================================================
1108 // VD FACET OF CLASS JCB_E13
1109 //============================================================================
1110 
1111 // PUBLIC MEMBER FUNCTIONS
1112 
1113 // PROTECTED MEMBER FUNCTIONS
1114 
1115 // PRIVATE MEMBER FUNCTIONS
1116 
1117 
1118 //============================================================================
1119 // TUPLE FACET OF CLASS JCB_E13
1120 //============================================================================
1121 
1122 // PUBLIC MEMBER FUNCTIONS
1123 
1124 // PROTECTED MEMBER FUNCTIONS
1125 
1126 // PRIVATE MEMBER FUNCTIONS
1127 
1128 
1129 //============================================================================
1130 // ABSTRACT POSET MEMBER FACET OF CLASS JCB_E13
1131 //============================================================================
1132 
1133 // PUBLIC MEMBER FUNCTIONS
1134 
1135 const std::string&
1137 class_name() const
1138 {
1139  // Preconditions:
1140 
1141  // Body:
1142 
1143  const string& result = static_class_name();
1144 
1145  // Postconditions:
1146 
1147  ensure(!result.empty());
1148 
1149  // Exit:
1150 
1151  return result;
1152 }
1153 
1154 const std::string&
1157 {
1158  // Preconditions:
1159 
1160  // Body:
1161 
1162  static const string result("jcb_e13");
1163 
1164  // Postconditions:
1165 
1166  ensure(!result.empty());
1167 
1168  // Exit:
1169 
1170  return result;
1171 }
1172 
1175 clone() const
1176 {
1177 
1178  // Preconditions:
1179 
1180  // Body:
1181 
1182  // Create new handle of the current class.
1183 
1184  jcb_e13* result = new jcb_e13();
1185 
1186  // Postconditions:
1187 
1188  ensure(result != 0);
1189  ensure(result->invariant());
1190 
1191  // Exit:
1192 
1193  return result;
1194 
1195 }
1196 
1197 // PROTECTED MEMBER FUNCTIONS
1198 
1199 // PRIVATE MEMBER FUNCTIONS
1200 
1201 
1202 //============================================================================
1203 // ANY FACET OF CLASS JCB_E13
1204 //============================================================================
1205 
1206 // PUBLIC MEMBER FUNCTIONS
1207 
1208 bool
1210 is_ancestor_of(const any* xother) const
1211 {
1212 
1213  // Preconditions:
1214 
1215  require(xother != 0);
1216 
1217  // Body:
1218 
1219  // If xother may be dynamically cast to the type of this then this is an
1220  // ancestor of xother.
1221 
1222  bool result = dynamic_cast<const jcb_e13*>(xother) != 0;
1223 
1224  // Postconditions:
1225 
1226  // ensure(invariant());
1227 
1228  // Exit:
1229 
1230  return result;
1231 
1232 }
1233 
1234 bool
1236 invariant() const
1237 {
1238  bool result = true;
1239 
1240  // Preconditions:
1241 
1242  // Body:
1243 
1244  // Must satisfy base class invariant.
1245 
1246  invariance(jcb_ed::invariant());
1247 
1248  if (invariant_check())
1249  {
1250  // Prevent recursive calls to invariant.
1251 
1252  disable_invariant_check();
1253 
1254  invariance((is_attached() ? (dr() == 3) : true));
1255  invariance((is_attached() ? (dd() == 1) : true));
1256 
1257  // Finished, turn invariant checking back on.
1258 
1259  enable_invariant_check();
1260  }
1261 
1262  // Postconditions:
1263 
1264  ensure(is_derived_query);
1265 
1266  // Exit:
1267 
1268  return result;
1269 }
1270 
1271 // PROTECTED MEMBER FUNCTIONS
1272 
1273 // PRIVATE MEMBER FUNCTIONS
1274 
1275 
1276 //==============================================================================
1277 // NON-MEMBER FUNCTIONS
1278 //==============================================================================
1279 
1281 void
1283 push(const jcb_e13& xjcb, const e1& xvector, e3& xresult, bool xauto_access)
1284 {
1285  // Preconditions:
1286 
1287  require(xjcb.state_is_auto_read_accessible(xauto_access));
1288  require(xvector.state_is_auto_read_accessible(xauto_access));
1289  require(xresult.state_is_auto_read_write_accessible(xauto_access));
1290  require(xvector.d(xauto_access) == xjcb.dd(xauto_access));
1291  require(xresult.d(xauto_access) == xjcb.dr(xauto_access));
1292 
1294 
1295  require(xvector.is_contravariant(0, xauto_access)); // !is_dual
1296 
1297  // Body:
1298 
1299  if(xauto_access)
1300  {
1301  xjcb.get_read_access();
1302  xvector.get_read_access();
1303  xresult.get_read_write_access(true);
1304  }
1305 
1306  // Left matrix multiply vector with jacobian.
1307 
1308  int num_rows = xjcb.dr();
1309  int num_cols = xjcb.dd();
1310 
1311  for(int i=0; i<num_rows; ++i)
1312  {
1313  vd_value_type sumi = 0.0;
1314  for(int j=0; j<num_cols; ++j)
1315  {
1316  vd_value_type vj = xvector.component(j);
1317  vd_value_type cij = xjcb.component(i, j);
1318  sumi += cij*vj;
1319  }
1320  xresult.put_component(i, sumi);
1321  }
1322 
1323  // Make sure the result is contravariant/p_vector.
1324 
1325  xresult.put_is_p_vector(false);
1326 
1327  if(xauto_access)
1328  {
1329  xjcb.release_access();
1330  xvector.release_access();
1331  xresult.release_access();
1332  }
1333 
1334  // Postconditions:
1335 
1336  ensure(xresult.is_contravariant(0, xauto_access)); // !is_dual
1337 
1338  // Exit:
1339 }
1340 
1342 void
1344 push(const jcb_e13_lite& xjcb, const e1_lite& xvector, e3_lite& xresult)
1345 {
1346  // Preconditions:
1347 
1348  require(xvector.d() == xjcb.dd());
1349  require(xresult.d() == xjcb.dr());
1350 
1352 
1353  require(unexecutable("xvector.is_contravariant())")); // !is_dual
1354 
1355  // Body:
1356 
1357  // Left matrix multiply vector with jacobian.
1358 
1359  int num_rows = xjcb.dr();
1360  int num_cols = xjcb.dd();
1361 
1362  for(int i=0; i<num_rows; ++i)
1363  {
1364  vd_value_type sumi = 0.0;
1365  for(int j=0; j<num_cols; ++j)
1366  {
1367  vd_value_type vj = xvector.component(j);
1368  vd_value_type cij = xjcb.component(i, j);
1369  sumi += cij*vj;
1370  }
1371  xresult.put_component(i, sumi);
1372  }
1373 
1374  // Postconditions:
1375 
1376  //ensure(unexecutable("???"));
1377  ensure(unexecutable("xresult.is_contravariant())")); // !is_dual
1378 
1379  // Exit:
1380 
1381 }
1382 
1386 push(const jcb_e13_lite& xjcb, const e1_lite& xvector)
1387 {
1388  // Preconditions:
1389 
1390  require(precondition_of(push(xjcb, xvector, *result)));
1391 
1392  // Body:
1393 
1394  e3_lite* result = new e3_lite();
1395 
1396  push(xjcb, xvector, *result);
1397 
1398  // Postconditions:
1399 
1400  ensure(postcondition_of(push(xjcb, xvector, *result)));
1401 
1402  // Exit:
1403 
1404  return result;
1405 
1406 }
1407 
1409 void
1411 pull(const jcb_e13& xjcb, const e3& xcovector, e1& xresult, bool xauto_access)
1412 {
1413  // Preconditions:
1414 
1415  require(xjcb.state_is_auto_read_accessible(xauto_access));
1416  require(xcovector.state_is_auto_read_accessible(xauto_access));
1417  require(xresult.state_is_auto_read_write_accessible(xauto_access));
1418  require(xcovector.d(xauto_access) == xjcb.dr(xauto_access));
1419  require(xresult.d(xauto_access) == xjcb.dd(xauto_access));
1420 
1422 
1423  require(xcovector.is_covariant(0, xauto_access)); // is_dual
1424 
1425  // Body:
1426 
1427  if(xauto_access)
1428  {
1429  xjcb.get_read_access();
1430  xcovector.get_read_access();
1431  xresult.get_read_write_access(true);
1432  }
1433 
1434  // Right matrix multiply covector with jacobian.
1435 
1436  int num_rows = xjcb.dd();
1437  int num_cols = xjcb.dr();
1438 
1439  for(int i=0; i<num_rows; ++i)
1440  {
1441  vd_value_type sumi = 0.0;
1442  for(int j=0; j<num_cols; ++j)
1443  {
1444  vd_value_type vj = xcovector.component(j);
1445  vd_value_type cji = xjcb.component(j, i);
1446  sumi += vj*cji;
1447  }
1448  xresult.put_component(i, sumi);
1449  }
1450 
1451  // Make sure the result is covariant/p_form.
1452 
1453  xresult.put_is_p_form(false);
1454 
1455 
1456  if(xauto_access)
1457  {
1458  xjcb.release_access();
1459  xcovector.release_access();
1460  xresult.release_access();
1461  }
1462 
1463  // Postconditions:
1464 
1465  ensure(xresult.is_covariant(0, xauto_access)); // is_dual
1466 
1467  // Exit:
1468 }
1469 
1471 void
1473 pull(const jcb_e13_lite& xjcb, const e3_lite& xcovector, e1_lite& xresult)
1474 {
1475  // Preconditions:
1476 
1477  require(xcovector.d() == xjcb.dr());
1478  require(xresult.d() == xjcb.dd());
1479 
1481 
1482  require(unexecutable("xcovector.is_covariant())")); // is_dual
1483 
1484  // Body:
1485 
1486  // Right matrix multiply covector with jacobian.
1487 
1488  int num_rows = xjcb.dd();
1489  int num_cols = xjcb.dr();
1490 
1491  for(int i=0; i<num_rows; ++i)
1492  {
1493  vd_value_type sumi = 0.0;
1494  for(int j=0; j<num_cols; ++j)
1495  {
1496  vd_value_type vj = xcovector.component(j);
1497  vd_value_type cji = xjcb.component(j, i);
1498  sumi += vj*cji;
1499  }
1500  xresult.put_component(i, sumi);
1501  }
1502 
1503  // Postconditions:
1504 
1505  ensure(unexecutable("xresult.is_covariant())")); // is_dual
1506 
1507  // Exit:
1508 }
1509 
1513 pull(const jcb_e13_lite& xjcb, const e3_lite& xcovector)
1514 {
1515  // Preconditions:
1516 
1517  require(precondition_of(pull(xjcb, xcovector, *result)));
1518 
1519  // Body:
1520 
1521  e1_lite* result = new e1_lite();
1522 
1523  pull(xjcb, xcovector, *result);
1524 
1525  // Postconditions:
1526 
1527  ensure(postcondition_of(pull(xjcb, xcovector, *result)));
1528 
1529  // Exit:
1530 
1531  return result;
1532 
1533 }
1534 
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...
~jcb_e13()
Destructor.
Definition: jcb_e13.cc:969
virtual jcb_e13_lite * clone() const
Virtual constructor, makes a new instance of the same type as this.
Definition: jcb_e13.cc:439
virtual bool is_contravariant(bool xauto_access) const
True if and only if all tensor index positions are contravariant.
Definition: tp.cc:1160
virtual const std::string & class_name() const
The name of this class.
Definition: jcb_e13.cc:401
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 ...
value_type component(int xrow, int xcolumn) const
The value of the component in a specified row and column (const version).
Definition: jcb.cc:229
vd_value_type value_type
The type of component in the fiber; the scalar type in the fiber vector space.
Definition: vd.h:129
bool full() const
True if both poset name and member name are not empty.
Definition: poset_path.cc:311
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
static host_type & new_host(namespace_type &xns, const poset_path &xhost_path, const poset_path &xschema_path, const poset_path &xdomain_path, const poset_path &xrange_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: jcb_e13.cc:599
Euclidean vector space of dimension 3 (volatile version).
Definition: e3.h:116
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
jcb_e13()
Default constructor.
Definition: jcb_e13.cc:743
virtual bool is_ancestor_of(const any_lite &xother) const
Conformance test; true if other conforms to this.
Definition: jcb_e13.cc:472
int dd() const
The dimension of the underlying ("domain") vector space.
Definition: jcb_space.cc:248
Jacobian of a map from a 1 dimensional domain (u) to a 3 dimensional Euclidean space (x...
Definition: jcb_e13.h:147
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 invariant() const
Class invariant.
Definition: jcb_e13.cc:491
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...
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.
A path defined by a poset name and a member name separated by a forward slash (&#39;/&#39;). For example: "cell_definitions/triangle".
Definition: poset_path.h:48
STL namespace.
value_type component(int xindex) const
The xindex-th component.
Definition: vd.cc:209
static const std::string & static_class_name()
The name of this class.
Definition: jcb_e13.cc:1156
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.
jcb_e13_row_dofs_type< double >::matrix_type matrix_type
The type of the associated matrix.
Definition: jcb_e13.h:166
virtual const volatile_type & lite_prototype() const
Virtual constructor for the associated volatile type.
Definition: jcb_e13.cc:982
value_type component(int xrow, int xcolumn) const
The component with row index xrow and column index xcolumn.
Definition: jcb.cc:1037
static host_type & standard_host(namespace_type &xns, const std::string &xsuffix, bool xauto_access)
The host with path standard_host_path<jcb_e13>(xsuffix). Returns the host if it already exists...
Definition: jcb_e13.cc:667
Euclidean vector space of dimension 3 (persistent version).
Definition: e3.h:467
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 void * row_dofs()
The row dofs for this instance (mutable version).
Definition: jcb_e13.cc:519
Euclidean vector space of dimension 1 (persistent version).
Definition: e1.h:400
static const poset_path & standard_schema_path()
The path to the standard schema for this class.
Definition: jcb_e13.cc:548
jcb_e13_lite & operator=(const jcb_e13_lite &xother)
Assignment operator.
Definition: jcb_e13.cc:80
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 schema_poset_member & schema()
The schema for this poset (mutable version).
virtual ~jcb_e13_lite()
Destructor.
Definition: jcb_e13.cc:107
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)
Abstract jacobian class (volatile version).
Definition: jcb.h:54
bool is_ancestor_of(const any *xother) const
True if xother conforms to current.
Definition: jcb_e13.cc:1210
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 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. ...
virtual void put_components(const value_type &dxdu, const value_type &dydu, const value_type &dzdu)
Set values of the components to the given arguments.
Definition: jcb_e13.cc:280
virtual value_type component(int xindex) const
The value of the xi-th component.
Definition: vd.cc:1115
Jacobian of a map from a 1 dimensional domain (u) to a 3 dimensional Euclidean space (x...
Definition: jcb_e13.h:433
virtual int d() const
Dimension of this as a vector space.
Definition: atp.cc:161
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...
bool invariant() const
Class invariant.
Definition: jcb_e13.cc:1236
SHEAF_DLL_SPEC void pull(const jcb &xjcb, const at1 &xcovector, at1 &xresult, bool xauto_access)
Pull covector back (pre-allocated version for persistent types).
Definition: jcb.cc:1440
poset_path domain_path() const
The path of the domain vector space.
Definition: jcb_space.cc:296
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.
virtual int dd() const
Dimension of the domain.
Definition: jcb.cc:831
virtual void put_components(dof_type dxdu_comp, dof_type dydu_comp, dof_type dzdu_comp)
Set values of the components to the given arguments.
Definition: jcb_e13.cc:1021
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
T components[3]
The dofs in the following order: components[0] => dx/du components[1] => dy/du components[2] => dz/du...
Definition: jcb_e13.h:130
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...
void put_component(int xindex, value_type xcomp)
Set the xindex-th component to xcomp.
Definition: vd.cc:230
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 jacobian dimension implied by the schema specified by xschema_path.
Definition: jcb_space.cc:87
virtual dof_type component() const
Get value of component xindex.
Definition: e1.cc:1171
virtual volatile_type * lite_type() const
Virtual conversion to the associated volatile type.
Definition: jcb_e13.cc:1000
poset_path range_path() const
The path of the range vector space.
Definition: jcb_space.cc:396
An abstract space of Jacobians.
Definition: jcb_space.h:46
virtual jcb_e13 * clone() const
Make a new handle, no state instance of current.
Definition: jcb_e13.cc:1175
static int factor_ct(int xd)
Factor_ct() as a function of dimension xd.
Definition: vd_space.cc:167
jcb_e13 & operator=(const row_dofs_type &xrdt)
Assignment to an instance of the associated row dofs type.
Definition: jcb_e13.cc:899
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
jcb_e13_lite()
Default constructor.
Definition: jcb_e13.cc:48
Euclidean vector space of dimension 1 (volatile version).
Definition: e1.h:113
virtual int dr() const
Dimension of the range.
Definition: jcb_e13.cc:347
virtual int d() const
Dimension of this as a vector space.
Definition: vd.cc:1017
static const std::string & static_class_name()
The name of this class.
Definition: jcb_e13.cc:420
static void make_standard_schema(namespace_poset &xns)
Creates the standard schema for this class in namespace xns.
Definition: jcb_e13.cc:566
virtual int dr() const
Dimension of the range.
Definition: jcb_space.cc:348
virtual int dr() const
Dimension of the range.
Definition: jcb.cc:915
An abstract client handle for a member of a poset.
std::string path() const
The full path as a string.
Definition: poset_path.cc:450
vd_dof_type dof_type
The type of the degrees of freedom. Note that although dof_type == value_type in this implementation...
Definition: vd.h:431
virtual const std::string & class_name() const
The name of this class.
Definition: jcb_e13.cc:1137
SHEAF_DLL_SPEC void push(const jcb &xjcb, const at1 &xvector, at1 &xresult, bool xauto_access)
Push vector forward (pre-allocated version for persistent types).
Definition: jcb.cc:1374
virtual void put_component(int xindex, value_type xvalue)
Sets the value of the xindex-th component to xvalue.
Definition: vd.cc:1169
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
Namespace for the fiber_bundles component of the sheaf system.
virtual int dd() const
Dimension of the domain.
Definition: jcb_e13.cc:327
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
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