CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Transport Equation for a scalar - Compressible Solver (https://www.cfd-online.com/Forums/openfoam-programming-development/84295-transport-equation-scalar-compressible-solver.html)

alessio.nz January 25, 2011 13:22

Transport Equation for a scalar - Compressible Solver
 
Hi, I am a beginner with OF and I am new in the programming of the code.

I have to modify XiFoam, premix solver for turbulent combustion (which is rhoPisoFoam without any combustion) adding simply a new scalar transport equation for a variable ''C".

The equation is on the form of:

d/dt(rho*C)+rho*Ud/dxj(C) - laplacian(rho*nu * C) = ST

where the ST is the source term for the scalar.

The solver XiFoam is composed on the following files:

bEqn.H
createFields.H
ftEqn.H
hEqn.H
huEqn.H
Make (directory)
pEqn.H
readCombustionProperties.H
UEqn.H
XiFoam.C
XiFoam.dep

1) I have changed the names regarding XiFoam in NewXiFoam and the path of compilation (make/files).

2)I have created the file "Ceqn.H" and typed the following code:

solve
(
fvm::ddt(rho, C)
+ fvc::div(phi, C)
- fvm::laplacian(nu, C) == f
);

where f is taken from a table.

2) on the NewXiFoam.C I have added the following script on the code at the beginning the PISO loop:

for (int corr=1; corr<=nCorr; corr++)
{
#include "pEqn.H"
#include "Ceqn.H"
}

turbulence->correct();

3)on the "createFields.H"

I have added the script :

Info<< "\nReading field C\n" << endl;
volScalarField C
(
IOobject
(
"C",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);


Now everything should be done and after the compilation "wmake" it gives 1 error. Could you please tell if the steps for this compressible solver are the correct ones or not and what I should take car of.

Thanks,
alex

smehdi609 January 26, 2011 02:17

It can be several things, like syntas error, unit error and so on. You should post that so that we can help you. BTW, I bet you are implmenting PCM-FPI.

mvoss January 26, 2011 03:46

hi,
did you try a wclean before wmake? what is wmake complaining about?
how did you set up the table for "f"? I mean,... is it read from an external file?

neewbie

alessio.nz January 26, 2011 11:58

thanks to all of you! finally, after checking all things, I succeed!

l_r_mcglashan January 27, 2011 04:39

d/dt(rho*C)+rho*Ud/dxj(C) - laplacian(rho*nu * C) = ST

The above equation does not match what you've programmed below:

solve
(
fvm::ddt(rho, C)
+ fvc::div(phi, C)
- fvm::laplacian(nu, C) == f
);

Barlo April 11, 2013 09:04

I'm sorry Alex, I'm interested in change XiFoam solver too, could you post your "well-done" code below, please? Thank you :)
Lorenzo


All times are GMT -4. The time now is 04:28.