====== XElement ====== **//Inherited from//** [[class::domain::orderitem|OrderItem]], **//Inherited by//** NULL **//Friend class//** XManager,GeometryManager,ElementManager, **//Description//** XElement是所有网格单元的基类,它封装了单元数据及方法,它是模型的内部数据对象,属且仅属于一个几何对象。单元是CAE处理中的重要数据结构,它抽象了真实世界中保持结构(流体)物理特性的最小组织。在XT中,几何模型和网格模型中的实体都由若干单元组成。单元由一系列有顺序的节点包围形成,根据单元类型,根据节点可计算面积、体积、法向等几何属性。XT中所有单元类型都从此基类继承。 XT使用工厂模式管理单元的创建、销毁和访问,但是与一般的工厂模式不同,新加入的单元并不使用虚继承,这是为了保证在大规模模型场景下避免由于虚函数带来的性能损失和内存空间的额外消耗。XElment提供了统一的接口,通过函数表调用单元子类型的具体调用。 XT预置了适用于结构分析的13种单元以及适用于有限体积法的3种单元,它们均从XElement继承,列举如下: | 单元类型 | 类名 | 节点数 | 说明 | | 点单元 | Point1Element | 1 | 一般用于几何顶点 | | 1阶线单元 | Line2Element | 2 | | | 2阶线单元 | Point1Element | 3 | | | 1阶三角形面单元 | Tri3Element | 3 | | | 2阶三角形面单元 | Tri6Element | 6 | | | 1阶四边形面单元 | Quad4Element | 4 | | | 2阶四边形面单元 | Quad8Element | 8 | | | 1阶四面体单元 | Tet4Element | 4 | | | 2阶四面体单元 | Tet10Element | 10 | | | 1阶三棱柱单元 | Prism6Element | 6 | | | 2阶三棱柱单元 | Prism15Element | 15 | | | 1阶金字塔单元 | Pyramid5Element | 5 | | | 2阶金字塔单元 | Pyramid13Element | 13 | | | 1阶六面体单元 | Hex8Element | 8 | | | 2阶六面体单元 | Hex20Element | 20 | | | 多折线单元 | PolylineElement | 取决于实际情况 | | | 多边形面单元 | PolygonElement | 取决于实际情况 | | | 多面体单元 | CellElement | 取决于实际情况 | 不能直接访问节点,通过访问它包含的多边形面单元或者多折线单元访问节点 | 单元类图如下: {{ pics::class::Element.png }} **//Members//** * void * [[xelement#m_pextdata|m_pExtData]] * ulong [[xelement#m_ulflag|m_ulFlag]] * int [[xelement#m_ulrid|m_ulRId]] * ElemNodeInfo * [[xelement#m_parnodes|m_parNodes]] **//Public interface//** * [[xelement#xelement1|XElement]](ulong id, TypeID t) * int [[xelement#getrid|getRId]]() const * void [[xelement#setrid|setRId]](int id) * void [[xelement#setflag|setFlag]](int i) * int [[xelement#getflag|getFlag]]() const * void [[xelement#setextdata|setExtData]](void * pData) * void * [[xelement#getextdata|getExtData]]() const * void [[xelement#setgeometry|setGeometry]](const XGeometry * pData) * const XGeometry * [[xelement#getgeometry|getGeometry]]() const * void [[xelement#setnodes|setNodes]](const NodePtr*ppNodes) * void [[xelement#updatenodespointer|updateNodesPointer]]() * NodePtr [[xelement#getnode|getNode]](int index) const * ElemNodeInfo * [[xelement#getnodeinfo|getNodeInfo]](int index) * const ElemNodeInfo * [[xelement#getnodeinfo|getNodeInfo]](int index) const * void [[xelement#setnode|setNode]](int index,NodePtr n) * int [[xelement#getnodecount|getNodeCount]]() const * static int [[xelement#getnodecount|getNodeCount]](TypeID et) * static int [[xelement#getvertexcount|getVertexCount]](TypeID et) * real [[xelement#getlength|getLength]]() const * real [[xelement#getarea|getArea]]() const * real [[xelement#getvolume|getVolume]]() const * void [[xelement#getboundbox|getBoundbox]](XBoundBox * box) const * void [[xelement#flip|flip]]() * void [[xelement#calccenter|calcCenter]](float * center) const * void [[xelement#calcnormal|calcNormal]](float * normal) const * void [[xelement#calccenter|calcCenter]](double * center) const * void [[xelement#calcnormal|calcNormal]](double * normal) const * real [[xelement#calcquality|calcQuality]](CriterionType c) const * int [[xelement#buildsection|buildSection]](const XPlane * plane,SegmentPoint * sp, int * sectionFacetID = NULL) const * int [[xelement#buildgldata|buildGLData]](ArrayGLObject * gl_tri,ArrayGLObject * gl_seg) const * int [[xelement#buildrendertridata|buildRenderTriData]](float * triv, float * trin) const * int [[xelement#buildrenderlinedata|buildRenderLineData]](float * segv) const * void [[xelement#serialize|serialize]](XBinaryIO * io,XModel * mdl,bool bSave) * void [[xelement#mapgausstonodal|mapGaussToNodal]](const float * g_value,float * n_value,int numIntPoint) const * void [[xelement#buildlocalcoordsystem|buildLocalCoordSystem]](XCoordSystem * cs) const * void [[xelement#getjacobimatrix|getJacobiMatrix]](Vector3d * jacobi) const * void [[xelement#convertlocaltensortoglobal|convertLocalTensorToGlobal]](const double **localT, double ** globalT, int planeType = -1) const * Point1Element * [[xelement#topoint1|toPoint1]]() const * Line2Element * [[xelement#tobar2|toBar2]]() const * Line3Element * [[xelement#tobar3|toBar3]]() const * Tri3Element * [[xelement#totri3|toTri3]]() const * Quad4Element * [[xelement#toquad4|toQuad4]]() const * Tet4Element * [[xelement#totet4|toTet4]]() const * Hex8Element * [[xelement#tohex8|toHex8]]() const * Pyramid5Element * [[xelement#topyramid5|toPyramid5]]() const **//Protected interface//** * int [[xelement#calcsegmentpoints|calcSegmentPoints]](SegmentPoint * sp, int eCnt, const XPlane * fp, const int eni[][2], int usedEdgeIndex[], int usedEdgeVertex[]) const ---- {{anchor:m_pextdata}} **void * m_pExtData** 扩展数据地址 {{anchor:m_ulflag}} **ulong m_ulFlag** 辅助标志 {{anchor:m_ulrid}} **int m_ulRId** 参考ID,一般用于后处理结果排序。 {{anchor:m_parnodes}} **ElemNodeInfo * m_parNodes** 节点数组首地址 ---- {{anchor:xelement1}} **XElement(ulong id, TypeID t)** *function: 构造函数 *parameters: - [i]ulong id: 单元ID - [i] TypeID t: 单元类型 *return value: 无 {{anchor:getrid}} **int getRId() const** *function: 获取参考ID *parameters: NULL *return value: 参考ID {{anchor:setrid}} **void setRId(int id)** *function: 设置参考ID *parameters: - [i]int id: 参考ID *return value: 无 {{anchor:setflag}} **void setFlag(int i)** *function: 设置辅助标志 *parameters: - [i]int i: 标志值 *return value: 无 {{anchor:getflag}} **int getFlag() const** *function: 获取辅助标志 *parameters: NULL *return value: 辅助标志值 {{anchor:setextdata}} **void setExtData(void * pData)** *function: 设置扩展数据地址 *parameters: - [i]void * pData: 扩展数据地址 *return value: 无 {{anchor:getextdata}} **void * getExtData() const** *function: 获取扩展数据地址 *parameters: NULL *return value: 扩展数据地址 {{anchor:setgeometry}} **void setGeometry(const XGeometry * pData)** *function: 设置所属几何对象 *parameters: - [i]const XGeometry * pData: 所属几何对象 *return value: 无 {{anchor:getgeometry}} **const XGeometry * getGeometry() const** *function: 设置所属几何对象 *parameters: NULL *return value: 所属几何对象 {{anchor:setnodes}} **void setNodes(const NodePtr*ppNodes)** *function: 设置单元的节点 - [i]const NodePtr*ppNodes: 节点指针数组 *return value: 无 {{anchor:updatenodespointer}} **void updateNodesPointer()** *function: 更新节点数组地址,在FVM场景中使用 *parameters: NULL *return value: 无 {{anchor:getnode}} **NodePtr getNode(int index) const** *function: 访问第index个节点 *parameters: - [i]int index: 节点序号 *return value: 第index个节点对象 {{anchor:setnode}} **void setNode(int index,NodePtr n)** *function: 设置第index个节点 *parameters: - [i]int index: 节点序号 - [i]NodePtr n: 第index个节点对象 *return value: 无 {{anchor:getnodecount}} **int getNodeCount() const** *function: 获取该单元的节点数 *parameters: NULL *return value: 节点数 {{anchor:getnodecount}} **static int getNodeCount(TypeID et)** *function: 静态函数,获取该单元类型的节点数 *parameters: - [i]TypeID et: 单元类型 *return value: 节点数 {{anchor:getvertexcount}} **static int getVertexCount(TypeID et)** *function: 静态函数,获取该单元类型的角节点数(不含中节点) *parameters: - [i]TypeID et: 单元类型 *return value: 角节点数 {{anchor:getlength}} **real getLength() const** *function: 获取一维单元的长度值 *parameters: NULL *return value: 长度 {{anchor:getarea}} **real getArea() const** *function: 计算二维单元的面积 *parameters: NULL *return value: 面积 {{anchor:getvolume}} **real getVolume() const** *function: 计算三维单元的体积 *parameters: NULL *return value: 体 {{anchor:getboundbox}} **void getBoundbox(XBoundBox * box) const** *function: 获得单元的空间包围盒 *parameters: - [i]XBoundBox * box: 空间包围盒 *return value: 无 {{anchor:flip}} **void flip()** *function: 翻转二维单元的节点顺序 *parameters: NULL *return value: 无 {{anchor:calccenter}} **void calcCenter(float * center) const** *function: 计算单元的中心坐标 *parameters: - [o]float * center: 计算得到的中心坐标放入到其中 *return value: 无 {{anchor:calcnormal}} **void calcNormal(float * normal) const** *function: *function: 按照右手定则计算二维单元的法向 *parameters: - [o]float * normal: 得到的单元法向方向放入到其中 *return value: 无 {{anchor:calccenter}} **void calcCenter(double * center) const** *function: 计算单元的中心坐标 *parameters: - [i]double * center: 计算得到的中心坐标放入到其中 *return value: 无 {{anchor:calcnormal}} **void calcNormal(double * normal) const** *function: 按照右手定则计算二维单元的法向 *parameters: - [i]double * normal: 得到的单元法向方向放入到其中 *return value: 无 {{anchor:calcquality}} **real calcQuality(CriterionType c) const** *function: 计算单元的质量 *parameters: - [i]CriterionType c: 准则类型 *return value: 对应准则的质量值 {{anchor:buildsection}} **int buildSection(const XPlane * plane,SegmentPoint * sp, int * sectionFacetID = NULL) const** *function: 计算单元每一条单元边被平面所截的截面点数据 *parameters: - [i]const XPlane * plane: 截平面 - [i]SegmentPoint * sp: 截断点数组 - [i] int * sectionFacetID = NULL: *return value: 截断点个数 {{anchor:buildgldata}} **int buildGLData(ArrayGLObject * gl_tri,ArrayGLObject * gl_seg) const** *function: 为3D渲染生成数据 *parameters: - [i]ArrayGLObject * gl_tri: 三角片数据 - [i]ArrayGLObject * gl_seg: 线段数据 *return value: 用于渲染的顶点坐标个数(渲染顶点个数×3) {{anchor:serialize}} **void serialize(XBinaryIO * io,XModel * mdl,bool bSave)** *function: 序列化单元对象到二进制文件中 *parameters: - [i]XBinaryIO * io: 二进制文件句柄 - [i]XModel * mdl: 所属模型对象 - [i]bool bSave: 是否保存单元对象 *return value: 无 {{anchor:mapgausstonodal}} **void mapGaussToNodal(const float * g_value,float * n_value,int numIntPoint) const** *function: 将积分点的值外插到节点上 *parameters: - [i]const float * g_value: 积分点的值数组 - [i]float * n_value: 节点上的值数组 - [i]int numIntPoint: 积分点个数 *return value: 无 {{anchor:buildlocalcoordsystem}} **void buildLocalCoordSystem(XCoordSystem * cs) const** *function: 构建单元局部坐标系 *parameters: - [i]XCoordSystem * cs: 坐标系对象 *return value: 无 {{anchor:getjacobimatrix}} **void getJacobiMatrix(Vector3d * jacobi) const** *function: 计算单元雅可比矩阵 *parameters: - [i]Vector3d * jacobi: 雅可比矩阵向量 *return value: 无 {{anchor:convertlocaltensortoglobal}} **void convertLocalTensorToGlobal(const double **localT, double ** globalT, int planeType = -1) const** *function: 将局部张量转换为全局坐标系下的张量 *parameters: - [i]const double **localT: 单元局部坐标系下的张量 - [i] double ** globalT: 全局坐标系下的张量 - [i] int planeType = -1: 辅助参数,特殊场合下使用 *return value: 无 {{anchor:topoint1}} **Point1Element * toPoint1() const** *function: 常用函数,转换为点单元对象 *parameters: NULL *return value: 点单元对象 {{anchor:tobar2}} **Line2Element * toBar2() const** *function: 常用函数,转换为1阶线单元对象 *parameters: NULL *return value: 1阶线单元对象 {{anchor:tobar3}} **Line3Element * toBar3() const** *function: 常用函数,转换为2阶线单元对象 *parameters: NULL *return value: 2阶线单元对象 {{anchor:totri3}} **Tri3Element * toTri3() const** *function: 常用函数,转换为1阶三角形单元对象 *parameters: NULL *return value: 1阶三角形单元对象 {{anchor:toquad4}} **Quad4Element * toQuad4() const** *function: 常用函数,转换为1阶四边形单元对象 *parameters: NULL *return value: 1阶四边形单元对象 {{anchor:totet4}} **Tet4Element * toTet4() const** *function: 常用函数,转换为1阶四面体单元对象 *parameters: NULL *return value: 1阶四面体单元对象 {{anchor:tohex8}} **Hex8Element * toHex8() const** *function: 常用函数,转换为1阶六面体单元对象 *parameters: NULL *return value: 1阶六面体单元对象 ---- {{anchor:calcsegmentpoints}} **int calcSegmentPoints(SegmentPoint * sp, int eCnt, const XPlane * fp, const int eni[][2], int usedEdgeIndex[], int usedEdgeVertex[]) const** *function: 计算单元于平面相交的交点 *parameters: - [i]SegmentPoint * sp: 交点数组 - [i] int eCnt: 单元边的数目 - [i] const XPlane * fp: 平面对象 - [i] const int eni[][2]: 单元边节点数组 - [i] int usedEdgeIndex[]: 使用过的单元边标志数组 - [i] int usedEdgeVertex[]: 使用过的单元边节点标志数组 *return value: 无