function_base.h
Go to the documentation of this file.00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2012 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_FUNCTION_BASE_H 00021 #define LIBMESH_FUNCTION_BASE_H 00022 00023 // Local Includes 00024 #include "libmesh/libmesh_common.h" 00025 #include "libmesh/dense_vector.h" // required to instantiate a DenseVector<> below 00026 #include "libmesh/auto_ptr.h" 00027 00028 // C++ includes 00029 #include <cstddef> 00030 00031 namespace libMesh 00032 { 00033 00034 00035 00036 // Forward Declarations 00037 class Point; 00038 00039 00062 // ------------------------------------------------------------ 00063 // FunctionBase class definition 00064 template <typename Output=Number> 00065 class FunctionBase 00066 { 00067 protected: 00068 00072 explicit 00073 FunctionBase (const FunctionBase* master = NULL); 00074 00075 public: 00076 00080 virtual ~FunctionBase (); 00081 00085 virtual void init () {} 00086 00090 virtual void clear () {} 00091 00097 virtual AutoPtr<FunctionBase<Output> > clone () const = 0; 00098 00099 00100 // ------------------------------------------------------ 00101 // misc 00108 virtual Output operator() (const Point& p, 00109 const Real time = 0.) = 0; 00110 00116 void operator() (const Point& p, 00117 DenseVector<Output>& output); 00118 00126 virtual void operator() (const Point& p, 00127 const Real time, 00128 DenseVector<Output>& output) = 0; 00129 00140 virtual Output component(unsigned int i, 00141 const Point& p, 00142 Real time=0.); 00143 00144 00149 bool initialized () const; 00150 00151 00152 protected: 00153 00160 const FunctionBase* _master; 00161 00166 bool _initialized; 00167 00168 }; 00169 00170 00171 // ------------------------------------------------------------ 00172 // FunctionBase inline methods 00173 00174 template<typename Output> 00175 inline 00176 FunctionBase<Output>::FunctionBase (const FunctionBase* master) : 00177 _master (master), 00178 _initialized (false) 00179 { 00180 } 00181 00182 00183 00184 template<typename Output> 00185 inline 00186 FunctionBase<Output>::~FunctionBase () 00187 { 00188 } 00189 00190 00191 00192 template <typename Output> 00193 inline 00194 bool FunctionBase<Output>::initialized() const 00195 { 00196 return (this->_initialized); 00197 } 00198 00199 00200 00201 template <typename Output> 00202 inline 00203 Output FunctionBase<Output>::component (unsigned int i, 00204 const Point& p, 00205 Real time) 00206 { 00207 DenseVector<Output> outvec(i+1); 00208 (*this)(p, time, outvec); 00209 return outvec(i); 00210 } 00211 00212 00213 00214 template <typename Output> 00215 inline 00216 void FunctionBase<Output>::operator() (const Point& p, 00217 DenseVector<Output>& output) 00218 { 00219 // Call the time-dependent function with t=0. 00220 this->operator()(p, 0., output); 00221 } 00222 00223 } // namespace libMesh 00224 00225 #endif // LIBMESH_FUNCTION_BASE_H
Site Created By: libMesh Developers
Last modified: February 05 2013 19:54:47 UTC
Hosted By: