CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   transforming a function defined on mesh().points() into a pointScalarField (http://www.cfd-online.com/Forums/openfoam-programming-development/63029-transforming-function-defined-mesh-points-into-pointscalarfield.html)

virginie_e March 26, 2009 07:49

transforming a function defined on mesh().points() into a pointScalarField
 
Hello Foamers,

I am new to programming in OpenFOAM and I have created a function which is gives a certain value for each of the points of the mesh (mesh().points()) and I would to transform it in a pointScalarField so that I could see the values of the function with paraview. How would you advise me to do that?

Thank you.

Virginie

deepsterblue March 26, 2009 10:27

Virginie,

Perhaps this would be helpful:

Code:


#include "pointMesh.H"
#include "pointFields.H"
#include "fixedValuePointPatchFields.H"

        // Instantiate a pointMesh object
        pointMesh pMesh(mesh);

        pointScalarField pValues
        (
            IOobject
            (
                "pValues",
                runTime.timeName(),
                mesh,
                IOobject::NO_READ,
                IOobject::AUTO_WRITE
            ),
            pMesh,
            dimensionedVector("scalar", dimless, 0.0),
            "zeroGradient"
        );

        pValues.internalField() = myPointField;
   
        pValues.write();

where myPointField is a field that is points-big.

Cheers,
Sandeep

deepsterblue March 26, 2009 10:29

Sorry... Cut'n'Paste error:

dimensionedVector("scalar", dimless, 0.0)

should be
dimensionedScalar("scalar", dimless, 0.0)

Cheers,
Sandeep


virginie_e March 26, 2009 11:13

Thank you a lot Sandeep.
It works perfectly fine.

Virginie

wendywu March 31, 2009 10:30

How to begin with OpenFOAM?
 
Hi,

I am a beginner, I am going to read OpenFOAM code and modify it for purpose of simulating aluminum extrusion. I think maybe OpenFOAM can mesh complex geometry already, but I didn't try. So I think the first step is to modify the constitutive model. When I read the code, there are so many files. I think I should understand the whole structure of the software.But it is so big. So where can I start with? Anybody can give me some advice?

Wendy


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