20 #include "SheafSystem/sparse_field_dof_map.h" 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" 42 const string& result = static_class_name();
46 ensure(!result.empty());
62 static const string result(
"sparse_field_dof_map");
66 ensure(!result.empty());
67 ensure(result ==
"sparse_field_dof_map");
193 _val_map = xother._val_map;
195 _def_val = xother._def_val;
263 _def_val = xdefault_value;
282 require(xis_poset_id ?
schema().contains_row_dof(xid) :
true);
284 require(xbuf_len >=
sizeof(
double));
285 require(unexecutable(
"xbuf is properly aligned for double"));
286 require(xis_poset_id ? xid.
in_scope() :
true);
290 require(
host()->multiplicity() == 1);
310 lbase_id = xid.
pod() / lfiber_dof_ct;
313 lfiber_id = xid.
pod() % lfiber_dof_ct;
318 double* lbuf =
reinterpret_cast<double*
>(xbuf);
321 val_map_type::const_iterator itr = _val_map.find(lid);
323 if(itr != _val_map.end())
348 require(xis_poset_id ?
schema().contains_row_dof(xid) :
true);
350 require(xbuf_len >=
sizeof(
double));
351 require(unexecutable(
"xbuf is properly aligned for double"));
352 require(xis_poset_id ? xid.
in_scope() :
true);
356 require(
host()->multiplicity() == 1);
376 lbase_id = xid.
pod() / lfiber_dof_ct;
379 lfiber_id = xid.
pod() % lfiber_dof_ct;
384 const double* lbuf =
reinterpret_cast<const double*
>(xbuf);
386 if(*lbuf != _def_val)
391 _val_map[lid] = *lbuf;
413 get_dofs(
const client_index* xclient_ids,
int xclient_id_ct,
414 void* xbuf,
size_t xbuf_len)
const 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));
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"));
434 ensure(unexecutable(xbuf holds dofs referred to by xclient_ids));
445 put_dofs(
const client_index* xclient_ids,
int xclient_id_ct,
446 const void* xbuf,
size_t xbuf_len)
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));
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"));
466 ensure(unexecutable(
internal storage holds dofs referred to by xclient_ids));
483 size_t xbuf_len)
const 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));
491 require(xbuf_len >=
sizeof(
double));
500 lfiber_id = xfiber_id.
hub_pod();
511 get_dof(l_id,
true, xbuf, xbuf_len);
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));
537 require(xbuf_len >=
sizeof(
double));
546 lfiber_id = xfiber_id.
hub_pod();
557 put_dof(l_id,
true, xbuf, xbuf_len);
561 ensure(unexecutable(
internal storage holds
dof referred to by xids));
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 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));
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));
592 cthis->copy_dofs(xclient_base_ids, xclient_base_id_ct, xclient_fiber_ids,
593 xclient_fiber_id_ct, xbuf, xbuf_len,
true);
598 ensure(unexecutable(xbuf holds dofs referred to by xclient_ids));
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)
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));
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));
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);
635 ensure(unexecutable(
internal storage holds dofs referred to by xclient_ids));
648 size_t xbuf_len)
const 653 require(unexecutable(xbuf points to buffer of
length xbuf_len));
654 require(xbuf_len >=
schema().fiber_schema().row_dof_tuple_ub());
669 char* lbuf =
reinterpret_cast<char*
>(xbuf);
677 get_dof(lpid,
true, lbuf, xbuf_len);
678 lbuf +=
sizeof(double);
679 xbuf_len -=
sizeof(double);
701 require(unexecutable(xbuf points to buffer of
length xbuf_len));
702 require(xbuf_len >=
schema().fiber_schema().row_dof_tuple_ub());
717 const char* lbuf =
reinterpret_cast<const char*
>(xbuf);
725 put_dof(lpid,
true, lbuf, xbuf_len);
726 lbuf +=
sizeof(double);
727 xbuf_len -=
sizeof(double);
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]));
759 char* lbuf =
reinterpret_cast<char*
>(xbuf);
765 for(
size_t i=0; i<xdisc_ids_ct; i++)
769 scoped_index::ZERO(),
774 lbuf +=
sizeof(double);
775 xbuf_len -=
sizeof(double);
787 scoped_index::ZERO(),
792 lbuf +=
sizeof(double);
793 xbuf_len -=
sizeof(double);
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]));
827 const char* lbuf =
reinterpret_cast<const char*
>(xbuf);
833 for(
size_t i=0; i<xdisc_ids_ct; i++)
837 scoped_index::ZERO(),
842 lbuf +=
sizeof(double);
843 xbuf_len -=
sizeof(double);
855 scoped_index::ZERO(),
860 lbuf +=
sizeof(double);
861 xbuf_len -=
sizeof(double);
878 const client_index& xcomp_id,
879 const id_map* xcomp_client_id_map,
880 const client_index* xdisc_ids,
882 const id_map* xdisc_client_id_map)
const 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)));
961 const client_index& xcomp_id,
962 const id_map* xcomp_client_id_map,
963 const client_index* xdisc_ids,
965 const id_map* xdisc_client_id_map)
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)));
1066 const void* result = 0;
1095 double* lbuf =
reinterpret_cast<double*
>(xbuf);
1096 size_t lbuf_len = xbuf_len/
sizeof(double);
1109 ensure(unexecutable(
dof tuple copied to xbuf));
1131 double* lbuf =
reinterpret_cast<double*
>(
const_cast<void*
>(xbuf));
1132 size_t lbuf_len = xbuf_len/
sizeof(double);
1145 ensure(unexecutable(xbuf copied to
dof tuple));
1185 fiber_bundle::sparse_field_dof_map::
1186 _has_prototype = make_prototype();
1190 fiber_bundle::sparse_field_dof_map::
1193 bool result =
false;
1201 SPARSE_FIELD_DOF_TUPLE_ID;
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...
virtual ~sparse_field_dof_map()
Destructor.
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)
bool in_scope() const
True if and only if scope() contains an entry for pod().
const pod_type & pod() const
The "plain old data" storage of this; the value in the external id space.
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...
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.
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.
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.
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).
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.
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.
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.
virtual void allocate_dofs()
Allocates dof storage.
A handle for a poset whose members are numerical representations of sections of a fiber bundle...