21 #include "SheafSystem/base_space_member.h" 23 #include "SheafSystem/assert_contract.h" 24 #include "SheafSystem/arg_list.h" 25 #include "SheafSystem/base_space_poset.h" 26 #include "SheafSystem/fiber_bundles_namespace.h" 27 #include "SheafSystem/poset_path.h" 28 #include "SheafSystem/preorder_iterator.h" 29 #include "SheafSystem/tern.h" 30 #include "SheafSystem/wsv_block.h" 51 static const poset_path result(
"base_space_schema",
"base_space_member_schema");
69 const poset_path& result = standard_schema_path();
90 string ldof_specs =
"max_db INT true";
91 ldof_specs +=
" db INT false";
92 ldof_specs +=
" type_id INT false";
93 ldof_specs +=
" type_name C_STRING false";
94 ldof_specs +=
" refinement_depth INT false";
95 ldof_specs +=
" local_cell_type_id INT false";
96 ldof_specs +=
" local_cell_type_name C_STRING false";
97 ldof_specs +=
" size SIZE_TYPE false";
98 ldof_specs +=
" i_size SIZE_TYPE false";
99 ldof_specs +=
" j_size SIZE_TYPE false";
100 ldof_specs +=
" k_size SIZE_TYPE false";
104 standard_schema_path().member_name(),
105 poset_path(standard_schema_path().poset_name(),
"bottom"),
130 static const string result =
"base_space_member_prototypes";
134 ensure(!result.empty());
151 require(!xhost_path.
empty());
154 require(xschema_path.
full());
156 require(schema_poset_member::conforms_to(xns, xschema_path, standard_schema_path(), xauto_access));
158 require(xmax_db >= 0);
163 host_type::new_table(xns, xhost_path, xschema_path, xmax_db, xauto_access);
167 ensure(xns.
owns(result, xauto_access));
168 ensure(result.
path(
true) == xhost_path);
170 ensure(result.
schema(
true).
path(xauto_access) == xschema_path);
172 ensure(result.
max_db() == xmax_db);
190 require(poset_path::is_valid_name(xhost_path.
poset_name()));
195 require(xmax_db >= 0);
206 result_ptr = &new_host(xns, xhost_path, standard_schema_path(), xmax_db, xauto_access);
213 ensure(xns.
owns(result, xauto_access));
214 ensure(result.
path(
true) == xhost_path);
216 ensure(result.
schema(
true).
path(xauto_access) == standard_schema_path());
218 ensure(result.
max_db() == xmax_db);
248 ensure(! is_attached() );
266 new_jem_state(const_cast<abstract_poset_member*>(&xother),
true, xauto_access);
270 attach_to_state(&xother);
303 require(precondition_of(new_jim_state(same args)));
307 new_jim_state(xhost, xdof_map, xcopy_dof_map, xauto_access);
311 ensure(postcondition_of(new_jim_state(same args)));
321 const std::string& xprototype_name,
330 require(!xprototype_name.empty());
343 attach_to_state(xhost, lid);
361 const std::string& xtype_name,
363 const std::string& xlocal_cell_name,
369 require(!xtype_name.empty());
371 require(xlocal_cell_name.empty() || xhost->
contains_member(xlocal_cell_name));
377 disable_invariant_check();
393 attach_to_state(xhost, lid);
398 enable_invariant_check();
403 ensure(host() == xhost);
404 ensure(name() == xtype_name);
406 ensure(type_name() == xtype_name);
407 ensure(refinement_depth() == 0);
408 ensure(local_cell_type_name() == xlocal_cell_name);
425 const tern& xnew_jem,
431 require(precondition_of(new_jrm_state(same args)));
435 new_jrm_state(xhost, xexpansion, xexpansion_ct, xnew_jem, xauto_access);
439 ensure(postcondition_of(new_jrm_state(same args)));
454 require(precondition_of(attach_to_state(xhost, xhub_id)));
458 attach_to_state(xhost, xhub_id);
462 ensure(postcondition_of(attach_to_state(xhost, xhub_id)));
471 require(precondition_of(attach_to_state(xhost, xid)));
475 attach_to_state(xhost, xid.
hub_pod());
479 ensure(postcondition_of(attach_to_state(xhost, xid)));
488 require(precondition_of(attach_to_state(same args)));
492 attach_to_state(xhost, xname);
496 ensure(postcondition_of(attach_to_state(same args)));
507 require(precondition_of(attach_to_state(same args)));
511 attach_to_state(xnamespace, xpath, xauto_access);
515 ensure(postcondition_of(attach_to_state(same args)));
532 require(precondition_of(attach_to_state(same args)));
536 attach_to_state(xnamespace, xposet_id, xmember_id);
540 ensure(postcondition_of(attach_to_state(same args)));
557 require(precondition_of(attach_to_state(same args)));
561 attach_to_state(xnamespace,
567 ensure(postcondition_of(attach_to_state(same args)));
584 require(state_is_read_accessible());
590 poset_path result(prototypes_poset_name(), type_name());
615 lproto.get_read_access();
619 lproto.release_access();
620 lproto.detach_from_state();
640 poset_path lproto_path(prototypes_poset_name(), xname);
661 require(xrequire_write_access ?
662 state_is_read_write_accessible() : state_is_read_accessible());
663 require(is_jim(
false));
687 require(!xprototype_name.empty());
699 result->put_defaults();
703 poset_path lproto_path(prototypes_poset_name(), xprototype_name);
711 ltuple.
db = lproto.db();
712 ltuple.type_id = lproto.type_id();
713 ltuple.type_name = strdup(lproto.type_name());
714 ltuple.refinement_depth = lproto.refinement_depth();
716 lproto.detach_from_state();
735 require(!xprototype_name.empty());
748 define_old_variable(
int old_xhost_row_dof_tuple_ct = xhost.
row_dof_tuple_ct());
758 poset_path lproto_path(prototypes_poset_name(), xprototype_name);
763 ltuple->
db = lproto.db();
764 ltuple->
type_id = lproto.type_id();
765 ltuple->
type_name = strdup(lproto.type_name());
770 lproto.detach_from_state();
806 require(state_is_read_accessible());
825 host()->member_dof_tuple_id(itr.
index().
hub_pod(),
false);
833 result = lmbr_dim > result ? lmbr_dim : result;
843 ensure(result >= -1);
844 ensure( (result == -1) == is_jem(&(host()->bottom())) );
857 require(state_is_read_accessible());
858 require(is_jim(
false));
879 require(state_is_read_accessible());
880 require(is_jim(
false));
901 require(state_is_read_accessible());
902 require(is_jim(
false));
922 require(state_is_read_write_accessible());
923 require(is_jim(
false));
927 row_dof_tuple()->refinement_depth = xdepth;
931 ensure(refinement_depth() == xdepth);
946 require(state_is_read_accessible());
970 require(state_is_read_accessible());
1003 require(xauto_access || state_is_read_accessible());
1017 int lmax_db = lhost->
max_db();
1023 while(!litr.is_done())
1025 int lmbr_db = lhost->
db(litr.index());
1027 litr.next(lmbr_db == 0);
1034 ensure(unexecutable(xresult.
ct() == host()->max_db()));
1049 require(is_attached());
1050 require(xauto_access || state_is_read_write_accessible());
1056 get_read_write_access();
1060 c_not_pa(*result,
false);
1069 ensure(result != 0);
1070 ensure(postcondition_of(c_not_pa(result,
false)));
1083 require(is_attached());
1084 require(xauto_access || state_is_read_write_accessible());
1088 get_read_write_access();
1091 require(host()->includes_subposet(
"__elements"));
1098 subposet lall_zones(host(),
"__elements");
1099 subposet lother_zones(lall_zones,
true);
1137 ensure(unexecutable(this->join(&result)->is_same_state(&host()->top())));
1152 require(state_is_auto_read_write_accessible(xauto_access));
1153 require(in_same_space(&xother));
1159 get_read_write_access();
1163 c_minus(xother, *result, xnew_jem,
false);
1172 ensure(result != 0);
1173 ensure(postcondition_of(c_not_pa(xother, result,
false)));
1189 require(state_is_auto_read_write_accessible(xauto_access));
1190 require(in_same_space(&xother));
1194 get_read_write_access();
1197 require(host()->includes_subposet(
"__elements", xauto_access));
1239 ensure(unexecutable(this->join(&result)->is_same_state(&host()->top())));
1285 require(xrequire_write_access ?
1286 state_is_read_write_accessible() :
1287 state_is_read_accessible());
1288 require(is_jim(
false));
1297 ensure(is_basic_query);
1310 require(xrequire_write_access ?
1311 state_is_read_write_accessible() :
1312 state_is_read_accessible());
1313 require(is_jim(
false));
1322 ensure(is_basic_query);
1337 require(xdof_map != 0);
1373 result =
reinterpret_cast<poset*
>(total_poset_member::host());
1390 require(xother != 0);
1394 result =
dynamic_cast<const poset*
>(xother) != 0;
1424 invariance(total_poset_member::invariant());
1426 if(invariant_check())
1430 disable_invariant_check();
1441 enable_invariant_check();
1485 ensure(result != 0);
1502 attach_to_state(&xother);
1506 ensure(is_same_state(&xother));
1521 attach_to_state(&xother);
1525 ensure(is_same_state(&xother));
virtual void get_read_write_access(bool xrelease_read_only_access=false)
Get read write access to the state associated with this. If release_read_only_access is requested...
Index for identifying a poset member relative to a given name space.
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 ...
A client handle for a subposet.
virtual base_space_member & operator=(const abstract_poset_member &xother)
Assignment operator; attaches this to the same state as xother.
void truncate()
Makes this the next member of the subset which is not less than old this, i.e. the depth-first descen...
bool path_is_auto_read_write_available(const poset_path &xpath, bool xauto_access) const
True if the state referred to xpath does not exist or exists and is auto read-write accessible...
bool full() const
True if both poset name and member name are not empty.
size_type ct() const
The number of items currently in use.
int db() const
The base space dimension.
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.
int local_cell_type_id
The local cell type id.
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...
void d_cells_ct(block< size_type > &xresult, bool xauto_access) const
The number of cells (jims) of each dimension in the down set of this.
void l_join_pa(abstract_poset_member *result, bool xnew_jem=true)
Lattice join of the members of this, pre-allocated The lattice join is the least upper bound in the...
const char * local_cell_type_name
The local cell type name.
void put_visit_once(bool xvisit_once)
Set visit_once() to xvisit_once.
virtual ~base_space_member()
Destructor; deletes a poset member and its attached state, if any.
void c_not_pa(base_space_member &result, bool xauto_access)
The cellular space psuedo-complement of this, pre-allocated.
bool contains_poset_member(pod_index_type xposet_hub_id, pod_index_type xmember_hub_id, bool xauto_access=true) const
True if this contains a poset with hub id xposet_hub_id which contains a member with hub id xmember_h...
bool state_is_auto_read_accessible(bool xauto_access) const
True if the state is auto accessible for read, that is, if the state is already accessible for read o...
A client handle for a general, abstract partially order set.
A three state "bool". Does not provide the operations of ternary logic and is intended for use mostly...
scoped_index poset_id
The index of the poset relative to the namespace.
base_space_member * c_not(bool xauto_access)
The cellular space psuedo-complement of this, auto-allocated. The cellular space psuedo-complement is...
virtual void * dof_tuple()=0
The dof tuple (mutable version).
A path defined by a poset name and a member name separated by a forward slash ('/'). For example: "cell_definitions/triangle".
void reserve(index_type xub)
Makes ub() at least xub; if new storage is allocated, it is uninitialized.
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.
const scoped_index & index() const
The index of the component state this handle is attached to.
const pod_index_type & type_id() const
The cell type id of this. The id of the prototype of this in the "cell_types" id space of the prototy...
The general, abstract map from dof ids to dof values.
static const std::string & prototypes_poset_name()
The name of the prototypes poset.
int db
The base space dimension.
base_space_member * c_minus(base_space_member &xother, bool xnew_jem, bool xauto_access)
The cellular space difference of this and xother, auto-allocated. The cellular space difference is de...
A client handle for a member of a base space poset.
pod_index_type local_cell_type_id() const
The local cell type id.
Abstract base class with useful features for all objects.
virtual array_poset_dof_map & dof_map(bool xrequire_write_access=false)
The map from client_ids to dof values for this poset member (mutable version)
scoped_index member_id
The index of the member relative to the poset.
The lattice of closed cells of a cellular space; a lattice representation of a computational mesh...
virtual const poset_path & schema_path() const
The path of the schema required by this.
const bool NOT_STRICT
Iteration strictness control.
const bool DOWN
Iteration directions.
virtual schema_poset_member & schema()
The schema for this poset (mutable version).
void assign(const_reference_type xitem)
Sets the values of all items to xitem.
A client handle for a mutable partially ordered set.
bool state_is_read_write_accessible() const
True if this is attached and if the state is accessible for read and write or access control is disab...
virtual const scoped_index & new_row_dof_map()
Creates a new row dof map.
virtual bool dof_map_is_ancestor_of(const poset_dof_map *xdof_map) const
True if xdof_map conforms to (is derived from) the type of dof map required by this handle...
poset * host() const
The poset which this is a handle to a member of.
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)
static bool prototype_exists(const std::string &xname, bool xauto_access)
True if base space member prototypes poset in the current name space contains a member with name xnam...
virtual void detach_from_state()
Detach this handle from its state, if any.
void set_ct(size_type xct)
Sets ct() == xct.
An index within the external ("client") scope of a given id space.
virtual bool is_attached() const
True if this handle is attached to a non-void state.
virtual void get_read_access() const
Get read access to the state associated with this.
std::string poset_name() const
The poset name part of the path.
virtual void insert_member(pod_index_type xmbr_hub_id)
Inserts the member of host() with hub id xmbr_hub_id.
static array_poset_dof_map * new_row_dof_map(const poset *xhost, const std::string &xprototype_name)
bool contains_path(const poset_path &xpath, bool xauto_access=true) const
True if this contains the poset or poset member specified by xpath.
size_type row_dof_tuple_ct() const
The number of row_dof_tuples of this poset.
bool is_empty() const
True if this poset is empty.
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. ...
int db(pod_index_type xmbr_hub_id) const
The base space dimension of the member with hub id xmbr_hub_id.
bool empty() const
True if both poset name and member name are empty.
virtual void release_access(bool xall=false) const
Release access. If xall is true, release all levels of access. Otherwise, release one level of access...
pod_index_type new_member(const std::string &xprototype_name, bool xcopy_dof_map)
Creates a disconnected jim using the prototype with name xprototype_name. If xcopy_dof_map or if xhos...
const char * type_name() const
The cell type name.
const char * local_cell_type_name() const
The local cell type name.
bool contains_poset(pod_index_type xhub_id, bool xauto_access=true) const
True if this contains a poset with hub id xhub_id..
bool is_done() const
True if iteration finished.
void put_refinement_depth(int xdepth)
Sets the refinement depth to xdepth.
static host_type & standard_host(namespace_type &xns, const poset_path &xhost_path, int xmax_db, bool xauto_access)
The host with path xhost_path. Returns the host if it already exists, otherwise, creates it in namesp...
static const poset_path & standard_schema_path()
The path of the schema required by this class.
virtual void detach_from_state()
Detach this handle from its state, if any.
virtual poset_dof_map & row_dof_map(pod_index_type xtuple_hub_id, bool xrequire_write_access=false) const
The map from row dof client_ids to row dof values for dof tuple hub id xtuple_hub_id.
namespace_poset * name_space() const
The namespace this poset resides in.
const char * type_name
The cell type name.
virtual bool is_attached() const
True if this is attached to a state.
bool member_exists(bool xauto_access) const
base_space_member()
Default constructor; creates a new, unattached base_space_member handle.
virtual void * dof_tuple()
The dof tuple (mutable version).
virtual void reset(bool xreset_markers=true)
Restarts the iteration over the down set of anchor().
poset_path prototype_path() const
The path of the prototype for this.
virtual bool invariant() const
Class invariant.
int refinement_depth
The refinement depth.
virtual void remove_member(pod_index_type xmbr_hub_id)
Removes the member of host() with hub id xmbr_hub_id.
int_type pod_index_type
The plain old data index type.
static void make_standard_schema(namespace_poset &xns)
Creates the standard schema for this class in namespace xns.
int type_id
The cell type id.
virtual subposet & jims()
The subset of all jims (mutable version)
virtual void end_jim_edit_mode(bool xensure_lattice_invariant=true, bool xauto_access=true)
Prevent editing of jims and jim order relation.
virtual void put_anchor(const abstract_poset_member *xanchor)
Set anchor() to xanchor.
void attach_to_state(const namespace_poset *xns, const poset_path &xpath, bool xauto_access=true)
Attach to the state specified by path xpath in the namespace xns.
static host_type & new_host(namespace_type &xns, const poset_path &xhost_path, const poset_path &xschema_path, int xmax_db, bool xauto_access)
Creates a new host poset for members of this type. The poset is created in namespace xns with path xh...
virtual void get_read_access() const
Get read access to the state associated with this.
int max_db() const
The maximum dimension of the members of this base space.
An abstract client handle for a member of a poset.
The type of row dof tuple for base_space_member.
bool in_jim_edit_mode() const
True if editing jims and jim order relation is allowed.
An array representation of abstract class poset_dof_map.
Namespace for the fiber_bundles component of the sheaf system.
virtual void delete_state(bool xauto_access=false)
Detach this from its state and delete the state.
virtual bool is_ancestor_of(const any *other) const
True if other conforms to this.
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...
int refinement_depth() const
The refinement depth.
A client handle for a poset member which has been prepared for use as a schema.
virtual bool host_is_ancestor_of(const poset_state_handle *other) const
True if other conforms to host.
virtual void release_access(bool xall=false) const
Release access. If xall is true, release all levels of access. Otherwise, release one level of access...
row_dof_tuple_type * row_dof_tuple(bool xrequire_write_access=false)
The row dof tuple for this.
virtual base_space_member * clone() const
Make a new handle, no state instance of current.
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.
const scoped_index & index() const
The index of the current member of the iteration.
virtual void begin_jim_edit_mode(bool xauto_access=true)
Allow editing of jims and jim order relation.