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/)
-   -   Implement source term in rhoSimpleFoam (https://www.cfd-online.com/Forums/openfoam-programming-development/223363-implement-source-term-rhosimplefoam.html)

Soll January 7, 2020 18:08

Implement source term in rhoSimpleFoam
 
Greetings!


Recently I'm working on adding source term to rhoSimpleFoam.
I read through the source code and did some test, but still I have some problems unsolved. Please if someone could help:


1. Is it correct to add source term, i.e., mySource (volVectorField, constant but updated at every iteration) to the three locations?
a. In UEqn.H:
Code:

solve(UEqn == -fvc::grad(p)+mySource);
b. In pEqn.H, NonOrthogonal correction
Code:

fvScalarMatrix pEqn
        (
            fvc::div(phiHbyA)
          - fvm::laplacian(rhorAUf, p)
          + fvc::div(mySource*rAU)

          ==
            fvOptions(psi, p, rho.name())
        );

c. In pEqn.H, corrector
Code:

U = HbyA - rAU*fvc::grad(p) + mySource;
I saw a thread
HTML Code:

https://www.cfd-online.com/Forums/openfoam/65293-add-source-term-simplefoam.html
related to this. Basically they are discussing adding source term to a. and c., but why not b.?


2. Why in pEqn.H phiHbyA is interpolated like this
Code:

surfaceScalarField phiHbyA("phiHbyA", fvc::interpolate(rho)*fvc::flux(HbyA));
instead of
Code:

surfaceScalarField phiHbyA("phiHbyA", fvc::flux(rho*HbyA));
like the way rhorAUf did, or they are the same.


3. Why rho*HbyA is interpolated to the cell surface in the first place? may be it is more of a algorithm question but I just cant figure it out.

Soll January 8, 2020 07:19

I think I know the answer to question 3 if I'm correct

post here if anyone is interested:
for any volVectorField V

Code:

fvc::div(fvc::flux(V)) equals to fvc::div(V)
with additional options to specify the interpolation schemes


All times are GMT -4. The time now is 15:56.