Simcenter STAR-CCM+ How to access and use a scalar or vector field from the previous iteration or time-step?

2023-12-04T16:35:03.000-0500
Simcenter STAR-CCM+ Simcenter STAR-CCM+ Virtual Reality Teamcenter Share Simcenter STAR-CCM+ Viewer Simcenter STAR-CCM+ Application Specific Solutions

Summary

Retain a usable scalar field from the previous iteration or time-step.


Details

It can sometimes be useful to access a given field as it was at the time of the previous time-step. This can be used e.g. to calculate variations, time derivatives, or update a quantity based on its last value. However, Simcenter STAR-CCM+ only ever keeps the latest fields that are required for a simulation, which increases performance and reduces the size of .sim files. Thus, the fields that are accessible inside a simulation are always the ones from the very latest iteration, if the solution was not explicitly saved at regular intervals.

There is an in-built approach introduced in recent versions of Simcenter STAR-CCM+ and legacy approaches for older version of the software. Legacy approaches work only for scalar quantities. Of course, user can rebuilt a vector from a set of scalars.

Field History Monitor Approach

This approach is nicely described in the user guide under chapter Accessing Field Data from Previous Time-Steps or Iterations, see related articles for link.

In a nutshell, user needs to create a new monitor for an existing field function. The option is accessible through menu open after right clicking Monitors node.
In the newly created monitor user can set trigger to be iteration or time-step and set the sliding sample window size. For the purpose of accessing only the previous iteration or time-step values, the sliding window size can be set to 2. 

The monitor will create field functions named History of F Sample Y, where F is the field you are averaging and Y is a number. Field function with Y=0 is a duplicate of current iteration or time-step values, Y=1 gives you values from previous iteration or time-step.

Legacy approaches

1. Monitor approach

One relatively direct way to obtain a past field in the current simulation is to use some type of Field Monitor with a sliding window size of 2 (which will provide some combination of the two latest fields), then remove the value of the current field. For instance, let us consider that we want to get the value of a scalar field f at the previous step. 
By creating a Field Sum Monitor with a sliding window value of 2, this Monitor will create a field function whose value is equal to FieldSumMonitor = f_previous_state + (current state).  Thus, we can create a Field Function
f_previous_state = FieldSumMonitor – f
Here, "previous state" can be either the previous iteration or the previous time-step, depending on the Trigger that was selected for the Monitor. However, a drawback of this method is that the value of f_previous_state cannot be used in the calculation of the current field f, because then f would depend on itself. This might not generally be a problem, but this prevents from defining the Field Function f in this way:
f = function(f_previous_state)

2. Monitor approach

The following is an alternative method, which allows such recursive definitions for f. However, the following method is only applicable for unsteady simulations to get the field at the previous time-step, and it is not suitable to get the field at the previous iteration.
Furthermore, the number of inner iterations per time-step has to be known, and constant. 

The principle of this method is to create two Monitors. The first Monitor will sample the field f at each time step, and keep it frozen within a time-step. The second Monitor will sample the first Monitor with a frequency of 1 time-step, but with a 1 iteration offset so that its value has not yet been updated when the time-step is complete. This second Monitor automatically provides a field function whose value is directly f_previous_state.
 

Settings of the first Monitor, Previous_f_intermediary

User-added imageUser-added imageUser-added image

•    Create a new Field Sum Monitor. Rename it, for example, Previous_f_intermediary.
Generally, sampling a field with a monitor can be done with any type of Monitor (e.g. Field Sum, Field Mean, Field Min, Field Max, etc.) since we will later use a sliding window of 1 sample. However, no value will exist yet during the first time-step, and the type of Monitor used influences the value that is returned when 0 samples have been taken. Using a Field Sum Monitor simply returns 0 during the first time-step. 
•    Set Parts to contain all the Regions and Boundaries where you will like the f_previous_state field to be available. 
•    Make sure that Trigger is Time Step. This should be the default if your continuum is set up as unsteady. 
•    Select Enable Sliding Sample Window. This adds a sub-node called Sliding Window.
•    As Field Function, select the field f for which you would like to keep the previous state. 
•    In the Time-Step Frequency sub-node, the default values Frequency: 1, Start: 0 should be set.
•    In the Sliding Window sub-node, set the Sliding Sample Window Size to 1. 
This will allow to sample simply the current field, without applying any operation (such as mean, max, etc.)

 

Settings of the second Monitor, Previous_f

User-added imageUser-added imageUser-added image

•    Create a new Field Sum Monitor. Rename it, for example, Previous_f.
•    Set Parts in the same way as the previous Monitor, Previous_f_intermediary.
•    Change Trigger to Iteration.
•    Select Enable Sliding Sample Window.
•    As Field Function, select the Field Function that was created automatically by the previous Monitor, which in our example is named "Sum of f".
•    In the Sliding Window sub-node, set the Sliding Sample Window Size to 1. 
•    In the Iteration Frequency sub-node, use the number of inner iterations as value of Iteration Frequency, and set the Start Iteration to 1. 

This Monitor will create a Field Function, called in our example "Sum of Sum of f", which contains the value of f_previous_state. For clarity, you may create and define a new field function with a more relevant name, such as

f_previous = ${Previous_fMonitor}

where ${Previous_fMonitor} is the variable pointing to the Monitor Field Function "Sum of Sum of f"

KB Article ID# KB000040982_EN_US

Contents

SummaryDetails

Associated Components

Design Manager Electronics Cooling In-Cylinder (STAR-ICE) Job Manager Simcenter STAR-CCM+