VTK_CON_XML Function

public function VTK_CON_XML(NC, connect, offset, cell_type) result(E_IO)

This function \MaiuscolettoBS{must} be used when unstructured grid is used. It saves the connectivity of the unstructured mesh.

Arguments

Type IntentOptional AttributesName
integer(kind=I4P), intent(in) :: NC
integer(kind=I4P), intent(in) :: connect(:)
integer(kind=I4P), intent(in) :: offset(1:NC)
integer(kind=I1P), intent(in) :: cell_type(1:NC)

Return Value integer(kind=I4P)


Calls

proc~~vtk_con_xml~~CallsGraph proc~vtk_con_xml VTK_CON_XML interface~str str proc~vtk_con_xml->interface~str proc~str_i8p str_I8P interface~str->proc~str_i8p proc~str_r8p str_R8P interface~str->proc~str_r8p proc~str_i1p str_I1P interface~str->proc~str_i1p proc~str_i4p str_I4P interface~str->proc~str_i4p proc~str_r16p str_R16P interface~str->proc~str_r16p proc~str_i2p str_I2P interface~str->proc~str_i2p proc~str_r4p str_R4P interface~str->proc~str_r4p

Contents

Source Code


Source Code

  function VTK_CON_XML(NC,connect,offset,cell_type) result(E_IO)
  !---------------------------------------------------------------------------------------------------------------------------------
  !!This function \MaiuscolettoBS{must} be used when unstructured grid is used. It saves the connectivity of the unstructured mesh.
  !---------------------------------------------------------------------------------------------------------------------------------

  !---------------------------------------------------------------------------------------------------------------------------------
  implicit none
  integer(I4P), intent(IN):: NC              ! number of cells
  integer(I4P), intent(IN):: connect(:)      ! mesh connectivity
  integer(I4P), intent(IN):: offset(1:NC)    ! cell offset
  integer(I1P), intent(IN):: cell_type(1:NC) ! VTK cell type
  integer(I4P)::             E_IO            ! Input/Output inquiring flag: $0$ if IO is done, $> 0$ if IO is not done
  integer(I4P)::             n1              ! counter
  !!The VTK\_CON\_XML variables have the following meaning:
  !!
  !!\begin{description}
  !! \item[{\color{RoyalBlue}NCelle}] indicates the number of all cells.
  !! \item[{\color{RoyalBlue}connect}] contains the connectivity of the mesh. It is a vector.
  !! \item[{\color{RoyalBlue}offset}] contains the offset\footnote{The summ of nodes of all previous cells included the
  !!                                  current cell.} of every cells. It is a vector of $[1:NCelle]$.
  !! \item[{\color{RoyalBlue}tipo}] contains the type of every cells. It is a vector of $[1:NCelle]$.
  !! \item[{\color{RoyalBlue}E\_IO}] contains the inquiring integer flag for error handling.
  !!\end{description}
  !!
  !!The vector \MaiuscolettoBS{connect} must follow the VTK XML standard. It is passed as \MaiuscolettoBS{assumed-shape}
  !!array because its dimensions is related to the mesh dimensions in a complex way. Its dimensions can be calculated by
  !!the following equation:
  !!
  !!\begin{equation}
  !!dc = \sum\limits_{i = 1}^{NCelle} {nvertex_i }
  !!\label{eq:xml connectivity dimensions}
  !!\end{equation}
  !!
  !!\noindent where $dc$ is connectivity vector dimension and $nvertex_i$ is the number of vertices of $i^{th}$ cell.
  !!Note that this equation is different from the legacy one (eq. \ref{eq:connectivity dimensions}). The XML connectivity
  !!convention is quite different from the legacy standard. As an example considering the same mesh of section \ref{sec:VTKCON}:
  !!suppose we have a mesh composed by 2 cells, one hexahedron (8 vertices) and one pyramid with square basis (5 vertices);
  !!suppose that the basis of pyramid is constitute by a face of the hexahedron and so the two cells share 4 vertices. The
  !!equation \ref{eq:xml connectivity dimensions} gives $dc=8+5=13$; the connectivity vector for this mesh can be:
  !!
  !!\begin{boxred}{Connectivity vector example for VTK XML standard}
  !!\begin{verbatim}
  !!! first cell
  !!connect(1)  = 0  => identification flag of 1° vertex of 1° cell
  !!connect(2)  = 1  => identification flag of 2° vertex of 1° cell
  !!connect(3)  = 2  => identification flag of 3° vertex of 1° cell
  !!connect(4)  = 3  => identification flag of 4° vertex of 1° cell
  !!connect(5)  = 4  => identification flag of 5° vertex of 1° cell
  !!connect(6)  = 5  => identification flag of 6° vertex of 1° cell
  !!connect(7)  = 6  => identification flag of 7° vertex of 1° cell
  !!connect(8)  = 7  => identification flag of 8° vertex of 1° cell
  !!! second cell
  !!connect(9)  = 0  => identification flag of 1° vertex of 2° cell
  !!connect(10) = 1  => identification flag of 2° vertex of 2° cell
  !!connect(11) = 2  => identification flag of 3° vertex of 2° cell
  !!connect(12) = 3  => identification flag of 4° vertex of 2° cell
  !!connect(13) = 8  => identification flag of 5° vertex of 2° cell
  !!\end{verbatim}
  !!\end{boxred}
  !!
  !!Therefore this connectivity vector convention is more simple than the legacy convention, now we must create also the
  !!\MaiuscolettoBS{offset} vector that contains the data now missing in the \MaiuscolettoBS{connect} vector. The offset
  !!vector for this mesh can be:
  !!
  !!\begin{boxred}{Offset vector example for VTK XML standard}
  !!\begin{verbatim}
  !!! first cell
  !!offset(1) = 8  => summ of nodes of 1° cell
  !!! second cell
  !!offset(2) = 13 => summ of nodes of 1° and 2° cells
  !!\end{verbatim}
  !!\end{boxred}
  !!
  !!\noindent The value of every cell-offset can be calculated by the following equation:
  !!
  !!\begin{equation}
  !!offset_c = \sum\limits_{i = 1}^{c} {nvertex_i }
  !!\label{eq:xml offset vlue}
  !!\end{equation}
  !!
  !!\noindent where $offset_c$ is the value of $c^{th}$ cell and $nvertex_i$ is the number of vertices of $i^{th}$ cell.
  !!
  !!The function VTK\_CON\_XML does not calculate the connectivity and offset vectors: it writes the connectivity and offset
  !!vectors conforming the VTK XML standard, but does not calculate them. In the future release of \LIBVTKIO will be included
  !!a function to calculate the connectivity and offset vector.
  !!
  !!The vector variable \MaiuscolettoBS{tipo} must conform the VTK XML standard \footnote{See the file VTK-Standard at the
  !!Kitware homepage.} that is the same of the legacy standard presented previous (sec. \ref{sec:VTKCON}). It contains the
  !!\emph{type} of each cells. For the above example this vector is:
  !!
  !!\begin{boxred}{Cell-Type vector example for VTK legacy standard}
  !!\begin{verbatim}
  !!tipo(1) = 12  => VTK hexahedron type of 1° cell
  !!tipo(2) = 14  => VTK pyramid type of 2° cell
  !!\end{verbatim}
  !!\end{boxred}
  !!
  !!The following is an example of VTK\_CON\_XML calling:
  !!
  !!\begin{boxred}{VTK\_CON\_XML Calling}
  !!\begin{verbatim}
  !!...
  !!integer(4), parameter:: NCelle=2
  !!integer(4), parameter:: Nvertex1=8
  !!integer(4), parameter:: Nvertex2=5
  !!integer(4), parameter:: dc=Nvertex1+Nvertex2
  !!integer(4)::            connect(1:dc)
  !!integer(4)::            offset(1:NCelle)
  !!integer(4)::            tipo(1:NCelle)
  !!...
  !!E_IO = VTK_CON_XML(NCelle,connect,offset,tipo)
  !!...
  !!\end{verbatim}
  !!\end{boxred}
  !---------------------------------------------------------------------------------------------------------------------------------

  !---------------------------------------------------------------------------------------------------------------------------------
  select case(f_out)
  case(f_out_ascii)
    write(unit=Unit_VTK,fmt='(A)',iostat=E_IO)repeat(' ',indent)//'<Cells>'
    indent = indent + 2
    write(unit=Unit_VTK,fmt='(A)',iostat=E_IO)repeat(' ',indent)//'<DataArray type="Int32" Name="connectivity" format="ascii">'
    write(unit=Unit_VTK,fmt=FI4P, iostat=E_IO)(connect(n1),n1=1,size(connect))
    write(unit=Unit_VTK,fmt='(A)',iostat=E_IO)repeat(' ',indent)//'</DataArray>'
    write(unit=Unit_VTK,fmt='(A)',iostat=E_IO)repeat(' ',indent)//'<DataArray type="Int32" Name="offsets" format="ascii">'
    write(unit=Unit_VTK,fmt=FI4P, iostat=E_IO)(offset(n1),n1=1,NC)
    write(unit=Unit_VTK,fmt='(A)',iostat=E_IO)repeat(' ',indent)//'</DataArray>'
    write(unit=Unit_VTK,fmt='(A)',iostat=E_IO)repeat(' ',indent)//'<DataArray type="Int8" Name="types" format="ascii">'
    write(unit=Unit_VTK,fmt=FI1P, iostat=E_IO)(cell_type(n1),n1=1,NC)
    write(unit=Unit_VTK,fmt='(A)',iostat=E_IO)repeat(' ',indent)//'</DataArray>'
    indent = indent - 2
    write(unit=Unit_VTK,fmt='(A)',iostat=E_IO)repeat(' ',indent)//'</Cells>'
  case(f_out_binary)
    write(unit=Unit_VTK,iostat=E_IO)repeat(' ',indent)//'<Cells>'//end_rec
    indent = indent + 2
    write(unit=Unit_VTK,iostat=E_IO)repeat(' ',indent)//                                                      &
                                    '<DataArray type="Int32" Name="connectivity" format="appended" offset="', &
                                    trim(str(.true.,ioffset)),                                                &
                                    '">'//                                                                    &
                                    end_rec
    N_Byte  = size(connect)*sizeof(Tipo_I4)
    ioffset = ioffset + sizeof(Tipo_I4) + N_Byte
    write(unit=Unit_VTK_Append,iostat=E_IO)N_Byte,'I4',size(connect)
    write(unit=Unit_VTK_Append,iostat=E_IO)(connect(n1),n1=1,size(connect))
    write(unit=Unit_VTK,iostat=E_IO)repeat(' ',indent)//'</DataArray>'//end_rec
    write(unit=Unit_VTK,iostat=E_IO)repeat(' ',indent)//                                                 &
                                    '<DataArray type="Int32" Name="offsets" format="appended" offset="', &
                                    trim(str(.true.,ioffset)),                                           &
                                    '">'//                                                               &
                                    end_rec
    N_Byte  = NC*sizeof(Tipo_I4)
    ioffset = ioffset + sizeof(Tipo_I4) + N_Byte
    write(unit=Unit_VTK_Append,iostat=E_IO)N_Byte,'I4',NC
    write(unit=Unit_VTK_Append,iostat=E_IO)(offset(n1),n1=1,NC)
    write(unit=Unit_VTK,iostat=E_IO)repeat(' ',indent)//'</DataArray>'//end_rec
    write(unit=Unit_VTK,iostat=E_IO)repeat(' ',indent)//                                              &
                                    '<DataArray type="Int8" Name="types" format="appended" offset="', &
                                    trim(str(.true.,ioffset)),                                        &
                                    '">'//                                                            &
                                    end_rec
    N_Byte  = NC*sizeof(Tipo_I1)
    ioffset = ioffset + sizeof(Tipo_I4) + N_Byte
    write(unit=Unit_VTK_Append,iostat=E_IO)N_Byte,'I1',NC
    write(unit=Unit_VTK_Append,iostat=E_IO)(cell_type(n1),n1=1,NC)
    write(unit=Unit_VTK,iostat=E_IO)repeat(' ',indent)//'</DataArray>'//end_rec
    indent = indent - 2
    write(unit=Unit_VTK,iostat=E_IO)repeat(' ',indent)//'</Cells>'//end_rec
  endselect
  return
  !---------------------------------------------------------------------------------------------------------------------------------
  endfunction VTK_CON_XML