21 #include "SheafSystem/poset_powerset_state.h" 22 #include "SheafSystem/assert_contract.h" 23 #include "SheafSystem/index_space_iterator.h" 24 #include "SheafSystem/hub_index_space_handle.h" 25 #include "SheafSystem/std_sstream.h" 26 #include "SheafSystem/std_iomanip.h" 42 require(xsubposet_member_index_ub >= 0);
48 disable_invariant_check();
52 _subposet_index_ub.put(hub_id_space(), 0);
56 _subposet_member_index_ub = xsubposet_member_index_ub;
60 _subposets.reserve(xcapacity);
67 ensure(subposet_index_ub().is_hub_scope());
68 ensure(subposet_member_index_ub() == xsubposet_member_index_ub);
76 _coarsest_common_refinement.detach_from_state();
77 _coarsest_common_refinement_jims.detach_from_state();
78 _whole.detach_from_state();
79 _jims.detach_from_state();
80 _table_dof_subposet.detach_from_state();
81 _row_dof_subposet.detach_from_state();
88 delete _subposets[litr.
pod()];
92 hub_id_space().release_iterator(litr);
112 require(contains_subposet(xindex));
131 require(contains_subposet(xindex));
150 require(contains_subposet(xindex));
169 require(contains_subposet(xindex));
190 define_old_variable(
scoped_index old_subposet_index_ub = subposet_index_ub());
191 define_old_variable(
size_type old_subposet_ct = subposet_ct());
206 _subposets[result]->initialize(_subposet_member_index_ub.pod(),
207 hub_id(result), xinitialize);
211 _subposet_index_ub = hub_id_space().end();
216 ensure(subposet_index_ub() > old_subposet_index_ub);
217 ensure(subposet_ct() == old_subposet_ct + 1);
218 ensure(hub_id_space().contains(result));
219 ensure(contains_subposet(result));
220 ensure(member(result).is_persistent());
236 define_old_variable(
scoped_index old_subposet_index_ub = subposet_index_ub());
237 define_old_variable(
size_type old_subposet_ct = subposet_ct());
239 result.
put(hub_id_space(), new_subposet(xinitialize));
244 ensure(subposet_index_ub() > old_subposet_index_ub);
245 ensure(subposet_ct() == old_subposet_ct + 1);
248 ensure(contains_subposet(result));
249 ensure(member(result).is_persistent());
264 define_old_variable(
scoped_index old_subposet_index_ub = subposet_index_ub());
265 define_old_variable(
size_type old_subposet_ct = subposet_ct());
280 _subposets[result]->initialize(_subposet_member_index_ub.pod(),
281 hub_id(result), xmembers);
285 _subposet_index_ub = hub_id_space().end();
290 ensure(subposet_index_ub() > old_subposet_index_ub);
291 ensure(subposet_ct() == old_subposet_ct + 1);
292 ensure(hub_id_space().contains(result));
293 ensure(contains_subposet(result));
294 ensure(member(result).is_persistent());
309 define_old_variable(
scoped_index old_subposet_index_ub = subposet_index_ub());
310 define_old_variable(
size_type old_subposet_ct = subposet_ct());
320 result.
put(hub_id_space(), _id_spaces.new_id());
325 _subposets[result.
pod()]->initialize(_subposet_member_index_ub.pod(),
330 _subposet_index_ub = hub_id_space().end();
335 ensure(subposet_index_ub() > old_subposet_index_ub);
336 ensure(subposet_ct() == old_subposet_ct + 1);
339 ensure(contains_subposet(result));
340 ensure(member(result).is_persistent());
353 require(contains_subposet(xindex));
359 delete _subposets[xindex];
363 _subposets[xindex] = 0;
367 _id_spaces.delete_id(xindex);
371 _subposet_index_ub = !hub_id_space().is_empty() ? hub_id_space().end() : 0;
375 ensure(!contains_subposet(xindex));
388 require(contains_subposet(xindex));
392 delete_subposet(xindex.
hub_pod());
396 ensure(!contains_subposet(xindex));
407 return _subposet_index_ub;
414 return hub_id_space().ct();
429 ensure(hub_id_space().allocated_iterator(result));
442 require(hub_id_space().allocated_iterator(xitr));
446 hub_id_space().release_iterator(xitr);
463 bool result = hub_id_space().contains(xindex);
476 return contains_subposet(xindex.
hub_pod());
537 ensure(result.
pod() == xid);
559 return _subposet_name_map;
566 return _subposet_name_map;
584 return _subposet_member_index_ub;
593 require(xub.
same_scope(subposet_member_index_ub()));
597 if(_subposet_member_index_ub < xub)
599 _subposet_member_index_ub = xub.
pod();
604 _subposets[itr.
pod()]->members()->extend_to(_subposet_member_index_ub.pod());
607 hub_id_space().release_iterator(itr);
612 ensure(subposet_member_index_ub() >= xub);
623 require(contains_subposet(xindex));
627 bool result = _subposets[xindex]->is_dof_subposet();
642 require(contains_subposet(xindex));
646 bool result = _subposets[xindex.
hub_pod()]->is_dof_subposet();
668 _subposets[itr.
pod()]->members()->put(xindex,
false);
672 hub_id_space().release_iterator(itr);
685 delete_poset_member(xindex.
hub_pod());
695 require(contains_subposet(xsubposet_index));
700 (*_subposets[xsubposet_index]->members())[xmbr_index];
716 require(contains_subposet(xsubposet_index));
721 (*_subposets[xsubposet_index.
hub_pod()]->members())[xmbr_index.
hub_pod()];
745 return _coarsest_common_refinement;
752 return _coarsest_common_refinement;
759 return _coarsest_common_refinement_jims;
766 return _coarsest_common_refinement_jims;
787 return _table_dof_subposet;
794 return _table_dof_subposet;
801 return _row_dof_subposet;
808 return _row_dof_subposet;
815 return _standard_subposet_ct;
826 _standard_subposet_ct = xct;
830 ensure(standard_subposet_ct() == xct);
900 if(invariant_check())
904 disable_invariant_check();
906 invariance(subposet_member_index_ub().is_hub_scope());
907 invariance(subposet_member_index_ub() >= 0);
913 enable_invariant_check();
942 <<
"ROW GRAPH SUBPOSETS" << endl
943 <<
"-------------------" << endl
946 os <<
"Subposets" << endl
947 <<
"---------" << endl
964 while(lname_itr != lname_list.end())
967 lmax_name_len = (lname_len > lmax_name_len) ? lname_len : lmax_name_len;
974 const int ID_WIDTH = 8;
975 int lname_width = lmax_name_len + 2;
987 os <<
"index: " << setw(ID_WIDTH) << right << lstr.str();
996 if(lname_itr != lname_list.end())
998 lfirst_name = *lname_itr;
1002 os <<
" " << setw(lname_width) << left << lfirst_name << right
1003 <<
" " << *p._subposets[itr.
pod()]
1006 while(lname_itr != lname_list.end())
1008 os << setw(7 + ID_WIDTH) <<
" " 1009 <<
" " << setw(lname_width) << left << *lname_itr << right
1022 <<
"Subposet Id Space Family" << endl
1023 <<
"----------------------" << endl
1047 result = xinclude_shallow ?
sizeof(xp) : 0;
1051 result += deep_size(xp._id_spaces,
false);
1055 result += deep_size(xp._subposets,
false);
1062 result += deep_size(xp._subposet_name_map,
false);
1072 result += deep_size(xp._coarsest_common_refinement,
false);
1073 result += deep_size(xp._coarsest_common_refinement_jims,
false);
1074 result += deep_size(xp._whole,
false);
1075 result += deep_size(xp._jims,
false);
1084 ensure(result >= 0);
A client handle for a subposet.
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.
subposet & whole()
The members of the current version of this poset.
name_list_type::const_iterator const_name_iterator
The const iterator type for names.
pod_type pod() const
The current id in the iteration.
void delete_subposet(pod_index_type xindex)
Deallocate the subposet with index xindex.
The data structure representing the state of a subposet.
const name_list_type & all_names(index_type xindex) const
All names associated with index xindex.
bool contains_subposet(pod_index_type xindex) const
True if and only if there exists a subposet with index xindex.
std::list< std::string > name_list_type
The type of name list for this map.
A partial multi-valued relation with total injective inverse between names and indices of type index_...
subposet & coarsest_common_refinement_jims()
The jims of the coarsest_common_refinement (mutable version).
subposet & table_dof_subposet()
The table dof subposet when this poset is used as a schema (mutable version).
pod_index_type new_subposet(bool xinitializ)
Allocate a new subposet. If xinitialize, make the subposet empty,.
virtual void next()=0
Makes id() the next id in the iteration.
virtual bool is_ancestor_of(const any *other) const
True if other conforms to current.
An implementation of class sum_index_space_handle that has a primary sum id space state...
const hub_index_space_handle & hub_id_space() const
The hub id space.
poset_powerset_state(size_type xcapacity, const scoped_index &xsubposet_member_index_ub)
Creates an instance with initial space for xcapacity subposets each of which has an index upper bound...
bool same_scope(const scoped_index &xother) const
True if and only if this is in the same id space as xother.
subposet & row_dof_subposet()
The row dof subposet when this poset is used as a schema (mutable version).
virtual void reset()=0
Restarts the iteration.
bool is_hub_scope() const
True if and only if the id space of this is the hub id space.
subposet & jims()
The jims of the current version of this poset.
Abstract base class with useful features for all objects.
void release_subposet_id_space_iterator(index_space_iterator &xitr) const
Returns the id space iterator xitr to the subposet iterator pool.
bool is_done() const
True if iteration is finished.
~poset_powerset_state()
Destructor.
virtual poset_powerset_state * clone() const
Make a new instance of the same type as this.
index_space_iterator & get_subposet_id_space_iterator() const
Allocates an id space iterator over the subposet ids from the iterator pool.
An index within the external ("client") scope of a given id space.
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.
void delete_poset_member(pod_index_type xindex)
Removes the poset member with index xindex from all subposets.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
bool is_dof_subposet(pod_index_type xindex) const
True, if the subposet with index xindex is a dofs subposet.
void put(const index_space_handle &xid_space, pod_type xpod)
Set the scope to id space, xid_space and pod() to xpod.
const scoped_index & hub_id() const
A id in the hub id space; intended for copying to initialize ids to the hub id space.
const index_space_family & id_spaces() const
Collection of id spaces for this poset powerset.
size_type subposet_ct() const
The number of subposets.
void put_subposet_member_index_ub(const scoped_index &xub)
Sets the upper bound of member index in each subposet to xub.
void put_standard_subposet_ct(int xct)
Put the number of standard subposets automatically allocated by the poset handle constructor.
const scoped_index & subposet_index_ub() const
The upper bound on the subposet index.
int_type pod_index_type
The plain old data index type.
int standard_subposet_ct() const
The number of standard subposets automatically allocated by the poset handle constructor.
SHEAF_DLL_SPEC std::ostream & operator<<(std::ostream &os, const dof_descriptor_array &p)
Insert dof_descriptor_array& p into ostream& os.
bool invariant() const
Class invariant.
subposet_name_map_type & subposet_name_map()
Bi-directional map between subposet names and indices.
subposet_state & member(pod_index_type xindex)
The subposet with index xindex (mutable version).
Factory and container for a family of id spaces.
const hub_index_space_handle & hub_id_space() const
Hub id space for this poset powerset.
bool subposet_contains_member(pod_index_type xsubposet_index, pod_index_type xmbr_index) const
True if and only if the subposet with index xsubposet_index contains the member with index xmbr_index...
subposet & coarsest_common_refinement()
The coarsest common refinement of all versions of this poset (mutable version).
The set of subsets of a poset.
const scoped_index & subposet_member_index_ub() const
Upper bound of member index in each subposet.
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.