GetFEM++  5.3
getfem_generic_assembly.h
Go to the documentation of this file.
1 /* -*- c++ -*- (enables emacs c++ mode) */
2 /*===========================================================================
3 
4  Copyright (C) 2013-2017 Yves Renard
5 
6  This file is a part of GetFEM++
7 
8  GetFEM++ is free software; you can redistribute it and/or modify it
9  under the terms of the GNU Lesser General Public License as published
10  by the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version along with the GCC Runtime Library
12  Exception either version 3.1 or (at your option) any later version.
13  This program is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16  License and GCC Runtime Library Exception for more details.
17  You should have received a copy of the GNU Lesser General Public License
18  along with this program; if not, write to the Free Software Foundation,
19  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20 
21  As a special exception, you may use this file as it is a part of a free
22  software library without restriction. Specifically, if other files
23  instantiate templates or use macros or inline functions from this file,
24  or you compile this file and link it with other files to produce an
25  executable, this file does not by itself cause the resulting executable
26  to be covered by the GNU Lesser General Public License. This exception
27  does not however invalidate any other reasons why the executable file
28  might be covered by the GNU Lesser General Public License.
29 
30 ===========================================================================*/
31 
32 /** @file getfem_generic_assembly.h
33  @author Yves Renard <Yves.Renard@insa-lyon.fr>
34  @date November 18, 2013.
35  @brief A langage for generic assembly of pde boundary value problems.
36  */
37 
38 
39 #ifndef GETFEM_GENERIC_ASSEMBLY_H__
40 #define GETFEM_GENERIC_ASSEMBLY_H__
41 
42 #include <map>
45 
46 
47 #ifdef _WIN32
48 #include <limits>
49 #if defined(INFINITY)
50 #undef INFINITY
51 #endif
52 #define INFINITY std::numeric_limits<scalar_type>::infinity()
53 #endif
54 
55 namespace getfem {
56 
57  struct ga_tree;
58  class model;
59  class ga_workspace;
60 
61  typedef gmm::rsvector<scalar_type> model_real_sparse_vector;
62  typedef gmm::rsvector<complex_type> model_complex_sparse_vector;
63  typedef std::vector<scalar_type> model_real_plain_vector;
64  typedef std::vector<complex_type> model_complex_plain_vector;
65 
66  typedef gmm::col_matrix<model_real_sparse_vector> model_real_sparse_matrix;
67  typedef gmm::col_matrix<model_complex_sparse_vector>
68  model_complex_sparse_matrix;
69 
70  typedef gmm::row_matrix<model_real_sparse_vector>
71  model_real_row_sparse_matrix;
72  typedef gmm::row_matrix<model_complex_sparse_vector>
73  model_complex_row_sparse_matrix;
74 
75  // 0 : ok
76  // 1 : function or operator name or "X"
77  // 2 : reserved prefix Grad, Hess, Div, Test and Test2
78  int ga_check_name_validity(const std::string &name);
79 
80  //=========================================================================
81  // Virtual interpolate_transformation object.
82  //=========================================================================
83 
84  struct var_trans_pair {
85  std::string varname, transname;
86  bool operator <(const var_trans_pair &vt) const {
87  return (varname < vt.varname) ||
88  (!(varname > vt.varname) && transname < vt.transname);
89  }
90  var_trans_pair() : varname(), transname() {}
91  var_trans_pair(const std::string &v, const std::string &t)
92  : varname(v), transname(t) {}
93  };
94 
95  class APIDECL virtual_interpolate_transformation {
96 
97  public:
98  virtual void extract_variables
99  (const ga_workspace &workspace, std::set<var_trans_pair> &vars,
100  bool ignore_data, const mesh &m,
101  const std::string &interpolate_name) const = 0;
102  virtual void init(const ga_workspace &workspace) const = 0;
103  virtual int transform
104  (const ga_workspace &workspace, const mesh &m,
105  fem_interpolation_context &ctx_x, const base_small_vector &Normal,
106  const mesh **m_t, size_type &cv, short_type &face_num,
107  base_node &P_ref, base_small_vector &N_y,
108  std::map<var_trans_pair, base_tensor> &derivatives,
109  bool compute_derivatives) const = 0;
110  virtual void finalize() const = 0;
111  virtual std::string expression(void) const { return std::string(); }
112 
113  virtual ~virtual_interpolate_transformation() {}
114  };
115 
116  typedef std::shared_ptr<const virtual_interpolate_transformation>
117  pinterpolate_transformation;
118 
119  //=========================================================================
120  // Virtual elementary_transformation object.
121  //=========================================================================
122 
123  class APIDECL virtual_elementary_transformation {
124 
125  public:
126 
127  virtual void give_transformation(const mesh_fem &mf, size_type cv,
128  base_matrix &M) const = 0;
129  virtual ~virtual_elementary_transformation() {}
130  };
131 
132  typedef std::shared_ptr<const virtual_elementary_transformation>
133  pelementary_transformation;
134 
135  //=========================================================================
136  // Structure dealing with macros.
137  //=========================================================================
138 
139  class ga_macro {
140 
141  protected:
142  ga_tree *ptree;
143  std::string macro_name_;
144  size_type nbp;
145 
146  public:
147  ga_macro();
148  ga_macro(const std::string &name, const ga_tree &t, size_type nbp_);
149  ga_macro(const ga_macro &);
150  ~ga_macro();
151  ga_macro &operator =(const ga_macro &);
152 
153  const std::string &name() const { return macro_name_; }
154  std::string &name() { return macro_name_; }
155  size_type nb_params() const { return nbp; }
156  size_type &nb_params() { return nbp; }
157  const ga_tree& tree() const { return *ptree; }
158  ga_tree& tree() { return *ptree; }
159  };
160 
161 
162  class ga_macro_dictionnary {
163 
164  protected:
165  const ga_macro_dictionnary *parent;
166  std::map<std::string, ga_macro> macros;
167 
168  public:
169  bool macro_exists(const std::string &name) const;
170  const ga_macro &get_macro(const std::string &name) const;
171 
172  void add_macro(const ga_macro &gam);
173  void add_macro(const std::string &name, const std::string &expr);
174  void del_macro(const std::string &name);
175 
176  ga_macro_dictionnary() : parent(0) {}
177  ga_macro_dictionnary(bool, const ga_macro_dictionnary& gamd)
178  : parent(&gamd) {}
179 
180  };
181 
182  //=========================================================================
183  // Structure dealing with predefined operators.
184  //=========================================================================
185 
186 
187  struct ga_nonlinear_operator {
188 
189  typedef std::vector<const base_tensor *> arg_list;
190 
191  virtual bool result_size(const arg_list &args,
192  bgeot::multi_index &sizes) const = 0;
193 
194  virtual void value(const arg_list &args, base_tensor &result) const = 0;
195 
196  virtual void derivative(const arg_list &args, size_type i,
197  base_tensor &result) const = 0;
198 
199  virtual void second_derivative(const arg_list &args, size_type i,
200  size_type j, base_tensor &result) const = 0;
201 
202  virtual ~ga_nonlinear_operator() {}
203  };
204 
205  struct ga_predef_operator_tab {
206  typedef std::map<std::string, std::shared_ptr<ga_nonlinear_operator>> T;
207  T tab;
208 
209  void add_method(const std::string &name,
210  const std::shared_ptr<ga_nonlinear_operator> &pt)
211  { tab[name] = pt; }
212  ga_predef_operator_tab();
213  };
214 
215  //=========================================================================
216  // For user predefined scalar functions.
217  //=========================================================================
218 
219  typedef scalar_type (*pscalar_func_onearg)(scalar_type);
220  typedef scalar_type (*pscalar_func_twoargs)(scalar_type, scalar_type);
221 
222  void ga_define_function(const std::string &name, size_type nb_args,
223  const std::string &expr, const std::string &der1="",
224  const std::string &der2="");
225  void ga_define_function(const std::string &name, pscalar_func_onearg f,
226  const std::string &der1="");
227  void ga_define_function(const std::string &name, pscalar_func_twoargs f2,
228  const std::string &der1="",
229  const std::string &der2="");
230 
231  void ga_undefine_function(const std::string &name);
232  bool ga_function_exists(const std::string &name);
233 
234  //=========================================================================
235  // Structure dealing with user defined environment : constant, variables,
236  // functions, operators.
237  //=========================================================================
238 
239  class ga_workspace {
240 
241  const model *md;
242  const ga_workspace *parent_workspace;
243  bool enable_all_md_variables;
244 
245  void init();
246 
247  struct var_description {
248 
249  bool is_variable;
250  bool is_fem_dofs;
251  const mesh_fem *mf;
252  gmm::sub_interval I;
253  const model_real_plain_vector *V;
254  const im_data *imd;
255  bgeot::multi_index qdims; // For data having a qdim != of the fem
256  // (dim per dof for dof data)
257  // and for constant variables.
258 
259  size_type qdim() const {
260  size_type q = 1;
261  for (size_type i = 0; i < qdims.size(); ++i) q *= qdims[i];
262  return q;
263  }
264 
265  var_description(bool is_var, bool is_fem,
266  const mesh_fem *mmf, gmm::sub_interval I_,
267  const model_real_plain_vector *v, const im_data *imd_,
268  size_type Q)
269  : is_variable(is_var), is_fem_dofs(is_fem), mf(mmf), I(I_), V(v),
270  imd(imd_), qdims(1) {
271  GMM_ASSERT1(Q > 0, "Bad dimension");
272  qdims[0] = Q;
273  }
274  var_description() : is_variable(false), is_fem_dofs(false),
275  mf(0), V(0), imd(0), qdims(1) { qdims[0] = 1; }
276  };
277 
278  public:
279 
280  struct tree_description { // CAUTION: Specific copy constructor
281  size_type order; // 0: potential, 1: weak form, 2: tangent operator
282  // -1 : interpolation/ assignment all order,
283  // -2 : assignment on potential, -3 : assignment on weak form
284  // -3 : assignment on tangent operator
285  size_type interpolation; // O : assembly, 1 : interpolate before assembly
286  // 2 : interpolate after assembly.
287  std::string varname_interpolation; // Where to interpolate
288  std::string name_test1, name_test2;
289  std::string interpolate_name_test1, interpolate_name_test2;
290  const mesh_im *mim;
291  const mesh *m;
292  const mesh_region *rg;
293  ga_tree *ptree;
294  tree_description()
295  : interpolation(0), varname_interpolation(""),
296  name_test1(""), name_test2(""),
297  interpolate_name_test1(""), interpolate_name_test2(""),
298  mim(0), m(0), rg(0), ptree(0) {}
299  void copy(const tree_description& td);
300  tree_description(const tree_description& td) { copy(td); }
301  tree_description &operator =(const tree_description& td);
302  ~tree_description();
303  };
304 
305  mutable std::set<var_trans_pair> test1, test2;
306  var_trans_pair selected_test1, selected_test2;
307 
308  private:
309 
310  // mesh regions
311  std::map<const mesh *, std::list<mesh_region> > registred_mesh_regions;
312 
313  const mesh_region &
314  register_region(const mesh &m, const mesh_region &region);
315 
316  // variables and variable groups
317  mutable std::map<std::string, gmm::sub_interval> int_disabled_variables;
318 
319  typedef std::map<std::string, var_description> VAR_SET;
320  VAR_SET variables;
321  std::map<std::string, pinterpolate_transformation> transformations;
322  std::map<std::string, pelementary_transformation> elem_transformations;
323  std::vector<tree_description> trees;
324 
325  std::map<std::string, std::vector<std::string> > variable_groups;
326 
327  ga_macro_dictionnary macro_dict;
328 
329  struct m_tree {
330  ga_tree *ptree;
331  size_type meshdim;
332  bool ignore_X;
333  m_tree() : ptree(0), meshdim(-1), ignore_X(false) {}
334  m_tree(const m_tree& o);
335  m_tree &operator =(const m_tree& o);
336  ~m_tree();
337  };
338 
339  void add_tree(ga_tree &tree, const mesh &m, const mesh_im &mim,
340  const mesh_region &rg,
341  const std::string &expr, size_type add_derivative_order,
342  bool scalar_expr, size_type for_interpolation,
343  const std::string varname_interpolation);
344 
345 
346  std::shared_ptr<model_real_sparse_matrix> K;
347  model_real_sparse_matrix unreduced_K;
348  std::shared_ptr<base_vector> V;
349  base_vector unreduced_V;
350  base_tensor assemb_t;
351  bool include_empty_int_pts = false;
352 
353  public:
354 
355  const model_real_sparse_matrix &assembled_matrix() const { return *K;}
356  model_real_sparse_matrix &assembled_matrix() { return *K; }
357  scalar_type &assembled_potential()
358  { GMM_ASSERT1(assemb_t.size() == 1, "Bad result size"); return assemb_t[0]; }
359  const scalar_type &assembled_potential() const
360  { GMM_ASSERT1(assemb_t.size() == 1, "Bad result size"); return assemb_t[0]; }
361  const base_vector &assembled_vector() const { return *V; }
362  base_vector &assembled_vector() { return *V; }
363  void set_assembled_matrix(model_real_sparse_matrix &K_) {
364  K = std::shared_ptr<model_real_sparse_matrix>
365  (std::shared_ptr<model_real_sparse_matrix>(), &K_);
366  }
367  void set_assembled_vector(base_vector &V_) {
368  V = std::shared_ptr<base_vector>
369  (std::shared_ptr<base_vector>(), &V_);
370  }
371  base_tensor &assembled_tensor() { return assemb_t; }
372  const base_tensor &assembled_tensor() const { return assemb_t; }
373 
374  model_real_sparse_matrix &unreduced_matrix()
375  { return unreduced_K; }
376  base_vector &unreduced_vector() { return unreduced_V; }
377 
378  /** Add an expression, perform the semantic analysis, split into
379  * terms in separated test functions, derive if necessary to obtain
380  * the tangent terms. Return the maximal order found in the expression.
381  */
382  size_type add_expression(const std::string &expr, const mesh_im &mim,
383  const mesh_region &rg=mesh_region::all_convexes(),
384  size_type add_derivative_order = 2);
385  /* Internal use */
386  void add_function_expression(const std::string &expr);
387  /* Internal use */
388  void add_interpolation_expression
389  (const std::string &expr, const mesh &m,
390  const mesh_region &rg = mesh_region::all_convexes());
391  void add_interpolation_expression
392  (const std::string &expr, const mesh_im &mim,
393  const mesh_region &rg = mesh_region::all_convexes());
394  void add_assignment_expression
395  (const std::string &dataname, const std::string &expr,
396  const mesh_region &rg_ = mesh_region::all_convexes(),
397  size_type order = 1, bool before = false);
398 
399  /** Delete all previously added expressions. */
400  void clear_expressions();
401 
402  /** Print some information about all previously added expressions. */
403  void print(std::ostream &str);
404 
405  size_type nb_trees() const;
406  tree_description &tree_info(size_type i);
407 
408  // variables and variable groups
409  void add_fem_variable(const std::string &name, const mesh_fem &mf,
410  const gmm::sub_interval &I,
411  const model_real_plain_vector &VV);
412  void add_fixed_size_variable(const std::string &name,
413  const gmm::sub_interval &I,
414  const model_real_plain_vector &VV);
415  void add_fem_constant(const std::string &name, const mesh_fem &mf,
416  const model_real_plain_vector &VV);
417  void add_fixed_size_constant(const std::string &name,
418  const model_real_plain_vector &VV);
419  void add_im_data(const std::string &name, const im_data &imd,
420  const model_real_plain_vector &VV);
421 
422  bool used_variables(std::vector<std::string> &vl,
423  std::vector<std::string> &vl_test1,
424  std::vector<std::string> &vl_test2,
425  std::vector<std::string> &dl,
426  size_type order);
427 
428  bool variable_exists(const std::string &name) const;
429 
430  const std::string &variable_in_group(const std::string &group_name,
431  const mesh &m) const;
432 
433  void define_variable_group(const std::string &group_name,
434  const std::vector<std::string> &nl);
435 
436  bool variable_group_exists(const std::string &name) const;
437 
438  bool variable_or_group_exists(const std::string &name) const
439  { return variable_exists(name) || variable_group_exists(name); }
440 
441  const std::vector<std::string> &
442  variable_group(const std::string &group_name) const;
443 
444  const std::string& first_variable_of_group(const std::string &name) const;
445 
446  bool is_constant(const std::string &name) const;
447 
448  bool is_disabled_variable(const std::string &name) const;
449 
450  const scalar_type &factor_of_variable(const std::string &name) const;
451 
452  const gmm::sub_interval &
453  interval_of_disabled_variable(const std::string &name) const;
454 
455  const gmm::sub_interval &
456  interval_of_variable(const std::string &name) const;
457 
458  const mesh_fem *associated_mf(const std::string &name) const;
459 
460  const im_data *associated_im_data(const std::string &name) const;
461 
462  size_type qdim(const std::string &name) const;
463 
464  bgeot::multi_index qdims(const std::string &name) const;
465 
466  const model_real_plain_vector &value(const std::string &name) const;
467  scalar_type get_time_step() const;
468 
469  // macros
470  bool macro_exists(const std::string &name) const
471  { return macro_dict.macro_exists(name); }
472 
473  void add_macro(const std::string &name, const std::string &expr)
474  { macro_dict.add_macro(name, expr); }
475 
476  void del_macro(const std::string &name) { macro_dict.del_macro(name); }
477 
478  const std::string& get_macro(const std::string &name) const;
479 
480  const ga_macro_dictionnary &macro_dictionnary() const { return macro_dict; }
481 
482 
483  // interpolate and elementary transformations
484  void add_interpolate_transformation(const std::string &name,
485  pinterpolate_transformation ptrans);
486 
487  bool interpolate_transformation_exists(const std::string &name) const;
488 
489  pinterpolate_transformation
490  interpolate_transformation(const std::string &name) const;
491 
492  void add_elementary_transformation(const std::string &name,
493  pelementary_transformation ptrans)
494  { elem_transformations[name] = ptrans; }
495 
496  bool elementary_transformation_exists(const std::string &name) const;
497 
498  pelementary_transformation
499  elementary_transformation(const std::string &name) const;
500 
501 
502  // extract terms
503  std::string extract_constant_term(const mesh &m);
504  std::string extract_order1_term(const std::string &varname);
505  std::string extract_order0_term();
506  std::string extract_Neumann_term(const std::string &varname);
507 
508 
509  void assembly(size_type order);
510 
511  void set_include_empty_int_points(bool include);
512  bool include_empty_int_points() const;
513 
514  ga_workspace(const getfem::model &md_, bool enable_all_variables = false);
515  ga_workspace(bool, const ga_workspace &gaw);
516  ga_workspace();
517  ~ga_workspace();
518 
519  };
520 
521  // Small tool to make basic substitutions into an assembly string
522  std::string ga_substitute(const std::string &expr,
523  const std::map<std::string, std::string> &dict);
524 
525  inline std::string ga_substitute(const std::string &expr,
526  const std::string &o1,const std::string &s1) {
527  std::map<std::string, std::string> dict;
528  dict[o1] = s1;
529  return ga_substitute(expr, dict);
530  }
531 
532  inline std::string ga_substitute(const std::string &expr,
533  const std::string &o1,const std::string &s1,
534  const std::string &o2,const std::string &s2) {
535  std::map<std::string, std::string> dict;
536  dict[o1] = s1; dict[o2] = s2;
537  return ga_substitute(expr, dict);
538  }
539 
540  inline std::string ga_substitute(const std::string &expr,
541  const std::string &o1,const std::string &s1,
542  const std::string &o2,const std::string &s2,
543  const std::string &o3,const std::string &s3) {
544  std::map<std::string, std::string> dict;
545  dict[o1] = s1; dict[o2] = s2; dict[o3] = s3;
546  return ga_substitute(expr, dict);
547  }
548 
549  inline std::string ga_substitute(const std::string &expr,
550  const std::string &o1,const std::string &s1,
551  const std::string &o2,const std::string &s2,
552  const std::string &o3,const std::string &s3,
553  const std::string &o4,const std::string &s4) {
554  std::map<std::string, std::string> dict;
555  dict[o1] = s1; dict[o2] = s2; dict[o3] = s3; dict[o4] = s4;
556  return ga_substitute(expr, dict);
557  }
558 
559 
560  //=========================================================================
561  // Intermediate structure for user function manipulation
562  //=========================================================================
563 
564  struct ga_instruction_set;
565 
566  class ga_function {
567  mutable ga_workspace local_workspace;
568  std::string expr;
569  mutable ga_instruction_set *gis;
570 
571  public:
572  ga_function() : local_workspace(), expr(""), gis(0) {}
573  ga_function(const model &md, const std::string &e);
574  ga_function(const ga_workspace &workspace_, const std::string &e);
575  ga_function(const std::string &e);
576  ga_function(const ga_function &gaf);
577  ga_function &operator =(const ga_function &gaf);
578  ~ga_function();
579  const std::string &expression() const { return expr; }
580  const base_tensor &eval() const;
581  void derivative(const std::string &variable);
582  void compile() const;
583  ga_workspace &workspace() const { return local_workspace; }
584 
585  };
586 
587  //=========================================================================
588  // Intermediate structure for interpolation functions
589  //=========================================================================
590 
591  struct ga_interpolation_context {
592 
593  virtual bgeot::pstored_point_tab
594  ppoints_for_element(size_type cv, short_type f,
595  std::vector<size_type> &ind) const = 0;
596  inline const bgeot::stored_point_tab &points_for_element
597  (size_type cv, short_type f, std::vector<size_type> &ind) const
598  { return *ppoints_for_element(cv, f, ind); }
599  virtual bool use_pgp(size_type cv) const = 0;
600  virtual bool use_mim() const = 0;
601  virtual void store_result(size_type cv, size_type i, base_tensor &t) = 0;
602  virtual void finalize() = 0;
603  virtual const mesh &linked_mesh() = 0;
604  virtual ~ga_interpolation_context() {}
605  };
606 
607  //=========================================================================
608  // Interpolation functions
609  //=========================================================================
610 
611  void ga_interpolation(ga_workspace &workspace,
612  ga_interpolation_context &gic);
613 
614  void ga_interpolation_Lagrange_fem
615  (ga_workspace &workspace, const mesh_fem &mf, base_vector &result);
616 
617  void ga_interpolation_Lagrange_fem
618  (const getfem::model &md, const std::string &expr, const mesh_fem &mf,
619  base_vector &result, const mesh_region &rg=mesh_region::all_convexes());
620 
621  void ga_interpolation_mti
622  (const getfem::model &md, const std::string &expr, mesh_trans_inv &mti,
623  base_vector &result, const mesh_region &rg=mesh_region::all_convexes(),
624  int extrapolation = 0,
625  const mesh_region &rg_source=mesh_region::all_convexes(),
626  size_type nbdof_ = size_type(-1));
627 
628  void ga_interpolation_im_data
629  (ga_workspace &workspace, const im_data &imd, base_vector &result);
630 
631  void ga_interpolation_im_data
632  (const getfem::model &md, const std::string &expr, const im_data &imd,
633  base_vector &result, const mesh_region &rg=mesh_region::all_convexes());
634 
635  void ga_interpolation_mesh_slice
636  (ga_workspace &workspace, const stored_mesh_slice &sl, base_vector &result);
637 
638  void ga_interpolation_mesh_slice
639  (const getfem::model &md, const std::string &expr, const stored_mesh_slice &sl,
640  base_vector &result, const mesh_region &rg=mesh_region::all_convexes());
641 
642 
643  //=========================================================================
644  // Local projection functions
645  //=========================================================================
646 
647  /** Make an elementwise L2 projection of an expression with respect
648  to the mesh_fem `mf`. This mesh_fem has to be a discontinuous one.
649  The expression has to be valid according to the high-level generic
650  assembly language possibly including references to the variables
651  and data of the model.
652  */
653  void ga_local_projection(const getfem::model &md, const mesh_im &mim,
654  const std::string &expr, const mesh_fem &mf,
655  base_vector &result,
656  const mesh_region &rg=mesh_region::all_convexes());
657 
658  //=========================================================================
659  // Interpolate transformations
660  //=========================================================================
661 
662  /** Add a transformation to a workspace `workspace` or a model `md` mapping
663  point in mesh `source_mesh` to mesh `target_mesh`, optionally restricted
664  to the region `target_region`. The transformation is defined by the
665  expression `expr`, which has to be in the high-level generic assembly
666  syntax and may contain some variables of the workspace/model.
667  CAUTION: For the moment, the derivative of the transformation with
668  respect to any of these variables is not taken into account in the model
669  solve.
670  */
672  (ga_workspace &workspace, const std::string &transname,
673  const mesh &source_mesh, const mesh &target_mesh, const std::string &expr);
675  (ga_workspace &workspace, const std::string &transname,
676  const mesh &source_mesh, const mesh &target_mesh,
677  size_type target_region, const std::string &expr);
679  (model &md, const std::string &transname,
680  const mesh &source_mesh, const mesh &target_mesh, const std::string &expr);
682  (model &md, const std::string &transname,
683  const mesh &source_mesh, const mesh &target_mesh,
684  size_type target_region, const std::string &expr);
685 
686  /** Add a transformation to the workspace that creates an identity mapping
687  between two meshes in deformed state. Conceptually, it can be viewed
688  as a transformation from expression Xsource + Usource - Utarget,
689  except such an expression cannot be used directly in the transformation
690  from expression (function above), as Utarget needs to be interpolated
691  though an inversion of the transformation of the target domain.
692  Thread safe if added to thread local workspace.
693  */
695  (ga_workspace &workspace, const std::string &transname,
696  const mesh &source_mesh, const std::string &source_displacements,
697  const mesh_region &source_region, const mesh &target_mesh,
698  const std::string &target_displacements, const mesh_region &target_region);
699 
700  /** The same as above, but adding transformation to the model.
701  Note, this version is not thread safe.*/
703  (model &md, const std::string &transname,
704  const mesh &source_mesh, const std::string &source_displacements,
705  const mesh_region &source_region, const mesh &target_mesh,
706  const std::string &target_displacements, const mesh_region &target_region);
707 
708  /** Create a new instance of a transformation corresponding to the
709  interpolation on the neighbour element. Can only be applied to the
710  computation on some internal faces of a mesh.
711  (mainly for internal use in the constructor of getfem::model)
712  */
713  pinterpolate_transformation interpolate_transformation_neighbour_instance();
714 
715  /* Add a special interpolation transformation which represents the identity
716  transformation but allows to evaluate the expression on another element
717  than the current element by polynomial extrapolation. It is used for
718  stabilization term in fictitious domain applications. the map elt_cor
719  list the element concerned by the transformation and associate them
720  to the element on which the extrapolation has to be made. If an element
721  is not listed in elt_cor the evaluation is just made on the current
722  element.
723  */
724  void add_element_extrapolation_transformation
725  (model &md, const std::string &name, const mesh &sm,
726  std::map<size_type, size_type> &elt_corr);
727 
728  void add_element_extrapolation_transformation
729  (ga_workspace &workspace, const std::string &name, const mesh &sm,
730  std::map<size_type, size_type> &elt_corr);
731 
732  /* Change the correspondance map of an element extrapolation interpolate
733  transformation.
734  */
735  void set_element_extrapolation_correspondance
736  (model &md, const std::string &name,
737  std::map<size_type, size_type> &elt_corr);
738 
739  void set_element_extrapolation_correspondance
740  (ga_workspace &workspace, const std::string &name,
741  std::map<size_type, size_type> &elt_corr);
742 
743 
744 
745 
746 } /* end of namespace getfem. */
747 
748 
749 #endif /* GETFEM_GENERIC_ASSEMBLY_H__ */
void add_interpolate_transformation_on_deformed_domains(ga_workspace &workspace, const std::string &transname, const mesh &source_mesh, const std::string &source_displacements, const mesh_region &source_region, const mesh &target_mesh, const std::string &target_displacements, const mesh_region &target_region)
Add a transformation to the workspace that creates an identity mapping between two meshes in deformed...
void add_interpolate_transformation_from_expression(ga_workspace &workspace, const std::string &transname, const mesh &source_mesh, const mesh &target_mesh, const std::string &expr)
Add a transformation to a workspace workspace or a model md mapping point in mesh source_mesh to mesh...
static mesh_region all_convexes()
provide a default value for the mesh_region parameters of assembly procedures etc.
void interpolation(const mesh_fem &mf_source, const mesh_fem &mf_target, const VECTU &U, VECTV &V, int extrapolation=0, double EPS=1E-10, mesh_region rg_source=mesh_region::all_convexes(), mesh_region rg_target=mesh_region::all_convexes())
interpolation/extrapolation of (mf_source, U) on mf_target.
Point tab storage.
pinterpolate_transformation interpolate_transformation_neighbour_instance()
Create a new instance of a transformation corresponding to the interpolation on the neighbour element...
``Model&#39;&#39; variables store the variables, the data and the description of a model. ...
size_t size_type
used as the common size type in the library
Definition: bgeot_poly.h:49
void copy(const L1 &l1, L2 &l2)
*/
Definition: gmm_blas.h:977
Interpolation of fields from a mesh_fem onto another.
void ga_local_projection(const getfem::model &md, const mesh_im &mim, const std::string &expr, const mesh_fem &mf, base_vector &result, const mesh_region &rg=mesh_region::all_convexes())
Make an elementwise L2 projection of an expression with respect to the mesh_fem mf.
sparse vector built upon std::vector.
Definition: gmm_def.h:488
GEneric Tool for Finite Element Methods.
gmm::uint16_type short_type
used as the common short type integer in the library
Definition: bgeot_config.h:79
Define the class getfem::stored_mesh_slice.