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

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

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