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/)
-   -   Using fvOption for adding momentum (https://www.cfd-online.com/Forums/openfoam-programming-development/230769-using-fvoption-adding-momentum.html)

farzadmech October 5, 2020 12:18

Using fvOption for adding momentum
 
3 Attachment(s)
Dear friends
I am using fvOption to add extra momentum in the domain and I use fvOption for this purpose, but It does not work properly. my fvOption is as follow;

Code:

/*--------------------------------*- C++ -*----------------------------------*\
  =========                |
  \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox
  \\    /  O peration    | Website:  https://openfoam.org
    \\  /    A nd          | Version:  6
    \\/    M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    location    "constant";
    object      fvOptions;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

momentumSource

{

    type            meanVelocityForce;

    active          on;            //on/off switch

    //cellSet      sourceSet;

 

    meanVelocityForceCoeffs

    {

        selectionMode  cellZone;
        cellZone        farzadSulzerr;

        fields                  (U);

        Ubar        ( 0. -1.0 0.);

        relaxation  1.0;

    }

}

// ************************************************************************* //



Do you know what is my mistake?

I have attached my cellZone, and also my simulation which I expect to make difference but fvOption has no effect.

Tibo99 October 6, 2020 10:32

I was able to do something similar like so and it was working, hope this help:

Code:

fixU
{
        type                        vectorFixedValueConstraint;
        active                        true;
       
        selectionMode                cellZone;
        cellZone                firstCellU;       
        volumeMode                absolute;
       
        fieldValues
        {
                U        (1.458308317 0 0);
        }
       
}

Regards,

farzadmech October 6, 2020 13:43

Dear René Thibault
Thanks for your reply. Could you please tell me that if there is any fvOption(U) in your solver? I mean in Ueqn.C?


Thanks,
Farzad


Quote:

Originally Posted by Tibo99 (Post 784570)
I was able to do something similar like so and it was working, hope this help:

Code:

fixU
{
        type                        vectorFixedValueConstraint;
        active                        true;
       
        selectionMode                cellZone;
        cellZone                firstCellU;       
        volumeMode                absolute;
       
        fieldValues
        {
                U        (1.458308317 0 0);
        }
       
}

Regards,


Tibo99 October 6, 2020 13:57

What exactly does this code is fixing the component 'x' of 'U' at the first cell (I was setting a cellZone on the entire domain on the first cell from the wall with a topoSetDict file and using 'topoSet' command, like you probably did in a similar fashion way) at a fix value of 1.458..... At every time step, the value is carry on and fixed at this value at the cellZone set already.

By using the type 'vectorFixedValueConstraint', apparently you don't need to use the form 'vectorField& uSource = equ.source()' to apply the fixed value. Perform a test, and you'll see in your writing folder under 'U' file that the value will stay fix, the same, during the whole simulation in your cellZone. To answer your question about 'fvOption(U)' and 'Ueqn.C', that is a good question. The only thing that I can answer is I used the standard k-epsilon solver and didn't modify anything in the solver.

Plus, is it possible to use this same technique with scalar value, like 'k' and 'epsilon' by using the type 'scalarFixedValueConstraint'.

If you want to use an equation, maybe this post could help: https://www.cfd-online.com/Forums/op...-equation.html


Regards,

H.Tofighian October 6, 2020 15:14

Could anyone give me a good reference for fvOption usage in OpenFOAM?

farzadmech October 7, 2020 07:35

Dear René Thibault
Thank you very much for your answer. I am using DPMFoam and according to below thread;

https://www.cfd-online.com/Forums/op...tml#post784672

There is no fvOption in the Ueqn.C(Uceqn.C), and I need to add it to my solver, but I have not tested it yet. According to previous thread, adding fvOption is not enough and I have to do another actions also.




Thanks,
Farzad






Quote:

Originally Posted by Tibo99 (Post 784589)
What exactly does this code is fixing the component 'x' of 'U' at the first cell (I was setting a cellZone on the entire domain on the first cell from the wall with a topoSetDict file and using 'topoSet' command, like you probably did in a similar fashion way) at a fix value of 1.458..... At every time step, the value is carry on and fixed at this value at the cellZone set already.

By using the type 'vectorFixedValueConstraint', apparently you don't need to use the form 'vectorField& uSource = equ.source()' to apply the fixed value. Perform a test, and you'll see in your writing folder under 'U' file that the value will stay fix, the same, during the whole simulation in your cellZone. To answer your question about 'fvOption(U)' and 'Ueqn.C', that is a good question. The only thing that I can answer is I used the standard k-epsilon solver and didn't modify anything in the solver.

Plus, is it possible to use this same technique with scalar value, like 'k' and 'epsilon' by using the type 'scalarFixedValueConstraint'.

If you want to use an equation, maybe this post could help: https://www.cfd-online.com/Forums/op...-equation.html


Regards,


Tibo99 October 7, 2020 08:03

I use OpenFoam v1906 and I looked into 'DPMFoam.C' file and there is in fact, no 'fvOptions' framework.

Good luck with your work.

Regards,

farzadmech October 20, 2020 08:35

Dear René Thibault
Finally I decided to code instead of using fvOption, and I did the coding and I have add externalMomentum to the momentum equation in that specific region like this;


Code:

forAll(mesh.C(),i)
{
        scalar x = mesh.C()[i].component(0);
        scalar y = mesh.C()[i].component(1);
        scalar z = mesh.C()[i].component(2);

       
        if(x>0.096 && x<0.404 && y>0.10 && y<0.20 && z>0.0357 && z<0.0643)
        {
        externalMomentum[i] = (1.0 ,0.0 ,0.0);
    }
       
}

But it gives me below error;

Code:

ExMom.H:10:22: error: no match for ‘operator=’ (operand types are ‘Foam::Vector<double>’ and ‘double’)
  externalMomentum[i] = (1.0 ,0.0 ,0.0);

by the way, externalMomentum is a volVectorField. Do you know why this problem happens?


Thanks,
Farzad

Quote:

Originally Posted by Tibo99 (Post 784678)
I use OpenFoam v1906 and I looked into 'DPMFoam.C' file and there is in fact, no 'fvOptions' framework.

Good luck with your work.

Regards,


jherb October 20, 2020 10:26

Code:

(1.0 ,0.0 ,0.0)
is not a OpenFOAM vector but some C++ construction boiling down to one double value. Either you assign the three values explicitly to the components of the
Code:

externalMomentum[i]
vector of you first create a vector object.
Code:

vector(1.0, 0.0, 0.0)
see e.g. https://www.cfd-online.com/Forums/op...tml#post690555

Tibo99 October 20, 2020 10:59

I agree with Joachim.

farzadmech October 20, 2020 11:31

Thanks, It is solved.


Farzad

Quote:

Originally Posted by jherb (Post 785633)
Code:

(1.0 ,0.0 ,0.0)
is not a OpenFOAM vector but some C++ construction boiling down to one double value. Either you assign the three values explicitly to the components of the
Code:

externalMomentum[i]
vector of you first create a vector object.
Code:

vector(1.0, 0.0, 0.0)
see e.g. https://www.cfd-online.com/Forums/op...tml#post690555


farzadmech October 20, 2020 12:55

Also please see this thread;

https://www.cfd-online.com/Forums/op...tml#post785652


thanks,
Farzad


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