Fixed some malloc errors that left some memory unfreed.
This commit is contained in:
parent
47ef65b849
commit
59c867ebae
4 changed files with 113 additions and 83 deletions
|
|
@ -156,22 +156,22 @@ namespace Cantera {
|
|||
return (dynamic_cast<Transport *>(tr));
|
||||
}
|
||||
|
||||
LiquidTransport::~LiquidTransport() {
|
||||
LiquidTransport::~LiquidTransport() {
|
||||
|
||||
//These are constructed in TransportFactory::newLTP
|
||||
for ( int k = 0; k < m_nsp; k++) {
|
||||
if ( m_viscTempDep_Ns[k] ) delete m_viscTempDep_Ns[k];
|
||||
if ( m_lambdaTempDep_Ns[k] ) delete m_lambdaTempDep_Ns[k];
|
||||
if ( m_radiusTempDep_Ns[k] ) delete m_radiusTempDep_Ns[k];
|
||||
if ( m_diffTempDep_Ns[k] ) delete m_diffTempDep_Ns[k];
|
||||
}
|
||||
//These are constructed in TransportFactory::newLTI
|
||||
if ( m_viscMixModel ) delete m_viscMixModel;
|
||||
if ( m_lambdaMixModel ) delete m_lambdaMixModel;
|
||||
if ( m_diffMixModel ) delete m_diffMixModel;
|
||||
//if ( m_radiusMixModel ) delete m_radiusMixModel;
|
||||
//These are constructed in TransportFactory::newLTP
|
||||
for ( int k = 0; k < m_nsp; k++) {
|
||||
if ( m_viscTempDep_Ns[k] ) delete m_viscTempDep_Ns[k];
|
||||
if ( m_lambdaTempDep_Ns[k] ) delete m_lambdaTempDep_Ns[k];
|
||||
if ( m_radiusTempDep_Ns[k] ) delete m_radiusTempDep_Ns[k];
|
||||
if ( m_diffTempDep_Ns[k] ) delete m_diffTempDep_Ns[k];
|
||||
}
|
||||
//These are constructed in TransportFactory::newLTI
|
||||
if ( m_viscMixModel ) delete m_viscMixModel;
|
||||
if ( m_lambdaMixModel ) delete m_lambdaMixModel;
|
||||
if ( m_diffMixModel ) delete m_diffMixModel;
|
||||
//if ( m_radiusMixModel ) delete m_radiusMixModel;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize the transport object
|
||||
/*
|
||||
|
|
@ -264,13 +264,17 @@ namespace Cantera {
|
|||
* present class).
|
||||
*/
|
||||
m_viscMixModel = tr.viscosity;
|
||||
tr.viscosity = 0;
|
||||
m_lambdaMixModel = tr.thermalCond;
|
||||
//m_radiusMixModel = tr.hydroRadius;
|
||||
tr.thermalCond = 0;
|
||||
|
||||
m_diffMixModel = tr.speciesDiffusivity;
|
||||
tr.speciesDiffusivity = 0;
|
||||
|
||||
m_bdiff.resize(m_nsp,m_nsp, 0.0);
|
||||
//Don't really need to update this here.
|
||||
//It is updated in updateDiff_T()
|
||||
m_diffMixModel->getMatrixTransProp( m_bdiff );
|
||||
m_diffMixModel->getMatrixTransProp(m_bdiff);
|
||||
|
||||
m_mode = tr.mode_;
|
||||
|
||||
|
|
@ -281,8 +285,9 @@ namespace Cantera {
|
|||
m_concentrations.resize(m_nsp, 0.0);
|
||||
m_actCoeff.resize(m_nsp, 0.0);
|
||||
m_chargeSpecies.resize(m_nsp, 0.0);
|
||||
for ( int i = 0; i < m_nsp; i++ )
|
||||
m_chargeSpecies[i] = m_thermo->charge( i );
|
||||
for ( int i = 0; i < m_nsp; i++ ) {
|
||||
m_chargeSpecies[i] = m_thermo->charge(i);
|
||||
}
|
||||
m_volume_spec.resize(m_nsp, 0.0);
|
||||
m_Grad_lnAC.resize(m_nsp, 0.0);
|
||||
m_spwork.resize(m_nsp, 0.0);
|
||||
|
|
@ -333,17 +338,6 @@ namespace Cantera {
|
|||
m_viscmix = m_viscMixModel->getMixTransProp( m_viscTempDep_Ns );
|
||||
|
||||
return m_viscmix;
|
||||
|
||||
/*
|
||||
// update m_viscSpecies[] if necessary
|
||||
if (!m_visc_temp_ok) {
|
||||
updateViscosity_T();
|
||||
}
|
||||
|
||||
if (!m_visc_conc_ok) {
|
||||
updateViscosities_C();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// Returns the pure species viscosities for all species
|
||||
|
|
@ -382,7 +376,7 @@ namespace Cantera {
|
|||
|
||||
}
|
||||
|
||||
//================================================================
|
||||
//================================================================
|
||||
|
||||
// Return the thermal conductivity of the solution
|
||||
/*
|
||||
|
|
@ -397,8 +391,8 @@ namespace Cantera {
|
|||
update_C();
|
||||
|
||||
if (!m_cond_mix_ok) {
|
||||
m_lambda = m_lambdaMixModel->getMixTransProp( m_lambdaTempDep_Ns );
|
||||
m_cond_mix_ok = true;
|
||||
m_lambda = m_lambdaMixModel->getMixTransProp( m_lambdaTempDep_Ns );
|
||||
m_cond_mix_ok = true;
|
||||
}
|
||||
|
||||
return m_lambda;
|
||||
|
|
@ -638,12 +632,12 @@ namespace Cantera {
|
|||
* @param current The electric current in A/m^2.
|
||||
*/
|
||||
void LiquidTransport::getElectricCurrent(int ndim,
|
||||
const doublereal* grad_T,
|
||||
int ldx,
|
||||
const doublereal* grad_X,
|
||||
int ldf,
|
||||
const doublereal* grad_V,
|
||||
doublereal* current) {
|
||||
const doublereal* grad_T,
|
||||
int ldx,
|
||||
const doublereal* grad_X,
|
||||
int ldf,
|
||||
const doublereal* grad_V,
|
||||
doublereal* current) {
|
||||
|
||||
set_Grad_T(grad_T);
|
||||
set_Grad_X(grad_X);
|
||||
|
|
@ -690,9 +684,9 @@ namespace Cantera {
|
|||
* length = ldx * ndim
|
||||
*/
|
||||
void LiquidTransport::getSpeciesVdiff(int ndim,
|
||||
const doublereal* grad_T,
|
||||
int ldx, const doublereal* grad_X,
|
||||
int ldf, doublereal* Vdiff) {
|
||||
const doublereal* grad_T,
|
||||
int ldx, const doublereal* grad_X,
|
||||
int ldf, doublereal* Vdiff) {
|
||||
set_Grad_T(grad_T);
|
||||
set_Grad_X(grad_X);
|
||||
getSpeciesVdiffExt(ldf, Vdiff);
|
||||
|
|
@ -709,12 +703,12 @@ namespace Cantera {
|
|||
* \f]
|
||||
*/
|
||||
void LiquidTransport::getSpeciesVdiffES(int ndim,
|
||||
const doublereal* grad_T,
|
||||
int ldx,
|
||||
const doublereal* grad_X,
|
||||
int ldf,
|
||||
const doublereal* grad_V,
|
||||
doublereal* Vdiff) {
|
||||
const doublereal* grad_T,
|
||||
int ldx,
|
||||
const doublereal* grad_X,
|
||||
int ldf,
|
||||
const doublereal* grad_V,
|
||||
doublereal* Vdiff) {
|
||||
set_Grad_T(grad_T);
|
||||
set_Grad_X(grad_X);
|
||||
set_Grad_V(grad_V);
|
||||
|
|
@ -1305,9 +1299,9 @@ namespace Cantera {
|
|||
&& ( m_velocityBasis < m_nsp ) )
|
||||
// use species number m_velocityBasis as reference velocity
|
||||
if ( m_velocityBasis == j ) m_A(0,j) = 1.0;
|
||||
else
|
||||
throw CanteraError("LiquidTransport::stefan_maxwell_solve",
|
||||
"Unknown reference velocity provided.");
|
||||
else
|
||||
throw CanteraError("LiquidTransport::stefan_maxwell_solve",
|
||||
"Unknown reference velocity provided.");
|
||||
}
|
||||
for (i = 1; i < m_nsp; i++){
|
||||
m_B(i,0) = m_Grad_mu[i] / (GasConstant * T);
|
||||
|
|
@ -1315,8 +1309,8 @@ namespace Cantera {
|
|||
for (j = 0; j < m_nsp; j++){
|
||||
if (j != i) {
|
||||
if ( !( m_bdiff(i,j) > 0.0 ) )
|
||||
throw CanteraError("LiquidTransport::stefan_maxwell_solve",
|
||||
"m_bdiff has zero entry in non-diagonal.");
|
||||
throw CanteraError("LiquidTransport::stefan_maxwell_solve",
|
||||
"m_bdiff has zero entry in non-diagonal.");
|
||||
tmp = m_molefracs_tran[j] / m_bdiff(i,j);
|
||||
m_A(i,i) -= tmp;
|
||||
m_A(i,j) = + tmp;
|
||||
|
|
@ -1341,9 +1335,9 @@ namespace Cantera {
|
|||
&& ( m_velocityBasis < m_nsp ) )
|
||||
// use species number m_velocityBasis as reference velocity
|
||||
if ( m_velocityBasis == j ) m_A(0,j) = 1.0;
|
||||
else
|
||||
throw CanteraError("LiquidTransport::stefan_maxwell_solve",
|
||||
"Unknown reference velocity provided.");
|
||||
else
|
||||
throw CanteraError("LiquidTransport::stefan_maxwell_solve",
|
||||
"Unknown reference velocity provided.");
|
||||
}
|
||||
for (i = 1; i < m_nsp; i++){
|
||||
m_B(i,0) = m_Grad_mu[i] / (GasConstant * T);
|
||||
|
|
@ -1352,8 +1346,8 @@ namespace Cantera {
|
|||
for (j = 0; j < m_nsp; j++) {
|
||||
if (j != i) {
|
||||
if ( !( m_bdiff(i,j) > 0.0 ) )
|
||||
throw CanteraError("LiquidTransport::stefan_maxwell_solve",
|
||||
"m_bdiff has zero entry in non-diagonal.");
|
||||
throw CanteraError("LiquidTransport::stefan_maxwell_solve",
|
||||
"m_bdiff has zero entry in non-diagonal.");
|
||||
tmp = m_molefracs_tran[j] / m_bdiff(i,j);
|
||||
m_A(i,i) -= tmp;
|
||||
m_A(i,j) = + tmp;
|
||||
|
|
@ -1381,9 +1375,9 @@ namespace Cantera {
|
|||
&& ( m_velocityBasis < m_nsp ) )
|
||||
// use species number m_velocityBasis as reference velocity
|
||||
if ( m_velocityBasis == j ) m_A(0,j) = 1.0;
|
||||
else
|
||||
throw CanteraError("LiquidTransport::stefan_maxwell_solve",
|
||||
"Unknown reference velocity provided.");
|
||||
else
|
||||
throw CanteraError("LiquidTransport::stefan_maxwell_solve",
|
||||
"Unknown reference velocity provided.");
|
||||
}
|
||||
for (i = 1; i < m_nsp; i++){
|
||||
m_B(i,0) = m_Grad_mu[i] / (GasConstant * T);
|
||||
|
|
@ -1393,8 +1387,8 @@ namespace Cantera {
|
|||
for (j = 0; j < m_nsp; j++) {
|
||||
if (j != i) {
|
||||
if ( !( m_bdiff(i,j) > 0.0 ) )
|
||||
throw CanteraError("LiquidTransport::stefan_maxwell_solve",
|
||||
"m_bdiff has zero entry in non-diagonal.");
|
||||
throw CanteraError("LiquidTransport::stefan_maxwell_solve",
|
||||
"m_bdiff has zero entry in non-diagonal.");
|
||||
tmp = m_molefracs_tran[j] / m_bdiff(i,j);
|
||||
m_A(i,i) -= tmp;
|
||||
m_A(i,j) = + tmp;
|
||||
|
|
|
|||
|
|
@ -128,7 +128,46 @@ namespace Cantera {
|
|||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//====================================================================================================================
|
||||
LiquidTransportParams::LiquidTransportParams() :
|
||||
viscosity(0), thermalCond(0), speciesDiffusivity(0), electCond(0), hydroRadius(0), model_viscosity(LTI_MODEL_NOTSET),
|
||||
model_speciesDiffusivity(LTI_MODEL_NOTSET), model_hydroradius(LTI_MODEL_NOTSET)
|
||||
{
|
||||
|
||||
}
|
||||
//====================================================================================================================
|
||||
LiquidTransportParams::~LiquidTransportParams()
|
||||
{
|
||||
delete viscosity;
|
||||
delete thermalCond;
|
||||
delete speciesDiffusivity;
|
||||
delete electCond;
|
||||
delete hydroRadius;
|
||||
}
|
||||
|
||||
//====================================================================================================================
|
||||
LiquidTransportParams::LiquidTransportParams(const LiquidTransportParams &right) :
|
||||
viscosity(0), thermalCond(0), speciesDiffusivity(0), electCond(0), hydroRadius(0), model_viscosity(LTI_MODEL_NOTSET),
|
||||
model_speciesDiffusivity(LTI_MODEL_NOTSET), model_hydroradius(LTI_MODEL_NOTSET)
|
||||
{
|
||||
throw CanteraError("LiquidTransportParams(const LiquidTransportParams &right)","not implemented");
|
||||
}
|
||||
|
||||
//====================================================================================================================
|
||||
|
||||
LiquidTransportParams& LiquidTransportParams::operator=(const LiquidTransportParams & right)
|
||||
{
|
||||
if (&right != this) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
throw CanteraError("LiquidTransportParams(const LiquidTransportParams &right)","not implemented");
|
||||
return *this;
|
||||
|
||||
}
|
||||
|
||||
//====================================================================================================================
|
||||
|
||||
|
||||
|
||||
doublereal LTI_Solvent::getMixTransProp( doublereal *speciesValues, doublereal *speciesWeight ) {
|
||||
|
|
@ -236,10 +275,7 @@ namespace Cantera {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
doublereal LTI_MassFracs::getMixTransProp( doublereal *speciesValues, doublereal *speciesWeight ) {
|
||||
doublereal LTI_MassFracs::getMixTransProp(doublereal *speciesValues, doublereal *speciesWeight ) {
|
||||
|
||||
int nsp = m_thermo->nSpecies();
|
||||
doublereal massfracs[nsp];
|
||||
|
|
|
|||
|
|
@ -196,8 +196,10 @@ namespace Cantera {
|
|||
|
||||
public:
|
||||
|
||||
LiquidTransportParams() {}
|
||||
~LiquidTransportParams() {}
|
||||
LiquidTransportParams();
|
||||
~LiquidTransportParams();
|
||||
LiquidTransportParams(const LiquidTransportParams &right);
|
||||
LiquidTransportParams & operator=(const LiquidTransportParams &right);
|
||||
|
||||
//! Species transport parameters
|
||||
std::vector<Cantera::LiquidTransportData> LTData;
|
||||
|
|
|
|||
|
|
@ -1047,25 +1047,25 @@ namespace Cantera {
|
|||
* instance of TransportParams containing the transport data for
|
||||
* these species read from the file.
|
||||
*/
|
||||
void TransportFactory::getLiquidInteractionsTransportData( const XML_Node &transportNode,
|
||||
XML_Node& log,
|
||||
const std::vector<std::string> &names,
|
||||
LiquidTransportParams& trParam)
|
||||
{
|
||||
|
||||
void
|
||||
TransportFactory::getLiquidInteractionsTransportData(const XML_Node &transportNode,
|
||||
XML_Node& log,
|
||||
const std::vector<std::string> &names,
|
||||
LiquidTransportParams& trParam)
|
||||
{
|
||||
try {
|
||||
|
||||
int num = transportNode.nChildren();
|
||||
for (int iChild = 0; iChild < num; iChild++) {
|
||||
//tranTypeNode is a type of transport property like viscosity
|
||||
XML_Node &tranTypeNode = transportNode.child(iChild);
|
||||
if ( tranTypeNode.hasChild("compositionDependence")) {
|
||||
if (tranTypeNode.hasChild("compositionDependence")) {
|
||||
//compDepNode contains the interaction model
|
||||
XML_Node &compDepNode = tranTypeNode.child("compositionDependence");
|
||||
|
||||
std::string nodeName = tranTypeNode.name();
|
||||
|
||||
switch ( m_tranPropMap[nodeName] ) {
|
||||
switch (m_tranPropMap[nodeName]) {
|
||||
break;
|
||||
case TP_VISCOSITY:
|
||||
trParam.viscosity = newLTI( compDepNode,
|
||||
|
|
@ -1083,9 +1083,9 @@ namespace Cantera {
|
|||
trParam );
|
||||
break;
|
||||
case TP_HYDRORADIUS:
|
||||
trParam.hydroRadius = newLTI( compDepNode,
|
||||
m_tranPropMap[nodeName],
|
||||
trParam );
|
||||
trParam.hydroRadius = newLTI(compDepNode,
|
||||
m_tranPropMap[nodeName],
|
||||
trParam);
|
||||
break;
|
||||
case TP_ELECTCOND:
|
||||
trParam.electCond = newLTI( compDepNode,
|
||||
|
|
@ -1123,9 +1123,7 @@ namespace Cantera {
|
|||
else {
|
||||
int linenum;
|
||||
throw TransportDBError( linenum, "Unknown attribute " + velocityBasis + " for <velocityBasis> node. ");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue