SheafSystem  0.0.0.0
section_space_schema_table_dof_crg_range.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/section_space_schema_table_dof_crg_range.h"
22 #include "SheafSystem/assert_contract.h"
23 #include "SheafSystem/factory.h"
24 #include "SheafSystem/cover_set_iterator.h"
25 #include "SheafSystem/ij_product_structure.h"
26 #include "SheafSystem/index_space_iterator.h"
27 #include "SheafSystem/product_section_space_schema_crg_range.h"
28 #include "SheafSystem/product_section_space_schema_poset.h"
29 
30 // ===========================================================
31 // SECTION_SPACE_SCHEMA_TABLE_DOF_CRG_RANGE FACET
32 // ===========================================================
33 
34 // PUBLIC MEMBER FUNCTIONS
35 
38  : _product_range(0)
39 {
40  // Preconditions:
41 
42  // Body:
43 
44  // Postconditions:
45 
46  ensure(invariant());
47 
48  // Exit:
49 
50  return;
51 }
52 
55 {
56  // Preconditions:
57 
58  // Body:
59 
60  // Postconditions:
61 
62  // Exit:
63 
64  return;
65 }
66 
67 bool
70 {
71  // Preconditions:
72 
73  // Body:
74 
75  bool result = (_product_range != 0);
76 
77  // Postconditions:
78 
79  ensure(is_basic_query);
80 
81  // Exit:
82 
83  return result;
84 }
85 
86 // PROTECTED MEMBER FUNCTIONS
87 
88 void
91 {
92  // Preconditions:
93 
94  require(!product_range_initialized());
95 
96  // Body:
97 
98  _product_range = &xproduct_range;
99 
100  // Postconditions:
101 
102  ensure(product_range_initialized());
103 
104  // Exit:
105 
106  return;
107 }
108 
109 // PRIVATE MEMBER FUNCTIONS
110 
111 
112 // ===========================================================
113 // SECTION_SPACE_SCHEMA_CRG_RANGE FACET
114 // ===========================================================
115 
116 // PUBLIC MEMBER FUNCTIONS
117 
118 bool
121  pod_index_type xfiber_schema_id) const
122 {
123  // Preconditions:
124 
125  // Body:
126 
127  bool result =
128  xbase_space_id == BOTTOM_INDEX &&
129  _fiber_schema->table_dof_subposet().id_space().contains_hub(xfiber_schema_id);
130 
131  // Postconditions:
132 
133  ensure(is_basic_query);
134 
135  // Exit:
136 
137  return result;
138 }
139 
140 void
143  pod_index_type& xbase_space_id,
144  pod_index_type& xfiber_schema_id) const
145 {
146  // Preconditions:
147 
148  require(local_id_space().contains_hub(xindex));
149 
150  // Body:
151 
152  pod_index_type lpod = _local_id_space.pod(xindex);
153 
154  xbase_space_id = BOTTOM_INDEX;
155  xfiber_schema_id =
157 
158  // Postconditions:
159 
160  ensure(contains_member(xbase_space_id, xfiber_schema_id));
161 
162  // Exit:
163 
164  return;
165 }
166 
167 void
169 ordinal(pod_index_type xbase_space_id,
170  pod_index_type xfiber_schema_id,
171  pod_index_type& xindex) const
172 {
173  // Preconditions:
174 
175  require(contains_member(xbase_space_id, xfiber_schema_id));
176 
177  // Body:
178 
179  xindex = _fiber_schema->table_dof_subposet().id_space().pod(xfiber_schema_id);
180  xindex = _local_id_space.hub_pod(xindex);
181 
182  // Postconditions:
183 
184  ensure(local_id_space().contains_hub(xindex));
185 
186  // Exit:
187 
188  return;
189 }
190 
191 // PROTECTED MEMBER FUNCTIONS
192 
193 // PRIVATE MEMBER FUNCTIONS
194 
195 
196 // ===========================================================
197 // IMPLICIT_CRG_RANGE FACET
198 // ===========================================================
199 
200 // PUBLIC MEMBER FUNCTIONS
201 
202 // PROTECTED MEMBER FUNCTIONS
203 
204 // PRIVATE MEMBER FUNCTIONS
205 
206 
207 // ===========================================================
208 // RANGE FACET
209 // ===========================================================
210 
211 // PUBLIC MEMBER FUNCTIONS
212 
213 void
216 {
217  // Preconditions:
218 
219  require(xhost.state_is_read_accessible());
220 
221  // Body:
222 
223  result = xhost.fiber_schema().table_dof_subposet().id_space().ct();
224 
225  // Postconditions:
226 
227  // Exit:
228 
229  return;
230 }
231 
232 sheaf::cover_set_iterator
234 atoms() const
235 {
236  // Preconditions:
237 
238  // Body:
239 
240  list_cover_set* lcover = new list_cover_set(0);
241  lcover->put_is_implicit(true);
242 
243 
244  index_space_iterator& litr =
246  while(!litr.is_done())
247  {
248  lcover->push_back(_local_id_space.hub_pod(litr.pod()));
249 
250  litr.next();
251  }
253 
254  cover_set_iterator result(lcover);
255 
256  // Postconditions:
257 
258  // Exit:
259 
260  return result;
261 }
262 
263 
264 // PROTECTED MEMBER FUNCTIONS
265 
266 // PRIVATE MEMBER FUNCTIONS
267 
268 
269 // ===========================================================
270 // COVER SET FACET
271 // ===========================================================
272 
273 // PUBLIC MEMBER FUNCTIONS
274 
275 // PROTECTED MEMBER FUNCTIONS
276 
277 sheaf::cover_set_iterator
279 implicit_cover_iterator(bool xlower, pod_index_type xmbr_index) const
280 {
281  // Preconditions:
282 
283  require(contains_member(xmbr_index));
284 
285  // Body:
286 
287  list_cover_set* lcover = new list_cover_set(0);
288  lcover->put_is_implicit(true);
289 
290  if(xlower)
291  {
292  lcover->push_back(BOTTOM_INDEX);
293  }
294  else
295  {
296  pod_index_type lbase_space_id, lfiber_schema_id, lid;
297  tuple(xmbr_index, lbase_space_id, lfiber_schema_id);
298 
299  cover_set_iterator litr = _base_space->cover_iterator(false, BOTTOM_INDEX);
300  while(!litr.is_done())
301  {
302  _product_range->ordinal(litr.item(), lfiber_schema_id, lid);
303  lcover->push_back(lid);
304 
305  litr.next();
306  }
307  }
308 
309  cover_set_iterator result(lcover);
310 
311  // Postconditions:
312 
313  // Exit:
314 
315  return result;
316 }
317 
318 bool
320 implicit_cover_is_empty(bool xlower, pod_index_type xmbr_index) const
321 {
322  // Preconditions:
323 
324  require(contains_member(xmbr_index));
325 
326  // Body:
327 
328  // The cover is never empty.
329 
330  // Postconditions:
331 
332  ensure(is_basic_query);
333 
334  // Exit:
335 
336  return false;
337 }
338 
341 implicit_cover_size(bool xlower, pod_index_type xmbr_index) const
342 {
343  // Preconditions:
344 
345  require(contains_member(xmbr_index));
346 
347  // Body:
348 
349  size_type result;
350 
351  if(xlower)
352  {
353  result = 1;
354  }
355  else
356  {
357  result = _base_space->cover_ct(false, BOTTOM_INDEX);
358  }
359 
360  // Postconditions:
361 
362  ensure(is_basic_query);
363 
364  // Exit:
365 
366  return result;
367 }
368 
369 bool
372  pod_index_type xmbr_index,
373  pod_index_type xother_index) const
374 {
375  // Preconditions:
376 
377  require(contains_member(xmbr_index));
378 
379  // Body:
380 
381  // Factor xmbr_index.
382 
383  bool result;
384 
385  if(xlower)
386  {
387  result = (xother_index == BOTTOM_INDEX);
388  }
389  else
390  {
391  pod_index_type lbase_space_id, lfiber_schema_id;
392  tuple(xmbr_index, lbase_space_id, lfiber_schema_id);
393 
394  if(_product_range->contains_member(xother_index))
395  {
396  // In the product range, factor xother_index.
397 
398  pod_index_type lother_base_space_id, lother_fiber_schema_id;
399  _product_range->tuple(xother_index, lother_base_space_id, lother_fiber_schema_id);
400 
401  result = (lother_base_space_id == BOTTOM_INDEX) && (lother_fiber_schema_id == lfiber_schema_id);
402  }
403  else
404  {
405  // Not in the product range, cover does not contain the member.
406 
407  result = false;
408  }
409  }
410 
411  // Postconditions:
412 
413  ensure(is_basic_query);
414 
415  // Exit:
416 
417  return result;
418 }
419 
422 implicit_first_cover_member(bool xlower, pod_index_type xmbr_index) const
423 {
424  // Preconditions:
425 
426  require(contains_member(xmbr_index));
427  require(!cover_is_empty(xlower, xmbr_index));
428 
429  // Body:
430 
431  pod_index_type result;
432 
433  if(_fiber_schema->is_atom(_local_id_space.pod(xmbr_index)))
434  {
435  result = BOTTOM_INDEX;
436  }
437  else
438  {
439  result = _base_space->first_cover_member(false, BOTTOM_INDEX);
440  }
441 
442  // Postconditions:
443 
444  ensure(is_basic_query);
445 
446  // Exit:
447 
448  return result;
449 }
450 
451 // PRIVATE MEMBER FUNCTIONS
452 
453 
454 // ===========================================================
455 // DOF_TUPLE_ID FACET
456 // ===========================================================
457 
458 // PUBLIC MEMBER FUNCTIONS
459 
460 bool
462 is_jim(pod_index_type xmbr_index) const
463 {
464  // Preconditions:
465 
466  require(contains_member(xmbr_index));
467 
468  // Body:
469 
470  // All members are jims.
471 
472  // Postconditions:
473 
474  ensure(is_basic_query);
475 
476  // Exit:
477 
478  return true;
479 }
480 
481 const sheaf::scoped_index&
483 dof_tuple_id(pod_index_type xmbr_index) const
484 {
485  // Preconditions:
486 
487  require(contains_member(xmbr_index));
488 
489  // Body:
490 
491  pod_index_type lfiber_schema_id =
492  _fiber_schema->table_dof_subposet().id_space().hub_pod(_local_id_space.pod(xmbr_index));
493 
494  const scoped_index& result = _fiber_schema->dof_tuple_id(lfiber_schema_id);
495 
496  // Postconditions:
497 
498  ensure(result.is_valid());
499 
500  // Exit:
501 
502  return result;
503 }
504 
505 // PROTECTED MEMBER FUNCTIONS
506 
507 // PRIVATE MEMBER FUNCTIONS
508 
509 
510 // ===========================================================
511 // PRIVATE_DATA FACET
512 // ===========================================================
513 
514 // PUBLIC MEMBER FUNCTIONS
515 
516 // PROTECTED MEMBER FUNCTIONS
517 
521 {
522  // Preconditions:
523 
524  // Body:
525 
526  // Postconditions:
527 
528  ensure(is_basic_query);
529 
530  // Exit:
531 
532  return 0;
533 }
534 
535 void
538 {
539  // Preconditions:
540 
541  // Body:
542 
543  // nothing to do.
544 
545  // Postconditions:
546 
547  ensure(xdata.ct() == implicit_private_data_size());
548 
549  // Exit:
550 
551  return;
552 }
553 
554 void
557 {
558  // Preconditions:
559 
560  require(xdata.ct() >= implicit_private_data_size());
561 
562  // Body:
563 
564  // Postconditions:
565 
566  ensure(invariant());
567 
568  // Exit:
569 
570  return;
571 }
572 
573 // PRIVATE MEMBER FUNCTIONS
574 
575 
576 // ===========================================================
577 // FINIALIZE FACET
578 // ===========================================================
579 
580 // PUBLIC DATA MEMBERS
581 
582 void
585 {
586  // Preconditions:
587 
588  require(dynamic_cast<product_section_space_schema_poset*>(&xhost) != 0);
589  require(xhost.state_is_read_accessible());
590 
591  // Body:
592 
594  reinterpret_cast<product_section_space_schema_poset&>(xhost);
595 
596  // Initialize base space.
597 
598  initialize_base_space(lhost.base_space());
599 
600  // Initialize fiber schema.
601 
602  initialize_fiber_schema(lhost.fiber_schema());
603 
604  // Initialize the product crg range.
605 
606  initialize_product_range(lhost.product_range());
607 
608  // Put atoms in upper cover of bottom.
609 
613 
614  xhost.append_cover(atoms(), UPPER, BOTTOM_INDEX);
615 
616  implicit_crg_range::finalize(xhost);
617 
618  // Set the range of the host to this.
619 
620  lhost.put_table_dof_range(*this);
621 
622  // Postconditions:
623 
624  ensure(invariant());
625  ensure(is_initialized());
626 
627  // Exit:
628 
629  return;
630 }
631 
632 // PROTECTED DATA MEMBERS
633 
634 // PRIVATE DATA MEMBERS
635 
636 
637 // ===========================================================
638 // FACTORY FACET
639 // ===========================================================
640 
641 // PUBLIC MEMBER FUNCTIONS
642 
643 bool
646 {
647  // Preconditions:
648 
649  // Body:
650 
651  bool result =
652  implicit_crg_range::is_initialized() &&
654 
655  // Postconditions:
656 
657  ensure(is_basic_query);
658 
659  // Exit:
660 
661  return result;
662 }
663 
664 const std::string&
666 class_name() const
667 {
668  // Preconditions:
669 
670  // Body:
671 
672  static const string result("section_space_schema_table_dof_crg_range");
673 
674  // Postconditions:
675 
676  // Exit:
677 
678  return result;
679 }
680 
681 // PROTECTED MEMBER FUNCTIONS
682 
683 // PRIVATE MEMBER FUNCTIONS
684 
685 bool
686 fiber_bundle::section_space_schema_table_dof_crg_range::
687 make_prototype()
688 {
689  // Preconditions:
690 
691  // Body:
692 
695 
696  range_factory().insert_prototype(lproto);
697 
698  // Postconditions:
699 
700  // Exit:
701 
702  return true;
703 }
704 
705 
706 // ===========================================================
707 // ANY FACET
708 // ===========================================================
709 
710 // PUBLIC MEMBER FUNCTIONS
711 
712 bool
714 is_ancestor_of(const any *other) const
715 {
716  // Preconditions:
717 
718  require(other != 0);
719 
720  // Body:
721 
722  // True if other conforms to this
723 
724  bool result = dynamic_cast<const section_space_schema_table_dof_crg_range*>(other) != 0;
725 
726  // Postconditions:
727 
728  // Exit:
729 
730  return result;
731 }
732 
735 clone() const
736 {
737  // Preconditions:
738 
739  // Body:
740 
743 
744  // Postconditions:
745 
746  ensure(result != 0);
747  ensure(is_same_type(result));
748 
749  // Exit:
750 
751  return result;
752 }
753 
754 bool
756 invariant() const
757 {
758  bool result = true;
759 
760  if(invariant_check())
761  {
762  // Prevent recursive calls to invariant
763 
764  disable_invariant_check();
765 
766  // Must satisfy base class invariant
767 
768  invariance(implicit_crg_range::invariant());
769 
770  // Invariances for this class:
771 
772  // Finished, turn invariant checking back on.
773 
774  enable_invariant_check();
775  }
776 
777  // Exit
778 
779  return result;
780 }
781 
782 // PROTECTED MEMBER FUNCTIONS
783 
784 // PRIVATE MEMBER FUNCTIONS
785 
786 
787 // ===========================================================
788 // NON-MEMBER FUNCTIONS
789 // ===========================================================
790 
virtual size_type implicit_cover_size(bool xlower, pod_index_type xmbr_index) const
The number of members in the lower (xlower true) or upper (xlower false) cover set.
virtual cover_set_iterator implicit_cover_iterator(bool xlower, pod_index_type xmbr_index) const
Iterator for lower (xlower true) or upper (xlower false) cover set of the member with index xmbr_inde...
virtual pod_index_type implicit_first_cover_member(bool xlower, pod_index_type xmbr_index) const
The first member of the lower (xlower true) or upper (xlower false) cover.
bool is_valid() const
True if this is a valid id.
Definition: scoped_index.h:832
size_type ct() const
The number of items currently in use.
static void get_size(const product_section_space_schema_poset &xhost, size_type &result)
The size for an instance created with parameter xhost.
virtual size_type cover_ct(bool xlower, pod_index_type xmbr_hub_id) const
The number of members in the lower cover (xlower true) or upper cover (xlower false) of the member wi...
void initialize_fiber_schema(poset_state_handle &xfiber_schema)
Sets the fiber schema for section spaces on this schema to xfiber_schema.
An abstract iterator over the ids of an id space.
virtual bool contains_member(pod_index_type xbase_space_id, pod_index_type xfiber_schema_id) const
True if this range contains the member with base space id xbase_space_id and fiber schema id xfiber_s...
virtual void tuple(pod_index_type xindex, pod_index_type &xbase_space_id, pod_index_type &xfiber_schema_id) const
The tuple conversion from section space schema id xindex to the base space id xbase_space_id and fibe...
pod_type pod() const
The current id in the iteration.
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
virtual cover_set_iterator atoms() const
An iterator over the atoms in this range.
A client handle for a general, abstract partially order set.
virtual void finalize(poset_state_handle &xhost)
Finialize the initialization of this crg range in the host xhost.
bool contains_hub(pod_type xid) const
True if this space contains an id equivalent to xid in the unglued hub id space. synonym for contains...
virtual bool is_atom(pod_index_type xmbr_hub_id) const
True if the member with hub id xmbr_hub_id covers the bottom.
virtual bool contains_member(pod_index_type xbase_space_id, pod_index_type xfiber_schema_id) const
True if this range contains the member with base space id xbase_space_id and fiber schema id xfiber_s...
virtual const scoped_index & dof_tuple_id(bool xauto_access) const
An id in the dof tuple hub id space; intended for copying to initialize ids to the dof tuple id space...
virtual void next()=0
Makes id() the next id in the iteration.
virtual void ordinal(pod_index_type xbase_space_id, pod_index_type xfiber_schema_id, pod_index_type &xindex) const
The ordinal conversion from base space id xbase_space_id and fiber schema id xfiber_schema_id to sect...
virtual index_space_iterator & get_iterator() const
Allocates an id space iterator from the iterator pool.
void initialize_base_space(base_space_poset &xbase_space)
Sets the base space for section spaces on this schema to xbase_space.
An schema poset for a section space represented by a Cartesian product subspace of the tensor product...
const product_section_space_schema_crg_range * _product_range
The product crg range.
virtual pod_type pod(pod_type xid) const
The pod index in this space equivalent to xid in the hub id space.
void initialize_product_range(product_section_space_schema_crg_range &xproduct_range)
Sets the product crg range.
Abstract base class with useful features for all objects.
Definition: any.h:39
Abstract emulator for a range of implicit section space schema members.
bool is_done() const
True if iteration is finished.
virtual bool is_ancestor_of(const any *other) const
Conformance test; true if other conforms to this.
virtual void ordinal(pod_index_type xbase_space_id, pod_index_type xfiber_schema_id, pod_index_type &xindex) const
The ordinal conversion from base space id xbase_space_id and fiber schema id xfiber_schema_id to sect...
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
virtual void put_implicit_private_data(const block< pod_index_type > &xdata)
Initializes this using private data xdata.
virtual bool implicit_cover_contains_member(bool xlower, pod_index_type xmbr_index, pod_index_type xother_index) const
True if and only if the lower (xlower true) or upper (xlower false) cover set contains xindex...
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
const bool UPPER
Selector for upper cover.
Definition: sheaf.h:72
virtual size_type implicit_private_data_size() const
The size of the private data.
virtual const std::string & class_name() const
The name of this class; provided to satisfy factory template.
bool product_range_initialized() const
True if the product range has been initialized.
const scattered_insertion_index_space_handle & id_space() const
The id space for the members of with this (const version).
Definition: subposet.cc:508
pod_type hub_pod(pod_type xid) const
The pod index in the unglued hub id space equivalent to xid in this id space; synonym for unglued_hub...
virtual const scoped_index & dof_tuple_id(pod_index_type xmbr_index) const
The dof tuple id of the member with index xmbr_index.
poset_state_handle & fiber_schema()
The fiber schema for section spaces on this schema (mutable version).
virtual bool implicit_cover_is_empty(bool xlower, pod_index_type xmbr_index) const
True if and only if the lower (xlower true) or upper (xlower false) cover set of the member with inde...
Emulator for a range of implicit section space schema members representing the Cartesian product the ...
subposet & table_dof_subposet()
The table dof subposet when this poset is used as a schema (mutable version).
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
virtual void get_implicit_private_data(block< pod_index_type > &xdata) const
The private data for this instance.
base_space_poset * _base_space
The base space for section spaces on this schema.
virtual size_type ct() const
The number of members.
virtual void release_iterator(index_space_iterator &xitr) const
Returns the id space iterator xitr to the iterator pool.
pod_index_type first_cover_member(bool xlower, pod_index_type xmbr_hub_id) const
Hub id of the first member of the lower (xlower true) or upper (xlower false) cover of the member wit...
poset_state_handle * _fiber_schema
The fiber schema for section spaces on this schema.
virtual bool is_jim(pod_index_type xmbr_index) const
True if and only if the member with index xmbr_index is join-irreducible.
virtual void tuple(pod_index_type xindex, pod_index_type &xbase_space_id, pod_index_type &xfiber_schema_id) const
The tuple conversion from section space schema id xindex to the base space id xbase_space_id and fibe...
virtual section_space_schema_table_dof_crg_range * clone() const
Virtual constructor, makes a new instance of the same type as this.