CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   how to rename a field defined from others fields ? (https://www.cfd-online.com/Forums/openfoam-programming-development/100434-how-rename-field-defined-others-fields.html)

Cyp April 25, 2012 09:34

how to rename a field defined from others fields ?
 
Hi!

I defined a symmetric tensor field symGradU from a field U
Code:

volSymmTensorField symGradU = twoSymm(fvc::grad(U));
When I plot the field name using
Code:

Info << "Field symGradU name = " << symGradU.name() << endl;
I get
Field symGradU name = twoSymm(grad(U))

I want to change this name ("symGradU"), in particular to write the output correctly. I tried
Code:

symGradU.name() = "symGradU" ;
but it doesn't work.

Do you know a simple manner to rename a field ??

Regards,
Cyp

marupio April 26, 2012 10:50

You can do it during construction, (though it must be possible to do it afterwards too...). From GeometricField.H:

Code:

        //- Construct as copy resetting IO parameters
        GeometricField
        (
            const IOobject&,
            const GeometricField<Type, PatchField, GeoMesh>&
        );

        //- Construct as copy resetting name
        GeometricField
        (
            const word& newName,
            const GeometricField<Type, PatchField, GeoMesh>&
        );

So you could use:

Code:

    volSymmTensorField symGradU
    (
        "symmGradU",
        twoSymm(fvc::grad(U))
    );


Cyp April 26, 2012 11:32

Thank you very much ! It is exactly what I was looking for !


All times are GMT -4. The time now is 06:16.