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/)
-   -   Forcing the value of a point in internal Domain to remain fixed. (https://www.cfd-online.com/Forums/openfoam-programming-development/186302-forcing-value-point-internal-domain-remain-fixed.html)

Mehdi3031 April 16, 2017 03:10

Forcing the value of a point in internal Domain to remain fixed.
 
1 Attachment(s)
Hello dear Foamers,
I am developing a twophase flow solver where I solve species balance (binary mixture) for both phases; YlEqn and YgEqn.
Lets take the YgEqn as an example:

Code:

    fvScalarMatrix YgEqn
    (
        fvm::ddt(alpha2*rho2, yg)
      + fvm::div(rho2Phialpha2, yg, "div(rhoPhiAlpha,yg)")
      - fvm::laplacian(alpha2*rho2*Dg, yg)
    );

    ygEqn.relax();
    ygEqn.solve();

Now if you look at the picture that I attached, there is a line called interface which I can know it's location inside the domain with Alpha (volume fraction).

what I want to do now is to force yg to be equal to ygi (which I calculate from an external function) on the interface. so basically it is like a fixed value boundary condition, but inside the domain and not on the boundary.
the good point is that I know where inside the domain and which cell, but I am not sure how I should force it's value to remain constant and not be affected by the other cells.

Any hint would be really appreciated.

Zeppo April 16, 2017 07:13

Possibly, ExplicitSetValue is what you need.
Code:

fvScalarMatrix YgEqn
(
    fvm::ddt(alpha2*rho2, yg)
  + fvm::div(rho2Phialpha2, yg, "div(rhoPhiAlpha,yg)")
  - fvm::laplacian(alpha2*rho2*Dg, yg)
 ==
    fvOptions(rho, yg)
);

fvOptions.constrain(YgEqn);

ygEqn.relax();

ygEqn.solve();

Then add fvOptions file with an entry of type ExplicitSetValue to your case (search on the forum to learn how to use it and ask here if need more info).

Mehdi3031 April 17, 2017 05:09

Quote:

Originally Posted by Zeppo (Post 645068)
Possibly, ExplicitSetValue is what you need.
Code:

fvScalarMatrix YgEqn
(
    fvm::ddt(alpha2*rho2, yg)
  + fvm::div(rho2Phialpha2, yg, "div(rhoPhiAlpha,yg)")
  - fvm::laplacian(alpha2*rho2*Dg, yg)
 ==
    fvOptions(rho, yg)
);

fvOptions.constrain(YgEqn);

ygEqn.relax();

ygEqn.solve();

Then add fvOptions file with an entry of type ExplicitSetValue to your case (search on the forum to learn how to use it and ask here if need more info).

hello Zeppo,
Thank you so much for your reply, I actually thought of that at the beginning, but the point is that these values of Ygi are a function of P and T and I solve also energy equation and these values should get updated on runtime after energy equation is solved in each timestep.
Yg[celli]=Function_Ygi(T[celli],p[celli])
where celli is the index of the cells where there is interface.
So I need to force the values of Yg to be Ygi from the solver.
Can you think of any way to revise the YgEgn in the solver to do that?

Once again I really appreciate your help.
Happy Easter :)

Mehdi3031 April 18, 2017 13:42

How about this?
 
I figured out something but I am not sure if it is correct or not, I read on another post that this should work like this by using "setValues":

Code:

  fvScalarMatrix ygEqn
    (
        fvm::ddt(alpha2*rho2, yg)
      + fvm::div(rho2Phialpha2, yg, "div(rhoPhiAlpha,yg)")
      - fvm::laplacian(alpha2*rho2*Dg, yg)
    );


forAll(alpha2,celli){
                                if ( alpha2[celli] != 0 && alpha2[celli] != 1)
                                    {
                                        label ref = celli;
                                        labelList refCells (1,ref);
                                        scalarField refValues (1, ygi[celli]);
                                        ygEqn.setValues(refCells, refValues);
                                }
}
    ygEqn.relax();
    ygEqn.solve();

but when I do this and I print the values of yg and ygi of the interface cells as following, they are not equal. :( :( :(
Any idea what am I doing wrong?

Code:

forAll(alpha2,celli){
                                        Info << "  alpha2 = " << alpha2[celli]
                                        << "  yg = " << yg[celli]
                                        << "  =? ygi = " << ygi[celli]
                                        << endl;
}


Zeppo April 21, 2017 15:23

What is the code between the snippets from your latest post? ygi might somehow be modified there or something?

Mehdi3031 April 22, 2017 09:45

Quote:

Originally Posted by Zeppo (Post 645845)
What is the code between the snippets from your latest post? ygi might somehow be modified there or something?

Dear Zeppo, Thank you for your reply, Actually the problem was with a source term that I had on the same cell, When I cancelled the source term, setValue was working perfectly.
Thank you so much


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