20 #include "SheafSystem/tp_space.h" 22 #include "SheafSystem/abstract_poset_member.impl.h" 23 #include "SheafSystem/assert_contract.h" 24 #include "SheafSystem/at1_space.h" 25 #include "SheafSystem/fiber_bundles_namespace.h" 26 #include "SheafSystem/namespace_poset.impl.h" 27 #include "SheafSystem/namespace_poset_member.h" 28 #include "SheafSystem/poset_handle_factory.h" 29 #include "SheafSystem/tp.h" 49 static const string& result = tp::standard_schema_poset_name();
53 ensure(!result.empty());
69 static const poset_path& result = tp::standard_schema_path();
73 ensure(result.
full());
74 ensure(result.
poset_name() == standard_schema_poset_name());
87 require(xschema_path.
full());
92 int result = schema_poset_member::row_dof_ct(xns, xschema_path, xauto_access);
96 ensure(result == schema_poset_member::row_dof_ct(xns, xschema_path, xauto_access));
118 int result = ltmp.
d(xp, ldd);
144 require(!xpath.
empty());
147 require(xschema_path.
full());
149 require(schema_poset_member::conforms_to(xns, xschema_path, standard_schema_path(), xauto_access));
153 require(d(xns, xschema_path, xauto_access) == d(xns, xp, xvector_space_path, xauto_access));
161 table_type* ltable =
new table_type();
188 lmap->
put_dof(
"factor_ct", ld);
190 lmap->
put_dof(
"scalar_space_path", lscalar_space_path);
193 lmap->
put_dof(
"vector_space_path", xvector_space_path);
197 ltable->new_state(xns, xpath, lschema, *lmap);
208 ensure(xns.
owns(result, xauto_access));
209 ensure(result.
path(
true) == xpath);
211 ensure(result.
schema(
true).
path(xauto_access) == xschema_path);
213 ensure(result.
factor_ct(
true) == result.
d(
true));
214 ensure(result.
d(
true) == d(xns, xschema_path, xauto_access));
216 ensure(result.
p(
true) == xp);
228 d(
int xp,
int xdd)
const 230 return static_cast<int>(
pow(static_cast<double>(xdd), xp));
235 p(
int xd,
int xdd)
const 254 int result = (lpd == xd) ? lp : -1;
258 ensure(unexecutable(
"result < 0 implies schema dimension inconsistent with vector space dimension"));
273 require(state_is_read_accessible());
288 p(
bool xauto_access)
const 292 require(state_is_auto_read_accessible(xauto_access));
321 require(state_is_read_accessible());
336 dd(
bool xauto_access)
const 340 require(state_is_auto_read_accessible(xauto_access));
369 require(state_is_read_accessible());
377 ensure(!result.
empty());
390 require(state_is_auto_read_accessible(xauto_access));
408 ensure(!result.
empty());
421 require(state_is_auto_read_accessible(xauto_access));
422 require(contains_member(xmbr_id, xauto_access));
423 require(contains_variance_subposets(xauto_access));
435 for(
int i=0; i<lp; ++i)
437 result.
put_variance(i, is_covariant(xmbr_id, i,
false));
458 require(state_is_auto_read_accessible(xauto_access));
459 require(contains_member(xmbr_id, xauto_access));
460 require(contains_variance_subposets(xauto_access));
464 return variance(xmbr_id.
hub_pod(), xauto_access);
473 require(state_is_auto_read_accessible(xauto_access));
474 require(contains_member(xmbr_id, xauto_access));
478 bool result = is_covariant(xmbr_id, xi, xauto_access);
493 require(state_is_auto_read_accessible(xauto_access));
494 require(contains_member(xmbr_id, xauto_access));
498 return variance(xmbr_id.
hub_pod(), xi, xauto_access);
507 require(state_is_auto_read_write_accessible(xauto_access));
508 require(contains_member(xmbr_id, xauto_access));
509 require(xvariance.
p() == p(xauto_access));
515 get_read_write_access(
true);
518 int lct = covariant_subposet_ct();
520 for(
int i=0; i<lct; ++i)
522 put_variance(xmbr_id, i, xvariance.
variance(i),
false);
532 ensure(variance(xmbr_id, xauto_access) == round_variance(xvariance));
545 require(state_is_auto_read_write_accessible(xauto_access));
546 require(contains_member(xmbr_id, xauto_access));
547 require(xvariance.
p() == p(xauto_access));
551 put_variance(xmbr_id.
hub_pod(), xvariance, xauto_access);
555 ensure(variance(xmbr_id, xauto_access) == round_variance(xvariance));
568 require(state_is_auto_read_write_accessible(xauto_access));
569 require(contains_member(xmbr_id, xauto_access));
570 require((0 <= xi) && (xi < p(xauto_access)));
576 put_is_covariant(xmbr_id, xi, xauto_access);
580 put_is_contravariant(xmbr_id, xi, xauto_access);
585 ensure(variance(xmbr_id, xi, xauto_access) == xvariance);
598 require(state_is_auto_read_write_accessible(xauto_access));
599 require(contains_member(xmbr_id, xauto_access));
600 require((0 <= xi) && (xi < p(xauto_access)));
604 put_variance(xmbr_id.
hub_pod(), xi, xvariance, xauto_access);
608 ensure(variance(xmbr_id, xi, xauto_access) == xvariance);
636 require(state_is_auto_read_accessible(xauto_access));
637 require(contains_member(xmbr_id, xauto_access));
647 int lp = covariant_subposet_ct();
648 for(
int i=0; i<lp && result; ++i)
650 subposet lsp(
this, covariant_subposet_name(i));
657 assertion(p() == 0 ? result :
true);
678 require(state_is_auto_read_accessible(xauto_access));
679 require(contains_member(xmbr_id, xauto_access));
683 return is_covariant(xmbr_id.
hub_pod(), xauto_access);
692 require(state_is_auto_read_accessible(xauto_access));
693 require(contains_member(xmbr_id, xauto_access));
694 require((0 <= xi) && (xi < p(xauto_access)));
695 require(contains_variance_subposets(xauto_access));
709 int lxi = (covariant_subposet_ct() > 1) ? xi : 0;
715 subposet lsp(
this, covariant_subposet_name(lxi));
738 require(state_is_auto_read_accessible(xauto_access));
739 require(contains_member(xmbr_id, xauto_access));
740 require((0 <= xi) && (xi < p(xauto_access)));
741 require(contains_variance_subposets(xauto_access));
745 return is_covariant(xmbr_id.
hub_pod(), xi, xauto_access);
754 require(state_is_auto_read_write_accessible(xauto_access));
755 require(contains_member(xmbr_id, xauto_access));
761 get_read_write_access(
true);
764 int lp = covariant_subposet_ct();
765 for(
int i=0; i<lp; ++i)
767 subposet lcovariant(
this, covariant_subposet_name(i));
779 ensure(is_covariant(xmbr_id, xauto_access));
792 require(state_is_auto_read_write_accessible(xauto_access));
793 require(contains_member(xmbr_id, xauto_access));
797 put_is_covariant(xmbr_id.
hub_pod(), xauto_access);
801 ensure(is_covariant(xmbr_id, xauto_access));
814 require(state_is_auto_read_write_accessible(xauto_access));
815 require(contains_member(xmbr_id, xauto_access));
816 require((0 <= xi) && (xi < p(xauto_access)));
822 get_read_write_access(
true);
830 int lxi = (covariant_subposet_ct() > 1) ? xi : 0;
836 subposet lsp(
this, covariant_subposet_name(lxi));
847 ensure(is_covariant(xmbr_id, xi, xauto_access));
860 require(state_is_auto_read_write_accessible(xauto_access));
861 require(contains_member(xmbr_id, xauto_access));
862 require((0 <= xi) && (xi < p(xauto_access)));
866 put_is_covariant(xmbr_id.
hub_pod(), xi, xauto_access);
870 ensure(is_covariant(xmbr_id, xi, xauto_access));
883 require(state_is_auto_read_accessible(xauto_access));
884 require(contains_member(xmbr_id, xauto_access));
894 int lp = covariant_subposet_ct();
895 for(
int i=0; i<lp && result; ++i)
897 subposet lsp(
this, covariant_subposet_name(i));
904 assertion(p() == 0 ? result :
true);
926 require(state_is_auto_read_accessible(xauto_access));
927 require(contains_member(xmbr_id, xauto_access));
931 return is_contravariant(xmbr_id.
hub_pod(), xauto_access);
940 require(state_is_auto_read_accessible(xauto_access));
941 require(contains_member(xmbr_id, xauto_access));
942 require((0 <= xi) && (xi < p(xauto_access)));
946 bool result = !is_covariant(xmbr_id, xi, xauto_access);
968 require(state_is_auto_read_accessible(xauto_access));
969 require(contains_member(xmbr_id, xauto_access));
970 require((0 <= xi) && (xi < p(xauto_access)));
974 return is_contravariant(xmbr_id.
hub_pod(), xi, xauto_access);
983 require(state_is_auto_read_write_accessible(xauto_access));
984 require(contains_member(xmbr_id, xauto_access));
990 get_read_write_access(
true);
993 int lp = covariant_subposet_ct();
994 for(
int i=0; i<lp; ++i)
996 subposet lcovariant(
this, covariant_subposet_name(i));
1008 ensure(is_contravariant(xmbr_id, xauto_access));
1021 require(state_is_auto_read_write_accessible(xauto_access));
1022 require(contains_member(xmbr_id, xauto_access));
1026 put_is_contravariant(xmbr_id.
hub_pod(), xauto_access);
1030 ensure(is_contravariant(xmbr_id, xauto_access));
1043 require(state_is_auto_read_write_accessible(xauto_access));
1044 require(contains_member(xmbr_id, xauto_access));
1045 require((0 <= xi) && (xi < p(xauto_access)));
1051 get_read_write_access(
true);
1059 int lxi = (covariant_subposet_ct() > 1) ? xi : 0;
1065 subposet lsp(
this, covariant_subposet_name(lxi));
1076 ensure(is_contravariant(xmbr_id, xi, xauto_access));
1089 require(state_is_auto_read_write_accessible(xauto_access));
1090 require(contains_member(xmbr_id, xauto_access));
1091 require((0 <= xi) && (xi < p(xauto_access)));
1095 put_is_contravariant(xmbr_id.
hub_pod(), xi, xauto_access);
1099 ensure(is_contravariant(xmbr_id, xi, xauto_access));
1147 require(xbottom != 0);
1186 fiber_bundle::tp_space::
1189 bool result =
false;
1234 static const char* result =
"tp_space";
1302 result =
dynamic_cast<const tp_space*
>(xother) != 0;
1325 ensure(result != 0);
poset_state_handle * host() const
The poset which this is a handle to a component of.
virtual poset_path path(bool xauto_access=true) const
The path of this poset.
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 ...
A client handle for a subposet.
void insert_prototype(const poset_state_handle *xprototype)
Sets xprototype as the prototype for its client class.
bool full() const
True if both poset name and member name are not empty.
int p() const
The tensor degree.
const pod_type & pod() const
The "plain old data" storage of this; the value in the external id space.
The "type" of a tensor; specifies the degree and the co- or contra-variance for each index of a tenso...
virtual void put_is_covariant(pod_index_type xmbr_id, bool xauto_access)
Sets all tensor index positions of the member with id xmbr_id to covariant.
const scoped_index & index() const
The member index of this poset within the namespace host()
poset_path path(bool xauto_access=true) const
A path to this component.
The default name space; a poset which contains other posets as members.
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...
poset_path vector_space_path() const
The path of the underlying vector space.
poset_type
Identifiers for poset types.
virtual pod_index_type prereq_id(int xi) const
The id of the xi-th prerequisite poset for this.
void put_variance(int xi, bool xvalue)
Sets the variance of the xi-th index to xvalue.
A path defined by a poset name and a member name separated by a forward slash ('/'). For example: "cell_definitions/triangle".
virtual bool contains_member(pod_index_type xmbr_hub_id) const
True if this poset contains poset member with hub id xmbr_hub_id.
virtual void get_read_access() const
Get read access to the state associated with this.
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.
int p() const
The tensor degree of this space.
virtual tp_space * clone() const
Virtual constructor; creates a new handle of the same actual type as this, attached to the same state...
virtual tensor_variance variance(pod_index_type xmbr_id, bool xauto_access) const
The variance of the member with id xmbr_id.
static const std::string & standard_schema_poset_name()
The name of the standard schema poset for this class.
virtual void put_is_contravariant(pod_index_type xmbr_id, bool xauto_access)
Sets all tensor index positions of the member with id xmbr_id to contravariant.
A general tensor of "degree" p and given "variance" over an abstract vector space.
virtual size_type covariant_subposet_ct() const
The number of covariant subposets.
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...
Abstract base class with useful features for all objects.
virtual tensor_variance round_variance(const tensor_variance &xvariance) const
"Rounds" xvariance up or down to a supported value. Version defined in this class just returns xvaria...
virtual bool is_covariant(pod_index_type xmbr_id, bool xauto_access) const
True if and only if all tensor index positions of the member with id xmbr_id are covariant.
static const poset_path & standard_schema_path()
The path to the standard schema for this class.
virtual schema_poset_member & schema()
The schema for this poset (mutable version).
virtual poset_type type_id() const
Identifier for the type of this poset.
bool owns(const poset_state_handle &xposet, bool xauto_access) const
True if and only if this contains the poset xposet. synonym for contains_poset(xposet.poset_path(true), xauto_access)
virtual bool is_contravariant(pod_index_type xmbr_id, bool xauto_access) const
True if and only if all tensor index positions of the member with id xmbr_id are contravariant.
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.
std::string poset_name() const
The poset name part of the path.
virtual void insert_member(pod_index_type xmbr_hub_id)
Inserts the member of host() with hub id xmbr_hub_id.
bool contains_path(const poset_path &xpath, bool xauto_access=true) const
True if this contains the poset or poset member specified by xpath.
int p(int xd, int xdd) const
Tensor degree as a function of tensor dimension xd and domain dimension xdd.
static tp_space & new_table(namespace_type &xhost, const poset_path &xpath, const poset_path &xschema_path, int xp, const poset_path &xvector_space_path, bool xauto_access)
Creates a new tp_space in namespace xns with path xpath, schema specified by xschema_path, and table attributes p and vector_space_path specified by xp and xvector_space_path, respectively.
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...
bool empty() const
True if both poset name and member name are empty.
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
void put_variance(pod_index_type xmbr_id, const tensor_variance &xvariance, bool xauto_access)
Sets the variance of the member with id xmbr_id to xvariance.
poset_state_handle()
Default constructor.
poset_path scalar_space_path() const
The path of the underlying space of scalars.
virtual const char * class_name() const
The name of this class.
static poset_handle_factory & factory()
The poset handle factory.
int d() const
The dimension.
virtual void detach_from_state()
Detach this handle from its state, if any.
virtual bool is_ancestor_of(const any *xother) const
True if other conforms to this.
namespace_poset * name_space() const
The namespace this poset resides in.
virtual bool is_attached() const
True if this is attached to a state.
An abstract vector space viewed as an antisymmetric tensor space of degree 1.
An abstract vector space of dimension d.
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.
bool invariant_check() const
True if invariant checking is enabled.
static int d(const namespace_poset &xns, const poset_path &xschema_path, bool xauto_access)
The tensor dimension implied by the schema specified by xschema_path.
static int factor_ct(int xd)
Factor_ct() as a function of dimension xd.
virtual void remove_member(pod_index_type xmbr_hub_id)
Removes the member of host() with hub id xmbr_hub_id.
T::table_dofs_type & table_dofs(T &x0)
The table dofs pod type for x0 (mutable version).
int_type pod_index_type
The plain old data index type.
int dd() const
The dimension of the underlying ("domain") vector space.
bool variance(int xi) const
The variance of the xi-th index; covariant if true, contravariant if false.
virtual bool invariant() const
Class invariant.
tp_space()
Default constructor; creates a new tp_space handle not attached to any state.
vd_space()
Default constructor; creates a new vd_space handle not attached to any state.
virtual bool invariant() const
Class invariant.
An array representation of abstract class poset_dof_map.
An abstract tensor space of degree p.
Namespace for the fiber_bundles component of the sheaf system.
SHEAF_DLL_SPEC void pow(const sec_at0 &x0, const vd_value_type &xexponent, sec_at0 &xresult, bool xauto_access)
Compute x0 to power xexponent (pow(x0, xexponent)) (pre-allocated version).
SHEAF_DLL_SPEC pod_index_type invalid_pod_index()
The invalid pod index value.
bool is_same_type(const any *other) const
True if other is the same type as this.
void enable_invariant_check() const
Enable invariant checking.
int factor_ct() const
The number of factors in this product.
bool state_is_not_read_accessible() const
True if this is attached and if the state is accessible for read or if access control is disabled...
A client handle for a poset member which has been prepared for use as a schema.
virtual ~tp_space()
Destructor.
virtual const scoped_index & member_id(bool xauto_access) const
An id in the member hub id space; intended for copying to initialize ids to the member id space...
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.