CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   STAR-CCM+ (https://www.cfd-online.com/Forums/star-ccm/)
-   -   Macro problem: export specific monitors (https://www.cfd-online.com/Forums/star-ccm/218831-macro-problem-export-specific-monitors.html)

HerrOlsson July 5, 2019 08:47

Macro problem: export specific monitors
 
Hi,
I'm trying to export some of my monitors from my simulation to a csv file using a macro (I have A LOT of monitors, so I have to use a macro).

I want to export only the monitors which has "Force" in their name, and "time step" as trigger. My problem is that I can't find out how to write the line for filtering out the monitors I want. I can filter out the ones with "Force" in the name, no problem. But I don't know how to filter on trigger type.

My code is as below:
Code:

package macro;

import java.util.*;

import star.common.*;
import star.base.neo.*;
import star.base.report.*;

public class solutionDataExport extends StarMacro {
 
  public void execute() {
    execute0();
  }

  private void execute0() {

    Simulation simulation_0 =
      getActiveSimulation();
   
        // Collect all monitors
    Collection<Monitor> monitorReports = simulation_0.getMonitorManager().getMonitors();
       
        // Create an empty vector to which the monitors will be added
        Vector monitorsVector = new NeoObjectVector(new Object[] {});
       
        // Add monitors with "Force" in name and trigger type time step to vector
        for (Iterator<Monitor> iterator = monitorReports.iterator(); iterator.hasNext();) {
                Monitor thisMonitor = iterator.next();
                if (thisMonitor.getPresentationName().contains("Force") && ???){
                        monitorsVector.add(thisMonitor);
                }
    }
        // Export csv-file
        simulation_0.getMonitorManager().export("./simulationData.csv", ",", monitorsVector);
  }
}

In other words, with what should I replace ??? in line 29 of the code to make it work as intended?
Thanks in advance!


All times are GMT -4. The time now is 12:00.