|
[Sponsors] |
Add a scalarField type to the templated DataEntry class |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 17, 2013, 16:52 |
Add a scalarField type to the templated DataEntry class
|
#1 |
Member
Jim Carow
Join Date: Apr 2010
Location: Michigan, USA
Posts: 41
Rep Power: 16 |
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 |
|
March 20, 2014, 06:20 |
Hiii carowjp
|
#2 |
Member
Manjunath Reddy
Join Date: Jun 2013
Posts: 47
Rep Power: 13 |
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 |
|
May 24, 2016, 15:30 |
|
#3 |
Senior Member
Mahdi Hosseinali
Join Date: Apr 2009
Location: NB, Canada
Posts: 273
Rep Power: 18 |
If you want to read data from csv files use c++ approach. csv files are like text
|
|
Tags |
csv files, dataentry, template errors |
|
|
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 |