Skip to content

vtk_fortran_vtm_file ​

VTM file class.

Source: src/lib/vtk_fortran_vtm_file.F90

Dependencies

Contents ​

Derived Types ​

vtm_file ​

VTM file class.

Components ​

NameTypeAttributesDescription
xml_writerclass(xml_writer_abstract)allocatableXML writer.
scratch_unitinteger(kind=I4P)allocatableScratch units for very large list of named blocks.
xmltype(xml_scanner)Index of the file read (action='read').
is_readinglogicalThe file is open for reading.

Type-Bound Procedures ​

NameAttributesDescription
initializepass(self)Initialize file.
finalizepass(self)Finalize file.
get_entriespass(self)Return the blocks and datasets of a file read.
write_blockWrite one block dataset.
write_block_arraypass(self)Write one block dataset (array input).
write_block_stringpass(self)Write one block dataset (string input).
parse_scratch_filespass(self)Parse scratch files.
write_block_scratchpass(self)Write one block dataset on scratch files.

Functions ​

initialize ​

Initialize file: open it for writing (default) or for reading.

With action='read' (case insensitive) the file is indexed: its blocks and datasets are returned by get_entries, and each dataset file can then be read with vtk_file (or pvtk_file); finalize frees the index. The error is 1 if the file cannot be read, 2 if it is not a multi-block file (vtkMultiBlockDataSet).

Returns: integer(kind=I4P)

fortran
function initialize(self, filename, scratch_units_number, action) result(error)

Arguments

NameTypeIntentAttributesDescription
selfclass(vtm_file)inoutVTM file.
filenamecharacter(len=*)inFile name of output VTM file.
scratch_units_numberinteger(kind=I4P)inoptionalNumber of scratch units for very large list of named blocks.
actioncharacter(len=*)inoptionalAction: write (default) or read.

Call graph

finalize ​

Finalize file (writer).

Returns: integer(kind=I4P)

fortran
function finalize(self) result(error)

Arguments

NameTypeIntentAttributesDescription
selfclass(vtm_file)inoutVTM file.

Call graph

get_entries ​

Return the blocks and datasets of a file read (initialize(..., action='read')), in the order of the file.

The hierarchy is flattened depth first: each entry has its nesting level (1 for the children of the root), its kind (block, dataset, or piece for the pieces of a vtkMultiPieceDataSet written by VTK), its index among the children of its parent (-1 if the file has none), its name and, for datasets, its file (empty for blocks and pieces, or for datasets without file). The children of an entry are the following entries of the next level. The names and files are blank padded to the longest one; relative files are relative to the directory of the .vtm file.

fortran
 type(vtm_file)                :: vtm
 integer(I4P),     allocatable :: level(:)
 character(len=:), allocatable :: kind(:), file(:)
 error = vtm%initialize(filename='assembly.vtm', action='read')
 error = vtm%get_entries(level=level, kind=kind, file=file)
 error = vtm%finalize()

Returns: integer(kind=I4P)

fortran
function get_entries(self, level, kind, index, name, file) result(error)

Arguments

NameTypeIntentAttributesDescription
selfclass(vtm_file)inVTM file.
levelinteger(kind=I4P)outallocatable, optionalNesting level of the entries, from 1.
kindcharacter(len=:)outallocatable, optionalKind of the entries: block, dataset or piece.
indexinteger(kind=I4P)outallocatable, optionalIndex of the entries among their siblings.
namecharacter(len=:)outallocatable, optionalName of the entries.
filecharacter(len=:)outallocatable, optionalFile of the datasets.

Call graph

write_block_array ​

Write one block dataset (array input).

By default the files are wrapped in a new block; with action='write' they are written as datasets of the current (open) block, without a new block.

Example of usage: 3 files blocks ​

fortran
 error = vtm%write_block(filenames=['file_1.vts', 'file_2.vts', 'file_3.vtu'], name='my_block')

Example of usage: 3 files blocks with custom name ​

fortran
 error = vtm%write_block(filenames=['file_1.vts', 'file_2.vts', 'file_3.vtu'], &
                         names=['block-bar', 'block-foo', 'block-baz'], name='my_block')

Example of usage: nested blocks ​

fortran
 error = vtm%write_block(action='open', name='assembly')
 error = vtm%write_block(filenames=['part_1.vtu', 'part_2.vtu'], action='write') ! datasets 0, 1 of assembly
 error = vtm%write_block(filenames=['bolt_1.vtu', 'bolt_2.vtu'], name='bolts')  ! block 2 of assembly
 error = vtm%write_block(action='close')

Returns: integer(kind=I4P)

fortran
function write_block_array(self, filenames, names, name, action) result(error)

Arguments

NameTypeIntentAttributesDescription
selfclass(vtm_file)inoutVTM file.
filenamescharacter(len=*)inFile names of VTK files grouped into current block.
namescharacter(len=*)inoptionalAuxiliary names attributed to each files.
namecharacter(len=*)inoptionalBlock name
actioncharacter(len=*)inoptionalAction: 'write' (datasets of the current block) or default.

Call graph

write_block_string ​

Write one block dataset (string input).

With action the block is written in steps, so blocks can be nested: 'open' opens a (child) block, 'write' writes the files as datasets of the current block, 'close' closes it. The children of a block (blocks and datasets) are indexed from 0 in the order they are written.

Example of usage: 3 files blocks ​

fortran
 error = vtm%write_block(filenames='file_1.vts file_2.vts file_3.vtu', name='my_block')

Example of usage: 3 files blocks with custom name ​

fortran
 error = vtm%write_block(filenames='file_1.vts file_2.vts file_3.vtu', names='block-bar block-foo block-baz', name='my_block')

Returns: integer(kind=I4P)

fortran
function write_block_string(self, action, filenames, names, name) result(error)

Arguments

NameTypeIntentAttributesDescription
selfclass(vtm_file)inoutVTM file.
actioncharacter(len=*)inoptionalAction: [open, close, write].
filenamescharacter(len=*)inoptionalFile names of VTK files grouped into current block.
namescharacter(len=*)inoptionalAuxiliary names attributed to each files.
namecharacter(len=*)inoptionalBlock name

Call graph

parse_scratch_files ​

Parse scratch files.

Returns: integer(kind=I4P)

fortran
function parse_scratch_files(self) result(error)

Arguments

NameTypeIntentAttributesDescription
selfclass(vtm_file)inoutVTM file.

Call graph

write_block_scratch ​

Write one block dataset on scratch files.

Returns: integer(kind=I4P)

fortran
function write_block_scratch(self, scratch, action, filename, name) result(error)

Arguments

NameTypeIntentAttributesDescription
selfclass(vtm_file)inoutVTM file.
scratchinteger(kind=I4P)inScratch unit.
actioncharacter(len=*)inAction: [open, write].
filenamecharacter(len=*)inoptionalFile name of VTK file grouped into current block.
namecharacter(len=*)inoptionalBlock name