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