22 #include "SheafSystem/assert_contract.h" 23 #include "SheafSystem/arg_list.h" 24 #include "SheafSystem/binary_section_space_schema_member.h" 25 #include "SheafSystem/block.impl.h" 26 #include "SheafSystem/constant_push_action.h" 27 #include "SheafSystem/copy_push_action.h" 28 #include "SheafSystem/discretization_context.h" 29 #include "SheafSystem/discretization_iterator.h" 30 #include "SheafSystem/discretization_pusher.h" 31 #include "SheafSystem/error_message.h" 32 #include "SheafSystem/eval_iterator.h" 33 #include "SheafSystem/field_vd.h" 34 #include "SheafSystem/fiber_bundles_namespace.h" 35 #include "SheafSystem/namespace_poset.h" 36 #include "SheafSystem/postorder_iterator.h" 37 #include "SheafSystem/preorder_iterator.h" 38 #include "SheafSystem/property_disc_iterator.h" 39 #include "SheafSystem/sec_at1_space.h" 40 #include "SheafSystem/sec_ed_invertible.h" 41 #include "SheafSystem/sec_rep_descriptor.h" 42 #include "SheafSystem/sec_vd_space.h" 43 #include "SheafSystem/section_evaluator.h" 44 #include "SheafSystem/section_pusher.h" 45 #include "SheafSystem/section_pusher_push_action.h" 46 #include "SheafSystem/stl_scoped_index.h" 47 #include "SheafSystem/std_iomanip.h" 48 #include "SheafSystem/field_vd.h" 60 pullback_map::iterator& xitr,
63 cout <<
"eval id: " << setw(5) << xeval_client_id;
65 cout <<
" disc_id: " << setw(5) << lspace.
pod(xitr->disc_id);
66 cout <<
" source point:";
67 int ldb = xitr->domain_pt.db();
70 cout << setw(12) << setprecision(3) << xitr->domain_pt.local_coord(j);
72 cout << setw(5) << xitr->domain_pt.chart_id();
73 cout <<
" dst value:";
74 int ldf = xdst_dofs.
ct();
77 cout << setw(12) << setprecision(3) << xdst_dofs[j];
113 require(dynamic_cast<binary_section_space_schema_member*>(&(xdst.
coordinates().
schema())));
114 require(dynamic_cast<binary_section_space_schema_member*>(&(xdst.
property().
schema())));
122 _range_coords.attach_to_state(&xdst.
coordinates());
260 const sec_ed& xdomain_coord,
261 const sec_ed& xrange_coord,
272 define_old_variable(
int old_xdomain_access_request_depth =
274 define_old_variable(
int old_xdomain_coord_access_request_depth =
276 define_old_variable(
int old_xrange_access_request_depth =
278 define_old_variable(
int old_xrange_coord_access_request_depth =
289 require(same_base(xdomain_coord, xdomain));
290 require(same_base(xrange_coord, xrange));
292 require(same_fiber(xdomain, xrange));
293 require(same_fiber(*xdomain_coord.
host(), *xrange_coord.
host()));
298 require(dynamic_cast<const binary_section_space_schema_member*>(&(xrange.
schema())));
299 require(dynamic_cast<const binary_section_space_schema_member*>(&(xrange_coord.
schema())));
310 _range_coords.attach_to_state(&xrange_coord);
319 ensure(domain().is_same_state(&xdomain));
320 ensure(range().is_same_state(&xrange));
397 const sec_ed& result = _range_coords;
414 require(precondition_of(push_pa(xinput, result, xauto_access)));
415 require(xauto_access || range().in_jim_edit_mode());
419 require(xauto_access || range().name_space()->state_is_read_accessible());
423 result = xinput.
clone();
434 dynamic_cast<sec_rep_space&
>(_range->name_space()->member_poset(_range->index()));
437 push_pa(xinput, *result, xauto_access);
442 ensure(range().contains_member(result, xauto_access));
443 ensure(postcondition_of(push_pa));
455 #ifdef DIAGNOSTIC_OUTPUT 456 post_information_message(
"Entering push_pa:");
464 require(domain().contains_member(&xinput, xauto_access));
465 require(range().contains_member(&xresult, xauto_access));
467 require(xauto_access || domain_coords().state_is_read_accessible());
468 require(xauto_access || range_coords().state_is_read_accessible());
470 define_old_variable(
int old_xinput_access_request_depth =
472 define_old_variable(
int old_result_access_request_depth =
474 define_old_variable(
int old_domain_coord_access_request_depth =
475 domain_coords().access_request_depth());
476 define_old_variable(
int old_range_coord_access_request_depth =
477 range_coords().access_request_depth());
484 domain_coords().get_read_access();
485 range_coords().get_read_access();
497 if(domain_coords().is_jim())
505 pull_back_range_disc_mono_mono();
511 pull_back_range_disc_mono_multi();
522 pull_back_range_disc_multi_mono();
528 post_fatal_error_message(
"Source coordinate multisection with source property multisection not supported");
534 define_overlap(xinput, xresult);
538 define_extension(xresult);
546 range_coords().release_access();
547 domain_coords().release_access();
556 ensure(domain_coords().access_request_depth() == old_domain_coord_access_request_depth);
557 ensure(range_coords().access_request_depth() == old_range_coord_access_request_depth);
559 #ifdef DIAGNOSTIC_OUTPUT 561 post_information_message(
"Leaving push_pa:");
651 return *_overlap_action;
658 return *_default_overlap_action;
665 return *_extension_action;
672 return *_default_extension_action;
685 _overlap_action = &xoverlap_action;
689 ensure(&overlap_action() == &xoverlap_action);
705 _extension_action = &xextension_action;
709 ensure(&extension_action() == &xextension_action);
739 fields::section_pusher::
740 make_range_monovalent_subposet(
bool xis_ext)
744 require(domain().state_is_read_accessible());
745 require(range().state_is_read_accessible());
746 require(range().schema().base_space().state_is_read_write_accessible());
754 ensure(unexecutable(corresponding members of monovalent
subposet in domain and range have same client
id));
761 fields::section_pusher::
762 pull_back_range_disc_mono_mono()
764 #ifdef DIAGNOSTIC_OUTPUT 765 post_information_message(
"Entering pull_back_range_disc_mono_mono:");
770 require(_domain_coords.state_is_read_accessible());
771 require(_range_coords.state_is_read_accessible());
776 if(!_domain_coords.is_invertible())
780 _domain_coords.initialize_point_locator(
false);
790 property_disc_iterator::new_property_disc_iterator(_range_coords.schema(),
815 _domain_coords.point_at_value_ua(lcontext.
values,
819 #ifdef DIAGNOSTIC_OUTPUT 821 cout <<
"inserting pullback entry: " << lpb << endl;
826 _pb_maps[_first_branch.pod()]->insert(lpb);
839 #ifdef DIAGNOSTIC_OUTPUT 841 post_information_message(
"Leaving pull_back_range_disc_mono_mono:");
848 fields::section_pusher::
849 pull_back_range_disc_mono_multi()
851 #ifdef DIAGNOSTIC_OUTPUT 852 post_information_message(
"Entering pull_back_range_disc_mono_multi:");
857 require(_domain_coords.state_is_read_accessible());
858 require(_range_coords.state_is_read_accessible());
863 if(!_domain_coords.is_invertible())
867 _domain_coords.initialize_point_locator(
false);
874 set< stl_scoped_index<> > lbranches;
879 property_disc_iterator::new_property_disc_iterator(_range_coords.schema(),
905 _domain_coords.all_points_at_value_ua(lcontext.
values,
909 if(ldomain_pts.
ct() > 0)
923 for(
int i=0; i<ldomain_pts.
ct(); ++i)
926 #ifdef DIAGNOSTIC_OUTPUT 927 cout <<
"i: " << i <<
" chart pt[i]: " << ldomain_pts[i] << endl;
931 typedef chart_to_branch_map_type::iterator map_itr_type;
932 typedef pair<map_itr_type, map_itr_type> map_range_type;
934 map_range_type lrange =
935 _chart_to_branch_map.equal_range(ldomain_pts[i].chart_id());
937 map_itr_type lmap_itr = lrange.first;
938 while(lmap_itr != lrange.second)
941 if(lbranches.find(lbranch_id) == lbranches.end())
949 #ifdef DIAGNOSTIC_OUTPUT 951 cout <<
"inserting pullback entry: " << lpb << endl;
956 _pb_maps[lbranch_id.
pod()]->insert(lpb);
960 lbranches.insert(lbranch_id);
967 #ifdef DIAGNOSTIC_OUTPUT 968 cout <<
"Ignoring chart pt." << endl;
983 _pb_maps[_first_branch.pod()]->insert(lpb);
997 #ifdef DIAGNOSTIC_OUTPUT 999 post_information_message(
"Leaving pull_back_range_disc_mono_multi:");
1006 fields::section_pusher::
1007 pull_back_range_disc_multi_mono()
1009 #ifdef DIAGNOSTIC_OUTPUT 1010 post_information_message(
"Entering pull_back_range_disc_multi_mono:");
1015 require(_domain_coords.state_is_read_accessible());
1016 require(_range_coords.state_is_read_accessible());
1021 if(!_domain_coords.is_invertible())
1025 _domain_coords.initialize_point_locator(
false);
1036 property_disc_iterator::new_property_disc_iterator(_range_coords.schema(),
1062 _domain_coords.branch_points_at_value_ua(lcontext.
values,
1066 if(ldomain_pts.
ct() > 0)
1071 for(
int i=0; i<ldomain_pts.
ct(); ++i)
1074 #ifdef DIAGNOSTIC_OUTPUT 1076 <<
" branch id: " << ldomain_pts[i].first
1077 <<
" chart pt[i]: " << ldomain_pts[i].second
1083 #ifdef DIAGNOSTIC_OUTPUT 1085 cout <<
"inserting pullback entry: " << lpb << endl;
1088 _pb_maps[_first_branch.pod()]->insert(lpb);
1098 _pb_maps[_first_branch.pod()]->insert(lpb);
1112 #ifdef DIAGNOSTIC_OUTPUT 1114 post_information_message(
"Leaving pull_back_range_disc_multi_mono:");
1121 fields::section_pusher::
1122 make_maps(
const sec_vd& xinput)
1136 _pb_maps.reserve(_domain->member_index_ub().pod());
1138 _pb_maps.set_ct(_pb_maps.ub());
1149 leval_itr.put_visit_once(
false);
1155 _first_branch = lbranch_itr.
index();
1157 assertion(_first_branch.is_hub_scope());
1176 leval_itr.reset(
false);
1181 while(!leval_itr.is_done())
1183 chart_to_branch_map_type::value_type lval(leval_itr.index().hub_pod(), lbranch_id);
1184 _chart_to_branch_map.insert(lval);
1185 leval_itr.truncate();
1202 fields::section_pusher::
1212 for(
int i=0; i<_pb_maps.ct(); ++i)
1225 _first_branch.invalidate();
1229 _chart_to_branch_map.clear();
1241 fields::section_pusher::
1244 #ifdef DIAGNOSTIC_OUTPUT 1245 post_information_message(
"Entering define_overlap:");
1255 _overlap_action->initialize(xresult);
1285 leval_itr.put_schema_anchor(lbranch.
schema().
index());
1286 leval_itr.reset(
false);
1288 while(!leval_itr.is_done())
1290 push_eval_mbr(leval_itr, lbranch, xresult);
1301 _overlap_action->finalize(xresult);
1312 #ifdef DIAGNOSTIC_OUTPUT 1314 post_information_message(
"Leaving define_overlap:");
1321 fields::section_pusher::
1332 pb_map_range_type litr_range =
1335 if(litr_range.first != litr_range.second)
1342 _src_dofs.set_ct(0);
1355 for(pb_map_itr_type itr = litr_range.first; itr != litr_range.second; ++itr)
1361 itr->domain_pt.local_coords(),
1368 (*_overlap_action)(itr, xresult, _dst_dofs);
1371 #ifdef DIAGNOSTIC_OUTPUT 1373 print_debug_info(xeval_itr.
client_id(), range(), itr, _dst_dofs);
1378 xresult.put_fiber(itr->disc_id, _dst_dofs.base(),
1398 fields::section_pusher::
1399 define_extension(
sec_vd& xresult)
1401 #ifdef DIAGNOSTIC_OUTPUT 1402 post_information_message(
"Entering define_extension:");
1416 _extension_action->initialize(xresult);
1421 pb_map_type* lpb_map = _pb_maps[_first_branch.pod()];
1423 pb_map_range_type litr_range =
1426 for(pb_map_itr_type itr = litr_range.first; itr != litr_range.second; ++itr)
1431 (*_extension_action)(itr, xresult, _dst_dofs);
1434 #ifdef DIAGNOSTIC_OUTPUT 1441 xresult.put_fiber(itr->disc_id, _dst_dofs.base(),
1447 _extension_action->finalize(xresult);
1454 #ifdef DIAGNOSTIC_OUTPUT 1456 post_information_message(
"Leaving define_extension:");
1463 fields::section_pusher::
1468 require(domain().state_is_read_accessible());
1474 _prop_df = _domain->schema().df();
1475 _src_db = _domain->schema().db();
1477 _src_value.reserve(_prop_df);
1478 _src_value.set_ct(_prop_df);
1480 _dst_dofs.reserve(_prop_df);
1481 _dst_dofs.set_ct(_prop_df);
1486 _overlap_action = _default_overlap_action;
1489 _extension_action = _default_extension_action;
1494 _pb_maps.reserve(_domain->member_index_ub().pod());
1496 _pb_maps.set_ct(_pb_maps.ub());
1499 _first_branch.invalidate();
1527 ensure(invariant());
1539 _domain_coords.detach_from_state();
1540 _range_coords.detach_from_state();
1557 invariance(any::invariant());
1559 if(invariant_check())
1561 disable_invariant_check();
1566 invariance(unexecutable(same_fiber(domain(), range())));
1571 invariance(unexecutable(dynamic_cast<binary_section_space_schema_member*>(&(range().schema())) != 0));
1575 enable_invariant_check();
A context for discretization members. Intended for implementing various iterators, especially concurrent iterations over multiple sections.
virtual void force_is_done()
Force the iterator to be done.
virtual bool is_jim(bool xin_current_version=true) const
True if this member is join irreducible in the current version of the host (xin_current_version == tr...
A client handle for a subposet.
scoped_index disc_id
The global index of the disc member.
void truncate()
Makes this the next member of the subset which is not less than old this, i.e. the depth-first descen...
host_type * host() const
The poset this is a member of.
Functor to compute the dofs at a destination discretization point by copying the source value to the ...
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.
section_evaluator & evaluator()
The section evaluator associated with the current evaluation member (mutable version).
schema_poset_member & fiber_schema()
The fiber schema component of this (mutable version).
Abstract functor to compute the dofs at a destination discretization point.
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...
virtual void get_read_access() const
Get read access to the state associated with this.
virtual void force_is_done()
Force the iterator to be done.
An iterator over the members of the evaluation subposet contained in the downset of the base space of...
subposet & evaluation()
The evaluation subposet for section spaces on this schema (mutable version).
void put_overlap_action(section_pusher_push_action &xoverlap_action)
Sets the overlap action to xoverlap_action.
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.
An abstract handle to a space of alternate integer identifiers (aliases) for a subset of a hub set of...
section_pusher_push_action & extension_action() const
Computes value of destination dofs where dst does not overlap src.
virtual bool invariant() const
Class invariant.
virtual void get_read_access() const
Get read access to the state associated with this.
host_type * host() const
The poset this is a member of.
section_pusher()
Default constructor; protected to prevent default construction.
const scoped_index & index() const
The index of the component state this handle is attached to.
bool same_base(const sec_ed &xcoord, const sec_rep_space &xspace) const
True if and only if xcoord and xspace have the same base space.
virtual dof_type value_at_coord(const dof_type xdofs[], size_type xdofs_ub, const dof_type xlocal_coords[], size_type xlocal_coords_ub) const
Value at a specified local_coordinate. Single component version.
const geometry::sec_ed_invertible & domain_coords() const
The coordinates section for the domain.
void push_pa(const sec_vd &xinput, sec_vd &result, bool xauto_access)
Pushes field xinput from sec_rep_space domain() to sec_rep_space range(), pre-allocated.
bool is_hub_scope() const
True if and only if the id space of this is the hub id space.
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.
void invalidate()
Makes this invalid.
virtual section_space_schema_member & schema()
The schema for this poset (mutable version)
const bool NOT_STRICT
Iteration strictness control.
const bool DOWN
Iteration directions.
An abstract invertible section of a fiber bundle with a d-dimensional base space and a d-dimensional ...
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...
bool same_discretization(const sec_ed &xcoord, const sec_rep_space &xspace) const
True if and only if xcoord and xspace have the same discretization.
void set_ct(size_type xct)
Sets ct() == xct.
An index within the external ("client") scope of a given id space.
const sec_rep_space & domain() const
The domain of the push-forward map.
void put_extension_action(section_pusher_push_action &xextension_cction)
Sets the extension action to xextension_action.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
virtual ~section_pusher()
Destructor.
int access_request_depth() const
The number of times access has been requested and granted without being released. ...
A vd-valued property as a function of global coordinates.
sec_vd & property() const
The dependent variable of this field.
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...
section_pusher_push_action & default_overlap_action() const
Overlap action if none specified by clinet.
section_pusher_push_action & default_extension_action() const
Extension action if none specified by clinet.
scoped_index client_id() const
The client id of the current evaluation member.
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.
bool same_fiber(const sec_rep_space &xspace1, const sec_rep_space &xspace2) const
True if and only if xspace1 and xspace2 have the same fiber type and dimension.
subposet & discretization()
The discretization subposet for section spaces on this schema (mutable version).
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...
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.
virtual pod_type pod(pod_type xid) const =0
The pod index in this space equivalent to xid in the hub id space.
const block< discretization_context > & property_discretization_members() const
The property discretization members in the downset of the current evaluation member.
const sec_ed & range_coords() const
The coordinates section for the range.
chart_point_3d domain_pt
The location of the discretization member.
The general section push-forward operator; moves sections from one sec_rep_space to another using ext...
section_pusher_push_action & overlap_action() const
Computes value of destination dofs where dst overlaps src.
An abstract local section evaluator; a map from {local coordinates x dofs} to section value...
A section of a fiber bundle with a d-dimensional vector space fiber.
Abstract functor to compute the dofs at a destination discretization point.
bool is_done() const
True if iteration finished.
void detach_from_state()
Detaches field from state it is currently attached to.
const scattered_insertion_index_space_handle & id_space() const
The id space for the members of with this (const version).
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...
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).
void gather_dofs(const sec_vd &xsec, block< sec_vd::dof_type > &xdofs)
Gathers the dofs for the current evalaution member from section xsec and appends them to the back of ...
sec_ed_invertible & coordinates() const
The independent variable of this field.
bool state_is_read_accessible() const
True if this is attached and if the coordinates and property are accessible for read or access contro...
virtual sec_vd * clone() const
Make a new handle, no state instance of current.
int df() const
The dimension of the fiber space component.
A map from members of a discretization subposet to points in a base space.
void new_jim_state(abstract_poset_member &xbase_mbr, int xbase_version=CURRENT_HOST_VERSION, bool xauto_access=true)
Creates a new jim state in host() and attaches this handle to the state. The state is a partial secti...
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.
virtual void get_read_access() const
Get read access to the state associated with this.
double sec_vd_dof_type
The type of degree of freedom in the section space.
scoped_index disc_id
The id of a discretization member.
const sec_rep_space & range() const
The range of the push-forward map.
SHEAF_DLL_SPEC pod_index_type invalid_pod_index()
The invalid pod index value.
Abstract iterator over the discretization of the property section of a field_vd. Concurrently travers...
sec_vd * push(const sec_vd &xinput, bool xauto_access)
Pushes field xinput from sec_rep_space domain() to sec_rep_space range(), auto-allocated.
const scoped_index & index() const
The index of the current member of the iteration.
pod_index_type base_space_id() const
The member id of the base space component of this.
A handle for a poset whose members are numerical representations of sections of a fiber bundle...