CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Using sample to Inlet velocity field (https://www.cfd-online.com/Forums/openfoam-solving/145570-using-sample-inlet-velocity-field.html)

amanbearpig December 8, 2014 11:38

Using sample to Inlet velocity field
 
2 Attachment(s)
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! :o

amanbearpig March 26, 2015 13:32

1 Attachment(s)
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!! :o

rajibroy April 2, 2015 19:07

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

amanbearpig April 3, 2015 09:47

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? :confused: 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. :(

vatavuk April 3, 2015 11:33

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

amanbearpig April 6, 2015 10:14

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! :o

vatavuk April 6, 2015 11:46

Hi Amanbearpig,
Additional instructions are provided in the user guide:
http://www.openfoam.org/docs/user/mapFields.php
Best Regards,
Paulo

rajibroy April 6, 2015 18:31

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

amanbearpig April 7, 2015 10:44

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 :p) 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!

syavash October 9, 2015 04:58

Quote:

Originally Posted by amanbearpig (Post 540349)
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 :p) 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

amanbearpig October 13, 2015 08:05

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!

syavash October 13, 2015 09:47

Quote:

Originally Posted by amanbearpig (Post 567943)
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

amanbearpig October 13, 2015 11:34

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! :o

syavash October 13, 2015 13:20

Quote:

Originally Posted by amanbearpig (Post 568003)
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! :o

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

v199ah November 16, 2015 05:47

A way around
 
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.


All times are GMT -4. The time now is 06:28.