20 #include "SheafSystem/array_section_dof_map.h" 22 #include "SheafSystem/assert_contract.h" 23 #include "SheafSystem/discretization_iterator.h" 24 #include "SheafSystem/error_message.h" 25 #include "SheafSystem/dof_map_factory.h" 26 #include "SheafSystem/postorder_iterator.h" 27 #include "SheafSystem/sec_rep_space.h" 28 #include "SheafSystem/primitive_type.h" 47 const string& result = static_class_name();
51 ensure(!result.empty());
67 static const string result(
"array_section_dof_map");
71 ensure(!result.empty());
72 ensure(result ==
"array_section_dof_map");
95 _this_owns_dofs =
false;
148 _this_owns_dofs =
false;
206 if(xother._dofs != 0)
210 _fiber_dof_ct = xother._fiber_dof_ct;
211 _local_ct = xother._local_ct;
215 _this_owns_dofs = xother._this_owns_dofs;
224 _dofs = xother._dofs;
233 _this_owns_dofs =
false;
301 require(unexecutable(
"if xdofs != 0 it points to buffer of length xdofs_ub"));
305 init_dofs(xdofs, xdofs_ub);
309 ensure(_local_ct > 0);
313 ensure(xdofs != 0 ? _dofs == xdofs :
true);
328 require(precondition_of(sec_dof_map::sec_dof_map(xhost, xbase_id, xversion)));
329 require(unexecutable(
"if xdofs != 0 it points to buffer of length xdofs_ub"));
331 require(unexecutable(
"if xdofs != 0 xdofs_ub is large enough"));
335 init_dofs(xdofs, xdofs_ub);
339 assertion(_local_ct > 0);
340 assertion(_dofs != 0);
341 assertion(xdofs != 0 ? _dofs == xdofs :
true);
345 ensure(postcondition_of(sec_dof_map::sec_dof_map(xhost, xbase_id, xversion)));
348 ensure(xdofs != 0 ?
dof_tuple() == xdofs :
true);
363 require(precondition_of(sec_dof_map::sec_dof_map(xhost, xbase_id, xversion)));
364 require(unexecutable(
"if xdofs != 0 it points to buffer of length xdofs_ub"));
366 require(unexecutable(
"if xdofs != 0 xdofs_ub is large enough"));
370 init_dofs(xdofs, xdofs_ub);
374 assertion(_local_ct > 0);
375 assertion(_dofs != 0);
376 assertion(xdofs != 0 ? _dofs == xdofs :
true);
380 ensure(postcondition_of(sec_dof_map::sec_dof_map(xhost, xbase_id, xversion)));
383 ensure(xdofs != 0 ?
dof_tuple() == xdofs :
true);
408 #ifdef DIAGNOSTIC_OUTPUT 409 cout <<
" xdof_id: " << xdof_id
410 <<
" offset: " << loffset
411 <<
" size: " << lsize
414 <<
" result: " << boolalpha << result << noboolalpha
441 #ifdef DIAGNOSTIC_OUTPUT 442 cout <<
" xdisc_id: " << xdisc_id
443 <<
" xfiber_id: " << xfiber_id
444 <<
" offset: " << loffset
445 <<
" size: " << lsize
448 <<
" result: " << boolalpha << result << noboolalpha
467 require(
schema().state_is_read_accessible());
469 require(unexecutable(
"xdof points to buffer of size xdof_size"));
496 require(
schema().state_is_read_accessible());
498 require(unexecutable(
"xdof points to buffer of size xdof_size"));
512 ensure(unexecutable(
internal storage holds
dof referred to by xdof_id and xis_poset_id));
527 require(
schema().state_is_read_accessible());
528 require(
schema().discretization_id_space().contains(xdisc_id));
529 require(
schema().fiber_schema_id_space(
false).contains(xfiber_dof_id));
530 require(unexecutable(
"xdof points to buffer of size xdof_size"));
531 require(xdof_size >=
schema().size(xdisc_id, xfiber_dof_id));
559 require(
schema().state_is_read_accessible());
560 require(
schema().discretization_id_space().contains(xdisc_id));
561 require(
schema().fiber_schema_id_space(
false).contains(xfiber_dof_id));
562 require(unexecutable(
"xdof points to buffer of size xdof_size"));
563 require(xdof_size >=
schema().size(xdisc_id, xfiber_dof_id));
600 #ifdef DIAGNOSTIC_OUTPUT 601 cout <<
" xdisc_id: " << xdisc_id
602 <<
" offset: " << loffset
603 <<
" size: " << lsize
606 <<
" result: " << boolalpha << result << noboolalpha
633 size_t ldof_tuple_ub = (xdisc_id+1)*ltuple_size;
635 reserve(ldof_tuple_ub);
637 #ifdef DIAGNOSTIC_OUTPUT 638 cout <<
" xdisc_id: " << xdisc_id
639 <<
" ltuple_size: " << ltuple_size
640 <<
" ldof_tuple_ub: " << ldof_tuple_ub
660 require(
schema().state_is_read_accessible());
661 require(
schema().discretization_id_space().contains(xdisc_id));
662 require(unexecutable(
"xfiber points to buffer of size xfiber_size"));
663 require(xfiber_size >=
schema().fiber_size());
688 require(
schema().state_is_read_accessible());
689 require(
schema().discretization_id_space().contains(xdisc_id));
690 require(unexecutable(
"xfiber points to buffer of size xfiber_size"));
691 require(xfiber_size >=
schema().fiber_size());
716 require(
schema().state_is_read_accessible());
717 require(
schema().discretization_id_space().contains(xdisc_id));
718 require(unexecutable(
"xfiber points to buffer of size xfiber_size"));
719 require(xfiber_size >=
schema().fiber_size());
742 require(
schema().state_is_read_accessible());
743 require(
schema().fiber_schema_id_space(
false).contains(xfiber_dof_id));
744 require(unexecutable(
"xcomponent points to buffer of size xcomponent_size"));
745 require(xcomponent_size >=
schema().component_size(xfiber_dof_id));
750 char* lcomponent =
reinterpret_cast<char*
>(xcomponent);
751 char* ldof =
reinterpret_cast<char*
>(dof_ptr(0, xfiber_dof_id,
is_table_dof_map()));
758 memcpy(lcomponent, ldof, ldof_size);
759 lcomponent += ldof_size;
777 require(
schema().state_is_read_accessible());
778 require(
schema().fiber_schema_id_space(
false).contains(xfiber_dof_id));
779 require(unexecutable(
"xcomponent points to buffer of size xcomponent_size"));
780 require(xcomponent_size >=
schema().component_size(xfiber_dof_id));
785 const char* lcomponent =
reinterpret_cast<const char*
>(xcomponent);
786 char* ldof =
reinterpret_cast<char*
>(dof_ptr(0, xfiber_dof_id,
is_table_dof_map()));
793 memcpy(ldof, lcomponent, ldof_size);
794 lcomponent += ldof_size;
867 memcpy(xbuf, static_cast<void*>(_dofs),
dof_tuple_ub());
872 ensure(unexecutable(
dof tuple copied to xbuf));
892 memcpy(static_cast<void*>(_dofs), xbuf,
dof_tuple_ub());
897 ensure(unexecutable(xbuf copied to
dof tuple));
907 fiber_bundle::array_section_dof_map::
908 init_dofs(
void* xdofs,
size_t xdofs_ub)
913 require(xdofs != 0 ? xdofs_ub >=
schema().row_dof_tuple_ub():
true);
914 require(unexecutable(
"if xdofs != 0 it points to buffer of length xdofs_ub"));
923 _dofs =
static_cast<char*
>(xdofs);
928 _this_owns_dofs =
true;
932 _this_owns_dofs =
false;
937 ensure(_local_ct > 0);
939 ensure(xdofs != 0 ? _dofs == xdofs :
true);
967 fiber_bundle::array_section_dof_map::
995 fiber_bundle::array_section_dof_map::
996 reserve(
size_t xdof_tuple_ub)
1001 require(_dofs != 0);
1002 require(_this_owns_dofs);
1011 if(new_ub < xdof_tuple_ub)
1013 new_ub = xdof_tuple_ub;
1018 char* new_dofs =
new char[new_ub];
bool is_table_dof_map() const
True if this is a table dof map.
static const std::string & static_class_name()
The name of this class.
virtual void allocate_dofs()
Allocates dof storage.
The abstract map from section dof ids to section dof values of heterogeneous type.
virtual void force_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; allocates memory if necessary...
schema_poset_member & fiber_schema()
The fiber schema component of this (mutable version).
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 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.
virtual size_t size() const =0
The number of bytes in this dof.
primitive_value dof(pod_index_type xdof_id) const
The dof referred to by xdof_id.
int version() const
The version of the host of the schema this is defined on.
virtual void * dof_tuple()
The dof tuple (mutable version).
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...
array_section_dof_map()
Default constructor.
virtual array_section_dof_map * copy() const
Virtual copy constructor.
The general, abstract map from dof ids to dof values.
virtual const std::string & class_name() const
The name of the actual (possibly derived) class of this instance.
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 bool invariant() const
The class invariant.
array_section_dof_map & operator=(const array_section_dof_map &xother)
Assignment operator.
A contiguous tuple, contiguous fiber representation of the abstract map from section dof ids to secti...
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.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
virtual bool dof_in_bounds(pod_index_type xdof_id, bool xis_table_dofs) const
True if and only if the dof asociated with id xdof_id is within the current capacity of the dofs stor...
virtual ~array_section_dof_map()
Destructor.
int discretization_ct() const
The number of members in the intersection of the discretization subposet and the down set of the base...
virtual void get_dof_tuple(void *xbuf, size_t xbuflen) const
Copies the entire dof tuple from internal storage into xbuf.
dof_tuple_type
Identifiers for dof tuple types.
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).
section_dof_map & operator=(const section_dof_map &xother)
Assignment operator.
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.
virtual void put_dof(pod_index_type xdof_id, const void *xdof, size_type xdof_size)
Sets the dof referred to by xdof_id to the value at xdof.
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).
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.
void reserve_fiber(pod_index_type xdisc_id)
Ensures this has the capacity to store the fiber with discretization id xdisc_id. ...
virtual array_section_dof_map * clone() const
Virtual default constructor.
int_type pod_index_type
The plain old data index type.
virtual bool fiber_in_bounds(pod_index_type xdisc_id, bool xis_table_dofs) const
True if and only if the fiber asociated with discretization id xdisc_id is within the current capacit...
virtual void put_dof_tuple(const void *xbuf, size_t xbuflen)
Copies the entire dof tuple from xbuf into internal storage.
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.
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.
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 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 sec_rep_space * host() const
The poset which hosts member()
const scoped_index & index() const
The index of this in host() dof tuple table.
virtual size_type offset(pod_index_type xdof_id, bool xis_table_dof) const
The offset for the table dof (xis_table_dof true) or row dof referred to by xdof_id in the schema def...
A handle for a poset whose members are numerical representations of sections of a fiber bundle...