StarCCM Macro to export to Ensight


This macro exports StarCCM results into the Ensight Gold format. It will write the results in the subdirectory ensight.
This subdirectory will be put in the same directory as the simulation file. It selects all regions, and all boundaries within those regions to be exported.
Derived Parts are not exported by default. The corresponding line has to be commented in to include such parts.

Additional Field Functions can be added quickly by name.

import java.util.*;
import star.common.*;
import star.base.neo.*;
 * Script exports all regions and ascociated boundaries.
 * Add required field functions within the macro.
 * @author sengel
public class export2Ensight extends StarMacro {
    String sep = System.getProperty("file.separator"); //get the right separator for your operative system
    public void execute() {
        Simulation sim = getActiveSimulation();
        sim.println("The macro export2Ensight is running now.");
        String exportDir = sim.getSessionDir() + sep + "ensight";
        String exportName = sim.getPresentationName() + ".case";
        // *********************************************************************  
        // Which Field Functions to export
        // *********************************************************************        
        Collection<FieldFunction> scalarFieldFunctions = new ArrayList<>();
        Collection<FieldFunction> vectorFieldFunctions = new ArrayList<>();
        FieldFunctionManager ffmng = sim.getFieldFunctionManager();
        // *********************************************************************  
        // Collect all Regions and Boundaries
        // *********************************************************************    
        Collection<Region> regions = sim.getRegionManager().getRegions();
        Collection<Boundary> boundaries = new ArrayList<>();
        for (Region reg : regions) {
        Collection<Part> parts = new ArrayList<>();
        // remove comment of the next line to add derived Parts
        // parts.addAll(sim.getPartManager().getObjects());
        // *********************************************************************              
        // Initiate Manager
        ImportManager importManager_0 = sim.getImportManager();
        // Save location
        String exportPath = exportDir + sep + exportName;
        // create Directory if not already exist
        File dir = new File(exportDir);
        if (!dir.exists()) {
            sim.println("Created the export directory: " + exportDir);
        // Set Export Entities
        importManager_0.setExportRegions(new NeoObjectVector(regions.toArray()));
        importManager_0.setExportBoundaries(new NeoObjectVector(boundaries.toArray()));
        // Set Export Field Functions
        importManager_0.setExportScalars(new NeoObjectVector(scalarFieldFunctions.toArray()));
        importManager_0.setExportVectors(new NeoObjectVector(vectorFieldFunctions.toArray()));
        // Other Export Settings
        importManager_0.setExportParts(new NeoObjectVector(new Object[]{}));
        importManager_0.setExportPartSurfaces(new NeoObjectVector(new Object[]{}));
        // Combine Collections of FieldFunctions
        Collection<FieldFunction> fieldFunctions = new ArrayList<>();       
        // Export.  
        // The Boolean variables are 1.)AppendDataToExistingFile, 2.)exportDataOnVertices
        importManager_0.export(exportPath, regions, boundaries, parts, fieldFunctions, false, false);
        sim.println("Macro export2Ensight has finished.");
guide/starccm/ensight_export_macro.txt · Last modified: 2019/02/11 10:55 by seengel
Back to top
CC Attribution-Share Alike 3.0 Unported = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0