/Users/jack/Code/basso_dev/inc/Tetra4Basis.h

Go to the documentation of this file.
00001 
00010 #ifndef _TETRA4_BASIS_BASSO_H_
00011 #define _TETRA4_BASIS_BASSO_H_
00012 
00013 #include "basso.h"
00014 #include "Basis.h"
00015 #include "quadrature_rules.h"
00016 
00017 namespace basso {
00018 
00031 class Tetra4Basis : public Basis {
00032 
00033 public:
00034         
00035         // constructors
00036         Tetra4Basis() { }
00037         
00038         // destructors
00039         virtual ~Tetra4Basis() { }
00040         
00041         // member functions
00042         virtual BasisType       Type() const { return kTETRA4; }
00043         virtual BasisShape Shape() const { return kTETRAHEDRA; }
00044         virtual int                             NumNodes() const { return 4; }     
00045         virtual int                             NumEdges() const { return 6; }      
00046         virtual int                             NumFaces() const { return 4; }      
00047         virtual int                             Dimension() const { return 3; }
00048         virtual int                             Order() const { return 1; }
00049         
00050         virtual void            ParentCoord( Array< Point > &xi )       const;
00051         virtual Point           Centroid() const { return Point( 0.1666666666666666667, 0.1666666666666666667, 0.1666666666666666667 ); }
00052         virtual void            NumNodesOnFaces( iArray &nn_face )      const;
00053         virtual void            NumNodesOnEdges( iArray &nn_edge )      const;
00054         virtual void            NodesOnFace ( int f, iArray &face_nodeids )             const;
00055         virtual void            NodesOnEdge ( int e, iArray &edge_nodeids )                     const;
00056         virtual void            FaceBasisType( Array<BasisType> &face_basis )   const;
00057         virtual void            EdgeBasisType( Array< BasisType > &edge_basis ) const;
00058         
00059         virtual void            Quadrature( int order, QuadratureRule &qrule ) const;
00060         
00061         virtual void            Na( const Point &p, nArray &shapefunct ) const { shape_tetra4(shapefunct,p.x(),p.y(),p.z()); }
00062         virtual void            DNa( const Point &p, nMatrix &grad_shape ) const { dshape_tetra4(grad_shape,p.x(),p.y(),p.z()); }
00063         virtual void            Na( nArray &shapefunct )    const { Na( Centroid(), shapefunct ); }
00064         virtual void            DNa( nMatrix &grad_shape ) const { DNa( Centroid(), grad_shape ); }
00065 
00066 private:
00067         
00068 };
00069 
00070 void Tetra4Basis::ParentCoord( Array< Point > &xi ) const
00071 {
00072 #ifdef ALLOW_DYNAMIC_RESIZE 
00073         if ( xi.size()!=NumNodes() )
00074                 xi.resize(NumNodes());
00075 #endif
00076         xi[0]=Point(0.0,0.0,0.0);
00077         xi[1]=Point(1.0,0.0,0.0);
00078         xi[2]=Point(0.0,1.0,0.0);
00079         xi[3]=Point(0.0,0.0,1.0);
00080 }
00081 
00082 void    Tetra4Basis::NumNodesOnFaces( iArray &nn_face )         const
00083 {
00084 #ifdef ALLOW_DYNAMIC_RESIZE 
00085         if ( nn_face.size()!=NumEdges() )
00086                 nn_face.resize( NumEdges() );
00087 #endif
00088         for ( int i=0; i<NumFaces(); ++i )
00089                 nn_face[i]=3;
00090 }
00091 
00092 void    Tetra4Basis::NumNodesOnEdges( iArray &nn_edge )         const
00093 {
00094 #ifdef ALLOW_DYNAMIC_RESIZE 
00095         if ( nn_edge.size()!=NumEdges() )
00096                 nn_edge.resize( NumEdges() );
00097 #endif
00098         for ( int i=0; i<NumEdges(); ++i )
00099                 nn_edge[i]=2; 
00100 }
00101 
00102 void Tetra4Basis::NodesOnFace ( int f, iArray &face_nodeids ) const
00103 {
00104 #ifdef ALLOW_DYNAMIC_RESIZE 
00105         if ( face_nodeids.size()!=3 )
00106                 face_nodeids.resize(3);
00107 #endif
00108         switch (f) {
00109         
00110                 case 0:
00111                 face_nodeids[0]=1; face_nodeids[1]=2; face_nodeids[2]=3;
00112                 break;
00113                 
00114                 case 1:
00115                 face_nodeids[0]=3; face_nodeids[1]=2; face_nodeids[2]=0;
00116                 break;
00117                 
00118                 case 2:
00119                 face_nodeids[0]=3; face_nodeids[1]=0; face_nodeids[2]=1;
00120                 break;
00121                 
00122                 case 3:
00123                 face_nodeids[0]=2; face_nodeids[1]=1; face_nodeids[2]=0;
00124                 break;
00125                 
00126                 default:
00127                 WarningMessage("Tetra4Basis::NodesOnFace","face id out of range");
00128                 break;
00129                 
00130         }
00131 }
00132 
00133 void Tetra4Basis::NodesOnEdge ( int e, iArray &edge_nodeids ) const
00134 {
00135 #ifdef ALLOW_DYNAMIC_RESIZE 
00136         if ( edge_nodeids.size()!=2 )
00137                 edge_nodeids.resize(2);
00138 #endif
00139         
00140         switch (e) {
00141         
00142                 case 0:
00143                 edge_nodeids[0]=0; edge_nodeids[1]=1;
00144                 break;
00145                 
00146                 case 1:
00147                 edge_nodeids[0]=1; edge_nodeids[1]=2;
00148                 break;
00149                 
00150                 case 2:
00151                 edge_nodeids[0]=2; edge_nodeids[1]=0;
00152                 break;
00153                 
00154                 case 3:
00155                 edge_nodeids[0]=3; edge_nodeids[1]=0;
00156                 break;
00157                 
00158                 case 4:
00159                 edge_nodeids[0]=3; edge_nodeids[1]=2;
00160                 break;
00161                 
00162                 case 5:
00163                 edge_nodeids[0]=3; edge_nodeids[1]=1;
00164                 break;
00165                 
00166                 default:
00167                 WarningMessage("Tetra4Basis::NodesOnFace","face id out of range");
00168                 break;
00169                 
00170         }
00171 }
00172 
00173 void Tetra4Basis::FaceBasisType( Array< BasisType > &face_basis ) const
00174 {
00175 #ifdef ALLOW_DYNAMIC_RESIZE 
00176         if ( face_basis.size()!=NumFaces() )
00177                 face_basis.resize(NumFaces());
00178 #endif
00179         for ( int i=0; i<NumEdges(); ++i )
00180                 face_basis[i]=kTRIA3;
00181 }
00182 
00183 void Tetra4Basis::EdgeBasisType( Array< BasisType > &edge_basis ) const
00184 {
00185 #ifdef ALLOW_DYNAMIC_RESIZE 
00186         if ( edge_basis.size()!=NumEdges() )
00187                 edge_basis.resize(NumEdges());
00188 #endif
00189         for ( int i=0; i<NumEdges(); ++i )
00190                 edge_basis[i]=kLINE2; 
00191 }
00192 
00193 void Tetra4Basis::Quadrature( int order, QuadratureRule &qrule ) const
00194 {
00195         
00196         int npts;
00197         if ( order<=1 )
00198                 npts=1;
00199         else if ( order<=2 )
00200                 npts=4;
00201         else if ( order<=3 )
00202                 npts=5;
00203         else {
00204                 npts=5;
00205                 WarningMessage("Tetra4Basis::Quadrature( int order )","quadrature order >3");
00206         }
00207 
00208         if ( vect_size(qrule)!=npts )
00209                 resize(qrule,npts);
00210 
00211         quadrature_tetra( qrule );
00212         
00213 }
00214 /*
00215  void Tetra4Basis::Na( const Point &p, nArray &shapefunct ) const
00216 {
00217 #ifdef ALLOW_DYNAMIC_RESIZE 
00218         if ( shapefunct.size()!=NumNodes() )
00219                 shapefunct.resize(NumNodes());  
00220 #endif
00221         shapefunct[0]=1.0-p.x()-p.y()-p.z();
00222         shapefunct[1]=p.x();
00223         shapefunct[2]=p.y();
00224         shapefunct[3]=p.z();
00225 }
00226 
00227 void Tetra4Basis::DNa( const Point &p, nMatrix &grad_shape ) const
00228 {
00229 #ifdef ALLOW_DYNAMIC_RESIZE 
00230         if ( mat_nrows(grad_shape)!=NumNodes() || mat_ncols(grad_shape)!=Dimension() )
00231                 resize( grad_shape, NumNodes(), Dimension() );  
00232 #endif
00233         grad_shape(0,0)=-1.0; grad_shape(0,1)=-1.0; grad_shape(0,2)=-1.0; 
00234         grad_shape(1,0)= 1.0; grad_shape(1,1)= 0.0; grad_shape(1,2)= 0.0;
00235         grad_shape(2,0)= 0.0; grad_shape(2,1)= 1.0; grad_shape(2,2)= 0.0;
00236         grad_shape(3,0)= 0.0; grad_shape(3,1)= 0.0; grad_shape(3,2)= 1.0;
00237 }
00238 */
00239 } // end namespace
00240 
00241 #endif
00242 
00243 

Generated on Sat Jan 19 09:03:57 2008 for Basso by  doxygen 1.5.2