SheafSystem  0.0.0.0
sec_jcb_ed.cc
Go to the documentation of this file.
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
20 
21 #include "SheafSystem/sec_jcb_ed.h"
22 
23 #include "SheafSystem/assert_contract.h"
24 #include "SheafSystem/binary_section_space_schema_member.impl.h"
25 #include "SheafSystem/binary_section_space_schema_poset.h"
26 #include "SheafSystem/fiber_bundles_namespace.h"
27 #include "SheafSystem/section_space_schema_member.impl.h"
28 #include "SheafSystem/section_space_schema_poset.h"
29 #include "SheafSystem/sec_at0.h"
30 #include "SheafSystem/sec_at1.h"
31 #include "SheafSystem/sec_at1_space.h"
32 #include "SheafSystem/sec_jcb_space.h"
33 #include "SheafSystem/sec_tuple_space.impl.h"
34 #include "SheafSystem/jcb_ed.h"
35 #include "SheafSystem/jcb_space.h"
36 
37 using namespace std;
38 using namespace fiber_bundle; // Workaround for MS C++ bug.
39 
40 //==============================================================================
41 // CLASS SEC_JCB_ED
42 //==============================================================================
43 
44 // ===========================================================
45 // HOST FACTORY FACET
46 // ===========================================================
47 
48 // PUBLIC MEMBER FUNCTIONS
49 
53  const poset_path& xhost_path,
54  const poset_path& xschema_path,
55  const poset_path& xdomain_path,
56  const poset_path& xrange_path,
57  bool xauto_access)
58 {
59  // cout << endl << "Entering sec_jcb_ed::new_host." << endl;
60 
61  // Preconditions:
62 
63  require(xns.state_is_auto_read_write_accessible(xauto_access));
64 
65  require(!xhost_path.empty());
66  require(!xns.contains_path(xhost_path, xauto_access));
67 
68  require(xschema_path.full());
69  require(xns.path_is_auto_read_accessible<schema_type::host_type>(xschema_path, xauto_access));
70  require(host_type::fiber_space_conforms<fiber_type::host_type>(xns, xschema_path, xauto_access));
71 
72  require(xns.path_is_auto_read_accessible<domain_type::host_type>(xdomain_path, xauto_access));
73  require(xns.path_is_auto_read_accessible<range_type::host_type>(xrange_path, xauto_access));
74 
75  require(host_type::same_vector_fiber_space(xns, xschema_path, xdomain_path, xrange_path, xauto_access));
76 
77  // Body:
78 
79  host_type& result = host_type::new_table(xns, xhost_path, xschema_path, xdomain_path, xrange_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<domain_type::host_type>(xdomain_path, xauto_access).scalar_space_path(xauto_access));
92  ensure(result.scalar_space_path(true) ==
93  xns.member_poset<range_type::host_type>(xrange_path, xauto_access).scalar_space_path(xauto_access));
94  ensure(result.dd(true) == result.schema(true).fiber_space<fiber_type::host_type>().dd(xauto_access));
95  ensure(result.dr(true) == result.schema(true).fiber_space<fiber_type::host_type>().dr(xauto_access));
96  ensure(result.domain_path(true) == xdomain_path);
97  ensure(result.range_path(true) == xrange_path);
98 
99  // Exit:
100 
101  // cout << "Leaving sec_jcb_ed::new_host." << endl;
102  return result;
103 }
104 
105 // PROTECTED MEMBER FUNCTIONS
106 
107 // PRIVATE MEMBER FUNCTIONS
108 
109 
110 //==============================================================================
111 // JCB_ED FACET OF CLASS SEC_JCB_ED
112 //==============================================================================
113 
114 // PUBLIC MEMBER FUNCTIONS
115 
118 {
119 
120  // Preconditions:
121 
122 
123  // Body:
124 
125 
126  // Postconditions:
127 
128  ensure(invariant());
129 }
130 
133 {
134  // Preconditions:
135 
136  require(xhost != 0);
137  require(xhost->state_is_read_accessible());
138  require(xhost->contains_member(xhub_id));
139 
140  // Body:
141 
142  attach_to_state(xhost, xhub_id);
143 
144  // Postconditions:
145 
146  ensure(invariant());
147  //ensure(host() == xhost);
148  ensure(index() == xhub_id);
149  ensure(is_attached());
150  ensure(!is_restricted());
151 }
152 
154 sec_jcb_ed(const sec_rep_space* xhost, const scoped_index& xid)
155 {
156  // Preconditions:
157 
158  require(xhost != 0);
159  require(xhost->state_is_read_accessible());
160  require(xhost->contains_member(xid));
161 
162  // Body:
163 
164  attach_to_state(xhost, xid.hub_pod());
165 
166  // Postconditions:
167 
168  ensure(invariant());
169  //ensure(host() == xhost);
170  ensure(index() ==~ xid);
171  ensure(is_attached());
172  ensure(!is_restricted());
173 }
174 
176 sec_jcb_ed(const sec_rep_space* xhost, const std::string& xname)
177 {
178 
179  // Preconditions:
180 
181  require(xhost != 0);
182  require(xhost->state_is_read_accessible());
183  require(!xname.empty());
184  require(xhost->contains_member(xname));
185 
186  // Body:
187 
188  attach_to_state(xhost, xname);
189 
190  // Postconditions:
191 
192  ensure(invariant());
193  //ensure(host() == xhost);
194  ensure(name() == xname);
195  ensure(is_attached());
196  ensure(!is_restricted());
197 
198 }
199 
200 
202 sec_jcb_ed(const namespace_poset* xnamespace,
203  const poset_path& xpath,
204  bool xauto_access)
205 {
206 
207  // Preconditions:
208 
209  require(precondition_of(attach_to_state(same args)));
210 
211  // Body:
212 
213  attach_to_state(xnamespace, xpath, xauto_access);
214 
215  // Postconditions:
216 
217  ensure(postcondition_of(attach_to_state(same args)));
218 
219  // Exit:
220 
221  return;
222 }
223 
224 
227 {
228 
229  // Preconditions:
230 
231  require(xother != 0);
232 
233  // Body:
234 
235  attach_to_state(xother);
236 
237  // Postconditions:
238 
239  ensure(invariant());
240  ensure(is_attached());
241  ensure(is_same_state(xother));
242  ensure(is_same_restriction(xother));
243 
244 }
245 
247 sec_jcb_ed(sec_rep_space* xhost, section_dof_map* xdof_map, bool xauto_access)
248 {
249 
250  // Preconditions:
251 
252  require(precondition_of(new_jim_state(xhost, xdof_map, false, xauto_access)));
253 
254  // Body:
255 
256  new_jim_state(xhost, xdof_map, false, xauto_access);
257 
258  // Postconditions:
259 
260  ensure(postcondition_of(new_jim_state(xhost, xdof_map, false, xauto_access)));
261 
262  // Exit:
263 
264  return;
265 }
266 
270 {
271  // Preconditions:
272 
273  require(is_ancestor_of(&xother));
274  require(precondition_of(attach_to_state(&xother)));
275 
276  // Body:
277 
278  attach_to_state(&xother);
279 
280  // Postconditions:
281 
282  ensure(postcondition_of(attach_to_state(&xother)));
283 
284  // Exit:
285 
286  return *this;
287 }
288 
291 operator=(const sec_jcb_ed& xother)
292 {
293  // Preconditions:
294 
295  require(precondition_of(attach_to_state(&xother)));
296 
297  // Body:
298 
299  attach_to_state(&xother);
300 
301  // Postconditions:
302 
303  ensure(postcondition_of(attach_to_state(&xother)));
304 
305  // Exit:
306 
307  return *this;
308 }
309 
312 operator=(const jcb_ed& xfiber)
313 {
314  // Preconditions:
315 
316  require(precondition_of(sec_vd::operator=(xfiber)));
317 
318  // Body:
319 
320  sec_vd::operator=(xfiber);
321 
322  // Postconditions:
323 
324  ensure(postcondition_of(sec_vd::operator=(xfiber)));
325 
326  // Exit:
327 
328  return *this;
329 }
330 
333 operator=(const jcb_ed_lite& xfiber)
334 {
335  // Preconditions:
336 
337  require(precondition_of(sec_vd::operator=(xfiber)));
338 
339  // Body:
340 
341  sec_vd::operator=(xfiber);
342 
343  // Postconditions:
344 
345  ensure(postcondition_of(sec_vd::operator=(xfiber)));
346 
347  // Exit:
348 
349  return *this;
350 }
351 
354 {
355 
356  // Preconditions:
357 
358  // Body:
359 
360  // Postconditions:
361 
362 }
363 
367 {
368  // Preconditions:
369 
370  // Body:
371 
372  static const fiber_type result;
373 
374  // Postconditions:
375 
376  // Exit:
377 
378  return result;
379 }
380 
381 // PROTECTED MEMBER FUNCTIONS
382 
383 // PRIVATE MEMBER FUNCTIONS
384 
385 
386 //==============================================================================
387 // JCB FACET OF CLASS SEC_JCB_ED
388 //==============================================================================
389 
390 // PUBLIC MEMBER FUNCTIONS
391 
392 // PROTECTED MEMBER FUNCTIONS
393 
394 // PRIVATE MEMBER FUNCTIONS
395 
396 
397 //==============================================================================
398 // VD FACET OF CLASS SEC_JCB_ED
399 //==============================================================================
400 
401 // PUBLIC MEMBER FUNCTIONS
402 
403 // PROTECTED MEMBER FUNCTIONS
404 
405 // PRIVATE MEMBER FUNCTIONS
406 
407 
408 //==============================================================================
409 // TUPLE FACET OF CLASS SEC_JCB_ED
410 //==============================================================================
411 
412 // PUBLIC MEMBER FUNCTIONS
413 
414 // PROTECTED MEMBER FUNCTIONS
415 
416 // PRIVATE MEMBER FUNCTIONS
417 
418 
419 //==============================================================================
420 // ABSTRACT POSET MEMBER FACET OF CLASS SEC_JCB_ED
421 //==============================================================================
422 
423 // PUBLIC MEMBER FUNCTIONS
424 
425 const std::string&
427 class_name() const
428 {
429  // Preconditions:
430 
431  // Body:
432 
433  const string& result = static_class_name();
434 
435  // Postconditions:
436 
437  ensure(!result.empty());
438 
439  // Exit:
440 
441  return result;
442 }
443 
444 const std::string&
447 {
448  // Preconditions:
449 
450  // Body:
451 
452  static const string result("sec_jcb_ed");
453 
454  // Postconditions:
455 
456  ensure(!result.empty());
457 
458  // Exit:
459 
460  return result;
461 }
462 
465 clone() const
466 {
467 
468  // Preconditions:
469 
470  // Body:
471 
472  // create new handle of the current class.
473 
474  sec_jcb_ed *result = new sec_jcb_ed();
475 
476  // Postconditions:
477 
478  ensure(result != 0);
479  ensure(result->invariant());
480 
481  // Exit:
482 
483  return result;
484 
485 }
486 
487 // PROTECTED MEMBER FUNCTIONS
488 
489 // PRIVATE MEMBER FUNCTIONS
490 
491 
492 //==============================================================================
493 // ANY FACET OF CLASS SEC_JCB_ED
494 //==============================================================================
495 
496 // PUBLIC MEMBER FUNCTIONS
497 
498 bool
500 fiber_is_ancestor_of(const any* xother) const
501 {
502 
503  // Preconditions:
504 
505  require(xother != 0);
506 
507  // Body:
508 
509  // If xother may be dynamically cast to the type of this fiber then this
510  // fiber is an ancestor of xother.
511 
512  bool result = dynamic_cast<const jcb_ed*>(xother) != 0;
513 
514  // Postconditions:
515 
516  ensure(invariant());
517  ensure(xother->invariant());
518 
519  // Exit:
520 
521  return result;
522 
523 }
524 
525 bool
527 is_ancestor_of(const any* xother) const
528 {
529  // Preconditions:
530 
531  require(xother != 0);
532 
533  // Body:
534 
535  // If other may be dynamically cast to the type of this then this is an
536  // ancestor of other.
537 
538  bool result = dynamic_cast<const sec_jcb_ed*>(xother) != 0;
539 
540  // Postconditions:
541 
542  //ensure(invariant());
543 
544  // Exit:
545 
546  return result;
547 
548 }
549 
550 bool
552 invariant() const
553 {
554  bool result = true;
555 
556  // Preconditions:
557 
558  // Body:
559 
560  // Must satisfy base class invariant
561 
562  invariance(sec_jcb::invariant());
563 
564  if (invariant_check())
565  {
566  // Prevent recursive calls to invariant
567 
568  disable_invariant_check();
569 
570  // Finished, turn invariant checking back on.
571 
572  enable_invariant_check();
573  }
574 
575  // Postconditions:
576 
577  ensure(is_derived_query);
578 
579  // Exit:
580 
581  return result;
582 
583 }
584 
585 // PROTECTED MEMBER FUNCTIONS
586 
587 // PRIVATE MEMBER FUNCTIONS
588 
589 
590 
static int d(int xdd, int xdr)
Dimension d() as a function of domain dimension xdd and range dimension xdr.
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 is_ancestor_of(const any *xother) const
True if xother conforms to current.
Definition: sec_jcb_ed.cc:527
bool full() const
True if both poset name and member name are not empty.
Definition: poset_path.cc:311
sec_jcb_ed()
Default constructor.
Definition: sec_jcb_ed.cc:117
poset_path range_path() const
The path of the range vector space.
The abstract map from section dof ids to section dof values of heterogeneous type.
virtual sec_jcb_ed * clone() const
Make a new handle, no state instance of current.
Definition: sec_jcb_ed.cc:465
Abstract jacobian for d dimensional Euclidean space (volatile version).
Definition: jcb_ed.h:44
A space of scalars viewed as an antisymmetric tensor section space of degree 1.
Definition: sec_at1_space.h:48
poset_path domain_path() const
The path of the domain vector space.
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...
~sec_jcb_ed()
Destructor.
Definition: sec_jcb_ed.cc:353
bool invariant() const
Class invariant.
Definition: sec_jcb_ed.cc:552
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.
STL namespace.
A schema poset for a section space. A binary Cartesian product subspace of the binary tensor product ...
bool fiber_is_ancestor_of(const any *xother) const
True if xother conforms to an instance of the fiber of current.
Definition: sec_jcb_ed.cc:500
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.
Abstract base class with useful features for all objects.
Definition: any.h:39
virtual section_space_schema_member & schema()
The schema for this poset (mutable version)
virtual int dr() const
Dimension of the range.
virtual sec_jcb_ed & operator=(const abstract_poset_member &xother)
Assignment operator; synonym for attach_to_state(&xother).
Definition: sec_jcb_ed.cc:269
int dd() const
The dimension of the underlying ("domain") vector space.
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 section of a bundle with fiber type jcb_ed.
Definition: sec_jcb_ed.h:46
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. ...
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_jcb_ed.cc:446
virtual const std::string & class_name() const
The name of this class.
Definition: sec_jcb_ed.cc:427
Abstract jacobian class.
Definition: jcb.h:229
An abstract space of Jacobians.
Definition: jcb_space.h:46
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).
An abstract section space of Jacobians.
Definition: sec_jcb_space.h:53
static host_type & new_host(namespace_type &xns, const poset_path &xhost_path, const poset_path &xschema_path, const poset_path &xdomain_space_path, const poset_path &xrange_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_jcb_ed.cc:52
Abstract jacobian for d dimensional Euclidean space (persistent version).
Definition: jcb_ed.h:185
An abstract client handle for a member of a poset.
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...
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.
Definition: scoped_index.h:710
virtual const fiber_type & fiber_prototype() const
Virtual constructor for the associated fiber type.
Definition: sec_jcb_ed.cc:366
A handle for a poset whose members are numerical representations of sections of a fiber bundle...
Definition: sec_rep_space.h:61