libmesh解析
本工作只是尝试解析原libmesh的代码,供学习使用
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 
wrapped_function.h
浏览该文件的文档.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2023 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_WRAPPED_FUNCTION_H
21 #define LIBMESH_WRAPPED_FUNCTION_H
22 
23 // Local Includes
24 #include "libmesh/dense_vector.h"
25 #include "libmesh/equation_systems.h"
26 #include "libmesh/function_base.h"
27 #include "libmesh/libmesh_common.h"
28 #include "libmesh/point.h"
29 #include "libmesh/system.h"
30 
31 // C++ includes
32 #include <cstddef>
33 #include <memory>
34 
35 namespace libMesh
36 {
37 
49 template <typename Output=Number>
50 class WrappedFunction : public FunctionBase<Output>
51 {
52 public:
53 
61  WrappedFunction (const System & sys,
62  Output fptr(const Point & p,
63  const Parameters & parameters,
64  const std::string & sys_name,
65  const std::string & unknown_name) = nullptr,
66  const Parameters * parameters = nullptr,
67  unsigned int varnum=0)
68  : _sys(sys),
69  _fptr(fptr),
70  _parameters(parameters),
71  _varnum(varnum)
72  {
73  this->_initialized = true;
74  if (!parameters)
75  _parameters = &sys.get_equation_systems().parameters;
76  }
77 
81  WrappedFunction & operator= (const WrappedFunction &) = delete;
83 
87  WrappedFunction (WrappedFunction &&) = default;
88  WrappedFunction (const WrappedFunction &) = default;
89  virtual ~WrappedFunction () = default;
90 
95  virtual std::unique_ptr<FunctionBase<Output>> clone () const override;
96 
103  virtual Output operator() (const Point & p,
104  const Real time = 0.) override;
105 
112  virtual void operator() (const Point & p,
113  const Real time,
114  DenseVector<Output> & output) override;
115 
123  virtual Output component (unsigned int i,
124  const Point & p,
125  Real time=0.) override;
126 
127 protected:
128 
132  const System & _sys;
133 
137  Output (*_fptr)(const Point & p,
138  const Parameters & parameters,
139  const std::string & sys_name,
140  const std::string & unknown_name);
141 
146  const Parameters * _parameters;
147 
152  unsigned int _varnum;
153 };
154 
155 
156 
157 } // namespace libMesh
158 
159 #endif // LIBMESH_WRAPPED_FUNCTION_H
unsigned int _varnum
用于指示函数操作的变量编号。
将libMesh风格的函数指针封装成FunctionBase对象。
const System & _sys
引用一个System对象,用于评估函数的上下文。
virtual Output component(unsigned int i, const Point &p, Real time=0.) override
评估函数的特定分量值。
bool _initialized
当 init() 被调用以确保一切都准备好后,可以调用 operator() (...) 时为 true。
Output(* _fptr)(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name)
指向函数指针的指针,用于评估函数。
virtual Output operator()(const Point &p, const Real time=0.) override
评估函数在给定点和时间的值。
WrappedFunction & operator=(const WrappedFunction &)=delete
此类包含const引用,因此无法赋值。
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual ~WrappedFunction()=default
const Parameters * _parameters
指向函数参数的指针。
WrappedFunction(const System &sys, Output fptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name)=nullptr, const Parameters *parameters=nullptr, unsigned int varnum=0)
用于封装标量值函数指针的构造函数。
FunctionBase是一个函数对象的基类,可以在某一点(可选地包括时间)进行评估。
virtual std::unique_ptr< FunctionBase< Output > > clone() const override
创建此对象的副本。