SheafSystem  0.0.0.0
met_ed.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_ed.h"
22 
23 #include "SheafSystem/abstract_poset_member.impl.h"
24 #include "SheafSystem/assert_contract.h"
25 #include "SheafSystem/at0.h"
26 #include "SheafSystem/stp_space.h"
27 #include "SheafSystem/fiber_bundles_namespace.h"
28 #include "SheafSystem/schema_poset_member.h"
29 #include "SheafSystem/wsv_block.h"
30 
31 using namespace std;
32 using namespace fiber_bundle; // Workaround for MS C++ bug.
33 
34 
35 //==============================================================================
36 // CLASS MET_ED_LITE
37 //==============================================================================
38 
39 //==============================================================================
40 // EUCLIDEAN METRIC (MET_ED) FACET
41 //==============================================================================
42 
43 // PUBLIC MEMBER FUNCTIONS
44 
47 {
48 
49  // Preconditions:
50 
51  // Body:
52 
53  // Postconditions:
54 
55  ensure(invariant());
56 
57  // Exit:
58 }
59 
61 met_ed_lite(const met_ed_lite& xother)
62 {
63  // Preconditions:
64 
65  // Body:
66 
67  // Postconditions:
68 
69  ensure(invariant());
70 
71  // Exit:
72 }
73 
76 operator=(const met_ed_lite& xother)
77 {
78 
79  // Preconditions:
80 
81 
82  // Body:
83 
84 
85  // Postconditions:
86 
87  ensure(invariant());
88 
89  // Exit:
90 
91  return *this;
92 }
93 
96 {
97 
98  // Preconditions:
99 
100 
101  // Body:
102 
103 
104  // Postconditions:
105 
106  // Exit:
107 
108 }
109 
111 met_ed_lite(const row_dofs_type& xrow_dofs)
112 {
113  // Preconditions:
114 
115  // Body:
116 
117  *this = xrow_dofs;
118 
119  // Postconditions:
120 
121  ensure(invariant());
122 
123  // Exit:
124 }
125 
128 operator=(const row_dofs_type& xrow_dofs)
129 {
130  // Preconditions:
131 
132  // Body:
133 
134  vd_lite::operator=(xrow_dofs);
135 
136  // Postconditions:
137 
138  postcondition_of(vd_lite::operator=(xrow_dofs));
139 
140  // Exit:
141 
142  return *this;
143 
144 }
145 
146 //==============================================================================
147 // METRIC TENSOR (MET) FACET
148 //==============================================================================
149 
150 // PUBLIC MEMBER FUNCTIONS
151 
152 // PROTECTED MEMBER FUNCTIONS
153 
154 // PRIVATE MEMBER FUNCTIONS
155 
156 
157 //==============================================================================
158 // ST2 FACET
159 //==============================================================================
160 
161 // PUBLIC MEMBER FUNCTIONS
162 
163 // PROTECTED MEMBER FUNCTIONS
164 
165 // PRIVATE MEMBER FUNCTIONS
166 
167 
168 //==============================================================================
169 // INTERIOR ALGEBRA (STP) FACET
170 //==============================================================================
171 
172 // PUBLIC MEMBER FUNCTIONS
173 
174 // PROTECTED MEMBER FUNCTIONS
175 
176 // PRIVATE MEMBER FUNCTIONS
177 
178 
179 //==============================================================================
180 // TENSOR ALGEBRA (TP) FACET
181 //==============================================================================
182 
183 // PUBLIC MEMBER FUNCTIONS
184 
185 // PROTECTED MEMBER FUNCTIONS
186 
187 // PRIVATE MEMBER FUNCTIONS
188 
189 
190 //==============================================================================
191 // VECTOR ALGEBRA (VD) FACET
192 //==============================================================================
193 
194 // PUBLIC MEMBER FUNCTIONS
195 
196 // PROTECTED MEMBER FUNCTIONS
197 
198 // PRIVATE MEMBER FUNCTIONS
199 
200 
201 //==============================================================================
202 // CARTESIAN ALGEBRA (TUPLE) FACET
203 //==============================================================================
204 
205 // PUBLIC MEMBER FUNCTIONS
206 
207 // PROTECTED MEMBER FUNCTIONS
208 
209 // PRIVATE MEMBER FUNCTIONS
210 
211 
212 //==============================================================================
213 // ABSTRACT POSET MEMBER FACET
214 //==============================================================================
215 
216 // PUBLIC MEMBER FUNCTIONS
217 
218 const std::string&
220 class_name() const
221 {
222  // Preconditions:
223 
224  // Body:
225 
226  const string& result = static_class_name();
227 
228  // Postconditions:
229 
230  ensure(!result.empty());
231 
232  // Exit:
233 
234  return result;
235 }
236 
237 const std::string&
240 {
241  // Preconditions:
242 
243  // Body:
244 
245  static const string result("met_ed_lite");
246 
247  // Postconditions:
248 
249  ensure(!result.empty());
250 
251  // Exit:
252 
253  return result;
254 }
255 
258 clone() const
259 {
260  met_ed_lite* result = 0;
261 
262  // Preconditions:
263 
264  // Body:
265 
266  result = new met_ed_lite();
267 
268  // Postconditions:
269 
270  ensure(result != 0);
271  ensure(is_same_type(*result));
272 
273  // Exit:
274 
275  return result;
276 }
277 
278 // PROTECTED MEMBER FUNCTIONS
279 
280 // PRIVATE MEMBER FUNCTIONS
281 
282 
283 //==============================================================================
284 // ANY FACET
285 //==============================================================================
286 
287 // PUBLIC MEMBER FUNCTIONS
288 
289 bool
291 is_ancestor_of(const any_lite& xother) const
292 {
293  // Preconditions:
294 
295  require(&xother != 0);
296 
297  // Body:
298 
299  // True if other conforms to this.
300 
301  bool result = dynamic_cast<const met_ed_lite*>(&xother) != 0;
302 
303  // Postconditions:
304 
305  return result;
306 }
307 
308 bool
310 invariant() const
311 {
312  bool result = true;
313 
314  if(invariant_check())
315  {
316  // Prevent recursive calls to invariant.
317 
318  disable_invariant_check();
319 
320  // Must satisfy base class invariant.
321 
322  invariance(met_lite::invariant());
323 
324  // Invariances for this class:
325 
326  // Finished, turn invariant checking back on.
327 
328  enable_invariant_check();
329  }
330 
331  // Exit
332 
333  return result;
334 }
335 
336 //==============================================================================
337 // CLASS MET_ED
338 //==============================================================================
339 
340 // ===========================================================
341 // HOST FACTORY FACET OF CLASS MET_ED
342 // ===========================================================
343 
344 // PUBLIC MEMBER FUNCTIONS
345 
346 const sheaf::poset_path&
349 {
350  // Preconditions:
351 
352 
353  // Body:
354 
355  static const poset_path result(standard_schema_poset_name(), "met_ed_schema");
356 
357  // Postconditions:
358 
359  // Exit:
360 
361  return result;
362 }
363 
364 void
367 {
368  // Preconditions:
369 
370  require(xns.state_is_read_write_accessible());
371  require(xns.contains_poset(standard_schema_poset_name()));
372  require(!xns.contains_poset_member(standard_schema_path()));
373 
374  // Body:
375 
376  schema_poset_member lschema(xns,
377  standard_schema_path().member_name(),
378  met::standard_schema_path(),
379  "",
380  false);
381 
382  lschema.detach_from_state();
383 
384  // Postconditions:
385 
386  ensure(xns.contains_poset_member(standard_schema_path()));
387 
388  // Exit:
389 
390  return;
391 }
392 
396  const poset_path& xhost_path,
397  const poset_path& xschema_path,
398  const poset_path& xvector_space_path,
399  bool xauto_access)
400 {
401  // cout << endl << "Entering met_ed::new_host." << endl;
402 
403  // Preconditions:
404 
405  require(xns.state_is_auto_read_write_accessible(xauto_access));
406 
407  require(!xhost_path.empty());
408  require(!xns.contains_path(xhost_path, xauto_access));
409 
410  require(xschema_path.full());
411  require(xns.path_is_auto_read_accessible(xschema_path, xauto_access));
412  require(schema_poset_member::conforms_to(xns, xschema_path, standard_schema_path()));
413 
414  require(xns.path_is_auto_read_accessible(xvector_space_path, xauto_access));
415  require(xns.contains_poset<scalar_type::host_type>(xvector_space_path, xauto_access));
416 
417  // Body:
418 
419  host_type& result =
420  host_type::new_table(xns, xhost_path, xschema_path, 2, xvector_space_path, xauto_access);
421 
422  // Postconditions:
423 
424  ensure(xns.owns(result, xauto_access));
425  ensure(result.path(true) == xhost_path);
426  ensure(result.state_is_not_read_accessible());
427  ensure(result.schema(true).path(xauto_access) == xschema_path);
428 
429  ensure(result.factor_ct(true) == result.d(true));
430  ensure(result.d(true) == schema_poset_member::row_dof_ct(xns, xschema_path, xauto_access));
431  ensure(result.vector_space_path(true) == xvector_space_path );
432  ensure(result.p(true) == 2);
433  ensure(result.dd(true) == result.d(true));
434  ensure(result.vector_space_path(true) == xhost_path );
435 
436  // Exit:
437 
438  // cout << "Leaving met_ed::new_host." << endl;
439  return result;
440 }
441 
442 // PROTECTED MEMBER FUNCTIONS
443 
444 // PRIVATE MEMBER FUNCTIONS
445 
446 
447 //==============================================================================
448 // MET_ED FACET
449 //==============================================================================
450 
451 // PUBLIC MEMBER FUNCTIONS
452 
455 {
456 
457  // Preconditions:
458 
459  // Body:
460 
461  // Postconditions:
462 
463  ensure(invariant());
464 }
465 
468 {
469  // Preconditions:
470 
471  require(xhost != 0);
472  require(xhost->state_is_read_accessible());
473  require(xhost->contains_member(xhub_id));
474 
475  // Body:
476 
477  attach_to_state(xhost, xhub_id);
478 
479  // Postconditions:
480 
481  ensure(invariant());
482  // ensure(host() == xhost);
483  ensure(index() == xhub_id);
484  ensure(is_attached());
485 }
486 
488 met_ed(const poset_state_handle* xhost, const scoped_index& xid)
489 {
490  // Preconditions:
491 
492  require(xhost != 0);
493  require(xhost->state_is_read_accessible());
494  require(xhost->contains_member(xid));
495 
496  // Body:
497 
498  attach_to_state(xhost, xid.hub_pod());
499 
500  // Postconditions:
501 
502  ensure(invariant());
503  // ensure(host() == xhost);
504  ensure(index() ==~ xid);
505  ensure(is_attached());
506 }
507 
509 met_ed(const poset_state_handle* xhost, const std::string& xname)
510 {
511 
512  // Preconditions:
513 
514  require(xhost != 0);
515  require(xhost->state_is_read_accessible());
516  require(!xname.empty());
517  require(xhost->contains_member(xname));
518 
519  // Body:
520 
521  attach_to_state(xhost, xname);
522 
523  // Postconditions:
524 
525  ensure(invariant());
526  // ensure(host() == xhost);
527  ensure(name() == xname);
528  ensure(is_attached());
529 
530 }
531 
534 {
535 
536  // Preconditions:
537 
538  require(xother != 0);
539 
540  // Body:
541 
542  attach_to_state(xother);
543 
544  // Postconditions:
545 
546  ensure(invariant());
547  ensure(is_attached());
548  ensure(is_same_state(xother));
549 
550 }
551 
553 met_ed(poset_state_handle* xhost, bool xauto_access)
554 {
555 
556  // Preconditions:
557 
558  require(precondition_of(new_jim_state(xhost, 0, false, xauto_access)));
559 
560  // Body:
561 
562  new_jim_state(xhost, 0, false, xauto_access);
563 
564  // Postconditions:
565 
566  ensure(postcondition_of(new_jim_state(xhost, 0, false, xauto_access)));
567 
568  // Exit:
569 
570  return;
571 }
572 
577 {
578  // Preconditions:
579 
580  require(is_ancestor_of(&xother));
581  require(precondition_of(attach_to_state(&xother)));
582 
583  // Body:
584 
585  attach_to_state(&xother);
586 
587  // Postconditions:
588 
589  ensure(postcondition_of(attach_to_state(&xother)));
590 
591  // Exit:
592 
593  return *this;
594 }
595 
599 operator=(const met_ed& xother)
600 {
601  // Preconditions:
602 
603  require(precondition_of(attach_to_state(&xother)));
604 
605  // Body:
606 
607  attach_to_state(&xother);
608 
609  // Postconditions:
610 
611  ensure(postcondition_of(attach_to_state(&xother)));
612 
613  // Exit:
614 
615  return *this;
616 }
617 
620 {
621  // Preconditions:
622 
623  // Body:
624 
625  // Postconditions:
626 
627 }
628 
632 {
633  // Preconditions:
634 
635  // Body:
636 
637  static const volatile_type result;
638 
639  // Postconditions:
640 
641  // Exit:
642 
643  return result;
644 }
645 
649 lite_type() const
650 {
651  // Preconditions:
652 
653  // Body:
654 
655  volatile_type* result = new volatile_type(sheaf::row_dofs(*this));
656 
657  // Postconditions:
658 
659  // Exit:
660 
661  return result;
662 }
663 
664 
665 //==============================================================================
666 // MET FACET
667 //==============================================================================
668 
669 // PUBLIC MEMBER FUNCTIONS
670 
671 // PROTECTED MEMBER FUNCTIONS
672 
673 // PRIVATE MEMBER FUNCTIONS
674 
675 
676 //==============================================================================
677 // ST2 FACET
678 //==============================================================================
679 
680 // PUBLIC MEMBER FUNCTIONS
681 
682 // PROTECTED MEMBER FUNCTIONS
683 
684 // PRIVATE MEMBER FUNCTIONS
685 
686 
687 //==============================================================================
688 // INTERIOR ALGEBRA (STP) FACET
689 //==============================================================================
690 
691 // PUBLIC MEMBER FUNCTIONS
692 
693 // PROTECTED MEMBER FUNCTIONS
694 
695 // PRIVATE MEMBER FUNCTIONS
696 
697 
698 //==============================================================================
699 // TENSOR ALGEBRA (TP) FACET
700 //==============================================================================
701 
702 // PUBLIC MEMBER FUNCTIONS
703 
704 // PROTECTED MEMBER FUNCTIONS
705 
706 // PRIVATE MEMBER FUNCTIONS
707 
708 
709 //==============================================================================
710 // VECTOR ALGEBRA (VD) FACET
711 //==============================================================================
712 
713 // PUBLIC MEMBER FUNCTIONS
714 
715 // PROTECTED MEMBER FUNCTIONS
716 
717 // PRIVATE MEMBER FUNCTIONS
718 
719 
720 //==============================================================================
721 // CARTESIAN ALGEBRA (TUPLE) FACET
722 //==============================================================================
723 
724 // PUBLIC MEMBER FUNCTIONS
725 
726 // PROTECTED MEMBER FUNCTIONS
727 
728 // PRIVATE MEMBER FUNCTIONS
729 
730 
731 //==============================================================================
732 // ABSTRACT POSET MEMBER FACET
733 //==============================================================================
734 
735 // PUBLIC MEMBER FUNCTIONS
736 
737 const std::string&
739 class_name() const
740 {
741  // Preconditions:
742 
743  // Body:
744 
745  const string& result = static_class_name();
746 
747  // Postconditions:
748 
749  ensure(!result.empty());
750 
751  // Exit:
752 
753  return result;
754 }
755 
756 const std::string&
759 {
760  // Preconditions:
761 
762  // Body:
763 
764  static const string result("met_ed");
765 
766  // Postconditions:
767 
768  ensure(!result.empty());
769 
770  // Exit:
771 
772  return result;
773 }
774 
777 clone() const
778 {
779 
780  // Preconditions:
781 
782  // Body:
783 
784  // Create new handle of the current class..
785 
786  met_ed *result = new met_ed();
787 
788  // Postconditions:
789 
790  ensure(result != 0);
791  ensure(result->invariant());
792 
793  // Exit:
794 
795  return result;
796 
797 }
798 
799 // PROTECTED MEMBER FUNCTIONS
800 
801 // PRIVATE MEMBER FUNCTIONS
802 
803 
804 //==============================================================================
805 // ANY FACET
806 //==============================================================================
807 
808 // PUBLIC MEMBER FUNCTIONS
809 
810 bool
812 is_ancestor_of(const any* xother) const
813 {
814 
815  // Preconditions:
816 
817  require(xother != 0);
818 
819  // Body:
820 
821  // If xother may be dynamically cast to the type of this then this is an
822  // ancestor of other.
823 
824  bool result = dynamic_cast<const met_ed*>(xother) != 0;
825 
826  // Postconditions:
827 
828  // ensure(invariant());
829 
830  // Exit:
831 
832  return result;
833 
834 }
835 
836 bool
838 invariant() const
839 {
840  bool result = true;
841 
842  // Preconditions:
843 
844  // Body:
845 
846  // Must satisfy base class invariant.
847 
848  invariance(met::invariant());
849 
850  if (invariant_check())
851  {
852  // Prevent recursive calls to invariant.
853 
854  disable_invariant_check();
855 
856  // Invariants for this class:
857 
858  // Finished, turn invariant checking back on.
859 
860  enable_invariant_check();
861  }
862 
863  // Postconditions:
864 
865  ensure(is_derived_query);
866 
867  // Exit:
868 
869  return result;
870 }
871 
872 // PROTECTED MEMBER FUNCTIONS
873 
874 // PRIVATE MEMBER FUNCTIONS
875 
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 ...
bool full() const
True if both poset name and member name are not empty.
Definition: poset_path.cc:311
static void make_standard_schema(namespace_poset &xns)
Creates the standard schema for this class in namespace xns.
Definition: met_ed.cc:366
poset_path path(bool xauto_access=true) const
A path to this component.
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_ed.cc:395
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
virtual volatile_type * lite_type() const
Virtual conversion to the associated volatile type.
Definition: met_ed.cc:649
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...
A client handle for a general, abstract partially order set.
A metric tensor over a d-dimensional Euclidean vector space (persistent version). ...
Definition: met_ed.h:215
virtual const std::string & class_name() const
The name of this class.
Definition: met_ed.cc:739
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 const volatile_type & lite_prototype() const
Virtual constructor for the associated volatile type.
Definition: met_ed.cc:631
bool invariant() const
Class invariant.
Definition: met_ed.cc:838
STL namespace.
bool invariant() const
Class invariant.
Definition: met_ed.cc:310
virtual ~met_ed_lite()
Destructor.
Definition: met_ed.cc:95
A metric tensor over a d-dimensional Euclidean vector space (volatile version).
Definition: met_ed.h:43
met_ed_lite & operator=(const met_ed_lite &xother)
Assignment operator.
Definition: met_ed.cc:76
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 met_ed & operator=(const abstract_poset_member &xother)
Assignment operator; synonym for attach_to_state(&xother).
Definition: met_ed.cc:576
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
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).
A space of scalars viewed as an antisymmetric tensor space of degree 0.
Definition: at0_space.h:42
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)
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
virtual const std::string & class_name() const
The name of this class.
Definition: met_ed.cc:220
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. ...
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
met_ed()
Default constructor.
Definition: met_ed.cc:454
bool empty() const
True if both poset name and member name are empty.
Definition: poset_path.cc:291
bool contains_poset(pod_index_type xhub_id, bool xauto_access=true) const
True if this contains a poset with hub id xhub_id..
~met_ed()
Destructor.
Definition: met_ed.cc:619
static int factor_ct(int xd)
Factor_ct() as a function of dimension xd.
Definition: vd_space.cc:167
virtual bool is_ancestor_of(const any_lite &xother) const
Conformance test; true if other conforms to this.
Definition: met_ed.cc:291
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
int dd() const
The dimension of the underlying ("domain") vector space.
Definition: tp_space.cc:317
static const std::string & static_class_name()
The name of this class.
Definition: met_ed.cc:758
bool is_ancestor_of(const any *xother) const
True if xother conforms to current.
Definition: met_ed.cc:812
An abstract client handle for a member of a poset.
static const std::string & static_class_name()
The name of this class.
Definition: met_ed.cc:239
static const poset_path & standard_schema_path()
The path to the standard schema for this class.
Definition: met_ed.cc:348
virtual met_ed * clone() const
Make a new handle, no state instance of current.
Definition: met_ed.cc:777
An abstract symmetric tensor space of degree p.
Definition: stp_space.h:42
Namespace for the fiber_bundles component of the sheaf system.
Row dofs type for class vd.
Definition: vd.h:61
virtual met_ed_lite * clone() const
Virtual constructor, makes a new instance of the same type as this.
Definition: met_ed.cc:258
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.
met_ed_lite()
Default constructor.
Definition: met_ed.cc:46
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.
Definition: scoped_index.h:710