Macro API Changes 2020.2

In Simcenter STAR-CCM+ 2020.2, the macro API changed for directed meshing, material properties, adjoint, multiphase flow, solid stress, electrochemistry, visualization, and Simcenter STAR-CCM+ In-cylinder.

Directed Meshing: Possible Need for Rerecording Directed Patch Source Mesh Code

Due to improvements in how directed meshing works with source surfaces, existing macros with the DirectedPatchSourceMesh.autopopulateFeatureEdges command might not work in some of the cases. In that case, you must record a new macro.

Material Properties: Change to Default Choice of Material Property Method

In material properties, the default choice of method is now determined by the most recent choice of physics model. As a result, simulation files that are generated with macros saved in previous versions of Simcenter STAR-CCM+ may have some different default material property methods in Simcenter STAR-CCM+ 2020.2.

When running old macros, check the method settings of the material properties.

Adjoint

Renaming of Field Function

Due to refactoring of the Adjoint Solver, the field function CostFunction::CoordLagrangian_q has been renamed to CostFunction::CoordSensitivity, where CostFunction is the name of any cost function defined in the .sim file. Update all instances of this field function in your macros.

Change to Cost Function Creation Workflow

In Simcenter STAR-CCM+ 2020.2, you now create one type of cost function within the Adjoint solver, the Report cost function, and then select a (differentiable) report for the Report property of the cost function node. This redesign has resulted in changes to the macro code:

  • All specific cost functions must be replaced with report cost functions, that is, <X>CostFunction becomes ReportCostFunction.

    Previous Release Simcenter STAR-CCM+ 2020.2
    ForceCostFunction costFunction_0 =
      simulation.get(AdjointCostFunctionManager.class).createAdjointCostFunction(ForceCostFunction.class);
    ReportCostFunction costFunction_0 =
      simulation.get(AdjointCostFunctionManager.class).createAdjointCostFunction(ReportCostFunction.class);
  • All specific get and set methods of cost functions need to be changed to getReport and setReport, that is, get<X>Report becomes getReport and set<X>Report becomes setReport.

    Previous Release Simcenter STAR-CCM+ 2020.2
    ForceCostFunction costFunction_0 =
      ((ForceCostFunction) simulation.get(AdjointCostFunctionManager.class).getAdjointCostFunction("Force"));
    ReportCostFunction costFunction_0 =
      ((ReportCostFunction) simulation.get(AdjointCostFunctionManager.class).getAdjointCostFunction("Force"));
    ForceCostFunction.getForceReport()
    ReportCostFunction.getReport()
    costFunction_0.setForceReport(forceReport_0)
    costFunction_0.setReport(forceReport_0)
  • The default presentation name of newly created cost functions is now Report, irrespective of the associated report type. If you want the presentation name to reflect the report type (for example Force for a cost function associated with a Force Report), set it explicitly by adding the following command:

    costFunction_0.setPresentationName("Force");

Multiphase

End of Eulerian Activation Macro Code

Due to the renaming of some multiphase models, macro code for adding and subsequently removing a Eulerian Multiphase Mixture model by macro is no longer valid. To update your macros, remove instances of the following code:

EulerianMultiphaseMixtureModel eulerianMultiphaseMixtureModel_0 = 
physicsContinuum_0.getModelManager().getModel(EulerianMultiphaseMixtureModel.class);
physicsContinuum_0.disableModel(eulerianMultiphaseMixtureModel_0);

Changes to Wall Lubrication and Lift

Due to the introduction of the Lubchenko Wall Lubrication model in Simcenter STAR-CCM+ 2020.2, macro code has changed.

Wall Lubrication

Previous Release Simcenter STAR-CCM+ 2020.2
AntalWallLubricationCoefficientMethod antalWallLubricationCoefficientMethod_0 =    wallLubricationForceModel_0.getWallLubricationCoefficient().getMethod(AntalWallLubricationCoefficientMethod.class);
DispersedFlowRegime dispersedFlowRegime_0 =
      ((DispersedFlowRegime) eulerianPhaseInteractionModel_0.getFlowRegime(0));
AntalWallLubricationCoefficientMethod antalWallLubricationCoefficientMethod_0 = ((WallLubricationCoefficientMethodManager) wallLubricationForceModel_0.getWallLubricationCoefficientMethodManager(dispersedFlowRegime_0)).getMethod(AntalWallLubricationCoefficientMethod.class);

Lift

Remove the following code from your macros:

((LiftCoefficientMethodManager) liftForceModel_0.getLiftCoefficientMethods()).getCoefficientCorrectionOption().setSelected(LiftCoefficientCorrectionOption.ON);

Changes to Creation of Phase Interactions

