# Temperature in icoFoam

 Register Blogs Members List Search Today's Posts Mark Forums Read

December 15, 2016, 08:08
Temperature in icoFoam
#1
New Member

Join Date: May 2016
Posts: 25
Rep Power: 10
Hi,
i modified the icoFoam solver to solve the temperature following this wiki:
https://openfoamwiki.net/index.php/H...ure_to_icoFoam
I run the cavity example and everything worked.

Now i'm trying to simulate a mixing elbow in which the two flows have different velocities
(I know icoFoam is only laminar but i'm learning this and then i'll move to simpleFoam to account the turbulence)

The simulation runs without errors but the results are incorrect (see attached image)

This is the temperature BC:
Code:
```dimensions      [0 0 0 1 0 0 0];

internalField   uniform 0;

boundaryField
{
wall
{
}

inletSmall
{
type            fixedValue;
value            uniform 40;
}

inletBig
{
type            fixedValue;
value            uniform 20;
}

outlet
{
}
}```
And this is the modified solver:
Code:
```Info<< "Reading transportProperties\n" << endl;

IOdictionary transportProperties
(
IOobject
(
"transportProperties",
runTime.constant(),
mesh,
IOobject::NO_WRITE
)
);

dimensionedScalar nu
(
"nu",
dimViscosity,
transportProperties.lookup("nu")
);

dimensionedScalar DT
(
transportProperties.lookup("DT")
);

Info<< "Reading field p\n" << endl;
volScalarField p
(
IOobject
(
"p",
runTime.timeName(),
mesh,
IOobject::AUTO_WRITE
),
mesh
);

volScalarField T
(
IOobject
(
"T",
runTime.timeName(),
mesh,
IOobject::AUTO_WRITE
),
mesh
);

Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::AUTO_WRITE
),
mesh
);

#include "createPhi.H"

label pRefCell = 0;
scalar pRefValue = 0.0;
setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue);
mesh.setFluxRequired(p.name());```
Code:
```#include "fvCFD.H"
#include "pisoControl.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"

pisoControl piso(mesh);

#include "createFields.H"
#include "initContinuityErrs.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

Info<< "\nStarting time loop\n" << endl;

while (runTime.loop())
{
Info<< "Time = " << runTime.timeName() << nl << endl;

#include "CourantNo.H"

// Momentum predictor

fvVectorMatrix UEqn
(
fvm::ddt(U)
+ fvm::div(phi, U)
- fvm::laplacian(nu, U)
);

if (piso.momentumPredictor())
{
}

// --- PISO loop
while (piso.correct())
{
volScalarField rAU(1.0/UEqn.A());
volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p));
surfaceScalarField phiHbyA
(
"phiHbyA",
fvc::flux(HbyA)
+ fvc::interpolate(rAU)*fvc::ddtCorr(U, phi)
);

// Update the pressure BCs to ensure flux consistency
constrainPressure(p, U, phiHbyA, rAU);

// Non-orthogonal pressure corrector loop
while (piso.correctNonOrthogonal())
{
// Pressure corrector

fvScalarMatrix pEqn
(
fvm::laplacian(rAU, p) == fvc::div(phiHbyA)
);

pEqn.setReference(pRefCell, pRefValue);

pEqn.solve(mesh.solver(p.select(piso.finalInnerIter())));

if (piso.finalNonOrthogonalIter())
{
phi = phiHbyA - pEqn.flux();
}
}

#include "continuityErrs.H"

U.correctBoundaryConditions();
}

fvScalarMatrix TEqn
(
fvm::ddt(T)
+ fvm::div(phi, T)
- fvm::laplacian(DT, T)
);

TEqn.solve();

runTime.write();

Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< "  ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}

Info<< "End\n" << endl;

return 0;
}```
Is there something wrong in the solver? Or what?
Thanks!
Attached Images
 T.png (12.9 KB, 7 views)

 December 17, 2016, 17:55 #2 New Member   Join Date: May 2016 Posts: 25 Rep Power: 10 I kept looking for errors but i didn't. I tried to run a different simulation (2D T junction) with the same solver and similar BC and this one worked! How is that possible?

 Tags icofoam, solver, temperature