major clean-up

This commit is contained in:
andy
2009-02-04 09:46:26 +00:00
parent 6d3a272372
commit 61e1c0c1ea
17 changed files with 87 additions and 380 deletions

View File

@ -7,6 +7,8 @@ derivedFvPatchFields/solidWallHeatFluxTemperatureCoupled/solidWallHeatFluxTemper
derivedFvPatchFields/solidWallTemperatureCoupled/solidWallTemperatureCoupledFvPatchScalarField.C derivedFvPatchFields/solidWallTemperatureCoupled/solidWallTemperatureCoupledFvPatchScalarField.C
derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.C derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.C
fluid/compressibleCourantNo.C
chtMultiRegionFoam.C chtMultiRegionFoam.C
EXE = $(FOAM_APPBIN)/chtMultiRegionFoam EXE = $(FOAM_APPBIN)/chtMultiRegionFoam

View File

@ -36,16 +36,10 @@ Description
#include "turbulenceModel.H" #include "turbulenceModel.H"
#include "fixedGradientFvPatchFields.H" #include "fixedGradientFvPatchFields.H"
#include "regionProperties.H" #include "regionProperties.H"
#include "compressibleCourantNo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "solveContinuityEquation.C"
#include "solveMomentumEquation.C"
#include "compressibleContinuityErrors.C"
#include "solvePressureDifferenceEquation.C"
#include "solveEnthalpyEquation.C"
#include "compressibleCourantNo.C"
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
@ -58,7 +52,6 @@ int main(int argc, char *argv[])
# include "createSolidMeshes.H" # include "createSolidMeshes.H"
# include "createFluidFields.H" # include "createFluidFields.H"
# include "createSolidFields.H" # include "createSolidFields.H"
# include "initContinuityErrs.H" # include "initContinuityErrs.H"
@ -89,6 +82,7 @@ int main(int argc, char *argv[])
{ {
Info<< "\nSolving for fluid region " Info<< "\nSolving for fluid region "
<< fluidRegions[i].name() << endl; << fluidRegions[i].name() << endl;
# include "setRegionFluidFields.H"
# include "readFluidMultiRegionPISOControls.H" # include "readFluidMultiRegionPISOControls.H"
# include "solveFluid.H" # include "solveFluid.H"
} }
@ -97,6 +91,7 @@ int main(int argc, char *argv[])
{ {
Info<< "\nSolving for solid region " Info<< "\nSolving for solid region "
<< solidRegions[i].name() << endl; << solidRegions[i].name() << endl;
# include "setRegionSolidFields.H"
# include "readSolidMultiRegionPISOControls.H" # include "readSolidMultiRegionPISOControls.H"
# include "solveSolid.H" # include "solveSolid.H"
} }

View File

@ -1,10 +1,14 @@
tmp<fvVectorMatrix> UEqn = solveMomentumEquation // Solve the Momentum equation
tmp<fvVectorMatrix> UEqn
( (
momentumPredictor, fvm::ddt(rho, U)
Uf[i], + fvm::div(phi, U)
rhof[i], + turb.divDevRhoReff(U)
phif[i],
pdf[i],
ghf[i],
turb[i]
); );
UEqn().relax();
if (momentumPredictor)
{
solve(UEqn() == -fvc::grad(pd) - fvc::grad(rho)*gh);
}

View File

