SyFi 0.3
FE.cpp
Go to the documentation of this file.
00001 // Copyright (C) 2006-2009 Kent-Andre Mardal and Simula Research Laboratory.
00002 // Licensed under the GNU GPL Version 2, or (at your option) any later version.
00003 
00004 #include "FE.h"
00005 
00006 #include <stdexcept>
00007 
00008 using namespace std;
00009 
00010 namespace SyFi
00011 {
00012 
00013         StandardFE:: StandardFE()
00014         {
00015                 p = NULL;
00016                 order = -1;
00017                 description = "StandardFE";
00018         }
00019 
00020         StandardFE:: StandardFE(Polygon& p_, unsigned int order)
00021         {
00022                 p = NULL;
00023                 set_polygon(p_);
00024                 set_order(order);
00025                 description = "StandardFE";
00026         }
00027 
00028         StandardFE:: ~StandardFE()
00029         {
00030                 if (p)
00031                 {
00032                         delete p;
00033                 }
00034         }
00035 
00036         unsigned int StandardFE:: nbf() const
00037         {
00038                 return Ns.size();
00039         }
00040 
00041         std::string StandardFE:: str()
00042         {
00043                 return description;
00044         }
00045 
00046         void StandardFE:: compute_basis_functions()
00047         {
00048                 cout <<"StandardFE compute_basis_functions not implemented."<<endl;
00049                 cout <<"Use some derived class like e.g. LagrangeFE."<<endl;
00050         }
00051 
00052         Polygon& StandardFE:: get_polygon()
00053         {
00054                 if(!p)
00055                 {
00056                         throw std::runtime_error("No polygon has been set!");
00057                 }
00058                 return *p;
00059         }
00060 
00061         void StandardFE:: set_polygon(Polygon& p_)
00062         {
00063                 Ns.clear();
00064                 dofs.clear();
00065                 if (p)
00066                 {
00067                         delete p;
00068                 }
00069                 p = p_.copy();
00070         }
00071 
00072         unsigned int StandardFE:: get_order()
00073         {
00074                 return order;
00075         }
00076 
00077         void StandardFE:: set_order(unsigned int order_)
00078         {
00079                 Ns.clear();
00080                 dofs.clear();
00081                 order = order_;
00082         }
00083 
00084         GiNaC::ex StandardFE:: dof(unsigned int i)
00085         {
00086                 if ( i < 0 || i > nbf()-1)
00087                 {
00088                         throw(std::out_of_range("The index is out of range!"));
00089                 }
00090                 return dofs[i];
00091         }
00092 
00093         GiNaC::ex StandardFE::N(unsigned int i)
00094         {
00095                 if ( i < 0 || i > nbf()-1)
00096                 {
00097                         throw(std::out_of_range("The index is out of range!"));
00098                 }
00099                 return Ns[i];
00100         }
00101 
00102 }                                                                // namespace SyFi
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines