libmesh解析
本工作只是尝试解析原libmesh的代码,供学习使用
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 
wrapped_functor.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_FUNCTOR_H
21 #define LIBMESH_WRAPPED_FUNCTOR_H
22 
23 // Local Includes
24 #include "libmesh/fem_function_base.h"
25 #include "libmesh/function_base.h"
26 #include "libmesh/point.h"
27 
28 // C++ includes
29 #include <cstddef>
30 #include <memory>
31 
32 namespace libMesh
33 {
34 
42 template <typename Output=Number>
43 class WrappedFunctor : public FEMFunctionBase<Output>
44 {
45 public:
46 
52  : _func(func.clone())
53  { }
54 
58  WrappedFunctor (const WrappedFunctor &) = delete;
59  WrappedFunctor & operator= (const WrappedFunctor &) = delete;
60 
64  WrappedFunctor (WrappedFunctor &&) = default;
66  virtual ~WrappedFunctor () = default;
67 
72  virtual std::unique_ptr<FEMFunctionBase<Output>> clone () const override
73  {
74  return std::make_unique<WrappedFunctor<Output>>(*_func);
75  }
76 
84  virtual Output operator() (const FEMContext & context,
85  const Point & p,
86  const Real time = 0.) override
87  { return _func->operator()(p, time); }
88 
96  virtual void operator() (const FEMContext & context,
97  const Point & p,
98  const Real time,
99  DenseVector<Output> & output) override
100  { _func->operator() (p, time, output); }
101 
110  virtual Output component (const FEMContext & context,
111  unsigned int i,
112  const Point & p,
113  Real time=0.) override
114  { return _func->component(i, p, time); }
115 
116 protected:
117 
118  std::unique_ptr<FunctionBase<Output>> _func;
119 };
120 
121 
122 
123 } // namespace libMesh
124 
125 #endif // LIBMESH_WRAPPED_FUNCTOR_H
WrappedFunctor & operator=(const WrappedFunctor &)=delete
virtual std::unique_ptr< FEMFunctionBase< Output > > clone() const override
克隆函数,用于创建此对象的副本。
virtual Output component(const FEMContext &context, unsigned int i, const Point &p, Real time=0.) override
用于计算函数在给定点、时间和分量索引的特定分量的值。
该类提供了一个包装器,用于在FunctionBase&lt;Output&gt;兼容接口中评估(libMesh风格的)函数指针。
std::unique_ptr< FunctionBase< Output > > _func
virtual ~WrappedFunctor()=default
virtual Output operator()(const FEMContext &context, const Point &p, const Real time=0.) override
用于计算函数在给定点和时间的值。
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
WrappedFunctor(const FunctionBase< Output > &func)
用于将FunctionBase函数包装在FEMFunctionBase兼容的shim中的构造函数。
FunctionBase是一个函数对象的基类,可以在某一点(可选地包括时间)进行评估。
FEMFunctionBase是一个基类,用户可以从中派生出“函数样式”的对象,以在FEMSystem中使用。