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

Add a scalarField type to the templated DataEntry class

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

Reply
 
LinkBack Thread Tools 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: 40
Rep Power: 7
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: 37
Rep Power: 4
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
manju819 is offline   Reply With Quote

Reply

Tags
csv files, dataentry, template errors

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
CGNS converters available mbeaudoin OpenFOAM Meshing & Mesh Conversion 125 July 1, 2015 21:09
Mesh conversion problem (fluent3DMeshToFoam) Aadhavan OpenFOAM Other Meshers: ICEM, Star, Ansys, Pointwise, GridPro, Ansa, ... 1 December 12, 2012 11:38
turbulent jet simulation antonio_ing OpenFOAM Running, Solving & CFD 5 September 16, 2010 02: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 11:41.