// Simcenter STAR-CCM+ macro: autoPre.java
// Written by Simcenter STAR-CCM+ 20.02.007
package macro;

import java.util.*;

import star.common.*;
import star.base.neo.*;
import star.meshing.*;

public class autoPre extends StarMacro {

  public void execute() {
    execute0();
  }

  private void execute0() {

    Simulation simulation_0 = 
      getActiveSimulation();

    CompositePart compositePart_1 = 
      ((CompositePart) simulation_0.get(SimulationPartManager.class).getPart("Part1"));

    CadPart cadPart_0 = 
      ((CadPart) compositePart_1.getChildParts().getPart("\u8F66\u8EAB"));

    PartSurface partSurface_0 = 
      ((PartSurface) cadPart_0.getPartSurfaceManager().getPartSurface("Faces"));

    partSurface_0.setPresentationName("bd");

    CadPart cadPart_1 = 
      ((CadPart) compositePart_1.getChildParts().getPart("\u5E95\u677F"));

    PartSurface partSurface_1 = 
      ((PartSurface) cadPart_1.getPartSurfaceManager().getPartSurface("Faces"));

    partSurface_1.setPresentationName("bd");

    CadPart cadPart_2 = 
      ((CadPart) compositePart_1.getChildParts().getPart("\u524D\u7FFC"));

    PartSurface partSurface_2 = 
      ((PartSurface) cadPart_2.getPartSurfaceManager().getPartSurface("Faces"));

    partSurface_2.setPresentationName("fw");

    CadPart cadPart_3 = 
      ((CadPart) compositePart_1.getChildParts().getPart("\u5C3E\u7FFC"));

    PartSurface partSurface_3 = 
      ((PartSurface) cadPart_3.getPartSurfaceManager().getPartSurface("Faces"));

    partSurface_3.setPresentationName("rw");

    CadPart cadPart_4 = 
      ((CadPart) compositePart_1.getChildParts().getPart("ft"));

    PartSurface partSurface_4 = 
      ((PartSurface) cadPart_4.getPartSurfaceManager().getPartSurface("Faces"));

    partSurface_4.setPresentationName("ft");

    CadPart cadPart_5 = 
      ((CadPart) compositePart_1.getChildParts().getPart("rt"));

    PartSurface partSurface_5 = 
      ((PartSurface) cadPart_5.getPartSurfaceManager().getPartSurface("Faces"));

    partSurface_5.setPresentationName("rt");

    MeshActionManager meshActionManager_0 = 
      simulation_0.get(MeshActionManager.class);

    MeshPart meshPart_4 = 
      ((MeshPart) simulation_0.get(SimulationPartManager.class).getPart("\u5916\u8FB9\u754C"));

    MeshPart meshPart_1 = 
      meshActionManager_0.subtractParts(new ArrayList<>(Arrays.<MeshPart>asList(meshPart_4, cadPart_0, cadPart_1, cadPart_2, cadPart_3, cadPart_4, cadPart_5)), meshPart_4, "\u79BB\u6563");

    PartSurface partSurface_6 = 
      ((PartSurface) meshPart_1.getPartSurfaceManager().getPartSurface("bd"));

    PartSurface partSurface_7 = 
      ((PartSurface) meshPart_1.getPartSurfaceManager().getPartSurface("bd 2"));

    meshPart_1.combinePartSurfaces(new ArrayList<>(Arrays.<PartSurface>asList(partSurface_6, partSurface_7)));

    Region region_0 = 
      simulation_0.getRegionManager().getRegion("f");

    region_0.getPartGroup().addObjects(meshPart_1);

    AutoMeshOperation autoMeshOperation_0 = 
      ((AutoMeshOperation) simulation_0.get(MeshOperationManager.class).getObject("\u81EA\u52A8\u7F51\u683C"));

    autoMeshOperation_0.getInputGeometryObjects().setQuery(null);

    autoMeshOperation_0.getInputGeometryObjects().setObjects(meshPart_1);

    SurfaceCustomMeshControl surfaceCustomMeshControl_0 = 
      ((SurfaceCustomMeshControl) autoMeshOperation_0.getCustomMeshControls().getObject("\u8F66"));

    surfaceCustomMeshControl_0.getGeometryObjects().setQuery(null);

    PartSurface partSurface_8 = 
      ((PartSurface) meshPart_1.getPartSurfaceManager().getPartSurface("ft"));

    PartSurface partSurface_9 = 
      ((PartSurface) meshPart_1.getPartSurfaceManager().getPartSurface("fw"));

    PartSurface partSurface_10 = 
      ((PartSurface) meshPart_1.getPartSurfaceManager().getPartSurface("rt"));

    PartSurface partSurface_11 = 
      ((PartSurface) meshPart_1.getPartSurfaceManager().getPartSurface("rw"));

    surfaceCustomMeshControl_0.getGeometryObjects().setObjects(partSurface_6, partSurface_8, partSurface_9, partSurface_10, partSurface_11);

    SurfaceCustomMeshControl surfaceCustomMeshControl_1 = 
      ((SurfaceCustomMeshControl) autoMeshOperation_0.getCustomMeshControls().getObject("\u8FD1\u8F66\u5730\u9762"));

    surfaceCustomMeshControl_1.getGeometryObjects().setQuery(null);

    PartSurface partSurface_12 = 
      ((PartSurface) meshPart_1.getPartSurfaceManager().getPartSurface("ground_near"));

    surfaceCustomMeshControl_1.getGeometryObjects().setObjects(partSurface_12);

    SurfaceCustomMeshControl surfaceCustomMeshControl_2 = 
      ((SurfaceCustomMeshControl) autoMeshOperation_0.getCustomMeshControls().getObject("\u5916\u8FB9\u754C"));

    surfaceCustomMeshControl_2.getGeometryObjects().setQuery(null);

    PartSurface partSurface_13 = 
      ((PartSurface) meshPart_1.getPartSurfaceManager().getPartSurface("ground"));

    PartSurface partSurface_14 = 
      ((PartSurface) meshPart_1.getPartSurfaceManager().getPartSurface("inlet"));

    PartSurface partSurface_15 = 
      ((PartSurface) meshPart_1.getPartSurfaceManager().getPartSurface("outlet"));

    PartSurface partSurface_16 = 
      ((PartSurface) meshPart_1.getPartSurfaceManager().getPartSurface("symm"));

    PartSurface partSurface_17 = 
      ((PartSurface) meshPart_1.getPartSurfaceManager().getPartSurface("wall"));

    surfaceCustomMeshControl_2.getGeometryObjects().setObjects(partSurface_13, partSurface_14, partSurface_15, partSurface_16, partSurface_17);
  }
}
