![]() |
00001 // Copyright (C) 2002 Johan Hoffman and Anders Logg. 00002 // Licensed under the GNU GPL Version 2. 00003 // 00004 // Modified by Fredrik Bengzon and Johan Jansson, 2004. 00005 00006 #ifndef __PDE_H 00007 #define __PDE_H 00008 00009 #include <dolfin/constants.h> 00010 #include <dolfin/List.h> 00011 #include <dolfin/NewList.h> 00012 #include <dolfin/Map.h> 00013 #include <dolfin/Function.h> 00014 #include <dolfin/ElementFunction.h> 00015 #include <dolfin/ShapeFunction.h> 00016 #include <dolfin/FiniteElement.h> 00017 00018 namespace dolfin { 00019 00020 typedef FunctionSpace::ShapeFunction ShapeFunction; 00021 typedef FunctionSpace::Product Product; 00022 typedef FunctionSpace::ElementFunction ElementFunction; 00023 00024 class PDE { 00025 public: 00026 00028 PDE(int dim, int noeq = 1); 00029 00031 virtual ~PDE(); 00032 00034 virtual real lhs(const ShapeFunction &u, const ShapeFunction &v) 00035 { 00036 return 0.0; 00037 } 00038 00040 virtual real rhs(const ShapeFunction &v) 00041 { 00042 return 0.0; 00043 } 00044 00046 virtual real lhs(ShapeFunction::Vector &u, 00047 ShapeFunction::Vector &v) 00048 { 00049 return lhs(u(0), v(0)); 00050 } 00051 00053 virtual real rhs(ShapeFunction::Vector &v) 00054 { 00055 return rhs(v(0)); 00056 } 00057 00059 const void updateLHS(FiniteElement::Vector& element, 00060 // const Cell& cell, 00061 const Map& mapping, 00062 const Quadrature& interior_quadrature, 00063 const Quadrature& boundary_quadrature); 00064 00066 const void updateRHS(FiniteElement::Vector& element, 00067 // const Cell& cell, 00068 const Map& mapping, 00069 const Quadrature& interior_quadrature, 00070 const Quadrature& boundary_quadrature); 00071 00072 00074 int size(); 00075 00077 real t; // Time 00078 real k; // Time step 00079 00080 protected: 00081 00082 // --- Derivatives (computed using map) 00083 00084 // Derivative of constant 00085 real ddx(real a) const; 00086 real ddy(real a) const; 00087 real ddz(real a) const; 00088 real ddt(real a) const; 00089 00090 // Derivative of ShapeFunction 00091 const ElementFunction& ddx(const ShapeFunction& v) const; 00092 const ElementFunction& ddy(const ShapeFunction& v) const; 00093 const ElementFunction& ddz(const ShapeFunction& v) const; 00094 const ElementFunction& ddt(const ShapeFunction& v) const; 00095 00096 // Derivative of Product 00097 const ElementFunction ddx(const Product& v) const; 00098 const ElementFunction ddy(const Product& v) const; 00099 const ElementFunction ddz(const Product& v) const; 00100 const ElementFunction ddt(const Product& v) const; 00101 00102 // Derivative of ElementFunction 00103 const ElementFunction ddx(const ElementFunction& v) const; 00104 const ElementFunction ddy(const ElementFunction& v) const; 00105 const ElementFunction ddz(const ElementFunction& v) const; 00106 const ElementFunction ddt(const ElementFunction& v) const; 00107 00108 // Gradients 00109 const FunctionSpace::ElementFunction::Vector grad(const ShapeFunction& v); 00110 const FunctionSpace::ElementFunction::Vector grad(const ElementFunction& v); 00111 00112 // Function data 00113 class FunctionPair { 00114 public: 00115 FunctionPair(); 00116 FunctionPair(ElementFunction& v, Function& f); 00117 00118 // Update element function to current element 00119 void update(const FiniteElement& element, const Cell& cell, real t); 00120 00121 ElementFunction* v; 00122 Function* f; 00123 }; 00124 00125 // Add a function that needs to be updated on every new cell 00126 void add(ElementFunction& v, Function& f); 00127 void add(ElementFunction::Vector &v, Function::Vector &f); 00128 00129 // Update equation 00130 const void update(FiniteElement::Vector& element, 00131 // const Cell& cell, 00132 const Map& map, 00133 const Quadrature& interior_quadrature, 00134 const Quadrature& boundary_quadrature); 00135 00136 // Optional update before computation of left-hand side 00137 virtual void updateLHS() {}; 00138 // Optional update before computation of right-hand side 00139 virtual void updateRHS() {}; 00140 00141 // List of element functions that need to be updated 00142 NewList<FunctionPair> functions; 00143 00144 // Map from reference element 00145 const Map* map_; 00146 00147 // Cell 00148 const Cell* cell_; 00149 00150 // Integral measures 00151 Integral::InteriorMeasure dx; 00152 Integral::BoundaryMeasure ds; 00153 00154 int dim; // Space dimension 00155 int noeq; // Number of equations 00156 00157 real h; // Local mesh size 00158 00159 }; 00160 00161 } 00162 00163 #endif
![]()
Documentation automatically generated with Doxygen on 10 Sep 2004.