GetFEM  5.4.3
getfem_generic_assembly_semantic.h
Go to the documentation of this file.
1 /*===========================================================================
2 
3  Copyright (C) 2013-2020 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_semantic.h
32  @author Yves Renard <[email protected]>
33  @date November 18, 2013.
34  @brief Semantic analysis of assembly trees and semantic manipulations.
35  */
36 
37 
38 #ifndef GETFEM_GENERIC_ASSEMBLY_SEMANTIC_H__
39 #define GETFEM_GENERIC_ASSEMBLY_SEMANTIC_H__
40 
42 
43 
44 namespace getfem {
45 
46  /* Performs the semantic analysis, tree simplification and tree enrichment
47  - Control tensor sizes for operations, operator or function call
48  - Compute all constant operations (i.e. non element dependent)
49  - Build a ready to use tree for derivation/compilation
50  option = 0 : strict analysis,
51  1 : do not complain about incompatible test functions but
52  store them,
53  2 : cut incompatible test function branches with respect to the
54  one in workspace.selected_pair
55  3 : do not complain about incompatible test functions neither
56  store them.
57  */
58  void ga_semantic_analysis(ga_tree &tree,
59  const ga_workspace &workspace,
60  const mesh &m,
61  size_type ref_elt_dim,
62  bool eval_fixed_size,
63  bool ignore_X, int option = 0);
64 
65  /* Extract the variables used in a sub-tree, ignoring or not the data.
66  Variable groups are taken into account. Return if at least one variable
67  as been detected or not */
68  bool ga_extract_variables(const pga_tree_node pnode,
69  const ga_workspace &workspace,
70  const mesh &m,
71  std::set<var_trans_pair> &vars,
72  bool ignore_data);
73 
74  /* Extract a sub tree which consists of the corresponding node and of
75  the terms multiplying this term, but not the term in addition.
76  The aim is to expand an expression is a sum of elementary factors.
77  Complains if a nonlinear term is encountered. */
78  void ga_extract_factor(ga_tree &result_tree, pga_tree_node pnode,
79  pga_tree_node &new_pnode);
80 
81  /* Extract the constant term of degree 1 expressions. */
82  bool ga_node_extract_constant_term
83  (ga_tree &tree, pga_tree_node pnode, const ga_workspace &workspace,
84  const mesh &m);
85 
86  /* Extract the Neumann term of an assembly tree with respect to a variable. */
87  void ga_extract_Neumann_term
88  (ga_tree &tree, const std::string &varname,
89  ga_workspace &workspace, pga_tree_node pnode, std::string &result);
90 
91 
92  /* Derivation of the tree with respect to a variable.
93  The tree is modified and should be copied first and passed to
94  ga_semantic_analysis after for enrichment. */
95  void ga_derivative(ga_tree &tree, const ga_workspace &workspace,
96  const mesh &m, const std::string &varname,
97  const std::string &interpolatename,
98  size_type order);
99 
100  std::string ga_derivative_scalar_function(const std::string &expr,
101  const std::string &var);
102 
103  bool ga_is_affine(const ga_tree &tree, const ga_workspace &workspace,
104  const std::string &varname,
105  const std::string &interpolatename);
106 
107  // Function of internal use
108  inline size_type ref_elt_dim_of_mesh(const mesh &m, const mesh_region &rg) {
109  auto v = getfem::mr_visitor(rg, m, true);
110  return v.finished() ? size_type(0) : m.trans_of_convex(v.cv())->dim();
111  }
112 
113 
114 } /* end of namespace */
115 
116 
117 #endif /* GETFEM_GENERIC_ASSEMBLY_TREE_H__ */
"iterator" class for regions.
Compilation and execution operations.
size_t size_type
used as the common size type in the library
Definition: bgeot_poly.h:49
GEneric Tool for Finite Element Methods.