$extrastylesheet
fem_function_base.h
Go to the documentation of this file.
00001 // The libMesh Finite Element Library.
00002 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
00003 
00004 // This library is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public
00006 // License as published by the Free Software Foundation; either
00007 // version 2.1 of the License, or (at your option) any later version.
00008 
00009 // This library is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // Lesser General Public License for more details.
00013 
00014 // You should have received a copy of the GNU Lesser General Public
00015 // License along with this library; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 
00018 
00019 
00020 #ifndef LIBMESH_FEM_FUNCTION_BASE_H
00021 #define LIBMESH_FEM_FUNCTION_BASE_H
00022 
00023 // C++ includes
00024 
00025 
00026 
00027 // Local Includes
00028 #include "libmesh/libmesh_common.h"
00029 #include "libmesh/dense_vector.h" // required to instantiate a DenseVector<> below
00030 #include "libmesh/auto_ptr.h"
00031 #include "libmesh/fem_context.h"
00032 
00033 namespace libMesh
00034 {
00035 
00036 
00037 
00038 // Forward Declarations
00039 class Point;
00040 
00041 
00042 // ------------------------------------------------------------
00043 // FEMFunctionBase class definition
00044 template <typename Output=Number>
00045 class FEMFunctionBase
00046 {
00047 protected:
00048 
00052   FEMFunctionBase () {}
00053 
00054 public:
00055 
00059   virtual ~FEMFunctionBase () {}
00060 
00061 
00068   virtual void init_context (const FEMContext &) {}
00069 
00075   virtual UniquePtr<FEMFunctionBase<Output> > clone () const = 0;
00076 
00077   // ------------------------------------------------------
00078   // misc
00085   virtual Output operator() (const FEMContext&, const Point& p,
00086                              const Real time = 0.) = 0;
00087 
00088 
00094   void operator() (const FEMContext&, const Point& p,
00095                    DenseVector<Output>& output);
00096 
00104   virtual void operator() (const FEMContext&, const Point& p,
00105                            const Real time,
00106                            DenseVector<Output>& output) = 0;
00107 
00118   virtual Output component(const FEMContext&, unsigned int i,
00119                            const Point& p,
00120                            Real time=0.);
00121 
00122 };
00123 
00124 template <typename Output>
00125 inline
00126 Output FEMFunctionBase<Output>::component (const FEMContext& context, unsigned int i,
00127                                            const Point& p,
00128                                            Real time)
00129 {
00130   DenseVector<Output> outvec(i+1);
00131   (*this)(context, p, time, outvec);
00132   return outvec(i);
00133 }
00134 
00135 template <typename Output>
00136 inline
00137 void FEMFunctionBase<Output>::operator() (const FEMContext& context, const Point& p,
00138                                           DenseVector<Output>& output)
00139 {
00140   // Call the time-dependent function with t=0.
00141   this->operator()(context, p, 0., output);
00142 }
00143 
00144 } // namespace libMesh
00145 
00146 #endif // LIBMESH_FEM_FUNCTION_BASE_H