38 #ifndef GETFEM_MODELS_H__
39 #define GETFEM_MODELS_H__
50 typedef std::shared_ptr<const virtual_brick>
pbrick;
53 typedef std::shared_ptr<const virtual_dispatcher> pdispatcher;
56 typedef std::shared_ptr<const virtual_time_scheme> ptime_scheme;
88 typedef model_real_plain_vector modeling_standard_plain_vector;
90 typedef model_real_sparse_matrix modeling_standard_sparse_matrix;
91 typedef model_complex_plain_vector modeling_standard_complex_plain_vector;
93 typedef model_complex_sparse_matrix modeling_standard_complex_sparse_matrix;
98 const auto PREFIX_OLD_LENGTH = 4;
101 bool is_old(
const std::string &name);
106 std::string sup_previous_and_dot_to_varname(std::string v);
119 bool complex_version;
123 mutable model_real_sparse_matrix
126 mutable model_complex_sparse_matrix cTM;
127 mutable model_real_plain_vector
131 mutable model_complex_plain_vector crhs;
132 mutable bool act_size_to_be_done;
133 dim_type leading_dim;
134 getfem::lock_factory locks_;
138 enum var_description_filter {
140 VDESCRFILTER_REGION = 1,
142 VDESCRFILTER_INFSUP = 2,
145 VDESCRFILTER_CTERM = 4,
148 VDESCRFILTER_REGION_CTERM = 5,
151 struct var_description {
156 bool is_affine_dependent;
166 var_description_filter filter;
169 std::string filter_var;
174 ppartial_mesh_fem partial_mf;
177 bgeot::multi_index qdims;
180 gmm::uint64_type v_num;
181 std::vector<gmm::uint64_type> v_num_data;
186 std::vector<model_real_plain_vector> real_value;
187 std::vector<model_complex_plain_vector> complex_value;
188 std::vector<gmm::uint64_type> v_num_var_iter;
189 std::vector<gmm::uint64_type> v_num_iter;
192 model_real_plain_vector affine_real_value;
193 model_complex_plain_vector affine_complex_value;
195 std::string org_name;
198 var_description(
bool is_var =
false,
bool is_compl =
false,
201 var_description_filter filter_ = VDESCRFILTER_NO,
203 const std::string &filter_var_ = std::string(
""),
204 mesh_im const *filter_mim_ = 0)
205 : is_variable(is_var), is_disabled(
false), is_complex(is_compl),
206 is_affine_dependent(
false), is_internal(
false),
207 n_iter(std::max(
size_type(1), n_it)), n_temp_iter(0),
208 default_iter(0), ptsc(0),
209 filter(filter_), filter_region(filter_reg), filter_var(filter_var_),
210 filter_mim(filter_mim_), mf(mf_), imd(imd_), qdims(),
211 v_num(0), v_num_data(n_iter, act_counter()), I(0,0), alpha(1)
213 if (filter != VDESCRFILTER_NO && mf != 0)
214 partial_mf = std::make_shared<partial_mesh_fem>(*mf);
216 if (qdims.size() == 0) qdims.push_back(1);
217 GMM_ASSERT1(qdim(),
"Attempt to create a null size variable");
220 size_type qdim()
const {
return qdims.total_size(); }
225 size_type add_temporary(gmm::uint64_type id_num);
227 void clear_temporaries();
229 const mesh_fem &associated_mf()
const {
230 GMM_ASSERT1(mf,
"This variable is not linked to a fem");
231 return (filter == VDESCRFILTER_NO) ? *mf : *partial_mf;
234 const mesh_fem *passociated_mf()
const {
236 return (filter == VDESCRFILTER_NO || partial_mf.get() == 0)
237 ? mf : partial_mf.get();
243 return is_complex ? complex_value[0].size()
244 : real_value[0].size();
246 inline bool is_enabled()
const {
return !is_disabled; }
253 typedef std::vector<std::string> varnamelist;
254 typedef std::vector<const mesh_im *> mimlist;
255 typedef std::vector<model_real_sparse_matrix> real_matlist;
256 typedef std::vector<model_complex_sparse_matrix> complex_matlist;
257 typedef std::vector<model_real_plain_vector> real_veclist;
258 typedef std::vector<model_complex_plain_vector> complex_veclist;
260 struct term_description {
264 std::string var1, var2;
266 term_description(
const std::string &v)
267 : is_matrix_term(
false), is_symmetric(
false),
268 is_global(
false), var1(sup_previous_and_dot_to_varname(v)) {}
269 term_description(
const std::string &v1,
const std::string &v2,
271 : is_matrix_term(
true), is_symmetric(issym), is_global(
false),
272 var1(sup_previous_and_dot_to_varname(v1)), var2(v2) {}
273 term_description(
bool ism,
bool issym)
274 : is_matrix_term(ism), is_symmetric(issym), is_global(
true) {}
277 typedef std::vector<term_description> termlist;
283 BUILD_ON_DATA_CHANGE = 4,
285 BUILD_RHS_WITH_LIN = 9,
286 BUILD_WITH_INTERNAL = 16,
287 BUILD_RHS_WITH_INTERNAL = 17,
288 BUILD_MATRIX_CONDENSED = 18,
289 BUILD_ALL_CONDENSED = 19,
296 struct brick_description {
297 mutable bool terms_to_be_computed;
298 mutable gmm::uint64_type v_num;
300 pdispatcher pdispatch;
307 bool is_update_brick;
309 mutable scalar_type external_load;
311 mutable model_real_plain_vector coeffs;
312 mutable scalar_type matrix_coeff = scalar_type(0);
314 mutable real_matlist rmatlist;
316 mutable std::vector<real_veclist> rveclist;
318 mutable std::vector<real_veclist> rveclist_sym;
320 mutable complex_matlist cmatlist;
322 mutable std::vector<complex_veclist> cveclist;
324 mutable std::vector<complex_veclist> cveclist_sym;
326 brick_description() : v_num(0) {}
328 brick_description(
pbrick p,
const varnamelist &vl,
329 const varnamelist &dl,
const termlist &tl,
331 : terms_to_be_computed(
true), v_num(0), pbr(p), pdispatch(0), nbrhs(1),
332 vlist(vl), dlist(dl), tlist(tl), mims(mms), region(reg),
333 is_update_brick(
false), external_load(0),
334 rveclist(1), rveclist_sym(1), cveclist(1),
338 typedef std::map<std::string, var_description> VAR_SET;
339 mutable VAR_SET variables;
340 std::vector<brick_description> bricks;
341 dal::bit_vector valid_bricks, active_bricks;
342 std::map<std::string, pinterpolate_transformation> transformations;
343 std::map<std::string, pelementary_transformation> elem_transformations;
344 std::map<std::string, psecondary_domain> secondary_domains;
347 int time_integration;
349 scalar_type time_step;
350 scalar_type init_time_step;
353 typedef std::map<size_type, scalar_type> real_dof_constraints_var;
354 typedef std::map<size_type, complex_type> complex_dof_constraints_var;
355 mutable std::map<std::string, real_dof_constraints_var>
356 real_dof_constraints;
357 mutable std::map<std::string, complex_dof_constraints_var>
358 complex_dof_constraints;
359 void clear_dof_constraints()
360 { real_dof_constraints.clear(); complex_dof_constraints.clear(); }
367 std::string secondary_domain;
368 gen_expr(
const std::string &expr_,
const mesh_im &mim_,
369 size_type region_,
const std::string &secdom)
370 : expr(expr_), mim(mim_), region(region_), secondary_domain(secdom) {}
374 struct assignement_desc {
382 std::list<assignement_desc> assignments;
384 mutable std::list<gen_expr> generic_expressions;
388 std::map<std::string, std::vector<std::string> > variable_groups;
390 ga_macro_dictionary macro_dict;
393 virtual void actualize_sizes()
const;
394 bool check_name_validity(
const std::string &name,
bool assert=
true)
const;
395 void brick_init(
size_type ib, build_version version,
398 void init() { complex_version =
false; act_size_to_be_done =
false; }
400 void resize_global_system()
const;
403 virtual void post_to_variables_step();
405 scalar_type approx_external_load_;
408 VAR_SET::const_iterator find_variable(
const std::string &name)
const;
409 const var_description &variable_description(
const std::string &name)
const;
413 void add_generic_expression(
const std::string &expr,
const mesh_im &mim,
415 const std::string &secondary_domain =
"")
const {
416 generic_expressions.push_back(gen_expr(expr, mim, region,
419 void add_external_load(
size_type ib, scalar_type e)
const
420 { bricks[ib].external_load = e; }
421 scalar_type approx_external_load() {
return approx_external_load_; }
423 void update_brick(
size_type ib, build_version version)
const;
426 void update_affine_dependent_variables();
427 void brick_call(
size_type ib, build_version version,
429 model_real_plain_vector &rhs_coeffs_of_brick(
size_type ib)
const
430 {
return bricks[ib].coeffs; }
431 scalar_type &matrix_coeff_of_brick(
size_type ib)
const
432 {
return bricks[ib].matrix_coeff; }
433 bool is_var_newer_than_brick(
const std::string &varname,
435 bool is_var_mf_newer_than_brick(
const std::string &varname,
437 bool is_mim_newer_than_brick(
const mesh_im &mim,
441 GMM_ASSERT1(valid_bricks[ib],
"Inexistent brick");
442 return bricks[ib].pbr;
445 void variable_list(varnamelist &vl)
const
446 {
for (
const auto &v : variables) vl.push_back(v.first); }
448 void define_variable_group(
const std::string &group_name,
449 const std::vector<std::string> &nl);
450 bool variable_group_exists(
const std::string &group_name)
const
451 {
return variable_groups.count(group_name) > 0; }
453 const std::vector<std::string> &
454 variable_group(
const std::string &group_name)
const {
455 GMM_ASSERT1(variable_group_exists(group_name),
456 "Undefined variable group " << group_name);
457 return (variable_groups.find(group_name))->second;
460 void clear_assembly_assignments(
void) { assignments.clear(); }
461 void add_assembly_assignments(
const std::string &dataname,
462 const std::string &expr,
465 bool before =
false);
468 void add_real_dof_constraint(
const std::string &varname,
size_type dof,
469 scalar_type val)
const
470 { real_dof_constraints[varname][dof] = val; }
472 void add_complex_dof_constraint(
const std::string &varname,
size_type dof,
473 complex_type val)
const
474 { complex_dof_constraints[varname][dof] = val; }
477 void add_temporaries(
const varnamelist &vl, gmm::uint64_type id_num)
const;
479 const mimlist &mimlist_of_brick(
size_type ib)
const
480 {
return bricks[ib].mims; }
482 const varnamelist &varnamelist_of_brick(
size_type ib)
const
483 {
return bricks[ib].vlist; }
485 const varnamelist &datanamelist_of_brick(
size_type ib)
const
486 {
return bricks[ib].dlist; }
489 {
return bricks[ib].region; }
491 bool temporary_uptodate(
const std::string &varname,
492 gmm::uint64_type id_num,
size_type &ind)
const;
494 size_type n_iter_of_variable(
const std::string &name)
const {
495 return variables.count(name) == 0 ?
size_type(0)
496 : variables[name].n_iter;
499 void set_default_iter_of_variable(
const std::string &varname,
501 void reset_default_iter_of_variables(
const varnamelist &vl)
const;
505 const model_real_sparse_matrix &linear_real_matrix_term
508 const model_complex_sparse_matrix &linear_complex_matrix_term
513 GMM_ASSERT1(valid_bricks[ib],
"Inexistent brick");
514 active_bricks.del(ib);
519 GMM_ASSERT1(valid_bricks[ib],
"Inexistent brick");
520 active_bricks.add(ib);
524 void disable_variable(
const std::string &name);
527 void enable_variable(
const std::string &name,
bool enabled=
true);
530 bool variable_exists(
const std::string &name)
const;
533 bool is_disabled_variable(
const std::string &name)
const;
536 bool is_data(
const std::string &name)
const;
539 bool is_true_data(
const std::string &name)
const;
542 bool is_internal_variable(
const std::string &name)
const;
544 bool is_affine_dependent_variable(
const std::string &name)
const;
546 const std::string &org_variable(
const std::string &name)
const;
548 const scalar_type &factor_of_variable(
const std::string &name)
const;
550 void set_factor_of_variable(
const std::string &name, scalar_type a);
552 bool is_im_data(
const std::string &name)
const;
554 const im_data *pim_data_of_variable(
const std::string &name)
const;
556 const gmm::uint64_type &
557 version_number_of_data_variable(
const std::string &varname,
570 for (
const auto &v : variables)
571 if (v.second.is_internal && !v.second.is_disabled)
return true;
583 size_type nb_dof(
bool with_internal=
false)
const;
592 dim_type leading_dimension()
const {
return leading_dim; }
595 std::string new_name(
const std::string &name);
597 const gmm::sub_interval &
598 interval_of_variable(
const std::string &name)
const;
602 const model_real_plain_vector &
603 real_variable(
const std::string &name,
size_type niter)
const;
607 const model_real_plain_vector &
608 real_variable(
const std::string &name)
const;
612 const model_complex_plain_vector &
613 complex_variable(
const std::string &name,
size_type niter)
const;
617 const model_complex_plain_vector &
618 complex_variable(
const std::string &name)
const;
622 model_real_plain_vector &
623 set_real_variable(
const std::string &name,
size_type niter)
const;
627 model_real_plain_vector &
628 set_real_variable(
const std::string &name)
const;
632 model_complex_plain_vector &
633 set_complex_variable(
const std::string &name,
size_type niter)
const;
637 model_complex_plain_vector &
638 set_complex_variable(
const std::string &name)
const;
640 model_real_plain_vector &
641 set_real_constant_part(
const std::string &name)
const;
643 model_complex_plain_vector &
644 set_complex_constant_part(
const std::string &name)
const;
647 template<
typename VECTOR,
typename T>
648 void from_variables(VECTOR &V,
bool with_internal, T)
const {
649 for (
const auto &v : variables)
650 if (v.second.is_variable && !v.second.is_affine_dependent
651 && !v.second.is_disabled
652 && (with_internal || !v.second.is_internal))
653 gmm::copy(v.second.real_value[0], gmm::sub_vector(V, v.second.I));
656 template<
typename VECTOR,
typename T>
657 void from_variables(VECTOR &V,
bool with_internal, std::complex<T>)
const {
658 for (
const auto &v : variables)
659 if (v.second.is_variable && !v.second.is_affine_dependent
660 && !v.second.is_disabled
661 && (with_internal || !v.second.is_internal))
662 gmm::copy(v.second.complex_value[0], gmm::sub_vector(V, v.second.I));
666 template<
typename VECTOR>
667 void from_variables(VECTOR &V,
bool with_internal=
false)
const {
668 typedef typename gmm::linalg_traits<VECTOR>::value_type T;
669 context_check();
if (act_size_to_be_done) actualize_sizes();
670 from_variables(V, with_internal, T());
674 template<
typename VECTOR,
typename T>
675 void to_variables(
const VECTOR &V,
bool with_internal, T) {
676 for (
auto &&v : variables)
677 if (v.second.is_variable && !v.second.is_affine_dependent
678 && !v.second.is_disabled
679 && (with_internal || !v.second.is_internal)) {
680 gmm::copy(gmm::sub_vector(V, v.second.I), v.second.real_value[0]);
681 v.second.v_num_data[0] = act_counter();
683 update_affine_dependent_variables();
684 this->post_to_variables_step();
687 template<
typename VECTOR,
typename T>
688 void to_variables(
const VECTOR &V,
bool with_internal, std::complex<T>) {
689 for (
auto &&v : variables)
690 if (v.second.is_variable && !v.second.is_affine_dependent
691 && !v.second.is_disabled
692 && (with_internal || !v.second.is_internal)) {
693 gmm::copy(gmm::sub_vector(V, v.second.I), v.second.complex_value[0]);
694 v.second.v_num_data[0] = act_counter();
696 update_affine_dependent_variables();
697 this->post_to_variables_step();
701 template<
typename VECTOR>
702 void to_variables(
const VECTOR &V,
bool with_internal=
false) {
703 typedef typename gmm::linalg_traits<VECTOR>::value_type T;
704 context_check();
if (act_size_to_be_done) actualize_sizes();
705 to_variables(V, with_internal, T());
710 void add_fixed_size_variable(
const std::string &name,
size_type size,
715 void add_fixed_size_variable(
const std::string &name,
716 const bgeot::multi_index &sizes,
721 void add_fixed_size_data(
const std::string &name,
size_type size,
726 void add_fixed_size_data(
const std::string &name,
727 const bgeot::multi_index &sizes,
731 void resize_fixed_size_variable(
const std::string &name,
size_type size);
734 void resize_fixed_size_variable(
const std::string &name,
735 const bgeot::multi_index &sizes);
739 template <
typename VECT>
742 this->add_fixed_size_data(name, gmm::vect_size(v));
743 if (this->is_complex())
744 gmm::copy(v, this->set_complex_variable(name));
746 gmm::copy(gmm::real_part(v), this->set_real_variable(name));
751 template <
typename VECT>
754 const bgeot::multi_index &sizes) {
755 this->add_fixed_size_data(name, sizes);
756 if (this->is_complex())
757 gmm::copy(v, this->set_complex_variable(name));
759 gmm::copy(gmm::real_part(v), this->set_real_variable(name));
764 void add_initialized_matrix_data(
const std::string &name,
765 const base_matrix &M);
766 void add_initialized_matrix_data(
const std::string &name,
767 const base_complex_matrix &M);
771 void add_initialized_tensor_data(
const std::string &name,
772 const base_tensor &t);
773 void add_initialized_tensor_data(
const std::string &name,
774 const base_complex_tensor &t);
778 template <
typename T>
780 this->add_fixed_size_data(name, 1, 1);
781 if (this->is_complex())
782 this->set_complex_variable(name)[0] = e;
784 this->set_real_variable(name)[0] = gmm::real(e);
789 void add_im_variable(
const std::string &name,
const im_data &imd,
792 void add_internal_im_variable(
const std::string &name,
795 void add_im_data(
const std::string &name,
const im_data &imd,
801 void add_fem_variable(
const std::string &name,
const mesh_fem &mf,
808 void add_filtered_fem_variable(
const std::string &name,
const mesh_fem &mf,
816 void add_affine_dependent_variable(
const std::string &name,
817 const std::string &org_name,
818 scalar_type alpha = scalar_type(1));
821 void add_fem_data(
const std::string &name,
const mesh_fem &mf,
825 void add_fem_data(
const std::string &name,
const mesh_fem &mf,
826 const bgeot::multi_index &sizes,
size_type niter = 1);
831 template <
typename VECT>
834 this->add_fem_data(name, mf,
835 dim_type(gmm::vect_size(v) / mf.
nb_dof()), 1);
836 if (this->is_complex())
837 gmm::copy(v, this->set_complex_variable(name));
839 gmm::copy(gmm::real_part(v), this->set_real_variable(name));
844 template <
typename VECT>
847 const bgeot::multi_index &sizes) {
848 this->add_fem_data(name, mf, sizes, 1);
849 if (this->is_complex())
850 gmm::copy(v, this->set_complex_variable(name));
852 gmm::copy(gmm::real_part(v), this->set_real_variable(name));
861 void add_multiplier(
const std::string &name,
const mesh_fem &mf,
862 const std::string &primal_name,
872 void add_multiplier(
const std::string &name,
const mesh_fem &mf,
873 size_type region,
const std::string &primal_name,
882 void add_multiplier(
const std::string &name,
const mesh_fem &mf,
883 const std::string &primal_name,
const mesh_im &mim,
892 void add_macro(
const std::string &name,
const std::string &expr);
895 void del_macro(
const std::string &name);
899 {
return macro_dict.macro_exists(name); }
902 void delete_variable(
const std::string &varname);
906 const mesh_fem &mesh_fem_of_variable(
const std::string &name)
const;
909 const mesh_fem *pmesh_fem_of_variable(
const std::string &name)
const;
912 bgeot::multi_index qdims_of_variable(
const std::string &name)
const;
913 size_type qdim_of_variable(
const std::string &name)
const;
916 const model_real_sparse_matrix &
918 GMM_ASSERT1(!complex_version,
"This model is a complex one");
919 context_check();
if (act_size_to_be_done) actualize_sizes();
920 return internal ? internal_rTM : rTM;
925 GMM_ASSERT1(complex_version,
"This model is a real one");
926 context_check();
if (act_size_to_be_done) actualize_sizes();
932 const model_real_plain_vector &
real_rhs(
bool with_internal=
false)
const {
933 GMM_ASSERT1(!complex_version,
"This model is a complex one");
934 context_check();
if (act_size_to_be_done) actualize_sizes();
935 return (with_internal && gmm::vect_size(full_rrhs)) ? full_rrhs : rrhs;
941 model_real_plain_vector &
set_real_rhs(
bool with_internal=
false)
const {
942 GMM_ASSERT1(!complex_version,
"This model is a complex one");
943 context_check();
if (act_size_to_be_done) actualize_sizes();
944 return (with_internal && gmm::vect_size(full_rrhs)) ? full_rrhs : rrhs;
950 GMM_ASSERT1(!complex_version,
"This model is a complex one");
951 context_check();
if (act_size_to_be_done) actualize_sizes();
963 GMM_ASSERT1(!complex_version,
"This model is a complex one");
964 context_check();
if (act_size_to_be_done) actualize_sizes();
965 GMM_ASSERT1(valid_bricks[ib],
"Inexistent brick");
966 GMM_ASSERT1(ind_term < bricks[ib].tlist.size(),
"Inexistent term");
967 GMM_ASSERT1(ind_iter < bricks[ib].nbrhs,
"Inexistent iter");
968 GMM_ASSERT1(!sym || bricks[ib].tlist[ind_term].is_symmetric,
969 "Term is not symmetric");
971 return bricks[ib].rveclist_sym[ind_iter][ind_term];
973 return bricks[ib].rveclist[ind_iter][ind_term];
979 GMM_ASSERT1(complex_version,
"This model is a real one");
980 context_check();
if (act_size_to_be_done) actualize_sizes();
988 GMM_ASSERT1(complex_version,
"This model is a real one");
989 context_check();
if (act_size_to_be_done) actualize_sizes();
1001 GMM_ASSERT1(!complex_version,
"This model is a complex one");
1002 context_check();
if (act_size_to_be_done) actualize_sizes();
1003 GMM_ASSERT1(valid_bricks[ib],
"Inexistent brick");
1004 GMM_ASSERT1(ind_term < bricks[ib].tlist.size(),
"Inexistent term");
1005 GMM_ASSERT1(ind_iter < bricks[ib].nbrhs,
"Inexistent iter");
1006 GMM_ASSERT1(!sym || bricks[ib].tlist[ind_term].is_symmetric,
1007 "Term is not symmetric");
1009 return bricks[ib].cveclist_sym[ind_iter][ind_term];
1011 return bricks[ib].cveclist[ind_iter][ind_term];
1015 void listvar(std::ostream &ost)
const;
1017 void listresiduals(std::ostream &ost)
const;
1020 void listbricks(std::ostream &ost,
size_type base_id = 0)
const;
1024 return active_bricks;
1029 GMM_ASSERT1(valid_bricks[ib],
"Inexistent brick");
1030 bricks[ib].terms_to_be_computed =
true;
1038 const varnamelist &datanames,
1039 const termlist &terms,
const mimlist &mims,
1049 void change_terms_of_brick(
size_type ib,
const termlist &terms);
1053 void change_variables_of_brick(
size_type ib,
const varnamelist &vl);
1057 void change_data_of_brick(
size_type ib,
const varnamelist &vl);
1061 void change_mims_of_brick(
size_type ib,
const mimlist &ml);
1065 void change_update_flag_of_brick(
size_type ib,
bool flag);
1067 void set_time(scalar_type t = scalar_type(0),
bool to_init =
true);
1069 scalar_type get_time();
1071 void set_time_step(scalar_type dt) { time_step = dt; }
1072 scalar_type get_time_step()
const {
return time_step; }
1073 scalar_type get_init_time_step()
const {
return init_time_step; }
1074 int is_time_integration()
const {
return time_integration; }
1075 void set_time_integration(
int ti) { time_integration = ti; }
1076 bool is_init_step()
const {
return init_step; }
1077 void cancel_init_step() { init_step =
false; }
1078 void call_init_affine_dependent_variables(
int version);
1079 void shift_variables_for_time_integration();
1080 void copy_init_time_derivative();
1081 void add_time_integration_scheme(
const std::string &varname,
1083 void perform_init_time_derivative(scalar_type ddt)
1084 { init_step =
true; init_time_step = ddt; }
1088 void add_time_dispatcher(
size_type ibrick, pdispatcher pdispatch);
1090 void set_dispatch_coeff();
1093 virtual void first_iter();
1098 virtual void next_iter();
1104 pinterpolate_transformation ptrans) {
1105 if (secondary_domain_exists(name))
1106 GMM_ASSERT1(
false,
"An secondary domain with the same "
1107 "name already exists");
1108 if (transformations.count(name) > 0)
1109 GMM_ASSERT1(name.compare(
"neighbor_element"),
"neighbor_element is a "
1110 "reserved interpolate transformation name");
1111 transformations[name] = ptrans;
1116 pinterpolate_transformation
1118 std::map<std::string, pinterpolate_transformation>::const_iterator
1119 it = transformations.find(name);
1120 GMM_ASSERT1(it != transformations.end(),
"Inexistent transformation " << name);
1127 {
return transformations.count(name) > 0; }
1133 pelementary_transformation ptrans) {
1134 elem_transformations[name] = ptrans;
1139 pelementary_transformation
1141 std::map<std::string, pelementary_transformation>::const_iterator
1142 it = elem_transformations.find(name);
1143 GMM_ASSERT1(it != elem_transformations.end(),
1144 "Inexistent elementary transformation " << name);
1151 {
return elem_transformations.count(name) > 0; }
1158 psecondary_domain ptrans) {
1159 if (interpolate_transformation_exists(name))
1160 GMM_ASSERT1(
false,
"An interpolate transformation with the same "
1161 "name already exists");secondary_domains[name] = ptrans;
1168 auto it = secondary_domains.find(name);
1169 GMM_ASSERT1(it != secondary_domains.end(),
1170 "Inexistent transformation " << name);
1177 {
return secondary_domains.count(name) > 0; }
1181 const std::string &varname_of_brick(
size_type ind_brick,
1186 const std::string &dataname_of_brick(
size_type ind_brick,
1228 virtual void assembly(build_version version);
1238 std::string Neumann_term(
const std::string &varname,
size_type region);
1240 virtual void clear();
1242 explicit model(
bool comp_version =
false);
1247 void check_brick_stiffness_rhs(
size_type ind_brick)
const;
1266 virtual void init_affine_dependent_variables(
model &md)
const = 0;
1267 virtual void init_affine_dependent_variables_precomputation(
model &md)
1269 virtual void time_derivative_to_be_initialized
1270 (std::string &name_v, std::string &name_previous_v)
const = 0;
1271 virtual void shift_variables(
model &md)
const = 0;
1275 void add_theta_method_for_first_order(
model &md,
const std::string &varname,
1278 void add_theta_method_for_second_order(
model &md,
const std::string &varname,
1281 void add_Newmark_scheme(
model &md,
const std::string &varname,
1282 scalar_type beta, scalar_type gamma);
1284 void add_Houbolt_scheme(
model &md,
const std::string &varname);
1302 std::vector<std::string> param_names;
1306 size_type nbrhs()
const {
return nbrhs_; }
1308 typedef model::build_version build_version;
1311 { GMM_ASSERT1(
false,
"Time dispatcher with not set_dispatch_coeff !"); }
1313 virtual void next_real_iter
1315 const model::varnamelist &,
1316 model::real_matlist &,
1317 std::vector<model::real_veclist> &,
1318 std::vector<model::real_veclist> &,
1320 GMM_ASSERT1(
false,
"Time dispatcher with not defined first real iter !");
1323 virtual void next_complex_iter
1325 const model::varnamelist &,
1326 model::complex_matlist &,
1327 std::vector<model::complex_veclist> &,
1328 std::vector<model::complex_veclist> &,
1330 GMM_ASSERT1(
false,
"Time dispatcher with not defined first comples iter");
1333 virtual void asm_real_tangent_terms
1335 model::real_matlist &, std::vector<model::real_veclist> &,
1336 std::vector<model::real_veclist> &,
1337 build_version)
const {
1338 GMM_ASSERT1(
false,
"Time dispatcher with not defined real tangent "
1342 virtual void asm_complex_tangent_terms
1344 model::complex_matlist &, std::vector<model::complex_veclist> &,
1345 std::vector<model::complex_veclist> &,
1346 build_version)
const {
1347 GMM_ASSERT1(
false,
"Time dispatcher with not defined complex tangent "
1352 GMM_ASSERT1(_nbrhs > 0,
"Time dispatcher with no rhs");
1368 typedef model::build_version build_version;
1372 template <
typename MATLIST,
typename VECTLIST>
1374 const model::varnamelist &,
1375 const model::varnamelist &,
1377 VECTLIST &vectl, VECTLIST &vectl_sym,
1378 bool first_iter)
const {
1379 if (first_iter) md.update_brick(ib, model::BUILD_RHS);
1382 for (
size_type i = 0; i < vectl[0].size(); ++i)
1383 gmm::copy(vectl[0][i], vectl[1][i]);
1384 for (
size_type i = 0; i < vectl_sym[0].size(); ++i)
1385 gmm::copy(vectl_sym[0][i], vectl_sym[1][i]);
1389 md.linear_brick_add_to_rhs(ib, 1, 0);
1393 (
const model &md,
size_type ib,
const model::varnamelist &vl,
1394 const model::varnamelist &dl, model::real_matlist &matl,
1395 std::vector<model::real_veclist> &vectl,
1396 std::vector<model::real_veclist> &vectl_sym,
bool first_iter)
const;
1398 void next_complex_iter
1399 (
const model &md,
size_type ib,
const model::varnamelist &vl,
1400 const model::varnamelist &dl,
1401 model::complex_matlist &matl,
1402 std::vector<model::complex_veclist> &vectl,
1403 std::vector<model::complex_veclist> &vectl_sym,
1404 bool first_iter)
const;
1406 void asm_real_tangent_terms
1407 (
const model &md,
size_type ib, model::real_matlist &,
1408 std::vector<model::real_veclist> &,
1409 std::vector<model::real_veclist> &,
1410 build_version version)
const;
1412 virtual void asm_complex_tangent_terms
1413 (
const model &md,
size_type ib, model::complex_matlist &,
1414 std::vector<model::complex_veclist> &,
1415 std::vector<model::complex_veclist> &,
1416 build_version version)
const;
1418 theta_method_dispatcher(
const std::string &THETA);
1432 const std::string &THETA);
1440 (model &md,
const std::string &U,
const std::string &V,
1441 const std::string &pdt,
const std::string &ptheta);
1457 (model &md,
size_type id2dt2b,
const std::string &U,
const std::string &V,
1458 const std::string &pdt,
const std::string &ptwobeta,
1459 const std::string &pgamma);
1483 bool compute_each_time;
1491 typedef model::build_version build_version;
1495 void set_flags(
const std::string &bname,
bool islin,
bool issym,
1496 bool iscoer,
bool ire,
bool isco,
bool each_time =
false) {
1498 islinear = islin; issymmetric = issym; iscoercive = iscoer;
1499 isreal = ire; iscomplex = isco; isinit =
true;
1500 compute_each_time = each_time;
1503 # define BRICK_NOT_INIT GMM_ASSERT1(isinit, "Set brick flags !")
1504 bool is_linear()
const { BRICK_NOT_INIT;
return islinear; }
1505 bool is_symmetric()
const { BRICK_NOT_INIT;
return issymmetric; }
1506 bool is_coercive()
const { BRICK_NOT_INIT;
return iscoercive; }
1507 bool is_real()
const { BRICK_NOT_INIT;
return isreal; }
1508 bool is_complex()
const { BRICK_NOT_INIT;
return iscomplex; }
1509 bool is_to_be_computed_each_time()
const
1510 { BRICK_NOT_INIT;
return compute_each_time; }
1511 const std::string &brick_name()
const { BRICK_NOT_INIT;
return name; }
1528 const model::varnamelist &,
1529 const model::varnamelist &,
1530 const model::mimlist &,
1531 model::real_matlist &,
1532 model::real_veclist &,
1533 model::real_veclist &,
1554 const model::varnamelist &,
1555 const model::varnamelist &,
1556 const model::mimlist &,
1557 model::complex_matlist &,
1558 model::complex_veclist &,
1559 model::complex_veclist &,
1572 const model::varnamelist &,
1573 const model::varnamelist &,
1574 const model::mimlist &,
1575 model::real_matlist &,
1576 model::real_veclist &,
1577 model::real_veclist &,
1586 const model::varnamelist &,
1587 const model::varnamelist &,
1588 const model::mimlist &,
1589 model::complex_matlist &,
1590 model::complex_veclist &,
1591 model::complex_veclist &,
1600 const model::varnamelist &,
1601 const model::varnamelist &,
1602 const model::mimlist &,
1603 model::real_matlist &,
1604 model::real_veclist &,
1605 model::real_veclist &,
1614 const model::varnamelist &,
1615 const model::varnamelist &,
1616 const model::mimlist &,
1617 model::complex_matlist &,
1618 model::complex_veclist &,
1619 model::complex_veclist &,
1625 const model::termlist& tlist,
1626 const model::varnamelist &,
1627 const model::varnamelist &,
1628 const model::mimlist &,
1629 model::real_matlist &,
1630 model::real_veclist &,
1632 const scalar_type delta = 1e-8)
const;
1638 const model::varnamelist &)
const {
1639 GMM_ASSERT1(
false,
"No assemby string declared, computation of Neumann "
1640 "term impossible for brick " << name);
1647 const model::varnamelist &,
1648 const model::varnamelist &,
1649 const model::mimlist &,
1650 model::real_matlist &,
1651 model::real_veclist &,
1652 model::real_veclist &,
1680 (model &md,
const mesh_im &mim,
const std::string &expr,
1682 bool is_coercive =
false,
const std::string &brickname =
"",
1683 bool return_if_nonlin =
false);
1685 inline size_type APIDECL add_linear_generic_assembly_brick
1686 (model &md,
const mesh_im &mim,
const std::string &expr,
1688 bool is_coercive =
false,
const std::string &brickname =
"",
1689 bool return_if_nonlin =
false) {
1691 is_coercive, brickname, return_if_nonlin);
1707 (model &md,
const mesh_im &mim,
const std::string &expr,
1709 bool is_coercive =
false,
const std::string &brickname =
"");
1711 inline size_type APIDECL add_nonlinear_generic_assembly_brick
1712 (model &md,
const mesh_im &mim,
const std::string &expr,
1714 bool is_coercive =
false,
const std::string &brickname =
"") {
1716 is_sym, is_coercive, brickname);
1729 (model &md,
const mesh_im &mim,
const std::string &expr,
1731 const std::string &brickname = std::string(),
1732 const std::string &directvarname = std::string(),
1733 const std::string &directdataname = std::string(),
1734 bool return_if_nonlin =
false);
1735 inline size_type APIDECL add_source_term_generic_assembly_brick
1736 (model &md,
const mesh_im &mim,
const std::string &expr,
1738 const std::string &brickname = std::string(),
1739 const std::string &directvarname = std::string(),
1740 const std::string &directdataname = std::string(),
1741 bool return_if_nonlin =
false) {
1743 directvarname, directdataname, return_if_nonlin);
1753 (model &md,
const mesh_im &mim,
const std::string &expr,
1754 size_type region,
const std::string &secondary_domain,
1755 bool is_sym =
false,
bool is_coercive =
false,
1756 const std::string &brickname =
"",
bool return_if_nonlin =
false);
1765 (model &md,
const mesh_im &mim,
const std::string &expr,
1766 size_type region,
const std::string &secondary_domain,
1767 bool is_sym =
false,
bool is_coercive =
false,
1768 const std::string &brickname =
"");
1777 (model &md,
const mesh_im &mim,
const std::string &expr,
1778 size_type region,
const std::string &secondary_domain,
1779 const std::string &brickname = std::string(),
1780 const std::string &directvarname = std::string(),
1781 const std::string &directdataname = std::string(),
1782 bool return_if_nonlin =
false);
1792 (model &md,
const mesh_im &mim,
const std::string &varname,
1818 (model &md,
const mesh_im &mim,
const std::string &varname,
1832 (model &md,
const mesh_im &mim,
const std::string &varname,
1834 const std::string &directdataname = std::string());
1847 (model &md,
const mesh_im &mim,
const std::string &varname,
1848 const std::string &dataexpr,
size_type region);
1870 (model &md,
const std::string &varname,
size_type region,
1871 const std::string &dataname = std::string());
1885 (model &md,
const mesh_im &mim,
const std::string &varname,
1886 const std::string &multname,
size_type region,
1887 const std::string &dataname = std::string());
1896 (model &md,
const mesh_im &mim,
const std::string &varname,
1897 const mesh_fem &mf_mult,
size_type region,
1898 const std::string &dataname = std::string());
1905 (model &md,
const mesh_im &mim,
const std::string &varname,
1907 const std::string &dataname = std::string());
1929 (model &md,
const mesh_im &mim,
const std::string &varname,
1930 scalar_type penalization_coeff,
size_type region,
1931 const std::string &dataname = std::string(),
1932 const mesh_fem *mf_mult = 0);
1952 (model &md,
const mesh_im &mim,
const std::string &varname,
1953 const std::string &Neumannterm,
1954 const std::string &datagamma0,
size_type region,
1955 scalar_type theta = scalar_type(0),
1956 const std::string &datag = std::string());
1973 (model &md,
const mesh_im &mim,
const std::string &varname,
1974 const std::string &multname,
size_type region,
1975 const std::string &dataname = std::string());
1984 (model &md,
const mesh_im &mim,
const std::string &varname,
1985 const mesh_fem &mf_mult,
size_type region,
1986 const std::string &dataname = std::string());
1993 (model &md,
const mesh_im &mim,
const std::string &varname,
1995 const std::string &dataname = std::string());
2012 (model &md,
const mesh_im &mim,
const std::string &varname,
2013 scalar_type penalization_coeff,
size_type region,
2014 const std::string &dataname = std::string(),
2015 const mesh_fem *mf_mult = 0);
2038 (model &md,
const mesh_im &mim,
const std::string &varname,
2039 const std::string &Neumannterm,
const std::string &datagamma0,
2040 size_type region, scalar_type theta = scalar_type(0),
2041 const std::string &datag = std::string());
2061 (model &md,
const std::string &varname,
2062 scalar_type penalisation_coeff,
const std::string &dataname_pt,
2063 const std::string &dataname_unitv = std::string(),
2064 const std::string &dataname_val = std::string());
2086 (model &md,
const std::string &varname,
2087 const std::string &multname,
const std::string &dataname_pt,
2088 const std::string &dataname_unitv = std::string(),
2089 const std::string &dataname_val = std::string());
2108 (model &md,
const std::string &varname,
const std::string &dataname_pt,
2109 const std::string &dataname_unitv = std::string(),
2110 const std::string &dataname_val = std::string());
2118 scalar_type penalisation_coeff);
2134 (model &md,
const mesh_im &mim,
const std::string &varname,
2135 const std::string &multname,
size_type region,
2136 const std::string &dataname,
const std::string &Hname);
2145 (model &md,
const mesh_im &mim,
const std::string &varname,
2146 const mesh_fem &mf_mult,
size_type region,
2147 const std::string &dataname,
const std::string &Hname);
2154 (model &md,
const mesh_im &mim,
const std::string &varname,
2156 const std::string &dataname,
const std::string &Hname);
2175 (model &md,
const mesh_im &mim,
const std::string &varname,
2176 scalar_type penalization_coeff,
size_type region,
2177 const std::string &dataname,
const std::string &Hname,
2178 const mesh_fem *mf_mult = 0);
2201 (model &md,
const mesh_im &mim,
const std::string &varname,
2202 const std::string &Neumannterm,
const std::string &datagamma0,
2204 const std::string &datag,
const std::string &dataH);
2215 const std::string &varname,
2216 const std::string &dataexpr,
2232 const std::string &varname,
2233 const std::string &dataexpr,
2238 model_real_sparse_matrix APIDECL &set_private_data_brick_real_matrix
2240 model_real_plain_vector APIDECL &set_private_data_brick_real_rhs
2242 model_complex_sparse_matrix APIDECL &set_private_data_brick_complex_matrix
2244 model_complex_plain_vector APIDECL &set_private_data_brick_complex_rhs
2246 size_type APIDECL add_constraint_with_penalization
2247 (model &md,
const std::string &varname, scalar_type penalisation_coeff);
2248 size_type APIDECL add_constraint_with_multipliers
2249 (model &md,
const std::string &varname,
const std::string &multname);
2251 void set_private_data_rhs
2252 (model &md,
size_type indbrick,
const std::string &varname);
2254 template <
typename VECT,
typename T>
2255 void set_private_data_rhs(model &md,
size_type ind,
2257 model_real_plain_vector &LL = set_private_data_brick_real_rhs(md, ind);
2262 template <
typename VECT,
typename T>
2263 void set_private_data_rhs(model &md,
size_type ind,
const VECT &L,
2265 model_complex_plain_vector &LL = set_private_data_brick_complex_rhs(md, ind);
2274 template <
typename VECT>
2276 typedef typename gmm::linalg_traits<VECT>::value_type T;
2277 set_private_data_rhs(md, indbrick, L, T());
2280 template <
typename MAT,
typename T>
2281 void set_private_data_matrix(model &md,
size_type ind,
2283 model_real_sparse_matrix &BB = set_private_data_brick_real_matrix(md, ind);
2284 gmm::resize(BB, gmm::mat_nrows(B), gmm::mat_ncols(B));
2288 template <
typename MAT,
typename T>
2289 void set_private_data_matrix(model &md,
size_type ind,
const MAT &B,
2291 model_complex_sparse_matrix &BB
2292 = set_private_data_brick_complex_matrix(md, ind);
2293 gmm::resize(BB, gmm::mat_nrows(B), gmm::mat_ncols(B));
2300 template <
typename MAT>
2303 typedef typename gmm::linalg_traits<MAT>::value_type T;
2304 set_private_data_matrix(md, indbrick, B, T());
2315 template <
typename MAT,
typename VECT>
2317 (
model &md,
const std::string &varname, scalar_type penalisation_coeff,
2318 const MAT &B,
const VECT &L) {
2320 = add_constraint_with_penalization(md, varname, penalisation_coeff);
2321 size_type n = gmm::mat_nrows(B), m = gmm::mat_ncols(B);
2322 set_private_data_rhs(md, ind, L);
2323 set_private_data_matrix(md, ind, B);
2335 template <
typename MAT,
typename VECT>
2337 (
model &md,
const std::string &varname,
const std::string &multname,
2338 const MAT &B,
const VECT &L) {
2339 size_type ind = add_constraint_with_multipliers(md, varname, multname);
2340 set_private_data_rhs(md, ind, L);
2341 set_private_data_matrix(md, ind, B);
2345 template <
typename MAT>
2346 size_type add_constraint_with_multipliers
2347 (model &md,
const std::string &varname,
const std::string &multname,
2348 const MAT &B,
const std::string &Lname) {
2349 size_type ind = add_constraint_with_multipliers(md, varname, multname);
2350 set_private_data_rhs(md, ind, Lname);
2351 set_private_data_matrix(md, ind, B);
2355 size_type APIDECL add_explicit_matrix(model &md,
const std::string &varname1,
2356 const std::string &varname2,
2357 bool issymmetric,
bool iscoercive);
2358 size_type APIDECL add_explicit_rhs(model &md,
const std::string &varname);
2370 template <
typename MAT>
2372 const std::string &varname2,
const MAT &B,
2373 bool issymmetric =
false,
2374 bool iscoercive =
false) {
2375 size_type ind = add_explicit_matrix(md, varname1, varname2,
2376 issymmetric, iscoercive);
2377 set_private_data_matrix(md, ind, B);
2387 template <
typename VECT>
2390 size_type ind = add_explicit_rhs(md, varname);
2391 set_private_data_rhs(md, ind, L);
2401 (model &md,
const mesh_im &mim,
const std::string &varname,
2402 const std::string &dataname_lambda,
const std::string &dataname_mu,
2404 const std::string &dataname_preconstraint = std::string());
2414 (model &md,
const mesh_im &mim,
const std::string &varname,
2415 const std::string &data_E,
const std::string &data_nu,
2427 (model &md,
const mesh_im &mim,
const std::string &varname,
2428 const std::string &data_E,
const std::string &data_nu,
2431 void APIDECL compute_isotropic_linearized_Von_Mises_or_Tresca
2432 (model &md,
const std::string &varname,
const std::string &dataname_lambda,
2433 const std::string &dataname_mu,
const mesh_fem &mf_vm,
2434 model_real_plain_vector &VM,
bool tresca);
2441 template <
class VECTVM>
2442 void compute_isotropic_linearized_Von_Mises_or_Tresca
2443 (
model &md,
const std::string &varname,
const std::string &dataname_lambda,
2444 const std::string &dataname_mu,
const mesh_fem &mf_vm,
2445 VECTVM &VM,
bool tresca) {
2446 model_real_plain_vector VMM(mf_vm.
nb_dof());
2447 compute_isotropic_linearized_Von_Mises_or_Tresca
2448 (md, varname, dataname_lambda, dataname_mu, mf_vm, VMM, tresca);
2458 (model &md,
const std::string &varname,
const std::string &data_E,
2459 const std::string &data_nu,
const mesh_fem &mf_vm,
2460 model_real_plain_vector &VM);
2468 (model &md,
const std::string &varname,
const std::string &data_E,
2469 const std::string &data_nu,
const mesh_fem &mf_vm,
2470 model_real_plain_vector &VM);
2493 (model &md,
const mesh_im &mim,
const std::string &varname,
2495 const std::string &dataexpr_penal_coeff = std::string());
2502 (model &md,
const mesh_im &mim,
const std::string &varname,
2503 const std::string &dataexpr_rho = std::string(),
2511 (model &md,
const mesh_im &mim,
const std::string &varname,
2512 const std::string &dataexpr_rho = std::string(),
2522 (model &md,
const mesh_im &mim,
const std::string &varname,
2523 const std::string &dataname_dt,
2524 const std::string &dataname_rho = std::string(),
2535 (model &md,
const mesh_im &mim,
const std::string &varnameU,
2536 const std::string &datanameV,
2537 const std::string &dataname_dt,
2538 const std::string &dataname_alpha,
2539 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.