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

How to read .dat files into OpenFOAM

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

Like Tree2Likes
  • 2 Post By manju819

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 26, 2014, 11:38
Default How to read .dat files into OpenFOAM
  #1
Member
 
Manjunath Reddy
Join Date: Jun 2013
Posts: 47
Rep Power: 12
manju819 is on a distinguished road
Hiiii,
I want to read data file like .dat into solver and interpolate
for example

SGAS KRG PCOG
0 0 0
0.02 0 0
0.05 0.005 0
0.12 0.025 0
0.2 0.075 0
0.25 0.125 0
0.3 0.19 0
0.4 0.41 0

On searching i found In interFOAM solver reading of data file is there but it is commented
that is

interpolationTable<vector> timeSeriesAcceleration
(
runTime.path()/runTime.caseConstant()/"acceleration.dat"
);

i want to know what is the format of "acceleration.dat".

Thanks & Regards
N.Manjunath,
M-Tech,
IIT Guwahati
manju819 is offline   Reply With Quote

Old   March 1, 2014, 08:56
Default
  #2
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings Manjunath,

It really depends on the objective on what to do with the loaded data. Is it for:
  1. Using in a function object?
  2. Using in a boundary condition?
  3. For post-processing?
  4. For implementing in a custom (modified) solver?
Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   March 1, 2014, 10:46
Default Hiiii wyldckat
  #3
Member
 
Manjunath Reddy
Join Date: Jun 2013
Posts: 47
Rep Power: 12
manju819 is on a distinguished road
Thank you for your reply.


Where KRG = f(SGAS) . I want to interpolate the KRG & SGAS and then use it in my equation.
That is coefficient of 'sw'

volScalarField KRG = f(SGAS) ;

- fvm::ddt(KRG,sw)
==
fvc::laplacian(phik*phiM_o,p)
- fvc::laplacian(KRG*phik*rho_o,gh)
- fvc::Sp(J*n*KRG,p)
+ fvc::Sp(J*n*KRG,pbh)


Thanks & Regards
N.Manjunath Reddy
manju819 is offline   Reply With Quote

Old   March 1, 2014, 11:16
Default
  #4
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
If I'm not mistaken, for the file extension ".dat", OpenFOAM will use it's own data formatting convention. Therefore, for a vector, it should be:
Code:
#SGAS   KRG   PCOG 
(0       0       0)
(0.02  0       0)
(0.05  0.005   0)
(0.12  0.025   0)
(0.2    0.075   0)
(0.25  0.125   0)
(0.3    0.19    0)
(0.4    0.41    0)
Mmm... but the problem is that we're dealing with a time based interpolation table and you're asking for a vector table, where the first column is time, so I think it should be:
Code:
#SGAS   KRG   PCOG 
(0       (0       0))
(0.02  (0       0))
(0.05  (0.005   0))
(0.12  (0.025   0))
(0.2    (0.075   0))
(0.25 ( 0.125   0))
(0.3    (0.19    0))
(0.4    (0.41    0))
Or:
Code:
#SGAS   KRG   PCOG 
0       (0       0)
0.02  (0       0)
0.05  (0.005   0)
0.12  (0.025   0)
0.2    (0.075   0)
0.25 ( 0.125   0)
0.3    (0.19    0)
0.4    (0.41    0)
wyldckat is offline   Reply With Quote

Old   March 4, 2014, 05:11
Default Hiiii wyldckat
  #5
Member
 
Manjunath Reddy
Join Date: Jun 2013
Posts: 47
Rep Power: 12
manju819 is on a distinguished road
Thank you so much for your reply.

As you told i wrote the .dat file in vector form while reading
OpenFOAM shown this error

--> FOAM FATAL IO ERROR:
incorrect first token, expected <int> or '(', found on line 1 the word '#SGAS'

file: /home/manjunath/OpenFOAM/manjunath-2.2.2/run/tutorials/basic/laplacianFoam/flange/constant/acceleration.dat at line 1.

From function operator>>(Istream&, List<T>&)
in file /opt/openfoam222/src/OpenFOAM/lnInclude/ListIO.C at line 149.


i used laplacianFoam as sample code too run this


Thanks &Regards
N.Manjunath
manju819 is offline   Reply With Quote

