Demo entry 6632003

TL3D

   

Submitted by anonymous on Jul 20, 2017 at 16:50
Language: Java. Code size: 2.5 kB.

model.result().table().clear();
model.result().numerical().clear();

double n = model.param().evaluate("n");
int nRowsTotal = 0;

for (int i = 0; i < n; ++i) {
  String data = "dset"+toString(i+2);
  String pev = "pev"+toString(i+1);
  String cpt = "cpt"+toString(i+2);
  String tbl = "tbl"+toString(i+1);
  
  model.result().dataset().create(cpt, "CutPoint3D");
  with(model.result().dataset(cpt));
    set("pointx", 0);
    set("pointy", 0);
    set("pointz", "(ds/2)-0.0001");
    set("data", data);
  endwith();
  
  model.result().numerical().create(pev, "EvalPoint");
  with(model.result().numerical(pev));
    set("data", cpt);
  endwith();
  
  for (int k = 0; k < i+1; ++k) {
    model.result().numerical(pev).remove("unit", 0);
    model.result().numerical(pev).remove("descr", 0);
    model.result().numerical(pev).remove("expr", 0);
  }
  
  for (int j = i+1; j < n; ++j) {
    model.result().numerical(pev).remove("unit", 1);
    model.result().numerical(pev).remove("descr", 1);
    model.result().numerical(pev).remove("expr", 1);
  }
  
  model.result().table().create(tbl, "Table");
  model.result().table(tbl).comments("Point Evaluation T"+toString(i+2));
  with(model.result().numerical(pev));
    set("table", tbl);
  endwith();
  model.result().numerical(pev).setResult();
  nRowsTotal += model.result().table(tbl).getNRows();
}


// Initialize array to store all the data
double[][] allData = new double[nRowsTotal][2];

// Loop over all tables
int startIndexAlldata = 0;
for (int i = 0; i < n; i++) {
  
  // Get the table data
  String tbl = "tbl"+toString(i+1);
  double[][] tableData = model.result().table(tbl).getReal();
  
  // Populte the array with all the data
  for (int j = 0; j < model.result().table(tbl).getNRows(); j++) {
    allData[j+startIndexAlldata][0] = tableData[j][0];
    allData[j+startIndexAlldata][1] = tableData[j][1];
  }
  startIndexAlldata += model.result().table(tbl).getNRows();
}



// Create a new table
String tbl = "tableAllData";
model.result().table().create(tbl, "Table");
model.result().table(tbl).setTableData(allData);

// Create a table graph
String plotTag = "tableGraphPlot1";
model.result().remove(plotTag);
model.result().create(plotTag, "PlotGroup1D");
model.result(plotTag).set("data", "none");
model.result(plotTag).create("tblp1", "Table");
model.result(plotTag).feature("tblp1").set("table", tbl);
model.result(plotTag).run();

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).