writeh3ddata
Writes data in an H3D file.
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.
Example
writeh3ddata(idx, 'Subcase 2', 1, 'DT scalar node:nolayer nocorner', 0, 0, nodes, 2*nodes)
% 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
Comments
- 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).