CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Bugs (http://www.cfd-online.com/Forums/openfoam-bugs/)
-   -   sampleDict Bug (http://www.cfd-online.com/Forums/openfoam-bugs/95191-sampledict-bug.html)

musahossein December 8, 2011 17:51

sampleDict Bug
 
Dear all:
I have the following bits of commands in sampleDict per the users manual:setFormat raw;
surfaceFormat raw;

interpolationScheme cell;

sets
(
left
{
type uniform;
axis xyz;
start ( 0 -15.0 5.0);
end ( 0 -15.0 -5.0);
nPoints 10;
}
middle
{
type uniform;
axis xyz;
start ( 0 0 5.0);
end ( 0 0 -5.0);
nPoints 10;
}
right
{
type uniform;
axis xyz;
start ( 0 15 5.0);
end ( 0 15 -5.0);
nPoints 10;
}
);
fields (alpha1);
surfaces
(
wallPressure
{
type patch;
patches (leftWall);
interpolate true;
triangulate false;
}
);
fields (p);

My assumption is that once I run it, it will do two things:
1. Provide value of alpha1
2. Provide value of pressure at left wall.

However, upon running sampleDict, in the sets folder, the following subfolders are generated for each time folder left_p.xy, middle_p.xy, right_p.xy. Upon opening of any one of these p.xy folders, the contents are:

0 -15 5 99954.9
0 -15 3.88889 99964.7
0 -15 2.77778 99974.7
0 -15 1.66667 99984.7
0 -15 0.555556 100004
0 -15 -0.555556 108959
0 -15 -1.66667 118995
0 -15 -2.77778 128842
0 -15 -3.88889 138618
0 -15 -5 148398

which is pressure along the three lines (left middle and right) that I defined. But this is bizzare, since I expected sampleDict to give me the alpha1 values along the 3 lines and the pressure at the left wall. Can any one help?

akidess December 9, 2011 04:08

I don't think the sample utility cares about the order in the input file. Thus, it doesn't correlate the fields keyword with the input that came previously. Just use "fields(alpha1 p)" instead. You will sample a bit more data than you need, but that shouldn't be a huge problem.

musahossein December 9, 2011 10:17

I see. Thanks for the reply! One thing I am also trying to do is to see if OpenFOAM can read pressure for one phase only. So say I have a glass half full of water and as I rock the glass back and forth, I only want to see the pressure on glass walls from the water only and not the air above it. Right now specifying "p" in sampleDict gives me the pressure along the entire height of the wall specified. Is there a command that will do this?

Many thanks for your response.

akidess December 9, 2011 12:33

I would sample alpha and p along the walls, and use a python script to filter out values you don't want.

musahossein December 9, 2011 12:51

Quote:

Originally Posted by akidess (Post 335309)
I would sample alpha and p along the walls, and use a python script to filter out values you don't want.

Good suggestion. But I see a potential problem though:

Say my phases are 0 and 1. So I know the interface or free surface occurs at 0.5. I can find out using sampleDict what the phase values are along the vertical surface. The accuracy of the phase value will depend on how many points I sample the phase along the wall vertically. So if I have 40 cells in the vertical direction, then I must sample the phase at more than 40 points - say 60 points. Now I will need to compute where the phase transition ("0.5") occurs and correlate that with all the points the pressures are measured. So there will have to be two sets of interpolation:
1. Find where 0.5 phase occurs and record the height
2. Find the corresponding height in the pressure value file. Interpolate between the values in the event there is no exact match.

Too bad OpenFOAM does not have this utility. An unfortunately I am not great at C++ :(

akidess December 9, 2011 13:40

You never said you want to interpolate the interface. Your previous description corresponds to throwing away all values smaller than 0.5 (assuming air is denoted with zero) and doing the same for the list of pressure values. In this case, you won't need to do interpolation.

If you don't like to do it this way, you can use the threshold filter in paraview, select the cells closest to the wall and then export the values as a spreadsheet. This will require more programming effort though if you want to automate the process.

musahossein December 9, 2011 14:13

Quote:

Originally Posted by akidess (Post 335324)
You never said you want to interpolate the interface. Your previous description corresponds to throwing away all values smaller than 0.5 (assuming air is denoted with zero) and doing the same for the list of pressure values. In this case, you won't need to do interpolation.

If you don't like to do it this way, you can use the threshold filter in paraview, select the cells closest to the wall and then export the values as a spreadsheet. This will require more programming effort though if you want to automate the process.

Yes but I dont know how many cells will have values less than or close to 0.5 (a threshold that would have to be defined). It will depend on how many points along the vertical face of the wall the points are sampled. In paraview, the threshold filter can be used as you suggest, but my goal is to extract the forces on the wall at each time increment. This would make the paraview option impractical. But many thanks for your suggestion

musahossein December 12, 2011 13:45

Dear All:
I put the following code inthe sampleDict file:

fields (alpha1
p);
surfaces
(
wallPressure
{
type patch;
patches (leftWall);
interpolate true;
triangulate false;
}
);

I also put the same code in the controlDict file:

wallPressure
{
type surfaces;
functionObjectLibs ("libsampling.so");
outputControl outputTime;
outputInterval 10;
surfaceFormat raw;
interpolationScheme cellPoint;

fields ( alpha1
p
);
surfaces
(
walls
{
type patch;
patches (leftWall);
interpolate true;
triangulate false;
}
);
}

I am modeling a rectangular tank with the fluid halfway up the tank, as a variation of the sloshingTank2D. After running OpenFOAM, I checked the pressures for the left wall at the same time interval. The output from controlDict for the first few lines is:

# p POINT_DATA 82
# x y z p
-0.5 -19.97 -10 536249
0.5 -19.97 -10 536249
0.5 -19.97 -9.5 536249
-0.5 -19.97 -9.5 536249
0.5 -19.97 -9 530098
-0.5 -19.97 -9 530098
0.5 -19.97 -8.5 522683
-0.5 -19.97 -8.5 522683

The output from the sampleDict file is:
# p POINT_DATA 82
# x y z p
-0.5 -19.97 -10 533173
0.5 -19.97 -10 536942
0.5 -19.97 -9.5 536942
-0.5 -19.97 -9.5 533173
0.5 -19.97 -9 533173
-0.5 -19.97 -9 526390
0.5 -19.97 -8.5 526390
-0.5 -19.97 -8.5 518337

There are significant difference pressure values between the two. Can anyone tell me why this may be occuring?
Thanks


All times are GMT -4. The time now is 04:16.