CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   reading in a string (

sripplinger August 3, 2009 18:06

reading in a string
I'm in the middle of writing some code for colloidal particle transport based on the solidParticle class. I would like to be able to read in the name of the model I want to use. For instance, in the particleProperties file I am trying to add a vdwModel variable which is read in as a string ("Gregory" or "SchenkelKitchener"). This would then be used later in the code to specify which force model I want to use.

My question is exactly how do I read in a string? Something along the lines of readScalar is what I'm looking for, but if I need to rethink how I'm doing this, then I'll listen to any suggestions you have.

l_r_mcglashan August 4, 2009 05:36

I assume you're familiar with something like this:

scalar variable = readScalar(dictionary.lookup("variableName"));

Well you can have:

word variable = word(dictionary.lookup("variableName"));

sripplinger August 4, 2009 11:28

Yes! I think that is exactly what I am looking for. I'll give it a go and see if it works for me.

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