37 #ifndef GETFEM_GENERIC_ASSEMBLY_COMP_EXEC_H__
38 #define GETFEM_GENERIC_ASSEMBLY_COMP_EXEC_H__
44 class ga_if_hierarchy :
public std::vector<size_type> {
47 void increment() { (back())++; }
48 void child_of(
const ga_if_hierarchy &gih) { *
this = gih; push_back(0); }
49 bool is_compatible(
const std::list<ga_if_hierarchy> &gihl) {
50 for (
const auto &gih : gihl) {
51 if (gih.size() <= size()) {
53 for (
size_type i = 0; i+1 < gih.size(); ++i)
54 if (gih[i] != (*
this)[i]) { ok =
false;
break; }
55 if (gih.back() > (*
this)[gih.size()-1]) { ok =
false;
break; }
62 ga_if_hierarchy() : std::vector<
size_type>(1) { (*this)[0] = 0; }
66 struct ga_instruction {
67 virtual int exec() = 0;
68 virtual ~ga_instruction() {};
71 typedef std::shared_ptr<ga_instruction> pga_instruction;
73 struct gauss_pt_corresp {
75 papprox_integration pai;
76 std::vector<size_type> nodes;
79 bool operator <(
const gauss_pt_corresp &gpc1,
80 const gauss_pt_corresp &gpc2);
82 struct ga_instruction_set {
84 papprox_integration pai;
85 fem_interpolation_context ctx;
86 base_small_vector Normal;
94 fem_precomp_pool fp_pool;
95 std::map<gauss_pt_corresp, bgeot::pstored_point_tab> neighbor_corresp;
96 std::set<std::pair<std::string,std::string>> unreduced_terms;
100 using region_mim_tuple = std::tuple<const mesh_im *, const mesh_region *, psecondary_domain>;
101 struct region_mim :
public region_mim_tuple {
102 const mesh_im* mim()
const {
return std::get<0>(
static_cast<region_mim_tuple
>(*
this));}
103 const mesh_region* region()
const {
return std::get<1>(
static_cast<region_mim_tuple
>(*
this));}
104 psecondary_domain psd()
const {
return std::get<2>(
static_cast<region_mim_tuple
>(*
this));}
106 region_mim(
const mesh_im *mim_,
const mesh_region *region_, psecondary_domain psd)
107 : region_mim_tuple(mim_, region_, psd) {}
110 std::map<std::string, const base_vector *> extended_vars;
111 std::map<std::string, base_vector> really_extended_vars;
113 struct variable_group_info {
114 const mesh *cached_mesh;
115 const std::string *varname;
118 const gmm::sub_interval *I;
121 const base_vector *U;
122 variable_group_info()
123 : cached_mesh(0), varname(0), mf(0), reduced_mf(false), I(0) {}
126 struct interpolate_info {
130 fem_interpolation_context ctx;
132 base_small_vector Normal;
134 std::map<std::string, variable_group_info> groups_info;
135 std::map<var_trans_pair, base_tensor> derivatives;
136 std::map<const mesh_fem *, pfem_precomp> pfps;
140 struct secondary_domain_info {
142 papprox_integration pai;
143 fem_interpolation_context ctx;
144 base_small_vector Normal;
146 std::map<std::string, base_vector> local_dofs;
147 std::map<const mesh_fem *, pfem_precomp> pfps;
148 std::map<const mesh_fem *, base_tensor> base;
149 std::map<const mesh_fem *, base_tensor> grad;
150 std::map<const mesh_fem *, base_tensor> hess;
154 struct elementary_trans_info {
159 std::set<std::string> transformations;
161 struct region_mim_instructions {
165 ga_if_hierarchy current_hierarchy;
166 std::map<std::string, base_vector> local_dofs;
167 std::map<const mesh_fem *, pfem_precomp> pfps;
168 std::map<const mesh_fem *, std::list<ga_if_hierarchy>> pfp_hierarchy;
169 std::map<const mesh_fem *, base_tensor> base;
170 std::map<const mesh_fem *, std::list<ga_if_hierarchy>> base_hierarchy;
171 std::map<const mesh_fem *, base_tensor> grad;
172 std::map<const mesh_fem *, std::list<ga_if_hierarchy>> grad_hierarchy;
173 std::map<const mesh_fem *, base_tensor> hess;
174 std::map<const mesh_fem *, std::list<ga_if_hierarchy>> hess_hierarchy;
176 std::map<const mesh_fem *, base_tensor>
177 xfem_plus_base, xfem_plus_grad, xfem_plus_hess,
178 xfem_minus_base, xfem_minus_grad, xfem_minus_hess;
179 std::map<const mesh_fem *, std::list<ga_if_hierarchy>>
180 xfem_plus_base_hierarchy, xfem_plus_grad_hierarchy,
181 xfem_plus_hess_hierarchy, xfem_minus_base_hierarchy,
182 xfem_minus_grad_hierarchy, xfem_minus_hess_hierarchy;
184 std::map<std::string, std::set<std::string>> transformations;
185 std::set<std::string> transformations_der;
186 std::map<std::string, interpolate_info> interpolate_infos;
187 std::map<std::tuple<std::string, const mesh_fem *, const mesh_fem *>,
188 elementary_trans_info> elementary_trans_infos;
189 secondary_domain_info secondary_domain_infos;
191 std::vector<pga_instruction>
197 std::map<scalar_type, std::list<pga_tree_node> > node_list;
199 region_mim_instructions(): m(0), im(0) {}
202 std::list<ga_tree> trees;
204 std::list<ga_tree> interpolation_trees;
206 std::map<region_mim, region_mim_instructions> all_instructions;
209 std::list<std::shared_ptr<base_tensor>> condensation_tensors;
211 ga_instruction_set() : need_elt_size(false), nbpt(0), ipt(0) {}
215 void ga_exec(ga_instruction_set &gis, ga_workspace &workspace);
216 void ga_function_exec(ga_instruction_set &gis);
217 void ga_compile(ga_workspace &workspace, ga_instruction_set &gis,
218 size_type order,
bool condensation=
false);
219 void ga_compile_function(ga_workspace &workspace,
220 ga_instruction_set &gis,
bool scalar);
221 void ga_compile_interpolation(ga_workspace &workspace,
222 ga_instruction_set &gis);
223 void ga_interpolation_exec(ga_instruction_set &gis,
224 ga_workspace &workspace,
225 ga_interpolation_context &gic);