reading data from a text file

Submitted by evansmuts on Mon, 05/09/2011 - 11:14

Hi

I want to read in values from a text file so that I can control the speed of a rotational boundary condition that I have created (similar to conveyor - covered in another post). I want to read in two columns of numbers and assign each one to an array. This way I can calculate the speed based on the solution time. What would be the best (i.e. simplest and efficient) way of doing it?

I am aware of the read_data function, but this seems far too complex for what I need. Would it be best to trim it down for my purposes? I see that it has lots of MPI commands. Would I need these for running in parallel?

Alternatively, would I be able to use "standard" C++ commands for reading in text files in LIGGGHTS?

Regards

Evan

ckloss's picture

ckloss | Mon, 05/09/2011 - 13:34

Hi Evan,

there are multiple options to do this.

You can look at fix mesh gran, how meshes are read from STL files.

But of course, to start, using standard C/C++ commands to read from a file would be the best idea. But we aware that if you want to run in parallel, make sure that only proc 0 reads from the file and then bcasts the content.

Christoph