SheafSystem  0.0.0.0
sec_t2_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_t2_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_tuple.impl.h"
35 #include "SheafSystem/sec_tuple_space.impl.h"
36 #include "SheafSystem/sec_vd.impl.h"
37 #include "SheafSystem/t2_e2.h"
38 
39 using namespace std;
40 using namespace fiber_bundle; // Workaround for MS C++ bug.
41 
42 //==============================================================================
43 // CLASS SEC_T2_E2
44 //==============================================================================
45 
46 // ===========================================================
47 // HOST FACTORY FACET OF CLASS SEC_T2_E2
48 // ===========================================================
49 
50 // PUBLIC MEMBER FUNCTIONS
51 
55  const poset_path& xhost_path,
56  const poset_path& xschema_path,
57  const poset_path& xvector_space_path,
58  bool xauto_access)
59 {
60  // cout << endl << "Entering sec_t2_e2::new_host." << endl;
61 
62  // Preconditions:
63 
64  require(xns.state_is_auto_read_write_accessible(xauto_access));
65 
66  require(!xhost_path.empty());
67  require(!xns.contains_path(xhost_path, xauto_access));
68 
69  require(xschema_path.full());
70  require(xns.path_is_auto_read_accessible<schema_type::host_type>(xschema_path, xauto_access));
71  require(host_type::fiber_space_conforms<fiber_type::host_type>(xns, xschema_path, xauto_access));
72 
73  require(xns.path_is_auto_read_accessible<vector_space_type::host_type>(xvector_space_path, xauto_access));
74 
75  require(host_type::same_vector_fiber_space(xns, xschema_path, xvector_space_path, xauto_access));
76 
77  // Body:
78 
79  host_type& result = host_type::new_table(xns, xhost_path, xschema_path, xvector_space_path, xauto_access);
80 
81  // Postconditions:
82 
83  ensure(xns.owns(result, xauto_access));
84  ensure(result.path(true) == xhost_path);
85  ensure(result.state_is_not_read_accessible());
86  ensure(result.schema(true).path(xauto_access) == xschema_path);
87 
88  ensure(result.factor_ct(true) == result.schema(true).fiber_space<fiber_type::host_type>().factor_ct(xauto_access));
89  ensure(result.d(true) == result.schema(true).fiber_space<fiber_type::host_type>().d(xauto_access));
90  ensure(result.scalar_space_path(true) ==
91  xns.member_poset<vector_space_type::host_type>(xvector_space_path, xauto_access).scalar_space_path(xauto_access));
92  ensure(result.p(true) == result.schema(true).fiber_space<fiber_type::host_type>().p(xauto_access));
93  ensure(result.p(true) == 2);
94  ensure(result.dd(true) == result.schema(true).fiber_space<fiber_type::host_type>().dd(xauto_access));
95  ensure(result.vector_space_path(true) == xvector_space_path);
96 
97  // Exit:
98 
99  // cout << "Leaving sec_t2_e2::new_host." << endl;
100  return result;
101 }
102 
106  const poset_path& xbase_path,
107  const poset_path& xrep_path,
108  const std::string& xsection_suffix,
109  const std::string& xfiber_suffix,
110  bool xauto_access)
111 {
112  // cout << endl << "Entering sec_t2_e2::new_host." << endl;
113 
114  // Preconditions:
115 
116  require(xns.state_is_auto_read_write_accessible(xauto_access));
117 
118  require(xbase_path.full());
119  require(xns.path_is_auto_read_accessible<base_space_poset>(xbase_path, xauto_access));
120 
121  require(xrep_path.empty() || xrep_path.full());
122  require(xrep_path.empty() || xns.path_is_auto_read_accessible<sec_rep_descriptor_poset>(xrep_path, xauto_access));
123 
124  require(xsection_suffix.empty() || poset_path::is_valid_name(xsection_suffix));
125 
126  require(xfiber_suffix.empty() || poset_path::is_valid_name(xfiber_suffix));
127 
128  require(standard_host_is_available<sec_t2_e2>(xns, xbase_path, xrep_path, xsection_suffix, xfiber_suffix, xauto_access));
129  require(fiber_type::standard_host_is_available<fiber_type>(xns, xfiber_suffix, xauto_access));
130  require(schema_type::standard_host_is_available<sec_t2_e2>(xns, xbase_path, xrep_path, xfiber_suffix, xauto_access));
131 
132  // Body:
133 
134  poset_path lstd_path = standard_host_path<sec_t2_e2>(xbase_path, xrep_path, xsection_suffix, xfiber_suffix);
135 
136  host_type* lresult_ptr;
137 
138  if(xns.contains_path(lstd_path, xauto_access))
139  {
140  // Standard host already exists, just return it.
141 
142  lresult_ptr = &xns.member_poset<host_type>(lstd_path, xauto_access);
143  }
144  else
145  {
146  // Standard host doesn't exist, have to create it.
147 
148  // Apply default for rep path if needed.
149 
150  poset_path lrep_path = (!xrep_path.empty() ? xrep_path : standard_rep_path());
151 
152  // Find or create the standard schema member.
153 
154  poset_path lstd_schema_path =
155  schema_type::standard_member<sec_t2_e2>(xns, xbase_path, lrep_path, xfiber_suffix, xauto_access);
156 
157  // Find or create the standard vector space.
158 
159  poset_path lvector_space_path =
160  vector_space_type::standard_host(xns, xbase_path, lrep_path, xsection_suffix, xfiber_suffix, xauto_access).path(xauto_access);
161 
162  // Create the standard host.
163 
164  lresult_ptr = &new_host(xns, lstd_path, lstd_schema_path, lvector_space_path, xauto_access);
165  }
166 
167  host_type& result = *lresult_ptr;
168 
169  // Postconditions:
170 
171  ensure(xns.owns(result, xauto_access));
172  ensure(result.path(true) == standard_host_path<sec_t2_e2>(xbase_path, xrep_path, xsection_suffix, xfiber_suffix));
173  ensure(result.state_is_not_read_accessible());
174  ensure(result.schema(true).path(xauto_access) ==
175  schema_type::standard_member_path<sec_t2_e2>(xbase_path, xrep_path, xfiber_suffix));
176 
177  ensure(result.factor_ct(true) == result.schema(true).fiber_space<fiber_type::host_type>().factor_ct(xauto_access));
178  ensure(result.d(true) == result.schema(true).fiber_space<fiber_type::host_type>().d(xauto_access));
179  ensure(result.scalar_space_path(true) ==
180  scalar_type::standard_host_path<scalar_type>(xbase_path, result.rep().path(xauto_access), xsection_suffix, xfiber_suffix));
181  ensure(result.p(true) == result.schema(true).fiber_space<fiber_type::host_type>().p(xauto_access));
182  ensure(result.p(true) == 2);
183  ensure(result.dd(true) == result.schema(true).fiber_space<fiber_type::host_type>().dd(xauto_access));
184  ensure(result.vector_space_path(true) ==
185  vector_space_type::standard_host_path<vector_space_type>(xbase_path, result.rep().path(xauto_access), xsection_suffix, xfiber_suffix));
186 
187  // Exit:
188 
189  // cout << "Leaving sec_t2_e2::new_host." << endl;
190  return result;
191 }
192 
193 // PROTECTED MEMBER FUNCTIONS
194 
195 // PRIVATE MEMBER FUNCTIONS
196 
197 
198 //==============================================================================
199 // T2_E2 FACET OF CLASS SEC_T2_E2
200 //==============================================================================
201 
202 // PUBLIC MEMBER FUNCTIONS
203 
206 {
207  // Preconditions:
208 
209  // Body:
210 
211  // Postconditions:
212 
213  ensure(invariant());
214 }
215 
218 {
219 
220  // Preconditions:
221 
222  require(xother.is_attached() ? xother.state_is_read_accessible() : true);
223 
224  // Body:
225 
226  attach_to_state(&xother);
227 
228  // Postconditions:
229 
230  ensure(invariant());
231  ensure(is_attached() == xother.is_attached());
232  ensure(is_same_state(&xother));
233  ensure(is_same_restriction(&xother));
234 
235 }
236 
239  abstract_poset_member& xbase_mbr,
240  int xbase_version, bool xauto_access)
241 {
242 
243  // Preconditions:
244 
245  require(precondition_of(new_jim_state(\
246  xhost, xbase_mbr, xbase_version, xauto_access)));
247 
248  // Body:
249 
250  new_jim_state(xhost, xbase_mbr, xbase_version, xauto_access);
251 
252  // Postconditions:
253 
254  ensure(postcondition_of(new_jim_state(\
255  xhost, xbase_mbr, xbase_version, xauto_access)));
256 
257  // Exit:
258 
259  return;
260 }
261 
263 sec_t2_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_t2_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_t2_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_t2_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_t2_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_t2_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 t2_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 t2_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 // T2 FACET OF CLASS SEC_T2_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_T2_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_T2_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_T2_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_T2_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_t2_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_t2_e2 *result = new sec_t2_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_T2_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 t2_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_t2_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 ...
bool full() const
True if both poset name and member name are not empty.
Definition: poset_path.cc:311
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_t2_e2.cc:105
virtual sec_t2_e2 * clone() const
Make a new handle, no state instance of current.
Definition: sec_t2_e2.cc:583
The abstract map from section dof ids to section dof values of heterogeneous type.
A tensor of degree 2 over a Euclidean vector space of dimension 2 (volatile version).
Definition: t2_e2.h:148
A space of scalars viewed as an antisymmetric tensor section space of degree 1.
Definition: sec_at1_space.h:48
bool fiber_is_ancestor_of(const any *xother) const
True if xother conforms to an instance of the fiber of current.
Definition: sec_t2_e2.cc:618
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 tensor of degree 2 over a Euclidean vector space of dimension 2 (persistent version).
Definition: t2_e2.h:444
virtual const std::string & class_name() const
The name of this class.
Definition: sec_t2_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.
STL namespace.
A schema poset for a section space. A binary Cartesian product subspace of the binary tensor product ...
~sec_t2_e2()
Destructor.
Definition: sec_t2_e2.cc:461
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.
Abstract base class with useful features for all objects.
Definition: any.h:39
int p() const
The tensor degree of this space.
virtual const fiber_type & fiber_prototype() const
Virtual constructor for the associated fiber type.
Definition: sec_t2_e2.cc:473
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_t2_e2 & operator=(const abstract_poset_member &xother)
Assignment operator; synonym for attach_to_state(&xother).
Definition: sec_t2_e2.cc:377
static const std::string & static_class_name()
The name of this class.
Definition: sec_t2_e2.cc:564
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
bool is_ancestor_of(const any *xother) const
True if xother conforms to current.
Definition: sec_t2_e2.cc:642
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
sec_t2_e2()
Default constructor; creates an unattached handle.
Definition: sec_t2_e2.cc:205
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).
A section of a bundle with fiber type t2_e2.
Definition: sec_t2_e2.h:48
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.
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.
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_t2_e2.cc:54
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...
bool invariant() const
Class invariant.
Definition: sec_t2_e2.cc:664
A tensor of degree 2 over an abstract vector space (persistent version).
Definition: t2.h:226
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