[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] (no subject)
From: |
Tetsuo Koyama |
Subject: |
[Getfem-commits] (no subject) |
Date: |
Wed, 20 Feb 2019 08:20:33 -0500 (EST) |
branch: devel-tetsuo-code-cleanup
commit fe2a3574d2db25bc1d99994738847cf5bb448147
Author: Tetsuo Koyama <address@hidden>
Date: Wed Feb 20 22:13:24 2019 +0900
Simplify disable_variable and enable_variable
---
src/getfem/getfem_models.h | 3 +++
src/getfem_models.cc | 28 +++++++++-------------------
2 files changed, 12 insertions(+), 19 deletions(-)
diff --git a/src/getfem/getfem_models.h b/src/getfem/getfem_models.h
index b8b697c..5ada2c3 100644
--- a/src/getfem/getfem_models.h
+++ b/src/getfem/getfem_models.h
@@ -506,6 +506,9 @@ namespace getfem {
active_bricks.add(ib);
}
+ /** Set is_disable of a variable (and its attached mutlipliers). */
+ inline void set_is_disabled_of_variable(const std::string &name, bool
flag);
+
/** Disable a variable (and its attached mutlipliers). */
void disable_variable(const std::string &name);
diff --git a/src/getfem_models.cc b/src/getfem_models.cc
index 6754dd0..3424c8e 100644
--- a/src/getfem_models.cc
+++ b/src/getfem_models.cc
@@ -873,40 +873,30 @@ namespace getfem {
add_dependency(mf);
}
- void model::disable_variable(const std::string &name) {
+ inline void model::set_is_disabled_of_variable(const std::string &name, bool
flag) {
VAR_SET::iterator it = variables.find(name);
GMM_ASSERT1(it != variables.end(), "Undefined variable " << name);
- it->second.is_disabled = true;
+ it->second.is_disabled = flag;
for (VAR_SET::iterator itv = variables.begin();
itv != variables.end(); ++itv) {
if (((itv->second.filter & VDESCRFILTER_INFSUP) ||
(itv->second.filter & VDESCRFILTER_CTERM))
&& (name.compare(itv->second.filter_var) == 0)) {
- itv->second.is_disabled = true;
+ itv->second.is_disabled = flag;
}
if (itv->second.is_variable && itv->second.is_affine_dependent
&& name.compare(itv->second.org_name) == 0)
- itv->second.is_disabled = true;
+ itv->second.is_disabled = flag;
}
if (!act_size_to_be_done) resize_global_system();
}
+ void model::disable_variable(const std::string &name) {
+ set_is_disabled_of_variable(name, true);
+ }
+
void model::enable_variable(const std::string &name) {
- VAR_SET::iterator it = variables.find(name);
- GMM_ASSERT1(it != variables.end(), "Undefined variable " << name);
- it->second.is_disabled = false;
- for (VAR_SET::iterator itv = variables.begin();
- itv != variables.end(); ++itv) {
- if (((itv->second.filter & VDESCRFILTER_INFSUP) ||
- (itv->second.filter & VDESCRFILTER_CTERM))
- && (name.compare(itv->second.filter_var) == 0)) {
- itv->second.is_disabled = false;
- }
- if (itv->second.is_variable && itv->second.is_affine_dependent
- && name.compare(itv->second.org_name) == 0)
- itv->second.is_disabled = false;
- }
- if (!act_size_to_be_done) resize_global_system();
+ set_is_disabled_of_variable(name, false);
}
bool model::variable_exists(const std::string &name) const {