Extracting Data at Node Points
The function mpheval lets you evaluate expressions on node points.
Call the function mpheval as in this command:
pd = mpheval(model, <expr>)
where <expr> is a string cell array that lists the expression to evaluate. The expression has to be defined in the COMSOL model object in order to be evaluated.
pd is a structure with the following fields:
expr contains the list of names of the expressions evaluated with mpheval;
d1 contains the value of the expression evaluated. The columns in the data value fields correspond to node point coordinates in columns in the field p. In case of several expressions are evaluated in mpheval, additional field d2, d3,... are available;
p contains the node point coordinates information. The number of rows in p is the number of space dimensions;
t contains the indices to columns in pd.p of a simplex mesh; each column in pd.t represents a simplex;
ve contains the indices to mesh elements for each node points; and
unit contains the list of the unit for each evaluated expressions.
The rest of this section has additional information for the function mpheval:
Specify the Evaluation Data
The function mpheval supports the following properties to set the data of the evaluation to perform:
dataset, specify the solution dataset to use in the evaluation:
pd = mpheval(model, <expr>, 'dataset', <dsettag>)
<dsettag> is the tag of a solution dataset. The default value is the current solution dataset of the model. Selection datasets such as Cut Point, Cut Line, Edge, Surface, and so forth are not supported.
selection, specify the domain selection for evaluation:
pd = mpheval(model, <expr>, 'selection', <seltag>)
where <seltag> is the tag of a selection node to use for the data evaluation. <seltag> can also be a positive integer array that corresponds to the domain index list. The default selection is all domains where the expression is defined. If the evaluation point does not belong to the specified domain selection, the output value is NaN.
edim, specify the element dimension for evaluation:
pd = mpheval(model, <expr>, 'edim', edim)
where edim is one of the strings 'point', 'edge', 'boundary', or 'domain'. It is also possible to use the corresponding integer which in 3D is in the range from 0 to 3. The default settings correspond to the model geometry space dimension. When using a lower space dimension value, make sure that the evaluation point coordinates dimension has the same size.
Use the function mphevalpoint to evaluate expressions at geometric points (see Evaluating an Expression at Geometry Vertices).
solnum, specify the inner solution number for data evaluation. Inner solutions are generated for the following analysis types: time domain, frequency domain, eigenvalue, or stationary with continuation parameters:
pd = mpheval(model, <expr>, 'solnum', <solnum>)
where <solnum> is an integer array corresponding to the inner solution index. <solnum> can also be a string:'end' or 'all' to evaluate the expression for the last inner solution, or all inner solution respectively. By default the evaluation is performed on all inner solution.
outersolnum, specify the outer solution number for data evaluation. Outer solutions are generated with parametric sweeps:
pd = mpheval(model, <expr>, 'outersolnum', <outersolnum>)
where <outersolnum> is a positive integer corresponding to the outer solution index. <outersolnum> can also be a string, 'all' or 'end', to evaluate the expression for all or the last outer solution respectively. The default setting uses the first outer solution for the data evaluation.
pd = mpheval(model, <expr>, 't', <time>)
where <time> is a double array. The default value corresponds to all the stored time steps.
phase, specify the phase in degrees:
pd = mpheval(model, <expr>, 'phase', <phase>)
where <phase> is a double value.
pattern, use Gauss point evaluation:
pd = mpheval(model, <expr>, 'pattern','gauss')
The default evaluation is performed on the Lagrange points.
Output Format
The function mpheval returns a structure in the MATLAB workspace. You can specify other output data formats.
To only obtain the data evaluation as a double array, set the property dataonly to on. This is speeds up the call to COMSOL since the coordinate and element information is not retrieved.
pd = mpheval(model, <expr>, 'dataonly', 'on')
Returns only the real part in the data evaluation with the property complexout:
pd = mpheval(model, <expr>, 'complexout', 'off')
Specify the Evaluation Quality
Define mpheval function settings to specify the evaluation quality using these properties:
refine, specify the element refinement for evaluation:
pd = mpheval(model, <expr>, 'refine', <refine>)
where <refine> is a positive integer. The default value is 1 which set the simplex mesh identical to the geometric mesh. Many model use second order elements for which a refine value of 2 must be used to use all the data in the model.
smooth, specify the smoothing method to enforce continuity on discontinuous data evaluation:
pd = mpheval(model, <expr>, 'smooth', smooth)
where smooth is either 'none', 'everywhere', or 'internal' (default). Set the property to none to evaluate the data on elements independently, set to everywhere to apply the smoothing to the entire geometry, and set to internal to smooth the quantity inside the geometry (but no smoothing takes place across borders between domains with different settings). The output with the same data and same coordinates are automatically merged, which means that the output size can differ depending on the smoothing method.
recover, specify the accurate derivative recovery:
pd = mpheval(model, <expr>, 'recover', recover)
where recover is either 'ppr', 'pprint', or 'off' (default). Set the property to ppr to perform recovery inside domains or set to pprint to perform recovery inside domains. Because the accurate derivative processing takes time, the property is disabled by default.
Other Evaluation Properties
To not use complex-value functions with real inputs, use the property complexfun:
pd = mpheval(model, <expr>, 'complexfun', 'off')
The default value uses complex-valued functions with real inputs.
Use the property matherr to return an error for undefined operations or expressions:
pd = mpheval(model, <expr>, 'matherr', 'on')
Display the Expression in Figures
You can display an expression evaluated with mpheval in an external figure with the function mphplot (see Displaying The Results).