libmesh解析
本工作只是尝试解析原libmesh的代码,供学习使用
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 
const_fem_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 #ifndef LIBMESH_CONST_FEM_FUNCTION_H
19 #define LIBMESH_CONST_FEM_FUNCTION_H
20 
21 // libMesh includes
22 #include "libmesh/dense_vector.h"
23 #include "libmesh/fem_function_base.h"
24 #include "libmesh/int_range.h"
25 
26 // C++ includes
27 #include <memory>
28 #include <string>
29 
30 namespace libMesh
31 {
32 
33 // Forward declarations
34 class Point;
35 
41 template <typename Output=Number>
42 class ConstFEMFunction : public FEMFunctionBase<Output>
43 {
44 public:
49  ConstFEMFunction (const Output c) : _c(c) {}
50 
54  ConstFEMFunction (ConstFEMFunction &&) = default;
55  ConstFEMFunction (const ConstFEMFunction &) = default;
56  ConstFEMFunction & operator= (const ConstFEMFunction &) = default;
58 
62  virtual ~ConstFEMFunction () = default;
63 
68  virtual std::unique_ptr<FEMFunctionBase<Output>> clone () const override
69  {return std::make_unique<ConstFEMFunction>(*this); }
70 
78  virtual Output operator() (const FEMContext & c,
79  const Point & p,
80  const Real /* time */ = 0.) override
81  { return _c; }
82 
90  virtual void operator() (const FEMContext & c,
91  const Point & p,
92  const Real,
93  DenseVector<Output> & output) override
94  {
95  // 将输出矢量的每个分量设置为常量值
96  for (auto i : index_range(output))
97  output(i) = _c;
98  }
99 
100 private:
101  Output _c; // 存储常量值
102 };
103 
104 } // namespace libMesh;
105 
106 
107 #endif // LIBMESH_CONST_FEM_FUNCTION_H
ConstFEMFunction(const Output c)
构造函数,用于初始化常量值。
virtual std::unique_ptr< FEMFunctionBase< Output > > clone() const override
克隆函数。创建并返回一个与当前实例相同类型的新实例。
virtual Output operator()(const FEMContext &c, const Point &p, const Real=0.) override
重载操作符,用于计算标量值。
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual ~ConstFEMFunction()=default
默认析构函数。
由Roy Stogner创作 2012年
ConstFEMFunction & operator=(const ConstFEMFunction &)=default
FEMFunctionBase是一个基类,用户可以从中派生出“函数样式”的对象,以在FEMSystem中使用。