fem_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_FEM_FUNCTION_BASE_H
21 #define LIBMESH_FEM_FUNCTION_BASE_H
22 
23 // C++ includes
24 
25 
26 
27 // Local Includes
28 #include "libmesh/libmesh_common.h"
29 #include "libmesh/dense_vector.h" // required to instantiate a DenseVector<> below
30 #include "libmesh/auto_ptr.h"
31 #include "libmesh/fem_context.h"
32 
33 namespace libMesh
34 {
35 
36 
37 
38 // Forward Declarations
39 class Point;
40 
41 
42 // ------------------------------------------------------------
43 // FEMFunctionBase class definition
44 template <typename Output=Number>
46 {
47 protected:
48 
53 
54 public:
55 
59  virtual ~FEMFunctionBase () {}
60 
61 
68  virtual void init_context (const FEMContext &) {}
69 
75  virtual AutoPtr<FEMFunctionBase<Output> > clone () const = 0;
76 
77  // ------------------------------------------------------
78  // misc
85  virtual Output operator() (const FEMContext&, const Point& p,
86  const Real time = 0.) = 0;
87 
88 
94  void operator() (const FEMContext&, const Point& p,
95  DenseVector<Output>& output);
96 
104  virtual void operator() (const FEMContext&, const Point& p,
105  const Real time,
106  DenseVector<Output>& output) = 0;
107 
118  virtual Output component(const FEMContext&, unsigned int i,
119  const Point& p,
120  Real time=0.);
121 
122 
123 protected:
124 
129  unsigned int var_index ;
130 
131 };
132 
133 template <typename Output>
134 inline
135 Output FEMFunctionBase<Output>::component (const FEMContext& context, unsigned int i,
136  const Point& p,
137  Real time)
138 {
139  DenseVector<Output> outvec(i+1);
140  (*this)(context, p, time, outvec);
141  return outvec(i);
142 }
143 
144 template <typename Output>
145 inline
147  DenseVector<Output>& output)
148 {
149  // Call the time-dependent function with t=0.
150  this->operator()(context, p, 0., output);
151 }
152 
153 } // namespace libMesh
154 
155 #endif // LIBMESH_FEM_FUNCTION_BASE_H

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

Hosted By:
SourceForge.net Logo