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/)
-   -   rotating source term using fvOptions (https://www.cfd-online.com/Forums/openfoam-programming-development/208370-rotating-source-term-using-fvoptions.html)

anon_q October 16, 2018 03:27

rotating source term using fvOptions
 
Hello
In my simulation, I need to add a rotating source term to momentum equations without modifying the code of the solver.
Is it possible to use a rotating source term in fvOptions (has a distance R from the origin rotates about the origin (0,0,0) as a function of time and with given angular velocity)?
Please, can you give me an example?

PS: Without using MRF or Dynamic mesh.

C. Okubo October 29, 2018 10:12

Hi!

I am trying to do this also, but still not successful. Even though, SRFSimpleFoam is not an option for you?

Okubo

C. Okubo October 29, 2018 10:52

Tried some variations of the code below (in .../constant/fvOptions), but it is still not working well...

As far as I understand, this implements a explicit source...maybe, it should be implicit to work (like SRFSimpleFoam)?

Hope somebody can help...

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  v1806                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.com                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    location    "constant";
    object      fvOptions;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
velocitySource
{
    type            vectorCodedSource;

    vectorCodedSourceCoeffs
    {
        selectionMode  all;

        fields          (U);
        name            vectorSource;

        codeInclude
        #{

        #};

        codeCorrect
        #{
            Pout<< "**codeCorrect**" << endl;
        #};

        codeAddSup
        #{
            vectorField& Usource = eqn.source();
            vector rotation = vector(0, 1, 0); // rotation in rad/s

            const vectorField& radius = mesh_.C(); // center of cells (axis is considered passing through origin)
            const vectorField& U_ = mesh().lookupObject<volVectorField>("U");

            Usource =  - (rotation^(rotation^radius)) - 2.0*(rotation^U_);
        #};

        codeSetValue
        #{
            Pout<< "**codeSetValue**" << endl;
        #};

        // Dummy entry. Make dependent on above to trigger recompilation
        code
        #{
            $codeInclude
            $codeCorrect
            $codeAddSup
            $codeSetValue
        #};
    }
}// ************************************************************************* //


ozi March 30, 2023 04:55

Did you get any progress with your code. I am struggling with the same issue. Code is working but the solution blows up very quick because of the large numbers produced by the additional source term.



Quote:

Originally Posted by C. Okubo (Post 713413)
Tried some variations of the code below (in .../constant/fvOptions), but it is still not working well...

As far as I understand, this implements a explicit source...maybe, it should be implicit to work (like SRFSimpleFoam)?

Hope somebody can help...

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  v1806                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.com                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    location    "constant";
    object      fvOptions;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
velocitySource
{
    type            vectorCodedSource;

    vectorCodedSourceCoeffs
    {
        selectionMode  all;

        fields          (U);
        name            vectorSource;

        codeInclude
        #{

        #};

        codeCorrect
        #{
            Pout<< "**codeCorrect**" << endl;
        #};

        codeAddSup
        #{
        vectorField& Usource = eqn.source();
            vector rotation = vector(0, 1, 0); // rotation in rad/s

        const vectorField& radius = mesh_.C(); // center of cells (axis is considered passing through origin)
        const vectorField& U_ = mesh().lookupObject<volVectorField>("U");

            Usource =  - (rotation^(rotation^radius)) - 2.0*(rotation^U_);
        #};

        codeSetValue
        #{
            Pout<< "**codeSetValue**" << endl;
        #};

        // Dummy entry. Make dependent on above to trigger recompilation
        code
        #{
            $codeInclude
            $codeCorrect
            $codeAddSup
            $codeSetValue
        #};
    }
}// ************************************************************************* //




All times are GMT -4. The time now is 11:40.