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

Using sample to Inlet velocity field

Register Blogs Community New Posts Updated Threads Search

Like Tree9Likes
  • 1 Post By amanbearpig
  • 1 Post By amanbearpig
  • 1 Post By vatavuk
  • 5 Post By amanbearpig
  • 1 Post By v199ah

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 8, 2014, 11:38
Default Using sample to Inlet velocity field
  #1
Member
 
Join Date: Apr 2011
Posts: 57
Rep Power: 15
amanbearpig is on a distinguished road
Hello, I'm trying to use the sample utility to get a velocity field to use as the inlet field for a subsequent simulation.

I run sample, and get my U file from a constant plane (setting the point and normal direction), which appears to have twice the amount of values I was expecting. I looked at the file, and there are duplicates of all the values (I'm not entirely sure why this is, perhaps how I am sampling the plane?). So, I go through and delete every other line in the U vector field to eliminate the duplicates - getting a vector field which matches what I need for the inlet.

However when I take this field and set it as a nonuniform List<vector> at the inlet (as an initial condition) the result is nothing like what it should be! I'm attaching a picture of the sampled field, and then the result when I try and place this sampled field as the inlet initial condition.

Where am I going wrong in this process? My guess is something to do with the sampling/removing duplicate values, but I'm not sure what precisely I'm doing incorrectly. Thank you for your help!
Attached Images
File Type: jpg SampledU_Velocity_Field.jpg (13.3 KB, 170 views)
File Type: jpg Inlet_VelocityField_Messedup.jpg (13.2 KB, 170 views)
amanbearpig is offline   Reply With Quote

Old   March 26, 2015, 13:32
Default
  #2
Member
 
Join Date: Apr 2011
Posts: 57
Rep Power: 15
amanbearpig is on a distinguished road
Hello,

I am still having an issue mapping a custom plane to the Inlet of a domain. I have circled back to this problem as work has brought it back into focus, and am still having problems.

My process: I run the 'sample' utility, mapping a defined plane - say the Outlet of a domain. I check the postProcessing folder and find the surface/surface_sampled/vectorField folder which contains the sampled U values. There is one value for each cell on the outlet.

If I take these values and paste them as a custom Inlet nonuniform List<vector> (in a new 0/U file), my inlet profile is all messed up. I'm attaching a picture below of a mapped annular flow inlet where I followed the above steps.

How can I sample a plane, either the Outlet or a custom plane, and set those values as a nonuniform List<vector> for a velocity inlet? Thank you!!
Attached Images
File Type: jpg Inlet_not_mapped_right.jpg (15.6 KB, 114 views)
rajibroy likes this.
amanbearpig is offline   Reply With Quote

Old   April 2, 2015, 19:07
Default
  #3
New Member
 
Rajib Roy
Join Date: Jun 2014
Location: Laramie, Wyoming
Posts: 18
Rep Power: 11
rajibroy is on a distinguished road
Hi,
I am also trying to resolve exactly the same issue; What I've found is that the sampling triangulates the sample plane if it is quadratic X-section; so it appears to be twice as much as faces.

Were you able to solve the problem? Your advise is highly appreciated.

Best,
Rajib
rajibroy is offline   Reply With Quote

Old   April 3, 2015, 09:47
Default
  #4
Member
 
Join Date: Apr 2011
Posts: 57
Rep Power: 15
amanbearpig is on a distinguished road
Hi Rajib,

Unfortunately I have not yet resolved the issue myself. I am no longer getting the doubling faces issue, I now get 1 U vector for each cell, but my attempts to map these to the Inlet is still not working correctly (see the most post above, obviously the velocity vectors are not mapping right!).

It is confusing to me, they have the exact same number of faces, the mesh was created by a 2D face extruded lengthwise, so they should match 1-to-1, but maybe the face ordering is all messed up? Are you getting the same odd looking Inlet profile like me?

This seems like it should be a very simple problem, and I have no explanation as to why I cannot seem to figure it out.
rajibroy likes this.
amanbearpig is offline   Reply With Quote

Old   April 3, 2015, 11:33
Default
  #5
Senior Member
 
Paulo Vatavuk
Join Date: Mar 2009
Location: Campinas, Brasil
Posts: 196
Rep Power: 17
vatavuk is on a distinguished road
Hi,
You could try using the mapFields application like described in this thread: http://www.cfd-online.com/Forums/ope...g-utility.html (see post #6)
Best Regards,
Paulo
lpz456 likes this.
vatavuk is offline   Reply With Quote

Old   April 6, 2015, 10:14
Default
  #6
Member
 
Join Date: Apr 2011
Posts: 57
Rep Power: 15
amanbearpig is on a distinguished road
Hi Paulo,

I have tried using mapFields, but it seems to only map the volume, not the boundaries? After running mapFields, my U file has a long nonuniform List for the domain with the velocity for all the interior cells, but at the Inlet/Outlet it still has my original velocity condition (at the Inlet I had initially uniform (1 0 0), and I want to take the Outlet velocity profile and impose it in the U file within the time directory, as the Inlet velocity).

Am I not using mapFields correctly? How can I go about getting a correct nonuniform List<vector> for the Inlet - mapped from the Outlet or some other defined plane within the domain?

Thank you very much for your help!
amanbearpig is offline   Reply With Quote

Old   April 6, 2015, 11:46
Default
  #7
Senior Member
 
Paulo Vatavuk
Join Date: Mar 2009
Location: Campinas, Brasil
Posts: 196
Rep Power: 17
vatavuk is on a distinguished road
Hi Amanbearpig,
Additional instructions are provided in the user guide:
http://www.openfoam.org/docs/user/mapFields.php
Best Regards,
Paulo
vatavuk is offline   Reply With Quote

Old   April 6, 2015, 18:31
Default
  #8
New Member
 
Rajib Roy
Join Date: Jun 2014
Location: Laramie, Wyoming
Posts: 18
Rep Power: 11
rajibroy is on a distinguished road
Hi All,
I've tried the mapFields Utility and it does not correctly map the neither the internal field nor the patches (I've looked at the post as you advised).

