SheafSystem  0.0.0.0
structured_block_3d.cc
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 #include "SheafSystem/structured_block_3d.h"
22 
23 #include "SheafSystem/assert_contract.h"
24 #include "SheafSystem/arg_list.h"
25 //#include "SheafSystem/base_space_member_prototype.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"
33 
34 using namespace fiber_bundle; // Workaround for MS C++ bug.
35 
36 // ===========================================================
37 // HOST FACTORY FACET
38 // ===========================================================
39 
40 // PUBLIC DATA MEMBERS
41 
42 const sheaf::poset_path&
45 {
46 
47  // Preconditions:
48 
49  // Body:
50 
51  static const poset_path
52  STATIC_PROTOTYPE_PATH(base_space_member::prototypes_poset_name(), "structured_block_3d");
53 
54  const poset_path& result = STATIC_PROTOTYPE_PATH;
55 
56  // Postconditions:
57 
59  ensure(result.member_name() == "structured_block_3d");
60 
61  // Exit
62 
63  return result;
64 }
65 
68 new_host(namespace_type& xns, const poset_path& xhost_path, const poset_path& xschema_path, bool xauto_access)
69 {
70  // cout << endl << "Entering structured_block_3d::new_host." << endl;
71 
72  // Preconditions:
73 
74  require(xns.state_is_auto_read_write_accessible(xauto_access));
75 
76  require(!xhost_path.empty());
77  require(!xns.contains_path(xhost_path, xauto_access));
78 
79  require(xschema_path.full());
80  require(xns.path_is_auto_read_accessible(xschema_path, xauto_access));
81  require(schema_poset_member::conforms_to(xns, xschema_path, standard_schema_path(), xauto_access));
82 
83  // Body:
84 
85  host_type& result =
86  host_type::new_table(xns, xhost_path, xschema_path, 3, xauto_access);
87 
88  // Postconditions:
89 
90  ensure(xns.owns(result, xauto_access));
91  ensure(result.path(true) == xhost_path);
92  ensure(result.state_is_not_read_accessible());
93  ensure(result.schema(true).path(xauto_access) == xschema_path);
94 
95  ensure(result.max_db() == 3);
96 
97  // Exit:
98 
99  // cout << "Leaving structured_block_3d::new_host." << endl;
100  return result;
101 }
102 
105 standard_host(namespace_type& xns, const poset_path& xhost_path, bool xauto_access)
106 {
107  // cout << endl << "Entering structured_block_3d::standard_host." << endl;
108 
109  // Preconditions:
110 
111  require(xns.state_is_auto_read_write_accessible(xauto_access));
112 
113  require(poset_path::is_valid_name(xhost_path.poset_name()));
114  require(xns.path_is_auto_read_write_available<host_type>(xhost_path.poset_name(), xauto_access));
115 
116  require(xns.path_is_auto_read_accessible(standard_schema_path(), xauto_access));
117 
118  // Body:
119 
120  host_type* result_ptr;
121  if(xns.contains_path(xhost_path.poset_name(), xauto_access))
122  {
123  result_ptr = &xns.member_poset<host_type>(xhost_path, xauto_access);
124  }
125  else
126  {
127  result_ptr = &new_host(xns, xhost_path, standard_schema_path(), xauto_access);
128  }
129 
130  host_type& result = *result_ptr;
131 
132  // Postconditions:
133 
134  ensure(xns.owns(result, xauto_access));
135  ensure(result.path(true) == xhost_path);
136  ensure(result.state_is_not_read_accessible());
137  ensure(result.schema(true).path(xauto_access) == standard_schema_path());
138 
139  ensure(result.max_db() == 3);
140 
141  // Exit:
142 
143  // cout << "Leaving structured_block_3d::standard_host." << endl;
144  return result;
145 }
146 
147 // PROTECTED DATA MEMBERS
148 
149 // PRIVATE DATA MEMBERS
150 
151 
152 // ===========================================================
153 // STRUCTURED_BLOCK_3D FACET
154 // ===========================================================
155 
156 // PUBLIC DATA MEMBERS
157 
160 {
161  // Preconditions:
162 
163  // Body:
164 
165  // Postconditions:
166 
167  ensure(invariant());
168  ensure(! is_attached() );
169 }
170 
172 structured_block_3d(const abstract_poset_member& xother, bool xnew_jem)
173 {
174  // Preconditions:
175 
176  require(xnew_jem ? xother.is_attached() : true);
177 
178  // Body:
179 
180  if(xnew_jem)
181  {
182  new_jem_state(const_cast<abstract_poset_member*>(&xother), true, true);
183  }
184  else
185  {
186  attach_to_state(const_cast<abstract_poset_member*>(&xother));
187  }
188 
189  // postconditions:
190 
191  ensure(invariant());
192  ensure(is_attached() == const_cast<abstract_poset_member&>(xother).is_attached() );
193 }
194 
197 {
198  // Preconditions:
199 
200  // Body:
201 
202  // Exit
203 
204  return;
205 }
206 
207 // NEW HANDLE, NEW STATE CONSTRUCTORS:
208 
211  const size_type& xi_size,
212  const size_type& xj_size,
213  const size_type& xk_size,
214  bool xauto_access)
215 {
216 
217  // Preconditions:
218 
219  require(precondition_of(new_state(same args)));
220 
221  // Body:
222 
223  new_state(xhost, xi_size, xj_size, xk_size, xauto_access);
224 
225  // Postconditions:
226 
227  ensure(postcondition_of(new_state(same args)));
228 
229  // Exit:
230 
231  return;
232 }
233 
234 // NEW HANDLE, EXISTING STATE CONSTRUCTORS:
235 
238 {
239  // Preconditions:
240 
241  require(precondition_of(attach_to_state(xhost, xhub_id)));
242 
243  // Body:
244 
245  attach_to_state(xhost, xhub_id);
246 
247  // Postconditions:
248 
249  ensure(postcondition_of(attach_to_state(xhost, xhub_id)));
250 }
251 
253 structured_block_3d(const poset* xhost, const scoped_index& xid)
254 {
255  // Preconditions:
256 
257  require(precondition_of(attach_to_state(xhost, xid)));
258 
259  // Body:
260 
261  attach_to_state(xhost, xid.hub_pod());
262 
263  // Postconditions:
264 
265  ensure(postcondition_of(attach_to_state(xhost, xid)));
266 }
267 
269 structured_block_3d(const poset* xhost, const std::string& xname)
270 {
271  // Preconditions:
272 
273  require(precondition_of(attach_to_state(same args)));
274 
275  // Body:
276 
277  attach_to_state(xhost, xname);
278 
279  // Postconditions:
280 
281  ensure(postcondition_of(attach_to_state(same args)));
282 }
283 
286  const poset_path& xpath,
287  bool xauto_access)
288 {
289  // Preconditions:
290 
292 
293  require(precondition_of(attach_to_state(same args)));
294 
295  // Body:
296 
297  attach_to_state(xnamespace, xpath, xauto_access);
298 
299  // Postconditions:
300 
301  ensure(postcondition_of(attach_to_state(same args)));
302 
303  // Exit:
304 
305  return;
306 }
307 
310  pod_index_type xposet_id,
311  pod_index_type xmember_id)
312 {
313  // Preconditions:
314 
316 
317  require(precondition_of(attach_to_state(same args)));
318 
319  // Body:
320 
321  attach_to_state(xnamespace, xposet_id, xmember_id);
322 
323  // Postconditions:
324 
325  ensure(postcondition_of(attach_to_state(same args)));
326 
327  // Exit:
328 
329  return;
330 }
331 
334  const scoped_index& xposet_id,
335  const scoped_index& xmember_id)
336 {
337  // Preconditions:
338 
340 
341  require(precondition_of(attach_to_state(same args)));
342 
343  // Body:
344 
345  attach_to_state(xnamespace, xposet_id.hub_pod(), xmember_id.hub_pod());
346 
347  // Postconditions:
348 
349  ensure(postcondition_of(attach_to_state(same args)));
350 
351  // Exit:
352 
353  return;
354 }
355 
356 // EXISTING HANDLE, NEW STATE "CONSTRUCTORS":
357 
358 void
360 new_state(const size_type& xi_size,
361  const size_type& xj_size,
362  const size_type& xk_size,
363  bool xauto_access)
364 {
365  // Preconditions:
366 
367  require(precondition_of(new_state(host(), xi_size, xj_size, xk_size, xauto_access)));
368 
369  // Body:
370 
371  new_state(host(), xi_size, xj_size, xk_size, xauto_access);
372 
373  // Postconditions:
374 
375  ensure(postcondition_of(new_state(host(), xi_size, xj_size, xk_size, xauto_access)));
376 
377  // Exit:
378 
379  return;
380 }
381 
382 void
385  const size_type& xi_size,
386  const size_type& xj_size,
387  const size_type& xk_size,
388  bool xauto_access)
389 {
390  // Preconditions:
391 
392  require(xhost != 0);
393  require(xauto_access ? xhost->is_attached() : xhost->in_jim_edit_mode());
394  require(xauto_access || xhost->name_space()->state_is_read_accessible());
395  require(xhost->name_space()->contains_poset_member(static_prototype_path(), true));
396  require(xauto_access || xhost->name_space()->member_poset(prototypes_poset_name(), true).state_is_read_accessible());
397 
398  // Get access if auto access is requested. Need to do it here so the
399  // remaining preconditions can be executed.
400 
401  if(xauto_access)
402  {
403  xhost->begin_jim_edit_mode(true);
404  xhost->name_space()->get_read_access();
405  xhost->name_space()->member_poset(prototypes_poset_name(), false).get_read_access();
406  }
407 
408  require(namespace_is_ancestor_of(xhost->name_space()));
409  require(xhost->schema().row_conforms_to(standard_schema_path()));
410 
412 
413  require(dynamic_cast<base_space_poset*>(xhost) != 0);
414 
415  // Body:
416 
417  base_space_poset* lhost = dynamic_cast<base_space_poset*>(xhost);
418 
419  // Get the size for the interval.
420 
421  size_type lsize;
422  structured_block_3d_crg_interval::get_size(xi_size, xj_size, xk_size, lsize);
423 
424  // Get the dof tuple_ids.
425 
426  block<pod_index_type> ldof_tuple_ids;
427  structured_block_3d_crg_interval::get_dof_tuple_ids(*xhost, xi_size, xj_size, xk_size, ldof_tuple_ids);
428 
429  // Get the private data for the interval
430 
431  block<pod_index_type> ldata;
432  structured_block_3d_crg_interval::get_private_data(xi_size, xj_size, xk_size, ldata);
433 
434  // Create the implicit crg interval for the block.
435 
436  pod_index_type lindex =
437  lhost->new_member_interval("structured_block_3d_crg_interval", lsize, ldof_tuple_ids, ldata);
438 
439  // Attach this handle to it.
440 
441  attach_to_state(lhost, lindex);
442 
443  // Block is linked to bottom via implicit lower cover of vertices,
444  // but not linked to top; link it now.
445 
446  lhost->top().create_cover_link(this);
447 
448  // Postconditions:
449 
450  ensure(invariant());
451  ensure(host() == xhost);
452  ensure(is_attached());
453  ensure(db() == 3);
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);
459 
460  // Release access if auto access was requested.
461 
462  if(xauto_access)
463  {
464  xhost->name_space()->member_poset(prototypes_poset_name(), false).release_access();
465  xhost->name_space()->release_access();
466 
467  // End jim edit mode without ensure_lattice_invariant;
468  // the check is unnecessary and expensive.
469 
470  xhost->end_jim_edit_mode(false, true);
471  }
472 
473  // Exit:
474 
475  return;
476 }
477 
478 // FEATURES:
479 
482 i_size() const
483 {
484  // Preconditions:
485 
486  require(state_is_read_accessible());
487 
488  // Body:
489 
490  size_type result = interval().i_size();
491 
492  // Postconditions:
493 
494  // Exit
495 
496  return result;
497 }
498 
501 j_size() const
502 {
503  // Preconditions:
504 
505  require(state_is_read_accessible());
506 
507  // Body:
508 
509  size_type result = interval().j_size();
510 
511  // Postconditions:
512 
513  // Exit
514 
515  return result;
516 }
517 
520 k_size() const
521 {
522  // Preconditions:
523 
524  require(state_is_read_accessible());
525 
526  // Body:
527 
528  size_type result = interval().k_size();
529 
530  // Postconditions:
531 
532  // Exit
533 
534  return result;
535 }
536 
537 // PROTECTED DATA MEMBERS
538 
542  size_type xi_size,
543  size_type xj_size,
544  size_type xk_size,
545  bool xauto_access)
546 {
547  // Preconditions:
548 
549  require(xhost.state_is_auto_read_write_accessible(xauto_access));
550  require(xauto_access || xhost.name_space()->poset_state_is_read_accessible(static_prototype_path()));
551  require(xhost.name_space()->contains_poset_member(static_prototype_path()));
552  require(xhost.name_space()->contains_poset_member(static_local_cell_prototype_path()));
553 
554  // Body:
555 
556  if(xauto_access)
557  {
558  xhost.get_read_write_access();
559  }
560 
561  define_old_variable(int old_xhost_row_dof_tuple_ct = xhost.row_dof_tuple_ct());
562 
563  // Create the dof map and set dofs to defaults.
564 
565  scoped_index result = xhost.new_row_dof_map();
566  row_dof_tuple_type* ltuple =
567  reinterpret_cast<row_dof_tuple_type*>(xhost.row_dof_map(result, true).dof_tuple());
568 
569  // Get the block prototype.
570 
571  base_space_member lproto(xhost.name_space(), static_prototype_path(), xauto_access);
572 
573  // Get the local cell prototype.
574 
575  base_space_member local_proto(xhost.name_space(), static_local_cell_prototype_path(), xauto_access);
576 
577  // Copy the dofs from the prototypes..
578 
579  ltuple->db = lproto.db();
580  ltuple->type_id = lproto.type_id();
581  ltuple->type_name = strdup(lproto.type_name());
582  ltuple->refinement_depth = lproto.refinement_depth();
583  ltuple->local_cell_type_id = local_proto.type_id();
584  ltuple->local_cell_type_name = strdup(local_proto.type_name());
585  ltuple->size = xi_size*xj_size*xk_size;
586  ltuple->i_size = xi_size;
587  ltuple->j_size = xj_size;
588  ltuple->k_size = xk_size;
589 
590  // Release the prototypes.
591 
592  local_proto.detach_from_state();
593  lproto.detach_from_state();
594 
595  if(xauto_access)
596  {
597  xhost.release_access();
598  }
599 
600  // Postconditions:
601 
602  ensure(xhost.row_dof_tuple_ct() == old_xhost_row_dof_tuple_ct + 1);
603 
604  // Exit:
605 
606  return result;
607 }
608 
609 // PRIVATE DATA MEMBERS
610 
611 #define NODE_ID(i, j, k) (((i)*node_ct_y + (j))*node_ct_z + (k))
612 
613 
614 // ===========================================================
615 // STRUCTURED_BLOCK FACET
616 // ===========================================================
617 
618 // PUBLIC DATA MEMBERS
619 
620 // PROTECTED DATA MEMBERS
621 
622 // PRIVATE DATA MEMBERS
623 
624 
625 // ===========================================================
626 // LOCAL_BASE_SPACE_MEMBER FACET
627 // ===========================================================
628 
629 // PUBLIC DATA MEMBERS
630 
631 void
633 refine_point_pa(const chart_point& xpt, chart_point& result) const
634 {
635  // Preconditions:
636 
637  require(state_is_read_accessible());
638 
639  require(xpt.chart_id() == index().pod());
640 
641  // See comment at structured_block::refine_point_pa.
642 
643  require(xpt.db() >= db());
644  require(result.db() >= db());
645 
646  // Body:
647 
648 
649  // Transform to zone-local coordinates..
650 
651  chart_point_coord_type lu_coord = xpt.local_coords()[0];
652  scoped_index::pod_type lu_chart_id;
653  refine_coordinate(lu_coord, lu_chart_id, i_size());
654 
655  chart_point_coord_type lv_coord = xpt.local_coords()[1];
656  scoped_index::pod_type lv_chart_id;
657  refine_coordinate(lv_coord, lv_chart_id, j_size());
658 
659  chart_point_coord_type lw_coord = xpt.local_coords()[2];
660  scoped_index::pod_type lw_chart_id;
661  refine_coordinate(lw_coord, lw_chart_id, k_size());
662 
663  // Compute chart sequence id from components.
664 
665  pod_index_type lref_chart_id = offset(lu_chart_id, lv_chart_id, lw_chart_id);
666 
667  // Convert sequence id to poset id and store result.
668 
669  result.put_chart_id(_elements_id_space->hub_pod(lref_chart_id));
670  result.put_local_coord(0, lu_coord);
671  result.put_local_coord(1, lv_coord);
672  result.put_local_coord(2, lw_coord);
673 
674  // Postconditions:
675 
676  // see $$ISSUE at structured_block::unrefine_pt_pa.
677  // ensure(covers(result.chart_id()));
678 
679  // Exit:
680 
681  return;
682 }
683 
684 void
687 {
688  // Preconditions:
689 
690  require(state_is_read_accessible());
691 
692  require(xpt.chart_id() == index().pod());
693 
694  // See comment at structured_block::refine_point_pa.
695 
696  require(xpt.db() >= db());
697 
698  // Body:
699 
700  // Transform to zone-local coordinates..
701 
702  chart_point_coord_type lu_coord = xpt.local_coords()[0];
703  scoped_index::pod_type lu_chart_id;
704  refine_coordinate(lu_coord, lu_chart_id, i_size());
705 
706  chart_point_coord_type lv_coord = xpt.local_coords()[1];
707  scoped_index::pod_type lv_chart_id;
708  refine_coordinate(lv_coord, lv_chart_id, j_size());
709 
710  chart_point_coord_type lw_coord = xpt.local_coords()[2];
711  scoped_index::pod_type lw_chart_id;
712  refine_coordinate(lw_coord, lw_chart_id, k_size());
713 
714  // Compute chart sequence id from components.
715 
716  pod_index_type lref_chart_id = offset(lu_chart_id, lv_chart_id, lw_chart_id);
717 
718  // Convert sequence id to poset id and store result.
719 
720  chart_point_3d lref_pt(_elements_id_space->hub_pod(lref_chart_id),
721  lu_coord, lv_coord, lw_coord);
722  result.set_ct(0);
723  result.push_back(lref_pt);
724 
725  // The computation above computes a sort of "principal value"
726  // chart point: if xpt is on the boundary between two zones,
727  // refine_coordinate always returns the coordinate lower bound
728  // in the greater zone. Since zones are closed and share boundaries,
729  // a point on a boundary is really in multiple zones. To return
730  // all the zones a point is in we have to figure out if it is on a
731  // boundary and if so, which boundary it is on. Then we have to
732  // generate the chart points for all the neighboring zones which
733  // contain the boundary. To do this, we first compute a 3 bit code:
734  // bit 0 = is on u boundary, bit 1 = is on v boundary, bit 2 = is on w boundary.
735  // Then we test the code to generate the appropriate chart points.
736 
737 
738  unsigned int lbit_code = 0;
739 
740  if(is_close_enough(lu_coord, -1.0) && (lu_chart_id > 0))
741  {
742  // Point is on an u-boundary.
743 
744  lbit_code |= static_cast<unsigned int>(1);
745  }
746 
747  if(is_close_enough(lv_coord, -1.0) && (lv_chart_id > 0))
748  {
749  // Point is on a v-boundary.
750 
751  lbit_code |= static_cast<unsigned int>(2);
752  }
753 
754  if(is_close_enough(lw_coord, -1.0) && (lw_chart_id > 0))
755  {
756  // Point is on a w-boundary.
757 
758  lbit_code |= static_cast<unsigned int>(4);
759  }
760 
761 
762  // Consider the "principal value" chart to be in the u > 0, v > 0, w > 0 octant.
763 
764  if((lbit_code & 1) == 1)
765  {
766  // Point is on the u = 0 face; return the u < 0, v > 0, w > 0 zone.
767 
768  --lu_chart_id;
769  lref_chart_id = offset(lu_chart_id, lv_chart_id, lw_chart_id);
770 
771  // Convert sequence id to poset id and store result.
772 
773  lref_pt.put(_elements_id_space->hub_pod(lref_chart_id),
774  1.0, lv_coord, lw_coord);
775  result.push_back(lref_pt);
776  }
777 
778  if((lbit_code & 2) == 2)
779  {
780  // Point is on the v = 0 face; return the u > 0, v < 0, w > 0 zone.
781 
782  --lv_chart_id;
783  lref_chart_id = offset(lu_chart_id, lv_chart_id, lw_chart_id);
784 
785  // Convert sequence id to poset id and store result.
786 
787  lref_pt.put(_elements_id_space->hub_pod(lref_chart_id),
788  lu_coord, 1.0, lw_coord);
789  result.push_back(lref_pt);
790  }
791 
792  if((lbit_code & 3) == 3)
793  {
794  // Point is on the u= 0, v = 0 edge; return the u < 0, v < 0, w > 0 zone.
795 
796  --lu_chart_id;
797  --lv_chart_id;
798  lref_chart_id = offset(lu_chart_id, lv_chart_id, lw_chart_id);
799 
800  // Convert sequence id to poset id and store result.
801 
802  lref_pt.put(_elements_id_space->hub_pod(lref_chart_id),
803  1.0, 1.0, lw_coord);
804  result.push_back(lref_pt);
805  }
806 
807  if((lbit_code & 4) == 4)
808  {
809  // Point is on the w = 0 face; return the u > 0, v > 0, w < 0 zone.
810 
811  --lw_chart_id;
812  lref_chart_id = offset(lu_chart_id, lv_chart_id, lw_chart_id);
813 
814  // Convert sequence id to poset id and store result.
815 
816  lref_pt.put(_elements_id_space->hub_pod(lref_chart_id),
817  lu_coord, lv_coord, 1.0);
818  result.push_back(lref_pt);
819  }
820 
821  if((lbit_code & 5) == 5)
822  {
823  // Point is on the u = 0, w = 0 edge; return the u < 0, v > 0, w < 0 zone.
824 
825  --lu_chart_id;
826  --lw_chart_id;
827  lref_chart_id = offset(lu_chart_id, lv_chart_id, lw_chart_id);
828 
829  // Convert sequence id to poset id and store result.
830 
831  lref_pt.put(_elements_id_space->hub_pod(lref_chart_id),
832  1.0, lv_coord, 1.0);
833  result.push_back(lref_pt);
834  }
835 
836  if((lbit_code & 6) == 6)
837  {
838  // Point is on the v = 0, w = 0 edge; return the u > 0, v < 0, w < 0 zone.
839 
840  --lv_chart_id;
841  --lw_chart_id;
842  lref_chart_id = offset(lu_chart_id, lv_chart_id, lw_chart_id);
843 
844  // Convert sequence id to poset id and store result.
845 
846  lref_pt.put(_elements_id_space->hub_pod(lref_chart_id),
847  lu_coord, 1.0, 1.0);
848  result.push_back(lref_pt);
849  }
850 
851  if((lbit_code & 7) == 7)
852  {
853  // Point is on the u= 0, v = 0, w = 0 vertex; return the u < 0, v < 0, w < 0 zone.
854 
855  --lu_chart_id;
856  --lv_chart_id;
857  --lw_chart_id;
858 
859  lref_chart_id = offset(lu_chart_id, lv_chart_id, lw_chart_id);
860 
861  // Convert sequence id to poset id and store result.
862 
863  lref_pt.put(_elements_id_space->hub_pod(lref_chart_id), 1.0, 1.0, 1.0);
864  result.push_back(lref_pt);
865  }
866 
867 
868 
869  // Postconditions:
870 
871  // see $$ISSUE at structured_block::unrefine_pt_pa.
872  // ensure(covers(result.chart_id()));
873 
874  // Exit:
875 
876  return;
877 }
878 
879 void
881 unrefine_point_pa(const chart_point& xpt, chart_point& result) const
882 {
883  // Preconditions:
884 
885  require(state_is_read_accessible());
886 
887  // See comment at structured_block::unrefine_point_pa.
888 
889  require(xpt.db() >= db());
890  require(result.db() >= db());
891 
892  // see $$ISSUE at structured_block::unrefine_pt_pa.
893  // require(covers(xpt.chart_id()));
894 
895  // Body:
896 
897  // Convert poset id to sequence id.
898 
899  pod_index_type lref_chart_id = _elements_id_space->pod(xpt.chart_id());
900 
901  // Assume refined local coordinates [-1, 1]; map to [0, 1] ...
902 
903  double lxcoord = (xpt.local_coord(0) + 1.0)*0.5;
904  double lycoord = (xpt.local_coord(1) + 1.0)*0.5;
905  double lzcoord = (xpt.local_coord(2) + 1.0)*0.5;
906 
907  // ... and then to unrefined coord [0, i_size] ...
908 
909  size_type lxy = lref_chart_id/k_size();
910 
911  lxcoord = lxcoord + lxy/j_size();
912  lycoord = lycoord + lxy%j_size();
913  lzcoord = lzcoord + lref_chart_id%k_size();
914 
915  // ... and then to unrefined [-1, 1]
918 
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;
922 
923  // Store result.
924 
925  result.put_chart_id(index().pod());
926 
927  result.put_local_coord(0, lxcoord);
928  result.put_local_coord(1, lycoord);
929  result.put_local_coord(2, lzcoord);
930 
931  // Exit:
932 
933  return;
934 }
935 
936 void
939 {
940  // Preconditions:
941 
942  require(state_is_read_write_accessible());
943  require(is_jim());
944 
945  // Body:
946 
947  not_implemented();
948 
949  // Postconditions:
950 
951  ensure(!is_jim());
952 
953  // Exit:
954 
955  return;
956 }
957 
958 
959 void
962 {
963  // Preconditions:
964 
965  require(state_is_read_write_accessible());
966  require(!is_jim());
967 
968  // Body:
969 
970  not_implemented();
971 
972  // Postconditions:
973 
974  ensure(is_jim());
975 
976  // Exit:
977 
978  return;
979 }
980 
981 void
984 {
985  // Preconditions:
986 
987  require(state_is_read_write_accessible());
988  require(is_jim());
989 
990  // Body:
991 
992  not_implemented();
993 
994  // Postconditions:
995 
996  ensure(!is_jim());
997 
998  // Exit:
999 
1000  return;
1001 }
1002 
1003 
1004 void
1007 {
1008  // Preconditions:
1009 
1010  require(state_is_read_write_accessible());
1011  require(!is_jim());
1012 
1013  // Body:
1014 
1015  not_implemented();
1016 
1017  // Postconditions:
1018 
1019  ensure(is_jim());
1020 
1021  // Exit:
1022 
1023  return;
1024 }
1025 
1026 // PROTECTED DATA MEMBERS
1027 
1028 // PRIVATE DATA MEMBERS
1029 
1030 
1031 // ===========================================================
1032 // HOMOGENEOUS_BLOCK FACET
1033 // ===========================================================
1034 
1035 // PUBLIC DATA MEMBERS
1036 
1037 const sheaf::poset_path&
1040 {
1041 
1042  // Preconditions:
1043 
1044  // Body:
1045 
1048 
1049  static const poset_path
1050  STATIC_LOCAL_CELL_PROTOTYPE_PATH(base_space_member::prototypes_poset_name(),
1051  "hex_nodes");
1052 
1053  const poset_path& result = STATIC_LOCAL_CELL_PROTOTYPE_PATH;
1054 
1055  // Postconditions:
1056 
1058  ensure(result.member_name() == "hex_nodes");
1059 
1060  // Exit
1061 
1062  return result;
1063 }
1064 
1065 // PROTECTED DATA MEMBERS
1066 
1069 interval() const
1070 {
1071  return *reinterpret_cast<const structured_block_3d_crg_interval*>(_interval);
1072 }
1073 
1074 // PRIVATE DATA MEMBERS
1075 
1076 
1077 // ===========================================================
1078 // BASE_SPACE_MEMBER FACET
1079 // ===========================================================
1080 
1081 // PUBLIC DATA MEMBERS
1082 
1083 // PROTECTED DATA MEMBERS
1084 
1085 // PRIVATE DATA MEMBERS
1086 
1087 
1088 // ===========================================================
1089 // TOTAL_POSET_MEMBER FACET
1090 // ===========================================================
1091 
1092 // PUBLIC DATA MEMBERS
1093 
1094 // PROTECTED DATA MEMBERS
1095 
1096 // PRIVATE DATA MEMBERS
1097 
1098 
1099 // ===========================================================
1100 // ABSTRACT_POSET_MEMBER FACET
1101 // ===========================================================
1102 
1103 // PUBLIC DATA MEMBERS
1104 
1107 clone() const
1108 {
1109 
1110  // Preconditions:
1111 
1112  // Body:
1113 
1114  // create new handle of the current class.
1115 
1116  structured_block_3d *result = new structured_block_3d();
1117 
1118  // Postconditions:
1119 
1120  ensure(result != 0);
1121  ensure(result->invariant());
1122 
1123  // Exit:
1124 
1125  return result;
1126 
1127 }
1128 
1129 // PROTECTED DATA MEMBERS
1130 
1131 // PRIVATE DATA MEMBERS
1132 
1133 
1134 // ===========================================================
1135 // ANY FACET
1136 // ===========================================================
1137 
1138 // PUBLIC DATA MEMBERS
1139 
1140 bool
1142 invariant() const
1143 {
1144  // Preconditions:
1145 
1146  // Body:
1147 
1148  // Must satisfy base class invariant
1149 
1150  invariance(total_poset_member::invariant());
1151 
1152  if(invariant_check())
1153  {
1154  // Prevent recursive calls to invariant
1155 
1156  disable_invariant_check();
1157 
1158  // Invariants for this class:
1159 
1160  invariance(state_is_read_accessible() ? is_jim(false) : true);
1161  invariance(state_is_read_accessible() ? size() == i_size()*j_size()*k_size() : true);
1162 
1163  // Finished, turn invariant checking back on.
1164 
1165  enable_invariant_check();
1166  }
1167 
1168  // Postconditions:
1169 
1170  // Exit
1171 
1172  return true;
1173 }
1174 
1175 bool
1177 is_ancestor_of(const any* xother) const
1178 {
1179  bool result;
1180 
1181  // Preconditions:
1182 
1183  // Body:
1184 
1185  result = dynamic_cast<const structured_block_3d*>(xother) != 0;
1186 
1187  // Postconditions:
1188 
1189  // Exit
1190 
1191  return result;
1192 }
1193 
1197 {
1198  // Preconditions:
1199 
1200  // Body:
1201 
1202  attach_to_state(const_cast<abstract_poset_member*>(&xother));
1203 
1204  // Postconditions:
1205 
1206  ensure(is_same_state(const_cast<abstract_poset_member*>(&xother)));
1207 
1208  // Exit
1209 
1210  return *this;
1211 }
1212 
1216 {
1217 
1218  // Preconditions:
1219 
1220  require(is_ancestor_of(&xother));
1221 
1222  // Body
1223 
1224  not_implemented();
1225 
1226  // Postconditions
1227 
1228  ensure(invariant());
1229 
1230  // Exit
1231 
1232  return *this;
1233 
1234 }
1235 
1236 // PROTECTED DATA MEMBERS
1237 
1238 // PRIVATE DATA MEMBERS
1239 
1240 
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...
Definition: fiber_bundle.h:57
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.
Definition: poset_path.cc:311
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.
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.
Definition: chart_point.cc:141
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 (&#39;/&#39;). For example: "cell_definitions/triangle".
Definition: poset_path.h:48
void put_chart_id(pod_index_type xchart)
Sets chart_id() to xchart_id.
Definition: chart_point.cc:103
A point in chart space.
Definition: chart_point.h:52
pod_index_type chart_id() const
The id of the chart this point is in.
Definition: chart_point.cc:96
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.
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.
Definition: any.h:39
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].
Definition: interval_set.h:48
virtual coord_type * local_coords()=0
The array of local coordinates.
Definition: chart_point.cc:209
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.
Definition: poset.h:40
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)
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
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.
Definition: sheaf.h:52
std::string poset_name() const
The poset name part of the path.
Definition: poset_path.cc:473
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.
Definition: poset_path.cc:291
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.
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.
Definition: scoped_index.h:128
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
std::string member_name() const
The member name part of the path.
Definition: poset_path.cc:511
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.
Definition: chart_point.cc:187
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...
virtual void end_jim_edit_mode(bool xensure_lattice_invariant=true, bool xauto_access=true)
Prevent editing of jims and jim order relation.
Definition: poset.cc:253
static bool is_valid_name(const std::string &xname)
True if xname is not empty and contains only name legal characters.
Definition: poset_path.cc:331
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.
Definition: chart_point.cc:163
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.
Definition: scoped_index.h:710
virtual bool invariant() const
Class invariant.
virtual void begin_jim_edit_mode(bool xauto_access=true)
Allow editing of jims and jim order relation.
Definition: poset.cc:230