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 rTM;
125 mutable model_complex_sparse_matrix cTM;
126 mutable model_real_plain_vector rrhs;
127 mutable model_complex_plain_vector crhs;
128 mutable bool act_size_to_be_done;
129 dim_type leading_dim;
130 getfem::lock_factory locks_;
134 enum var_description_filter {
136 VDESCRFILTER_REGION = 1,
138 VDESCRFILTER_INFSUP = 2,
141 VDESCRFILTER_CTERM = 4,
144 VDESCRFILTER_REGION_CTERM = 5,
147 struct var_description {
152 bool is_affine_dependent;
155 var_description_filter filter;
166 ppartial_mesh_fem partial_mf;
167 std::string filter_var;
169 bgeot::multi_index qdims;
172 gmm::uint64_type v_num;
173 std::vector<gmm::uint64_type> v_num_data;
178 std::vector<model_real_plain_vector> real_value;
179 std::vector<model_complex_plain_vector> complex_value;
180 std::vector<gmm::uint64_type> v_num_var_iter;
181 std::vector<gmm::uint64_type> v_num_iter;
184 model_real_plain_vector affine_real_value;
185 model_complex_plain_vector affine_complex_value;
187 std::string org_name;
193 size_type qdim()
const {
return qdims.total_size(); }
195 var_description(
bool is_var =
false,
bool is_com =
false,
197 var_description_filter fil = VDESCRFILTER_NO,
200 bgeot::multi_index qdims_ = bgeot::multi_index(),
201 const std::string &filter_v = std::string(
""),
203 : is_variable(is_var), is_disabled(
false), is_complex(is_com),
204 is_affine_dependent(
false), is_fem_dofs(is_fem), filter(fil),
205 n_iter(std::max(
size_type(1), n_it)), n_temp_iter(0),
206 default_iter(0), ptsc(0), mf(mmf), m_region(m_reg), mim(mim_),
207 filter_var(filter_v), qdims(qdims_), v_num(0),
208 v_num_data(n_iter, act_counter()), I(0,0),
209 alpha(1), pim_data(pimd) {
211 if (filter != VDESCRFILTER_NO && mf != 0)
212 partial_mf = std::make_shared<partial_mesh_fem>(*mf);
214 if (qdims.size() == 0) qdims.push_back(1);
215 GMM_ASSERT1(qdim(),
"Attempt to create a null size variable");
221 size_type add_temporary(gmm::uint64_type id_num);
223 void clear_temporaries();
225 const mesh_fem &associated_mf()
const {
226 GMM_ASSERT1(is_fem_dofs,
"This variable is not linked to a fem");
227 return (filter == VDESCRFILTER_NO) ? *mf : *partial_mf;
230 const mesh_fem *passociated_mf()
const {
233 return (filter == VDESCRFILTER_NO || partial_mf.get() == 0)
234 ? mf : partial_mf.get();
239 {
return is_complex ? complex_value[0].size() : real_value[0].size(); }
246 typedef std::vector<std::string> varnamelist;
247 typedef std::vector<const mesh_im *> mimlist;
248 typedef std::vector<model_real_sparse_matrix> real_matlist;
249 typedef std::vector<model_complex_sparse_matrix> complex_matlist;
250 typedef std::vector<model_real_plain_vector> real_veclist;
251 typedef std::vector<model_complex_plain_vector> complex_veclist;
253 struct term_description {
257 std::string var1, var2;
259 term_description(
const std::string &v)
260 : is_matrix_term(
false), is_symmetric(
false),
261 is_global(
false), var1(sup_previous_and_dot_to_varname(v)) {}
262 term_description(
const std::string &v1,
const std::string &v2,
264 : is_matrix_term(
true), is_symmetric(issym), is_global(
false),
265 var1(sup_previous_and_dot_to_varname(v1)), var2(v2) {}
266 term_description(
bool ism,
bool issym)
267 : is_matrix_term(ism), is_symmetric(issym), is_global(
true) {}
270 typedef std::vector<term_description> termlist;
272 enum build_version { BUILD_RHS = 1,
275 BUILD_ON_DATA_CHANGE = 4,
276 BUILD_WITH_COMPLETE_RHS = 8,
277 BUILD_COMPLETE_RHS = 9, };
283 struct brick_description {
284 mutable bool terms_to_be_computed;
285 mutable gmm::uint64_type v_num;
287 pdispatcher pdispatch;
294 bool is_update_brick;
296 mutable scalar_type external_load;
298 mutable model_real_plain_vector coeffs;
299 mutable scalar_type matrix_coeff = scalar_type(0);
300 mutable real_matlist rmatlist;
302 mutable std::vector<real_veclist> rveclist;
304 mutable std::vector<real_veclist> rveclist_sym;
306 mutable complex_matlist cmatlist;
308 mutable std::vector<complex_veclist> cveclist;
310 mutable std::vector<complex_veclist> cveclist_sym;
313 brick_description() : v_num(0) {}
315 brick_description(pbrick p,
const varnamelist &vl,
316 const varnamelist &dl,
const termlist &tl,
318 : terms_to_be_computed(
true), v_num(0), pbr(p), pdispatch(0), nbrhs(1),
319 vlist(vl), dlist(dl), tlist(tl), mims(mms), region(reg),
320 is_update_brick(
false), external_load(0),
321 rveclist(1), rveclist_sym(1), cveclist(1),
325 typedef std::map<std::string, var_description> VAR_SET;
326 mutable VAR_SET variables;
327 std::vector<brick_description> bricks;
328 dal::bit_vector valid_bricks, active_bricks;
329 std::map<std::string, pinterpolate_transformation> transformations;
330 std::map<std::string, pelementary_transformation> elem_transformations;
333 int time_integration;
335 scalar_type time_step;
336 scalar_type init_time_step;
339 typedef std::map<size_type, scalar_type> real_dof_constraints_var;
340 typedef std::map<size_type, complex_type> complex_dof_constraints_var;
341 mutable std::map<std::string, real_dof_constraints_var>
342 real_dof_constraints;
343 mutable std::map<std::string, complex_dof_constraints_var>
344 complex_dof_constraints;
345 void clear_dof_constraints()
346 { real_dof_constraints.clear(); complex_dof_constraints.clear(); }
353 gen_expr(
const std::string &expr_,
const mesh_im &mim_,
354 size_type region_) : expr(expr_), mim(mim_), region(region_) {}
358 struct assignement_desc {
366 std::list<assignement_desc> assignments;
369 mutable std::list<gen_expr> generic_expressions;
373 std::map<std::string, std::vector<std::string> > variable_groups;
375 ga_macro_dictionnary macro_dict;
379 virtual void actualize_sizes()
const;
380 bool check_name_validity(
const std::string &name,
bool assert=
true)
const;
381 void brick_init(
size_type ib, build_version version,
384 void init() { complex_version =
false; act_size_to_be_done =
false; }
386 void resize_global_system()
const;
389 virtual void post_to_variables_step();
391 scalar_type approx_external_load_;
394 VAR_SET::const_iterator find_variable(
const std::string &name)
const;
398 void add_generic_expression(
const std::string &expr,
const mesh_im &mim,
400 { generic_expressions.push_back(gen_expr(expr, mim, region)); }
401 void add_external_load(
size_type ib, scalar_type e)
const 402 { bricks[ib].external_load = e; }
403 scalar_type approx_external_load() {
return approx_external_load_; }
405 void update_brick(
size_type ib, build_version version)
const;
408 void update_affine_dependent_variables();
409 void brick_call(
size_type ib, build_version version,
411 model_real_plain_vector &rhs_coeffs_of_brick(
size_type ib)
const 412 {
return bricks[ib].coeffs; }
413 scalar_type &matrix_coeff_of_brick(
size_type ib)
const 414 {
return bricks[ib].matrix_coeff; }
415 bool is_var_newer_than_brick(
const std::string &varname,
417 bool is_var_mf_newer_than_brick(
const std::string &varname,
419 bool is_mim_newer_than_brick(
const mesh_im &mim,
422 pbrick brick_pointer(
size_type ib)
const {
423 GMM_ASSERT1(valid_bricks[ib],
"Inexistent brick");
424 return bricks[ib].pbr;
427 void variable_list(varnamelist &vl)
const 428 {
for (
const auto &v : variables) vl.push_back(v.first); }
430 void define_variable_group(
const std::string &group_name,
431 const std::vector<std::string> &nl);
432 bool variable_group_exists(
const std::string &group_name)
const 433 {
return variable_groups.count(group_name) > 0; }
435 const std::vector<std::string> &
436 variable_group(
const std::string &group_name)
const {
437 GMM_ASSERT1(variable_group_exists(group_name),
438 "Undefined variable group " << group_name);
439 return (variable_groups.find(group_name))->second;
442 void clear_assembly_assignments(
void) { assignments.clear(); }
443 void add_assembly_assignments(
const std::string &dataname,
444 const std::string &expr,
447 bool before =
false);
450 void add_real_dof_constraint(
const std::string &varname,
size_type dof,
451 scalar_type val)
const 452 { real_dof_constraints[varname][dof] = val; }
454 void add_complex_dof_constraint(
const std::string &varname,
size_type dof,
455 complex_type val)
const 456 { complex_dof_constraints[varname][dof] = val; }
459 void add_temporaries(
const varnamelist &vl, gmm::uint64_type id_num)
const;
461 const mimlist &mimlist_of_brick(
size_type ib)
const 462 {
return bricks[ib].mims; }
464 const varnamelist &varnamelist_of_brick(
size_type ib)
const 465 {
return bricks[ib].vlist; }
467 const varnamelist &datanamelist_of_brick(
size_type ib)
const 468 {
return bricks[ib].dlist; }
471 {
return bricks[ib].region; }
473 bool temporary_uptodate(
const std::string &varname,
474 gmm::uint64_type id_num,
size_type &ind)
const;
476 size_type n_iter_of_variable(
const std::string &name)
const {
477 return variables.count(name) == 0 ?
size_type(0)
478 : variables[name].n_iter;
481 void set_default_iter_of_variable(
const std::string &varname,
483 void reset_default_iter_of_variables(
const varnamelist &vl)
const;
487 const model_real_sparse_matrix &linear_real_matrix_term
490 const model_complex_sparse_matrix &linear_complex_matrix_term
495 GMM_ASSERT1(valid_bricks[ib],
"Inexistent brick");
496 active_bricks.del(ib);
501 GMM_ASSERT1(valid_bricks[ib],
"Inexistent brick");
502 active_bricks.add(ib);
506 void disable_variable(
const std::string &name);
509 void enable_variable(
const std::string &name);
512 bool variable_exists(
const std::string &name)
const;
514 bool is_disabled_variable(
const std::string &name)
const;
517 bool is_data(
const std::string &name)
const;
520 bool is_true_data(
const std::string &name)
const;
522 bool is_affine_dependent_variable(
const std::string &name)
const;
524 const std::string &org_variable(
const std::string &name)
const;
526 const scalar_type &factor_of_variable(
const std::string &name)
const;
528 void set_factor_of_variable(
const std::string &name, scalar_type a);
530 bool is_im_data(
const std::string &name)
const;
532 const im_data *pim_data_of_variable(
const std::string &name)
const;
534 const gmm::uint64_type &
535 version_number_of_data_variable(
const std::string &varname,
560 std::string new_name(
const std::string &name);
562 const gmm::sub_interval &
563 interval_of_variable(
const std::string &name)
const;
567 const model_real_plain_vector &
568 real_variable(
const std::string &name,
size_type niter)
const;
572 const model_real_plain_vector &
573 real_variable(
const std::string &name)
const;
577 const model_complex_plain_vector &
578 complex_variable(
const std::string &name,
size_type niter)
const;
582 const model_complex_plain_vector &
583 complex_variable(
const std::string &name)
const;
587 model_real_plain_vector &
588 set_real_variable(
const std::string &name,
size_type niter)
const;
592 model_real_plain_vector &
593 set_real_variable(
const std::string &name)
const;
597 model_complex_plain_vector &
598 set_complex_variable(
const std::string &name,
size_type niter)
const;
602 model_complex_plain_vector &
603 set_complex_variable(
const std::string &name)
const;
605 model_real_plain_vector &
606 set_real_constant_part(
const std::string &name)
const;
608 model_complex_plain_vector &
609 set_complex_constant_part(
const std::string &name)
const;
611 template<
typename VECTOR,
typename T>
612 void from_variables(VECTOR &V, T)
const {
613 for (
const auto &v : variables)
614 if (v.second.is_variable && !(v.second.is_affine_dependent)
615 && !(v.second.is_disabled))
616 gmm::copy(v.second.real_value[0],
617 gmm::sub_vector(V, v.second.I));
620 template<
typename VECTOR,
typename T>
621 void from_variables(VECTOR &V, std::complex<T>)
const {
622 for (
const auto &v : variables)
623 if (v.second.is_variable && !(v.second.is_affine_dependent)
624 && !(v.second.is_disabled))
625 gmm::copy(v.second.complex_value[0],
626 gmm::sub_vector(V, v.second.I));
629 template<
typename VECTOR>
void from_variables(VECTOR &V)
const {
630 typedef typename gmm::linalg_traits<VECTOR>::value_type T;
631 context_check();
if (act_size_to_be_done) actualize_sizes();
632 from_variables(V, T());
635 template<
typename VECTOR,
typename T>
636 void to_variables(
const VECTOR &V, T) {
637 for (
auto &&v : variables)
638 if (v.second.is_variable && !(v.second.is_affine_dependent)
639 && !(v.second.is_disabled)) {
640 gmm::copy(gmm::sub_vector(V, v.second.I),
641 v.second.real_value[0]);
642 v.second.v_num_data[0] = act_counter();
644 update_affine_dependent_variables();
645 this->post_to_variables_step();
648 template<
typename VECTOR,
typename T>
649 void to_variables(
const VECTOR &V, std::complex<T>) {
650 for (
auto &&v : variables)
651 if (v.second.is_variable && !(v.second.is_affine_dependent)
652 && !(v.second.is_disabled)) {
653 gmm::copy(gmm::sub_vector(V, v.second.I),
654 v.second.complex_value[0]);
655 v.second.v_num_data[0] = act_counter();
657 update_affine_dependent_variables();
658 this->post_to_variables_step();
661 template<
typename VECTOR>
void to_variables(
const VECTOR &V) {
662 typedef typename gmm::linalg_traits<VECTOR>::value_type T;
663 context_check();
if (act_size_to_be_done) actualize_sizes();
664 to_variables(V, T());
669 void add_fixed_size_variable(
const std::string &name,
size_type size,
674 void add_fixed_size_variable(
const std::string &name,
675 const bgeot::multi_index &sizes,
680 void add_fixed_size_data(
const std::string &name,
size_type size,
685 void add_fixed_size_data(
const std::string &name,
686 const bgeot::multi_index &sizes,
690 void resize_fixed_size_variable(
const std::string &name,
size_type size);
693 void resize_fixed_size_variable(
const std::string &name,
694 const bgeot::multi_index &sizes);
698 template <
typename VECT>
701 this->add_fixed_size_data(name, gmm::vect_size(v));
702 if (this->is_complex())
703 gmm::copy(v, this->set_complex_variable(name));
705 gmm::copy(gmm::real_part(v), this->set_real_variable(name));
710 template <
typename VECT>
713 const bgeot::multi_index &sizes) {
714 this->add_fixed_size_data(name, sizes);
715 if (this->is_complex())
716 gmm::copy(v, this->set_complex_variable(name));
718 gmm::copy(gmm::real_part(v), this->set_real_variable(name));
723 void add_initialized_matrix_data(
const std::string &name,
724 const base_matrix &M);
725 void add_initialized_matrix_data(
const std::string &name,
726 const base_complex_matrix &M);
730 void add_initialized_tensor_data(
const std::string &name,
731 const base_tensor &t);
732 void add_initialized_tensor_data(
const std::string &name,
733 const base_complex_tensor &t);
737 template <
typename T>
739 this->add_fixed_size_data(name, 1, 1);
740 if (this->is_complex())
741 this->set_complex_variable(name)[0] = e;
743 this->set_real_variable(name)[0] = gmm::real(e);
753 void add_fem_variable(
const std::string &name,
const mesh_fem &mf,
760 void add_filtered_fem_variable(
const std::string &name,
const mesh_fem &mf,
768 void add_affine_dependent_variable(
const std::string &name,
769 const std::string &org_name,
770 scalar_type alpha = scalar_type(1));
773 void add_fem_data(
const std::string &name,
const mesh_fem &mf,
777 void add_fem_data(
const std::string &name,
const mesh_fem &mf,
778 const bgeot::multi_index &sizes,
size_type niter = 1);
783 template <
typename VECT>
786 this->add_fem_data(name, mf,
787 dim_type(gmm::vect_size(v) / mf.
nb_dof()), 1);
788 if (this->is_complex())
789 gmm::copy(v, this->set_complex_variable(name));
791 gmm::copy(gmm::real_part(v), this->set_real_variable(name));
796 template <
typename VECT>
799 const bgeot::multi_index &sizes) {
800 this->add_fem_data(name, mf, sizes, 1);
801 if (this->is_complex())
802 gmm::copy(v, this->set_complex_variable(name));
804 gmm::copy(gmm::real_part(v), this->set_real_variable(name));
813 void add_multiplier(
const std::string &name,
const mesh_fem &mf,
814 const std::string &primal_name,
824 void add_multiplier(
const std::string &name,
const mesh_fem &mf,
825 size_type region,
const std::string &primal_name,
834 void add_multiplier(
const std::string &name,
const mesh_fem &mf,
835 const std::string &primal_name,
const mesh_im &mim,
844 void add_macro(
const std::string &name,
const std::string &expr);
847 void del_macro(
const std::string &name);
851 {
return macro_dict.macro_exists(name); }
854 void delete_variable(
const std::string &varname);
858 const mesh_fem &mesh_fem_of_variable(
const std::string &name)
const;
861 const mesh_fem *pmesh_fem_of_variable(
const std::string &name)
const;
864 bgeot::multi_index qdims_of_variable(
const std::string &name)
const;
865 size_type qdim_of_variable(
const std::string &name)
const;
869 GMM_ASSERT1(!complex_version,
"This model is a complex one");
870 context_check();
if (act_size_to_be_done) actualize_sizes();
876 GMM_ASSERT1(complex_version,
"This model is a real one");
877 context_check();
if (act_size_to_be_done) actualize_sizes();
884 GMM_ASSERT1(!complex_version,
"This model is a complex one");
885 context_check();
if (act_size_to_be_done) actualize_sizes();
891 GMM_ASSERT1(!complex_version,
"This model is a complex one");
892 context_check();
if (act_size_to_be_done) actualize_sizes();
893 GMM_ASSERT1(valid_bricks[ib],
"Inexistent brick");
894 GMM_ASSERT1(ind_term < bricks[ib].tlist.size(),
"Inexistent term");
895 GMM_ASSERT1(ind_iter < bricks[ib].nbrhs,
"Inexistent iter");
896 GMM_ASSERT1(!sym || bricks[ib].tlist[ind_term].is_symmetric,
897 "Term is not symmetric");
900 return bricks[ib].rveclist_sym[ind_iter][ind_term];
902 return bricks[ib].rveclist[ind_iter][ind_term];
908 GMM_ASSERT1(complex_version,
"This model is a real one");
909 context_check();
if (act_size_to_be_done) actualize_sizes();
915 GMM_ASSERT1(!complex_version,
"This model is a complex one");
916 context_check();
if (act_size_to_be_done) actualize_sizes();
917 GMM_ASSERT1(valid_bricks[ib],
"Inexistent brick");
918 GMM_ASSERT1(ind_term < bricks[ib].tlist.size(),
"Inexistent term");
919 GMM_ASSERT1(ind_iter < bricks[ib].nbrhs,
"Inexistent iter");
920 GMM_ASSERT1(!sym || bricks[ib].tlist[ind_term].is_symmetric,
921 "Term is not symmetric");
924 return bricks[ib].cveclist_sym[ind_iter][ind_term];
926 return bricks[ib].cveclist[ind_iter][ind_term];
930 void listvar(std::ostream &ost)
const;
932 void listresiduals(std::ostream &ost)
const;
935 void listbricks(std::ostream &ost,
size_type base_id = 0)
const;
939 return active_bricks;
944 GMM_ASSERT1(valid_bricks[ib],
"Inexistent brick");
945 bricks[ib].terms_to_be_computed =
true;
952 size_type add_brick(pbrick pbr,
const varnamelist &varnames,
953 const varnamelist &datanames,
954 const termlist &terms,
const mimlist &mims,
964 void change_terms_of_brick(
size_type ib,
const termlist &terms);
968 void change_variables_of_brick(
size_type ib,
const varnamelist &vl);
972 void change_data_of_brick(
size_type ib,
const varnamelist &vl);
976 void change_mims_of_brick(
size_type ib,
const mimlist &ml);
980 void change_update_flag_of_brick(
size_type ib,
bool flag);
982 void set_time(scalar_type t = scalar_type(0),
bool to_init =
true);
984 scalar_type get_time();
986 void set_time_step(scalar_type dt) { time_step = dt; }
987 scalar_type get_time_step()
const {
return time_step; }
988 scalar_type get_init_time_step()
const {
return init_time_step; }
989 int is_time_integration()
const {
return time_integration; }
990 void set_time_integration(
int ti) { time_integration = ti; }
991 bool is_init_step()
const {
return init_step; }
992 void cancel_init_step() { init_step =
false; }
993 void call_init_affine_dependent_variables(
int version);
994 void shift_variables_for_time_integration();
995 void copy_init_time_derivative();
996 void add_time_integration_scheme(
const std::string &varname,
998 void perform_init_time_derivative(scalar_type ddt)
999 { init_step =
true; init_time_step = ddt; }
1003 void add_time_dispatcher(
size_type ibrick, pdispatcher pdispatch);
1005 void set_dispatch_coeff();
1008 virtual void first_iter();
1013 virtual void next_iter();
1019 pinterpolate_transformation ptrans) {
1020 if (transformations.count(name) > 0)
1021 GMM_ASSERT1(name.compare(
"neighbour_elt"),
"neighbour_elt is a " 1022 "reserved interpolate transformation name");
1023 transformations[name] = ptrans;
1028 pinterpolate_transformation
1030 std::map<std::string, pinterpolate_transformation>::const_iterator
1031 it = transformations.find(name);
1032 GMM_ASSERT1(it != transformations.end(),
"Inexistent transformation " << name);
1039 {
return transformations.count(name) > 0; }
1045 pelementary_transformation ptrans) {
1046 elem_transformations[name] = ptrans;
1051 pelementary_transformation
1053 std::map<std::string, pelementary_transformation>::const_iterator
1054 it = elem_transformations.find(name);
1055 GMM_ASSERT1(it != elem_transformations.end(),
1056 "Inexistent elementary transformation " << name);
1063 {
return elem_transformations.count(name) > 0; }
1067 const std::string &varname_of_brick(
size_type ind_brick,
1072 const std::string &dataname_of_brick(
size_type ind_brick,
1077 virtual void assembly(build_version version);
1087 std::string Neumann_term(
const std::string &varname,
size_type region);
1089 virtual void clear();
1091 explicit model(
bool comp_version =
false);
1096 void check_brick_stiffness_rhs(
size_type ind_brick)
const;
1115 virtual void init_affine_dependent_variables(
model &md)
const = 0;
1116 virtual void init_affine_dependent_variables_precomputation(
model &md)
1118 virtual void time_derivative_to_be_intialized
1119 (std::string &name_v, std::string &name_previous_v)
const = 0;
1120 virtual void shift_variables(
model &md)
const = 0;
1124 void add_theta_method_for_first_order(
model &md,
const std::string &varname,
1127 void add_theta_method_for_second_order(
model &md,
const std::string &varname,
1130 void add_Newmark_scheme(
model &md,
const std::string &varname,
1131 scalar_type beta, scalar_type gamma);
1149 std::vector<std::string> param_names;
1153 size_type nbrhs()
const {
return nbrhs_; }
1155 typedef model::build_version build_version;
1158 { GMM_ASSERT1(
false,
"Time dispatcher with not set_dispatch_coeff !"); }
1160 virtual void next_real_iter
1162 const model::varnamelist &,
1163 model::real_matlist &,
1164 std::vector<model::real_veclist> &,
1165 std::vector<model::real_veclist> &,
1167 GMM_ASSERT1(
false,
"Time dispatcher with not defined first real iter !");
1170 virtual void next_complex_iter
1172 const model::varnamelist &,
1173 model::complex_matlist &,
1174 std::vector<model::complex_veclist> &,
1175 std::vector<model::complex_veclist> &,
1177 GMM_ASSERT1(
false,
"Time dispatcher with not defined first comples iter");
1180 virtual void asm_real_tangent_terms
1182 model::real_matlist &, std::vector<model::real_veclist> &,
1183 std::vector<model::real_veclist> &,
1184 build_version)
const {
1185 GMM_ASSERT1(
false,
"Time dispatcher with not defined real tangent " 1189 virtual void asm_complex_tangent_terms
1191 model::complex_matlist &, std::vector<model::complex_veclist> &,
1192 std::vector<model::complex_veclist> &,
1193 build_version)
const {
1194 GMM_ASSERT1(
false,
"Time dispatcher with not defined complex tangent " 1199 GMM_ASSERT1(_nbrhs > 0,
"Time dispatcher with no rhs");
1215 typedef model::build_version build_version;
1219 template <
typename MATLIST,
typename VECTLIST>
1221 const model::varnamelist &,
1222 const model::varnamelist &,
1224 VECTLIST &vectl, VECTLIST &vectl_sym,
1225 bool first_iter)
const {
1226 if (first_iter) md.update_brick(ib, model::BUILD_RHS);
1229 for (
size_type i = 0; i < vectl[0].size(); ++i)
1230 gmm::copy(vectl[0][i], vectl[1][i]);
1231 for (
size_type i = 0; i < vectl_sym[0].size(); ++i)
1232 gmm::copy(vectl_sym[0][i], vectl_sym[1][i]);
1236 md.linear_brick_add_to_rhs(ib, 1, 0);
1241 const model::varnamelist &dl, model::real_matlist &matl,
1242 std::vector<model::real_veclist> &vectl,
1243 std::vector<model::real_veclist> &vectl_sym,
bool first_iter)
const;
1245 void next_complex_iter
1247 const model::varnamelist &dl,
1248 model::complex_matlist &matl,
1249 std::vector<model::complex_veclist> &vectl,
1250 std::vector<model::complex_veclist> &vectl_sym,
1251 bool first_iter)
const;
1253 void asm_real_tangent_terms
1255 std::vector<model::real_veclist> &,
1256 std::vector<model::real_veclist> &,
1257 build_version version)
const;
1259 virtual void asm_complex_tangent_terms
1261 std::vector<model::complex_veclist> &,
1262 std::vector<model::complex_veclist> &,
1263 build_version version)
const;
1265 theta_method_dispatcher(
const std::string &THETA);
1279 const std::string &THETA);
1287 (
model &md,
const std::string &U,
const std::string &V,
1288 const std::string &pdt,
const std::string &ptheta);
1304 (
model &md,
size_type id2dt2b,
const std::string &U,
const std::string &V,
1305 const std::string &pdt,
const std::string &ptwobeta,
1306 const std::string &pgamma);
1330 bool compute_each_time;
1338 typedef model::build_version build_version;
1342 void set_flags(
const std::string &bname,
bool islin,
bool issym,
1343 bool iscoer,
bool ire,
bool isco,
bool each_time =
false) {
1345 islinear = islin; issymmetric = issym; iscoercive = iscoer;
1346 isreal = ire; iscomplex = isco; isinit =
true;
1347 compute_each_time = each_time;
1350 # define BRICK_NOT_INIT GMM_ASSERT1(isinit, "Set brick flags !") 1351 bool is_linear()
const { BRICK_NOT_INIT;
return islinear; }
1352 bool is_symmetric()
const { BRICK_NOT_INIT;
return issymmetric; }
1353 bool is_coercive()
const { BRICK_NOT_INIT;
return iscoercive; }
1354 bool is_real()
const { BRICK_NOT_INIT;
return isreal; }
1355 bool is_complex()
const { BRICK_NOT_INIT;
return iscomplex; }
1356 bool is_to_be_computed_each_time()
const 1357 { BRICK_NOT_INIT;
return compute_each_time; }
1358 const std::string &brick_name()
const { BRICK_NOT_INIT;
return name; }
1375 const model::varnamelist &,
1376 const model::varnamelist &,
1377 const model::mimlist &,
1378 model::real_matlist &,
1379 model::real_veclist &,
1380 model::real_veclist &,
1401 const model::varnamelist &,
1402 const model::varnamelist &,
1403 const model::mimlist &,
1404 model::complex_matlist &,
1405 model::complex_veclist &,
1406 model::complex_veclist &,
1419 const model::varnamelist &,
1420 const model::varnamelist &,
1421 const model::mimlist &,
1422 model::real_matlist &,
1423 model::real_veclist &,
1424 model::real_veclist &,
1433 const model::varnamelist &,
1434 const model::varnamelist &,
1435 const model::mimlist &,
1436 model::complex_matlist &,
1437 model::complex_veclist &,
1438 model::complex_veclist &,
1447 const model::varnamelist &,
1448 const model::varnamelist &,
1449 const model::mimlist &,
1450 model::real_matlist &,
1451 model::real_veclist &,
1452 model::real_veclist &,
1461 const model::varnamelist &,
1462 const model::varnamelist &,
1463 const model::mimlist &,
1464 model::complex_matlist &,
1465 model::complex_veclist &,
1466 model::complex_veclist &,
1472 const model::termlist& tlist,
1473 const model::varnamelist &,
1474 const model::varnamelist &,
1475 const model::mimlist &,
1476 model::real_matlist &,
1477 model::real_veclist &,
1479 const scalar_type delta = 1e-8)
const;
1483 virtual std::string declare_volume_assembly_string
1485 const model::varnamelist &)
const {
1486 GMM_ASSERT1(
false,
"No assemby string declared, computation of Neumann " 1487 "term impossible for brick " << name);
1494 const model::varnamelist &,
1495 const model::varnamelist &,
1496 const model::mimlist &,
1497 model::real_matlist &,
1498 model::real_veclist &,
1499 model::real_veclist &,
1527 (
model &md,
const mesh_im &mim,
const std::string &expr,
1529 bool is_coercive =
false, std::string brickname =
"",
1530 bool return_if_nonlin =
false);
1532 inline size_type APIDECL add_linear_generic_assembly_brick
1533 (
model &md,
const mesh_im &mim,
const std::string &expr,
1535 bool is_coercive =
false, std::string brickname =
"",
1536 bool return_if_nonlin =
false) {
1538 is_coercive, brickname, return_if_nonlin);
1553 (
model &md,
const mesh_im &mim,
const std::string &expr,
1555 bool is_coercive =
false, std::string brickname =
"");
1557 inline size_type APIDECL add_nonlinear_generic_assembly_brick
1558 (
model &md,
const mesh_im &mim,
const std::string &expr,
1560 bool is_coercive =
false, std::string brickname =
"") {
1562 is_sym, is_coercive, brickname);
1575 (
model &md,
const mesh_im &mim,
const std::string &expr,
1577 std::string directvarname = std::string(),
1578 const std::string &directdataname = std::string(),
1579 bool return_if_nonlin =
false);
1580 inline size_type APIDECL add_source_term_generic_assembly_brick
1581 (
model &md,
const mesh_im &mim,
const std::string &expr,
1583 std::string directvarname = std::string(),
1584 const std::string &directdataname = std::string(),
1585 bool return_if_nonlin =
false) {
1587 directvarname, directdataname, return_if_nonlin);
1597 (
model &md,
const mesh_im &mim,
const std::string &varname,
1623 (
model &md,
const mesh_im &mim,
const std::string &varname,
1637 (
model &md,
const mesh_im &mim,
const std::string &varname,
1639 const std::string &directdataname = std::string());
1652 (
model &md,
const mesh_im &mim,
const std::string &varname,
1653 const std::string &dataexpr,
size_type region);
1676 const std::string &dataname = std::string());
1690 (
model &md,
const mesh_im &mim,
const std::string &varname,
1691 const std::string &multname,
size_type region,
1692 const std::string &dataname = std::string());
1701 (
model &md,
const mesh_im &mim,
const std::string &varname,
1703 const std::string &dataname = std::string());
1710 (
model &md,
const mesh_im &mim,
const std::string &varname,
1712 const std::string &dataname = std::string());
1734 (
model &md,
const mesh_im &mim,
const std::string &varname,
1735 scalar_type penalization_coeff,
size_type region,
1736 const std::string &dataname = std::string(),
1757 (
model &md,
const mesh_im &mim,
const std::string &varname,
1758 const std::string &Neumannterm,
1759 const std::string &datagamma0,
size_type region,
1760 scalar_type theta = scalar_type(0),
1761 const std::string &datag = std::string());
1778 (
model &md,
const mesh_im &mim,
const std::string &varname,
1779 const std::string &multname,
size_type region,
1780 const std::string &dataname = std::string());
1789 (
model &md,
const mesh_im &mim,
const std::string &varname,
1791 const std::string &dataname = std::string());
1798 (
model &md,
const mesh_im &mim,
const std::string &varname,
1800 const std::string &dataname = std::string());
1817 (
model &md,
const mesh_im &mim,
const std::string &varname,
1818 scalar_type penalization_coeff,
size_type region,
1819 const std::string &dataname = std::string(),
1843 (
model &md,
const mesh_im &mim,
const std::string &varname,
1844 const std::string &Neumannterm,
const std::string &datagamma0,
1845 size_type region, scalar_type theta = scalar_type(0),
1846 const std::string &datag = std::string());
1866 (
model &md,
const std::string &varname,
1867 scalar_type penalisation_coeff,
const std::string &dataname_pt,
1868 const std::string &dataname_unitv = std::string(),
1869 const std::string &dataname_val = std::string());
1891 (
model &md,
const std::string &varname,
1892 const std::string &multname,
const std::string &dataname_pt,
1893 const std::string &dataname_unitv = std::string(),
1894 const std::string &dataname_val = std::string());
1913 (
model &md,
const std::string &varname,
const std::string &dataname_pt,
1914 const std::string &dataname_unitv = std::string(),
1915 const std::string &dataname_val = std::string());
1923 scalar_type penalisation_coeff);
1939 (
model &md,
const mesh_im &mim,
const std::string &varname,
1940 const std::string &multname,
size_type region,
1941 const std::string &dataname,
const std::string &Hname);
1950 (
model &md,
const mesh_im &mim,
const std::string &varname,
1952 const std::string &dataname,
const std::string &Hname);
1959 (
model &md,
const mesh_im &mim,
const std::string &varname,
1961 const std::string &dataname,
const std::string &Hname);
1980 (
model &md,
const mesh_im &mim,
const std::string &varname,
1981 scalar_type penalization_coeff,
size_type region,
1982 const std::string &dataname,
const std::string &Hname,
2006 (
model &md,
const mesh_im &mim,
const std::string &varname,
2007 const std::string &Neumannterm,
const std::string &datagamma0,
2009 const std::string &datag,
const std::string &dataH);
2020 const std::string &varname,
2021 const std::string &dataexpr,
2037 const std::string &varname,
2038 const std::string &dataexpr,
2043 model_real_sparse_matrix APIDECL &set_private_data_brick_real_matrix
2045 model_real_plain_vector APIDECL &set_private_data_brick_real_rhs
2047 model_complex_sparse_matrix APIDECL &set_private_data_brick_complex_matrix
2049 model_complex_plain_vector APIDECL &set_private_data_brick_complex_rhs
2051 size_type APIDECL add_constraint_with_penalization
2052 (
model &md,
const std::string &varname, scalar_type penalisation_coeff);
2053 size_type APIDECL add_constraint_with_multipliers
2054 (
model &md,
const std::string &varname,
const std::string &multname);
2056 void set_private_data_rhs
2059 template <
typename VECT,
typename T>
2062 model_real_plain_vector &LL = set_private_data_brick_real_rhs(md, ind);
2063 gmm::resize(LL, gmm::vect_size(L));
2067 template <
typename VECT,
typename T>
2068 void set_private_data_rhs(
model &md,
size_type ind,
const VECT &L,
2070 model_complex_plain_vector &LL = set_private_data_brick_complex_rhs(md, ind);
2071 gmm::resize(LL, gmm::vect_size(L));
2079 template <
typename VECT>
2081 typedef typename gmm::linalg_traits<VECT>::value_type T;
2082 set_private_data_rhs(md, indbrick, L, T());
2085 template <
typename MAT,
typename T>
2088 model_real_sparse_matrix &BB = set_private_data_brick_real_matrix(md, ind);
2089 gmm::resize(BB, gmm::mat_nrows(B), gmm::mat_ncols(B));
2093 template <
typename MAT,
typename T>
2094 void set_private_data_matrix(
model &md,
size_type ind,
const MAT &B,
2096 model_complex_sparse_matrix &BB
2097 = set_private_data_brick_complex_matrix(md, ind);
2098 gmm::resize(BB, gmm::mat_nrows(B), gmm::mat_ncols(B));
2105 template <
typename MAT>
2108 typedef typename gmm::linalg_traits<MAT>::value_type T;
2109 set_private_data_matrix(md, indbrick, B, T());
2120 template <
typename MAT,
typename VECT>
2121 size_type add_constraint_with_penalization
2122 (
model &md,
const std::string &varname, scalar_type penalisation_coeff,
2123 const MAT &B,
const VECT &L) {
2125 = add_constraint_with_penalization(md, varname, penalisation_coeff);
2126 size_type n = gmm::mat_nrows(B), m = gmm::mat_ncols(B);
2127 set_private_data_rhs(md, ind, L);
2128 set_private_data_matrix(md, ind, B);
2140 template <
typename MAT,
typename VECT>
2141 size_type add_constraint_with_multipliers
2142 (
model &md,
const std::string &varname,
const std::string &multname,
2143 const MAT &B,
const VECT &L) {
2144 size_type ind = add_constraint_with_multipliers(md, varname, multname);
2145 set_private_data_rhs(md, ind, L);
2146 set_private_data_matrix(md, ind, B);
2150 template <
typename MAT>
2151 size_type add_constraint_with_multipliers
2152 (
model &md,
const std::string &varname,
const std::string &multname,
2153 const MAT &B,
const std::string &Lname) {
2154 size_type ind = add_constraint_with_multipliers(md, varname, multname);
2155 set_private_data_rhs(md, ind, Lname);
2156 set_private_data_matrix(md, ind, B);
2160 size_type APIDECL add_explicit_matrix(
model &md,
const std::string &varname1,
2161 const std::string &varname2,
2162 bool issymmetric,
bool iscoercive);
2163 size_type APIDECL add_explicit_rhs(
model &md,
const std::string &varname);
2175 template <
typename MAT>
2177 const std::string &varname2,
const MAT &B,
2178 bool issymmetric =
false,
2179 bool iscoercive =
false) {
2180 size_type ind = add_explicit_matrix(md, varname1, varname2,
2181 issymmetric, iscoercive);
2182 set_private_data_matrix(md, ind, B);
2192 template <
typename VECT>
2195 size_type ind = add_explicit_rhs(md, varname);
2196 set_private_data_rhs(md, ind, L);
2206 (
model &md,
const mesh_im &mim,
const std::string &varname,
2207 const std::string &dataname_lambda,
const std::string &dataname_mu,
2209 const std::string &dataname_preconstraint = std::string());
2219 (
model &md,
const mesh_im &mim,
const std::string &varname,
2220 const std::string &data_E,
const std::string &data_nu,
2232 (
model &md,
const mesh_im &mim,
const std::string &varname,
2233 const std::string &data_E,
const std::string &data_nu,
2236 void APIDECL compute_isotropic_linearized_Von_Mises_or_Tresca
2237 (
model &md,
const std::string &varname,
const std::string &dataname_lambda,
2238 const std::string &dataname_mu,
const mesh_fem &mf_vm,
2239 model_real_plain_vector &VM,
bool tresca);
2246 template <
class VECTVM>
2247 void compute_isotropic_linearized_Von_Mises_or_Tresca
2248 (
model &md,
const std::string &varname,
const std::string &dataname_lambda,
2249 const std::string &dataname_mu,
const mesh_fem &mf_vm,
2250 VECTVM &VM,
bool tresca) {
2251 model_real_plain_vector VMM(mf_vm.
nb_dof());
2252 compute_isotropic_linearized_Von_Mises_or_Tresca
2253 (md, varname, dataname_lambda, dataname_mu, mf_vm, VMM, tresca);
2263 (
model &md,
const std::string &varname,
const std::string &data_E,
2264 const std::string &data_nu,
const mesh_fem &mf_vm,
2265 model_real_plain_vector &VM);
2273 (
model &md,
const std::string &varname,
const std::string &data_E,
2274 const std::string &data_nu,
const mesh_fem &mf_vm,
2275 model_real_plain_vector &VM);
2298 (
model &md,
const mesh_im &mim,
const std::string &varname,
2300 const std::string &dataexpr_penal_coeff = std::string());
2307 (
model &md,
const mesh_im &mim,
const std::string &varname,
2308 const std::string &dataexpr_rho = std::string(),
2318 (
model &md,
const mesh_im &mim,
const std::string &varname,
2319 const std::string &dataname_dt,
2320 const std::string &dataname_rho = std::string(),
2331 (
model &md,
const mesh_im &mim,
const std::string &varnameU,
2332 const std::string &datanameV,
2333 const std::string &dataname_dt,
2334 const std::string &dataname_alpha,
2335 const std::string &dataname_rho = std::string(),
const model_real_plain_vector & real_rhs() const
Gives the access to the right hand side of the tangent linear system.
pelementary_transformation elementary_transformation(const std::string &name) const
Get a pointer to the elementary transformation name.
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...
bool elementary_transformation_exists(const std::string &name) const
Tests if name correpsonds to an elementary transformation.
bool is_coercive() const
Return true if all the model terms do not affect the coercivity of the whole tangent system...
virtual size_type nb_dof() const
Return the total number of degrees of freedom.
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.
const model_complex_plain_vector & complex_rhs() const
Gives access to the right hand side of the tangent linear system.
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...
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.
const auto PREFIX_OLD
A prefix to refer to the previous version of a variable.
base class for static stored objects
void disable_brick(size_type ib)
Disable a brick.
Provides indexing of integration points for mesh_im.
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_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_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.
dim_type leading_dimension() const
Leading dimension of the meshes used in the model.
size_type APIDECL add_isotropic_linearized_elasticity_brick_pstress(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 ( ).
void update_from_context() const
this function has to be defined and should update the object when the context is modified.
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_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_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 ( ).
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.
a subclass of getfem::mesh_fem which allows to eliminate a number of dof of the original mesh_fem...
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_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 ...
bool is_old(const std::string &name)
Does the variable have Old_ prefix.
Describe an integration method linked to a mesh.
const ga_macro_dictionnary & macro_dictionnary() const
Dictonnary of user defined macros.
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.
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.
The time integration scheme object provides the necessary methods for the model object to apply a tim...
pinterpolate_transformation interpolate_transformation(const std::string &name) const
Get a pointer to the interpolate transformation name.
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.
bool is_linear() const
Return true if all the model terms are linear.
``Model'' variables store the variables, the data and the description of a model. ...
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.
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.
size_t size_type
used as the common size type in the library
void add_initialized_scalar_data(const std::string &name, T e)
Add a scalar data (i.e.
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 the access to the part of the right hand side of a term of a particular nonlinear brick...
bool interpolate_transformation_exists(const std::string &name) const
Tests if name correpsonds to an interpolate transformation.
size_type APIDECL add_isotropic_linearized_elasticity_brick_pstrain(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_complex() const
Boolean which says if the model deals with real or complex unknowns and data.
The time dispatcher object modify the result of a brick in order to apply a time integration scheme...
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.
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...
void add_interpolate_transformation(const std::string &name, pinterpolate_transformation ptrans)
Add a interpolate transformation to the model to be used with the generic assembly.
A langage for generic assembly of pde boundary value problems.
sparse vector built upon std::vector.
Deal with interdependencies of objects.
GEneric Tool for Finite Element Methods.
const model_real_sparse_matrix & real_tangent_matrix() const
Gives the access to the tangent matrix.
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 ( ).
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.
Describe a finite element method linked to a mesh.
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))...
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...
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 ...
The virtual brick has to be derived to describe real model bricks.
bool is_symmetric() const
Return true if all the model terms do not affect the coercivity of the whole tangent system...
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.
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 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 ...
bool macro_exists(const std::string &name) const
Says if a macro of that name has been defined.
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_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.
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 touch_brick(size_type ib)
Force the re-computation of a brick for the next assembly.
void enable_brick(size_type ib)
Enable a brick.
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.
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_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 ( ).
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.
size_type APIDECL add_source_term(model &md, const mesh_im &mim, const std::string &expr, size_type region=size_type(-1), std::string brickname="", 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...
const dal::bit_vector & get_active_bricks() const
Return the model brick ids.
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_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, std::string brickname="", bool return_if_nonlin=false)
Add a matrix term given by the assembly string expr which will be assembled in region region and with...
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.
std::string no_old_prefix_name(const std::string &name)
Strip the variable name from prefix Old_ if it has one.
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.
im_data provides indexing to the integration points of a mesh im object.
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, std::string brickname="")
Add a nonlinear term given by the assembly string expr which will be assembled in region region and w...
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.
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.
Miscelleanous assembly routines for common terms. Use the low-level generic assembly. Prefer the high-level one.
std::shared_ptr< const virtual_brick > pbrick
type of pointer on a brick
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.
const model_complex_sparse_matrix & complex_tangent_matrix() const
Gives the access to the tangent matrix.
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.