Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

Element.h

Go to the documentation of this file.
00001 // Copyright (C) 2003 Johan Hoffman and Anders Logg.
00002 // Licensed under the GNU GPL Version 2.
00003 
00004 #ifndef __ELEMENT_H
00005 #define __ELEMENT_H
00006 
00007 #include <dolfin/constants.h>
00008 #include <dolfin/Vector.h>
00009 #include <dolfin/NewArray.h>
00010 
00011 namespace dolfin {
00012 
00013   class RHS;
00014 
00018 
00019   class Element {
00020   public:
00021     
00022     enum Type {cg, dg};
00023 
00025     Element(unsigned int q, unsigned int index, real t0, real t1);
00026 
00028     virtual ~Element();
00029 
00031     virtual Type type() const = 0;
00032 
00034     unsigned int order() const;
00035 
00037     virtual unsigned int size() const = 0;
00038 
00040     virtual real value(real t) const = 0;
00041 
00043     virtual real value(unsigned int node, real t) const = 0;
00044 
00046     real value(unsigned int node) const;
00047 
00049     virtual real initval() const = 0;
00050 
00052     real endval() const;
00053 
00055     virtual real ddx() const = 0;
00056 
00058     virtual void update(real u0) = 0;
00059 
00061     void update(unsigned int node, real value);
00062 
00064     virtual real update(RHS& f) = 0;
00065 
00067     virtual real update(RHS& f, real* values) = 0;
00068 
00070     virtual real update(RHS& f, real alpha) = 0;
00071 
00073     virtual real update(RHS& f, real alpha, real* values) = 0;
00074 
00076     virtual real updateLocalNewton(RHS& f) = 0;
00077 
00079     virtual real updateLocalNewton(RHS& f, real* values) = 0;
00080 
00082     virtual void set(real u0) = 0;
00083 
00085     virtual void set(const real* const values) = 0;
00086 
00088     virtual void get(real* const values) const = 0;
00089 
00091     inline bool within(real t) const { return (t0 < t) && (t <= t1); }
00092 
00094     unsigned int index() const;
00095 
00097     real starttime() const;
00098 
00100     real endtime() const;
00101 
00103     inline real timestep() const { return t1 - t0; }
00104 
00105     // Compute continuous residual
00106     real computeResidual(RHS& f);
00107 
00109     virtual bool accept(real TOL, real r) = 0;
00110 
00111     // Compute discrete residual
00112     virtual real computeDiscreteResidual(RHS& f) = 0;
00113 
00114     // Compute element residual
00115     virtual real computeElementResidual(RHS& f) = 0;
00116 
00117     // Compute new time step
00118     virtual real computeTimeStep(real TOL, real r, real kmax) const = 0;
00119 
00120   protected:
00121 
00122     // Evaluate the right-hand side
00123     virtual void feval(RHS& f) = 0;
00124 
00125     // Compute integral for degree of freedom i using quadrature
00126     virtual real integral(unsigned int i) const = 0;
00127 
00128     // Temporary storage for function evaluations (common to all elements)
00129     static Vector f;
00130 
00131     // Temporary storage for local newton iteration (common to all elements)
00132     static NewArray<Matrix> A;
00133     static NewArray<Vector> x;
00134     static NewArray<Vector> b;
00135 
00136     //--- Element data ---
00137     
00138     // Order
00139     unsigned int q;
00140 
00142     unsigned int _index;
00143     
00144     // Interval
00145     real t0, t1;
00146 
00147     // Nodal values
00148     real* values;
00149     
00150   };   
00151     
00152 }
00153 
00154 #endif


Documentation automatically generated with Doxygen on 10 Sep 2004.