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.

LocalSelectionImpl/set error when using mphinterp

Please login with a confirmed email address before reporting spam

This is not a question, rather documentation for anyone who might encounter the same problem in the future.

I followed these steps:
1. Build a model.
2. Delete everything non-essential.
3. File -> Reset History
4. File -> Save As Model M-File...
5. Opened the m-file and added a few commands at the end to post-process the results. Including a call to mphinterp(..).
6. Ran it using a command like
comsolserver matlab "tbc_test, exit" -mlroot "C:\Program Files\MATLAB\R2012a" -np 6 -Dcs.ckl -nodesktop

7. Received the following error:



Error using com.comsol.model.impl.LocalSelectionImpl/set
Java exception occurred:
Exception:
java.lang.NullPointerException
(rethrown as com.comsol.util.exceptions.FlException)
Messages:



Stack trace:

at com.comsol.model.internal.impl.SelectionImpl.a(Unknown Source)

at com.comsol.model.internal.impl.SelectionImpl$a.a(Unknown Source)

at com.comsol.model.internal.impl.SelectionImpl$a.execute(Unknown Source)

at com.comsol.model.clientserver.ClientManagerImpl$e.call(Unknown Source)

at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)

at java.util.concurrent.FutureTask.run(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)


Error in C:\Programs\COMSOL42a\mli\mphinterp.p>mphinterp (line 153)


Error in tbc_test (line 192)
[t, unit] = mphinterp(model, ...



Solution: to avoid this happening, a "Solution 1" under "Data Sets" under "Results" should still be present when saving the model as an M-file. I had deleted it before saving, and this, somehow, lead to the error message above.

How I figured it out:
• Started COMSOL with MATLAB, copied-and-pasted the contents of the M-file (except the function header) into it. This way I could experiment with mphinterp(..) without having to run the model from the command line every time I change something.
• Made a very simple model, and experimented with it. Figured out that the difference was the presence of "model.result.dataset.remove('dset1');" in the original M-file.
• This took a long time because of the unhelpful error message and no access to the source.

2 Replies Last Post 2013年12月8日 GMT-5 20:47
COMSOL Moderator

Hello Evgeni Sergeev

Your Discussion has gone 30 days without a reply. If you still need help with COMSOL and have an on-subscription license, please visit our Support Center for help.

If you do not hold an on-subscription license, you may find an answer in another Discussion or in the Knowledge Base.


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2012年12月4日 GMT-5 08:39
I spent more than a day to figure out why I cannot use mpheval, mphinterp, etc... until I saw your note.

It is simply that the following statement will be written into the .m file if there is no solution object, i.e. in the results tree (in the GUI).

model.result.dataset.remove('dset1');

But when I just right clicked results tree (in the GUI) and added a solution object, the following statement will be written into

model.result.dataset.create('dset1', 'Solution');

The latter supersedes the former and hence mpheval, mphinterp, etc. become active and errors such as 'unknown source', will not appear when run in matlab.

I am sure this may have been implicitly or explicitly stated in the manuals - but don't know where.

Therefore, I would like to thank you.


Suresh
I spent more than a day to figure out why I cannot use mpheval, mphinterp, etc... until I saw your note. It is simply that the following statement will be written into the .m file if there is no solution object, i.e. in the results tree (in the GUI). model.result.dataset.remove('dset1'); But when I just right clicked results tree (in the GUI) and added a solution object, the following statement will be written into model.result.dataset.create('dset1', 'Solution'); The latter supersedes the former and hence mpheval, mphinterp, etc. become active and errors such as 'unknown source', will not appear when run in matlab. I am sure this may have been implicitly or explicitly stated in the manuals - but don't know where. Therefore, I would like to thank you. Suresh

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2013年12月8日 GMT-5 20:47
I saw this at the end of my model and was wondering what it was doing there.
Thanks for the clarification! And helping us save time!
I saw this at the end of my model and was wondering what it was doing there. Thanks for the clarification! And helping us save time!

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.