function_base.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_FUNCTION_BASE_H
21 #define LIBMESH_FUNCTION_BASE_H
22 
23 // Local Includes
24 #include "libmesh/libmesh_common.h"
25 #include "libmesh/dense_vector.h" // required to instantiate a DenseVector<> below
26 #include "libmesh/auto_ptr.h"
27 
28 // C++ includes
29 #include <cstddef>
30 
31 namespace libMesh
32 {
33 
34 
35 
36 // Forward Declarations
37 class Point;
38 
39 
62 // ------------------------------------------------------------
63 // FunctionBase class definition
64 template <typename Output=Number>
65 class FunctionBase
66 {
67 protected:
68 
72  explicit
73  FunctionBase (const FunctionBase* master = NULL);
74 
75 public:
76 
80  virtual ~FunctionBase ();
81 
85  virtual void init () {}
86 
90  virtual void clear () {}
91 
97  virtual AutoPtr<FunctionBase<Output> > clone () const = 0;
98 
99 
100  // ------------------------------------------------------
101  // misc
108  virtual Output operator() (const Point& p,
109  const Real time = 0.) = 0;
110 
116  void operator() (const Point& p,
117  DenseVector<Output>& output);
118 
126  virtual void operator() (const Point& p,
127  const Real time,
128  DenseVector<Output>& output) = 0;
129 
140  virtual Output component(unsigned int i,
141  const Point& p,
142  Real time=0.);
143 
144 
149  bool initialized () const;
150 
151 
152 protected:
153 
161 
167 
168 };
169 
170 
171 // ------------------------------------------------------------
172 // FunctionBase inline methods
173 
174 template<typename Output>
175 inline
177  _master (master),
178  _initialized (false)
179 {
180 }
181 
182 
183 
184 template<typename Output>
185 inline
187 {
188 }
189 
190 
191 
192 template <typename Output>
193 inline
195 {
196  return (this->_initialized);
197 }
198 
199 
200 
201 template <typename Output>
202 inline
203 Output FunctionBase<Output>::component (unsigned int i,
204  const Point& p,
205  Real time)
206 {
207  DenseVector<Output> outvec(i+1);
208  (*this)(p, time, outvec);
209  return outvec(i);
210 }
211 
212 
213 
214 template <typename Output>
215 inline
217  DenseVector<Output>& output)
218 {
219  // Call the time-dependent function with t=0.
220  this->operator()(p, 0., output);
221 }
222 
223 } // namespace libMesh
224 
225 #endif // LIBMESH_FUNCTION_BASE_H

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:05 UTC

Hosted By:
SourceForge.net Logo