CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Turbulence Model with Elliptic Relaxation (http://www.cfd-online.com/Forums/openfoam-programming-development/105724-turbulence-model-elliptic-relaxation.html)

twray August 7, 2012 15:50

Turbulence Model with Elliptic Relaxation
 
Hello all,

I've been working on implementing a damping function, fmu, defined by an elliptic relaxation equation. This is the first modification I've done that has required defining my own discretized equation so I'm sure there are errors in my implementation. Also I believe my method of setting the initial and boundary conditions could use improvement. Currently my simpleFoam case compiles and runs but the results are incorrect.

fmu must be between 0 and 1 and equal 0 on wall boundaries. To initialize this I added the code below to the constructor.
In /0/fmu I set a value of 0 to my wall patch and 0.5 to the internalField and all other patches.
Code:

fmu_
    (
        IOobject
        (
            "fmu",
            runTime_.timeName(),
            mesh_,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh_
),

Is this the proper method of defining initial conditions? Is adding something like the following in the constructor without defining a /0/fmu file possible or more appropriate?
dimensionedScalar("fmu",dimless,.5)
label patchWall = mesh_.boundaryMesh().findPatchID("wall")
fmu_.boundaryField()[patchWall]=0.0

The fmu equation is
http://i.imgur.com/F1DIL.png
Code:

        const volScalarField Lsqr(this->Lsqr(W,S,Cmu,Tt,k_,epsilon_,zeta));
        tmp<fvScalarMatrix> fmuEqu
        (
            Lsqr*fvm::laplacian(fmu_) == scalar(1.0) - fmu_
        );
        fmuEqu().relax();
        solve(fmuEqu);
        label patchWall = U_.mesh().boundaryMesh().findPatchID("wall");
        fmu_.boundaryField()[patchWall]=0.0;

I moved the negative into my Lsqr function. I added definitions for laplacian(fmu), relaxationFactors and solvers in fvSchemes and fvSolution. The last line is to update the boundary condition on the wall.

Does this procedure look correct? Is using the boudaryField()[patchWall]=0.0 the proper way to correct the wall boundary condition?

Thanks in advance for any input,
Tim

Tarak August 16, 2012 12:01

Hii,

You can do something like this so that you do not need to create Initial Condition files for the fields you want to get printed out:

LPrint_
(
IOobject
(
"LPrint",
runTime_.timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh_,
dimensionedScalar("LPrint", dimensionSet(0, 1, 0, 0, 0, 0, 0), 0.0),
zeroGradientFvPatchScalarField::typeName

twray August 16, 2012 15:46

Thanks for the input.

Also, as an update, I use the following to solve the elliptic equation. It seems to be working, but I'm still testing.

Code:

        tmp<fvScalarMatrix> fmuEqu
        (
            - fvm::laplacian(fmu_) == - fvm::Sp(1.0/Lsqr,fmu_) + 1.0/Lsqr
        );
        fmuEqu().relax();
        solve(fmuEqu);



All times are GMT -4. The time now is 21:22.