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

Weird interpolation using TimeVaryingMappedFixedValue

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

Like Tree2Likes
  • 2 Post By Djub

Reply
 
LinkBack Thread Tools Display Modes
Old   January 8, 2013, 10:45
Default Weird interpolation using TimeVaryingMappedFixedValue
  #1
New Member
 
Join Date: Dec 2012
Posts: 7
Rep Power: 4
CFD_Monkey is on a distinguished road
Hello everybody,

to get time and space dependent inlet boundary conditions I'm using TimeVaryingMappedFixedValue. Unfortunately I get kind of weird distribution of the velocity at the inlet patch.

I create point map and velocity map via octave.
To show you the problem I've made two examples. In both cases I prospect a cube with a equidistant mesh of 35x35x35. For the inlet patch I create 35 x 35 equidistant velocity values such that in each cell center the velocity is given. (And actually no interpolation is needed)

1. The velocity is a step function: 2 m/s within 7 cells next to the wall; 10 m/s in the middle.

octave output:
https://dl.dropbox.com/u/48415338/pr...tep_octave.png

velocity distribution after solving at the inlet patch:
https://dl.dropbox.com/u/48415338/pr...p_paraView.png


2. In this example there is no problem (velocity = x + y)

octave output:
https://dl.dropbox.com/u/48415338/no_problem_octave.png

velocity distribution after solving at the inlet patch:
https://dl.dropbox.com/u/48415338/no...m_paraView.png

So in cases of huge velocity gradient such as in ex. 1 I always get this kind of stripes. (I also have done some additional examples)


Maybe I have to change some settings in the U file where I call TimeVaryingMappedFixedValue?!

type timeVaryingMappedFixedValue;
setAverage off;



I would be grateful for any idea what's going on here.

Thank you very much!


Best regards

Heiko
CFD_Monkey is offline   Reply With Quote

Old   January 27, 2013, 10:31
Default
  #2
New Member
 
Join Date: Dec 2012
Posts: 7
Rep Power: 4
CFD_Monkey is on a distinguished road
In order to make my problem more obvious I have created a short example:

I treat a cube with 4x4x4 meter and uniform cell dimensions 1x1 meter. Now I want to show you the relevant files for the TimeVaryingMappedFixedValue. If there are more files which are addressed by TimeVaryingMappedFixedValue please let me know.

The inlet patch is placed at x=0 such that the inlet is y=0 to y=4 and z=0 und z=4 with stream direction in +x.

points file in boundaryData/inlet:
(the points are placed at the center of the inlet patch cells)

Code:
FoamFile
{
    version    2.0;
    format    ascii;
    class    vectorField;
    object    points;
}

(
//z = 0.500000:

(0 0.500000 0.500000)
(0 1.500000 0.500000)
(0 2.500000 0.500000)
(0 3.500000 0.500000)

//z = 1.500000:

(0 0.500000 1.500000)
(0 1.500000 1.500000)
(0 2.500000 1.500000)
(0 3.500000 1.500000)

//z = 2.500000:

(0 0.500000 2.500000)
(0 1.500000 2.500000)
(0 2.500000 2.500000)
(0 3.500000 2.500000)

//z = 3.500000:

(0 0.500000 3.500000)
(0 1.500000 3.500000)
(0 2.500000 3.500000)
(0 3.500000 3.500000)
)
The associated velocity values in boundaryData/inlet/0 are shown below. There are now further time directories.

Code:
FoamFile
{
    version    2.0;
    format    ascii;
    class    vectorAverageField;
    object    values;
}

(0 0 0)

16
(
//z = 0.500000:

(2.000000 0 0)
(2.000000 0 0)
(2.000000 0 0)
(2.000000 0 0)

//z = 1.500000:

(4.000000 0 0)
(4.000000 0 0)
(4.000000 0 0)
(4.000000 0 0)

//z = 2.500000:

(4.000000 0 0)
(4.000000 0 0)
(4.000000 0 0)
(4.000000 0 0)

//z = 3.500000:

(2.000000 0 0)
(2.000000 0 0)
(2.000000 0 0)
(2.000000 0 0)
)
The values for k and epsilon are constant with k=3 and epsilon = 300. I think they are not relevant for the velocity boundary inlet condition.

