21 #include "SheafSystem/structured_block_3d.h" 23 #include "SheafSystem/assert_contract.h" 24 #include "SheafSystem/arg_list.h" 26 #include "SheafSystem/chart_point_3d.h" 27 #include "SheafSystem/fiber_bundles_namespace.h" 28 #include "SheafSystem/namespace_poset.h" 29 #include "SheafSystem/poset_path.h" 30 #include "SheafSystem/preorder_iterator.h" 31 #include "SheafSystem/tern.h" 32 #include "SheafSystem/wsv_block.h" 54 const poset_path& result = STATIC_PROTOTYPE_PATH;
59 ensure(result.
member_name() ==
"structured_block_3d");
76 require(!xhost_path.
empty());
79 require(xschema_path.
full());
86 host_type::new_table(xns, xhost_path, xschema_path, 3, xauto_access);
90 ensure(xns.
owns(result, xauto_access));
91 ensure(result.
path(
true) == xhost_path);
93 ensure(result.
schema(
true).
path(xauto_access) == xschema_path);
95 ensure(result.
max_db() == 3);
127 result_ptr = &new_host(xns, xhost_path, standard_schema_path(), xauto_access);
134 ensure(xns.
owns(result, xauto_access));
135 ensure(result.
path(
true) == xhost_path);
137 ensure(result.
schema(
true).
path(xauto_access) == standard_schema_path());
139 ensure(result.
max_db() == 3);
168 ensure(! is_attached() );
182 new_jem_state(const_cast<abstract_poset_member*>(&xother),
true,
true);
186 attach_to_state(const_cast<abstract_poset_member*>(&xother));
192 ensure(is_attached() == const_cast<abstract_poset_member&>(xother).is_attached() );
219 require(precondition_of(new_state(same args)));
223 new_state(xhost, xi_size, xj_size, xk_size, xauto_access);
227 ensure(postcondition_of(new_state(same args)));
241 require(precondition_of(attach_to_state(xhost, xhub_id)));
245 attach_to_state(xhost, xhub_id);
249 ensure(postcondition_of(attach_to_state(xhost, xhub_id)));
257 require(precondition_of(attach_to_state(xhost, xid)));
261 attach_to_state(xhost, xid.
hub_pod());
265 ensure(postcondition_of(attach_to_state(xhost, xid)));
273 require(precondition_of(attach_to_state(same args)));
277 attach_to_state(xhost, xname);
281 ensure(postcondition_of(attach_to_state(same args)));
293 require(precondition_of(attach_to_state(same args)));
297 attach_to_state(xnamespace, xpath, xauto_access);
301 ensure(postcondition_of(attach_to_state(same args)));
317 require(precondition_of(attach_to_state(same args)));
321 attach_to_state(xnamespace, xposet_id, xmember_id);
325 ensure(postcondition_of(attach_to_state(same args)));
341 require(precondition_of(attach_to_state(same args)));
345 attach_to_state(xnamespace, xposet_id.
hub_pod(), xmember_id.
hub_pod());
349 ensure(postcondition_of(attach_to_state(same args)));
367 require(precondition_of(new_state(host(), xi_size, xj_size, xk_size, xauto_access)));
371 new_state(host(), xi_size, xj_size, xk_size, xauto_access);
375 ensure(postcondition_of(new_state(host(), xi_size, xj_size, xk_size, xauto_access)));
408 require(namespace_is_ancestor_of(xhost->
name_space()));
413 require(dynamic_cast<base_space_poset*>(xhost) != 0);
437 lhost->
new_member_interval(
"structured_block_3d_crg_interval", lsize, ldof_tuple_ids, ldata);
441 attach_to_state(lhost, lindex);
451 ensure(host() == xhost);
452 ensure(is_attached());
454 ensure(prototype_path() == static_prototype_path());
455 ensure(local_cell_type_name() == static_local_cell_prototype_path().member_name());
456 ensure(i_size() == xi_size);
457 ensure(j_size() == xj_size);
458 ensure(k_size() == xk_size);
486 require(state_is_read_accessible());
505 require(state_is_read_accessible());
524 require(state_is_read_accessible());
561 define_old_variable(
int old_xhost_row_dof_tuple_ct = xhost.
row_dof_tuple_ct());
579 ltuple->
db = lproto.db();
580 ltuple->
type_id = lproto.type_id();
581 ltuple->
type_name = strdup(lproto.type_name());
585 ltuple->
size = xi_size*xj_size*xk_size;
592 local_proto.detach_from_state();
593 lproto.detach_from_state();
611 #define NODE_ID(i, j, k) (((i)*node_ct_y + (j))*node_ct_z + (k)) 637 require(state_is_read_accessible());
639 require(xpt.
chart_id() == index().pod());
643 require(xpt.
db() >= db());
644 require(result.
db() >= db());
653 refine_coordinate(lu_coord, lu_chart_id, i_size());
657 refine_coordinate(lv_coord, lv_chart_id, j_size());
661 refine_coordinate(lw_coord, lw_chart_id, k_size());
665 pod_index_type lref_chart_id = offset(lu_chart_id, lv_chart_id, lw_chart_id);
669 result.
put_chart_id(_elements_id_space->hub_pod(lref_chart_id));
690 require(state_is_read_accessible());
692 require(xpt.
chart_id() == index().pod());
696 require(xpt.
db() >= db());
704 refine_coordinate(lu_coord, lu_chart_id, i_size());
708 refine_coordinate(lv_coord, lv_chart_id, j_size());
712 refine_coordinate(lw_coord, lw_chart_id, k_size());
716 pod_index_type lref_chart_id = offset(lu_chart_id, lv_chart_id, lw_chart_id);
720 chart_point_3d lref_pt(_elements_id_space->hub_pod(lref_chart_id),
721 lu_coord, lv_coord, lw_coord);
738 unsigned int lbit_code = 0;
740 if(is_close_enough(lu_coord, -1.0) && (lu_chart_id > 0))
744 lbit_code |=
static_cast<unsigned int>(1);
747 if(is_close_enough(lv_coord, -1.0) && (lv_chart_id > 0))
751 lbit_code |=
static_cast<unsigned int>(2);
754 if(is_close_enough(lw_coord, -1.0) && (lw_chart_id > 0))
758 lbit_code |=
static_cast<unsigned int>(4);
764 if((lbit_code & 1) == 1)
769 lref_chart_id = offset(lu_chart_id, lv_chart_id, lw_chart_id);
773 lref_pt.put(_elements_id_space->hub_pod(lref_chart_id),
774 1.0, lv_coord, lw_coord);
778 if((lbit_code & 2) == 2)
783 lref_chart_id = offset(lu_chart_id, lv_chart_id, lw_chart_id);
787 lref_pt.put(_elements_id_space->hub_pod(lref_chart_id),
788 lu_coord, 1.0, lw_coord);
792 if((lbit_code & 3) == 3)
798 lref_chart_id = offset(lu_chart_id, lv_chart_id, lw_chart_id);
802 lref_pt.put(_elements_id_space->hub_pod(lref_chart_id),
807 if((lbit_code & 4) == 4)
812 lref_chart_id = offset(lu_chart_id, lv_chart_id, lw_chart_id);
816 lref_pt.put(_elements_id_space->hub_pod(lref_chart_id),
817 lu_coord, lv_coord, 1.0);
821 if((lbit_code & 5) == 5)
827 lref_chart_id = offset(lu_chart_id, lv_chart_id, lw_chart_id);
831 lref_pt.put(_elements_id_space->hub_pod(lref_chart_id),
836 if((lbit_code & 6) == 6)
842 lref_chart_id = offset(lu_chart_id, lv_chart_id, lw_chart_id);
846 lref_pt.put(_elements_id_space->hub_pod(lref_chart_id),
851 if((lbit_code & 7) == 7)
859 lref_chart_id = offset(lu_chart_id, lv_chart_id, lw_chart_id);
863 lref_pt.put(_elements_id_space->hub_pod(lref_chart_id), 1.0, 1.0, 1.0);
885 require(state_is_read_accessible());
889 require(xpt.
db() >= db());
890 require(result.
db() >= db());
911 lxcoord = lxcoord + lxy/j_size();
912 lycoord = lycoord + lxy%j_size();
913 lzcoord = lzcoord + lref_chart_id%k_size();
919 lxcoord = (lxcoord/i_size())*2.0 - 1.0;
920 lycoord = (lycoord/j_size())*2.0 - 1.0;
921 lzcoord = (lzcoord/k_size())*2.0 - 1.0;
942 require(state_is_read_write_accessible());
965 require(state_is_read_write_accessible());
987 require(state_is_read_write_accessible());
1010 require(state_is_read_write_accessible());
1053 const poset_path& result = STATIC_LOCAL_CELL_PROTOTYPE_PATH;
1120 ensure(result != 0);
1152 if(invariant_check())
1156 disable_invariant_check();
1160 invariance(state_is_read_accessible() ? is_jim(
false) :
true);
1161 invariance(state_is_read_accessible() ? size() == i_size()*j_size()*k_size() :
true);
1165 enable_invariant_check();
1202 attach_to_state(const_cast<abstract_poset_member*>(&xother));
1206 ensure(is_same_state(const_cast<abstract_poset_member*>(&xother)));
1220 require(is_ancestor_of(&xother));
1228 ensure(invariant());
size_type k_size() const
The number of local cells (zones) in the i direction. The number of vertices in the i direction is i_...
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...
double chart_point_coord_type
The type of local coordinate in the base space; the scalar type for the local coordinate vector space...
virtual bool invariant() const
Class invariant.
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 ...
static const poset_path & static_local_cell_prototype_path()
The path of the local cell prototype required by this class.
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...
virtual void create_cover_link(abstract_poset_member *xlesser)
Insert a link from this to lesser; make lesser <= this.
bool full() const
True if both poset name and member name are not empty.
abstract_poset_member & top()
The top member of the poset (mutable version)
size_type size
The number of local cells.
A point in a 3D chart space.
virtual ~structured_block_3d()
Destructor; deletes a poset member and its attached state, if any.
poset_path path(bool xauto_access=true) const
A path to this component.
bool conforms_to(const schema_poset_member &xother) const
True if the dofs defined by this agree in type and in order with the dofs defined by xother...
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...
const char * local_cell_type_name
The local cell type name.
virtual int db() const =0
The dimension of this chart.
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...
A client handle for a general, abstract partially order set.
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 put_chart_id(pod_index_type xchart)
Sets chart_id() to xchart_id.
pod_index_type chart_id() const
The id of the chart this point is in.
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.
static host_type & new_host(namespace_type &xns, const poset_path &xhost_path, const poset_path &xschema_path, bool xauto_access)
Creates a new host poset for members of this type. The poset is created in namespace xns with path xh...
static const std::string & prototypes_poset_name()
The name of the prototypes poset.
int db
The base space dimension.
A client handle for a member of a base space poset.
virtual void unrefine()
Removes the standard refinement of this from its lower cover and changes this from a jrm to a jim...
Abstract base class with useful features for all objects.
virtual void refine()
Inserts the standard refinement of this into its lower cover and changes this from a jim to a jrm...
The lattice of closed cells of a cellular space; a lattice representation of a computational mesh...
size_type k_size
The upper bound on the z direction index for structured blocks.
static host_type & standard_host(namespace_type &xns, const poset_path &xhost_path, bool xauto_access)
The host with path xhost_path. Returns the host if it already exists, otherwise, creates it in namesp...
static void get_private_data(size_type xi_size, size_type xj_size, size_type xk_size, block< pod_index_type > &result)
The private data for an instance with parameter xi_size.
virtual schema_poset_member & schema()
The schema for this poset (mutable version).
Struct representing the closed interval [_begin, _end].
virtual coord_type * local_coords()=0
The array of local coordinates.
void push_back(const_reference_type item)
Insert item at the end of the items in the auto_block.
static const poset_path & static_prototype_path()
The path of the prototype required by this class.
size_type i_size
The upper bound on the x direction index for structured blocks.
structured_block_3d()
Default constructor; creates a new, unattached structured_block_3d handle.
A client handle for a mutable partially ordered set.
virtual const scoped_index & new_row_dof_map()
Creates a new row dof map.
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)
void set_ct(size_type xct)
Sets ct() == xct.
An index within the external ("client") scope of a given id space.
virtual bool is_ancestor_of(const any *other) const
True if other conforms to this.
static void get_dof_tuple_ids(poset_state_handle &xhost, size_type xi_size, size_type xj_size, size_type xk_size, block< pod_index_type > &result)
The dof tuple ids for an instance created with parameter xi_size.
void new_state(const size_type &xi_size, const size_type &xj_size, const size_type &xk_size, bool xauto_access=true)
Creates a new structured_block_1d state in host() with i_size() == xi_size, j_size() == xj_size...
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.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
std::string poset_name() const
The poset name part of the path.
virtual structured_block_3d & operator=(const abstract_poset_member &xother)
Assignment operator; attaches this to the same state as xother.
virtual void unsimplify()
Removes the standard simplex refinement of this from its lower cover and changes this from a jrm to a...
bool contains_path(const poset_path &xpath, bool xauto_access=true) const
True if this contains the poset or poset member specified by xpath.
virtual structured_block_3d * clone() const
Make a new handle, no state instance of current.
size_type i_size() const
The number of local cells (zones) in the i direction. The number of vertices in the i direction is i_...
size_type row_dof_tuple_ct() const
The number of row_dof_tuples of this poset.
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...
size_type j_size
The upper bound on the y direction index for structured blocks.
A homogeneous collection of connected hexahedra arranged in an i_size() x j_size() x k_size() array...
static scoped_index new_row_dof_map(poset_state_handle &xhost, size_type xi_size, size_type xj_size, size_type xk_size, bool xauto_access)
Creates a new row dof map and initializes it.
virtual void simplify()
Inserts the standard simplex refinement of this into its lower cover and changes this from a jim to a...
bool poset_state_is_read_accessible(const poset_path &xpath, bool xauto_access=true) const
True if the poset referred to by xpath is read accessible.
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.
pod_index_type pod_type
The "plain old data" storage type for this.
int refinement_depth
The refinement depth.
int_type pod_index_type
The plain old data index type.
std::string member_name() const
The member name part of the path.
virtual pod_index_type new_member_interval(const std::string &xinterval_type, size_type xsize, const block< pod_index_type > &xdof_tuple_ids, const block< pod_index_type > &xdata)
Create a disconnected member interval of type xinterval_type with size xsize, dof tuple ids xdof_tupl...
virtual void put_local_coord(int xi, coord_type xvalue)=0
Sets the xi-th local coordinate of this point to xvalue.
virtual void unrefine_point_pa(const chart_point &xpt, chart_point &result) const
The point in this which is the same as xpt in the direct refinement of this; pre-allocated version...
int type_id
The cell type id.
virtual void end_jim_edit_mode(bool xensure_lattice_invariant=true, bool xauto_access=true)
Prevent editing of jims and jim order relation.
static bool is_valid_name(const std::string &xname)
True if xname is not empty and contains only name legal characters.
virtual const structured_block_3d_crg_interval & interval() const
The implicit interval member for this block.
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.
bool row_conforms_to(const schema_poset_member &xother) const
True if the row dofs defined by this agree in type and in order with the dofs defined by xother...
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.
virtual void refine_point_pa(const chart_point &xpt, chart_point &result) const
The point in the direct refinement of this which is the same as xpt in this; pre-allocated version...
Emulator for a interval of implicit base space members representing a 3 dimensional structured block...
Namespace for the fiber_bundles component of the sheaf system.
size_type j_size() const
The number of local cells (zones) in the j direction. The number of vertices in the j direction is j_...
virtual coord_type local_coord(int xi) const =0
The xi-th local coordinate of this point.
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...
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...
static void get_size(size_type xi_size, size_type xj_size, size_type xk_size, size_type &result)
The size for an instance created with parameter xi_size.
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.
virtual bool invariant() const
Class invariant.
virtual void begin_jim_edit_mode(bool xauto_access=true)
Allow editing of jims and jim order relation.