21 #include "SheafSystem/cylindrical_point_locator.h" 23 #include "SheafSystem/assert_contract.h" 24 #include "SheafSystem/bilinear_2d.h" 25 #include "SheafSystem/chart_point_3d.h" 26 #include "SheafSystem/d_bin_coordinates.h" 27 #include "SheafSystem/eval_iterator.h" 28 #include "SheafSystem/error_message.h" 29 #include "SheafSystem/linear_2d.h" 30 #include "SheafSystem/preorder_iterator.h" 31 #include "SheafSystem/sec_at1_space.h" 32 #include "SheafSystem/sec_ed.h" 33 #include "SheafSystem/std_bitset.h" 123 ensure_for_all(i, 0,
db(), result[i] > 0);
186 ensure(result == (
box_ct() == 0));
202 require(xpt_ub >=
db());
228 require(xpt_ub >=
db());
229 require((-90.0 < xpt[1]) && (xpt[1] < 90.0));
240 if(lrel_pos[0] < 0.0)
244 else if(lrel_pos[0] >=
_bin_ub[0])
251 #ifdef DIAGNOSTIC_OUTPUT 253 cout <<
"rel pos: " << setw(12) << lrel_pos[0] << setw(12) << lrel_pos[1] << endl;
283 ensure(
box_ct() == old_box_ct + 1);
308 ensure(
box_ct() == old_box_ct - 1);
322 require(xpt_ub >=
db());
415 bitset<4> neg_x, neg_y;
419 for(
int i=0, j=0, k=0; i<4; i++, j+=2, k+=3)
421 neg_x[i] = (xdofs[k] < 0.0);
422 neg_y[i] = (xdofs[k+1] < 0.0);
426 #ifdef DIAGNOSTIC_OUTPUT 427 cout <<
"xdofs " << xdofs << endl;
428 cout <<
"neg_x " << neg_x << endl;
429 cout <<
"neg_y " << neg_y << endl << endl;
432 int neg_x_ct = neg_x.count();
433 int neg_y_ct = neg_y.count();
434 bool on_dateline = (neg_x_ct == 4) && (neg_y_ct != 4) && (neg_y_ct != 0);
442 for(
int i=0; i<4; ++i)
446 lat_lon[i*2] += 360.0;
450 #ifdef DIAGNOSTIC_OUTPUT 451 cout <<
"creating bbox at 180" << endl;
458 for(
int i=0; i<4; ++i)
460 lat_lon[i*2] -= 360.0;
463 #ifdef DIAGNOSTIC_OUTPUT 464 cout <<
"creating bbox at -180" << endl;
498 bitset<3> neg_x, neg_y;
502 for(
int i=0, j=0, k=0; i<3; i++, j+=2, k+=3)
504 neg_x[i] = (xdofs[k] < 0.0);
505 neg_y[i] = (xdofs[k+1] < 0.0);
509 #ifdef DIAGNOSTIC_OUTPUT 510 cout <<
"xdofs " << xdofs << endl;
511 cout <<
"neg_x " << neg_x << endl;
512 cout <<
"neg_y " << neg_y << endl << endl;
515 int neg_x_ct = neg_x.count();
516 int neg_y_ct = neg_y.count();
517 bool on_dateline = (neg_x_ct == 3) && (neg_y_ct != 3) && (neg_y_ct != 0);
525 for(
int i=0; i<3; ++i)
529 lat_lon[i*2] += 360.0;
533 #ifdef DIAGNOSTIC_OUTPUT 534 cout <<
"creating bbox at 180" << endl;
541 for(
int i=0; i<3; ++i)
543 lat_lon[i*2] -= 360.0;
546 #ifdef DIAGNOSTIC_OUTPUT 547 cout <<
"creating bbox at -180" << endl;
576 static const double RAD2DEG = 180.0/M_PI;
578 double x = xcartesian[0];
579 double y = xcartesian[1];
580 double z = xcartesian[2];
584 double radius =
sqrt(x*x + y*y + z*z);
585 double theta =
atan2(y, x);
586 double phi =
acos(z/radius);
588 double longitude = RAD2DEG*theta;
589 double latitude = 90.0 - RAD2DEG*phi;
593 xresult[0] = longitude;
594 xresult[1] = latitude;
613 #ifdef DIAGNOSTIC_OUTPUT 614 cout <<
"lat lon dofs: " << xlat_lon_dofs << endl;
632 levaluator.
min(xlat_lon_dofs.
base(), xlat_lon_dofs.
ct(), lat_lon_min, 2);
634 #ifdef DIAGNOSTIC_OUTPUT 636 cout <<
"lat_lon_min: " << setw(12) << lat_lon_min[0] << setw(12) << lat_lon_min[1] << endl;
640 levaluator.
max(xlat_lon_dofs.
base(), xlat_lon_dofs.
ct(), lat_lon_max, 2);
642 #ifdef DIAGNOSTIC_OUTPUT 644 cout <<
"lat_lon_max: " << setw(12) << lat_lon_max[0] << setw(12) << lat_lon_max[1] << endl;
663 #ifdef DIAGNOSTIC_OUTPUT 665 cout <<
"bounding box: " << bbox << endl;
691 #ifdef DIAGNOSTIC_OUTPUT 692 cout <<
"lat lon dofs: " << xlat_lon_dofs << endl;
710 levaluator.
min(xlat_lon_dofs.
base(), xlat_lon_dofs.
ct(), lat_lon_min, 2);
712 #ifdef DIAGNOSTIC_OUTPUT 714 cout <<
"lat_lon_min: " << setw(12) << lat_lon_min[0] << setw(12) << lat_lon_min[1] << endl;
718 levaluator.
max(xlat_lon_dofs.
base(), xlat_lon_dofs.
ct(), lat_lon_max, 2);
720 #ifdef DIAGNOSTIC_OUTPUT 722 cout <<
"lat_lon_max: " << setw(12) << lat_lon_max[0] << setw(12) << lat_lon_max[1] << endl;
741 #ifdef DIAGNOSTIC_OUTPUT 743 cout <<
"bounding box: " << bbox << endl;
822 #ifdef DIAGNOSTIC_OUTPUT 823 post_information_message(
"Entering update");
846 _boxes.reserve(2*leval_ct);
890 else if(ldisc_ct == 3)
896 post_warning_message(
"Not a bilinear quad or linear triangle.");
918 #ifdef DIAGNOSTIC_OUTPUT 920 post_information_message(
"Leaving update");
932 require(xvalue != 0);
933 require(xvalue_ub >=
dc());
934 require(xresult.
db() >=
db());
955 box_list_type::const_iterator iter;
957 for(iter = blist.
begin(); !xresult.
is_valid() && (iter != blist.
end()); ++iter)
998 ensure(unexecutable(xresult.
is_valid() ?
999 xresult.chart() contains xvalue at xresult.
local_coord() :
1000 no chart contains xvalue));
1014 #ifdef DIAGNOSTIC_OUTPUT 1015 post_information_message(
"Entering all_points_at_value");
1018 require(xvalue != 0);
1019 require(xvalue_ub >=
dc());
1027 define_old_variable(
int old_xresult_ct = xresult.
ct());
1040 box_list_type::const_iterator iter;
1042 for(iter = blist.
begin(); iter != blist.
end(); ++iter)
1060 lchart_pt.local_coords(),
1069 lchart_pt.put_chart_id(bbox->
member_id());
1080 #ifdef DIAGNOSTIC_OUTPUT 1081 cout <<
"result: " << xresult << endl;
1086 ensure_for_all(i, 0, xresult.
ct(), xresult[i].is_valid());
1091 #ifdef DIAGNOSTIC_OUTPUT 1093 post_information_message(
"Leaving all_points_at_value");
1105 #ifdef DIAGNOSTIC_OUTPUT 1106 post_information_message(
"Entering branch_points_at_value");
1109 require(xvalue != 0);
1110 require(xvalue_ub >=
dc());
1115 define_old_variable(
int old_xresult_ct = xresult.
ct());
1133 box_list_type::const_iterator iter;
1135 for(iter = blist.
begin(); iter != blist.
end(); ++iter)
1139 #ifdef DIAGNOSTIC_OUTPUT 1141 cout <<
"considering " << *bbox << endl;
1149 #ifdef DIAGNOSTIC_OUTPUT 1150 cout <<
"Inverting it ... ";
1175 #ifdef DIAGNOSTIC_OUTPUT 1176 cout <<
"valid" << endl;
1190 #ifdef DIAGNOSTIC_OUTPUT 1191 cout <<
"invalid" << endl;
1198 #ifdef DIAGNOSTIC_OUTPUT 1199 cout <<
"Ignoring it" << endl;
1210 #ifdef DIAGNOSTIC_OUTPUT 1212 cout <<
"result: " << xresult << endl;
1217 ensure(xresult.
ct() >= old_xresult_ct);
1218 ensure_for_all(i, old_xresult_ct, xresult.
ct(),
1220 ensure_for_all(i, old_xresult_ct, xresult.
ct(), xresult[i].second.is_valid());
1225 #ifdef DIAGNOSTIC_OUTPUT 1227 post_information_message(
"Leaving branch_points_at_value");
SHEAF_DLL_SPEC void sqrt(const sec_at0 &x0, sec_at0 &xresult, bool xauto_access)
Compute sqrt of x0 (sqrt(x0)) (pre-allocated version).
virtual void update()
Updates the search structure to the current values of coordinates().
void truncate()
Makes this the next member of the subset which is not less than old this, i.e. the depth-first descen...
block< sec_vd_value_type > _one_over_min_bin_size
Reciprocal of the dimensions of the smallest bins.
size_type ct() const
The number of items currently in use.
sec_ed & coordinates() const
The coordinate section this inverts.
const scoped_index & member_id() const
Index of the evaluation member this bounds.
const block< sec_vd_value_type > & bin_size() const
The dimensions of the smallest bins.
void put_lb(const d_bin_coordinates< DC, DB > &xlb)
Copies the contents of xlb to lb().
size_type box_ct() const
The number of bounding boxes stored in the search structure.
A point in a 3D chart space.
virtual void force_is_done()
Force the iterator to be done.
const block< size_type > & bin_ub() const
The upper bound for the bin index.
virtual int db() const =0
The dimension of this chart.
void put_dof_ct(size_type xct)
Sets dof_ct() to xct.
virtual int db() const
The dimension of this chart.
virtual cylindrical_point_locator & operator=(const point_locator &xother)
Assignment operator.
virtual void branch_points_at_value(const sec_vd_value_type *xvalue, size_type xvalue_ub, block< branch_point_pair > &xresult)
Finds one chart point in each branch at which coordinates() has value xvalue and appends them to xres...
std::set< stl_scoped_index<> > _branches
The branches for which a point has already been found for the current evaluation member. Used in all_points_at_value, allocated her to avoid reallocation for each query.
void reserve(index_type xub)
Makes ub() at least xub; if new storage is allocated, it is uninitialized.
eval_iterator _eval_itr
The evaluator iterator used to populate the search structure; must have same life time as the search ...
point_locator()
Default constructor.
void put_chart_id(pod_index_type xchart)
Sets chart_id() to xchart_id.
void update_domain()
Initializes the domain bounds and dimension.
cylindrical_point_locator()
Default constructor; disabled.
host_type * host() const
The poset this is a member of.
block< size_type > _bin_ub
The upper bound for the bin index.
const scoped_index & index() const
The index of the component state this handle is attached to.
virtual void point_at_value(const sec_vd_value_type *xvalue, size_type xvalue_ub, chart_point &xresult)
Finds a chart point at which coordinates() has value xvalue.
virtual bool contains_box(d_bounding_box< 2, 2 > *xbox) const =0
True if xbox is in the box list of some bin.
iterator begin()
Returns an iterator to the first element of the container.
Fixed point relative coordinates for a tree domain.
sec_vd_value_type _bin_0_max
A sec_vd_value_type that truncates to the maximum index for bin 0.
virtual bool in_standard_domain(const dof_type xlocal_coords[], size_type xlocal_coords_ub) const =0
True if the specified local coordinates are in the "standard" domain.
bool is_valid() const
True if this ia a valid point in a chart.
virtual const box_list_type & box_list(sec_vd_value_type *xpt, size_type xpt_ub) const =0
The list of bounding boxes which may contain xpt.
A section of a fiber bundle with a d-dimensional Euclidean vector space fiber.
void relative_position_pa(sec_vd_value_type *xpt, size_type xpt_ub, d_bin_coordinates< 2, 2 > &xresult) const
The position of xpt relative to the lower bound, in integer coordinates; pre-allocated version...
std::pair< scoped_index, chart_point_3d > branch_point_pair
A point in base space paired with a branch in section space.
void invalidate()
Makes this invalid.
const bool NOT_STRICT
Iteration strictness control.
const bool DOWN
Iteration directions.
block< sec_vd_value_type > _bin_size
The dimensions of the smallest bins.
bool contains_point(const d_bin_coordinates< DC, DB > &xpt) const
True if this contains point xpt.
virtual coord_type * local_coords()=0
The array of local coordinates.
size_type dof_ct() const
The number of dofs in the gathered dofs array for the evaluation member this bounds.
void push_back(const_reference_type item)
Insert item at the end of the items in the auto_block.
virtual dof_type max(const dof_type xdofs[], size_type xdofs_ub) const
The maximum value of the scalar or component section defined by xdofs.
size_type dofs_index() const
Index into the gathered dofs array for the evaluation member this bounds.
pointer_type base() const
The underlying storage array.
virtual ~cylindrical_point_locator()
Destructor.
void put_schema_anchor(const section_space_schema_member &xschema_anchor)
Set schema_anchor() to the same state as xschema_anchor.
void set_ct(size_type xct)
Sets ct() == xct.
void put_member_id(const scoped_index &xid)
Sets member_id() to xid.
An index within the external ("client") scope of a given id space.
block< sec_vd_dof_type > _gathered_dofs
The dofs of gathered by evaluation member.
virtual void remove_box(d_bounding_box< 2, 2 > *xbox)=0
Remove xbox from the search structure.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
A bounding box that can be strung together into a list.
SHEAF_DLL_SPEC void atan2(const sec_at0 &x0, const sec_at0 &x1, sec_at0 &xresult, bool xauto_access)
Compute atan2 of x0/x1 (atan2(x0, x1)) (pre-allocated version).
virtual void all_points_at_value(const sec_vd_value_type *xvalue, size_type xvalue_ub, block< chart_point_3d > &xresult)
Finds all chart points at which coordinates() has value xvalue and appends them to xresult...
void insert_triangle(block< sec_vd_dof_type > &xdofs, const scoped_index &xbranch_id, const scoped_index &xeval_id)
Creates the bounding box or boxes for the triangle defined by the dofs starting at xdofs and inserts ...
virtual void coord_at_value(const dof_type xdofs[], size_type xdofs_ub, const dof_type xvalue[], size_type xvalue_ub, dof_type xlocal_coords[], size_type xlocal_coords_ub) const =0
The local coordinates of a point at which the field has the value xvalue. The dofs are assumed to be ...
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. ...
d_bin_coordinates< 2, 2 > * relative_position(sec_vd_value_type *xpt, size_type xpt_ub) const
The position of xpt relative to the lower bound, in integer coordinates; auto-allocated version...
void put_dofs_index(size_type xindex)
Sets dofs_index() to xindex.
void make_triangle_bounding_box(block< sec_vd_dof_type > &xlat_lon_dofs, const scoped_index &xbranch_id, const scoped_index &xeval_id)
Makes a bounding box for a triangle.
void next()
Makes this the next member of the subset.
void xyz_to_lat_lon(const sec_vd_dof_type xcartesian[3], sec_vd_dof_type xresult[2])
Converts cartesian coordinates xcartesian to (longitude, latitude) xresult.
iterator end()
Returns an iterator to the element following the last element of the container.
An abstract local section evaluator; a map from {local coordinates x dofs} to section value...
coord_type * local_coords()
The array of local coordinates.
A section of a fiber bundle with a d-dimensional vector space fiber.
section_evaluator * evaluator() const
Evaluator for the evaluation member this bounds.
virtual void insert_box(d_bounding_box< 2, 2 > *xbox)=0
Insert xbox into the search structure.
bool is_done() const
True if iteration finished.
An abstract point location query in domains with global coordinate dimension dc and local coordinate ...
void detach_from_state()
Detaches field from state it is currently attached to.
size_type _box_ct
The number of bounding boxes stored in the search structure.
void put_evaluator(section_evaluator *xevaluator)
Sets evaluator() to xevaluator.
int db() const
The intrinsic dimension of the domain; the dimension of the local coordinates.
virtual void reset(bool xreset_markers=true)
Restarts the iteration over the down set of anchor().
virtual dof_type min(const dof_type xdofs[], size_type xdofs_ub) const
The minimum value of the scalar or component section defined by xdofs.
void put_ub(const d_bin_coordinates< DC, DB > &xub)
Copies the contents of xub to ub().
virtual section_space_schema_member & schema()
The restricted schema for this (mutable version).
A section evaluator using linear interpolation over a triangular 2D domain.
SHEAF_DLL_SPEC void acos(const sec_at0 &x0, sec_at0 &xresult, bool xauto_access)
Compute acos of x0 (acos(x0)) (pre-allocated version).
int dc() const
The spatial dimension of the domain; the dimension of the global coordinates.
const scoped_index & branch_id() const
Index of the branch that contains the evaluation member this bounds.
int evaluation_ct() const
The number of members in the intersection of the evaluation subposet and the down set of the base spa...
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 ...
virtual void update_bins()=0
Updates the bin parameters.
block< d_bounding_box< 2, 2 > > _boxes
Bounding boxes for the evaluation members.
bool is_empty() const
True if this contains no bounding boxes.
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.
void put_branch_id(const scoped_index &xid)
Sets branch_id() to xid.
double sec_vd_dof_type
The type of degree of freedom in the section space.
block< scoped_index > & discretization_members()
The discretization members in the downset of the current evaluation member (mutable version)...
An auto_block with a no-initialization initialization policy.
Namespace for geometry component of sheaf system.
A section evaluator using bilinear interpolation over a square 2D domain.
vd_value_type sec_vd_value_type
The type of component in the value of a section at a point.
SHEAF_DLL_SPEC pod_index_type invalid_pod_index()
The invalid pod index value.
virtual bool invariant() const
Class invariant.
virtual coord_type local_coord(int xi) const =0
The xi-th local coordinate of this point.
void insert_quad(block< sec_vd_dof_type > &xdofs, const scoped_index &xbranch_id, const scoped_index &xeval_id)
Creates the bounding box or boxes for the quad defined by the dofs starting at xdofs and inserts them...
void make_quad_bounding_box(block< sec_vd_dof_type > &xlat_lon_dofs, const scoped_index &xbranch_id, const scoped_index &xeval_id)
Makes a bounding box for a quad.
Wrapper class for forward_list or slist depending on compiler. The class replicates the minimum subse...
An abstract point location query in domains with global coordinate dimension dc and local coordinate ...
virtual void clear()=0
Clear the search structure of all bounding boxes.
const scoped_index & index() const
The index of the current member of the iteration.