39 #ifndef GETFEM_MODELS_H__ 
   40 #define GETFEM_MODELS_H__ 
   51   typedef std::shared_ptr<const virtual_brick> 
pbrick;
 
   54   typedef std::shared_ptr<const virtual_dispatcher> pdispatcher;
 
   57   typedef std::shared_ptr<const virtual_time_scheme> ptime_scheme;
 
   89   typedef model_real_plain_vector modeling_standard_plain_vector;
 
   91   typedef model_real_sparse_matrix modeling_standard_sparse_matrix;
 
   92   typedef model_complex_plain_vector modeling_standard_complex_plain_vector;
 
   94   typedef model_complex_sparse_matrix modeling_standard_complex_sparse_matrix;
 
   99   const auto PREFIX_OLD_LENGTH = 4;
 
  102   bool is_old(
const std::string &name);
 
  107   std::string sup_previous_and_dot_to_varname(std::string v);
 
  120     bool complex_version;
 
  124     mutable model_real_sparse_matrix
 
  127     mutable model_complex_sparse_matrix cTM; 
 
  128     mutable model_real_plain_vector
 
  132     mutable model_complex_plain_vector crhs;
 
  133     mutable bool act_size_to_be_done;
 
  134     dim_type leading_dim;
 
  135     getfem::lock_factory locks_;
 
  139     enum  var_description_filter {
 
  141       VDESCRFILTER_REGION = 1, 
 
  143       VDESCRFILTER_INFSUP = 2, 
 
  146       VDESCRFILTER_CTERM = 4, 
 
  149       VDESCRFILTER_REGION_CTERM = 5,  
 
  152     struct var_description {
 
  157       bool is_affine_dependent; 
 
  167       var_description_filter filter; 
 
  170       std::string filter_var;        
 
  175       ppartial_mesh_fem partial_mf;  
 
  178       bgeot::multi_index qdims;  
 
  181       gmm::uint64_type v_num;
 
  182       std::vector<gmm::uint64_type> v_num_data;
 
  187       std::vector<model_real_plain_vector> real_value;
 
  188       std::vector<model_complex_plain_vector> complex_value;
 
  189       std::vector<gmm::uint64_type> v_num_var_iter;
 
  190       std::vector<gmm::uint64_type> v_num_iter;
 
  193       model_real_plain_vector affine_real_value;
 
  194       model_complex_plain_vector affine_complex_value;
 
  196       std::string org_name; 
 
  199       var_description(
bool is_var = 
false, 
bool is_compl = 
false,
 
  202                       var_description_filter filter_ = VDESCRFILTER_NO,
 
  204                       const std::string &filter_var_ = std::string(
""),
 
  205                       mesh_im const *filter_mim_ = 0)
 
  206         : is_variable(is_var), is_disabled(
false), is_complex(is_compl),
 
  207           is_affine_dependent(
false), is_internal(
false),
 
  208           n_iter(std::max(
size_type(1), n_it)), n_temp_iter(0),
 
  209           default_iter(0), ptsc(0),
 
  210           filter(filter_), filter_region(filter_reg), filter_var(filter_var_),
 
  211           filter_mim(filter_mim_), mf(mf_), imd(imd_), qdims(),
 
  212           v_num(0), v_num_data(n_iter, act_counter()), I(0,0), alpha(1)
 
  214         if (filter != VDESCRFILTER_NO && mf != 0)
 
  215           partial_mf = std::make_shared<partial_mesh_fem>(*mf);
 
  217         if (qdims.size() == 0) qdims.push_back(1);
 
  218         GMM_ASSERT1(qdim(), 
"Attempt to create a null size variable");
 
  221       size_type qdim()
 const { 
return qdims.total_size(); }
 
  226       size_type add_temporary(gmm::uint64_type id_num);
 
  228       void clear_temporaries();
 
  230       const mesh_fem &associated_mf()
 const {
 
  231         GMM_ASSERT1(mf, 
"This variable is not linked to a fem");
 
  232         return (filter == VDESCRFILTER_NO) ? *mf : *partial_mf;
 
  235       const mesh_fem *passociated_mf()
 const {
 
  237           return (filter == VDESCRFILTER_NO || partial_mf.get() == 0)
 
  238                  ? mf : partial_mf.get();
 
  244         return is_complex ? complex_value[0].size()
 
  245                           : real_value[0].size();
 
  247       inline bool is_enabled()
 const { 
return !is_disabled; }
 
  254     typedef std::vector<std::string> varnamelist;
 
  255     typedef std::vector<const mesh_im *> mimlist;
 
  256     typedef std::vector<model_real_sparse_matrix> real_matlist;
 
  257     typedef std::vector<model_complex_sparse_matrix> complex_matlist;
 
  258     typedef std::vector<model_real_plain_vector> real_veclist;
 
  259     typedef std::vector<model_complex_plain_vector> complex_veclist;
 
  261     struct term_description {
 
  265       std::string var1, var2;
 
  267       term_description(
const std::string &v)
 
  268         : is_matrix_term(
false), is_symmetric(
false),
 
  269           is_global(
false), var1(sup_previous_and_dot_to_varname(v)) {}
 
  270       term_description(
const std::string &v1, 
const std::string &v2,
 
  272         : is_matrix_term(
true), is_symmetric(issym), is_global(
false),
 
  273           var1(sup_previous_and_dot_to_varname(v1)), var2(v2) {}
 
  274       term_description(
bool ism, 
bool issym)
 
  275         : is_matrix_term(ism), is_symmetric(issym), is_global(
true) {}
 
  278     typedef std::vector<term_description> termlist;
 
  284       BUILD_ON_DATA_CHANGE = 4,
 
  286       BUILD_RHS_WITH_LIN = 9,       
 
  287       BUILD_WITH_INTERNAL = 16,
 
  288       BUILD_RHS_WITH_INTERNAL = 17, 
 
  289       BUILD_MATRIX_CONDENSED = 18,  
 
  290       BUILD_ALL_CONDENSED = 19,     
 
  297     struct brick_description {
 
  298       mutable bool terms_to_be_computed;
 
  299       mutable gmm::uint64_type v_num;
 
  301       pdispatcher pdispatch;     
 
  308       bool is_update_brick;      
 
  310       mutable scalar_type external_load; 
 
  312       mutable model_real_plain_vector coeffs;
 
  313       mutable scalar_type matrix_coeff = scalar_type(0);
 
  315       mutable real_matlist rmatlist;
 
  317       mutable std::vector<real_veclist> rveclist;
 
  319       mutable std::vector<real_veclist> rveclist_sym;
 
  321       mutable complex_matlist cmatlist;
 
  323       mutable std::vector<complex_veclist> cveclist;
 
  325       mutable std::vector<complex_veclist> cveclist_sym;
 
  327       brick_description() : v_num(0) {}
 
  329       brick_description(
pbrick p, 
const varnamelist &vl,
 
  330                         const varnamelist &dl, 
const termlist &tl,
 
  332         : terms_to_be_computed(
true), v_num(0), pbr(p), pdispatch(0), nbrhs(1),
 
  333           vlist(vl), dlist(dl), tlist(tl), mims(mms), region(reg),
 
  334           is_update_brick(
false), external_load(0),
 
  335           rveclist(1), rveclist_sym(1), cveclist(1),
 
  339     typedef std::map<std::string, var_description> VAR_SET;
 
  340     mutable VAR_SET variables;             
 
  341     std::vector<brick_description> bricks; 
 
  342     dal::bit_vector valid_bricks, active_bricks;
 
  343     std::map<std::string, pinterpolate_transformation> transformations;
 
  344     std::map<std::string, pelementary_transformation> elem_transformations;
 
  345     std::map<std::string, psecondary_domain> secondary_domains;
 
  348     int time_integration; 
 
  350     scalar_type time_step; 
 
  351     scalar_type init_time_step; 
 
  354     typedef std::map<size_type, scalar_type> real_dof_constraints_var;
 
  355     typedef std::map<size_type, complex_type> complex_dof_constraints_var;
 
  356     mutable std::map<std::string, real_dof_constraints_var>
 
  357       real_dof_constraints;
 
  358     mutable std::map<std::string, complex_dof_constraints_var>
 
  359       complex_dof_constraints;
 
  360     void clear_dof_constraints()
 
  361     { real_dof_constraints.clear(); complex_dof_constraints.clear(); }
 
  368       std::string secondary_domain;
 
  369       gen_expr(
const std::string &expr_, 
const mesh_im &mim_,
 
  370                size_type region_, 
const std::string &secdom)
 
  371         : expr(expr_), mim(mim_), region(region_), secondary_domain(secdom) {}
 
  375     struct assignement_desc {
 
  383     std::list<assignement_desc> assignments;
 
  385     mutable std::list<gen_expr> generic_expressions;
 
  389     std::map<std::string, std::vector<std::string> > variable_groups;
 
  391     ga_macro_dictionary macro_dict;
 
  394     virtual void actualize_sizes() 
const;
 
  395     bool check_name_validity(
const std::string &name, 
bool assert=
true) 
const;
 
  396     void brick_init(
size_type ib, build_version version,
 
  399     void init() { complex_version = 
false; act_size_to_be_done = 
false; }
 
  401     void resize_global_system() 
const;
 
  404     virtual void post_to_variables_step();
 
  406     scalar_type approx_external_load_; 
 
  409     VAR_SET::const_iterator find_variable(
const std::string &name) 
const;
 
  410     const var_description &variable_description(
const std::string &name) 
const;
 
  414     void add_generic_expression(
const std::string &expr, 
const mesh_im &mim,
 
  416                                 const std::string &secondary_domain = 
"")
 const {
 
  417       generic_expressions.push_back(gen_expr(expr, mim, region,
 
  420     void add_external_load(
size_type ib, scalar_type e)
 const 
  421     { bricks[ib].external_load = e; }
 
  422     scalar_type approx_external_load() { 
return approx_external_load_; }
 
  424     void update_brick(
size_type ib, build_version version) 
const;
 
  427     void update_affine_dependent_variables();
 
  428     void brick_call(
size_type ib, build_version version,
 
  430     model_real_plain_vector &rhs_coeffs_of_brick(
size_type ib)
 const 
  431     { 
return bricks[ib].coeffs; }
 
  432     scalar_type &matrix_coeff_of_brick(
size_type ib)
 const 
  433     { 
return bricks[ib].matrix_coeff; }
 
  434     bool is_var_newer_than_brick(
const std::string &varname,
 
  436     bool is_var_mf_newer_than_brick(
const std::string &varname,
 
  438     bool is_mim_newer_than_brick(
const mesh_im &mim,
 
  442       GMM_ASSERT1(valid_bricks[ib], 
"Inexistent brick");
 
  443       return bricks[ib].pbr;
 
  446     void variable_list(varnamelist &vl)
 const 
  447     { 
for (
const auto &v : variables) vl.push_back(v.first); }
 
  449     void define_variable_group(
const std::string &group_name,
 
  450                                const std::vector<std::string> &nl);
 
  451     bool variable_group_exists(
const std::string &group_name)
 const 
  452     { 
return variable_groups.count(group_name) > 0; }
 
  454     const std::vector<std::string> &
 
  455     variable_group(
const std::string &group_name)
 const {
 
  456       GMM_ASSERT1(variable_group_exists(group_name),
 
  457                   "Undefined variable group " << group_name);
 
  458       return (variable_groups.find(group_name))->second;
 
  461     void clear_assembly_assignments(
void) { assignments.clear(); }
 
  462     void add_assembly_assignments(
const std::string &dataname,
 
  463                                   const std::string &expr,
 
  466                                   bool before = 
false);
 
  469     void add_real_dof_constraint(
const std::string &varname, 
size_type dof,
 
  470                                  scalar_type val)
 const 
  471     { real_dof_constraints[varname][dof] = val; }
 
  473     void add_complex_dof_constraint(
const std::string &varname, 
size_type dof,
 
  474                                     complex_type val)
 const 
  475     { complex_dof_constraints[varname][dof] = val; }
 
  478     void add_temporaries(
const varnamelist &vl, gmm::uint64_type id_num) 
const;
 
  480     const mimlist &mimlist_of_brick(
size_type ib)
 const 
  481     { 
return bricks[ib].mims; }
 
  483     const varnamelist &varnamelist_of_brick(
size_type ib)
 const 
  484     { 
return bricks[ib].vlist; }
 
  486     const varnamelist &datanamelist_of_brick(
size_type ib)
 const 
  487     { 
return bricks[ib].dlist; }
 
  490     { 
return bricks[ib].region; }
 
  492     bool temporary_uptodate(
const std::string &varname,
 
  493                             gmm::uint64_type id_num, 
size_type &ind) 
const;
 
  495     size_type n_iter_of_variable(
const std::string &name)
 const {
 
  496       return variables.count(name) == 0 ? 
size_type(0)
 
  497                                         : variables[name].n_iter;
 
  500     void set_default_iter_of_variable(
const std::string &varname,
 
  502     void reset_default_iter_of_variables(
const varnamelist &vl) 
const;
 
  506     const model_real_sparse_matrix &linear_real_matrix_term
 
  509     const model_complex_sparse_matrix &linear_complex_matrix_term
 
  514       GMM_ASSERT1(valid_bricks[ib], 
"Inexistent brick");
 
  515       active_bricks.del(ib);
 
  520       GMM_ASSERT1(valid_bricks[ib], 
"Inexistent brick");
 
  521       active_bricks.add(ib);
 
  525     void disable_variable(
const std::string &name);
 
  528     void enable_variable(
const std::string &name, 
bool enabled=
true);
 
  531     bool variable_exists(
const std::string &name) 
const;
 
  534     bool is_disabled_variable(
const std::string &name) 
const;
 
  537     bool is_data(
const std::string &name) 
const;
 
  540     bool is_true_data(
const std::string &name) 
const;
 
  543     bool is_internal_variable(
const std::string &name) 
const;
 
  545     bool is_affine_dependent_variable(
const std::string &name) 
const;
 
  547     const std::string &org_variable(
const std::string &name) 
const;
 
  549     const scalar_type &factor_of_variable(
const std::string &name) 
const;
 
  551     void set_factor_of_variable(
const std::string &name, scalar_type a);
 
  553     bool is_im_data(
const std::string &name) 
const;
 
  555     const im_data *pim_data_of_variable(
const std::string &name) 
const;
 
  557     const gmm::uint64_type &
 
  558     version_number_of_data_variable(
const std::string &varname,
 
  571       for (
const auto &v : variables)
 
  572         if (v.second.is_internal && !v.second.is_disabled) 
return true;
 
  584     size_type nb_dof(
bool with_internal=
false) 
const;
 
  593     dim_type leading_dimension()
 const { 
return leading_dim; }
 
  596     std::string new_name(
const std::string &name);
 
  598     const gmm::sub_interval &
 
  599     interval_of_variable(
const std::string &name) 
const;
 
  603     const model_real_plain_vector &
 
  604     real_variable(
const std::string &name, 
size_type niter) 
const;
 
  608     const model_real_plain_vector &
 
  609     real_variable(
const std::string &name) 
const;
 
  613     const model_complex_plain_vector &
 
  614     complex_variable(
const std::string &name, 
size_type niter) 
const;
 
  618     const model_complex_plain_vector &
 
  619     complex_variable(
const std::string &name) 
const;
 
  623     model_real_plain_vector &
 
  624     set_real_variable(
const std::string &name, 
size_type niter) 
const;
 
  628     model_real_plain_vector &
 
  629     set_real_variable(
const std::string &name) 
const;
 
  633     model_complex_plain_vector &
 
  634     set_complex_variable(
const std::string &name, 
size_type niter) 
const;
 
  638     model_complex_plain_vector &
 
  639     set_complex_variable(
const std::string &name) 
const;
 
  641     model_real_plain_vector &
 
  642     set_real_constant_part(
const std::string &name) 
const;
 
  644     model_complex_plain_vector &
 
  645     set_complex_constant_part(
const std::string &name) 
const;
 
  648     template<
typename VECTOR, 
typename T>
 
  649     void from_variables(VECTOR &V, 
bool with_internal, T)
 const {
 
  650       for (
const auto &v : variables)
 
  651         if (v.second.is_variable && !v.second.is_affine_dependent
 
  652             && !v.second.is_disabled
 
  653             && (with_internal || !v.second.is_internal))
 
  654           gmm::copy(v.second.real_value[0], gmm::sub_vector(V, v.second.I));
 
  657     template<
typename VECTOR, 
typename T>
 
  658     void from_variables(VECTOR &V, 
bool with_internal, std::complex<T>)
 const {
 
  659       for (
const auto &v : variables)
 
  660         if (v.second.is_variable && !v.second.is_affine_dependent
 
  661             && !v.second.is_disabled
 
  662             && (with_internal || !v.second.is_internal))
 
  663           gmm::copy(v.second.complex_value[0], gmm::sub_vector(V, v.second.I));
 
  667     template<
typename VECTOR>
 
  668     void from_variables(VECTOR &V, 
bool with_internal=
false)
 const {
 
  669       typedef typename gmm::linalg_traits<VECTOR>::value_type T;
 
  670       context_check(); 
if (act_size_to_be_done) actualize_sizes();
 
  671       from_variables(V, with_internal, T());
 
  675     template<
typename VECTOR, 
typename T>
 
  676     void to_variables(
const VECTOR &V, 
bool with_internal, T) {
 
  677       for (
auto &&v : variables)
 
  678         if (v.second.is_variable && !v.second.is_affine_dependent
 
  679             && !v.second.is_disabled
 
  680             && (with_internal || !v.second.is_internal)) {
 
  681           gmm::copy(gmm::sub_vector(V, v.second.I), v.second.real_value[0]);
 
  682           v.second.v_num_data[0] = act_counter();
 
  684       update_affine_dependent_variables();
 
  685       this->post_to_variables_step();
 
  688     template<
typename VECTOR, 
typename T>
 
  689     void to_variables(
const VECTOR &V, 
bool with_internal, std::complex<T>) {
 
  690       for (
auto &&v : variables)
 
  691         if (v.second.is_variable && !v.second.is_affine_dependent
 
  692             && !v.second.is_disabled
 
  693             && (with_internal || !v.second.is_internal)) {
 
  694           gmm::copy(gmm::sub_vector(V, v.second.I), v.second.complex_value[0]);
 
  695           v.second.v_num_data[0] = act_counter();
 
  697       update_affine_dependent_variables();
 
  698       this->post_to_variables_step();
 
  702     template<
typename VECTOR>
 
  703     void to_variables(
const VECTOR &V, 
bool with_internal=
false) {
 
  704       typedef typename gmm::linalg_traits<VECTOR>::value_type T;
 
  705       context_check(); 
if (act_size_to_be_done) actualize_sizes();
 
  706       to_variables(V, with_internal, T());
 
  711     void add_fixed_size_variable(
const std::string &name, 
size_type size,
 
  716     void add_fixed_size_variable(
const std::string &name,
 
  717                                  const bgeot::multi_index &sizes,
 
  722     void add_fixed_size_data(
const std::string &name, 
size_type size,
 
  727     void add_fixed_size_data(
const std::string &name,
 
  728                              const bgeot::multi_index &sizes,
 
  732     void resize_fixed_size_variable(
const std::string &name, 
size_type size);
 
  735     void resize_fixed_size_variable(
const std::string &name,
 
  736                                     const bgeot::multi_index &sizes);
 
  740     template <
typename VECT>
 
  743       this->add_fixed_size_data(name, gmm::vect_size(v));
 
  744       if (this->is_complex())
 
  745         gmm::copy(v, this->set_complex_variable(name));
 
  747         gmm::copy(gmm::real_part(v), this->set_real_variable(name));
 
  752     template <
typename VECT>
 
  755                                          const bgeot::multi_index &sizes) {
 
  756       this->add_fixed_size_data(name, sizes);
 
  757       if (this->is_complex())
 
  758         gmm::copy(v, this->set_complex_variable(name));
 
  760         gmm::copy(gmm::real_part(v), this->set_real_variable(name));
 
  765     void add_initialized_matrix_data(
const std::string &name,
 
  766                                      const base_matrix &M);
 
  767     void add_initialized_matrix_data(
const std::string &name,
 
  768                                      const base_complex_matrix &M);
 
  772     void add_initialized_tensor_data(
const std::string &name,
 
  773                                      const base_tensor &t);
 
  774     void add_initialized_tensor_data(
const std::string &name,
 
  775                                      const base_complex_tensor &t);
 
  779     template <
typename T>
 
  781       this->add_fixed_size_data(name, 1, 1);
 
  782       if (this->is_complex())
 
  783         this->set_complex_variable(name)[0] = e;
 
  785         this->set_real_variable(name)[0] = gmm::real(e);
 
  790     void add_im_variable(
const std::string &name, 
const im_data &imd,
 
  793     void add_internal_im_variable(
const std::string &name,
 
  796     void add_im_data(
const std::string &name, 
const im_data &imd,
 
  802     void add_fem_variable(
const std::string &name, 
const mesh_fem &mf,
 
  809     void add_filtered_fem_variable(
const std::string &name, 
const mesh_fem &mf,
 
  817     void add_affine_dependent_variable(
const std::string &name,
 
  818                                        const std::string &org_name,
 
  819                                        scalar_type alpha = scalar_type(1));
 
  822     void add_fem_data(
const std::string &name, 
const mesh_fem &mf,
 
  826     void add_fem_data(
const std::string &name, 
const mesh_fem &mf,
 
  827                       const bgeot::multi_index &sizes, 
size_type niter = 1);
 
  832     template <
typename VECT>
 
  835       this->add_fem_data(name, mf,
 
  836                          dim_type(gmm::vect_size(v) / mf.
nb_dof()), 1);
 
  837       if (this->is_complex())
 
  838         gmm::copy(v, this->set_complex_variable(name));
 
  840         gmm::copy(gmm::real_part(v), this->set_real_variable(name));
 
  845     template <
typename VECT>
 
  848                                   const bgeot::multi_index &sizes) {
 
  849       this->add_fem_data(name, mf, sizes, 1);
 
  850       if (this->is_complex())
 
  851         gmm::copy(v, this->set_complex_variable(name));
 
  853         gmm::copy(gmm::real_part(v), this->set_real_variable(name));
 
  862     void add_multiplier(
const std::string &name, 
const mesh_fem &mf,
 
  863                         const std::string &primal_name,
 
  873     void add_multiplier(
const std::string &name, 
const mesh_fem &mf,
 
  874                         size_type region, 
const std::string &primal_name,
 
  883     void add_multiplier(
const std::string &name, 
const mesh_fem &mf,
 
  884                         const std::string &primal_name, 
const mesh_im &mim,
 
  893     void add_macro(
const std::string &name, 
const std::string &expr);
 
  896     void del_macro(
const std::string &name);
 
  900     { 
return macro_dict.macro_exists(name); }
 
  903     void delete_variable(
const std::string &varname);
 
  907     const mesh_fem &mesh_fem_of_variable(
const std::string &name) 
const;
 
  910     const mesh_fem *pmesh_fem_of_variable(
const std::string &name) 
const;
 
  913     bgeot::multi_index qdims_of_variable(
const std::string &name) 
const;
 
  914     size_type qdim_of_variable(
const std::string &name) 
const;
 
  917     const model_real_sparse_matrix &
 
  919       GMM_ASSERT1(!complex_version, 
"This model is a complex one");
 
  920       context_check(); 
if (act_size_to_be_done) actualize_sizes();
 
  921       return internal ? internal_rTM : rTM;
 
  926       GMM_ASSERT1(complex_version, 
"This model is a real one");
 
  927       context_check(); 
if (act_size_to_be_done) actualize_sizes();
 
  933     const model_real_plain_vector &
real_rhs(
bool with_internal=
false)
 const {
 
  934       GMM_ASSERT1(!complex_version, 
"This model is a complex one");
 
  935       context_check(); 
if (act_size_to_be_done) actualize_sizes();
 
  936       return (with_internal && gmm::vect_size(full_rrhs)) ? full_rrhs : rrhs;
 
  942     model_real_plain_vector &
set_real_rhs(
bool with_internal=
false)
 const {
 
  943       GMM_ASSERT1(!complex_version, 
"This model is a complex one");
 
  944       context_check(); 
if (act_size_to_be_done) actualize_sizes();
 
  945       return (with_internal && gmm::vect_size(full_rrhs)) ? full_rrhs : rrhs;
 
  951       GMM_ASSERT1(!complex_version, 
"This model is a complex one");
 
  952       context_check(); 
if (act_size_to_be_done) actualize_sizes();
 
  964       GMM_ASSERT1(!complex_version, 
"This model is a complex one");
 
  965       context_check(); 
if (act_size_to_be_done) actualize_sizes();
 
  966       GMM_ASSERT1(valid_bricks[ib], 
"Inexistent brick");
 
  967       GMM_ASSERT1(ind_term < bricks[ib].tlist.size(), 
"Inexistent term");
 
  968       GMM_ASSERT1(ind_iter < bricks[ib].nbrhs, 
"Inexistent iter");
 
  969       GMM_ASSERT1(!sym || bricks[ib].tlist[ind_term].is_symmetric,
 
  970                   "Term is not symmetric");
 
  972         return bricks[ib].rveclist_sym[ind_iter][ind_term];
 
  974         return bricks[ib].rveclist[ind_iter][ind_term];
 
  980       GMM_ASSERT1(complex_version, 
"This model is a real one");
 
  981       context_check(); 
if (act_size_to_be_done) actualize_sizes();
 
  989       GMM_ASSERT1(complex_version, 
"This model is a real one");
 
  990       context_check(); 
if (act_size_to_be_done) actualize_sizes();
 
 1002       GMM_ASSERT1(!complex_version, 
"This model is a complex one");
 
 1003       context_check(); 
if (act_size_to_be_done) actualize_sizes();
 
 1004       GMM_ASSERT1(valid_bricks[ib], 
"Inexistent brick");
 
 1005       GMM_ASSERT1(ind_term < bricks[ib].tlist.size(), 
"Inexistent term");
 
 1006       GMM_ASSERT1(ind_iter < bricks[ib].nbrhs, 
"Inexistent iter");
 
 1007       GMM_ASSERT1(!sym || bricks[ib].tlist[ind_term].is_symmetric,
 
 1008                   "Term is not symmetric");
 
 1010         return bricks[ib].cveclist_sym[ind_iter][ind_term];
 
 1012         return bricks[ib].cveclist[ind_iter][ind_term];
 
 1016     void listvar(std::ostream &ost) 
const;
 
 1018     void listresiduals(std::ostream &ost) 
const;
 
 1021     void listbricks(std::ostream &ost, 
size_type base_id = 0) 
const;
 
 1025       return active_bricks;
 
 1030       GMM_ASSERT1(valid_bricks[ib], 
"Inexistent brick");
 
 1031       bricks[ib].terms_to_be_computed = 
true;
 
 1039                         const varnamelist &datanames,
 
 1040                         const termlist &terms, 
const mimlist &mims,
 
 1050     void change_terms_of_brick(
size_type ib, 
const termlist &terms);
 
 1054     void change_variables_of_brick(
size_type ib, 
const varnamelist &vl);
 
 1058     void change_data_of_brick(
size_type ib, 
const varnamelist &vl);
 
 1062     void change_mims_of_brick(
size_type ib, 
const mimlist &ml);
 
 1066     void change_update_flag_of_brick(
size_type ib, 
bool flag);
 
 1068     void set_time(scalar_type t = scalar_type(0), 
bool to_init = 
true);
 
 1070     scalar_type get_time();
 
 1072     void set_time_step(scalar_type dt) { time_step = dt; }
 
 1073     scalar_type get_time_step()
 const { 
return time_step; }
 
 1074     scalar_type get_init_time_step()
 const { 
return init_time_step; }
 
 1075     int is_time_integration()
 const { 
return time_integration; }
 
 1076     void set_time_integration(
int ti) { time_integration = ti; }
 
 1077     bool is_init_step()
 const { 
return init_step; }
 
 1078     void cancel_init_step() { init_step = 
false; }
 
 1079     void call_init_affine_dependent_variables(
int version);
 
 1080     void shift_variables_for_time_integration();
 
 1081     void copy_init_time_derivative();
 
 1082     void add_time_integration_scheme(
const std::string &varname,
 
 1084     void perform_init_time_derivative(scalar_type ddt)
 
 1085     { init_step = 
true; init_time_step = ddt; }
 
 1089     void add_time_dispatcher(
size_type ibrick, pdispatcher pdispatch);
 
 1091     void set_dispatch_coeff();
 
 1094     virtual void first_iter();
 
 1099     virtual void next_iter();
 
 1105                                         pinterpolate_transformation ptrans) {
 
 1106       if (secondary_domain_exists(name))
 
 1107         GMM_ASSERT1(
false, 
"An secondary domain with the same " 
 1108                     "name already exists");
 
 1109       if (transformations.count(name) > 0)
 
 1110         GMM_ASSERT1(name.compare(
"neighbor_element"), 
"neighbor_element is a " 
 1111                     "reserved interpolate transformation name");
 
 1112        transformations[name] = ptrans;
 
 1117     pinterpolate_transformation
 
 1119       std::map<std::string, pinterpolate_transformation>::const_iterator
 
 1120         it = transformations.find(name);
 
 1121       GMM_ASSERT1(it != transformations.end(), 
"Inexistent transformation " << name);
 
 1128     { 
return transformations.count(name) > 0; }
 
 1134                                        pelementary_transformation ptrans) {
 
 1135        elem_transformations[name] = ptrans;
 
 1140     pelementary_transformation
 
 1142       std::map<std::string, pelementary_transformation>::const_iterator
 
 1143         it = elem_transformations.find(name);
 
 1144       GMM_ASSERT1(it != elem_transformations.end(),
 
 1145                   "Inexistent elementary transformation " << name);
 
 1152     { 
return elem_transformations.count(name) > 0; }
 
 1159                               psecondary_domain ptrans) {
 
 1160       if (interpolate_transformation_exists(name))
 
 1161         GMM_ASSERT1(
false, 
"An interpolate transformation with the same " 
 1162                     "name already exists");secondary_domains[name] = ptrans;
 
 1169       auto  it = secondary_domains.find(name);
 
 1170       GMM_ASSERT1(it != secondary_domains.end(),
 
 1171                   "Inexistent transformation " << name);
 
 1178     { 
return secondary_domains.count(name) > 0; }
 
 1182     const std::string &varname_of_brick(
size_type ind_brick,
 
 1187     const std::string &dataname_of_brick(
size_type ind_brick,
 
 1229     virtual void assembly(build_version version);
 
 1239     std::string Neumann_term(
const std::string &varname, 
size_type region);
 
 1241     virtual void clear();
 
 1243     explicit model(
bool comp_version = 
false);
 
 1248     void check_brick_stiffness_rhs(
size_type ind_brick) 
const;
 
 1267     virtual void init_affine_dependent_variables(
model &md) 
const = 0;
 
 1268     virtual void init_affine_dependent_variables_precomputation(
model &md)
 
 1270     virtual void time_derivative_to_be_initialized
 
 1271       (std::string &name_v, std::string &name_previous_v) 
const = 0;
 
 1272     virtual void shift_variables(
model &md) 
const = 0;
 
 1276   void add_theta_method_for_first_order(
model &md, 
const std::string &varname,
 
 1279   void add_theta_method_for_second_order(
model &md, 
const std::string &varname,
 
 1282   void add_Newmark_scheme(
model &md, 
const std::string &varname,
 
 1283                           scalar_type beta, scalar_type gamma);
 
 1285   void add_Houbolt_scheme(
model &md, 
const std::string &varname);
 
 1303     std::vector<std::string> param_names;
 
 1307     size_type nbrhs()
 const { 
return nbrhs_; }
 
 1309     typedef model::build_version build_version;
 
 1312     { GMM_ASSERT1(
false, 
"Time dispatcher with not set_dispatch_coeff !"); }
 
 1314     virtual void next_real_iter
 
 1316      const model::varnamelist &,
 
 1317      model::real_matlist &,
 
 1318      std::vector<model::real_veclist> &,
 
 1319      std::vector<model::real_veclist> &,
 
 1321       GMM_ASSERT1(
false, 
"Time dispatcher with not defined first real iter !");
 
 1324     virtual void next_complex_iter
 
 1326      const model::varnamelist &,
 
 1327      model::complex_matlist &,
 
 1328      std::vector<model::complex_veclist> &,
 
 1329      std::vector<model::complex_veclist> &,
 
 1331       GMM_ASSERT1(
false,
"Time dispatcher with not defined first comples iter");
 
 1334     virtual void asm_real_tangent_terms
 
 1336      model::real_matlist &, std::vector<model::real_veclist> &,
 
 1337      std::vector<model::real_veclist> &,
 
 1338      build_version)
 const {
 
 1339       GMM_ASSERT1(
false, 
"Time dispatcher with not defined real tangent " 
 1343     virtual void asm_complex_tangent_terms
 
 1345      model::complex_matlist &, std::vector<model::complex_veclist> &,
 
 1346      std::vector<model::complex_veclist> &,
 
 1347      build_version)
 const {
 
 1348       GMM_ASSERT1(
false, 
"Time dispatcher with not defined complex tangent " 
 1353       GMM_ASSERT1(_nbrhs > 0, 
"Time dispatcher with no rhs");
 
 1369     typedef model::build_version build_version;
 
 1373     template <
typename MATLIST, 
typename VECTLIST>
 
 1375                           const model::varnamelist &,
 
 1376                           const model::varnamelist &,
 
 1378                           VECTLIST &vectl, VECTLIST &vectl_sym,
 
 1379                           bool first_iter)
 const {
 
 1380       if (first_iter) md.update_brick(ib, model::BUILD_RHS);
 
 1383       for (
size_type i = 0; i < vectl[0].size(); ++i)
 
 1384         gmm::copy(vectl[0][i], vectl[1][i]);
 
 1385       for (
size_type i = 0; i < vectl_sym[0].size(); ++i)
 
 1386         gmm::copy(vectl_sym[0][i], vectl_sym[1][i]);
 
 1390       md.linear_brick_add_to_rhs(ib, 1, 0);
 
 1394     (
const model &md, 
size_type ib, 
const model::varnamelist &vl,
 
 1395      const model::varnamelist &dl, model::real_matlist &matl,
 
 1396      std::vector<model::real_veclist> &vectl,
 
 1397      std::vector<model::real_veclist> &vectl_sym, 
bool first_iter) 
const;
 
 1399     void next_complex_iter
 
 1400     (
const model &md, 
size_type ib, 
const model::varnamelist &vl,
 
 1401      const model::varnamelist &dl,
 
 1402      model::complex_matlist &matl,
 
 1403      std::vector<model::complex_veclist> &vectl,
 
 1404      std::vector<model::complex_veclist> &vectl_sym,
 
 1405      bool first_iter) 
const;
 
 1407     void asm_real_tangent_terms
 
 1408     (
const model &md, 
size_type ib, model::real_matlist &,
 
 1409      std::vector<model::real_veclist> &,
 
 1410      std::vector<model::real_veclist> &,
 
 1411      build_version version) 
const;
 
 1413     virtual void asm_complex_tangent_terms
 
 1414     (
const model &md, 
size_type ib, model::complex_matlist &,
 
 1415      std::vector<model::complex_veclist> &,
 
 1416      std::vector<model::complex_veclist> &,
 
 1417      build_version version) 
const;
 
 1419     theta_method_dispatcher(
const std::string &THETA);
 
 1433                                    const std::string &THETA);
 
 1441   (model &md, 
const std::string &U, 
const std::string &V,
 
 1442    const std::string &pdt, 
const std::string &ptheta);
 
 1458   (model &md, 
size_type id2dt2b, 
const std::string &U, 
const std::string &V,
 
 1459    const std::string &pdt, 
const std::string &ptwobeta,
 
 1460    const std::string &pgamma);
 
 1484     bool compute_each_time; 
 
 1492     typedef model::build_version build_version;
 
 1496     void set_flags(
const std::string &bname, 
bool islin, 
bool issym,
 
 1497                    bool iscoer, 
bool ire, 
bool isco, 
bool each_time = 
false) {
 
 1499       islinear = islin; issymmetric = issym; iscoercive = iscoer;
 
 1500       isreal = ire; iscomplex = isco; isinit = 
true;
 
 1501       compute_each_time = each_time;
 
 1504 #   define BRICK_NOT_INIT GMM_ASSERT1(isinit, "Set brick flags !")
 
 1505     bool is_linear()
    const { BRICK_NOT_INIT; 
return islinear;    }
 
 1506     bool is_symmetric()
 const { BRICK_NOT_INIT; 
return issymmetric; }
 
 1507     bool is_coercive()
  const { BRICK_NOT_INIT; 
return iscoercive;  }
 
 1508     bool is_real()
      const { BRICK_NOT_INIT; 
return isreal;      }
 
 1509     bool is_complex()
   const { BRICK_NOT_INIT; 
return iscomplex;   }
 
 1510     bool is_to_be_computed_each_time()
 const 
 1511     { BRICK_NOT_INIT; 
return compute_each_time; }
 
 1512     const std::string &brick_name()
 const { BRICK_NOT_INIT; 
return name; }
 
 1529                                         const model::varnamelist &,
 
 1530                                         const model::varnamelist &,
 
 1531                                         const model::mimlist &,
 
 1532                                         model::real_matlist &,
 
 1533                                         model::real_veclist &,
 
 1534                                         model::real_veclist &,
 
 1555                                            const model::varnamelist &,
 
 1556                                            const model::varnamelist &,
 
 1557                                            const model::mimlist &,
 
 1558                                            model::complex_matlist &,
 
 1559                                            model::complex_veclist &,
 
 1560                                            model::complex_veclist &,
 
 1573                                         const model::varnamelist &,
 
 1574                                         const model::varnamelist &,
 
 1575                                         const model::mimlist &,
 
 1576                                         model::real_matlist &,
 
 1577                                         model::real_veclist &,
 
 1578                                         model::real_veclist &,
 
 1587                                         const model::varnamelist &,
 
 1588                                         const model::varnamelist &,
 
 1589                                         const model::mimlist &,
 
 1590                                         model::complex_matlist &,
 
 1591                                         model::complex_veclist &,
 
 1592                                         model::complex_veclist &,
 
 1601                                         const model::varnamelist &,
 
 1602                                         const model::varnamelist &,
 
 1603                                         const model::mimlist &,
 
 1604                                         model::real_matlist &,
 
 1605                                         model::real_veclist &,
 
 1606                                         model::real_veclist &,
 
 1615                                         const model::varnamelist &,
 
 1616                                         const model::varnamelist &,
 
 1617                                         const model::mimlist &,
 
 1618                                         model::complex_matlist &,
 
 1619                                         model::complex_veclist &,
 
 1620                                         model::complex_veclist &,
 
 1626                                         const model::termlist& tlist,
 
 1627                                         const model::varnamelist &,
 
 1628                                         const model::varnamelist &,
 
 1629                                         const model::mimlist &,
 
 1630                                         model::real_matlist &,
 
 1631                                         model::real_veclist &,
 
 1633                                         const scalar_type delta = 1e-8) 
const;
 
 1639      const model::varnamelist &)
 const {
 
 1640       GMM_ASSERT1(
false, 
"No assemby string declared, computation of Neumann " 
 1641                   "term impossible for brick " << name);
 
 1648         const model::varnamelist &,
 
 1649         const model::varnamelist &,
 
 1650         const model::mimlist &,
 
 1651         model::real_matlist &,
 
 1652         model::real_veclist &,
 
 1653         model::real_veclist &,
 
 1681   (model &md, 
const mesh_im &mim, 
const std::string &expr,
 
 1683    bool is_coercive = 
false, 
const std::string &brickname = 
"",
 
 1684    bool return_if_nonlin = 
false);
 
 1686   inline size_type APIDECL add_linear_generic_assembly_brick
 
 1687   (model &md, 
const mesh_im &mim, 
const std::string &expr,
 
 1689    bool is_coercive = 
false, 
const std::string &brickname = 
"",
 
 1690    bool return_if_nonlin = 
false) {
 
 1692                     is_coercive, brickname, return_if_nonlin);
 
 1708   (model &md, 
const mesh_im &mim, 
const std::string &expr,
 
 1710    bool is_coercive = 
false, 
const std::string &brickname = 
"");
 
 1712   inline size_type APIDECL add_nonlinear_generic_assembly_brick
 
 1713   (model &md, 
const mesh_im &mim, 
const std::string &expr,
 
 1715    bool is_coercive = 
false, 
const std::string &brickname = 
"") {
 
 1717                               is_sym, is_coercive, brickname);
 
 1730   (model &md, 
const mesh_im &mim, 
const std::string &expr,
 
 1732    const std::string &brickname = std::string(),
 
 1733    const std::string &directvarname = std::string(),
 
 1734    const std::string &directdataname = std::string(),
 
 1735    bool return_if_nonlin = 
false);
 
 1736   inline size_type APIDECL add_source_term_generic_assembly_brick
 
 1737   (model &md, 
const mesh_im &mim, 
const std::string &expr,
 
 1739    const std::string &brickname = std::string(),
 
 1740    const std::string &directvarname = std::string(),
 
 1741    const std::string &directdataname = std::string(),
 
 1742    bool return_if_nonlin = 
false) {
 
 1744                     directvarname, directdataname, return_if_nonlin);
 
 1754   (model &md, 
const mesh_im &mim, 
const std::string &expr,
 
 1755    size_type region, 
const std::string &secondary_domain,
 
 1756    bool is_sym = 
false, 
bool is_coercive = 
false,
 
 1757    const std::string &brickname = 
"", 
bool return_if_nonlin = 
false);
 
 1766   (model &md, 
const mesh_im &mim, 
const std::string &expr,
 
 1767    size_type region, 
const std::string &secondary_domain,
 
 1768    bool is_sym = 
false, 
bool is_coercive = 
false,
 
 1769    const std::string &brickname = 
"");
 
 1778   (model &md, 
const mesh_im &mim, 
const std::string &expr,
 
 1779    size_type region,  
const std::string &secondary_domain,
 
 1780    const std::string &brickname = std::string(),
 
 1781    const std::string &directvarname = std::string(),
 
 1782    const std::string &directdataname = std::string(),
 
 1783    bool return_if_nonlin = 
false);
 
 1793   (model &md, 
const mesh_im &mim, 
const std::string &varname,
 
 1819   (model &md, 
const mesh_im &mim, 
const std::string &varname,
 
 1833   (model &md, 
const mesh_im &mim, 
const std::string &varname,
 
 1835    const std::string &directdataname = std::string());
 
 1848   (model &md, 
const mesh_im &mim, 
const std::string &varname,
 
 1849    const std::string &dataexpr, 
size_type region);
 
 1871   (model &md, 
const std::string &varname, 
size_type region,
 
 1872    const std::string &dataname = std::string());
 
 1886   (model &md, 
const mesh_im &mim, 
const std::string &varname,
 
 1887    const std::string &multname, 
size_type region,
 
 1888    const std::string &dataname = std::string());
 
 1897   (model &md, 
const mesh_im &mim, 
const std::string &varname,
 
 1898    const mesh_fem &mf_mult, 
size_type region,
 
 1899    const std::string &dataname = std::string());
 
 1906   (model &md, 
const mesh_im &mim, 
const std::string &varname,
 
 1908    const std::string &dataname = std::string());
 
 1930   (model &md, 
const mesh_im &mim, 
const std::string &varname,
 
 1931    scalar_type penalization_coeff, 
size_type region,
 
 1932    const std::string &dataname = std::string(),
 
 1933    const mesh_fem *mf_mult = 0);
 
 1953   (model &md, 
const mesh_im &mim, 
const std::string &varname,
 
 1954    const std::string &Neumannterm,
 
 1955    const std::string &datagamma0, 
size_type region,
 
 1956    scalar_type theta = scalar_type(0),
 
 1957    const std::string &datag = std::string());
 
 1974   (model &md, 
const mesh_im &mim, 
const std::string &varname,
 
 1975    const std::string &multname, 
size_type region,
 
 1976    const std::string &dataname = std::string());
 
 1985   (model &md, 
const mesh_im &mim, 
const std::string &varname,
 
 1986    const mesh_fem &mf_mult, 
size_type region,
 
 1987    const std::string &dataname = std::string());
 
 1994   (model &md, 
const mesh_im &mim, 
const std::string &varname,
 
 1996    const std::string &dataname = std::string());
 
 2013   (model &md, 
const mesh_im &mim, 
const std::string &varname,
 
 2014    scalar_type penalization_coeff, 
size_type region,
 
 2015    const std::string &dataname = std::string(),
 
 2016    const mesh_fem *mf_mult = 0);
 
 2039   (model &md, 
const mesh_im &mim, 
const std::string &varname,
 
 2040    const std::string &Neumannterm, 
const std::string &datagamma0,
 
 2041    size_type region, scalar_type theta = scalar_type(0),
 
 2042    const std::string &datag = std::string());
 
 2062   (model &md, 
const std::string &varname,
 
 2063    scalar_type penalisation_coeff, 
const std::string &dataname_pt,
 
 2064    const std::string &dataname_unitv = std::string(),
 
 2065    const std::string &dataname_val = std::string());
 
 2087   (model &md, 
const std::string &varname,
 
 2088    const std::string &multname, 
const std::string &dataname_pt,
 
 2089    const std::string &dataname_unitv = std::string(),
 
 2090    const std::string &dataname_val = std::string());
 
 2109   (model &md, 
const std::string &varname, 
const std::string &dataname_pt,
 
 2110    const std::string &dataname_unitv = std::string(),
 
 2111    const std::string &dataname_val = std::string());
 
 2119                                          scalar_type penalisation_coeff);
 
 2135   (model &md, 
const mesh_im &mim, 
const std::string &varname,
 
 2136    const std::string &multname, 
size_type region,
 
 2137    const std::string &dataname, 
const std::string &Hname);
 
 2146   (model &md, 
const mesh_im &mim, 
const std::string &varname,
 
 2147    const mesh_fem &mf_mult, 
size_type region,
 
 2148    const std::string &dataname, 
const std::string &Hname);
 
 2155   (model &md, 
const mesh_im &mim, 
const std::string &varname,
 
 2157    const std::string &dataname, 
const std::string &Hname);
 
 2176   (model &md, 
const mesh_im &mim, 
const std::string &varname,
 
 2177    scalar_type penalization_coeff, 
size_type region,
 
 2178    const std::string &dataname, 
const std::string &Hname,
 
 2179    const mesh_fem *mf_mult = 0);
 
 2202   (model &md, 
const mesh_im &mim, 
const std::string &varname,
 
 2203    const std::string &Neumannterm, 
const std::string &datagamma0,
 
 2205    const std::string &datag, 
const std::string &dataH);
 
 2216                                         const std::string &varname,
 
 2217                                         const std::string &dataexpr,
 
 2233                                             const std::string &varname,
 
 2234                                             const std::string &dataexpr,
 
 2239   model_real_sparse_matrix APIDECL &set_private_data_brick_real_matrix
 
 2241   model_real_plain_vector APIDECL &set_private_data_brick_real_rhs
 
 2243   model_complex_sparse_matrix APIDECL &set_private_data_brick_complex_matrix
 
 2245   model_complex_plain_vector APIDECL &set_private_data_brick_complex_rhs
 
 2247   size_type APIDECL add_constraint_with_penalization
 
 2248   (model &md, 
const std::string &varname, scalar_type penalisation_coeff);
 
 2249   size_type APIDECL add_constraint_with_multipliers
 
 2250   (model &md, 
const std::string &varname, 
const std::string &multname);
 
 2252   void set_private_data_rhs
 
 2253   (model &md, 
size_type indbrick, 
const std::string &varname);
 
 2255   template <
typename VECT, 
typename T>
 
 2256   void set_private_data_rhs(model &md, 
size_type ind,
 
 2258     model_real_plain_vector &LL = set_private_data_brick_real_rhs(md, ind);
 
 2263   template <
typename VECT, 
typename T>
 
 2264   void set_private_data_rhs(model &md, 
size_type ind, 
const VECT &L,
 
 2266     model_complex_plain_vector &LL = set_private_data_brick_complex_rhs(md, ind);
 
 2275   template <
typename VECT>
 
 2277     typedef typename gmm::linalg_traits<VECT>::value_type T;
 
 2278     set_private_data_rhs(md, indbrick, L, T());
 
 2281   template <
typename MAT, 
typename T>
 
 2282   void set_private_data_matrix(model &md, 
size_type ind,
 
 2284     model_real_sparse_matrix &BB = set_private_data_brick_real_matrix(md, ind);
 
 2285     gmm::resize(BB, gmm::mat_nrows(B), gmm::mat_ncols(B));
 
 2289   template <
typename MAT, 
typename T>
 
 2290   void set_private_data_matrix(model &md, 
size_type ind, 
const MAT &B,
 
 2292     model_complex_sparse_matrix &BB
 
 2293       = set_private_data_brick_complex_matrix(md, ind);
 
 2294     gmm::resize(BB, gmm::mat_nrows(B), gmm::mat_ncols(B));
 
 2301   template <
typename MAT>
 
 2304     typedef typename gmm::linalg_traits<MAT>::value_type T;
 
 2305     set_private_data_matrix(md, indbrick, B, T());
 
 2316   template <
typename MAT, 
typename VECT>
 
 2318   (
model &md, 
const std::string &varname, scalar_type penalisation_coeff,
 
 2319    const MAT &B, 
const VECT &L) {
 
 2321       = add_constraint_with_penalization(md, varname, penalisation_coeff);
 
 2322     size_type n = gmm::mat_nrows(B), m = gmm::mat_ncols(B);
 
 2323     set_private_data_rhs(md, ind, L);
 
 2324     set_private_data_matrix(md, ind, B);
 
 2336   template <
typename MAT, 
typename VECT>
 
 2338   (
model &md, 
const std::string &varname, 
const std::string &multname,
 
 2339    const MAT &B, 
const VECT &L) {
 
 2340     size_type ind = add_constraint_with_multipliers(md, varname, multname);
 
 2341     set_private_data_rhs(md, ind, L);
 
 2342     set_private_data_matrix(md, ind, B);
 
 2346   template <
typename MAT>
 
 2347   size_type add_constraint_with_multipliers
 
 2348   (model &md, 
const std::string &varname, 
const std::string &multname,
 
 2349    const MAT &B, 
const std::string &Lname) {
 
 2350     size_type ind = add_constraint_with_multipliers(md, varname, multname);
 
 2351     set_private_data_rhs(md, ind, Lname);
 
 2352     set_private_data_matrix(md, ind, B);
 
 2356   size_type APIDECL add_explicit_matrix(model &md, 
const std::string &varname1,
 
 2357                                         const std::string &varname2,
 
 2358                                         bool issymmetric, 
bool iscoercive);
 
 2359   size_type APIDECL add_explicit_rhs(model &md, 
const std::string &varname);
 
 2371   template <
typename MAT>
 
 2373                                 const std::string &varname2, 
const MAT &B,
 
 2374                                 bool issymmetric = 
false,
 
 2375                                 bool iscoercive = 
false) {
 
 2376     size_type ind = add_explicit_matrix(md, varname1, varname2,
 
 2377                                         issymmetric, iscoercive);
 
 2378     set_private_data_matrix(md, ind, B);
 
 2388   template <
typename VECT>
 
 2391     size_type ind = add_explicit_rhs(md, varname);
 
 2392     set_private_data_rhs(md, ind, L);
 
 2402   (model &md, 
const mesh_im &mim, 
const std::string &varname,
 
 2403    const std::string &dataname_lambda, 
const std::string &dataname_mu,
 
 2405    const std::string &dataname_preconstraint = std::string());
 
 2415   (model &md, 
const mesh_im &mim, 
const std::string &varname,
 
 2416    const std::string &data_E, 
const std::string &data_nu,
 
 2428   (model &md, 
const mesh_im &mim, 
const std::string &varname,
 
 2429    const std::string &data_E, 
const std::string &data_nu,
 
 2432   void APIDECL compute_isotropic_linearized_Von_Mises_or_Tresca
 
 2433   (model &md, 
const std::string &varname, 
const std::string &dataname_lambda,
 
 2434    const std::string &dataname_mu, 
const mesh_fem &mf_vm,
 
 2435    model_real_plain_vector &VM, 
bool tresca);
 
 2442   template <
class VECTVM>
 
 2443   void compute_isotropic_linearized_Von_Mises_or_Tresca
 
 2444   (
model &md, 
const std::string &varname, 
const std::string &dataname_lambda,
 
 2445    const std::string &dataname_mu, 
const mesh_fem &mf_vm,
 
 2446    VECTVM &VM, 
bool tresca) {
 
 2447     model_real_plain_vector VMM(mf_vm.
nb_dof());
 
 2448     compute_isotropic_linearized_Von_Mises_or_Tresca
 
 2449       (md, varname, dataname_lambda, dataname_mu, mf_vm, VMM, tresca);
 
 2459   (model &md, 
const std::string &varname, 
const std::string &data_E,
 
 2460    const std::string &data_nu, 
const mesh_fem &mf_vm,
 
 2461    model_real_plain_vector &VM);
 
 2469   (model &md, 
const std::string &varname, 
const std::string &data_E,
 
 2470    const std::string &data_nu, 
const mesh_fem &mf_vm,
 
 2471    model_real_plain_vector &VM);
 
 2494   (model &md, 
const mesh_im &mim, 
const std::string &varname,
 
 2496    const std::string &dataexpr_penal_coeff = std::string());
 
 2503   (model &md, 
const mesh_im &mim, 
const std::string &varname,
 
 2504    const std::string &dataexpr_rho = std::string(),
 
 2512   (model &md, 
const mesh_im &mim, 
const std::string &varname,
 
 2513    const std::string &dataexpr_rho = std::string(),
 
 2523   (model &md, 
const mesh_im &mim, 
const std::string &varname,
 
 2524    const std::string &dataname_dt,
 
 2525    const std::string &dataname_rho = std::string(),
 
 2536   (model &md, 
const mesh_im &mim, 
const std::string &varnameU,
 
 2537    const std::string &datanameV,
 
 2538    const std::string &dataname_dt,
 
 2539    const std::string &dataname_alpha,
 
 2540    const std::string &dataname_rho = std::string(),
 
base class for static stored objects
Deal with interdependencies of objects.
im_data provides indexing to the integration points of a mesh im object.
Describe a finite element method linked to a mesh.
virtual size_type nb_dof() const
Return the total number of degrees of freedom.
Describe an integration method linked to a mesh.
`‘Model’' variables store the variables, the data and the description of a model.
size_type nb_internal_dof() const
Number of internal degrees of freedom in the model.
bool interpolate_transformation_exists(const std::string &name) const
Tests if name corresponds to an interpolate transformation.
void update_from_context() const
this function has to be defined and should update the object when the context is modified.
const model_complex_sparse_matrix & complex_tangent_matrix() const
Gives the access to the tangent matrix.
psecondary_domain secondary_domain(const std::string &name) const
Get a pointer to the interpolate transformation name.
const model_real_plain_vector & real_brick_term_rhs(size_type ib, size_type ind_term=0, bool sym=false, size_type ind_iter=0) const
Gives access to the part of the right hand side of a term of a particular nonlinear brick.
void add_initialized_scalar_data(const std::string &name, T e)
Add a scalar data (i.e.
bool is_symmetric() const
Return true if all the model terms do not affect the coercivity of the whole tangent system.
pelementary_transformation elementary_transformation(const std::string &name) const
Get a pointer to the elementary transformation name.
bool is_linear() const
Return true if all the model terms are linear.
model_real_plain_vector & set_real_rhs(bool with_internal=false) const
Gives write access to the right hand side of the tangent linear system.
const dal::bit_vector & get_active_bricks() const
Return the model brick ids.
void enable_brick(size_type ib)
Enable a brick.
void add_initialized_fixed_size_data(const std::string &name, const VECT &v)
Add a fixed size data (assumed to be a vector) to the model and initialized with v.
const model_real_plain_vector & real_rhs(bool with_internal=false) const
Gives access to the right hand side of the tangent linear system.
const model_real_plain_vector & internal_solution() const
Gives access to the partial solution for condensed internal variables.
void add_elementary_transformation(const std::string &name, pelementary_transformation ptrans)
Add an elementary transformation to the model to be used with the generic assembly.
void add_initialized_fem_data(const std::string &name, const mesh_fem &mf, const VECT &v)
Add an initialized fixed size data to the model, assumed to be a vector field if the size of the vect...
void add_initialized_fem_data(const std::string &name, const mesh_fem &mf, const VECT &v, const bgeot::multi_index &sizes)
Add a fixed size data to the model.
const ga_macro_dictionary & macro_dictionary() const
Dictonnary of user defined macros.
bool secondary_domain_exists(const std::string &name) const
Tests if name corresponds to an interpolate transformation.
bool macro_exists(const std::string &name) const
Says if a macro of that name has been defined.
const model_complex_plain_vector & complex_rhs() const
Gives access to the right hand side of the tangent linear system.
void disable_brick(size_type ib)
Disable a brick.
bool is_complex() const
Boolean which says if the model deals with real or complex unknowns and data.
bool has_internal_variables() const
Return true if the model has at least one internal variable.
void add_interpolate_transformation(const std::string &name, pinterpolate_transformation ptrans)
Add an interpolate transformation to the model to be used with the generic assembly.
const model_complex_plain_vector & complex_brick_term_rhs(size_type ib, size_type ind_term=0, bool sym=false, size_type ind_iter=0) const
Gives access to the part of the right hand side of a term of a particular nonlinear brick.
void add_initialized_fixed_size_data(const std::string &name, const VECT &v, const bgeot::multi_index &sizes)
Add a fixed size data (assumed to be a vector) to the model and initialized with v.
void touch_brick(size_type ib)
Force the re-computation of a brick for the next assembly.
const model_real_sparse_matrix & real_tangent_matrix(bool internal=false) const
Gives the access to the tangent matrix.
bool is_coercive() const
Return true if all the model terms do not affect the coercivity of the whole tangent system.
bool elementary_transformation_exists(const std::string &name) const
Tests if name corresponds to an elementary transformation.
void add_secondary_domain(const std::string &name, psecondary_domain ptrans)
Add a secondary domain to the model to be used with the generic assembly.
size_type nb_primary_dof() const
Number of primary degrees of freedom in the model.
model_complex_plain_vector & set_complex_rhs() const
Gives write access to the right hand side of the tangent linear system.
pinterpolate_transformation interpolate_transformation(const std::string &name) const
Get a pointer to the interpolate transformation name.
The virtual brick has to be derived to describe real model bricks.
virtual void asm_complex_tangent_terms(const model &, size_type, const model::varnamelist &, const model::varnamelist &, const model::mimlist &, model::complex_matlist &, model::complex_veclist &, model::complex_veclist &, size_type, build_version) const
Assembly of bricks complex tangent terms.
virtual void complex_pre_assembly_in_serial(const model &, size_type, const model::varnamelist &, const model::varnamelist &, const model::mimlist &, model::complex_matlist &, model::complex_veclist &, model::complex_veclist &, size_type, build_version) const
Peform any pre assembly action for complex term assembly.
virtual void asm_real_tangent_terms(const model &, size_type, const model::varnamelist &, const model::varnamelist &, const model::mimlist &, model::real_matlist &, model::real_veclist &, model::real_veclist &, size_type, build_version) const
Assembly of bricks real tangent terms.
virtual std::string declare_volume_assembly_string(const model &, size_type, const model::varnamelist &, const model::varnamelist &) const
The brick may declare an assembly string for the computation of the Neumann terms (in order to prescr...
virtual void real_pre_assembly_in_serial(const model &, size_type, const model::varnamelist &, const model::varnamelist &, const model::mimlist &, model::real_matlist &, model::real_veclist &, model::real_veclist &, size_type, build_version) const
Peform any pre assembly action for real term assembly.
virtual void complex_post_assembly_in_serial(const model &, size_type, const model::varnamelist &, const model::varnamelist &, const model::mimlist &, model::complex_matlist &, model::complex_veclist &, model::complex_veclist &, size_type, build_version) const
Peform any post assembly action for complex terms.
virtual void real_post_assembly_in_serial(const model &, size_type, const model::varnamelist &, const model::varnamelist &, const model::mimlist &, model::real_matlist &, model::real_veclist &, model::real_veclist &, size_type, build_version) const
Peform any post assembly action for real terms.
The time dispatcher object modify the result of a brick in order to apply a time integration scheme.
The time integration scheme object provides the necessary methods for the model object to apply a tim...
sparse vector built upon std::vector.
Miscelleanous assembly routines for common terms. Use the low-level generic assembly....
A language for generic assembly of pde boundary value problems.
Provides indexing of integration points for mesh_im.
a subclass of getfem::mesh_fem which allows to eliminate a number of dof of the original mesh_fem.
void copy(const L1 &l1, L2 &l2)
*/
void resize(V &v, size_type n)
*/
size_t size_type
used as the common size type in the library
GEneric Tool for Finite Element Methods.
size_type APIDECL add_nonlinear_term(model &md, const mesh_im &mim, const std::string &expr, size_type region=size_type(-1), bool is_sym=false, bool is_coercive=false, const std::string &brickname="")
Add a nonlinear term given by the weak form language expression expr which will be assembled in regio...
size_type APIDECL add_pointwise_constraints_with_penalization(model &md, const std::string &varname, scalar_type penalisation_coeff, const std::string &dataname_pt, const std::string &dataname_unitv=std::string(), const std::string &dataname_val=std::string())
Add some pointwise constraints on the variable varname thanks to a penalization.
size_type APIDECL add_isotropic_linearized_elasticity_pstrain_brick(model &md, const mesh_im &mim, const std::string &varname, const std::string &data_E, const std::string &data_nu, size_type region)
Linear elasticity brick (  ).
bool is_old(const std::string &name)
Does the variable have Old_ prefix.
size_type APIDECL add_nonlinear_twodomain_term(model &md, const mesh_im &mim, const std::string &expr, size_type region, const std::string &secondary_domain, bool is_sym=false, bool is_coercive=false, const std::string &brickname="")
Adds a nonlinear term given by a weak form language expression like add_nonlinear_term function but f...
size_type APIDECL add_normal_source_term_brick(model &md, const mesh_im &mim, const std::string &varname, const std::string &dataexpr, size_type region)
Add a source term on the variable varname on a boundary region.
size_type APIDECL add_lumped_mass_for_first_order_brick(model &md, const mesh_im &mim, const std::string &varname, const std::string &dataexpr_rho=std::string(), size_type region=size_type(-1))
Lumped mass brick for first order.
size_type APIDECL add_Dirichlet_condition_with_multipliers(model &md, const mesh_im &mim, const std::string &varname, const std::string &multname, size_type region, const std::string &dataname=std::string())
Add a Dirichlet condition on the variable varname and the mesh region region.
void APIDECL change_penalization_coeff(model &md, size_type ind_brick, scalar_type penalisation_coeff)
Change the penalization coefficient of a Dirichlet condition with penalization brick.
size_type APIDECL add_isotropic_linearized_elasticity_brick(model &md, const mesh_im &mim, const std::string &varname, const std::string &dataname_lambda, const std::string &dataname_mu, size_type region=size_type(-1), const std::string &dataname_preconstraint=std::string())
Linear elasticity brick (  ).
size_type APIDECL add_pointwise_constraints_with_given_multipliers(model &md, const std::string &varname, const std::string &multname, const std::string &dataname_pt, const std::string &dataname_unitv=std::string(), const std::string &dataname_val=std::string())
Add some pointwise constraints on the variable varname using a given multiplier multname.
size_type APIDECL add_basic_d2_on_dt2_brick(model &md, const mesh_im &mim, const std::string &varnameU, const std::string &datanameV, const std::string &dataname_dt, const std::string &dataname_alpha, const std::string &dataname_rho=std::string(), size_type region=size_type(-1))
Basic d2/dt2 brick (  ).
const auto PREFIX_OLD
A prefix to refer to the previous version of a variable.
size_type APIDECL add_mass_brick(model &md, const mesh_im &mim, const std::string &varname, const std::string &dataexpr_rho=std::string(), size_type region=size_type(-1))
Mass brick (  ).
size_type APIDECL add_Laplacian_brick(model &md, const mesh_im &mim, const std::string &varname, size_type region=size_type(-1))
Add a Laplacian term on the variable varname (in fact with a minus : :math:-\text{div}(\nabla u)).
size_type APIDECL add_source_term(model &md, const mesh_im &mim, const std::string &expr, size_type region=size_type(-1), const std::string &brickname=std::string(), const std::string &directvarname=std::string(), const std::string &directdataname=std::string(), bool return_if_nonlin=false)
Add a source term given by the assembly string expr which will be assembled in region region and with...
size_type APIDECL add_generic_elliptic_brick(model &md, const mesh_im &mim, const std::string &varname, const std::string &dataexpr, size_type region=size_type(-1))
Add an elliptic term on the variable varname.
size_type APIDECL add_Dirichlet_condition_with_Nitsche_method(model &md, const mesh_im &mim, const std::string &varname, const std::string &Neumannterm, const std::string &datagamma0, size_type region, scalar_type theta=scalar_type(0), const std::string &datag=std::string())
Add a Dirichlet condition on the variable varname and the mesh region region.
size_type APIDECL add_Helmholtz_brick(model &md, const mesh_im &mim, const std::string &varname, const std::string &dataexpr, size_type region=size_type(-1))
Add a Helmoltz brick to the model.
void APIDECL velocity_update_for_order_two_theta_method(model &md, const std::string &U, const std::string &V, const std::string &pdt, const std::string &ptheta)
Function which udpate the velocity $v^{n+1}$ after the computation of the displacement $u^{n+1}$ and ...
void APIDECL velocity_update_for_Newmark_scheme(model &md, size_type id2dt2b, const std::string &U, const std::string &V, const std::string &pdt, const std::string &ptwobeta, const std::string &pgamma)
Function which udpate the velocity $v^{n+1}$ after the computation of the displacement $u^{n+1}$ and ...
size_type APIDECL add_generalized_Dirichlet_condition_with_multipliers(model &md, const mesh_im &mim, const std::string &varname, const std::string &multname, size_type region, const std::string &dataname, const std::string &Hname)
Add a generalized Dirichlet condition on the variable varname and the mesh region region.
size_type APIDECL add_pointwise_constraints_with_multipliers(model &md, const std::string &varname, const std::string &dataname_pt, const std::string &dataname_unitv=std::string(), const std::string &dataname_val=std::string())
Add some pointwise constraints on the variable varname using multiplier.
size_type APIDECL add_twodomain_source_term(model &md, const mesh_im &mim, const std::string &expr, size_type region, const std::string &secondary_domain, const std::string &brickname=std::string(), const std::string &directvarname=std::string(), const std::string &directdataname=std::string(), bool return_if_nonlin=false)
Adds a source term given by a weak form language expression like add_source_term function but for an ...
void APIDECL compute_isotropic_linearized_Von_Mises_pstress(model &md, const std::string &varname, const std::string &data_E, const std::string &data_nu, const mesh_fem &mf_vm, model_real_plain_vector &VM)
Compute the Von-Mises stress of a displacement field for isotropic linearized elasticity in 3D or in ...
size_type APIDECL add_linear_incompressibility(model &md, const mesh_im &mim, const std::string &varname, const std::string &multname_pressure, size_type region=size_type(-1), const std::string &dataexpr_penal_coeff=std::string())
Mixed linear incompressibility condition brick.
std::shared_ptr< const virtual_brick > pbrick
type of pointer on a brick
size_type APIDECL add_generalized_Dirichlet_condition_with_penalization(model &md, const mesh_im &mim, const std::string &varname, scalar_type penalization_coeff, size_type region, const std::string &dataname, const std::string &Hname, const mesh_fem *mf_mult=0)
Add a Dirichlet condition on the variable varname and the mesh region region.
size_type APIDECL add_linear_term(model &md, const mesh_im &mim, const std::string &expr, size_type region=size_type(-1), bool is_sym=false, bool is_coercive=false, const std::string &brickname="", bool return_if_nonlin=false)
Add a term given by the weak form language expression expr which will be assembled in region region a...
size_type APIDECL add_linear_twodomain_term(model &md, const mesh_im &mim, const std::string &expr, size_type region, const std::string &secondary_domain, bool is_sym=false, bool is_coercive=false, const std::string &brickname="", bool return_if_nonlin=false)
Adds a linear term given by a weak form language expression like add_linear_term function but for an ...
void APIDECL compute_isotropic_linearized_Von_Mises_pstrain(model &md, const std::string &varname, const std::string &data_E, const std::string &data_nu, const mesh_fem &mf_vm, model_real_plain_vector &VM)
Compute the Von-Mises stress of a displacement field for isotropic linearized elasticity in 3D or in ...
size_type APIDECL add_generalized_Dirichlet_condition_with_Nitsche_method(model &md, const mesh_im &mim, const std::string &varname, const std::string &Neumannterm, const std::string &datagamma0, size_type region, scalar_type theta, const std::string &datag, const std::string &dataH)
Add a Dirichlet condition on the variable varname and the mesh region region.
size_type APIDECL add_Dirichlet_condition_with_penalization(model &md, const mesh_im &mim, const std::string &varname, scalar_type penalization_coeff, size_type region, const std::string &dataname=std::string(), const mesh_fem *mf_mult=0)
Add a Dirichlet condition on the variable varname and the mesh region region.
void APIDECL add_midpoint_dispatcher(model &md, dal::bit_vector ibricks)
Add a midpoint time dispatcher to a list of bricks.
size_type APIDECL add_Fourier_Robin_brick(model &md, const mesh_im &mim, const std::string &varname, const std::string &dataexpr, size_type region)
Add a Fourier-Robin brick to the model.
void APIDECL add_theta_method_dispatcher(model &md, dal::bit_vector ibricks, const std::string &THETA)
Add a theta-method time dispatcher to a list of bricks.
size_type APIDECL add_normal_Dirichlet_condition_with_penalization(model &md, const mesh_im &mim, const std::string &varname, scalar_type penalization_coeff, size_type region, const std::string &dataname=std::string(), const mesh_fem *mf_mult=0)
Add a Dirichlet condition to the normal component of the vector (or tensor) valued variable varname a...
size_type APIDECL add_isotropic_linearized_elasticity_pstress_brick(model &md, const mesh_im &mim, const std::string &varname, const std::string &data_E, const std::string &data_nu, size_type region)
Linear elasticity brick (  ).
size_type APIDECL add_basic_d_on_dt_brick(model &md, const mesh_im &mim, const std::string &varname, const std::string &dataname_dt, const std::string &dataname_rho=std::string(), size_type region=size_type(-1))
Basic d/dt brick (  ).
size_type APIDECL add_source_term_brick(model &md, const mesh_im &mim, const std::string &varname, const std::string &dataexpr, size_type region=size_type(-1), const std::string &directdataname=std::string())
Add a source term on the variable varname.
size_type APIDECL add_normal_Dirichlet_condition_with_Nitsche_method(model &md, const mesh_im &mim, const std::string &varname, const std::string &Neumannterm, const std::string &datagamma0, size_type region, scalar_type theta=scalar_type(0), const std::string &datag=std::string())
Add a Dirichlet condition on the normal component of the variable varname and the mesh region region.
size_type APIDECL add_normal_Dirichlet_condition_with_multipliers(model &md, const mesh_im &mim, const std::string &varname, const std::string &multname, size_type region, const std::string &dataname=std::string())
Add a Dirichlet condition to the normal component of the vector (or tensor) valued variable varname a...
const APIDECL std::string & mult_varname_Dirichlet(model &md, size_type ind_brick)
When ind_brick is the index of a Dirichlet brick with multiplier on the model md, the function return...
size_type APIDECL add_Dirichlet_condition_with_simplification(model &md, const std::string &varname, size_type region, const std::string &dataname=std::string())
Add a (simple) Dirichlet condition on the variable varname and the mesh region region.
std::string no_old_prefix_name(const std::string &name)
Strip the variable name from prefix Old_ if it has one.