20 #include "SheafSystem/mesh_partition.h" 22 #include "SheafSystem/assert_contract.h" 23 #include "SheafSystem/base_space_member.h" 24 #include "SheafSystem/error_message.h" 25 #include "SheafSystem/hash_index_space_state.h" 26 #include "SheafSystem/id_block.h" 27 #include "SheafSystem/index_iterator.h" 28 #include "SheafSystem/preorder_iterator.h" 29 #include "SheafSystem/std_set.h" 30 #include "SheafSystem/std_sstream.h" 31 #include "SheafSystem/tern.h" 60 ensure(!name().empty());
62 ensure(part_ct() == 0);
99 _parts.detach_from_state();
116 require(is_valid_name(xname));
129 initialize_parts_set();
131 _part_ct = (old_xmesh_includes_mesh_partition_xname ? _parts.member_ct() : 0);
135 ensure(mesh().is_same_state(&xmesh));
136 ensure(name() == xname);
138 ensure(part_ct() == (old_xmesh_includes_mesh_partition_xname ? parts().member_ct() : 0));
189 stringstream lstream;
190 lstream << _name <<
"::part_" << xp_id;
197 return lstream.str();
208 require(mesh().state_is_read_accessible());
209 require(mesh().contains_member(part_name(xp_id)));
220 while(!litr.is_done())
244 require(mesh().state_is_read_write_accessible());
245 require(!mesh().contains_member(part_name(xp_id)));
248 require_for_all(i, 0, xzones.
ct(), mesh().contains_member(xzones[i]));
254 lpart.
put_name(part_name(xp_id),
true,
false);
256 _parts.insert_member(result);
258 _parts.id_space().insert(xp_id, result);
260 lpart.detach_from_state();
264 ensure(mesh().contains_member(result));
265 ensure(mesh().member_name(result) == part_name(xp_id));
266 ensure(parts().contains_member(result));
284 string::size_type lidx1;
286 lidx1 = xname.find(
"::part_") + 7;
287 string lpart_id_str(xname.substr(lidx1));
289 stringstream lstream(lpart_id_str);
316 result = (xname.find(name_prefix()) == 0);
388 ensure(is_same_type(result));
407 _name = xother._name;
408 _mesh = xother._mesh;
409 _parts = xother._parts;
410 _part_ct = xother._part_ct;
428 if(invariant_check())
432 disable_invariant_check();
440 invariance(part_ct() >= 0);
441 invariance(!name().empty());
445 enable_invariant_check();
461 fiber_bundle::mesh_partition::
462 initialize_parts_set()
466 require(mesh().includes_subposet(name()) ?
467 mesh().state_is_read_accessible() :
468 mesh().state_is_read_write_accessible());
472 if(mesh().includes_subposet(_name))
476 _parts.attach_to_state(_mesh, _name);
482 _parts.new_state(_mesh,
true,
false);
483 _parts.put_name(_name,
true,
false);
484 _parts.new_id_space(
"hash_index_space_state",
485 hash_index_space_state::make_arg_list(0));
491 ensure(mesh().includes_subposet(name()));
492 ensure(parts().has_id_space());
static bool is_valid_name(const std::string &xname)
True if xname is a valid decomposition name.
virtual bool invariant() const
Class invariant, intended to be redefined in each descendant. See below for template for invariant in...
A client handle for a subposet.
size_type ct() const
The number of items currently in use.
mesh_partition()
Default constructor.
void part(const scoped_index &xp_id, id_block &xresult) const
The zones in the part with client id xp_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...
virtual bool includes_subposet(pod_index_type xsubposet_hub_id, bool xauto_access=true) const
True if this poset includes subposet with hub id xsubposet_hub_id.
void reserve(index_type xub)
Makes ub() at least xub; if new storage is allocated, it is uninitialized.
const scoped_index & put_part(const scoped_index &xp_id, id_block &xzones)
Creates a part with client id xp_id containing zones xzones.
A decomposition of a mesh into non-overlapping scopes.
A client handle for a member of a base space poset.
virtual ~mesh_partition()
Destructor.
Abstract base class with useful features for all objects.
The lattice of closed cells of a cellular space; a lattice representation of a computational mesh...
const bool NOT_STRICT
Iteration strictness control.
const bool DOWN
Iteration directions.
void push_back(const_reference_type item)
Insert item at the end of the items in the auto_block.
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...
pointer_type base() const
The underlying storage array.
void set_ct(size_type xct)
Sets ct() == xct.
An index within the external ("client") scope of a given id space.
static std::string reserved_prefix()
Prefix for identifying member names reserved by the sheaf system.
virtual bool is_ancestor_of(const any *other) const
Conformance test; true if other conforms to this.
virtual void put_name(const std::string &xname, bool xunique, bool xauto_access)
Make xname a name for this; if xunique, make xname the only name.
mesh_partition & operator=(const mesh_partition &xother)
Assignment operator.
const std::string & name() const
The name of this mesh_partition.
static string name_prefix()
The prefix for valid mesh_partition names.
virtual void detach_from_state()
Detach this handle from its state, if any.
string part_name(const scoped_index &xp_id) const
The name for the part associated with client id xp_id.
const subposet & parts() const
The set of processor read scope members.
bool is_member_hub_id_space() const
True if space() == host().member_hub_id_space().
int_type pod_index_type
The plain old data index type.
virtual mesh_partition * clone() const
Virtual constructor, makes a new instance of the same type as this.
subposet & elements()
The subposet containing the elements or zones, that is, the cells of maximal dimension.
pod_index_type part_id(const std::string &xname) const
Extracts the part id from part name xname.
int part_ct() const
The number of parts in this mesh_partition.
const base_space_poset & mesh() const
The mesh poset containing this mesh_partition.
Namespace for the fiber_bundles component of the sheaf system.
A block of ids all in the same id space.
virtual bool invariant() const
Class invariant.