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.
Handling Geometry or Meshing Failures in MATLAB-COMSOL Model
Posted 2025年4月17日 GMT+8 04:42 Geometry, Mesh, Modeling Workflow Version 6.2 0 Replies
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
Hello Mirhan Özdemir
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.