CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   To create a species name file for chemFoam (https://www.cfd-online.com/Forums/openfoam-programming-development/95320-create-species-name-file-chemfoam.html)

ayhan515 December 13, 2011 11: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 07: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 19:04.