synaps/topology/cell2d.h

00001 /*******************************************************************
00002  *   This file is part of the source code of the SYNAPS library.
00003  *   Author(s): 
00004  *   $Id: cell2d.h,v 1.1 2005/07/11 14:02:22 mourrain Exp $
00005  ********************************************************************/
00006 #ifndef synaps_mesh_cell2d_H
00007 #define synaps_mesh_cell2d_H
00008 /********************************************************************/
00009 #include <synaps/init.h>
00010 #include <synaps/linalg/MatrDse.h>
00011 //--------------------------------------------------------------------
00012 __BEGIN_NAMESPACE_SYNAPS
00013 //--------------------------------------------------------------------
00017 template<class C, class R = MatrDse<C> >
00018 struct cell2d
00019 {
00020   typedef typename R::row_type row_type;
00021   typedef typename R::col_type col_type;
00022   typedef C coeff_t;
00023   typedef R matr_t;
00024   C x0,x1,y0,y1;
00025   int reg;
00026   matr_t bz_pol;
00027 
00028   cell2d():x0(0),x1(1),y0(0),y1(1),reg(0),bz_pol(){}
00029   cell2d(coeff_t a, coeff_t b, coeff_t c, coeff_t d, matr_t M): 
00030     x0(a),x1(b),y0(c),y1(d),reg(0),bz_pol(M){}
00031   cell2d(const cell2d<C,R>& c): 
00032     x0(c.x0),x1(c.x1),y0(c.y0),y1(c.y1),
00033     reg(c.reg),
00034     bz_pol(c.bz_pol) {}
00035   cell2d& operator= (const cell2d<C,R> & c)
00036   {
00037     x0=c.x0;
00038     x1=c.x1;
00039     y0=c.y0;
00040     y1=c.y1;
00041     reg=c.reg;
00042     bz_pol=c.bz_pol;
00043     return *this;
00044   }
00045   int nbrow() const {return bz_pol.nbrow();}
00046   int nbcol() const {return bz_pol.nbcol();}
00047 
00048   typename R::coeff_t operator()(int i,int j) const {return bz_pol(i,j);}
00049 };
00050 //--------------------------------------------------------------------
00051 template<class C, class R>
00052 C size(const cell2d<C,R>& c)
00053 {
00054   return std::max(fabs(c.x1-c.x0),fabs(c.y1-c.y0));
00055 }
00056 
00057 __END_NAMESPACE_SYNAPS
00058 /********************************************************************/
00059 #endif //synaps_mesh_cell2d_H

SYNAPS DOCUMENTATION
logo