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 "DiscontinuousLagrange.h" 00019 #include "ElementComputations.h" 00020 00021 using std::cout; 00022 using std::endl; 00023 00024 namespace SyFi 00025 { 00026 00027 DiscontinuousLagrange:: DiscontinuousLagrange(Polygon& p, unsigned int order) : Lagrange(p,order) 00028 { 00029 compute_basis_functions(); 00030 element = GiNaC::symbol("e"); 00031 } 00032 00033 DiscontinuousLagrange:: DiscontinuousLagrange() : Lagrange() 00034 { 00035 description = "DiscontinuousLagrange"; 00036 element = GiNaC::symbol("e"); 00037 } 00038 00039 void DiscontinuousLagrange:: compute_basis_functions() 00040 { 00041 00042 // remove previously computed basis functions and dofs 00043 Ns.clear(); 00044 dofs.clear(); 00045 00046 if ( order < 1 ) 00047 { 00048 throw(std::logic_error("Discontinuous Lagrangian elements must be of order 1 or higher.")); 00049 } 00050 00051 if ( p == NULL ) 00052 { 00053 throw(std::logic_error("You need to set a polygon before the basisfunctions can be computed")); 00054 } 00055 00056 //FIXME should have element defined somehow other than 00057 //setting it to zero 00058 // 00059 //It could be a symbol 'e' instead ? 00060 00061 Lagrange:: compute_basis_functions(); 00062 for (unsigned int i=0; i< dofs.size(); i++) 00063 { 00064 dofs[i] = GiNaC::lst(dofs[i], element); 00065 } 00066 00067 description = "Discontinuous" + Lagrange:: str(); 00068 } 00069 00070 void DiscontinuousLagrange:: set_element_number(unsigned int element_) 00071 { 00072 element = element_; 00073 } 00074 00075 // ------------VectorDiscontinuousLagrange --- 00076 00077 VectorDiscontinuousLagrange:: VectorDiscontinuousLagrange(Polygon& p, unsigned int order) : VectorLagrange(p,order) 00078 { 00079 compute_basis_functions(); 00080 element = GiNaC::symbol("e"); 00081 } 00082 00083 VectorDiscontinuousLagrange:: VectorDiscontinuousLagrange() : 00084 VectorLagrange() 00085 { 00086 description = "DiscontinuousLagrange"; 00087 element = GiNaC::symbol("e"); 00088 } 00089 00090 void VectorDiscontinuousLagrange:: compute_basis_functions() 00091 { 00092 00093 // remove previously computed basis functions and dofs 00094 Ns.clear(); 00095 dofs.clear(); 00096 00097 VectorLagrange:: compute_basis_functions(); 00098 00099 for (unsigned int i=0; i< dofs.size(); i++) 00100 { 00101 dofs[i] = GiNaC::lst(dofs[i].op(0), dofs[i].op(1), element); 00102 } 00103 00104 description = "Discontinuous" + VectorLagrange:: str(); 00105 } 00106 00107 void VectorDiscontinuousLagrange:: set_size(unsigned int size_) 00108 { 00109 VectorLagrange::set_size(size_); 00110 } 00111 00112 void VectorDiscontinuousLagrange:: set_element_number(unsigned int element_) 00113 { 00114 element = element_; 00115 } 00116 00117 } // namespace SyFi