CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Read gravity data varying with time (https://www.cfd-online.com/Forums/openfoam-programming-development/166134-read-gravity-data-varying-time.html)

shipman February 3, 2016 04:35

Read gravity data varying with time
 
Dear Foam users,

I would like to read the gravity values varying with time from a dataFile located in constant folder. As much as I searched, there is a close post here: http://www.cfd-online.com/Forums/ope...ty-time-2.html

In this post, iinterpolationTable<vector> is recommended which can be only used when the gravity values increase. However, I have random value depending on the time such as:
4
(
(0 (10 -5 0))
(0.1 (2 4 0))
(0.2 (-6 1.31 0))
(0.3 (21 0 0))
...
)

Is there anyone let me know how to read these gravity data varying with time.

Thank you in advance.

Mehrez February 3, 2016 09:49

Hi
Try to use the swak4Foam toolkit.
Mehrez

shipman February 4, 2016 19:09

Quote:

Originally Posted by Mehrez (Post 583563)
Hi
Try to use the swak4Foam toolkit.
Mehrez

Hi Mehrez,

Thank you very much for your reply. Actually, after looking at the interpolationTable code I found how to read the gravitation data from .dat file as follows:

Code:

interpolationTable<vector> Acc
(
    runTime.path()/runTime.caseConstant()/".dat"
);
  g.value()= Acc.(runTime.value());

If the .dat file is same with the time step (for example deltaT= 1)
4
(
(1 (1 5 4))
(2 (2 4 8))
...

above code works well. My another question is if my time step is 0.5 how can i make interpolation between these values given in .dat file.

Any advice will be appreciated.

Thank you

________
Moderator note: The following was also asked via PM:
Quote:

Originally Posted by shipman
As an addition to above question, I used interFoam and I would like to get the water height vs time. Do you think that is it possible?


wyldckat February 21, 2016 15:57

Quick answers @Baris: Sorry, I'm out of time for today and a bit grumpy/hungry, but nonetheless here goes:
  1. You should have stated which OpenFOAM or foam-extend version you're using! :rolleyes:
  2. You should have provided code that I could test with, along with a test case :(
  3. Instead of using the interpolation table, use "DataEntry": http://www.cfd-online.com/Forums/ope...tablefile.html
  4. Quote:

    Originally Posted by shipman
    As an addition to above question, I used interFoam and I would like to get the water height vs time. Do you think that is it possible?

    Sorry, but the question is too vague :( I need a lot more details, context and what exactly you're trying to "get". Either way, it's probably possible, I guess :confused:

federicabi June 9, 2016 04:58

Quote:

Originally Posted by shipman (Post 583777)
Hi Mehrez,

Thank you very much for your reply. Actually, after looking at the interpolationTable code I found how to read the gravitation data from .dat file as follows:

Code:

interpolationTable<vector> Acc
(
    runTime.path()/runTime.caseConstant()/".dat"
);
  g.value()= Acc.(runTime.value());

If the .dat file is same with the time step (for example deltaT= 1)
4
(
(1 (1 5 4))
(2 (2 4 8))
...

above code works well. My another question is if my time step is 0.5 how can i make interpolation between these values given in .dat file.

Any advice will be appreciated.

Thank you

________
Moderator note: The following was also asked via PM:


Hi Baris, hi Foamers
do you know how to apply the interpolationTable code to read the forces.dat file, that is updated every timestep, in run time?

Thanks in advice.

Federica


All times are GMT -4. The time now is 18:31.