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/)
-   -   Add value to a Foam::volScalarField list (https://www.cfd-online.com/Forums/openfoam-programming-development/145737-add-value-foam-volscalarfield-list.html)

PicklER December 11, 2014 05:35

Add value to a Foam::volScalarField list
 
Hello

Is it possible to add a new value to an existing Foam::volScalarField nonuniform List<scalar>?

I have seen that a push_back() member exists for vectors in C++, but have not found a similiar member for volScalarField and I'm looking for something similar. If this is not possible, I will have to rewrite the variable in question file for each time step, but this is computationally expensive.

For example:
Pressure is created in createFields.H and is
Code:

p: dimensions      [1 -1 -2 0 0 0 0];

internalField  nonuniform List<scalar>
32
(
10006.5
10010.5
10010.5
10009.3
10010.5
10012.3
10012.3
10012.3
10010.5
10012.3
10012.3
10012.3
10006.5
10010.5
10010.5
10009.3
99775.3
99545.7
99545.7
99676.7
99545.7
99419.7
99419.7
99469.8
99545.7
99419.7
99419.7
99469.8
99775.3
99545.7
99545.7
99676.7
)
;

boundaryField
{
    grain
    {
        type            zeroGradient;
    }
    walls
    {
        type            zeroGradient;
    }
    defaultFaces
    {
        type            empty;
    }
}

So this pressure list contains 32 entries for the internal field. Is it possible to add to this, in order for it to have 36 entries. I am aware the the number of entries will not match that of the number of cells, but still need to know this.

Thanks in advance

alexeym December 11, 2014 05:55

Hi,

there's append method inherited from List class.

PicklER December 11, 2014 06:12

Thank you Alexey

Just something else out of curiosity. Have you seen anyone adding cells in a solver to the blockMesh. I am able to add new cells now in my solver, so now I just need to set the new cell variables.

Hopefully it will not end up in total disaster.

alexeym December 11, 2014 07:14

Hi,

Yes, I've seen several people. Though they were adding cells to dynamicFvMesh not to blockMesh.


All times are GMT -4. The time now is 11:31.