├── CoSimMapper.java ├── CoSimulationAbaqus.java ├── CoSimulationAbaqus_8_04.java ├── CoSimulationAbaqus_9_02_007.java ├── ContinuumBuilder.java ├── ContiuumBuilder.java ├── DataReader.java ├── DerivedParts.java ├── DirectedMesher8_02_008.java ├── FieldFunctions.java ├── GeoData.java ├── GeometryBuilder.java ├── ImportCAE.java ├── MeshElementData.java ├── MeshMorpher.java ├── MeshSpacingData.java ├── NewDataReader.java ├── PolyhedralMesher.java ├── RegionBuilder.java ├── ReportsMonitorsPlots.java ├── ReportsMonitorsPlots_8_04.java ├── Scenes.java ├── SimRunner.java ├── SolutionHistoryCreator.java ├── SolversNode.java ├── StoppingCriteria.java ├── Tools.java └── TrimmerMesher.java /CoSimMapper.java: -------------------------------------------------------------------------------- 1 | package starClasses; 2 | 3 | import star.common.Simulation; 4 | import star.cosimulation.abaqus.*; 5 | import star.cosimulation.common.*; 6 | 7 | public class CoSimMapper 8 | { 9 | private AbaqusCoSimulation m_abaqusCoSimulation; 10 | 11 | public CoSimMapper(Simulation m_sim) 12 | { 13 | m_abaqusCoSimulation = ((AbaqusCoSimulation) m_sim.get(CoSimulationManager.class).getObject("Abaqus Co-Simulation 1")); 14 | } 15 | 16 | /** 17 | * This method sets mapper's tolerance settings 18 | * @param normalTolerance 19 | * @param perimeterTolerance 20 | */ 21 | public void setMapperTolSettings(double normalTolerance, double perimeterTolerance) 22 | { 23 | m_abaqusCoSimulation.setMapperNormalTol(normalTolerance); 24 | m_abaqusCoSimulation.setMapperPerimeterTol(perimeterTolerance); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /CoSimulationAbaqus.java: -------------------------------------------------------------------------------- 1 | package starClasses; 2 | 3 | import star.base.neo.NeoObjectVector; 4 | import star.common.Boundary; 5 | import star.common.PrimitiveFieldFunction; 6 | import star.common.Region; 7 | import star.common.Simulation; 8 | import star.cosimulation.abaqus.*; 9 | import star.cosimulation.common.*; 10 | 11 | public class CoSimulationAbaqus 12 | { 13 | private String m_version; 14 | private Simulation m_sim; 15 | private Region m_region; 16 | private AbaqusCoSimulation m_abaqusCoSimulation; 17 | 18 | public CoSimulationAbaqus(String starVersion, Simulation sim, String regionName) 19 | { 20 | m_version = starVersion; 21 | m_sim = sim; 22 | m_region = m_sim.getRegionManager().getRegion(regionName); 23 | 24 | if(m_version.equals("8_04")) 25 | { 26 | m_abaqusCoSimulation = m_sim.get(CoSimulationManager.class).createCoSimulation(AbaqusCoSimulation.class, "Abaqus Co-Simulation"); 27 | } 28 | else if(m_version.equals("9_02")) 29 | { 30 | m_abaqusCoSimulation = ((AbaqusCoSimulation) m_sim.get(CoSimulationManager.class).getObject("Abaqus Co-Simulation 1")); 31 | } 32 | 33 | PrimitiveFieldFunction primitiveFieldFunction_0 = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction("StaticPressure")); 34 | PrimitiveFieldFunction primitiveFieldFunction_1 = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction("WallShearStress")); 35 | m_abaqusCoSimulation.setExportedFieldFunctions(new NeoObjectVector(new Object[] {primitiveFieldFunction_0, primitiveFieldFunction_1})); 36 | 37 | PrimitiveFieldFunction primitiveFieldFunction_2 = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction("NodalDisplacement")); 38 | PrimitiveFieldFunction primitiveFieldFunction_3 = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction("Velocity")); 39 | m_abaqusCoSimulation.setImportedFieldFunctions(new NeoObjectVector(new Object[] {primitiveFieldFunction_2, primitiveFieldFunction_3})); 40 | } 41 | 42 | /** 43 | * This method sets the coupled boundaries for the Abaqus Co-Simulation 44 | * @param boundaryNames names of the coupled boundaries to be included in the FSI simulation 45 | */ 46 | public void setCouplingBoundaries(String[] boundaryNames) 47 | { 48 | for(int i = 0; i < boundaryNames.length; i++) 49 | { 50 | Boundary boundary = m_region.getBoundaryManager().getBoundary(boundaryNames[i]); 51 | m_abaqusCoSimulation.getCouplingSurfaces().addObjects(boundary); 52 | } 53 | } 54 | 55 | /** 56 | * This method sets up the Abaqus execution settings in Star-CCM+ 57 | * @param jobName desired name of the Abaqus job 58 | * @param inputFilePath file path for the Abaqus input file, example 59 | * "D:\\Users\\cj8q5\\Simulations\\March 2013\\FSI_Comb_9\\Abaqus\\CombPlate.inp" 60 | * @param abaqusExecutableName executable file name, example "abq6122.bat" 61 | * @param numCPUs number of CPU's to use on the Abaqus side of the FSI simulation 62 | */ 63 | public void setAbaqusExecutionSettings(String jobName, String inputFilePath, String abaqusExecutableName, int numCPUs) 64 | { 65 | //File inputFile = new File(inputFilePath); 66 | 67 | AbaqusExecution abaqusExecution_0 = m_abaqusCoSimulation.getAbaqusExecution(); 68 | abaqusExecution_0.setJobName(jobName); 69 | abaqusExecution_0.setJobFileNameSilently(inputFilePath); 70 | abaqusExecution_0.setExecutableName(abaqusExecutableName); 71 | abaqusExecution_0.setNumCpus(numCPUs); 72 | } 73 | 74 | /** 75 | * This method sets up the coupling algorithm settings 76 | * @param couplingScheme "implicit" for implicit coupling "explicit" for explicit 77 | * @param rendezvousOption "Star Leads" for letting Star-CCM+ lead and "Abaqus Leads" for letting Abaqus lead 78 | * @param couplingTimeStep the coupling time step for the co-simulation 79 | */ 80 | public void abaqusCouplingAlgorithm(String couplingScheme, String rendezvousOption, double couplingTimeStep) 81 | { 82 | // Setting the coupling scheme 83 | CouplingAlgorithm couplingAlgorithm = m_abaqusCoSimulation.getCouplingAlgorithm(); 84 | if(couplingScheme.equals("Implicit")) 85 | { 86 | couplingAlgorithm.setCouplingScheme(1); 87 | } 88 | if(couplingScheme.equals("Explicit")) 89 | { 90 | couplingAlgorithm.setCouplingScheme(0); 91 | } 92 | 93 | // Setting if Star or Abaqus leads the co-simulation 94 | if(rendezvousOption.equals("Star Leads")) 95 | { 96 | couplingAlgorithm.getRendezvousOptions().setSelected(AbaqusRendezvousOptions.STARCCM_LEADS); 97 | } 98 | if(rendezvousOption.equals("Abaqus Leads")) 99 | { 100 | couplingAlgorithm.getRendezvousOptions().setSelected(AbaqusRendezvousOptions.ABAQUS_LEADS); 101 | } 102 | 103 | // Setting the constant coupling time step 104 | couplingAlgorithm.getConstCouplingDtQty().setValue(couplingTimeStep); 105 | } 106 | 107 | /** 108 | * This method sets the field exchange controls for the Abaqus Co-Simulation 109 | * @param minNumExchangesPerTS 110 | * @param numIterationsExchange 111 | * @param deflectionUnderRelax 112 | */ 113 | public void setFieldExchangeControls(int minNumExchangesPerTS, int numIterationsExchange, double deflectionUnderRelax) 114 | { 115 | AbaqusCoSimulationSolver abaqusCoSimulationSolver = 116 | ((AbaqusCoSimulationSolver) m_sim.getSolverManager().getSolver(AbaqusCoSimulationSolver.class)); 117 | FieldExchangeControls fieldExchangeControls = abaqusCoSimulationSolver.getFieldExchangeControls(); 118 | 119 | // Setting the number of exchanges and inner iterations per exchange 120 | fieldExchangeControls.setNumExchangesMin(minNumExchangesPerTS); 121 | fieldExchangeControls.setNumIterations(numIterationsExchange); 122 | 123 | // Setting the inputed Abaqus deflection under relaxation factor 124 | fieldExchangeControls.getIterUrfOptions().setSelected(AbaqusIterUrfOptions.CONST); 125 | fieldExchangeControls.setIncomingFieldURF(deflectionUnderRelax); 126 | } 127 | 128 | /** 129 | * This method sets mapper's tolerance settings 130 | * @param normalTolerance 131 | * @param perimeterTolerance 132 | */ 133 | public void setMapperTolSettings(double normalTolerance, double perimeterTolerance) 134 | { 135 | MapperSettings mapperSettings = m_abaqusCoSimulation.getMapperSettings(); 136 | mapperSettings.setMapperProximityTol(normalTolerance); 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /CoSimulationAbaqus_8_04.java: -------------------------------------------------------------------------------- 1 | package starClasses; 2 | 3 | import star.base.neo.NeoObjectVector; 4 | import star.common.Boundary; 5 | import star.common.PrimitiveFieldFunction; 6 | import star.common.Region; 7 | import star.common.Simulation; 8 | import star.cosimulation.abaqus.AbaqusCoSimulation; 9 | import star.cosimulation.abaqus.AbaqusCoSimulationSolver; 10 | import star.cosimulation.abaqus.AbaqusExecution; 11 | import star.cosimulation.abaqus.AbaqusIterUrfOptions; 12 | import star.cosimulation.abaqus.AbaqusRendezvousOptions; 13 | import star.cosimulation.abaqus.CouplingAlgorithm; 14 | import star.cosimulation.abaqus.FieldExchangeControls; 15 | import star.cosimulation.common.CoSimulationManager; 16 | 17 | public class CoSimulationAbaqus_8_04 18 | { 19 | private Simulation m_sim; 20 | private Region m_region; 21 | private AbaqusCoSimulation m_abaqusCoSimulation; 22 | 23 | public CoSimulationAbaqus_8_04(Simulation sim, String regionName) 24 | { 25 | m_sim = sim; 26 | m_region = m_sim.getRegionManager().getRegion(regionName); 27 | 28 | m_abaqusCoSimulation = m_sim.get(CoSimulationManager.class).createCoSimulation(AbaqusCoSimulation.class, "Abaqus Co-Simulation"); 29 | 30 | PrimitiveFieldFunction primitiveFieldFunction_0 = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction("StaticPressure")); 31 | PrimitiveFieldFunction primitiveFieldFunction_1 = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction("WallShearStress")); 32 | m_abaqusCoSimulation.setExportedFieldFunctions(new NeoObjectVector(new Object[] {primitiveFieldFunction_0, primitiveFieldFunction_1})); 33 | m_abaqusCoSimulation.setExportedFieldFunctions(new NeoObjectVector(new Object[] {primitiveFieldFunction_0, primitiveFieldFunction_1})); 34 | 35 | PrimitiveFieldFunction primitiveFieldFunction_2 = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction("NodalDisplacement")); 36 | PrimitiveFieldFunction primitiveFieldFunction_3 = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction("Velocity")); 37 | m_abaqusCoSimulation.setImportedFieldFunctions(new NeoObjectVector(new Object[] {primitiveFieldFunction_2, primitiveFieldFunction_3})); 38 | m_abaqusCoSimulation.setImportedFieldFunctions(new NeoObjectVector(new Object[] {primitiveFieldFunction_2, primitiveFieldFunction_3})); 39 | } 40 | 41 | /** 42 | * This method sets the coupled boundaries for the Abaqus Co-Simulation 43 | * @param boundaryNames names of the coupled boundaries to be included in the FSI simulation 44 | */ 45 | public void setCouplingBoundaries(String[] boundaryNames) 46 | { 47 | for(int i = 0; i < boundaryNames.length; i++) 48 | { 49 | Boundary boundary = m_region.getBoundaryManager().getBoundary(boundaryNames[i]); 50 | m_abaqusCoSimulation.getCouplingSurfaces().addObjects(boundary); 51 | } 52 | } 53 | 54 | /** 55 | * This method sets up the Abaqus execution settings in Star-CCM+ 56 | * @param jobName desired name of the Abaqus job 57 | * @param inputFilePath file path for the Abaqus input file, example 58 | * "D:\\Users\\cj8q5\\Simulations\\March 2013\\FSI_Comb_9\\Abaqus\\CombPlate.inp" 59 | * @param abaqusExecutableName executable file name, example "abq6122.bat" 60 | * @param numCPUs number of CPU's to use on the Abaqus side of the FSI simulation 61 | */ 62 | public void setAbaqusExecutionSettings(String jobName, String inputFilePath, String abaqusExecutableName, int numCPUs) 63 | { 64 | //File inputFile = new File(inputFilePath); 65 | 66 | AbaqusExecution abaqusExecution_0 = m_abaqusCoSimulation.getAbaqusExecution(); 67 | abaqusExecution_0.setJobName(jobName); 68 | //abaqusExecution_0.setJobFileName(inputFile); 69 | abaqusExecution_0.setJobFileNameSilently(inputFilePath); 70 | abaqusExecution_0.setExecutableName(abaqusExecutableName); 71 | abaqusExecution_0.setNumCpus(numCPUs); 72 | } 73 | 74 | /** 75 | * This method sets up the coupling algorithm settings 76 | * @param couplingScheme "implicit" for implicit coupling "explicit" for explicit 77 | * @param rendezvousOption "Star Leads" for letting Star-CCM+ lead and "Abaqus Leads" for letting Abaqus lead 78 | * @param couplingTimeStep the coupling time step for the co-simulation 79 | */ 80 | public void abaqusCouplingAlgorithm(String couplingScheme, String rendezvousOption, double couplingTimeStep) 81 | { 82 | // Setting the coupling scheme 83 | CouplingAlgorithm couplingAlgorithm = m_abaqusCoSimulation.getCouplingAlgorithm(); 84 | if(couplingScheme.equals("Implicit")) 85 | { 86 | couplingAlgorithm.setCouplingScheme(1); 87 | } 88 | if(couplingScheme.equals("Explicit")) 89 | { 90 | couplingAlgorithm.setCouplingScheme(0); 91 | } 92 | 93 | // Setting if Star or Abaqus leads the co-simulation 94 | if(rendezvousOption.equals("Star Leads")) 95 | { 96 | couplingAlgorithm.getRendezvousOptions().setSelected(AbaqusRendezvousOptions.STARCCM_LEADS); 97 | } 98 | if(rendezvousOption.equals("Abaqus Leads")) 99 | { 100 | couplingAlgorithm.getRendezvousOptions().setSelected(AbaqusRendezvousOptions.ABAQUS_LEADS); 101 | } 102 | 103 | // Setting the constant coupling time step 104 | couplingAlgorithm.getConstCouplingDtQty().setValue(couplingTimeStep); 105 | } 106 | 107 | /** 108 | * This method sets the field exchange controls for the Abaqus Co-Simulation 109 | * @param minNumExchangesPerTS 110 | * @param numIterationsExchange 111 | * @param deflectionUnderRelax 112 | */ 113 | public void setFieldExchangeControls(int minNumExchangesPerTS, int numIterationsExchange, double deflectionUnderRelax) 114 | { 115 | AbaqusCoSimulationSolver abaqusCoSimulationSolver = 116 | ((AbaqusCoSimulationSolver) m_sim.getSolverManager().getSolver(AbaqusCoSimulationSolver.class)); 117 | FieldExchangeControls fieldExchangeControls = abaqusCoSimulationSolver.getFieldExchangeControls(); 118 | 119 | // Setting the number of exchanges and inner iterations per exchange 120 | fieldExchangeControls.setNumExchangesMin(minNumExchangesPerTS); 121 | fieldExchangeControls.setNumIterations(numIterationsExchange); 122 | 123 | // Setting the inputed Abaqus deflection under relaxation factor 124 | fieldExchangeControls.getIterUrfOptions().setSelected(AbaqusIterUrfOptions.CONST); 125 | fieldExchangeControls.setIncomingFieldURF(deflectionUnderRelax); 126 | } 127 | } -------------------------------------------------------------------------------- /CoSimulationAbaqus_9_02_007.java: -------------------------------------------------------------------------------- 1 | package starClasses; 2 | 3 | import star.base.neo.NeoObjectVector; 4 | import star.common.Boundary; 5 | import star.common.PrimitiveFieldFunction; 6 | import star.common.Region; 7 | import star.common.Simulation; 8 | import star.cosimulation.abaqus.*; 9 | import star.cosimulation.common.*; 10 | 11 | public class CoSimulationAbaqus_9_02_007 12 | { 13 | private Simulation m_sim; 14 | private Region m_region; 15 | private AbaqusCoSimulation m_abaqusCoSimulation; 16 | 17 | public CoSimulationAbaqus_9_02_007(Simulation sim, String regionName) 18 | { 19 | m_sim = sim; 20 | m_region = m_sim.getRegionManager().getRegion(regionName); 21 | 22 | m_abaqusCoSimulation = m_sim.get(CoSimulationManager.class).createCoSimulation(AbaqusCoSimulation.class, "Abaqus Co-Simulation"); 23 | 24 | PrimitiveFieldFunction primitiveFieldFunction_0 = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction("StaticPressure")); 25 | PrimitiveFieldFunction primitiveFieldFunction_1 = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction("WallShearStress")); 26 | m_abaqusCoSimulation.setExportedFieldFunctions(new NeoObjectVector(new Object[] {primitiveFieldFunction_0, primitiveFieldFunction_1})); 27 | 28 | PrimitiveFieldFunction primitiveFieldFunction_2 = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction("NodalDisplacement")); 29 | PrimitiveFieldFunction primitiveFieldFunction_3 = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction("Velocity")); 30 | m_abaqusCoSimulation.setImportedFieldFunctions(new NeoObjectVector(new Object[] {primitiveFieldFunction_2, primitiveFieldFunction_3})); 31 | } 32 | 33 | /** 34 | * This method sets the coupled boundaries for the Abaqus Co-Simulation 35 | * @param boundaryNames names of the coupled boundaries to be included in the FSI simulation 36 | */ 37 | public void setCouplingBoundaries(String[] boundaryNames) 38 | { 39 | for(int i = 0; i < boundaryNames.length; i++) 40 | { 41 | Boundary boundary = m_region.getBoundaryManager().getBoundary(boundaryNames[i]); 42 | m_abaqusCoSimulation.getCouplingSurfaces().setObjects(boundary); 43 | } 44 | } 45 | 46 | /** 47 | * This method sets up the Abaqus execution settings in Star-CCM+ 48 | * @param jobName desired name of the Abaqus job 49 | * @param inputFilePath file path for the Abaqus input file, example 50 | * "D:\\Users\\cj8q5\\Simulations\\March 2013\\FSI_Comb_9\\Abaqus\\CombPlate.inp" 51 | * @param abaqusExecutableName executable file name, example "abq6122.bat" 52 | * @param numCPUs number of CPU's to use on the Abaqus side of the FSI simulation 53 | */ 54 | public void setAbaqusExecutionSettings(String jobName, String inputFilePath, String abaqusExecutableName, int numCPUs) 55 | { 56 | //File inputFile = new File(inputFilePath); 57 | 58 | AbaqusExecution abaqusExecution_0 = m_abaqusCoSimulation.getAbaqusExecution(); 59 | abaqusExecution_0.setJobName(jobName); 60 | abaqusExecution_0.setJobFileNameSilently(inputFilePath); 61 | abaqusExecution_0.setExecutableName(abaqusExecutableName); 62 | abaqusExecution_0.setNumCpus(numCPUs); 63 | } 64 | 65 | /** 66 | * This method sets up the coupling algorithm settings 67 | * @param couplingScheme "implicit" for implicit coupling "explicit" for explicit 68 | * @param rendezvousOption "Star Leads" for letting Star-CCM+ lead and "Abaqus Leads" for letting Abaqus lead 69 | * @param couplingTimeStep the coupling time step for the co-simulation 70 | */ 71 | public void abaqusCouplingAlgorithm(String couplingScheme, String rendezvousOption, double couplingTimeStep) 72 | { 73 | // Setting the coupling scheme 74 | CouplingAlgorithm couplingAlgorithm = m_abaqusCoSimulation.getCouplingAlgorithm(); 75 | if(couplingScheme.equals("Implicit")) 76 | { 77 | couplingAlgorithm.setCouplingScheme(1); 78 | } 79 | if(couplingScheme.equals("Explicit")) 80 | { 81 | couplingAlgorithm.setCouplingScheme(0); 82 | } 83 | 84 | // Setting if Star or Abaqus leads the co-simulation 85 | if(rendezvousOption.equals("Star Leads")) 86 | { 87 | couplingAlgorithm.getRendezvousOptions().setSelected(AbaqusRendezvousOptions.STARCCM_LEADS); 88 | } 89 | if(rendezvousOption.equals("Abaqus Leads")) 90 | { 91 | couplingAlgorithm.getRendezvousOptions().setSelected(AbaqusRendezvousOptions.ABAQUS_LEADS); 92 | } 93 | 94 | // Setting the constant coupling time step 95 | couplingAlgorithm.getConstCouplingDtQty().setValue(couplingTimeStep); 96 | } 97 | 98 | /** 99 | * This method sets the field exchange controls for the Abaqus Co-Simulation 100 | * @param minNumExchangesPerTS 101 | * @param numIterationsExchange 102 | * @param deflectionUnderRelax 103 | */ 104 | public void setFieldExchangeControls(int minNumExchangesPerTS, int numIterationsExchange, double deflectionUnderRelax) 105 | { 106 | AbaqusCoSimulationSolver abaqusCoSimulationSolver = 107 | ((AbaqusCoSimulationSolver) m_sim.getSolverManager().getSolver(AbaqusCoSimulationSolver.class)); 108 | FieldExchangeControls fieldExchangeControls = abaqusCoSimulationSolver.getFieldExchangeControls(); 109 | 110 | // Setting the number of exchanges and inner iterations per exchange 111 | fieldExchangeControls.setNumExchangesMin(minNumExchangesPerTS); 112 | fieldExchangeControls.setNumIterations(numIterationsExchange); 113 | 114 | // Setting the inputed Abaqus deflection under relaxation factor 115 | fieldExchangeControls.getIterUrfOptions().setSelected(AbaqusIterUrfOptions.CONST); 116 | fieldExchangeControls.setIncomingFieldURF(deflectionUnderRelax); 117 | } 118 | 119 | /** 120 | * This method sets mapper's tolerance settings 121 | * @param normalTolerance 122 | */ 123 | public void setMapperTolSettings(double normalTolerance) 124 | { 125 | MapperSettings mapperSettings = m_abaqusCoSimulation.getMapperSettings(); 126 | mapperSettings.setMapperProximityTol(normalTolerance); 127 | } 128 | 129 | } 130 | -------------------------------------------------------------------------------- /ContinuumBuilder.java: -------------------------------------------------------------------------------- 1 | package starClasses; 2 | 3 | import star.base.neo.NeoObjectVector; 4 | import star.common.ConstantVectorProfileMethod; 5 | import star.common.MeshContinuum; 6 | import star.common.MeshManager; 7 | import star.common.PhysicsContinuum; 8 | import star.common.Region; 9 | import star.common.Simulation; 10 | import star.coupledflow.CoupledImplicitSolver; 11 | import star.flow.VelocityProfile; 12 | import star.meshing.AbsoluteMinimumSize; 13 | import star.meshing.BaseSize; 14 | import star.meshing.GenericAbsoluteSize; 15 | import star.meshing.MeshPipelineController; 16 | import star.meshing.RelativeOrAbsoluteOption; 17 | import star.meshing.SurfaceSize; 18 | import star.prismmesher.NumPrismLayers; 19 | import star.prismmesher.PrismLayerStretching; 20 | import star.prismmesher.PrismMesherModel; 21 | import star.prismmesher.PrismThickness; 22 | import star.trimmer.TrimmerMeshingModel; 23 | 24 | /** This class contains methods for creating the physics and mesh continuum in the simulation 25 | * 26 | * @author cj8q5 27 | * 28 | */ 29 | public class ContinuumBuilder 30 | { 31 | private Simulation m_sim; 32 | 33 | public ContinuumBuilder(Simulation sim) 34 | { 35 | m_sim = sim; 36 | } 37 | 38 | /** This creates a physics continua with a specified name 39 | * 40 | * @param name presentation name of the physics continua 41 | */ 42 | public PhysicsContinuum createPhysicsContinua(String name) 43 | { 44 | PhysicsContinuum physics = m_sim.getContinuumManager().createContinuum(PhysicsContinuum.class); 45 | physics.setPresentationName(name); 46 | return physics; 47 | 48 | }//end method createPhysicsContinua 49 | 50 | /** 51 | * This method deletes a physics continuum from the simulation 52 | * @param physicsName 53 | */ 54 | public void deletePhysicsContinuum(String physicsName) 55 | { 56 | PhysicsContinuum physics = (PhysicsContinuum) m_sim.getContinuumManager().getContinuum(physicsName); 57 | m_sim.getContinuumManager().remove(physics); 58 | } 59 | 60 | /** 61 | * This method sets the physics of a specified region 62 | * @param regionName 63 | * @param physicsName 64 | */ 65 | public void setRegionPhysics(String regionName, String physicsName) 66 | { 67 | PhysicsContinuum physics = (PhysicsContinuum) m_sim.getContinuumManager().getContinuum(physicsName); 68 | Region region = m_sim.getRegionManager().getRegion(regionName); 69 | 70 | physics.add(region); 71 | } 72 | 73 | /** 74 | * This changes the name of a physics continuum 75 | * @param oldName 76 | * @param newName 77 | */ 78 | public PhysicsContinuum setPhysicsName(String oldName, String newName) 79 | { 80 | PhysicsContinuum physics = (PhysicsContinuum) m_sim.getContinuumManager().getContinuum(oldName); 81 | physics.setPresentationName(newName); 82 | return physics; 83 | } 84 | 85 | /** 86 | * This method sets the courant number for the coupled implicit solver 87 | * @param courantNumber 88 | */ 89 | public void setCourantNumber(double courantNumber) 90 | { 91 | m_sim.getSolverManager().getSolver(CoupledImplicitSolver.class).setCFL(courantNumber); 92 | } 93 | 94 | /** This method sets the initial velocity conditions in the fluid domains 95 | * 96 | * @param continuumName name of the physics continua where inlet velocity will be set 97 | * @param initialVel value for the initial velocity 98 | */ 99 | public void setInitialConditionsVel(PhysicsContinuum physics, double[] initialVel) 100 | { 101 | // Setting the initial condition of the velocity for the physics of the model 102 | VelocityProfile velocity = physics.getInitialConditions().get(VelocityProfile.class); 103 | velocity.getMethod(ConstantVectorProfileMethod.class).getQuantity().setComponents(initialVel[0], initialVel[1], initialVel[2]); 104 | }//end method setInitialConditions 105 | 106 | /** This method creates a mesh continua with a specified name 107 | * 108 | * @param name presentation name for the new mesh continua 109 | */ 110 | public void createMeshContinua(String name) 111 | { 112 | MeshContinuum meshContinuum = m_sim.getContinuumManager().createContinuum(MeshContinuum.class); 113 | meshContinuum.setPresentationName(name); 114 | 115 | }//end method createMeshContinua 116 | 117 | /** 118 | * This method converts a 3d mesh to a 2d mesh 119 | * @param regionName 120 | * @param tolerance 121 | */ 122 | public void convertMeshTo2D(String regionName, double tolerance) 123 | { 124 | MeshManager meshManager = m_sim.getMeshManager(); 125 | 126 | Region region = m_sim.getRegionManager().getRegion(regionName); 127 | 128 | meshManager.convertTo2d(tolerance, new NeoObjectVector(new Object[] {region}), true); 129 | } 130 | 131 | /** This method activates the trimmer mesh and sets its respective global mesh settings 132 | * 133 | * @param continuumName the name of the mesh continua where global mesh settings will be set 134 | * @param baseSize value for the global base size 135 | * @param minSurfSize value for the minimum surface size 136 | * @param targetSurfSize value for the target surface size 137 | */ 138 | public void activateTrimmerMesh(String continuumName, double baseSize, double minSurfSize, double targetSurfSize) 139 | { 140 | MeshContinuum trimMesh = ((MeshContinuum) m_sim.getContinuumManager().getContinuum(continuumName)); 141 | trimMesh.enable(TrimmerMeshingModel.class); 142 | 143 | trimMesh.getReferenceValues().get(BaseSize.class).setValue(baseSize); 144 | 145 | SurfaceSize surfaceSize = trimMesh.getReferenceValues().get(SurfaceSize.class); 146 | surfaceSize.getRelativeOrAbsoluteOption().setSelected(RelativeOrAbsoluteOption.ABSOLUTE); 147 | 148 | AbsoluteMinimumSize absoluteMinimumSize_0 = surfaceSize.getAbsoluteMinimumSize(); 149 | absoluteMinimumSize_0.getValue().setValue(minSurfSize); 150 | absoluteMinimumSize_0.getValue().setValue(targetSurfSize); 151 | 152 | }//end method activateTrimmerMesh 153 | 154 | /** This method activates the prism layer mesh and sets its respective global mesh settings 155 | * 156 | * @param continuumName the mesh continua where the prism layer mesher will be activated 157 | * @param layerStretching value for the stretching in the prism layer 158 | * @param numLayer value for the number of prism layers 159 | * @param layerThickness value for the thickness of the first prism layer 160 | */ 161 | public void activatePrismMesh(String continuumName, double layerStretching, int numLayer, double layerThickness) 162 | { 163 | MeshContinuum prismMesh = ((MeshContinuum) m_sim.getContinuumManager().getContinuum(continuumName)); 164 | prismMesh.enable(PrismMesherModel.class); 165 | 166 | PrismLayerStretching prismLayerStretching_0 = prismMesh.getReferenceValues().get(PrismLayerStretching.class); 167 | prismLayerStretching_0.setStretching(layerStretching); 168 | 169 | NumPrismLayers numPrismLayers_0 = prismMesh.getReferenceValues().get(NumPrismLayers.class); 170 | numPrismLayers_0.setNumLayers(numLayer); 171 | 172 | PrismThickness prismThickness_0 = prismMesh.getReferenceValues().get(PrismThickness.class); 173 | prismThickness_0.getRelativeOrAbsoluteOption().setSelected(RelativeOrAbsoluteOption.ABSOLUTE); 174 | 175 | GenericAbsoluteSize genericAbsoluteSize_0 = ((GenericAbsoluteSize) prismThickness_0.getAbsoluteSize()); 176 | genericAbsoluteSize_0.getValue().setValue(layerThickness); 177 | 178 | }//end method activatePrismMesh 179 | 180 | /** This method starts the volume mesher 181 | */ 182 | public void startVolumeMesh() 183 | { 184 | MeshPipelineController meshPipelineController_0 = m_sim.get(MeshPipelineController.class); 185 | meshPipelineController_0.generateVolumeMesh(); 186 | 187 | }//end method startVolumeMesh 188 | 189 | }//end class ContiuumBuilder 190 | -------------------------------------------------------------------------------- /ContiuumBuilder.java: -------------------------------------------------------------------------------- 1 | package starClasses; 2 | 3 | import star.base.neo.NeoObjectVector; 4 | import star.common.ConstantVectorProfileMethod; 5 | import star.common.MeshContinuum; 6 | import star.common.MeshManager; 7 | import star.common.PhysicsContinuum; 8 | import star.common.Region; 9 | import star.common.Simulation; 10 | import star.coupledflow.CoupledImplicitSolver; 11 | import star.flow.VelocityProfile; 12 | import star.meshing.AbsoluteMinimumSize; 13 | import star.meshing.BaseSize; 14 | import star.meshing.GenericAbsoluteSize; 15 | import star.meshing.MeshPipelineController; 16 | import star.meshing.RelativeOrAbsoluteOption; 17 | import star.meshing.SurfaceSize; 18 | import star.prismmesher.NumPrismLayers; 19 | import star.prismmesher.PrismLayerStretching; 20 | import star.prismmesher.PrismMesherModel; 21 | import star.prismmesher.PrismThickness; 22 | import star.trimmer.TrimmerMeshingModel; 23 | 24 | /** This class contains methods for creating the physics and mesh continuum in the simulation 25 | * 26 | * @author cj8q5 27 | * 28 | */ 29 | public class ContiuumBuilder 30 | { 31 | private Simulation m_sim; 32 | 33 | public ContiuumBuilder(Simulation sim) 34 | { 35 | m_sim = sim; 36 | } 37 | 38 | /** This creates a physics continua with a specified name 39 | * 40 | * @param name presentation name of the physics continua 41 | */ 42 | public PhysicsContinuum createPhysicsContinua(String name) 43 | { 44 | PhysicsContinuum physics = m_sim.getContinuumManager().createContinuum(PhysicsContinuum.class); 45 | physics.setPresentationName(name); 46 | return physics; 47 | 48 | }//end method createPhysicsContinua 49 | 50 | /** 51 | * This changes the name of a physics continuum 52 | * @param oldName 53 | * @param newName 54 | */ 55 | public PhysicsContinuum setPhysicsName(String oldName, String newName) 56 | { 57 | PhysicsContinuum physics = (PhysicsContinuum) m_sim.getContinuumManager().getContinuum(oldName); 58 | physics.setPresentationName(newName); 59 | return physics; 60 | } 61 | 62 | /** 63 | * This method sets the courant number for the coupled implicit solver 64 | * @param courantNumber 65 | */ 66 | public void setCourantNumber(double courantNumber) 67 | { 68 | m_sim.getSolverManager().getSolver(CoupledImplicitSolver.class).setCFL(courantNumber); 69 | } 70 | 71 | /** This method sets the initial velocity conditions in the fluid domains 72 | * 73 | * @param continuumName name of the physics continua where inlet velocity will be set 74 | * @param initialVel value for the initial velocity 75 | */ 76 | public void setInitialConditionsVel(PhysicsContinuum physics, double[] initialVel) 77 | { 78 | // Setting the initial condition of the velocity for the physics of the model 79 | VelocityProfile velocity = physics.getInitialConditions().get(VelocityProfile.class); 80 | velocity.getMethod(ConstantVectorProfileMethod.class).getQuantity().setComponents(initialVel[0], initialVel[1], initialVel[2]); 81 | }//end method setInitialConditions 82 | 83 | /** This method creates a mesh continua with a specified name 84 | * 85 | * @param name presentation name for the new mesh continua 86 | */ 87 | public void createMeshContinua(String name) 88 | { 89 | MeshContinuum meshContinuum = m_sim.getContinuumManager().createContinuum(MeshContinuum.class); 90 | meshContinuum.setPresentationName(name); 91 | 92 | }//end method createMeshContinua 93 | 94 | /** 95 | * This method converts a 3d mesh to a 2d mesh 96 | * @param regionName 97 | * @param tolerance 98 | */ 99 | public void convertMeshTo2D(String regionName, double tolerance) 100 | { 101 | MeshManager meshManager = m_sim.getMeshManager(); 102 | 103 | Region region = m_sim.getRegionManager().getRegion(regionName); 104 | 105 | meshManager.convertTo2d(tolerance, new NeoObjectVector(new Object[] {region}), true); 106 | } 107 | 108 | /** This method activates the trimmer mesh and sets its respective global mesh settings 109 | * 110 | * @param continuumName the name of the mesh continua where global mesh settings will be set 111 | * @param baseSize value for the global base size 112 | * @param minSurfSize value for the minimum surface size 113 | * @param targetSurfSize value for the target surface size 114 | */ 115 | public void activateTrimmerMesh(String continuumName, double baseSize, double minSurfSize, double targetSurfSize) 116 | { 117 | MeshContinuum trimMesh = ((MeshContinuum) m_sim.getContinuumManager().getContinuum(continuumName)); 118 | trimMesh.enable(TrimmerMeshingModel.class); 119 | 120 | trimMesh.getReferenceValues().get(BaseSize.class).setValue(baseSize); 121 | 122 | SurfaceSize surfaceSize = trimMesh.getReferenceValues().get(SurfaceSize.class); 123 | surfaceSize.getRelativeOrAbsoluteOption().setSelected(RelativeOrAbsoluteOption.ABSOLUTE); 124 | 125 | AbsoluteMinimumSize absoluteMinimumSize_0 = surfaceSize.getAbsoluteMinimumSize(); 126 | absoluteMinimumSize_0.getValue().setValue(minSurfSize); 127 | absoluteMinimumSize_0.getValue().setValue(targetSurfSize); 128 | 129 | }//end method activateTrimmerMesh 130 | 131 | /** This method activates the prism layer mesh and sets its respective global mesh settings 132 | * 133 | * @param continuumName the mesh continua where the prism layer mesher will be activated 134 | * @param layerStretching value for the stretching in the prism layer 135 | * @param numLayer value for the number of prism layers 136 | * @param layerThickness value for the thickness of the first prism layer 137 | */ 138 | public void activatePrismMesh(String continuumName, double layerStretching, int numLayer, double layerThickness) 139 | { 140 | MeshContinuum prismMesh = ((MeshContinuum) m_sim.getContinuumManager().getContinuum(continuumName)); 141 | prismMesh.enable(PrismMesherModel.class); 142 | 143 | PrismLayerStretching prismLayerStretching_0 = prismMesh.getReferenceValues().get(PrismLayerStretching.class); 144 | prismLayerStretching_0.setStretching(layerStretching); 145 | 146 | NumPrismLayers numPrismLayers_0 = prismMesh.getReferenceValues().get(NumPrismLayers.class); 147 | numPrismLayers_0.setNumLayers(numLayer); 148 | 149 | PrismThickness prismThickness_0 = prismMesh.getReferenceValues().get(PrismThickness.class); 150 | prismThickness_0.getRelativeOrAbsoluteOption().setSelected(RelativeOrAbsoluteOption.ABSOLUTE); 151 | 152 | GenericAbsoluteSize genericAbsoluteSize_0 = ((GenericAbsoluteSize) prismThickness_0.getAbsoluteSize()); 153 | genericAbsoluteSize_0.getValue().setValue(layerThickness); 154 | 155 | }//end method activatePrismMesh 156 | 157 | /** This method starts the volume mesher 158 | */ 159 | public void startVolumeMesh() 160 | { 161 | MeshPipelineController meshPipelineController_0 = m_sim.get(MeshPipelineController.class); 162 | meshPipelineController_0.generateVolumeMesh(); 163 | 164 | }//end method startVolumeMesh 165 | 166 | }//end class ContiuumBuilder 167 | -------------------------------------------------------------------------------- /DataReader.java: -------------------------------------------------------------------------------- 1 | package starClasses; 2 | 3 | import java.io.BufferedReader; 4 | 5 | import java.io.FileReader; 6 | import java.util.Scanner; 7 | 8 | import starClasses.GeoData; 9 | import javax.swing.JOptionPane; 10 | 11 | /** 12 | * This class reads data from the various input file. 13 | */ 14 | public class DataReader 15 | { 16 | private GeoData geoData; 17 | private MeshElementData meshElementData; 18 | private MeshSpacingData meshSpacingData; 19 | 20 | public void readGeometryData(String fileToRead) 21 | { 22 | try 23 | { 24 | // Read input file: fileToRead 25 | FileReader file = new FileReader(fileToRead); 26 | BufferedReader reader = new BufferedReader(file); 27 | Scanner scanner = new Scanner(reader); 28 | 29 | // Grabbing the geometry data for the plate 30 | scanner.nextLine(); 31 | scanner.nextLine(); 32 | double plateLength = scanner.nextDouble(); 33 | double plateHeight = scanner.nextDouble(); 34 | double plateWidth = scanner.nextDouble(); 35 | 36 | // Grabbing the geometry data for the channels 37 | scanner.nextLine(); 38 | scanner.nextLine(); 39 | scanner.nextLine(); 40 | scanner.nextLine(); 41 | double smallChannelHeight = scanner.nextDouble(); 42 | double largeChannelHeight = scanner.nextDouble(); 43 | 44 | // Grabbing the geometry data for the plenums 45 | scanner.nextLine(); 46 | scanner.nextLine(); 47 | scanner.nextLine(); 48 | scanner.nextLine(); 49 | double inletLength = scanner.nextDouble(); 50 | double outletLength = scanner.nextDouble(); 51 | 52 | geoData = new GeoData(plateLength, plateHeight, plateWidth, 53 | smallChannelHeight, largeChannelHeight, inletLength, outletLength); 54 | } 55 | 56 | catch (Exception e) 57 | { 58 | // Create a window displaying the error message. 59 | JOptionPane.showMessageDialog(null, e.toString()); 60 | } 61 | 62 | } 63 | 64 | public void readMeshElementData(String fileToRead) 65 | { 66 | try 67 | { 68 | // Read input file: fileToRead 69 | FileReader fr = new FileReader(fileToRead); 70 | BufferedReader br = new BufferedReader(fr); 71 | Scanner sc = new Scanner(br); 72 | 73 | // Grabbing the mesh data for the X and Z direction for the inlet, outlet, and extruded direction 74 | sc.nextLine(); 75 | int extrudeCell = sc.nextInt(); 76 | int inletX = sc.nextInt(); 77 | int outletX = sc.nextInt(); 78 | 79 | // Grabbing the mesh data for the inlet plenum parts 80 | sc.nextLine(); 81 | sc.nextLine(); 82 | int largeInletY = sc.nextInt(); 83 | int smallInletY = sc.nextInt(); 84 | int plateInletY = sc.nextInt(); 85 | 86 | // Grabbing the mesh data for the outlet plenum parts 87 | sc.nextLine(); 88 | sc.nextLine(); 89 | int largeOutletY = sc.nextInt(); 90 | int smallOutletY = sc.nextInt(); 91 | int plateOutletY = sc.nextInt(); 92 | 93 | // Grabbing the mesh data for the small channel part 94 | sc.nextLine(); 95 | sc.nextLine(); 96 | int smChannelX = sc.nextInt(); 97 | int smChannelY = sc.nextInt(); 98 | 99 | // Grabbing the mesh data for the large channel part 100 | sc.nextLine(); 101 | sc.nextLine(); 102 | int lgChannelX = sc.nextInt(); 103 | int lgChannelY = sc.nextInt(); 104 | 105 | meshElementData = new MeshElementData(extrudeCell, inletX, largeInletY, smallInletY, plateInletY, 106 | outletX, largeOutletY, smallOutletY, plateOutletY, 107 | smChannelX, smChannelY, lgChannelX, lgChannelY); 108 | } 109 | 110 | catch (Exception e) 111 | { 112 | // Create a window displaying the error message. 113 | JOptionPane.showMessageDialog(null, e.toString()); 114 | } 115 | } 116 | 117 | public void readMeshSpacingData(String fileToRead) 118 | { 119 | try 120 | { 121 | // Read input file: fileToRead 122 | FileReader fr = new FileReader(fileToRead); 123 | BufferedReader br = new BufferedReader(fr); 124 | Scanner sc = new Scanner(br); 125 | 126 | // Grabbing the mesh data for the X and Z direction for the inlet, outlet, and extruded direction 127 | sc.nextLine(); 128 | double inletSpacingX = sc.nextDouble(); 129 | double inletSpacingY = sc.nextDouble(); 130 | 131 | // Grabbing the mesh data for the inlet plenum parts 132 | sc.nextLine(); 133 | sc.nextLine(); 134 | double outletSpacingX = sc.nextDouble(); 135 | double outletSpacingY = sc.nextDouble(); 136 | 137 | // Grabbing the mesh data for the outlet plenum parts 138 | sc.nextLine(); 139 | sc.nextLine(); 140 | double smChannelSpacingX = sc.nextDouble(); 141 | double smChannelSpacingY = sc.nextDouble(); 142 | 143 | // Grabbing the mesh data for the small channel part 144 | sc.nextLine(); 145 | sc.nextLine(); 146 | double lgChannelSpacingX = sc.nextDouble(); 147 | double lgChannelSpacingY = sc.nextDouble(); 148 | 149 | meshSpacingData = new MeshSpacingData(inletSpacingX, inletSpacingY, outletSpacingX, outletSpacingY, smChannelSpacingX, 150 | smChannelSpacingY, lgChannelSpacingX, lgChannelSpacingY); 151 | } 152 | 153 | catch (Exception e) 154 | { 155 | // Create a window displaying the error message. 156 | JOptionPane.showMessageDialog(null, e.toString()); 157 | } 158 | } 159 | 160 | // Returns the object GeoData that contains the geometry parameters 161 | public GeoData getGeoDetails() 162 | { 163 | return geoData; 164 | } 165 | 166 | // Returns the object MeshElementData that contains the mesh element data 167 | public MeshElementData getMeshElementDetails() 168 | { 169 | return meshElementData; 170 | } 171 | 172 | // Returns the object MeshSpacingData that contains the mesh element data 173 | public MeshSpacingData getMeshSpacingDetails() 174 | { 175 | return meshSpacingData; 176 | } 177 | 178 | }//end class DataReader -------------------------------------------------------------------------------- /DerivedParts.java: -------------------------------------------------------------------------------- 1 | package starClasses; 2 | 3 | import star.base.neo.DoubleVector; 4 | import star.base.neo.IntVector; 5 | import star.base.neo.NeoObjectVector; 6 | import star.common.Coordinate; 7 | import star.common.LabCoordinateSystem; 8 | import star.common.Simulation; 9 | import star.common.Units; 10 | import star.vis.ConstrainedPlaneSection; 11 | import star.vis.LinePart; 12 | import star.vis.PlaneSection; 13 | import star.common.Region; 14 | 15 | /** 16 | * This class is for creating all of the derived parts in the simulation 17 | * 18 | * @author cj8q5 19 | * 20 | */ 21 | public class DerivedParts 22 | { 23 | private Simulation m_sim; 24 | private String[] m_regionNames; 25 | private Units m_units; 26 | 27 | public DerivedParts(Simulation sim, String[] regionNames) 28 | { 29 | m_sim = sim; 30 | m_regionNames = regionNames; 31 | m_units = m_sim.getUnitsManager(). 32 | getPreferredUnits(new IntVector(new int[] {0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})); 33 | 34 | } 35 | 36 | /** This method is for creating a plane within a simulation 37 | * 38 | * @param regionName the region within which the plane will be in 39 | * @param directionVector the direction vector for specifying the direction of the plane 40 | * @param locationVector the coordinates of the plane 41 | * @param planeName presentation name of the plane 42 | */ 43 | public void createSectionPlane(double[] directionVector, double[] locationVector, String planeName) 44 | { 45 | Object[] regionVector = null; 46 | if (m_regionNames.length > 1) 47 | { 48 | regionVector = new Object[m_regionNames.length]; 49 | for (int i = 0; i < m_regionNames.length; i++) 50 | { 51 | Region region = m_sim.getRegionManager().getRegion(m_regionNames[i]); 52 | regionVector[i] = region; 53 | 54 | } 55 | } 56 | if (m_regionNames.length == 1) 57 | { 58 | regionVector = new Object[m_regionNames.length]; 59 | Region region = m_sim.getRegionManager().getRegion(m_regionNames[0]); 60 | regionVector[0] = region; 61 | } 62 | //Region region = sim.getRegionManager().getRegion(regionName); 63 | //PlaneSection CenterPlaneYZ = (PlaneSection) sim.getPartManager().createImplicitPart(new NeoObjectVector(new Object[] {region}), 64 | PlaneSection CenterPlaneYZ = (PlaneSection) m_sim.getPartManager().createImplicitPart(new NeoObjectVector(regionVector), 65 | new DoubleVector(directionVector), 66 | new DoubleVector(locationVector), 0, 1, 67 | new DoubleVector(new double[] {0.0})); 68 | CenterPlaneYZ.setValueMode(0); 69 | CenterPlaneYZ.setPresentationName(planeName); 70 | 71 | }//end method createSectionPlane 72 | 73 | /** 74 | * This method creates a constrained plane 75 | * @param normalVector the normal vector for the constrained plane 76 | * @param origin the origin of the normal vector 77 | * @param contourCoordinates coordinates of points that define the countour of the constrained plane 78 | */ 79 | public ConstrainedPlaneSection createConstrainedPlane(String planeName, double[] normalVector, double[] origin, double[] contourCoordinates) 80 | { 81 | 82 | Region region = m_sim.getRegionManager().getRegion(m_regionNames[0]); 83 | 84 | ConstrainedPlaneSection constrainedPlaneSection = 85 | (ConstrainedPlaneSection) m_sim.getPartManager().createConstrainedPlaneImplicitPart( 86 | new NeoObjectVector(new Object[] {region}), new DoubleVector(contourCoordinates), m_units); 87 | constrainedPlaneSection.setReevaluateStatus(false); 88 | 89 | LabCoordinateSystem labCoordinateSystem = 90 | m_sim.getCoordinateSystemManager().getLabCoordinateSystem(); 91 | constrainedPlaneSection.setCoordinateSystem(labCoordinateSystem); 92 | 93 | Coordinate coordinate_0 = 94 | constrainedPlaneSection.getOriginCoordinate(); 95 | coordinate_0.setValue(new DoubleVector(origin)); 96 | 97 | Coordinate coordinate_1 = 98 | constrainedPlaneSection.getNormalCoordinate(); 99 | coordinate_1.setValue(new DoubleVector(normalVector)); 100 | 101 | coordinate_0.setCoordinate(m_units, m_units, m_units, new DoubleVector(origin)); 102 | coordinate_1.setCoordinate(m_units, m_units, m_units, new DoubleVector(normalVector)); 103 | 104 | constrainedPlaneSection.setReevaluateStatus(true); 105 | constrainedPlaneSection.setPresentationName(planeName); 106 | return constrainedPlaneSection; 107 | } 108 | 109 | /** This method is for creating a line probe within a simulation 110 | * 111 | */ 112 | public LinePart createLineProbe(double[] coordinate_0, double[] coordinate_1, int lineResolution, String lineProbeName) 113 | { 114 | Object[] regionVector = new Object[m_regionNames.length]; 115 | for (int i = 0; i < m_regionNames.length; i++) 116 | { 117 | Region region = m_sim.getRegionManager().getRegion(m_regionNames[i]); 118 | regionVector[i] = region; 119 | } 120 | LinePart linePart = m_sim.getPartManager().createLinePart(new NeoObjectVector(regionVector), 121 | new DoubleVector(coordinate_0), 122 | new DoubleVector(coordinate_1), lineResolution); 123 | linePart.setPresentationName(lineProbeName); 124 | return linePart; 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /DirectedMesher8_02_008.java: -------------------------------------------------------------------------------- 1 | package starClasses; 2 | 3 | import star.base.neo.DoubleVector; 4 | import star.base.neo.NeoObjectVector; 5 | import star.base.neo.StringVector; 6 | import star.cadmodeler.SolidModelPart; 7 | import star.common.PartSurface; 8 | import star.common.Simulation; 9 | import star.common.SimulationPartManager; 10 | import star.meshing.MeshOperationManager; 11 | import star.sweptmesher.DirectedMeshOperation; 12 | import star.sweptmesher.DirectedMeshPartCollection; 13 | import star.sweptmesher.DirectedPatchSourceMesh; 14 | import star.sweptmesher.DirectedSideMeshDistribution; 15 | import star.sweptmesher.PatchCurve; 16 | import star.sweptmesher.PatchVertex; 17 | import star.sweptmesher.StretchingFunction; 18 | import star.vis.Scene; 19 | 20 | /** This class creates directed meshes on rectangular parts 21 | * 22 | * @author cj8q5 23 | * 24 | */ 25 | 26 | public class DirectedMesher8_02_008 27 | { 28 | private Simulation m_sim = null; 29 | private Scene m_scene = null; 30 | private SolidModelPart m_part2Mesh = null; 31 | private DirectedMeshOperation m_directedMeshOperation = null; 32 | private DirectedMeshPartCollection m_directedMeshPartCollection = null; 33 | private DirectedPatchSourceMesh m_directedPatchSourceMesh = null; 34 | private PatchCurve m_patchCurveX = null; 35 | private PatchCurve m_patchCurveY = null; 36 | 37 | @SuppressWarnings("unchecked") 38 | public DirectedMesher8_02_008(Simulation sim, String partName) 39 | { 40 | m_sim = sim; 41 | 42 | m_scene = sim.getSceneManager().createScene("Directed Mesh"); 43 | 44 | m_part2Mesh = ((SolidModelPart) sim.get(SimulationPartManager.class).getPart(partName)); 45 | 46 | m_directedMeshOperation = (DirectedMeshOperation) sim.get(MeshOperationManager.class). 47 | createDirectedMeshOperation(m_scene, new NeoObjectVector(new Object[] {m_part2Mesh})); 48 | 49 | m_directedMeshPartCollection = 50 | ((DirectedMeshPartCollection) m_directedMeshOperation.getGuidedMeshPartCollectionManager().getObject(partName)); 51 | } 52 | 53 | @SuppressWarnings("unchecked") 54 | public void setSourceTargetSurfaces(String sourceSurf, String targetSurf) 55 | { 56 | // Setting the target and source surfaces 57 | PartSurface sourceSurface = m_part2Mesh.getPartSurfaceManager().getPartSurface(sourceSurf); 58 | m_directedMeshOperation.getSourceSurfaceGroup().setObjects(sourceSurface); 59 | 60 | PartSurface targetSurface = m_part2Mesh.getPartSurfaceManager().getPartSurface(targetSurf); 61 | m_directedMeshOperation.getTargetSurfaceGroup().setObjects(targetSurface); 62 | 63 | m_directedMeshOperation.getGuidedSurfaceMeshBaseManager().validateConfigurationForPatchMeshCreation(m_directedMeshPartCollection, 64 | new NeoObjectVector(new Object[] {sourceSurface}), new NeoObjectVector(new Object[] {targetSurface})); 65 | m_directedMeshOperation.getGuidedSurfaceMeshBaseManager().createPatchSourceMesh( 66 | new NeoObjectVector(new Object[] {sourceSurface}), m_directedMeshPartCollection); 67 | } 68 | 69 | /** 70 | * This method creates a patch mesh for the directed mesher and autopopulates the feature edges of the model 71 | */ 72 | public void createPatchMesh() 73 | { 74 | // Creating the patch mesh 75 | m_directedPatchSourceMesh = ((DirectedPatchSourceMesh) m_directedMeshOperation.getGuidedSurfaceMeshBaseManager().getObject("Patch Mesh")); 76 | 77 | // Auto populating the edges of the box 78 | m_directedPatchSourceMesh.autopopulateFeatureEdges(); 79 | } 80 | 81 | /** 82 | * This method splits a specified patch curve at a specified location 83 | * 84 | * @param patchCurveName name of the patch curve to be split 85 | * @param patchCurveSplitLocation X, Y, and Z coordinates of the split (must be along the line that the patch curve lies) 86 | */ 87 | public void splitPatchCurve(int patchCurveNumber, double[] patchCurveSplitLocation) 88 | { 89 | // Getting the patch curve from the model that will split into two new patch curves 90 | PatchCurve patchCurve = ((PatchCurve) m_directedPatchSourceMesh.getPatchCurve(patchCurveNumber)); 91 | 92 | // Splitting the patch curve into two new patch curves 93 | m_directedPatchSourceMesh.splitPatchCurve(patchCurve, new DoubleVector(patchCurveSplitLocation)); 94 | } 95 | 96 | /** 97 | * This method creates a patch curve between two patch vertexes 98 | * 99 | * @param patchCurve_0 the first vertex point of the patch curve 100 | * @param patchCurve_1 the second vertex point of the patch curve 101 | */ 102 | public void createPatchCurve(int patchVertexNumber_0, Integer patchVertexNumber_1) 103 | { 104 | // Getting the two patch vertexes 105 | PatchVertex patchVertex_0 = ((PatchVertex) m_directedPatchSourceMesh.getPatchVertex(patchVertexNumber_0)); 106 | PatchVertex patchVertex_1 = ((PatchVertex) m_directedPatchSourceMesh.getPatchVertex(patchVertexNumber_1)); 107 | 108 | // Creating the patch curve between the two points 109 | m_directedPatchSourceMesh.createPatchCurve(patchVertex_0, patchVertex_1, new DoubleVector(new double[] {}), new StringVector(new String[] {})); 110 | m_directedPatchSourceMesh.initializePatchCurveCreation(); 111 | } 112 | 113 | /** 114 | * This method sets the mesh settings of a specified patch curve 115 | * 116 | * @param patchCurveNumber 117 | * @param numberOfDivisions 118 | * @param stretchingFunctionSide_0 119 | * @param stretchingFunctionSide_1 120 | * @param isDirectionReversed 121 | */ 122 | public void setPatchCurveParameters(int patchCurveNumber, int numberOfDivisions, 123 | double stretchingFunctionSide_0, double stretchingFunctionSide_1, boolean isDirectionReversed, String stretchingFunction) 124 | { 125 | m_directedPatchSourceMesh.rebuildPatchPolygonSourceMesh(true); 126 | PatchCurve patchCurve = ((PatchCurve) m_directedPatchSourceMesh.getPatchCurve(patchCurveNumber)); 127 | 128 | if(stretchingFunction == "Two Sided Hyperbolic") 129 | { 130 | patchCurve.getStretchingFunction().setSelected(StretchingFunction.TWO_SIDED_HYPERBOLIC); 131 | } 132 | 133 | if(stretchingFunction == "Constant") 134 | { 135 | patchCurve.getStretchingFunction().setSelected(StretchingFunction.CONSTANT); 136 | } 137 | m_directedPatchSourceMesh.defineMeshPatchCurve(patchCurve, patchCurve.getStretchingFunction(), 138 | stretchingFunctionSide_0, stretchingFunctionSide_1, 139 | numberOfDivisions, isDirectionReversed, false); 140 | } 141 | 142 | public void definePatchCurveParameters(int cellX, int cellY, double spacingX, double spacingY, 143 | String stretchingFnX, String stretchingFnY, boolean isDirectionReversedX, boolean isDirectedReservedY) 144 | { 145 | m_directedPatchSourceMesh = ((DirectedPatchSourceMesh) m_directedMeshOperation.getGuidedSurfaceMeshBaseManager().getObject("Patch Mesh")); 146 | 147 | // Auto populating the edges of the box 148 | m_directedPatchSourceMesh.autopopulateFeatureEdges(); 149 | m_patchCurveX = ((PatchCurve) m_directedPatchSourceMesh.getPatchCurveManager().getObject("PatchCurve 0")); 150 | m_patchCurveY = ((PatchCurve) m_directedPatchSourceMesh.getPatchCurveManager().getObject("PatchCurve 2")); 151 | 152 | // Defining the number of Cells in the Y direction 153 | if (stretchingFnY == "One") 154 | { 155 | m_patchCurveY.getStretchingFunction().setSelected(StretchingFunction.ONE_SIDED_HYPERBOLIC); 156 | m_directedPatchSourceMesh.defineMeshPatchCurve(m_patchCurveY, m_patchCurveY.getStretchingFunction(), spacingY, spacingY, cellY, isDirectedReservedY, true); 157 | } 158 | if (stretchingFnY == "Two") 159 | { 160 | m_patchCurveY.getStretchingFunction().setSelected(StretchingFunction.TWO_SIDED_HYPERBOLIC); 161 | m_directedPatchSourceMesh.defineMeshPatchCurve(m_patchCurveY, m_patchCurveY.getStretchingFunction(), spacingY, spacingY, cellY, isDirectedReservedY, true); 162 | } 163 | if (stretchingFnY == "Constant") 164 | { 165 | m_patchCurveY.getStretchingFunction().setSelected(StretchingFunction.CONSTANT); 166 | m_directedPatchSourceMesh.defineMeshPatchCurve(m_patchCurveY, m_patchCurveY.getStretchingFunction(), spacingY, spacingY, cellY, isDirectedReservedY, false); 167 | } 168 | 169 | // Defining the number of Cells in the X direction 170 | if (stretchingFnX == "One") 171 | { 172 | m_patchCurveX.getStretchingFunction().setSelected(StretchingFunction.ONE_SIDED_HYPERBOLIC); 173 | m_directedPatchSourceMesh.defineMeshPatchCurve(m_patchCurveX, m_patchCurveX.getStretchingFunction(), spacingX, spacingX, cellX, isDirectionReversedX, true); 174 | 175 | } 176 | if (stretchingFnX == "Two") 177 | { 178 | m_patchCurveX.getStretchingFunction().setSelected(StretchingFunction.TWO_SIDED_HYPERBOLIC); 179 | m_directedPatchSourceMesh.defineMeshPatchCurve(m_patchCurveX, m_patchCurveX.getStretchingFunction(), spacingX, spacingX, cellX, isDirectionReversedX, true); 180 | } 181 | if (stretchingFnX == "Constant") 182 | { 183 | m_patchCurveX.getStretchingFunction().setSelected(StretchingFunction.CONSTANT); 184 | m_directedPatchSourceMesh.defineMeshPatchCurve(m_patchCurveX, m_patchCurveX.getStretchingFunction(), spacingX, spacingX, cellX, isDirectionReversedX, false); 185 | } 186 | 187 | // Ending the patch mesh 188 | m_directedPatchSourceMesh.stopEditPatchOperation(); 189 | } 190 | 191 | @SuppressWarnings("unchecked") 192 | public void createDirectedVolumeMesh(int cellExtrude) 193 | { 194 | m_directedMeshOperation.getGuidedSurfaceMeshBaseManager().createGuidedSideMeshDistribution(new NeoObjectVector(new Object[] {m_directedMeshPartCollection})); 195 | 196 | // Creating the volume mesh and setting the number of cells in the extruded direction 197 | DirectedSideMeshDistribution directedSideMeshDistribution_0 = ((DirectedSideMeshDistribution) m_directedMeshOperation.getGuidedSurfaceMeshBaseManager().getObject("Volume Distribution")); 198 | directedSideMeshDistribution_0.setNumLayers(cellExtrude); 199 | m_directedMeshOperation.generateVolumeMeshOnPartCollections(new NeoObjectVector(new Object[] {m_directedMeshPartCollection})); 200 | 201 | m_directedMeshOperation.stopEditingDirectedMeshOperation(); 202 | m_sim.getSceneManager().deleteScenes(new NeoObjectVector(new Object[] {m_scene})); 203 | } 204 | 205 | @SuppressWarnings("unchecked") 206 | public void stopDirectedMesher() 207 | { 208 | // Ending the patch mesh 209 | m_directedPatchSourceMesh.stopEditPatchOperation(); 210 | 211 | m_directedMeshOperation.stopEditingDirectedMeshOperation(); 212 | m_sim.getSceneManager().deleteScenes(new NeoObjectVector(new Object[] {m_scene})); 213 | } 214 | } 215 | -------------------------------------------------------------------------------- /FieldFunctions.java: -------------------------------------------------------------------------------- 1 | package starClasses; 2 | 3 | import star.common.CellQualityFunction; 4 | import star.common.PrimitiveFieldFunction; 5 | import star.common.Simulation; 6 | import star.common.VectorComponentFieldFunction; 7 | import star.common.VectorMagnitudeFieldFunction; 8 | import star.common.XYPlot; 9 | import star.common.YAxisType; 10 | import star.metrics.CellAspectRatioFunction; 11 | import star.vis.ScalarDisplayer; 12 | import star.vis.Scene; 13 | 14 | public class FieldFunctions 15 | { 16 | private Simulation m_sim; 17 | private PrimitiveFieldFunction m_staticPressure; 18 | private PrimitiveFieldFunction m_TDR; 19 | private PrimitiveFieldFunction m_TKE; 20 | private PrimitiveFieldFunction m_uStar; 21 | private PrimitiveFieldFunction m_volume; 22 | private PrimitiveFieldFunction m_wallYPlus; 23 | private PrimitiveFieldFunction m_nodalDisplacement; 24 | private CellAspectRatioFunction m_cellAspectRatio; 25 | private CellQualityFunction m_cellQuality; 26 | private PrimitiveFieldFunction m_velocity; 27 | private PrimitiveFieldFunction m_shearStress; 28 | 29 | public FieldFunctions(Simulation sim) 30 | { 31 | m_sim = sim; 32 | } 33 | 34 | public PrimitiveFieldFunction getStaticPressureFunction() 35 | { 36 | m_staticPressure = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction("StaticPressure")); 37 | return m_staticPressure; 38 | } 39 | 40 | public PrimitiveFieldFunction getTurbDissRateFunction() 41 | { 42 | m_TDR = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction("TurbulentDissipationRate")); 43 | return m_TDR; 44 | } 45 | 46 | public PrimitiveFieldFunction getTurbKinEnergyFunction() 47 | { 48 | m_TKE = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction("TurbulentKineticEnergy")); 49 | return m_TKE; 50 | } 51 | 52 | public PrimitiveFieldFunction getUStarFunction() 53 | { 54 | m_uStar = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction("Ustar")); 55 | return m_uStar; 56 | } 57 | 58 | public PrimitiveFieldFunction getVolumeFunction() 59 | { 60 | m_volume = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction("Volume")); 61 | return m_volume; 62 | } 63 | 64 | public PrimitiveFieldFunction getWallYPlusFunction() 65 | { 66 | m_wallYPlus = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction("WallYplus")); 67 | return m_wallYPlus; 68 | } 69 | 70 | public PrimitiveFieldFunction getNodalDisplacement() 71 | { 72 | m_nodalDisplacement = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction("NodalDisplacement")); 73 | return m_nodalDisplacement; 74 | } 75 | 76 | public CellAspectRatioFunction getCellQualityFunction() 77 | { 78 | m_cellAspectRatio = ((CellAspectRatioFunction) m_sim.getFieldFunctionManager().getFunction("CellAspectRatio")); 79 | return m_cellAspectRatio; 80 | } 81 | 82 | public CellQualityFunction getCellAspectRatioFunction() 83 | { 84 | m_cellQuality = ((CellQualityFunction) m_sim.getFieldFunctionManager().getFunction("CellQuality")); 85 | return m_cellQuality; 86 | } 87 | 88 | public PrimitiveFieldFunction getVelocityFunction() 89 | { 90 | m_velocity = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction("Velocity")); 91 | return m_velocity; 92 | } 93 | 94 | public PrimitiveFieldFunction getWallShearStress() 95 | { 96 | m_shearStress = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction("WallShearStress")); 97 | return m_shearStress; 98 | } 99 | 100 | /** This method sets the field function for a scalar scene 101 | * 102 | * @param sceneName the scene where the scalar field function will be set 103 | * @param fieldFunctionName name of the field function choices are: 104 | * StaticPressure, TurbulentDissipationRate, TurbulentKineticEnergy, Ustar, Volume, WallYplus, CellAspectRatio, CellQuality, Velocity, WallShearStress 105 | * @param vectorDirection name of the field function choices are: 106 | * Magnitude, 0, 1, 2 107 | */ 108 | public void setSceneFieldFunction(Scene scene, String fieldFunctionName, String vectorDirection) 109 | { 110 | VectorComponentFieldFunction vectorComponentFieldFunction; 111 | VectorMagnitudeFieldFunction vectorMagnitudeFieldFunction; 112 | ScalarDisplayer scalarDisplayer = ((ScalarDisplayer) scene.getDisplayerManager().getDisplayer("Scalar 1")); 113 | 114 | if (fieldFunctionName == "StaticPressure" || fieldFunctionName == "TurbulentDissipationRate" || 115 | fieldFunctionName == "TurbulentKineticEnergy" || fieldFunctionName == "Ustar" || fieldFunctionName == "Volume" || 116 | fieldFunctionName == "WallYplus") 117 | { 118 | PrimitiveFieldFunction primitiveFieldFunction = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction(fieldFunctionName)); 119 | scalarDisplayer.getScalarDisplayQuantity().setFieldFunction(primitiveFieldFunction); 120 | } 121 | if (fieldFunctionName == "CellAspectRatio") 122 | { 123 | CellAspectRatioFunction cellAspectRatioFunction = ((CellAspectRatioFunction) m_sim.getFieldFunctionManager().getFunction("CellAspectRatio")); 124 | scalarDisplayer.getScalarDisplayQuantity().setFieldFunction(cellAspectRatioFunction); 125 | } 126 | if (fieldFunctionName == "CellQuality") 127 | { 128 | CellQualityFunction cellQualityFunction = ((CellQualityFunction) m_sim.getFieldFunctionManager().getFunction("CellQuality")); 129 | scalarDisplayer.getScalarDisplayQuantity().setFieldFunction(cellQualityFunction); 130 | } 131 | if (fieldFunctionName == "Velocity" || fieldFunctionName == "WallShearStress" || fieldFunctionName == "Morpher Displacement") 132 | { 133 | PrimitiveFieldFunction primitiveFieldFunction = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction(fieldFunctionName)); 134 | 135 | if (vectorDirection == "Magnitude") 136 | { 137 | vectorMagnitudeFieldFunction = ((VectorMagnitudeFieldFunction) primitiveFieldFunction.getMagnitudeFunction()); 138 | scalarDisplayer.getScalarDisplayQuantity().setFieldFunction(vectorMagnitudeFieldFunction); 139 | } 140 | if (vectorDirection == "0") 141 | { 142 | vectorComponentFieldFunction = ((VectorComponentFieldFunction) primitiveFieldFunction.getComponentFunction(0)); 143 | scalarDisplayer.getScalarDisplayQuantity().setFieldFunction(vectorComponentFieldFunction); 144 | } 145 | if (vectorDirection == "1") 146 | { 147 | vectorComponentFieldFunction = ((VectorComponentFieldFunction) primitiveFieldFunction.getComponentFunction(1)); 148 | scalarDisplayer.getScalarDisplayQuantity().setFieldFunction(vectorComponentFieldFunction); 149 | } 150 | if (vectorDirection == "2") 151 | { 152 | vectorComponentFieldFunction = ((VectorComponentFieldFunction) primitiveFieldFunction.getComponentFunction(2)); 153 | scalarDisplayer.getScalarDisplayQuantity().setFieldFunction(vectorComponentFieldFunction); 154 | } 155 | } 156 | }// end method setSceneFieldFunction 157 | 158 | /** This method sets the field function for a XYPlot scene 159 | * 160 | * @param scene the scene where the scalar field function will be set 161 | * @param fieldFunctionName name of the field function choices are: 162 | * StaticPressure, TurbulentDissipationRate, TurbulentKineticEnergy, Ustar, Volume, WallYplus, CellAspectRatio, CellQuality, Velocity, WallShearStress 163 | * @param vectorDirection name of the field function choices are: 164 | * Magnitude, 0, 1, 2 165 | */ 166 | public void setXYPlotFieldFunction(XYPlot xYPlot, String fieldFunctionName, String vectorDirection) 167 | { 168 | VectorComponentFieldFunction vectorComponentFieldFunction; 169 | VectorMagnitudeFieldFunction vectorMagnitudeFieldFunction; 170 | YAxisType yAxisType_0 = ((YAxisType) xYPlot.getYAxes().getAxisType("Y Type 1")); 171 | 172 | if (fieldFunctionName == "StaticPressure" || fieldFunctionName == "TurbulentDissipationRate" || 173 | fieldFunctionName == "TurbulentKineticEnergy" || fieldFunctionName == "Ustar" || fieldFunctionName == "Volume" || 174 | fieldFunctionName == "WallYplus") 175 | { 176 | PrimitiveFieldFunction primitiveFieldFunction = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction(fieldFunctionName)); 177 | yAxisType_0.setFieldFunction(primitiveFieldFunction); 178 | } 179 | if (fieldFunctionName == "Velocity" || fieldFunctionName == "WallShearStress") 180 | { 181 | PrimitiveFieldFunction primitiveFieldFunction = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction(fieldFunctionName)); 182 | 183 | if (vectorDirection == "Magnitude") 184 | { 185 | vectorMagnitudeFieldFunction = ((VectorMagnitudeFieldFunction) primitiveFieldFunction.getMagnitudeFunction()); 186 | yAxisType_0.setFieldFunction(vectorMagnitudeFieldFunction); 187 | } 188 | if (vectorDirection == "0") 189 | { 190 | vectorComponentFieldFunction = ((VectorComponentFieldFunction) primitiveFieldFunction.getComponentFunction(0)); 191 | yAxisType_0.setFieldFunction(vectorComponentFieldFunction); 192 | } 193 | if (vectorDirection == "1") 194 | { 195 | vectorComponentFieldFunction = ((VectorComponentFieldFunction) primitiveFieldFunction.getComponentFunction(1)); 196 | yAxisType_0.setFieldFunction(vectorComponentFieldFunction); 197 | } 198 | if (vectorDirection == "2") 199 | { 200 | vectorComponentFieldFunction = ((VectorComponentFieldFunction) primitiveFieldFunction.getComponentFunction(2)); 201 | yAxisType_0.setFieldFunction(vectorComponentFieldFunction); 202 | } 203 | } 204 | }// end method setXYPlotFieldFunction 205 | 206 | /** This method sets the field function for a report 207 | * 208 | * @param fieldFunctionName name of the field function choices are: 209 | * StaticPressure, TurbulentDissipationRate, TurbulentKineticEnergy, Ustar, Volume, WallYplus, CellAspectRatio, CellQuality, Velocity, WallShearStress 210 | * @return the scalar field function 211 | */ 212 | public PrimitiveFieldFunction getFieldFunctionScalar(String fieldFunctionName) 213 | { 214 | PrimitiveFieldFunction primitiveFieldFunction = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction(fieldFunctionName)); 215 | return primitiveFieldFunction; 216 | 217 | }// end method setSceneFieldFunction 218 | 219 | /** This method gets the vector magnitude of a field function 220 | * 221 | * @param fieldFunctionName the name of the desired field function that is a vector magnitude 222 | * @return the vector magnitude field function 223 | */ 224 | public VectorMagnitudeFieldFunction getFieldFunctionVectorMag(String fieldFunctionName) 225 | { 226 | PrimitiveFieldFunction primitiveFieldFunction = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction(fieldFunctionName)); 227 | VectorMagnitudeFieldFunction vectorMagnitudeFieldFunction = ((VectorMagnitudeFieldFunction) primitiveFieldFunction.getMagnitudeFunction()); 228 | return vectorMagnitudeFieldFunction; 229 | 230 | }// end method getFieldFunctionVectorMag 231 | 232 | /** This method gets the vector component of a field function 233 | * 234 | * @param fieldFunctionName the name of the field function 235 | * @param vectorComponent the component that is required either a "0" 236 | * @return 237 | */ 238 | public VectorComponentFieldFunction getFieldFunctionVectorComp(String fieldFunctionName, int vectorComponent) 239 | { 240 | PrimitiveFieldFunction primitiveFieldFunction = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction(fieldFunctionName)); 241 | VectorComponentFieldFunction vectorComponentFieldFunction = null; 242 | 243 | if (vectorComponent == 0 || vectorComponent == 1 || vectorComponent == 2) 244 | { 245 | vectorComponentFieldFunction = ((VectorComponentFieldFunction) primitiveFieldFunction.getComponentFunction(vectorComponent)); 246 | } 247 | return vectorComponentFieldFunction; 248 | 249 | }//end method getFieldFunctionVectorComponent 250 | 251 | }// end class FieldFunctions 252 | -------------------------------------------------------------------------------- /GeoData.java: -------------------------------------------------------------------------------- 1 | package starClasses; 2 | 3 | /** 4 | * This class receives data from the input data file and contains getter 5 | * methods which can be used to set the geometry parameters in the 6 | * simulation. 7 | */ 8 | public class GeoData 9 | { 10 | // Member variables 11 | private double m_plateLength = 0; 12 | private double m_plateHeight = 0; 13 | private double m_plateWidth = 0; 14 | 15 | private double m_smallChannelHeight = 0; 16 | private double m_largeChannelHeight = 0; 17 | 18 | private double m_inletLength = 0; 19 | private double m_outletLength = 0; 20 | 21 | // Constructor 22 | public GeoData(double plateLength, double plateHeight, double plateWidth, 23 | double smallChannelHeight, double largeChannelHeight, 24 | double inletLength, double outletLength) 25 | { 26 | // Assign input parameter to member variable 27 | m_plateLength = plateLength; 28 | m_plateHeight = plateHeight; 29 | m_plateWidth = plateWidth; 30 | 31 | m_smallChannelHeight = smallChannelHeight; 32 | m_largeChannelHeight = largeChannelHeight; 33 | 34 | m_inletLength = inletLength; 35 | m_outletLength = outletLength; 36 | } 37 | 38 | // Getter methods to provide access to the member variables 39 | public double getPlateLength() 40 | { 41 | return m_plateLength; 42 | } 43 | 44 | public double getPlateHeight() 45 | { 46 | return m_plateHeight; 47 | } 48 | 49 | public double getPlateWidth() 50 | { 51 | return m_plateWidth; 52 | } 53 | 54 | public double getSmallChannelHeight() 55 | { 56 | return m_smallChannelHeight; 57 | } 58 | 59 | public double getLargeChannelHeight() 60 | { 61 | return m_largeChannelHeight; 62 | } 63 | 64 | public double getInletLength() 65 | { 66 | return m_inletLength; 67 | } 68 | 69 | public double getOutletLength() 70 | { 71 | return m_outletLength; 72 | } 73 | 74 | }//end GeoData 75 | -------------------------------------------------------------------------------- /GeometryBuilder.java: -------------------------------------------------------------------------------- 1 | package starClasses; 2 | 3 | import star.base.neo.DoubleVector; 4 | import star.base.neo.IntVector; 5 | import star.base.neo.NeoObjectVector; 6 | import star.cadmodeler.CadModel; 7 | import star.cadmodeler.CanonicalSketchPlane; 8 | import star.cadmodeler.ExtrusionMerge; 9 | import star.cadmodeler.PointSketchPrimitive; 10 | import star.cadmodeler.Sketch; 11 | import star.cadmodeler.SolidModelManager; 12 | import star.cadmodeler.SolidModelPart; 13 | import star.common.BrickVolumeShape; 14 | import star.common.LabCoordinateSystem; 15 | import star.common.PartSurface; 16 | import star.common.Simulation; 17 | import star.common.SimulationPartManager; 18 | import star.common.Units; 19 | import star.common.VolumeShapeManager; 20 | import star.meshing.LeafMeshPart; 21 | import star.meshing.MeshOperationManager; 22 | import star.meshing.MeshOperationPart; 23 | import star.meshing.SubtractPartsOperation; 24 | 25 | /** This class creates geometry for a Star CCM+ simulation 26 | * 27 | * @author cj8q5 28 | * 29 | */ 30 | public class GeometryBuilder 31 | { 32 | private Simulation m_sim; 33 | private String m_partName; 34 | private CadModel m_cadModel; 35 | private CanonicalSketchPlane m_sketchingPlane; 36 | private Units m_units; 37 | 38 | public GeometryBuilder(Simulation sim, String partName, String sketchPlane) 39 | { 40 | m_sim = sim; 41 | m_partName = partName; 42 | m_cadModel = m_sim.get(SolidModelManager.class).createSolidModel(); 43 | m_cadModel.setPresentationName(m_partName); 44 | m_sketchingPlane = ((CanonicalSketchPlane) m_cadModel.getFeatureManager().getObject(sketchPlane)); 45 | m_units = m_sim.getUnitsManager().getPreferredUnits( 46 | new IntVector( 47 | new int[] {0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})); 48 | 49 | } 50 | 51 | /** This method builds a 3D model of a rectangular box and makes it a part in the geometry tree 52 | * 53 | * @param sketchPlane is the plane to sketch on either XY, XZ, or YZ 54 | * @param X vector of two x coordinates one for the lower left corner and one for the upper right corner 55 | * @param Y vector of two y coordinates one for the lower left corner and one for the upper right corner 56 | * @param Z value for the length of the extrusion 57 | * @param partName name of the part 58 | */ 59 | public void boxBuilder(double[] X, double[] Y, double Z) 60 | { 61 | // Sketching the rectangle 62 | Sketch sketch = m_cadModel.getFeatureManager().createSketch(m_sketchingPlane); 63 | m_cadModel.getFeatureManager().startSketchEdit(sketch); 64 | sketch.createRectangle(new DoubleVector(new double[] {X[0], Y[0]}), new DoubleVector(new double[] {X[1], Y[1]})); 65 | m_cadModel.getFeatureManager().stopSketchEdit(sketch, true); 66 | 67 | // Extruding the sketched rectangle 68 | ExtrusionMerge extrusionMerge = m_cadModel.getFeatureManager().createExtrusionMerge(sketch); 69 | extrusionMerge.getDistance().setValue(Z); 70 | 71 | m_cadModel.getFeatureManager().execute(extrusionMerge); 72 | m_cadModel.createParts("SharpEdges", 30.0, 2, true); 73 | 74 | SolidModelPart solidModelPart = ((SolidModelPart) m_sim.get(SimulationPartManager.class).getPart("Body 1")); 75 | solidModelPart.setPresentationName(m_partName); 76 | }//end method partBuilder 77 | 78 | /** This method creates a rectangular part with a void through the center 79 | * 80 | * @param sketchPlane is the plane to be sketched on (XY, YZ, or XZ) 81 | * @param X array of x coordinates the first two values create the outer rectangle and the second two create the inner rectangle 82 | * @param Y array of y coordinates the first two values create the outer rectangle and the second two create the inner rectangle 83 | * @param Z value for the size of the extrusion 84 | * @param partName name of the new part 85 | */ 86 | public void boxWithVoidBuilder(double[] X, double[] Y, double Z) 87 | { 88 | // Sketching the rectangles 89 | Sketch sketch = m_cadModel.getFeatureManager().createSketch(m_sketchingPlane); 90 | m_cadModel.getFeatureManager().startSketchEdit(sketch); 91 | sketch.createRectangle(new DoubleVector(new double[] {X[0], Y[0]}), new DoubleVector(new double[] {X[1], Y[1]})); 92 | sketch.createRectangle(new DoubleVector(new double[] {X[2], Y[2]}), new DoubleVector(new double[] {X[3], Y[3]})); 93 | m_cadModel.getFeatureManager().stopSketchEdit(sketch, true); 94 | 95 | // Extruding the sketched rectangle 96 | ExtrusionMerge extrusionMerge = m_cadModel.getFeatureManager().createExtrusionMerge(sketch); 97 | extrusionMerge.getDistance().setValue(Z); 98 | 99 | m_cadModel.getFeatureManager().execute(extrusionMerge); 100 | m_cadModel.createParts("SharpEdges", 30.0, 2, true); 101 | 102 | SolidModelPart solidModelPart = ((SolidModelPart) m_sim.get(SimulationPartManager.class).getPart("Body 1")); 103 | solidModelPart.setPresentationName(m_partName); 104 | } 105 | 106 | /** 107 | * This method creates a cylinder part 108 | * @param sketchPlane the sketch plane will be perpendicular to the axial direction of the cylinder 109 | * @param pipeCenter the coordinates for the center of the pipe 110 | * @param radius the radius of the cylinder 111 | * @param pipeLength the length of the cylinder 112 | */ 113 | public void cylinderBuilder(double[] pipeCenter, double radius, double pipeLength) 114 | { 115 | Sketch sketch = m_cadModel.getFeatureManager().createSketch(m_sketchingPlane); 116 | m_cadModel.getFeatureManager().startSketchEdit(sketch); 117 | sketch.createCircle(new DoubleVector(pipeCenter), radius); 118 | m_cadModel.getFeatureManager().stopSketchEdit(sketch, true); 119 | 120 | ExtrusionMerge extrusionMerge = m_cadModel.getFeatureManager().createExtrusionMerge(sketch); 121 | extrusionMerge.getDistance().setValue(pipeLength); 122 | 123 | m_cadModel.setPresentationName(m_partName); 124 | m_cadModel.getFeatureManager().execute(extrusionMerge); 125 | m_cadModel.createParts("SharpEdges", 30.0, 2, true); 126 | 127 | SolidModelPart solidModelPart = ((SolidModelPart) m_sim.get(SimulationPartManager.class).getPart("Body 1")); 128 | solidModelPart.setPresentationName(m_partName); 129 | } 130 | 131 | /** 132 | * This method creates a box with an arc on the left side, useful for airfoil bulk fluid 133 | * @param inletCircleDiameter diameter of the inlet arc 134 | * @param outletBoxLength length of the outlet box 135 | */ 136 | public void airfoilBulkFluidBuilder(double inletCircleDiameter, double outletBoxLength, double extrudeLength) 137 | { 138 | Sketch sketch = m_cadModel.getFeatureManager().createSketch(m_sketchingPlane); 139 | m_cadModel.getFeatureManager().startSketchEdit(sketch); 140 | 141 | // Creating the outlet box 142 | sketch.createLine(new DoubleVector(new double[] {0.0, -inletCircleDiameter}), 143 | new DoubleVector(new double[] {outletBoxLength, -inletCircleDiameter})); 144 | 145 | sketch.createLine(new DoubleVector(new double[] {outletBoxLength, -inletCircleDiameter}), 146 | new DoubleVector(new double[] {outletBoxLength, inletCircleDiameter})); 147 | 148 | sketch.createLine(new DoubleVector(new double[] {outletBoxLength, inletCircleDiameter}), 149 | new DoubleVector(new double[] {0.0, inletCircleDiameter})); 150 | 151 | // Creating the circular inlet arc 152 | sketch.createCircularArc(new DoubleVector(new double[] {0.0, 0.0}), 153 | new DoubleVector(new double[] {0.0, inletCircleDiameter}), 154 | new DoubleVector(new double[] {0.0, -inletCircleDiameter})); 155 | 156 | m_cadModel.getFeatureManager().stopSketchEdit(sketch, true); 157 | 158 | // Creating the extruded length of the fluid 159 | ExtrusionMerge extrusionMerge = m_cadModel.getFeatureManager().createExtrusionMerge(sketch); 160 | extrusionMerge.getDistance().setValue(extrudeLength); 161 | 162 | m_cadModel.setPresentationName(m_partName); 163 | m_cadModel.getFeatureManager().execute(extrusionMerge); 164 | m_cadModel.createParts("SharpEdges", 30.0, 2, true); 165 | 166 | SolidModelPart solidModelPart = ((SolidModelPart) m_sim.get(SimulationPartManager.class).getPart("Body 1")); 167 | solidModelPart.setPresentationName(m_partName); 168 | } 169 | 170 | /** 171 | * This method creates the sketch 172 | * @return 173 | */ 174 | public Sketch createSketch() 175 | { 176 | Sketch sketch = m_cadModel.getFeatureManager().createSketch(m_sketchingPlane); 177 | return sketch; 178 | } 179 | 180 | /** 181 | * This method creates a sketch point on the sketch 182 | * @param pointcoordinates 183 | * @param sketchPlane 184 | */ 185 | public PointSketchPrimitive createSketchPoint(Sketch sketch, double[] pointcoordinates) 186 | { 187 | // Creating sketch point 188 | PointSketchPrimitive pointSketchPrimitive = sketch.createPoint(new DoubleVector(pointcoordinates)); 189 | return pointSketchPrimitive; 190 | } 191 | 192 | /** 193 | * This method creates a spline around specified points 194 | * @param sketch 195 | * @param xySplineCoordinates 196 | * @param firstPoint 197 | * @param secondPoint 198 | */ 199 | public void createSpline(Sketch sketch, double[] xySplineCoordinates, PointSketchPrimitive firstPoint, PointSketchPrimitive secondPoint) 200 | { 201 | // Creating the spline 202 | sketch.createSpline(true, firstPoint, false, secondPoint, new DoubleVector(xySplineCoordinates)); 203 | } 204 | /** 205 | * This method creates an extrude and creates a part given a sketch 206 | * @param sketch 207 | * @param extrudedLength 208 | */ 209 | public void createPart(Sketch sketch, double extrudedLength) 210 | { 211 | ExtrusionMerge extrusionMerge = m_cadModel.getFeatureManager().createExtrusionMerge(sketch); 212 | extrusionMerge.getDistance().setValue(extrudedLength); 213 | m_cadModel.setPresentationName(m_partName); 214 | m_cadModel.getFeatureManager().execute(extrusionMerge); 215 | m_cadModel.createParts("SharpEdges", 30.0, 2, true); 216 | 217 | SolidModelPart solidModelPart = ((SolidModelPart) m_sim.get(SimulationPartManager.class).getPart("Body 1")); 218 | solidModelPart.setPresentationName(m_partName); 219 | } 220 | 221 | /** 222 | * This method translates a part in the simulation 223 | * @param partName name of the part that is to be translated 224 | * @param X distance to translate in the x direction 225 | * @param Y distance to translate in the y direction 226 | * @param Z distance to translate in the z direction 227 | */ 228 | public void partTranslate(double[] xyzCoords) 229 | { 230 | SolidModelPart solidModelPart = ((SolidModelPart) m_sim.get(SimulationPartManager.class).getPart(m_partName)); 231 | 232 | LabCoordinateSystem labCoordinateSystem = m_sim.getCoordinateSystemManager().getLabCoordinateSystem(); 233 | 234 | m_sim.get(SimulationPartManager.class).translateParts(new NeoObjectVector(new Object[] {solidModelPart}), 235 | new DoubleVector(xyzCoords), 236 | new NeoObjectVector(new Object[] {m_units, m_units, m_units}), labCoordinateSystem); 237 | }//end method partTranslate 238 | 239 | /** 240 | * This method subtracts one part from the other 241 | * @param partBase name of the part that is to be subtracted from 242 | * @param partSubtract name of the part that is subtracting from the base part 243 | * @param newPartName name of the new subtracted part 244 | */ 245 | public void partSubtract(String partBase, String partSubtract, String newPartName) 246 | { 247 | SolidModelPart solidPartBase = ((SolidModelPart) m_sim.get(SimulationPartManager.class).getPart(partBase)); 248 | SolidModelPart solidPartSubtract = ((SolidModelPart) m_sim.get(SimulationPartManager.class).getPart(partSubtract)); 249 | 250 | SubtractPartsOperation subtractPartsOperation = (SubtractPartsOperation) m_sim.get(MeshOperationManager.class).createSubtractPartsOperation(); 251 | subtractPartsOperation.getInputGeometryObjects().setObjects(solidPartBase, solidPartSubtract); 252 | subtractPartsOperation.setMergePartSurfaces(false); 253 | subtractPartsOperation.setMergePartCurves(true); 254 | subtractPartsOperation.setTargetPart(solidPartBase); 255 | subtractPartsOperation.execute(); 256 | 257 | MeshOperationPart subtractedPart = ((MeshOperationPart) m_sim.get(SimulationPartManager.class).getPart("Subtract")); 258 | subtractedPart.detach(); 259 | 260 | LeafMeshPart leafMeshPart = ((LeafMeshPart) m_sim.get(SimulationPartManager.class).getPart("Subtract")); 261 | leafMeshPart.setPresentationName(newPartName); 262 | }//end method partSubtract 263 | 264 | /** 265 | * This method rotates the part by a specified angle 266 | * @param rotationAngle angle in radian by which the part will be rotated 267 | * @param rotationAxis the axis the part will rotate on 268 | */ 269 | public void partRotate(double rotationAngle, double[] rotationAxis) 270 | { 271 | SolidModelPart solidModelPart = ((SolidModelPart) m_sim.get(SimulationPartManager.class).getPart(m_partName)); 272 | 273 | LabCoordinateSystem labCoordinateSystem = m_sim.getCoordinateSystemManager().getLabCoordinateSystem(); 274 | 275 | // Rotating the part 276 | m_sim.get(SimulationPartManager.class).rotateParts( 277 | new NeoObjectVector(new Object[] {solidModelPart}), 278 | new DoubleVector(rotationAxis), 279 | new NeoObjectVector(new Object[] {m_units, m_units, m_units}), 280 | rotationAngle, labCoordinateSystem); 281 | } 282 | 283 | /** 284 | * This method splits the surface of a part by an angle and names them 285 | * @param partName name of the part where its surfaces will be split 286 | * @param angle value of the angle to be used when splitting the surfaces 287 | * @param surfaceNames vector of surface names that will be used to name the new surfaces 288 | * @param partType true if the part is a solid model part and false if the part is a leaf mesh part created from a subtract operation 289 | */ 290 | public void splitSurface(double angle, String[] surfaceNames, boolean partType) 291 | { 292 | if (partType == true) 293 | { 294 | SolidModelPart part2Split = ((SolidModelPart) m_sim.get(SimulationPartManager.class).getPart(m_partName)); 295 | PartSurface splitSurface = part2Split.getPartSurfaceManager().getPartSurface("Default"); 296 | 297 | part2Split.getPartSurfaceManager().splitPartSurfacesByAngle(new NeoObjectVector(new Object[] {splitSurface}), angle); 298 | splitSurface.setPresentationName("Default 1"); 299 | 300 | for (int i = 0; i < surfaceNames.length; i++) 301 | { 302 | PartSurface surface = part2Split.getPartSurfaceManager().getPartSurface("Default " + (i + 1)); 303 | surface.setPresentationName(surfaceNames[i]); 304 | }//end for loop 305 | } 306 | if (partType == false) 307 | { 308 | LeafMeshPart part2Split = ((LeafMeshPart) m_sim.get(SimulationPartManager.class). getPart(m_partName)); 309 | PartSurface splitSurface = part2Split.getPartSurfaceManager().getPartSurface("Default"); 310 | 311 | part2Split.getPartSurfaceManager().splitPartSurfacesByAngle(new NeoObjectVector(new Object[] {splitSurface}), angle); 312 | splitSurface.setPresentationName("Default 1"); 313 | 314 | for (int i = 0; i < surfaceNames.length; i++) 315 | { 316 | PartSurface surface = part2Split.getPartSurfaceManager().getPartSurface("Default " + (i + 1)); 317 | surface.setPresentationName(surfaceNames[i]); 318 | }//end for loop 319 | } 320 | 321 | }//end method splitSurface 322 | 323 | /** 324 | * This method creates a volume shape block 325 | * @param coordinate_0 bottom corner of the block 326 | * @param coordinate_1 top corner of the block 327 | */ 328 | public BrickVolumeShape createVolumeShapeBlock(double[] coordinate_0, double[] coordinate_1) 329 | { 330 | BrickVolumeShape brickVolumeShape_0 = (BrickVolumeShape) m_sim.get(VolumeShapeManager.class).createBrickVolumeShape(); 331 | 332 | brickVolumeShape_0.getCorner1().setCoordinate(m_units, m_units, m_units, new DoubleVector(coordinate_0)); 333 | brickVolumeShape_0.getCorner2().setCoordinate(m_units, m_units, m_units, new DoubleVector(coordinate_1)); 334 | return brickVolumeShape_0; 335 | } 336 | 337 | } 338 | 339 | -------------------------------------------------------------------------------- /ImportCAE.java: -------------------------------------------------------------------------------- 1 | package starClasses; 2 | /** This java script is to be run using the FSI_Abaqus_StarCCM.py python script within Star-CCM+ 3 | * Written by Casey J. Jesse on June 2014 at the University of Missouri - Columbia 4 | * Revisions: 5 | * 6 | */ 7 | 8 | import star.base.neo.*; 9 | import star.common.*; 10 | import star.cae.common.*; 11 | 12 | 13 | public class ImportCAE 14 | { 15 | private Simulation m_sim; 16 | private CaeImportManager m_cae; 17 | private String m_fileLocation; 18 | private Units m_units; 19 | private ImportedModel m_importedModel; 20 | private String m_regionName; 21 | 22 | public ImportCAE(Simulation sim, String fileLocation, String regionName) 23 | { 24 | m_sim = sim; 25 | m_cae = m_sim.get(CaeImportManager.class); 26 | m_fileLocation = fileLocation; 27 | m_units = m_sim.getUnitsManager().getPreferredUnits(new IntVector(new int[] {0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})); 28 | m_regionName = regionName; 29 | } 30 | 31 | /** This method creates a imported Abaqus model and region in Star-CCM+ 32 | * 33 | * @param fileName name of the file to be imported 34 | * @param createRegion boolean for creating a region from the imported Abaqus model 35 | */ 36 | @SuppressWarnings("unchecked") 37 | public void importAbaqusInputFile(String fileName, boolean createRegion, boolean createImportedModel) 38 | { 39 | m_cae.importAbaqusModelFile(m_fileLocation + fileName + ".inp", m_units, createImportedModel, createRegion); 40 | 41 | FvRepresentation fvRepresentation_0 = ((FvRepresentation) m_sim.getRepresentationManager().getObject("Volume Mesh")); 42 | Region region = m_sim.getRegionManager().getRegion(m_regionName); 43 | fvRepresentation_0.generateMeshReport(new NeoObjectVector(new Object[] {region})); 44 | } 45 | 46 | /** This method imports Abaqus solution from an Abaqus .odb file 47 | * 48 | * @param fileName name of the .odb file to be imported 49 | * @param stepName name of the Abaqus step to use during the import 50 | */ 51 | public void importAbaqusOdbFile(String fileName, String stepName) 52 | { 53 | m_importedModel = ((ImportedModel) m_sim.get(ImportedModelManager.class).getImportedModel("Abaqus: " + fileName)); 54 | 55 | m_cae.importAbaqusData(m_fileLocation + fileName + ".odb", 56 | new NeoObjectVector(new Object[] {m_importedModel}), 1, "Displacement", 1, "abq6122.bat", stepName, "ALLMODES", m_units); 57 | } 58 | 59 | /** This method deforms the imported .odb file's deflection 60 | * 61 | * @param fileName name of the file the .odb solution file 62 | */ 63 | public void deformImportedAbaqusModel() 64 | { 65 | m_sim.get(ImportedModelManager.class).deformImportedModelsUsingDisplacements(new NeoObjectVector(new Object[] {m_importedModel})); 66 | } 67 | 68 | /** This method maps the imported deflection data to the fluid regions 69 | * 70 | * @param fluidRegions names of the regions each boundary specified must have its corresponding region in this string 71 | * @param fluidBoundaries names of the boundaries that are to have the plate deflections mapped 72 | * @param solidBoundary name of the solid boundary in Abaqus that the fluid region is being mapped from 73 | */ 74 | public void mapAbaqusDeflectionData(String[] fluidRegions, String[] fluidBoundaries, String solidBoundary) 75 | { 76 | Object[] mappedBoundaries = new Object[fluidBoundaries.length]; 77 | for (int i = 0; i < fluidBoundaries.length; i++) 78 | { 79 | Region region = m_sim.getRegionManager().getRegion(fluidRegions[i]); 80 | Boundary boundary = region.getBoundaryManager().getBoundary(fluidBoundaries[i]); 81 | mappedBoundaries[i] = boundary; 82 | } 83 | 84 | ImportedSurface importedSurface = m_importedModel.getImportedSurfaceManager().getImportedSurface(solidBoundary); 85 | 86 | m_sim.get(ImportedModelManager.class).mapImportedSurfaceVertexDataToBoundaryVertices( 87 | new NeoObjectVector(mappedBoundaries), 88 | new NeoObjectVector(new Object[] {importedSurface}), "ImportedDisplacement", false, 1.0, false, true, 90.0, 89 | new DoubleVector(new double[] {0.0, 0.0, 0.0})); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /MeshElementData.java: -------------------------------------------------------------------------------- 1 | package starClasses; 2 | 3 | /** 4 | * This class receives data from the input data file and contains getter 5 | * methods which can be used to set the mesh parameters, etc. in the 6 | * simulation. The input data includes the mesh parameters where the mesh density is 7 | * computed. 8 | */ 9 | public class MeshElementData 10 | { 11 | // Member variables 12 | private int m_extrudeCell; 13 | 14 | // Inlet plenum mesh parameters 15 | private int m_inletX; 16 | private int m_largeInletY; 17 | private int m_smallInletY; 18 | private int m_plateInletY; 19 | 20 | // Outlet plenum mesh parameters 21 | private int m_outletX; 22 | private int m_largeOutletY; 23 | private int m_smallOutletY; 24 | private int m_plateOutletY; 25 | 26 | // Small channel mesh parameters 27 | private int m_smChannelX; 28 | private int m_smChannelY; 29 | 30 | // Large channel mesh parameters 31 | private int m_lgChannelX; 32 | private int m_lgChannelY; 33 | 34 | // Random variables 35 | private double m_meshDensity; 36 | private double[] m_maxPressures; 37 | private double[] m_minPressures; 38 | private double[] m_pressureDrops; 39 | 40 | public MeshElementData(int extrudeCell, int inletX, int largeInletY, int smallInletY, int plateInletY, 41 | int outletX, int largeOutletY, int smallOutletY, int plateOutletY, 42 | int smChannelX, int smChannelY, int lgChannelX, int lgChannelY) 43 | { 44 | // Assign input parameter to member variable 45 | m_extrudeCell = extrudeCell; 46 | m_inletX = inletX; 47 | m_largeInletY = largeInletY; 48 | m_smallInletY = smallInletY; 49 | m_plateInletY = plateInletY; 50 | 51 | m_outletX = outletX; 52 | m_largeOutletY = largeOutletY; 53 | m_smallOutletY = smallOutletY; 54 | m_plateOutletY = plateOutletY; 55 | 56 | m_smChannelX = smChannelX; 57 | m_smChannelY = smChannelY; 58 | m_lgChannelX = lgChannelX; 59 | m_lgChannelY = lgChannelY; 60 | m_meshDensity = (((largeInletY + smallInletY + plateInletY)*inletX) + 61 | ((largeOutletY + smallOutletY + plateOutletY)*outletX) + 62 | (smChannelX*smChannelY) + (lgChannelX*lgChannelY))*extrudeCell; 63 | } 64 | 65 | // Getter methods to provide access to the member variables 66 | public int getExtrudeCell() 67 | { 68 | return m_extrudeCell; 69 | } 70 | 71 | public int getInletX() 72 | { 73 | return m_inletX; 74 | } 75 | 76 | public int getOutletX() 77 | { 78 | return m_outletX; 79 | } 80 | 81 | public int getSmallInletY() 82 | { 83 | return m_smallInletY; 84 | } 85 | 86 | public int getLargeInletY() 87 | { 88 | return m_largeInletY; 89 | } 90 | 91 | public int getPlateInletY() 92 | { 93 | return m_plateInletY; 94 | } 95 | 96 | public int getSmallOutletY() 97 | { 98 | return m_smallOutletY; 99 | } 100 | 101 | public int getLargeOutletY() 102 | { 103 | return m_largeOutletY; 104 | } 105 | 106 | public int getPlateOutletY() 107 | { 108 | return m_plateOutletY; 109 | } 110 | 111 | public int getSmChannelX() 112 | { 113 | return m_smChannelX; 114 | } 115 | 116 | public int getSmChannelY() 117 | { 118 | return m_smChannelY; 119 | } 120 | 121 | public int getLgChannelX() 122 | { 123 | return m_lgChannelX; 124 | } 125 | 126 | public int getLgChannelY() 127 | { 128 | return m_lgChannelY; 129 | } 130 | 131 | public double[] getMaxPressures() 132 | { 133 | return m_maxPressures; 134 | } 135 | 136 | public double[] getMinPressures() 137 | { 138 | return m_minPressures; 139 | } 140 | 141 | public double[] getPressureDrops() 142 | { 143 | m_pressureDrops[0] = m_maxPressures[0] - m_minPressures[0]; 144 | m_pressureDrops[1] = m_maxPressures[1] - m_minPressures[1]; 145 | return m_pressureDrops; 146 | } 147 | 148 | public double getMeshDensity() 149 | { 150 | return m_meshDensity; 151 | } 152 | 153 | /** 154 | * When the simulation has run, important values will be stored in 155 | * the MeshData object using the method. 156 | */ 157 | public void setMaxPressures(double maxPressureLg, double maxPressureSm) 158 | { 159 | m_maxPressures[0] = maxPressureLg; 160 | m_maxPressures[1] = maxPressureSm; 161 | } 162 | 163 | public void setMinPressures(double minPressureLg, double minPressureSm) 164 | { 165 | m_minPressures[0] = minPressureLg; 166 | m_minPressures[1] = minPressureSm; 167 | } 168 | 169 | }//end MeshData 170 | -------------------------------------------------------------------------------- /MeshMorpher.java: -------------------------------------------------------------------------------- 1 | package starClasses; 2 | 3 | import star.common.Boundary; 4 | import star.common.FunctionVectorProfileMethod; 5 | import star.common.PrimitiveFieldFunction; 6 | import star.common.Region; 7 | import star.common.Simulation; 8 | import star.morpher.MovingMeshOption; 9 | import star.morpher.MovingMeshSolver; 10 | import star.morpher.TotalDisplacementProfile; 11 | import star.motion.MorphOrderOption; 12 | import star.motion.MorphingMotion; 13 | import star.motion.MotionManager; 14 | import star.motion.MotionSpecification; 15 | 16 | public class MeshMorpher 17 | { 18 | private Simulation m_sim; 19 | private MorphingMotion m_motion; 20 | private PrimitiveFieldFunction m_fieldFunction; 21 | private Region m_region; 22 | 23 | public MeshMorpher(Simulation sim, String regionName) 24 | { 25 | m_sim = sim; 26 | m_motion = m_sim.get(MotionManager.class).createMotion(MorphingMotion.class, "Morphing"); 27 | m_motion.getMorphOrderOption().setSelected(MorphOrderOption.REGIONWISE); 28 | 29 | m_region = m_sim.getRegionManager().getRegion(regionName); 30 | 31 | MotionSpecification motionSpecification = m_region.getValues().get(MotionSpecification.class); 32 | motionSpecification.setMotion(m_motion); 33 | } 34 | 35 | /** This method adds a boundary to the mesh morpher solver 36 | * 37 | * @param regionName name of the region where the boundary is 38 | * @param boundaryName name of the boundary where the mesh morhper solver where solve 39 | */ 40 | public void addRegionBoundary(String boundaryName, String FSIorSS) 41 | { 42 | Boundary boundary = m_region.getBoundaryManager().getBoundary(boundaryName); 43 | 44 | if(FSIorSS == "SS") 45 | { 46 | boundary.getConditions().get(MovingMeshOption.class).setSelected(MovingMeshOption.TOTAL_DISPLACEMENT); 47 | 48 | TotalDisplacementProfile totalDisplacementProfile = boundary.getValues().get(TotalDisplacementProfile.class); 49 | totalDisplacementProfile.setMethod(FunctionVectorProfileMethod.class); 50 | m_fieldFunction = ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction("MappedVertexImportedDisplacement")); 51 | totalDisplacementProfile.getMethod(FunctionVectorProfileMethod.class).setFieldFunction(m_fieldFunction); 52 | } 53 | if(FSIorSS == "FSI") 54 | { 55 | boundary.getConditions().get(MovingMeshOption.class).setSelected(MovingMeshOption.ABAQUSCOSIMULATION); 56 | } 57 | } 58 | 59 | /** 60 | * This method turns the morph at inner iterations on and off 61 | * @param onOrOff 62 | */ 63 | public void innerIterationMorphing(boolean onOrOff) 64 | { 65 | MovingMeshSolver movingMeshSolver = ((MovingMeshSolver) m_sim.getSolverManager().getSolver(MovingMeshSolver.class)); 66 | movingMeshSolver.setSolveInnerIterations(onOrOff); 67 | } 68 | 69 | /** 70 | * This method turns morph from zero on or off 71 | * @param onOrOff 72 | */ 73 | public void setMorphFromZero(boolean onOrOff) 74 | { 75 | MovingMeshSolver movingMeshSolver = ((MovingMeshSolver) m_sim.getSolverManager().getSolver(MovingMeshSolver.class)); 76 | movingMeshSolver.setMorphFromZero(onOrOff); 77 | } 78 | } 79 | 80 | -------------------------------------------------------------------------------- /MeshSpacingData.java: -------------------------------------------------------------------------------- 1 | package starClasses; 2 | 3 | /** 4 | * This class receives data from the input data file and contains getter 5 | * methods which can be used to set the mesh parameters, etc. in the 6 | * simulation. The input data includes the mesh parameters where the mesh density is 7 | * computed. 8 | */ 9 | public class MeshSpacingData 10 | { 11 | // Inlet plenum mesh parameters 12 | private double m_inletSpacingX = 0; 13 | private double m_inletSpacingY = 0; 14 | 15 | // Outlet plenum mesh parameters 16 | private double m_outletSpacingX = 0; 17 | private double m_outletSpacingY = 0; 18 | 19 | // Small channel mesh parameters 20 | private double m_smChannelSpacingX = 0; 21 | private double m_smChannelSpacingY = 0; 22 | 23 | // Large channel mesh parameters 24 | private double m_lgChannelSpacingX = 0; 25 | private double m_lgChannelSpacingY = 0; 26 | 27 | 28 | public MeshSpacingData(double inletSpacingX, double inletSpacingY, double outletSpacingX, 29 | double outletSpacingY, double smChannelSpacingX, double smChannelSpacingY, 30 | double lgChannelSpacingX, double lgChannelSpacingY) 31 | { 32 | // Assign input parameter to member variable 33 | m_inletSpacingX = inletSpacingX; 34 | m_inletSpacingY = inletSpacingY; 35 | m_outletSpacingX = outletSpacingX; 36 | m_outletSpacingY = outletSpacingY; 37 | m_lgChannelSpacingX = lgChannelSpacingX; 38 | m_lgChannelSpacingY = lgChannelSpacingY; 39 | m_smChannelSpacingX = smChannelSpacingX; 40 | m_smChannelSpacingY = smChannelSpacingY; 41 | } 42 | 43 | public double getInletSpacingX() 44 | { 45 | return m_inletSpacingX; 46 | } 47 | 48 | public double getInletSpacingY() 49 | { 50 | return m_inletSpacingY; 51 | } 52 | 53 | public double getOutletSpacingX() 54 | { 55 | return m_outletSpacingX; 56 | } 57 | 58 | public double getOutletSpacingY() 59 | { 60 | return m_outletSpacingY; 61 | } 62 | 63 | public double getSmChannelSpacingX() 64 | { 65 | return m_smChannelSpacingX; 66 | } 67 | 68 | public double getSmChannelSpacingY() 69 | { 70 | return m_smChannelSpacingY; 71 | } 72 | 73 | public double getLgChannelSpacingX() 74 | { 75 | return m_lgChannelSpacingX; 76 | } 77 | 78 | public double getLgChannelSpacingY() 79 | { 80 | return m_lgChannelSpacingY; 81 | } 82 | 83 | }//end MeshSpacingData 84 | -------------------------------------------------------------------------------- /NewDataReader.java: -------------------------------------------------------------------------------- 1 | package starClasses; 2 | 3 | 4 | import java.io.BufferedReader; 5 | import java.io.FileNotFoundException; 6 | import java.io.FileReader; 7 | import java.io.IOException; 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | 11 | import javax.swing.JOptionPane; 12 | 13 | public class NewDataReader 14 | { 15 | 16 | private Map m_doubleParameters = new HashMap(); 17 | private Map m_intParameters = new HashMap(); 18 | private Map m_stringParameters = new HashMap(); 19 | 20 | public void readGeometryData(String file2Read) throws NumberFormatException, IOException 21 | { 22 | FileReader file; 23 | try 24 | { 25 | file = new FileReader(file2Read); 26 | BufferedReader reader = new BufferedReader(file); 27 | 28 | String line; 29 | while((line=reader.readLine()) != null) 30 | { 31 | if(line.startsWith("#")) 32 | { 33 | continue; 34 | } 35 | else if(line.trim().length() == 0) 36 | { 37 | continue; 38 | } 39 | else 40 | { 41 | line = line.replaceAll("\\t", ""); 42 | String[] lineParameters = line.split(":"); 43 | 44 | if(lineParameters[1].equals("float")) 45 | { 46 | m_doubleParameters.put(lineParameters[0], Double.parseDouble(lineParameters[2])); 47 | } 48 | else if(lineParameters[1].equals("integer")) 49 | { 50 | m_intParameters.put(lineParameters[0], Integer.parseInt(lineParameters[2])); 51 | } 52 | else if(lineParameters[1].equals("string")) 53 | { 54 | m_stringParameters.put(lineParameters[0], lineParameters[2]); 55 | } 56 | } 57 | } 58 | reader.close(); 59 | 60 | } 61 | catch (FileNotFoundException e) 62 | { 63 | JOptionPane.showMessageDialog(null, e.toString()); 64 | } 65 | }// end method readGeometryData 66 | 67 | public double getDoubleData(String variableName) 68 | { 69 | double variable = m_doubleParameters.get(variableName); 70 | return variable; 71 | } 72 | 73 | public int getIntData(String variableName) 74 | { 75 | int variable = m_intParameters.get(variableName); 76 | return variable; 77 | } 78 | 79 | public String getStringData(String variableName) 80 | { 81 | String variable = m_stringParameters.get(variableName); 82 | return variable; 83 | } 84 | } 85 | 86 | -------------------------------------------------------------------------------- /PolyhedralMesher.java: -------------------------------------------------------------------------------- 1 | package starClasses; 2 | 3 | import star.common.Boundary; 4 | import star.common.MeshContinuum; 5 | import star.common.Region; 6 | import star.common.Simulation; 7 | import star.meshing.BaseSize; 8 | import star.meshing.GenericAbsoluteSize; 9 | import star.meshing.MeshPipelineController; 10 | import star.meshing.RelativeMinimumSize; 11 | import star.meshing.RelativeOrAbsoluteOption; 12 | import star.meshing.RelativeTargetSize; 13 | import star.meshing.SurfaceSize; 14 | import star.prismmesher.NumPrismLayers; 15 | import star.prismmesher.PrismMesherModel; 16 | import star.prismmesher.PrismStretchingOption; 17 | import star.prismmesher.PrismThickness; 18 | import star.prismmesher.PrismWallThickness; 19 | import star.meshing.*; 20 | import star.resurfacer.*; 21 | import star.dualmesher.*; 22 | 23 | public class PolyhedralMesher 24 | { 25 | private Simulation m_sim; 26 | private String m_regionName; 27 | private MeshContinuum m_mesh; 28 | private PrismMesherModel m_prism; 29 | private Region m_region; 30 | 31 | public PolyhedralMesher(Simulation activeSim, String regionName) 32 | { 33 | m_sim = activeSim; 34 | m_regionName = regionName; 35 | m_region = m_sim.getRegionManager().getRegion(m_regionName); 36 | 37 | m_mesh = m_sim.getContinuumManager().createContinuum(MeshContinuum.class); 38 | m_mesh.enable(ResurfacerMeshingModel.class); 39 | m_mesh.enable(DualMesherModel.class); 40 | m_mesh.enable(PrismMesherModel.class); 41 | m_mesh.add(m_region); 42 | 43 | m_prism = m_mesh.getModelManager().getModel(PrismMesherModel.class); 44 | m_prism.getPrismStretchingOption().setSelected(PrismStretchingOption.WALL_THICKNESS); 45 | } 46 | 47 | /** 48 | * This method turns meshing in parallel on and off 49 | * @param onOrOff boolean for turning meshing in parallel on and off 50 | */ 51 | public void meshInParallel(boolean onOrOff) 52 | { 53 | m_mesh.setMeshInParallel(onOrOff); 54 | } 55 | 56 | /** 57 | * 58 | * @param baseCellSize 59 | * @param targetCellSizePercentage 60 | * @param minimumCellSizePercentage 61 | * @param maximumCellSizePercentage 62 | */ 63 | public void setMesherSettings(double baseCellSize, double targetCellSizePercentage, double minimumCellSizePercentage) 64 | { 65 | m_mesh.getReferenceValues().get(BaseSize.class).setValue(baseCellSize); 66 | SurfaceSize surfaceSize = m_mesh.getReferenceValues().get(SurfaceSize.class); 67 | 68 | RelativeTargetSize relativeTargetSize = surfaceSize.getRelativeTargetSize(); 69 | relativeTargetSize.setPercentage(targetCellSizePercentage); 70 | 71 | RelativeMinimumSize relativeMinimumSize = surfaceSize.getRelativeMinimumSize(); 72 | relativeMinimumSize.setPercentage(minimumCellSizePercentage); 73 | } 74 | 75 | /** 76 | * This method sets the surface growth rate for custom surface sizes 77 | * @param surfaceGrowthRate the value for the surface growth rate 78 | */ 79 | public void setSurfaceGrowthRate(double surfaceGrowthRate) 80 | { 81 | SurfaceGrowthRate surfaceGrowthRate_0 = m_mesh.getReferenceValues().get(SurfaceGrowthRate.class); 82 | surfaceGrowthRate_0.setGrowthRate(surfaceGrowthRate); 83 | } 84 | 85 | /** 86 | * This method sets the minimum surface size and the target surface sizes for the overall mesh 87 | * @param minSurfaceSize 88 | * @param targetSurfaceSize 89 | */ 90 | public void setReferenceValuesSurfaceSize(double minSurfaceSize, double targetSurfaceSize) 91 | { 92 | SurfaceSize surfaceSize = m_mesh.getReferenceValues().get(SurfaceSize.class); 93 | surfaceSize.getRelativeOrAbsoluteOption().setSelected(RelativeOrAbsoluteOption.ABSOLUTE); 94 | 95 | AbsoluteMinimumSize absoluteMinimumSize = surfaceSize.getAbsoluteMinimumSize(); 96 | absoluteMinimumSize.getValue().setValue(minSurfaceSize); 97 | 98 | AbsoluteTargetSize absoluteTargetSize = surfaceSize.getAbsoluteTargetSize(); 99 | absoluteTargetSize.getValue().setValue(targetSurfaceSize); 100 | } 101 | 102 | /** 103 | * This method sets custom surface sizes on a specified region boundary 104 | * @param minSurfSizePercentage 105 | * @param targetSurfSizePercentage 106 | */ 107 | public void setCustomBoundarySurfaceSize(String regionName, String boundaryName, double minSurfSizePercentage, double targetSurfSizePercentage) 108 | { 109 | Boundary boundary = m_region.getBoundaryManager().getBoundary(boundaryName); 110 | 111 | SurfaceSizeOption surfaceSizeOption_0 = boundary.get(MeshConditionManager.class).get(SurfaceSizeOption.class); 112 | surfaceSizeOption_0.setSurfaceSizeOption(true); 113 | 114 | SurfaceSize surfaceSize = boundary.get(MeshValueManager.class).get(SurfaceSize.class); 115 | RelativeMinimumSize relativeMinimumSize = surfaceSize.getRelativeMinimumSize(); 116 | relativeMinimumSize.setPercentage(minSurfSizePercentage); 117 | 118 | RelativeTargetSize relativeTargetSize = surfaceSize.getRelativeTargetSize(); 119 | relativeTargetSize.setPercentage(targetSurfSizePercentage); 120 | } 121 | 122 | /** 123 | * 124 | * @param prismLayerThickness 125 | * @param wallThickness 126 | * @param numPrismLayers 127 | */ 128 | public void setPrismLayerSettings(double prismLayerThickness, double wallThickness, int numPrismLayers) 129 | { 130 | m_mesh.getReferenceValues().get(PrismWallThickness.class).setValue(wallThickness); 131 | 132 | // Setting the number of prism layers for the prism layer mesher 133 | NumPrismLayers prismLayers = m_mesh.getReferenceValues().get(NumPrismLayers.class); 134 | prismLayers.setNumLayers(numPrismLayers); 135 | 136 | // Setting the overall thickness of all of the prism layers for the prism layer mesher 137 | PrismThickness prismThickness = m_mesh.getReferenceValues().get(PrismThickness.class); 138 | prismThickness.getRelativeOrAbsoluteOption().setSelected(RelativeOrAbsoluteOption.ABSOLUTE); 139 | GenericAbsoluteSize genericAbsoluteSize = ((GenericAbsoluteSize) prismThickness.getAbsoluteSize()); 140 | genericAbsoluteSize.getValue().setValue(prismLayerThickness); 141 | } 142 | 143 | public void generateMesh() 144 | { 145 | MeshPipelineController meshPipelineController = m_sim.get(MeshPipelineController.class); 146 | meshPipelineController.generateVolumeMesh(); 147 | } 148 | 149 | } 150 | -------------------------------------------------------------------------------- /RegionBuilder.java: -------------------------------------------------------------------------------- 1 | package starClasses; 2 | 3 | import star.base.neo.*; 4 | import star.cadmodeler.SolidModelPart; 5 | import star.common.Boundary; 6 | import star.common.ConstantScalarProfileMethod; 7 | import star.common.ConstantVectorProfileMethod; 8 | import star.common.DirectBoundaryInterface; 9 | import star.common.InletBoundary; 10 | import star.common.InterfaceConfigurationOption; 11 | import star.common.MeshContinuum; 12 | import star.common.PhysicsContinuum; 13 | import star.common.PressureBoundary; 14 | import star.common.Region; 15 | import star.common.Simulation; 16 | import star.common.SimulationPartManager; 17 | import star.common.SymmetryBoundary; 18 | import star.energy.HeatFluxProfile; 19 | import star.energy.WallThermalOption; 20 | import star.flow.FlowDirectionOption; 21 | import star.flow.FlowDirectionProfile; 22 | import star.flow.VelocityMagnitudeProfile; 23 | import star.meshing.AbsoluteMinimumSize; 24 | import star.meshing.AbsoluteTargetSize; 25 | import star.meshing.GenericAbsoluteSize; 26 | import star.meshing.LeafMeshPart; 27 | import star.meshing.MeshConditionManager; 28 | import star.meshing.MeshValueManager; 29 | import star.meshing.RelativeOrAbsoluteOption; 30 | import star.meshing.SurfaceSize; 31 | import star.meshing.SurfaceSizeOption; 32 | import star.prismmesher.CustomizeBoundaryPrismsOption; 33 | import star.prismmesher.NumPrismLayers; 34 | import star.prismmesher.PrismLayerStretching; 35 | import star.prismmesher.PrismThickness; 36 | 37 | /** 38 | * This class creates the regions in the part and its associated boundaries, flag = 0 for leaftMeshPart and flag = 1 for solidModelPart 39 | * 40 | * @author cj8q5 41 | * 42 | */ 43 | public class RegionBuilder 44 | { 45 | private Simulation m_sim; 46 | private String m_regionName; 47 | private Region m_region; 48 | 49 | public RegionBuilder(Simulation sim, String regionName) 50 | { 51 | m_sim = sim; 52 | m_regionName = regionName; 53 | } 54 | 55 | /** 56 | * This method creates regions from parts, flag = true for leafMeshPart and flag = false for solidModelPart 57 | * 58 | * @param partName name of the part to be used in creating a region 59 | * @param flag true for a leaf mesh part and false for a solid model part 60 | */ 61 | @SuppressWarnings("unchecked") 62 | public void part2Region(String partName, boolean flag) 63 | { 64 | if (flag == true) 65 | { 66 | LeafMeshPart leafMeshPart = ((LeafMeshPart) m_sim.get(SimulationPartManager.class).getPart(partName)); 67 | m_sim.getRegionManager().newRegionsFromParts(new NeoObjectVector(new Object[] {leafMeshPart}), 68 | "OneRegionPerPart", null, "OneBoundaryPerPartSurface", null, "OneFeatureCurve", null, true); 69 | } 70 | if (flag == false) 71 | { 72 | SolidModelPart solidModelPart = ((SolidModelPart) m_sim.get(SimulationPartManager.class).getPart(partName)); 73 | m_sim.getRegionManager().newRegionsFromParts(new NeoObjectVector(new Object[] {solidModelPart}), 74 | "OneRegionPerPart", null, "OneBoundaryPerPartSurface", null, "OneFeatureCurve", null, true); 75 | 76 | m_region = m_sim.getRegionManager().getRegion(m_regionName); 77 | } 78 | }//end method part2Region 79 | 80 | /** 81 | * This method creates a region that contains multiple parts 82 | * 83 | * @param partNames string array with the names of the parts 84 | * @param regionName presentation name of the region 85 | */ 86 | @SuppressWarnings("unchecked") 87 | public void parts2Region(String[] partNames) 88 | { 89 | int numParts = partNames.length; 90 | Object[] partVector = new Object[numParts]; 91 | for (int i = 0; i < numParts; i++) 92 | { 93 | SolidModelPart part = ((SolidModelPart) m_sim.get(SimulationPartManager.class).getPart(partNames[i])); 94 | partVector[i] = part; 95 | }//end for loop 96 | 97 | m_sim.getRegionManager().newRegionsFromParts(new NeoObjectVector(partVector), 98 | "OneRegion", null, "OneBoundaryPerPartSurface", null, "OneFeatureCurve", null, true); 99 | m_sim.getRegionManager().getRegion("Region 1").setPresentationName(m_regionName); 100 | 101 | m_region = m_sim.getRegionManager().getRegion(m_regionName); 102 | }//end method parts2Region 103 | 104 | /** 105 | * This method deletes a boundary from a region 106 | * @param boundaryName name of the boundary to be deleted 107 | */ 108 | public void deleteBoundary(String boundaryName) 109 | { 110 | Region region = m_sim.getRegionManager().getRegion(m_regionName); 111 | Boundary boundary = region.getBoundaryManager().getBoundary(boundaryName); 112 | region.getBoundaryManager().remove(boundary); 113 | } 114 | 115 | /** 116 | * This method sets a physics continua to a particular region 117 | * 118 | * @param regionName name of the region to be set to physics continua 119 | * @param continua Name name of the continua to be set to the specified region 120 | */ 121 | public void setRegionPhysics(String continuaName) 122 | { 123 | Region region = m_sim.getRegionManager().getRegion(m_regionName); 124 | 125 | PhysicsContinuum physics = ((PhysicsContinuum) m_sim.getContinuumManager().getContinuum(continuaName)); 126 | physics.add(region); 127 | }//end method setRegionPhysics 128 | 129 | /** 130 | * This method sets the prism layer meshing settings on specified boundaries within a region 131 | * 132 | * @param boundaryName name of the boundary that the prism mesher settings will be set 133 | * @param Switch false for switching the prism layer off for that boundary 134 | */ 135 | public void setBoundaryPrismOption(String boundaryName, boolean Switch) 136 | { 137 | Boundary boundary = m_region.getBoundaryManager().getBoundary(boundaryName); 138 | if (Switch == false) 139 | { 140 | boundary.get(MeshConditionManager.class).get(CustomizeBoundaryPrismsOption.class).setSelected(CustomizeBoundaryPrismsOption.DISABLE); 141 | } 142 | else 143 | { 144 | boundary.get(MeshConditionManager.class).get(CustomizeBoundaryPrismsOption.class).setSelected(CustomizeBoundaryPrismsOption.DEFAULT); 145 | } 146 | } 147 | 148 | /** 149 | * This method creates a new boundary group for organizing large numbers of boundaries within a region 150 | * 151 | * @param groupName presentation name of the group 152 | * @param boundaryNames name of the all the boundaries that are in the new group 153 | */ 154 | @SuppressWarnings("unchecked") 155 | public void createBoundaryGroup(String groupName, String[] boundaryNames) 156 | { 157 | m_region.getBoundaryManager().getGroupsManager().createGroup(groupName); 158 | Object[] boundaryVector = new Object[boundaryNames.length]; 159 | for (int i = 0; i < boundaryNames.length; i++) 160 | { 161 | Boundary boundary = m_region.getBoundaryManager().getBoundary(boundaryNames[i]); 162 | boundaryVector[i] = boundary; 163 | } 164 | 165 | ((ClientServerObjectGroup) m_region.getBoundaryManager().getGroupsManager().getObject(groupName)).getGroupsManager(). 166 | groupObjects(groupName, new NeoObjectVector(boundaryVector), true); 167 | } 168 | 169 | /** 170 | * This method creates an interaction between two boundaries within a region 171 | * 172 | * @param regionNames name of the regions where the interaction will be created 173 | * @param boundaryNames name of the two boundaries where the interaction will exist 174 | * @param interactionName name of the interaction that is to be created 175 | */ 176 | public void createInterface(String[] regionNames, String[] boundaryNames, String interactionName) 177 | { 178 | Region region_0 = m_sim.getRegionManager().getRegion(regionNames[0]); 179 | Region region_1 = m_sim.getRegionManager().getRegion(regionNames[1]); 180 | 181 | Boundary boundary_0 = region_0.getBoundaryManager().getBoundary(boundaryNames[0]); 182 | Boundary boundary_1 = region_1.getBoundaryManager().getBoundary(boundaryNames[1]); 183 | 184 | DirectBoundaryInterface boundaryInterface = m_sim.getInterfaceManager().createDirectInterface(boundary_0, boundary_1, "In-place"); 185 | 186 | boundaryInterface.getTopology().setSelected(InterfaceConfigurationOption.IN_PLACE); 187 | boundaryInterface.setPresentationName(interactionName); 188 | }//end method createInteraction 189 | 190 | /** 191 | * This method sets the type of boundary condition and the value at that position 192 | * 193 | * @param regionName name of the region where the boundary condition will be set 194 | * @param boundaryName name of the boundary on the specified region to set the boundary condition 195 | * @param boundaryType type of boundary condition either "Velocity Inlet" or "Pressure Outlet" or "Symmetry" 196 | * @param boundaryValue specified value for the boundary condition 197 | */ 198 | public void setBoundaryCondition(String boundaryName, String boundaryType, 199 | double[] components, double boundaryValue) 200 | { 201 | Region region = m_sim.getRegionManager().getRegion(m_regionName); 202 | Boundary boundary = region.getBoundaryManager().getBoundary(boundaryName); 203 | if (boundaryType == "Velocity Inlet") 204 | { 205 | boundary.setBoundaryType(InletBoundary.class); 206 | 207 | boundary.getConditions().get(FlowDirectionOption.class).setSelected(FlowDirectionOption.COMPONENTS); 208 | 209 | boundary.getValues().get(FlowDirectionProfile.class).getMethod(ConstantVectorProfileMethod.class). 210 | getQuantity().setComponents(components[0], components[1], components[2]); 211 | 212 | boundary.getValues().get(VelocityMagnitudeProfile.class). 213 | getMethod(ConstantScalarProfileMethod.class).getQuantity().setValue(boundaryValue); 214 | } 215 | if (boundaryType == "Pressure Outlet") 216 | { 217 | boundary.setBoundaryType(PressureBoundary.class); 218 | } 219 | if (boundaryType == "Symmetry") 220 | { 221 | boundary.setBoundaryType(SymmetryBoundary.class); 222 | } 223 | }// end nested method setBoundaryCondition 224 | 225 | /** 226 | * This method sets a heat flux on a boundary 227 | * 228 | * @param regionName name of the where a boundary heat flux will be set 229 | * @param boundaryName specific boundary on the region where the heat flux will be applied 230 | * @param heatFluxMagnitude magnitude of the heat flux 231 | */ 232 | public void setBoundaryHeatFlux(String boundaryName, double heatFluxMagnitude) 233 | { 234 | Region region = m_sim.getRegionManager().getRegion(m_regionName); 235 | Boundary boundary = region.getBoundaryManager().getBoundary(boundaryName); 236 | boundary.getConditions().get(WallThermalOption.class).setSelected(WallThermalOption.HEAT_FLUX); 237 | HeatFluxProfile heatFluxProfile_0 = boundary.getValues().get(HeatFluxProfile.class); 238 | heatFluxProfile_0.getMethod(ConstantScalarProfileMethod.class).getQuantity().setValue(heatFluxMagnitude); 239 | }//end nested method setBoundaryHeatFlux 240 | 241 | /** 242 | * This method sets the Surface mesh settings within a region's boundary 243 | * 244 | * @param regionName name of the region where mesh settings will be specified 245 | * @param boundaryName name of the boundary on the region where the mesh will be specified 246 | * @param meshName name of the mesh continua 247 | * @param minSurfSize the minimum mesh surface size 248 | * @param targSurfSize the target mesh surface size 249 | */ 250 | public void setBoundarySurfaceMeshSettings(String boundaryName, String meshName, 251 | double minSurfSize, double targSurfSize) 252 | { 253 | // Grabbing the region, mesh, and boundary 254 | Region region = m_sim.getRegionManager().getRegion(m_regionName); 255 | MeshContinuum mesh = ((MeshContinuum) m_sim.getContinuumManager().getContinuum(meshName)); 256 | mesh.add(region); 257 | Boundary boundary = region.getBoundaryManager().getBoundary(boundaryName); 258 | 259 | SurfaceSizeOption surfaceSizeOption = boundary.get(MeshConditionManager.class).get(SurfaceSizeOption.class); 260 | surfaceSizeOption.setSurfaceSizeOption(true); 261 | 262 | SurfaceSize surfaceSize_1 = boundary.get(MeshValueManager.class).get(SurfaceSize.class); 263 | surfaceSize_1.getRelativeOrAbsoluteOption().setSelected(RelativeOrAbsoluteOption.ABSOLUTE); 264 | 265 | AbsoluteMinimumSize absoluteMinimumSize_1 = surfaceSize_1.getAbsoluteMinimumSize(); 266 | absoluteMinimumSize_1.getValue().setValue(minSurfSize); 267 | 268 | AbsoluteTargetSize absoluteTargetSize_0 = surfaceSize_1.getAbsoluteTargetSize(); 269 | absoluteTargetSize_0.getValue().setValue(targSurfSize); 270 | }//end nested method setBoundarySurfaceMeshSetttings 271 | 272 | /** 273 | * This method sets the prism mesh settings within a region's boundary 274 | * 275 | * @param regionName the name of the region where the prism mesh settings will be specified 276 | * @param boundaryName the name of the boundary where the prism mesh will be specified 277 | * @param meshName the name of the mesh continua 278 | * @param numLayer the number of layers in the prism layer mesh 279 | * @param layerStretch specifying the layer stretching in the prism layer mesh 280 | * @param layerThickness specifying the first layer's thickness (I believe anyway) 281 | */ 282 | public void setBoundaryPrismMeshSettings(String boundaryName, String meshName, 283 | int numLayer, double layerStretch, double layerThickness) 284 | { 285 | // Grabbing the region, mesh, and boundary 286 | Region region = m_sim.getRegionManager().getRegion(m_regionName); 287 | MeshContinuum mesh = ((MeshContinuum) m_sim.getContinuumManager().getContinuum(meshName)); 288 | mesh.add(region); 289 | Boundary boundary = region.getBoundaryManager().getBoundary(boundaryName); 290 | 291 | // Prism layer mesh settings 292 | boundary.get(MeshConditionManager.class).get(CustomizeBoundaryPrismsOption.class).setSelected(CustomizeBoundaryPrismsOption.CUSTOM_VALUES); 293 | 294 | NumPrismLayers numPrismLayers_1 = boundary.get(MeshValueManager.class).get(NumPrismLayers.class); 295 | numPrismLayers_1.setNumLayers(numLayer); 296 | 297 | PrismLayerStretching prismLayerStretching_1 = boundary.get(MeshValueManager.class).get(PrismLayerStretching.class); 298 | prismLayerStretching_1.setStretching(layerStretch); 299 | 300 | PrismThickness prismThickness_1 = boundary.get(MeshValueManager.class).get(PrismThickness.class); 301 | prismThickness_1.getRelativeOrAbsoluteOption().setSelected(RelativeOrAbsoluteOption.ABSOLUTE); 302 | 303 | GenericAbsoluteSize genericAbsoluteSize_1 = ((GenericAbsoluteSize) prismThickness_1.getAbsoluteSize()); 304 | genericAbsoluteSize_1.getValue().setValue(layerThickness); 305 | }//end nested method setBoundaryPrismMeshSettings 306 | } 307 | -------------------------------------------------------------------------------- /ReportsMonitorsPlots.java: -------------------------------------------------------------------------------- 1 | package starClasses; 2 | 3 | import star.base.neo.DoubleVector; 4 | import star.base.report.*; 5 | import star.common.Axes; 6 | import star.common.Axis; 7 | import star.common.AxisTitle; 8 | import star.common.AxisType; 9 | import star.common.Boundary; 10 | import star.common.Coordinate; 11 | import star.common.InternalDataSet; 12 | import star.common.MonitorNormalizeOption; 13 | import star.common.MonitorPlot; 14 | import star.common.Region; 15 | import star.common.ResidualMonitor; 16 | import star.common.Simulation; 17 | import star.common.StarPlot; 18 | import star.common.StarUpdate; 19 | import star.common.StarUpdateModeOption; 20 | import star.common.Units; 21 | import star.common.XYPlot; 22 | import star.common.YAxisType; 23 | import star.flow.ForceCoefficientReport; 24 | import star.flow.ForceReportForceOption; 25 | import star.vis.FrontalAreaReport; 26 | import star.vis.LinePart; 27 | 28 | /** 29 | * This class is for creating reports, monitors, and plots 30 | * 31 | * @author cj8q5 32 | * 33 | */ 34 | public class ReportsMonitorsPlots 35 | { 36 | private Simulation m_sim; 37 | private Units m_units; 38 | 39 | public ReportsMonitorsPlots(Simulation sim) 40 | { 41 | m_sim = sim; 42 | m_units = ((Units) m_sim.getUnitsManager().getObject("m")); 43 | } 44 | 45 | /** This method is for creating a maximum report 46 | * 47 | * @param objectPath vector string containing a region and then a boundary, if only a region is found the report 48 | * will be created for the entire region 49 | * @param fieldFunction the name of the field function to be used in the max report such as "Pressure" or "Temperature" 50 | * @param reportName presentation name for the max report 51 | */ 52 | public MaxReport createMaxReport(String[] objectPath, String reportName) 53 | { 54 | MaxReport maxReport = m_sim.getReportManager().createReport(MaxReport.class); 55 | 56 | if (objectPath.length == 1) 57 | { 58 | Region region = m_sim.getRegionManager().getRegion(objectPath[0]); 59 | maxReport.getParts().setObjects(region); 60 | } 61 | if (objectPath.length > 1) 62 | { 63 | Region region = m_sim.getRegionManager().getRegion(objectPath[0]); 64 | for(int i = 1; i < objectPath.length; i++) 65 | { 66 | Boundary boundary = region.getBoundaryManager().getBoundary(objectPath[i]); 67 | maxReport.getParts().addObjects(boundary); 68 | } 69 | } 70 | 71 | maxReport.setPresentationName(reportName); 72 | return maxReport; 73 | 74 | }//end method createMaxReport 75 | 76 | /** This method creates a minimum report 77 | * 78 | * @param objectPath vector string containing a region and then a boundary, if only a region is found the report 79 | * will be created for the entire region 80 | * @param reportName presentation name for the min report 81 | */ 82 | public MinReport createMinReport(String[] objectPath, String reportName) 83 | { 84 | MinReport minReport = m_sim.getReportManager().createReport(MinReport.class); 85 | 86 | if (objectPath.length == 1) 87 | { 88 | Region region = m_sim.getRegionManager().getRegion(objectPath[0]); 89 | minReport.getParts().setObjects(region); 90 | } 91 | if (objectPath.length > 1) 92 | { 93 | Region region = m_sim.getRegionManager().getRegion(objectPath[0]); 94 | for(int i = 1; i < objectPath.length; i++) 95 | { 96 | Boundary boundary = region.getBoundaryManager().getBoundary(objectPath[i]); 97 | minReport.getParts().addObjects(boundary); 98 | } 99 | } 100 | 101 | minReport.setPresentationName(reportName); 102 | return minReport; 103 | 104 | }//end method createMinReport 105 | 106 | /** This method creates an average report 107 | * 108 | * @param regionName the name of the region where the avg report will be reporting from 109 | * @param boundaryName the name of the boundary where the field function will be averaged 110 | * @param fieldFunction the name of the field function that the avg report will use such as "Pressure" and "Temperature" 111 | * @param reportName presentation name for the avg report 112 | */ 113 | public AreaAverageReport createAverageReport(String[] objectPath, String reportName) 114 | { 115 | AreaAverageReport areaAverageReport = m_sim.getReportManager().createReport(AreaAverageReport.class); 116 | 117 | if (objectPath.length == 1) 118 | { 119 | Region region = m_sim.getRegionManager().getRegion(objectPath[0]); 120 | areaAverageReport.getParts().setObjects(region); 121 | } 122 | else 123 | { 124 | Region region = m_sim.getRegionManager().getRegion(objectPath[0]); 125 | for(int i = 1; i < objectPath.length; i++) 126 | { 127 | Boundary boundary = region.getBoundaryManager().getBoundary(objectPath[i]); 128 | areaAverageReport.getParts().addObjects(boundary); 129 | } 130 | } 131 | areaAverageReport.setPresentationName(reportName); 132 | return areaAverageReport; 133 | 134 | }//end method createAverageReport 135 | 136 | /** 137 | * This method creates an frontal area report for reporting the area of a part 138 | * @param partNames names of the parts for the desired area 139 | * @param reportName name of the report 140 | * @param viewUpVector view up vector, must be orthogonal to the normal vector 141 | * @param normalVector the normal vector 142 | * @return 143 | */ 144 | public FrontalAreaReport createAreaReport(String reportName, double[] viewUpVector, double[] normalVector) 145 | { 146 | FrontalAreaReport frontalAreaReport = m_sim.getReportManager().createReport(FrontalAreaReport.class); 147 | frontalAreaReport.setPresentationName(reportName); 148 | 149 | Coordinate coordinate_0 = frontalAreaReport.getViewUpCoordinate(); 150 | coordinate_0.setCoordinate(m_units, m_units, m_units, new DoubleVector(viewUpVector)); 151 | 152 | Coordinate coordinate_1 = frontalAreaReport.getNormalCoordinate(); 153 | coordinate_1.setCoordinate(m_units, m_units, m_units, new DoubleVector(normalVector)); 154 | return frontalAreaReport; 155 | } 156 | 157 | /** 158 | * This method creates a force coefficient report 159 | * @param regionName name of the region for the report to be created for 160 | * @param boundaryNames name of the boundaries 161 | * @param forceOption either "Pressure", "Shear", OR "Pressure and Shear" 162 | * @param refPressure the reference pressure (atmospheric) 163 | * @param forceDirection direction of the force 164 | * @param numOfBands number of bands the 165 | */ 166 | public void createForceCoefficientReportMonitorPlot(String regionName, String[] boundaryNames, String forceOption, 167 | double refPressure, double refVelocity, double refArea, double refDensity, double[] forceDirection, String reportName) 168 | { 169 | ForceCoefficientReport forceCoefficientReport = m_sim.getReportManager().createReport(ForceCoefficientReport.class); 170 | 171 | forceCoefficientReport.getReferenceDensity().setValue(refDensity); 172 | forceCoefficientReport.getReferenceVelocity().setValue(refVelocity); 173 | forceCoefficientReport.getReferenceArea().setValue(refArea); 174 | if(forceOption == "Pressure") 175 | { 176 | forceCoefficientReport.getForceOption().setSelected(ForceReportForceOption.PRESSURE); 177 | } 178 | if(forceOption == "Shear") 179 | { 180 | forceCoefficientReport.getForceOption().setSelected(ForceReportForceOption.SHEAR); 181 | } 182 | if(forceOption == "Pressure and Shear") 183 | { 184 | forceCoefficientReport.getForceOption().setSelected(ForceReportForceOption.PRESSURE_AND_SHEAR); 185 | } 186 | forceCoefficientReport.getReferencePressure().setValue(refPressure); 187 | forceCoefficientReport.getDirection().setComponents(forceDirection[0], forceDirection[1], forceDirection[2]); 188 | Region region = m_sim.getRegionManager().getRegion(regionName); 189 | 190 | for(int i = 0; i < boundaryNames.length; i++) 191 | { 192 | Boundary boundary = region.getBoundaryManager().getBoundary(boundaryNames[i]); 193 | forceCoefficientReport.getParts().addPart(boundary); 194 | } 195 | forceCoefficientReport.setPresentationName(reportName); 196 | 197 | ReportMonitor forceMonitor = forceCoefficientReport.createMonitor(); 198 | MonitorPlot monitorPlot = m_sim.getPlotManager().createMonitorPlot(); 199 | monitorPlot.getMonitors().addObjects(forceMonitor); 200 | monitorPlot.setPresentationName(reportName); 201 | } 202 | 203 | /** 204 | * This method turns off the "auto" normalization for the residual monitors in a simulation 205 | */ 206 | public void residualNormalization(String[] residualNames) 207 | { 208 | //String[] residualNames = {"Continuity", "Tdr", "Tke", "X-momentum", "Y-momentum", "Z-momentum"}; 209 | 210 | for (int i = 0; i < residualNames.length; i++) 211 | { 212 | ResidualMonitor residualMonitor = ((ResidualMonitor) m_sim.getMonitorManager().getMonitor(residualNames[i])); 213 | residualMonitor.getNormalizeOption().setSelected(MonitorNormalizeOption.OFF); 214 | } 215 | 216 | }// end method residualNormalization 217 | 218 | /** This method creates monitors and a monitor plot with them using two reports 219 | * 220 | * @param reportNames the name of the reports to be made into monitors and to be placed on a monitor plot 221 | * @param plotName presentation name of the plot 222 | * @param axesTitles presentation name of the X and Y axes 223 | * @param flag true for a plot with a max, min, and average reports and false for a plot with two average reports 224 | */ 225 | public void createMonitorPlot2(String[] reportNames, String plotName, String[] axesTitles, boolean flag) 226 | { 227 | if (flag == true) 228 | { 229 | MinReport minReport = ((MinReport) m_sim.getReportManager().getReport(reportNames[0])); 230 | ReportMonitor reportMonitor_0 = minReport.createMonitor(); 231 | StarUpdate starUpdate_0 = reportMonitor_0.getStarUpdate(); 232 | starUpdate_0.getUpdateModeOption().setSelected(StarUpdateModeOption.ITERATION); 233 | 234 | MaxReport maxReport = ((MaxReport) m_sim.getReportManager().getReport(reportNames[1])); 235 | ReportMonitor reportMonitor_1 = maxReport.createMonitor(); 236 | StarUpdate starUpdate_1 = reportMonitor_1.getStarUpdate(); 237 | starUpdate_1.getUpdateModeOption().setSelected(StarUpdateModeOption.ITERATION); 238 | 239 | AreaAverageReport aveReport = ((AreaAverageReport) m_sim.getReportManager().getReport(reportNames[2])); 240 | ReportMonitor reportMonitor_2 = aveReport.createMonitor(); 241 | StarUpdate starUpdate_2 = reportMonitor_2.getStarUpdate(); 242 | starUpdate_2.getUpdateModeOption().setSelected(StarUpdateModeOption.ITERATION); 243 | 244 | MonitorPlot monitorPlot = m_sim.getPlotManager().createMonitorPlot(); 245 | monitorPlot.setPresentationName(plotName); 246 | monitorPlot.getMonitors().addObjects(reportMonitor_0, reportMonitor_1, reportMonitor_2); 247 | 248 | IterationMonitor iterationMonitor = ((IterationMonitor) m_sim.getMonitorManager().getMonitor("Iteration")); 249 | monitorPlot.setXAxisMonitor(iterationMonitor); 250 | } 251 | 252 | if (flag == false) 253 | { 254 | AreaAverageReport aveReport_0 = ((AreaAverageReport) m_sim.getReportManager().getReport(reportNames[0])); 255 | ReportMonitor reportMonitor_0 = aveReport_0.createMonitor(); 256 | StarUpdate starUpdate_0 = reportMonitor_0.getStarUpdate(); 257 | starUpdate_0.getUpdateModeOption().setSelected(StarUpdateModeOption.ITERATION); 258 | 259 | AreaAverageReport aveReport_1 = ((AreaAverageReport) m_sim.getReportManager().getReport(reportNames[1])); 260 | ReportMonitor reportMonitor_1 = aveReport_1.createMonitor(); 261 | StarUpdate starUpdate_1 = reportMonitor_1.getStarUpdate(); 262 | starUpdate_1.getUpdateModeOption().setSelected(StarUpdateModeOption.ITERATION); 263 | 264 | MonitorPlot monitorPlot_1 = m_sim.getPlotManager().createMonitorPlot(); 265 | monitorPlot_1.setPresentationName(plotName); 266 | monitorPlot_1.getMonitors().addObjects(reportMonitor_0, reportMonitor_1); 267 | } 268 | 269 | StarPlot monitorPlot = m_sim.getPlotManager().getPlot(plotName); 270 | Axes axes = monitorPlot.getAxes(); 271 | 272 | Axis axis_0 = axes.getXAxis(); 273 | AxisTitle axisTitle_0 = axis_0.getTitle(); 274 | axisTitle_0.setText(axesTitles[0]); 275 | 276 | Axis axis_1 = axes.getYAxis(); 277 | AxisTitle axisTitle_1 = axis_1.getTitle(); 278 | axisTitle_1.setText(axesTitles[1]); 279 | }//end method createMonitorPlot2 280 | 281 | /** This method creates a XY plot of a field function versus position 282 | * 283 | * @param regionNames names of the regions where the boundaries can be found 284 | * @param boundaryNames names of the boundaries that will be plotted on the XY plot 285 | * @param positionVector a position vector that will be used on the X axis of the XY plot, Example: {0.0 1.0 0.0} 286 | * @param fieldFunction the field function to be used on the Y axis of the XY plot 287 | * @param plotName the presentation name of the XY plot 288 | */ 289 | public XYPlot createXYPlot(double[] positionVector, String plotName, String yAxisTitle) 290 | { 291 | XYPlot xYPlot_1 = m_sim.getPlotManager().createXYPlot(); 292 | xYPlot_1.setPresentationName(plotName); 293 | 294 | AxisType axisType_1 = xYPlot_1.getXAxisType(); 295 | axisType_1.setDirection(new DoubleVector(positionVector)); 296 | 297 | Axes axes_1 = xYPlot_1.getAxes(); 298 | Axis axis_2 = axes_1.getXAxis(); 299 | AxisTitle axisTitle_2 = axis_2.getTitle(); 300 | axisTitle_2.setText("Position [" + positionVector[0] + ", " + positionVector[1] + ", " + positionVector[2] + "] (m)"); 301 | 302 | Axis axis_3 = axes_1.getYAxis(); 303 | AxisTitle axisTitle_3 = axis_3.getTitle(); 304 | axisTitle_3.setText(yAxisTitle); 305 | 306 | return xYPlot_1; 307 | 308 | }// end method createXYPlot 309 | 310 | /** This method adds boundaries to a XY plot 311 | * 312 | * @param xYPlot the Star CCM+ object XYPlot 313 | * @param regionName the name of the region that will be added to the XY plot 314 | * @param boundaryNames the name of the boundaries that will be added to the XY plot must be contained in the previously defined region 315 | */ 316 | public void addObjects2XYPlot(XYPlot xYPlot, String regionName, String[] boundaryNames) 317 | { 318 | Region region = m_sim.getRegionManager().getRegion(regionName); 319 | YAxisType yAxisType_1 = ((YAxisType) xYPlot.getYAxes().getAxisType("Y Type 1")); 320 | for (int i = 0; i < boundaryNames.length; i++) 321 | { 322 | Boundary boundary = region.getBoundaryManager().getBoundary(boundaryNames[i]); 323 | xYPlot.getParts().addObjects(boundary); 324 | InternalDataSet internalDataSet = ((InternalDataSet) yAxisType_1.getDataSets().getDataSet(regionName + ": " + boundaryNames[i])); 325 | internalDataSet.setSeriesName(regionName + ": " + boundaryNames[i]); 326 | }//end for loop 327 | 328 | }// end of method addObjects2XYPlot 329 | 330 | /** This method adds a boundary to a XY plot 331 | * 332 | * @param xYPlot the Star CCM+ object XYPlot 333 | * @param regionName the name of the region that will be added to the XY plot 334 | * @param boundaryName the name of the boundary that will be added to the XY plot must be contained in the previously defined region 335 | */ 336 | public void addObject2XYPlot(XYPlot xYPlot, String regionName, String boundaryName) 337 | { 338 | Region region = m_sim.getRegionManager().getRegion(regionName); 339 | Boundary boundary = region.getBoundaryManager().getBoundary(boundaryName); 340 | xYPlot.getParts().addObjects(boundary); 341 | 342 | YAxisType yAxisType_1 = ((YAxisType) xYPlot.getYAxes().getAxisType("Y Type 1")); 343 | InternalDataSet internalDataSet = ((InternalDataSet) yAxisType_1.getDataSets().getDataSet(regionName + ": " + boundaryName)); 344 | internalDataSet.setSeriesName(regionName + ": " + boundaryName); 345 | }// end of method addObject2XYPlot 346 | 347 | 348 | /** This method adds a line probe to an XY plot 349 | * 350 | * @param xYPlot the Star-CCM+ object XYPlot 351 | * @param derivedPart the name of the line probe 352 | */ 353 | public void addLineProbe2XYPlot(XYPlot xYPlot, LinePart lineProbe) 354 | { 355 | xYPlot.getParts().addObjects(lineProbe); 356 | } 357 | 358 | }// end class ReportsMonitorsPlots 359 | -------------------------------------------------------------------------------- /ReportsMonitorsPlots_8_04.java: -------------------------------------------------------------------------------- 1 | package starClasses; 2 | 3 | import star.base.neo.DoubleVector; 4 | import star.base.report.*; 5 | import star.common.Axes; 6 | import star.common.Axis; 7 | import star.common.AxisTitle; 8 | import star.common.AxisType; 9 | import star.common.Boundary; 10 | import star.common.Coordinate; 11 | import star.common.InternalDataSet; 12 | import star.common.MonitorNormalizeOption; 13 | import star.common.MonitorPlot; 14 | import star.common.Region; 15 | import star.common.ResidualMonitor; 16 | import star.common.Simulation; 17 | import star.common.StarPlot; 18 | import star.common.StarUpdate; 19 | import star.common.StarUpdateModeOption; 20 | import star.common.Units; 21 | import star.common.XYPlot; 22 | import star.common.YAxisType; 23 | import star.flow.ForceCoefficientReport; 24 | import star.flow.ForceReportForceOption; 25 | import star.vis.FrontalAreaReport; 26 | import star.vis.LinePart; 27 | 28 | /** 29 | * This class is for creating reports, monitors, and plots 30 | * 31 | * @author cj8q5 32 | * 33 | */ 34 | public class ReportsMonitorsPlots_8_04 35 | { 36 | private Simulation m_sim; 37 | private Units m_units; 38 | 39 | public ReportsMonitorsPlots_8_04(Simulation sim) 40 | { 41 | m_sim = sim; 42 | m_units = ((Units) m_sim.getUnitsManager().getObject("m")); 43 | } 44 | 45 | /** This method is for creating a maximum report 46 | * 47 | * @param objectPath vector string containing a region and then a boundary, if only a region is found the report 48 | * will be created for the entire region 49 | * @param fieldFunction the name of the field function to be used in the max report such as "Pressure" or "Temperature" 50 | * @param reportName presentation name for the max report 51 | */ 52 | public MaxReport createMaxReport(String[] objectPath, String reportName) 53 | { 54 | MaxReport maxReport = m_sim.getReportManager().createReport(MaxReport.class); 55 | 56 | if (objectPath.length == 1) 57 | { 58 | Region region = m_sim.getRegionManager().getRegion(objectPath[0]); 59 | maxReport.getParts().setObjects(region); 60 | } 61 | if (objectPath.length > 1) 62 | { 63 | Region region = m_sim.getRegionManager().getRegion(objectPath[0]); 64 | for(int i = 1; i < objectPath.length; i++) 65 | { 66 | Boundary boundary = region.getBoundaryManager().getBoundary(objectPath[i]); 67 | maxReport.getParts().addObjects(boundary); 68 | } 69 | } 70 | 71 | maxReport.setPresentationName(reportName); 72 | return maxReport; 73 | 74 | }//end method createMaxReport 75 | 76 | /** This method creates a minimum report 77 | * 78 | * @param objectPath vector string containing a region and then a boundary, if only a region is found the report 79 | * will be created for the entire region 80 | * @param reportName presentation name for the min report 81 | */ 82 | public MinReport createMinReport(String[] objectPath, String reportName) 83 | { 84 | MinReport minReport = m_sim.getReportManager().createReport(MinReport.class); 85 | 86 | if (objectPath.length == 1) 87 | { 88 | Region region = m_sim.getRegionManager().getRegion(objectPath[0]); 89 | minReport.getParts().setObjects(region); 90 | } 91 | if (objectPath.length > 1) 92 | { 93 | Region region = m_sim.getRegionManager().getRegion(objectPath[0]); 94 | for(int i = 1; i < objectPath.length; i++) 95 | { 96 | Boundary boundary = region.getBoundaryManager().getBoundary(objectPath[i]); 97 | minReport.getParts().addObjects(boundary); 98 | } 99 | } 100 | 101 | minReport.setPresentationName(reportName); 102 | return minReport; 103 | 104 | }//end method createMinReport 105 | 106 | /** This method creates an average report 107 | * 108 | * @param regionName the name of the region where the avg report will be reporting from 109 | * @param boundaryName the name of the boundary where the field function will be averaged 110 | * @param fieldFunction the name of the field function that the avg report will use such as "Pressure" and "Temperature" 111 | * @param reportName presentation name for the avg report 112 | */ 113 | public AreaAverageReport createAverageReport(String[] objectPath, String reportName) 114 | { 115 | AreaAverageReport areaAverageReport = m_sim.getReportManager().createReport(AreaAverageReport.class); 116 | 117 | if (objectPath.length == 1) 118 | { 119 | Region region = m_sim.getRegionManager().getRegion(objectPath[0]); 120 | areaAverageReport.getParts().setObjects(region); 121 | } 122 | else 123 | { 124 | Region region = m_sim.getRegionManager().getRegion(objectPath[0]); 125 | for(int i = 1; i < objectPath.length; i++) 126 | { 127 | Boundary boundary = region.getBoundaryManager().getBoundary(objectPath[i]); 128 | areaAverageReport.getParts().addObjects(boundary); 129 | } 130 | } 131 | areaAverageReport.setPresentationName(reportName); 132 | return areaAverageReport; 133 | 134 | }//end method createAverageReport 135 | 136 | /** 137 | * This method creates an frontal area report for reporting the area of a part 138 | * @param partNames names of the parts for the desired area 139 | * @param reportName name of the report 140 | * @param viewUpVector view up vector, must be orthogonal to the normal vector 141 | * @param normalVector the normal vector 142 | * @return 143 | */ 144 | public FrontalAreaReport createAreaReport(String reportName, double[] viewUpVector, double[] normalVector) 145 | { 146 | FrontalAreaReport frontalAreaReport = m_sim.getReportManager().createReport(FrontalAreaReport.class); 147 | frontalAreaReport.setPresentationName(reportName); 148 | 149 | Coordinate coordinate_0 = frontalAreaReport.getViewUpCoordinate(); 150 | coordinate_0.setCoordinate(m_units, m_units, m_units, new DoubleVector(viewUpVector)); 151 | 152 | Coordinate coordinate_1 = frontalAreaReport.getNormalCoordinate(); 153 | coordinate_1.setCoordinate(m_units, m_units, m_units, new DoubleVector(normalVector)); 154 | return frontalAreaReport; 155 | } 156 | 157 | /** 158 | * This method creates a force coefficient report 159 | * @param regionName name of the region for the report to be created for 160 | * @param boundaryNames name of the boundaries 161 | * @param forceOption either "Pressure", "Shear", OR "Pressure and Shear" 162 | * @param refPressure the reference pressure (atmospheric) 163 | * @param forceDirection direction of the force 164 | * @param numOfBands number of bands the 165 | */ 166 | public void createForceCoefficientReportMonitorPlot(String regionName, String[] boundaryNames, String forceOption, 167 | double refPressure, double refVelocity, double refArea, double refDensity, double[] forceDirection, String reportName) 168 | { 169 | ForceCoefficientReport forceCoefficientReport = m_sim.getReportManager().createReport(ForceCoefficientReport.class); 170 | 171 | forceCoefficientReport.getReferenceDensity().setValue(refDensity); 172 | forceCoefficientReport.getReferenceVelocity().setValue(refVelocity); 173 | forceCoefficientReport.getReferenceArea().setValue(refArea); 174 | if(forceOption == "Pressure") 175 | { 176 | forceCoefficientReport.getForceOption().setSelected(ForceReportForceOption.PRESSURE); 177 | } 178 | if(forceOption == "Shear") 179 | { 180 | forceCoefficientReport.getForceOption().setSelected(ForceReportForceOption.SHEAR); 181 | } 182 | if(forceOption == "Pressure and Shear") 183 | { 184 | forceCoefficientReport.getForceOption().setSelected(ForceReportForceOption.PRESSURE_AND_SHEAR); 185 | } 186 | forceCoefficientReport.getReferencePressure().setValue(refPressure); 187 | forceCoefficientReport.getDirection().setComponents(forceDirection[0], forceDirection[1], forceDirection[2]); 188 | Region region = m_sim.getRegionManager().getRegion(regionName); 189 | 190 | for(int i = 0; i < boundaryNames.length; i++) 191 | { 192 | Boundary boundary = region.getBoundaryManager().getBoundary(boundaryNames[i]); 193 | forceCoefficientReport.getParts().addPart(boundary); 194 | } 195 | forceCoefficientReport.setPresentationName(reportName); 196 | 197 | ReportMonitor forceMonitor = forceCoefficientReport.createMonitor(); 198 | MonitorPlot monitorPlot = m_sim.getPlotManager().createMonitorPlot(); 199 | monitorPlot.getMonitors().addObjects(forceMonitor); 200 | monitorPlot.setPresentationName(reportName); 201 | } 202 | 203 | /** 204 | * This method turns off the "auto" normalization for the residual monitors in a simulation 205 | */ 206 | public void residualNormalization(String[] residualNames) 207 | { 208 | //String[] residualNames = {"Continuity", "Tdr", "Tke", "X-momentum", "Y-momentum", "Z-momentum"}; 209 | 210 | for (int i = 0; i < residualNames.length; i++) 211 | { 212 | ResidualMonitor residualMonitor = ((ResidualMonitor) m_sim.getMonitorManager().getMonitor(residualNames[i])); 213 | residualMonitor.getNormalizeOption().setSelected(MonitorNormalizeOption.OFF); 214 | } 215 | 216 | }// end method residualNormalization 217 | 218 | /** This method creates monitors and a monitor plot with them using two reports 219 | * 220 | * @param reportNames the name of the reports to be made into monitors and to be placed on a monitor plot 221 | * @param plotName presentation name of the plot 222 | * @param axesTitles presentation name of the X and Y axes 223 | * @param flag true for a plot with a max, min, and average reports and false for a plot with two average reports 224 | */ 225 | public void createMonitorPlot2(String[] reportNames, String plotName, String[] axesTitles, boolean flag) 226 | { 227 | if (flag == true) 228 | { 229 | MinReport minReport = ((MinReport) m_sim.getReportManager().getReport(reportNames[0])); 230 | ReportMonitor reportMonitor_0 = minReport.createMonitor(); 231 | StarUpdate starUpdate_0 = reportMonitor_0.getStarUpdate(); 232 | starUpdate_0.getUpdateModeOption().setSelected(StarUpdateModeOption.ITERATION); 233 | 234 | MaxReport maxReport = ((MaxReport) m_sim.getReportManager().getReport(reportNames[1])); 235 | ReportMonitor reportMonitor_1 = maxReport.createMonitor(); 236 | StarUpdate starUpdate_1 = reportMonitor_1.getStarUpdate(); 237 | starUpdate_1.getUpdateModeOption().setSelected(StarUpdateModeOption.ITERATION); 238 | 239 | AreaAverageReport aveReport = ((AreaAverageReport) m_sim.getReportManager().getReport(reportNames[2])); 240 | ReportMonitor reportMonitor_2 = aveReport.createMonitor(); 241 | StarUpdate starUpdate_2 = reportMonitor_2.getStarUpdate(); 242 | starUpdate_2.getUpdateModeOption().setSelected(StarUpdateModeOption.ITERATION); 243 | 244 | MonitorPlot monitorPlot = m_sim.getPlotManager().createMonitorPlot(); 245 | monitorPlot.setPresentationName(plotName); 246 | monitorPlot.getMonitors().addObjects(reportMonitor_0, reportMonitor_1, reportMonitor_2); 247 | 248 | IterationMonitor iterationMonitor = ((IterationMonitor) m_sim.getMonitorManager().getMonitor("Iteration")); 249 | monitorPlot.setXAxisMonitor(iterationMonitor); 250 | } 251 | 252 | if (flag == false) 253 | { 254 | AreaAverageReport aveReport_0 = ((AreaAverageReport) m_sim.getReportManager().getReport(reportNames[0])); 255 | ReportMonitor reportMonitor_0 = aveReport_0.createMonitor(); 256 | StarUpdate starUpdate_0 = reportMonitor_0.getStarUpdate(); 257 | starUpdate_0.getUpdateModeOption().setSelected(StarUpdateModeOption.ITERATION); 258 | 259 | AreaAverageReport aveReport_1 = ((AreaAverageReport) m_sim.getReportManager().getReport(reportNames[1])); 260 | ReportMonitor reportMonitor_1 = aveReport_1.createMonitor(); 261 | StarUpdate starUpdate_1 = reportMonitor_1.getStarUpdate(); 262 | starUpdate_1.getUpdateModeOption().setSelected(StarUpdateModeOption.ITERATION); 263 | 264 | MonitorPlot monitorPlot_1 = m_sim.getPlotManager().createMonitorPlot(); 265 | monitorPlot_1.setPresentationName(plotName); 266 | monitorPlot_1.getMonitors().addObjects(reportMonitor_0, reportMonitor_1); 267 | } 268 | 269 | StarPlot monitorPlot = m_sim.getPlotManager().getPlot(plotName); 270 | Axes axes = monitorPlot.getAxes(); 271 | 272 | Axis axis_0 = axes.getXAxis(); 273 | AxisTitle axisTitle_0 = axis_0.getTitle(); 274 | axisTitle_0.setText(axesTitles[0]); 275 | 276 | Axis axis_1 = axes.getYAxis(); 277 | AxisTitle axisTitle_1 = axis_1.getTitle(); 278 | axisTitle_1.setText(axesTitles[1]); 279 | }//end method createMonitorPlot2 280 | 281 | /** This method creates a XY plot of a field function versus position 282 | * 283 | * @param regionNames names of the regions where the boundaries can be found 284 | * @param boundaryNames names of the boundaries that will be plotted on the XY plot 285 | * @param positionVector a position vector that will be used on the X axis of the XY plot, Example: {0.0 1.0 0.0} 286 | * @param fieldFunction the field function to be used on the Y axis of the XY plot 287 | * @param plotName the presentation name of the XY plot 288 | */ 289 | public XYPlot createXYPlot(double[] positionVector, String plotName, String yAxisTitle) 290 | { 291 | XYPlot xYPlot_1 = m_sim.getPlotManager().createXYPlot(); 292 | xYPlot_1.setPresentationName(plotName); 293 | 294 | AxisType axisType_1 = xYPlot_1.getXAxisType(); 295 | axisType_1.setDirection(new DoubleVector(positionVector)); 296 | 297 | Axes axes_1 = xYPlot_1.getAxes(); 298 | Axis axis_2 = axes_1.getXAxis(); 299 | AxisTitle axisTitle_2 = axis_2.getTitle(); 300 | axisTitle_2.setText("Position [" + positionVector[0] + ", " + positionVector[1] + ", " + positionVector[2] + "] (m)"); 301 | 302 | Axis axis_3 = axes_1.getYAxis(); 303 | AxisTitle axisTitle_3 = axis_3.getTitle(); 304 | axisTitle_3.setText(yAxisTitle); 305 | 306 | return xYPlot_1; 307 | 308 | }// end method createXYPlot 309 | 310 | /** This method adds boundaries to a XY plot 311 | * 312 | * @param xYPlot the Star CCM+ object XYPlot 313 | * @param regionName the name of the region that will be added to the XY plot 314 | * @param boundaryNames the name of the boundaries that will be added to the XY plot must be contained in the previously defined region 315 | */ 316 | public void addObjects2XYPlot(XYPlot xYPlot, String regionName, String[] boundaryNames) 317 | { 318 | Region region = m_sim.getRegionManager().getRegion(regionName); 319 | YAxisType yAxisType_1 = ((YAxisType) xYPlot.getYAxes().getAxisType("Y Type 1")); 320 | for (int i = 0; i < boundaryNames.length; i++) 321 | { 322 | Boundary boundary = region.getBoundaryManager().getBoundary(boundaryNames[i]); 323 | xYPlot.getParts().addObjects(boundary); 324 | InternalDataSet internalDataSet = ((InternalDataSet) yAxisType_1.getDataSets().getDataSet(regionName + ": " + boundaryNames[i])); 325 | internalDataSet.setSeriesName(regionName + ": " + boundaryNames[i]); 326 | }//end for loop 327 | 328 | }// end of method addObjects2XYPlot 329 | 330 | /** This method adds a boundary to a XY plot 331 | * 332 | * @param xYPlot the Star CCM+ object XYPlot 333 | * @param regionName the name of the region that will be added to the XY plot 334 | * @param boundaryName the name of the boundary that will be added to the XY plot must be contained in the previously defined region 335 | */ 336 | public void addObject2XYPlot(XYPlot xYPlot, String regionName, String boundaryName) 337 | { 338 | Region region = m_sim.getRegionManager().getRegion(regionName); 339 | Boundary boundary = region.getBoundaryManager().getBoundary(boundaryName); 340 | xYPlot.getParts().addObjects(boundary); 341 | 342 | YAxisType yAxisType_1 = ((YAxisType) xYPlot.getYAxes().getAxisType("Y Type 1")); 343 | InternalDataSet internalDataSet = ((InternalDataSet) yAxisType_1.getDataSets().getDataSet(regionName + ": " + boundaryName)); 344 | internalDataSet.setSeriesName(regionName + ": " + boundaryName); 345 | }// end of method addObject2XYPlot 346 | 347 | 348 | /** This method adds a line probe to an XY plot 349 | * 350 | * @param xYPlot the Star-CCM+ object XYPlot 351 | * @param derivedPart the name of the line probe 352 | */ 353 | public void addLineProbe2XYPlot(XYPlot xYPlot, LinePart lineProbe) 354 | { 355 | xYPlot.getParts().addObjects(lineProbe); 356 | } 357 | 358 | }// end class ReportsMonitorsPlots -------------------------------------------------------------------------------- /Scenes.java: -------------------------------------------------------------------------------- 1 | package starClasses; 2 | 3 | import star.common.Boundary; 4 | import star.common.PrimitiveFieldFunction; 5 | import star.common.Region; 6 | import star.common.Simulation; 7 | import star.common.VectorComponentFieldFunction; 8 | import star.common.VectorMagnitudeFieldFunction; 9 | import star.vis.PlaneSection; 10 | import star.vis.ScalarDisplayer; 11 | import star.vis.Scene; 12 | 13 | /** 14 | * This class is for creating scenes in the simulation for post processing 15 | * 16 | * @author cj8q5 17 | * 18 | */ 19 | public class Scenes 20 | { 21 | private Simulation m_sim; 22 | private String m_sceneName; 23 | private Scene m_scene; 24 | private ScalarDisplayer m_scalarDisplayer; 25 | 26 | public Scenes(Simulation sim, String sceneName) 27 | { 28 | m_sim = sim; 29 | m_sceneName = sceneName; 30 | } 31 | 32 | /** This method creates a scene with specified parts and functions 33 | * 34 | * @param sceneName the presentation name for the new scalar scene 35 | */ 36 | public Scene createScalarScene() 37 | { 38 | m_sim.getSceneManager().createScalarScene("Scalar Scene", "Outline", "Scalar"); 39 | 40 | m_scene = m_sim.getSceneManager().getScene("Scalar Scene 1"); 41 | m_scene.setPresentationName(m_sceneName); 42 | m_scalarDisplayer = ((ScalarDisplayer) m_scene.getDisplayerManager().getDisplayer("Scalar 1")); 43 | 44 | m_scene.close(true); 45 | return m_scene; 46 | }//end createScalarScene 47 | 48 | /** 49 | * This method sets scalar scene for a primitive field function 50 | * @param primitiveFieldFunction the desired field function for the scene 51 | * @param scalarOrVector for setting the field function as a scalar or a vector 52 | * for a scalar input "4" for a vector magnitude input "3" for a vector component input "0", "1", or "2" 53 | */ 54 | public void setSceneFieldFunction(PrimitiveFieldFunction primitiveFieldFunction, int scalarOrVector) 55 | { 56 | if(scalarOrVector == 4) 57 | { 58 | m_scalarDisplayer.getScalarDisplayQuantity().setFieldFunction(primitiveFieldFunction); 59 | } 60 | if(scalarOrVector == 0 || scalarOrVector == 1 || scalarOrVector == 2) 61 | { 62 | VectorComponentFieldFunction vectorComponentFieldFunction = 63 | ((VectorComponentFieldFunction) primitiveFieldFunction.getComponentFunction(scalarOrVector)); 64 | 65 | m_scalarDisplayer.getScalarDisplayQuantity().setFieldFunction(vectorComponentFieldFunction); 66 | } 67 | else 68 | { 69 | VectorMagnitudeFieldFunction vectorMagnitudeFieldFunction = 70 | ((VectorMagnitudeFieldFunction) primitiveFieldFunction.getMagnitudeFunction()); 71 | 72 | m_scalarDisplayer.getScalarDisplayQuantity().setFieldFunction(vectorMagnitudeFieldFunction); 73 | } 74 | } 75 | 76 | /** This method adds boundaries to a scene 77 | * 78 | * @param scene the Star CCM+ object scene 79 | * @param regionName the name of the region that will be added to the scalar scene 80 | * @param boundaryNames the name of the boundaries that will be added to the scalar scene must be contained in the previously defined region 81 | */ 82 | public void addObject2Scene(Scene scene, String regionName, String[] boundaryNames) 83 | { 84 | ScalarDisplayer scalarDisplayer = ((ScalarDisplayer) scene.getDisplayerManager().getDisplayer("Scalar 1")); 85 | Region region = m_sim.getRegionManager().getRegion(regionName); 86 | for (int i = 0; i < boundaryNames.length; i++) 87 | { 88 | Boundary boundary = region.getBoundaryManager().getBoundary(boundaryNames[i]); 89 | scalarDisplayer.getParts().addObjects(boundary); 90 | } 91 | }// end of method addObject2Scene 92 | 93 | /** This method adds derived parts to a scene 94 | * 95 | * @param scene the Star CCM+ object scene 96 | * @param partNames the name of the derived parts that will be added to the scalar scene 97 | */ 98 | public void addDerivedPart2Scene(Scene scene, String[] partNames) 99 | { 100 | ScalarDisplayer scalarDisplayer = ((ScalarDisplayer) scene.getDisplayerManager().getDisplayer("Scalar 1")); 101 | for (int i = 0; i < partNames.length; i++) 102 | { 103 | PlaneSection plane = ((PlaneSection) m_sim.getPartManager().getObject(partNames[i])); 104 | scalarDisplayer.getParts().addObjects(plane); 105 | } 106 | }// end of method addDerivedPart2Scene 107 | 108 | }// end of class Scenes 109 | 110 | -------------------------------------------------------------------------------- /SimRunner.java: -------------------------------------------------------------------------------- 1 | package starClasses; 2 | 3 | import star.base.report.AreaAverageReport; 4 | import star.base.report.MaxReport; 5 | import star.base.report.MinReport; 6 | import star.common.Simulation; 7 | /** 8 | * 9 | * @author cj8q5 10 | * 11 | * This class sets various conditions in the simulation using data read in from each Mesh Data object 12 | */ 13 | public class SimRunner 14 | { 15 | private Simulation m_sim; 16 | private MaxReport m_maxPressureLargeCh; 17 | private MinReport m_minPressureLargeCh; 18 | private MaxReport m_maxPressureSmallCh; 19 | private MinReport m_minPressureSmallCh; 20 | 21 | // Constructor receives the current simulation as a Simulation object 22 | public SimRunner(Simulation sim) 23 | { 24 | m_sim = sim; 25 | m_maxPressureLargeCh = ((MaxReport) m_sim.getReportManager().getReport("MaxPressure_LargeCh")); 26 | m_minPressureLargeCh = ((MinReport) m_sim.getReportManager().getReport("MinPressure_LargeCh")); 27 | m_maxPressureSmallCh = ((MaxReport) m_sim.getReportManager().getReport("MaxPressure_SmallCh")); 28 | m_minPressureSmallCh = ((MinReport) m_sim.getReportManager().getReport("MinPressure_SmallCh")); 29 | } 30 | 31 | // Method to set variables, clear solution, and run the simulation 32 | public void runCase(MeshElementData mED, MeshSpacingData mSD, int iterations) 33 | { 34 | int extrudeCell = mED.getExtrudeCell(); 35 | int inletX = mED.getInletX(); 36 | int largeInletY = mED.getLargeInletY(); 37 | int smallInletY = mED.getSmallInletY(); 38 | int plateInletY = mED.getPlateInletY(); 39 | 40 | int largeChannelX = mED.getLgChannelX(); 41 | int largeChannelY = mED.getLgChannelY(); 42 | int smallChannelX = mED.getSmChannelX(); 43 | int smallChannelY = mED.getSmChannelY(); 44 | 45 | int outletX = mED.getOutletX(); 46 | int largeOutletY = mED.getLargeOutletY(); 47 | int smallOutletY = mED.getSmallOutletY(); 48 | int plateOutletY = mED.getPlateOutletY(); 49 | 50 | double inletSpacingX = mSD.getInletSpacingX(); 51 | double inletSpacingY = mSD.getInletSpacingY(); 52 | double outletSpacingX = mSD.getOutletSpacingX(); 53 | double outletSpacingY = mSD.getOutletSpacingY(); 54 | double smChannelSpacingX = mSD.getSmChannelSpacingX(); 55 | double smChannelSpacingY = mSD.getSmChannelSpacingY(); 56 | double lgChannelSpacingX = mSD.getLgChannelSpacingX(); 57 | double lgChannelSpacingY = mSD.getLgChannelSpacingY(); 58 | 59 | 60 | // Print line to output window to show how far the process has reached 61 | m_sim.println("Inside runCase with fluid mesh density at " + mED.getMeshDensity()); 62 | 63 | // Clear any previous solution 64 | m_sim.clearSolution(); 65 | 66 | // Run for x iterations 67 | m_sim.getSimulationIterator().run(iterations); 68 | 69 | // Get the max pressure in left channel 70 | double maxPressureLg = m_maxPressureLargeCh.getReportMonitorValue(); 71 | double minPressureLg = m_minPressureLargeCh.getReportMonitorValue(); 72 | double maxPressureSm = m_maxPressureSmallCh.getReportMonitorValue(); 73 | double minPressureSm = m_minPressureSmallCh.getReportMonitorValue(); 74 | 75 | mED.setMaxPressures(maxPressureLg, maxPressureSm); 76 | mED.setMinPressures(minPressureLg, minPressureSm); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /SolutionHistoryCreator.java: -------------------------------------------------------------------------------- 1 | package starClasses; 2 | 3 | import star.base.neo.NeoObjectVector; 4 | import star.common.PrimitiveFieldFunction; 5 | import star.common.Simulation; 6 | import star.common.StarUpdate; 7 | import star.post.SolutionHistoryManager; 8 | import star.post.SolutionHistory; 9 | 10 | public class SolutionHistoryCreator 11 | { 12 | 13 | private Simulation m_sim; 14 | private SolutionHistory m_solutionHistory; 15 | private StarUpdate m_starUpdate; 16 | 17 | public SolutionHistoryCreator(Simulation sim, String simhFileLocation) 18 | { 19 | m_solutionHistory = sim.get(SolutionHistoryManager.class).createForFile(simhFileLocation, false); 20 | m_sim = sim; 21 | } 22 | 23 | public void setUpdateSettings(String timestepOrIteration, int updateFrequency) 24 | { 25 | m_starUpdate = m_solutionHistory.getUpdate(); 26 | if (timestepOrIteration.equals("Iteration")) 27 | { 28 | m_starUpdate.setUpdateMode(1); 29 | } 30 | else if (timestepOrIteration.equals("Time Step")) 31 | { 32 | m_starUpdate.setUpdateMode(2); 33 | } 34 | } 35 | 36 | public void addScalarFieldFunction(String[] fieldFunction) 37 | { 38 | if (fieldFunction.length == 1) 39 | { 40 | PrimitiveFieldFunction primitiveFieldFunction_0 = 41 | ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction(fieldFunction[0])); 42 | m_solutionHistory.setScalars(new NeoObjectVector(new Object[] {primitiveFieldFunction_0})); 43 | } 44 | else if (fieldFunction.length > 1) 45 | { 46 | Object[] fieldFunctionVector = new Object[fieldFunction.length]; 47 | for (int i = 0; i < fieldFunction.length; i++) 48 | { 49 | PrimitiveFieldFunction primitiveFieldFunction = 50 | ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction(fieldFunction[i])); 51 | fieldFunctionVector[i] = primitiveFieldFunction; 52 | } 53 | m_solutionHistory.setScalars(new NeoObjectVector(fieldFunctionVector)); 54 | } 55 | } 56 | 57 | public void addVectorFieldFunction(String[] fieldFunction) 58 | { 59 | if (fieldFunction.length == 1) 60 | { 61 | PrimitiveFieldFunction primitiveFieldFunction_0 = 62 | ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction(fieldFunction[0])); 63 | m_solutionHistory.setVectors(new NeoObjectVector(new Object[] {primitiveFieldFunction_0})); 64 | } 65 | else if (fieldFunction.length > 1) 66 | { 67 | Object[] fieldFunctionVector = new Object[fieldFunction.length]; 68 | for (int i = 0; i < fieldFunction.length; i++) 69 | { 70 | PrimitiveFieldFunction primitiveFieldFunction = 71 | ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction(fieldFunction[i])); 72 | fieldFunctionVector[i] = primitiveFieldFunction; 73 | } 74 | m_solutionHistory.setVectors(new NeoObjectVector(fieldFunctionVector)); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /SolversNode.java: -------------------------------------------------------------------------------- 1 | package starClasses; 2 | 3 | import star.common.ImplicitUnsteadySolver; 4 | import star.common.Simulation; 5 | import star.common.TimeDiscretizationOption; 6 | import star.coupledflow.CoupledImplicitSolver; 7 | import star.keturb.KeTurbSolver; 8 | import star.cosimulation.abaqus.*; 9 | import star.morpher.*; 10 | 11 | /** 12 | * This class is setting various values and settings in the solvers node 13 | * 14 | * @author cj8q5 15 | * 16 | */ 17 | public class SolversNode 18 | { 19 | private Simulation m_sim; 20 | private AbaqusCoSimulationSolver m_abaqusCoSimSolver; 21 | private MovingMeshSolver m_movingMeshSolver; 22 | 23 | public SolversNode(Simulation sim) 24 | { 25 | m_sim = sim; 26 | } 27 | 28 | public void setSSorFSI(boolean SSorFSI) 29 | { 30 | m_abaqusCoSimSolver = ((AbaqusCoSimulationSolver) m_sim.getSolverManager().getSolver(AbaqusCoSimulationSolver.class)); 31 | m_movingMeshSolver = ((MovingMeshSolver) m_sim.getSolverManager().getSolver(MovingMeshSolver.class)); 32 | m_abaqusCoSimSolver.setFrozen(SSorFSI); 33 | m_movingMeshSolver.setFrozen(SSorFSI); 34 | } 35 | 36 | /** This method sets the k-epsilon under relaxation factor 37 | * 38 | * @param underRelaxFactor the desired under relaxation factor 39 | */ 40 | public void setKepsilonRelax(double underRelaxFactor) 41 | { 42 | // Setting the K-epsilon Turbulence model under relaxation factor 43 | KeTurbSolver keTurbSolver_0 = ((KeTurbSolver) m_sim.getSolverManager().getSolver(KeTurbSolver.class)); 44 | keTurbSolver_0.setUrf(underRelaxFactor); 45 | 46 | }// end method setKepsilonRelax 47 | 48 | /** 49 | * This method sets the courant number in the Implicit Solver 50 | * @param courantNumber desired value for the courant number 51 | */ 52 | public void setCourantNumber(double courantNumber) 53 | { 54 | CoupledImplicitSolver coupledSolver = ((CoupledImplicitSolver) m_sim.getSolverManager().getSolver(CoupledImplicitSolver.class)); 55 | coupledSolver.setCFL(courantNumber); 56 | } 57 | 58 | /** This method sets the unsteady time step in an implicit unsteady solver and the discretization option to either 1st or 2nd order 59 | * 60 | * @param timeStep the desired time step in seconds 61 | * @param timeDiscretizationOption either enter an int of 1 for first order or an int of 2 for second order 62 | */ 63 | public void setUnsteadyTimeStep(double timeStep, int timeDiscretizationOption) 64 | { 65 | ImplicitUnsteadySolver implicitUnsteadySolver = ((ImplicitUnsteadySolver) m_sim.getSolverManager().getSolver(ImplicitUnsteadySolver.class)); 66 | implicitUnsteadySolver.getTimeStep().setValue(timeStep); 67 | 68 | if (timeDiscretizationOption == 1) 69 | { 70 | implicitUnsteadySolver.getTimeDiscretizationOption().setSelected(TimeDiscretizationOption.FIRST_ORDER); 71 | } 72 | if (timeDiscretizationOption == 2) 73 | { 74 | implicitUnsteadySolver.getTimeDiscretizationOption().setSelected(TimeDiscretizationOption.SECOND_ORDER); 75 | } 76 | 77 | }// end method setUnsteadyTimeStep 78 | 79 | }// end class SolversNode 80 | 81 | -------------------------------------------------------------------------------- /StoppingCriteria.java: -------------------------------------------------------------------------------- 1 | package starClasses; 2 | 3 | import star.base.report.ReportMonitor; 4 | import star.common.InnerIterationStoppingCriterion; 5 | import star.common.MonitorIterationStoppingCriterion; 6 | import star.common.MonitorIterationStoppingCriterionAsymptoticType; 7 | import star.common.MonitorIterationStoppingCriterionMaxLimitType; 8 | import star.common.MonitorIterationStoppingCriterionMinLimitType; 9 | import star.common.MonitorIterationStoppingCriterionOption; 10 | import star.common.PhysicalTimeStoppingCriterion; 11 | import star.common.ResidualMonitor; 12 | import star.common.Simulation; 13 | import star.common.SolverStoppingCriterionLogicalOption; 14 | import star.common.StepStoppingCriterion; 15 | 16 | /** 17 | * This class is creating and setting parameters for stopping criteria 18 | * 19 | * @author cj8q5 20 | * 21 | */ 22 | public class StoppingCriteria 23 | { 24 | private Simulation m_sim = null; 25 | 26 | public StoppingCriteria(Simulation sim) 27 | { 28 | m_sim = sim; 29 | } 30 | 31 | /** 32 | * This method creates a stopping criteria of type minimum 33 | * 34 | * @param monitorName name of the monitor to be used in the stopping criteria 35 | * @param monitorType type of monitor being used either "Residual" or "Report" 36 | * @param innerOrOuterIterations for stopping inner or outer iterations 37 | * @param minLimit the minimum limit for the stopping criteria 38 | */ 39 | public void createMinStoppingCriteria(String monitorName, String monitorType, double minLimit, String innerOrOuterIterations, boolean Switch) 40 | { 41 | if (monitorType == "Residual") 42 | { 43 | ResidualMonitor residualMonitor = ((ResidualMonitor) m_sim.getMonitorManager().getMonitor(monitorName)); 44 | MonitorIterationStoppingCriterion monitorStoppingCriterion = residualMonitor.createIterationStoppingCriterion(); 45 | 46 | ((MonitorIterationStoppingCriterionOption) monitorStoppingCriterion.getCriterionOption()).setSelected(MonitorIterationStoppingCriterionOption.MINIMUM); 47 | MonitorIterationStoppingCriterionMinLimitType minLimitType = ((MonitorIterationStoppingCriterionMinLimitType) monitorStoppingCriterion.getCriterionType()); 48 | minLimitType.getLimit().setValue(minLimit); 49 | monitorStoppingCriterion.setIsUsed(Switch); 50 | } 51 | 52 | if (monitorType == "Report") 53 | { 54 | ReportMonitor reportMonitor = ((ReportMonitor) m_sim.getMonitorManager().getMonitor(monitorName)); 55 | MonitorIterationStoppingCriterion monitorStoppingCriterion = reportMonitor.createIterationStoppingCriterion(); 56 | 57 | ((MonitorIterationStoppingCriterionOption) monitorStoppingCriterion.getCriterionOption()).setSelected(MonitorIterationStoppingCriterionOption.MINIMUM); 58 | MonitorIterationStoppingCriterionMinLimitType minLimitType = ((MonitorIterationStoppingCriterionMinLimitType) monitorStoppingCriterion.getCriterionType()); 59 | minLimitType.getLimit().setValue(minLimit); 60 | monitorStoppingCriterion.setIsUsed(Switch); 61 | if (innerOrOuterIterations == "Inner") 62 | { 63 | monitorStoppingCriterion.setInnerIterationCriterion(true); 64 | monitorStoppingCriterion.setOuterIterationCriterion(false); 65 | } 66 | if (innerOrOuterIterations == "Outer") 67 | { 68 | monitorStoppingCriterion.setInnerIterationCriterion(false); 69 | monitorStoppingCriterion.setOuterIterationCriterion(true); 70 | } 71 | } 72 | 73 | }//end method createMinStoppingCriteria 74 | 75 | /** 76 | * This method creates a stopping criteria of type maximum 77 | * 78 | * @param monitorName name of the monitor to be used in the stopping criteria 79 | * @param monitorType type of monitor being used either "Residual" or "Report" 80 | * @param maxLimit the minimum limit for the stopping criteria 81 | */ 82 | public void createMaxStoppingCriteria(String monitorName, String monitorType, double maxLimit, String innerOrOuterIterations, boolean Switch) 83 | { 84 | if (monitorType == "Residual") 85 | { 86 | ResidualMonitor residualMonitor = ((ResidualMonitor) m_sim.getMonitorManager().getMonitor(monitorName)); 87 | MonitorIterationStoppingCriterion monitorStoppingCriterion = residualMonitor.createIterationStoppingCriterion(); 88 | 89 | ((MonitorIterationStoppingCriterionOption) monitorStoppingCriterion.getCriterionOption()).setSelected(MonitorIterationStoppingCriterionOption.MAXIMUM); 90 | MonitorIterationStoppingCriterionMaxLimitType maxLimitType = ((MonitorIterationStoppingCriterionMaxLimitType) monitorStoppingCriterion.getCriterionType()); 91 | maxLimitType.getLimit().setValue(maxLimit); 92 | monitorStoppingCriterion.setIsUsed(Switch); 93 | } 94 | 95 | if (monitorType == "Report") 96 | { 97 | ReportMonitor reportMonitor = ((ReportMonitor) m_sim.getMonitorManager().getMonitor(monitorName)); 98 | MonitorIterationStoppingCriterion monitorStoppingCriterion = reportMonitor.createIterationStoppingCriterion(); 99 | 100 | ((MonitorIterationStoppingCriterionOption) monitorStoppingCriterion.getCriterionOption()).setSelected(MonitorIterationStoppingCriterionOption.MAXIMUM); 101 | MonitorIterationStoppingCriterionMaxLimitType maxLimitType = ((MonitorIterationStoppingCriterionMaxLimitType) monitorStoppingCriterion.getCriterionType()); 102 | maxLimitType.getLimit().setValue(maxLimit); 103 | monitorStoppingCriterion.setIsUsed(Switch); 104 | if (innerOrOuterIterations == "Inner") 105 | { 106 | monitorStoppingCriterion.setInnerIterationCriterion(true); 107 | monitorStoppingCriterion.setOuterIterationCriterion(false); 108 | } 109 | if (innerOrOuterIterations == "Outer") 110 | { 111 | monitorStoppingCriterion.setInnerIterationCriterion(false); 112 | monitorStoppingCriterion.setOuterIterationCriterion(true); 113 | } 114 | } 115 | 116 | }//end method createMaxStoppingCriteria 117 | 118 | /** 119 | * This method creates a stopping criteria of type asymptotic 120 | * 121 | * @param monitorName name of the monitor to be used in the stopping criteria 122 | * @param monitorType type of monitor being used either "Residual" or "Report" 123 | * @param maxLimit the minimum limit for the stopping criteria 124 | */ 125 | public void createAsymStoppingCriteria(String monitorName, String monitorType, double rangeMaxMin, int numSamples, 126 | String logic, String innerOrOuterIterations, boolean Switch) 127 | { 128 | if (monitorType == "Residual") 129 | { 130 | ResidualMonitor residualMonitor = ((ResidualMonitor) m_sim.getMonitorManager().getMonitor(monitorName)); 131 | MonitorIterationStoppingCriterion monitorStoppingCriterion = residualMonitor.createIterationStoppingCriterion(); 132 | 133 | ((MonitorIterationStoppingCriterionOption) monitorStoppingCriterion.getCriterionOption()).setSelected(MonitorIterationStoppingCriterionOption.ASYMPTOTIC); 134 | MonitorIterationStoppingCriterionAsymptoticType monitorIterationStopping = ((MonitorIterationStoppingCriterionAsymptoticType) monitorStoppingCriterion.getCriterionType()); 135 | monitorIterationStopping.getMaxWidth().setValue(rangeMaxMin); 136 | monitorIterationStopping.setNumberSamples(numSamples); 137 | monitorStoppingCriterion.setIsUsed(Switch); 138 | 139 | if (logic == "AND") 140 | { 141 | monitorStoppingCriterion.getLogicalOption().setSelected(SolverStoppingCriterionLogicalOption.AND); 142 | } 143 | 144 | if (logic == "OR") 145 | { 146 | monitorStoppingCriterion.getLogicalOption().setSelected(SolverStoppingCriterionLogicalOption.OR); 147 | } 148 | 149 | } 150 | 151 | if (monitorType == "Report") 152 | { 153 | ReportMonitor reportMonitor = ((ReportMonitor) m_sim.getMonitorManager().getMonitor(monitorName)); 154 | MonitorIterationStoppingCriterion monitorStoppingCriterion = reportMonitor.createIterationStoppingCriterion(); 155 | 156 | ((MonitorIterationStoppingCriterionOption) monitorStoppingCriterion.getCriterionOption()).setSelected(MonitorIterationStoppingCriterionOption.ASYMPTOTIC); 157 | MonitorIterationStoppingCriterionAsymptoticType monitorIterationStopping = ((MonitorIterationStoppingCriterionAsymptoticType) monitorStoppingCriterion.getCriterionType()); 158 | monitorIterationStopping.getMaxWidth().setValue(rangeMaxMin); 159 | monitorIterationStopping.setNumberSamples(numSamples); 160 | monitorStoppingCriterion.setIsUsed(Switch); 161 | 162 | if (logic == "AND") 163 | { 164 | monitorStoppingCriterion.getLogicalOption().setSelected(SolverStoppingCriterionLogicalOption.AND); 165 | } 166 | 167 | if (logic == "OR") 168 | { 169 | monitorStoppingCriterion.getLogicalOption().setSelected(SolverStoppingCriterionLogicalOption.OR); 170 | } 171 | if (innerOrOuterIterations == "Inner") 172 | { 173 | monitorStoppingCriterion.setInnerIterationCriterion(true); 174 | monitorStoppingCriterion.setOuterIterationCriterion(false); 175 | } 176 | if (innerOrOuterIterations == "Outer") 177 | { 178 | monitorStoppingCriterion.setInnerIterationCriterion(false); 179 | monitorStoppingCriterion.setOuterIterationCriterion(true); 180 | } 181 | } 182 | 183 | }//end method createAsymStoppingCriteria 184 | 185 | /** This method is for controlling the inner iteration stopping criteria that is automatically added when an unsteady solver is enabled 186 | * 187 | * @param numInnerIterations the maximum number of inner iterations to make before moving on to the next time step 188 | * @param logic either "AND" or "OR" 189 | * @param Switch boolean for enabling or disabling the inner iteration stopping criteria 190 | */ 191 | public void innerIterationStoppingCriteriaController(int numInnerIterations, String logic, boolean Switch) 192 | { 193 | InnerIterationStoppingCriterion innerIterationStopCrit = 194 | ((InnerIterationStoppingCriterion) m_sim.getSolverStoppingCriterionManager().getSolverStoppingCriterion("Maximum Inner Iterations")); 195 | 196 | innerIterationStopCrit.setIsUsed(Switch); 197 | 198 | innerIterationStopCrit.setMaximumNumberInnerIterations(numInnerIterations); 199 | 200 | if (logic == "AND") 201 | { 202 | innerIterationStopCrit.getLogicalOption().setSelected(SolverStoppingCriterionLogicalOption.AND); 203 | } 204 | if (logic == "OR") 205 | { 206 | innerIterationStopCrit.getLogicalOption().setSelected(SolverStoppingCriterionLogicalOption.OR); 207 | } 208 | }// end of method innerIterationStoppingCriteriaController 209 | 210 | /** This method is for controlling the max physical time stopping criteria 211 | * 212 | * @param maxTime the maximum physical time 213 | * @param logic either "AND" or "OR" 214 | * @param Switch boolean for enabling or disabling the inner iteration stopping criteria 215 | */ 216 | public void maxPhysicalTime(double maxTime, String logic, boolean Switch) 217 | { 218 | PhysicalTimeStoppingCriterion physicalTime = 219 | ((PhysicalTimeStoppingCriterion) m_sim.getSolverStoppingCriterionManager().getSolverStoppingCriterion("Maximum Physical Time")); 220 | 221 | physicalTime.setIsUsed(Switch); 222 | 223 | physicalTime.getMaximumTime().setValue(maxTime); 224 | 225 | if (logic == "AND") 226 | { 227 | physicalTime.getLogicalOption().setSelected(SolverStoppingCriterionLogicalOption.AND); 228 | } 229 | if (logic == "OR") 230 | { 231 | physicalTime.getLogicalOption().setSelected(SolverStoppingCriterionLogicalOption.OR); 232 | } 233 | }// end of method maxPhysicalTime 234 | 235 | /** This method is for controlling the max steps stopping criteria 236 | * 237 | * @param numSteps the max number of time steps 238 | * @param logic either "AND" or "OR" 239 | * @param Switch boolean for enabling or disabling the max steps stopping criteria 240 | */ 241 | public void maxSteps(int numSteps, String logic, boolean Switch) 242 | { 243 | StepStoppingCriterion stepStoppingCriterion = 244 | ((StepStoppingCriterion) m_sim.getSolverStoppingCriterionManager().getSolverStoppingCriterion("Maximum Steps")); 245 | 246 | stepStoppingCriterion.setIsUsed(Switch); 247 | 248 | stepStoppingCriterion.setMaximumNumberSteps(numSteps); 249 | 250 | if (logic == "AND") 251 | { 252 | stepStoppingCriterion.getLogicalOption().setSelected(SolverStoppingCriterionLogicalOption.AND); 253 | } 254 | if (logic == "OR") 255 | { 256 | stepStoppingCriterion.getLogicalOption().setSelected(SolverStoppingCriterionLogicalOption.OR); 257 | } 258 | 259 | }// end of method maxSteps 260 | 261 | }//end class StoppingCriteria 262 | 263 | -------------------------------------------------------------------------------- /Tools.java: -------------------------------------------------------------------------------- 1 | package starClasses; 2 | 3 | import star.base.neo.NeoObjectVector; 4 | import star.common.Boundary; 5 | import star.common.PrimitiveFieldFunction; 6 | import star.common.Region; 7 | import star.common.Simulation; 8 | import star.common.XyzInternalTable; 9 | 10 | public class Tools 11 | { 12 | private Simulation m_sim; 13 | private XyzInternalTable m_internalTable; 14 | 15 | public Tools(Simulation sim) 16 | { 17 | m_sim = sim; 18 | } 19 | 20 | public void createXYZInternalTable(String regionName, String[] boundaryNames, String tableName) 21 | { 22 | m_internalTable = m_sim.getTableManager().createTable(XyzInternalTable.class); 23 | 24 | Region region = m_sim.getRegionManager().getRegion("Fluid"); 25 | 26 | for(int i = 0; i < boundaryNames.length; i++) 27 | { 28 | Boundary boundary = region.getBoundaryManager().getBoundary("Fluid.FSI_Back"); 29 | m_internalTable.getParts().addObjects(boundary); 30 | } 31 | m_internalTable.setPresentationName(tableName); 32 | } 33 | 34 | public void setXYZInternalTableFieldFunction(String fieldFunctionName) 35 | { 36 | PrimitiveFieldFunction primitiveFieldFunction_1 = 37 | ((PrimitiveFieldFunction) m_sim.getFieldFunctionManager().getFunction(fieldFunctionName)); 38 | m_internalTable.setFieldFunctions(new NeoObjectVector(new Object[] {primitiveFieldFunction_1})); 39 | } 40 | 41 | public void extractAndExportXYZInternalTableData(String outputFileLocation) 42 | { 43 | m_internalTable.extract(); 44 | m_internalTable.export(outputFileLocation, ","); 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /TrimmerMesher.java: -------------------------------------------------------------------------------- 1 | package starClasses; 2 | 3 | import star.common.Boundary; 4 | import star.common.BrickVolumeShape; 5 | import star.common.MeshContinuum; 6 | import star.common.Region; 7 | import star.common.Simulation; 8 | import star.meshing.AbsoluteMinimumSize; 9 | import star.meshing.AbsoluteTargetSize; 10 | import star.meshing.BaseSize; 11 | import star.meshing.GenericAbsoluteSize; 12 | import star.meshing.MeshConditionManager; 13 | import star.meshing.MeshPipelineController; 14 | import star.meshing.MeshValueManager; 15 | import star.meshing.RelativeMinimumSize; 16 | import star.meshing.RelativeOrAbsoluteOption; 17 | import star.meshing.RelativeTargetSize; 18 | import star.meshing.SurfaceSize; 19 | import star.meshing.SurfaceSizeOption; 20 | import star.meshing.VolumeSource; 21 | import star.meshing.VolumeSourceSize; 22 | import star.prismmesher.NumPrismLayers; 23 | import star.prismmesher.PrismMesherModel; 24 | import star.prismmesher.PrismStretchingOption; 25 | import star.prismmesher.PrismThickness; 26 | import star.prismmesher.PrismWallThickness; 27 | import star.resurfacer.ResurfacerMeshingModel; 28 | import star.resurfacer.SurfaceGrowthRate; 29 | import star.trimmer.TrimmerAnisotropicSize; 30 | import star.trimmer.TrimmerMeshingModel; 31 | import star.trimmer.TrimmerSizeOption; 32 | 33 | public class TrimmerMesher 34 | { 35 | private Simulation m_sim; 36 | private String m_regionName; 37 | private MeshContinuum m_mesh; 38 | private PrismMesherModel m_prism; 39 | private Region m_region; 40 | 41 | 42 | public TrimmerMesher(Simulation activeSim, String regionName) 43 | { 44 | m_sim = activeSim; 45 | m_regionName = regionName; 46 | m_region = m_sim.getRegionManager().getRegion(m_regionName); 47 | 48 | m_mesh = m_sim.getContinuumManager().createContinuum(MeshContinuum.class); 49 | m_mesh.enable(ResurfacerMeshingModel.class); 50 | m_mesh.enable(TrimmerMeshingModel.class); 51 | m_mesh.enable(PrismMesherModel.class); 52 | m_mesh.add(m_region); 53 | 54 | m_prism = m_mesh.getModelManager().getModel(PrismMesherModel.class); 55 | m_prism.getPrismStretchingOption().setSelected(PrismStretchingOption.WALL_THICKNESS); 56 | } 57 | 58 | /** 59 | * This method turns meshing in parallel on and off 60 | * @param onOrOff boolean for turning meshing in parallel on and off 61 | */ 62 | public void meshInParallel(boolean onOrOff) 63 | { 64 | m_mesh.setMeshInParallel(onOrOff); 65 | } 66 | 67 | public void setMesherSettings(double baseCellSize, double targetCellSizePercentage, double minimumCellSizePercentage) 68 | { 69 | m_mesh.getReferenceValues().get(BaseSize.class).setValue(baseCellSize); 70 | SurfaceSize surfaceSize = m_mesh.getReferenceValues().get(SurfaceSize.class); 71 | 72 | RelativeTargetSize relativeTargetSize = surfaceSize.getRelativeTargetSize(); 73 | relativeTargetSize.setPercentage(targetCellSizePercentage); 74 | 75 | RelativeMinimumSize relativeMinimumSize = surfaceSize.getRelativeMinimumSize(); 76 | relativeMinimumSize.setPercentage(minimumCellSizePercentage); 77 | } 78 | 79 | /** 80 | * This method sets the surface growth rate for custom surface sizes 81 | * @param surfaceGrowthRate the value for the surface growth rate 82 | */ 83 | public void setSurfaceGrowthRate(double surfaceGrowthRate) 84 | { 85 | SurfaceGrowthRate surfaceGrowthRate_0 = m_mesh.getReferenceValues().get(SurfaceGrowthRate.class); 86 | surfaceGrowthRate_0.setGrowthRate(surfaceGrowthRate); 87 | } 88 | 89 | /** 90 | * This method sets the minimum surface size and the target surface sizes for the overall mesh 91 | * @param minSurfaceSize 92 | * @param targetSurfaceSize 93 | */ 94 | public void setReferenceValuesSurfaceSize(double minSurfaceSize, double targetSurfaceSize) 95 | { 96 | SurfaceSize surfaceSize = m_mesh.getReferenceValues().get(SurfaceSize.class); 97 | surfaceSize.getRelativeOrAbsoluteOption().setSelected(RelativeOrAbsoluteOption.ABSOLUTE); 98 | 99 | AbsoluteMinimumSize absoluteMinimumSize = surfaceSize.getAbsoluteMinimumSize(); 100 | absoluteMinimumSize.getValue().setValue(minSurfaceSize); 101 | 102 | AbsoluteTargetSize absoluteTargetSize = surfaceSize.getAbsoluteTargetSize(); 103 | absoluteTargetSize.getValue().setValue(targetSurfaceSize); 104 | } 105 | 106 | /** 107 | * This method sets custom surface sizes on a specified region boundary 108 | * @param minSurfSizePercentage 109 | * @param targetSurfSizePercentage 110 | */ 111 | public void setCustomBoundarySurfaceSize(String boundaryName, double minSurfSizePercentage, double targetSurfSizePercentage) 112 | { 113 | Boundary boundary = m_region.getBoundaryManager().getBoundary(boundaryName); 114 | 115 | SurfaceSizeOption surfaceSizeOption_0 = boundary.get(MeshConditionManager.class).get(SurfaceSizeOption.class); 116 | surfaceSizeOption_0.setSurfaceSizeOption(true); 117 | 118 | SurfaceSize surfaceSize = boundary.get(MeshValueManager.class).get(SurfaceSize.class); 119 | RelativeMinimumSize relativeMinimumSize = surfaceSize.getRelativeMinimumSize(); 120 | relativeMinimumSize.setPercentage(minSurfSizePercentage); 121 | 122 | RelativeTargetSize relativeTargetSize = surfaceSize.getRelativeTargetSize(); 123 | relativeTargetSize.setPercentage(targetSurfSizePercentage); 124 | } 125 | 126 | public void setPrismLayerSettings(double prismLayerThickness, double wallThickness, int numPrismLayers) 127 | { 128 | m_mesh.getReferenceValues().get(PrismWallThickness.class).setValue(wallThickness); 129 | 130 | // Setting the number of prism layers for the prism layer mesher 131 | NumPrismLayers prismLayers = m_mesh.getReferenceValues().get(NumPrismLayers.class); 132 | prismLayers.setNumLayers(numPrismLayers); 133 | 134 | // Setting the overall thickness of all of the prism layers for the prism layer mesher 135 | PrismThickness prismThickness = m_mesh.getReferenceValues().get(PrismThickness.class); 136 | prismThickness.getRelativeOrAbsoluteOption().setSelected(RelativeOrAbsoluteOption.ABSOLUTE); 137 | GenericAbsoluteSize genericAbsoluteSize = ((GenericAbsoluteSize) prismThickness.getAbsoluteSize()); 138 | genericAbsoluteSize.getValue().setValue(prismLayerThickness); 139 | } 140 | 141 | /** 142 | * This method creates the volumetric control within the trimmer mesh 143 | * @param volumeShape 144 | */ 145 | public VolumeSource createBlockVolumetricControl(BrickVolumeShape volumeShape) 146 | { 147 | VolumeSource volumeSource = m_mesh.getVolumeSources().createVolumeSource(); 148 | volumeSource.getVolumeShapeGroup().setObjects(volumeShape); 149 | return volumeSource; 150 | } 151 | 152 | /** 153 | * This method sets the volumetric controls for the new volume shape 154 | * @param volumeSource 155 | * @param genericSize 156 | */ 157 | public void setTrimmerVolumetricControl(VolumeSource volumeSource, double genericSize) 158 | { 159 | volumeSource.get(MeshConditionManager.class).get(TrimmerSizeOption.class).setTrimmerSizeOption(true); 160 | 161 | volumeSource.get(MeshValueManager.class).get(VolumeSourceSize.class).getRelativeSize(). 162 | setPercentage(genericSize); 163 | } 164 | 165 | /** 166 | * This method sets the anisotropic settings for the volumetric control 167 | * @param volumeSource 168 | * @param anisotropicSwitchX 169 | * @param anisotropicSizeX 170 | * @param anisotropicSwitchY 171 | * @param anisotropicSizeY 172 | * @param anisotropicSwitchZ 173 | * @param anisotropicSizeZ 174 | */ 175 | public void setTrimmerVolumetricAnisotropicSize(VolumeSource volumeSource, 176 | boolean anisotropicSwitchX, double anisotropicSizeX, 177 | boolean anisotropicSwitchY, double anisotropicSizeY, 178 | boolean anisotropicSwitchZ, double anisotropicSizeZ) 179 | { 180 | volumeSource.get(MeshConditionManager.class).get(TrimmerSizeOption.class).setTrimmerAnisotropicSizeOption(true); 181 | TrimmerAnisotropicSize trimmerAnisotropicSize_0 = volumeSource.get(MeshValueManager.class). 182 | get(TrimmerAnisotropicSize.class); 183 | if(anisotropicSwitchX == true) 184 | { 185 | trimmerAnisotropicSize_0.setXSize(anisotropicSwitchX); 186 | trimmerAnisotropicSize_0.getRelativeXSize().setPercentage(anisotropicSizeX); 187 | } 188 | 189 | if(anisotropicSwitchY == true) 190 | { 191 | trimmerAnisotropicSize_0.setYSize(anisotropicSwitchY); 192 | trimmerAnisotropicSize_0.getRelativeYSize().setPercentage(anisotropicSizeY); 193 | } 194 | if(anisotropicSwitchZ == true) 195 | { 196 | trimmerAnisotropicSize_0.setZSize(anisotropicSwitchZ); 197 | trimmerAnisotropicSize_0.getRelativeZSize().setPercentage(anisotropicSizeZ); 198 | } 199 | } 200 | 201 | public void generateMesh() 202 | { 203 | MeshPipelineController meshPipelineController = m_sim.get(MeshPipelineController.class); 204 | meshPipelineController.generateVolumeMesh(); 205 | } 206 | 207 | } --------------------------------------------------------------------------------