Selection Using Adjacent Geometry
Another approach is to select geometric entities and define the adjacent object. For example, select edges adjacent to a specific domain or boundaries adjacent to a specific point. There are different ways to create an adjacent selection: Adjacent Selection Using the COMSOL API or Adjacent Selection Using mphgetadj
Adjacent Selection Using the COMSOL API
This command creates a selection node using adjacent geometric entities:
model.component(<ctag>).selection.create(<seltag>, 'Adjacent')
The geometric entity level needs to be specified with the command:
sel.set(edim)
where sel is a link to an Adjacent Selection node and edim is an integer defining the space dimension value (3 for domains, 2 for boundaries/domains, 1 for edges/boundaries, and 0 for points).
The Adjacent selection node only supports the Selection node as an input:
sel.set( 'Adjacent')
and specify the ball radius <r0> with the command:
sel.set('input', <seltag>)
where <seltag> is the tag of an existing Selection node.
Select the level of geometric entities to add in the selection with the command:
sel.set('outputdim', edim)
where edim is an integer defining the space dimension value (3 for domains, 2 for boundaries/domains, 1 for edges/boundaries, and 0 for points).
If there are multiple domains in the geometry to include in the interior and exterior selected geometric entities, then enter:
sel.set('interior', 'on')
sel.set('exterior', 'on')
To exclude the interior/exterior, select geometric entities and set the respective property to 'off'.
Adjacent Selection Using mphgetadj
An alternative to the COMSOL API is to use the function mphgetadj to select geometric entities using an adjacent domain.
To get a list of entities of type entitytype adjacent to the entity with the index <adjnumber> of type adjtype, enter:
idx = mphgetadj(model, <geomtag>, returntype, adjtype, <adjnumber>)
where <geomtag> is the tag of geometry where the selection applies, returntype is the type of geometry entities whose index are returned and adjtype is the type of input geometric entity. The string variables returntype and adjtype can be one of 'point', 'edge', 'boundary', or 'domain'.
If <adjnumber> is an array, you can get the list of adjacent entities that connect the input entities the best, to do so enter:
[idx,idx_cnct] = mphgetadj(model, <geomtag>, ...
       returntype, adjtype, <adjnumber>)
The list returned by the function can be used to specify the selection for a model feature or to create an explicit selection as described in Setting an Explicit Selection.