-
Notifications
You must be signed in to change notification settings - Fork 53
PVTK XML files
Presently, the available functions for PVTK-XML standard files are:
- PVTK_INI_XML: function for initializing the PVTK file;
- PVTK_GEO_XML: function for saving the geometry of the current piece;
- PVTK_DAT_XML: function for start/finish the saving of data associated to the current piece mesh;
- PVTK_VAR_XML: function for actually saving the data associated to the current piece mesh;
- PVTK_END_XML: function for finalizing the PVTK file.
The complete signature of each functions can be found on the API documentation. These functions are listed with their hierarchy: PVTK_INI_XML
must be the first function called and PVTK_END_XML
the last one. PVTK_GEO_XML
must be called one time for each partition, #partition_number
.
For a more complete examples of usage of these functions refer to the Testing-Program documentation. In the following a pseudo callings sequences are reported for different scenario.
This example demonstrate the creation of parallel (partitioned) PStructuredGrid file (.pvts). The mesh is a simple prism partitioned into two pieces along x direction. The extent of the whole dataset is [nx1-nx2,ny1-ny2,nz1-nz2] and the ordinate x is partitioned as
- nx1_p[1]=nx1;
- nx1_p[2]=nx12;
- nx2_p[1]=nx12;
- nx2_p[2]=nx2;
where nx12 is the ordinate where the prism has been partitioned. The following is a schematic 2D draw of the partitioned prism
y ^
| ny2 +-----------------+--------------+
| | | |
| | | |
| | | |
| | | |
o--------> ny1 +-----------------+--------------+
x nx1 i=nx2_p(1) nx2
Let us assume that all the necessary StructuredGrid variables have been defined and initialized, the following is a pseudo code showing how to create partitioned files:
do p=1,2 ! loop over pieces
E_IO = VTK_INI_XML(cf=mf(p),output_format='binary', filename='XML_STRG_part'//trim(str(.true.,p-1))//'.vts', &
mesh_topology='StructuredGrid', nx1=nx1_p(p), nx2=nx2_p(p), ny1=ny1, ny2=ny2, nz1=nz1, nz2=nz2)
enddo
do p=1,2 ! loop over pieces
E_IO = VTK_GEO_XML(cf=mf(p),nx1=nx1_p(p), nx2=nx2_p(p), ny1=ny1, ny2=ny2, nz1=nz1, nz2=nz2, NN=nn_p(p), &
X=reshape(x(nx1_p(p):nx2_p(p),:,:),(/nn_p(p)/)), &
Y=reshape(y(nx1_p(p):nx2_p(p),:,:),(/nn_p(p)/)), &
Z=reshape(z(nx1_p(p):nx2_p(p),:,:),(/nn_p(p)/)))
E_IO = VTK_DAT_XML(cf=mf(p),var_location = 'node', var_block_action = 'open')
E_IO = VTK_VAR_XML(cf=mf(p),NC_NN = nn_p(p), varname = 'node_value', var = reshape(v(nx1_p(p):nx2_p(p),:,:),(/nn_p(p)/)))
E_IO = VTK_DAT_XML(cf=mf(p),var_location = 'node', var_block_action = 'close')
E_IO = VTK_GEO_XML(cf=mf(p))
enddo
do p=1,2 ! loop over pieces
E_IO = VTK_END_XML()
enddo
E_IO = PVTK_INI_XML(filename = 'XML_STRG.pvts', mesh_topology = 'PStructuredGrid', &
nx1=nx1, nx2=nx2, ny1=ny1, ny2=ny2, nz1=nz1, nz2=nz2, tp='Float64')
E_IO = PVTK_GEO_XML(nx1=nx1, nx2=nx2_p(1), ny1=ny1, ny2=ny2, nz1=nz1, nz2=nz2, source='XML_STRG_part0.vts')
E_IO = PVTK_GEO_XML(nx1=nx2_p(1), nx2=nx2_p(2), ny1=ny1, ny2=ny2, nz1=nz1, nz2=nz2, source='XML_STRG_part1.vts')
E_IO = PVTK_DAT_XML(var_location = 'node', var_block_action = 'open')
E_IO = PVTK_VAR_XML(varname = 'node_value', tp='Int32')
E_IO = PVTK_DAT_XML(var_location = 'node', var_block_action = 'close')
E_IO = PVTK_END_XML()
It is worth noting the relation between pieces extents. The pieces must be "adjacent" meaning that they must share the "patch" where they have been partitioned, i.e. nx1_p[2]=nx12 = nx2_p[1]. This is necessary at least for a proper visualization with ParaView, but it is not clear (for the authors) if it is a requirements of VTK standard.
This example demonstrate the creation of parallel (partitioned) PUnstructuredGrid file (.pvtu). The mesh is composed by two independent UnstructuredGrid dataset that are identical.
Let us assume that all the necessary UnstructuredGrid variables have been defined and initialized, the following is a pseudo code showing how to create partitioned files.
E_IO = VTK_INI_XML(output_format = 'Binary', filename = 'XML_UNST_part0.vtu', mesh_topology = 'UnstructuredGrid')
E_IO = VTK_GEO_XML(NN = Nn, NC = Ne, X = x, Y = y, Z = z)
E_IO = VTK_CON_XML(NC = Ne, connect = connect, offset = offset, cell_type = cell_type )
E_IO = VTK_DAT_XML(var_location = 'node', var_block_action = 'opeN')
E_IO = VTK_VAR_XML(NC_NN = Nn, varname = 'scalars', var = v)
E_IO = VTK_VAR_XML(NC_NN = Nn, varname = 'vector', varX=v_X,varY=v_Y,varZ=v_Z)
E_IO = VTK_DAT_XML(var_location = 'node', var_block_action = 'CLOSE')
E_IO = VTK_GEO_XML()
E_IO = VTK_END_XML()
x = x + 10._R4P
E_IO = VTK_INI_XML(output_format = 'Binary', filename = 'XML_UNST_part1.vtu', mesh_topology = 'UnstructuredGrid')
E_IO = VTK_GEO_XML(NN = Nn, NC = Ne, X = x, Y = y, Z = z)
E_IO = VTK_CON_XML(NC = Ne, connect = connect, offset = offset, cell_type = cell_type )
E_IO = VTK_DAT_XML(var_location = 'node', var_block_action = 'opeN')
E_IO = VTK_VAR_XML(NC_NN = Nn, varname = 'scalars', var = v)
E_IO = VTK_VAR_XML(NC_NN = Nn, varname = 'vector', varX=v_X,varY=v_Y,varZ=v_Z)
E_IO = VTK_DAT_XML(var_location = 'node', var_block_action = 'CLOSE')
E_IO = VTK_GEO_XML()
E_IO = VTK_END_XML()
E_IO = PVTK_INI_XML(filename = 'XML_UNST.pvtu', mesh_topology = 'PUnstructuredGrid', tp='Float32')
E_IO = PVTK_GEO_XML(source='XML_UNST_part0.vtu')
E_IO = PVTK_GEO_XML(source='XML_UNST_part1.vtu')
E_IO = PVTK_DAT_XML(var_location = 'node', var_block_action = 'OPEN')
E_IO = PVTK_VAR_XML(varname = 'scalars', tp='Float64')
E_IO = PVTK_VAR_XML(Nc = 3, varname = 'vector', tp='Int32' )
E_IO = PVTK_DAT_XML(var_location = 'node', var_block_action = 'Close')
E_IO = PVTK_END_XML()
The PUnstructuredGrid pieces have the tag field GhostLevel. At present, it is not used.