CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   problem with speciesTable constructor (https://www.cfd-online.com/Forums/openfoam/81559-problem-speciestable-constructor.html)

Hrushi October 30, 2010 09:03

problem with speciesTable constructor
 
I am trying to create table of species from the wordList defined in one of the dictionary.

Here is my code:

Info<< nl << "Reading thermophysicalProperties" << endl;

PtrList<volScalarField> Y(3);

IOdictionary speciesProperties
(
IOobject
(
"speciesProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);


wordList speciesName
(
speciesProperties.lookup("speciesNames")
);

speciesTable speciesTable s(wordList speciesName);

dimensionedScalar source_r
(
speciesProperties.lookup("source_r")
);



word inertSpecie(speciesProperties.lookup("inertSpecie" ));

Info << "Reading field p\n" << endl;
volScalarField p
(
IOobject
(
"p",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);

Info << "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);

# include "createPhi.H"


label pRefCell = 0;
scalar pRefValue = 0.0;
setRefCell(p, mesh.solutionDict().subDict("SIMPLE"), pRefCell, pRefValue);


singlePhaseTransportModel laminarTransport(U, phi);

autoPtr<incompressible::RASModel> turbulence
(
incompressible::RASModel::New(U, phi, laminarTransport)
);


The compilation error with speciesTable constructor is:

createFields.H: In function 'int main(int, char**)':
createFields.H:23: error: 'speciesTable' was not declared in this scope
createFields.H:23: error: expected `;' before 'speciesTable'
/export/apps/OpenFOAM/OpenFOAM-1.6/src/finiteVolume/lnInclude/readSIMPLEControls.H:6: warning: unused variable 'momentumPredictor'
/export/apps/OpenFOAM/OpenFOAM-1.6/src/finiteVolume/lnInclude/readSIMPLEControls.H:9: warning: unused variable 'fluxGradp'
/export/apps/OpenFOAM/OpenFOAM-1.6/src/finiteVolume/lnInclude/readSIMPLEControls.H:12: warning: unused variable 'transonic'
make: *** [Make/linux64GccDPOpt/simpleMyFoam.o] Error 1

Any suggestions, please?

Hrushikesh

mturcios777 October 30, 2010 13:30

Hi Hrushikesh,

It seems to me that the problem lies in this line:

Code:

speciesTable speciesTable s(wordList speciesName);
I think the line should be

Code:

speciesTable s(speciesName);
My guess is that you want to declare a speciesTable variable names "s", so all you need is the type and a constructor. Also, as you have already declared speciesName as a wordList, so you just need to pass the variable to the constructor.

Hrushi October 31, 2010 23:11

speciesTable constructor
 
Hi Marco,

I changed the line you have suggested. But the compiler throws up the same error again.

I checked speciesTable.C again. Below is the constructor.

// Construct from list of specie names
Foam::speciesTable::speciesTable(const wordList& specieNames)
:
wordList(specieNames)
{
setIndices();
}

I am now confused what to do? I don't understand the error
createFields.H:23: error: 'speciesTable' was not declared in this scope

Hrushikesh

olesen November 1, 2010 05:07

Quote:

Originally Posted by Hrushi (Post 281591)
Hi Marco,

I changed the line you have suggested. But the compiler throws up the same error again.

I checked speciesTable.C again. Below is the constructor.

// Construct from list of specie names
Foam::speciesTable::speciesTable(const wordList& specieNames)
:
wordList(specieNames)
{
setIndices();
}

I am now confused what to do? I don't understand the error
createFields.H:23: error: 'speciesTable' was not declared in this scope

Hrushikesh


Perhaps it is just something quite banal - like a missing include?

In the Make/options:
Code:

  -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude
In your code:
Code:

    #include "speciesTable.H"
/mark

Hrushi November 1, 2010 06:34

Quote:

Originally Posted by olesen (Post 281622)
Perhaps it is just something quite banal - like a missing include?

In the Make/options:
Code:

  -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude
In your code:
Code:

    #include "speciesTable.H"
/mark

Hi,

I have included the above suggestions. The error message is the same.
Here is the error message:

In file included from simpleMyFoam.C:44:
createFields.H:1:26: error: speciesTable.H: No such file or directory
In file included from simpleMyFoam.C:44:
createFields.H: In function 'int main(int, char**)':
createFields.H:25: error: 'speciesTable' was not declared in this scope
createFields.H:25: error: expected `;' before 'species'
/export/apps/OpenFOAM/OpenFOAM-1.6/src/finiteVolume/lnInclude/readSIMPLEControls.H:6: warning: unused variable 'momentumPredictor'
/export/apps/OpenFOAM/OpenFOAM-1.6/src/finiteVolume/lnInclude/readSIMPLEControls.H:9: warning: unused variable 'fluxGradp'
/export/apps/OpenFOAM/OpenFOAM-1.6/src/finiteVolume/lnInclude/readSIMPLEControls.H:12: warning: unused variable 'transonic'
make: *** [Make/linux64GccDPOpt/simpleMyFoam.o] Error 1

Line no 44 in simpleMyFoam is createFields.H line


Hrushikesh

herbert November 1, 2010 07:25

Hi Hrushikesh,
I think you have to insert the #include inside the header of your code, i.e. before
Code:

int main(int argc, char *argv[])
instead of inseting it inside createFields.H.

Regards,
Stefan

Hrushi November 2, 2010 07:31

speciesTable constructor
 
Hi Stefan/Mark/Marco,

Thanks for your help. The problem is solved now.

Thanks:):D

Hrushi


All times are GMT -4. The time now is 06:53.