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