Skip to content

How to sum and average multiple columns? #1505

Answered by jqnatividad
OpenFoam-User asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @OpenFoam-User ,

Happy New Year! 🎆

Here's one solution using luau:

First, create a luau script named xuvw_avgs.luau with the following contents:

BEGIN {
    -- this is the BEGIN block, which is executed ONCE at the beginning
    -- where we typically initialize variables, setup functions
    -- and load additional Lua libraries as required

    -- set to num of repeating columns, set to 4 as the sample data only had 4
    num_col_repeats = 4;

    -- use string.format using C format specifiers
    -- see https://cplusplus.com/reference/cstdio/printf/

    function round_string(number, precision)
        local fmtStr = string.format('%%0.%sg',precision)
        formatted_number = string…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@OpenFoam-User
Comment options

@OpenFoam-User
Comment options

@OpenFoam-User
Comment options

@jqnatividad
Comment options

Answer selected by OpenFoam-User
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants