SyFi
0.3
|
00001 // Copyright (C) 2006-2009 Kent-Andre Mardal and Simula Research Laboratory 00002 // 00003 // This file is part of SyFi. 00004 // 00005 // SyFi is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 2 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // SyFi is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with SyFi. If not, see <http://www.gnu.org/licenses/>. 00017 00018 #include "FE.h" 00019 00020 #include <stdexcept> 00021 00022 using namespace std; 00023 00024 namespace SyFi 00025 { 00026 00027 StandardFE:: StandardFE() 00028 { 00029 p = NULL; 00030 order = -1; 00031 description = "StandardFE"; 00032 } 00033 00034 StandardFE:: StandardFE(Polygon& p_, unsigned int order) 00035 { 00036 p = NULL; 00037 set_polygon(p_); 00038 set_order(order); 00039 description = "StandardFE"; 00040 } 00041 00042 StandardFE:: ~StandardFE() 00043 { 00044 if (p) 00045 { 00046 delete p; 00047 } 00048 } 00049 00050 unsigned int StandardFE:: nbf() const 00051 { 00052 return Ns.size(); 00053 } 00054 00055 std::string StandardFE:: str() 00056 { 00057 return description; 00058 } 00059 00060 void StandardFE:: compute_basis_functions() 00061 { 00062 cout <<"StandardFE compute_basis_functions not implemented."<<endl; 00063 cout <<"Use some derived class like e.g. LagrangeFE."<<endl; 00064 } 00065 00066 Polygon& StandardFE:: get_polygon() 00067 { 00068 if(!p) 00069 { 00070 throw std::runtime_error("No polygon has been set!"); 00071 } 00072 return *p; 00073 } 00074 00075 void StandardFE:: set_polygon(Polygon& p_) 00076 { 00077 Ns.clear(); 00078 dofs.clear(); 00079 if (p) 00080 { 00081 delete p; 00082 } 00083 p = p_.copy(); 00084 } 00085 00086 unsigned int StandardFE:: get_order() 00087 { 00088 return order; 00089 } 00090 00091 void StandardFE:: set_order(unsigned int order_) 00092 { 00093 Ns.clear(); 00094 dofs.clear(); 00095 order = order_; 00096 } 00097 00098 GiNaC::ex StandardFE:: dof(unsigned int i) 00099 { 00100 if ( i < 0 || i > nbf()-1) 00101 { 00102 throw(std::out_of_range("The index is out of range!")); 00103 } 00104 return dofs[i]; 00105 } 00106 00107 GiNaC::ex StandardFE::N(unsigned int i) 00108 { 00109 if ( i < 0 || i > nbf()-1) 00110 { 00111 throw(std::out_of_range("The index is out of range!")); 00112 } 00113 return Ns[i]; 00114 } 00115 00116 } // namespace SyFi