In previous releases, the workflow related to Passive Scalar Interaction required you to create multiple interactions between the same Lagrangian phase and its physics continuum so that multiple passive scalars within those continua could interact with each other. Additionally, for each weighting model, that is, Area or Volume, a new interaction had to be created.

Since the new workflow for creating interactions in Simcenter STAR-CCM+ 2020.2 is designed to avoid the need for creating duplicate interactions, that is, interactions connecting the same two phases (continua in general), the Passive Scalar Interaction objects have been refactored. The previous weighting models have been refactored into methods that can be created multiple times within the same interaction, each working on its own pair of passive scalars. This approach allows you to incorporate any combination of passive scalars and weighting methods in a single interaction for those two phases.

This refactoring has resulted in changes to the macro code.

Previous Release Simcenter STAR-CCM+ 2020.2
// Area weighting
{
  PhaseInteraction phaseInteraction_0 = multiPhaseInteractionModel_0.createPhaseInteraction();

  phaseInteraction_0.enable(PassiveScalarPhaseInteractionModel.class);
  PassiveScalarPhaseInteractionModel passiveScalarPhaseInteractionModel_0 = 
    phaseInteraction_0.getModelManager().getModel(PassiveScalarPhaseInteractionModel.class);
  passiveScalarPhaseInteractionModel_0.setPhase0(lagrangianPhase_0);
  passiveScalarPhaseInteractionModel_0.setPhase1(physicsContinuum_0);

  phaseInteraction_0.enable(PassiveScalarAreaWeightInteraction.class);

  PassiveScalarAreaWeightInteraction passiveScalarAreaWeightInteraction_0 = 
    phaseInteraction_0.getModelManager().getModel(PassiveScalarAreaWeightInteraction.class);
  // work on passiveScalarAreaWeightInteraction_0
}
// Area and Volume weighting in one interaction
multiPhaseInteractionModel_0.createPhaseInteraction(
  PhaseInteractionTopology.LAGRANGIAN_PASSIVE_SCALAR, lagrangianPhase_0, physicsContinuum_0); 
// NB., accounts for enabling "PassiveScalarPhaseInteractionModel"

phaseInteraction_0.enable(LagrangianPassiveScalarTransferModel.class); // NB., new model
LagrangianPassiveScalarTransferModel lagrangianPassiveScalarTransferModel_0 =
  phaseInteraction_0.getModelManager().getModel(LagrangianPassiveScalarTransferModel.class);

PassiveScalarAreaWeightInteraction passiveScalarAreaWeightInteraction_0 = 
  lagrangianPassiveScalarTransferModel_0.getPassiveScalarInteractionMethodManager().createObject(PassiveScalarAreaWeightInteraction.class);
PassiveScalarVolumeWeightInteraction passiveScalarVolumeWeightInteraction_0 = 
  lagrangianPassiveScalarTransferModel_0.getPassiveScalarInteractionMethodManager().createObject(PassiveScalarVolumeWeightInteraction.class);

// work on either interaction
// Volume weighting
{
  PhaseInteraction phaseInteraction_0 = multiPhaseInteractionModel_0.createPhaseInteraction();

  phaseInteraction_0.enable(PassiveScalarPhaseInteractionModel.class);
  PassiveScalarPhaseInteractionModel passiveScalarPhaseInteractionModel_0 = 
    phaseInteraction_0.getModelManager().getModel(PassiveScalarPhaseInteractionModel.class);
  passiveScalarPhaseInteractionModel_0.setPhase0(lagrangianPhase_0);
  passiveScalarPhaseInteractionModel_0.setPhase1(physicsContinuum_0);

  phaseInteraction_0.enable(PassiveScalarVolumeWeightInteraction.class);

  PassiveScalarVolumeWeightInteraction passiveScalarVolumeWeightInteraction_0 = 
    phaseInteraction_0.getModelManager().getModel(PassiveScalarVolumeWeightInteraction.class);
  // work on passiveScalarVolumeWeightInteraction_0
}

The macro API within the PassiveScalarAreaWeightInteraction and PassiveScalarVolumeWeightInteraction, and dependent classes has not been changed.

Eulerian Multiphase (EMP): Transfer of Incident Mass Flux Impingement Phase Model

As a result of the implementation of incident mass flux impingement in the Mixture Multiphase (MMP) model, the registration of ImpingementEfficiencyProfile for the EMP IncidentMassFluxImpingementModel has been moved from the dispersed liquid phase to the phase interaction.

Previous Release Simcenter STAR-CCM+ 2020.2
private static final String LIQ_PHASE_NAME = "Eulerian-Liquid";
// Set impingmenent efficiency
InterfaceBoundary interfaceBoundary_0 =
    ((InterfaceBoundary) region_0.getBoundaryManager().getBoundary("Bottom [In-place 1]"));
