diff --git a/urdme/comsol/comsol2urdme.m b/urdme/comsol/comsol2urdme.m index 567845ca..fdba2c36 100644 --- a/urdme/comsol/comsol2urdme.m +++ b/urdme/comsol/comsol2urdme.m @@ -22,7 +22,18 @@ % Get extended mesh data l_info(verbose,1,'Start mphxmeshinfo...'); -xmi = mphxmeshinfo(fem); +try + xmi = mphxmeshinfo(fem); +catch ME + % Comsol-problems: sometimes the solution is lost and a model + % re-run is the most immediate solution. + if strcmp(ME.message,'The model does not contain any solutions') + warning(['No solution found in the Comsol object. ' ... + 'Will now try to execute model.sol.run().']); + fem.sol.run() + xmi = mphxmeshinfo(fem); + end +end l_info(verbose,1,' ...done.\n'); % Get number of species and number of cells.