Mesh > Mesh Commands > Refine

Refine
Refine a mesh.
Syntax
model.mesh(<tag>).create(<ftag>,"Refine");
model.mesh(<tag>).feature(<ftag>).selection();
model.mesh(<tag>).feature(<ftag>).set(property,<value>);
model.mesh(<tag>).feature(<ftag>).getType(property);
Description
Use model.mesh(<tag>).create(<ftag>,"Refine") to refine the mesh.
Use model.mesh(<tag>).feature(<ftag>).selection() to specify the domain selection or the entire geometry. If you do not specify any selection the feature refines all triangular and tetrahedral elements in the mesh.
The following properties are available:
on | off
longest | regular
xmax, xmin, ymax, ymin, zmax, zmin
Use the boxcoord property to refine elements inside a bounding box. To define the bounding box, set the properties xmin, xmax, ymin, ymax, zmax, and zmin on the feature, where (xmin,ymin,zmin) defines the lower-left corner, and (xmax,ymax,zmax) defines the upper-right corner of the bounding box. The elements that have all its corner points in the bounding box are refined once. boxcoord is automatically set to on if one of the coordinates are set.
The default refinement method in 2D is regular refinement, where all of the specified triangles are divided into four triangles of the same shape. Longest edge refinement, where the longest edge of each specified triangle is bisected, can be selected by giving longest as rmethod. Using regular as rmethod results in regular refinement. Some triangles outside of the specified set can also be refined, in order to preserve the triangulation and its quality.
In 3D, the default refinement method is longest. The regular refinement method is only implemented for uniform refinements (that is, when all elements are refined).
In 1D, regular refinement, where each element is divided into two elements of the same shape, is always used.
By default, all elements are refined once. By using the element property, you can specify which elements are refined and the numrefine property specifies how many times the elements is refined. If numrefine is an integer, all refined elements are refined numrefine times. If numrefine is a vector, it must have the same length as the element vector, and gives the number of refinements for each element.
Compatibility
The following properties from the corresponding COMSOL Multiphysics 3.5a command, meshrefine, have been removed:
Table 4-52: Removed Properties
Examples
Mesh two squares with free mesh. Refine the mesh on sq2 once and refine the elements inside a box in sq1 twice.
Code for use with Java
Model model = ModelUtil.create("Model");
GeomSequence g = model.geom().create("geom1", 2);
MeshSequence m = model.mesh().create("mesh1", "geom1");
 
g.create("sq1", "Square");
g.create("sq2", "Square");
g.feature("sq2").setIndex("pos", "1", 0);
g.run();
 
m.create("ftri1", "FreeTri");
m.create("ref1", "Refine");
m.feature("ref1").selection().geom("geom1", 2).set(new int[]{2});
m.create("ref2", "Refine");
m.feature("ref2").set("xmin", "0.2");
m.feature("ref2").set("xmax", "0.8");
m.feature("ref2").set("ymin", "0.2");
m.feature("ref2").set("ymax", "0.6");
m.run();
Code for use with MATLAB
model = ModelUtil.create('Model');
g = model.geom.create('geom1', 2);
m = model.mesh.create('mesh1', 'geom1');
 
g.create('sq1', 'Square');
g.create('sq2', 'Square');
g.feature('sq2').setIndex('pos', '1', 0);
g.run;
 
m.create('ftri1', 'FreeTri');
m.create('ref1', 'Refine');
m.feature('ref1').selection().geom('geom1', 2).set(2);
m.create('ref2', 'Refine');
m.feature('ref2').set('xmin', '0.2');
m.feature('ref2').set('xmax', '0.8');
m.feature('ref2').set('ymin', '0.2');
m.feature('ref2').set('ymax', '0.6');
m.run();
See Also
Convert