model.nodeGroup()
Node groups.
You can create node groups to structure the nodes in the model tree. It can be useful in this context when editing a Model Java-file created in the COMSOL Desktop and then opens it in the COMSOL Desktop again. It can also be useful in model methods.
Syntax
model.nodeGroup().create(<tag>,<type>);
model.nodeGroup().create(<tag>,<type>,<context>);
 
model.nodeGroup(<tag>).add(<nodetag>);
model.nodeGroup(<tag>).add(<parenttag>,<nodetag>);
 
model.nodeGroup().ungroup(<tag>);
 
There is also a component list model.component("comp1").nodeGroup() with the groups belonging to a component.
Description
model.nodeGroup(<tag>) represents a node group in the model tree.
model.nodeGroup().create(<tag>,<type>) creates a node group of the specified type. For example,
model.nodeGroup().create("grp1", "GlobalDefinitions");
creates a node group with the tag "grp1" under the Global Definitions node in the model tree.
model.nodeGroup().create(<tag>,<type>,<context>) creates a group of the specified type in the specified context. For example,
model.nodeGroup().create("g", "Geometry", "geom1")
creates a group in a geometry sequence.
Use model.nodeGroup().ungroup(<tag>) to ungroup (remove) a group. Removing the group does not remove its members form the model.
For a node group, the following methods are available:
Use nodeGroup.add(<type>,<tag>) to add a node with the tag <tag> of the type <type> to the group. For example group.add("func", "an1") adds model.func("an1") to the group.
Use nodeGroup.remove(<type>,<tag>) to remove a node with the tag <tag> of the type <type> from the group.
Example
The following example creates a node group under Definitions in a Component, adds two Model Input features to it, and then removes it by the ungroup method:
Code for Use with Java
Model model = ModelUtil.create("Model");
model.component().create("comp1", true);
model.component("comp1").geom().create("geom1", 3);
model.component("comp1").common().create("minpt1", "CommonInputDef");
model.component("comp1").common().create("minpt2", "CommonInputDef");
model.nodeGroup().create("grp1", "Definitions", "comp1");
model.nodeGroup("grp1").set("type", "commondef");
model.nodeGroup("grp1").add("common", "minpt1");
model.nodeGroup("grp1").add("common", "minpt2");
model.nodeGroup().ungroup("grp1");
Code for Use with MATLAB
model = ModelUtil.create('Model');
model.component.create('comp1',true);
model.component('comp1').geom.create('geom1',3);
model.component('comp1').common.create('minpt1','CommonInputDef');
model.component('comp1').common().create('minpt2', 'CommonInputDef');
model.nodeGroup.create('grp1','Definitions','comp1');
model.nodeGroup('grp1').set('type','commondef');
model.nodeGroup('grp1').add('common','minpt1');
model.nodeGroup('grp1').add('common','minpt2');
model.nodeGroup.ungroup('grp1');