SheafSystem  0.0.0.0
sec_t3_e3.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_t3_e3.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_e3.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/t3_e3.h"
38 
39 using namespace std;
40 using namespace fiber_bundle; // Workaround for MS C++ bug.
41 
42 //==============================================================================
43 // CLASS SEC_T3_E3
44 //==============================================================================
45 
46 // ===========================================================
47 // HOST FACTORY FACET OF CLASS SEC_T3_E3
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_t3_e3::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) == 3);
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_t3_e3::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_t3_e3::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_t3_e3>(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_t3_e3>(xns, xbase_path, xrep_path, xfiber_suffix, xauto_access));
131 
132  // Body:
133 
134  poset_path lstd_path = standard_host_path<sec_t3_e3>(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_t3_e3>(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_t3_e3>(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_t3_e3>(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) == 3);
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_t3_e3::new_host." << endl;
190  return result;
191 }
192 
193 // PROTECTED MEMBER FUNCTIONS
194 
195 // PRIVATE MEMBER FUNCTIONS
196 
197 
198 //==============================================================================
199 // T3_E3 FACET OF CLASS SEC_T3_E3
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(xhost, xbase_mbr, xbase_version, xauto_access)));
246 
247  // Body:
248 
249  new_jim_state(xhost, xbase_mbr, xbase_version, xauto_access);
250 
251  // Postconditions:
252 
253  ensure(postcondition_of(new_jim_state(xhost, xbase_mbr, xbase_version, xauto_access)));
254 
255  // Exit:
256 
257  return;
258 }
259 
261 sec_t3_e3(sec_rep_space* xhost, section_dof_map* xdof_map, bool xauto_access)
262 {
263 
264  // Preconditions:
265 
266  require(precondition_of(new_jim_state(xhost, xdof_map, false, xauto_access)));
267 
268  // Body:
269 
270  new_jim_state(xhost, xdof_map, false, xauto_access);
271 
272  // Postconditions:
273 
274  ensure(postcondition_of(new_jim_state(xhost, xdof_map, false, xauto_access)));
275 
276  // Exit:
277 
278  return;
279 }
280 
282 sec_t3_e3(const sec_rep_space* xhost, pod_index_type xhub_id)
283 {
284  // Preconditions:
285 
286  require(xhost != 0);
287  require(xhost->state_is_read_accessible());
288  require(xhost->contains_member(xhub_id));
289 
290  // Body:
291 
292  attach_to_state(xhost, xhub_id);
293 
294  // Postconditions:
295 
296  ensure(invariant());
297  //ensure(host() == xhost);
298  ensure(index() == xhub_id);
299  ensure(is_attached());
300  ensure(!is_restricted());
301 }
302 
304 sec_t3_e3(const sec_rep_space* xhost, const scoped_index& xid)
305 {
306  // Preconditions:
307 
308  require(xhost != 0);
309  require(xhost->state_is_read_accessible());
310  require(xhost->contains_member(xid));
311 
312  // Body:
313 
314  attach_to_state(xhost, xid.hub_pod());
315 
316  // Postconditions:
317 
318  ensure(invariant());
319  //ensure(host() == xhost);
320  ensure(index() ==~ xid);
321  ensure(is_attached());
322  ensure(!is_restricted());
323 }
324 
326 sec_t3_e3(const sec_rep_space* xhost, const std::string& xname)
327 {
328 
329  // Preconditions:
330 
331  require(xhost != 0);
332  require(xhost->state_is_read_accessible());
333  require(!xname.empty());
334  require(xhost->contains_member(xname));
335 
336  // Body:
337 
338  attach_to_state(xhost, xname);
339 
340  // Postconditions:
341 
342  ensure(invariant());
343  //ensure(host() == xhost);
344  ensure(name() == xname);
345  ensure(is_attached());
346  ensure(!is_restricted());
347 
348 }
349 
351 sec_t3_e3(const namespace_poset* xnamespace,
352  const poset_path& xpath,
353  bool xauto_access)
354 {
355 
356  // Preconditions:
357 
358  require(precondition_of(attach_to_state(same args)));
359 
360  // Body:
361 
362  attach_to_state(xnamespace, xpath, xauto_access);
363 
364  // Postconditions:
365 
366  ensure(postcondition_of(attach_to_state(same args)));
367 
368  // Exit:
369 
370  return;
371 }
372 
376 {
377  // Preconditions:
378 
379  require(is_ancestor_of(&xother));
380  require(precondition_of(attach_to_state(&xother)));
381 
382  // Body:
383 
384  attach_to_state(&xother);
385 
386  // Postconditions:
387 
388  ensure(postcondition_of(attach_to_state(&xother)));
389 
390  // Exit:
391 
392  return *this;
393 }
394 
397 operator=(const sec_t3_e3& xother)
398 {
399  // Preconditions:
400 
401  require(precondition_of(attach_to_state(&xother)));
402 
403  // Body:
404 
405  attach_to_state(&xother);
406 
407  // Postconditions:
408 
409  ensure(postcondition_of(attach_to_state(&xother)));
410 
411  // Exit:
412 
413  return *this;
414 }
415 
418 operator=(const t3_e3& xfiber)
419 {
420  // Preconditions:
421 
422  require(precondition_of(sec_vd::operator=(xfiber)));
423 
424  // Body:
425 
426  sec_vd::operator=(xfiber);
427 
428  // Postconditions:
429 
430  ensure(postcondition_of(sec_vd::operator=(xfiber)));
431 
432  // Exit:
433 
434  return *this;
435 }
436 
439 operator=(const t3_e3_lite& xfiber)
440 {
441  // Preconditions:
442 
443  require(precondition_of(sec_vd::operator=(xfiber)));
444 
445  // Body:
446 
447  sec_vd::operator=(xfiber);
448 
449  // Postconditions:
450 
451  ensure(postcondition_of(sec_vd::operator=(xfiber)));
452 
453  // Exit:
454 
455  return *this;
456 }
457 
460 {
461  // Preconditions:
462 
463  // Body:
464 
465  // Postconditions:
466 
467 }
468 
472 {
473  // Preconditions:
474 
475  // Body:
476 
477  static const fiber_type result;
478 
479  // Postconditions:
480 
481  // Exit:
482 
483  return result;
484 }
485 
486 // PROTECTED MEMBER FUNCTIONS
487 
488 // PRIVATE MEMBER FUNCTIONS
489 
490 
491 //==============================================================================
492 // T3 FACET OF CLASS SEC_T3_E3
493 //==============================================================================
494 
495 // PUBLIC MEMBER FUNCTIONS
496 
497 // PROTECTED MEMBER FUNCTIONS
498 
499 // PRIVATE MEMBER FUNCTIONS
500 
501 
502 //==============================================================================
503 // TP FACET OF CLASS SEC_T3_E3
504 //==============================================================================
505 
506 // PUBLIC MEMBER FUNCTIONS
507 
508 // PROTECTED MEMBER FUNCTIONS
509 
510 // PRIVATE MEMBER FUNCTIONS
511 
512 
513 //==============================================================================
514 // VD FACET OF CLASS SEC_T3_E3
515 //==============================================================================
516 
517 // PUBLIC MEMBER FUNCTIONS
518 
519 // PROTECTED MEMBER FUNCTIONS
520 
521 // PRIVATE MEMBER FUNCTIONS
522 
523 
524 //==============================================================================
525 // TUPLE FACET OF CLASS SEC_T3_E3
526 //==============================================================================
527 
528 // PUBLIC MEMBER FUNCTIONS
529 
530 // PROTECTED MEMBER FUNCTIONS
531 
532 // PRIVATE MEMBER FUNCTIONS
533 
534 
535 //==============================================================================
536 // ABSTRACT POSET MEMBER FACET OF CLASS SEC_T3_E3
537 //==============================================================================
538 
539 // PUBLIC MEMBER FUNCTIONS
540 
541 const std::string&
543 class_name() const
544 {
545  // Preconditions:
546 
547  // Body:
548 
549  const string& result = static_class_name();
550 
551  // Postconditions:
552 
553  ensure(!result.empty());
554 
555  // Exit:
556 
557  return result;
558 }
559 
560 const std::string&
563 {
564  // Preconditions:
565 
566  // Body:
567 
568  static const string result("sec_t3_e3");
569 
570  // Postconditions:
571 
572  ensure(!result.empty());
573 
574  // Exit:
575 
576  return result;
577 }
578 
581 clone() const
582 {
583 
584  // Preconditions:
585 
586  // Body:
587 
588  // create new handle of the current class.
589 
590  sec_t3_e3 *result = new sec_t3_e3();
591 
592  // Postconditions:
593 
594  ensure(result != 0);
595  ensure(result->invariant());
596 
597  // Exit:
598 
599  return result;
600 
601 }
602 
603 // PROTECTED MEMBER FUNCTIONS
604 
605 // PRIVATE MEMBER FUNCTIONS
606 
607 
608 //==============================================================================
609 // ANY FACET OF CLASS SEC_T3_E3
610 //==============================================================================
611 
612 // PUBLIC MEMBER FUNCTIONS
613 
614 bool
616 fiber_is_ancestor_of(const any* xother) const
617 {
618  // Preconditions:
619 
620  require(xother != 0);
621 
622  // Body:
623 
624  bool result = dynamic_cast<const t3_e3*>(xother) != 0;
625 
626  // Postconditions:
627 
628  ensure(invariant());
629  ensure(xother->invariant());
630 
631  // Exit:
632 
633  return result;
634 
635 }
636 
637 bool
639 is_ancestor_of(const any* xother) const
640 {
641  // Preconditions:
642 
643  require(xother != 0);
644 
645  // Body:
646 
647  bool result = dynamic_cast<const sec_t3_e3*>(xother) != 0;
648 
649  // Postconditions:
650 
651  //ensure(invariant());
652 
653  // Exit:
654 
655  return result;
656 
657 }
658 
659 bool
661 invariant() const
662 {
663  bool result = true;
664 
665  // Body:
666 
667  if (invariant_check())
668  {
669  // Prevent recursive calls to invariant
670 
671  disable_invariant_check();
672 
673  // Must satisfy base class invariant
674 
675  invariance(sec_tp::invariant());
676 
677  // Invariances for this class:
678 
679  invariance(state_is_read_accessible() ? dd() == 3 : true);
680 
681  // Finished, turn invariant checking back on.
682 
683  enable_invariant_check();
684  }
685 
686  // Exit:
687 
688  return result;
689 }
690 
691 // PROTECTED MEMBER FUNCTIONS
692 
693 // PRIVATE MEMBER FUNCTIONS
694 
695 
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 ...
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_t3_e3.cc:105
bool full() const
True if both poset name and member name are not empty.
Definition: poset_path.cc:311
bool is_ancestor_of(const any *xother) const
True if xother conforms to current.
Definition: sec_t3_e3.cc:639
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...
A tensor of degree 3 over an abstract vector space (persistent version).
Definition: t3.h:222
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 ...
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 sec_t3_e3 * clone() const
Make a new handle, no state instance of current.
Definition: sec_t3_e3.cc:581
bool fiber_is_ancestor_of(const any *xother) const
True if xother conforms to an instance of the fiber of current.
Definition: sec_t3_e3.cc:616
A section of a bundle with fiber type t3_e3.
Definition: sec_t3_e3.h:48
virtual sec_t3_e3 & operator=(const abstract_poset_member &xother)
Assignment operator; synonym for attach_to_state(&xother).
Definition: sec_t3_e3.cc:375
Abstract base class with useful features for all objects.
Definition: any.h:39
A tensor of degree 3 over a Euclidean vector space of dimension 3 (volatile version).
Definition: t3_e3.h:151
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 const fiber_type & fiber_prototype() const
Virtual constructor for the associated fiber type.
Definition: sec_t3_e3.cc:471
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.
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_t3_e3.cc:54
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
virtual const std::string & class_name() const
The name of this class.
Definition: sec_t3_e3.cc:543
~sec_t3_e3()
Destructor.
Definition: sec_t3_e3.cc:459
sec_t3_e3()
Default constructor; creates an unattached handle.
Definition: sec_t3_e3.cc:205
bool invariant() const
Class invariant.
Definition: sec_t3_e3.cc:661
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.
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.
A tensor of degree 3 over a Euclidean vector space of dimension 3 (persistent version).
Definition: t3_e3.h:401
static const std::string & static_class_name()
The name of this class.
Definition: sec_t3_e3.cc:562
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...
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