-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReport_to_CSV.java
More file actions
55 lines (39 loc) · 1.45 KB
/
Report_to_CSV.java
File metadata and controls
55 lines (39 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// STAR-CCM+ macro: Report_to_csv.java
package macro;
import java.util.*;
import java.io.*;
import java.nio.*;
import star.common.*;
import star.base.neo.*;
import star.base.report.*;
import star.flow.*;
public class Report_to_CSV extends StarMacro {
BufferedWriter bwout = null;
public void execute() {
try {
Simulation simulation_0 = getActiveSimulation();
// Collecting the simualtion file name
String simulationName = simulation_0.getPresentationName();
simulation_0.println("Simulation Name:" + simulationName);
// Open Buffered Input and Output Readers
// Creating file with name "<sim_file_name>+report.csv"
bwout = new BufferedWriter(new FileWriter(resolvePath(simulationName +"report.csv")));
bwout.write("Report Name, Value, Unit, \n");
Collection<Report> reportCollection = simulation_0.getReportManager().getObjects();
for (Report thisReport : reportCollection){
String fieldLocationName = thisReport.getPresentationName();
Double fieldValue = thisReport.getReportMonitorValue();
String fieldUnits = thisReport.getUnits().toString();
// Printing to chek in output window
simulation_0.println("Field Location :" + fieldLocationName);
simulation_0.println(" Field Value :" + fieldValue);
simulation_0.println(" Field Units :" + fieldUnits);
simulation_0.println("");
// Write Output file as "sim file name"+report.csv
bwout.write( fieldLocationName + ", " +fieldValue + ", " + fieldUnits +"\n");
}
bwout.close();
} catch (IOException iOException) {
}
}
}