I am running a bunch of 1 hour time dependent COMSOL models in a big 'for' loop. I can get Eclipse to export a .txt file for each iteration of the 'for' loop and I can show a progress bar and a 2D/3D image at the end inside a the GUI (this is the GUI in the back of the API guide) Comsol provides for eclipse. I am having 2 problems though:
1) I can not get COMSOL to export an image file. The line of code:
model.result().export("plot1").run();
works for exporting .txt, but using:
model.result().export("img1").run();
does NOT work for exporting an image file. nothing appears.
I added the code:
BufferedImage bi = new BufferedImage(pWidth,pHeight, BufferedImage.TYPE_INT_RGB);
Graphics g = bi.createGraphics();
frame.paint(g);
g.dispose();
try{ImageIO.write(bi,"png",new File("C:\\Users\\Alex\\Desktop\\surf_"+i+".png"));}catch (Exception e) {}
and I can get a screenshot of the JFrame of the GUI at the end of each time simulation but not the 2D plot that shoud appear (see attached file).
Anyone have hints how to make the export feature work for COMSOL and an image or how to take a screenshot with the 2D image in the JFrame?
2)
In that same GUI, what code and where do I need to add it to have the GUI display the solution as it happens?
model.sol("sol1").feature("t1").feature("fc1").set("plot", "on"); does not work, and:
model.sol("sol1").feature().create("t1","PlotWhileSolving") gives me the error:
com.comsol.util.exceptions.FlException: Operation cannot be created in this context
Thanks for any help
1) I can not get COMSOL to export an image file. The line of code:
model.result().export("plot1").run();
works for exporting .txt, but using:
model.result().export("img1").run();
does NOT work for exporting an image file. nothing appears.
I added the code:
BufferedImage bi = new BufferedImage(pWidth,pHeight, BufferedImage.TYPE_INT_RGB);
Graphics g = bi.createGraphics();
frame.paint(g);
g.dispose();
try{ImageIO.write(bi,"png",new File("C:\\Users\\Alex\\Desktop\\surf_"+i+".png"));}catch (Exception e) {}
and I can get a screenshot of the JFrame of the GUI at the end of each time simulation but not the 2D plot that shoud appear (see attached file).
Anyone have hints how to make the export feature work for COMSOL and an image or how to take a screenshot with the 2D image in the JFrame?
2)
In that same GUI, what code and where do I need to add it to have the GUI display the solution as it happens?
model.sol("sol1").feature("t1").feature("fc1").set("plot", "on"); does not work, and:
model.sol("sol1").feature().create("t1","PlotWhileSolving") gives me the error:
com.comsol.util.exceptions.FlException: Operation cannot be created in this context
Thanks for any help