CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Add a scalarField type to the templated DataEntry class (http://www.cfd-online.com/Forums/openfoam-programming-development/114779-add-scalarfield-type-templated-dataentry-class.html)

carowjp March 17, 2013 17:52

Add a scalarField type to the templated DataEntry class
 
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

manju819 March 20, 2014 07:20

Hiii carowjp
 
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


All times are GMT -4. The time now is 21:48.