[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] r5412 - in /trunk/getfem/src: getfem/getfem_models.h ge
From: |
andriy . andreykiv |
Subject: |
[Getfem-commits] r5412 - in /trunk/getfem/src: getfem/getfem_models.h getfem_models.cc |
Date: |
Wed, 12 Oct 2016 13:51:04 -0000 |
Author: andrico
Date: Wed Oct 12 15:51:04 2016
New Revision: 5412
URL: http://svn.gna.org/viewcvs/getfem?rev=5412&view=rev
Log:
fixed sub-string length.
Slightly more consistent interface for the "Old_" prefix
Modified:
trunk/getfem/src/getfem/getfem_models.h
trunk/getfem/src/getfem_models.cc
Modified: trunk/getfem/src/getfem/getfem_models.h
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/getfem_models.h?rev=5412&r1=5411&r2=5412&view=diff
==============================================================================
--- trunk/getfem/src/getfem/getfem_models.h (original)
+++ trunk/getfem/src/getfem/getfem_models.h Wed Oct 12 15:51:04 2016
@@ -129,7 +129,7 @@
if (!(v.compare(0, 3, "Dot")) && (v[3] == '_' || v[4] == '_')) {
v = v.substr((v[3] == '_') ? 4 : 5);
}
- if (!(v.compare(0, 9, "Old_"))) v = v.substr(9);
+ if (!(v.compare(0, 4, "Old_"))) v = v.substr(4);
return v;
}
@@ -560,8 +560,8 @@
/** Says if a name corresponds to a declared variable. */
bool variable_exists(const std::string &name) const {
- if (!(name.compare(0, 9, "Old_")))
- return variables.count(name.substr(9)) > 0;
+ if (!(name.compare(0, 4, "Old_")))
+ return variables.count(name.substr(4)) > 0;
else
return variables.count(name) > 0;
}
@@ -620,26 +620,42 @@
/** Gives the access to the vector value of a variable. For the real
version. */
const model_real_plain_vector &
- real_variable(const std::string &name,
- size_type niter = size_type(-1)) const;
+ real_variable(const std::string &name, size_type niter) const;
+
+ /**The same as above, but either accessing the latest variable version,
+ or the previous, if using "Old_" prefix*/
+ const model_real_plain_vector &
+ real_variable(const std::string &name) const;
/** Gives the access to the vector value of a variable. For the complex
version. */
const model_complex_plain_vector &
- complex_variable(const std::string &name,
- size_type niter = size_type(-1)) const;
+ complex_variable(const std::string &name, size_type niter) const;
+
+ /**The same as above, but either accessing the latest variable version,
+ or the previous, if using "Old_" prefix*/
+ const model_complex_plain_vector &
+ complex_variable(const std::string &name) const;
/** Gives the write access to the vector value of a variable. Make a
change flag of the variable set. For the real version. */
model_real_plain_vector &
- set_real_variable(const std::string &name,
- size_type niter = size_type(-1)) const;
+ set_real_variable(const std::string &name, size_type niter) const;
+
+ /**The same as above, but for either latest variable, or
+ for the previous, if prefixed with "Old_".*/
+ model_real_plain_vector &
+ set_real_variable(const std::string &name) const;
/** Gives the write access to the vector value of a variable. Make a
change flag of the variable set. For the complex version. */
model_complex_plain_vector &
- set_complex_variable(const std::string &name,
- size_type niter = size_type(-1)) const;
+ set_complex_variable(const std::string &name, size_type niter) const;
+
+ /**The same as above, but either accessing the latest variable version,
+ or the previous, if using "Old_" prefix*/
+ model_complex_plain_vector &
+ set_complex_variable(const std::string &name) const;
model_real_plain_vector &
set_real_constant_part(const std::string &name) const;
Modified: trunk/getfem/src/getfem_models.cc
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem_models.cc?rev=5412&r1=5411&r2=5412&view=diff
==============================================================================
--- trunk/getfem/src/getfem_models.cc (original)
+++ trunk/getfem/src/getfem_models.cc Wed Oct 12 15:51:04 2016
@@ -244,7 +244,7 @@
}
bool model::is_disabled_variable(const std::string &name) const {
- if (!(name.compare(0, 9, "Old_"))) return false;
+ if (!(name.compare(0, 4, "Old_"))) return false;
VAR_SET::const_iterator it = find_variable(name);
if (!(it->second.is_variable)) return false;
if (it->second.is_affine_dependent)
@@ -253,7 +253,7 @@
}
bool model::is_data(const std::string &name) const {
- if (!(name.compare(0, 9, "Old_"))) return true;
+ if (!(name.compare(0, 4, "Old_"))) return true;
VAR_SET::const_iterator it = find_variable(name);
if (it->second.is_affine_dependent)
it = variables.find(it->second.org_name);
@@ -261,13 +261,13 @@
}
bool model::is_true_data(const std::string &name) const {
- if (!(name.compare(0, 9, "Old_"))) return true;
+ if (!(name.compare(0, 4, "Old_"))) return true;
VAR_SET::const_iterator it = find_variable(name);
return (!(it->second.is_variable));
}
bool model::is_affine_dependent_variable(const std::string &name) const {
- if (!(name.compare(0, 9, "Old_"))) return false;
+ if (!(name.compare(0, 4, "Old_"))) return false;
VAR_SET::const_iterator it = find_variable(name);
return (it->second.is_affine_dependent);
}
@@ -297,8 +297,8 @@
bool model::is_im_data(const std::string &name) const {
VAR_SET::const_iterator it;
- if (!(name.compare(0, 9, "Old_")))
- it = find_variable(name.substr(9));
+ if (!(name.compare(0, 4, "Old_")))
+ it = find_variable(name.substr(4));
else
it = find_variable(name);
return (it->second.pim_data != 0);
@@ -307,8 +307,8 @@
const im_data *
model::pim_data_of_variable(const std::string &name) const {
VAR_SET::const_iterator it;
- if (!(name.compare(0, 9, "Old_")))
- it = find_variable(name.substr(9));
+ if (!(name.compare(0, 4, "Old_")))
+ it = find_variable(name.substr(4));
else
it = find_variable(name);
return it->second.pim_data;
@@ -3017,16 +3017,18 @@
}
const model_real_plain_vector &
+ model::real_variable(const std::string &name) const {
+ if (!name.compare(0, 4, "Old_")) return real_variable(name.substr(4), 1);
+ else return real_variable(name, size_type(-1));
+ }
+
+ const model_real_plain_vector &
model::real_variable(const std::string &name, size_type niter) const {
GMM_ASSERT1(!complex_version, "This model is a complex one");
+ GMM_ASSERT1(name.compare(0, 4, "Old_"), "Please don't use Old_ prefix in
combination with"
+ " variable version");
context_check();
- VAR_SET::iterator it;
- if (!(name.compare(0, 9, "Old_"))) {
- it = variables.find(name.substr(9)); niter = 1;
- } else {
- it = variables.find(name);
- }
-
+ auto it = variables.find(name);
GMM_ASSERT1(it!=variables.end(), "Undefined variable " << name);
if (act_size_to_be_done && it->second.is_fem_dofs) {
if (it->second.filter != VDESCRFILTER_NO)
@@ -3041,15 +3043,18 @@
}
const model_complex_plain_vector &
+ model::complex_variable(const std::string &name) const {
+ if (!name.compare(0, 4, "Old_")) return complex_variable(name.substr(4),
1);
+ else return complex_variable(name, size_type(-1));
+ }
+
+ const model_complex_plain_vector &
model::complex_variable(const std::string &name, size_type niter) const {
GMM_ASSERT1(complex_version, "This model is a real one");
+ GMM_ASSERT1(name.compare(0, 4, "Old_"), "Please don't use Old_ prefix in
combination with"
+ " variable version");
context_check();
- VAR_SET::iterator it;
- if (!(name.compare(0, 9, "Old_"))) {
- it = variables.find(name.substr(9)); niter = 1;
- } else {
- it = variables.find(name);
- }
+ auto it = variables.find(name);
GMM_ASSERT1(it!=variables.end(), "Undefined variable " << name);
if (act_size_to_be_done && it->second.is_fem_dofs) {
if (it->second.filter != VDESCRFILTER_NO)
@@ -3065,15 +3070,19 @@
}
model_real_plain_vector &
+ model::set_real_variable(const std::string &name) const {
+ if (!name.compare(0, 4, "Old_")) return set_real_variable(name.substr(4),
1);
+ else return set_real_variable(name, size_type(-1));
+ }
+
+
+ model_real_plain_vector &
model::set_real_variable(const std::string &name, size_type niter) const {
GMM_ASSERT1(!complex_version, "This model is a complex one");
+ GMM_ASSERT1(name.compare(0, 4, "Old_"), "Please don't use Old_ prefix in
combination with"
+ " variable version");
context_check();
- VAR_SET::iterator it;
- if (!(name.compare(0, 9, "Old_"))) {
- it = variables.find(name.substr(9)); niter = 1;
- } else {
- it = variables.find(name);
- }
+ auto it = variables.find(name);
GMM_ASSERT1(it!=variables.end(), "Undefined variable " << name);
if (act_size_to_be_done && it->second.is_fem_dofs) {
if (it->second.filter != VDESCRFILTER_NO)
@@ -3089,16 +3098,19 @@
return it->second.real_value[niter];
}
+model_complex_plain_vector &
+ model::set_complex_variable(const std::string &name) const {
+ if (!name.compare(0, 4, "Old_")) return
set_complex_variable(name.substr(4), 1);
+ else return set_complex_variable(name, size_type(-1));
+ }
+
model_complex_plain_vector &
model::set_complex_variable(const std::string &name, size_type niter) const {
GMM_ASSERT1(complex_version, "This model is a real one");
+ GMM_ASSERT1(name.compare(0, 4, "Old_"), "Please don't use Old_ prefix in
combination with"
+ " variable version");
context_check();
- VAR_SET::iterator it;
- if (!(name.compare(0, 9, "Old_"))) {
- it = variables.find(name.substr(9)); niter = 1;
- } else {
- it = variables.find(name);
- }
+ auto it = variables.find(name);
GMM_ASSERT1(it!=variables.end(), "Undefined variable " << name);
if (act_size_to_be_done && it->second.is_fem_dofs) {
if (it->second.filter != VDESCRFILTER_NO)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Getfem-commits] r5412 - in /trunk/getfem/src: getfem/getfem_models.h getfem_models.cc,
andriy . andreykiv <=