Retain a usable scalar field from the previous iteration or time-step.
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.
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.
f_previous_state = FieldSumMonitor – fHere, "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)
• 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.)
• 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"