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

Add a scalarField type to the templated DataEntry class

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By manju819

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 17, 2013, 16:52
Default Add a scalarField type to the templated DataEntry class
  #1
Member
 
carowjp's Avatar
 
Jim Carow
Join Date: Apr 2010
Location: Michigan, USA
Posts: 41
Rep Power: 16
carowjp is on a distinguished road
Hello,

I would like to add a scalarField type to the DataEntry class such that an arbitrary number of scalars could be read in from CSV file. As it stands you can only get 1, 3, or 9 values in using scalar, vector, and tensor types. See code in /src/OpenFOAM/primitives/functions/DataEntry.

I wrote specializations for the scalarField nCSV<scalarField>::readValue and void Foam::nCSV<scalarField>::read() functions to allow specifying the start column and number of columns to read in from CSV.

The problem I facing at compile is that the scalarField, Foam:: pTraits<Foam::Field<double> >, does not have members 'nComponents' or 'zero', which of course the scalar, vector, and tensor types do.

Can anyone please give me some direction on how to fix this? I don't want to resort to using a VectorN type just to read data from file.

thanks,

Jim
carowjp is offline   Reply With Quote

Old   March 20, 2014, 06:20
Default Hiii carowjp
  #2
Member
 
Manjunath Reddy
Join Date: Jun 2013
Posts: 47
Rep Power: 13
manju819 is on a distinguished road
If you want to read the scalarField
create a data file which has a scalarFields
Ex: file name PVTdata

which has a scalarField Bg

/*--------------------------------*- 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;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

Bg
(
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 Bg
(
PVTdata.lookup("Bg")
);

I'm also tried to read data from CSV file but i dint get and I followed this. Hope this will help you

Regards
Manjunath
Bana likes this.
manju819 is offline   Reply With Quote

Old   May 24, 2016, 15:30
Default
  #3
Senior Member
 
Mahdi Hosseinali
Join Date: Apr 2009
Location: NB, Canada
Posts: 273
Rep Power: 18
anishtain4 is on a distinguished road
If you want to read data from csv files use c++ approach. csv files are like text
anishtain4 is offline   Reply With Quote

Reply

Tags
csv files, dataentry, template errors


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
[CGNS] CGNS converters available mbeaudoin OpenFOAM Meshing & Mesh Conversion 137 December 14, 2018 05:20
[Commercial meshers] Mesh conversion problem (fluent3DMeshToFoam) Aadhavan OpenFOAM Meshing & Mesh Conversion 2 March 8, 2018 02:47
turbulent jet simulation antonio_ing OpenFOAM Running, Solving & CFD 5 September 16, 2010 03:31
pipe flow with heat transfer Fabian OpenFOAM 2 December 12, 2009 05:53
Errors running allwmake in OpenFOAM141dev with WM_COMPILE_OPTION%3ddebug unoder OpenFOAM Installation 11 January 30, 2008 21:30


All times are GMT -4. The time now is 09:52.