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