Now I have came up with an idea which is as follows:
1. Using toposet and subset utilities to trim the source mesh to match the target mesh. Now the cutting plane is a patch which needs to map.

2. Declare the new patch as mapped BC and, write out the fields after 1 iteration. The internal fields will be mapped to fields as a non-uniform list.

*** On going work ***
The mapped BC is dependent on a prescribed initial value which affects the mapping results. Working on to create a new BC that maps from internal field to a patch.

Could you suggest any idea regarding this matter.
Thanks for the advise and support.

Best,
Rajib
rajibroy is offline   Reply With Quote

Old   April 7, 2015, 10:44
Default
  #9
Member
 
Join Date: Apr 2011
Posts: 57
Rep Power: 15
amanbearpig is on a distinguished road
Hi Paulo,

I've been trying to use mapFields for some time (I had tried it before you had mentioned it, and I went back and re-tried it to make sure I did not miss something ) and perhaps I am not implementing it correctly but I am still not getting what I want from it.

What I am trying to get is, for a geometry that does not change, map the Outlet or some arbitrary plane to the Inlet for a new simulation. I don't want a cyclic case, I want a mapped Inlet with a defined nonuniform List as the Inlet boundary condition, using the mapped values from the Outlet of the previous case.

When I run mapFields, using the mappedFieldsDict which specifies:
Code:
patchMap
( Outlet Inlet);
for the source and target patches, respectively, I still am not getting a changed Inlet boundary condition in the U file. The interior is mapped, but the Inlet boundary condition still contains the initial boundary condition (in this case it was fixedValue uniform (1 0 0);.

I will look at what you have posted Rajib and see if it can help me, I just wanted to reply to Paulo. I am not discounting the fact I could be doing something wrong, I just have not met with success yet using mapFields.

Thank you!
amanbearpig is offline   Reply With Quote

Old   October 9, 2015, 04:58
Default
  #10
Senior Member
 
Syavash Asgari
Join Date: Apr 2010
Posts: 473
Rep Power: 18
syavash is on a distinguished road
Quote:
Originally Posted by amanbearpig View Post
Hi Paulo,

I've been trying to use mapFields for some time (I had tried it before you had mentioned it, and I went back and re-tried it to make sure I did not miss something ) and perhaps I am not implementing it correctly but I am still not getting what I want from it.

What I am trying to get is, for a geometry that does not change, map the Outlet or some arbitrary plane to the Inlet for a new simulation. I don't want a cyclic case, I want a mapped Inlet with a defined nonuniform List as the Inlet boundary condition, using the mapped values from the Outlet of the previous case.

When I run mapFields, using the mappedFieldsDict which specifies:
Code:
patchMap
( Outlet Inlet);
for the source and target patches, respectively, I still am not getting a changed Inlet boundary condition in the U file. The interior is mapped, but the Inlet boundary condition still contains the initial boundary condition (in this case it was fixedValue uniform (1 0 0);.

I will look at what you have posted Rajib and see if it can help me, I just wanted to reply to Paulo. I am not discounting the fact I could be doing something wrong, I just have not met with success yet using mapFields.

Thank you!
Hi,

Any chance in sampling inlet plane?! I just want to start with this idea as I think it is required for my LES simulations, as a boundary condition for the second simulation.

Thanks
Syavash
syavash is offline   Reply With Quote

Old   October 13, 2015, 08:05
Default
  #11
Member
 
Join Date: Apr 2011
Posts: 57
Rep Power: 15
amanbearpig is on a distinguished road
Hi syavash,

Unfortunately I was unable to find a way to easily use mapfields to sample to the inlet plane in this manner, however I found a workaround which I have used.

So, say you have a domain of length L, and you want to sample the velocity profile at 0.8L and put that as your inlet boundary condition.

What I've done is instead of sampling the plane I want, I instead translate the domain using transformPoints in the -x direction to get the plane I want to sample from lined up with the inlet plane, assuming the flow is in the x direction.

The way I do it is I have my folder with my RANS run, say /RANSrun/ then I make a subfolder to transform the points, say OFRUN/RANSrun/translated/. I copy my constant, system, and the time directory I want to use for my LES inlet to this /RANSrun/translated/ directory. Then from this translated directory, if I wanted to get the velocity from 0.8L, I would run: transformPoints -translate '(-0.8L 0 0)'. This moves the whole domain -0.8L in the x direction.

Then, I go to the LES folder, say OFRUN/LESrun/, and copy the original (not transformed) constant folder (along with your 0 time directory and system folder, what you have in the 0 time directory is not very crucial just yet, all that matters is that you have files for whatever variables you want to get from your RANS run, so in this case, make sure you have a U file).

Also, make sure you have a mapFieldsDict in your OFRUN/LESrun/system folder. The only important part in this file is that you have the name of your inlet patch in the cuttingPatches section, so something like this:

cuttingPatches( Inlet );


Then, from my OFRUN/LESrun/ folder, I run: mapFields OFRUN/RANSrun/translated. Finally, you can go and check your boundary conditions for the variables in the time directory, and ensure everything is set up correctly. You should have a nonuniform List for your inlet boundary condition, which is from 0.8L in your RANS run.

Hope this is what you're looking for!
amanbearpig is offline   Reply With Quote

Old   October 13, 2015, 09:47
Default
  #12
Senior Member
 
Syavash Asgari
Join Date: Apr 2010
Posts: 473
Rep Power: 18
syavash is on a distinguished road
Quote:
Originally Posted by amanbearpig View Post
Hi syavash,

Unfortunately I was unable to find a way to easily use mapfields to sample to the inlet plane in this manner, however I found a workaround which I have used.

So, say you have a domain of length L, and you want to sample the velocity profile at 0.8L and put that as your inlet boundary condition.

What I've done is instead of sampling the plane I want, I instead translate the domain using transformPoints in the -x direction to get the plane I want to sample from lined up with the inlet plane, assuming the flow is in the x direction.

The way I do it is I have my folder with my RANS run, say /RANSrun/ then I make a subfolder to transform the points, say OFRUN/RANSrun/translated/. I copy my constant, system, and the time directory I want to use for my LES inlet to this /RANSrun/translated/ directory. Then from this translated directory, if I wanted to get the velocity from 0.8L, I would run: transformPoints -translate '(-0.8L 0 0)'. This moves the whole domain -0.8L in the x direction.

Then, I go to the LES folder, say OFRUN/LESrun/, and copy the original (not transformed) constant folder (along with your 0 time directory and system folder, what you have in the 0 time directory is not very crucial just yet, all that matters is that you have files for whatever variables you want to get from your RANS run, so in this case, make sure you have a U file).

Also, make sure you have a mapFieldsDict in your OFRUN/LESrun/system folder. The only important part in this file is that you have the name of your inlet patch in the cuttingPatches section, so something like this:

cuttingPatches( Inlet );


Then, from my OFRUN/LESrun/ folder, I run: mapFields OFRUN/RANSrun/translated. Finally, you can go and check your boundary conditions for the variables in the time directory, and ensure everything is set up correctly. You should have a nonuniform List for your inlet boundary condition, which is from 0.8L in your RANS run.

Hope this is what you're looking for!
Hi amanbearpig,

Thanks for sharing your solution. If I could understand you correctly, you have saved all the time steps in your first simulation (RANS simulation). Please correct me if I am wrong.
Actually, this is what I cannot afford to do, because saving every time steps for my precursor simulation along with all the data included (U, p, nusgs, etc) would result in a huge amount of data.
So, I think I should only save inlet boundary U field at each time step and save them for the next LES simulation (primary simulation).
What is your opinion about my situation?

Thanks,
Syavash
syavash is offline   Reply With Quote

Old   October 13, 2015, 11:34
Default
  #13
Member
 
Join Date: Apr 2011
Posts: 57
Rep Power: 15
amanbearpig is on a distinguished road
Hi Syavash,

Ah, I see you are doing a slightly different thing than I was. I was using a RANS solution to get a U inlet condition for an LES run using the LeMOS inflow generator, but only taking the latest iteration, so I only had one time directory.

I take it you want to save a bunch of time steps from some plane to use as a time-dependent inlet condition for LES? I have to think there is a way to do that, even if it requires some extra scripting, but off the top of my head I am not sure how to go about doing that. I admit I'm no OpenFOAM expert, I just know a few things I've picked up on my own. I will think about it and if I come up with something let you know, otherwise hopefully a more knowledgeable OpenFOAMer can comment with a suggestion!
amanbearpig is offline   Reply With Quote

Old   October 13, 2015, 13:20
Default
  #14
Senior Member
 
Syavash Asgari
Join Date: Apr 2010
Posts: 473
Rep Power: 18
syavash is on a distinguished road
Quote:
Originally Posted by amanbearpig View Post
Hi Syavash,

Ah, I see you are doing a slightly different thing than I was. I was using a RANS solution to get a U inlet condition for an LES run using the LeMOS inflow generator, but only taking the latest iteration, so I only had one time directory.

I take it you want to save a bunch of time steps from some plane to use as a time-dependent inlet condition for LES? I have to think there is a way to do that, even if it requires some extra scripting, but off the top of my head I am not sure how to go about doing that. I admit I'm no OpenFOAM expert, I just know a few things I've picked up on my own. I will think about it and if I come up with something let you know, otherwise hopefully a more knowledgeable OpenFOAMer can comment with a suggestion!
Dear amanbearpig,

It is your kindness that you care about my problem. I really appreciate it .

Actually, I have come up with several solutions:

1-Using sample utility
2-Using sampling function within controlDict
3-Modifying pimpleFoam to write the U field at the inlet boundary at each time step.

I refer you to these threads of mine:
HTML Code:
http://www.cfd-online.com/Forums/openfoam-programming-development/160541-give-file-proper-header-being-used-timevaryingmappedfixedvalue-input.html
and

HTML Code:
http://www.cfd-online.com/Forums/openfoam-programming-development/160761-modifying-solver-write-variable.html
Well, I could successfully extract the U field at inlet for every time steps, but I use timeVaryingMappedFixedValue bc and it demands its own Header, something like the following:

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.3.1                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       vectorAverageField;
    object      values;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //


More precisely, the problem is "class vectorAverageField" which is different from the vectorField which is the default output class of OpenFOAM.
I hope you or anyone else would have an idea to solve this problem and generate the proper Header for being used in timeVaryingMappedFixedValue bc.

Sincerely,
Syavash
syavash is offline   Reply With Quote

Old   November 16, 2015, 05:47
Default A way around
  #15
New Member
 
Join Date: Oct 2015
Location: Trondheim
Posts: 6
Rep Power: 10
v199ah is on a distinguished road
Another way to get around the problem of sample writing out each point twice, can be to copy the files to excel or LibreOffice Calc and do this:

http://stackoverflow.com/questions/2...eet-to-another

And then copy paste it into the respective files in the 0-directory.
lpz456 likes this.
v199ah is offline   Reply With Quote

Reply


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
Velocity inlet boundary condition for porous medium Chander CFX 3 March 11, 2012 21:18
Inlet velocity mismatch in low microchannel alligngr8 FLUENT 0 December 10, 2011 01:43
ATTENTION! Reliability problems in CFX 5.7 Joseph CFX 14 April 20, 2010 15:45
velocity of massless particles and velocity of flow field in same coordinate payam_IUST FLUENT 0 October 18, 2009 23:24
Variables Definition in CFX Solver 5.6 R P CFX 2 October 26, 2004 02:13


All times are GMT -4. The time now is 08:38.