CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   Accessing Velocity Components (

anfho June 30, 2011 17:47

Accessing Velocity Components
Dear All,

How can I access the components of volVecorField U ?

Meaning: u, v, w component.

Thanks for the help.

anfho June 30, 2011 19:21

I've been doing trial and error for a while, but at the end it wasn't as complicated as I thought, if I do:


      double lesCllCtrDomSze  = U.size();
      double ules[lesCllCtrDomSze];
      double vles[lesCllCtrDomSze];
      double wles[lesCllCtrDomSze];
      OFstream uvw_velocities ( "uvw_velocities" );
      for(int i=0; i<lesCllCtrDomSze; i++)
        Vector<double> Uvector = U[i];
        ules[i] = Uvector.x();
        vles[i] = Uvector.y();
        wles[i] = Uvector.z();

        uvw_velocities <<ules[i]<<", " <<vles[i]<<", " <<wles[i] <<endl;

everything works perfectly fine.

This link was helpful:

All times are GMT -4. The time now is 18:36.