libmesh解析
本工作只是尝试解析原libmesh的代码,供学习使用
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 
parsed_function_parameter.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_PARSED_FUNCTION_PARAMETER_H
21 #define LIBMESH_PARSED_FUNCTION_PARAMETER_H
22 
23 
24 // Local Includes
25 #include "libmesh/libmesh_common.h"
26 #include "libmesh/parameter_accessor.h"
27 #include "libmesh/parsed_function.h"
28 
29 // C++ Includes
30 #include <memory>
31 
32 namespace libMesh
33 {
34 
45 template <typename T=Number>
46 class ParsedFunctionParameter : public ParameterAccessor<T>
47 {
48 public:
57  std::string param_name) :
58  _func(func_ref), _name(std::move(param_name)) {}
59 
63  virtual ParameterAccessor<T> &
64  operator= (T * /* new_ptr */) { libmesh_error(); return *this; }
65 
69  virtual void set (const T & new_value) override {
70  _func.set_inline_value(_name, new_value);
71  }
72 
76  virtual const T & get () const override {
78  return _current_val;
79  }
80 
84  virtual std::unique_ptr<ParameterAccessor<T>> clone() const override {
85  return std::make_unique<ParsedFunctionParameter<T>>(_func, _name);
86  }
87 
88 private:
90  std::string _name;
91 
92  // 我们需要从 get() 返回引用。这对于 libMesh::Number 来说是没有意义的,但是当我们处理字段参数时,这可能会变得有意义。
94 };
95 
96 } // namespace libMesh
97 
98 #endif // LIBMESH_PARSED_FUNCTION_PARAMETER_H
void set_inline_value(std::string_view inline_var_name, Output newval)
Changes the value of an inline variable.
virtual void set(const T &new_value) override
设置器:更改我们访问的参数的值。
Output get_inline_value(std::string_view inline_var_name) const
获取内联变量的值。
访问器对象,允许在参数敏感性计算中读取和修改参数的独立变量。
ParsedFunctionParameter(ParsedFunction< T > &func_ref, std::string param_name)
构造函数:接受要修改的函数和表示我们要访问的内联变量的名称。
virtual ParameterAccessor< T > & operator=(T *)
简单的重置器对于解析函数是无效的
virtual std::unique_ptr< ParameterAccessor< T > > clone() const override