model.methodCall()
Calling model methods. You can create and run model methods to extend the functionality of a COMSOL Multiphysics simulation using custom methods. See the Application Programming Guide for more information about creating and using methods.
Syntax
model.methodCall().create(<tag>,<methodname>);
model.methodCall(<tag>).run();
model.methodCall(<tag>).inputNames();
model.methodCall(<tag>).methodName();
model.methodCall(<tag>).methods();
model.methodCall(<tag>).set(<param>,<expr>);
Description
model.methodCall(<tag>) represents a method call for a model method.
model.methodCall().create(<tag>,<methodname>) creates a method call for the model method <methodname> with the given tag.
model.methodCall(<tag>).inputNames(); returns the names of input parameters of a method reference by a given method call.
model.methodCall(<tag>).methodName returns the name of the method that the method call runs.
model.methodCall(<tag>).methods(); returns the names of all methods in the model.
model.methodCall(<tag>).run() runs the method call with the tag <tag>.
The following examples show how you can specify the names of an input parameter, the value of a 1D double array parameter, and the value of a Boolean parameter:
model.methodCall(<tag>).set("paramname","p1");
model.methodCall(<tag>).set("paramvalues",new double[]{2.3 3.7 5.6 7.1 11.3 17.5});
model.methodCall(<tag>).set("sendmail",true);
Parameter names are created automatically with the appropriate types according to the inputs that have been specified in the method. This means that you can then use a natural set syntax as shown in the examples above.
Arguments to Method Calls
The following table describes the names of arguments that you can use to change the value of inputs to a method call before running it:
size,times
A file to read the inputs to the method call from. This file has the same format as the one used together with -appargsfile (see the Application Builder documentation about application arguments),
Specifying method call inputs both from a file and individually on the command line can be combined. If an input is given both in a file and on the command line, the value given on the command line overrides the value given in the file. If a value is given several times in the file or on the command line, the last given value overrides any previous given value.
Using Method Calls from a Model Java-File
You can use the model method in a method call from a Model Java-file if the file starts by loading an MPH-file (including its model method) and then calls a run of a method call. However, in this context, model methods do not support user interface commands or file schema. The table below table lists user interface commands that are not supported:
See Also
model.form()