def aggregate(global_params, running_aggregate, aggregation_result):
    """
    add an aggregation result into a running total aggregate
    aggregation must be associative
    :global_params: global parameters object
    :running_aggregate: running top level AggregationResult
    :aggregation_result: new aggregation result to add
    :returns: running aggregate
    """
    running_ref = running_aggregate.get_ref('values')
    agg_ref = aggregation_result.get_ref('values')
    for i in range(global_params.dims):
        running_ref[i] += agg_ref[i]
    return running_aggregate