Retrieving Problem Information Example of Retrieving Problem Information in a Mesh The following example shows how to retrieve information about a problem in the mesh: 1 Build a geometry: Model mdl = com.comsol.model.util.ModelUtil.create("Model1"); mdl.geom().create("g",3); mdl.geom("g").create("cyl1","Cylinder").set("h",3.0); mdl.geom("g").create("cyl2","Cylinder").set("h",3.0).set("r",0.95); mdl.geom("g").create("co1","Difference"); mdl.geom("g").feature("co1").selection("input").set("cyl1"); mdl.geom("g").feature("co1").selection("input2").set("cyl2"); 2 Build a mesh: MeshSequence ms = mdl.mesh().create("m", "g"); ms.feature("size").set("hauto", 9); ms.create("ftri1","FreeTri"); ms.feature("ftri1").selection().geom(2).set(1, 2, 7, 10); ms.create("ftet1","FreeTet"); ms.feature("ftet1").create("ms1","Size"); ms.run(); 3 Check if the mesh was built with problems: boolean problem = ms.hasProblems(); 4 Get the names of the features with problems. In this case the feature ftet1: String[] problemNames = ms.feature().problemNames(); 5 Get error information: String[] errorNames = ms.feature(problemNames[0]).problem(). errorNames(); for (String errorName : errorNames) { int errorDepth = ms.feature(problemNames[0]). problem(errorName).depth(); for (int i=0; i<errorDepth; ++i) { MeshFeature errorFeature = ms.feature(problemNames[0]).problem(errorName).get(i); String errorMessage = errorFeature.getString("message"); MeshSelection sel = null; if (errorFeature.hasSelection()) sel = errorFeature.selection(); } } 6 Get warning information: String[] warningNames = ms.feature(problemNames[0]).problem().warningNames(); MeshFeature warningFeature = ms.feature(problemNames[0]).problem(warningNames[0]); String warningMessage = warningFeature.getString("message"); MeshSelection sel = warningFeature.selection(); Example of Retrieving Problem and Warning Information in a Solver The same technique is also available for retrieving information about problems and warnings in a solvers sequence: 1 For a solver sequence ss1, check if there are any problems: SolverSequence ss1 boolean problem = ss1.hasProblems(); 2 Get the names of the features with problems: String[] problemNames = ss1.feature().problemNames(); 3 Get error information: String[] errorNames = ss1.feature(problemNames[0]).problem().errorNames(); SolverFeature errorFeature = ss1.feature(problemNames[0]).problem(errorNames[0]); String errorMessage = errorFeature.getString("message"); 4 Get warning information: String[] warningNames = ss1.feature(problemNames[0]).problem().warningNames(); SolverFeature warningFeature = ss1.feature(problemNames[0]).problem(warningNames[0]); String warningMessage = warningFeature.getString("message");