21 #include "SheafSystem/subposet_state.h" 22 #include "SheafSystem/assert_contract.h" 23 #include "SheafSystem/std_iomanip.h" 24 #include "SheafSystem/zn_to_bool.h" 43 _is_dof_subposet =
false;
47 _is_persistent =
true;
51 ensure(!has_id_space());
52 ensure(is_persistent());
53 ensure(is_terminated());
67 ensure(is_terminated());
79 require(xmember_ub >= 0);
81 require(unexecutable(
"for all i in xmembers: 0 <= i < xmember_ub"));
91 _members->make_false_sa();
104 ensure(is_initialized());
105 ensure(_members->ub() >= xmember_ub);
106 ensure(_index == xindex);
107 ensure(is_persistent());
123 require(xmember_ub >= 0);
125 require(unexecutable(
"for all i in xmembers: 0 <= i < xmember_ub"));
135 for(
int i=0; i<xmembers.
ct(); ++i)
137 _members->put(xmembers[i],
true);
145 ensure(is_initialized());
146 ensure(_members->ub() >= xmember_ub);
147 ensure(_index == xindex);
148 ensure(is_persistent());
164 require(xmember_ub >= 0);
166 require(unexecutable(
"for all i in xmembers: 0 <= i < xmember_ub"));
176 for(
int i=0; i<xmembers.
ct(); ++i)
178 _members->put(xmembers[i].hub_pod(),
true);
186 ensure(is_initialized());
187 ensure(_members->ub() >= xmember_ub);
188 ensure(_index == xindex);
189 ensure(is_persistent());
206 result = result && _members != 0;
207 result = result && _index.is_valid();
211 ensure(_members != 0);
212 ensure(_index.is_valid());
234 _is_dof_subposet =
false;
237 if(_dof_descriptors != 0)
239 _dof_descriptors->remove_reference();
240 _dof_descriptors = 0;
245 _id_space->release_id_space();
251 ensure(is_terminated());
268 result = result && (_members == 0);
269 result = result && (!_index.is_valid());
270 result = result && (_is_dof_subposet ==
false);
271 result = result && (_dof_ct == 0);
272 result = result && (_dof_descriptors == 0);
273 result = result && (_id_space == 0);
277 ensure(result ? members() == 0 :
true);
278 ensure(result ? !index().
is_valid() :
true);
279 ensure(result ? !is_dof_subposet() :
true);
280 ensure(result ? dof_ct() == 0 :
true);
281 ensure(result ? dof_descriptors() == 0 :
true);
282 ensure(result ? !has_id_space() :
true);
334 ensure(members() == xmembers);
352 return _is_dof_subposet;
363 _is_dof_subposet = xis_dof_subposet;
367 ensure(is_dof_subposet() == xis_dof_subposet);
393 ensure(dof_ct() == xdof_ct);
406 require(dof_descriptors() != 0);
410 return (*_dof_descriptors)[_dof_ct].offset;
417 return _dof_descriptors;
433 ensure(dof_descriptors() == xdof_descriptors);
444 return (_id_space != 0);
453 require(has_id_space());
466 require(has_id_space());
489 _id_space->release_id_space();
496 ensure(&id_space().id_spaces() == &xid_spaces);
497 ensure(id_space().index() == xid);
510 require(xid_spaces.
contains(xname));
520 _id_space->release_id_space();
527 ensure(&id_space().id_spaces() == &xid_spaces);
528 ensure(id_space().name() == xname);
539 return _is_persistent;
550 _is_persistent = xvalue;
554 _id_space->put_is_persistent(xvalue);
559 ensure(is_persistent() == xvalue);
560 ensure(!has_id_space() || id_space().is_persistent() == xvalue);
580 (*(s.
members()))[i] ? os <<
'1' : os <<
'0';
585 <<
" dof_ct: " << s.
dof_ct();
591 for(
int i=0; i<s.
dof_ct(); i++)
613 result = xinclude_shallow ?
sizeof(xp) : 0;
620 if(lxp.members() != 0)
622 result += deep_size(*(lxp.members()),
true);
628 if(lxp.dof_descriptors() != 0)
630 result += deep_size(*(lxp.dof_descriptors()),
true);
633 #ifdef DIAGNOSTIC_OUTPUT 634 cout <<
"$$$ deep_size(const subposet_state& xp) result = " << result << endl;
size_type dof_ct() const
Get the number of dofs Only defined if this is a dofs subposet, in which case _dof_ct == _members...
bool is_dof_subposet() const
True, if this is a dofs subposet.
bool is_valid() const
True if this is a valid id.
zn_to_bool * members() const
Get the members of the subposet.
void put_dof_descriptors(const dof_descriptor_array *xdof_descriptors)
Put the offset of each dof when the dofs are contiguously allocated. Only defined if this is a dofs...
const scattered_insertion_index_space_handle & id_space() const
The id space for this subposet state (const version).
size_type ct() const
The number of items currently in use.
void put_next(const scoped_index &xnext)
Put the next member in free list.
size_type dof_tuple_ub()
Get the upper bound of the dof tuple Only defined if this is a dofs subposet.
The data structure representing the state of a subposet.
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.
int ub() const
The upper bound for the domain index.
dof_descriptor_array * dof_descriptors() const
Get the offset of each dof when the dofs are contiguously allocated. Only defined if this is a dofs...
void put_is_dof_subposet(bool xis_dof_subposet)
True, if this is a dofs subposet.
subposet_state()
Default constructor.
void put_members(const zn_to_bool *xmembers)
Put members of the subposet.
bool handle_conforms_to_state(const std::string &xname) const
True if handle of type T conforms to the state with name xname.
A map from Zn (the integers mod n) to bools. A characteristic function used to represent subsets of Z...
bool is_initialized() const
True, if this is initialized.
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.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
void put_id_space(const index_space_family &xid_spaces, pod_index_type xid)
Put the id space for this subposet state.
void put_is_persistent(bool xvalue)
Sets is_persistent() to xvalue.
An array for storing structs which describe the size, alignment, and offset of dofs within a dof tupl...
void put_dof_ct(size_type xdof_ct)
Put the number of dofs Only defined if this is a dofs subposet, in which case _dof_ct == _members...
const scoped_index & next() const
Get the next member in free list.
bool has_id_space() const
True if this has an id space.
int_type pod_index_type
The plain old data index type.
void add_reference()
Add a reference to this.
SHEAF_DLL_SPEC std::ostream & operator<<(std::ostream &os, const dof_descriptor_array &p)
Insert dof_descriptor_array& p into ostream& os.
A handle for a scattered_insertion_index_space_state.
~subposet_state()
Destructor.
bool contains(pod_type xid) const
True, if this contains an id space with id xid.
Factory and container for a family of id spaces.
bool is_terminated() const
True, if this is teminated.
void initialize(int xmember_ub, const scoped_index &xindex, bool xinitialize)
Initialize data members.
void terminate()
Set all data members to NULL.
bool is_persistent() const
True if this id space should be written to disk.
SHEAF_DLL_SPEC bool is_valid(pod_index_type xpod_index)
True if an only if xpod_index is valid.
const scoped_index & index() const
Get index of the subposet.