![]() |
00001 // Copyright (C) 2003 Johan Hoffman and Anders Logg. 00002 // Licensed under the GNU GPL Version 2. 00003 00004 #ifndef __INTEGRAL_H 00005 #define __INTEGRAL_H 00006 00007 #include <dolfin/constants.h> 00008 #include <dolfin/Tensor.h> 00009 #include <dolfin/FunctionSpace.h> 00010 00011 namespace dolfin { 00012 00013 class Quadrature; 00014 class Map; 00015 00016 class Integral 00017 { 00018 public: 00019 00020 // Forward declarations of nested classes 00021 class Measure; 00022 class InteriorMeasure; 00023 class BoundaryMeasure; 00024 00026 class Measure 00027 { 00028 public: 00029 00030 Measure(); 00031 Measure(const Map& map, const Quadrature& quadrature); 00032 virtual ~Measure(); 00033 00034 // Update map and quadrature 00035 virtual void update(const Map& map, const Quadrature& quadrature); 00036 00037 // Integration operators dm * v 00038 real operator* (real a) const; 00039 virtual real operator* (const FunctionSpace::ShapeFunction& v) = 0; 00040 virtual real operator* (const FunctionSpace::Product& v) = 0; 00041 real operator* (const FunctionSpace::ElementFunction& v); 00042 00043 protected: 00044 00045 // Return determinant of map 00046 virtual real det() const = 0; 00047 00048 // Integral data 00049 class Value 00050 { 00051 public: 00052 00053 Value() { value = 0.0; computed = false; } 00054 real operator() () { return value; } 00055 bool ok() { return computed; } 00056 void set(real value) { this->value = value; computed = true; } 00057 void operator= (int a) { value = 0.0; computed = false; } 00058 00059 private: 00060 00061 real value; 00062 bool computed; 00063 00064 }; 00065 00066 // Map from reference cell 00067 const Map* m; 00068 00069 // Quadrature rule on reference cell 00070 const Quadrature* q; 00071 00072 // True if the measure is active 00073 bool active; 00074 00075 }; 00076 00077 // Integral measure for the interior of an element 00078 class InteriorMeasure : public Measure 00079 { 00080 public: 00081 00083 InteriorMeasure(); 00084 00086 InteriorMeasure(Map& m, Quadrature& q); 00087 00088 // Destructor 00089 ~InteriorMeasure(); 00090 00091 // Update map and quadrature 00092 void update(const Map& map, const Quadrature& quadrature); 00093 00094 // Return integral of shape function 00095 real operator* (const FunctionSpace::ShapeFunction& v); 00096 00097 // Return integral of product of shape functions 00098 real operator* (const FunctionSpace::Product& v); 00099 00100 private: 00101 00102 // Evaluate integral of shape function 00103 real integral(const FunctionSpace::ShapeFunction& v); 00104 00105 // Evaluate integral of product of shape functions 00106 real integral(const FunctionSpace::Product& v); 00107 00108 // Return determinant of map 00109 real det() const; 00110 00111 // Init table 00112 virtual void init(); 00113 00114 // Resize table 00115 virtual void resize(unsigned int new_order, unsigned int new_n); 00116 00117 // A lookup table for integrals 00118 Tensor<Value>* table; 00119 00120 // Maximum number of factors 00121 unsigned int order; 00122 00123 // Number of different shape functions 00124 unsigned int n; 00125 00126 }; 00127 00128 // Integral measure for the boundary of an element 00129 class BoundaryMeasure : public Measure 00130 { 00131 public: 00132 00133 // Constructor 00134 BoundaryMeasure(); 00135 00136 // Constructor 00137 BoundaryMeasure(Map& m, Quadrature& q); 00138 00139 // Destructor 00140 ~BoundaryMeasure(); 00141 00142 // Update map and quadrature 00143 void update(const Map& map, const Quadrature& quadrature); 00144 00145 // Return integral of shape function 00146 real operator* (const FunctionSpace::ShapeFunction& v); 00147 00148 // Return integral of product of shape functions 00149 real operator* (const FunctionSpace::Product& v); 00150 00151 private: 00152 00153 // Evaluate integral of shape function 00154 real integral(const FunctionSpace::ShapeFunction& v); 00155 00156 // Evaluate integral of product of shape functions 00157 real integral(const FunctionSpace::Product& v); 00158 00159 // Return determinant of map 00160 real det() const; 00161 00162 // Init table 00163 virtual void init(); 00164 00165 // Resize table 00166 virtual void resize(unsigned int new_order, unsigned int new_n); 00167 00168 // A lookup table for integrals 00169 Tensor<Value>** table; 00170 00171 // Maximum number of factors 00172 unsigned int order; 00173 00174 // Number of different shape functions 00175 unsigned int n; 00176 00177 // Current boundary 00178 int boundary; 00179 00180 // Maximum number of different boundaries 00181 unsigned int bndmax; 00182 00183 }; 00184 00185 }; 00186 00187 real operator* (real a, const Integral::Measure& dm); 00188 00189 } 00190 00191 #endif
![]()
Documentation automatically generated with Doxygen on 10 Sep 2004.