21 #include "SheafSystem/index_space_family.h" 22 #include "SheafSystem/assert_contract.h" 23 #include "SheafSystem/explicit_index_space_interval.h" 24 #include "SheafSystem/hub_index_space_handle.h" 25 #include "SheafSystem/index_equivalence_iterator.h" 26 #include "SheafSystem/index_space_family_iterator.h" 27 #include "SheafSystem/index_space_interval_iterator.h" 28 #include "SheafSystem/index_space_iterator.h" 29 #include "SheafSystem/interval_index_space_state.h" 30 #include "SheafSystem/scattered_insertion_index_space_handle.h" 31 #include "SheafSystem/poset_path.h" 32 #include "SheafSystem/primary_index_space_handle.h" 33 #include "SheafSystem/primary_sum_index_space_state.h" 34 #include "SheafSystem/scoped_index.h" 35 #include "SheafSystem/std_iomanip.h" 36 #include "SheafSystem/std_set.h" 50 _explicit_interval(0),
81 interval_map_type::iterator litr =
_intervals.begin();
113 ensure(result.empty() ||
contains(result));
122 index(
const std::string& xname)
const 126 require(!xname.empty());
177 ensure(is_basic_query);
198 ensure(is_basic_query);
217 ensure(is_basic_query);
236 ensure(is_basic_query);
255 ensure(is_basic_query);
293 interval_map_type::iterator itr =
_intervals.begin();
297 interval_map_type::iterator old_itr = itr;
319 assertion(dynamic_cast<explicit_index_space_interval*>(linterval) != 0);
387 require(
contains(xid) ? !handle_conforms_to_state<primary_index_space_handle>(xid) :
true);
424 require(
contains(xname) ? !handle_conforms_to_state<primary_index_space_handle>(xname) :
true);
456 ensure(is_basic_query);
513 require(handle_conforms_to_state<primary_index_space_handle>(xid));
520 get_id_space<primary_index_space_handle>(xid);
541 const std::string& xstate_class_name)
545 require(!xname.empty());
547 require(!xstate_class_name.empty());
551 require(unexecutable(
"xstate_class_name is a mutable id space state"));
558 lstate->
new_state(const_cast<index_space_family&>(*
this), xname,
true);
566 ensure(handle_conforms_to_state<scattered_insertion_index_space_handle>(xname));
593 lcollection->
remove(local_id);
626 require(xinterval.
begin() ==
end());
634 if(_intervals.find(xinterval.
begin()) == _intervals.end())
639 _intervals[xinterval.
begin()] = 0;
660 require(!
contains(xid) || !handle_conforms_to_state<primary_index_space_handle>(xid));
678 if(!lprevious->second)
680 if((lnext ==
_intervals.end()) || (!lnext->second))
698 if((lnext ==
_intervals.end()) || (!lnext->second))
752 (litr !=
_intervals.end()) ? litr->second : 0;
756 ensure(is_basic_query);
774 (litr !=
_intervals.end()) ? litr->second : 0;
778 ensure(is_basic_query);
910 ensure(is_basic_query);
977 ensure(is_basic_query);
996 ensure(is_basic_query);
1015 ensure(is_basic_query);
1034 ensure(is_basic_query);
1053 ensure(is_basic_query);
1072 ensure(is_basic_query);
1091 ensure(is_basic_query);
1112 ensure(is_basic_query);
1137 ensure_for_range(
scoped_index i=old_last_term_begin, i<old_last_term_begin+xct, ++i, i.
in_scope());
1157 ct(
const std::string& xname)
const 1169 ensure(is_basic_query);
1193 ensure(is_basic_query);
1214 ensure(is_basic_query);
1231 bool result = (
ct(xspace_id) == 0);
1235 ensure(is_basic_query);
1256 ensure(is_basic_query);
1280 ensure(is_basic_query);
1289 end(
const std::string& xname)
const 1301 ensure(is_basic_query);
1325 ensure(is_basic_query);
1346 ensure(is_basic_query);
1370 ensure(is_basic_query);
1391 ensure(is_basic_query);
1408 bool result = (
begin(xspace_id) == 0) && (
end(xspace_id) ==
ct(xspace_id));
1412 ensure(is_basic_query);
1433 ensure(is_basic_query);
1453 bool result = lcollection->
contains(local_id, xid);
1457 ensure(is_basic_query);
1478 ensure(is_basic_query);
1499 ensure(is_basic_query);
1520 ensure(is_basic_query);
1541 ensure(is_basic_query);
1562 ensure(is_basic_query);
1586 ensure(is_basic_query);
1607 ensure(is_basic_query);
1629 ensure(is_basic_query);
1650 ensure(is_basic_query);
1671 ensure(is_basic_query);
1692 ensure(is_basic_query);
1712 bool result = lcollection->
contains(local_id, xid, xhub_id);
1716 ensure(is_basic_query);
1757 pod_type result = lcollection->
pod(local_id, xid);
1954 ensure(is_basic_query);
1978 ensure(is_basic_query);
2078 ensure(is_basic_query);
2204 ensure(is_basic_query);
2230 ensure(is_basic_query);
2253 ensure(is_basic_query);
2279 ensure(is_basic_query);
2300 ensure(is_basic_query);
2324 ensure(is_basic_query);
2401 ensure(is_basic_query);
2420 ensure(is_basic_query);
2497 ensure(is_basic_query);
2516 ensure(is_basic_query);
2540 require(other != 0);
2573 invariance(
begin() == 0);
2605 set<pod_index_type> lprimary;
2606 set<pod_index_type> lsecondary;
2611 if(litr.
name().substr(0, 5) ==
"__hub")
2615 lprimary.insert(litr.
index());
2621 lsecondary.insert(litr.
index());
2627 xos <<
"id spaces" << endl;
2628 xos <<
"---------" << endl;
2631 xos <<
" begin = " << xfamily.
begin() << endl;
2632 xos <<
" end = " << xfamily.
end() << endl << endl;
2634 xos << setw(10) <<
"index" 2635 << setw(32) <<
"name" 2637 << setw(10) <<
"begin" 2638 << setw(10) <<
"end" 2639 << setw(12) <<
"persistent" 2642 xos << setw(10) <<
"---------" 2643 << setw(32) <<
"-------------------------------" 2644 << setw(10) <<
"---------" 2645 << setw(10) <<
"---------" 2646 << setw(10) <<
"---------" 2647 << setw(12) <<
"-----------" 2650 set<pod_index_type>::const_iterator lprimary_itr = lprimary.begin();
2656 xos << setw(10) << *lprimary_itr
2657 << setw(32) << xfamily.
name(*lprimary_itr)
2662 xos << setw(10) << xfamily.
begin(*lprimary_itr)
2663 << setw(10) << xfamily.
end(*lprimary_itr);
2671 xos <<
" primary:" << endl;
2673 while(lprimary_itr != lprimary.end())
2675 lct = xfamily.
ct(*lprimary_itr);
2677 xos << setw(10) << *lprimary_itr
2678 << setw(32) << xfamily.
name(*lprimary_itr)
2683 xos << setw(10) << xfamily.
begin(*lprimary_itr)
2684 << setw(10) << xfamily.
end(*lprimary_itr);
2694 xos <<
" secondary:" << endl;
2696 set<pod_index_type>::const_iterator lsecondary_itr = lsecondary.begin();
2698 while(lsecondary_itr != lsecondary.end())
2700 lct = xfamily.
ct(*lsecondary_itr);
2702 xos << setw(10) << *lsecondary_itr
2703 << setw(32) << xfamily.
name(*lsecondary_itr)
2708 xos << setw(10) << xfamily.
begin(*lsecondary_itr)
2709 << setw(10) << xfamily.
end(*lsecondary_itr)
2710 << setw(12) << boolalpha << xfamily.
is_persistent(*lsecondary_itr) << noboolalpha;
2720 xos <<
"equivalence classes" << endl;
2721 xos <<
"-------------------" << endl;
2735 lid = lid_itr.
pod();
2746 << setw(4) << lid.
pod()
2752 << setw(4) << leqv_itr.
item().first
2754 << setw(4) << leqv_itr.
item().second
2770 xos <<
" ... " << endl
2771 <<
" Equivalence class output terminated because the " << endl
2772 <<
" size of the hub id space exceeded " 2774 <<
" use index_space_family::max_rep_ids() to change default." << endl;
2795 result = xinclude_shallow ?
sizeof(xfamily) : 0;
2802 if(itr->second != 0)
2804 result += itr->second->deep_size(
true);
2814 ensure(result >= 0);
virtual pod_type glued_hub_pod(pod_type xid) const
The pod index in the hub id space equivalent to xid in this id space. synonym for unglued_hub_pod(xid...
virtual bool invariant() const
Class invariant, intended to be redefined in each descendant. See below for template for invariant in...
name_multimap _name_to_index
Map from name to id space index.
bool allocated_id_space_iterator(const index_space_iterator &xitr) const
True if and only if id space iterator xitr was allocated by the iterator pool.
virtual pod_type local_scope(pod_type xspace_id) const
Id relative to this collection equivalent to the id space family id xspace_id.
const index_space_collection * collection(pod_type xid) const
Id space collection for id xid (const version).
const member_type & item() const
The current equivalence class member.
friend SHEAF_DLL_SPEC size_t deep_size(const index_space_family &xfamily, bool xinclude_shallow)
The deep size of index_space_family& xn.
void insert_interval(index_space_interval &xinterval)
Inserts an id space interval into this family.
pod_type end() const
The ending index of the id spaces.
virtual void new_product_structure(pod_type xlocal_id, const abstract_product_structure &xproduct)=0
Creates a new product structure for the id space with id xlocal_id by cloning the product structure...
pod_type pod(const std::string &xname, pod_type xid) const
The pod index in the space with name xname equivalent to xid in the hub id space. ...
std::string name(pod_type xid) const
The name for id xid.
An abstract class that defines the product structure for an id space.
bool in_scope() const
True if and only if scope() contains an entry for pod().
const pod_type & pod() const
The "plain old data" storage of this; the value in the external id space.
An abstract iterator over the ids of an id space.
void next()
Makes item() the next item in the equivalence class.
void release_id_space(index_space_handle &xid_space) const
Returns the id space handle xid_space to the handle pool.
void extend_last_term(size_type xct)
Extends the last term to ct() == xct.
virtual bool contains_family(pod_type xspace_id) const =0
True if this collection contains the id space with family id xspace_id.
static const std::string & hub_id_space_name()
Name of the hub id space.
index_type index(const std::string &xname) const
The index associated with name xname.
void glue(pod_type xid, pod_type xrep)
Glues xid to xrep; adds xid to the equivalence class with representative member xrep.
pod_type hub_begin(const std::string &xname) const
Beginning id of the space in the hub id space with name xname.
pod_type pod() const
The current id in the iteration.
const index_space_handle & term_of(pod_type xid) const
The term in the hub id space containing id xid.
static hub_index_space_handle new_space(index_space_family &xid_spaces, const std::string &xname)
Create a new primary sum id space in the id space family xid_space at the next available id space ind...
bool is_persistent(const std::string &xname) const
True if the id space with name xname should be written to disk.
hub_index_space_handle _hub_id_space
The hub id space.
const abstract_product_structure & product_structure(const std::string &xname) const
The product structure for the id space with name xname (const version).
void extend_last_term(size_type xct)
Extends the last term to to ct == xct.
void put_rep_id(pod_index_type xrep_id)
Sets rep_id() to xrep_id.
interval_map_type::const_iterator const_interval_iterator_type
Type of interval map iterator.
index_space_handle & get_id_space(const std::string &xname) const
Allocates an id space handle from the handle pool attached to state with name xname.
void clear_id_spaces()
Clear all the non-standard id spaces in this family.
virtual void delete_product_structure(pod_type xlocal_id)=0
Deletes the product structure for the id space with id xlocal_id.
void delete_state(pod_type xid)
Delete the state with id xid.
bool is_valid_reserved_id(pod_type xid) const
True if and only if the reserved term containing xid is already a reserved term or is available for a...
virtual pod_type end(pod_type xlocal_id) const =0
Ending id of the space with id xlocal_id.
pod_type _standard_end
Ending index of the standard id spaces.
static size_type explicit_interval_size()
Size of the explicit id space intervals.
pod_type _end
Ending index of the id spaces.
An abstract handle to a space of alternate integer identifiers (aliases) for a subset of a hub set of...
void put_name(pod_type xid, const std::string &xname)
Associate name xname with id space index xid.
const index_space_handle & new_gathered_id_space(bool xexclude_bottom)
Construct a gathered id space from this id space. If xexclude_bottom, construct the id space without ...
virtual pod_type index() const =0
Index of this space.
virtual void next()=0
Makes id() the next id in the iteration.
virtual bool is_attached() const =0
True if this handle is attached to a state.
void update_standard_id_spaces()
Update the initially allocated id spaces.
An implementation of class sum_index_space_handle that has a primary sum id space state...
virtual index_space_iterator & get_iterator() const
Allocates an id space iterator from the iterator pool.
virtual bool contains_unglued_hub(pod_type xlocal_id, pod_type xid) const =0
True if the space with id xlocal_id contains an id equivalent to xid in the unglued hub id space...
index_space_iterator & get_id_space_iterator(const std::string &xname) const
Allocates an id space iterator from the iterator pool attached to state with name xname...
pod_type begin() const
The beginning index of the id spaces.
virtual explicit_index_space_state * explicit_state(pod_type xlocal_id) const =0
The explicit id space state for id xlocal_id. Returns null if there is no explicit id space for xloca...
interval_map_type::iterator interval_iterator_type
Type of interval map iterator.
void unglue_all(pod_type xrep_id)
Unglue all ids glued to representative xrep_id; makes each id in the equivalence class of xrep_id its...
virtual bool has_product_structure(pod_type xlocal_id) const =0
True if the id space with id xlocal_id has a product structure.
index_space_family()
Default constructor.
virtual pod_type local_scope(pod_type xspace_id) const =0
Id relative to this collection equivalent to the id space family id xspace_id.
pod_type index(const std::string &xname) const
The index for name xname.
An implementation of class explicit_index_space_handle that has a primary id space state...
pod_type scope_id() const
The index of the scope id space.
pod_type glued_hub_pod(const std::string &xname, pod_type xid) const
The pod index in the glued hub id space equivalent to xid in the id space with name xname...
void new_product_structure(const std::string &xname, const abstract_product_structure &xproduct)
Creates a new product structure for the id space with name xname by cloning the product structure...
An abstract iterator over the id spaces of a interval.
static size_type & max_rep_ids()
Maximum number of representive ids which are permitted by the stream insertion operator to output the...
Abstract base class with useful features for all objects.
const size_type EXPLICIT_INTERVAL_SIZE
Size of the explicit id space intervals.
An implemenation of index_space_collection that adds an interface for the interval [begin()...
bool has_only_standard_id_spaces() const
True if and only if all the id spaces are standard id spaces.
bool is_done() const
True if iteration is finished.
virtual pod_type begin(pod_type xlocal_id) const =0
Beginning id of the space with id xlocal_id.
bool is_done() const
True if iteration is finished.
pod_type new_id()
Allocate the next available id in this family.
An immutable abstract state for a space of alternate integer identifiers (aliases) for a subset of th...
void unglue(pod_type xid)
Unglues xid; makes xid its own representative.
pod_type new_primary_term(size_type xct)
Create a new primary term [next_id(), next_id()+xct). Returns the index of the term created...
pod_type hub_pod(const std::string &xname, pod_type xid) const
The pod index in the unglued hub id space equivalent to xid in the id space with name xname...
void release_id_space_iterator(index_space_iterator &xitr) const
Returns the id space iterator xitr to the iterator pool.
void unglue_all(pod_type xrep_id)
Unglue all ids glued to representative xrep_id; makes each id in the equivalence class of xrep_id its...
An index within the external ("client") scope of a given id space.
bool has_gathered_hub_id_space() const
True if there is a gathered hub id space for this family.
SHEAF_DLL_SPEC size_t deep_size(const dof_descriptor_array &xp, bool xinclude_shallow=true)
The deep size of the referenced object of type dof_descriptor_array.
std::string name() const
The name of the current id space in the iteration.
const index_space_handle & gathered_id_space() const
The gathered id space.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
void new_state(const std::string &xname, const std::string &xstate_class_name)
Create a new id space with class type xstate_class_name and name xname. Used by the I/O system to rea...
bool has_product_structure(const std::string &xname) const
True if the id space with name xname has a product structure.
void delete_id(pod_type xid)
Deallocate the id xid in this family.
bool contains_name(const std::string &xname) const
True if this already contains an entry with name xname.
virtual size_type ct(pod_type xlocal_id) const =0
The number of members for the id space with id xlocal_id.
static std::string reserved_prefix()
Prefix for identifying member names reserved by the sheaf system.
bool is_explicit_interval(pod_type xid)
True, if and only if the id space interval that contains index xid is an explicit interval...
void update_gathered_id_space()
Update the gathered id space.
void reset()
Restarts the iteration.
void delete_primary_state(pod_type xid)
Delete the primary space state with id xid.
virtual pod_type pod(pod_type xlocal_id, pod_type xid) const =0
The pod index in the space with id xlocal_id equivalent to xid in the hub id space.
virtual bool is_persistent(pod_type xlocal_id) const =0
True if the id space with id xlocal_id should be written to disk.
bool gathered_hub_id_space_excludes_bottom() const
True, if the gathered hub id space excludes BOTTOM_INDEX.
pod_index_type pod_type
The "plain old data" index type for this.
void update_standard_ids()
Make end() the standard id end.
void clear_ids()
Deallocate all non-standard ids.
interval_map_type _intervals
Map from id to id space interval.
pod_type new_id()
Allocate the next available id in this space.
A collection of id space states. This is a virtual class with provides an interface for accessing the...
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
virtual const abstract_product_structure & product_structure(pod_type xlocal_id) const =0
The product structure for the id space with id xlocal_id (const version).
bool contains_index(index_type xindex) const
True if this already contains an entry with index xindex.
virtual bool contains(pod_type xlocal_id) const =0
True if this collection contains the id space with local id xlocal_id.
void new_state(index_space_family &xid_spaces, const std::string &xname, bool xis_persistent)
Create a new id space state in the id space family xid_spaces at the next available id space index wi...
virtual pod_type index() const =0
Index of this space.
void glue(pod_type xid, pod_type xrep)
Glues xid to xrep; adds xid to the equivalence class with representative member xrep.
An implementation of index_space_interval for an interval of explicit id spaces.
bool is_valid_reserved_id(pod_type xid) const
True if and only if the reserved term containing xid is already a reserved term or is available for a...
const index_space_handle & new_gathered_hub_id_space(bool xexclude_bottom)
Create a gathered hub id space for this family. If xexclude_bottom, construct the id space without BO...
virtual bool invariant() const
Class invariant.
pod_type index() const
The index of the current id space in the iteration.
void delete_id(pod_type xid)
Deallocate the id xid in this space.
void delete_interval(pod_type xid)
Delete the interval that contains the id space with id xid.
void delete_space(pod_type xid)
Delete the id space with index xid.
pod_type _next_explicit_id
The next available id for an explicit index space.
bool is_empty(const std::string &xname) const
True if there are no ids in the space with name xname.
const index_space_handle & last_term() const
The last term.
bool gathered_id_space_excludes_bottom() const
True, if the gathered id space excludes BOTTOM_INDEX.
pod_type new_primary_state(size_type xct)
Creates a new primary id space state with xct number of ids. Returns the index of the id space state ...
virtual bool is_attached() const =0
True if this iterator is attached to a state.
explicit_index_space_interval * _explicit_interval
The current explicit id space interval.
bool has_gathered_id_space() const
True, if the gathered id space exists.
bool invariant_check() const
True if invariant checking is enabled.
void next()
Makes id_space() the next id space in the iteration.
bool allocated_id_space(const index_space_handle &xid_space) const
True if and only if id space handle xid_space was allocated by the handle pool.
void delete_product_structure(const std::string &xname)
Deletes the product structure for the id space with name xname.
bool is_gathered(const std::string &xname) const
True if begin(xspace_id) == 0 and end(xspace_id) == ct(xspace_id).
int_type pod_index_type
The plain old data index type.
virtual index_space_handle & get_id_space(pod_type xlocal_id) const =0
Allocates an id space handle from the handle pool attached to state with id xlocal_id.
pod_type hub_term_id() const
The term id of this in the hub id space.
void update_gathered_hub_id_space()
Update the gathered hub id space.
SHEAF_DLL_SPEC std::ostream & operator<<(std::ostream &os, const dof_descriptor_array &p)
Insert dof_descriptor_array& p into ostream& os.
void put_entry(const entry_type &xentry, bool xunique)
Sets (xindex, xname) as an entry in the map. If xunique, deletes all other entries for xindex...
virtual index_space_iterator & get_id_space_iterator(pod_type xlocal_id) const =0
Allocates an id space iterator from the iterator pool attached to state with id xlocal_id.
pod_type end() const
Ending space id of this interval in the id space family scope.
bool contains(pod_type xid) const
True, if this contains an id space with id xid.
virtual void remove(pod_type xlocal_id)=0
Remove the id space with id xlocal_id.
bool contains_unglued_hub(const std::string &xname, pod_type xid) const
True if the space with name xname contains an id equivalent to xid in the unglued hub id space...
const index_space_handle & last_term() const
The last term in the hub id space.
virtual size_type ct() const
The number of members.
An iterator over members of an id equivalence class.
virtual void release_iterator(index_space_iterator &xitr) const
Returns the id space iterator xitr to the iterator pool.
Factory and container for a family of id spaces.
bool is_done() const
True if iteration is finished.
std::string name(index_type xindex) const
The primary (0-th) name associated with index xindex.
pod_type hub_pod(pod_type xlocal_id, pod_type xid) const
The pod index in the glued hub id space equivalent to xid in the id space with id xlocal_id...
void remove_term(pod_type xi)
Remove xi-th term of this sum.
virtual pod_type begin(pod_type xlocal_id) const
Beginning id of the space with id xlocal_id.
virtual pod_type end(pod_type xlocal_id) const
Ending id of the space with id xlocal_id.
pod_type unglued_hub_pod(const std::string &xname, pod_type xid) const
The pod index in the unglued hub id space equivalent to xid in the id space with name xname...
size_type ct(const std::string &xname) const
The number of members for the id space with name xname.
bool contains_glued_hub(const std::string &xname, pod_type xid) const
True if the space with name xname contains an id equivalent to xid in the glued hub id space...
SHEAF_DLL_SPEC bool is_valid(pod_index_type xpod_index)
True if an only if xpod_index is valid.
static factory< explicit_index_space_state > & id_space_factory()
A factory for making descendants of this class.
const index_space_handle & gathered_hub_id_space() const
A secondary id space that is a gathered version of the hub id space.
pod_type begin() const
Beginning space id of this interval in the id space family scope.
void enable_invariant_check() const
Enable invariant checking.
void delete_index(index_type xindex)
Removes all entires for index xindex.
virtual ~index_space_family()
Destructor.
virtual bool is_ancestor_of(const any *other) const
Conformance test; true if other conforms to this.
bool has_gluing() const
Ture if there is any gluing.
bool has_gluing() const
Ture if there is any gluing in the hub id space.
const index_space_handle & term_of(pod_type xid) const
The term containing id xid.
pod_type reserve_next_explicit_id()
Reserve the next available id for an explicit index space.
const hub_index_space_handle & hub_id_space() const
The hub id space of this family.
bool contains_hub(const std::string &xname, pod_type xid) const
True if the space with name xname contains an id equivalent to xid in the unglued hub id space...
static const explicit_index_space_interval & new_space(index_space_family &xid_spaces, size_type xub)
Create a new interval of id spaces for explicit id spaces in the id space family xid_spaces with uppe...
void unglue(pod_type xid)
Unglues xid; makes xid its own representative.
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.