writeh3ddata
Writes data in an H3D file.
Attention: Valid only with Altair CAE Readers and Writers Extension.
Syntax
R = writeh3ddata(fid, subcase, simulation, datatype, layer, corners, entities, data[,pool])
Inputs
- fid
- Integer representing the file ID, returned from createh3dfile().
- subcase
- Subcase name or ID.
- simulation
- Simulation index (starting from 1). The simulation index can be defined as starting from 1 to length(timestep), not the timestep itself (who can start from 0.0).
- datatype
- Datatype name or ID.
- layer
- Layer name or ID. Can be zero.
- corners
- Write corner data (0=no , 1=yes).
- entities
- Matrix with entities IDs.
- data
- List of data to be added for each entity. The size of the matrix must be of numberofentities x numberofcomponents.
Examples
writeh3ddata(idx, 'Subcase 2', 1, 'DT scalar node:nolayer nocorner', 0, 0, nodes, 2*nodes)
Create an H3D file, which contains one subcase, with one data type containing two
components:
% File : test.oml
clear all; close all; clc;
cd(fileparts(omlfilename('fullpath')));
modelFile = 'model_only.h3d';
resultFile = 'test1.h3d';
delete(resultFile);
copyfile(modelFile, resultFile, 'f');
% Entities
nodes = [1:32];
elems2D = [20 24 27 31 36 39 42 43 47];
elems3D = [10:18];
lsnd = [1:length(nodes)]';
ls2d = [1:length(elems2D)]';
ls3d = [1:length(elems3D)]';
tensor2d2d = [ls2d ls2d*2 ls2d*3];
tensor2d3d = [ls2d ls2d*2 zeros(length(elems2D), 1) ls2d zeros(length(elems2D), 1) zeros(length(elems2D), 1)];
tensor3d3d = [ls3d ; ls3d*2 ; ls3d*3 ; ls3d ; ls3d*2 ; ls3d*3];
idx = createh3dfile(resultFile, 'append')
lidx1 = createh3dlayer(idx, 'Layer 1');
lidx2 = createh3dlayer(idx, 'Layer 2');
pidx1 = createh3dpool(idx, '2D');
pidx2 = createh3dpool(idx, '3D');
tidx1 = createh3ddatatype(idx, 'Element Stresses', '3Dtensor', 'elem', 'pools', [pidx1 pidx2], 'layers', [lidx1 lidx2], 'corners');
sidx1 = createh3dsubcase(idx, 'Subcase 2', {'SC2 Iteration 1' 'SC2 Iteration 2'}, [0.0 1.0]);
writeh3ddata(idx, sidx1, 1, tidx1, 1, 0, elems2D, tensor2d3d, pidx1);
writeh3ddata(idx, sidx1, 1, tidx1, 2, 0, elems2D, 2*tensor2d3d, pidx1);
writeh3ddata(idx, sidx1, 1, tidx1, 0, 0, elems3D, tensor3d3d, pidx2);
writeh3ddata(idx, sidx1, 2, tidx1, 1, 0, elems2D, tensor2d3d, pidx1);
writeh3ddata(idx, sidx1, 2, tidx1, 2, 0, elems2D, 2*tensor2d3d, pidx1);
writeh3ddata(idx, sidx1, 2, tidx1, 0, 0, elems3D, tensor3d3d, pidx2);
% Close file
closeh3dfile(idx); % Close H3D file
Create an H3D file, which contains 3 subcases, where the first has only one time step, the
second has two time steps, and the third has one time step and complex
data:
% Create results file
resultFile = 'multiple_subcase_example.h3d';
% Define Entities
nodes = [1:32]';
% Open file
idx = createh3dfile(resultFile);
% Datatypes
tidx1 = createh3ddatatype(idx, 'DT scalar node: nolayer nocorner', 'scalar', 'node');
% Subcases
sidx1 = createh3dsubcase(idx, 'Subcase 1', {'SC1 Iteration 1'});
sidx2 = createh3dsubcase(idx, 'Subcase 2', {'SC2 Iteration 1' 'SC2 Iteration 2'});
sidx3 = createh3dsubcase(idx, 'Subcase 3', {'SC2 Iteration 1'},'complex');
% Create random data
scalar_nodes = ones(length(nodes),1);
scalar_nodes_multi = [2*ones(length(nodes),1) 3*ones(length(nodes),1)];
scalar_nodes_comp = complex(randn(length(nodes),1),randn(length(nodes),1));
% Write data to H3D file
writeh3ddata(idx, sidx1, 1, tidx1, 0, 0, nodes, scalar_nodes);
writeh3ddata(idx, sidx2, 1, tidx1, 0, 0, nodes, scalar_nodes_multi(:,1));
writeh3ddata(idx, sidx2, 2, tidx1, 0, 0, nodes, scalar_nodes_multi(:,2));
writeh3ddata(idx, sidx3, 1, tidx1, 0, 0, nodes, scalar_nodes_comp);
% Close H3D file
closeh3dfile(idx);
Comments
When writing data, the definition must follow this order:
- Layer definition (if required).
- Datatype definition (needs the layer definition if it exists).
- Subcase definition (needs the datatype definition).
- Data write (needs the subcase, datatype, and layer (if it exists) definitions).
When writing complex data, real and imaginary parts are the inputs, which are internally
converted to magnitude and phase in the H3D file, knowing
that:
mag = sqrt(real^2+imag^2)
pha = atan(imag/real)