SheafSystem  0.0.0.0
field_factory_2.impl.h
Go to the documentation of this file.
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
20 
21 #ifndef FIELD_FACTORY_2_IMPL_H
22 #define FIELD_FACTORY_2_IMPL_H
23 
24 #ifndef SHEAF_DLL_SPEC_H
25 #include "SheafSystem/sheaf_dll_spec.h"
26 #endif
27 
28 #ifndef FIELD_FACTORY_2_H
29 #include "SheafSystem/field_factory_2.h"
30 #endif
31 
32 #ifndef ASSERT_CONTRACT_H
33 #include "SheafSystem/assert_contract.h"
34 #endif
35 
36 #ifndef BASE_SPACE_MEMBER_H
37 #include "SheafSystem/base_space_member.h"
38 #endif
39 
40 #ifndef ERROR_MESSAGE_H
41 #include "SheafSystem/error_message.h"
42 #endif
43 
44 #ifndef FIBER_BUNDLES_NAMESPACE_H
45 #include "SheafSystem/fiber_bundles_namespace.h"
46 #endif
47 
48 #ifndef POINT_BLOCK_1D_H
49 #include "SheafSystem/point_block_1d.h"
50 #endif
51 
52 #ifndef POINT_BLOCK_2D_H
53 #include "SheafSystem/point_block_2d.h"
54 #endif
55 
56 #ifndef POINT_BLOCK_3D_H
57 #include "SheafSystem/point_block_3d.h"
58 #endif
59 
60 #ifndef SEC_E1_UNIFORM_H
61 #include "SheafSystem/sec_e1_uniform.h"
62 #endif
63 
64 #ifndef SEC_E2_UNIFORM_H
65 #include "SheafSystem/sec_e2_uniform.h"
66 #endif
67 
68 #ifndef SEC_E3_UNIFORM_H
69 #include "SheafSystem/sec_e3_uniform.h"
70 #endif
71 
72 #ifndef SECTION_TRAITS_H
73 #include "SheafSystem/section_traits.h"
74 #endif
75 
76 #ifndef STRUCTURED_BLOCK_1D_H
77 #include "SheafSystem/structured_block_1d.h"
78 #endif
79 
80 #ifndef STRUCTURED_BLOCK_2D_H
81 #include "SheafSystem/structured_block_2d.h"
82 #endif
83 
84 #ifndef STRUCTURED_BLOCK_3D_H
85 #include "SheafSystem/structured_block_3d.h"
86 #endif
87 
88 #ifndef UNSTRUCTURED_BLOCK_H
89 #include "SheafSystem/unstructured_block.h"
90 #endif
91 
92 #include "SheafSystem/sec_e1.h"
93 #include "SheafSystem/sec_e2.h"
94 #include "SheafSystem/sec_e3.h"
95 
96 #include "SheafSystem/sec_at0.h"
97 #include "SheafSystem/sec_at0_space.h"
98 #include "SheafSystem/sec_at1_space.h"
99 #include "SheafSystem/section_space_schema_poset.h"
100 
101 
102 namespace
103 {
104 
105 using namespace fiber_bundle;
106 
107 //
108 // Sets the dofs implied by vertex index bound xi_size
109 // and dof bounds xlb, xub into section xsec.
110 //
111 void put_dofs(sec_e1* xsec,
112  size_type xi_size,
115 {
116  // Preconditions:
117 
118  require(xi_size > 0);
119  require(xlb.ct() >= 1);
120  require(xub.ct() >= 1);
121 
122  // Body:
123 
124  sec_vd_dof_type ldelx = (xub[0] - xlb[0])/(xi_size-1);
125  int i_ct = xi_size;
126 
128  for(int i=0; i<i_ct; ++i)
129  {
130  lfiber[0] = xlb[0] + i*ldelx;
131  xsec->put_fiber(i, lfiber);
132  }
133 
134  // Postconditions:
135 
136  // Exit:
137 
138  return;
139 }
140 
141 //
142 // Sets the dofs implied by vertex index bounds xi_size, xj_size
143 // and dof bounds xlb, xub into section xsec.
144 //
145 void put_dofs(sec_e2* xsec,
146  size_type xi_size,
147  size_type xj_size,
150 {
151  // Preconditions:
152 
153  require(xi_size > 0);
154  require(xj_size > 0);
155  require(xlb.ct() >= 2);
156  require(xub.ct() >= 2);
157 
158  // Body:
159 
160  sec_vd_dof_type ldelx = (xub[0] - xlb[0])/(xi_size-1);
161  int i_ct = xi_size;
162 
163  sec_vd_dof_type ldely = (xub[1] - xlb[1])/(xj_size-1);
164  int j_ct = xj_size;
165 
167 
168  pod_index_type ldisc_id;
169  for(int i=0; i<i_ct; ++i)
170  {
171  lfiber[0] = xlb[0] + i*ldelx;
172  for(int j=0; j<j_ct; ++j)
173  {
174  ldisc_id = i*j_ct+j;
175  lfiber[1] = xlb[1] + j*ldely;
176  xsec->put_fiber(ldisc_id, lfiber);
177  }
178  }
179 
180  // Postconditions:
181 
182  // Exit:
183 
184  return;
185 }
186 
187 //
188 // Sets the dofs implied by vertex index bounds xi_size,
189 // xj_size, xk_size and dof bounds xlb, xub into section xsec.
190 //
191 void put_dofs(sec_e3* xsec,
192  size_type xi_size,
193  size_type xj_size,
194  size_type xk_size,
197 {
198  // Preconditions:
199 
200  require(xi_size > 0);
201  require(xj_size > 0);
202  require(xlb.ct() >= 3);
203  require(xub.ct() >= 3);
204 
205  // Body:
206 
207  sec_vd_dof_type ldelx = (xub[0] - xlb[0])/(xi_size-1);
208  int i_ct = xi_size;
209 
210  sec_vd_dof_type ldely = (xub[1] - xlb[1])/(xj_size-1);
211  int j_ct = xj_size;
212 
213  sec_vd_dof_type ldelz = (xub[2] - xlb[2])/(xk_size-1);
214  int k_ct = xk_size;
215 
217 
218  pod_index_type ldisc_id;
219 
220  for(int i=0; i<i_ct; ++i)
221  {
222  lfiber[0] = xlb[0] + i*ldelx;
223  for(int j=0; j<j_ct; ++j)
224  {
225  lfiber[1] = xlb[1] + j*ldely;
226  for(int k=0; k<k_ct; ++k)
227  {
228  lfiber[2] = xlb[2] + k*ldelz;
229  ldisc_id = (i*j_ct+j)*k_ct + k;
230  xsec->put_fiber(ldisc_id, lfiber);
231  }
232  }
233  }
234 
235  // Postconditions:
236 
237  // Exit:
238 
239  return;
240 }
241 
242 //
243 // Initializes section dofs from xlb and xub.
244 //
245 void
246 put_bounds(sec_e1* xsec,
247  block<int> xbase_index_ubs,
250 {
251  // Preconditions:
252 
253  // Body:
254 
255  using namespace std;
256 
257  xsec->get_read_write_access(true);
258 
259  // Set the coordinate dofs from the bounds if we know how.
260 
261  base_space_poset& lbase_host = xsec->schema().host()->base_space();
262  pod_index_type lbase_id = xsec->schema().base_space_id();
263 
264  if(lbase_host.is_jim(lbase_id, false))
265  {
266  // The base space is a jim, may be able to set the dofs.
267  // Check the bounds cts.
268 
270 
271  if((xsec->schema().df() == 1) && (xlb.ct() == 1) && (xub.ct() == 1))
272  {
273  // Bounds are ok; get the cell type for the base space.
274 
275  string lbase_type_name(lbase_host.type_name(lbase_id));
276  if((lbase_type_name == "structured_block_1d"))
277  {
278  // The base space is a structured_block_1d and
279  // the user has provided appropriate bounds.
280  // We know how to set the coordinates from the bounds.
281  // The number of "vertices" is the number of "zones" + 1.
282 
283  structured_block_1d lbase(&lbase_host, lbase_id);
284  put_dofs(xsec, lbase.i_size()+1, xlb, xub);
285  lbase.detach_from_state();
286  }
287  else if((lbase_type_name == "point_block_1d"))
288  {
289  // The base space is a point_block_1d and
290  // the user has provided appropriate bounds.
291  // We know how to set the coordinates from the bounds.
292 
293  point_block_1d lbase(&lbase_host, lbase_id);
294  put_dofs(xsec, lbase.i_size(), xlb, xub);
295  lbase.detach_from_state();
296  }
297  }
298  }
299  else
300  {
301  // The base space is not a jim, don't know how to set the dofs.
302  }
303 
304  xsec->release_access();
305 
306  // Postconditions:
307 
308  // Exit:
309 
310  return;
311 }
312 
313 //
314 // Sets the uniform coordinate dof bounds xlb, xub into section xsec.
315 //
316 void
317 put_bounds(sec_e1_uniform* xsec,
318  block<int> xbase_index_ubs,
321 {
322  if((xlb.ct() == 1) && (xub.ct() == 1))
323  {
324  xsec->put_bounds(xlb[0], xub[0], true);
325  }
326 }
327 
328 //
329 // Initializes section dofs from xlb and xub.
330 //
331 void
332 put_bounds(sec_e2* xsec,
333  block<int> xbase_index_ubs,
336 {
337  // Preconditions:
338 
339  // Body:
340 
341  using namespace std;
342 
343  xsec->get_read_write_access(true);
344 
345  // Set the coordinate dofs from the bounds if we know how.
346 
347  base_space_poset& lbase_host = xsec->schema().host()->base_space();
348  pod_index_type lbase_id = xsec->schema().base_space_id();
349 
350  if(lbase_host.is_jim(lbase_id, false))
351  {
352  // The base space is a jim, may be able to set the dofs.
353  // Check the bounds cts.
354 
356 
357  if((xsec->schema().df() == 2) && (xlb.ct() == 2) && (xub.ct() == 2))
358  {
359  // Bounds are ok; get the cell type for the base space.
360 
361  string lbase_type_name(lbase_host.type_name(lbase_id));
362  if(lbase_type_name == "structured_block_2d")
363  {
364  // The base space is a structured_block_2d and
365  // the user has provided appropriate bounds.
366  // We know how to set the coordinates from the bounds.
367  // The number of "vertices" is the number of "zones" + 1.
368 
369  structured_block_2d lbase(&lbase_host, lbase_id);
370  put_dofs(xsec, lbase.i_size()+1, lbase.j_size()+1, xlb, xub);
371  lbase.detach_from_state();
372  }
373  else if(lbase_type_name == "point_block_2d")
374  {
375  // The base space is a point_block_2d and
376  // the user has provided appropriate bounds.
377  // We know how to set the coordinates from the bounds.
378 
379  point_block_2d lbase(&lbase_host, lbase_id);
380  put_dofs(xsec, lbase.i_size(), lbase.j_size(), xlb, xub);
381  lbase.detach_from_state();
382  }
383  }
384  }
385  else
386  {
387  // The base space is not a jim, don't know how to set the dofs.
388  }
389 
390  xsec->release_access();
391 
392  // Postconditions:
393 
394  // Exit:
395 
396  return;
397 }
398 
399 //
400 // Sets the uniform coordinate dof bounds xlb, xub into section xsec.
401 //
402 void
403 put_bounds(sec_e2_uniform* xsec,
404  block<int> xbase_index_ubs,
407 {
408  if((xlb.ct() == 2) && (xub.ct() == 2))
409  {
410  xsec->put_bounds(xlb, xub, true);
411  }
412 }
413 
414 //
415 // Initializes section dofs from xlb and xub.
416 //
417 void
418 put_bounds(sec_e3* xsec,
419  block<int> xbase_index_ubs,
422 {
423  // Preconditions:
424 
425  // Body:
426 
427  using namespace std;
428 
429  xsec->get_read_write_access(true);
430 
431  // Set the coordinate dofs from the bounds if we know how.
432 
433  base_space_poset& lbase_host = xsec->schema().host()->base_space();
434  pod_index_type lbase_id = xsec->schema().base_space_id();
435 
436  if(lbase_host.is_jim(lbase_id, false))
437  {
438  // The base space is a jim, may be able to set the dofs.
439  // check the bounds.
440 
441  if((xsec->schema().df() == 3) && (xlb.ct() == 3) && (xub.ct() == 3))
442  {
443  // Bounds are ok; get the cell type for the base space.
444 
445  string lbase_type_name(lbase_host.type_name(lbase_id));
446  if(lbase_type_name == "structured_block_3d")
447  {
448  // The base space is a structured_block_3d and
449  // the user has provided appropriate bounds.
450  // We know how to set the coordinates from the bounds.
451  // The number of "vertices" is the number of "zones" + 1.
452 
453  structured_block_3d lbase(&lbase_host, lbase_id);
454  put_dofs(xsec, lbase.i_size()+1, lbase.j_size()+1, lbase.k_size()+1, xlb, xub);
455  lbase.detach_from_state();
456  }
457  else if(lbase_type_name == "point_block_3d")
458  {
459  // The base space is a point_block_3d and
460  // the user has provided appropriate bounds.
461  // We know how to set the coordinates from the bounds.
462 
463  point_block_3d lbase(&lbase_host, lbase_id);
464  put_dofs(xsec, lbase.i_size(), lbase.j_size(), lbase.k_size(), xlb, xub);
465  lbase.detach_from_state();
466  }
467  }
468  }
469  else
470  {
471  // The base space is not a jim, don't know how to set the dofs.
472  }
473 
474  xsec->release_access();
475 
476  // Postconditions:
477 
478  // Exit:
479 
480  return;
481 }
482 
483 //
484 // Sets the uniform coordinate dof bounds xlb, xub into section xsec.
485 //
486 void
487 put_bounds(sec_e3_uniform* xsec,
488  block<int> xbase_index_ubs,
491 {
492  if((xlb.ct() == 3) && (xub.ct() == 3))
493  {
494  xsec->put_bounds(xlb, xub, true);
495  }
496 }
497 
498 } // unnamed namespace
499 
500 
501 namespace fields
502 {
503 
507 template <typename base_type>
508 void
510  const poset_path& xbase_path,
511  const wsv_block<int>& xbase_index_ubs,
512  poset_path& xlocal_cell_prototype_path,
513  base_type& xresult)
514 {
515  // Preconditions:
516 
517  require(xns.state_is_read_accessible());
518  require(xbase_path.full());
519  require(xns.contains_poset_member(xbase_path, true));
520 
521 
522  // Body:
523 
524  xresult.attach_to_state(&xns, xbase_path);
525 
526  // Get
527 
528  // Postconditions:
529 
530  ensure(xns.contains_poset_member(xbase_path, true));
531 
532  // Exit:
533 
534  return;
535 }
536 
541 template <>
542 void
544  const poset_path& xbase_path,
545  const wsv_block<int>& xbase_index_ubs,
546  poset_path& xlocal_cell_prototype_path,
547  structured_block_1d& xresult)
548 {
549  // Preconditions:
550 
551  require(xns.state_is_read_write_accessible());
552  require(xbase_path.full());
553  require(xns.contains_poset_member(xbase_path, true) || xbase_index_ubs.ct() >= 1);
554 
555  // Body:
556 
557  if(xns.contains_poset_member(xbase_path, true))
558  {
559  xresult.attach_to_state(&xns, xbase_path);
560  }
561  else
562  {
563  base_space_poset* lhost;
564 
565  if(xns.contains_poset(xbase_path, false))
566  {
567  lhost = dynamic_cast<base_space_poset*>(&xns.member_poset(xbase_path, false));
568  }
569  else
570  {
571  lhost = &structured_block_1d::standard_host(xns, xbase_path.poset_name(), false);
572  }
573 
574  xresult.new_state(lhost, xbase_index_ubs[0], true);
575  xresult.put_name(xbase_path.member_name(), true, true);
576  }
577 
578  // Postconditions:
579 
580  ensure(xns.contains_poset_member(xbase_path, true));
581 
582  // Exit:
583 
584  return;
585 }
586 
591 template <>
592 void
594  const poset_path& xbase_path,
595  const wsv_block<int>& xbase_index_ubs,
596  poset_path& xlocal_cell_prototype_path,
597  structured_block_2d& xresult)
598 {
599  // Preconditions:
600 
601  require(xns.state_is_read_write_accessible());
602  require(xbase_path.full());
603  require(xns.contains_poset_member(xbase_path, true) || xbase_index_ubs.ct() >= 2);
604 
605  // Body:
606 
607  if(xns.contains_poset_member(xbase_path, true))
608  {
609  xresult.attach_to_state(&xns, xbase_path);
610  }
611  else
612  {
613  base_space_poset* lhost;
614 
615  if(xns.contains_poset(xbase_path, false))
616  {
617  lhost = dynamic_cast<base_space_poset*>(&xns.member_poset(xbase_path, false));
618  }
619  else
620  {
621  lhost = &structured_block_2d::standard_host(xns, xbase_path.poset_name(), false);
622  }
623 
624  xresult.new_state(lhost, xbase_index_ubs[0], xbase_index_ubs[1], true);
625  xresult.put_name(xbase_path.member_name(), true, true);
626  }
627 
628 
629 
630  // Postconditions:
631 
632  ensure(xns.contains_poset_member(xbase_path, true));
633 
634  // Exit:
635 
636  return;
637 }
638 
643 template <>
644 void
646  const poset_path& xbase_path,
647  const wsv_block<int>& xbase_index_ubs,
648  poset_path& xlocal_cell_prototype_path,
649  structured_block_3d& xresult)
650 {
651  // Preconditions:
652 
653  require(xns.state_is_read_write_accessible());
654  require(xbase_path.full());
655  require(xns.contains_poset_member(xbase_path, true) || xbase_index_ubs.ct() >= 3);
656 
657  // Body:
658 
659  if(xns.contains_poset_member(xbase_path, true))
660  {
661  xresult.attach_to_state(&xns, xbase_path);
662  }
663  else
664  {
665  base_space_poset* lhost;
666 
667  if(xns.contains_poset(xbase_path, false))
668  {
669  lhost = dynamic_cast<base_space_poset*>(&xns.member_poset(xbase_path, false));
670  }
671  else
672  {
673  lhost = &structured_block_3d::standard_host(xns, xbase_path.poset_name(), false);
674  }
675 
676  xresult.new_state(lhost,
677  xbase_index_ubs[0],
678  xbase_index_ubs[1],
679  xbase_index_ubs[2],
680  true);
681  xresult.put_name(xbase_path.member_name(), true, true);
682  }
683 
684  // Postconditions:
685 
686  ensure(xns.contains_poset_member(xbase_path, true));
687 
688  // Exit:
689 
690  return;
691 }
692 
697 template <>
698 void
700  const poset_path& xbase_path,
701  const wsv_block<int>& xbase_index_ubs,
702  poset_path& xlocal_cell_prototype_path,
703  point_block_1d& xresult)
704 {
705  // Preconditions:
706 
707  require(xns.state_is_read_write_accessible());
708  require(xbase_path.full());
709  require(xns.contains_poset_member(xbase_path, true) || xbase_index_ubs.ct() >= 1);
710 
711  // Body:
712 
713  if(xns.contains_poset_member(xbase_path, true))
714  {
715  xresult.attach_to_state(&xns, xbase_path);
716  }
717  else
718  {
719  base_space_poset* lhost;
720 
721  if(xns.contains_poset(xbase_path, false))
722  {
723  lhost = dynamic_cast<base_space_poset*>(&xns.member_poset(xbase_path, false));
724  }
725  else
726  {
727  lhost = &point_block_1d::standard_host(xns, xbase_path.poset_name(), false);
728  }
729 
730  xresult.new_state(lhost, xbase_index_ubs[0], true);
731  xresult.put_name(xbase_path.member_name(), true, true);
732  }
733 
734  // Postconditions:
735 
736  ensure(xns.contains_poset_member(xbase_path, true));
737 
738  // Exit:
739 
740  return;
741 }
742 
747 template <>
748 void
750  const poset_path& xbase_path,
751  const wsv_block<int>& xbase_index_ubs,
752  poset_path& xlocal_cell_prototype_path,
753  point_block_2d& xresult)
754 {
755  // Preconditions:
756 
757  require(xns.state_is_read_write_accessible());
758  require(xbase_path.full());
759  require(xns.contains_poset_member(xbase_path, true) || xbase_index_ubs.ct() >= 2);
760 
761  // Body:
762 
763  if(xns.contains_poset_member(xbase_path, true))
764  {
765  xresult.attach_to_state(&xns, xbase_path);
766  }
767  else
768  {
769  base_space_poset* lhost;
770 
771  if(xns.contains_poset(xbase_path, false))
772  {
773  lhost = dynamic_cast<base_space_poset*>(&xns.member_poset(xbase_path, false));
774  }
775  else
776  {
777  lhost = &point_block_2d::standard_host(xns, xbase_path.poset_name(), false);
778  }
779 
780  xresult.new_state(lhost, xbase_index_ubs[0], xbase_index_ubs[1], true);
781  xresult.put_name(xbase_path.member_name(), true, true);
782  }
783 
784  // Postconditions:
785 
786  ensure(xns.contains_poset_member(xbase_path, true));
787 
788  // Exit:
789 
790  return;
791 }
792 
797 template <>
798 void
800  const poset_path& xbase_path,
801  const wsv_block<int>& xbase_index_ubs,
802  poset_path& xlocal_cell_prototype_path,
803  point_block_3d& xresult)
804 {
805  // Preconditions:
806 
807  require(xns.state_is_read_write_accessible());
808  require(xbase_path.full());
809  require(xns.contains_poset_member(xbase_path, true) || xbase_index_ubs.ct() >= 3);
810 
811  // Body:
812 
813  if(xns.contains_poset_member(xbase_path, true))
814  {
815  xresult.attach_to_state(&xns, xbase_path);
816  }
817  else
818  {
819  base_space_poset* lhost;
820 
821  if(xns.contains_poset(xbase_path, false))
822  {
823  lhost = dynamic_cast<base_space_poset*>(&xns.member_poset(xbase_path, false));
824  }
825  else
826  {
827  lhost = &point_block_3d::standard_host(xns, xbase_path.poset_name(), false);
828  }
829 
830  xresult.new_state(lhost,
831  xbase_index_ubs[0],
832  xbase_index_ubs[1],
833  xbase_index_ubs[2],
834  true);
835  xresult.put_name(xbase_path.member_name(), true, true);
836  }
837 
838  // Postconditions:
839 
840  ensure(xns.contains_poset_member(xbase_path, true));
841 
842  // Exit:
843 
844  return;
845 }
846 
847 
852 template <>
853 void
855  const poset_path& xbase_path,
856  const wsv_block<int>& xbase_index_ubs,
857  poset_path& xlocal_cell_prototype_path,
858  unstructured_block& xresult)
859 {
860  // Preconditions:
861 
862  require(xns.state_is_read_write_accessible());
863  require(xbase_path.full());
864  require(xns.contains_poset_member(xbase_path, true) ||
865  ((1 <= xbase_index_ubs.ct()) && (xbase_index_ubs.ct() <= 3)));
866 
867  // Body:
868 
869  using namespace std;
870 
871  if(xns.contains_poset_member(xbase_path))
872  {
873  xresult.attach_to_state(&xns, xbase_path);
874  }
875  else
876  {
877  int ldb = xbase_index_ubs.ct();
878 
879  base_space_poset* lhost;
880 
881  if(xns.contains_poset(xbase_path, true))
882  {
883  lhost = dynamic_cast<base_space_poset*>(&xns.member_poset(xbase_path, false));
884  }
885  else
886  {
887  lhost = &unstructured_block::standard_host(xns, xbase_path.poset_name(), ldb, false);
888  }
889 
890  string lposet_name(base_space_member::prototypes_poset_name());
891 
892  switch(ldb)
893  {
894  case 0:
895  {
896  int lpt_ct = 1;
897  for(int i=0; i< xbase_index_ubs.ct(); ++i)
898  {
899  lpt_ct *= xbase_index_ubs.ct();
900  }
901  xresult.new_state(lhost, xlocal_cell_prototype_path, lpt_ct, true);
902  }
903  break;
904  case 1:
905  if(xlocal_cell_prototype_path.empty())
906  {
907  xlocal_cell_prototype_path.put_poset_name(lposet_name);
908  xlocal_cell_prototype_path.put_member_name("segment_complex");
909  }
910 
911  xresult.new_state(lhost,
912  xlocal_cell_prototype_path,
913  xbase_index_ubs[0],
914  true);
915  break;
916  case 2:
917  if(xlocal_cell_prototype_path.empty())
918  {
919  xlocal_cell_prototype_path.put_poset_name(lposet_name);
920  xlocal_cell_prototype_path.put_member_name("quad_nodes");
921  }
922  xresult.new_state(lhost,
923  xlocal_cell_prototype_path,
924  xbase_index_ubs[0],
925  xbase_index_ubs[1],
926  true);
927  break;
928  case 3:
929  if(xlocal_cell_prototype_path.empty())
930  {
931  xlocal_cell_prototype_path.put_poset_name(lposet_name);
932  xlocal_cell_prototype_path.put_member_name("hex_nodes");
933  }
934  xresult.new_state(lhost,
935  xlocal_cell_prototype_path,
936  xbase_index_ubs[0],
937  xbase_index_ubs[1],
938  xbase_index_ubs[2],
939  true);
940  break;
941  default:
942  post_fatal_error_message("Unsupported base dimension");
943  break;
944  }
945 
946  xresult.put_name(xbase_path.member_name(), true, true);
947  }
948 
949  // Postconditions:
950 
951  ensure(xns.contains_poset_member(xbase_path, true));
952 
953  // Exit:
954 
955  return;
956 }
957 
958 
959 //=============================================================================
960 // FIELD_FACTORY_2 FACET
961 //=============================================================================
962 
963 // PUBLIC MEMBERS
964 
965 template <typename coord_type, typename prop_type, typename base_type>
968 {
969 
970  // Preconditions:
971 
972  // Body:
973 
974  // Postconditions:
975 
976  // Exit:
977 
978  return;
979 }
980 
981 
982 template <typename coord_type, typename prop_type, typename base_type>
985 {
986  // Preconditions:
987 
988 
989  // Body:
990 
991  // Nothing to do.
992 
993  // Postconditions:
994 
995  // Exit:
996 
997  return;
998 }
999 
1000 
1001 template <typename coord_type, typename prop_type, typename base_type>
1005  const poset_path& xbase_path,
1006  const poset_path& xcoord_path,
1007  const poset_path& xprop_path,
1008  bool xauto_access)
1009 {
1010  field_type* result;
1011 
1012  // Preconditions:
1013 
1014  require(xns.state_is_auto_read_write_accessible(xauto_access));
1015 
1016  require(xbase_path.full());
1017  require(unexecutable("base exists or index_ubs compatible with base_type"));
1018 
1019  require(xcoord_path.full());
1020  require(xns.path_is_auto_read_write_accessible<typename coord_type::host_type>(xcoord_path.poset_name(), xauto_access));
1021 
1022  require(xprop_path.full());
1023  require(xns.path_is_auto_read_write_accessible<typename prop_type::host_type>(xprop_path.poset_name(), xauto_access));
1024 
1025  // Body:
1026 
1027  using namespace std;
1028 
1029  if(xauto_access)
1030  {
1031  xns.get_read_write_access();
1032  }
1033 
1034  // Find or create the base space.
1035 
1036  poset_path llocal_cell_prototype_path(_local_cell_prototype_path);
1037 
1039  {
1041  make_base_space(xns,
1042  xbase_path,
1043  _base_index_ubs,
1044  llocal_cell_prototype_path,
1045  lbase);
1046  lbase.detach_from_state();
1047  }
1048  else
1049  {
1050  base_type lbase;
1051  make_base_space(xns,
1052  xbase_path,
1053  _base_index_ubs,
1054  llocal_cell_prototype_path,
1055  lbase);
1056  lbase.detach_from_state();
1057  }
1058 
1059  // Find the coordinates section space.
1060 
1061  typename coord_type::host_type& lcoords_host =
1062  xns.member_poset<typename coord_type::host_type>(xcoord_path, false);
1063 
1064  // Find or create the coordinate section.
1065 
1066  string lcoord_name(xcoord_path.member_name());
1067 
1068  coord_type lcoords;
1069  if(lcoords_host.contains_member(lcoord_name))
1070  {
1071  lcoords_host.get_read_access();
1072  lcoords.attach_to_state(&lcoords_host, lcoord_name);
1073  lcoords_host.release_access();
1074  }
1075  else
1076  {
1077  lcoords.new_jim_state(&lcoords_host);
1078  lcoords.put_name(lcoord_name, true, true);
1079  put_bounds(&lcoords, _base_index_ubs, _coord_lb, _coord_ub);
1080  }
1081 
1082  // Find property section space.
1083 
1084  typename prop_type::host_type& lprop_host =
1085  xns.member_poset<typename prop_type::host_type>(xprop_path, false);
1086 
1087  // Find or create the property section.
1088 
1089  string lprop_name(xprop_path.member_name());
1090 
1091  prop_type lprop;
1092  if(lprop_host.contains_member(lprop_name))
1093  {
1094  lprop_host.get_read_access();
1095  lprop.attach_to_state(&lprop_host, lprop_name);
1096  lprop_host.release_access();
1097  }
1098  else
1099  {
1100  lprop.new_jim_state(&lprop_host);
1101  lprop.put_name(lprop_name, true, true);
1102  }
1103 
1104  // Create the field.
1105 
1106  result = new field_type(xns, lcoords.path(), lprop.path(), true);
1107 
1108  // Clean up.
1109 
1110  lcoords.detach_from_state();
1111  lprop.detach_from_state();
1112 
1113  if(xauto_access)
1114  {
1115  xns.release_access();
1116  }
1117 
1118  // Postconditions:
1119 
1120  ensure(result->base_space().path(true) == xbase_path);
1121  ensure(result->coordinates().path(true) == xcoord_path);
1122  ensure(result->property().path(true) == xprop_path);
1123 
1124  // Exit:
1125 
1126  return result;
1127 }
1128 
1129 template <typename coord_type, typename prop_type, typename base_type>
1133  const poset_path& xbase_path,
1134  const std::string& xcoord_name,
1135  const std::string& xprop_name,
1136  bool xauto_access)
1137 {
1138  field_type* result;
1139 
1140  // Preconditions:
1141 
1142  require(xns.state_is_auto_read_write_accessible(xauto_access));
1143 
1144  require(xbase_path.full());
1145  require(unexecutable("base exists or index_ubs compatible with base_type"));
1146 
1147  require(poset_path::is_valid_name(xcoord_name));
1148  require(poset_path::is_valid_name(xprop_name));
1149 
1150  require(coord_rep_path().empty() || coord_rep_path().full());
1151  require(coord_rep_path().empty() || xns.path_is_auto_read_accessible<sec_rep_descriptor_poset>(coord_rep_path(), xauto_access));
1152 
1153  require(coord_fiber_suffix().empty() || poset_path::is_valid_name(coord_fiber_suffix()));
1154  require(coord_type::fiber_type::template standard_host_is_available<typename coord_type::fiber_type>(xns, coord_fiber_suffix(), xauto_access));
1155 
1156  require(coord_section_suffix().empty() || poset_path::is_valid_name(coord_section_suffix()));
1157  require(coord_type::template standard_host_is_available<coord_type>(xns, xbase_path, coord_rep_path(), coord_section_suffix(), coord_fiber_suffix(), xauto_access));
1158 
1159  require(prop_rep_path().empty() || prop_rep_path().full());
1160  require(prop_rep_path().empty() || xns.path_is_auto_read_accessible<sec_rep_descriptor_poset>(prop_rep_path(), xauto_access));
1161 
1162  require(prop_fiber_suffix().empty() || poset_path::is_valid_name(prop_fiber_suffix()));
1163  require(prop_type::fiber_type::template standard_host_is_available<typename prop_type::fiber_type>(xns, prop_fiber_suffix(), xauto_access));
1164 
1165  require(prop_section_suffix().empty() || poset_path::is_valid_name(prop_section_suffix()));
1166  require(prop_type::template standard_host_is_available<prop_type>(xns, xbase_path, prop_rep_path(), prop_section_suffix(), prop_fiber_suffix(), xauto_access));
1167 
1168  // Body:
1169 
1170  if(xauto_access)
1171  {
1172  xns.get_read_write_access();
1173  }
1174 
1175  // Find or create the base space.
1176 
1177  poset_path llocal_cell_prototype_path(_local_cell_prototype_path);
1178 
1180  {
1182  make_base_space(xns,
1183  xbase_path,
1184  _base_index_ubs,
1185  llocal_cell_prototype_path,
1186  lbase);
1187  lbase.detach_from_state();
1188  }
1189  else
1190  {
1191  base_type lbase;
1192  make_base_space(xns,
1193  xbase_path,
1194  _base_index_ubs,
1195  llocal_cell_prototype_path,
1196  lbase);
1197  lbase.detach_from_state();
1198  }
1199 
1200  // Find or create the standard coordinates section space.
1201 
1202  typename coord_type::host_type& lcoords_host =
1203  coord_type::standard_host(xns,
1204  xbase_path,
1205  coord_rep_path(),
1206  coord_section_suffix(),
1207  coord_fiber_suffix(),
1208  false);
1209 
1210  // Find or create the coordinate section.
1211 
1212  coord_type lcoords;
1213  if(lcoords_host.contains_member(xcoord_name))
1214  {
1215  lcoords_host.get_read_access();
1216  lcoords.attach_to_state(&lcoords_host, xcoord_name);
1217  lcoords_host.release_access();
1218  }
1219  else
1220  {
1221  lcoords.new_jim_state(&lcoords_host);
1222  lcoords.put_name(xcoord_name, true, true);
1223  put_bounds(&lcoords, _base_index_ubs, _coord_lb, _coord_ub);
1224  }
1225 
1226  // Find or create the standard property section space.
1227 
1228  typename prop_type::host_type& lprop_host =
1229  prop_type::standard_host(xns,
1230  xbase_path,
1231  prop_rep_path(),
1232  prop_section_suffix(),
1233  prop_fiber_suffix(),
1234  false);
1235 
1236  // Find or create the property section.
1237 
1238  prop_type lprop;
1239  if(lprop_host.contains_member(xprop_name))
1240  {
1241  lprop_host.get_read_access();
1242  lprop.attach_to_state(&lprop_host, xprop_name);
1243  lprop_host.release_access();
1244  }
1245  else
1246  {
1247  lprop.new_jim_state(&lprop_host);
1248  lprop.put_name(xprop_name, true, true);
1249  }
1250 
1251  // Create the field.
1252 
1253  result = new field_type(xns, lcoords.path(), lprop.path(), true);
1254 
1255  // Clean up.
1256 
1257  lcoords.detach_from_state();
1258  lprop.detach_from_state();
1259 
1260  if(xauto_access)
1261  {
1262  xns.release_access();
1263  }
1264 
1265  // Postconditions:
1266 
1267  ensure(result->base_space().path(true) == xbase_path);
1268 
1269  ensure(result->coordinates().path(true).poset_name() ==
1270  coord_type::template standard_host_path<coord_type>(xbase_path, coord_rep_path(), coord_section_suffix(), coord_fiber_suffix()).poset_name());
1271  ensure(result->coordinates().path(true).member_name() == xcoord_name);
1272 
1273  ensure(result->property().path(true).poset_name() ==
1274  prop_type::template standard_host_path<prop_type>(xbase_path, prop_rep_path(), prop_section_suffix(), prop_fiber_suffix()).poset_name());
1275  ensure(result->property().path(true).member_name() == xprop_name);
1276 
1277  // Exit:
1278 
1279  return result;
1280 }
1281 
1282 // =============================================================================
1283 // BASE SPACE FACET
1284 // =============================================================================
1285 
1286 // PUBLIC MEMBERS
1287 
1288 template <typename coord_type, typename prop_type, typename base_type>
1289 poset_path&
1292 {
1293  return _base_schema_path;
1294 }
1295 
1296 template <typename coord_type, typename prop_type, typename base_type>
1300 {
1301  return _base_index_ubs;
1302 }
1303 
1304 template <typename coord_type, typename prop_type, typename base_type>
1305 poset_path&
1308 {
1309  return _local_cell_prototype_path;
1310 }
1311 
1312 
1313 
1314 // =============================================================================
1315 // COORDINATES SECTION FACET
1316 // =============================================================================
1317 
1318 // PUBLIC MEMBERS
1319 
1320 template <typename coord_type, typename prop_type, typename base_type>
1321 poset_path&
1324 {
1325  return _coord_rep_path;
1326 }
1327 
1328 template <typename coord_type, typename prop_type, typename base_type>
1329 std::string&
1332 {
1333  return _coord_fiber_suffix;
1334 }
1335 
1336 template <typename coord_type, typename prop_type, typename base_type>
1337 std::string&
1340 {
1341  return _coord_section_suffix;
1342 }
1343 
1344 template <typename coord_type, typename prop_type, typename base_type>
1348 {
1349  return _coord_lb;
1350 }
1351 
1352 template <typename coord_type, typename prop_type, typename base_type>
1356 {
1357  return _coord_ub;
1358 }
1359 
1360 
1361 // =============================================================================
1362 // PROPERTY SECTION FACET
1363 // =============================================================================
1364 
1365 // PUBLIC MEMBERS
1366 
1367 template <typename coord_type, typename prop_type, typename base_type>
1368 poset_path&
1371 {
1372  return _prop_rep_path;
1373 }
1374 
1375 template <typename coord_type, typename prop_type, typename base_type>
1376 std::string&
1379 {
1380  return _prop_fiber_suffix;
1381 }
1382 
1383 template <typename coord_type, typename prop_type, typename base_type>
1384 std::string&
1387 {
1388  return _prop_section_suffix;
1389 }
1390 
1391 template <typename coord_type, typename prop_type, typename base_type>
1395 {
1396  return _prop_lb;
1397 }
1398 
1399 template <typename coord_type, typename prop_type, typename base_type>
1403 {
1404  return _prop_ub;
1405 }
1406 
1407 
1408 // =============================================================================
1409 // NON-MEMBER FUNCTIONS
1410 // =============================================================================
1411 
1412 } // namespace fields
1413 
1414 
1415 #endif // FIELD_FACTORY_2_IMPL_H
A section of a fiber bundle with a 1-dimensional Euclidean vector space fiber.
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 ...
void new_state(const size_type &xi_size, const size_type &xj_size, bool xauto_access=true)
Creates a new point_block_2d state in host() with i_size() == xi_size and j_size() == xj_size and att...
section_space_schema_poset * host() const
The poset which this is a handle to a component of.
bool full() const
True if both poset name and member name are not empty.
Definition: poset_path.cc:311
size_type ct() const
The number of items currently in use.
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...
A homogeneous collection of connected quads arranged in an i_size() x j_size() array.
virtual poset_path path(bool xauto_access=true) const
The path of this poset.
void put_bounds(const block< dof_type > &xmin, const block< dof_type > &xmax, bool xauto_access)
Sets the dofs to match the rectangle defined by xmin and xmax.
std::string type_name(pod_index_type xmbr_hub_id) const
The type id of the member with hub id xmbr_hub_id.
Namespace for fields component of sheaf system.
A section of a fiber bundle with a 3-dimensional Euclidean vector space fiber.
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...
void make_base_space(fiber_bundles_namespace &xns, const poset_path &xbase_path, const wsv_block< int > &xbase_index_ubs, poset_path &xlocal_cell_prototype_path, unstructured_block &xresult)
Finds or creates the base space specified by xbase_path; specialization for unstructured_block.
A general antisymmetric tensor of degree 1 over an abstract vector space (volatile version)...
Definition: at1.h:44
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 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
STL namespace.
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...
void put_bounds(const block< dof_type > &xmin, const block< dof_type > &xmax, bool xauto_access)
Sets the dofs to match the rectangle defined by xmin and xmax.
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 homogeneous_block_1d state in host() with i_size() == xi_size, j_size() == xj_size...
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.
OBSOLETE: use zone_nodes_block or point_block_*d. A client handle for a base space member which repre...
The poset for sec_rep_descriptors.
static const std::string & prototypes_poset_name()
The name of the prototypes poset.
field_traits< prop_type >::field_type field_type
Typedef: The type of the field to create.
A homogeneous collection of connected segments arranged in an i_size() array.
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 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...
The lattice of closed cells of a cellular space; a lattice representation of a computational mesh...
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...
Features describing a section type. Declaration only; there is no generic implementation for this tem...
void put_bounds(const block< dof_type > &xmin, const block< dof_type > &xmax, bool xauto_access)
Sets the dofs to match the bounds xmin and xmax.
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...
void put_member_name(const std::string &xname)
Sets member_name() to xname.
Definition: poset_path.cc:526
A homogeneous collection of i_size() * j_size() disconnected points similar to a structured_block_2d...
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...
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 void put_name(const std::string &xname, bool xunique, bool xauto_access)
Make xname a name for this; if xunique, make xname the only name.
bool empty() const
True if both poset name and member name are empty.
Definition: poset_path.cc:291
void put_poset_name(const std::string &xname)
Sets poset_name() to xname.
Definition: poset_path.cc:489
A section of a fiber bundle with a 3-dimensional Euclidean vector space fiber.
Definition: sec_e3.h:47
bool contains_poset(pod_index_type xhub_id, bool xauto_access=true) const
True if this contains a poset with hub id xhub_id..
A homogeneous collection of connected hexahedra arranged in an i_size() x j_size() x k_size() array...
bool path_is_auto_read_write_accessible(const poset_path &xpath, bool xauto_access) const
True if the state referred to xpath exists and is auto read-write accessible.
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...
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 & 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...
void put_fiber(pod_index_type xdisc_id, const vd_lite &xfiber)
Sets the fiber referred to by discretization id xdisc_id to xfiber.
Definition: sec_vd.cc:1144
virtual section_space_schema_member & schema()
The restricted schema for this (mutable version).
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
A section of a fiber bundle with a 2-dimensional Euclidean vector space fiber.
A section of a fiber bundle with a 1-dimensional Euclidean vector space fiber.
Definition: sec_e1.h:47
std::string member_name() const
The member name part of the path.
Definition: poset_path.cc:511
Features describing a field type. Declaration only; there is no generic implementation for this templ...
Definition: field_traits.h:86
virtual bool is_jim(pod_index_type xmbr_hub_id, bool xin_current_version=true) const
True if the member with hub id xmbr_hub_id is a jim in the current version (xin_current_version == tr...
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...
A homogeneous collection of i_size() disconnected points; similar to a structured_block_1d, but without the segments.
int df() const
The dimension of the fiber space component.
void attach_to_state(const namespace_poset *xns, const poset_path &xpath, bool xauto_access=true)
Attach to the state specified by path xpath in the namespace xns.
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 void get_read_access() const
Get read access to the state associated with this.
std::string path() const
The full path as a string.
Definition: poset_path.cc:450
double sec_vd_dof_type
The type of degree of freedom in the section space.
Definition: fiber_bundle.h:78
void new_state(const size_type &xi_size, const size_type &xj_size, bool xauto_access=true)
Creates a new structured_block_2d state in host() with i_size() == xi_size and j_size() == xj_size an...
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...
Namespace for the fiber_bundles component of the sheaf system.
A homogeneous collection of i_size()*j_size()*k_size() disconnected points similar to a structured_bl...
void new_state(const size_type &xi_size, bool xauto_access=true)
Creates a new point_block_1d state in host() with i_size() == xi_size and attaches this to it...
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...
void new_state(const size_type &xi_size, bool xauto_access=true)
Creates a new structured_block_1d state in host() with i_size() == xi_size and attaches this to it...
base_space_poset & base_space()
The base space for section spaces on this schema.
A section of a fiber bundle with a 2-dimensional Euclidean vector space fiber.
Definition: sec_e2.h:48
A factory for making field_vd objects with coordinates section of type coord_type, property section of type prop_type and base space of type base_type.
pod_index_type base_space_id() const
The member id of the base space component of this.