CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM

Calculating phi from U read from file

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 20, 2020, 21:51
Default Calculating phi from U read from file
  #1
New Member
 
Kaushik
Join Date: Jun 2019
Posts: 14
Rep Power: 6
kauraajn is on a distinguished road
Hi,

I have used the incompressible navier stokes equations to compute the velocity field for my domain using a third part solver, and I need to use this velocity to implement a scalar transport solver in openfoam. How should I calculate phi for this application? I have my velocity field in the format required by openfoam on file.
kauraajn is offline   Reply With Quote

Old   June 21, 2020, 06:04
Default
  #2
Senior Member
 
Carlos Rubio Abujas
Join Date: Jan 2018
Location: Spain
Posts: 127
Rep Power: 9
crubio.abujas is on a distinguished road
When you mention you need to implement a scalar transport solver you mean to write the code? Have you tried scalarTransportFoam? You can check in the tutorials how to define the case and it do just that (inside the basic folder).

Basically you define a U Boundary condition with a non-uniform internal with the velocity field you have, and also set the boundary condition properly. The scalar has to be named T for this case, and a diffusion term is defined in constant/transportProperties as DT. With that information it will calculate phi and solve the scalar transport. It sounds pretty much to want you want.

However, if you want to modify the behavior, adding additional scalarFields, renamed or whatever you may check the code of scalarTransient. There are plenty of tutorials out there explaining how to do that. (i.e https://openfoamwiki.net/index.php/H...ure_to_icoFoam).
crubio.abujas is offline   Reply With Quote

Old   June 21, 2020, 06:29
Default
  #3
New Member
 
Kaushik
Join Date: Jun 2019
Posts: 14
Rep Power: 6
kauraajn is on a distinguished road
Thanks for your reply crubio.abujas! Yes, I have implemented what you have pointed out using scalarTransportFoam. However, I am having trouble in obtaining the phi field. It seems to be always be set to 0 throughout my domain. I guess my question is: how do I obtain the right phi field from U which I know.
kauraajn is offline   Reply With Quote

Old   June 21, 2020, 06:54
Default
  #4
Senior Member
 
Carlos Rubio Abujas
Join Date: Jan 2018
Location: Spain
Posts: 127
Rep Power: 9
crubio.abujas is on a distinguished road
Quote:
Originally Posted by kauraajn View Post
Thanks for your reply crubio.abujas! Yes, I have implemented what you have pointed out using scalarTransportFoam. However, I am having trouble in obtaining the phi field. It seems to be always be set to 0 throughout my domain. I guess my question is: how do I obtain the right phi field from U which I know.

It's hard to tell without knowing how your settings file look like. What is 0? the U field? the scalar (lets name it T) T field? or the phi field?

When you define the BC you have to tell two pieces of information, one is the value field inside the domain and other is the treatment on the boundaries. Typically you set the scalar value in a boundary and then let the solver calculate the distribution. Maybe you defined de velocity in that particular patch to be 0, or to point outwards the domain and that is why the scalar is not distributing.

I'm only guessing here, please share more information about the setting of the case for more insight.
crubio.abujas is offline   Reply With Quote

Old   June 21, 2020, 16:10
Default
  #5
New Member
 
Kaushik
Join Date: Jun 2019
Posts: 14
Rep Power: 6
kauraajn is on a distinguished road
The phi field is always zero.

I read the internal field for U from a file, and compute U on the boundary using correctBoundaryConditions. I use zeroGradient boundary conditions for U for my inlet and outlet, and no slip conditions on the walls.

I find that even if U is updated, phi does not get updated. How do I tell the solver to update the values of phi based on U?
kauraajn is offline   Reply With Quote

Old   June 22, 2020, 03:16
Default
  #6
Senior Member
 
Carlos Rubio Abujas
Join Date: Jan 2018
Location: Spain
Posts: 127
Rep Power: 9
crubio.abujas is on a distinguished road
So you are coding your own solver, right? In that case it would be useful if you share the code, so it is clearer where something may be wrong instead of me having to guess what you have done.

If you're getting a phi field to visualize means that, at least, you're initiating the field. You probably have created this field using
Code:
#include "createPhi.H"
Quote:
Originally Posted by kauraajn View Post
I read the internal field for U from a file, and compute U on the boundary using correctBoundaryConditions. I use zeroGradient boundary conditions for U for my inlet and outlet, and no slip conditions on the walls.
When you said you're reading the internal field from a file, I'm guessing that file is not 0/U internalField, right? If you initialize the U field, then initialize the phi field and only after these two initializations you read the external U field, then phi is not being updated with this new information. The scalarTransportFoam solver does not solve for U, so it only calculate the phi field at the initialization.

If that is your case, you can just call createPhi after U is properly set. Or call
Code:
phi = fvc::flux(U);
Whenever that happens.

Again, it's hard to forecast the details and implementation of your solver without seeing the code itself. If the problems persist please share the important bits of the code. It's also important to know your OF version, as the code may be different.

Regars
crubio.abujas is offline   Reply With Quote

Old   June 22, 2020, 07:22
Default
  #7
New Member
 
Kaushik
Join Date: Jun 2019
Posts: 14
Rep Power: 6
kauraajn is on a distinguished road
That worked, thanks a lot! Yes, phi was not getting updated because I read U after creating phi.
kauraajn is offline   Reply With Quote

Old   June 22, 2020, 07:43
Default
  #8
Senior Member
 
Carlos Rubio Abujas
Join Date: Jan 2018
Location: Spain
Posts: 127
Rep Power: 9
crubio.abujas is on a distinguished road
Quote:
Originally Posted by kauraajn View Post
That worked, thanks a lot! Yes, phi was not getting updated because I read U after creating phi.

Glad to know it worked!
crubio.abujas is offline   Reply With Quote

Reply

Tags
phi field

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[swak4Foam] Installation Problem with OF 6 version Aurel OpenFOAM Community Contributions 14 November 18, 2020 17:18
[foam-extend.org] Problems installing foam-extend-4.0 on openSUSE 42.2 and Ubuntu 16.04 ordinary OpenFOAM Installation 19 September 3, 2019 19:13
what is swap4foam ?? AB08 OpenFOAM 28 February 2, 2016 02:22
SparceImage v1.7.x Issue on MAC OS X rcarmi OpenFOAM Installation 4 August 14, 2014 07:42
DxFoam reader update hjasak OpenFOAM Post-Processing 69 April 24, 2008 02:24


All times are GMT -4. The time now is 10:39.