提示双精度实数输入

可以编辑用于提示双精度实数的宏。

双精度实数通常用于在 Simcenter STAR-CCM+ 中指定如边界条件等值。



对于此示例,录制了简单的宏,以将压力从 -3066.82 更改为 -4017.39



名为 doublePrecision.java 的宏包含以下代码:

// STAR-CCM+ macro: doublePrecision.java
package macro;
import java.util.*;
import star.common.*;
import star.base.neo.*;
import star.flow.*;
public class doublePrecision extends StarMacro {
  public void execute() {
    Simulation simulation_0 = 
      getActiveSimulation();
    Region region_0 = 
      simulation_0.getRegionManager().getRegion("Fluid");
    Boundary boundary_0 = 
region_0.getBoundaryManager().getBoundary("Free_Stream");
    StaticPressureProfile staticPressureProfile_0 = 
boundary_0.getValues().get(StaticPressureProfile.class);
    ((ConstantScalarProfileMethod) staticPressureProfile_0.getMethod()).getQuantity().
      setValue(-4017.39);
  }
}

此典型宏代码包含在录制过程中输入的静压的值 — 它保持不变。 但是,当宏包含用户输入的代码时,它将暂停以激活可在其中指定该值的对话框。



单击确定时,宏将继续。

doublePrecision.java 代码将进行如下修改以使其发挥作用:

// STAR-CCM+ macro: doublePrecision.java
package macro;
import java.util.*;
import star.common.*;
import star.base.neo.*;
import star.flow.*;
public class doublePrecision extends StarMacro {
  public void execute() {
    Simulation simulation_0 = 
      getActiveSimulation();
    Region region_0 = 
      simulation_0.getRegionManager().getRegion("Fluid");
    Boundary boundary_0 = 
region_0.getBoundaryManager().getBoundary("Free_Stream");
    StaticPressureProfile staticPressureProfile_0 = 
boundary_0.getValues().get(StaticPressureProfile.class);
    double ret = promptUserForInput("Static Pressure", -3066.82); /* <---NEW CODE */
    ((ConstantScalarProfileMethod) staticPressureProfile_0.getMethod()).getQuantity().setValue(ret); /* <---- "ret"
         * replaces the numeric entry that was recorded automatically */
  }
}