SheafSystem  0.0.0.0
unstructured_block.cc
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 
18 // Implementation for class unstructured_block.
19 
20 #include "SheafSystem/unstructured_block.h"
21 
22 #include "SheafSystem/assert_contract.h"
23 #include "SheafSystem/arg_list.h"
24 #include "SheafSystem/fiber_bundles_namespace.h"
25 #include "SheafSystem/hex_connectivity.h"
26 #include "SheafSystem/line_connectivity.h"
27 #include "SheafSystem/namespace_poset.h"
28 #include "SheafSystem/point_connectivity.h"
29 #include "SheafSystem/poset_path.h"
30 #include "SheafSystem/preorder_iterator.h"
31 #include "SheafSystem/quad_connectivity.h"
32 #include "SheafSystem/tetra_connectivity.h"
33 #include "SheafSystem/triangle_connectivity.h"
34 #include "SheafSystem/unstructured_block_builder.h"
35 #include "SheafSystem/wsv_block.h"
36 
37 
38 using namespace fiber_bundle; // Workaround for MS C++ bug.
39 
40 //#define DIAGNOSTIC_OUTPUT
41 
42 // ===========================================================
43 // HOST FACTORY FACET
44 // ===========================================================
45 
46 const sheaf::poset_path&
49 {
50 
51  // Preconditions:
52 
53  // Body:
54 
55  static const poset_path
56  STATIC_PROTOTYPE_PATH(base_space_member::prototypes_poset_name(),
57  "unstructured_block");
58 
59  const poset_path& result = STATIC_PROTOTYPE_PATH;
60 
61  // Postconditions:
62 
64  ensure(result.member_name() == "unstructured_block");
65 
66  // Exit
67 
68  return result;
69 }
70 
73 new_host(namespace_type& xns, const poset_path& xhost_path, const poset_path& xschema_path, int xmax_db, bool xauto_access)
74 {
75  // cout << endl << "Entering unstructured_block::new_host." << endl;
76 
77  // Preconditions:
78 
79  require(xns.state_is_auto_read_write_accessible(xauto_access));
80 
81  require(!xhost_path.empty());
82  require(!xns.contains_path(xhost_path, xauto_access));
83 
84  require(xschema_path.full());
85  require(xns.path_is_auto_read_accessible(xschema_path, xauto_access));
86  require(schema_poset_member::conforms_to(xns, xschema_path, standard_schema_path(), xauto_access));
87 
88  require(xmax_db >= 0);
89 
90  // Body:
91 
92  host_type& result =
93  host_type::new_table(xns, xhost_path, xschema_path, xmax_db, xauto_access);
94 
95  // Postconditions:
96 
97  ensure(xns.owns(result, xauto_access));
98  ensure(result.path(true) == xhost_path);
99  ensure(result.state_is_not_read_accessible());
100  ensure(result.schema(true).path(xauto_access) == xschema_path);
101 
102  ensure(result.max_db() == xmax_db);
103 
104  // Exit:
105 
106  // cout << "Leaving unstructured_block::new_host." << endl;
107  return result;
108 }
109 
112 standard_host(namespace_type& xns, const poset_path& xhost_path, int xmax_db, bool xauto_access)
113 {
114  // cout << endl << "Entering unstructured_block::standard_host." << endl;
115 
116  // Preconditions:
117 
118  require(xns.state_is_auto_read_write_accessible(xauto_access));
119 
120  require(poset_path::is_valid_name(xhost_path.poset_name()));
121  require(xns.path_is_auto_read_write_available<host_type>(xhost_path.poset_name(), xauto_access));
122 
123  require(xns.path_is_auto_read_accessible(standard_schema_path(), xauto_access));
124 
125  require(xmax_db >= 0);
126 
127  // Body:
128 
129  host_type* result_ptr;
130  if(xns.contains_path(xhost_path.poset_name(), xauto_access))
131  {
132  result_ptr = &xns.member_poset<host_type>(xhost_path, xauto_access);
133  }
134  else
135  {
136  result_ptr = &new_host(xns, xhost_path, standard_schema_path(), xmax_db, xauto_access);
137  }
138 
139  host_type& result = *result_ptr;
140 
141  // Postconditions:
142 
143  ensure(xns.owns(result, xauto_access));
144  ensure(result.path(true) == xhost_path);
145  ensure(result.state_is_not_read_accessible());
146  ensure(result.schema(true).path(xauto_access) == standard_schema_path());
147 
148  ensure(result.max_db() == xmax_db);
149 
150  // Exit:
151 
152  // cout << "Leaving unstructured_block::standard_host." << endl;
153  return result;
154 }
155 
156 
157 // ===========================================================
158 // ANY FACET
159 // ===========================================================
160 
161 bool
163 invariant() const
164 {
165  // Preconditions:
166 
167  // Body:
168 
169  // Must satisfy base class invariant
170 
171  invariance(total_poset_member::invariant());
172 
173  if(invariant_check())
174  {
175  // Prevent recursive calls to invariant
176 
177  disable_invariant_check();
178 
179  // Invariants for this class:
180 
181  // Finished, turn invariant checking back on.
182 
183  enable_invariant_check();
184  }
185 
186  // Postconditions:
187 
188  // Exit
189 
190  return true;
191 }
192 
193 
194 
195 bool
197 is_ancestor_of(const any* xother) const
198 {
199  bool result;
200 
201  // Preconditions:
202 
203  // Body:
204 
205  result = dynamic_cast<const unstructured_block*>(xother) != 0;
206 
207  // Postconditions:
208 
209  // Exit
210 
211  return result;
212 }
213 
214 
218 {
219  // Preconditions:
220 
221  // Body:
222 
223  attach_to_state(&xother);
224 
225  // Postconditions:
226 
227  ensure(is_same_state(&xother));
228 
229  // Exit
230 
231  return *this;
232 }
233 
237 {
238 
239  // Preconditions:
240 
241  require(is_ancestor_of(&xother));
242 
243  // Body
244 
245  not_implemented();
246 
247  // Postconditions
248 
249  ensure(invariant());
250 
251  // Exit
252 
253  return *this;
254 
255 }
256 
257 // ===========================================================
258 // ABSTRACT POSET MEMBER FACET
259 // ===========================================================
260 
263 clone() const
264 {
265 
266  // Preconditions:
267 
268  // Body:
269 
270  // create new handle of the current class.
271 
272  unstructured_block *result = new unstructured_block();
273 
274  // Postconditions:
275 
276  ensure(result != 0);
277  ensure(result->invariant());
278 
279  // Exit:
280 
281  return result;
282 
283 }
284 
285 
286 // ===========================================================
287 // UNSTRUCTURED_BLOCK FACET
288 // ===========================================================
289 
290 
293 {
294 
295  // Preconditions:
296 
297  // Body:
298 
299  // Postconditions:
300 
301  ensure(invariant());
302  ensure(! is_attached() );
303 }
304 
305 
307 unstructured_block(const abstract_poset_member& xother, bool xnew_jem)
308 {
309 
310  // Preconditions:
311 
312  require(xnew_jem ? xother.is_attached() : true);
313 
314  // Body:
315 
316  if(xnew_jem)
317  {
318  new_jem_state(const_cast<abstract_poset_member*>(&xother), true, true);
319  }
320  else
321  {
322  attach_to_state(&xother);
323  }
324 
325  // postconditions:
326 
327  ensure(invariant());
328  ensure(is_attached() == xother.is_attached() );
329 }
330 
333 {
334 
335  // Preconditions:
336 
337  // Body:
338 
339  // Exit
340 
341  return;
342 }
343 
344 // ===========================================================
345 // NEW HANDLE, NEW STATE CONSTRUCTORS
346 // ===========================================================
347 
350  const std::string& xlocal_cell_prototype_name,
351  bool xis_prototype_name,
352  bool xauto_access)
353 {
354  // Preconditions:
355 
356  require(precondition_of(new_state(xhost, xlocal_cell_prototype_name, xauto_access)));
357 
358  // Body:
359 
360  new_state(xhost, xlocal_cell_prototype_name, xauto_access);
361 
362  // Postconditions:
363 
364  ensure(postcondition_of(new_state(xhost, xlocal_cell_prototype_name, xauto_access)));
365 
366  // Exit
367 
368  return;
369 }
370 
373  const poset_path& xlocal_cell_prototype_path,
374  const scoped_index* xids,
375  int xub,
376  bool xauto_access)
377 {
378  // Preconditions:
379 
380  require(precondition_of(new_state(same args)));
381 
382  // Body:
383 
384  new_state(xhost, xlocal_cell_prototype_path, xids, xub, xauto_access);
385 
386  // Postconditions:
387 
388  ensure(postcondition_of(new_state(same args)));
389 
390  // Exit
391 
392  return;
393 }
394 
397  const base_space_member& xlocal_cell_prototype,
398  const scoped_index* xids,
399  int xub,
400  bool xauto_access)
401 {
402  // Preconditions:
403 
404  require(precondition_of(new_state(same args)));
405 
406  // Body:
407 
408  new_state(xhost, xlocal_cell_prototype, xids, xub, xauto_access);
409 
410  // Postconditions:
411 
412  ensure(postcondition_of(new_state(same args)));
413 
414  // Exit
415 
416  return;
417 }
418 
421  const poset_path& xlocal_cell_prototype_path,
422  const pod_index_type* xids,
423  int xub,
424  bool xauto_access)
425 {
426  // Preconditions:
427 
428  require(precondition_of(new_state(same args)));
429 
430  // Body:
431 
432  new_state(xhost, xlocal_cell_prototype_path, xids, xub, xauto_access);
433 
434  // Postconditions:
435 
436  ensure(postcondition_of(new_state(same args)));
437 
438  // Exit
439 
440  return;
441 }
442 
445  const base_space_member& xlocal_cell_prototype,
446  const pod_index_type* xids,
447  int xub,
448  bool xauto_access)
449 {
450  // Preconditions:
451 
452  require(precondition_of(new_state(same args)));
453 
454  // Body:
455 
456  new_state(xhost, xlocal_cell_prototype, xids, xub, xauto_access);
457 
458  // Postconditions:
459 
460  ensure(postcondition_of(new_state(same args)));
461 
462  // Exit
463 
464  return;
465 }
466 
469  const poset_path& xlocal_cell_prototype_path,
470  const size_type& xi_size,
471  bool xauto_access)
472 {
473  // Preconditions:
474 
475  require(precondition_of(new_state(same args)));
476 
477  // Body:
478 
479  new_state(xhost, xlocal_cell_prototype_path, xi_size, xauto_access);
480 
481  // Postconditions:
482 
483  ensure(postcondition_of(new_state(same args)));
484 
485  // Exit
486 
487  return;
488 }
489 
492  const base_space_member& xlocal_cell_prototype,
493  const size_type& xi_size,
494  bool xauto_access)
495 {
496  // Preconditions:
497 
498  require(precondition_of(new_state(same args)));
499 
500  // Body:
501 
502  new_state(xhost, xlocal_cell_prototype, xi_size, xauto_access);
503 
504  // Postconditions:
505 
506  ensure(postcondition_of(new_state(same args)));
507 
508  // Exit
509 
510  return;
511 }
512 
515  const poset_path& xlocal_cell_prototype_path,
516  const size_type& xi_size,
517  const size_type& xj_size,
518  bool xauto_access)
519 {
520  // Preconditions:
521 
522  require(precondition_of(new_state(same args)));
523 
524  // Body:
525 
526  new_state(xhost, xlocal_cell_prototype_path, xi_size, xj_size, xauto_access);
527 
528  // Postconditions:
529 
530  ensure(postcondition_of(new_state(same args)));
531 
532  // Exit
533 
534  return;
535 }
536 
539  const base_space_member& xlocal_cell_prototype,
540  const size_type& xi_size,
541  const size_type& xj_size,
542  bool xauto_access)
543 {
544  // Preconditions:
545 
546  require(precondition_of(new_state(same args)));
547 
548  // Body:
549 
550  new_state(xhost, xlocal_cell_prototype, xi_size, xj_size, xauto_access);
551 
552  // Postconditions:
553 
554  ensure(postcondition_of(new_state(same args)));
555 
556  // Exit
557 
558  return;
559 }
560 
563  const poset_path& xlocal_cell_prototype_path,
564  const size_type& xi_size,
565  const size_type& xj_size,
566  const size_type& xk_size,
567  bool xauto_access)
568 {
569  // Preconditions:
570 
571  require(precondition_of(new_state(same args)));
572 
573  // Body:
574 
575  new_state(xhost, xlocal_cell_prototype_path, xi_size, xj_size, xk_size,
576  xauto_access);
577 
578  // Postconditions:
579 
580  ensure(postcondition_of(new_state(same args)));
581 
582  // Exit
583 
584  return;
585 }
586 
589  const base_space_member& xlocal_cell_prototype,
590  const size_type& xi_size,
591  const size_type& xj_size,
592  const size_type& xk_size,
593  bool xauto_access)
594 {
595  // Preconditions:
596 
597  require(precondition_of(new_state(same args)));
598 
599  // Body:
600 
601  new_state(xhost, xlocal_cell_prototype, xi_size, xj_size, xk_size, xauto_access);
602 
603  // Postconditions:
604 
605  ensure(postcondition_of(new_state(same args)));
606 
607  // Exit
608 
609  return;
610 }
611 
612 // ===========================================================
613 // NEW HANDLE, EXISTING STATE CONSTRUCTORS
614 // ===========================================================
615 
616 
618 unstructured_block(const poset* xhost, scoped_index xindex)
619 {
620 
621  // Preconditions:
622 
623  require(precondition_of(attach_to_state(xhost, xindex)));
624 
625  // Body:
626 
627  attach_to_state(xhost, xindex);
628 
629  // Postconditions:
630 
631  ensure(postcondition_of(attach_to_state(xhost, xindex)));
632 }
633 
634 
636 unstructured_block(const poset* xhost, const std::string& xname)
637 {
638 
639  // Preconditions:
640 
641  require(precondition_of(attach_to_state(same args)));
642 
643  // Body:
644 
645  attach_to_state(xhost, xname);
646 
647  // Postconditions:
648 
649  ensure(postcondition_of(attach_to_state(same args)));
650 }
651 
652 
655  const poset_path& xpath,
656  bool xauto_access)
657 {
658 
659  // Preconditions:
660 
662 
663  require(precondition_of(attach_to_state(same args)));
664 
665  // Body:
666 
667  attach_to_state(xnamespace, xpath, xauto_access);
668 
669  // Postconditions:
670 
671  ensure(postcondition_of(attach_to_state(same args)));
672 
673  // Exit:
674 
675  return;
676 }
677 
680  const scoped_index& xposet_id,
681  const scoped_index& xmember_id)
682 {
683 
684  // Preconditions:
685 
687 
688  require(precondition_of(attach_to_state(same args)));
689 
690  // Body:
691 
692  attach_to_state(xnamespace, xposet_id, xmember_id);
693 
694  // Postconditions:
695 
696  ensure(postcondition_of(attach_to_state(same args)));
697 
698  // Exit:
699 
700  return;
701 }
702 
703 
704 // ===========================================================
705 // EXISTING HANDLE, NEW STATE "CONSTRUCTORS"
706 // ===========================================================
707 
708 
709 void
712  const std::string& xlocal_cell_prototype_name,
713  bool xauto_access)
714 {
715  // Preconditions:
716 
717  require(xhost != 0);
718  require(xauto_access || xhost->in_jim_edit_mode());
719 
720  // Get access if auto access is requested. Need to do it here so the
721  // remaining preconditions can be executed.
722 
723  if(xauto_access)
724  xhost->begin_jim_edit_mode(true);
725 
726  require(namespace_is_ancestor_of(xhost->name_space()));
727  require(xhost->schema().row_conforms_to(standard_schema_path()));
728  require(prototype_exists(xlocal_cell_prototype_name, true));
729 
730  // Body:
731 
732  // $$HACK: force subposets to be persistent
733 
734  make_standard_subposets_persistent(*xhost);
735 
736  // Create the dof map and initialize the dofs.
737 
738  array_poset_dof_map* lmap = new_row_dof_map(xhost,
739  static_prototype_path().member_name(),
740  xlocal_cell_prototype_name,
741  0);
742 
743  // Create the new state.
744 
745  new_jim_state(xhost, lmap, false, false);
746 
747  // Link it as an isolated atom.
748 
749  host()->top().create_cover_link(this);
750  create_cover_link(&host()->bottom());
751 
752  // Postconditions:
753 
754  ensure(invariant());
755  ensure(prototype_path() == static_prototype_path());
756  ensure(local_cell_type_name() == xlocal_cell_prototype_name);
757  ensure(size() == 0);
758  ensure(is_jim());
759 
760  // Release access if auto access was requested.
761 
762  if(xauto_access)
763  xhost->end_jim_edit_mode(true, true);
764 
765  // Exit
766 
767  return;
768 }
769 
770 void
772 new_state(const poset_path& xlocal_cell_prototype_path,
773  const scoped_index* xids,
774  int xub,
775  bool xauto_access)
776 {
777  // Preconditions:
778 
779  require(state_is_read_write_accessible());
780  require(host()->name_space()->contains_poset_member(xlocal_cell_prototype_path));
781  require(precondition_of(new_state(host(), xlocal_cell_prototype, xids, xub, xauto_access)));
782 
783  // Body:
784 
785  new_state(host(), xlocal_cell_prototype_path, xids, xub, xauto_access);
786 
787  // Postconditions:
788 
789  ensure(postcondition_of(new_state(host(), xlocal_cell_prototype, xids, xub, xauto_access)));
790 
791  // Exit
792 
793  return;
794 }
795 
796 void
798 new_state(const base_space_member& xlocal_cell_prototype,
799  const scoped_index* xids,
800  int xub,
801  bool xauto_access)
802 {
803  // Preconditions:
804 
805  require(precondition_of(new_state(host(), xlocal_cell_prototype, xids, xub, xauto_access)));
806 
807  // Body:
808 
809  new_state(host(), xlocal_cell_prototype, xids, xub, xauto_access);
810 
811  // Postconditions:
812 
813  ensure(postcondition_of(new_state(host(), xlocal_cell_prototype, xids, xub, xauto_access)));
814 
815  // Exit
816 
817  return;
818 }
819 
820 
821 void
824  const poset_path& xlocal_cell_prototype_path,
825  const scoped_index* xids,
826  int xub,
827  bool xauto_access)
828 {
829  // Preconditions:
830 
831  require(xauto_access ? xhost->is_attached() : xhost->state_is_read_write_accessible());
832  require(xauto_access || xhost->name_space()->state_is_read_accessible());
833  require(xlocal_cell_prototype_path.member_exists(xauto_access));
834  require(xauto_access || xlocal_cell_prototype_path.state_is_read_accessible(xauto_access));
835 
836  require(precondition_of(new_state(xhost, xlocal_cell_prototype, xids, xub, xauto_access)));
837 
838  // Body:
839 
840  base_space_member lproto(xhost->name_space(), xlocal_cell_prototype_path, xauto_access);
841 
842  new_state(xhost, lproto, xids, xub, xauto_access);
843 
844  lproto.detach_from_state();
845 
846  // Postconditions:
847 
848  ensure(postcondition_of(new_state(host(), xlocal_cell_prototype, xids, xub, xauto_access)));
849 
850  // Exit
851 
852  return;
853 }
854 
855 void
858  const base_space_member& xlocal_cell_prototype,
859  const scoped_index* xids,
860  int xub,
861  bool xauto_access)
862 {
863  // Preconditions:
864 
865  require(xhost != 0);
866  require(xauto_access ? xhost->is_attached() : xhost->in_jim_edit_mode());
867  require(xauto_access ?
868  xlocal_cell_prototype.is_attached() :
869  xlocal_cell_prototype.state_is_read_accessible());
870  require(xauto_access || xlocal_cell_prototype.name_space()->state_is_read_accessible());
871 
872  if(xauto_access)
873  {
874  xhost->begin_jim_edit_mode(true);
875  xlocal_cell_prototype.get_read_access();
876  xlocal_cell_prototype.name_space()->get_read_access();
877  }
878 
879  require(namespace_is_ancestor_of(xhost->name_space()));
880  require(xhost->schema().row_conforms_to(standard_schema_path()));
881  require(xlocal_cell_prototype.schema().row_conforms_to(xhost->schema()));
882  require(!xlocal_cell_prototype.host()->is_same_state(xhost));
883  require(xlocal_cell_prototype.atom_ct() > 0);
884  require(xids != 0);
885  require(xub > 0);
886  require( (xub % xlocal_cell_prototype.atom_ct()) == 0 );
887 
888  // Body:
889 
890  // $$HACK: force subposets to be persistent
891 
892  make_standard_subposets_persistent(*xhost);
893 
894  // Create the dof map and initialize the dofs.
895 
896  size_type lsize = xub/xlocal_cell_prototype.atom_ct();
897  array_poset_dof_map* lmap = new_row_dof_map(xhost,
898  static_prototype_path().member_name(),
899  xlocal_cell_prototype.name(),
900  lsize);
901 
902  // Create the new state.
903 
904  new_jim_state(xhost, lmap, false, false);
905 
906  // Link it as an isolated atom.
907 
908  host()->top().create_cover_link(this);
909  create_cover_link(&host()->bottom());
910 
913 
916 
917  base_space_poset* lhost = dynamic_cast<base_space_poset*>(host());
918 
919  bool lcompute_cover = (db() < lhost->max_db());
920 
921  // Build the block
922 
923  unstructured_block_builder block_builder;
924  block_builder.build_block_pa(&xlocal_cell_prototype,
925  xids,
926  xub,
927  this,
928  lcompute_cover,
929  false);
930 
931  // Postconditions:
932 
933  ensure(db() == xlocal_cell_prototype.db());
934  ensure(prototype_path() == static_prototype_path());
935  // ensure(local_cell_type_name() == xlocal_cell_prototype.name());
936  ensure(xlocal_cell_prototype.has_name(local_cell_type_name()));
937  ensure(size() == xub/xlocal_cell_prototype.atom_ct());
938 
939  // Release access if auto access was requested.
940 
941  if(xauto_access)
942  {
943  xlocal_cell_prototype.name_space()->release_access();
944  xlocal_cell_prototype.release_access();
945  xhost->end_jim_edit_mode(true, true);
946  }
947 
948  // Exit
949 
950  return;
951 }
952 
953 void
955 new_state(const poset_path& xlocal_cell_prototype_path,
956  const pod_index_type* xids,
957  int xub,
958  bool xauto_access)
959 {
960  // Preconditions:
961 
962  require(state_is_read_write_accessible());
963  require(host()->name_space()->contains_poset_member(xlocal_cell_prototype_path));
964  require(precondition_of(new_state(host(), xlocal_cell_prototype, xids, xub, xauto_access)));
965 
966  // Body:
967 
968  new_state(host(), xlocal_cell_prototype_path, xids, xub, xauto_access);
969 
970  // Postconditions:
971 
972  ensure(postcondition_of(new_state(host(), xlocal_cell_prototype, xids, xub, xauto_access)));
973 
974  // Exit
975 
976  return;
977 }
978 
979 void
981 new_state(const base_space_member& xlocal_cell_prototype,
982  const pod_index_type* xids,
983  int xub,
984  bool xauto_access)
985 {
986  // Preconditions:
987 
988  require(precondition_of(new_state(host(), xlocal_cell_prototype, xids, xub, xauto_access)));
989 
990  // Body:
991 
992  new_state(host(), xlocal_cell_prototype, xids, xub, xauto_access);
993 
994  // Postconditions:
995 
996  ensure(postcondition_of(new_state(host(), xlocal_cell_prototype, xids, xub, xauto_access)));
997 
998  // Exit
999 
1000  return;
1001 }
1002 
1003 
1004 void
1007  const poset_path& xlocal_cell_prototype_path,
1008  const pod_index_type* xids,
1009  int xub,
1010  bool xauto_access)
1011 {
1012  // Preconditions:
1013 
1014  require(xauto_access ? xhost->is_attached() : xhost->state_is_read_write_accessible());
1015  require(xauto_access || xhost->name_space()->state_is_read_accessible());
1016  require(xlocal_cell_prototype_path.member_exists(xauto_access));
1017  require(xauto_access || xlocal_cell_prototype_path.state_is_read_accessible(xauto_access));
1018 
1019  require(precondition_of(new_state(xhost, xlocal_cell_prototype, xids, xub, xauto_access)));
1020 
1021  // Body:
1022 
1023  base_space_member lproto(xhost->name_space(),
1024  xlocal_cell_prototype_path,
1025  xauto_access);
1026 
1027  new_state(xhost, lproto, xids, xub, xauto_access);
1028 
1029  lproto.detach_from_state();
1030 
1031  // Postconditions:
1032 
1033  ensure(postcondition_of(new_state(host(), xlocal_cell_prototype, xids, xub, xauto_access)));
1034 
1035  // Exit
1036 
1037  return;
1038 }
1039 
1040 void
1043  const base_space_member& xlocal_cell_prototype,
1044  const pod_index_type* xids,
1045  int xub,
1046  bool xauto_access)
1047 {
1048  // Preconditions:
1049 
1050  require(xhost != 0);
1051  require(xauto_access ? xhost->is_attached() : xhost->in_jim_edit_mode());
1052  require(xauto_access ?
1053  xlocal_cell_prototype.is_attached() :
1054  xlocal_cell_prototype.state_is_read_accessible());
1055  require(xauto_access || xlocal_cell_prototype.name_space()->state_is_read_accessible());
1056 
1057  if(xauto_access)
1058  {
1059  xhost->begin_jim_edit_mode(true);
1060  xlocal_cell_prototype.get_read_access();
1061  xlocal_cell_prototype.name_space()->get_read_access();
1062  }
1063 
1064  require(namespace_is_ancestor_of(xhost->name_space()));
1065  require(xhost->schema().row_conforms_to(standard_schema_path()));
1066  require(xlocal_cell_prototype.schema().row_conforms_to(xhost->schema()));
1067  require(!xlocal_cell_prototype.host()->is_same_state(xhost));
1068  require(xlocal_cell_prototype.atom_ct() > 0);
1069  require(xids != 0);
1070  require(xub > 0);
1071  require( (xub % xlocal_cell_prototype.atom_ct()) == 0 );
1072 
1073  // Body:
1074 
1075  // $$HACK: force subposets to be persistent
1076 
1077  make_standard_subposets_persistent(*xhost);
1078 
1079  // Create the dof map and initialize the dofs.
1080 
1081  size_type lsize = xub/xlocal_cell_prototype.atom_ct();
1082  array_poset_dof_map* lmap = new_row_dof_map(xhost,
1083  static_prototype_path().member_name(),
1084  xlocal_cell_prototype.name(),
1085  lsize);
1086 
1087  // Create the new state.
1088 
1089  new_jim_state(xhost, lmap, false, false);
1090 
1091  // Link it as an isolated atom.
1092 
1093  host()->top().create_cover_link(this);
1094  create_cover_link(&host()->bottom());
1095 
1098 
1101 
1102  base_space_poset* lhost = dynamic_cast<base_space_poset*>(host());
1103 
1104  bool lcompute_cover = (db() < lhost->max_db());
1105 
1106  // Build the block
1107 
1108  unstructured_block_builder block_builder;
1109  block_builder.build_block_pa(&xlocal_cell_prototype,
1110  xids,
1111  xub,
1112  this,
1113  lcompute_cover,
1114  false);
1115 
1116  // Postconditions:
1117 
1118  ensure(db() == xlocal_cell_prototype.db());
1119  ensure(prototype_path() == static_prototype_path());
1120  // ensure(local_cell_type_name() == xlocal_cell_prototype.name());
1121  ensure(xlocal_cell_prototype.has_name(local_cell_type_name()));
1122  ensure(size() == xub/xlocal_cell_prototype.atom_ct());
1123 
1124  // Release access if auto access was requested.
1125 
1126  if(xauto_access)
1127  {
1128  xlocal_cell_prototype.name_space()->release_access();
1129  xlocal_cell_prototype.release_access();
1130  xhost->end_jim_edit_mode(true, true);
1131  }
1132 
1133  // Exit
1134 
1135  return;
1136 }
1137 
1138 void
1140 new_state(const poset_path& xlocal_cell_prototype_path,
1141  const size_type& xi_size,
1142  bool xauto_access)
1143 {
1144  // Preconditions:
1145 
1146  require(xauto_access || state_is_read_write_accessible());
1147  require(precondition_of(new_state(host(), xlocal_cell_prototype, xi_size, xauto_access)));
1148 
1149  // Body:
1150 
1151  new_state(host(), xlocal_cell_prototype_path, xi_size, xauto_access);
1152 
1153  // Postconditions:
1154 
1155  ensure(postcondition_of(new_state(host(), xlocal_cell_prototype, xi_size, xauto_access)));
1156 
1157  // Exit
1158 
1159  return;
1160 }
1161 
1162 void
1164 new_state(const base_space_member& xlocal_cell_prototype,
1165  const size_type& xi_size,
1166  bool xauto_access)
1167 {
1168  // Preconditions:
1169 
1170  require(precondition_of(new_state(host(), xlocal_cell_prototype, xi_size, xauto_access)));
1171 
1172  // Body:
1173 
1174  new_state(host(), xlocal_cell_prototype, xi_size, xauto_access);
1175 
1176  // Postconditions:
1177 
1178  ensure(postcondition_of(new_state(host(), xlocal_cell_prototype, xi_size, xauto_access)));
1179 
1180  // Exit
1181 
1182  return;
1183 }
1184 
1185 
1186 void
1189  const poset_path& xlocal_cell_prototype_path,
1190  const size_type& xi_size,
1191  bool xauto_access)
1192 {
1193  // Preconditions:
1194 
1195  require(xauto_access ? xhost->is_attached() : xhost->state_is_read_write_accessible());
1196  require(xauto_access || xhost->name_space()->state_is_read_accessible());
1197  require(xlocal_cell_prototype_path.member_exists(xauto_access));
1198  require(xauto_access || xlocal_cell_prototype_path.state_is_read_accessible(xauto_access));
1199 
1200  require(precondition_of(new_state(xhost, xlocal_cell_prototype, xi_size, xauto_access)));
1201 
1202  // Body:
1203 
1204  base_space_member lproto(xhost->name_space(),
1205  xlocal_cell_prototype_path,
1206  xauto_access);
1207 
1208  new_state(xhost, lproto, xi_size, xauto_access);
1209 
1210  lproto.detach_from_state();
1211 
1212  // Postconditions:
1213 
1214  ensure(postcondition_of(new_state(host(), xlocal_cell_prototype, xi_size, xauto_access)));
1215 
1216  // Exit
1217 
1218  return;
1219 }
1220 
1221 void
1224  const base_space_member& xlocal_cell_prototype,
1225  const size_type& xi_size,
1226  bool xauto_access)
1227 {
1228  // Preconditions:
1229 
1230  require(xhost != 0);
1231  require(xauto_access ? xhost->is_attached() : xhost->in_jim_edit_mode());
1232  require(xauto_access ?
1233  xlocal_cell_prototype.is_attached() :
1234  xlocal_cell_prototype.state_is_read_accessible());
1235 
1236  if(xauto_access)
1237  {
1238  xhost->begin_jim_edit_mode(true);
1239  xlocal_cell_prototype.get_read_access();
1240  }
1241 
1242  require(namespace_is_ancestor_of(xhost->name_space()));
1243  require(xhost->schema().row_conforms_to(standard_schema_path()));
1244 
1245  require(xlocal_cell_prototype.schema().row_conforms_to(xhost->schema()));
1246  require(!xlocal_cell_prototype.host()->is_same_state(xhost));
1247  require(xlocal_cell_prototype.atom_ct() > 0);
1248  require(xlocal_cell_prototype.name() == "segment_complex" ||
1249  xlocal_cell_prototype.name() == "point");
1250  require(xi_size > 0);
1251 
1252  // Body:
1253 
1254  // $$HACK: force subposets to be persistent
1255 
1256  make_standard_subposets_persistent(*xhost);
1257 
1258  // Create the connectivity.
1259 
1260  block_connectivity* lconnectivity;
1261  if(xlocal_cell_prototype.name() == "segment_complex")
1262  {
1263  lconnectivity = new line_connectivity(xi_size);
1264  }
1265  else
1266  {
1267  lconnectivity = new point_connectivity(xi_size);
1268  }
1269 
1270 #ifdef DIAGNOSTIC_OUTPUT
1271  cout << *lconnectivity << endl;
1272 #endif
1273 
1274  int* lnode_ids = lconnectivity->node_ids();
1275  int lnode_ids_ub = lconnectivity->node_id_ct();
1276 
1277  new_state(xhost,
1278  xlocal_cell_prototype,
1279  lnode_ids,
1280  lnode_ids_ub,
1281  false);
1282 
1283  delete lconnectivity;
1284 
1285  // Postconditions:
1286 
1287  ensure(postcondition_of(new_state(host(), xlocal_cell_prototype, lnode_ids, lnode_ids_ub, false)));
1288 
1289  // Release access if auto access was requested.
1290 
1291  if(xauto_access)
1292  {
1293  xhost->end_jim_edit_mode(true, true);
1294  xlocal_cell_prototype.release_access();
1295  }
1296 
1297 
1298  // Exit
1299 
1300  return;
1301 }
1302 
1303 void
1305 new_state(const poset_path& xlocal_cell_prototype_path,
1306  const size_type& xi_size,
1307  const size_type& xj_size,
1308  bool xauto_access)
1309 {
1310  // Preconditions:
1311 
1312  require(xauto_access || state_is_read_write_accessible());
1313  require(precondition_of(new_state(host(), xlocal_cell_prototype_path, xi_size, xj_size, xauto_access)));
1314 
1315  // Body:
1316 
1317  new_state(host(), xlocal_cell_prototype_path, xi_size, xj_size, xauto_access);
1318 
1319  // Postconditions:
1320 
1321  ensure(postcondition_of(new_state(host(), xlocal_cell_prototype, xi_size, xj_size, xauto_access)));
1322 
1323  // Exit
1324 
1325  return;
1326 }
1327 
1328 void
1330 new_state(const base_space_member& xlocal_cell_prototype,
1331  const size_type& xi_size,
1332  const size_type& xj_size,
1333  bool xauto_access)
1334 {
1335  // Preconditions:
1336 
1337  require(precondition_of(new_state(host(), xlocal_cell_prototype, xi_size, xj_size, xauto_access)));
1338 
1339  // Body:
1340 
1341  new_state(host(), xlocal_cell_prototype, xi_size, xj_size, xauto_access);
1342 
1343  // Postconditions:
1344 
1345  ensure(postcondition_of(new_state(host(), xlocal_cell_prototype, xi_size, xj_size, xauto_access)));
1346 
1347  // Exit
1348 
1349  return;
1350 }
1351 
1352 
1353 void
1356  const poset_path& xlocal_cell_prototype_path,
1357  const size_type& xi_size,
1358  const size_type& xj_size,
1359  bool xauto_access)
1360 {
1361  // Preconditions:
1362 
1363  require(xauto_access ? xhost->is_attached() : xhost->state_is_read_write_accessible());
1364  require(xlocal_cell_prototype_path.member_exists(xauto_access));
1365  require(xauto_access || xlocal_cell_prototype_path.state_is_read_accessible(xauto_access));
1366  require(precondition_of(new_state(xhost, xlocal_cell_prototype, xi_size, xj_size, xauto_access)));
1367 
1368  // Body:
1369 
1370 
1371  base_space_member lproto(xhost->name_space(),
1372  xlocal_cell_prototype_path,
1373  xauto_access);
1374 
1375  new_state(xhost, lproto, xi_size, xj_size, xauto_access);
1376 
1377  lproto.detach_from_state();
1378 
1379  // Postconditions:
1380 
1381  ensure(postcondition_of(new_state(host(), xlocal_cell_prototype, xi_size, xj_size, xauto_access)));
1382 
1383  // Exit
1384 
1385  return;
1386 }
1387 
1388 void
1391  const base_space_member& xlocal_cell_prototype,
1392  const size_type& xi_size,
1393  const size_type& xj_size,
1394  bool xauto_access)
1395 {
1396  // Preconditions:
1397 
1398  require(xhost != 0);
1399  require(xauto_access ? xhost->is_attached() : xhost->in_jim_edit_mode());
1400  require(xauto_access ?
1401  xlocal_cell_prototype.is_attached() :
1402  xlocal_cell_prototype.state_is_read_accessible());
1403  require(xauto_access || xlocal_cell_prototype.name_space()->state_is_read_accessible());
1404 
1405  if(xauto_access)
1406  {
1407  xhost->begin_jim_edit_mode(true);
1408  xlocal_cell_prototype.get_read_access();
1409  xlocal_cell_prototype.name_space()->get_read_access();
1410  }
1411 
1412  require(namespace_is_ancestor_of(xhost->name_space()));
1413  require(xhost->schema().row_conforms_to(standard_schema_path()));
1414  require(xlocal_cell_prototype.schema().row_conforms_to(xhost->schema()));
1415  require(!xlocal_cell_prototype.host()->is_same_state(xhost));
1416  require(xlocal_cell_prototype.atom_ct() > 0);
1417  require(xlocal_cell_prototype.db() == 2);
1418  // require((xlocal_cell_prototype.name() == "quad_nodes") ||
1419  // (xlocal_cell_prototype.name() == "quad_complex") ||
1420  // (xlocal_cell_prototype.name() == "triangle_complex") ||
1421  // (xlocal_cell_prototype.name() == "triangle_nodes"));
1422  require((xlocal_cell_prototype.has_name("quad_nodes")) ||
1423  (xlocal_cell_prototype.has_name("quad_complex")) ||
1424  (xlocal_cell_prototype.has_name("triangle_complex")) ||
1425  (xlocal_cell_prototype.has_name("triangle_nodes")));
1426  require(xi_size > 0);
1427  require(xj_size > 0);
1428 
1429  // Body:
1430 
1431  // $$HACK: force subposets to be persistent
1432 
1433  make_standard_subposets_persistent(*xhost);
1434 
1435  // Create the connectivity.
1436 
1437  block_connectivity* lconnectivity = 0;
1438 
1439  if((xlocal_cell_prototype.name() == "quad_nodes") ||
1440  (xlocal_cell_prototype.name() == "quad_complex"))
1441  {
1442  lconnectivity = new quad_connectivity(xi_size, xj_size);
1443  }
1444  else
1445  {
1446  // Has to be "triangle_nodes" or "triangle_complex"
1447  // due to the precondition.
1448 
1449  lconnectivity = new triangle_connectivity(xi_size, xj_size);
1450  }
1451 
1452 #ifdef DIAGNOSTIC_OUTPUT
1453  cout << *lconnectivity << endl;
1454 #endif
1455 
1456  int* lnode_ids = lconnectivity->node_ids();
1457  int lnode_ids_ub = lconnectivity->node_id_ct();
1458 
1459  new_state(xhost,
1460  xlocal_cell_prototype,
1461  lnode_ids,
1462  lnode_ids_ub,
1463  false);
1464 
1465  delete lconnectivity;
1466 
1467  // Postconditions:
1468 
1469  ensure(postcondition_of(new_state(host(), xlocal_cell_prototype, lnode_ids, lnode_ids_ub, false)));
1470 
1471  // Release access if auto access was requested.
1472 
1473  if(xauto_access)
1474  {
1475  xlocal_cell_prototype.name_space()->release_access();
1476  xlocal_cell_prototype.release_access();
1477  xhost->end_jim_edit_mode(true, true);
1478  }
1479 
1480 
1481  // Exit
1482 
1483  return;
1484 }
1485 
1486 void
1488 new_state(const poset_path& xlocal_cell_prototype_path,
1489  const size_type& xi_size,
1490  const size_type& xj_size,
1491  const size_type& xk_size,
1492  bool xauto_access)
1493 {
1494  // Preconditions:
1495 
1496  require(xauto_access || state_is_read_write_accessible());
1497  require(precondition_of(new_state(host(), xlocal_cell_prototype, xi_size, xj_size, xk_size, xauto_access)));
1498 
1499  // Body:
1500 
1501  new_state(host(), xlocal_cell_prototype_path, xi_size, xj_size, xk_size, xauto_access);
1502 
1503  // Postconditions:
1504 
1505  ensure(postcondition_of(new_state(host(), xlocal_cell_prototype, xi_size, xj_size, xk_size, xauto_access)));
1506 
1507  // Exit
1508 
1509  return;
1510 }
1511 
1512 void
1514 new_state(const base_space_member& xlocal_cell_prototype,
1515  const size_type& xi_size,
1516  const size_type& xj_size,
1517  const size_type& xk_size,
1518  bool xauto_access)
1519 {
1520  // Preconditions:
1521 
1522  require(precondition_of(new_state(host(), xlocal_cell_prototype, xi_size, xj_size, xk_size, xauto_access)));
1523 
1524  // Body:
1525 
1526  new_state(host(), xlocal_cell_prototype, xi_size, xj_size, xk_size, xauto_access);
1527 
1528  // Postconditions:
1529 
1530  ensure(postcondition_of(new_state(host(), xlocal_cell_prototype, xi_size, xj_size, xk_size, xauto_access)));
1531 
1532  // Exit
1533 
1534  return;
1535 }
1536 
1537 
1538 void
1541  const poset_path& xlocal_cell_prototype_path,
1542  const size_type& xi_size,
1543  const size_type& xj_size,
1544  const size_type& xk_size,
1545  bool xauto_access)
1546 {
1547  // Preconditions:
1548 
1549  require(xauto_access ? xhost->is_attached() : xhost->state_is_read_write_accessible());
1550  require(xauto_access || xhost->name_space()->state_is_read_accessible());
1551  require(xlocal_cell_prototype_path.member_exists(xauto_access));
1552  require(xauto_access || xlocal_cell_prototype_path.state_is_read_accessible(xauto_access));
1553 
1554  require(precondition_of(new_state(xhost, xlocal_cell_prototype, xi_size, xj_size, xk_size, xauto_access)));
1555 
1556  // Body:
1557 
1558  base_space_member lproto(xhost->name_space(),
1559  xlocal_cell_prototype_path,
1560  xauto_access);
1561 
1562  new_state(xhost, lproto, xi_size, xj_size, xk_size, xauto_access);
1563 
1564  lproto.detach_from_state();
1565 
1566  // Postconditions:
1567 
1568  ensure(postcondition_of(new_state(host(), xlocal_cell_prototype, xi_size, xj_size, xk_size, xauto_access)));
1569 
1570  // Exit
1571 
1572  return;
1573 }
1574 
1575 void
1578  const base_space_member& xlocal_cell_prototype,
1579  const size_type& xi_size,
1580  const size_type& xj_size,
1581  const size_type& xk_size,
1582  bool xauto_access)
1583 {
1584  // Preconditions:
1585 
1586  require(xhost != 0);
1587  require(xauto_access ? xhost->is_attached() : xhost->in_jim_edit_mode());
1588  require(xauto_access ?
1589  xlocal_cell_prototype.is_attached() :
1590  xlocal_cell_prototype.state_is_read_accessible());
1591  require(xauto_access || xlocal_cell_prototype.name_space()->state_is_read_accessible());
1592 
1593  if(xauto_access)
1594  {
1595  xhost->begin_jim_edit_mode(true);
1596  xlocal_cell_prototype.get_read_access();
1597  xlocal_cell_prototype.name_space()->get_read_access();
1598  }
1599 
1600  require(namespace_is_ancestor_of(xhost->name_space()));
1601  require(xhost->schema().row_conforms_to(standard_schema_path()));
1602  require(xlocal_cell_prototype.state_is_read_accessible());
1603  require(xlocal_cell_prototype.schema().row_conforms_to(xhost->schema()));
1604  require(!xlocal_cell_prototype.host()->is_same_state(xhost));
1605  require(xlocal_cell_prototype.atom_ct() > 0);
1606  require(xlocal_cell_prototype.db() == 3);
1607  require((xlocal_cell_prototype.name().substr(0, 3) == "hex") ||
1608  (xlocal_cell_prototype.name() == "tetra_nodes"));
1609  require(xi_size > 0);
1610  require(xj_size > 0);
1611  require(xk_size > 0);
1612 
1613  // Body:
1614 
1615  // $$HACK: force subposets to be persistent
1616 
1617  make_standard_subposets_persistent(*xhost);
1618 
1619  // Create the connectivity.
1620 
1621  block_connectivity* lconnectivity = 0;
1622 
1623  if(xlocal_cell_prototype.name().substr(0, 3) == "hex")
1624  {
1625  lconnectivity = new hex_connectivity(xi_size, xj_size, xk_size);
1626  }
1627  else
1628  {
1629  // Has to be (xlocal_cell_prototype.name() == "tetra_nodes")
1630  // due to the precondition.
1631  lconnectivity = new tetra_connectivity(xi_size, xj_size, xk_size);
1632  }
1633 
1634 #ifdef DIAGNOSTIC_OUTPUT
1635  cout << *lconnectivity << endl;
1636 #endif
1637 
1638  int* lnode_ids = lconnectivity->node_ids();
1639  int lnode_ids_ub = lconnectivity->node_id_ct();
1640 
1641  new_state(xhost,
1642  xlocal_cell_prototype,
1643  lnode_ids,
1644  lnode_ids_ub,
1645  false);
1646 
1647  delete lconnectivity;
1648 
1649  // Postconditions:
1650 
1651  ensure(postcondition_of(new_state(host(), xlocal_cell_prototype, lnode_ids, lnode_ids_ub, false)));
1652 
1653  // Release access if auto access was requested.
1654 
1655  if(xauto_access)
1656  {
1657  xlocal_cell_prototype.name_space()->release_access();
1658  xlocal_cell_prototype.release_access();
1659  xhost->end_jim_edit_mode(true, true);
1660  }
1661 
1662  // Exit
1663 
1664  return;
1665 }
1666 
1667 // ===========================================================
1668 // ROW DOFS
1669 // ===========================================================
1670 
1671 
1672 // ===========================================================
1673 // OTHER FEATURES
1674 // ===========================================================
1675 
1676 void
1678 refine(const poset_path& xlocal_cell_prototype_path,
1679  const scoped_index* xids,
1680  int xub,
1681  bool xauto_access)
1682 {
1683  // Preconditions:
1684 
1685  require(xauto_access ? is_attached() : state_is_read_write_accessible());
1686  require(xauto_access || name_space()->state_is_read_accessible());
1687  require(xlocal_cell_prototype_path.member_exists(xauto_access));
1688  require(xauto_access || xlocal_cell_prototype_path.state_is_read_accessible(xauto_access));
1689 
1690  require(precondition_of(refine(xlocal_cell_prototype, xids, xub, xauto_access)));
1691 
1692  // Body:
1693 
1694  base_space_member lproto(name_space(),
1695  xlocal_cell_prototype_path,
1696  xauto_access);
1697 
1698  refine(lproto, xids, xub, xauto_access);
1699 
1700  lproto.detach_from_state();
1701 
1702  // Postconditions:
1703 
1704  ensure(postcondition_of(refine(xlocal_cell_prototype, xids, xub, xauto_access)));
1705 
1706  // Exit
1707 
1708  return;
1709 }
1710 
1711 void
1713 refine(const base_space_member& xlocal_cell_prototype,
1714  const scoped_index* xids,
1715  int xub,
1716  bool xauto_access)
1717 {
1718  // Preconditions:
1719 
1720  require(xauto_access ? is_attached() : host()->in_jim_edit_mode());
1721  require(xauto_access ?
1722  xlocal_cell_prototype.is_attached() :
1723  xlocal_cell_prototype.state_is_read_accessible());
1724 
1725  if(xauto_access)
1726  {
1727  get_read_write_access();
1728  xlocal_cell_prototype.get_read_access();
1729  }
1730 
1731  require(is_atom());
1732  require(prototype_path() == static_prototype_path());
1733 
1734  require(xlocal_cell_prototype.schema().row_conforms_to(host()->schema()));
1735  require(!xlocal_cell_prototype.host()->is_same_state(host()));
1736  require(xlocal_cell_prototype.atom_ct() > 0);
1737 
1738  require(xids != 0);
1739  require(xub > 0);
1740  require((xub % xlocal_cell_prototype.atom_ct()) == 0);
1741 
1742  // Body:
1743 
1744  // Build the block;
1745 
1746  if(xauto_access)
1747  {
1748  host()->begin_jim_edit_mode(false);
1749  }
1750 
1751  // Refine the block; assume we don't need to compute the upper cover.
1752 
1753  unstructured_block_builder block_builder;
1754  block_builder.build_block_pa(&xlocal_cell_prototype, xids, xub, this, false, false);
1755 
1756  if(xauto_access)
1757  {
1758  // Exit jim edit mode but do not ensure lattice invariant
1759  // because it is expensive and we don't need to do it -
1760  // the block building routine has properly hooked up everything.
1761  // Don't release access because we still need it below.
1762 
1763  host()->end_jim_edit_mode(false, false);
1764  }
1765 
1766  // Postconditions:
1767 
1768  ensure(db() == xlocal_cell_prototype.db());
1769  ensure(local_cell_type_name() == xlocal_cell_prototype.name());
1770  ensure(size() == xub/xlocal_cell_prototype.atom_ct());
1771 
1772  if(xauto_access)
1773  {
1774  release_access();
1775  xlocal_cell_prototype.release_access();
1776  }
1777 
1778  // Exit
1779 
1780  return;
1781 }
1782 
1783 bool
1786 {
1787  bool result;
1788 
1789  // Preconditions:
1790 
1791  require(xhost.state_is_read_accessible());
1792 
1793  // Body:
1794 
1795  // $$HACK: unstructured_block hack.
1796 
1797  // If new_host created xhost, it's actually a base_space_poset
1798  // and the standard subposets, vertices in particular, are persisent.
1799 
1800  const base_space_poset* lhost = dynamic_cast<const base_space_poset*>(&xhost);
1801 
1802  result = (lhost != 0) && lhost->vertices().is_persistent();
1803 
1804  // Postconditions:
1805 
1806 
1807  // Exit:
1808 
1809  return result;
1810 }
1811 
1812 void
1815 {
1816 
1817  // Preconditions:
1818 
1819  require(xhost.state_is_read_accessible());
1820 
1821  // Body:
1822 
1823  base_space_poset* lhost = dynamic_cast<base_space_poset*>(&xhost);
1824 
1825  // @hack unstructured_block hack.
1826  // The standard subposets created by base_space_poset are now volatile
1827  // by default, but unstructured_block has no mechanism for recreating
1828  // them when read from a file. So they must be made persistent.
1829 
1830  lhost->get_read_write_access();
1831  lhost->blocks().put_is_persistent(true);
1832  lhost->block_vertices().put_is_persistent(true);
1833  lhost->cells().put_is_persistent(true);
1834  for(int_type i=0; i<=lhost->max_db(); ++i)
1835  {
1836  lhost->d_cells(i).put_is_persistent(true);
1837  }
1838  lhost->release_access();
1839 
1840  // Postconditions:
1841 
1842  // Exit:
1843 }
1844 
1845 // ===========================================================
1846 // PROTECTED MEMBER FUNCTIONS
1847 // ===========================================================
1848 
1849 // ===========================================================
1850 // PRIVATE MEMBER FUNCTIONS
1851 // ===========================================================
1852 
OBSOLETE: use zone_nodes_block or point_block_*d. A builder object for constructing unstructured bloc...
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...
static host_type & new_host(namespace_type &xns, const poset_path &xhost_path, const poset_path &xschema_path, int xmax_db, bool xauto_access)
Creates a new host poset for members of this type. The poset is created in namespace xns with path xh...
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 ...
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...
bool full() const
True if both poset name and member name are not empty.
Definition: poset_path.cc:311
int db() const
The base space dimension.
bool state_is_read_accessible(bool xauto_access) const
Definition: poset_path.cc:1103
bool is_persistent() const
True if this id space should be written to disk.
Definition: subposet.cc:645
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...
virtual unstructured_block * clone() const
Make a new handle, no state instance of current.
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...
A client handle for a general, abstract partially order set.
size_type node_id_ct() const
The number of entries in node_ids().
virtual int atom_ct() const
The number of members in the set of atoms contained in the down set of this member.
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
virtual unstructured_block & operator=(const abstract_poset_member &xother)
Assignment operator; attaches this to the same state as xother.
Zone to node connectivity relation for a block of zones of a given type.
virtual void get_read_access() const
Get read access to the state associated with this.
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.
virtual namespace_poset * name_space() const
The namespace of host()
std::string name() const
A name for this.
OBSOLETE: use zone_nodes_block or point_block_*d. A client handle for a base space member which repre...
static const std::string & prototypes_poset_name()
The name of the prototypes poset.
Nodal connectivity for a block containing zones of type tetra.
pod_index_type * node_ids()
The nodal connectivity array.
A client handle for a member of a base space poset.
Nodal connectivity for a block containing zones of type triangle.
static host_type & standard_host(namespace_type &xns, const poset_path &xhost_path, int xmax_db, bool xauto_access)
The host with path xhost_path. Returns the host if it already exists, otherwise, creates it in namesp...
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...
Abstract base class with useful features for all objects.
Definition: any.h:39
The lattice of closed cells of a cellular space; a lattice representation of a computational mesh...
virtual schema_poset_member & schema()
The schema for this poset (mutable version).
virtual bool has_name(const std::string &xname, bool xauto_access=false) const
True if xname is a name for this.
virtual bool invariant() const
Class invariant.
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...
A client handle for a mutable partially ordered set.
Definition: poset.h:40
poset * host() const
The poset which this is a handle to a member of.
subposet & vertices()
The subposet containing all the vertices, that is, the cells of dimension 0 (mutable version)...
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_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
bool contains_path(const poset_path &xpath, bool xauto_access=true) const
True if this contains the poset or poset member specified by xpath.
Nodal connectivity for a block containing zones of type hex.
static void make_standard_subposets_persistent(poset_state_handle &xhost)
Make the standard subposets created by base_space_poset persistent.
bool empty() const
True if both poset name and member name are empty.
Definition: poset_path.cc:291
Nodal connectivity for a block containing zones of type segment.
virtual void detach_from_state()
Detach this handle from its state, if any.
namespace_poset * name_space() const
The namespace this poset resides in.
virtual bool is_attached() const
True if this is attached to a state.
bool member_exists(bool xauto_access) const
Definition: poset_path.cc:1079
Nodal connectivity for a block containing zones of type quad.
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 ~unstructured_block()
Destructor; deletes a poset member and its attached state, if any.
unstructured_block()
Default constructor; creates a new, unattached unstructured_block handle.
static const poset_path & static_prototype_path()
The path of the prototype required by this class.
virtual void new_state(poset *xhost, const std::string &xlocal_cell_prototype_name, bool xauto_access)
Creates a new unrefined (jim) unstructured block state in xhost and attaches this to it...
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
bool is_same_state(const poset_state_handle *xother) const
True if this is attached to the same state as xother.
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
static bool host_created_with_new_host(const poset_state_handle &xhost)
True if host created with unstructured_block::new_host. $$HACK: unstructured_block hack; checks for p...
Nodal connectivity for a block containing zones of type point. Since a point block is just a collecti...
int max_db() const
The maximum dimension of the members of this base space.
An abstract client handle for a member of a poset.
int int_type
The preferred integer type.
Definition: sheaf.h:41
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...
bool in_jim_edit_mode() const
True if editing jims and jim order relation is allowed.
virtual schema_poset_member & schema()
The schema for this member (mutable version).
An array representation of abstract class poset_dof_map.
Namespace for the fiber_bundles component of the sheaf system.
void refine(const poset_path &xlocal_cell_prototype_path, const scoped_index *ids, int xub, bool xauto_access)
Refines this (which must be an atom) into copies of the down set of the cell specified by xlocal_cell...
void build_block_pa(const base_space_member *xtemplate, const int *xglue, size_type xglue_ub, unstructured_block *result, bool xcompute_upper_cover, bool xauto_access)
Build the unstructured block result using local cell template xtemplate and the atomic equivalences (...
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...
virtual bool is_ancestor_of(const any *other) const
True if other conforms to this.
virtual void begin_jim_edit_mode(bool xauto_access=true)
Allow editing of jims and jim order relation.
Definition: poset.cc:230