branch: integration-point-variables commit ebcf00df4611dd9fda05630704824f5988a891b3 Author: Konstantinos Poulios <logar...@gmail.com> Date: Wed Jan 16 12:58:12 2019 +0100
Code cleanup and stricter constness --- src/getfem/getfem_generic_assembly.h | 17 +++++++---------- src/getfem_generic_assembly_workspace.cc | 24 ++++++++++++------------ 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/getfem/getfem_generic_assembly.h b/src/getfem/getfem_generic_assembly.h index c87bf56..7d91a8c 100644 --- a/src/getfem/getfem_generic_assembly.h +++ b/src/getfem/getfem_generic_assembly.h @@ -270,12 +270,12 @@ namespace getfem { struct var_description { - bool is_variable; - bool is_fem_dofs; + const bool is_variable; + const bool is_fem_dofs; const mesh_fem *mf; + const im_data *imd; gmm::sub_interval I; const model_real_plain_vector *V; - const im_data *imd; bgeot::multi_index qdims; // For data having a qdim different than // the qdim of the fem or im_data // (dim per dof for dof data) @@ -287,18 +287,15 @@ namespace getfem { return q; } - var_description(bool is_var, bool is_fem, const mesh_fem *mf_, + var_description(bool is_var, const mesh_fem *mf_, const im_data *imd_, gmm::sub_interval I_, const model_real_plain_vector *v, - const im_data *imd_, size_type Q) - : is_variable(is_var), is_fem_dofs(is_fem), mf(mf_), I(I_), V(v), - imd(imd_), qdims(1) + size_type Q) + : is_variable(is_var), is_fem_dofs(mf_ != 0), mf(mf_), imd(imd_), + I(I_), V(v), qdims(1) { GMM_ASSERT1(Q > 0, "Bad dimension"); qdims[0] = Q; } - var_description() : is_variable(false), is_fem_dofs(false), - mf(0), V(0), imd(0), qdims(1) - { qdims[0] = 1; } }; public: diff --git a/src/getfem_generic_assembly_workspace.cc b/src/getfem_generic_assembly_workspace.cc index eebb7b8..dd2dc89 100644 --- a/src/getfem_generic_assembly_workspace.cc +++ b/src/getfem_generic_assembly_workspace.cc @@ -45,20 +45,20 @@ namespace getfem { void ga_workspace::add_fem_variable (const std::string &name, const mesh_fem &mf, const gmm::sub_interval &I, const model_real_plain_vector &VV) { - variables[name] = var_description(true, true, &mf, I, &VV, 0, 1); + variables.emplace(name, var_description(true, &mf, 0, I, &VV, 1)); } void ga_workspace::add_im_variable (const std::string &name, const im_data &imd, const gmm::sub_interval &I, const model_real_plain_vector &VV) { - variables[name] = var_description(true, false, 0, I, &VV, &imd, 1); + variables.emplace(name, var_description(true, 0, &imd, I, &VV, 1)); } void ga_workspace::add_fixed_size_variable (const std::string &name, const gmm::sub_interval &I, const model_real_plain_vector &VV) { - variables[name] = var_description(true, false, 0, I, &VV, 0, - dim_type(gmm::vect_size(VV))); + variables.emplace(name, var_description(true, 0, 0, I, &VV, + dim_type(gmm::vect_size(VV)))); } void ga_workspace::add_fem_constant @@ -68,22 +68,22 @@ namespace getfem { << "has zero degrees of freedom"); size_type Q = gmm::vect_size(VV)/mf.nb_dof(); if (Q == 0) Q = size_type(1); - variables[name] = var_description(false, true, &mf, - gmm::sub_interval(), &VV, 0, Q); + variables.emplace(name, var_description(false, &mf, 0, + gmm::sub_interval(), &VV, Q)); } void ga_workspace::add_fixed_size_constant (const std::string &name, const model_real_plain_vector &VV) { - variables[name] = var_description(false, false, 0, - gmm::sub_interval(), &VV, 0, - gmm::vect_size(VV)); + variables.emplace(name, var_description(false, 0, 0, + gmm::sub_interval(), &VV, + gmm::vect_size(VV))); } void ga_workspace::add_im_data(const std::string &name, const im_data &imd, const model_real_plain_vector &VV) { - variables[name] = var_description - (false, false, 0, gmm::sub_interval(), &VV, &imd, - gmm::vect_size(VV)/(imd.nb_filtered_index() * imd.nb_tensor_elem())); + variables.emplace(name, var_description + (false, 0, &imd, gmm::sub_interval(), &VV, + gmm::vect_size(VV)/(imd.nb_filtered_index() * imd.nb_tensor_elem()))); } bool ga_workspace::variable_exists(const std::string &name) const {