[1D] Eliminate deprecated methods of Domain1D

This commit is contained in:
Ray Speth 2014-01-30 00:47:52 +00:00
parent f9278b7e68
commit e59a7a7eeb
9 changed files with 72 additions and 151 deletions

View file

@ -235,38 +235,11 @@ public:
"no component named "+name);
}
//! Set the lower and upper bounds for each solution component.
//! @deprecated Use the scalar version
void setBounds(size_t nl, const doublereal* lower,
size_t nu, const doublereal* upper) {
warn_deprecated("setBounds", "Use the scalar version.");
if (nl < m_nv || nu < m_nv)
throw CanteraError("Domain1D::setBounds",
"wrong array size for solution bounds. "
"Size should be at least "+int2str(m_nv));
std::copy(upper, upper + m_nv, m_max.begin());
std::copy(lower, lower + m_nv, m_min.begin());
}
void setBounds(size_t n, doublereal lower, doublereal upper) {
m_min[n] = lower;
m_max[n] = upper;
}
//! set the error tolerances for all solution components.
//! @deprecated Use setTransientTolerances() and setSteadyTolerances().
void setTolerances(size_t nr, const doublereal* rtol,
size_t na, const doublereal* atol, int ts = 0);
//! set the error tolerances for solution component \a n.
//! @deprecated Use setTransientTolerances() and setSteadyTolerances().
void setTolerances(size_t n, doublereal rtol, doublereal atol, int ts = 0);
//! set scalar error tolerances. All solution components will have the
//! same relative and absolute error tolerances.
//! @deprecated Use setTransientTolerances() and setSteadyTolerances().
void setTolerances(doublereal rtol, doublereal atol,int ts=0);
//! Set tolerances for time-stepping mode
/*!
* @param rtol Relative tolerance
@ -277,9 +250,6 @@ public:
*/
void setTransientTolerances(doublereal rtol, doublereal atol, size_t n=npos);
//! @deprecated use setTransientTolerances()
void setTolerancesTS(doublereal rtol, doublereal atol, size_t n=npos);
//! Set tolerances for steady-state mode
/*!
* @param rtol Relative tolerance
@ -290,9 +260,6 @@ public:
*/
void setSteadyTolerances(doublereal rtol, doublereal atol, size_t n=npos);
//! @deprecated use setSteadyTolerances()
void setTolerancesSS(doublereal rtol, doublereal atol, size_t n=npos);
//! Relative tolerance of the nth component.
doublereal rtol(size_t n) {
return (m_rdt == 0.0 ? m_rtol_ss[n] : m_rtol_ts[n]);

View file

@ -50,20 +50,20 @@ while length(property_argin) >= 2,
case 'tol'
sz = size(val);
if sz == nComponents(a)
setTolerances(a, val(1,:), val(2,:));
setSteadyTolerances(a, val(1,:), val(2,:));
elseif length(val) == 2
setTolerances(a, 'default', val(1), val(2));
setSteadyTolerances(a, 'default', val(1), val(2));
else
error('wrong array size for error tolerances');
end
case 'tol-time'
sz = size(val);
if sz == nComponents(a)
setTolerances(a, val(1,:), val(2,:));
setTransientTolerances(a, val(1,:), val(2,:));
elseif length(val) == 2
rt = val(1);
at = val(2);
setTolerances(a, 'default', rt, at, 'ts');
setTransientTolerances(a, 'default', rt, at);
else
error('wrong array size for error tolerances');
end

View file

@ -0,0 +1,18 @@
function d = setSteadyTolerances(d, component, rtol, atol)
% SETSTEADYTOLERANCES -
%
if strcmp(component,'default')
nc = nComponents(d);
for ii = 1:nc
domain_methods(d.dom_id, 55, ii, rtol, atol);
end
elseif iscell(component)
nc = length(component);
for ii = 1:nc
n = componentIndex(d, component{ii});
domain_methods(d.dom_id, 55, n, rtol, atol);
end
else
n = componentIndex(d, component);
domain_methods(d.dom_id, 55, n, rtol, atol);
end

View file

@ -1,35 +0,0 @@
function d = setTolerances(d, component, rtol, atol, typ)
% SETTOLERANCES -
%
ityp = 0;
if nargin == 5
switch typ
case 'ts'
ityp = -1;
case 'time'
ityp = -1;
case 'ss'
ityp = 1;
case 'steady'
ityp = 1;
end
end
if strcmp(component,'default')
nc = nComponents(d);
for ii = 1:nc
domain_methods(d.dom_id, 52, ii, rtol, atol, ityp);
end
return
end
if iscell(component)
nc = length(component);
for ii = 1:nc
n = componentIndex(d, component{ii});
domain_methods(d.dom_id, 52, n, rtol, atol, ityp);
end
else
n = componentIndex(d, component);
domain_methods(d.dom_id, 52, n, rtol, atol, ityp);
end

View file

@ -0,0 +1,18 @@
function d = setSteadyTolerances(d, component, rtol, atol)
% SETSTEADYTOLERANCES -
%
if strcmp(component,'default')
nc = nComponents(d);
for ii = 1:nc
domain_methods(d.dom_id, 56, ii, rtol, atol);
end
elseif iscell(component)
nc = length(component);
for ii = 1:nc
n = componentIndex(d, component{ii});
domain_methods(d.dom_id, 56, n, rtol, atol);
end
else
n = componentIndex(d, component);
domain_methods(d.dom_id, 56, n, rtol, atol);
end

View file

@ -152,13 +152,26 @@ extern "C" {
}
}
int domain_setTolerances(int i, int n, double rtol,
double atol, int itime)
int domain_setSteadyTolerances(int i, int n, double rtol,
double atol)
{
try {
Domain1D& dom = DomainCabinet::item(i);
dom.checkComponentIndex(n);
dom.setTolerances(n, rtol, atol, itime);
dom.setSteadyTolerances(rtol, atol, n);
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}
int domain_setTransientTolerances(int i, int n, double rtol,
double atol)
{
try {
Domain1D& dom = DomainCabinet::item(i);
dom.checkComponentIndex(n);
dom.setTransientTolerances(rtol, atol, n);
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);

View file

@ -20,8 +20,10 @@ extern "C" {
double upper);
CANTERA_CAPI double domain_lowerBound(int i, int n);
CANTERA_CAPI double domain_upperBound(int i, int n);
CANTERA_CAPI int domain_setTolerances(int i, int n, double rtol,
double atol, int itime);
CANTERA_CAPI int domain_setSteadyTolerances(int i, int n, double rtol,
double atol);
CANTERA_CAPI int domain_setTransientTolerances(int i, int n, double rtol,
double atol);
CANTERA_CAPI double domain_rtol(int i, int n);
CANTERA_CAPI double domain_atol(int i, int n);
CANTERA_CAPI int domain_setupGrid(int i, size_t npts, double* grid);

View file

@ -229,14 +229,6 @@ void onedimmethods(int nlhs, mxArray* plhs[],
upper = getDouble(prhs[5]);
iok = domain_setBounds(dom, n, lower, upper);
break;
case 52:
checkNArgs(7, nrhs);
n = getInt(prhs[3]) - 1;
rtol = getDouble(prhs[4]);
atol = getDouble(prhs[5]);
itime = getInt(prhs[6]);
iok = domain_setTolerances(dom, n, rtol, atol, itime);
break;
case 53:
checkNArgs(4, nrhs);
grid = mxGetPr(prhs[3]);
@ -247,6 +239,18 @@ void onedimmethods(int nlhs, mxArray* plhs[],
id = getString(prhs[3]);
iok = domain_setID(dom, id);
break;
case 55:
case 56:
checkNArgs(6, nrhs);
n = getInt(prhs[3]) - 1;
rtol = getDouble(prhs[4]);
atol = getDouble(prhs[5]);
if (job == 55) {
iok = domain_setSteadyTolerances(dom, n, rtol, atol);
} else {
iok = domain_setTransientTolerances(dom, n, rtol, atol);
}
break;
case 60:
checkNArgs(4, nrhs);
mdot = getDouble(prhs[3]);

View file

@ -15,58 +15,6 @@ using namespace ctml;
namespace Cantera
{
void Domain1D::
setTolerances(size_t nr, const doublereal* rtol,
size_t na, const doublereal* atol, int ts)
{
warn_deprecated("Domain1D::setTolerances",
"Use setTransientTolerances or setSteadyTolerances.");
if (nr < m_nv || na < m_nv)
throw CanteraError("Domain1D::setTolerances",
"wrong array size for solution error tolerances. "
"Size should be at least "+int2str(m_nv));
if (ts >= 0) {
copy(rtol, rtol + m_nv, m_rtol_ss.begin());
copy(atol, atol + m_nv, m_atol_ss.begin());
}
if (ts <= 0) {
copy(rtol, rtol + m_nv, m_rtol_ts.begin());
copy(atol, atol + m_nv, m_atol_ts.begin());
}
}
void Domain1D::
setTolerances(size_t n, doublereal rtol, doublereal atol, int ts)
{
warn_deprecated("Domain1D::setTolerances",
"Use setTransientTolerances or setSteadyTolerances.");
if (ts >= 0) {
m_rtol_ss[n] = rtol;
m_atol_ss[n] = atol;
}
if (ts <= 0) {
m_rtol_ts[n] = rtol;
m_atol_ts[n] = atol;
}
}
void Domain1D::
setTolerances(doublereal rtol, doublereal atol,int ts)
{
warn_deprecated("Domain1D::setTolerances",
"Use setTransientTolerances or setSteadyTolerances.");
for (size_t n = 0; n < m_nv; n++) {
if (ts >= 0) {
m_rtol_ss[n] = rtol;
m_atol_ss[n] = atol;
}
if (ts <= 0) {
m_rtol_ts[n] = rtol;
m_atol_ts[n] = atol;
}
}
}
void Domain1D::setTransientTolerances(doublereal rtol, doublereal atol, size_t n)
{
if (n == npos) {
@ -80,13 +28,6 @@ void Domain1D::setTransientTolerances(doublereal rtol, doublereal atol, size_t n
}
}
void Domain1D::setTolerancesTS(doublereal rtol, doublereal atol, size_t n)
{
warn_deprecated("Domain1D::setTolerancesTS",
"Use setTransientTolerances");
setTransientTolerances(rtol, atol, n);
}
void Domain1D::setSteadyTolerances(doublereal rtol, doublereal atol, size_t n)
{
if (n == npos) {
@ -100,13 +41,6 @@ void Domain1D::setSteadyTolerances(doublereal rtol, doublereal atol, size_t n)
}
}
void Domain1D::setTolerancesSS(doublereal rtol, doublereal atol, size_t n)
{
warn_deprecated("Domain1D::setTolerancesSS",
"Use setSteadyTolerances");
setSteadyTolerances(rtol, atol, n);
}
void Domain1D::needJacUpdate()
{
if (m_container) {