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().
Type: double | integer
subcase
Subcase name or ID.
Type: char | string or double | integer
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).
Type: double | integer
datatype
Datatype name or ID.
Type: char | string or double | integer
layer
Layer name or ID. Can be zero.
Type: char | string or double | integer
corners
Write corner data (0=no , 1=yes).
Type: double | integer
entities
Matrix with entities IDs.
Type: matrix
data
List of data to be added for each entity. The size of the matrix must be of numberofentities x numberofcomponents.
The number of components is:
  • 6 for "3Dtensor" format
  • 3 for "2Dtensor" and "vector"
  • 1 for "scalar"
Type: integer | matrix | complex

Example

writeh3ddata simple example:
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:

resultFile = 'testfile.h3d';
   % 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 = cw_h3d_createFile(resultFile, 'append')

   lidx1 = cw_h3d_createLayer(idx, 'Layer 1');
   lidx2 = cw_h3d_createLayer(idx, 'Layer 2');

   pidx1 = cw_h3d_createPool(idx, '2D');
   pidx2 = cw_h3d_createPool(idx, '3D');

   tidx1 = cw_h3d_createDatatype(idx, 'Element Stresses', '3Dtensor', 'elem', 'pools', [pidx1 pidx2], 'layers', [lidx1 lidx2]);

   sidx1 = cw_h3d_createSubcase(idx, 'Subcase 2', {'SC2 Iteration 1' 'SC2 Iteration 2'}, [0.0 1.0]);

   cw_h3d_writeData(idx, sidx1, 1, tidx1, 1, 0, elems2D, tensor2d3d, pidx1);
   cw_h3d_writeData(idx, sidx1, 1, tidx1, 2, 0, elems2D, 2*tensor2d3d, pidx1);
   cw_h3d_writeData(idx, sidx1, 1, tidx1, 0, 0, elems3D, tensor3d3d, pidx2);
   cw_h3d_writeData(idx, sidx1, 2, tidx1, 1, 0, elems2D, tensor2d3d, pidx1);
   cw_h3d_writeData(idx, sidx1, 2, tidx1, 2, 0, elems2D, 2*tensor2d3d, pidx1);
   cw_h3d_writeData(idx, sidx1, 2, tidx1, 0, 0, elems3D, tensor3d3d, pidx2);

   % Close file
   cw_h3d_closeH3DFile(idx);

Comments

When writing data, the definition must follow this order:
  1. Layer definition (if required).
  2. Datatype definition (needs the layer definition if it exists).
  3. Subcase definition (needs the datatype definition).
  4. Data write (needs the subcase, datatype, and layer (if it exists) definitions).