/[escript]/trunk/finley/src/ShapeFunctions.cpp
ViewVC logotype

Diff of /trunk/finley/src/ShapeFunctions.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4491 by jfenwick, Tue Apr 2 04:46:45 2013 UTC revision 4492 by caltinay, Tue Jul 2 01:44:11 2013 UTC
# Line 23  Line 23 
23  #include "ShapeFunctions.h"  #include "ShapeFunctions.h"
24  #include "esysUtils/mem.h"  #include "esysUtils/mem.h"
25  #include "esysUtils/index.h"  #include "esysUtils/index.h"
26  #include <string.h>  #include <cstring>
27    
28    namespace finley {
29    
30    ShapeFunctionInfo ShapeFunction_InfoList[]={
31  Finley_ShapeFunctionInfo Finley_ShapeFunction_InfoList[]={      {Point1Shape, "Point1", 0,  1, 1, 1,    Shape_Point1 } ,
32      {Point1Shape, "Point1", 0,  1, 1, 1,    Finley_Shape_Point1 } ,          {Line2Shape,  "Line2",  1,  2, 1, 2,    Shape_Line2  } ,
33          {Line2Shape,  "Line2",  1,  2, 1, 2,    Finley_Shape_Line2  } ,      {Line3Shape,  "Line3",  1,  3, 2, 2,    Shape_Line3  },
34      {Line3Shape,  "Line3",  1,  3, 2, 2,    Finley_Shape_Line3  },      {Line4Shape,  "Line4",  1,  4, 3, 2,    Shape_Line4  },
35      {Line4Shape,  "Line4",  1,  4, 3, 2,    Finley_Shape_Line4  },      {Tri3Shape,   "Tri3",   2,  3, 1, 3,    Shape_Tri3   },
36      {Tri3Shape,   "Tri3",   2,  3, 1, 3,    Finley_Shape_Tri3   },      {Tri6Shape,   "Tri6",   2,  6, 2, 3,    Shape_Tri6   },
37      {Tri6Shape,   "Tri6",   2,  6, 2, 3,    Finley_Shape_Tri6   },      {Tri9Shape,   "Tri9",   2,  9, 3, 3,    Shape_Tri9   },
38      {Tri9Shape,   "Tri9",   2,  9, 3, 3,    Finley_Shape_Tri9   },      {Tri10Shape,  "Tri10",  2, 10, 3, 3,    Shape_Tri10, },
39      {Tri10Shape,  "Tri10",  2, 10, 3, 3,    Finley_Shape_Tri10, },      {Rec4Shape,   "Rec4",   2,  4, 1, 4,    Shape_Rec4,  },
40      {Rec4Shape,   "Rec4",   2,  4, 1, 4,    Finley_Shape_Rec4,  },      {Rec8Shape,   "Rec8",   2,  8, 2, 4,    Shape_Rec8,  },
41      {Rec8Shape,   "Rec8",   2,  8, 2, 4,    Finley_Shape_Rec8,  },      {Rec9Shape,   "Rec9",   2,  9, 2, 4,    Shape_Rec9,  },
42      {Rec9Shape,   "Rec9",   2,  9, 2, 4,    Finley_Shape_Rec9,  },      {Rec12Shape,  "Rec12",  2, 12, 3, 4,    Shape_Rec12, },
43      {Rec12Shape,  "Rec12",  2, 12, 3, 4,    Finley_Shape_Rec12, },      {Rec16Shape,  "Rec16",  2, 16, 3, 4,    Shape_Rec16, },
44      {Rec16Shape,  "Rec16",  2, 16, 3, 4,    Finley_Shape_Rec16, },      {Tet4Shape,   "Tet4",   3,  4, 1, 4,    Shape_Tet4,  },
45      {Tet4Shape,   "Tet4",   3,  4, 1, 4,    Finley_Shape_Tet4,  },      {Tet10Shape,  "Tet10",  3, 10, 2, 4,    Shape_Tet10, },
46      {Tet10Shape,  "Tet10",  3, 10, 2, 4,    Finley_Shape_Tet10, },      {Tet16Shape,  "Tet16",  3, 16, 3, 4,    Shape_Tet16, },
47      {Tet16Shape,  "Tet16",  3, 16, 3, 4,    Finley_Shape_Tet16, },      {Hex8Shape,   "Hex8",   3,  8, 1, 8,    Shape_Hex8,  },
48      {Hex8Shape,   "Hex8",   3,  8, 1, 8,    Finley_Shape_Hex8,  },      {Hex20Shape,  "Hex20",  3, 20, 2, 8,    Shape_Hex20, },
49      {Hex20Shape,  "Hex20",  3, 20, 2, 8,    Finley_Shape_Hex20, },      {Hex27Shape,  "Hex27",  3, 27, 2, 8,    Shape_Hex27, },
50      {Hex27Shape,  "Hex27",  3, 27, 2, 8,    Finley_Shape_Hex27, },      {Hex32Shape,  "Hex32",  3, 32, 3, 8,    Shape_Hex32, },
51      {Hex32Shape,  "Hex32",  3, 32, 3, 8,    Finley_Shape_Hex32, },      {NoShape, "NoType", 0,  1, 1, 1,    Shape_Point1  }
     {NoShape, "NoType", 0,  1, 1, 1,    Finley_Shape_Point1  }  
52  };  };
53    
54    
# Line 61  Finley_ShapeFunctionInfo Finley_ShapeFun Line 61  Finley_ShapeFunctionInfo Finley_ShapeFun
61      nodes. Otherwise it is assumed that a quadrature scheme is given on this array and a copy is created within the structure.      nodes. Otherwise it is assumed that a quadrature scheme is given on this array and a copy is created within the structure.
62    
63  */  */
64  Finley_ShapeFunction* Finley_ShapeFunction_alloc(Finley_ShapeFunctionTypeId id,int numQuadDim, int numQuadNodes, double *QuadNodes, double *QuadWeights) {  ShapeFunction* ShapeFunction_alloc(ShapeFunctionTypeId id,int numQuadDim, int numQuadNodes, double *QuadNodes, double *QuadWeights) {
65      Finley_ShapeFunction *out=NULL;      ShapeFunction *out=NULL;
66      int numDim, numShapes, i, q;      int numDim, numShapes, i, q;
67        
68      numDim=Finley_ShapeFunction_InfoList[id].numDim;      numDim=ShapeFunction_InfoList[id].numDim;
69          numShapes=Finley_ShapeFunction_InfoList[id].numShapes;          numShapes=ShapeFunction_InfoList[id].numShapes;
70        
71      if (numQuadDim>numDim) {          if (numQuadDim>numDim) {    
72          Finley_setError(VALUE_ERROR,"Finley_ShapeFunction_alloc: spatial dimension of quadrature scheme is bigger then spatial dimension of shape function.");          Finley_setError(VALUE_ERROR,"ShapeFunction_alloc: spatial dimension of quadrature scheme is bigger then spatial dimension of shape function.");
73          return NULL;          return NULL;
74      }      }
75            
76      /*  allocate the Finley_ShapeFunction to be returned: */      /*  allocate the ShapeFunction to be returned: */
77        
78      out=new Finley_ShapeFunction;      out=new ShapeFunction;
79      if (Finley_checkPtr(out)) return NULL;      if (Finley_checkPtr(out)) return NULL;
80    
81        
82      out->Type=Finley_ShapeFunction_getInfo(id);      out->Type=ShapeFunction_getInfo(id);
83      out->numQuadNodes=numQuadNodes;      out->numQuadNodes=numQuadNodes;
84      out->QuadNodes=NULL;      out->QuadNodes=NULL;
85      out->QuadWeights=NULL;      out->QuadWeights=NULL;
# Line 94  Finley_ShapeFunction* Finley_ShapeFuncti Line 94  Finley_ShapeFunction* Finley_ShapeFuncti
94      out->S=new double[numShapes*numQuadNodes];      out->S=new double[numShapes*numQuadNodes];
95      out->dSdv=new double[numShapes*numDim*numQuadNodes];      out->dSdv=new double[numShapes*numDim*numQuadNodes];
96      if ( Finley_checkPtr(out->QuadNodes) || Finley_checkPtr(out->QuadWeights) || Finley_checkPtr(out->S) || Finley_checkPtr(out->dSdv) ) {      if ( Finley_checkPtr(out->QuadNodes) || Finley_checkPtr(out->QuadWeights) || Finley_checkPtr(out->S) || Finley_checkPtr(out->dSdv) ) {
97           Finley_ShapeFunction_dealloc(out);           ShapeFunction_dealloc(out);
98           return NULL;           return NULL;
99      }      }
100        
# Line 111  Finley_ShapeFunction* Finley_ShapeFuncti Line 111  Finley_ShapeFunction* Finley_ShapeFuncti
111      out->Type->getValues(numQuadNodes,out->QuadNodes,out->S,out->dSdv);      out->Type->getValues(numQuadNodes,out->QuadNodes,out->S,out->dSdv);
112    
113      if (! Finley_noError()) {      if (! Finley_noError()) {
114           Finley_ShapeFunction_dealloc(out);           ShapeFunction_dealloc(out);
115           return NULL;           return NULL;
116      }      }
117        
# Line 120  Finley_ShapeFunction* Finley_ShapeFuncti Line 120  Finley_ShapeFunction* Finley_ShapeFuncti
120      return out;      return out;
121  }  }
122    
123  Finley_ShapeFunction* Finley_ShapeFunction_reference(Finley_ShapeFunction* in) {  ShapeFunction* ShapeFunction_reference(ShapeFunction* in) {
124       if (in!=NULL) ++(in->reference_counter);       if (in!=NULL) ++(in->reference_counter);
125       return in;       return in;
126  }  }
127  /************************************************************************************/  /************************************************************************************/
128    
129  void Finley_ShapeFunction_dealloc(Finley_ShapeFunction* in) {  void ShapeFunction_dealloc(ShapeFunction* in) {
130    if (in!=NULL) {    if (in!=NULL) {
131        in->reference_counter--;        in->reference_counter--;
132        if (in->reference_counter<1) {        if (in->reference_counter<1) {
# Line 141  void Finley_ShapeFunction_dealloc(Finley Line 141  void Finley_ShapeFunction_dealloc(Finley
141    
142  /************************************************************************************/  /************************************************************************************/
143    
144  Finley_ShapeFunctionTypeId Finley_ShapeFunction_getTypeId(char* element_type)  ShapeFunctionTypeId ShapeFunction_getTypeId(char* element_type)
145  {  {
146      int ptr=0;      int ptr=0;
147      Finley_ShapeFunctionTypeId out=NoShape;      ShapeFunctionTypeId out=NoShape;
148      while (Finley_ShapeFunction_InfoList[ptr].TypeId!=NoShape && out==NoShape) {      while (ShapeFunction_InfoList[ptr].TypeId!=NoShape && out==NoShape) {
149         if (strcmp(element_type,Finley_ShapeFunction_InfoList[ptr].Name)==0) out=Finley_ShapeFunction_InfoList[ptr].TypeId;         if (strcmp(element_type,ShapeFunction_InfoList[ptr].Name)==0) out=ShapeFunction_InfoList[ptr].TypeId;
150         ptr++;         ptr++;
151      }      }
152      return out;      return out;
153  }  }
154    
155  Finley_ShapeFunctionInfo* Finley_ShapeFunction_getInfo(Finley_ShapeFunctionTypeId id)  ShapeFunctionInfo* ShapeFunction_getInfo(ShapeFunctionTypeId id)
156  {  {
157      int ptr=0;      int ptr=0;
158      Finley_ShapeFunctionInfo* out=NULL;      ShapeFunctionInfo* out=NULL;
159      while (Finley_ShapeFunction_InfoList[ptr].TypeId!=NoShape && out==NULL) {      while (ShapeFunction_InfoList[ptr].TypeId!=NoShape && out==NULL) {
160         if (Finley_ShapeFunction_InfoList[ptr].TypeId==id) out=&(Finley_ShapeFunction_InfoList[ptr]);         if (ShapeFunction_InfoList[ptr].TypeId==id) out=&(ShapeFunction_InfoList[ptr]);
161         ptr++;         ptr++;
162      }      }
163      if (out==NULL) {      if (out==NULL) {
164          Finley_setError(VALUE_ERROR,"Finley_ShapeFunctionInfo_getInfo: cannot find requested shape function");          Finley_setError(VALUE_ERROR,"ShapeFunctionInfo_getInfo: cannot find requested shape function");
165      }      }
166      return out;      return out;
167  }  }
# Line 174  Finley_ShapeFunctionInfo* Finley_ShapeFu Line 174  Finley_ShapeFunctionInfo* Finley_ShapeFu
174    
175  /************************************************************************************/  /************************************************************************************/
176    
177  void Finley_Shape_Point1(int NumV,double* v,double* s,double* dsdv) {  void Shape_Point1(int NumV,double* v,double* s,double* dsdv) {
178    #define NUMSHAPES 1    #define NUMSHAPES 1
179    #define DIM 0    #define DIM 0
180    int i;    int i;
# Line 188  void Finley_Shape_Point1(int NumV,double Line 188  void Finley_Shape_Point1(int NumV,double
188    
189  /************************************************************************************/  /************************************************************************************/
190    
191  void Finley_Shape_Line2(int NumV,double* v,double* s,double* dsdv) {  void Shape_Line2(int NumV,double* v,double* s,double* dsdv) {
192    #define NUMSHAPES 2    #define NUMSHAPES 2
193    #define DIM 1    #define DIM 1
194    register double x;    register double x;
# Line 207  void Finley_Shape_Line2(int NumV,double* Line 207  void Finley_Shape_Line2(int NumV,double*
207    
208  /************************************************************************************/  /************************************************************************************/
209    
210  void Finley_Shape_Line3(int NumV,double* v,double* s,double* dsdv) {  void Shape_Line3(int NumV,double* v,double* s,double* dsdv) {
211    #define NUMSHAPES 3    #define NUMSHAPES 3
212    #define DIM 1    #define DIM 1
213    register double x;    register double x;
# Line 228  void Finley_Shape_Line3(int NumV,double* Line 228  void Finley_Shape_Line3(int NumV,double*
228    
229  /************************************************************************************/  /************************************************************************************/
230    
231  void Finley_Shape_Line4(int NumV,double* v,double* s,double* dsdv) {  void Shape_Line4(int NumV,double* v,double* s,double* dsdv) {
232    #define NUMSHAPES 4    #define NUMSHAPES 4
233    #define DIM 1    #define DIM 1
234    register double x;    register double x;
# Line 251  void Finley_Shape_Line4(int NumV,double* Line 251  void Finley_Shape_Line4(int NumV,double*
251    
252  /************************************************************************************/  /************************************************************************************/
253    
254  void Finley_Shape_Tri3(int NumV,double* v,double* s,double* dsdv) {  void Shape_Tri3(int NumV,double* v,double* s,double* dsdv) {
255    #define NUMSHAPES 3    #define NUMSHAPES 3
256    #define DIM 2    #define DIM 2
257    register double x,y;    register double x,y;
# Line 276  void Finley_Shape_Tri3(int NumV,double* Line 276  void Finley_Shape_Tri3(int NumV,double*
276    
277  /************************************************************************************/  /************************************************************************************/
278    
279  void Finley_Shape_Tri6(int NumV,double* v,double* s,double* dsdv) {  void Shape_Tri6(int NumV,double* v,double* s,double* dsdv) {
280    #define NUMSHAPES 6    #define NUMSHAPES 6
281    #define DIM 2    #define DIM 2
282    register double x,y;    register double x,y;
# Line 310  void Finley_Shape_Tri6(int NumV,double* Line 310  void Finley_Shape_Tri6(int NumV,double*
310    
311  /************************************************************************************/  /************************************************************************************/
312    
313  void Finley_Shape_Tri9(int NumV,double* v,double* s,double* dsdv) {  void Shape_Tri9(int NumV,double* v,double* s,double* dsdv) {
314    #define NUMSHAPES 9    #define NUMSHAPES 9
315    #define DIM 2    #define DIM 2
316    register double x,y;    register double x,y;
# Line 353  void Finley_Shape_Tri9(int NumV,double* Line 353  void Finley_Shape_Tri9(int NumV,double*
353    
354  /************************************************************************************/  /************************************************************************************/
355    
356  void Finley_Shape_Tri10(int NumV,double* v,double* s,double* dsdv) {  void Shape_Tri10(int NumV,double* v,double* s,double* dsdv) {
357    #define NUMSHAPES 10    #define NUMSHAPES 10
358    #define DIM 2    #define DIM 2
359    register double x,y;    register double x,y;
# Line 399  void Finley_Shape_Tri10(int NumV,double* Line 399  void Finley_Shape_Tri10(int NumV,double*
399    
400  /************************************************************************************/  /************************************************************************************/
401    
402  void Finley_Shape_Rec4(int NumV,double* v,double* s,double* dsdv) {  void Shape_Rec4(int NumV,double* v,double* s,double* dsdv) {
403    #define NUMSHAPES 4    #define NUMSHAPES 4
404    #define DIM 2    #define DIM 2
405    register double x,y;    register double x,y;
# Line 427  void Finley_Shape_Rec4(int NumV,double* Line 427  void Finley_Shape_Rec4(int NumV,double*
427    
428  /************************************************************************************/  /************************************************************************************/
429    
430  void Finley_Shape_Rec8(int NumV,double* v,double* s,double* dsdv) {  void Shape_Rec8(int NumV,double* v,double* s,double* dsdv) {
431    #define NUMSHAPES 8    #define NUMSHAPES 8
432    #define DIM 2    #define DIM 2
433    register double x,y;    register double x,y;
# Line 467  void Finley_Shape_Rec8(int NumV,double* Line 467  void Finley_Shape_Rec8(int NumV,double*
467    
468  /************************************************************************************/  /************************************************************************************/
469    
470  void Finley_Shape_Rec9(int NumV,double* v,double* s,double* dsdv) {  void Shape_Rec9(int NumV,double* v,double* s,double* dsdv) {
471    #define NUMSHAPES 9    #define NUMSHAPES 9
472    #define DIM 2    #define DIM 2
473    register double x,y;    register double x,y;
# Line 510  void Finley_Shape_Rec9(int NumV,double* Line 510  void Finley_Shape_Rec9(int NumV,double*
510    
511  /************************************************************************************/  /************************************************************************************/
512    
513  void Finley_Shape_Rec12(int NumV,double* v,double* s,double* dsdv) {  void Shape_Rec12(int NumV,double* v,double* s,double* dsdv) {
514    #define NUMSHAPES 12    #define NUMSHAPES 12
515    #define DIM 2    #define DIM 2
516    register double x,y;    register double x,y;
# Line 562  void Finley_Shape_Rec12(int NumV,double* Line 562  void Finley_Shape_Rec12(int NumV,double*
562    
563  /************************************************************************************/  /************************************************************************************/
564    
565  void Finley_Shape_Rec16(int NumV,double* v,double* s,double* dsdv) {  void Shape_Rec16(int NumV,double* v,double* s,double* dsdv) {
566    #define NUMSHAPES 16    #define NUMSHAPES 16
567    #define DIM 2    #define DIM 2
568    register double x,y;    register double x,y;
# Line 626  void Finley_Shape_Rec16(int NumV,double* Line 626  void Finley_Shape_Rec16(int NumV,double*
626    
627  /************************************************************************************/  /************************************************************************************/
628    
629  void Finley_Shape_Tet4(int NumV,double* v,double* s,double* dsdv) {  void Shape_Tet4(int NumV,double* v,double* s,double* dsdv) {
630    #define NUMSHAPES 4    #define NUMSHAPES 4
631    #define DIM 3    #define DIM 3
632    register double x,y,z;    register double x,y,z;
# Line 659  void Finley_Shape_Tet4(int NumV,double* Line 659  void Finley_Shape_Tet4(int NumV,double*
659    
660  /************************************************************************************/  /************************************************************************************/
661    
662  void Finley_Shape_Tet10(int NumV,double* v,double* s,double* dsdv) {  void Shape_Tet10(int NumV,double* v,double* s,double* dsdv) {
663    #define NUMSHAPES 10    #define NUMSHAPES 10
664    #define DIM 3    #define DIM 3
665    register double x,y,z;    register double x,y,z;
# Line 727  void Finley_Shape_Tet10(int NumV,double* Line 727  void Finley_Shape_Tet10(int NumV,double*
727    
728  /************************************************************************************/  /************************************************************************************/
729    
730  void Finley_Shape_Tet16(int NumV,double* v,double* s,double* dsdv) {  void Shape_Tet16(int NumV,double* v,double* s,double* dsdv) {
731    #define NUMSHAPES 16    #define NUMSHAPES 16
732    #define DIM 3    #define DIM 3
733    register double x,y,z;    register double x,y,z;
# Line 808  void Finley_Shape_Tet16(int NumV,double* Line 808  void Finley_Shape_Tet16(int NumV,double*
808    
809  /************************************************************************************/  /************************************************************************************/
810    
811  void Finley_Shape_Hex8(int NumV,double* v,double* s,double* dsdv) {  void Shape_Hex8(int NumV,double* v,double* s,double* dsdv) {
812    #define NUMSHAPES 8    #define NUMSHAPES 8
813    #define DIM 3    #define DIM 3
814    register double x,y,z;    register double x,y,z;
# Line 857  void Finley_Shape_Hex8(int NumV,double* Line 857  void Finley_Shape_Hex8(int NumV,double*
857    
858  /************************************************************************************/  /************************************************************************************/
859    
860  void Finley_Shape_Hex20(int NumV,double* v,double* s,double* dsdv) {  void Shape_Hex20(int NumV,double* v,double* s,double* dsdv) {
861    #define NUMSHAPES 20    #define NUMSHAPES 20
862    #define DIM 3    #define DIM 3
863    register double x,y,z;    register double x,y,z;
# Line 954  void Finley_Shape_Hex20(int NumV,double* Line 954  void Finley_Shape_Hex20(int NumV,double*
954    
955  /************************************************************************************/  /************************************************************************************/
956    
957  void Finley_Shape_Hex27(int NumV,double* v,double* s,double* dsdv) {  void Shape_Hex27(int NumV,double* v,double* s,double* dsdv) {
958    #define NUMSHAPES 27    #define NUMSHAPES 27
959    #define DIM 3    #define DIM 3
960    register double x,y,z;    register double x,y,z;
# Line 1079  void Finley_Shape_Hex27(int NumV,double* Line 1079  void Finley_Shape_Hex27(int NumV,double*
1079    
1080  /************************************************************************************/  /************************************************************************************/
1081    
1082  void Finley_Shape_Hex32(int NumV,double* v,double* s,double* dsdv) {  void Shape_Hex32(int NumV,double* v,double* s,double* dsdv) {
1083    #define NUMSHAPES 32    #define NUMSHAPES 32
1084    #define DIM 3    #define DIM 3
1085    register double x,y,z;    register double x,y,z;
# Line 1225  void Finley_Shape_Hex32(int NumV,double* Line 1225  void Finley_Shape_Hex32(int NumV,double*
1225  #undef S  #undef S
1226  #undef DSDV  #undef DSDV
1227    
1228    } // namespace finley
1229    

Legend:
Removed from v.4491  
changed lines
  Added in v.4492

  ViewVC Help
Powered by ViewVC 1.1.26