Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.

Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

Save as java file

Please login with a confirmed email address before reporting spam

Hello

On Comsol 4.1:
I'm trying to use java editing to build a dynamic model with subsequent changes in the geometry based on results of previous simulations. I would like to start from a model I already built and simulated with the GUI, but when I export the model into Java I get the whole history of my actions, like deleting/modifying stuff, so the code is full of useless parts. Is there any way of cleaning up the code automatically? Something like "save the model as it is" discarding all the history?

Many thanks,

Giuseppe Schiavone

10 Replies Last Post 29 juin 2012, 03:37 UTC−4
Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 13 déc. 2010, 08:33 UTC−5
Hi

have you tried int eh v4.1, "file reset model" ?

--
Good luck
Ivar
Hi have you tried int eh v4.1, "file reset model" ? -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 13 déc. 2010, 08:43 UTC−5
Alright,

didn't really see the menu item.. It works fine! Thanks a lot!

G. Schiavone
Alright, didn't really see the menu item.. It works fine! Thanks a lot! G. Schiavone

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 23 mars 2011, 04:49 UTC−4

Hi G. Schiavone,

Can you please tell from where I can get some java examples.

I want to creat a random distribution of my geometry feature (rectange) within a certain area(bigger rectangle). I make the rectangle in COMSOL GUI and then save model as .java file ... open it in Java editor and now I want to put random function and loops so that I can get randomly placed rectangles within a certain area (bigger rectangle)

In other words you can say that I want to make randomly placed rectangles within a bigger rectangle....

Thanks in advance
Hi G. Schiavone, Can you please tell from where I can get some java examples. I want to creat a random distribution of my geometry feature (rectange) within a certain area(bigger rectangle). I make the rectangle in COMSOL GUI and then save model as .java file ... open it in Java editor and now I want to put random function and loops so that I can get randomly placed rectangles within a certain area (bigger rectangle) In other words you can say that I want to make randomly placed rectangles within a bigger rectangle.... Thanks in advance

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 23 mars 2011, 05:43 UTC−4
I'm not sure I've well understood the question but I get what you're trying to do.
If you want Java code examples google is your friend. If you want COMSOL Java code samples.... just open any model and export it as Java and you'll have the code which you can read>understand>edit as you like.

Hope this was helpful..

G. Schiavone
I'm not sure I've well understood the question but I get what you're trying to do. If you want Java code examples google is your friend. If you want COMSOL Java code samples.... just open any model and export it as Java and you'll have the code which you can read>understand>edit as you like. Hope this was helpful.. G. Schiavone

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 23 mars 2011, 07:28 UTC−4


If you want COMSOL Java code samples.... just open any model and export it as Java and you'll have the code which you can read>understand>edit as you like.



Thanks a lot. Yes I need COMSOL JAVA code samples. However, I do not find any model that used loops. So is it possible to script loops in COMSOL JAVA scripting?

Thanks again
[QUOTE] If you want COMSOL Java code samples.... just open any model and export it as Java and you'll have the code which you can read>understand>edit as you like. [/QUOTE] Thanks a lot. Yes I need COMSOL JAVA code samples. However, I do not find any model that used loops. So is it possible to script loops in COMSOL JAVA scripting? Thanks again

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 23 mars 2011, 07:35 UTC−4
Yes I think it is possible. I've done it in the past with version 3.5, but using matlab code.
I used a while loop to redraw the geometry according to some values computed in the solution. So the cycle was: draw, compute, extract values -> modify geometry accordingly and all over again..
Not sure how Java works for what you want to do, but I don't think it'll take too much fiddling about to implement a simple loop cycle.

Keep experimenting!

G.Schiavone
Yes I think it is possible. I've done it in the past with version 3.5, but using matlab code. I used a while loop to redraw the geometry according to some values computed in the solution. So the cycle was: draw, compute, extract values -> modify geometry accordingly and all over again.. Not sure how Java works for what you want to do, but I don't think it'll take too much fiddling about to implement a simple loop cycle. Keep experimenting! G.Schiavone

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 1 août 2011, 22:08 UTC−4
I have a question regarding your posts. I know you can export COMSOL files as java files and they are relatively to understand but how do you run COMSOL java files externally from Eclipse for example? The API reference guide is unclear to a novice such as myself. Any help would be much appreciated. I do not have a background in java or eclipse.

Thanks
Alex
I have a question regarding your posts. I know you can export COMSOL files as java files and they are relatively to understand but how do you run COMSOL java files externally from Eclipse for example? The API reference guide is unclear to a novice such as myself. Any help would be much appreciated. I do not have a background in java or eclipse. Thanks Alex

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 1 août 2011, 22:56 UTC−4
In eclipse you have to start a new project. Then import the Library from Plugin folder of comsol, as stated in API guide. Then in the "src" folder copy your exported java file (from comsol gui) and then you just need to type in two statements one in the beginning of the code to connect to the local host (as explained in API) and one in the end of code to disconnect.

After doing above all. Run Comsol server, you should find it some where in start menu. After the server is running, click the play button to run the program in Eclipse.

I hope this helps ..... questions are welcome
In eclipse you have to start a new project. Then import the Library from Plugin folder of comsol, as stated in API guide. Then in the "src" folder copy your exported java file (from comsol gui) and then you just need to type in two statements one in the beginning of the code to connect to the local host (as explained in API) and one in the end of code to disconnect. After doing above all. Run Comsol server, you should find it some where in start menu. After the server is running, click the play button to run the program in Eclipse. I hope this helps ..... questions are welcome

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 4 août 2011, 09:02 UTC−4
And what is expected to happen when you do that (i.e. when you run a java model from eclipse)?

I have tried it with the feeder clamp model and I only see messages been displayed in the Comsol server window saying that a client has connected/disconnected, but nothing more happens... I am using Comsol version 4.2.

Do you know what is the expected result of executing a Java model externally from Eclipse? Thank you very much for your help.
And what is expected to happen when you do that (i.e. when you run a java model from eclipse)? I have tried it with the feeder clamp model and I only see messages been displayed in the Comsol server window saying that a client has connected/disconnected, but nothing more happens... I am using Comsol version 4.2. Do you know what is the expected result of executing a Java model externally from Eclipse? Thank you very much for your help.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 29 juin 2012, 03:37 UTC−4
I've had the same problem regarding old information in the java file. Whist it results in very large java files if you alter a model several times, it could be useful if you want to return to an old version of a model.

Does COMSOL allow you to restore a previous version of a model like this, given that all the information is contained in the java file?
I've had the same problem regarding old information in the java file. Whist it results in very large java files if you alter a model several times, it could be useful if you want to return to an old version of a model. Does COMSOL allow you to restore a previous version of a model like this, given that all the information is contained in the java file?

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.