[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] (no subject)
From: |
Konstantinos Poulios |
Subject: |
[Getfem-commits] (no subject) |
Date: |
Thu, 7 Mar 2019 16:06:34 -0500 (EST) |
branch: master
commit ccb9a29bed98470d88ef896976b38e6eab147b07
Author: Konstantinos Poulios <address@hidden>
Date: Thu Mar 7 22:06:26 2019 +0100
Code clean up, renamings, stricter constness
---
src/getfem/getfem_generic_assembly.h | 28 +++++-------
src/getfem/getfem_models.h | 60 +++++++++++++------------
src/getfem_generic_assembly_compile_and_exec.cc | 60 ++++++++++++-------------
src/getfem_generic_assembly_workspace.cc | 26 +++++------
src/getfem_models.cc | 56 +++++++++++------------
5 files changed, 110 insertions(+), 120 deletions(-)
diff --git a/src/getfem/getfem_generic_assembly.h
b/src/getfem/getfem_generic_assembly.h
index 4312ec8..ece421f 100644
--- a/src/getfem/getfem_generic_assembly.h
+++ b/src/getfem/getfem_generic_assembly.h
@@ -276,10 +276,9 @@ namespace getfem {
const im_data *imd;
gmm::sub_interval I;
const model_real_plain_vector *V;
- 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)
- // and for constant variables.
+ 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) and for constant variables.
size_type qdim() const {
size_type q = 1;
@@ -337,8 +336,7 @@ namespace getfem {
// mesh regions
std::map<const mesh *, std::list<mesh_region> > registred_mesh_regions;
- const mesh_region &
- register_region(const mesh &m, const mesh_region ®ion);
+ const mesh_region ®ister_region(const mesh &m, const mesh_region &rg);
// variables and variable groups
mutable std::map<std::string, gmm::sub_interval> int_disabled_variables;
@@ -355,16 +353,8 @@ namespace getfem {
ga_macro_dictionary macro_dict;
- struct m_tree {
- ga_tree *ptree;
- size_type meshdim;
- bool ignore_X;
- m_tree() : ptree(0), meshdim(-1), ignore_X(false) {}
- m_tree(const m_tree& o);
- m_tree &operator =(const m_tree& o);
- ~m_tree();
- };
-
+ // Adds a tree to the workspace. The argument tree is consumed by the
+ // function and cannot be reused afterwards.
void add_tree(ga_tree &tree, const mesh &m, const mesh_im &mim,
const mesh_region &rg,
const std::string &expr, size_type add_derivative_order,
@@ -389,14 +379,16 @@ namespace getfem {
{ GMM_ASSERT1(assemb_t.size() == 1, "Bad result size"); return
assemb_t[0]; }
const base_vector &assembled_vector() const { return *V; }
base_vector &assembled_vector() { return *V; }
+ // setter functions
void set_assembled_matrix(model_real_sparse_matrix &K_) {
K = std::shared_ptr<model_real_sparse_matrix>
- (std::shared_ptr<model_real_sparse_matrix>(), &K_);
+ (std::shared_ptr<model_real_sparse_matrix>(), &K_); // alias
}
void set_assembled_vector(base_vector &V_) {
V = std::shared_ptr<base_vector>
- (std::shared_ptr<base_vector>(), &V_);
+ (std::shared_ptr<base_vector>(), &V_); // alias
}
+ // getter functions
base_tensor &assembled_tensor() { return assemb_t; }
const base_tensor &assembled_tensor() const { return assemb_t; }
diff --git a/src/getfem/getfem_models.h b/src/getfem/getfem_models.h
index 31c0023..2d884ad 100644
--- a/src/getfem/getfem_models.h
+++ b/src/getfem/getfem_models.h
@@ -149,22 +149,25 @@ namespace getfem {
bool is_variable; // This is a variable or a parameter.
bool is_disabled; // For a variable, to be solved or not
bool is_complex; // The variable is complex numbers
- bool is_affine_dependent; // The variable depends in an affine way
- // to another variable.
+ bool is_affine_dependent; // The variable depends in an affine way
+ // to another variable.
bool is_fem_dofs; // The variable is the dofs of a fem
- var_description_filter filter; // A filter on the dofs is applied or not.
- size_type n_iter; // Number of versions of the variable stored.
- size_type n_temp_iter; // Number of additional temporary versions
- size_type default_iter; // default iteration number.
+ size_type n_iter; // Number of versions of the variable stored.
+ size_type n_temp_iter; // Number of additional temporary versions
+ size_type default_iter; // default iteration number.
- ptime_scheme ptsc; // For optional time integration scheme
+ ptime_scheme ptsc; // For optional time integration scheme
- // fem description of the variable
- const mesh_fem *mf; // Main fem of the variable.
- size_type m_region; // Optional region for the filter
- const mesh_im *mim; // Optional integration method for the filter
- ppartial_mesh_fem partial_mf; // Filter with respect to mf.
- std::string filter_var; // Optional variable name for the filter
+ var_description_filter filter; // Version of an optional filter
+ // on the dofs
+ size_type filter_region; // Optional region for the filter
+ std::string filter_var; // Optional variable name for the filter
+ const mesh_im *filter_mim; // Optional integration method for the
filter
+
+ // fem or im_data description of the variable
+ const mesh_fem *mf; // Main fem of the variable.
+ ppartial_mesh_fem partial_mf; // Filter with respect to mf.
+ const im_data *imd; // im data description
bgeot::multi_index qdims; // For data having a qdim != of the fem
// (dim per dof for dof data)
@@ -187,26 +190,25 @@ namespace getfem {
std::string org_name; // Name of the original variable for affine
// dependent variables
- // im data description
- const im_data *pim_data;
-
size_type qdim() const { return qdims.total_size(); }
var_description(bool is_var = false, bool is_com = false,
bool is_fem = false, size_type n_it = 1,
- var_description_filter fil = VDESCRFILTER_NO,
- const mesh_fem *mmf = 0,
- size_type m_reg = size_type(-1),
+ var_description_filter filter_ = VDESCRFILTER_NO,
+ const mesh_fem *mf_ = 0,
+ size_type filter_reg = size_type(-1),
bgeot::multi_index qdims_ = bgeot::multi_index(),
- const std::string &filter_v = std::string(""),
- const mesh_im *mim_ = 0, const im_data *pimd = 0)
+ const std::string &filter_var_ = std::string(""),
+ const mesh_im *filter_mim_ = 0, const im_data *imd_ = 0)
: is_variable(is_var), is_disabled(false), is_complex(is_com),
- is_affine_dependent(false), is_fem_dofs(is_fem), filter(fil),
+ is_affine_dependent(false), is_fem_dofs(is_fem),
n_iter(std::max(size_type(1), n_it)), n_temp_iter(0),
- default_iter(0), ptsc(0), mf(mmf), m_region(m_reg), mim(mim_),
- filter_var(filter_v), qdims(qdims_), v_num(0),
+ default_iter(0), ptsc(0),
+ filter(filter_), filter_region(filter_reg), filter_var(filter_var_),
+ filter_mim(filter_mim_),
+ mf(mf_), imd(imd_), qdims(qdims_), v_num(0),
v_num_data(n_iter, act_counter()), I(0,0),
- alpha(1), pim_data(pimd) {
+ alpha(1) {
if (filter != VDESCRFILTER_NO && mf != 0)
partial_mf = std::make_shared<partial_mesh_fem>(*mf);
@@ -228,10 +230,10 @@ namespace getfem {
}
const mesh_fem *passociated_mf() const {
- if (!is_fem_dofs)
- return 0;
- return (filter == VDESCRFILTER_NO || partial_mf.get() == 0)
- ? mf : partial_mf.get();
+ if (is_fem_dofs)
+ return (filter == VDESCRFILTER_NO || partial_mf.get() == 0)
+ ? mf : partial_mf.get();
+ return 0;
}
size_type size() const // Should control that the variable is
diff --git a/src/getfem_generic_assembly_compile_and_exec.cc
b/src/getfem_generic_assembly_compile_and_exec.cc
index cb7bd65..875e0a8 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -1179,8 +1179,8 @@ namespace getfem {
struct ga_instruction_interpolate_filter : public ga_instruction {
base_tensor &t;
const ga_instruction_set::interpolate_info &inin;
- size_type pt_type;
- int nb;
+ const size_type pt_type;
+ const int nb;
virtual int exec() {
GA_DEBUG_INFO("Instruction: interpolated filter");
@@ -1206,7 +1206,7 @@ namespace getfem {
struct ga_instruction_copy_interpolated_small_vect : public ga_instruction {
base_tensor &t;
const base_small_vector &vec;
- ga_instruction_set::interpolate_info &inin;
+ const ga_instruction_set::interpolate_info &inin;
virtual int exec() {
GA_DEBUG_INFO("Instruction: copy small vector");
@@ -1216,9 +1216,9 @@ namespace getfem {
gmm::copy(vec, t.as_vector());
return 0;
}
- ga_instruction_copy_interpolated_small_vect(base_tensor &t_,
- const base_small_vector &vec_,
- ga_instruction_set::interpolate_info &inin_)
+ ga_instruction_copy_interpolated_small_vect
+ (base_tensor &t_, const base_small_vector &vec_,
+ const ga_instruction_set::interpolate_info &inin_)
: t(t_), vec(vec_), inin(inin_) {}
};
@@ -4040,7 +4040,7 @@ namespace getfem {
for (; it != ite;) *it++ += (*itt++) * coeff;
// gmm::add(gmm::scaled(t.as_vector(), coeff), elem);
}
- if (ipt == nbpt-1 || interpolate) {
+ if (ipt == nbpt-1 || interpolate) { // finalize
const mesh_fem &mf = *(mfg ? *mfg : mfn);
GMM_ASSERT1(mfg ? *mfg : mfn, "Internal error");
const gmm::sub_interval &I = mf.is_reduced() ? Ir : In;
@@ -4212,10 +4212,9 @@ namespace getfem {
}
- template <class MAT = model_real_sparse_matrix>
struct ga_instruction_matrix_assembly : public ga_instruction {
const base_tensor &t;
- MAT &Kr, &Kn;
+ model_real_sparse_matrix &Kr, &Kn;
const fem_interpolation_context &ctx1, &ctx2;
const gmm::sub_interval &Ir1, &Ir2, &In1, &In2;
const mesh_fem *mfn1, *mfn2, **mfg1, **mfg2;
@@ -4252,12 +4251,12 @@ namespace getfem {
for (; it != ite;) *it++ += (*itt++) * e;
// gmm::add(gmm::scaled(t.as_vector(), coeff*alpha1*alpha2), elem);
}
- if (ipt == nbpt-1 || interpolate) {
+ if (ipt == nbpt-1 || interpolate) { // finalize
const mesh_fem *pmf1 = mfg1 ? *mfg1 : mfn1;
const mesh_fem *pmf2 = mfg2 ? *mfg2 : mfn2;
bool reduced = (pmf1 && pmf1->is_reduced())
|| (pmf2 && pmf2->is_reduced());
- MAT &K = reduced ? Kr : Kn;
+ model_real_sparse_matrix &K = reduced ? Kr : Kn;
const gmm::sub_interval &I1 = reduced ? Ir1 : In1;
const gmm::sub_interval &I2 = reduced ? Ir2 : In2;
GA_DEBUG_ASSERT(I1.size() && I2.size(), "Internal error");
@@ -4272,7 +4271,7 @@ namespace getfem {
dofs1.assign(s1, I1.first());
if (pmf1) {
- if (!(ctx1.is_convex_num_valid())) return 0;
+ if (!ctx1.is_convex_num_valid()) return 0;
N = ctx1.N();
auto &ct1 = pmf1->ind_scalar_basic_dof_of_element(cv1);
size_type qmult1 = pmf1->get_qdim();
@@ -4301,7 +4300,7 @@ namespace getfem {
} else {
dofs2.assign(s2, I2.first());
if (pmf2) {
- if (!(ctx2.is_convex_num_valid())) return 0;
+ if (!ctx2.is_convex_num_valid()) return 0;
N = std::max(N, ctx2.N());
auto &ct2 = pmf2->ind_scalar_basic_dof_of_element(cv2);
size_type qmult2 = pmf2->get_qdim();
@@ -4324,7 +4323,8 @@ namespace getfem {
return 0;
}
ga_instruction_matrix_assembly
- (const base_tensor &t_, MAT &Kr_, MAT &Kn_,
+ (const base_tensor &t_,
+ model_real_sparse_matrix &Kr_, model_real_sparse_matrix &Kn_,
const fem_interpolation_context &ctx1_,
const fem_interpolation_context &ctx2_,
const gmm::sub_interval &Ir1_, const gmm::sub_interval &In1_,
@@ -4341,10 +4341,9 @@ namespace getfem {
dofs1(0), dofs2(0) {}
};
- template <class MAT = model_real_sparse_matrix>
struct ga_instruction_matrix_assembly_standard_scalar: public ga_instruction
{
const base_tensor &t;
- MAT &K;
+ model_real_sparse_matrix &K;
const fem_interpolation_context &ctx1, &ctx2;
const gmm::sub_interval &I1, &I2;
const mesh_fem *pmf1, *pmf2;
@@ -4378,7 +4377,7 @@ namespace getfem {
for (; it != ite;) *it++ += (*itt++) * e;
// gmm::add(gmm::scaled(t.as_vector(), coeff*alpha1*alpha2), elem);
}
- if (ipt == nbpt-1) {
+ if (ipt == nbpt-1) { // finalize
GA_DEBUG_ASSERT(I1.size() && I2.size(), "Internal error");
scalar_type ninf = gmm::vect_norminf(elem);
@@ -4414,7 +4413,7 @@ namespace getfem {
return 0;
}
ga_instruction_matrix_assembly_standard_scalar
- (const base_tensor &t_, MAT &Kn_,
+ (const base_tensor &t_, model_real_sparse_matrix &Kn_,
const fem_interpolation_context &ctx1_,
const fem_interpolation_context &ctx2_,
const gmm::sub_interval &In1_, const gmm::sub_interval &In2_,
@@ -4426,10 +4425,9 @@ namespace getfem {
coeff(coeff_), alpha1(a1), alpha2(a2), nbpt(nbpt_), ipt(ipt_) {}
};
- template <class MAT = model_real_sparse_matrix>
struct ga_instruction_matrix_assembly_standard_vector: public ga_instruction
{
const base_tensor &t;
- MAT &K;
+ model_real_sparse_matrix &K;
const fem_interpolation_context &ctx1, &ctx2;
const gmm::sub_interval &I1, &I2;
const mesh_fem *pmf1, *pmf2;
@@ -4467,7 +4465,7 @@ namespace getfem {
for (; it != ite;) *it++ += (*itt++) * e;
// gmm::add(gmm::scaled(t.as_vector(), coeff*alpha1*alpha2), elem);
}
- if (ipt == nbpt-1) {
+ if (ipt == nbpt-1) { // finalize
GA_DEBUG_ASSERT(I1.size() && I2.size(), "Internal error");
scalar_type ninf = gmm::vect_norminf(elem);
@@ -4511,7 +4509,7 @@ namespace getfem {
return 0;
}
ga_instruction_matrix_assembly_standard_vector
- (const base_tensor &t_, MAT &Kn_,
+ (const base_tensor &t_, model_real_sparse_matrix &Kn_,
const fem_interpolation_context &ctx1_,
const fem_interpolation_context &ctx2_,
const gmm::sub_interval &In1_, const gmm::sub_interval &In2_,
@@ -4557,7 +4555,7 @@ namespace getfem {
*itel++ += (*it) * e;
}
}
- if (ipt == nbpt-1) {
+ if (ipt == nbpt-1) { // finalize
GA_DEBUG_ASSERT(I1.size() && I2.size(), "Internal error");
scalar_type ninf = gmm::vect_norminf(elem) * 1E-14;
@@ -4643,7 +4641,7 @@ namespace getfem {
*itel++ += (*it) * e;
}
}
- if (ipt == nbpt-1) {
+ if (ipt == nbpt-1) { // finalize
GA_DEBUG_ASSERT(I1.size() && I2.size(), "Internal error");
scalar_type ninf = gmm::vect_norminf(elem)*1E-14;
@@ -4742,9 +4740,9 @@ namespace getfem {
const mesh_fem *mf = workspace.associated_mf(varname);
if (mf->is_reduced()) {
auto n = (mf->get_qdim() == 1) ? workspace.qdim(varname) : 1;
- base_vector U(mf->nb_basic_dof() * n);
+ base_vector &U = gis.really_extended_vars[varname];
+ gmm::resize(U, mf->nb_basic_dof() * n);
mf->extend_vector(workspace.value(varname), U);
- gis.really_extended_vars[varname] = U;
gis.extended_vars[varname] = &(gis.really_extended_vars[varname]);
} else {
gis.extended_vars[varname] = &(workspace.value(varname));
@@ -6804,7 +6802,7 @@ namespace getfem {
const mesh_fem **mfg = 0;
const gmm::sub_interval *Ir = 0, *In = 0;
const std::string &intn1 = root->interpolate_name_test1;
- bool secondary = intn1.size() &&
+ bool secondary = !intn1.empty() &&
workspace.secondary_domain_exists(intn1);
if (intn1.size() && !secondary &&
workspace.variable_group_exists(root->name_test1)) {
@@ -6906,7 +6904,7 @@ namespace getfem {
!(mf1->is_reduced()) && !(mf2->is_reduced());
if (simple && mf1->get_qdim() == 1 && mf2->get_qdim() == 1) {
pgai = std::make_shared
- <ga_instruction_matrix_assembly_standard_scalar<>>
+ <ga_instruction_matrix_assembly_standard_scalar>
(root->tensor(), workspace.assembled_matrix(), ctx1,
ctx2,
*In1, *In2, mf1, mf2,
gis.coeff, *alpha1, *alpha2, gis.nbpt, gis.ipt);
@@ -6925,13 +6923,13 @@ namespace getfem {
gis.coeff, *alpha1, *alpha2, gis.nbpt, gis.ipt);
else
pgai = std::make_shared
- <ga_instruction_matrix_assembly_standard_vector<>>
+ <ga_instruction_matrix_assembly_standard_vector>
(root->tensor(),
workspace.assembled_matrix(),ctx1,ctx2,
*In1, *In2, mf1, mf2,
gis.coeff, *alpha1, *alpha2, gis.nbpt, gis.ipt);
} else {
- pgai = std::make_shared<ga_instruction_matrix_assembly<>>
+ pgai = std::make_shared<ga_instruction_matrix_assembly>
(root->tensor(), workspace.unreduced_matrix(),
workspace.assembled_matrix(), ctx1, ctx2,
*Ir1, *In1, *Ir2, *In2, mf1, mfg1, mf2, mfg2,
@@ -6948,7 +6946,7 @@ namespace getfem {
}
}
}
- }
+ } // ga_compile(...)
diff --git a/src/getfem_generic_assembly_workspace.cc
b/src/getfem_generic_assembly_workspace.cc
index 4a7237b..9d95991 100644
--- a/src/getfem_generic_assembly_workspace.cc
+++ b/src/getfem_generic_assembly_workspace.cc
@@ -514,24 +514,24 @@ namespace getfem {
GA_TOC("First analysis time");
if (ltrees[0].root) {
if (test1.size() > 1 || test2.size() > 1) {
- size_type ntest2 = std::max(size_type(1), test2.size());
- size_type nb_ltrees = test1.size()*ntest2;
- ltrees.resize(nb_ltrees);
- for (size_type i = 1; i < nb_ltrees; ++i) ltrees[i] = ltrees[0];
- std::set<var_trans_pair>::iterator it1 = test1.begin();
- for (size_type i = 0; i < test1.size(); ++i, ++it1) {
- std::set<var_trans_pair>::iterator it2 = test2.begin();
- for (size_type j = 0; j < ntest2; ++j) {
- selected_test1 = *it1;
- if (test2.size()) selected_test2 = *it2++;
+ size_type ntest2 = test2.size();
+ if (ntest2 == 0) // temporarily add an element to
+ test2.insert(var_trans_pair()); // allow entering the inner loop
+ ltrees.resize(test1.size()*test2.size(), ltrees[0]);
+ auto ltree = ltrees.begin();
+ for (const auto &t1 : test1) {
+ for (const auto &t2 : test2) {
+ selected_test1 = t1;
+ if (ntest2 > 0) selected_test2 = t2;
// cout << "analysis with " << selected_test1.first << endl;
- ga_semantic_analysis(ltrees[i*ntest2+j], *this,
- mim.linked_mesh(),
+ ga_semantic_analysis(*ltree, *this, mim.linked_mesh(),
ref_elt_dim_of_mesh(mim.linked_mesh()),
false, false, 2);
- // cout <<"split: "<< ga_tree_to_string(ltrees[i*ntest2+j]) <<
endl;
+ // cout <<"split: "<< ga_tree_to_string(*ltree) << endl;
+ if (ltree != ltrees.end()) ++ltree;
}
}
+ if (ntest2 == 0) test2.clear(); // remove temporarily added element
}
for (ga_tree <ree : ltrees) {
diff --git a/src/getfem_models.cc b/src/getfem_models.cc
index 19bb092..8a75b86 100644
--- a/src/getfem_models.cc
+++ b/src/getfem_models.cc
@@ -51,8 +51,9 @@ namespace getfem {
v_num_var_iter.resize(n_iter);
v_num_iter.resize(n_iter);
size_type s = is_fem_dofs ? passociated_mf()->nb_dof()
- : (pim_data ?
- (pim_data->nb_filtered_index() * pim_data->nb_tensor_elem()) : 1);
+ : (imd ? imd->nb_filtered_index()
+ * imd->nb_tensor_elem()
+ : 1);
s *= qdim();
for (size_type i = 0; i < n_iter; ++i)
if (is_complex)
@@ -247,13 +248,12 @@ namespace getfem {
}
bool model::is_im_data(const std::string &name) const {
- return variable_description(no_old_prefix_name(name)).pim_data != 0;
+ return variable_description(no_old_prefix_name(name)).imd != 0;
}
const im_data *
model::pim_data_of_variable(const std::string &name) const {
- auto it = find_variable(no_old_prefix_name(name));
- return it->second.pim_data;
+ return variable_description(no_old_prefix_name(name)).imd;
}
const gmm::uint64_type &
@@ -357,7 +357,7 @@ namespace getfem {
case VDESCRFILTER_REGION:
if (vdescr.v_num < vdescr.mf->version_number()) {
dal::bit_vector
- dor = vdescr.mf->dof_on_region(vdescr.m_region);
+ dor = vdescr.mf->dof_on_region(vdescr.filter_region);
vdescr.partial_mf->adapt(dor);
vdescr.set_size();
vdescr.v_num = act_counter();
@@ -367,9 +367,8 @@ namespace getfem {
}
}
- if (vdescr.pim_data != 0
- && vdescr.v_num < vdescr.pim_data->version_number()) {
- // const im_data *pimd = vdescr.pim_data;
+ if (vdescr.imd != 0
+ && vdescr.v_num < vdescr.imd->version_number()) {
vdescr.set_size();
vdescr.v_num = act_counter();
}
@@ -527,9 +526,9 @@ namespace getfem {
GMM_WARNING1("No term found to filter multiplier " << multname
<< ". Variable is cancelled");
} else if (multdescr.filter & VDESCRFILTER_INFSUP) {
- mesh_region rg(multdescr.m_region);
- multdescr.mim->linked_mesh().intersect_with_mpi_region(rg);
- asm_mass_matrix(MM, *(multdescr.mim), vdescr.associated_mf(),
+ mesh_region rg(multdescr.filter_region);
+ multdescr.filter_mim->linked_mesh().intersect_with_mpi_region(rg);
+ asm_mass_matrix(MM, *(multdescr.filter_mim), vdescr.associated_mf(),
*(multdescr.mf), rg);
}
@@ -556,7 +555,7 @@ namespace getfem {
for (const size_type &icol : columns)
kept.add(icol);
if (multdescr.filter & VDESCRFILTER_REGION)
- kept &= multdescr.mf->dof_on_region(multdescr.m_region);
+ kept &= multdescr.mf->dof_on_region(multdescr.filter_region);
multdescr.partial_mf->adapt(kept);
multdescr.set_size();
multdescr.v_num = act_counter();
@@ -582,7 +581,7 @@ namespace getfem {
for (const size_type &icol : glob_columns)
if (icol >= s && icol < s + nbdof) kept.add(icol-s);
if (multdescr.filter & VDESCRFILTER_REGION)
- kept &= multdescr.mf->dof_on_region(multdescr.m_region);
+ kept &= multdescr.mf->dof_on_region(multdescr.filter_region);
multdescr.partial_mf->adapt(kept);
multdescr.set_size();
multdescr.v_num = act_counter();
@@ -628,7 +627,7 @@ namespace getfem {
if (vdescr.is_variable &&
is_disabled_variable(v.first)) ost << "\t (disabled)";
else ost << "\t ";
- if (vdescr.pim_data != 0) ost << "\t (is im_data)";
+ if (vdescr.imd != 0) ost << "\t (is im_data)";
if (vdescr.is_affine_dependent) ost << "\t (is affine dependent)";
ost << endl;
}
@@ -648,6 +647,7 @@ namespace getfem {
}
void model::listresiduals(std::ostream &ost) const {
+ context_check(); if (act_size_to_be_done) actualize_sizes();
if (variables.size() == 0)
ost << "Model with no variable nor data" << endl;
else {
@@ -690,7 +690,7 @@ namespace getfem {
size_type size) {
GMM_ASSERT1(!(variables[name].is_fem_dofs),
"Cannot explicitly resize a fem variable or data");
- GMM_ASSERT1(variables[name].pim_data == 0,
+ GMM_ASSERT1(variables[name].imd == 0,
"Cannot explicitly resize an im data");
GMM_ASSERT1(size, "Variables of null size are not allowed");
variables[name].qdims.resize(1);
@@ -702,7 +702,7 @@ namespace getfem {
const bgeot::multi_index &sizes) {
GMM_ASSERT1(!(variables[name].is_fem_dofs),
"Cannot explicitly resize a fem variable or data");
- GMM_ASSERT1(variables[name].pim_data == 0,
+ GMM_ASSERT1(variables[name].imd == 0,
"Cannot explicitly resize an im data");
variables[name].qdims = sizes;
variables[name].set_size();
@@ -710,11 +710,9 @@ namespace getfem {
void model::add_fixed_size_data(const std::string &name, size_type size,
size_type niter) {
- check_name_validity(name);
- variables[name] = var_description(false, is_complex(), false, niter);
- GMM_ASSERT1(size, "Data of null size are not allowed");
- variables[name].qdims[0] = size;
- variables[name].set_size();
+ bgeot::multi_index sizes(1);
+ sizes[0] = size;
+ add_fixed_size_data(name, sizes, niter);
}
void model::add_fixed_size_data(const std::string &name,
@@ -761,7 +759,7 @@ namespace getfem {
size_type niter) {
check_name_validity(name);
variables[name] = var_description(false, is_complex(), false, niter);
- variables[name].pim_data = &im_data;
+ variables[name].imd = &im_data;
variables[name].set_size();
add_dependency(im_data);
}
@@ -908,7 +906,7 @@ namespace getfem {
for (const auto &v : variables) {
if (v.second.is_fem_dofs &&
(v.second.filter & VDESCRFILTER_INFSUP) &&
- mim == v.second.mim) found = true;
+ mim == v.second.filter_mim) found = true;
}
if (!found) sup_dependency(*mim);
}
@@ -945,7 +943,7 @@ namespace getfem {
if (!found) sup_dependency(*mf);
if (it->second.filter & VDESCRFILTER_INFSUP) {
- const mesh_im *mim = it->second.mim;
+ const mesh_im *mim = it->second.filter_mim;
found = false;
for (dal::bv_visitor ibb(valid_bricks); !ibb.finished(); ++ibb) {
for (size_type j = 0; j < bricks[ibb].mims.size(); ++j)
@@ -955,13 +953,13 @@ namespace getfem {
it2 != variables.end(); ++it2) {
if (it != it2 && it2->second.is_fem_dofs &&
(it2->second.filter & VDESCRFILTER_INFSUP) &&
- mim == it2->second.mim) found = true;
+ mim == it2->second.filter_mim) found = true;
}
if (!found) sup_dependency(*mim);
}
}
- if (it->second.pim_data != 0) sup_dependency(*(it->second.pim_data));
+ if (it->second.imd != 0) sup_dependency(*(it->second.imd));
variables.erase(varname);
act_size_to_be_done = true;
@@ -2643,7 +2641,7 @@ namespace getfem {
model::qdims_of_variable(const std::string &name) const {
auto it = find_variable(no_old_prefix_name(name));
const mesh_fem *mf = it->second.passociated_mf();
- const im_data *imd = it->second.pim_data;
+ const im_data *imd = it->second.imd;
size_type n = it->second.qdim();
if (mf) {
bgeot::multi_index mi = mf->get_qdims();
@@ -2673,7 +2671,7 @@ namespace getfem {
size_type model::qdim_of_variable(const std::string &name) const {
auto it = find_variable(no_old_prefix_name(name));
const mesh_fem *mf = it->second.passociated_mf();
- const im_data *imd = it->second.pim_data;
+ const im_data *imd = it->second.imd;
size_type n = it->second.qdim();
if (mf) {
return mf->get_qdim() * n;