/************************************************************************** ** Title: demo program for use of templates ** Date: 29.4.2006 ** Copyright: Bernard Haasdonk **************************************************************************/ #include #include using namespace std; class Function1 { public: void evaluate(const double x[2], double& result) const { result = x[1]*x[1]*x[1]; } }; class Function2 { public: void evaluate(const double x[2], double& result) const { result = sin(3*x[0])*cos(3*x[1]); } }; class QuadratureP2 { public: // constructor QuadratureP2() { for (int i=0;i<3;i++) weights_[i]=1.0/6; for (int i=0;i<3;i++) for (int j=0;j<2;j++) points_[i][j]=1.0/2; points_[0][1] = 0.0; points_[1][0] = 0.0; }; int npoints() const {return 3;}; double weight(const int pnumber) const { return weights_[pnumber]; }; const double* point(const int pnumber) const { return points_[pnumber]; }; private: double weights_[3]; double points_[3][2]; }; class QuadratureP3 { public: // constructor QuadratureP3() { for (int i=0;i<3;i++) weights_[i]=25.0/96; for (int i=0;i<3;i++) for (int j=0;j<2;j++) points_[i][j]=1.0/5; points_[0][0] = 3.0/5; points_[2][1] = 3.0/5; weights_[3] = -9.0/32; points_[3][0] = 1.0/3; points_[3][1] = 1.0/3; }; int npoints() const {return 4;}; double weight(const int pnumber) const { return weights_[pnumber]; }; const double* point(const int pnumber) const { return points_[pnumber]; }; private: double weights_[4]; double points_[4][2]; }; // implement ReferenceElementIntegrator and main program here! // ....... // .......