Is There a Fix for COMSOL Script Null Pointer Java Error?

  • Thread starter Thread starter py_engineer
  • Start date Start date
  • Tags Tags
    Comsol Issues
Click For Summary
SUMMARY

The discussion addresses a common issue encountered in COMSOL Script, specifically a Null Pointer Java error when executing a mesh initialization command. The error arises due to the attempt to run the script in a graphical mode on a remote server lacking graphics capabilities. The solution provided is to use the command 'comsol batch filename' instead of 'comsol script filename' to prevent the progress window from opening, which leads to the simulation crash. Users are advised to ensure that their scripts are compatible with batch processing to avoid similar errors.

PREREQUISITES
  • Familiarity with COMSOL Multiphysics scripting
  • Understanding of Java error handling
  • Knowledge of remote server operations
  • Experience with mesh initialization in COMSOL
NEXT STEPS
  • Research the differences between 'comsol script' and 'comsol batch' commands
  • Learn about handling Java exceptions in COMSOL scripts
  • Explore best practices for running simulations on remote servers
  • Investigate COMSOL's mesh initialization techniques and parameters
USEFUL FOR

This discussion is beneficial for COMSOL users, particularly those working with scripts for simulations on remote servers, as well as developers looking to troubleshoot Java-related errors in their COMSOL projects.

py_engineer
Messages
11
Reaction score
0
Hi,

Is there anyone who can help me with COMSOL Script?

Is there anything wrong with this statement:

flclear fem

g6=rect2(1.0E-6,11.0E-6,'base','corner','pos',[0,0]);

clear s
s.objs={g6};
s.name={'CO1'};
s.tags={'g6'};

fem.draw=struct('s',s);
fem.geom=geomcsg(fem);

fem.mesh=meshinit(fem,'hauto',5);

---------------------

However, when I run this, I get this f..#@>*^& null pointer Java error! :(

Error: java.lang.NullPointerException
at com.femlab.server.MlProgressDlg.runAndWait(Unknown Source)

Error in built-in function javaMethod.
meshinitaux 67 MeshRun.smartRunner(report, loopTime);
meshinit 351 varargout = meshinitaux(fem,'meshinit',varargin{:});
comsol_DLPH_basefile 116 fem.mesh=meshinit(fem.geom,'hauto',5)
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
at com.femlab.jline.ConsoleReader.readBinding(Unknown Source)
at com.femlab.jline.ConsoleReader.readLine(Unknown Source)
at com.femlab.jline.ConsoleReader.readLine(Unknown Source)
at com.femlab.script.Terminal.a(Unknown Source)
at com.femlab.script.Terminal.b(Unknown Source)
at com.femlab.script.Terminal.main(Unknown Source)

--------------------------

Any help would be greatly appreciated!

Thanks!
 
Physics news on Phys.org
...got a geometry and a mesh out of it so perhaps there is an error "somewhere else"?
 
Ok, I got it, that wasn't too difficult, but it took me so long!

So I was trying to run COMSOL in the background. But 'comsol script filename' tries to open a progress window, and this makes the simulation crash since I was running this on a remote server with no graphics capability.. To avoid that, you just do 'comsol batch filename'..
 
An error keep repeating myself very often :blushing: .
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
5K