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/)
-   -   An array to store scalar value at every time step (https://www.cfd-online.com/Forums/openfoam-programming-development/247559-array-store-scalar-value-every-time-step.html)

Parth1999 February 12, 2023 03:09

An array to store scalar value at every time step
 
Hi
i am new to OpenFOAM
i am trying to compile a solver, in which i need to store the the instantaneous
calculated variable (scalar) to array for every time step

I mean
CF_spatial = gsum(V_ecs)/gsum(por)
V_ecs and por are time dependent field variables, but CF_spatial is calculated at every time step and is a scalar value and it is not a field variable, i want to create an array where i can store CF_spatial value at every time step,

pls help

überschwupper February 12, 2023 16:20

Quote:

Originally Posted by Parth1999 (Post 844410)
Hi
i am new to OpenFOAM
i am trying to compile a solver, in which i need to store the the instantaneous
calculated variable (scalar) to array for every time step

I mean
CF_spatial = gsum(V_ecs)/gsum(por)
V_ecs and por are time dependent field variables, but CF_spatial is calculated at every time step and is a scalar value and it is not a field variable, i want to create an array where i can store CF_spatial value at every time step,

pls help


When you know the size, then why not using C++ arrays (or OpenFoam class List<T>), otherwise you could use vector from the standard library (std::vectory<T>) and then use the push_back() method.


All times are GMT -4. The time now is 14:26.