PhaseConditions phaseConditions_0 =
      ((PhaseConditions) interfaceBoundary_0.get(PhaseConditionsManager.class).getPhaseConditions(LIQ_PHASE_NAME));
ImpingementEfficiencyProfile impingementEfficiencyProfile_0 =
    phaseConditions_0.getPhaseValueManager().get(ImpingementEfficiencyProfile.class);
impingementEfficiencyProfile_0.getMethod(ConstantScalarProfileMethod.class).getQuantity().setValue(0.8);
private static final String PHASE_INTERACTION_NAME = "Film-EulerianLiquid";
// Set impingmenent efficiency
InterfaceBoundary interfaceBoundary_0 =
    ((InterfaceBoundary) region_0.getBoundaryManager().getBoundary("Bottom [In-place 1]"));
PhaseConditions phaseConditions_0 =
      ((PhaseConditions) interfaceBoundary_0.get(PhaseConditionsManager.class).getPhaseConditions(PHASE_INTERACTION_NAME));
ImpingementEfficiencyProfile impingementEfficiencyProfile_0 =
    phaseConditions_0.getPhaseValueManager().get(ImpingementEfficiencyProfile.class);
impingementEfficiencyProfile_0.getMethod(ConstantScalarProfileMethod.class).getQuantity().setValue(0.8);

Solid Stress: Specified Temperature Model No Longer Requires Initial Conditions

For the Specified Temperature Model, the use of initial conditions has been found to be an excessive specification of the temperature profile. In Simcenter STAR-CCM+ 2020.2, the temperature profile chosen for the continuum or region now dictates the initial conditions as well. Some workflows are affected by this change, specifically those that use DataMapper and rely on the specified (initial) values when the data mapper itself has not been initialized. In these instances, it is possible to use the alternateValue() field function to specify a fall-back value when the data mapper is not ready to be queried.

At the same time, the initial condition specification for this model has been removed. To update your macro code, remove the instances of initial conditions for this model, as shown in the following example of an option that no longer works:

SpecifiedTemperatureProfile specifiedTemperatureProfileInitial_0 = 
	      physicsContinuum_0.getInitialConditions().get(SpecifiedTemperatureProfile.class);

Electrochemistry: Surface Reactions Now Allowed with Electrochemical Reactions

The incompatibility between the Surface Chemistry model and the Electrochemical Reactions model has been removed. In previous releases, these models were incompatible due to their need to use the same Surface Mechanism Option.

In Simcenter STAR-CCM+ 2020.2, the Electrochemical Reactions model now uses the Electrochemistry Mechanism Option, resulting in changes to the macro code:

  • Provided you are not currently using surface chemistry in your simulation (in a different continuum since previously the models were incompatible), you must replace headers:

    Previous Release Simcenter STAR-CCM+ 2020.2
    import star.reactions.SurfaceMechanismOption;
    import star.reactions.ElectrochemistryMechanismOption;
  • Any macro code that referenced the SurfaceMechanismOption class must be updated to use the ElectrochemistryMechanismOption class:

    Previous Release Simcenter STAR-CCM+ 2020.2
    SurfaceMechanismOption smo = iface.getConditions().get(SurfaceMechanismOption.class);
    SurfaceMechanismOption smo2 = boundary.getConditions().get(SurfaceMechanismOption.class);
    ElectrochemistryMechanismOption smo = iface.getConditions().get(ElectrochemistryMechanismOption.class);
    ElectrochemistryMechanismOption smo2 = boundary.getConditions().get(ElectrochemistryMechanismOption.class);

Visualization: Change to Default Displayer Representation

The default selection for the Representation property of a scene displayer is now Latest Surface/Volume. As you continue to create a surface or volume mesh, the displayer that contains this representation is updated as well. This change only affects default representations of displayers—plots and reports are not affected.

This modification has resulted in changes to the macro code. The LatestMeshProxyRepresentation has moved from star.meshing package to star.common package. If you have included the entire path in the import statement, update your macros.

Previous Release Simcenter STAR-CCM+ 2020.2
import star.meshing.LatestMeshProxyRepresentation;
import star.common.LatestMeshProxyRepresentation;

Simcenter STAR-CCM+ In-cylinder: Change to PDF Table Import

Due to changes in table headers, the way in which Simcenter STAR-CCM+ In-cylinder imports PDF tables has changed, resulting in changes to the macro code for this import.

Previous Release Simcenter STAR-CCM+ 2020.2
starIcePhysicsManager_0.createProfileFileTable(resolveDataPath("case/injector_DropletDiameterPDF.csv"), quickPartInstance_0, "Droplet Diameter");
starIcePhysicsManager_0.createProfileFileTable(resolveDataPath("case/injector_DropletDiameterPDF.csv"), quickPartInstance_0, "Droplet Diameter", "PDF");