CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   STAR-CCM+ (https://www.cfd-online.com/Forums/star-ccm/)
-   -   Importing probes coordinates (https://www.cfd-online.com/Forums/star-ccm/233026-importing-probes-coordinates.html)

DrDerpy13 January 11, 2021 02:47

Importing probes coordinates
 
Hello guys,


I am struggling for a while to import an .csv file to starccm in order to create probes from those coordinates. Does anybody have any clue how i should proceed?

JBeilke January 11, 2021 03:38

A java macro should do the job.

DrDerpy13 January 11, 2021 04:36

Could you give me more details how to do it? I know how to import the table, but not to correlate the data with my probes :(

JBeilke January 11, 2021 05:09

There should be 2 ways.

1) Don't read the csv into a table but read it via the macro and create a probe for every line in the file
2) Read the csv into a table and loop over the lines of the table.

cwl January 12, 2021 04:14

Quote:

Originally Posted by JBeilke (Post 792999)
There should be 2 ways.
2) Read the csv into a table and loop over the lines of the table.

Now I am curious - how can a loop over the lines of the table be implemented?

UPD The only way I can imagine - is to loop in Simulation Operations with Parameter and interpolateTable() using that parameter.
Is there any better way?

ping January 13, 2021 08:05

here are two java macros from 2011 that read from and write to a star table - see class table in the api - might need mods for recent versions of star

package macro;

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

/**
* This macro takes the first table it finds in the STAR-CCM+ simulation and prints the data in the 1st 4 columns
*
*/

public class JavaReadTable extends StarMacro {

Simulation sim;
Units meter;

public void execute() {
int rowStart = 0;
int colStart = 0;

sim = getActiveSimulation();
Table t = sim.getTableManager().getObjects().iterator().next ();

String format = "%0" + (Math.log10(t.getNumColumns()) + 1) + "d";
int nPoints = t.getNumRows();

for (int n = rowStart; n < nPoints; n++) {

sim.println( "Table data a, b, c, d : " +
t.getTableDataItem(n, 0) + ", " +
t.getTableDataItem(n, 1) + ", " +
t.getTableDataItem(n, 2) + ", " +
t.getTableDataItem(n, 3) ) ;

}
}

}

package macro;

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

/**
* This macro takes the first table it finds in the STAR-CCM+ simulation and prints the data in the 1st 4 columns
*
*/

public class JavaWriteToTable extends StarMacro {

Simulation sim;
Units meter;

public void execute() {
int rowStart = 0;
int colStart = 0;

sim = getActiveSimulation();
Table t = sim.getTableManager().getObjects().iterator().next ();

String format = "%0" + (Math.log10(t.getNumColumns()) + 1) + "d";
int nPoints = t.getNumRows();

t.setTableDataItem(0, 0) = 1234 ;

}

}


All times are GMT -4. The time now is 19:38.