ModelUtil.create(<tag>): The
create method creates a model with tag
<tag>. Returns a reference to the model. If there is already a model with this tag the previous model is removed.
ModelUtil.remove(<tag>): The
remove method removes the model tagged
<tag>.
ModelUtil.clear(): The
clear method removes all models.
ModelUtil.tags(): The
tags method obtains the current list of model tags.
ModelUtil.model(<tag>): The
model method returns a reference to the model tagged
<tag>.
ModelUtil.closeWindow(<windowtag>): The
closeWindow method closes the window tagged
<windowtag>.
ModelUtil.closeWindows(): The
closeWindows method closes all windows on the server.
ModelUtil.createUnique(<prefix>): The
createUnique method creates a model with a unique tag that begins with the prefix
<prefix>.
ModelUtil.getComsolVersion(): The
getComsolVersion method returns the current COMSOL Multiphysics version as a string.
ModelUtil.getOpenGeometryKernel(): The
getOpenGeometryKernel method returns the geometry kernel to use when opening models. Valid values are
model for the geometry kernel used by the model file, and
comsol to convert the geometry to the COMSOL kernel.
ModelUtil.getDefaultGeometryKernel(): The
getDefaultGeometryKernel method returns the default geometry kernel in new models. Valid values are
comsol for the COMSOL kernel and
cadps for the CAD kernel (Parasolid kernel). The CAD kernel requires the CAD Import Module.
ModelUtil.setOpenGeometryKernel(<openkernel>): The
setOpenGeometryKernel method specifies the geometry kernel to use when opening models. Valid values are
model for the geometry kernel used by the model file, and
comsol to convert the geometry to the COMSOL kernel.
ModelUtil.setDefaultGeometryKernel(<defaultkernel>): The
setDefaultGeometryKernel method specifies the default geometry kernel to use in new models with the string
<defaultkernel>. Valid values are
comsol for the COMSOL kernel and
cadps for the CAD kernel (Parasolid kernel). The CAD kernel requires the CAD Import Module.
ModelUtil.getEntityPath(<entity>,<divider>): The
getEntityPath method creates the path from the root of the model object for the given entity
<entity>.
<divider> specifies a divider to use between entities in path.
ModelUtil.load(<tag>,<modelLocation>): The
load method loads a model from a model location
<modelLocation>, which can be the absolute path of a file on the file system or a model location URI identifying a model version in a Model Manager database and names it
<tag>. Loading a model file from a directory on the file system sets the model directory. The model directory is used for saving files on the file system if you do not provide an absolute path to the file. The model directory is the directory where the model is saved. If the model has not been saved there is no model directory, you can get the model directory from a saved model using
model.getFilePath.
ModelUtil.loadCopy(<tag>,<filename>): The
loadCopy method loads a copy of a model from a file
<filename> in the client’s file system and names it
<tag>. The
loadCopy method is the same as
load except that the loaded model is not associated with the file, so
model.save() does not work. You have to specify the filename the first time you save it again.
ModelUtil.loadOnServer(<tag>,<filename>): The
loadOnServer method works like
ModelUtil.load except that the filename is a path on the server computer. The client does not have to have access to the file.
ModelUtil.loadProtected(<tag>,<filename>,<password>): The
loadProtected method works like
ModelUtil.load but with password protection.
ModelUtil.loadProtectedOnServer(<tag>,<filename>,<password>): The
loadProtectedOnServer method works like
ModelUtil.loadOnServer but with password protection.
ModelUtil.loadRecovery(<tag>,<foldername>): The
loadRecovery method loads a model from a recovery directory or folder structure in the client’s file system and names it
<tag>.
ModelUtil.showPlots(bool): The
showPlots method applies when connected to a graphics server, and
ModelUtil.showPlots(false) will disable plotting. It will not close any existing plot windows. Use
ModelUtil.closeWindow(<tag>) or
ModelUtil.closeWindows() to do that.
ModelUtil.showProgress(bool): The
showProgress method with a boolean input turns on or off showing of progress in a window or on a file when running lengthy tasks when connected to a server. The return value is a boolean value that is true if showing progress is possible.
ModelUtil.showProgress(<filename>): The
showProgress method with a filename input turns on logging of progress to the file
<filename> in the client’s file system. If
<filename> is
null progress is logged to the standard output.
ModelUtil.initStandalone(bool): The
initStandalone method initializes the environment for using the COMSOL API in model files for Java
®. You should
not use this command from the LiveLink™
for MATLAB®. Set the argument to true if support for plotting in a GUI using Java Swing widgets should be available.
ModelUtil.initStandalone(bool,<guiToolkit>) allows to specify that support for using a given Java GUI toolkit should be available. The optional
<guiToolkit> parameter can have the values
"swing" or
"swt" telling that Swing widgets or widgets from the Standard Widget Toolkit (SWT) can be used.
ModelUtil.getPreference(<prefsName>): The
getPreference method returns the value of a preference.
ModelUtil.setPreference(<prefsName>, <value>): The
setPreference method sets the value of a preference.
ModelUtil.listPreferences(): The
listPreferences method returns a string with a listing of the preferences names and their descriptions.
ModelUtil.loadPreferences(): The
loadPreferences method loads the preferences from file. Use this in model files for Java, which do not load the preferences at launch time.
ModelUtil.savePreferences(): The
savePreferences method saves the preferences to file.
ModelUtil.uniquetag(String prefix): The
uniquetag method returns a unique model tag with a prefix that the tag should begin as an input argument.
ModelUtil.modelsUsedByOtherClients(): The
modelsUsedByOtherClients method returns the tags of models used by other clients.
ModelUtil.blockOtherClients(boolean blockOtherClients), which blocks other clients from a server. This command is only meaningful when there are multiple clients connected to the server. Calling
ModelUtil.blockOtherClients(true) will block other clients. The blocking is lifted when clients requesting the block call
ModelUtil.blockOtherClients(false) or when it disconnects from the server.
ModelUtil.ClearCache(), which clears the memory and disk cache (containing, for example, geometries, meshes, rendering data, and plots).
ModelUtil.setCacheMaxSize(long fileCache, long memoryCache): Set the maximum size used for caching (for example, geometries, meshes, rendering data, and plots).
fileCache is the maximum number of megabytes (MB) used for caching in the temp file area, and
memoryCache is the maximum number of megabytes (MB) used for caching in memory. Note that when running memory-demanding operations in the COMSOL Multiphysics software, the memory cache is automatically swapped to disk.
getCacheMaxSizeMemory() returns, as a long data type, the maximum amount of memory in megabytes (MB) used for caching, for example, geometries, meshes, and rendering data.
getCacheMaxSizeDisk() returns, as a long data type, the maximum amount of disk in megabytes (MB) used in the temp area for caching, for example, geometries, meshes, and rendering data.
ModelUtil provides functionality to check availability for and control the checkout of COMSOL product licenses.
ModelUtil.hasProduct(String... product): The
hasProduct method checks if the current license allows to run the specified COMSOL products given as the input (as an array of strings).
ModelUtil.hasProductForFile(String file): The
hasProductForFile method checks if the current license allows the specified COMSOL products needed to use that COMSOL MPH file.
ModelUtil.hasProductForFileonServer(String file): The
hasProductForFileonServer method is similar to
hasProductForFile but checks if the license allows the specified COMSOL products needed for a file on the server.
ModelUtil.checkoutLicense(String... product): The
checkoutLicense method checks out licenses for the COMSOL products given as the input (as an array of strings).
ModelUtil.checkoutLicenseForFile(String file): The
checkoutLicenseForFile method checks out the licenses needed to use that COMSOL MPH file.
ModelUtil.checkoutLicenseForFileonServer(String file): The
checkoutLicenseForFileonServer method is similar to
checkoutLicenseForFile but checks out the licenses needed to use that COMSOL MPH file on the server.
ModelUtil provides functionality to control COMSOL client-server options. You can connect/disconnect and control connections from multiple clients to a server using, for example, the
connect and
disconnect methods.
ModelUtil.connect() connects to a COMSOL server (COMSOL Multiphysics server or COMSOL Server™). The COMSOL command arguments
-Dcs.host=<host> and
-Dcs.port=<port> can provide the hostname and port number. In case those are not provided, and the both client and server access the same file system, the host and port can be automatically transferred.
ModelUtil.connect(<host>,<port>) connects to a COMSOL server. The arguments
<host> and
<port> provide the hostname (a string) and port number (an integer) for the COMSOL server.
ModelUtil.connect(<host>,<port>,<user>,<password>) connects to a COMSOL server. The arguments
<host>,
<port>,
<user> and
<password> provide the hostname (a string), port number (an integer), user (a string), and password (a string) for the COMSOL server.
ModelUtil.connect(<host>,<port>,<encryption>) and
ModelUtil.connect(<host>,<port>,<encryption>,<user>,<password>) connects to a COMSOL server using encryption. With the boolean
<encryption> set to false, it uses the
ws WebSocket URI scheme; when set to true, it uses the secure
wss (SSL) WebSocket URI scheme.
ModelUtil.disconnect() disconnects from a COMSOL server.
ModelUtil.setServerBusyHandler(<ServerBusyHandler>): Use the
setServerBusyHandler method to register a
ServerBusyHandler. Several clients can be connected to the same server, but only one client at a time can ask the server to perform an operation. The default behavior when attempting to call the server when it is busy is to issue an exception. By registering a
ServerBusyHandler it is possible to make the client wait until the server is free again, and to set a time-out for how long to wait.
ServerBusyHandler is a class which controls how long a client waits for a busy server to become free again. It also has hooks to perform any action on the client side before starting to wait and just after stopping to wait. Implement a subclass in Java to
ServerBusyHandler to change the default behavior.
ServerBusyHandler() creates a server-busy handler that waits for the server to be free without any time-out.
ServerBusyHandler(<timeOut>) creates a server-busy handler that waits for the server to be free. The time to wait,
<timeOut>, is given in milliseconds.
postWaitForServer(<boolean>) is a hook to perform any action right after waiting for the server to become free.
preWaitForServer(<host>, <username>) is a hook to perform any action before beginning to wait for the server to become free. The inputs are the hostname and username as strings.
ModelUtil.setModelChangedHandler(<ModelChangedHandler>): The s
etModelChangedHandler method registers a handler of changes to models made by other clients. If any other client changes any model in use by this client, the model change handler is notified.
ModelChangedHandler is an interface for handling updates of the client when another client has modified any models in use by this client. Implement the interface in Java to change the default behavior.
handleModelChangeOnServer(<modelChangeInfo>) is called when another client has changed any models in use by this client. The
ModelChangedHandler interface includes the boolean method
triggeredByChangesFromThisClient(). It has a default implementation returning false. In this case, the method
handleModelChangeOnServer(<modelChangeInfo>) is only called when another client changes the model. If
triggeredByChangesFromThisClient() returns true then
handleModelChangeOnServer(<modelChangeInfo>) is also called when the client registering the
ModelChangedHandler changes the model.
ModelChangeInfo is a class with information about changes to models by other clients.
getModelTags() returns the tags of the models that have changed.
The scanModel method is an advanced tool that scans the raw data of a model file for a certain node type and collects the tag and label of all nodes that it finds. See
Scanning Models for more information.