SheafSystem  0.0.0.0
sparse_field_dof_map.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 sparse_field_dof_map
19 
20 #include "SheafSystem/sparse_field_dof_map.h"
21 
22 #include "SheafSystem/assert_contract.h"
23 #include "SheafSystem/discretization_iterator.h"
24 #include "SheafSystem/dof_map_factory.h"
25 #include "SheafSystem/sec_rep_space.h"
26 
27 using namespace fiber_bundle; // Workaround for MS C++ bug.
28 
29 // PUBLIC MEMBER FUNCTIONS
30 
31 
32 
34 const std::string&
36 class_name() const
37 {
38  // Preconditions:
39 
40  // Body:
41 
42  const string& result = static_class_name();
43 
44  // Postconditions:
45 
46  ensure(!result.empty());
47 
48  // Exit:
49 
50  return result;
51 }
52 
54 const std::string&
57 {
58  // Preconditions:
59 
60  // Body:
61 
62  static const string result("sparse_field_dof_map");
63 
64  // Postconditions:
65 
66  ensure(!result.empty());
67  ensure(result == "sparse_field_dof_map");
68 
69  // Exit:
70 
71  return result;
72 }
73 
74 // ===========================================================
75 // CANONICAL FACET
76 // ===========================================================
77 
81  : field_dof_map()
82 {
83 
84  // Preconditions:
85 
86 
87  // Body:
88 
90 
91  _def_val = 0.0;
92 
93  // Postconditions:
94 
95  ensure(invariant());
96 
97  // Exit
98 
99  return;
100 }
101 
105 clone() const
106 {
107  sparse_field_dof_map* result;
108 
109  // Preconditions:
110 
111 
112  // Body:
113 
114  result = new sparse_field_dof_map();
115 
116  // Postconditions:
117 
118  ensure(result != 0);
119  ensure(result->is_same_type(this));
120  ensure(postcondition_of(sparse_field_dof_map()));
121 
122  // Exit:
123 
124  return result;
125 }
126 
127 
131  : field_dof_map(xother)
132 {
133 
134  // Preconditions:
135 
136 
137  // Body:
138 
139  _def_val = 0.0;
140 
141  *this = xother;
142 
143  // Postconditions:
144 
145  ensure(invariant());
146 
147  // Exit
148 
149  return;
150 }
151 
155 copy() const
156 {
157  sparse_field_dof_map* result;
158 
159  // Preconditions:
160 
161 
162  // Body:
163 
164  result = new sparse_field_dof_map(*this);
165 
166  // Postconditions:
167 
168  ensure(result != 0);
169  ensure(result->is_same_type(this));
170  ensure(postcondition_of(sparse_field_dof_map(*this)));
171 
172  // Exit:
173 
174  return result;
175 }
176 
181 {
182 
183  // Preconditions:
184 
185  require(xother.is_initialized());
186 
187  // Body:
188 
189  field_dof_map::operator=(xother);
190 
191 
192  _val_map.clear();
193  _val_map = xother._val_map;
194 
195  _def_val = xother._def_val;
196 
197  // Postconditions:
198 
199  ensure(invariant());
200 
201  // Exit
202 
203  return *this;
204 }
205 
206 
210 {
211 
212  // Preconditions:
213 
214 
215  // Body:
216 
217  // Postconditions:
218 
219 }
220 
221 
223 bool
225 invariant() const
226 {
227  bool result = true;
228 
229  // Preconditions:
230 
231  // Body:
232 
234 
235  // Postconditions:
236 
237  // Exit
238 
239  return result;
240 }
241 
242 
243 // ===========================================================
244 // MAP FACET
245 // ===========================================================
246 
249 sparse_field_dof_map(const sec_rep_space* xhost, double xdefault_value)
250  : field_dof_map(xhost)
251 {
252 
253  // Preconditions:
254 
255  require(xhost != 0);
256  require(xhost->state_is_read_accessible());
257 
258  // Body:
259 
260  // Initialize counts
261 
262 
263  _def_val = xdefault_value;
264 
265 
266  // Postconditions:
267 
268  ensure(invariant());
269  ensure(default_value() == xdefault_value);
270 
271 }
272 
273 
274 
276 void
278 get_dof(const scoped_index& xid, bool xis_poset_id, void* xbuf, size_t xbuf_len) const
279 {
280  // Preconditions:
281 
282  require(xis_poset_id ? schema().contains_row_dof(xid) : true);
283  require(xbuf != 0);
284  require(xbuf_len >= sizeof(double));
285  require(unexecutable("xbuf is properly aligned for double"));
286  require(xis_poset_id ? xid.in_scope() : true);
287 
289 
290  require(host()->multiplicity() == 1);
291 
292  // Body:
293 
294  // Dofs are hashed on internal ids;
295  // convert to internal ids.
296 
297  pod_index_type lid;
298 
299  if(xis_poset_id)
300  {
301  lid = xid.hub_pod();
302  }
303  else
304  {
306 
307  int lfiber_dof_ct = schema().fiber_schema().row_dof_ct();
308 
309  scoped_index lbase_id(&schema().disc_seq_id_map());
310  lbase_id = xid.pod() / lfiber_dof_ct;
311 
312  scoped_index lfiber_id(&schema().fiber_schema().row_dof_client_id_map());
313  lfiber_id = xid.pod() % lfiber_dof_ct;
314 
315  lid = schema().host()->get_index_from_components(lbase_id, lfiber_id).hub_pod();
316  }
317 
318  double* lbuf = reinterpret_cast<double*>(xbuf);
319 
320 
321  val_map_type::const_iterator itr = _val_map.find(lid);
322 
323  if(itr != _val_map.end())
324  {
325  *lbuf = itr->second;
326  }
327  else
328  {
329  *lbuf = _def_val;
330  }
331 
332 
333  // Postconditions:
334 
335  // Exit
336 
337  return;
338 }
339 
340 
342 void
344 put_dof(const scoped_index& xid, bool xis_poset_id, const void* xbuf, size_t xbuf_len)
345 {
346  // Preconditions:
347 
348  require(xis_poset_id ? schema().contains_row_dof(xid) : true);
349  require(xbuf != 0);
350  require(xbuf_len >= sizeof(double));
351  require(unexecutable("xbuf is properly aligned for double"));
352  require(xis_poset_id ? xid.in_scope() : true);
353 
355 
356  require(host()->multiplicity() == 1);
357 
358  // Body:
359 
360  // Dofs are hashed on internal ids;
361  // convert to internal ids.
362 
363  pod_index_type lid;
364 
365  if(xis_poset_id)
366  {
367  lid = xid.hub_pod();
368  }
369  else
370  {
372 
373  int lfiber_dof_ct = schema().fiber_schema().row_dof_ct();
374 
375  scoped_index lbase_id(&schema().disc_seq_id_map());
376  lbase_id = xid.pod() / lfiber_dof_ct;
377 
378  scoped_index lfiber_id(&schema().fiber_schema().row_dof_client_id_map());
379  lfiber_id = xid.pod() % lfiber_dof_ct;
380 
381  lid = schema().host()->get_index_from_components(lbase_id, lfiber_id).hub_pod();
382  }
383 
384  const double* lbuf = reinterpret_cast<const double*>(xbuf);
385 
386  if(*lbuf != _def_val)
387  {
388  // Insert the value in the map;
389  // updates entry if one already exists.
390 
391  _val_map[lid] = *lbuf;
392  }
393  else
394  {
395  // Value is default,
396  // make sure it's not in the map
397 
398  _val_map.erase(lid);
399  }
400 
401  // Postconditions:
402 
403  // Exit
404 
405  return;
406 }
407 
408 
409 
411 void
413 get_dofs(const client_index* xclient_ids, int xclient_id_ct,
414  void* xbuf, size_t xbuf_len) const
415 {
416  // Preconditions:
417 
418  require(xclient_ids != 0);
419  require(xclient_id_ct > 0);
420  require(unexecutable(xclient_ids points to buffer of length xclient_id_ct));
421  require(unexecutable(xclient_ids are valid client ids));
422  require(xbuf != 0);
423  require(unexecutable(xbuf points to buffer of length xbuf_len));
424  require(unexecutable(xbuf_len is large enough to hold the dofs referred to by xclient_ids));
426  require(unexecutable("xbuf must be aligned for all data types"));
427 
428  // Body:
429 
430  not_implemented();
431 
432  // Postconditions:
433 
434  ensure(unexecutable(xbuf holds dofs referred to by xclient_ids));
435 
436  // Exit
437 
438  return;
439 }
440 
441 
443 void
445 put_dofs(const client_index* xclient_ids, int xclient_id_ct,
446  const void* xbuf, size_t xbuf_len)
447 {
448  // Preconditions:
449 
450  require(xclient_ids != 0);
451  require(xclient_id_ct > 0);
452  require(unexecutable(xclient_ids points to buffer of length xclient_id_ct));
453  require(unexecutable(xclient_ids are valid client ids));
454  require(xbuf != 0);
455  require(unexecutable(xbuf points to buffer of length xbuf_len));
456  require(unexecutable(xbuf_len is large enough to hold the dofs referred to by xclient_ids));
458  require(unexecutable("xbuf must be aligned for all data types"));
459 
460  // Body:
461 
462  not_implemented();
463 
464  // Postconditions:
465 
466  ensure(unexecutable(internal storage holds dofs referred to by xclient_ids));
467 
468  // Exit
469 
470  return;
471 }
472 
473 
474 
476 void
478 get_dof(const scoped_index& xbase_id,
479  const scoped_index& xfiber_id,
480  const scoped_index& xmult_id,
481  bool xis_poset_id,
482  void* xbuf,
483  size_t xbuf_len) const
484 {
485  // Preconditions:
486 
487  require(xis_poset_id ? schema().contains_row_dof(xbase_id, xfiber_id) : true);
488  require(unexecutable("if !xis_poset_id xbase_idand xfiber_id are valid client ids"));
489  require(unexecutable(0 <= xmult_id && xmult_id < multiplicity));
490  require(xbuf != 0);
491  require(xbuf_len >= sizeof(double));
492 
493  // Body:
494 
495  scoped_index lbase_id, lfiber_id; // Unscoped.
496 
497  if(xis_poset_id)
498  {
499  lbase_id = xbase_id.hub_pod();
500  lfiber_id = xfiber_id.hub_pod();
501  }
502  else
503  {
504  lbase_id = schema().discretization().id_map()->poset_id(xbase_id);
505  lfiber_id = schema().fiber_schema().row_dof_client_id_map().poset_id(xfiber_id);
506  }
507 
508  scoped_index l_id =
509  schema().host()->get_index_from_components(lbase_id, lfiber_id);
510 
511  get_dof(l_id, true, xbuf, xbuf_len);
512 
513  // Postconditions:
514 
515  // Exit
516 
517  return;
518 }
519 
520 
522 void
524 put_dof(const scoped_index& xbase_id,
525  const scoped_index& xfiber_id,
526  const scoped_index& xmult_id,
527  bool xis_poset_id,
528  const void* xbuf,
529  size_t xbuf_len)
530 {
531  // Preconditions:
532 
533  require(xis_poset_id ? schema().contains_row_dof(xbase_id, xfiber_id) : true);
534  require(unexecutable("if !xis_poset_id xbase_idand xfiber_id are valid client ids"));
535  require(unexecutable(0 <= xmult_id && xmult_id < multiplicity));
536  require(xbuf != 0);
537  require(xbuf_len >= sizeof(double));
538 
539  // Body:
540 
541  scoped_index lbase_id, lfiber_id; // Unscoped.
542 
543  if(xis_poset_id)
544  {
545  lbase_id = xbase_id.hub_pod();
546  lfiber_id = xfiber_id.hub_pod();
547  }
548  else
549  {
550  lbase_id = schema().discretization().id_map()->poset_id(xbase_id);
551  lfiber_id = schema().fiber_schema().row_dof_client_id_map().poset_id(xfiber_id);
552  }
553 
554  scoped_index l_id =
555  schema().host()->get_index_from_components(lbase_id, lfiber_id);
556 
557  put_dof(l_id, true, xbuf, xbuf_len);
558 
559  // Postconditions:
560 
561  ensure(unexecutable(internal storage holds dof referred to by xids));
562 
563  // Exit
564 
565  return;
566 }
567 
569 void
571 get_dofs(const client_index* xclient_base_ids, int xclient_base_id_ct,
572  const client_index* xclient_fiber_ids, int xclient_fiber_id_ct,
573  void* xbuf, size_t xbuf_len) const
574 {
575  // Preconditions:
576 
577  require(xclient_base_ids != 0);
578  require(xclient_base_id_ct > 0);
579  require(unexecutable(xclient_base_ids points to buffer of length xclient_base_id_ct));
580  require(unexecutable(xclient_base_ids are valid client ids));
581  require(xclient_fiber_ids != 0);
582  require(xclient_fiber_id_ct > 0);
583  require(unexecutable(xclient_fiber_ids points to buffer of length xclient_fiber_id_ct));
584  require(unexecutable(xclient_fiber_ids are valid client ids));
585  require(xbuf != 0);
586  require(unexecutable(xbuf points to buffer of length xbuf_len));
587  require(unexecutable(xbuf_len is large enough to hold the dofs referred to by client ids));
588 
589  // Body:
590 
591  sparse_field_dof_map* cthis = const_cast<sparse_field_dof_map*>(this);
592  cthis->copy_dofs(xclient_base_ids, xclient_base_id_ct, xclient_fiber_ids,
593  xclient_fiber_id_ct, xbuf, xbuf_len, true);
594 
595  // Postconditions:
596 
597  ensure(invariant());
598  ensure(unexecutable(xbuf holds dofs referred to by xclient_ids));
599 
600  // Exit
601 
602  return;
603 }
604 
605 
607 void
609 put_dofs(const client_index* xclient_base_ids, int xclient_base_id_ct,
610  const client_index* xclient_fiber_ids, int xclient_fiber_id_ct,
611  const void* xbuf, size_t xbuf_len)
612 {
613  // Preconditions:
614 
615  require(xclient_base_ids != 0);
616  require(xclient_base_id_ct > 0);
617  require(unexecutable(xclient_base_ids points to buffer of length xclient_base_id_ct));
618  require(unexecutable(xclient_base_ids are valid client ids));
619  require(xclient_fiber_ids != 0);
620  require(xclient_fiber_id_ct > 0);
621  require(unexecutable(xclient_fiber_ids points to buffer of length xclient_fiber_id_ct));
622  require(unexecutable(xclient_fiber_ids are valid client ids));
623  require(xbuf != 0);
624  require(unexecutable(xbuf points to buffer of length xbuf_len));
625  require(unexecutable(xbuf_len is large enough to hold the dofs referred to by xclient_ids));
626 
627  // Body:
628 
629  copy_dofs(xclient_base_ids, xclient_base_id_ct, xclient_fiber_ids,
630  xclient_fiber_id_ct, const_cast<void*>(xbuf), xbuf_len, false);
631 
632  // Postconditions:
633 
634  ensure(invariant());
635  ensure(unexecutable(internal storage holds dofs referred to by xclient_ids));
636 
637  // Exit
638 
639  return;
640 }
641 
643 void
646  bool xis_poset_id,
647  void* xbuf,
648  size_t xbuf_len) const
649 {
650  // Preconditions:
651 
652  require(xbuf != 0);
653  require(unexecutable(xbuf points to buffer of length xbuf_len));
654  require(xbuf_len >= schema().fiber_schema().row_dof_tuple_ub());
655 
656  // Body:
657 
658  scoped_index ldisc_id; // Unscoped.
659 
660  if(xis_poset_id)
661  {
662  ldisc_id = xdisc_id.hub_pod();
663  }
664  else
665  {
666  ldisc_id = schema().discretization().id_map()->poset_id(xdisc_id);
667  }
668 
669  char* lbuf = reinterpret_cast<char*>(xbuf);
670 
672  while(!itr->is_done())
673  {
674  scoped_index lpid =
675  schema().host()->get_index_from_components(ldisc_id, itr->index());
676 
677  get_dof(lpid, true, lbuf, xbuf_len);
678  lbuf += sizeof(double);
679  xbuf_len -= sizeof(double);
680  itr->next();
681  }
682 
683  // Postconditions:
684 
685  // Exit
686 
687  return;
688 }
689 
691 void
694  bool xis_poset_id,
695  const void* xbuf,
696  size_t xbuf_len)
697 {
698  // Preconditions:
699 
700  require(xbuf != 0);
701  require(unexecutable(xbuf points to buffer of length xbuf_len));
702  require(xbuf_len >= schema().fiber_schema().row_dof_tuple_ub());
703 
704  // Body:
705 
706  scoped_index ldisc_id; // Unscoped.
707 
708  if(xis_poset_id)
709  {
710  ldisc_id = xdisc_id.hub_pod();
711  }
712  else
713  {
714  ldisc_id = schema().discretization().id_map()->poset_id(xdisc_id);
715  }
716 
717  const char* lbuf = reinterpret_cast<const char*>(xbuf);
718 
720  while(!itr->is_done())
721  {
722  scoped_index lpid =
723  schema().host()->get_index_from_components(ldisc_id, itr->index());
724 
725  put_dof(lpid, true, lbuf, xbuf_len);
726  lbuf += sizeof(double);
727  xbuf_len -= sizeof(double);
728  itr->next();
729  }
730 
731  // Postconditions:
732 
733  // Exit
734 
735  return;
736 }
737 
739 void
742  size_t xbuf_len,
743  const scoped_index& xcomp_id,
744  const scoped_index* xdisc_ids,
745  size_type xdisc_ids_ct) const
746 {
747  // Preconditions:
748 
749  require(is_initialized());
750  require(xbuf != 0);
751  require(unexecutable(xbuf points to buffer of length xbuf_len));
752  require(unexecutable("xbuf_len is large enough for the requested dofs"));
753  require(schema().fiber_schema().contains_row_dof(xcomp_id));
754  require(xdisc_ids == 0 ? xdisc_ids_ct == 0 : true);
755  require_for_all(i, 0, xdisc_ids_ct, schema().discretization().contains_member(xdisc_ids[i]));
756 
757  // Body:
758 
759  char* lbuf = reinterpret_cast<char*>(xbuf);
760 
761  if(xdisc_ids != 0)
762  {
763  // Client has specified which dofs to get.
764 
765  for(size_t i=0; i<xdisc_ids_ct; i++)
766  {
767  get_dof(xdisc_ids[i],
768  xcomp_id,
769  scoped_index::ZERO(),
770  true,
771  lbuf,
772  xbuf_len);
773 
774  lbuf += sizeof(double);
775  xbuf_len -= sizeof(double);
776  }
777  }
778  else
779  {
780  // Transfer all the dofs in the component.
781 
783  while(!ditr.is_done())
784  {
786  xcomp_id,
787  scoped_index::ZERO(),
788  true,
789  lbuf,
790  xbuf_len);
791 
792  lbuf += sizeof(double);
793  xbuf_len -= sizeof(double);
794  ditr.next();
795  }
796  }
797 
798  // Postconditions:
799 
800  // Exit
801 
802  return;
803 }
804 
805 
807 void
809 put_component_dofs(const void* xbuf,
810  size_t xbuf_len,
811  const scoped_index& xcomp_id,
812  const scoped_index* xdisc_ids,
813  size_type xdisc_ids_ct)
814 {
815  // Preconditions:
816 
817  require(is_initialized());
818  require(xbuf != 0);
819  require(unexecutable(xbuf points to buffer of length xbuf_len));
820  require(unexecutable("xbuf_len is large enough for the requested dofs"));
821  require(schema().fiber_schema().contains_row_dof(xcomp_id));
822  require(xdisc_ids == 0 ? xdisc_ids_ct == 0 : true);
823  require_for_all(i, 0, xdisc_ids_ct, schema().discretization().contains_member(xdisc_ids[i]));
824 
825  // Body:
826 
827  const char* lbuf = reinterpret_cast<const char*>(xbuf);
828 
829  if(xdisc_ids != 0)
830  {
831  // Client has specified which dofs to get.
832 
833  for(size_t i=0; i<xdisc_ids_ct; i++)
834  {
835  put_dof(xdisc_ids[i],
836  xcomp_id,
837  scoped_index::ZERO(),
838  true,
839  lbuf,
840  xbuf_len);
841 
842  lbuf += sizeof(double);
843  xbuf_len -= sizeof(double);
844  }
845  }
846  else
847  {
848  // Transfer all the dofs in the component.
849 
851  while(!ditr.is_done())
852  {
854  xcomp_id,
855  scoped_index::ZERO(),
856  true,
857  lbuf,
858  xbuf_len);
859 
860  lbuf += sizeof(double);
861  xbuf_len -= sizeof(double);
862  ditr.next();
863  }
864  }
865 
866  // Postconditions:
867 
868  // Exit
869 
870  return;
871 }
872 
874 void
877  size_t xbuf_len,
878  const client_index& xcomp_id,
879  const id_map* xcomp_client_id_map,
880  const client_index* xdisc_ids,
881  size_type xdisc_ids_ct,
882  const id_map* xdisc_client_id_map) const
883 {
884  // Preconditions:
885 
886  require(is_initialized());
887  require(xbuf != 0);
888  require(unexecutable(xbuf points to buffer of length xbuf_len));
889  require(unexecutable("xbuf_len is large enough for the requested dofs"));
890  require(xcomp_client_id_map != 0);
891  require(schema().fiber_schema().contains_row_dof(scoped_index(xcomp_id, xcomp_client_id_map)));
892  require(xdisc_ids == 0 ? xdisc_ids_ct == 0 : true);
893  require(xdisc_ids_ct != 0 ? xdisc_client_id_map != 0 : true);
894  require_for_all(i, 0, xdisc_ids_ct, schema().discretization().contains_member(scoped_index(xdisc_ids[i], xdisc_client_id_map)));
895 
896 
897  // Body:
898 
901 
902  not_implemented();
903 
904  // scoped_index lcomp_id(xcomp_client_id_map->poset_id(xcomp_id));
905 
906  // char* lbuf = reinterpret_cast<char*>(xbuf);
907 
908  // if(xdisc_ids != 0)
909  // {
910  // // Client has specified which dofs to get.
911 
912  // for(size_t i=0; i<xdisc_ids_ct; i++)
913  // {
914  // scoped_index ldisc_id(xdisc_client_id_map->poset_id(xdisc_ids[i]));
915 
916  // get_dof(ldisc_id,
917  // lcomp_id,
918  // scoped_index::ZERO(),
919  // true,
920  // lbuf,
921  // xbuf_len);
922 
923  // lbuf += sizeof(double);
924  // xbuf_len -= sizeof(double);
925  // }
926  // }
927  // else
928  // {
929  // // Transfer all the dofs in the component.
930 
931  // discretization_iterator ditr(schema());
932  // while(!ditr.is_done())
933  // {
934  // scoped_index ldisc_id = ditr.discretization_member_index();
935 
936  // get_dof(ldisc_id,
937  // lcomp_id,
938  // scoped_index::ZERO(),
939  // true,
940  // lbuf,
941  // xbuf_len);
942 
943  // lbuf += sizeof(double);
944  // xbuf_len -= sizeof(double);
945  // ditr.next();
946  // }
947  // }
948 
949  // Postconditions:
950 
951  // Exit
952 
953  return;
954 }
955 
957 void
959 put_component_dofs(const void* xbuf,
960  size_t xbuf_len,
961  const client_index& xcomp_id,
962  const id_map* xcomp_client_id_map,
963  const client_index* xdisc_ids,
964  size_type xdisc_ids_ct,
965  const id_map* xdisc_client_id_map)
966 {
967  // Preconditions:
968 
969  require(is_initialized());
970  require(xbuf != 0);
971  require(unexecutable(xbuf points to buffer of length xbuf_len));
972  require(unexecutable("xbuf_len is large enough for the requested dofs"));
973  require(xcomp_client_id_map != 0);
974  require(schema().fiber_schema().contains_row_dof(scoped_index(xcomp_id, xcomp_client_id_map)));
975  require(xdisc_ids == 0 ? xdisc_ids_ct == 0 : true);
976  require(xdisc_ids_ct != 0 ? xdisc_client_id_map != 0 : true);
977  require_for_all(i, 0, xdisc_ids_ct, schema().discretization().contains_member(scoped_index(xdisc_ids[i], xdisc_client_id_map)));
978 
979 
980  // Body:
981 
984 
985  not_implemented();
986 
987  // scoped_index lcomp_id(xcomp_client_id_map->poset_id(xcomp_id));
988 
989  // char* lbuf = reinterpret_cast<char*>(xbuf);
990 
991  // if(xdisc_ids != 0)
992  // {
993  // // Client has specified which dofs to get.
994 
995  // for(size_t i=0; i<xdisc_ids_ct; i++)
996  // {
997  // scoped_index ldisc_id(xdisc_client_id_map->poset_id(xdisc_ids[i]));
998 
999  // put_dof(ldisc_id,
1000  // lcomp_id,
1001  // scoped_index::ZERO(),
1002  // true,
1003  // lbuf,
1004  // xbuf_len);
1005 
1006  // lbuf += sizeof(double);
1007  // xbuf_len -= sizeof(double);
1008  // }
1009  // }
1010  // else
1011  // {
1012  // // Transfer all the dofs in the component.
1013 
1014  // discretization_iterator ditr(schema());
1015  // while(!ditr.is_done())
1016  // {
1017  // scoped_index ldisc_id = ditr.discretization_member_index();
1018 
1019  // put_dof(ldisc_id,
1020  // lcomp_id,
1021  // scoped_index::ZERO(),
1022  // true,
1023  // lbuf,
1024  // xbuf_len);
1025 
1026  // lbuf += sizeof(double);
1027  // xbuf_len -= sizeof(double);
1028  // ditr.next();
1029  // }
1030  // }
1031 
1032  // Postconditions:
1033 
1034  // Exit
1035 
1036  return;
1037 }
1038 
1040 void*
1043 {
1044  void* result = 0;
1045 
1046  // Preconditions:
1047 
1048  // Body:
1049 
1050  not_implemented();
1051 
1052  // Postconditions:
1053 
1054  ensure(invariant());
1055 
1056  // Exit
1057 
1058  return result;
1059 }
1060 
1062 const void*
1064 dof_tuple() const
1065 {
1066  const void* result = 0;
1067 
1068  // Preconditions:
1069 
1070  // Body:
1071 
1072  not_implemented();
1073 
1074  // Postconditions:
1075 
1076  ensure(invariant());
1077 
1078  // Exit
1079 
1080  return result;
1081 }
1082 
1084 void
1086 get_dof_tuple(void* xbuf, size_t xbuf_len) const
1087 {
1088  // Preconditions:
1089 
1090  require(xbuf != 0);
1091  require(dof_tuple_ub() <= xbuf_len);
1092 
1093  // Body:
1094 
1095  double* lbuf = reinterpret_cast<double*>(xbuf);
1096  size_t lbuf_len = xbuf_len/sizeof(double);
1097 
1099  while(!itr->is_done())
1100  {
1101  get_dof(itr->index(), true, lbuf++, lbuf_len--);
1102 
1103  itr->next();
1104  }
1105 
1106  // Postconditions:
1107 
1108  ensure(invariant());
1109  ensure(unexecutable(dof tuple copied to xbuf));
1110 
1111  // Exit
1112 
1113  return;
1114 }
1115 
1116 
1118 void
1120 put_dof_tuple(const void* xbuf, size_t xbuf_len)
1121 {
1122  // Preconditions:
1123 
1124  require(xbuf != 0);
1125  require(dof_tuple_ub() <= xbuf_len);
1126 
1127  // Body:
1128 
1130 
1131  double* lbuf = reinterpret_cast<double*>(const_cast<void*>(xbuf));
1132  size_t lbuf_len = xbuf_len/sizeof(double);
1133 
1135  while(!itr->is_done())
1136  {
1137  put_dof(itr->index(), true, lbuf++, lbuf_len--);
1138 
1139  itr->next();
1140  }
1141 
1142  // Postconditions:
1143 
1144  ensure(invariant());
1145  ensure(unexecutable(xbuf copied to dof tuple));
1146 
1147  // Exit
1148 
1149  return ;
1150 }
1151 
1152 
1153 
1155 bool
1158 {
1160  return false;
1161 }
1162 
1163 // PROTECTED MEMBER FUNCTIONS
1164 
1165 void
1168 {
1169 
1170  // Preconditions:
1171 
1172  // Body:
1173 
1174  // Nothing to do.
1175 
1176  // Postconditions:
1177 
1178  // Exit:
1179 
1180  return;
1181 }
1182 
1183 
1184 bool
1185 fiber_bundle::sparse_field_dof_map::
1186 _has_prototype = make_prototype();
1187 
1189 bool
1190 fiber_bundle::sparse_field_dof_map::
1191 make_prototype()
1192 {
1193  bool result = false;
1194 
1195  // Preconditions:
1196 
1197 
1198  // Body:
1199 
1200  dof_tuple_type ltype =
1201  SPARSE_FIELD_DOF_TUPLE_ID;
1202 
1203  poset_dof_map* lproto = new sparse_field_dof_map;
1204 
1205  factory().insert_prototype(lproto);
1206  factory().insert_prototype(ltype, lproto);
1207 
1208  // Postconditions:
1209 
1210 
1211  // Exit:
1212 
1213  return result;
1214 }
virtual void put_discretization_dofs(const scoped_index &xdisc_id, bool xis_poset_id, const void *xbuf, size_t xbuf_len)
Copys the dofs associated with the discretization member identified by xdisc_id from the buffer of le...
section_space_schema_poset * host() const
The poset which this is a handle to a component of.
void length(const S &x0, SR &xresult, bool xauto_access)
Definition: sec_ed.impl.h:181
bool in_scope() const
True if and only if scope() contains an entry for pod().
Definition: scoped_index.h:584
const pod_type & pod() const
The "plain old data" storage of this; the value in the external id space.
Definition: scoped_index.h:672
virtual void next()
Makes this the next member of the subset.
virtual sparse_field_dof_map * copy() const
Virtual copy constructor.
double default_value() const
The default value; the value for dofs that are not stored in _val_map.
schema_poset_member & fiber_schema()
The fiber schema component of this (mutable version).
poset_dof_iterator * row_dof_iterator(int xversion=CURRENT_MEMBER_VERSION) const
A postorder iterator over the row dofs defined by this.
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
OBSOLETE: Use array_sec_vd_dof_map or sparse_section_dof_map. The abstract map from section_space_sch...
Definition: field_dof_map.h:48
primitive_value dof(pod_index_type xdof_id) const
The dof referred to by xdof_id.
OBSOLETE: Use array_sec_vd_dof_map or sparse_section_dof_map. A representation of the abstract map fr...
Iterates in postorder over dofs of a schema member anchor. Attaches an a handle of type section_space...
virtual section_space_schema_member & schema()
The schema on which this is allocated (mutable version).
bool is_initialized() const
True if this has been initialized, that is, if the schema has been set and the dof map storage alloca...
virtual void get_dof_tuple(void *xbuf, size_t xbuflen) const
Copies the entire dof tuple from internal storage into xbuf.
void next()
Makes this the next member of the subset.
virtual bool is_done() const
True if iteration finished.
The general, abstract map from dof ids to dof values.
Definition: poset_dof_map.h:59
virtual void get_dofs(const client_index *xclient_ids, int xclient_id_ct, void *xbuf, size_t xbuf_len) const
Copies the values of the dofs referred to by the xclient_id_ct client ids in xclient_ids into the buf...
virtual sparse_field_dof_map * clone() const
Virtual default constructor.
virtual void put_component_dofs(const void *xbuf, size_t xbuf_len, const scoped_index &xcomp_id, const scoped_index *xdisc_ids=0, size_type xdisc_ids_ct=0)
Copys the dofs associated with the fiber component identified by xcomp_id from buffer xbuf of length ...
virtual pod_index_type get_index_from_components(pod_index_type xbase_space_id, pod_index_type xfiber_schema_id) const =0
Computes the index associated with component ids xbase_space_id and xfiber_schema_id.
section_dof_iterator * row_dof_iterator(int xversion=CURRENT_MEMBER_VERSION) const
A postorder iterator over the row dofs defined by this.
static dof_map_factory & factory()
The dof map factory.
virtual void put_dofs(const client_index *xclient_ids, int xclient_id_ct, const void *xbuf, size_t xbuf_len)
Copies the values of the dofs referred to by the xclient_id_ct client ids in xclient_ids from the buf...
virtual void get_discretization_dofs(const scoped_index &xdisc_id, bool xis_poset_id, void *xbuf, size_t xbuf_len) const
Copys the dofs associated with the discretization member identified by xdisc_id into the buffer of le...
size_t dof_tuple_ub() const
The size of the dof tuple in bytes.
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
virtual void get_component_dofs(void *xbuf, size_t xbuf_len, const scoped_index &xcomp_id, const scoped_index *xdisc_ids=0, size_type xdisc_ids_ct=0) const
Copys the dofs associated with the fiber component identified by xcomp_id from internal storage into ...
virtual void put_dof_tuple(const void *xbuf, size_t xbuflen)
Copies the entire dof tuple from xbuf into internal storage.
virtual void put_dof(const scoped_index &xid, bool xis_poset_id, const void *xbuf, size_t xbuf_len)
Copies the value of the dof referred to by the xid and xis_poset_id from the buffer of length xbuf_le...
virtual bool is_done() const
True if iteration finished.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
virtual const std::string & class_name() const
The name of the actual (possibly derived) class of this instance.
static const std::string & static_class_name()
The name of this class.
dof_tuple_type
Identifiers for dof tuple types.
Iterator over the discretization subposet associated with a section_space_schema_member anchor...
static int row_dof_ct(const namespace_poset &xns, const poset_path &xpath, bool xauto_access=true)
The number of row dofs defined by the schema specified by xns and xpath. Synonym for dof_ct(xns...
A member of a Cartesian product space; a tuple of attributes (persistent version).
Definition: tuple.h:191
subposet & discretization()
The discretization subposet for section spaces on this schema (mutable version).
virtual void get_dof(const scoped_index &xid, bool xis_poset_id, void *xbuf, size_t xbuf_len) const
Copies the value of the dof referred to by the xid and xis_poset_id into the buffer of length xbuf_le...
const scoped_index & discretization_member_index() const
The current discretization member index.
virtual void * dof_tuple()
The dof tuple (mutable version).
virtual const scoped_index & index()
The index of the current member of the iteration.
bool is_done() const
True if iteration finished.
Iterates in postorder over dofs of a schema member anchor. Attaches a handle of type schema_poset_mem...
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
virtual bool supports_xfr_opt() const
True if this dof map type supports dof tuple transfer optimization. /.
sparse_field_dof_map()
Default constructor.
virtual bool invariant() const
The class invariant.
field_dof_map & operator=(const field_dof_map &xother)
Assignment operator.
virtual void next()
Makes this the next member of the subset.
sparse_field_dof_map & operator=(const sparse_field_dof_map &xother)
Assignment operator.
void insert_prototype(const poset_dof_map *xprototype)
Sets xprototype as the prototype for its client class.
Namespace for the fiber_bundles component of the sheaf system.
bool is_same_type(const any *other) const
True if other is the same type as this.
Definition: any.cc:79
virtual sec_rep_space * host() const
The poset which hosts member()
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.
Definition: scoped_index.h:710
virtual void allocate_dofs()
Allocates dof storage.
A handle for a poset whose members are numerical representations of sections of a fiber bundle...
Definition: sec_rep_space.h:61