mphinterp
Evaluate expressions in arbitrary points or datasets.
Syntax
[v1,...,vn] = mphinterp(model,{e1,...,en},'coord',coord,...)
[v1,...,vn] = mphinterp(model,{e1,...,en},'dataset',dsettag,...)
[v1,...,vn,unit] = mphinterp(model,{e1,...,en},...)
Description
[v1,...,vn] = mphinterp(model,{e1,...,en},'coord',coord,...) evaluates expressions e1,...en at the coordinates specified in the double matrix coord. Evaluation is supported only on Solution datasets.
[v1,...,vn] = mphinterp(model,{e1,...,en},'dataset',dsettag,...) evaluates expressions e1,...en on the specified dataset dsettag. In this case the dataset needs to be of a type that defines an interpolation in itself, such as cut planes, revolve, and so forth.
[v1,...,vn,unit] = mphinterp(model,{e1,...,en},...) returns in addition the unit of the expressions.
The function mphinterp accepts the following property/value pairs:
off | on
off | on
off | on
off | on
point | edge | boundary | domain | 0 | 1 | 2 | 3
linpoint | harmonic | lintotal | lintotalavg | lintotalrms | lintotalpeak
off | on
off | ppr | pprint
The columns of the matrix coord are the coordinates for the evaluation points. If the number of rows in coord equals the space dimension, then coord are global coordinates, and the property edim determines the dimension in which the expressions are evaluated. For instance, edim='boundary' means that the expressions are evaluated on boundaries in a 3D model. If edim is less than the space dimension, then the points in coord are projected onto the closest point on a domain of dimension edim. If, in addition, the property selection is given, then the closest point on domain number selection in dimension edim is used.
If the number of rows in coord is less than the space dimension, then these coordinates are parameter values on a geometry face or edge. In that case, the domain number for that face or edge must be specified with the property selection.
The expressions that are evaluated can be expressions involving variables, in particular physics interface variables.
The matrices v1,...,vn are of the size k-by-size(coord,2), where k is the number of solutions for which the evaluation is carried out, see below. The value of expression ei for solution number j in evaluation point coord(:,m) is vi(j,m).
The vector pe contains the indices m for the evaluation points code(:,m) that are outside the mesh, or, if a domain is specified, are outside that domain.
The property Data controls which dataset is used for the evaluation. Datasets contain or refer to the source of data for postprocessing purposes. Evaluation is supported only on Solution datasets. The active solution dataset is used by default.
The property edim decides which elements to evaluate on. Evaluation takes place only on elements with space dimension edim. If not specified, edim equal to the space dimension of the geometry is used. The setting is specified as one of the following strings 'point', 'edge', 'boundary' or 'domain'. In previous versions it was only possible to specify edim as a number. For example, in a 3D model, if evaluation is done on edges (1D elements), edim is 1. Similarly, for boundary evaluation (2D elements), edim is 2, and for domain evaluation (3D elements), edim is 3 (default in 3D).
The property evalmethod decides which solution to use in presence of linearization point. Set the property value to harmonic to harmonic perturbation analysis, linpoint evaluates the expression by taking the values of any dependent variables from the linearization point of the solution, lintotal evaluates the expression by adding the linearization point and the harmonic perturbation and taking the real part of this sum. lintotalavg (lintotalrms and lintotalpeak) do the same as with lintotal and then averaging (taking the RMS and taking the maximum respectively) over all phases of the harmonic perturbation. When harmonic is selected, the property differential specify to evaluate the differential of the expression with respect to the perturbation at the linearization point (on) or to evaluates the expression by taking the values of any dependent variables from the harmonic perturbation part of the solution (off).
Use Recover to recover fields using polynomial-preserving recovery. This techniques recover fields with derivatives such as stresses or fluxes with a higher theoretical convergence than smoothing. Recovery is expensive so it is turned off by default. The value pprint means that recovery is performed inside domains. The value ppr means that recovery is also applied on all domain boundaries.
The property Refine constructs evaluation points by making a regular refinements of each element. Each mesh edge is divided into Refine equal parts.
When the property phase is used, the solution vector is multiplied with exp(i*phase) before evaluating the expression.
The expressions e1,...,en are evaluated for one or several solutions. Each solution generates an additional row in the data fields of the post data output structure. The properties solnum and t control which solutions are used for the evaluations. The solnum property is available when the dataset has multiple solutions — for example, in the case of parametric, eigenfrequency, or time-dependent solutions. The t property is available only for time-dependent problems. If solnum is provided, the solutions indicated by the indices provided with the solnum property are used. If t is provided, solutions are interpolated. If neither solnum nor t is provided, all solutions are evaluated.
For time-dependent problems, the variable t can be used in the expressions ei. The value of t is the interpolation time when the property t is provided, and the time for the solution, when solnum is used. Similarly, lambda and the parameter are available as eigenvalues for eigenvalue problems and as parameter values for parametric problems, respectively.
In case of multiple expression, if the unit property is defined with a string, the same unit is used for both expressions. To use different units, set the property with a cell array. In case of inconsistent unit definition, the default unit is used instead.
The property solnum is used to select the solution number when a parametric, eigenvalue, or time-dependent solver has been used.
The property outersolnum is used to select the outer solution number when a parametric sweep has been used in the study step node.
Example
Evaluate the temperature at given coordinates:
model = mphopen('model_tutorial_llmatlab');
std = model.study.create('std');
std.feature.create('stat','Stationary');
std.run;
coord = [0,0,1e-2;0,0,1e-2;0,1e-2,1e-2];
T = mphinterp(model,'T','coord',coord);
Evaluate both the temperature and the heat flux magnitude:
[T,tfluxMag] = mphinterp(model,{'T','ht.tfluxMag'},...
'coord',coord);
Evaluate the temperature field on a structure grid:
x0 = [0,1e-2,2.5e-2,5e-2]; y0 = x0; z0 = [5e-3,1e-2,1.1e-2];
[x,y,z] = meshgrid(x0,y0,z0); xx = [x(:),y(:),z(:)]';
T = mphinterp(model,'T','coord',xx);
Evaluate the temperature on boundary 7 using global coordinates:
x0 = [0,5e-3,1e-2]; y0 = x0; z0 = [1.1e-2];
[x,y,z] = meshgrid(x0,y0,z0); xx = [x(:),y(:),z(:)]';
T = mphinterp(model,'T','coord',xx,'edim','boundary',...
'selection',7);
Evaluate the temperature and evaluation point global coordinates on boundary 7 using local coordinates:
s10 = [0,0.25,0.5]; s20 = [0,0.25,0.5];
[s1,s2] = meshgrid(s10,s20); ss = [s1(:),s2(:)]';
[x,y,z,T] = mphinterp(model,{'x','y','z','T'},'coord',ss,...
'edim','boundary','selection',7);
Modify the extrapolation distance for point coordinates outside of the geometry:
coord = [5e-2;5e-2;1.1e-2];
T = mphinterp(model,'T','coord',coord)
T = mphinterp(model,'T','coord',coord,'ext',0.5);
Extract data using a cut line dataset. First create the cut line dataset, then evaluate the temperature field along the line:
cln = model.result.dataset.create('cln', 'CutLine3D');
cln.setIndex('genpoints','1e-2',1,0);
cln.setIndex('genpoints','1e-2',0,2);
cln.setIndex('genpoints','5e-2',1,0);
T = mphinterp(model,'T','dataset','cln');
Evaluation including several solution
model = mphopen('model_tutorial_llmatlab');
std = model.study.create('std');
param = std.feature.create('param','Parametric');
time = std.feature.create('time','Transient');
time.set('tlist', 'range(0,1,25)');
param.setIndex('pname','power',0);
param.setIndex('plistarr','30 60 90',0);
std.run;
Evaluate the temperature at every time step computed with power set to 30:
coord = [0 0 1e-2;0 0 1e-2;0 1e-2 1e-2];
T = mphinterp(model,'T','coord',coord,'dataset','dset2');
Evaluate the temperature at the fifth time step:
T = mphinterp(model,'T','coord',coord,'dataset','dset2',...
'solnum',5);
Evaluate the temperature at 10.5 sec:
T = mphinterp(model,'T','coord',coord,'dataset','dset2',...
't',10.5);
Evaluate the temperature at every time step computed with power set to 90:
T = mphinterp(model,'T','coord',coord,'dataset','dset2',...
'outersolnum',3)
See also
mpheval, mphevalglobalmatrix, mphevalpoint, mphevalpointmatrix, mphint2, mphint2, mphparticle, mphray