20 #include "SheafSystem/array_field_dof_map.h" 21 #include "SheafSystem/assert_contract.h" 23 #include "SheafSystem/dof_map_factory.h" 24 #include "SheafSystem/discretization_iterator.h" 25 #include "SheafSystem/sec_rep_space.h" 40 const string& result = static_class_name();
44 ensure(!result.empty());
60 static const string result(
"array_field_dof_map");
64 ensure(!result.empty());
65 ensure(result ==
"array_field_dof_map");
92 _fiber_tuple_size = 0;
94 _this_owns_dofs =
false;
146 _fiber_tuple_size = 0;
148 _this_owns_dofs =
false;
203 if(xother._dofs != 0)
207 _disc_ct = xother._disc_ct;
208 _fiber_ct = xother._fiber_ct;
209 _local_ct = xother._local_ct;
210 _fiber_tuple_size = xother._fiber_tuple_size;
214 _this_owns_dofs = xother._this_owns_dofs;
224 _dofs = xother._dofs;
232 _fiber_tuple_size = 0;
234 _this_owns_dofs =
false;
277 result = result && (_fiber_tuple_size == _fiber_ct*_local_ct);
304 require(unexecutable(
"if xdofs != 0 it points to buffer of length xdofs_ub"));
312 _fiber_ct = xhost->
df();
314 _fiber_tuple_size = _fiber_ct*_local_ct;
319 _dofs =
static_cast<double*
>(xdofs);
325 _this_owns_dofs =
true;
329 _this_owns_dofs =
false;
335 ensure(_disc_ct > 0);
336 ensure(_fiber_ct > 0);
337 ensure(_local_ct > 0);
338 ensure(
dof_ct() == _disc_ct*_fiber_ct*_local_ct);
341 ensure(xdofs != 0 ? _dofs == xdofs :
true);
358 require(
schema().state_is_read_accessible());
359 require(
schema().dof_id_space().contains_range_id(xdof_id));
360 require(unexecutable(
"xdof points to buffer of size xdof_size"));
361 require(xdof_size >=
schema().size(xdof_id));
382 require(
schema().state_is_read_accessible());
383 require(
schema().dof_id_space().contains_range_id(xdof_id));
384 require(unexecutable(
"xdof points to buffer of size xdof_size"));
385 require(xdof_size >=
schema().size(xdof_id));
393 ensure(unexecutable(
internal storage holds
dof referred to by xdof_id and xis_poset_id));
407 require(
schema().state_is_read_accessible());
408 require(
schema().discretization_id_space().contains_range_id(xdisc_id));
409 require(
schema().fiber_id_space().contains_range_id(xfiber_dof_id));
410 require(unexecutable(
"xdof points to buffer of size xdof_size"));
411 require(xdof_size >=
schema().size(xdisc_id, xfiber_dof_id));
416 memcpy(xdof, dof_ptr(xdisc_id, xfiber_dof_id),
sizeof(
sec_vd_dof_type));
433 require(
schema().state_is_read_accessible());
434 require(
schema().discretization_id_space().contains_range_id(xdisc_id));
435 require(
schema().fiber_id_space().contains_range_id(xfiber_dof_id));
436 require(unexecutable(
"xdof points to buffer of size xdof_size"));
437 require(xdof_size >=
schema().size(xdisc_id, xfiber_dof_id));
442 memcpy(dof_ptr(xdisc_id, xfiber_dof_id), xdof,
sizeof(
sec_vd_dof_type));
459 require(
schema().state_is_read_accessible());
460 require(
schema().discretization_id_space().contains_range_id(xdisc_id));
461 require(unexecutable(
"xfiber points to buffer of size xfiber_size"));
462 require(xfiber_size >=
schema().fiber_size());
467 memcpy(xfiber, dof_ptr(xdisc_id, 0),
schema().fiber_size());
483 require(
schema().state_is_read_accessible());
484 require(
schema().discretization_id_space().contains_range_id(xdisc_id));
485 require(unexecutable(
"xfiber points to buffer of size xfiber_size"));
486 require(xfiber_size >=
schema().fiber_size());
491 memcpy(dof_ptr(xdisc_id, 0), xfiber,
schema().fiber_size());
507 require(
schema().state_is_read_accessible());
508 require(
schema().fiber_id_space().contains_range_id(xfiber_dof_id));
509 require(unexecutable(
"xcomponent points to buffer of size xcomponent_size"));
510 require(xcomponent_size >=
schema().component_size(xfiber_dof_id));
515 char* lcomponent =
reinterpret_cast<char*
>(xcomponent);
516 char* ldof = dof_ptr(0, xfiber_dof_id);
522 memcpy(lcomponent, ldof, ldof_size);
523 lcomponent += ldof_size;
542 require(
schema().state_is_read_accessible());
543 require(
schema().fiber_id_space().contains_range_id(xfiber_dof_id));
544 require(unexecutable(
"xcomponent points to buffer of size xcomponent_size"));
545 require(xcomponent_size >=
schema().component_size(xfiber_dof_id));
550 char* lcomponent =
reinterpret_cast<char*
>(xcomponent);
551 char* ldof = dof_ptr(0, xfiber_dof_id);
557 memcpy(ldof, lcomponent, ldof_size);
558 lcomponent += ldof_size;
582 require(xis_poset_id ?
schema().contains_row_dof(xid) :
true);
584 require(unexecutable(
"xbuf_len is large enough to contain the requested dof"));
585 require(unexecutable(
"xbuf is properly aligned for the type of dof"));
590 cthis->copy_dof(xid, xis_poset_id, xbuf, xbuf_len,
true);
607 require(xis_poset_id ?
schema().contains_row_dof(xid) :
true);
610 require(unexecutable(
"xbuf_len is large enough to contain the requested dof"));
611 require(unexecutable(
"xbuf is properly aligned for the type of dof"));
614 require(unexecutable(
"xbuf must be aligned for the given data type"));
618 copy_dof(xid, xis_poset_id, const_cast<void*>(xbuf), xbuf_len,
false);
622 ensure(unexecutable(
internal storage holds
dof referred to by xid and xis_poset_id));
634 get_dofs(
const client_index* xclient_ids,
int xclient_id_ct,
void* xbuf,
size_t xbuf_len)
const 638 require(xclient_ids != 0);
639 require(xclient_id_ct > 0);
640 require(unexecutable(xclient_ids points to buffer of
length xclient_id_ct));
641 require(unexecutable(xclient_ids are valid client ids));
643 require(unexecutable(xbuf points to buffer of
length xbuf_len));
644 require(unexecutable(xbuf_len is large enough to hold the dofs referred to by xclient_ids));
646 require(unexecutable(
"xbuf must be aligned for all data types"));
654 ensure(unexecutable(xbuf holds dofs referred to by xclient_ids));
665 put_dofs(
const client_index* xclient_ids,
int xclient_id_ct,
const void* xbuf,
size_t xbuf_len)
669 require(xclient_ids != 0);
670 require(xclient_id_ct > 0);
671 require(unexecutable(xclient_ids points to buffer of
length xclient_id_ct));
672 require(unexecutable(xclient_ids are valid client ids));
674 require(unexecutable(xbuf points to buffer of
length xbuf_len));
675 require(unexecutable(xbuf_len is large enough to hold the dofs referred to by xclient_ids));
677 require(unexecutable(
"xbuf must be aligned for all data types"));
685 ensure(unexecutable(
internal storage holds dofs referred to by xclient_ids));
700 bool xis_poset_id,
void* xbuf,
size_t xbuf_len)
const 704 require(unexecutable(xbase_id is a valid client
id));
705 require(unexecutable(xfiber_id is a valid client
id));
706 require(unexecutable(0 <= xmult_id && xmult_id < multiplicity));
708 require(unexecutable(xbuf points to buffer of
length xbuf_len));
709 require(unexecutable(xbuf_len is large enough to hold the dofs referred to by client ids));
714 cthis->copy_dof(xbase_id, xfiber_id, xmult_id, xis_poset_id, xbuf, xbuf_len,
true);
718 ensure(unexecutable(xbuf holds
dof referred to by xids));
732 bool xis_poset_id,
const void* xbuf,
size_t xbuf_len)
736 require(unexecutable(xbase_id is a valid client
id));
737 require(unexecutable(xfiber_id is a valid client
id));
738 require(unexecutable(0 <= xmult_id && xmult_id < multiplicity));
740 require(unexecutable(xbuf points to buffer of
length xbuf_len));
741 require(unexecutable(xbuf_len is large enough to hold the dofs referred to by client ids));
745 copy_dof(xbase_id, xfiber_id, xmult_id, xis_poset_id, const_cast<void*>(xbuf), xbuf_len,
false);
749 ensure(unexecutable(
internal storage holds
dof referred to by xids));
759 get_dofs(
const client_index* xclient_base_ids,
int xclient_base_id_ct,
760 const client_index* xclient_fiber_ids,
int xclient_fiber_id_ct,
761 void* xbuf,
size_t xbuf_len)
const 765 require(xclient_base_ids != 0);
766 require(xclient_base_id_ct > 0);
767 require(unexecutable(xclient_base_ids points to buffer of
length xclient_base_id_ct));
768 require(unexecutable(xclient_base_ids are valid client ids));
769 require(xclient_fiber_ids != 0);
770 require(xclient_fiber_id_ct > 0);
771 require(unexecutable(xclient_fiber_ids points to buffer of
length xclient_fiber_id_ct));
772 require(unexecutable(xclient_fiber_ids are valid client ids));
774 require(unexecutable(xbuf points to buffer of
length xbuf_len));
775 require(unexecutable(xbuf_len is large enough to hold the dofs referred to by client ids));
780 cthis->copy_dofs(xclient_base_ids, xclient_base_id_ct, xclient_fiber_ids,
781 xclient_fiber_id_ct, xbuf, xbuf_len,
true);
786 ensure(unexecutable(xbuf holds dofs referred to by xclient_ids));
797 put_dofs(
const client_index* xclient_base_ids,
int xclient_base_id_ct,
798 const client_index* xclient_fiber_ids,
int xclient_fiber_id_ct,
799 const void* xbuf,
size_t xbuf_len)
803 require(xclient_base_ids != 0);
804 require(xclient_base_id_ct > 0);
805 require(unexecutable(xclient_base_ids points to buffer of
length xclient_base_id_ct));
806 require(unexecutable(xclient_base_ids are valid client ids));
807 require(xclient_fiber_ids != 0);
808 require(xclient_fiber_id_ct > 0);
809 require(unexecutable(xclient_fiber_ids points to buffer of
length xclient_fiber_id_ct));
810 require(unexecutable(xclient_fiber_ids are valid client ids));
812 require(unexecutable(xbuf points to buffer of
length xbuf_len));
813 require(unexecutable(xbuf_len is large enough to hold the dofs referred to by xclient_ids));
817 copy_dofs(xclient_base_ids, xclient_base_id_ct, xclient_fiber_ids,
818 xclient_fiber_id_ct, const_cast<void*>(xbuf), xbuf_len,
false);
823 ensure(unexecutable(
internal storage holds dofs referred to by xclient_ids));
836 size_t xbuf_len)
const 841 require(unexecutable(xbuf points to buffer of
length xbuf_len));
842 require(xbuf_len >=
schema().fiber_schema().row_dof_tuple_ub());
843 require(xis_poset_id ? xdisc_id.
in_scope() :
true);
850 ldisc_id =
schema().disc_seq_id_map().client_id(xdisc_id.
hub_pod());
860 char* ldof_base =
reinterpret_cast<char*
>(_dofs) + ldisc_id*ltuple_size;
862 memcpy(xbuf, ldof_base, ltuple_size);
882 require(unexecutable(xbuf points to buffer of
length xbuf_len));
883 require(xbuf_len >=
schema().fiber_schema().row_dof_tuple_ub());
884 require(xis_poset_id ? xdisc_id.
in_scope() :
true);
891 ldisc_id =
schema().disc_seq_id_map().client_id(xdisc_id.
hub_pod());
899 size_t ltuple_size =
sizeof(double)*lfiber_dof_ct;
901 size_t lindex = ldisc_id*lfiber_dof_ct;
905 char* ldof_base =
reinterpret_cast<char*
>(_dofs) + lindex*
sizeof(
double);
907 memcpy(ldof_base, xbuf, ltuple_size);
929 require(unexecutable(xbuf points to buffer of
length xbuf_len));
930 require(unexecutable(
"xbuf_len is large enough for the requested dofs"));
931 require(
schema().fiber_schema().contains_row_dof(xcomp_id));
932 require(xdisc_ids == 0 ? xdisc_ids_ct == 0 :
true);
933 require_for_all(i, 0, xdisc_ids_ct,
schema().discretization().contains_member(xdisc_ids[i]));
937 copy_component_dofs(xbuf,
965 require(unexecutable(xbuf points to buffer of
length xbuf_len));
966 require(unexecutable(
"xbuf_len is large enough for the requested dofs"));
967 require(
schema().fiber_schema().contains_row_dof(xcomp_id));
968 require(xdisc_ids == 0 ? xdisc_ids_ct == 0 :
true);
969 require_for_all(i, 0, xdisc_ids_ct,
schema().discretization().contains_member(xdisc_ids[i]));
973 copy_component_dofs(const_cast<void*>(xbuf),
992 const client_index& xcomp_id,
993 const id_map* xcomp_client_id_map,
994 const client_index* xdisc_ids,
996 const id_map* xdisc_client_id_map)
const 1002 require(unexecutable(xbuf points to buffer of
length xbuf_len));
1003 require(unexecutable(
"xbuf_len is large enough for the requested dofs"));
1004 require(xcomp_client_id_map != 0);
1005 require(
schema().fiber_schema().contains_row_dof(
scoped_index(xcomp_id, xcomp_client_id_map)));
1006 require(xdisc_ids == 0 ? xdisc_ids_ct == 0 :
true);
1007 require(xdisc_ids_ct != 0 ? xdisc_client_id_map != 0 :
true);
1008 require_for_all(i, 0, xdisc_ids_ct,
schema().discretization().contains_member(
scoped_index(xdisc_ids[i], xdisc_client_id_map)));
1013 copy_component_dofs(xbuf,
1016 xcomp_client_id_map,
1019 xdisc_client_id_map,
1034 const client_index& xcomp_id,
1035 const id_map* xcomp_client_id_map,
1036 const client_index* xdisc_ids,
1038 const id_map* xdisc_client_id_map)
1044 require(unexecutable(xbuf points to buffer of
length xbuf_len));
1045 require(unexecutable(
"xbuf_len is large enough for the requested dofs"));
1046 require(xcomp_client_id_map != 0);
1047 require(
schema().fiber_schema().contains_row_dof(
scoped_index(xcomp_id, xcomp_client_id_map)));
1048 require(xdisc_ids == 0 ? xdisc_ids_ct == 0 :
true);
1049 require(xdisc_ids_ct != 0 ? xdisc_client_id_map != 0 :
true);
1050 require_for_all(i, 0, xdisc_ids_ct,
schema().discretization().contains_member(
scoped_index(xdisc_ids[i], xdisc_client_id_map)));
1055 copy_component_dofs(const_cast<void*>(xbuf),
1058 xcomp_client_id_map,
1061 xdisc_client_id_map,
1127 memcpy(xbuf, static_cast<void*>(_dofs),
dof_tuple_ub());
1132 ensure(unexecutable(
dof tuple copied to xbuf));
1152 memcpy(static_cast<void*>(_dofs), xbuf,
dof_tuple_ub());
1157 ensure(unexecutable(xbuf copied to
dof tuple));
1182 _this_owns_dofs =
true;
1193 fiber_bundle::array_field_dof_map::
1194 _has_prototype = make_prototype();
1198 fiber_bundle::array_field_dof_map::
1201 bool result =
false;
1225 fiber_bundle::array_field_dof_map::
1231 require(xindex >= 0);
1232 require(_dofs != 0);
1233 require(_this_owns_dofs);
1242 if(new_ub <= xindex)
1243 new_ub = xindex + 1;
1247 double* new_dofs =
new double[new_ub];
1258 _dof_tuple_ub = new_ub;
array_field_dof_map & operator=(const array_field_dof_map &xother)
Assignment operator.
virtual array_field_dof_map * clone() const
Virtual default constructor.
virtual void put_dof_tuple(const void *xbuf, size_t xbuflen)
Copies the entire dof tuple from xbuf into internal storage.
virtual void get_fiber(pod_index_type xdisc_id, void *xfiber, size_type xfiber_size) const
Sets xfiber to the fiber referred to by discretization id xdisc_id.
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().
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...
virtual ~array_field_dof_map()
Destructor.
schema_poset_member & fiber_schema()
The fiber schema component of this (mutable version).
virtual const std::string & class_name() const
The name of the actual (possibly derived) class of this instance.
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
virtual size_t size() const =0
The number of bytes in this dof.
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.
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 section_space_schema_member & schema()
The schema on which this is allocated (mutable version).
virtual void allocate_dofs()
Allocates dof storage.
virtual void put_dof(pod_index_type xdof_id, bool xis_poset_id, const void *xdof, size_type xdof_size)
Sets the dof referred to by xdof_id to the value at xdof.
bool is_initialized() const
True if this has been initialized, that is, if the schema has been set and the dof map storage alloca...
int df() const
The dimension of the fiber space.
The general, abstract map from dof ids to dof values.
virtual void put_component(pod_index_type xfiber_dof_id, const void *xcomponent, size_type xcomponent_size)
Sets the component referred to by fiber id xfiber_dof_id to xcomponent.
virtual void put_fiber(pod_index_type xdisc_id, const void *xfiber, size_type xfiber_size)
Sets the fiber referred to by discretization id xdisc_id to xfiber.
size_t _dof_tuple_ub
The size of the dof tuple.
virtual section_space_schema_member & schema()
The schema for this poset (mutable version)
static dof_map_factory & factory()
The dof map factory.
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 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...
subposet & discretization()
The subposet on which the degrees of freedom are defined (mutable version).
A contiguous tuple, contiguous fiber representation of the abstract map from section_space_schema_mem...
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 ...
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
dof_tuple_type
Identifiers for dof tuple types.
static const std::string & static_class_name()
The name of this class.
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).
int member_ct() const
The number of members of this subposet.
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 ...
int dof_ct() const
The number of dofs in this map.
int multiplicity() const
The number of degrees of freedom associated with each member of the discretization.
size_type fiber_size() const
The number of bytes in the fiber.
size_t row_dof_tuple_ub() const
The size in bytes of the row dof tuple defined by this schema. Synonym for dof_tuple_ub(false).
pod_index_type pod_type
The "plain old data" storage type for this.
virtual array_field_dof_map * copy() const
Virtual copy constructor.
virtual void get_dof_tuple(void *xbuf, size_t xbuflen) const
Copies the entire dof tuple from internal storage into xbuf.
int_type pod_index_type
The plain old data index type.
virtual void get_component(pod_index_type xfiber_dof_id, void *xcomponent, size_type xcomponent_size) const
Sets xcomponent to the component referred to by fiber id xfiber_dof_id.
array_field_dof_map()
Default constructor.
field_dof_map & operator=(const field_dof_map &xother)
Assignment operator.
void insert_prototype(const poset_dof_map *xprototype)
Sets xprototype as the prototype for its client class.
double sec_vd_dof_type
The type of degree of freedom in the section space.
virtual void get_dof(pod_index_type xdof_id, void *xdof, size_type xdof_size) const
Copies the dof referred to by xdof_id into xdof.
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 void * dof_tuple()
The dof tuple (mutable version).
virtual bool invariant() const
The class invariant.
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.
A handle for a poset whose members are numerical representations of sections of a fiber bundle...