libMesh
Loading...
Searching...
No Matches
fem_function_base.h
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 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// Local Includes
24#include "libmesh/libmesh_common.h"
25#include "libmesh/dense_vector.h" // required to instantiate a DenseVector<> below
26#include "libmesh/fem_context.h"
27
28// C++ includes
29#include <memory>
30
31namespace libMesh
32{
33
34// Forward Declarations
35class Point;
36
45template <typename Output=Number>
47{
48protected:
49
53 FEMFunctionBase () = default;
54
55public:
56
61 FEMFunctionBase (const FEMFunctionBase &) = default;
64 virtual ~FEMFunctionBase () = default;
65
69 virtual void init () {}
70
77 virtual void init_context (const FEMContext &) {}
78
86 virtual std::unique_ptr<FEMFunctionBase<Output>> clone () const = 0;
87
94 virtual Output operator() (const FEMContext &,
95 const Point & p,
96 const Real time = 0.) = 0;
97
103 const Point & p,
104 DenseVector<Output> & output);
105
112 virtual void operator() (const FEMContext &,
113 const Point & p,
114 const Real time,
115 DenseVector<Output> & output) = 0;
116
129 virtual Output component(const FEMContext &,
130 unsigned int i,
131 const Point & p,
132 Real time=0.);
133};
134
135template <typename Output>
136inline
138 unsigned int i,
139 const Point & p,
140 Real time)
141{
142 DenseVector<Output> outvec(i+1);
143 (*this)(context, p, time, outvec);
144 return outvec(i);
145}
146
147template <typename Output>
148inline
150 const Point & p,
151 DenseVector<Output> & output)
152{
153 // Call the time-dependent function with t=0.
154 this->operator()(context, p, 0., output);
155}
156
157} // namespace libMesh
158
159#endif // LIBMESH_FEM_FUNCTION_BASE_H
Defines a dense vector for use in Finite Element-type computations.
This class provides all data required for a physics package (e.g.
Definition fem_context.h:63
FEMFunctionBase is a base class from which users can derive in order to define "function-like" object...
FEMFunctionBase(FEMFunctionBase &&)=default
The 5 special functions can be defaulted for this class.
FEMFunctionBase(const FEMFunctionBase &)=default
virtual void init_context(const FEMContext &)
Prepares a context object for use.
FEMFunctionBase()=default
Constructor.
virtual std::unique_ptr< FEMFunctionBase< Output > > clone() const =0
virtual ~FEMFunctionBase()=default
virtual Output operator()(const FEMContext &, const Point &p, const Real time=0.)=0
FEMFunctionBase & operator=(const FEMFunctionBase &)=default
virtual Output component(const FEMContext &, unsigned int i, const Point &p, Real time=0.)
virtual void init()
Any post-construction initialization.
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:40
The libMesh namespace provides an interface to certain functionality in the library.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real