NGSolve  4.9
fem/specialelement.hpp
00001 #ifndef FILE_SPECIALELEMENT
00002 #define FILE_SPECIALELEMENT
00003 
00004 /*********************************************************************/
00005 /* File:   specialelement.hpp                                        */
00006 /* Author: Joachim Schoeberl                                         */
00007 /* Date:   28. Mar. 2002                                             */
00008 /*********************************************************************/
00009 
00010 namespace ngfem
00011 {
00012 
00013   /*
00014     Something special ...
00015 
00016     Finite-Element + Integrator
00017 
00018     E.g., a Contact-Element  
00019   */
00020 
00021 
00022 
00023   class NGS_DLL_HEADER SpecialElement
00024   {
00025   public:
00026     SpecialElement ()
00027     {
00028       ;
00029     }
00030     virtual ~SpecialElement() { ; }
00031   
00032 
00033 
00034     virtual void GetDofNrs (Array<int> & dnums) const = 0;
00035     virtual double Energy (const FlatVector<double> & elx, 
00036                            LocalHeap & lh) const
00037     {
00038       return 0;
00039     }
00040     virtual double Energy (const FlatVector<Complex> & elx, 
00041                            LocalHeap & lh) const 
00042     {
00043       cerr << "SpecialElement::Energy (complex) called" << endl;
00044       return 0;
00045     }
00046 
00047     template<int S, class T>
00048     void Apply (const FlatVector< Vec<S,T> > & elx, 
00049                 FlatVector< Vec<S,T> > & ely, 
00050                 LocalHeap & lh) const
00051     {
00052       cerr << "SpecialElement::Apply (Vec) called" << endl;
00053     }
00054 
00055     virtual void Apply (const FlatVector<double> & elx, FlatVector<double> & ely, 
00056                         LocalHeap & lh) const;
00057 
00058     virtual void Apply (const FlatVector<Complex> & elx, 
00059                         FlatVector<Complex> & ely, 
00060                         LocalHeap & lh) const
00061     {
00062       cerr << "SpecialElement::Apply (complex) called" << endl;
00063     }
00064 
00065     virtual void Assemble (FlatMatrix<double> & elmat,
00066                            LocalHeap & lh) const;
00067 
00068     virtual void Assemble (FlatMatrix<Complex> & elmat,
00069                            LocalHeap & lh) const
00070     {
00071       cerr << "SpecialElement::Assemble (complex) called" << endl;
00072       exit(10);
00073       FlatMatrix<double> relmat;
00074       Assemble (relmat, lh);
00075       elmat.AssignMemory (relmat.Height(), relmat.Width(), lh);
00076       elmat = relmat;
00077     }
00078 
00079     virtual void Assemble (FlatVector<double> & elvec,
00080                            LocalHeap & lh) const;
00081 
00082     virtual void Assemble (FlatVector<Complex> & elvec,
00083                            LocalHeap & lh) const
00084     {
00085       cerr << "SpecialElement::Assemble (complex) called" << endl;
00086       exit(10);
00087       FlatVector<double> relvec;
00088       Assemble (relvec, lh);
00089       elvec.AssignMemory (relvec.Height(),lh);
00090       elvec = relvec;
00091     }
00092   };
00093 
00094 }
00095 
00096 #endif