The General Utility Functionality
The model object utility methods are available with the ModelUtil object. These methods can be used, for example, to create or remove a new model object, but also to enable the progress bar or list the model object available in the COMSOL server.
Managing The COMSOL model object
Use the method ModelUtil.create to create a new model object in the COMSOL server:
model = ModelUtil.create(<ModelTag>);
This command creates a model object Model on the COMSOL server and a MATLAB object model that is linked to the model object <ModelTag> in the COMSOL server.
It is possible to have several model objects on the COMSOL server, each with a different name. To access each model object requires different MATLAB variables linked to them and each MATLAB variable must have a different name.
Create a MATLAB variable linked to an existing model object with the function ModelUtil.model. For example, to create a MATLAB variable model that is linked to the existing model object <ModelTag> on the COMSOL server, enter the command
model = ModelUtil.model(<ModelTag>);
Alternatively you can use the function mphload as in the command
model = mphload(<ModelTag>);
The mphload function is most commonly used with the filename of a COMSOL model as an argument. You can use the function mphopen as well for the same purpose.
To remove a specific model object use the method ModelUtil.remove. For example, to remove the model object <ModelTag> from the COMSOL server enter the command
ModelUtil.remove(<ModelTag>);
Alternatively remove all the COMSOL objects stored in the COMSOL server with the command
ModelUtil.clear
COMSOL may produce a series of temporary files when settings up and model and solving it. These files may take up a considerable amount of disk space. The temporary files are deleted when COMSOL is shut down, but when solving model repeatedly you may experience that you run out of disk space. You may use the following command to purge any temporary files that are not in use
ModelUtil.clearCache
List the names of the model objects available on the COMSOL server with the command
mphtags -show
Using the RUN function and Activating The Progress Bar
It is possible to use the mphrun function to run solvers and to create geometries, meshes and so on. The mphrun command will by default show a progress bar while performing work to make it possible to monitor the progress of COMSOL while working on the model. For example, to start the solver execute
mphrun(model, 'std1')
By default when calling a run() method no progress information is displayed while running COMSOL with MATLAB. To manually enable a progress bar and visualize the progress of operations (such as loading a model, creating a mesh, assembling matrices, or computing the solution), enter the command
ModelUtil.showProgress(true)
To deactivate the progress bar enter
ModelUtil.showProgress(false)