00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef SELEMENT_H
00014 #define SELEMENT_H
00015
00016 #if defined(HAVE_CONFIG_H)
00017
00018 #include <config.h>
00019 #elif defined(BLD_PROCEDURE)
00020
00021 #include <portinfo.h>
00022 #endif
00023
00024 #include <assert.h>
00025 #include <stdlib.h>
00026
00027 #include "svertex.h"
00028
00029 #ifdef __cplusplus
00030 namespace shells {
00031 #define DECLARE_EXTERN extern "C"
00032 #else
00033 #define DECLARE_EXTERN extern
00034 #endif
00035
00036 typedef struct SElementS {
00037 struct SElementS *adt[3];
00038 SVertex *vtx[3];
00039
00040 struct InterpolationS *interpol;
00041
00042 struct InternalStorageS *matStorage;
00043 } SElement;
00044
00045
00046 DECLARE_EXTERN SElement *createSElement();
00047 DECLARE_EXTERN SElement *createSElement2(SVertex *vtx0,
00048 SVertex *vtx1,
00049 SVertex *vtx2);
00050 DECLARE_EXTERN SElement *duplicateSElement(SElement *);
00051 DECLARE_EXTERN void deleteSElement(SElement *);
00052
00053 DECLARE_EXTERN int selementsOneRingSVertex(SElement *element,
00054 int inode,
00055 SElement* oneRing[MAXVAL]);
00056
00057 DECLARE_EXTERN int sverticesOneRingSVertex(SElement *element,
00058 int inode,
00059 SVertex* oneRing[MAXVAL]);
00060
00061 DECLARE_EXTERN void selementPtrToHistory(SElement *element,
00062 double **data,
00063 int *size);
00064
00065 DECLARE_EXTERN void selementResetHistory(SElement *element,
00066 double *data);
00067
00068 static int localSEdgeNumber(SElement *t, SVertex *v1, SVertex *v2)
00069 {
00070 int result;
00071 assert( (v1 != NULL) && (v2 != NULL) );
00072 assert( v1 != v2 );
00073
00074 result = ( v1 == t->vtx[0] ? ( v2 == t->vtx[1] ? 0 : 2 )
00075 : ( v1 == t->vtx[1] ? ( v2 == t->vtx[2] ? 1 : 0 ) :
00076 ( v2 == t->vtx[0] ? 2 : 1 ) ) );
00077 return result;
00078 }
00079
00080 static int localSEdgeNumber2(SElement *t, SElement *neighbor)
00081 {
00082 int j;
00083 assert(t != NULL);
00084 assert(neighbor != NULL);
00085 j = (t->adt[0] == neighbor) ? 0 : ((t->adt[1] == neighbor) ? 1 :
00086 ((t->adt[2] == neighbor) ? 2 : 3));
00087 assert(j!=3);
00088
00089 return j;
00090 }
00091
00092 static int localSVtxNumber(SVertex * vtx, SElement * t)
00093 {
00094 int j;
00095 assert(t != NULL);
00096 assert(vtx != NULL);
00097 j = (t->vtx[0] == vtx) ? 0 : ((t->vtx[1] == vtx) ? 1 :
00098 ((t->vtx[2] == vtx) ? 2 : 3));
00099
00100 return j;
00101 }
00102
00103 static void edgeTangentInParamSpace(double t[3], unsigned iedg)
00104 {
00105 switch (iedg) {
00106 case 0:
00107 t[0] = 1.0;
00108 t[1] = 0.0;
00109 t[2] = 0.0;
00110 break;
00111 case 1:
00112 t[0] =-1.0;
00113 t[1] = 1.0;
00114 t[2] = 0.0;
00115 break;
00116 case 2:
00117 t[0] = 0.0;
00118 t[1] =-1.0;
00119 t[2] = 0.0;
00120 break;
00121 default:
00122 assert(0);
00123 break;
00124 }
00125 }
00126
00127 static void resetSElementSVertices(SElement *element, SVertex *vtx0,
00128 SVertex *vtx1, SVertex *vtx2)
00129 {
00130 element->vtx[0] = vtx0;
00131 element->vtx[1] = vtx1;
00132 element->vtx[2] = vtx2;
00133 }
00134
00135 static void resetSElementNeighbors(SElement *element, SElement *adt0,
00136 SElement *adt1, SElement *adt2)
00137 {
00138 element->adt[0] = adt0;
00139 element->adt[1] = adt1;
00140 element->adt[2] = adt2;
00141 }
00142
00143
00144 #ifdef __cplusplus
00145 }
00146 #endif
00147 #undef DECLARE_EXTERN
00148
00149 #endif
00150