Handling Geometry or Meshing Failures in MATLAB-COMSOL Model

Please login with a confirmed email address before reporting spam

Hi all,

I’m running a MATLAB-COMSOL model where I update my design variables using a command like:

% Set the variables nPoints = size(xy, 1); % Number of point pairs for i = 1:nPoints xi = xy(i,1); % x-coordinate yi = xy(i,2); % y-coordinate

model.param.set(sprintf('x%d', i), sprintf('%0.4f [mm]', xi));
model.param.set(sprintf('y%d', i), sprintf('%0.4f [mm]', yi));

end

However, in some cases, certain combinations of design variables lead to non-viable geometries. As a result, the model fails either during geometry generation or meshing, and I get an error when trying to evaluate:'

mphglobal(model, 'solid.LFcrit');

To handle this, I would like to check whether the geometry and mesh were successfully generated before calling mphglobal. If they weren’t, I want to skip that part so that MATLAB can continue iterating without crashing the whole optimization loop.

Is there a recommended way to check the status of geometry and mesh generation in COMSOL via the MATLAB API?

Any suggestions would be much appreciated!

Best regards, Mirhan


Reply

Please read the discussion forum rules before posting.

Please log in to post a reply.

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.