In the 0 boundary directory in the main folder of the case, I call the TimeVaryingMappedFixedValue by:

Code:
inlet
    {
        type            timeVaryingMappedFixedValue;
        setAverage      off;
    }
So if there are some additional commands needed please let me know.

Finally the results for the inlet at time 1 after solving the case with simpleFoam:

Code:
boundaryField
{
    inlet
    {
        type            timeVaryingMappedFixedValue;
        setAverage      0;
        peturb          1e-05;
        value           nonuniform List<vector>
16
(
(2 0 0)               
(2 0 0)
(2.00005 0 0)
(2 0 0)
(3.99998 0 0)
(4 0 0)
(4 0 0)
(4 0 0)
(3.00001 0 0)
(4 0 0)
(3.99997 0 0)
(3.73515 0 0)
(2 0 0)
(2 0 0)
(2.00001 0 0)
(2 0 0)
);
As you can see the values for cell 8 (value about 3) and cell 11 (value about 3.7) don't fit to my values in boundaryData/inlet/0/U apart from the perturbation.

I'm still hoping that I made a stupid mistake. So if you have any idea what's wrong please let me know.


The hole test case is also attached to this post.




BIG THX
Attached Files
File Type: zip test.zip (37.5 KB, 29 views)
CFD_Monkey is offline   Reply With Quote

Old   May 3, 2013, 05:13
Default
  #3
Senior Member
 
Julien
Join Date: Jun 2012
Location: France
Posts: 153
Rep Power: 5
Djub is on a distinguished road
Hi Heiko,

Did you solve out your problem?
I am not an expert, but I successfully used timeVaryingMappedFixedValue , so maybe I can bring some help...

First of all, it seems that this boundary condition is very powerful since it can interpolate in time and space: thus, you do not need to take care about the space grid and time steps. Foam will interpolate (I suppose by linear interpolation ?) from the given data to the needed points and time steps. You just need to check that your data "cover" the needed points : the first boundary data must be before (or equal) first calculation time step, and the boundary data map larger (or equal) to the patch with boundary condition 'timeVaryingMappedFixedValue '.

I don't see any "mistake" in your files, but I have some suggestions:
  • I had once a problem of "ugly" inlet, a bit like your second picture (in second post): the reason was an incorrect numbering order between my inlet file (boundaryData/inlet/0...) and my geometry file (boundaryData/inlet/points). The "diagonals" in your picture look a bit like this (4 points in one line, interpreted as 5 points, so a shift of 1 point by line)
  • A second idea is about time steps (in your first post): you gave us the boundary map at time 0, saying you have other time folders, and you show us the result at time step 1s: maybe the interpolation of maps between time 0 and time XXX (the next after 1s) makes this field?
  • In your second post, first example (the one which doesn't work): Your inlet with sharp steps (discontinuities) seems to be physically impossible. You solve Navier-Stokes between two physically impossible forced states; I don't know the behavior between these two steps ! Maybe you should define a smoother inlet condition, more realistic, to avoid this numerical problems.
In my case, I used a first Foam calculation in order to construct my time varying inlet. In my controlDict, I exported the (future) inlet using a function, type surfaces, surfaceFormat foamFile, with interpolate false. The output is not convenient, because in each output time step there is a large structure:
Code:
% - turbInletFields
% | - scalarField
% | | k
% | | p
% | | nuSgs
% | - Vectorfield
% | | U
% | faceCenters
% | faces
% | points
But a simple program (in Octave for instance) can deal with this and rearrange it in order to fit with timeVaryingMappedFixedValue . (Be careful! With this interpolation, the geometry needed by timeVaryingMappedFixedValue is "faceCenters" . And you have also to insert the Foam header in each file).

I think all these advices won't help you, Heiko, sorry. But maybe somebody else (Timo from Stuttgart ?) will find here some interesting information...

Sincerely,
Djub
mgg and CFD_Monkey like this.
Djub is offline   Reply With Quote

Old   June 27, 2013, 11:39
Default
  #4
New Member
 
Join Date: Dec 2012
Posts: 7
Rep Power: 4
CFD_Monkey is on a distinguished road
Hi everyone,

@Djub: sorry for replying so late and thanks for your answer.

I tried to fix the problem by your suggestions but indeed I couldn't make it.

Recently I manipulated the data of a cuttingPlane and created the corresponding files for timeVaryingMappedFixedValue for an other simulation. In this case I didn't run into trouble using timeVaryingMappedFixedValue, even if I change the grid steps.

A close look to the data written by the cuttingPlane shows that the value is written at two points per cell. Maybe this helps for creating the input files "by hand".
You can also try to run the case with any inlet BC and write any Field value with cuttingPlane just to get the points. Of course you have to manipulate your input data to match up with this points which is not very convenient.

If anyone get any progress or insight, please let me know.

Cheers
CFD_Monkey is offline   Reply With Quote

Old   May 21, 2014, 09:35
Default
  #5
Member
 
Niu
Join Date: Apr 2014
Posts: 42
Rep Power: 3
Z.Q. Niu is on a distinguished road
Dear Julien,
I'm also using TimeVaryingMappedFixedValue to supply velocity of inlet of a channel, but there are too much time steps need to be convert the format that TimeVaryingMappedFixedValue could use. Do you have a quick way to achieve it ?
Z.Q. Niu is offline   Reply With Quote

Old   May 22, 2014, 08:41
Default
  #6
Senior Member
 
Julien
Join Date: Jun 2012
Location: France
Posts: 153
Rep Power: 5
Djub is on a distinguished road
Dear Niu,

Quote:
there are too much time steps need to be convert the format that TimeVaryingMappedFixedValue could use.
I don't understand your question. I think you should try to have more or less one time folder in your boundaryData folder, for each time step you want to run. For me, it makes a huge amount of data! But it is necessary to run my case.

In my process, I don't have to "convert" any data. I just change the name and position of the files, adding a header. But the data is still in ASCII format, same numbering as the Foam output.

If you need further help, please be more precise in your question.
Djub is offline   Reply With Quote

Old   May 22, 2014, 11:10
Default
  #7
Member
 
Niu
Join Date: Apr 2014
Posts: 42
Rep Power: 3
Z.Q. Niu is on a distinguished road
Dear Julien,
I'm so sorry for my bad explanation for my queation. In my works, I need to simulate transient procesure of channel1 and channel2 separately. the outlet velocity of channel1 at every time step is mapped to inlet of channel2 via TimeVaryingMappedFixedValue bc. the case of channel1 at least has thousands of timesteps, which means I must add foam header to thousands of U profiles. This is a huge work! How do you deal it? Would you mind sharing your case with me? Thank you very much!

Best regards!

Z.Q. Niu
Z.Q. Niu is offline   Reply With Quote

Old   May 23, 2014, 09:36
Default
  #8
Senior Member
 
Julien
Join Date: Jun 2012
Location: France
Posts: 153
Rep Power: 5
Djub is on a distinguished road
Eh eh... Yes you're right, this is a huge work done by hand. This is why I wrote:
Quote:
But a simple program (in Octave for instance) can deal with this and rearrange it in order to fit with timeVaryingMappedFixedValue . (Be careful! With this interpolation, the geometry needed by timeVaryingMappedFixedValue is "faceCenters" . And you have also to insert the Foam header in each file).
Recently, I tried to "translate" this Octave program into Bash, and it looks like this:
Code:
#!/bin/sh
mkdir inlet_ready
cd ouput_from_first_calculation
first_dir=`ls | head -1`
cd $first_dir/name_of_mapping
cp faceCentres ../../../inlet_ready
cd ../../../inlet_ready
mv faceCentres points
sed -i '1cFoamFile{version 2.0; format ascii; class vectorField; object points;}' points
cd ../output_from_first_calculation
all_dir=`ls | wc -l`
for rep in *
 do
	mkdir ../inlet_ready/$rep

	cp $rep/name_of_mapping/vectorField/U ../inlet_ready/$rep
	sed -i '1cFoamFile{version 2.0; format ascii; class vectorAverageField; object values;} (0 0 0)' ../inlet_ready/$rep/U

	cp $rep/name_of_mapping/scalarField/p ../inlet_ready/$rep
	sed -i '1cFoamFile{version 2.0; format ascii; class scalarAverageField; object values;} 0' ../inlet_ready/$rep/p

... (etc... all the fields you need) ...
    
 done
But actually, I did not try this on the distant machine I am running... By the way, I only used "cp" so this is not destructive!

'hope this can help
Djub is offline   Reply With Quote

Old   May 28, 2014, 13:16
Default
  #9
Member
 
Niu
Join Date: Apr 2014
Posts: 42
Rep Power: 3
Z.Q. Niu is on a distinguished road
Dear Julien,
Thank your sharing your code very much! I has tried to use this bash, but I have some confusion about the path of dictionary in this code, would you mind attaching a completed bash ?

Best regards!

Z.Q. Niu
Z.Q. Niu is offline   Reply With Quote

Old   May 30, 2014, 10:32
Default
  #10
Senior Member
 
Julien
Join Date: Jun 2012
Location: France
Posts: 153
Rep Power: 5
Djub is on a distinguished road
OK. Let's be a bit more precise. First, I ran a first computation (precursor), with an "auto export" of the field in my controlDict:
Code:
functions
{
    output_from_first_calculation {
        type 				surfaces;
        enabled         		true;
        outputControl   		timeStep;	
        outputInterval  		1;
        interpolationScheme 	cell;
        surfaceFormat 		foamFile;
        fields 				( p U ); //all your needed fields
        surfaces (
            name_of_mapping {
                type            patch;
                patches         ( the_outlet );
                interpolate     false;
                triangulate     false;
            }
        );
    }
}
Note: you have to find your correct settings, making all coherent between 1/ the interpolation (here false) 2/ eventually your interpolation scheme (no interest here because no interpolation) and 3/ the geometry file (here faceCentres renamed as points )

In your case, at the same place as your system and constant folders, FOAM will create a folder named ouput_from_first_calculation. This folder will contain a huge number of folders, each one with its timestamp as name. Each one of these folders will contain a unique folder named name_of_mapping. This folder will contain some geometry files (faceCenters, faces and points), and two folders or more (depending on what you asked for) (scalarField and vectorField). These two last folders will contain the fields themselves, named p, U, etc...

My batch is supposed to be located at the top of your case, in the same place as system and constant.

If this is not detailed enough, please ask specific questions.

Regards
Djub is offline   Reply With Quote

Reply

Tags
confusing, inlet, interplation, mappedfixedvalue, timevarying

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
Interpolation Error on FAM Mesh with Cyclic BCs ngj OpenFOAM Bugs 1 August 9, 2011 06:12
urgent help needed (rhie-chow interpolation problem) Ardalan Main CFD Forum 2 March 18, 2011 16:22
Help on 2D interpolation in StarCCM+ madhuri CD-adapco 0 November 3, 2010 15:21
Surface interpolation schemes and parallelization jutta OpenFOAM Running, Solving & CFD 0 February 25, 2010 15:32
momentum interpolation for collocated grid Hadian Main CFD Forum 4 December 25, 2009 08:25


All times are GMT -4. The time now is 11:55.