Skip to content
Snippets Groups Projects
Commit 10fa5172 authored by Andrew Heather's avatar Andrew Heather
Browse files

optimisation - removed double allocation of storage of t

parent 0f2ed0ee
Branches
Tags
No related merge requests found
...@@ -246,11 +246,9 @@ Foam::scalar Foam::ODEChemistryModel<CompType, ThermoType>::omega ...@@ -246,11 +246,9 @@ Foam::scalar Foam::ODEChemistryModel<CompType, ThermoType>::omega
{ {
pr *= pow(cr, exp - 1.0); pr *= pow(cr, exp - 1.0);
} }
} }
return pf*cf - pr*cr; return pf*cf - pr*cr;
} }
...@@ -468,10 +466,27 @@ Foam::ODEChemistryModel<CompType, ThermoType>::tc() const ...@@ -468,10 +466,27 @@ Foam::ODEChemistryModel<CompType, ThermoType>::tc() const
this->thermo().rho() this->thermo().rho()
); );
label nCells = rho.size(); tmp<volScalarField> tsource
label nReaction = reactions_.size(); (
new volScalarField
(
IOobject
(
"tc",
this->time().timeName(),
this->mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
this->mesh(),
dimensionedScalar("zero", dimTime, SMALL),
zeroGradientFvPatchScalarField::typeName
)
);
scalarField& t = tsource();
scalarField t(nCells, SMALL); label nReaction = reactions_.size();
if (this->chemistry_) if (this->chemistry_)
{ {
...@@ -509,25 +524,7 @@ Foam::ODEChemistryModel<CompType, ThermoType>::tc() const ...@@ -509,25 +524,7 @@ Foam::ODEChemistryModel<CompType, ThermoType>::tc() const
} }
} }
tmp<volScalarField> tsource
(
new volScalarField
(
IOobject
(
"tc",
this->mesh_.time().timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
this->mesh_,
dimensionedScalar("zero", dimTime, 0.0),
zeroGradientFvPatchScalarField::typeName
)
);
tsource().internalField() = t;
tsource().correctBoundaryConditions(); tsource().correctBoundaryConditions();
return tsource; return tsource;
...@@ -682,7 +679,7 @@ Foam::scalar Foam::ODEChemistryModel<CompType, ThermoType>::solve ...@@ -682,7 +679,7 @@ Foam::scalar Foam::ODEChemistryModel<CompType, ThermoType>::solve
forAll(rho, celli) forAll(rho, celli)
{ {
for (label i=0; i<nSpecie(); i++) for (label i=0; i<nSpecie_; i++)
{ {
RR_[i][celli] = 0.0; RR_[i][celli] = 0.0;
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment