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/)
-   -   To create a species name file for chemFoam (http://www.cfd-online.com/Forums/openfoam-programming-development/95320-create-species-name-file-chemfoam.html)

ayhan515 December 13, 2011 12:49

To create a species name file for chemFoam
 
Dear Foamers,
i would like to create a a species name file for chemFoam
I put the codes below to createFields.H and it s ok it is working.

But i want to write all species name not first 4, so i need a variable to determine "number of species"

the problem is
how can i use nSpecie_ or nSpecie () or something like that.

Thanks in advance.

Code:

int speciesname;
    for (int speciesname=0; speciesname<=3; speciesname++)
    {
#include <iostream>
using namespace std;
fileName myDir = args.path();
word tracingFileName="speciesname.dat";
fileName myFile = myDir/tracingFileName;
std:: ofstream myStream(myFile.c_str(),ios_base::app);
myStream

<< Y[speciesname].name() << endl;

    }


Hagen April 11, 2012 10:35

Did you try Y.size() instead of a fixed value? This should give you the number of species.
Best, Hagen

ayhan515 January 24, 2014 08:49

Quote:

Originally Posted by Hagen (Post 354191)
Did you try Y.size() instead of a fixed value? This should give you the number of species.
Best, Hagen

Thank you for Y.size()
Code:

int speciesname;
//    for (int speciesname=0; speciesname<=3; speciesname++)
    for (int speciesname=0; speciesname<=Y.size(); speciesname++)
    {



All times are GMT -4. The time now is 16:01.