21 #include "SheafSystem/st2_e2.impl.h" 23 #include "SheafSystem/abstract_poset_member.impl.h" 24 #include "SheafSystem/assert_contract.h" 25 #include "SheafSystem/at0.h" 26 #include "SheafSystem/at1_space.h" 27 #include "SheafSystem/stp_space.h" 28 #include "SheafSystem/fiber_bundles_namespace.h" 29 #include "SheafSystem/schema_poset_member.h" 30 #include "SheafSystem/stp_space.h" 31 #include "SheafSystem/wsv_block.h" 136 _row_dofs = xrow_dofs;
183 fiber_bundle::st2_e2_lite::
199 fiber_bundle::st2_e2_lite::
215 fiber_bundle::st2_e2_lite::
231 fiber_bundle::st2_e2_lite::
256 put_components(xx, xy, yy);
273 put_component(0, xx_comp);
274 put_component(1, xy_comp);
275 put_component(2, yy_comp);
357 require(precondition_of(e2_lite::static_tp_prototype(xp)));
361 const tp_lite& result = e2_lite::static_tp_prototype(xp);
365 ensure(postcondition_of(e2_lite::static_tp_prototype(xp)));
378 require(precondition_of(e2_lite::static_atp_prototype(xp)));
382 const atp_lite& result = e2_lite::static_atp_prototype(xp);
386 ensure(postcondition_of(e2_lite::static_atp_prototype(xp)));
399 require(precondition_of(e2_lite::static_stp_prototype(xp)));
403 const stp_lite& result = e2_lite::static_stp_prototype(xp);
407 ensure(postcondition_of(e2_lite::static_stp_prototype(xp)));
445 const string& result = static_class_name();
449 ensure(!result.empty());
464 static const string result(
"st2_e2_lite");
468 ensure(!result.empty());
490 ensure(is_same_type(*result));
514 require(&xother != 0);
520 bool result =
dynamic_cast<const st2_e2_lite*
>(&xother) != 0;
533 if(invariant_check())
537 disable_invariant_check();
541 invariance(st2_lite::invariant());
547 enable_invariant_check();
593 static const poset_path result(standard_schema_poset_name(),
"st2_e2_schema");
614 string lmember_names =
"xx DOUBLE false ";
615 lmember_names +=
"xy DOUBLE false ";
616 lmember_names +=
"yy DOUBLE false";
619 standard_schema_path().member_name(),
620 st2::standard_schema_path(),
649 require(!xhost_path.
empty());
652 require(xschema_path.
full());
654 require(schema_poset_member::conforms_to(xns, xschema_path, standard_schema_path()));
655 require(schema_poset_member::row_dof_ct(xns, xschema_path, xauto_access) == 3);
665 host_type::new_table(xns, xhost_path, xschema_path, 2, xvector_space_path, xauto_access);
669 ensure(xns.
owns(result, xauto_access));
670 ensure(result.path(
true) == xhost_path);
671 ensure(result.state_is_not_read_accessible());
672 ensure(result.schema(
true).path(xauto_access) == xschema_path);
674 ensure(result.factor_ct(
true) == 3);
675 ensure(result.d(
true) == 3);
677 ensure(result.p(
true) == 2);
678 ensure(result.dd(
true) == 2);
679 ensure(result.vector_space_path(
true) == xvector_space_path);
697 require(xsuffix.empty() || poset_path::is_valid_name(xsuffix));
698 require(standard_host_is_available<st2_e2>(xns, xsuffix, xauto_access));
708 poset_path lvector_space_path = vector_space_type::standard_host(xns, xsuffix, xauto_access).
path(
true);
710 poset_path lpath(standard_host_path<st2_e2>(xsuffix));
719 result_ptr = &new_host(xns, lpath, standard_schema_path(), lvector_space_path, xauto_access);
726 ensure(xns.
owns(result, xauto_access));
727 ensure(result.
path(
true) == standard_host_path<st2_e2>(xsuffix));
729 ensure(result.
schema(
true).
path(xauto_access) == standard_schema_path());
732 ensure(result.
d(
true) == 3);
733 ensure(result.
scalar_space_path(
true) == standard_host_path<vector_space_type::scalar_type>(xsuffix) );
734 ensure(result.
p(
true) == 2);
735 ensure(result.
dd(
true) == 2);
736 ensure(result.
vector_space_path(
true) == standard_host_path<vector_space_type>(xsuffix) );
761 require(precondition_of(e2::new_tp(vector_space(xauto_access), xp)));
765 tp* result = e2::new_tp(vector_space(xauto_access), xp);
769 ensure(postcondition_of(e2::new_tp(vector_space(xauto_access), xp)));
782 require(precondition_of(e2::new_atp(vector_space(xauto_access), xp)));
786 atp* result = e2::new_atp(vector_space(xauto_access), xp);
790 ensure(postcondition_of(e2::new_atp(vector_space(xauto_access), xp)));
803 require(precondition_of(e2::new_stp(vector_space(xauto_access), xp)));
807 stp* result = e2::new_stp(vector_space(xauto_access), xp);
811 ensure(postcondition_of(e2::new_stp(vector_space(xauto_access), xp)));
842 attach_to_state(xhost, xhub_id);
848 ensure(index() == xhub_id);
849 ensure(is_attached());
863 attach_to_state(xhost, xid.
hub_pod());
869 ensure(index() ==~ xid);
870 ensure(is_attached());
881 require(!xname.empty());
886 attach_to_state(xhost, xname);
892 ensure(name() == xname);
893 ensure(is_attached());
903 require(xother != 0);
907 attach_to_state(xother);
912 ensure(is_attached());
913 ensure(is_same_state(xother));
923 require(precondition_of(new_jim_state(xhost, 0,
false, xauto_access)));
927 new_jim_state(xhost, 0,
false, xauto_access);
931 ensure(postcondition_of(new_jim_state(xhost, 0,
false, xauto_access)));
946 require(precondition_of(new_jim_state(&xhost, 0,
false, xauto_access)));
950 new_jim_state(&xhost, 0,
false, xauto_access);
966 ensure(postcondition_of(new_jim_state(&xhost, 0,
false, xauto_access)));
979 require(state_is_read_write_accessible());
987 ensure_for_all(i, 0, d(), component(i) == xrdt.
components[i]);
1002 require(is_ancestor_of(&xother));
1003 require(precondition_of(attach_to_state(&xother)));
1007 attach_to_state(&xother);
1011 ensure(postcondition_of(attach_to_state(&xother)));
1025 require(precondition_of(attach_to_state(&xother)));
1029 attach_to_state(&xother);
1033 ensure(postcondition_of(attach_to_state(&xother)));
1141 require(state_is_read_write_accessible());
1145 put_component(0, xx_comp);
1146 put_component(1, xy_comp);
1147 put_component(2, yy_comp);
1152 ensure(invariant());
1162 fiber_bundle::st2_e2::
1167 require(state_is_read_write_accessible());
1180 fiber_bundle::st2_e2::
1185 require(state_is_read_accessible());
1223 const string& result = static_class_name();
1227 ensure(!result.empty());
1242 static const string result(
"st2_e2");
1246 ensure(!result.empty());
1268 ensure(result != 0);
1295 require(xother != 0);
1302 bool result =
dynamic_cast<const st2_e2*
>(xother) != 0;
1306 ensure(invariant());
1324 if (invariant_check())
1328 disable_invariant_check();
1332 invariance(st2::invariant());
1336 invariance(state_is_read_accessible() ? (dd() == 2) :
true);
1337 invariance(state_is_read_accessible() ? (d() == 3) :
true);
1341 enable_invariant_check();
1346 ensure(is_derived_query);
1382 xresult = a00*a11 - a01*a01;
1391 ensure(unexecutable(
"xresult == determinant of x0"));
1405 require(precondition_of(
determinant(x0, result, xauto_access)));
1415 ensure(postcondition_of(
determinant(x0, result, xauto_access)));
1435 xresult = a00*a11 - a01*a01;
1439 ensure(unexecutable(
"xresult == determinant of x0"));
1453 require(precondition_of(
determinant(x0, result)));
1463 ensure(postcondition_of(
determinant(x0, result)));
1490 mlite.diagonalization(xresult);
1496 value_type sxx = xlite[0];
1497 value_type sxy = xlite[1];
1498 value_type syy = xlite[2];
1500 value_type theta = 0.5*
atan2(2.0*sxy, sxx-syy);
1502 value_type cos_theta =
cos(theta);
1503 value_type sin_theta =
sin(theta);
1507 xtransform[0] = cos_theta;
1508 xtransform[1] = sin_theta;
1509 xtransform[2] = -sin_theta;
1510 xtransform[3] = cos_theta;
1514 xtransform[4] = cos_theta;
1515 xtransform[5] = -sin_theta;
1516 xtransform[6] = sin_theta;
1517 xtransform[7] = cos_theta;
1532 bool xpd_lite_is_positive_definite = mlite.is_positive_definite();
1534 require(xpd_lite_is_positive_definite ==
true);
1557 const dof_type* lxdofs =
1558 reinterpret_cast<const dof_type*
>(lrdt.
components);
1560 const dof_type* lxpd_dofs =
1561 reinterpret_cast<const dof_type*
>(lpd_rdt.
components);
1563 dof_type* ltransform_dofs =
1564 reinterpret_cast<dof_type*
>(ltransform_rdt.
components);
1566 dof_type* lresult_dofs =
1567 reinterpret_cast<dof_type*
>(lresult_rdt.
components);
1572 dof_type a = lxpd_dofs[0]*lxpd_dofs[2] - lxpd_dofs[1]*lxpd_dofs[1];
1574 dof_type b = 2*lxdofs[1]*lxpd_dofs[1]-lxdofs[0]*lxpd_dofs[2]
1575 -lxdofs[2]*lxpd_dofs[0];
1577 dof_type c = lxdofs[0]*lxdofs[2] - lxdofs[1]*lxdofs[1];
1583 dof_type sqrt_discr =
sqrt(abs(b*b-4*a*c));
1587 lresult_dofs[0] = (-b+sqrt_discr)/2/a;
1588 lresult_dofs[1] = 0;
1589 lresult_dofs[2] = (-b-sqrt_discr)/2/a;
1647 for(
int i=0; i<2; ++i)
1651 dof_type lambda = (i == 0) ? lresult_dofs[0] : lresult_dofs[2];
1653 ss[0] = lxdofs[0]-lambda*lxpd_dofs[0];
1654 ss[1] = lxdofs[1]-lambda*lxpd_dofs[1];
1655 ss[2] = lxdofs[2]-lambda*lxpd_dofs[2];
1669 ltransform_dofs[0] = 1;
1670 ltransform_dofs[2] = 0;
1676 ltransform_dofs[1] = 0;
1677 ltransform_dofs[3] = 1;
1684 ltransform_dofs[i] = 0;
1685 ltransform_dofs[2+i] = 1;
1692 ltransform_dofs[i] = 1;
1693 ltransform_dofs[2+i] = 0;
1700 ltransform_dofs[i] = -ss[1];
1701 ltransform_dofs[2+i] = ss[0];
1717 (ltransform_dofs[i]*lxpd_dofs[0]+ltransform_dofs[2+i]*lxpd_dofs[1])
1718 +ltransform_dofs[2+i]*
1719 (ltransform_dofs[i]*lxpd_dofs[1]+ltransform_dofs[2+i]*lxpd_dofs[2]);
1723 ltransform_dofs[i] /= d;
1724 ltransform_dofs[2+i] /= d;
1729 dof_type det = ltransform_dofs[0]*ltransform_dofs[3]
1730 - ltransform_dofs[1]*ltransform_dofs[2];
1732 ltransform_dofs[4] = ltransform_dofs[3]/det;
1733 ltransform_dofs[5] = -ltransform_dofs[1]/det;
1734 ltransform_dofs[6] = -ltransform_dofs[2]/det;
1735 ltransform_dofs[7] = ltransform_dofs[0]/det;
virtual void get_read_write_access(bool xrelease_read_only_access=false)
Get read write access to the state associated with this. If release_read_only_access is requested...
SHEAF_DLL_SPEC void sqrt(const sec_at0 &x0, sec_at0 &xresult, bool xauto_access)
Compute sqrt of x0 (sqrt(x0)) (pre-allocated version).
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 ...
virtual volatile_type * lite_type() const
Virtual conversion to the associated volatile type.
virtual void put_components(dof_type xx_comp, dof_type xy_comp, dof_type yy_comp)
Sets values of the components to the given arguments.
A symmetric tensor of degree p over an abstract vector space.
bool full() const
True if both poset name and member name are not empty.
row_dofs_type::matrix_type matrix_type
The type of the associated matrix.
row_dofs_type _row_dofs
Row_dofs_type.
An antisymmetric tensor of degree p.
vd_value_type value_type
The type of component in the fiber; the scalar type in the fiber vector space.
static int d(const namespace_poset &xns, int xp, const poset_path &xvector_space_path, bool xauto_access)
The tensor dimension implied by tensor degree xp and the dimension of the domain vector space specifi...
virtual int dd() const
Dimension of the underlying vector space.
double dof_type
The type of the dofs.
poset_path path(bool xauto_access=true) const
A path to this component.
bool conforms_to(const schema_poset_member &xother) const
True if the dofs defined by this agree in type and in order with the dofs defined by xother...
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...
virtual stp * new_stp(int xp, bool xauto_access) const
Virtual constructor for symmetric tensors of degree xp over vector space xvector_space.
poset_path vector_space_path() const
The path of the underlying vector space.
bool contains_poset_member(pod_index_type xposet_hub_id, pod_index_type xmember_hub_id, bool xauto_access=true) const
True if this contains a poset with hub id xposet_hub_id which contains a member with hub id xmember_h...
bool state_is_auto_read_accessible(bool xauto_access) const
True if the state is auto accessible for read, that is, if the state is already accessible for read o...
A client handle for a general, abstract partially order set.
virtual st2_e2 * clone() const
Make a new handle, no state instance of current.
A path defined by a poset name and a member name separated by a forward slash ('/'). For example: "cell_definitions/triangle".
static void make_standard_schema(namespace_poset &xns)
Creates the standard schema for this class in namespace xns.
static host_type & new_host(namespace_type &xns, const poset_path &xhost_path, const poset_path &xschema_path, const poset_path &xvector_space_path, bool xauto_access)
Creates a new host table for members of this type. The poset is created in namespace xns with path xh...
virtual value_type component(int xrow, int xcolumn) const
The value of the component in a specified row and column.
virtual const volatile_type & lite_prototype() const
Virtual constructor for the associated volatile type.
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.
static const std::string & static_class_name()
The name of this class.
SHEAF_DLL_SPEC void determinant(const st2 &x0, vd_value_type &xresult, bool xauto_access)
The determinant of a symmetric tensor (pre-allocated version for persistent types).
T * to_principal_axes(const T &xlite, GLN &xtransform)
Computes the principal axes basis for xlite. Returns the diagonalization in the auto-allocated result...
T::row_dofs_type & row_dofs(T &x0)
The row dofs pod type for x0 (mutable version).
virtual bool is_ancestor_of(const any_lite &xother) const
Conformance test; true if other conforms to this.
An antisymmetric tensor of degree p over an abstract vector space (volatile version).
static int d(const namespace_poset &xns, int xp, const poset_path &xvector_space_path, bool xauto_access)
The tensor dimension implied by tensor degree xp and the dimension of the domain vector space specifi...
A general tensor of "degree" p and given "variance" over an abstract vector space.
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 volatile objects.
Abstract base class with useful features for all objects.
virtual atp * new_atp(int xp, bool xauto_access) const
Virtual constructor for antisymmetric tensors of degree xp over vector space xvector_space.
A general symmetric tensor of degree 2 over an abstract vector space (volatile version).
virtual schema_poset_member & schema()
The schema for this poset (mutable version).
st2_e2_lite()
Default constructor.
The mathematical group GL(2, R). The group of all invertible, linear transformations on the R2...
virtual st2_e2_lite * clone() const
Virtual constructor, makes a new instance of the same type as this.
bool state_is_read_write_accessible() const
True if this is attached and if the state is accessible for read and write or access control is disab...
st2_e2()
Default constructor.
static const poset_path & standard_schema_path()
The path to the standard schema for this class.
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 void detach_from_state()
Detach this handle from its state, if any.
An index within the external ("client") scope of a given id space.
bool contains_path(const poset_path &xpath, bool xauto_access=true) const
True if this contains the poset or poset member specified by xpath.
T components[3]
Assignment to array of type dof_type.
SHEAF_DLL_SPEC void atan2(const sec_at0 &x0, const sec_at0 &x1, sec_at0 &xresult, bool xauto_access)
Compute atan2 of x0/x1 (atan2(x0, x1)) (pre-allocated version).
virtual const std::string & class_name() const
The name of this class.
virtual bool contains_member(pod_index_type xmbr_hub_id, bool xauto_access=true) const
True if some version of this poset contains poset member with hub id xmbr_hub_id. ...
int p(int xd, int xdd) const
Tensor degree as a function of tensor dimension xd and domain dimension xdd.
bool empty() const
True if both poset name and member name are empty.
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...
A general tensor of degree p over an abstract vector space (volatile version). Volatile version does ...
virtual tp * new_tp(int xp, bool xauto_access) const
Virtual constructor for general tensors of degree xp over vector space xvector_space.
bool contains_poset(pod_index_type xhub_id, bool xauto_access=true) const
True if this contains a poset with hub id xhub_id..
bool invariant() const
Class invariant.
bool path_is_auto_read_available(const poset_path &xpath, bool xauto_access) const
True if the state referred to xpath does not exist or exists and is auto read accessible.
poset_path scalar_space_path() const
The path of the underlying space of scalars.
virtual void * row_dofs()
The row dofs for this instance (mutable version).
SHEAF_DLL_SPEC void cos(const sec_at0 &x0, sec_at0 &xresult, bool xauto_access)
Compute cos of x0 (cos(x0)) (pre-allocated version).
An abstract vector space viewed as an antisymmetric tensor space of degree 1.
virtual const atp_lite & atp_prototype(int xp) const
Prototype for antisymmetric tensors of degree xp over this vector space.
static int factor_ct(int xd)
Factor_ct() as a function of dimension xd.
st2_e2 & operator=(const row_dofs_type &xrdt)
Assignment to an instance of the associated row dofs type.
int_type pod_index_type
The plain old data index type.
virtual void put_components(const value_type &xx_comp, const value_type &xy_comp, const value_type &yy_comp)
Set values of the components to the given arguments.
A symmetric tensor of degree 2 over a Euclidean vector space of dimension 2 (persistent version)...
int dd() const
The dimension of the underlying ("domain") vector space.
static const std::string & static_class_name()
The name of this class.
A symmetric tensor of degree 2 over a Euclidean vector space of dimension 2 (volatile version)...
T components[8]
The dofs in the following order:
virtual ~st2_e2_lite()
Destructor.
An abstract client handle for a member of a poset.
std::string path() const
The full path as a string.
vd_dof_type dof_type
The type of the degrees of freedom. Note that although dof_type == value_type in this implementation...
virtual const stp_lite & stp_prototype(int xp) const
Prototype for symmetric tensors of degree xp over this vector space.
A symmetric tensor of degree p over an abstract vector space (volatile version).
An abstract symmetric tensor space of degree p.
Namespace for the fiber_bundles component of the sheaf system.
value_type component(int xrow, int xcolumn) const
The component with row index xrow and column index xcolumn.
SHEAF_DLL_SPEC void sin(const sec_at0 &x0, sec_at0 &xresult, bool xauto_access)
Compute sin of x0 (sin(x0)) (pre-allocated version).
virtual const std::string & class_name() const
The name of this class.
static host_type & standard_host(namespace_type &xns, const std::string &xsuffix, bool xauto_access)
The host with path standard_host_path<st2_e2>(xsuffix). Returns the host if it already exists...
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.
double vd_value_type
The type of component in the fiber; the scalar type in the fiber vector space.
st2_e2_lite & operator=(const st2_e2_lite &xother)
Assignment operator.
virtual const tp_lite & tp_prototype(int xp) const
Prototype for general tensors of degree xp over this vector space.
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.
bool is_ancestor_of(const any *xother) const
True if other conforms to current.
bool invariant() const
Class invariant.
SHEAF_DLL_SPEC bool isunordered_or_equals(float x1, float x2)
True if isunordered(x1, x2) or x1 == x2.