SheafSystem  0.0.0.0
d_uniform_point_locator.impl.h
Go to the documentation of this file.
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
20 
21 #ifndef D_UNIFORM_POINT_LOCATOR_IMPL_H
22 #define D_UNIFORM_POINT_LOCATOR_IMPL_H
23 
24 #ifndef SHEAF_DLL_SPEC_H
25 #include "SheafSystem/sheaf_dll_spec.h"
26 #endif
27 
28 
29 #ifndef D_UNIFORM_POINT_LOCATOR_H
30 #include "SheafSystem/d_uniform_point_locator.h"
31 #endif
32 
33 #ifndef ASSERT_CONTRACT_H
34 #include "SheafSystem/assert_contract.h"
35 #endif
36 
37 #ifndef CHART_POINT_1D_H
38 #include "SheafSystem/chart_point_1d.h"
39 #endif
40 
41 #ifndef CHART_POINT_2D_H
42 #include "SheafSystem/chart_point_2d.h"
43 #endif
44 
45 #ifndef CHART_POINT_3D_H
46 #include "SheafSystem/chart_point_3d.h"
47 #endif
48 
49 #ifndef SEC_AT1_SPACE_H
50 #include "SheafSystem/sec_at1_space.h"
51 #endif
52 
53 #ifndef SEC_ED_H
54 #include "SheafSystem/sec_ed.h"
55 #endif
56 
57 #ifndef STRUCTURED_BLOCK_1D_H
58 #include "SheafSystem/structured_block_1d.h"
59 #endif
60 
61 #ifndef STRUCTURED_BLOCK_2D_H
62 #include "SheafSystem/structured_block_2d.h"
63 #endif
64 
65 #ifndef STRUCTURED_BLOCK_3D_H
66 #include "SheafSystem/structured_block_3d.h"
67 #endif
68 
69 #ifndef UNIFORM_1D_H
70 #include "SheafSystem/uniform_1d.h"
71 #endif
72 
73 #ifndef UNIFORM_2D_H
74 #include "SheafSystem/uniform_2d.h"
75 #endif
76 
77 #ifndef UNIFORM_3D_H
78 #include "SheafSystem/uniform_3d.h"
79 #endif
80 
81 //#undef DIAGNOSTIC_OUTPUT
82 //#define DIAGNOSTIC_OUTPUT
83 
84 namespace geometry
85 {
86 
87 // ===========================================================
88 // D_UNIFORM_POINT_LOCATOR FACET
89 // ===========================================================
90 
91 // PUBLIC MEMBER FUNCTIONS
92 
93 template <int DC, int DB>
96 {
97  // Preconditions:
98 
99  // Body:
100 
101  _block->detach_from_state();
102  delete _block;
103 
104  delete _block_pt;
105 
106  delete _evaluator;
107 
108 
109  // Postconditions:
110 
111  // Exit:
112 
113  return;
114 }
115 
116 template <int DC, int DB>
117 bool
119 invariant() const
120 {
121  bool result = true;
122 
123 
124  return result;
125 }
126 
127 
128 // PROTECTED MEMBER FUNCTIONS
129 
130 template <int DC, int DB>
134 {
135  sec_vd_value_type result = xcomp;
136 
137  if(xcomp == xupper_bound)
138  {
139  // The coordinate to be inverted matches the domain upper bound;
140  // make sure it is strictly less than the bound.
141 
142  result = xcomp*(1.0 - std::numeric_limits<sec_vd_value_type>::epsilon());
143  }
144 
145  return result;
146 }
147 
148 
149 // ===========================================================
150 // POINT_LOCATOR FACET
151 // ===========================================================
152 
153 // PUBLIC MEMBER FUNCTIONS
154 
155 template <int DC, int DB>
156 void
159 {
160  // Preconditions:
161 
162  require(this->coordinates().state_is_read_accessible());
163 
164  // Body:
165 
166  this->update_domain();
167 
168  _dofs = reinterpret_cast<sec_vd_dof_type*>(coordinates().dof_map().dof_tuple());
169  _dof_ct = coordinates().dof_map().dof_ct();
170 
171  // Postconditions:
172 
173 
174  // Exit:
175 
176  return;
177 }
178 
179 template <int DC, int DB>
180 void
183  size_type xvalue_ub,
184  chart_point& xresult)
185 {
186  require(xvalue != 0);
187  require(xvalue_ub >= this->dc());
188  require(xresult.db() >= this->db());
189 
190  // Body:
191 
192  // Clip the value against the upper bound to make sure
193  // point on boundary is considered inside.
194  // Also initialize _block_pt.
195 
199 
200  for(int i=0; i<DC; ++i)
201  {
202  _clipped_value[i] = clip_component(xvalue[i], ub()[i]);
203  }
204 
205  _block_pt->put_local_coords_zero();
206  _block_pt->put_chart_id(_block->index());
207 
208  _evaluator->coord_at_value(_dofs,
209  _dof_ct,
210  _clipped_value,
211  DC,
212  _block_pt->local_coords(),
213  _block_pt->db());
214 
215  // If the local coordinates are in the "standard" domain of the
216  // evaluator, then we have a valid chart point. Otherwise, just
217  // return a chard id of "NOT_AN_INDEX".
218 
219  if(_evaluator->in_standard_domain(_block_pt->local_coords(), _block_pt->db()))
220  {
221  // Local coordinates are in the standard domain of the evaluator.
222  // Block point is valid; result is refinement.
223 
224  _block->refine_point_pa(*_block_pt, xresult);
225  }
226  else
227  {
228  // No valid point at the given value.
229 
230  xresult.invalidate();
231  }
232 
233  // Postconditions:
234 
235  ensure(unexecutable(xresult.is_valid() ?
236  xresult.chart() contains xvalue at xresult.local_coord() :
237  no chart contains xvalue));
238 
239 
240  // Exit:
241 
242  return;
243 }
244 
245 template <int DC, int DB>
246 void
249  size_type xvalue_ub,
250  block<chart_point_3d>& xresult)
251 {
252  require(xvalue != 0);
253  require(xvalue_ub >= this->dc());
254  require(this->db() <= 3);
255 
256  // Body:
257 
258  define_old_variable(int old_xresult_ct = xresult.ct());
259 
260  // Clip the value against the upper bound to make sure
261  // point on boundary is considered inside.
262  // Also initialize _block_pt.
263 
267 
268  for(int i=0; i<DC; ++i)
269  {
270  _clipped_value[i] = clip_component(xvalue[i], ub()[i]);
271  }
272 
273  _block_pt->put_local_coords_zero();
274  _block_pt->put_chart_id(_block->index());
275 
276  _evaluator->coord_at_value(_dofs,
277  _dof_ct,
278  _clipped_value,
279  DC,
280  _block_pt->local_coords(),
281  _block_pt->db());
282 
283  // If the local coordinates are in the "standard" domain of the
284  // evaluator, then we have a valid chart point. Otherwise, just
285  // return a chard id of "NOT_AN_INDEX".
286 
287  if(_evaluator->in_standard_domain(_block_pt->local_coords(), _block_pt->db()))
288  {
289  // Local coordinates are in the standard domain of the evaluator.
290  // Block point is valid; result is refinement.
291 
292  _block->refine_point_pa(*_block_pt, xresult);
293  }
294  else
295  {
296  // No valid point at the given value; do nothing
297  }
298 
299  // Postconditions:
300 
301  ensure(xresult.ct() >= old_xresult_ct);
302  ensure_for_all(i, old_xresult_ct, xresult.ct(), xresult[i].is_valid());
303 
304 
305  // Exit:
306 
307  return;
308 }
309 
310 template <int DB, int DC>
311 void
314  size_type xvalue_ub,
315  block<branch_point_pair>& xresult)
316 {
317  require(xvalue != 0);
318  require(xvalue_ub >= this->dc());
319  require(this->dc() <= 3);
320 
321  // Body:
322 
323  define_old_variable(int old_xresult_ct = xresult.ct());
324 
325  branch_point_pair lbranch_pt;
326  scoped_index& lbranch_id = lbranch_pt.first;
327  chart_point_3d& lpt = lbranch_pt.second;
328 
329  lbranch_id = coordinates().index();
330  point_at_value(xvalue, xvalue_ub, lpt);
331 
332  xresult.push_back(lbranch_pt);
333 
334  // Postconditions:
335 
336  ensure(xresult.ct() == old_xresult_ct + 1);
337  ensure_for_all(i, old_xresult_ct, xresult.ct(),
338  coordinates().host()->contains_member(xresult[i].first, false));
339  ensure_for_all(i, old_xresult_ct, xresult.ct(), xresult[i].second.is_valid());
340 
341 
342  // Exit:
343 
344  return;
345 }
346 
347 
348 // ===========================================================
349 // NON-MEMBER FUNCTIONS
350 // ===========================================================
351 
352 } // namespace geometry
353 
354 #endif // D_UNIFORM_POINT_LOCATOR_IMPL_H
size_type ct() const
The number of items currently in use.
A point in a 3D chart space.
virtual int db() const =0
The dimension of this chart.
Definition: chart_point.cc:141
A point in chart space.
Definition: chart_point.h:52
bool is_valid() const
True if this ia a valid point in a chart.
Definition: chart_point.cc:303
std::pair< scoped_index, chart_point_3d > branch_point_pair
A point in base space paired with a branch in section space.
Definition: geometry.h:79
void invalidate()
Makes this invalid.
Definition: chart_point.cc:322
void push_back(const_reference_type item)
Insert item at the end of the items in the auto_block.
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...
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...
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
sec_vd_value_type clip_component(sec_vd_value_type xcomp, sec_vd_value_type xupper_bound)
Ensures that xcomp is strictly less than xupper_bound.
virtual bool invariant() const
Class invariant.
virtual void point_at_value(const sec_vd_value_type *xvalue, size_type xvalue_ub, chart_point &xresult)
Finds the chart point at which coordinates() has value xvalue.
double sec_vd_dof_type
The type of degree of freedom in the section space.
Definition: fiber_bundle.h:78
An auto_block with a no-initialization initialization policy.
Namespace for geometry component of sheaf system.
Definition: field_vd.h:54
vd_value_type sec_vd_value_type
The type of component in the value of a section at a point.
Definition: fiber_bundle.h:73
virtual coord_type local_coord(int xi) const =0
The xi-th local coordinate of this point.
Definition: chart_point.cc:163
virtual void update()
Updates the search structure to the current values of coordinates().