SheafSystem  0.0.0.0
sec_t4_e2.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 
22 #include "SheafSystem/sec_t4_e2.h"
23 
24 #include "SheafSystem/assert_contract.h"
25 #include "SheafSystem/base_space_poset.h"
26 #include "SheafSystem/binary_section_space_schema_member.impl.h"
27 #include "SheafSystem/at1_space.h"
28 #include "SheafSystem/fiber_bundles_namespace.h"
29 #include "SheafSystem/index_space_iterator.h"
30 #include "SheafSystem/sec_at0.h"
31 #include "SheafSystem/sec_at0_space.h"
32 #include "SheafSystem/sec_at1_space.h"
33 #include "SheafSystem/sec_e2.h"
34 #include "SheafSystem/sec_stp_space.h"
35 #include "SheafSystem/sec_tuple.impl.h"
36 #include "SheafSystem/sec_tuple_space.impl.h"
37 #include "SheafSystem/sec_vd.impl.h"
38 #include "SheafSystem/t4_e2.h"
39 #include "SheafSystem/stp_space.h"
40 
41 using namespace std;
42 using namespace fiber_bundle; // Workaround for MS C++ bug.
43 
44 //==============================================================================
45 // CLASS SEC_T4_E2
46 //==============================================================================
47 
48 // ===========================================================
49 // HOST FACTORY FACET OF CLASS SEC_T4_E2
50 // ===========================================================
51 
52 // PUBLIC MEMBER FUNCTIONS
53 
57  const poset_path& xhost_path,
58  const poset_path& xschema_path,
59  const poset_path& xvector_space_path,
60  bool xauto_access)
61 {
62  // cout << endl << "Entering sec_t4_e2::new_host." << endl;
63 
64  // Preconditions:
65 
66  require(xns.state_is_auto_read_write_accessible(xauto_access));
67 
68  require(!xhost_path.empty());
69  require(!xns.contains_path(xhost_path, xauto_access));
70 
71  require(xschema_path.full());
72  require(xns.path_is_auto_read_accessible<schema_type::host_type>(xschema_path, xauto_access));
73  require(host_type::fiber_space_conforms<fiber_type::host_type>(xns, xschema_path, xauto_access));
74 
75  require(xns.path_is_auto_read_accessible<vector_space_type::host_type>(xvector_space_path, xauto_access));
76 
77  require(host_type::same_vector_fiber_space(xns, xschema_path, xvector_space_path, xauto_access));
78 
79  // Body:
80 
81  host_type& result = host_type::new_table(xns, xhost_path, xschema_path, xvector_space_path, xauto_access);
82 
83  // Postconditions:
84 
85  ensure(xns.owns(result, xauto_access));
86  ensure(result.path(true) == xhost_path);
87  ensure(result.state_is_not_read_accessible());
88  ensure(result.schema(true).path(xauto_access) == xschema_path);
89 
90  ensure(result.factor_ct(true) == result.schema(true).fiber_space<fiber_type::host_type>().factor_ct(xauto_access));
91  ensure(result.d(true) == result.schema(true).fiber_space<fiber_type::host_type>().d(xauto_access));
92  ensure(result.scalar_space_path(true) ==
93  xns.member_poset<vector_space_type::host_type>(xvector_space_path, xauto_access).scalar_space_path(xauto_access));
94  ensure(result.p(true) == result.schema(true).fiber_space<fiber_type::host_type>().p(xauto_access));
95  ensure(result.p(true) == 4);
96  ensure(result.dd(true) == result.schema(true).fiber_space<fiber_type::host_type>().dd(xauto_access));
97  ensure(result.vector_space_path(true) == xvector_space_path);
98 
99  // Exit:
100 
101  // cout << "Leaving sec_t4_e2::new_host." << endl;
102  return result;
103 }
104 
108  const poset_path& xbase_path,
109  const poset_path& xrep_path,
110  const std::string& xsection_suffix,
111  const std::string& xfiber_suffix,
112  bool xauto_access)
113 {
114  // cout << endl << "Entering sec_t4_e2::new_host." << endl;
115 
116  // Preconditions:
117 
118  require(xns.state_is_auto_read_write_accessible(xauto_access));
119 
120  require(xbase_path.full());
121  require(xns.path_is_auto_read_accessible<base_space_poset>(xbase_path, xauto_access));
122 
123  require(xrep_path.empty() || xrep_path.full());
124  require(xrep_path.empty() || xns.path_is_auto_read_accessible<sec_rep_descriptor_poset>(xrep_path, xauto_access));
125 
126  require(xsection_suffix.empty() || poset_path::is_valid_name(xsection_suffix));
127 
128  require(xfiber_suffix.empty() || poset_path::is_valid_name(xfiber_suffix));
129 
130  require(standard_host_is_available<sec_t4_e2>(xns, xbase_path, xrep_path, xsection_suffix, xfiber_suffix, xauto_access));
131  require(fiber_type::standard_host_is_available<fiber_type>(xns, xfiber_suffix, xauto_access));
132  require(schema_type::standard_host_is_available<sec_t4_e2>(xns, xbase_path, xrep_path, xfiber_suffix, xauto_access));
133 
134  // Body:
135 
136  poset_path lstd_path = standard_host_path<sec_t4_e2>(xbase_path, xrep_path, xsection_suffix, xfiber_suffix);
137 
138  host_type* lresult_ptr;
139 
140  if(xns.contains_path(lstd_path, xauto_access))
141  {
142  // Standard host already exists, just return it.
143 
144  lresult_ptr = &xns.member_poset<host_type>(lstd_path, xauto_access);
145  }
146  else
147  {
148  // Standard host doesn't exist, have to create it.
149 
150  // Apply default for rep path if needed.
151 
152  poset_path lrep_path = (!xrep_path.empty() ? xrep_path : standard_rep_path());
153 
154  // Find or create the standard schema member.
155 
156  poset_path lstd_schema_path =
157  schema_type::standard_member<sec_t4_e2>(xns, xbase_path, lrep_path, xfiber_suffix, xauto_access);
158 
159  // Find or create the standard vector space.
160 
161  poset_path lvector_space_path =
162  vector_space_type::standard_host(xns, xbase_path, lrep_path, xsection_suffix, xfiber_suffix, xauto_access).path(xauto_access);
163 
164  // Create the standard host.
165 
166  lresult_ptr = &new_host(xns, lstd_path, lstd_schema_path, lvector_space_path, xauto_access);
167  }
168 
169  host_type& result = *lresult_ptr;
170 
171  // Postconditions:
172 
173  ensure(xns.owns(result, xauto_access));
174  ensure(result.path(true) == standard_host_path<sec_t4_e2>(xbase_path, xrep_path, xsection_suffix, xfiber_suffix));
175  ensure(result.state_is_not_read_accessible());
176  ensure(result.schema(true).path(xauto_access) ==
177  schema_type::standard_member_path<sec_t4_e2>(xbase_path, xrep_path, xfiber_suffix));
178 
179  ensure(result.factor_ct(true) == result.schema(true).fiber_space<fiber_type::host_type>().factor_ct(xauto_access));
180  ensure(result.d(true) == result.schema(true).fiber_space<fiber_type::host_type>().d(xauto_access));
181  ensure(result.scalar_space_path(true) ==
182  scalar_type::standard_host_path<scalar_type>(xbase_path, result.rep().path(xauto_access), xsection_suffix, xfiber_suffix));
183  ensure(result.p(true) == result.schema(true).fiber_space<fiber_type::host_type>().p(xauto_access));
184  ensure(result.p(true) == 4);
185  ensure(result.dd(true) == result.schema(true).fiber_space<fiber_type::host_type>().dd(xauto_access));
186  ensure(result.vector_space_path(true) ==
187  vector_space_type::standard_host_path<vector_space_type>(xbase_path, result.rep().path(xauto_access), xsection_suffix, xfiber_suffix));
188 
189  // Exit:
190 
191  // cout << "Leaving sec_t4_e2::new_host." << endl;
192  return result;
193 }
194 
195 // PROTECTED MEMBER FUNCTIONS
196 
197 // PRIVATE MEMBER FUNCTIONS
198 
199 
200 //==============================================================================
201 // T4_E2 FACET OF CLASS SEC_T4_E2
202 //==============================================================================
203 
204 // PUBLIC MEMBER FUNCTIONS
205 
208 {
209  // Preconditions:
210 
211  // Body:
212 
213  // Postconditions:
214 
215  ensure(invariant());
216 }
217 
220 {
221 
222  // Preconditions:
223 
224  require(xother.is_attached() ? xother.state_is_read_accessible() : true);
225 
226  // Body:
227 
228  attach_to_state(&xother);
229 
230  // Postconditions:
231 
232  ensure(invariant());
233  ensure(is_attached() == xother.is_attached());
234  ensure(is_same_state(&xother));
235  ensure(is_same_restriction(&xother));
236 
237 }
238 
241  abstract_poset_member& xbase_mbr,
242  int xbase_version, bool xauto_access)
243 {
244 
245  // Preconditions:
246 
247  require(precondition_of(new_jim_state(xhost, xbase_mbr, xbase_version, xauto_access)));
248 
249  // Body:
250 
251  new_jim_state(xhost, xbase_mbr, xbase_version, xauto_access);
252 
253  // Postconditions:
254 
255  ensure(postcondition_of(new_jim_state(xhost, xbase_mbr, xbase_version, xauto_access)));
256 
257  // Exit:
258 
259  return;
260 }
261 
263 sec_t4_e2(sec_rep_space* xhost, section_dof_map* xdof_map, bool xauto_access)
264 {
265 
266  // Preconditions:
267 
268  require(precondition_of(new_jim_state(xhost, xdof_map, false, xauto_access)));
269 
270  // Body:
271 
272  new_jim_state(xhost, xdof_map, false, xauto_access);
273 
274  // Postconditions:
275 
276  ensure(postcondition_of(new_jim_state(xhost, xdof_map, false, xauto_access)));
277 
278  // Exit:
279 
280  return;
281 }
282 
284 sec_t4_e2(const sec_rep_space* xhost, pod_index_type xhub_id)
285 {
286  // Preconditions:
287 
288  require(xhost != 0);
289  require(xhost->state_is_read_accessible());
290  require(xhost->contains_member(xhub_id));
291 
292  // Body:
293 
294  attach_to_state(xhost, xhub_id);
295 
296  // Postconditions:
297 
298  ensure(invariant());
299  //ensure(host() == xhost);
300  ensure(index() == xhub_id);
301  ensure(is_attached());
302  ensure(!is_restricted());
303 }
304 
306 sec_t4_e2(const sec_rep_space* xhost, const scoped_index& xid)
307 {
308  // Preconditions:
309 
310  require(xhost != 0);
311  require(xhost->state_is_read_accessible());
312  require(xhost->contains_member(xid));
313 
314  // Body:
315 
316  attach_to_state(xhost, xid.hub_pod());
317 
318  // Postconditions:
319 
320  ensure(invariant());
321  //ensure(host() == xhost);
322  ensure(index() ==~ xid);
323  ensure(is_attached());
324  ensure(!is_restricted());
325 }
326 
328 sec_t4_e2(const sec_rep_space* xhost, const std::string& xname)
329 {
330 
331  // Preconditions:
332 
333  require(xhost != 0);
334  require(xhost->state_is_read_accessible());
335  require(!xname.empty());
336  require(xhost->contains_member(xname));
337 
338  // Body:
339 
340  attach_to_state(xhost, xname);
341 
342  // Postconditions:
343 
344  ensure(invariant());
345  //ensure(host() == xhost);
346  ensure(name() == xname);
347  ensure(is_attached());
348  ensure(!is_restricted());
349 
350 }
351 
353 sec_t4_e2(const namespace_poset* xnamespace,
354  const poset_path& xpath,
355  bool xauto_access)
356 {
357 
358  // Preconditions:
359 
360  require(precondition_of(attach_to_state(same args)));
361 
362  // Body:
363 
364  attach_to_state(xnamespace, xpath, xauto_access);
365 
366  // Postconditions:
367 
368  ensure(postcondition_of(attach_to_state(same args)));
369 
370  // Exit:
371 
372  return;
373 }
374 
378 {
379  // Preconditions:
380 
381  require(is_ancestor_of(&xother));
382  require(precondition_of(attach_to_state(&xother)));
383 
384  // Body:
385 
386  attach_to_state(&xother);
387 
388  // Postconditions:
389 
390  ensure(postcondition_of(attach_to_state(&xother)));
391 
392  // Exit:
393 
394  return *this;
395 }
396 
399 operator=(const sec_t4_e2& xother)
400 {
401  // Preconditions:
402 
403  require(precondition_of(attach_to_state(&xother)));
404 
405  // Body:
406 
407  attach_to_state(&xother);
408 
409  // Postconditions:
410 
411  ensure(postcondition_of(attach_to_state(&xother)));
412 
413  // Exit:
414 
415  return *this;
416 }
417 
420 operator=(const t4_e2& xfiber)
421 {
422  // Preconditions:
423 
424  require(precondition_of(sec_vd::operator=(xfiber)));
425 
426  // Body:
427 
428  sec_vd::operator=(xfiber);
429 
430  // Postconditions:
431 
432  ensure(postcondition_of(sec_vd::operator=(xfiber)));
433 
434  // Exit:
435 
436  return *this;
437 }
438 
441 operator=(const t4_e2_lite& xfiber)
442 {
443  // Preconditions:
444 
445  require(precondition_of(sec_vd::operator=(xfiber)));
446 
447  // Body:
448 
449  sec_vd::operator=(xfiber);
450 
451  // Postconditions:
452 
453  ensure(postcondition_of(sec_vd::operator=(xfiber)));
454 
455  // Exit:
456 
457  return *this;
458 }
459 
462 {
463  // Preconditions:
464 
465  // Body:
466 
467  // Postconditions:
468 
469 }
470 
474 {
475  // Preconditions:
476 
477  // Body:
478 
479  static const fiber_type result;
480 
481  // Postconditions:
482 
483  // Exit:
484 
485  return result;
486 }
487 
488 // PROTECTED MEMBER FUNCTIONS
489 
490 // PRIVATE MEMBER FUNCTIONS
491 
492 
493 //==============================================================================
494 // T4 FACET OF CLASS SEC_T4_E2
495 //==============================================================================
496 
497 // PUBLIC MEMBER FUNCTIONS
498 
499 // PROTECTED MEMBER FUNCTIONS
500 
501 // PRIVATE MEMBER FUNCTIONS
502 
503 
504 //==============================================================================
505 // TP FACET OF CLASS SEC_T4_E2
506 //==============================================================================
507 
508 // PUBLIC MEMBER FUNCTIONS
509 
510 // PROTECTED MEMBER FUNCTIONS
511 
512 // PRIVATE MEMBER FUNCTIONS
513 
514 
515 //==============================================================================
516 // VD FACET OF CLASS SEC_T4_E2
517 //==============================================================================
518 
519 // PUBLIC MEMBER FUNCTIONS
520 
521 // PROTECTED MEMBER FUNCTIONS
522 
523 // PRIVATE MEMBER FUNCTIONS
524 
525 
526 //==============================================================================
527 // TUPLE FACET OF CLASS SEC_T4_E2
528 //==============================================================================
529 
530 // PUBLIC MEMBER FUNCTIONS
531 
532 // PROTECTED MEMBER FUNCTIONS
533 
534 // PRIVATE MEMBER FUNCTIONS
535 
536 
537 //==============================================================================
538 // ABSTRACT POSET MEMBER FACET OF CLASS SEC_T4_E2
539 //==============================================================================
540 
541 // PUBLIC MEMBER FUNCTIONS
542 
543 const std::string&
545 class_name() const
546 {
547  // Preconditions:
548 
549  // Body:
550 
551  const string& result = static_class_name();
552 
553  // Postconditions:
554 
555  ensure(!result.empty());
556 
557  // Exit:
558 
559  return result;
560 }
561 
562 const std::string&
565 {
566  // Preconditions:
567 
568  // Body:
569 
570  static const string result("sec_t4_e2");
571 
572  // Postconditions:
573 
574  ensure(!result.empty());
575 
576  // Exit:
577 
578  return result;
579 }
580 
583 clone() const
584 {
585 
586  // Preconditions:
587 
588  // Body:
589 
590  // create new handle of the current class.
591 
592  sec_t4_e2 *result = new sec_t4_e2();
593 
594  // Postconditions:
595 
596  ensure(result != 0);
597  ensure(result->invariant());
598 
599  // Exit:
600 
601  return result;
602 
603 }
604 
605 // PROTECTED MEMBER FUNCTIONS
606 
607 // PRIVATE MEMBER FUNCTIONS
608 
609 
610 //==============================================================================
611 // ANY FACET OF CLASS SEC_T4_E2
612 //==============================================================================
613 
614 // PUBLIC MEMBER FUNCTIONS
615 
616 bool
618 fiber_is_ancestor_of(const any* xother) const
619 {
620 
621  // Preconditions:
622 
623  require(xother != 0);
624 
625  // Body:
626 
627  bool result = dynamic_cast<const t4_e2*>(xother) != 0;
628 
629  // Postconditions:
630 
631  ensure(invariant());
632  ensure(xother->invariant());
633 
634  // Exit:
635 
636  return result;
637 
638 }
639 
640 bool
642 is_ancestor_of(const any* xother) const
643 {
644  // Preconditions:
645 
646  require(xother != 0);
647 
648  // Body:
649 
650  bool result = dynamic_cast<const sec_t4_e2*>(xother) != 0;
651 
652  // Postconditions:
653 
654  //ensure(invariant());
655 
656  // Exit:
657 
658  return result;
659 
660 }
661 
662 bool
664 invariant() const
665 {
666  bool result = true;
667 
668  // Body:
669 
670  if (invariant_check())
671  {
672  // Prevent recursive calls to invariant
673 
674  disable_invariant_check();
675 
676  // Must satisfy base class invariant
677 
678  invariance(sec_tp::invariant());
679 
680  // Invariances for this class:
681 
682  invariance(state_is_read_accessible() ? dd() == 2 : true);
683 
684  // Finished, turn invariant checking back on.
685 
686  enable_invariant_check();
687  }
688 
689  // Exit:
690 
691  return result;
692 }
693 
694 // PROTECTED MEMBER FUNCTIONS
695 
696 // PRIVATE MEMBER FUNCTIONS
697 
698 
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 ...
virtual sec_t4_e2 & operator=(const abstract_poset_member &xother)
Assignment operator; synonym for attach_to_state(&xother).
Definition: sec_t4_e2.cc:377
bool is_ancestor_of(const any *xother) const
True if xother conforms to current.
Definition: sec_t4_e2.cc:642
bool full() const
True if both poset name and member name are not empty.
Definition: poset_path.cc:311
The abstract map from section dof ids to section dof values of heterogeneous type.
A space of scalars viewed as an antisymmetric tensor section space of degree 1.
Definition: sec_at1_space.h:48
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 fiber_is_ancestor_of(const any *xother) const
True if xother conforms to an instance of the fiber of current.
Definition: sec_t4_e2.cc:618
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: sec_t4_e2.cc:56
virtual const std::string & class_name() const
The name of this class.
Definition: sec_t4_e2.cc:545
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.
A tensor of degree 4 over a Euclidean vector space of dimension 2 (persistent version).
Definition: t4_e2.h:378
STL namespace.
bool invariant() const
Class invariant.
Definition: sec_t4_e2.cc:664
A schema poset for a section space. A binary Cartesian product subspace of the binary tensor product ...
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.
The poset for sec_rep_descriptors.
virtual const fiber_type & fiber_prototype() const
Virtual constructor for the associated fiber type.
Definition: sec_t4_e2.cc:473
~sec_t4_e2()
Destructor.
Definition: sec_t4_e2.cc:461
Abstract base class with useful features for all objects.
Definition: any.h:39
int p() const
The tensor degree of this space.
The lattice of closed cells of a cellular space; a lattice representation of a computational mesh...
sec_rep_descriptor & rep()
A representation descriptor for this sec rep space (mutable version).
virtual section_space_schema_member & schema()
The schema for this poset (mutable version)
virtual sec_t4_e2 * clone() const
Make a new handle, no state instance of current.
Definition: sec_t4_e2.cc:583
static host_type & standard_host(namespace_type &xns, const poset_path &xbase_path, const poset_path &xrep_path, const std::string &xsection_suffix, const std::string &xfiber_suffix, bool xauto_access)
The standard host for sections of this type with base space xbase_path, representation xrep_path...
Definition: sec_t4_e2.cc:107
An abstract tensor section space of degree p.
Definition: sec_tp_space.h:53
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 bool is_attached() const
True if this handle is attached to a non-void state.
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
static const std::string & static_class_name()
The name of this class.
Definition: sec_t4_e2.cc:564
A section of a bundle with fiber type t4_e2.
Definition: sec_t4_e2.h:48
sec_t4_e2()
Default constructor; creates an unattached handle.
Definition: sec_t4_e2.cc:207
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 int d(int xp, int xdd) const
Dimension d() as a function of degree xp and domain dimension xdd.
An abstract client handle for a member of a poset.
A tensor of degree 4 over a Euclidean vector space of dimension 2 (volatile version).
Definition: t4_e2.h:140
std::string path() const
The full path as a string.
Definition: poset_path.cc:450
An abstract tensor space of degree p.
Definition: tp_space.h:47
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 tensor of degree 4 over an abstract vector space (persistent version).
Definition: t4.h:223
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