Accessing Higher-Order Finite Element Nodes
The extended mesh data structure contains information related to the finite element method including, for example, the placement of higher-order element nodes. The extended mesh information is contained in the class XmeshInfo and provides information about the numbering of elements, nodes, and degrees of freedom (DOFs) in the extended mesh and in the matrices returned by the Assemble feature and the solvers. For detailed information on XmeshInfo, see the Programming Reference Manual.
The following example method illustrates how to use the extended mesh information to plot higher-order nodes in a few important special cases. Note that general functionality for this is built-in when creating a Mesh Plot under Results while also using a Study as the referenced Dataset.
The example below covers cases with one model component, one geometry, and a subset of physics combinations. If you apply it to other cases, you will get an error message.
// Note that this method is only implemented for one component and one geometry and does not work for all physics combinations.
 
String stdTag = model.study().uniquetag("stdfe");
model.study().create(stdTag);
model.study(stdTag).label("FE Nodes Study "+stdTag.substring(5));
model.study(stdTag).showAutoSequences("sol");
String solTag = model.sol().uniquetag("sol");
model.sol().create(solTag);
model.sol(solTag).create("st1", "StudyStep");
model.sol(solTag).create("v1", "Variables");
 
SolverFeature step = model.sol(solTag).feature("v1");
 
XmeshInfo xmi = step.xmeshInfo();
try {
  XmeshInfoNodes testnodes = xmi.nodes();
} catch (Exception e) {
  error("Cannot access finite element data. Only implemented for one geometry and stationary studies.");
}
 
XmeshInfoNodes mynodes = xmi.nodes();
double[][] coords = mynodes.gCoords();
int[] coordsize = matrixSize(coords);
 
int sdim = 0;
if (coordsize[0] == 3) {
  sdim = 3;
} else if (coordsize[0] == 2) {
  sdim = 2;
} else
  error("The geometry of the first component is not 2D or 3D.");
 
String mesh = "mesh"+stdTag;
model.result().dataset().create(mesh, "Mesh");
 
String pgTag = model.result().uniquetag("pgfe");
ResultFeature pg = model.result().create(pgTag, sdim);
model.result(pgTag).label("FE Nodes Plot "+pgTag.substring(4));
String nodes = pgTag;
model.result(nodes).create("mesh", "Mesh");
if (sdim == 3) {
  with(model.result(nodes).feature("mesh"));
    set("data", mesh);
    set("meshdomain", "volume");
  endwith();
} else {
  with(model.result(nodes).feature("mesh"));
    set("data", mesh);
    set("meshdomain", "surface");
  endwith();
}
 
with(model.result(nodes).feature("mesh"));
  set("elemcolor", "none");
  set("wireframecolor", "gray");
  set("elemscale", 0.999);
endwith();
 
with(model.result(nodes));
  set("edges", true);
  set("data", mesh);
endwith();
 
ResultFeature plot = pg.create("pt1", "PointData");
plot.set("pointdata", coords)
  .set("coloring", "uniform")
  .set("color", "red");
plot.run();
 
selectNode(pg);
Comments
The first few lines of the method set up a solver step object step, which is used to extract the extended mesh information. The extended mesh information, which contains information on the higher-order nodes, is extracted in the line
XmeshInfo xmi = step.xmeshInfo();
The lines
XmeshInfoNodes mynodes = xmi.nodes();
double[][] coords = mynodes.gCoords();
int[] coordsize = matrixSize(coords);
access and store the finite element node coordinates in a 2-by-coordsize (2D) or 3-by-coordsize (3D) array.
The following code segments set up a mesh dataset and an associated mesh plot.
The last section uses the low-level PointData plot type to visualize the finite element nodes. For more information on this plot type, see “Points in 3D” on page 161.