GetFEM++  5.3
getfem_generic_assembly_functions_and_operators.h
1 /*===========================================================================
2 
3  Copyright (C) 2013-2018 Yves Renard
4 
5  This file is a part of GetFEM++
6 
7  GetFEM++ is free software; you can redistribute it and/or modify it
8  under the terms of the GNU Lesser General Public License as published
9  by the Free Software Foundation; either version 3 of the License, or
10  (at your option) any later version along with the GCC Runtime Library
11  Exception either version 3.1 or (at your option) any later version.
12  This program is distributed in the hope that it will be useful, but
13  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15  License and GCC Runtime Library Exception for more details.
16  You should have received a copy of the GNU Lesser General Public License
17  along with this program; if not, write to the Free Software Foundation,
18  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19 
20  As a special exception, you may use this file as it is a part of a free
21  software library without restriction. Specifically, if other files
22  instantiate templates or use macros or inline functions from this file,
23  or you compile this file and link it with other files to produce an
24  executable, this file does not by itself cause the resulting executable
25  to be covered by the GNU Lesser General Public License. This exception
26  does not however invalidate any other reasons why the executable file
27  might be covered by the GNU Lesser General Public License.
28 
29 ===========================================================================*/
30 
31 /** @file getfem_generic_assembly_tree.h
32  @author Yves Renard <Yves.Renard@insa-lyon.fr>
33  @date November 18, 2013.
34  @brief Definition of functions and basic operators of the assembly language
35  */
36 
37 
38 #ifndef GETFEM_GENERIC_ASSEMBLY_FUNC_OP_H__
39 #define GETFEM_GENERIC_ASSEMBLY_FUNC_OP_H__
40 
42 
43 namespace getfem {
44 
45  struct ga_instruction_set;
46  using instruction_set = omp_distribute<ga_instruction_set>;
47 
48  class ga_predef_function {
49  size_type ftype_; // 0 : C++ function with C++ derivative(s)
50  // 1 : function defined by an string expression.
51 
52  size_type dtype_; // 0 : no derivative(s)
53  // 1 : derivative(s) given by C++ functions
54  // 2 : derivatives(s) given by string expression(s)
55  // 3 : derivatives(s) to be symbolically computed.
56  size_type nbargs_; // One or two arguments
57  pscalar_func_onearg f1_; // Function pointer for a one argument function
58  pscalar_func_twoargs f2_; // Function pointer for a two arguments function
59  std::string expr_;
60  std::string derivative1_, derivative2_;
61  mutable omp_distribute<base_vector> t, u;
62  mutable omp_distribute<ga_workspace> workspace;
63  copyable_ptr<instruction_set> gis;
64 
65  friend void ga_define_function(const std::string &name, size_type nbargs,
66  const std::string &expr,
67  const std::string &der1,
68  const std::string &der2);
69  friend void ga_define_function(const std::string &name,
70  pscalar_func_onearg f,
71  const std::string &der);
72  friend void ga_define_function(const std::string &name,
73  pscalar_func_twoargs f,
74  const std::string &der1,
75  const std::string &der2);
76  public:
77  scalar_type operator()(scalar_type t_, scalar_type u_ = 0.) const;
78 
79  bool is_affine(const std::string &varname) const;
80 
81  size_type ftype() const { return ftype_;}
82  size_type dtype() const { return dtype_;}
83  size_type nbargs() const { return nbargs_;}
84  const std::string &derivative1() const { return derivative1_;}
85  const std::string &derivative2() const { return derivative2_;}
86  const std::string &expr() const { return expr_;}
87  pscalar_func_onearg f1() const { return f1_;}
88  pscalar_func_twoargs f2() const { return f2_;}
89 
90  ga_predef_function();
91  ga_predef_function(pscalar_func_onearg f, size_type dtype__ = 0,
92  const std::string &der = "");
93  ga_predef_function(pscalar_func_twoargs f, size_type dtype__ = 0,
94  const std::string &der1 = "",
95  const std::string &der2 = "");
96  ga_predef_function(const std::string &expr__);
97  };
98 
99  struct ga_predef_function_tab
100  : public std::map<std::string, ga_predef_function> {
101 
102  ga_predef_function_tab();
103  };
104 
105  struct ga_spec_function_tab : public std::set<std::string> {
106  ga_spec_function_tab();
107  };
108 
109  struct ga_spec_op_tab : public std::set<std::string> {
110  ga_spec_op_tab();
111  };
112 
113 } /* end of namespace */
114 
115 
116 #endif /* GETFEM_GENERIC_ASSEMBLY_FUNC_OP_H__ */
size_t size_type
used as the common size type in the library
Definition: bgeot_poly.h:49
GEneric Tool for Finite Element Methods.
Compilation and execution operations.