20 #ifndef LIBMESH_FUNCTION_BASE_H
21 #define LIBMESH_FUNCTION_BASE_H
24 #include "libmesh/libmesh_common.h"
25 #include "libmesh/dense_vector.h"
60 template <
typename Output=Number>
102 virtual std::unique_ptr<FunctionBase<Output>>
clone ()
const = 0;
110 const Real time = 0.) = 0;
204 template<
typename Output>
208 _initialized (false),
209 _is_time_dependent (true)
214 template <
typename Output>
218 return (this->_initialized);
222 template <
typename Output>
226 this->_is_time_dependent = is_time_dependent;
230 template <
typename Output>
234 return (this->_is_time_dependent);
238 template <
typename Output>
245 (*this)(p, time, outvec);
250 template <
typename Output>
256 this->operator()(p, 0., output);
261 #endif // LIBMESH_FUNCTION_BASE_H
FunctionBase(const FunctionBase *master=nullptr)
构造函数。可选地接受一个master。
virtual Output component(unsigned int i, const Point &p, Real time=0.)
const FunctionBase * _master
指向我们的主函数对象的const指针,初始化为 nullptr。 可能存在需要多个函数的情况,但为了节省内存,一个主函数对象可以处理一些集中的数据。
bool _initialized
当 init() 被调用以确保一切都准备好后,可以调用 operator() (...) 时为 true。
virtual Output operator()(const Point &p, const Real time=0.)=0
virtual void init()
实际的初始化过程。
void set_is_time_dependent(bool is_time_dependent)
设置函数是否依赖时间的函数。 这仅应该由无法本地确定时间依赖性的子类使用。 在这种情况下,应在构造之后立即使用这个函数。
bool is_time_dependent() const
virtual ~FunctionBase()=default
bool _is_time_dependent
成员变量用于缓存函数是否真正依赖于时间。
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual std::unique_ptr< FunctionBase< Output > > clone() const =0
FunctionBase是一个函数对象的基类,可以在某一点(可选地包括时间)进行评估。
FunctionBase & operator=(const FunctionBase &)=default
virtual void clear()
清除函数。