The Method Nodes and Method Editor Windows
The Method nodes () contain user-defined methods. There are three types of methods:
To add a new Method node, right-click the main Methods node, for a global method, or the Methods node under a Form node, for a form method, and choose New Method. You can also choose Global Method or Form Method from the New Method button in the Method toolbar (Form Method is only active if there is an active Form Editor window). In the New Method dialog box that opens, type a label for the method in the Name field.
Also, commands to be run, such as for buttons, can be converted to a global method, form method, or, in most cases, local method.
Methods within an application provide functionality connected to buttons, windows, and other components created using the Application Builder.
Methods used in the Model Builder can directly modify the model object represented by the Model Builder in the current session. Such methods can be used, for example, to automate modeling tasks that consist of several manual steps, possibly in connection with settings forms. Methods used in the Model Builder are global methods.
To edit the method, double-click the method node, or right-click it and choose Edit (). An editor window opens, where you can edit the code for the method. Depending on the View all code preference setting, you see just the method declarations or the full class. In the editor, you can highlight part of the code and right-click to cut, copy, paste, and delete it. You can also use the standard keyboard shortcuts such as Ctrl+C to copy, Ctrl+A to select all code in the editor window, and the Delete button. The code extends a Java class called ApplicationMethod that only requires one method with the following signature:
public void execute() {
  model.physics("es").feature("ccn1").set("ConstitutiveRelationD", 1,
model.modelData().getString("dielectricModel"));
}
This method can perform any operations available to the COMSOL Multiphysics API. There are a number of methods and members available through the extended class, the most important of which is the model object accessible as the member model. The code example above reads a data field named dielectricModel from the application’s own data (in an Electrostatics interface) and sets it to a parameter of a physics feature in the embedded model.
See The Method Node for information about the inputs and outputs that you can add in the Settings window for method nodes (not local methods).