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

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

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