It is possible to retrieve numerical results from any numerical feature, but there are a number of features especially designed for the COMSOL® API that are not present in the COMSOL Desktop
®. These functions support multiple expressions, as well as some additional advanced properties, and a more convenient way to extract interpolated data. These two groups have slightly different access methods. Note that
numerical in the model object corresponds to Derived Values in the Model Tree. In the API, code like
model.result().numerical(<ftag>) returns objects of type NumericalFeature.
result = model.result().numerical(<ftag>).getData() returns the real part of the result, recomputing the feature if necessary.
result is a three-dimensional double matrix ordered
result[expression][solnum][coordinates].
model.result().numerical(<ftag>).getData(<expressionIndex>) returns the real part of the result for one expression, equivalent to
result[expressionIndex].
result = model.result().numerical(<ftag>).getImagData() returns the imaginary part of the result, recomputing the feature if necessary.
result is a three-dimensional double matrix ordered
result[expression][solnum][coordinates].
model.result().numerical(<ftag>).getImagData(<expressionIndex>) returns the imaginary part of the result for one expression, equivalent to
result[expressionIndex].
model.result().numerical(<ftag>).isComplex() returns true if the result is complex. For models with outer solutions,
isComplex() returns true if the result for the current value of
outersolnum is complex.
model.result().numerical(<ftag>).isComplex(<outersolnum>) returns true if the result is complex for the given outer solution.
model.result().numerical(<ftag>).getNData() returns the number of points in the data vector.
model.result().numerical(<ftag>).getCoordinates() returns the coordinates of the evaluation or interpolation.
model.result().numerical(<ftag>).getElements() returns indices to columns in p of a simplex mesh.
model.result().numerical(<ftag>).getVertexElements() returns indices to mesh elements for each point.
model.result().numerical(<ftag>).getReal() returns the real result, recomputing the feature if necessary. Data is ordered such that one row contains data for all solution numbers. This is identical to
(<columnwise>) when
<columnwise> is
false. If
<columnwise> is
true, the ordering is the opposite: each
column contains the values for all solution numbers.
model.result().numerical(<ftag>).getImag(<allocate>, <columnwise>) returns the imaginary part of complex result, recomputing the feature if necessary. If
<allocate> is
true, a zero-valued matrix is allocated even when the result is real.
getImag() uses
<allocate> true and
<columnwise> false.
model.result().numerical(<ftag>).getComplex() returns a complex-valued result (the real and imaginary values), as an array of length two, where the first element is the real part and the second element is the imaginary part. The second element is null if the return value is all-real. Data is ordered such that one row contains data for all solution numbers. This is identical to
(<columnwise>) when
<columnwise> is
false. If
<columnwise> is
true, the ordering is the opposite: each
column contains the values for all solution numbers.
model.result().numerical(<ftag>).getComplex(<columnwise>) returns the real and imaginary part of a complex-valued result. If the Boolean
<columnwise> is
false, data is ordered such that each row contains the values for all solution numbers. If
true, one column contains the values for all solution numbers.
model.result().numerical(<ftag>).getComplex(<outersolnum>) returns the real and imaginary part of a complex-valued result for the given outer solution number (the 1-indexed integer
<outersolnum>).
model.result().numerical(<ftag>).getComplex(<columnwise>,<outersolnum>) returns the real and imaginary part of a complex-valued result for the given outer solution number in
<outersolnum> using an order determined by the Boolean
<columnwise> (see above).
model.result().numerical(<ftag>).isComplex() returns true if the result is complex. For models with outer solutions,
isComplex() returns true if the result is complex for any of the currently set
outersolnum.
model.result().numerical(<ftag>).isComplex(<outersolnum>) returns true if the result is complex for the given outer solution (the 1-indexed integer
<outersolnum>).