From c5de13525094e1f477ea517f1bba3b9cb396a0c2 Mon Sep 17 00:00:00 2001 From: Stefan Engblom Date: Thu, 16 Mar 2017 14:36:09 +0100 Subject: [PATCH] added resilience to missing solution in Comsol object --- urdme/comsol/comsol2urdme.m | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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.