CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Programming & Development

Forcing the value of a point in internal Domain to remain fixed.

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   April 16, 2017, 03:10
Default Forcing the value of a point in internal Domain to remain fixed.
  #1
New Member
 
Mehdi Aminyavari
Join Date: Feb 2016
Location: Milan
Posts: 18
Rep Power: 3
Mehdi3031 is on a distinguished road
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.
Attached Images
File Type: jpg InterfaceY.jpg (79.0 KB, 12 views)
Mehdi3031 is offline   Reply With Quote

Old   April 16, 2017, 07:13
Default
  #2
Senior Member
 
Zeppo's Avatar
 
Sergei
Join Date: Dec 2009
Posts: 183
Rep Power: 10
Zeppo is on a distinguished road
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).
Zeppo is offline   Reply With Quote

Old   April 17, 2017, 05:09
Default
  #3
New Member
 
Mehdi Aminyavari
Join Date: Feb 2016
Location: Milan
Posts: 18
Rep Power: 3
Mehdi3031 is on a distinguished road
Quote:
Originally Posted by Zeppo View Post
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 is offline   Reply With Quote

Old   April 18, 2017, 13:42
Default How about this?
  #4
New Member
 
Mehdi Aminyavari
Join Date: Feb 2016
Location: Milan
Posts: 18
Rep Power: 3
Mehdi3031 is on a distinguished road
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;
}
Mehdi3031 is offline   Reply With Quote

Old   April 21, 2017, 15:23
Default
  #5
Senior Member
 
Zeppo's Avatar
 
Sergei
Join Date: Dec 2009
Posts: 183
Rep Power: 10
Zeppo is on a distinguished road
What is the code between the snippets from your latest post? ygi might somehow be modified there or something?
Zeppo is offline   Reply With Quote

Old   April 22, 2017, 09:45
Default
  #6
New Member
 
Mehdi Aminyavari
Join Date: Feb 2016
Location: Milan
Posts: 18
Rep Power: 3
Mehdi3031 is on a distinguished road
Quote:
Originally Posted by Zeppo View Post
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
Mehdi3031 is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Monte Carlo Simulation: H-Energy is not convergating & high Incident Radiation volleyHC CFX 5 April 3, 2016 05:41
Pressure distribution on a wall darazsbence CFX 17 October 6, 2015 10:38
sliding mesh problem in CFX Saima CFX 45 September 22, 2015 10:53
Named selection for internal surfaces in the domain Ahmed Saeed CFX 1 November 20, 2013 10:32
CFX4.3 -build analysis form Chie Min CFX 5 July 12, 2001 23:19


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