CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (https://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   Field interpolation in mesh points code (https://www.cfd-online.com/Forums/openfoam-post-processing/61463-field-interpolation-mesh-points-code.html)

jzlam January 16, 2006 08:21

I calculated field U and I nee
 
I calculated field U and I need Ux,Uy,Uz in each point of mesh (together with mesh coordinates) like
1 x y z Ux Uy Uz
2 x y z Ux Uy Uz

to be able to import field to my program.

Can anyone give me code to do this? I am not succesfull to do it myself and I am little bit confused from C++ because I am programming in FORTRAN.

Thank for any advice

Jakub Zlamal

nlc December 14, 2010 16:42

ave you tried something like this !

Code:

int main(int argc, char *argv[])
{

# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
# include "createFields.H"

  // Read  U field
  Info<< "Reading U field \n" << endl;
    volVectorField U
    (
        IOobject
        (
            "U",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );

  pointField C = mesh.C()
 
  forAll(cell,U)
  {
  Info <<  C[cell] << U[Cell] << endl;
  }

  return(0);
}


nlc December 14, 2010 16:48

or
Code:

  forAll(cell,U)
  {
  Info <<  cell
        <<  C[cell].x()
        <<  C[cell].y()
        <<  C[cell].z()
        << U[cell].x()
        << U[cell].y()
        << U[cell].z()
        << endl;
  }

Regards


All times are GMT -4. The time now is 19:07.