21 #include "SheafSystem/body_pusher.h" 23 #include "SheafSystem/assert_contract.h" 24 #include "SheafSystem/base_space_member.h" 25 #include "SheafSystem/base_space_poset.h" 26 #include "SheafSystem/binary_section_space_schema_member.h" 27 #include "SheafSystem/binary_section_space_schema_poset.h" 28 #include "SheafSystem/discretization_context.h" 29 #include "SheafSystem/index_iterator.h" 30 #include "SheafSystem/poset_joiner.h" 31 #include "SheafSystem/postorder_itr.h" 32 #include "SheafSystem/property_disc_iterator.h" 33 #include "SheafSystem/sec_ed_invertible.h" 34 #include "SheafSystem/sec_rep_descriptor.h" 35 #include "SheafSystem/section_evaluator.h" 36 #include "SheafSystem/tern.h" 59 require(same_fiber(xdomain_coord, xrange_coord, xauto_access));
63 define_old_variable(
int old_domain_coord_access_request_depth = xdomain_coord.
access_request_depth());
64 define_old_variable(
int old_range_coord_access_request_depth = xrange_coord.
access_request_depth());
73 _domain_coord = xdomain_coord.
clone();
80 define_old_variable(
int old_range_access_request_depth = range().access_request_depth());
86 poset_path::make_name(poset_path::reserved_prefix() + _range->name(),
88 "body_pusher_schema" );
90 string lschema_poset_name =
91 sec_rep_space_member::standard_schema_poset_name(lschema_name);
93 poset_path lschema_path(lschema_poset_name, lschema_name);
104 if(xrange_coord.
schema().
rep().
name() ==
"vertex_vertex_constant")
120 binary_section_space_schema_poset::new_table(lns,
122 binary_section_space_schema_poset::standard_schema_path(),
139 pull_back_range_disc();
147 ensure(name_prefix().empty());
148 ensure(name_suffix().empty());
150 ensure(range().access_request_depth() == old_range_access_request_depth );
224 const sec_ed& result = _range_coord;
242 require(xauto_access || domain_coord().state_is_read_accessible());
243 require(domain().contains_member(&xinput, xauto_access));
244 require(xauto_access || range_coord().state_is_read_accessible());
245 require(xauto_access || range().state_is_read_write_accessible());
250 result = xinput.
clone();
251 push_pa(xinput, *result, xcompute_upper_bound, xauto_access);
256 ensure(postcondition_of(push_pa));
267 bool xcompute_upper_bound,
270 #ifdef DIAGNOSTIC_OUTPUT 272 <<
"body_pusher::push_pa" 279 require(xauto_access || domain_coord().state_is_read_accessible());
280 require(domain().contains_member(&xinput, xauto_access));
281 require(xauto_access || range().state_is_read_write_accessible());
282 require(xauto_access || range_coord().state_is_read_accessible());
286 define_old_variable(
int old_domain_coord_access_request_depth = domain_coord().access_request_depth());
287 define_old_variable(
int old_range_coord_access_request_depth = range_coord().access_request_depth());
288 define_old_variable(
int old_range_access_request_depth = range().access_request_depth());
293 _domain_coord->get_read_access();
294 _range->get_read_write_access(
true);
295 _range_coord.get_read_access();
301 unordered_set<scoped_index> lvertices;
307 while(!litr.is_done())
312 pb_map_range_type litr_range = _pb_map.equal_range(
pb_type(litr.index()));
313 for(pb_map_itr_type lpb_itr = litr_range.first;
314 lpb_itr != litr_range.second;
317 lvertices.insert(lpb_itr->disc_id);
330 unordered_set<scoped_index> lelements;
340 for(unordered_set<scoped_index>::const_iterator lvertex_itr = lvertices.begin();
341 lvertex_itr != lvertices.end();
349 while(!lelem_itr.is_done())
353 lelements.insert(lelem_itr.index());
364 bool lhas_zones =
false;
369 lelem_itr.put_filter(_range->vertices());
375 for(unordered_set<scoped_index>::const_iterator lub_elem_itr = lelements.begin();
376 lub_elem_itr != lelements.end();
381 if(!xcompute_upper_bound)
385 lelem_itr.put_anchor(*lub_elem_itr);
388 while(!lelem_itr.is_done())
390 if(lvertices.find(lelem_itr.index()) == lvertices.end())
405 if(xcompute_upper_bound || lis_lb)
420 ljoiner.
join(lelement_ids.
base(), lelement_ids.
ct(), tern::TRUE, result);
422 if(push_name() && !xinput.
name().empty())
424 result.
put_name(name_prefix() + xinput.
name() + name_suffix(),
false,
false);
430 ensure(result.
is_attached() ? range().is_same_state(result.
host()) :
true);
431 ensure((result.
is_attached() && !xinput.
name().empty() && push_name()) ?
432 result.
name() == name_prefix() + xinput.
name() + name_suffix() :
437 _range_coord.release_access();
438 _range->release_access();
439 _domain_coord->release_access();
442 ensure(domain_coord().access_request_depth() == old_domain_coord_access_request_depth);
443 ensure(range_coord().access_request_depth() == old_range_coord_access_request_depth);
444 ensure(range().access_request_depth() == old_range_access_request_depth );
453 push(
const subposet& xinput,
bool xcompute_upper_bound,
bool xauto_access)
459 require(precondition_of(push_pa(xinput, *result, xcompute_upper_bound, xauto_access)));
463 domain_coord().get_read_access();
464 range_coord().get_read_access();
466 _range->get_read_write_access(
true);
469 require(!xinput.
name().empty());
473 result = xinput.
clone();
477 string lresult_name(name_prefix() + xinput.
name() + name_suffix());
478 if(range().includes_subposet(lresult_name))
488 result->new_state(_range,
false,
false);
489 result->put_name(lresult_name,
false,
false);
492 push_pa(xinput, *result, xcompute_upper_bound, xauto_access);
498 domain_coord().release_access();
499 range_coord().release_access();
500 range().release_access();
504 ensure(postcondition_of(push_pa(xinput, *result, xcompute_upper_bound, xauto_access)));
515 bool xcompute_upper_bound,
520 require(xauto_access || domain_coord().state_is_read_accessible());
521 require(domain().includes_subposet(&xinput, xauto_access));
522 require(xauto_access || range_coord().state_is_read_accessible());
523 require(xauto_access || range().state_is_read_write_accessible());
524 require(range().includes_subposet(&result, xauto_access));
528 domain_coord().get_read_access();
529 range_coord().get_read_access();
531 _range->get_read_write_access(
true);
542 lsrc_body.attach_to_state(litr.
index());
544 push_pa(lsrc_body, ldst_body, xcompute_upper_bound,
false);
545 if(ldst_body.is_attached())
548 ldst_body.detach_from_state();
555 lsrc_body.detach_from_state();
559 domain_coord().release_access();
560 range_coord().release_access();
561 range().release_access();
634 fields::body_pusher::
635 pull_back_range_disc()
639 require(_range_coord.state_is_read_accessible());
643 int ldf = _range_coord.schema().df();
647 _body_schema->get_read_access();
649 if(!_domain_coord->is_invertible())
653 _domain_coord->initialize_point_locator(
false);
659 property_disc_iterator::new_property_disc_iterator(_range_coord.schema(),
683 _domain_coord->all_points_at_value_ua(lcontext.
values, ldf, ldomain_pts);
699 _body_schema->release_access();
759 _range_coord.detach_from_state();
760 _body_schema->detach_from_state();
780 invariance(any::invariant());
782 if(invariant_check())
784 disable_invariant_check();
788 enable_invariant_check();
const base_space_poset & domain() const
The domain of the push-forward map.
poset_state_handle * host() const
The poset which this is a handle to a component of.
A context for discretization members. Intended for implementing various iterators, especially concurrent iterations over multiple sections.
virtual poset_path path(bool xauto_access=true) const
The path of this poset.
A client handle for a subposet.
scoped_index disc_id
The global index of the disc member.
section_space_schema_poset * host() const
The poset which this is a handle to a component of.
A client handle for a poset member which has been prepared for use as a schema for a section space...
size_type ct() const
The number of items currently in use.
const pod_type & pod() const
The "plain old data" storage of this; the value in the external id space.
virtual void get_prop_disc_values(const sec_vd &xsec)=0
The gets the values of xsec at the property discretization points.
schema_poset_member & fiber_schema()
The fiber schema component of this (mutable version).
poset_path path(bool xauto_access=true) const
A path to this component.
Namespace for fields component of sheaf system.
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
The standard fiber bundles name space; extends the standard sheaves namespace by defining base space...
const base_space_poset & range() const
The range of the push-forward map.
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...
const scoped_index & index() const
The current item in the subset.
A path defined by a poset name and a member name separated by a forward slash ('/'). For example: "cell_definitions/triangle".
const geometry::sec_ed_invertible & domain_coord() const
The coordinate field for the domain.
bool is_same_state(const poset_state_handle *xhost, pod_index_type xhub_id) const
True is this is attached to state with hub id xhub_id in host xhost.
Specialization of the filtered depth-first iterator which exposes the POSTVISIT_ACTION to the client...
A schema poset for a section space. A binary Cartesian product subspace of the binary tensor product ...
virtual void get_read_access() const
Get read access to the state associated with this.
const scoped_index & index() const
The index of the component state this handle is attached to.
std::string name() const
A name for this.
A client handle for a member of a base space poset.
void next()
Makes item the next member of the subset.
void attach_to_state(const poset_state_handle *xhost, pod_index_type xhub_id)
Attach this handle to the state with hub id xhub_id in the current version of host xhost...
void push_pa(const base_space_member &xinput, base_space_member &result, bool xcompute_upper_bound, bool xauto_access)
Pushes member xinput from base_space_poset domain() to base_space_poset range(), pre-allocated.
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...
A section of a fiber bundle with a d-dimensional Euclidean vector space fiber.
poset & fiber_space()
The fiber space for section spaces on this schema.
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.
virtual schema_poset_member & schema()
The schema for this poset (mutable version).
void push_back(const_reference_type item)
Insert item at the end of the items in the auto_block.
An abstract invertible section of a fiber bundle with a d-dimensional base space and a d-dimensional ...
virtual ~body_pusher()
Destructor.
poset * host() const
The poset which this is a handle to a member of.
void put_member_name(const std::string &xname)
Sets member_name() to xname.
pointer_type base() const
The underlying storage array.
void set_ct(size_type xct)
Sets ct() == xct.
virtual bool is_attached() const
True if this handle is attached to a non-void state.
body_pusher()
Default constructor; protected to prevent default construction.
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 void insert_member(pod_index_type xmbr_hub_id)
Inserts the member of host() with hub id xmbr_hub_id.
void join(const scoped_index *xexpansion, int xexpansion_ct, const tern &xgreatest, abstract_poset_member &xresult)
The join of the members of xexpansion.
bool same_fiber(const sec_ed &xcoord1, const sec_ed &xcoord2, bool xauto_access) const
True if and only if xcoord1 and xcoord2 have the same fiber type and dimension.
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.
void next()
Makes this the next member of the subset.
void attach_to_state(const poset_state_handle *xother)
Attach this handle to the same state as xother.
const bool UP
Iteration directions.
void put_poset_name(const std::string &xname)
Sets poset_name() to xname.
An entry in a discretization map.
sec_vd_value_type values[values_ub]
The values of another section (typically the global coordinates) at this disc point.
const block< discretization_context > & property_discretization_members() const
The property discretization members in the downset of the current evaluation member.
chart_point_3d domain_pt
The location of the discretization member.
virtual subposet * clone() const
Virtual constructor; makes a new instance of the same type as this.
const bool & push_name() const
True if destination body should be named from the source body.
base_space_member * push(const base_space_member &xinput, bool xcompute_upper_bound, bool xauto_access)
Pushes member xinput from domain() to base_space_poset range(), auto-allocated.
bool is_done() const
True if iteration finished.
Iterates over the subset of Zn defined by the characteristic function host().
base_space_member * clone(bool xnew_state, bool xauto_access=true) const
Make a new handle instance of current. Attach the new instance to a new state if xnew_state is true...
virtual void put_anchor(const abstract_poset_member *xanchor)
Set anchor() to xanchor.
virtual bool invariant() const
Class invariant.
int access_request_depth() const
The number of times access has been requested and granted without being released. ...
total_poset_member & base_space()
The base space component of this (mutable version).
virtual section_space_schema_member & schema()
The restricted schema for this (mutable version).
poset & fiber_space()
The fiber space for section spaces on this schema (mutable version).
std::string member_name() const
The member name part of the path.
bool is_done() const
True if iteration finished.
virtual sec_ed_invertible * clone() const
Make a new handle, no state instance of current.
The general push-forward operator for base space members; moves a base space member from one base spa...
const sec_ed & range_coord() const
The coordinate field for the range.
int df() const
The dimension of the fiber space component.
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.
scoped_index disc_id
The id of a discretization member.
sec_rep_descriptor & rep()
The representation for section spaces on this schema (mutable version).
Computes the join of given poset members.
std::string & name_prefix()
Prefix for destination name.
Abstract iterator over the discretization of the property section of a field_vd. Concurrently travers...
virtual index_iterator indexed_member_iterator() const
An iterator for members of this poset; index version.
base_space_poset & base_space()
The base space for section spaces on this schema.
std::string & name_suffix()
Suffix for destination name.