SheafSystem  0.0.0.0
sec_at2.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/sec_at2.h"
22 
23 #include "SheafSystem/assert_contract.h"
24 #include "SheafSystem/binary_section_space_schema_member.impl.h"
25 #include "SheafSystem/binary_section_space_schema_poset.h"
26 #include "SheafSystem/fiber_bundles_namespace.h"
27 #include "SheafSystem/sec_at0.h"
28 #include "SheafSystem/sec_at0_space.h"
29 #include "SheafSystem/sec_tuple_space.impl.h"
30 #include "SheafSystem/section_space_schema_member.impl.h"
31 #include "SheafSystem/section_space_schema_poset.h"
32 #include "SheafSystem/atp.h"
33 #include "SheafSystem/atp_space.h"
34 
35 using namespace std;
36 using namespace fiber_bundle; // Workaround for MS C++ bug.
37 
38 //=============================================================================
39 // CLASS SEC_AT2
40 //=============================================================================
41 
42 // ===========================================================
43 // HOST FACTORY FACET OF CLASS SEC_AT2
44 // ===========================================================
45 
46 // PUBLIC MEMBER FUNCTIONS
47 
51  const poset_path& xhost_path,
52  const poset_path& xschema_path,
53  const poset_path& xscalar_space_path,
54  bool xauto_access)
55 {
56  // cout << endl << "Entering sec_at2::new_host." << endl;
57 
58  // Preconditions:
59 
60  require(xns.state_is_auto_read_write_accessible(xauto_access));
61 
62  require(!xhost_path.empty());
63  require(!xns.contains_path(xhost_path, xauto_access));
64 
65  require(xschema_path.full());
66  require(xns.path_is_auto_read_accessible<schema_type::host_type>(xschema_path, xauto_access));
67  require(host_type::fiber_space_conforms<fiber_type::host_type>(xns, xschema_path, xauto_access));
68 
69  require(xns.path_is_auto_read_accessible<scalar_type::host_type>(xscalar_space_path, xauto_access));
70 
71  require(host_type::same_scalar_fiber_space(xns, xschema_path, xscalar_space_path, xauto_access));
72 
73  // Body:
74 
75  host_type& result = host_type::new_table(xns, xhost_path, xschema_path, xscalar_space_path, xauto_access);
76 
77  // Postconditions:
78 
79  ensure(xns.owns(result, xauto_access));
80  ensure(result.path(true) == xhost_path);
81  ensure(result.state_is_not_read_accessible());
82  ensure(result.schema(true).path(xauto_access) == xschema_path);
83 
84  ensure(result.factor_ct(true) == result.schema(true).fiber_space<fiber_type::host_type>().factor_ct(xauto_access));
85  ensure(result.d(true) == result.schema(true).fiber_space<fiber_type::host_type>().d(xauto_access));
86  ensure(result.d(true) == result.dd(true));
87  ensure(result.scalar_space_path(true) == xscalar_space_path);
88  ensure(result.p(true) == result.schema(true).fiber_space<fiber_type::host_type>().p(xauto_access));
89  ensure(result.p(true) == 2);
90  ensure(result.dd(true) == result.schema(true).fiber_space<fiber_type::host_type>().dd(xauto_access));
91  ensure(result.vector_space_path(true) == xhost_path);
92 
93  // Exit:
94 
95  // cout << "Leaving sec_at2::new_host." << endl;
96  return result;
97 }
98 
99 // PROTECTED MEMBER FUNCTIONS
100 
101 // PRIVATE MEMBER FUNCTIONS
102 
103 
104 //==============================================================================
105 // AT2 FACET OF CLASS SEC_AT2
106 //==============================================================================
107 
108 // PUBLIC MEMBER FUNCTIONS
109 
112 {
113 
114  // Preconditions:
115 
116  // Body:
117 
118  // Postconditions:
119 
120  ensure(invariant());
121 }
122 
124 sec_at2(const sec_rep_space* xhost, pod_index_type xhub_id)
125 {
126  // Preconditions:
127 
128  require(xhost != 0);
129  require(xhost->state_is_read_accessible());
130  require(xhost->contains_member(xhub_id));
131 
132  // Body:
133 
134  attach_to_state(xhost, xhub_id);
135 
136  // Postconditions:
137 
138  ensure(invariant());
139  //ensure(host() == xhost);
140  ensure(index() == xhub_id);
141  ensure(is_attached());
142  ensure(!is_restricted());
143 }
144 
146 sec_at2(const sec_rep_space* xhost, const scoped_index& xid)
147 {
148  // Preconditions:
149 
150  require(xhost != 0);
151  require(xhost->state_is_read_accessible());
152  require(xhost->contains_member(xid));
153 
154  // Body:
155 
156  attach_to_state(xhost, xid.hub_pod());
157 
158  // Postconditions:
159 
160  ensure(invariant());
161  //ensure(host() == xhost);
162  ensure(index() ==~ xid);
163  ensure(is_attached());
164  ensure(!is_restricted());
165 }
166 
168 sec_at2(const sec_rep_space* xhost, const std::string& xname)
169 {
170 
171  // Preconditions:
172 
173  require(xhost != 0);
174  require(xhost->state_is_read_accessible());
175  require(!xname.empty());
176  require(xhost->contains_member(xname));
177 
178  // Body:
179 
180  attach_to_state(xhost, xname);
181 
182  // Postconditions:
183 
184  ensure(invariant());
185  //ensure(host() == xhost);
186  ensure(name() == xname);
187  ensure(is_attached());
188  ensure(!is_restricted());
189 
190 }
191 
192 
194 sec_at2(const namespace_poset* xnamespace,
195  const poset_path& xpath,
196  bool xauto_access)
197 {
198 
199  // Preconditions:
200 
201  require(precondition_of(attach_to_state(same args)));
202 
203  // Body:
204 
205  attach_to_state(xnamespace, xpath, xauto_access);
206 
207  // Postconditions:
208 
209  ensure(postcondition_of(attach_to_state(same args)));
210 
211  // Exit:
212 
213  return;
214 }
215 
216 
219 {
220 
221  // Preconditions:
222 
223  require(xother != 0);
224 
225  // Body:
226 
227  attach_to_state(xother);
228 
229  // Postconditions:
230 
231  ensure(invariant());
232  ensure(is_attached());
233  ensure(is_same_state(xother));
234  ensure(is_same_restriction(xother));
235 
236 }
237 
239 sec_at2(sec_rep_space* xhost, section_dof_map* xdof_map, bool xauto_access)
240 {
241 
242  // Preconditions:
243 
244  require(precondition_of(new_jim_state(xhost, xdof_map, false, xauto_access)));
245 
246  // Body:
247 
248  new_jim_state(xhost, xdof_map, false, xauto_access);
249 
250  // Postconditions:
251 
252  ensure(postcondition_of(new_jim_state(xhost, xdof_map, false, xauto_access)));
253 
254  // Exit:
255 
256  return;
257 }
258 
261  abstract_poset_member& xbase_mbr,
262  int xbase_version,
263  bool xauto_access)
264 {
265 
266  // Preconditions:
267 
268  require(precondition_of(new_jim_state(xhost, xbase_mbr, xbase_version, xauto_access)));
269 
270  // Body:
271 
272  new_jim_state(xhost, xbase_mbr, xbase_version, xauto_access);
273 
274  // Postconditions:
275 
276  ensure(postcondition_of(new_jim_state(xhost, xbase_mbr, xbase_version, xauto_access)));
277 
278  // Exit:
279 
280  return;
281 }
282 
286 {
287  // Preconditions:
288 
289  require(is_ancestor_of(&xother));
290  require(precondition_of(attach_to_state(&xother)));
291 
292  // Body:
293 
294  attach_to_state(&xother);
295 
296  // Postconditions:
297 
298  ensure(postcondition_of(attach_to_state(&xother)));
299 
300  // Exit:
301 
302  return *this;
303 }
304 
307 operator=(const sec_at2& xother)
308 {
309  // Preconditions:
310 
311  require(precondition_of(attach_to_state(&xother)));
312 
313  // Body:
314 
315  attach_to_state(&xother);
316 
317  // Postconditions:
318 
319  ensure(postcondition_of(attach_to_state(&xother)));
320 
321  // Exit:
322 
323  return *this;
324 }
325 
328 operator=(const at2& xfiber)
329 {
330  // Preconditions:
331 
332  require(precondition_of(sec_vd::operator=(xfiber)));
333 
334  // Body:
335 
336  sec_vd::operator=(xfiber);
337 
338  // Postconditions:
339 
340  ensure(postcondition_of(sec_vd::operator=(xfiber)));
341 
342  // Exit:
343 
344  return *this;
345 }
346 
349 operator=(const at2_lite& xfiber)
350 {
351  // Preconditions:
352 
353  require(precondition_of(sec_vd::operator=(xfiber)));
354 
355  // Body:
356 
357  sec_vd::operator=(xfiber);
358 
359  // Postconditions:
360 
361  ensure(postcondition_of(sec_vd::operator=(xfiber)));
362 
363  // Exit:
364 
365  return *this;
366 }
367 
370 {
371 
372  // Preconditions:
373 
374  // Body:
375 
376  // Postconditions:
377 
378 }
379 
383 {
384  // Preconditions:
385 
386  // Body:
387 
388  static const fiber_type result;
389 
390  // Postconditions:
391 
392  // Exit:
393 
394  return result;
395 }
396 
397 // PROTECTED MEMBER FUNCTIONS
398 
399 // PRIVATE MEMBER FUNCTIONS
400 
401 
402 //==============================================================================
403 // ATP FACET OF CLASS SEC_AT2
404 //==============================================================================
405 
406 // PUBLIC MEMBER FUNCTIONS
407 
408 // PROTECTED MEMBER FUNCTIONS
409 
410 // PRIVATE MEMBER FUNCTIONS
411 
412 
413 //==============================================================================
414 // TP FACET OF CLASS SEC_AT2
415 //==============================================================================
416 
417 // PUBLIC MEMBER FUNCTIONS
418 
419 // PROTECTED MEMBER FUNCTIONS
420 
421 // PRIVATE MEMBER FUNCTIONS
422 
423 
424 //==============================================================================
425 // VD FACET OF CLASS SEC_AT2
426 //==============================================================================
427 
428 // PUBLIC MEMBER FUNCTIONS
429 
430 // PROTECTED MEMBER FUNCTIONS
431 
432 // PRIVATE MEMBER FUNCTIONS
433 
434 
435 //==============================================================================
436 // TUPLE FACET OF CLASS SEC_AT2
437 //==============================================================================
438 
439 // PUBLIC MEMBER FUNCTIONS
440 
441 // PROTECTED MEMBER FUNCTIONS
442 
443 // PRIVATE MEMBER FUNCTIONS
444 
445 
446 //==============================================================================
447 // ABSTRACT POSET MEMBER FACET OF CLASS SEC_AT2
448 //==============================================================================
449 
450 // PUBLIC MEMBER FUNCTIONS
451 
452 const std::string&
454 class_name() const
455 {
456  // Preconditions:
457 
458  // Body:
459 
460  const string& result = static_class_name();
461 
462  // Postconditions:
463 
464  ensure(!result.empty());
465 
466  // Exit:
467 
468  return result;
469 }
470 
471 const std::string&
474 {
475  // Preconditions:
476 
477  // Body:
478 
479  static const string result("sec_at2");
480 
481  // Postconditions:
482 
483  ensure(!result.empty());
484 
485  // Exit:
486 
487  return result;
488 }
489 
492 clone() const
493 {
494 
495  // Preconditions:
496 
497  // Body:
498 
499  // Create new handle of the current class.
500 
501  sec_at2 *result = new sec_at2();
502 
503  // Postconditions:
504 
505  ensure(result != 0);
506  ensure(result->invariant());
507 
508  // Exit:
509 
510  return result;
511 
512 }
513 
514 // PROTECTED MEMBER FUNCTIONS
515 
516 // PRIVATE MEMBER FUNCTIONS
517 
518 
519 //==============================================================================
520 // ANY FACET OF CLASS SEC_AT2
521 //==============================================================================
522 
523 // PUBLIC MEMBER FUNCTIONS
524 
525 bool
527 fiber_is_ancestor_of(const any* xother) const
528 {
529 
530  // Preconditions:
531 
532  require(xother != 0);
533 
534  // Body:
535 
536  // If xother may be dynamically cast to the type of this fiber then this
537  // fiber is an ancestor of xother.
538 
539  bool result = dynamic_cast<const at2*>(xother) != 0;
540 
541  // Postconditions:
542 
543  ensure(invariant());
544  ensure(xother->invariant());
545 
546  // Exit:
547 
548  return result;
549 
550 }
551 
552 bool
554 is_ancestor_of(const any* xother) const
555 {
556 
557  // Preconditions:
558 
559  require(xother != 0);
560 
561  // Body:
562 
563  // If other may be dynamically cast to the type of this then this is an
564  // ancestor of other.
565 
566  bool result = dynamic_cast<const sec_at2*>(xother) != 0;
567 
568  // Postconditions:
569 
570  //ensure(invariant());
571 
572  // Exit:
573 
574  return result;
575 
576 }
577 
578 bool
580 invariant() const
581 {
582  bool result = true;
583 
584  // Preconditions:
585 
586  // Body:
587 
588  // Must satisfy base class invariant
589 
590  invariance(sec_atp::invariant());
591 
592  if (invariant_check())
593  {
594  // Prevent recursive calls to invariant
595 
596  disable_invariant_check();
597 
598  invariance(is_attached() ? p() == 2 : true);
599 
600  // Finished, turn invariant checking back on.
601 
602  enable_invariant_check();
603  }
604 
605  // Postconditions:
606 
607  ensure(is_derived_query);
608 
609  // Exit:
610 
611  return result;
612 }
613 
614 // PROTECTED MEMBER FUNCTIONS
615 
616 // PRIVATE MEMBER FUNCTIONS
617 
618 
619 //##############################################################################
620 //##############################################################################
621 
622 
623 // fiber_bundle::sec_at2::scalar_type*
624 // fiber_bundle::sec_at2::
625 // comp2(int row, int col)
626 // {
627 
628 // // Preconditions:
629 
630 // require(0 <= row && row <= dd());
631 // require(0 <= col && col <= dd());
632 
633 // // Body:
634 
635 // int index = index_for_row_column(row, col);
636 // scalar_type* result = comp(index);
637 
638 // // Postconditions:
639 
640 // ensure(result != 0);
641 // ensure(invariant());
642 // ensure(result->invariant());
643 
644 // // Exit:
645 
646 // return result;
647 
648 // }
649 
650 // void
651 // fiber_bundle::sec_at2::
652 // set_comp2(int row, int col, scalar_type* new_comp)
653 // {
654 
655 // // Preconditions:
656 
657 // require(0 <= row && row <= dd());
658 // require(0 <= col && col <= dd());
659 // require(new_comp != 0);
660 
661 // // Body:
662 
663 // int index = index_for_row_column(row, col);
664 // set_comp(index, new_comp);
665 
666 // // Postconditions:
667 
668 // ensure(comp(index) == new_comp);
669 // ensure(invariant());
670 
671 // }
672 
virtual bool invariant() const
Class invariant, intended to be redefined in each descendant. See below for template for invariant in...
Definition: any.cc:153
static int factor_ct(int xd)
Factor_ct() as a function of dimension xd.
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
A Cartesian product section space.
The abstract map from section dof ids to section dof values of heterogeneous type.
poset_path path(bool xauto_access=true) const
A path to this component.
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...
A path defined by a poset name and a member name separated by a forward slash (&#39;/&#39;). For example: "cell_definitions/triangle".
Definition: poset_path.h:48
A member of a sec_rep_space; a section.
poset_path vector_space_path() const
The path of the underlying vector space.
STL namespace.
static host_type & new_host(namespace_type &xns, const poset_path &xhost_path, const poset_path &xschema_path, const poset_path &xscalar_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: sec_at2.cc:50
virtual const fiber_type & fiber_prototype() const
Virtual constructor for the associated fiber type.
Definition: sec_at2.cc:382
A schema poset for a section space. A binary Cartesian product subspace of the binary tensor product ...
Abstract base class with useful features for all objects.
Definition: any.h:39
int p() const
The tensor degree of this space.
An abstract antisymmetric tensor section space of degree p.
Definition: sec_atp_space.h:47
virtual section_space_schema_member & schema()
The schema for this poset (mutable version)
An abstract antisymmetric tensor space of degree p.
Definition: atp_space.h:42
~sec_at2()
Destructor.
Definition: sec_at2.cc:369
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
A section of a bundle with fiber type at2.
Definition: sec_at2.h:46
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 dd() const
The dimension of the underlying ("domain") vector space.
bool empty() const
True if both poset name and member name are empty.
Definition: poset_path.cc:291
sec_at2()
Default constructor.
Definition: sec_at2.cc:111
bool is_ancestor_of(const any *xother) const
True if xother conforms to current.
Definition: sec_at2.cc:554
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
poset_path scalar_space_path() const
The path of the underlying space of scalars.
poset & fiber_space()
The fiber space for section spaces on this schema (mutable version).
virtual sec_at2 * clone() const
Make a new handle, no state instance of current.
Definition: sec_at2.cc:492
bool fiber_is_ancestor_of(const any *xother) const
True if xother conforms to an instance of the fiber of current.
Definition: sec_at2.cc:527
A general antisymmetric tensor of degree 2 over an abstract vector space (volatile version)...
Definition: at2.h:43
An abstract client handle for a member of a poset.
virtual const std::string & class_name() const
The name of this class.
Definition: sec_at2.cc:454
Namespace for the fiber_bundles component of the sheaf system.
static const std::string & static_class_name()
The name of this class.
Definition: sec_at2.cc:473
A general antisymmetric tensor of degree 2 over an abstract vector space.
Definition: at2.h:233
virtual int d(int xp, int xdd) const
Dimension d() as a function of degree xp and domain dimension xdd.
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...
virtual sec_at2 & operator=(const abstract_poset_member &xother)
Assignment operator; synonym for attach_to_state(&xother).
Definition: sec_at2.cc:285
bool invariant() const
Class invariant.
Definition: sec_at2.cc:580
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.
Definition: scoped_index.h:710
A handle for a poset whose members are numerical representations of sections of a fiber bundle...
Definition: sec_rep_space.h:61