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/)
-   -   Make full copy of a volScalarField (https://www.cfd-online.com/Forums/openfoam-programming-development/247017-make-full-copy-volscalarfield.html)

kilimanjaro2 January 9, 2023 04:13

Make full copy of a volScalarField
 
Hello to all,

I have a field, say:

Code:

volScalarField field1
(
    IOobject
    (
        "field1",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ,
        IOobject::AUTO_WRITE
    ),
    mesh
);

and another:

Code:

volScalarField field2
(
    IOobject
    (
        "field2",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ,
        IOobject::AUTO_WRITE
    ),
    mesh,
    dimensionedScalar(dimless, Zero)
);

I am performing some computations with field2 e.g:

field2 = field2 + 20;

Now, I would like that field1 be a copy of field2 down to the boundary conditions and values.

How can I achieve this?


All times are GMT -4. The time now is 15:44.