TOC PREV NEXT INDEX

Example of importing a simple UCD ASCII File

Synopsis

This example uses the file objects and V functions to import a file in AVS ASCII UCD format. It reads the bluntfin.inp file.

To represent the general UCD file format using file objects is a rather challenging task. This example uses the fact that bluntfin.inp has just one hexahedral cell type. In general it is possible to use file objects with a UCD format only if there is just one cell type or a list of cells that is sorted by cell types. In this case it is possible to map UCD cells onto the Cell_Sets used in AVS/Express to represent different cell types.

In the following example the "cache" function is used to prevent multiple access to the file from different modules.

file ucd_file {
name="$AVS_PATH<0>/data/ucd/bluntfin.inp";
};

Mesh+Node_Data+OPort ucd_file_field {
int file_beg => cache(file_skip_lines(ucd_file,0, 18)); /* skip SCCS header */

nnodes => cache( /* number of nodes */
file_scalar_ascii(ucd_file, file_beg, 3));

int rncells =>cache( /* number of cells */
file_scalar_ascii(ucd_file,
file_skip_words(ucd_file, file_beg, 1), 3));

nspace=3; * UCD always have nspace = 3 */
coordinates {
values=> cache( /* xyz arrays, skip first column: node index */
file_array_ascii(ucd_file,
file_skip_lines(ucd_file,file_beg,1),4,{0,1,1,1}));
};
ncell_sets=1; /* we can use file objects only for sorted cell types */
Hex cell_set { /* only one cell set */
ncells => rncells; /* rncells defined before */
node_connect_list=> cache( /* cell connectivity, skip 3 columns: cell
index, cell_type and material_id */
file_array_ascii(ucd_file,
file_skip_lines(ucd_file,file_beg,1+nnodes),3,
{0,0,0,1,1,1,1,1,1,1,1}) -1);
};
int ncomps = 5; /* number of components in file */
nnode_data =1; /* read just one first component */
!node_data[0]{
veclen =>cache( /* offset for veclen is rather involved...*/
file_scalar_ascii(ucd_file,
file_skip_words(ucd_file,
file_skip_lines(ucd_file,file_beg,
1+nnodes+rncells),1), 3));
float values[nvals][veclen]=> cache( /* node data, just the second colunm */
file_array_ascii(ucd_file,
file_skip_lines(ucd_file,file_beg,
2+nnodes+rncells+ncomps),4,{0,1,0,0,0,0}));
};
};

These objects act like arrays in that you can connect them to field mapper modules; they import generic data, not field data.

Online examples are also available in:


v/examples.v
examples/file_ucd.v
example/fileuni.v


TOC PREV NEXT INDEX