SheafSystem  0.0.0.0
sec_st4.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_st4.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_stp_space.h"
30 #include "SheafSystem/sec_tuple_space.impl.h"
31 #include "SheafSystem/section_space_schema_member.impl.h"
32 #include "SheafSystem/section_space_schema_poset.h"
33 #include "SheafSystem/stp.h"
34 #include "SheafSystem/stp_space.h"
35 
36 
37 using namespace std;
38 using namespace fiber_bundle; // Workaround for MS C++ bug.
39 
40 //=============================================================================
41 // CLASS SEC_ST4
42 //=============================================================================
43 
44 // ===========================================================
45 // HOST FACTORY FACET OF CLASS SEC_ST2
46 // ===========================================================
47 
48 // PUBLIC MEMBER FUNCTIONS
49 
53  const poset_path& xhost_path,
54  const poset_path& xschema_path,
55  const poset_path& xscalar_space_path,
56  bool xauto_access)
57 {
58  // cout << endl << "Entering sec_st4::new_host." << endl;
59 
60  // Preconditions:
61 
62  require(xns.state_is_auto_read_write_accessible(xauto_access));
63 
64  require(!xhost_path.empty());
65  require(!xns.contains_path(xhost_path, xauto_access));
66 
67  require(xschema_path.full());
68  require(xns.path_is_auto_read_accessible<schema_type::host_type>(xschema_path, xauto_access));
69  require(host_type::fiber_space_conforms<fiber_type::host_type>(xns, xschema_path, xauto_access));
70 
71  require(xns.path_is_auto_read_accessible<scalar_type::host_type>(xscalar_space_path, xauto_access));
72 
73  require(host_type::same_scalar_fiber_space(xns, xschema_path, xscalar_space_path, xauto_access));
74 
75  // Body:
76 
77  host_type& result = host_type::new_table(xns, xhost_path, xschema_path, xscalar_space_path, xauto_access);
78 
79  // Postconditions:
80 
81  ensure(xns.owns(result, xauto_access));
82  ensure(result.path(true) == xhost_path);
83  ensure(result.state_is_not_read_accessible());
84  ensure(result.schema(true).path(xauto_access) == xschema_path);
85 
86  ensure(result.factor_ct(true) == result.schema(true).fiber_space<fiber_type::host_type>().factor_ct(xauto_access));
87  ensure(result.d(true) == result.schema(true).fiber_space<fiber_type::host_type>().d(xauto_access));
88  ensure(result.d(true) == result.dd(true));
89  ensure(result.scalar_space_path(true) == xscalar_space_path);
90  ensure(result.p(true) == result.schema(true).fiber_space<fiber_type::host_type>().p(xauto_access));
91  ensure(result.p(true) == 4);
92  ensure(result.dd(true) == result.schema(true).fiber_space<fiber_type::host_type>().dd(xauto_access));
93  ensure(result.vector_space_path(true) == xhost_path);
94 
95  // Exit:
96 
97  // cout << "Leaving sec_st4::new_host." << endl;
98  return result;
99 }
100 
101 // PROTECTED MEMBER FUNCTIONS
102 
103 // PRIVATE MEMBER FUNCTIONS
104 
105 
106 //==============================================================================
107 // ST4 FACET OF CLASS SEC_ST4
108 //==============================================================================
109 
110 // PUBLIC MEMBER FUNCTIONS
111 
114 {
115  // Preconditions:
116 
117  // Body:
118 
119  // Postconditions:
120 
121  ensure(invariant());
122 }
123 
125 sec_st4(const sec_rep_space* xhost, pod_index_type xhub_id)
126 {
127  // Preconditions:
128 
129  require(xhost != 0);
130  require(xhost->state_is_read_accessible());
131  require(xhost->contains_member(xhub_id));
132 
133  // Body:
134 
135  attach_to_state(xhost, xhub_id);
136 
137  // Postconditions:
138 
139  ensure(invariant());
140  //ensure(host() == xhost);
141  ensure(index() == xhub_id);
142  ensure(is_attached());
143  ensure(!is_restricted());
144 }
145 
147 sec_st4(const sec_rep_space* xhost, const scoped_index& xid)
148 {
149  // Preconditions:
150 
151  require(xhost != 0);
152  require(xhost->state_is_read_accessible());
153  require(xhost->contains_member(xid));
154 
155  // Body:
156 
157  attach_to_state(xhost, xid.hub_pod());
158 
159  // Postconditions:
160 
161  ensure(invariant());
162  //ensure(host() == xhost);
163  ensure(index() ==~ xid);
164  ensure(is_attached());
165  ensure(!is_restricted());
166 }
167 
169 sec_st4(const sec_rep_space* xhost, const std::string& xname)
170 {
171 
172  // Preconditions:
173 
174  require(xhost != 0);
175  require(xhost->state_is_read_accessible());
176  require(!xname.empty());
177  require(xhost->contains_member(xname));
178 
179  // Body:
180 
181  attach_to_state(xhost, xname);
182 
183  // Postconditions:
184 
185  ensure(invariant());
186  //ensure(host() == xhost);
187  ensure(name() == xname);
188  ensure(is_attached());
189  ensure(!is_restricted());
190 
191 }
192 
193 
195 sec_st4(const namespace_poset* xnamespace,
196  const poset_path& xpath,
197  bool xauto_access)
198 {
199 
200  // Preconditions:
201 
202  require(precondition_of(attach_to_state(same args)));
203 
204  // Body:
205 
206  attach_to_state(xnamespace, xpath, xauto_access);
207 
208  // Postconditions:
209 
210  ensure(postcondition_of(attach_to_state(same args)));
211 
212  // Exit:
213 
214  return;
215 }
216 
217 
220 {
221 
222  // Preconditions:
223 
224  require(xother != 0);
225 
226  // Body:
227 
228  attach_to_state(xother);
229 
230  // Postconditions:
231 
232  ensure(invariant());
233  ensure(is_attached());
234  ensure(is_same_state(xother));
235  ensure(is_same_restriction(xother));
236 
237 }
238 
240 sec_st4(sec_rep_space* xhost, section_dof_map* xdof_map, bool xauto_access)
241 {
242 
243  // Preconditions:
244 
245  require(precondition_of(new_jim_state(xhost, xdof_map, false, xauto_access)));
246 
247  // Body:
248 
249  new_jim_state(xhost, xdof_map, false, xauto_access);
250 
251  // Postconditions:
252 
253  ensure(postcondition_of(new_jim_state(xhost, xdof_map, false, xauto_access)));
254 
255  // Exit:
256 
257  return;
258 }
259 
262  abstract_poset_member& xbase_mbr,
263  int xbase_version,
264  bool xauto_access)
265 {
266 
267  // Preconditions:
268 
269  require(precondition_of(new_jim_state(xhost, xbase_mbr, xbase_version, xauto_access)));
270 
271  // Body:
272 
273  new_jim_state(xhost, xbase_mbr, xbase_version, xauto_access);
274 
275  // Postconditions:
276 
277  ensure(postcondition_of(new_jim_state(xhost, xbase_mbr, xbase_version, xauto_access)));
278 
279  // Exit:
280 
281  return;
282 }
283 
287 {
288  // Preconditions:
289 
290  require(is_ancestor_of(&xother));
291  require(precondition_of(attach_to_state(&xother)));
292 
293  // Body:
294 
295  attach_to_state(&xother);
296 
297  // Postconditions:
298 
299  ensure(postcondition_of(attach_to_state(&xother)));
300 
301  // Exit:
302 
303  return *this;
304 }
305 
308 operator=(const sec_st4& xother)
309 {
310  // Preconditions:
311 
312  require(precondition_of(attach_to_state(&xother)));
313 
314  // Body:
315 
316  attach_to_state(&xother);
317 
318  // Postconditions:
319 
320  ensure(postcondition_of(attach_to_state(&xother)));
321 
322  // Exit:
323 
324  return *this;
325 }
326 
329 operator=(const st4& xfiber)
330 {
331  // Preconditions:
332 
333  require(precondition_of(sec_vd::operator=(xfiber)));
334 
335  // Body:
336 
337  sec_vd::operator=(xfiber);
338 
339  // Postconditions:
340 
341  ensure(postcondition_of(sec_vd::operator=(xfiber)));
342 
343  // Exit:
344 
345  return *this;
346 }
347 
350 operator=(const st4_lite& xfiber)
351 {
352  // Preconditions:
353 
354  require(precondition_of(sec_vd::operator=(xfiber)));
355 
356  // Body:
357 
358  sec_vd::operator=(xfiber);
359 
360  // Postconditions:
361 
362  ensure(postcondition_of(sec_vd::operator=(xfiber)));
363 
364  // Exit:
365 
366  return *this;
367 }
368 
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 // STP FACET OF CLASS SEC_ST4
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_ST4
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_ST4
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_ST4
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_ST4
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_st4");
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_st4* result = new sec_st4();
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_ST4
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 st4*>(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_st4*>(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_stp::invariant());
591 
592  if (invariant_check())
593  {
594  // Prevent recursive calls to invariant
595 
596  disable_invariant_check();
597 
598  invariance(is_attached() ? p() == 4 : 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 
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 ...
An abstract symmetric tensor section space of degree p.
Definition: sec_stp_space.h:47
~sec_st4()
Destructor.
Definition: sec_st4.cc:370
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...
bool is_ancestor_of(const any *xother) const
True if xother conforms to current.
Definition: sec_st4.cc:554
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.
bool invariant() const
Class invariant.
Definition: sec_st4.cc:580
STL namespace.
A schema poset for a section space. A binary Cartesian product subspace of the binary tensor product ...
A symmetric rank 4 tensor over an abstract vector space (persistent version).
Definition: st4.h:230
Abstract base class with useful features for all objects.
Definition: any.h:39
int p() const
The tensor degree of this space.
virtual section_space_schema_member & schema()
The schema for this poset (mutable version)
virtual int d(int xp, int xdd) const
Dimension d() as a function of degree xp and domain dimension xdd.
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
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 const std::string & class_name() const
The name of this class.
Definition: sec_st4.cc:454
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
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_st4.cc:52
virtual const fiber_type & fiber_prototype() const
Virtual constructor for the associated fiber type.
Definition: sec_st4.cc:382
virtual sec_st4 * clone() const
Make a new handle, no state instance of current.
Definition: sec_st4.cc:492
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).
bool fiber_is_ancestor_of(const any *xother) const
True if xother conforms to an instance of the fiber of current.
Definition: sec_st4.cc:527
A section of a bundle with fiber type st4.
Definition: sec_st4.h:46
sec_st4()
Default constructor.
Definition: sec_st4.cc:113
static const std::string & static_class_name()
The name of this class.
Definition: sec_st4.cc:473
An abstract client handle for a member of a poset.
An abstract symmetric tensor space of degree p.
Definition: stp_space.h:42
Namespace for the fiber_bundles component of the sheaf system.
virtual sec_st4 & operator=(const abstract_poset_member &xother)
Assignment operator; synonym for attach_to_state(&xother).
Definition: sec_st4.cc:286
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 symmetric rank 4 tensor over an abstract vector space. (volatile version).
Definition: st4.h:43
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