Old   March 4, 2014, 05:37
Default
  #6
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Quote:
Originally Posted by manju819 View Post
--> FOAM FATAL IO ERROR:
incorrect first token, expected <int> or '(', found on line 1 the word '#SGAS'
Maybe you should also use OpenFOAM syntax for comments? I.e. // instead of #
alexeym is offline   Reply With Quote

Old   March 4, 2014, 06:09
Default
  #7
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Mmm... Try this:
Code:
//SGAS   KRG   PCOG 
(
(0       0       0)
(0.02  0       0)
(0.05  0.005   0)
(0.12  0.025   0)
(0.2    0.075   0)
(0.25  0.125   0)
(0.3    0.19    0)
(0.4    0.41    0)
)
wyldckat is offline   Reply With Quote

Old   April 9, 2014, 21:07
Default
  #8
Member
 
Ripudaman Manchanda
Join Date: May 2013
Posts: 55
Rep Power: 12
ripudaman is on a distinguished road
I have a similar issue where I am trying to import a set of X-Y values. I want to run some explicit calculation in my solver using this field of values. One such implementation is going to be calculating the minimum distance of the XY vaues imported to a chosen point in the Openfoam mesh.

I am stuck at the first step though. I am unable to import the file in my code.

Here is the data I am trying to import:
Quote:
(
(-152.4 -91.44)
(-152.4 91.44)
)
Here is the error message i get:
Code:
--> FOAM FATAL ERROR: 
out-of-order value: -152.4 at index 1


    From function Foam::interpolationTable<Type>::checkOrder() const
    in file /opt/OpenFOAM/OpenFOAM-2.3.x/src/OpenFOAM/lnInclude/interpolationTable.C at line 226.

FOAM exiting
and here is my code snippet :
Code:
interpolationTable<scalar> previousFracTraj(previousFrac);
Can you guide me please?

Thanks.
Ripu
ripudaman is offline   Reply With Quote

Old   April 10, 2014, 01:59
Default Hi Ripudaman
  #9
Member
 
Manjunath Reddy
Join Date: Jun 2013
Posts: 47
Rep Power: 12
manju819 is on a distinguished road
I overcome d the problem by reading individual X and Y data like given below....



If you want to read the scalarField
create a data file which has a scalarFields
Ex: file name PVTdata

which has a scalarField X

/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.2.2 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

X
(
9.342894e-02
4.567101e-02
3.013131e-02
2.219316e-02
1.746954e-02
1.427184e-02
1.205589e-02
1.041777e-02
9.144300e-03
8.184990e-03
7.393980e-03
6.737610e-03
6.221490e-03
5.789520e-03
5.452920e-03
5.172420e-03
4.925580e-03
4.712400e-03
4.532880e-03
4.370190e-03
);

and you can read this Field in create fields

using a IOdict

IOdictionary PVTdata
(
IOobject
(
"PVTdata",
runTime.constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
);


scalarField X
(
PVTdata.lookup("X")
);
similarly for Y


Regards
Manjunath
Alish1984 and kanchajiaxie like this.
manju819 is offline   Reply With Quote

Old   April 10, 2014, 02:19
Default
  #10
Member
 
Ripudaman Manchanda
Join Date: May 2013
Posts: 55
Rep Power: 12
ripudaman is on a distinguished road
Thanks this is very helpful.
ripudaman is offline   Reply With Quote

Old   April 10, 2014, 04:30
Default
  #11
Member
 
Manjunath Reddy
Join Date: Jun 2013
Posts: 47
Rep Power: 12
manju819 is on a distinguished road
If you have Swak4foam in that " wobbler " case consist similar type of file importing as you mentioned in the previous post....
manju819 is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[CAD formats] Importing mesh files to OpenFOAM: is obj format viable? sudo OpenFOAM Meshing & Mesh Conversion 3 March 5, 2014 06:14
999999 (../../src/mpsystem.c@1123):mpt_read: failed:errno = 11 UDS_rambler FLUENT 2 November 22, 2011 10:46
Cross-compiling OpenFOAM 1.7.0 on Linux for Windows 32 and 64bits with Mingw-w64 wyldckat OpenFOAM Announcements from Other Sources 3 September 8, 2010 07:25
Modified OpenFOAM Forum Structure and New Mailing-List pete Site News & Announcements 0 June 29, 2009 06:56
Results saving in CFD hawk Main CFD Forum 16 July 21, 2005 21:51


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