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/)
-   -   Adding a Source Term to an User Defined transport equation (https://www.cfd-online.com/Forums/openfoam-programming-development/182142-adding-source-term-user-defined-transport-equation.html)

rma January 1, 2017 18:00

Adding a Source Term to an User Defined transport equation
 
Hello everyone,

I have added a new transport equation to an existing solver, and I have all the bits working but the source term.

That source term takes the following form: div(K*scalarField*vectorField)

with K being a constant.

Therefore, I have created in createFields.H an volVectorField countaining that product, so I can easily take the divergence afterwards in the solvers's '.C' file.

volVectorField sourceTerm
(
IOobject
(
"sourceTerm",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
K*scalarField*vectorField
);

Then, in the '.C' file of the solver I do:

sourceTerm=K*scalarField*vectorField;

fvScalarMatrix uds1Eqn
(
fvm::ddt(uds1)
- fvm::laplacian(D_uds1, uds1)
==
- fvc::div(sourceTerm)
);

uds1Eqn.solve();

Everything compiles fine, but when I am running the solver, I get the following error:

--> FOAM FATAL IO ERROR:
attempt to read beyond EOF

file: /home/rma/OpenFOAM/Pruebas/case/system/fvSchemes.divSchemes.div(sourceTerm) at line 33.

From function ITstream::read(token&)
in file db/IOstreams/Tstreams/ITstream.C at line 83.

FOAM exiting


However, the fvSchemes file does have that scheme specified:

divSchemes
{
default Gauss upwind;
div(phi,U) Gauss limitedLinearV 1;
div(sourceTerm) Gauss upwind;
}


I don't really know how to proceed from here, maybe that is not the way I am suppossed to create a source term, so I would really appreciate if someone could help me with this problem.

Thank you very much.

Zeppo January 2, 2017 05:55

http://cfd.direct/openfoam/user-guid...19-1400004.4.3
Code:

divSchemes
{
    div(sourceTerm) Gauss upwind;
}

requires you to specify "the (volumetric) flux of velocity on the cell faces for constant-density flows and the mass flux for compressible flows"
Code:

div(phi, sourceTerm) Gauss upwind;
Depending on the physical meaning of the term you might be happy with
Code:

div(sourceTerm)        Gauss linear;


All times are GMT -4. The time now is 23:48.