readmultvector, readcae: why are they 2?


Altair Compose, an Integrated Development Environment for Math, Scripting, Data processing and visualization, has a built-in suite of Altair’s results readers under the CAE Reader Library that can be used to extract data from CAE/Test result files.

The CAE reader library has over 20 functions in which 2 are used to extract multiple vectors of data from a given CAE/Test result file in CAE Reader library, namely readmultvector, readcae

Why are there 2 functions for the same purpose (readmultvector vs readcae)? Which one to we use and when?

Let's break it down based on 2 key factors.

  1. Syntax differences
  2. Speed/Performance

 For insights into the CAE Reader library please first read Extracting and Post-Processing CAE/TEST results in Altair Compose

We will take the same sample results file from the above paper ‘bezel.h3d’ to compare the 2 functions.

The Bezel.h3d results file consists of:

# of Subcases = 4

# of Type = 6

Requests:      #Nodes = 236

                    #Elements = 198

Component: Displacement = 4 --(X, Y, Z, MAG)

                    Stress = 21 --different result components (von-mises, P1, P2, P3, XX, YY, ZZ …)

Time-Step = 1


  1. Syntax difference: Passing the arguments

The readmultvectors function is used to extract the multiple vectors of data for the given range of Request/Component/Timestep information of a results file and arguments to this function are to be passed as ‘strings’ or ‘int’ datatypes.

This function supports multiple syntaxes and requires arguments to be passed in a specific format;

readmultvectors(filename, subcase, type, startRequest, endRequest, startComponent, endComponent, timeRange)

this extracts data of specific ‘Subcase’, ‘Type’, range of request (Nodes/elements) between startRequest and endRequest, range of Component between startComponent, endComponent and for a given timeRange.

readcae function is also used to extract multiple vectors of data for a given/specified/range of Request/Component/Timestep information of a results file and these are parsed to the function as ‘strings’ or ‘int’ or ‘cell’ datatypes.

readcae(filename, subcase, datatype, request, component, time, outputType)

where request/component in above syntax can be in a matrix format:

[]           - Extracts all requests.

[i:j]         - Extracts ith to jth index (inclusive).

[i,j,k,l]    - Extracts the specified request indices.

Or

Cell supported format:

{}                               -Extracts all requests.

{i,j,k,l}                        -Extracts the specified indices.

{'req1','req2','req3'}     -Extracts the specified requests.


You can specify what output type you want to have from readcae function as the last argument ‘outputType’.

For more information go to the online help: readcae

  1. Speed/Performance

There are multiple syntaxes that go along with both functions so let’s take the most commonly used syntax for extract different portions of data for comparison.

Let us compare the performance of both functions with a use-case of extracting Von-mises stresses for elements having odd numbered Id’s.


First, let’s extract the von-mises stress using readmultvectors,


As readmultvectors function extracts the data for a given range of request/component between start and end, we must create a variable which has a list of elements having odd numbered id’s and parse it to the readmultvectors function.


tic

result_file      = 'bezel.h3d';

%Extract Request (Node)list from result file

req     = getreqlist('bezel.h3d',2,'Element Stresses (2D & 3D) (2D)');

      

for i = 1:numel(req)

       %data_test(i,1) = req{i};

      temp = strsplit(req{i},'E');

      elementid(i,1) = str2num(temp{2});

end

x = find(mod(elementid,2) == 1);

for i = 1:numel(x)

   element_extract{i,1} = ['E',num2str(elementid(x(i)))];

end

   

for i = 1: numel(element_extract)

output1(i,1)=readmultvectors(result_file,2,'Element Stresses (2D & 3D) (2D)',element_extract{i},element_extract{i},'vonMises (Z1)','vonMises (Z1)',1);

end

toc


The time taken for the above script to extract the Von-mises Stress for odd element numbers from the result file is 0.039 seconds. Most of the elapsed time is taken for executing readmultvectors function in “for” loop to extract results for each element at a time.

Now, let us extract the same results using readcae function,

As readcae function can take 'request'/'component' as Matrix. We can parse the matrix of elements which have odd numbered id’s to the function,


tic

result_file = 'bezel.h3d';

 

%Extract Request (Node)list from result file

req     = getreqlist('bezel.h3d',2,'Element Stresses (2D & 3D) (2D)');

% get element numbers

for i = 1:numel(req)

                    %data_test(i,1) = req{i};

                    temp = strsplit(req{i},'E');

                    elementid(i,1) = str2num(temp{2});

end

%find the element numbers which has odd numbering

x = find(mod(elementid,2) == 1);

output = readcae(result_file,2,'Element Stresses (2D & 3D) (2D)',[x(1):x(end)],'vonMises (Z1)',[],1);

toc


The time taken to extract the Von-mises Stress for odd element numbers from the result file using readcae function is 0.022 seconds.

In this simple use-case, we achieve a 40% of performance improvement with the readcae function. This performance improvement over the readmultvectors function is mostly due to the fact that the readcae function avoids the “for” loop to extract the results.

With the ease of parsing the required inputs and performance boost that comes with it, readcae is a go-to function for most use-cases, so give it a try!