@ -1,58 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Continuity errors for fluid meshes
\*---------------------------------------------------------------------------*/
void compressibleContinuityErrors
(
scalar& cumulativeContErr,
const volScalarField& rho,
const basicThermo& thermo
)
{
dimensionedScalar totalMass = fvc::domainIntegrate(rho);
scalar sumLocalContErr =
(
fvc::domainIntegrate(mag(rho - thermo.rho()))/totalMass
).value();
scalar globalContErr =
(
fvc::domainIntegrate(rho - thermo.rho())/totalMass
).value();
cumulativeContErr += globalContErr;
const word& regionName = rho.mesh().name();
Info<< "time step continuity errors (" << regionName << ")"
<< ": sum local = " << sumLocalContErr
<< ", global = " << globalContErr
<< ", cumulative = " << cumulativeContErr
<< endl;
}

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -22,13 +22,12 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation, along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Calculates and outputs the mean and maximum Courant Numbers for the fluid
regions
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
scalar compressibleCourantNo #include "compressibleCourantNo.H"
#include "fvc.H"
Foam::scalar Foam::compressibleCourantNo
( (
const fvMesh& mesh, const fvMesh& mesh,
const Time& runTime, const Time& runTime,

View File

@ -4,7 +4,7 @@
PtrList<volScalarField> Kf(fluidRegions.size()); PtrList<volScalarField> Kf(fluidRegions.size());
PtrList<volVectorField> Uf(fluidRegions.size()); PtrList<volVectorField> Uf(fluidRegions.size());
PtrList<surfaceScalarField> phif(fluidRegions.size()); PtrList<surfaceScalarField> phif(fluidRegions.size());
PtrList<compressible::turbulenceModel> turb(fluidRegions.size()); PtrList<compressible::turbulenceModel> turbulence(fluidRegions.size());
PtrList<volScalarField> DpDtf(fluidRegions.size()); PtrList<volScalarField> DpDtf(fluidRegions.size());
PtrList<volScalarField> ghf(fluidRegions.size()); PtrList<volScalarField> ghf(fluidRegions.size());
PtrList<volScalarField> pdf(fluidRegions.size()); PtrList<volScalarField> pdf(fluidRegions.size());
@ -123,8 +123,8 @@
) )
); );
Info<< " Adding to turb\n" << endl; Info<< " Adding to turbulence\n" << endl;
turb.set turbulence.set
( (
i, i,
autoPtr<compressible::turbulenceModel> autoPtr<compressible::turbulenceModel>

View File

@ -1,9 +1,17 @@
solveEnthalpyEquation {
tmp<fvScalarMatrix> hEqn
( (
rhof[i], fvm::ddt(rho, h)
DpDtf[i], + fvm::div(phi, h)
phif[i], - fvm::laplacian(turb.alphaEff(), h)
turb[i], ==
thermof[i] DpDt
); );
hEqn().relax();
hEqn().solve();
thermo.correct();
Info<< "Min/max T:" << min(thermo.T()) << ' ' << max(thermo.T())
<< endl;
}

View File

@ -1,60 +1,70 @@
{ {
bool closedVolume = false; bool closedVolume = false;
rhof[i] = thermof[i].rho(); rho = thermo.rho();
volScalarField rUA = 1.0/UEqn().A(); volScalarField rUA = 1.0/UEqn().A();
Uf[i] = rUA*UEqn().H(); U = rUA*UEqn().H();
phif[i] = phi =
fvc::interpolate(rhof[i]) fvc::interpolate(rho)
*( *(
(fvc::interpolate(Uf[i]) & fluidRegions[i].Sf()) (fvc::interpolate(U) & mesh.Sf())
+ fvc::ddtPhiCorr(rUA, rhof[i], Uf[i], phif[i]) + fvc::ddtPhiCorr(rUA, rho, U, phi)
) )
- fvc::interpolate(rhof[i]*rUA*ghf[i]) - fvc::interpolate(rho*rUA*gh)*fvc::snGrad(rho)*mesh.magSf();
*fvc::snGrad(rhof[i])
*fluidRegions[i].magSf();
// Solve pressure difference for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
# include "pdEqn.H" {
fvScalarMatrix pdEqn
(
fvc::ddt(rho)
+ fvc::div(phi)
- fvm::laplacian(rho*rUA, pd)
);
if (corr == nCorr-1 && nonOrth == nNonOrthCorr)
{
pdEqn.solve(mesh.solver(pd.name() + "Final"));
}
else
{
pdEqn.solve(mesh.solver(pd.name()));
}
if (nonOrth == nNonOrthCorr)
{
phi += pdEqn.flux();
}
}
// Update pressure field (including bc)
thermo.p() == pd + rho*gh + pRef;
DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p);
// Solve continuity // Solve continuity
# include "rhoEqn.H" # include "rhoEqn.H"
// Update pressure field (including bc)
thermof[i].p() == pdf[i] + rhof[i]*ghf[i] + pRef;
DpDtf[i] = fvc::DDt
(
surfaceScalarField("phiU", phif[i]/fvc::interpolate(rhof[i])),
thermof[i].p()
);
// Update continuity errors // Update continuity errors
compressibleContinuityErrors(cumulativeContErr, rhof[i], thermof[i]); # include "compressibleContinuityErrors.H"
// Correct velocity field // Correct velocity field
Uf[i] -= rUA*(fvc::grad(pdf[i]) + fvc::grad(rhof[i])*ghf[i]); U -= rUA*(fvc::grad(pd) + fvc::grad(rho)*gh);
Uf[i].correctBoundaryConditions(); U.correctBoundaryConditions();
// For closed-volume cases adjust the pressure and density levels // For closed-volume cases adjust the pressure and density levels
// to obey overall mass continuity // to obey overall mass continuity
if (closedVolume) if (closedVolume)
{ {
thermof[i].p() += thermo.p() +=
( (
dimensionedScalar dimensionedScalar("massIni", dimMass, initialMassf[i])
( - fvc::domainIntegrate(thermo.psi()*thermo.p())
"massIni", )/fvc::domainIntegrate(thermo.psi());
dimMass, pd == thermo.p() - (rho*gh + pRef);
initialMassf[i] rho = thermo.rho();
)
- fvc::domainIntegrate(thermof[i].psi()*thermof[i].p())
)/fvc::domainIntegrate(thermof[i].psi());
pdf[i] == thermof[i].p() - (rhof[i]*ghf[i] + pRef);
rhof[i] = thermof[i].rho();
} }
// Update thermal conductivity // Update thermal conductivity
Kf[i] = thermof[i].Cp()*turb[i].alphaEff(); K = thermo.Cp()*turb.alphaEff();
} }

View File

@ -1,14 +0,0 @@
solvePressureDifferenceEquation
(
corr,
nCorr,
nNonOrthCorr,
closedVolume,
pdf[i],
pRef,
rhof[i],
thermof[i].psi(),
rUA,
ghf[i],
phif[i]
);

View File

@ -1 +1 @@
solveContinuityEquation(rhof[i], phif[i]); solve(fvm::ddt(rho) + fvc::div(phi));

View File

@ -1,15 +0,0 @@
if (adjustTimeStep)
{
if (CoNum > SMALL)
{
runTime.setDeltaT
(
min
(
maxCo*runTime.deltaT().value()/CoNum,
maxDeltaT
)
);
}
}

View File

@ -1,37 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Solve continuity equation
\*---------------------------------------------------------------------------*/
void solveContinuityEquation
(
volScalarField& rho,
const surfaceScalarField& phi
)
{
solve(fvm::ddt(rho) + fvc::div(phi));
}

View File

@ -1,56 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Solve enthalpy equation
\*---------------------------------------------------------------------------*/
void solveEnthalpyEquation
(
const volScalarField& rho,
const volScalarField& DpDt,
const surfaceScalarField& phi,
const compressible::turbulenceModel& turb,
basicThermo& thermo
)
{
volScalarField& h = thermo.h();
tmp<fvScalarMatrix> hEqn
(
fvm::ddt(rho, h)
+ fvm::div(phi, h)
- fvm::laplacian(turb.alphaEff(), h)
==
DpDt
);
hEqn().relax();
hEqn().solve();
thermo.correct();
Info<< "Min/max T:" << min(thermo.T()) << ' ' << max(thermo.T())
<< endl;
}

View File

@ -12,4 +12,4 @@
# include "pEqn.H" # include "pEqn.H"
} }
} }
turb[i].correct(); turb.correct();

View File

@ -1,57 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Solve momentum equation and return matrix for use in pressure equation
\*---------------------------------------------------------------------------*/
tmp<fvVectorMatrix> solveMomentumEquation
(
const bool momentumPredictor,
volVectorField& U,
const volScalarField& rho,
const surfaceScalarField& phi,
const volScalarField& pd,
const volScalarField& gh,
const compressible::turbulenceModel& turb
)
{
// Solve the Momentum equation
tmp<fvVectorMatrix> UEqn
(
fvm::ddt(rho, U)
+ fvm::div(phi, U)
+ turb.divDevRhoReff(U)
);
UEqn().relax();
if (momentumPredictor)
{
solve(UEqn() == -fvc::grad(pd) - fvc::grad(rho)*gh);
}
return UEqn;
}

View File

@ -1,73 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Solve pressure difference equation
\*---------------------------------------------------------------------------*/
void solvePressureDifferenceEquation
(
const label corr,
const label nCorr,
const label nNonOrthCorr,
bool& closedVolume,
volScalarField& pd,
const dimensionedScalar& pRef,
const volScalarField& rho,
const volScalarField& psi,
const volScalarField& rUA,
const volScalarField& gh,
surfaceScalarField& phi
)
{
closedVolume = pd.needReference();
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pdEqn
(
fvm::ddt(psi, pd)
+ fvc::ddt(psi)*pRef
+ fvc::ddt(psi, rho)*gh
+ fvc::div(phi)
- fvm::laplacian(rho*rUA, pd)
);
//pdEqn.solve();
if (corr == nCorr-1 && nonOrth == nNonOrthCorr)
{
pdEqn.solve(pd.mesh().solver(pd.name() + "Final"));
}
else
{
pdEqn.solve(pd.mesh().solver(pd.name()));
}
if (nonOrth == nNonOrthCorr)
{
phi += pdEqn.flux();
}
}
}

View File

@ -3,10 +3,9 @@
{ {
solve solve
( (
fvm::ddt(rhosCps[i], Ts[i]) - fvm::laplacian(Ks[i], Ts[i]) fvm::ddt(rho*cp, T) - fvm::laplacian(K, T)
); );
} }
Info<< "Min/max T:" << min(Ts[i]) << ' ' << max(Ts[i]) Info<< "Min/max T:" << min(T) << ' ' << max(T) << endl;
<< endl;
} }