[Paraview] Degrees of freedom

Samuel Key samuelkey at bresnan.net
Tue Nov 21 16:38:15 EST 2017


Doina--


In what follows, I will skip talking about a 3-nod quadratic line as a 
way to display a cured beam or a deformed beam. (I live in a world of 
large deformation simulations and I like to display that type of behavior.)


The concept of FIELD (aka GLOBAL) simulation results, for example, 
results that come from or related to overall behavior like total Kinetic 
Energy (KE), are well supported by the Exodus-II format and are absent 
from the EnSight format and the VTK format for simulation results. I 
will confine my comments to what I have to offer to just POINT data and 
CELL data.


It is convenient to divide simulation results into three categories for 
virtually all of the data formats that PV can read.

(1) GEOMETRY data

(2) POINT data

(3) CELL data


The following is the VTK-XML ASCII format. (See the attached file 
'resultsvtk.f')


(1) GEOMETRY. ParaView is quite happy with just GEOMETRY data.(It is a 
nice way to start when one is trying to write a datum set for ParaView. 
ParaView will display an object with only the geometry data.)


(1a) Write the entire Point inventory from 1 to n where n = number of 
nodal points  in terms of coordinate 3-tuples [(x1,y1,z1,), ...,(xn,yn,zn)]


(1b) Write the entire Cell inventory of connectivity n-tuples (as array 
offsets!)

(1c) Write the 'starting location' for the n-tuples in (1b)

(1d) Write the VTK cell-type values for the n-tuples in (1b)


ParaView now has everything it needs to display your geometry.


(2) Write POINT data information.

(2a) In the case of 'mode shapes,' write the mode's displacement 
3-tuples (aka Vectors, name="Mode1")

[(UxM1,UyM1,UzM1),...,(UxMn,UyMn,UzMn)]

(2b) Repeat with name="Mode2", and so fourth (aka/und so weiter/)


ParaView now has the enough information to animate the mode shapes. 
Instructions are here

( https://public.kitware.com/pipermail/paraview/2017-October/041077.html 
) for producing animations of the mode shapes.


Hope this helps.


--Sam


On 11/21/2017 7:15 AM, Doina Gumeniuc (224252 MAHS) wrote:
>
> Hi Samuel,
>
>
> Thank you for your reply.
>
> I have different frequencies, 50 in total. If I use FIELD POINT DATA 
> and then for arrayname 1 and so on, I use the Freq1, Freq2... then for 
> 6Dofs, I use vectors in x,y,z for translation and Phi-x,Phi-y, Phi-z 
> for rotation.... would it make sense in paraview? I can hopefully then 
> warp by vectors using the data for each frequency.
>
>
> Thank you! I hope I was clear.
>
> ------------------------------------------------------------------------
> *From:* ParaView <paraview-bounces at paraview.org> on behalf of Samuel 
> Key <samuelkey at bresnan.net>
> *Sent:* November 18, 2017 7:00:51 PM
> *To:* paraview at paraview.org
> *Subject:* Re: [Paraview] Degrees of freedom
>
> Doina--
>
>
> At the risk of underestimating ParaView's functionalities, I can tell 
> you what will work. For displaying geometry,  PV only needs Point (aka 
> nodal point) x,y,z-coordinates, a Cell (aka Finite Element, ...)  
> type  and for each Cell an n-tuple of Point "array locations", for 
> example, EnSight-format::{1,2,4,3,7,8,} or VTK-format::{0,1,3,2,6,7}.
>
>
> The VTK format uses C-language 'array offsets' for Cell connectivity 
> n-tuples. The EnSight format uses FORTRAN-language array locations for 
> Finite Element connectivity n-tuples. It is just the way it is.
>
>
> Variables are either located at Points or in Cells (conceptually Cell 
> centers). The arrays supplied for variables must span all of the 
> Points or all of the Cells. (I do not know how to use or about the 
> acceptability of "partially" specified variable datum sets.) For 
> Points with 6-DOFs versus 3-DOFs, if you want to see the three 
> rotational DOFs, use POINT DATA arrays and fill in the Phi-x, Phi-y, 
> Phi-z values using zeros for at those Points without a rotation.
>
>
> If you want to visually display a 2-node, 6-DOF beam's geometry (a 
> curved beam or a deformed beam) , one solution is too use a VTK Cell 
> type 'VTK_QUADRATIC_EDGE = 21'  for the beam. This will require you to 
> add-on-the-fly to the simulation results a beam center-Point with 
> x,y,z-coordinates and displacements for the beam's center Point using 
> the beam's interpolation functions. (PV has a Warp Filter that will 
> let you then scale up the deflections for visualization purposes.)
>
>
> Should you have access to source code for the simulations, I can 
> supply FORTRAN language routines that write VTK ASCII-formatted 
> simulation results. (My personal preference is the EnSight format.)
>
>
> --Sam
>
>
>
>
> On 11/18/2017 6:12 AM, Doina Gumeniuc (224252 MAHS) wrote:
>>
>> Hi all!
>>
>> I am still learning the use of paraview and I have got to such a 
>> question: How to show in a vtk input file the degrees of freedom of 
>> elements? Some of the beams have 6 degrees of freedom, some of the 
>> other elements...less or nothing at all. IS there any possibility?
>>
>> Thank you a lot in advance!
>>
>>
>>
>> _______________________________________________
>> Powered bywww.kitware.com <http://www.kitware.com>
>>
>> Visit other Kitware open-source projects athttp://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the ParaView Wiki at:http://paraview.org/Wiki/ParaView
>>
>> Search the list archives at:http://markmail.org/search/?q=ParaView
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/paraview
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20171121/c8dabba6/attachment-0001.html>
-------------- next part --------------
      SUBROUTINE WRITE_TO_VTK_RESULTS_FILE
!!
!! Copyright (c) by FMA Development, LLC, 28-MAY-2004
!!
!! Purpose: Write results to ASCII file suitable for VTK postprocessing.
!!
      USE shared_common_data
      USE mxphg_mxphn_mxpgn_values
!!
!! The complete simulation data set.
!!
      USE indx_;           USE node_;           USE input_function_;
      USE beam_;           USE coord_;          USE sliding_interface_;
      USE value_;          USE force_;          USE nodal_constraints_;
      USE hexah_;          USE penta_;          USE nonreflecting_bc_;
      USE tetra_;          USE lsold_;          USE nodal_point_mass_;
      USE membq_;          USE membt_;          USE rigid_body_mass_;
      USE truss_;          USE platq_;          USE state_variables_;
      USE platt_;          USE motion_;         USE enumerated_sets_;
      USE spring_;         USE damper_;         USE displacement_bc_;
      USE stress_;         USE segment_;        USE contact_surface_;
      USE tied_bc_;        USE results_;        USE relink_scratch_;
      USE gauge1d_;        USE gauge2d_;        USE rigid_wall_bc_;
      USE gauge3d_;        USE massprop_;       USE include_file_;
      USE material_;       USE layering_;       USE sliding_node_;
      USE force_bc_;       USE node_set_;       USE contact_node_;
      USE nrbc_data_;      USE spring_bc_;      USE periodic_bc_;
      USE damper_bc_;      USE spot_weld_;      USE pressure_bc_;
      USE qa_record_;      USE plate_pair_;     USE segment_set_;
      USE body_force_;     USE section_2d_;     USE element_set_;
      USE section_1d_;     USE rigid_body_;     USE velocity_ic_;
      USE section_3d_;     USE extreme_value_;  USE centrifugal_force_;
      USE location_;       USE mean_stress_;    USE output_;         
      USE wedge_;          USE energy_flow_;    USE pyramid_;
      USE polyh_;          USE cgmotion_bc_;    USE cgforce_bc_;
      USE rigid_tube_bc_;  
      USE flux_transfer_pair_;  
      USE traction_transfer_pair_;
      USE slave_trias_; Use master_trias_;

      USE precision_

      IMPLICIT    REAL(RTYPE) ( A-H, O-Z )
      IMPLICIT INTEGER(ITYPE) ( I-N      )
!!
!! Local variables.
      CHARACTER(4)         :: CVTO        ! Buffer for unique file extension
      CHARACTER(4)         :: PVTO        ! Buffer for unique file extension
      INTEGER(ITYPE), SAVE :: IVTO = 0    ! Counter for unique file extension
      CHARACTER(8)         :: BUFFER1     ! Internal buffer, int & float writes
      CHARACTER(8)         :: BUFFER2     ! Internal buffer, int & float writes
      CHARACTER(12)        :: TimeStep    ! Internal buffer to construct time step
      CHARACTER(132)       :: Part_Name   ! Internal buffer to construct part name
      CHARACTER(132)       :: File_Name   ! Internal buffer to construct file name

      INTEGER(ITYPE), SAVE :: NUMXL, MStep
      INTEGER(ITYPE)       :: NTUPLE(8)
      LOGICAL              :: IOERROR
      LOGICAL,    EXTERNAL :: NEXT_NP_ID
      LOGICAL,    EXTERNAL :: NEXT_SEG_ID
      LOGICAL,        SAVE :: FIRST  = .TRUE.

      INTEGER(ITYPE), PARAMETER :: IBCOUNT = 1000
!!
!! The following arrays are used to extract VTK "Pieces" based on material models.
!! For material "M," I = ELEMENTS_AND_NODES_USED(M) fills the arrays with indecies.
!!
      INTEGER(ITYPE), DIMENSION(:), ALLOCATABLE, SAVE :: NELUSED ! Elems used by material M
      INTEGER(ITYPE), DIMENSION(:), ALLOCATABLE, SAVE :: NPTUSED ! Nodes used by material M
      INTEGER(ITYPE), DIMENSION(:), ALLOCATABLE, SAVE :: NPTNOWI ! Node's vtk output-index
!!
!! Array for saving results output time values.
!!
      REAL(RTYPE),    DIMENSION(:), ALLOCATABLE, SAVE :: TIME_VALUES
!!
!! Contained functions
!!    INTEGER :: ELEMENTS_AND_NODES_USED ! Gens material access arrays
!!    INTEGER :: ELEMENT_N_TUPLE         ! Rtns connectivity count
!!    INTEGER :: ELEMENT_VTK_OFFSET      ! Rtns vtk element offset
!!    INTEGER :: ELEMENT_VTK_TYPE        ! Rtns vtk element type
!!    INTEGER :: MatID_DATA              ! Rtns material ID MatID
!!    INTEGER :: EleID_DATA              ! Rtns element ID  EleID
!!    REAL    :: STRESS_DATA             ! Rtns element stress
!!    REAL    :: BULK_STRAIN             ! Rtns element bulk strain
!!    REAL    :: STRAIN_ENERGY_DENSITY   ! Rtns element int energy
!!    REAL    :: PRESSURE                ! Rtns element pressure
!!    REAL    :: EFFECTIVE_STRESS        ! Rtns element eff stress
!!    INTEGER :: SEGMENTS_AND_NODES_USED ! Gens segment access arrays
!!    INTEGER :: SEGMENT_N_TUPLE         ! Rtns connectivity count
!!    INTEGER :: SEGMENT_VTK_OFFSET      ! Rtns vtk element offset
!!    INTEGER :: SEGMENT_VTK_TYPE        ! Rtns vtk element type

!!
!! Trial usage of xtkXMLWriterF.o (a Fortran binding for vtkXMLWriter)
!!
!      integer(8) :: numpoints=8, numcells=1, cellsSize=9, cells(9) = (/8,0,1,2,3,4,5,6,7/)
!      real(4)    :: pdata(8)= (/0,0,0,0,1,1,1,1/)
!      real(4)    :: points(24) = (/0,0,0, 1,0,0, 1,1,0, 0,1,0, 0,0,1, 1,0,1, 1,1,1, 0,1,1/)
!
!      call vtkXMLWriterF_New               ( nHandle )
!      call vtkXMLWriterF_SetDataObjectType ( nHandle, 4 )
!      call vtkXMLWriterF_SetFileName       ( nHandle, 'test1.vtu' )
!      call vtkXMLWriterF_SetPoints         ( nHandle, 10, points, numpoints )
!      call vtkXMLWriterF_SetCellsWithType  ( nHandle, 12, numcells, cells, cellsSize )
!      call vtkXMLWriterF_SetPointData      ( nHandle, 'Example Data', 10, pdata, numpoints, 1, 'SCALARS' )
!      call vtkXMLWriterF_Write             ( nHandle, Istatus )
!      call vtkXMLWriterF_Delete            ( nHandle )
!      write (IO_UNIT%LELO,'(/A,I8)') ' Istatus:',Istatus

!!############################################################################
!! 1. CONSTANT FOR ALL-TIME DATA
!! "Create one-time 'fromfile' for subsequent VTK Data Files to reference."
!! Note: This should be one-time data that has no business being in each
!! "this-time" file that is generated below. Until we can figure out how 
!! to do this in vtk, this file will contain the undeformed configuration 
!! the first time this routine is called with the current velocities. 
!!
!!

!! =========FIRST=============================================================
!! This file will contain the the undeformed mesh colored by material and 
!! have velocity initial conditions for examination. 
!!
      IF (FIRST) THEN
        !!
        !! Allocate storage for the number of time steps expected from the 
        !! VTKFILE input record entries. If the requested time increment is 
        !! zero, limit the number of time steps.
        !!
        Tbgn = VTK_RESULTS_FILE%Begin
        Tinc = VTK_RESULTS_FILE%Delta
        Tend = MIN( TIME%Stop, VTK_RESULTS_FILE%End )

        IF (Tinc .GT. ZERO) THEN
          MStep = NINT( (Tend-Tbgn)/Tinc ) + 1
        ELSE
          MStep = 101
          WRITE (MSG1,'(I8)') MStep
          CALL USER_MESSAGE
     &      (
     &      MSGL//'INFORM'//
     &      MSGL//'WRITE_TO_VTK_RESULTS_FILE.010.01'//
     &      MSGL//'Since "VTKFILE DELTA=0.0" Was Input And'//
     &      MSGL//'Due To The Nature Of The VTK *.pvd File'//
     &      MSGL//'Format, The Number Of Time Steps Was'//
     &      MSGL//'Capped At'//MSG1//' Steps. Try A Non-Zero'//
     &      MSGL//'DELTA Value To Allow A Non-Zero Divide.'
     &      )
        ENDIF
      !!
      ALLOCATE ( TIME_VALUES(1:MStep) )
      TIME_VALUES(:) = 0.0
!!
!! Total finite element count. Note: Only one qudrilateral is produced for
!! each membrane (NUMM3, NUMM4) and shell (NUMP3, NUMP4) finite element.
!!
        NUMXL = NUMHX + NUMPX + NUMPY + NUMTX + NUMM3 + NUMP3 + NUMM4 + NUMP4 + NUMTR
!!
!! Count number of elements using each material model. Note: There may be more
!! material models specified then are actually referenced by elements in the
!! mesh. Hence, the effort to isolate materials that have a null usage count.
!!
        MXSNW = MAX ( NUMXL, NUMSG, NUMNP, NUMWX )
        ALLOCATE ( NELUSED(1:MXSNW), NPTUSED(1:NUMNP), NPTNOWI(1:NUMNP) )
        NELUSED(:) = 0
        NPTUSED(:) = 0
        NPTNOWI(:) = 0
!!
!! Define element and node counts for MATERIAL(*)%NElems and MATERIAL(*)%NNodes
!!
        DO M = 1,NUMMT
          I = ELEMENTS_AND_NODES_USED(M)
        ENDDO
!!
!! Open initial configuration VTK Data File.
!!
        IOERROR = .TRUE.
        OPEN
     &    (
     &    UNIT    =  IO_UNIT%LVTO,
     &    FILE    = 'fmavto.msh0000.vtu',
     &    STATUS  = 'UNKNOWN',
     &    FORM    = 'FORMATTED',
     &    ERR     =  100
     &    )
        IOERROR = .FALSE.
!!
!! Fatal error exit for failed OPEN operation.
!!
 100    IF (IOERROR) THEN
          CALL USER_MESSAGE
     &      (
     &      MSGL//'FATAL'//
     &      MSGL//'WRITE_VTK_DATA_FILE.001.01'//
     &      MSGL//'Unable To Execute OPEN On: '//'fmavto.msh0000.vtu'
     &      )
        ELSE
!!
!! Define NPTNOWI array as if all finite elements use the same material.
!! (We need to do this to get all finite element n-tuples into the cell 
!! definition data via the function ELEMENT_N_TUPLE used in the output
!! lists below.)
!!
          NPTNOWI = (/(I, i = 1,NUMNP)/)
!!
!!***************************************************************************
!! To avoid any output buffer et cetera limitations, break output writes
!! into smaller batches of IBCOUNT each.  (Overflows have occurred already.)
!! Element(Cell) Blocking: L... counter items.
!! Nodal(Points) Blocking: N... counter items.
!!
          LBCOUNT=IBCOUNT;  LBLOCKS=NUMXL/LBCOUNT;  LREMAIN=NUMXL-LBCOUNT*LBLOCKS

          NBCOUNT=IBCOUNT;  NBLOCKS=NUMNP/NBCOUNT;  NREMAIN=NUMNP-NBCOUNT*NBLOCKS
!!
!! For now, this blocking is used only for the whole-mesh write. It may need 
!! to be extended if any one material block causes the executable to blow a
!! gasket.
!!***************************************************************************
!!
!! Initialize vtk xml data file.
!!
          WRITE (IO_UNIT%LVTO,'(A/)') '<?xml version="1.0"?>'
!!
!! Analysis QA information.
!!
          WRITE (IO_UNIT%LVTO,'(A )') '<!--'
          WRITE (IO_UNIT%LVTO,'(A )') '   Title: '//TRIM(JOB_ID_RECORD%CURRENT%TITLE)
          WRITE (IO_UNIT%LVTO,'(A )') ' Program: '//JOB_ID_RECORD%PROGRAM
          WRITE (IO_UNIT%LVTO,'(A )') ' Version: '//JOB_ID_RECORD%VERSION
          WRITE (IO_UNIT%LVTO,'(A )') '    Date: '//JOB_ID_RECORD%CURRENT%DATE
          WRITE (IO_UNIT%LVTO,'(A )') '    Time: '//JOB_ID_RECORD%CURRENT%TIME
          WRITE (IO_UNIT%LVTO,'(A/)') ' -->'
!!
!! Current time step and cycle number.
!!
          WRITE (IO_UNIT%LVTO,'(A )')        '<!--'
          WRITE (IO_UNIT%LVTO,'(A,1PE15.7)') ' Problem Time: ',REAL(TIME%Total,KIND(0E0))
          WRITE (IO_UNIT%LVTO,'(A,I8)')      ' Cycle Number: ',TIME%Step
          WRITE (IO_UNIT%LVTO,'(A/)')        ' -->'
!!
!! Start vtk "UnstructuredGrid" data.
!!
          WRITE (IO_UNIT%LVTO,'(A)') '<VTKFile type="UnstructuredGrid" version="0.1" byte_order="LittleEndian">'
          WRITE (IO_UNIT%LVTO,'(A)') '<UnstructuredGrid>'
!!
!! Start vtk "Piece" data.
!!
          WRITE (BUFFER1,'(I8)') NUMNP;  I1 = SCAN( BUFFER1, "123456789" )
          WRITE (BUFFER2,'(I8)') NUMXL;  I2 = SCAN( BUFFER2, "123456789" )
          WRITE (IO_UNIT%LVTO,'(A)') '<Piece NumberOfPoints="'//BUFFER1(I1:)//'" NumberOfCells="'//BUFFER2(I2:)//'">'
!!
!! Start vtk "Points" data.
!!
          WRITE (IO_UNIT%LVTO,'(A)') '<Points>'
!!
!! Write initial nodal point coordinates for the "Points" data.
!!
          WRITE (IO_UNIT%LVTO,'(2X,A)') '<DataArray type="Float32" Name="Position" NumberOfComponents="3" format="ascii">'
          Nbgn = 1
          Nend = NREMAIN
          DO i = 1,NBLOCKS+1
            WRITE (IO_UNIT%LVTO,'((6(1PE15.7)))') ( (/REAL(MOTION(N)%Px,KIND(0E0)),
     &      REAL(MOTION(N)%Py,KIND(0E0)), REAL(MOTION(N)%Pz,KIND(0E0)) /), N = Nbgn,Nend)
            Nbgn = Nend + 1
            Nend = Nend + NBCOUNT
          ENDDO
          WRITE (IO_UNIT%LVTO,'(2X,A)') '</DataArray>'
!!
!! End vtk "Points" data.
!!
          WRITE (IO_UNIT%LVTO,'(A)') '</Points>'
!!
!! Start vtk "Cells" data.
!!
          WRITE (IO_UNIT%LVTO,'(A)') '<Cells>'
!!
!! Write vtk cell data (cell-connectivities, cell-tuple-offsets, cell-types).
!!
          WRITE (IO_UNIT%LVTO,'(2X,A)') '<DataArray type="Int32" Name="connectivity" NumberOfComponents="1" format="ascii">'
          Lbgn = 1
          Lend = LREMAIN
          DO i = 1,LBLOCKS+1
            WRITE (IO_UNIT%LVTO,'((6X,8I10))') (NTUPLE(1:ELEMENT_N_TUPLE(L)), L = Lbgn,Lend) 
            Lbgn = Lend + 1
            Lend = Lend + LBCOUNT
          ENDDO
          WRITE (IO_UNIT%LVTO,'(2X,A)') '</DataArray>'

          WRITE (IO_UNIT%LVTO,'(2X,A)') '<DataArray type="Int32" Name="offsets" NumberOfComponents="1" format="ascii">'
          Lbgn = 1
          Lend = LREMAIN
          DO i = 1,LBLOCKS+1
            WRITE (IO_UNIT%LVTO,'((6X,8I10))') (ELEMENT_VTK_OFFSET(L,L), L = Lbgn,Lend) 
            Lbgn = Lend + 1
            Lend = Lend + LBCOUNT
          ENDDO
          WRITE (IO_UNIT%LVTO,'(2X,A)') '</DataArray>'

          WRITE (IO_UNIT%LVTO,'(2X,A)') '<DataArray type="UInt8"  Name="types" NumberOfComponents="1" format="ascii">'
          Lbgn = 1
          Lend = LREMAIN
          DO i = 1,LBLOCKS+1
            WRITE (IO_UNIT%LVTO,'((6X,28I3))') (ELEMENT_VTK_TYPE(L), L = Lbgn,Lend) 
            Lbgn = Lend + 1
            Lend = Lend + LBCOUNT
          ENDDO
          WRITE (IO_UNIT%LVTO,'(2X,A)') '</DataArray>'
!!
!! End vtk "Cells" data.
!!
          WRITE (IO_UNIT%LVTO,'(A)') '</Cells>'
!!
!! Start vtk "PointData" data.
!!
          WRITE (IO_UNIT%LVTO,'(A)') '<PointData Vectors="Velocity">'
!!
!! Write nodal point based motion data to VTK Data File.
!!
          WRITE (IO_UNIT%LVTO,'(2X,A)') '<DataArray type="Float32" Name="Velocity" NumberOfComponents="3" format="ascii">'
          Nbgn = 1
          Nend = NREMAIN
          DO i = 1,NBLOCKS+1
            WRITE (IO_UNIT%LVTO,'((6(1PE15.7)))') ( (/REAL(MOTION(N)%Vx,KIND(0E0)), 
     &      REAL(MOTION(N)%Vy,KIND(0E0)), REAL(MOTION(N)%Vz,KIND(0E0)) /), N = Nbgn,Nend)
            Nbgn = Nend + 1
            Nend = Nend + NBCOUNT
          ENDDO
          WRITE (IO_UNIT%LVTO,'(2X,A)') '</DataArray>'
!!
!! End vtk "PointData" data.
!!
          WRITE (IO_UNIT%LVTO,'(A)') '</PointData>'
!!
!! Start vtk "CellData" data.
!!
          WRITE (IO_UNIT%LVTO,'(A)') '<CellData Scalars="Material">'
!!
!! Write element-based (cell) material number data to VTK Data File.
!!
          WRITE (IO_UNIT%LVTO,'(2X,A)')'<DataArray type="Int32" Name="Material" NumberOfComponents="1" format="ascii">'
          Lbgn = 1
          Lend = LREMAIN
          DO i = 1,LBLOCKS+1
            WRITE (IO_UNIT%LVTO,'((6X,8I10))') (MatID_DATA(L), L = Lbgn,Lend)
            Lbgn = Lend + 1
            Lend = Lend + LBCOUNT
          ENDDO
          WRITE (IO_UNIT%LVTO,'(2X,A)')'</DataArray>'
!!
!! End vtk "CellData" data.
!!
          WRITE (IO_UNIT%LVTO,'(A)') '</CellData>'
!!
!! End vtk "Piece" data.
!!
          WRITE (IO_UNIT%LVTO,'(A)') '</Piece>'
!!
!! End vtk "UnstructuredGrid" data.
!!
          WRITE (IO_UNIT%LVTO,'(A)') '</UnstructuredGrid>'
!!
!! End vtk "VTKFile" data.
!!
          WRITE (IO_UNIT%LVTO,'(A)') '</VTKFile>'
!!
          CLOSE (UNIT=IO_UNIT%LVTO, STATUS='KEEP')
!!
        ENDIF
!!
!!

!! =========SECOND============================================================
!! Write the individual segment-sets, node-sets and wedge-sets to separate 
!! files. The idea is that ParaView can load these files one at a time "on 
!! top of" the above mesh file to confirm that the individual sets have been 
!! correctly specified. (The underlying mesh should first be colored "gray" 
!! so that the colors assigned by ParaView to each set standout and are more 
!! easily examined for correctness.)
!!
        DO M = 1,NUMNS
!!
!! Clear marker/index-sequence and translation arrays.
!!
          NELUSED = 0
          NPTUSED = 0
          NPTNOWI = 0
!!
!! Mark nodes used by this node set.
!!
          N = 0
          DO WHILE (NEXT_NP_ID(M,N))
            NPTUSED(N) = 1
          ENDDO
!!
!! Covert NPTUSED (and NELUSED) into a sequential index map.
!!
          K = 0
          DO N = 1,NUMNP
            IF (NPTUSED(N) .EQ. 1) THEN
              K = K + 1
              NPTNOWI(N) = K
              NPTUSED(K) = N
              NELUSED(K) = N
            ENDIF
          ENDDO
!!
!! For later use, record the number of nodes and elements (each node will be 
!! a "vertex element" for ParaView) that will be in the file for this NP_SET.
!!
          NNodes = K
          NElems = K

          IF (NNodes .GT. 0) THEN
            WRITE (PVTO,'(I4.4)') M
!!
!! Open new VTK Data File.
!!
            IOERROR = .TRUE.
            OPEN
     &        (
     &        UNIT    =  IO_UNIT%LVTO,
     &        FILE    = 'fmavto.mns'//PVTO//'.vtu',
     &        STATUS  = 'UNKNOWN',
     &        FORM    = 'FORMATTED',
     &        ERR     =  200
     &        )
            IOERROR = .FALSE.
!!
!! Fatal error exit for failed OPEN operation.
!!
 200        IF (IOERROR) THEN
              CALL USER_MESSAGE
     &          (
     &          MSGL//'FATAL'//
     &          MSGL//'WRITE_VTK_DATA_FILE.001.02'//
     &          MSGL//'Unable To Execute OPEN On: '//'fmavto.mns'//PVTO//'.vtu'
     &          )
            ELSE
!!
!! Initialize vtk xml data file.
!!
              WRITE (IO_UNIT%LVTO,'(A/)') '<?xml version="1.0"?>'
!!
!! Analysis QA information.
!!
              WRITE (IO_UNIT%LVTO,'(A )') '<!--'
              WRITE (IO_UNIT%LVTO,'(A )') '   Title: '//TRIM(JOB_ID_RECORD%CURRENT%TITLE)
              WRITE (IO_UNIT%LVTO,'(A )') ' Program: '//JOB_ID_RECORD%PROGRAM
              WRITE (IO_UNIT%LVTO,'(A )') ' Version: '//JOB_ID_RECORD%VERSION
              WRITE (IO_UNIT%LVTO,'(A )') '    Date: '//JOB_ID_RECORD%CURRENT%DATE
              WRITE (IO_UNIT%LVTO,'(A )') '    Time: '//JOB_ID_RECORD%CURRENT%TIME
              WRITE (IO_UNIT%LVTO,'(A/)') ' -->'
!!
!! Current time step, cycle number, node set user's ID and node set label.
!!
              WRITE (IO_UNIT%LVTO,'(A )')        '<!--'
              WRITE (IO_UNIT%LVTO,'(A,1PE15.7)') '   Problem Time: ',REAL(TIME%Total,KIND(0E0))
              WRITE (IO_UNIT%LVTO,'(A,I8)')      '   Cycle Number: ',TIME%Step
              WRITE (IO_UNIT%LVTO,'(A,I8)')      '    Node Set ID: ',NODE_SET(M)%SetID
              WRITE (IO_UNIT%LVTO,'(A,A)')       ' Node Set Label: ',NODE_SET(M)%LABEL
              WRITE (IO_UNIT%LVTO,'(A/)')        ' -->'
!!
!! Start vtk "UnstructuredGrid" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '<VTKFile type="UnstructuredGrid" version="0.1" byte_order="LittleEndian">'
              WRITE (IO_UNIT%LVTO,'(A)') '<UnstructuredGrid>'
!!
!! Start vtk "Piece" data.
!!
              WRITE (BUFFER1,'(I8)') NNodes;  I1 = SCAN( BUFFER1, "123456789" )
              WRITE (BUFFER2,'(I8)') NElems;  I2 = SCAN( BUFFER2, "123456789" )
              WRITE (IO_UNIT%LVTO,'(A)') '<Piece NumberOfPoints="'//BUFFER1(I1:)//'" NumberOfCells="'//BUFFER2(I2:)//'">'
!!
!! Start vtk "Points" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '<Points>'
!!
!! Write initial nodal point coordinates for the "Points" data.
!!
              WRITE (IO_UNIT%LVTO,'(2X,A)') '<DataArray type="Float32" Name="Position" NumberOfComponents="3" format="ascii">'
              WRITE (IO_UNIT%LVTO,'((6(1PE15.7)))') ( (/REAL(MOTION(NPTUSED(i))%Px,KIND(0E0)),
     &                                                  REAL(MOTION(NPTUSED(i))%Py,KIND(0E0)),
     &                                                  REAL(MOTION(NPTUSED(i))%Pz,KIND(0E0)) /), i = 1,NNodes)
              WRITE (IO_UNIT%LVTO,'(2X,A)') '</DataArray>'
!!
!! End vtk "Points" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '</Points>'
!!
!! Start vtk "Cells" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '<Cells>'
!!
!! Write vtk cell data (cell-connectivities=n-1, cell-tuple-offsets=n, cell-type=1).
!!
              WRITE (IO_UNIT%LVTO,'(2X,A)') '<DataArray type="Int32" Name="connectivity" NumberOfComponents="1" format="ascii">'
              WRITE (IO_UNIT%LVTO,'((6X,8I10))') (n-1, n = 1,NElems) 
              WRITE (IO_UNIT%LVTO,'(2X,A)') '</DataArray>'

              WRITE (IO_UNIT%LVTO,'(2X,A)') '<DataArray type="Int32" Name="offsets" NumberOfComponents="1" format="ascii">'
              WRITE (IO_UNIT%LVTO,'((6X,8I10))') (n, n = 1,NElems) 
              WRITE (IO_UNIT%LVTO,'(2X,A)') '</DataArray>'

              WRITE (IO_UNIT%LVTO,'(2X,A)') '<DataArray type="UInt8" Name="types" NumberOfComponents="1" format="ascii">'
              WRITE (IO_UNIT%LVTO,'((6X,28I3))') (1, n = 1,NElems) 
              WRITE (IO_UNIT%LVTO,'(2X,A)') '</DataArray>'
!!
!! End vtk "Cells" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '</Cells>'
!!
!! Start vtk "PointData" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '<PointData Vectors="Velocity">'
!!
!! Write nodal point based motion data to VTK Data File.
!!
              WRITE (IO_UNIT%LVTO,'(2X,A)') '<DataArray type="Float32" Name="Velocity" NumberOfComponents="3" format="ascii">'
              WRITE (IO_UNIT%LVTO,'((6(1PE15.7)))') ( (/REAL(MOTION(NPTUSED(i))%Vx,KIND(0E0)), 
     &                                                  REAL(MOTION(NPTUSED(i))%Vy,KIND(0E0)), 
     &                                                  REAL(MOTION(NPTUSED(i))%Vz,KIND(0E0)) /), i = 1,NNodes)
              WRITE (IO_UNIT%LVTO,'(2X,A)') '</DataArray>'
!!
!! End vtk "PointData" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '</PointData>'
!!
!! Start vtk "CellData" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '<CellData Scalars="Material">'
!!
!! Write element-based (cell) material number data to VTK Data File.
!!
              WRITE (IO_UNIT%LVTO,'(2X,A)')'<DataArray type="Int32" Name="Material" NumberOfComponents="1" format="ascii">'
              WRITE (IO_UNIT%LVTO,'((6X,8I10))') (NUMMT+M, n = 1,NElems)
              WRITE (IO_UNIT%LVTO,'(2X,A)')'</DataArray>'
!!
!! End vtk "CellData" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '</CellData>'
!!
!! End vtk "Piece" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '</Piece>'
!!
!! End vtk "UnstructuredGrid" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '</UnstructuredGrid>'
!!
!! End vtk "VTKFile" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '</VTKFile>'
!!
              CLOSE (UNIT=IO_UNIT%LVTO, STATUS='KEEP')

            ENDIF
          ENDIF
        ENDDO
!!
!! Now, write segment set files.
!!
        DO M = 1,NUMSS
!!
!! The function SEGMENTS_AND_NODES_USED(*) gen's nodal-points-used array NPTUSED, 
!! segments-used array NELUSED and vtk output-index translation array NPTNOWI for 
!! this segment set. If segment set M is not empty, the function returns 1, else 0. 
!!
          IF (SEGMENTS_AND_NODES_USED(M) .GT. 0) THEN
            WRITE (PVTO,'(I4.4)') NUMNS + M
!!
!! Open new VTK Data File.
!!
            IOERROR = .TRUE.
            OPEN
     &        (
     &        UNIT    =  IO_UNIT%LVTO,
     &        FILE    = 'fmavto.mss'//PVTO//'.vtu',
     &        STATUS  = 'UNKNOWN',
     &        FORM    = 'FORMATTED',
     &        ERR     =  300
     &        )
            IOERROR = .FALSE.
!!
!! Fatal error exit for failed OPEN operation.
!!
 300        IF (IOERROR) THEN
              CALL USER_MESSAGE
     &          (
     &          MSGL//'FATAL'//
     &          MSGL//'WRITE_VTK_DATA_FILE.001.03'//
     &          MSGL//'Unable To Execute OPEN On: '//'fmavto.mss'//PVTO//'.vtu'
     &          )
            ELSE
!!
!! Initialize vtk xml data file.
!!
              WRITE (IO_UNIT%LVTO,'(A/)') '<?xml version="1.0"?>'
!!
!! Analysis QA information.
!!
              WRITE (IO_UNIT%LVTO,'(A )') '<!--'
              WRITE (IO_UNIT%LVTO,'(A )') '   Title: '//TRIM(JOB_ID_RECORD%CURRENT%TITLE)
              WRITE (IO_UNIT%LVTO,'(A )') ' Program: '//JOB_ID_RECORD%PROGRAM
              WRITE (IO_UNIT%LVTO,'(A )') ' Version: '//JOB_ID_RECORD%VERSION
              WRITE (IO_UNIT%LVTO,'(A )') '    Date: '//JOB_ID_RECORD%CURRENT%DATE
              WRITE (IO_UNIT%LVTO,'(A )') '    Time: '//JOB_ID_RECORD%CURRENT%TIME
              WRITE (IO_UNIT%LVTO,'(A/)') ' -->'
!!
!! Current time step, cycle number, segment set user's ID and segment set user's label.
!!
              WRITE (IO_UNIT%LVTO,'(A )')        '<!--'
              WRITE (IO_UNIT%LVTO,'(A,1PE15.7)') '   Problem Time: ',REAL(TIME%Total,KIND(0E0))
              WRITE (IO_UNIT%LVTO,'(A,I8)')      '   Cycle Number: ',TIME%Step
              WRITE (IO_UNIT%LVTO,'(A,I8)')      ' Segment Set ID: ',SEGMENT_SET(M)%SetID
              WRITE (IO_UNIT%LVTO,'(A,A)')       '  Seg Set Label: ',SEGMENT_SET(M)%LABEL
              WRITE (IO_UNIT%LVTO,'(A/)')        ' -->'
!!
!! Start vtk "UnstructuredGrid" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '<VTKFile type="UnstructuredGrid" version="0.1" byte_order="LittleEndian">'
              WRITE (IO_UNIT%LVTO,'(A)') '<UnstructuredGrid>'
!!
!! Start vtk "Piece" data.
!!
              WRITE (BUFFER1,'(I8)') NNodes;  I1 = SCAN( BUFFER1, "123456789" )
              WRITE (BUFFER2,'(I8)') NElems;  I2 = SCAN( BUFFER2, "123456789" )
              WRITE (IO_UNIT%LVTO,'(A)') '<Piece NumberOfPoints="'//BUFFER1(I1:)//'" NumberOfCells="'//BUFFER2(I2:)//'">'
!!
!! Start vtk "Points" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '<Points>'
!!
!! Write initial nodal point coordinates for the "Points" data.
!!
              WRITE (IO_UNIT%LVTO,'(2X,A)') '<DataArray type="Float32" Name="Position" NumberOfComponents="3" format="ascii">'
              WRITE (IO_UNIT%LVTO,'((6(1PE15.7)))') ( (/REAL(MOTION(NPTUSED(i))%Px,KIND(0E0)),
     &                                                  REAL(MOTION(NPTUSED(i))%Py,KIND(0E0)),
     &                                                  REAL(MOTION(NPTUSED(i))%Pz,KIND(0E0)) /), i = 1,NNodes)
              WRITE (IO_UNIT%LVTO,'(2X,A)') '</DataArray>'
!!
!! End vtk "Points" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '</Points>'
!!
!! Start vtk "Cells" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '<Cells>'
!!
!! Write vtk cell data (cell-connectivities, cell-tuple-offsets, cell-types).
!!
              WRITE (IO_UNIT%LVTO,'(2X,A)') '<DataArray type="Int32" Name="connectivity" NumberOfComponents="1" format="ascii">'
              WRITE (IO_UNIT%LVTO,'((6X,8I10))') (NTUPLE(1:SEGMENT_N_TUPLE(NELUSED(n))), n = 1,NElems) 
              WRITE (IO_UNIT%LVTO,'(2X,A)') '</DataArray>'

              WRITE (IO_UNIT%LVTO,'(2X,A)') '<DataArray type="Int32" Name="offsets" NumberOfComponents="1" format="ascii">'
              WRITE (IO_UNIT%LVTO,'((6X,8I10))') (SEGMENT_VTK_OFFSET(NELUSED(n),n), n = 1,NElems) 
              WRITE (IO_UNIT%LVTO,'(2X,A)') '</DataArray>'

              WRITE (IO_UNIT%LVTO,'(2X,A)') '<DataArray type="UInt8" Name="types" NumberOfComponents="1" format="ascii">'
              WRITE (IO_UNIT%LVTO,'((6X,28I3))') (SEGMENT_VTK_TYPE(NELUSED(n)), n = 1,NElems) 
              WRITE (IO_UNIT%LVTO,'(2X,A)') '</DataArray>'
!!
!! End vtk "Cells" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '</Cells>'
!!
!! Start vtk "PointData" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '<PointData Vectors="Velocity">'
!!
!! Write nodal point based motion data to VTK Data File.
!!
              WRITE (IO_UNIT%LVTO,'(2X,A)') '<DataArray type="Float32" Name="Velocity" NumberOfComponents="3" format="ascii">'
              WRITE (IO_UNIT%LVTO,'((6(1PE15.7)))') ( (/REAL(MOTION(NPTUSED(i))%Vx,KIND(0E0)), 
     &                                                  REAL(MOTION(NPTUSED(i))%Vy,KIND(0E0)), 
     &                                                  REAL(MOTION(NPTUSED(i))%Vz,KIND(0E0)) /), i = 1,NNodes)
              WRITE (IO_UNIT%LVTO,'(2X,A)') '</DataArray>'
!!
!! End vtk "PointData" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '</PointData>'
!!
!! Start vtk "CellData" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '<CellData Scalars="Material">'
!!
!! Write element-based (cell) material number data to VTK Data File.
!!
              WRITE (IO_UNIT%LVTO,'(2X,A)')'<DataArray type="Int32" Name="Material" NumberOfComponents="1" format="ascii">'
              WRITE (IO_UNIT%LVTO,'((6X,8I10))') (NUMMT+NUMNS+M, n = 1,NElems)
              WRITE (IO_UNIT%LVTO,'(2X,A)')'</DataArray>'
!!
!! End vtk "CellData" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '</CellData>'
!!
!! End vtk "Piece" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '</Piece>'
!!
!! End vtk "UnstructuredGrid" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '</UnstructuredGrid>'
!!
!! End vtk "VTKFile" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '</VTKFile>'
!!
              CLOSE (UNIT=IO_UNIT%LVTO, STATUS='KEEP')

            ENDIF
          ENDIF
        ENDDO
!!
!! Now, write wedge-set files. (Wedge-sets are generated internally based
!! on each specified solid-to-solid tied interface (Keyword: MPCON4).
!!
        DO M = 1,NUMC4
!!
!! The function WEDGES_AND_NODES_USED(*) gen's nodal-points-used array NPTUSED,
!! wedges-used array NELUSED and vtk output-index translation array NPTNOWI for
!! this wedge set. If wedge set M is not empty, the function returns 1, else 0.
!!
          IF (WEDGES_AND_NODES_USED(M) .GT. 0) THEN
            WRITE (PVTO,'(I4.4)') NUMNS + NUMSS + M
!!
!! Open new VTK Data File.
!!
            IOERROR = .TRUE.
            OPEN
     &        (
     &        UNIT    =  IO_UNIT%LVTO,
     &        FILE    = 'fmavto.mws'//PVTO//'.vtu',
     &        STATUS  = 'UNKNOWN',
     &        FORM    = 'FORMATTED',
     &        ERR     =  400
     &        )
            IOERROR = .FALSE.
!!
!! Fatal error exit for failed OPEN operation.
!!
 400        IF (IOERROR) THEN
              CALL USER_MESSAGE
     &          (
     &          MSGL//'FATAL'//
     &          MSGL//'WRITE_VTK_DATA_FILE.001.03'//
     &          MSGL//'Unable To Execute OPEN On: '//'fmavto.mws'//PVTO//'.vtu'
     &          )
            ELSE
!!
!! Initialize vtk xml data file.
!!
              WRITE (IO_UNIT%LVTO,'(A/)') '<?xml version="1.0"?>'
!!
!! Analysis QA information.
!!
              WRITE (IO_UNIT%LVTO,'(A )') '<!--'
              WRITE (IO_UNIT%LVTO,'(A )') '   Title: '//TRIM(JOB_ID_RECORD%CURRENT%TITLE)
              WRITE (IO_UNIT%LVTO,'(A )') ' Program: '//JOB_ID_RECORD%PROGRAM
              WRITE (IO_UNIT%LVTO,'(A )') ' Version: '//JOB_ID_RECORD%VERSION
              WRITE (IO_UNIT%LVTO,'(A )') '    Date: '//JOB_ID_RECORD%CURRENT%DATE
              WRITE (IO_UNIT%LVTO,'(A )') '    Time: '//JOB_ID_RECORD%CURRENT%TIME
              WRITE (IO_UNIT%LVTO,'(A/)') ' -->'
!!
!! Current time step, cycle number, wedge set user's ID and wedge set user's label.
!!
              WRITE (IO_UNIT%LVTO,'(A )')        '<!--'
              WRITE (IO_UNIT%LVTO,'(A,1PE15.7)') '   Problem Time: ',REAL(TIME%Total,KIND(0E0))
              WRITE (IO_UNIT%LVTO,'(A,I8)')      '   Cycle Number: ',TIME%Step
              WRITE (IO_UNIT%LVTO,'(A,I8)')      '   MPCON4    ID: ',SOLID_SOLID_INTERFACE(M)%MPCID
!!            WRITE (IO_UNIT%LVTO,'(A,A)')       '   MPCON4 Label: ',SOLID_SOLID_INTERFACE(M)%LABEL
              WRITE (IO_UNIT%LVTO,'(A/)')        ' -->'
!!
!!***************************************************************************
!! To avoid any output buffer et cetera limitations, break output writes
!! into smaller batches of IBCOUNT each.  (Overflows have occurred already.)
!! Element(Cell) Blocking: L... counter items.
!! Nodal(Points) Blocking: N... counter items.
!!
          LBCOUNT=IBCOUNT;  LBLOCKS=NElems/LBCOUNT;  LREMAIN=NElems-LBCOUNT*LBLOCKS

          NBCOUNT=IBCOUNT;  NBLOCKS=NNodes/NBCOUNT;  NREMAIN=NNodes-NBCOUNT*NBLOCKS
!!
!! For now, this blocking is used only for the whole-mesh write. It may need 
!! to be extended if any one material block causes the executable to blow a
!! gasket.
!!***************************************************************************
!!
!! Start vtk "UnstructuredGrid" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '<VTKFile type="UnstructuredGrid" version="0.1" byte_order="LittleEndian">'
              WRITE (IO_UNIT%LVTO,'(A)') '<UnstructuredGrid>'
!!
!! Start vtk "Piece" data.
!!
              WRITE (BUFFER1,'(I8)') NNodes;  I1 = SCAN( BUFFER1, "123456789" )
              WRITE (BUFFER2,'(I8)') NElems;  I2 = SCAN( BUFFER2, "123456789" )
              WRITE (IO_UNIT%LVTO,'(A)') '<Piece NumberOfPoints="'//BUFFER1(I1:)//'" NumberOfCells="'//BUFFER2(I2:)//'">'
!!
!! Start vtk "Points" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '<Points>'
!!
!! Write time(0.0) nodal point coordinates for the "Points" data.
!!
              WRITE (IO_UNIT%LVTO,'(2X,A)') '<DataArray type="Float32" Name="Position" NumberOfComponents="3" format="ascii">'
              Nbgn = 1
              Nend = NREMAIN
              DO i = 1,NBLOCKS+1
                WRITE (IO_UNIT%LVTO,'((6(1PE15.7)))') ( (/REAL(WEDGE_NP_COORDINATE(N,1),KIND(0E0)), 
     &           REAL(WEDGE_NP_COORDINATE(N,2),KIND(0E0)),REAL(WEDGE_NP_COORDINATE(N,3),KIND(0E0)) /), N = Nbgn,Nend)
                Nbgn = Nend + 1
                Nend = Nend + NBCOUNT
              ENDDO
              WRITE (IO_UNIT%LVTO,'(2X,A)') '</DataArray>'
!!
!! End vtk "Points" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '</Points>'
!!
!! Start vtk "Cells" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '<Cells>'
!!
!! Write vtk cell data (cell-connectivities, cell-tuple-offsets, cell-types).
!!
              WRITE (IO_UNIT%LVTO,'(2X,A)') '<DataArray type="Int32" Name="connectivity" NumberOfComponents="1" format="ascii">'
              Lbgn = 1
              Lend = LREMAIN
              DO i = 1,LBLOCKS+1
                WRITE (IO_UNIT%LVTO,'((6X,8I10))') (NTUPLE(1:WEDGE_N_TUPLE(L)), L = Lbgn,Lend) 
                Lbgn = Lend + 1
                Lend = Lend + LBCOUNT
              ENDDO
              WRITE (IO_UNIT%LVTO,'(2X,A)') '</DataArray>'

              WRITE (IO_UNIT%LVTO,'(2X,A)') '<DataArray type="Int32" Name="offsets" NumberOfComponents="1" format="ascii">'
              Lbgn = 1
              Lend = LREMAIN
              DO i = 1,LBLOCKS+1
                WRITE (IO_UNIT%LVTO,'((6X,8I10))') (WEDGE_VTK_OFFSET(L,L), L = Lbgn,Lend) 
                Lbgn = Lend + 1
                Lend = Lend + LBCOUNT
              ENDDO
              WRITE (IO_UNIT%LVTO,'(2X,A)') '</DataArray>'



              WRITE (IO_UNIT%LVTO,'(2X,A)') '<DataArray type="UInt8" Name="types" NumberOfComponents="1" format="ascii">'
              Lbgn = 1
              Lend = LREMAIN
              DO i = 1,LBLOCKS+1
                WRITE (IO_UNIT%LVTO,'((6X,28I3))') (WEDGE_VTK_TYPE(L), L = Lbgn,Lend) 
                Lbgn = Lend + 1
                Lend = Lend + LBCOUNT
              ENDDO
              WRITE (IO_UNIT%LVTO,'(2X,A)') '</DataArray>'
!!
!! End vtk "Cells" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '</Cells>'
!!
!! Start vtk "PointData" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '<PointData Vectors="Velocity">'
!!
!! Write nodal point based motion data to VTK Data File.
!!
              WRITE (IO_UNIT%LVTO,'(2X,A)') '<DataArray type="Float32" Name="Velocity" NumberOfComponents="3" format="ascii">'
              Nbgn = 1
              Nend = NREMAIN
              DO i = 1,NBLOCKS+1
              WRITE (IO_UNIT%LVTO,'((6(1PE15.7)))') ( (/REAL(WEDGE_NP_VELOCITY(N,1),KIND(0E0)), 
     &          REAL(WEDGE_NP_VELOCITY(N,2),KIND(0E0)), REAL(WEDGE_NP_VELOCITY(N,3),KIND(0E0)) /), N = Nbgn,Nend)
                Nbgn = Nend + 1
                Nend = Nend + NBCOUNT
              ENDDO
              WRITE (IO_UNIT%LVTO,'(2X,A)') '</DataArray>'
!!
!! End vtk "PointData" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '</PointData>'
!!
!! Start vtk "CellData" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '<CellData Scalars="Material">'
!!
!! Write element-based (cell) material number data to VTK Data File.
!!
              WRITE (IO_UNIT%LVTO,'(2X,A)')'<DataArray type="Int32" Name="Material" NumberOfComponents="1" format="ascii">'
              Lbgn = 1
              Lend = LREMAIN
              DO i = 1,LBLOCKS+1
                WRITE (IO_UNIT%LVTO,'((6X,8I10))') (NUMMT+NUMNS+NUMSS+M, L = Lbgn,Lend)
                Lbgn = Lend + 1
                Lend = Lend + LBCOUNT
              ENDDO
              WRITE (IO_UNIT%LVTO,'(2X,A)')'</DataArray>'
!!
!! End vtk "CellData" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '</CellData>'
!!
!! End vtk "Piece" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '</Piece>'
!!
!! End vtk "UnstructuredGrid" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '</UnstructuredGrid>'
!!
!! End vtk "VTKFile" data.
!!
              WRITE (IO_UNIT%LVTO,'(A)') '</VTKFile>'
!!
              CLOSE (UNIT=IO_UNIT%LVTO, STATUS='KEEP')

            ENDIF
          ENDIF
        ENDDO
!!
!! =========THIRD=============================================================
!! Write a *.pvd file to allow ParaView to identify the mesh, node-set,
!! side-set and wedge-set files as distinct "Parts" for the "Extract 
!! Parts" filter.
!! 
!! Open new VTK Data File.
!!
        IOERROR = .TRUE.
        OPEN
     &    (
     &    UNIT    =  IO_UNIT%LVTO,
     &    FILE    = 'fmavto.mesh.pvd',
     &    STATUS  = 'UNKNOWN',
     &    FORM    = 'FORMATTED',
     &    ERR     =  500
     &    )
        IOERROR = .FALSE.
!!
!! Fatal error exit for failed OPEN operation.
!!
 500    IF (IOERROR) THEN
          CALL USER_MESSAGE
     &      (
     &      MSGL//'FATAL'//
     &      MSGL//'WRITE_VTK_DATA_FILE.001.04'//
     &      MSGL//'Unable To Execute OPEN On: '//'fmavto.mesh.pvd'
     &      )
        ELSE
          WRITE (IO_UNIT%LVTO,'(A/)') '<?xml version="1.0"?>'
!!
!! Analysis QA information.
!!
          WRITE (IO_UNIT%LVTO,'(A )') '<!--'
          WRITE (IO_UNIT%LVTO,'(A )') '   Title: '//TRIM(JOB_ID_RECORD%CURRENT%TITLE)
          WRITE (IO_UNIT%LVTO,'(A )') ' Program: '//JOB_ID_RECORD%PROGRAM
          WRITE (IO_UNIT%LVTO,'(A )') ' Version: '//JOB_ID_RECORD%VERSION
          WRITE (IO_UNIT%LVTO,'(A )') '    Date: '//JOB_ID_RECORD%CURRENT%DATE
          WRITE (IO_UNIT%LVTO,'(A )') '    Time: '//JOB_ID_RECORD%CURRENT%TIME
          WRITE (IO_UNIT%LVTO,'(A/)') ' -->'
!!
!! Current time step, cycle number, segment set user's ID and segment set user's label.
!!
          WRITE (IO_UNIT%LVTO,'(A )')        '<!--'
          WRITE (IO_UNIT%LVTO,'(A,1PE15.7)') '   Problem Time: ',REAL(TIME%Total,KIND(0E0))
          WRITE (IO_UNIT%LVTO,'(A,I8)')      '   Cycle Number: ',TIME%Step
          WRITE (IO_UNIT%LVTO,'(A/)')        ' -->'
!!
!! Start vtk "Collection" data.
!!
          WRITE (IO_UNIT%LVTO,'(A)') '<VTKFile type="Collection" version="0.1" byte_order="LittleEndian">'
          WRITE (IO_UNIT%LVTO,'(A)') '  <Collection>'
          WRITE (IO_UNIT%LVTO,'(A)') '    <DataSet part="0000" file="fmavto.msh0000.vtu" name="The Mesh"/>'

          NNSMAX = 0
          DO M = 1,NUMNS
            NNSMAX = MAX( NNSMAX, NODE_SET(M)%SetID )
          ENDDO
          DO M = 1,NUMSS
            NNSMAX = MAX( NNSMAX, SEGMENT_SET(M)%SetID )
          ENDDO
          DO M = 1,NUMC4
            NNSMAX = MAX( NNSMAX, SOLID_SOLID_INTERFACE(M)%MPCID )
          ENDDO
          WRITE (BUFFER1,'(I8)') NNSMAX;  I1 = SCAN( BUFFER1, "123456789" ) 

          DO M = 1,NUMNS
            WRITE (PVTO,'(I4.4)') M
            File_Name(1:) = 'fmavto.mns'//PVTO//'.vtu'
            WRITE (BUFFER1,'(I8.8)') NODE_SET(M)%SetID
            Part_Name(1:) = 'NSet:'//BUFFER1(I1:)//' Label:'//TRIM(NODE_SET(M)%LABEL)
            WRITE (IO_UNIT%LVTO,'(A)') '    <DataSet part="'//PVTO//'" file="'//TRIM(File_Name)//'" name="'//TRIM(Part_Name)//'"/>'
          ENDDO

          DO M = 1,NUMSS
            WRITE (PVTO,'(I4.4)') NUMNS + M
            File_Name(1:) = 'fmavto.mss'//PVTO//'.vtu'
            WRITE (BUFFER1,'(I8.8)') SEGMENT_SET(M)%SetID
            Part_Name(1:) = 'SSet:'//BUFFER1(I1:)//' Label:'//TRIM(SEGMENT_SET(M)%LABEL)
            WRITE (IO_UNIT%LVTO,'(A)') '    <DataSet part="'//PVTO//'" file="'//TRIM(File_Name)//'" name="'//TRIM(Part_Name)//'"/>'
          ENDDO

          DO M = 1,NUMC4
            WRITE (PVTO,'(I4.4)') NUMNS + NUMSS + M
            File_Name(1:) = 'fmavto.mws'//PVTO//'.vtu'
            WRITE (BUFFER1,'(I8.8)') SOLID_SOLID_INTERFACE(M)%MPCID
            Part_Name(1:) = 'WSet:'//BUFFER1(I1:)//' Label:'//' MPCON4'  !  TRIM(SOLID_SOLID_INTERFACE(M)%LABEL)
            WRITE (IO_UNIT%LVTO,'(A)') '    <DataSet part="'//PVTO//'" file="'//TRIM(File_Name)//'" name="'//TRIM(Part_Name)//'"/>'
          ENDDO

          WRITE (IO_UNIT%LVTO,'(A)') '  </Collection>'
          WRITE (IO_UNIT%LVTO,'(A)') '</VTKFile>'

          CLOSE (UNIT=IO_UNIT%LVTO, STATUS='KEEP')
        ENDIF

        FIRST = .FALSE.
      ENDIF
!!
!!############################################################################
!! PART 2. RESULTS FOR THIS TIME STEP.
!!
!! Build unique extension "nnn" for next VTK Data File set: fmavto.tnnn.pvtu
!!
      IVTO = IVTO + 1
      WRITE (CVTO,'(I4.4)') IVTO
      CVTO(1:1) = 't'
      TIME_VALUES(IVTO) = TIME%Total
!!
!! =========FIRST=============================================================
!! Use VTK's parallel file-per-processor-decomposition-read-each-piece feature 
!! to create a "master" file of the entire finite element model decomposed into 
!! vtk input pieces by material.
!!
!! Open new VTK Data File.
!!
!!@   IOERROR = .TRUE.
!!@   OPEN
!!@  &  (
!!@  &  UNIT    =  IO_UNIT%LVTO,
!!@  &  FILE    = 'fmavto.'//CVTO//'.pvtu',
!!@  &  STATUS  = 'UNKNOWN',
!!@  &  FORM    = 'FORMATTED',
!!@  &  ERR     =  600
!!@  &  )
!!@   IOERROR = .FALSE.
!!
!! Fatal error exit for failed OPEN operation.
!!
!600  IF (IOERROR) THEN
!!@     CALL USER_MESSAGE
!!@  &    (
!!@  &    MSGL//'FATAL'//
!!@  &    MSGL//'WRITE_VTK_DATA_FILE.001.05'//
!!@  &    MSGL//'Unable To Execute OPEN On: '//'fmavto.'//CVTO//'.pvtu'
!!@  &    )
!!@   ELSE
!!
!! Initialize vtk xml data file.
!!
!!@     WRITE (IO_UNIT%LVTO,'(A/)') '<?xml version="1.0"?>'
!!
!! Analysis QA information.
!!
!!@     WRITE (IO_UNIT%LVTO,'(A )') '<!--'
!!@     WRITE (IO_UNIT%LVTO,'(A )') '   Title: '//TRIM(JOB_ID_RECORD%CURRENT%TITLE)
!!@     WRITE (IO_UNIT%LVTO,'(A )') ' Program: '//JOB_ID_RECORD%PROGRAM
!!@     WRITE (IO_UNIT%LVTO,'(A )') ' Version: '//JOB_ID_RECORD%VERSION
!!@     WRITE (IO_UNIT%LVTO,'(A )') '    Date: '//JOB_ID_RECORD%CURRENT%DATE
!!@     WRITE (IO_UNIT%LVTO,'(A )') '    Time: '//JOB_ID_RECORD%CURRENT%TIME
!!@     WRITE (IO_UNIT%LVTO,'(A/)') ' -->'
!!
!! Current time step and cycle number.
!!
!!@     WRITE (IO_UNIT%LVTO,'(A )')        '<!--'
!!@     WRITE (IO_UNIT%LVTO,'(A,1PE15.7)') ' Problem Time: ',REAL(TIME%Total,KIND(0E0))
!!@     WRITE (IO_UNIT%LVTO,'(A,I8)')      ' Cycle Number: ',TIME%Step
!!@     WRITE (IO_UNIT%LVTO,'(A/)')        ' -->'
!!
!! Start vtk "PUnstructuredGrid" data template.
!!
!!@     WRITE (IO_UNIT%LVTO,'(A)') '<VTKFile type="PUnstructuredGrid" version="0.1" byte_order="LittleEndian">'
!!@     WRITE (IO_UNIT%LVTO,'(A)') '<PUnstructuredGrid GhostLevel="0">'
!!
!! Write vtk "PPoints" data template.
!!
!!@     WRITE (IO_UNIT%LVTO,'(A)')    '<PPoints>'
!!@     WRITE (IO_UNIT%LVTO,'(2X,A)') '<PDataArray type="Float32" Name="Position" NumberOfComponents="3"/>'
!!@     WRITE (IO_UNIT%LVTO,'(A)')    '</PPoints>'
!!
!! Write vtk "PCells" data template.
!!
!!@     WRITE (IO_UNIT%LVTO,'(A)')    '<PCells>'
!!@     WRITE (IO_UNIT%LVTO,'(2X,A)') '<PDataArray type="Int32" Name="connectivity" NumberOfComponents="1"/>'
!!@     WRITE (IO_UNIT%LVTO,'(2X,A)') '<PDataArray type="Int32" Name="offsets"      NumberOfComponents="1"/>'
!!@     WRITE (IO_UNIT%LVTO,'(2X,A)') '<PDataArray type="UInt8" Name="types"        NumberOfComponents="1"/>'
!!@     WRITE (IO_UNIT%LVTO,'(A)')    '</PCells>'
!!
!! Write vtk "PPointData" data template.
!!
!!@     WRITE (IO_UNIT%LVTO,'(A)')    '<PPointData Vectors="Velocity">'
!!@     WRITE (IO_UNIT%LVTO,'(2X,A)') '<PDataArray type="Float32" Name="Displacement" NumberOfComponents="3"/>'
!!@     WRITE (IO_UNIT%LVTO,'(2X,A)') '<PDataArray type="Float32" Name="Velocity"     NumberOfComponents="3"/>'
!!@     WRITE (IO_UNIT%LVTO,'(2X,A)') '<PDataArray type="Float32" Name="Acceleration" NumberOfComponents="3"/>'
!!@     WRITE (IO_UNIT%LVTO,'(A)')    '</PPointData>'
!!
!! Write vtk "PCellData" data template.
!!
!!@     WRITE (IO_UNIT%LVTO,'(A)')    '<PCellData Tensors="Stress" Scalars="Material">'
!!@     WRITE (IO_UNIT%LVTO,'(2X,A)') '<PDataArray type="Float32" Name="Stress"           NumberOfComponents="9"/>'
!!@     WRITE (IO_UNIT%LVTO,'(2X,A)') '<PDataArray type="Float32" Name="Effective_Stress" NumberOfComponents="1"/>'
!!@     WRITE (IO_UNIT%LVTO,'(2X,A)') '<PDataArray type="Float32" Name="Pressure"         NumberOfComponents="1"/>'
!!@     WRITE (IO_UNIT%LVTO,'(2X,A)') '<PDataArray type="Float32" Name="Bulk_Strain"      NumberOfComponents="1"/>'
!!@     WRITE (IO_UNIT%LVTO,'(2X,A)') '<PDataArray type="Float32" Name="Strain_Energy"    NumberOfComponents="1"/>'
!!@     WRITE (IO_UNIT%LVTO,'(2X,A)') '<PDataArray type="Int32"   Name="Material"         NumberOfComponents="1"/>'
!!@     WRITE (IO_UNIT%LVTO,'(A)')    '</PCellData>'
!!
!! Write vtk "Piece" source-file specification by material.
!!
!!@     DO M = 1,NUMMT
!!@       IF (MATERIAL(M)%NElems .GT. 0) THEN
!!@         WRITE (PVTO,'(I4.4)') M
!!@         PVTO(1:1) = 'm'
!!@         WRITE (IO_UNIT%LVTO,'(A)') '<Piece Source="fmavto.'//PVTO//'.'//CVTO//'.vtu"/>'
!!@       ENDIF
!!@     ENDDO
!!
!! End vtk "PUnstructuredGrid" data.
!!
!!@     WRITE (IO_UNIT%LVTO,'(A)') '</PUnstructuredGrid>'
!!
!! End vtk parallel "VTKFile" data template.
!!
!!@     WRITE (IO_UNIT%LVTO,'(A)') '</VTKFile>'
!!
!! Write as an xml comment block using the vtk "Piece" source-file specification 
!! by material with the user's label appended.
!!
!!@     WRITE (IO_UNIT%LVTO,'(/A)') '<!--'
!!@     DO M = 1,NUMMT
!!@       IF (MATERIAL(M)%NElems .GT. 0) THEN
!!@         WRITE (PVTO,'(I4.4)') M
!!@         PVTO(1:1) = 'm'
!!@         WRITE (IO_UNIT%LVTO,'(A)') ' Piece Source="fmavto.'//PVTO//'.'//CVTO//'.vtu"  <==  '//MATERIAL(M)%Label
!!@       ENDIF
!!@     ENDDO
!!@     WRITE (IO_UNIT%LVTO,'(A)') ' -->'
!!
!! Close and save file.
!!
!!@     CLOSE (UNIT=IO_UNIT%LVTO, STATUS='KEEP')
!!@   ENDIF
!!
!! =========SECOND============================================================
!! Write the individual vtk piece part files.
!!
      DO M = 1,NUMMT
!!
!! The function ELEMENTS_AND_NODES_USED(*) gen's nodal-points-used array NPTUSED, 
!! elements-used array NELUSED and vtk output-index translation array NPTNOWI for 
!! this material. If material M is used, the function returns 1, otherwise 0. 
!!
        IF (ELEMENTS_AND_NODES_USED(M) .GT. 0) THEN
          WRITE (PVTO,'(I4.4)') M
          PVTO(1:1) = 'm'
!!
!! Open new VTK Data File.
!!
          IOERROR = .TRUE.
          OPEN
     &      (
     &      UNIT    =  IO_UNIT%LVTO,
     &      FILE    = 'fmavto.'//PVTO//'.'//CVTO//'.vtu',
     &      STATUS  = 'UNKNOWN',
     &      FORM    = 'FORMATTED',
     &      ERR     =  700
     &      )
          IOERROR = .FALSE.
!!
!! Fatal error exit for failed OPEN operation.
!!
 700      IF (IOERROR) THEN
            CALL USER_MESSAGE
     &        (
     &        MSGL//'FATAL'//
     &        MSGL//'WRITE_VTK_DATA_FILE.001.06'//
     &        MSGL//'Unable To Execute OPEN On: '//'fmavto.'//PVTO//'.'//CVTO//'.vtu'
     &        )
          ELSE
!!
!! Initialize vtk xml data file.
!!
            WRITE (IO_UNIT%LVTO,'(A/)') '<?xml version="1.0"?>'
!!
!! Analysis QA information.
!!
            WRITE (IO_UNIT%LVTO,'(A )') '<!--'
            WRITE (IO_UNIT%LVTO,'(A )') '   Title: '//TRIM(JOB_ID_RECORD%CURRENT%TITLE)
            WRITE (IO_UNIT%LVTO,'(A )') ' Program: '//JOB_ID_RECORD%PROGRAM
            WRITE (IO_UNIT%LVTO,'(A )') ' Version: '//JOB_ID_RECORD%VERSION
            WRITE (IO_UNIT%LVTO,'(A )') '    Date: '//JOB_ID_RECORD%CURRENT%DATE
            WRITE (IO_UNIT%LVTO,'(A )') '    Time: '//JOB_ID_RECORD%CURRENT%TIME
            WRITE (IO_UNIT%LVTO,'(A/)') ' -->'
!!
!! Current time step, cycle number, material user's ID and material label.
!!
            WRITE (IO_UNIT%LVTO,'(A )')        '<!--'
            WRITE (IO_UNIT%LVTO,'(A,1PE15.7)') '   Problem Time: ',REAL(TIME%Total,KIND(0E0))
            WRITE (IO_UNIT%LVTO,'(A,I8)')      '   Cycle Number: ',TIME%Step
            WRITE (IO_UNIT%LVTO,'(A,I8)')      ' Material MatID: ',MATERIAL(M)%MatID
            WRITE (IO_UNIT%LVTO,'(A,A)')       ' Material Label: ',MATERIAL(M)%LABEL
            WRITE (IO_UNIT%LVTO,'(A/)')        ' -->'
!!
!!***************************************************************************
!! To avoid any output buffer et cetera limitations, break output writes
!! into smaller batches of IBCOUNT each.  (Overflows have occurred already.)
!! Element(Cell) Blocking: L... counter items.
!! Nodal(Points) Blocking: N... counter items.
!!
            NElems = MATERIAL(M)%NElems
            NNodes = MATERIAL(M)%NNodes

            LBCOUNT=IBCOUNT;  LBLOCKS=NElems/LBCOUNT;  LREMAIN=NElems-LBCOUNT*LBLOCKS

            NBCOUNT=IBCOUNT;  NBLOCKS=NNodes/NBCOUNT;  NREMAIN=NNodes-NBCOUNT*NBLOCKS
!!
!! For now, this blocking is used only for the whole-mesh write. It may need 
!! to be extended if any one material block causes the executable to blow a
!! gasket.
!!***************************************************************************
!!
!! Start vtk "UnstructuredGrid" data.
!!
            WRITE (IO_UNIT%LVTO,'(A)') '<VTKFile type="UnstructuredGrid" version="0.1" byte_order="LittleEndian">'
            WRITE (IO_UNIT%LVTO,'(A)') '<UnstructuredGrid>'
!!
!! Start vtk "Piece" data.
!!
            WRITE (BUFFER1,'(I8)') MATERIAL(M)%NNodes;  I1 = SCAN( BUFFER1, "123456789" )
            WRITE (BUFFER2,'(I8)') MATERIAL(M)%NElems;  I2 = SCAN( BUFFER2, "123456789" )
            WRITE (IO_UNIT%LVTO,'(A)') '<Piece NumberOfPoints="'//BUFFER1(I1:)//'" NumberOfCells="'//BUFFER2(I2:)//'">'
!!
!! Start vtk "Points" data.
!!
            WRITE (IO_UNIT%LVTO,'(A)') '<Points>'
!!
!! Write current nodal point coordinates for the "Points" data.
!!
            WRITE (IO_UNIT%LVTO,'(2X,A)') '<DataArray type="Float32" Name="Position" NumberOfComponents="3" format="ascii">'
            Nbgn = 1
            Nend = NREMAIN
            DO i = 1,NBLOCKS+1
              WRITE (IO_UNIT%LVTO,'((6(1PE15.7)))') ( (/REAL(MOTION(NPTUSED(N))%Px+MOTION(NPTUSED(N))%Ux,KIND(0E0)),
     &                                                  REAL(MOTION(NPTUSED(N))%Py+MOTION(NPTUSED(N))%Uy,KIND(0E0)),
     &                                                  REAL(MOTION(NPTUSED(N))%Pz+MOTION(NPTUSED(N))%Uz,KIND(0E0)) 
     &                                                  /), N = Nbgn,Nend)
              Nbgn = Nend + 1
              Nend = Nend + NBCOUNT
            ENDDO
            WRITE (IO_UNIT%LVTO,'(2X,A)') '</DataArray>'
!!
!! End vtk "Points" data.
!!
            WRITE (IO_UNIT%LVTO,'(A)') '</Points>'
!!
!! Start vtk "Cells" data.
!!
            WRITE (IO_UNIT%LVTO,'(A)') '<Cells>'
!!
!! Write vtk cell data (cell-connectivities, cell-tuple-offsets, cell-types).
!!
            WRITE (IO_UNIT%LVTO,'(2X,A)') '<DataArray type="Int32" Name="connectivity" NumberOfComponents="1" format="ascii">'
            Lbgn = 1
            Lend = LREMAIN
            DO i = 1,LBLOCKS+1
              WRITE (IO_UNIT%LVTO,'((6X,8I10))') (NTUPLE(1:ELEMENT_N_TUPLE(NELUSED(L))), L = Lbgn,Lend) 
              Lbgn = Lend + 1
              Lend = Lend + LBCOUNT
            ENDDO
            WRITE (IO_UNIT%LVTO,'(2X,A)') '</DataArray>'

            WRITE (IO_UNIT%LVTO,'(2X,A)') '<DataArray type="Int32" Name="offsets" NumberOfComponents="1" format="ascii">'
            Lbgn = 1
            Lend = LREMAIN
            DO i = 1,LBLOCKS+1
              WRITE (IO_UNIT%LVTO,'((6X,8I10))') (ELEMENT_VTK_OFFSET(NELUSED(L),L), L = Lbgn,Lend) 
              Lbgn = Lend + 1
              Lend = Lend + LBCOUNT
            ENDDO
            WRITE (IO_UNIT%LVTO,'(2X,A)') '</DataArray>'

            WRITE (IO_UNIT%LVTO,'(2X,A)') '<DataArray type="UInt8"  Name="types" NumberOfComponents="1" format="ascii">'
            Lbgn = 1
            Lend = LREMAIN
            DO i = 1,LBLOCKS+1
              WRITE (IO_UNIT%LVTO,'((6X,28I3))') (ELEMENT_VTK_TYPE(NELUSED(L)), L = Lbgn,Lend) 
              Lbgn = Lend + 1
              Lend = Lend + LBCOUNT
            ENDDO
            WRITE (IO_UNIT%LVTO,'(2X,A)') '</DataArray>'
!!
!! End vtk "Cells" data.
!!
            WRITE (IO_UNIT%LVTO,'(A)') '</Cells>'
!!
!! Start vtk "PointData" data.
!!
            WRITE (IO_UNIT%LVTO,'(A)') '<PointData Vectors="Velocity">'
!!
!! Write nodal point based motion data to VTK Data File.
!!
            WRITE (IO_UNIT%LVTO,'(2X,A)') '<DataArray type="Float32" Name="Displacement" NumberOfComponents="3" format="ascii">'
            Nbgn = 1
            Nend = NREMAIN
            DO i = 1,NBLOCKS+1
            WRITE (IO_UNIT%LVTO,'((6(1PE15.7)))') ( (/REAL(MOTION(NPTUSED(N))%Ux,KIND(0E0)), 
     &                                                REAL(MOTION(NPTUSED(N))%Uy,KIND(0E0)), 
     &                                                REAL(MOTION(NPTUSED(N))%Uz,KIND(0E0)) /), N = Nbgn,Nend)
              Nbgn = Nend + 1
              Nend = Nend + NBCOUNT
            ENDDO
            WRITE (IO_UNIT%LVTO,'(2X,A)') '</DataArray>'

            WRITE (IO_UNIT%LVTO,'(2X,A)') '<DataArray type="Float32" Name="Velocity" NumberOfComponents="3" format="ascii">'
            Nbgn = 1
            Nend = NREMAIN
            DO i = 1,NBLOCKS+1
            WRITE (IO_UNIT%LVTO,'((6(1PE15.7)))') ( (/REAL(MOTION(NPTUSED(N))%Vx,KIND(0E0)), 
     &                                                REAL(MOTION(NPTUSED(N))%Vy,KIND(0E0)), 
     &                                                REAL(MOTION(NPTUSED(N))%Vz,KIND(0E0)) /), N = Nbgn,Nend)
              Nbgn = Nend + 1
              Nend = Nend + NBCOUNT
            ENDDO
            WRITE (IO_UNIT%LVTO,'(2X,A)') '</DataArray>'

            WRITE (IO_UNIT%LVTO,'(2X,A)') '<DataArray type="Float32" Name="Acceleration" NumberOfComponents="3" format="ascii">'
            Nbgn = 1
            Nend = NREMAIN
            DO i = 1,NBLOCKS+1
            WRITE (IO_UNIT%LVTO,'((6(1PE15.7)))') ( (/REAL(MOTION(NPTUSED(N))%Ax,KIND(0E0)), 
     &                                                REAL(MOTION(NPTUSED(N))%Ay,KIND(0E0)), 
     &                                                REAL(MOTION(NPTUSED(N))%Az,KIND(0E0)) /), N = Nbgn,Nend)
              Nbgn = Nend + 1
              Nend = Nend + NBCOUNT
            ENDDO
            WRITE (IO_UNIT%LVTO,'(2X,A)') '</DataArray>'
!!
!! End vtk "PointData" data.
!!
            WRITE (IO_UNIT%LVTO,'(A)') '</PointData>'
!!
!! Start vtk "CellData" data.
!!
            WRITE (IO_UNIT%LVTO,'(A)') '<CellData Tensors="Stress" Scalars="Material">'
!!
!! Write element-based (cell) stress data to VTK Data File.
!! The retrieval function STRESS_DATA( element_n, component_i ) is used 
!! with the following stress-component retrieval pattern to produce the
!! the stress-component pattern expected by ParaView (PV):
!!                   ( 1 4 5 )   ( xx xy xz )   ( 0 1 2 )
!! Fma-3D Indices => ( 4 2 6 ) = ( yx yy yz ) = ( 3 4 5 ) <= PV Indices
!!                   ( 5 6 3 )   ( zx zy zz )   ( 6 7 8 )
!!
            WRITE(IO_UNIT%LVTO,'(2X,A)')'<DataArray type="Float32" Name="Stress" NumberOfComponents="9" format="ascii"
     &                                    ComponentName0="XX" ComponentName1="XY" ComponentName2="XZ" 
     &                                    ComponentName3="YX" ComponentName4="YY" ComponentName5="YZ" 
     &                                    ComponentName6="ZX" ComponentName7="ZY" ComponentName8="ZZ">'
            Lbgn = 1
            Lend = LREMAIN
            DO i = 1,LBLOCKS+1
              WRITE(IO_UNIT%LVTO,'((6(1PE15.7)))') 
     &        ((/ STRESS_DATA(NELUSED(L),1),STRESS_DATA(NELUSED(L),4),STRESS_DATA(NELUSED(L),5),
     &            STRESS_DATA(NELUSED(L),4),STRESS_DATA(NELUSED(L),2),STRESS_DATA(NELUSED(L),6),
     &            STRESS_DATA(NELUSED(L),5),STRESS_DATA(NELUSED(L),6),STRESS_DATA(NELUSED(L),3) /),  L = Lbgn,Lend)
              Lbgn = Lend + 1
              Lend = Lend + LBCOUNT
            ENDDO
            WRITE(IO_UNIT%LVTO,'(2X,A)')'</DataArray>'

            WRITE(IO_UNIT%LVTO,'(2X,A)')'<DataArray type="Float32" Name="Effective_Stress" NumberOfComponents="1" format="ascii">'
            Lbgn = 1
            Lend = LREMAIN
            DO i = 1,LBLOCKS+1
              WRITE(IO_UNIT%LVTO,'((6(1PE15.7)))') (EFFECTIVE_STRESS(NELUSED(L)), L = Lbgn,Lend)
              Lbgn = Lend + 1
              Lend = Lend + LBCOUNT
            ENDDO
            WRITE(IO_UNIT%LVTO,'(2X,A)')'</DataArray>'

            WRITE(IO_UNIT%LVTO,'(2X,A)')'<DataArray type="Float32" Name="Pressure" NumberOfComponents="1" format="ascii">'
            Lbgn = 1
            Lend = LREMAIN
            DO i = 1,LBLOCKS+1
              WRITE(IO_UNIT%LVTO,'((6(1PE15.7)))') (PRESSURE(NELUSED(L)), L = Lbgn,Lend)
              Lbgn = Lend + 1
              Lend = Lend + LBCOUNT
            ENDDO
            WRITE(IO_UNIT%LVTO,'(2X,A)')'</DataArray>'

            WRITE(IO_UNIT%LVTO,'(2X,A)')'<DataArray type="Float32" Name="Bulk_Strain" NumberOfComponents="1" format="ascii">'
            Lbgn = 1
            Lend = LREMAIN
            DO i = 1,LBLOCKS+1
              WRITE(IO_UNIT%LVTO,'((6(1PE15.7)))') (BULK_STRAIN(NELUSED(L)), L = Lbgn,Lend)
              Lbgn = Lend + 1
              Lend = Lend + LBCOUNT
            ENDDO
            WRITE(IO_UNIT%LVTO,'(2X,A)')'</DataArray>'

            WRITE(IO_UNIT%LVTO,'(2X,A)')'<DataArray type="Float32" Name="Strain_Energy" NumberOfComponents="1" format="ascii">'
            Lbgn = 1
            Lend = LREMAIN
            DO i = 1,LBLOCKS+1
              WRITE(IO_UNIT%LVTO,'((6(1PE15.7)))') (STRAIN_ENERGY_DENSITY(NELUSED(L)), L = Lbgn,Lend)
              Lbgn = Lend + 1
              Lend = Lend + LBCOUNT
            ENDDO
            WRITE(IO_UNIT%LVTO,'(2X,A)')'</DataArray>'

            WRITE(IO_UNIT%LVTO,'(2X,A)')'<DataArray type="Int32" Name="Material" NumberOfComponents="1" format="ascii">'
            Lbgn = 1
            Lend = LREMAIN
            DO i = 1,LBLOCKS+1
              WRITE(IO_UNIT%LVTO,'((6X,8I10))') (MatID_DATA(NELUSED(L)), L = Lbgn,Lend)
              Lbgn = Lend + 1
              Lend = Lend + LBCOUNT
            ENDDO
            WRITE(IO_UNIT%LVTO,'(2X,A)')'</DataArray>'
!!
!! End vtk "CellData" data.
!!
            WRITE (IO_UNIT%LVTO,'(A)') '</CellData>'
!!
!! End vtk "Piece" data.
!!
            WRITE (IO_UNIT%LVTO,'(A)') '</Piece>'
!!
!! End vtk "UnstructuredGrid" data.
!!
            WRITE (IO_UNIT%LVTO,'(A)') '</UnstructuredGrid>'
!!
!! End vtk "VTKFile" data.
!!
            WRITE (IO_UNIT%LVTO,'(A)') '</VTKFile>'
!!
            CLOSE (UNIT=IO_UNIT%LVTO, STATUS='KEEP')

          ENDIF
        ENDIF
      ENDDO
!!
!!

!! =========THIRD=============================================================
!! Use ParaView's *.pvd format to identify and name the individual materials
!! by time-step, by assembly (Asmb:), by part (Part:), by material (Matl:) for 
!! this and all past time steps.
!!
!! Open new VTK Data File.
!!
      IOERROR = .TRUE.
      OPEN
     &  (
     &  UNIT    =  IO_UNIT%LVTO,
     &  FILE    = 'fmavto.pvd',
     &  STATUS  = 'UNKNOWN',
     &  FORM    = 'FORMATTED',
     &  ERR     =  800
     &  )
      IOERROR = .FALSE.
!!
!! Fatal error exit for failed OPEN operation.
!!
 800  IF (IOERROR) THEN
        CALL USER_MESSAGE
     &    (
     &    MSGL//'FATAL'//
     &    MSGL//'WRITE_VTK_DATA_FILE.001.05'//
     &    MSGL//'Unable To Execute OPEN On: '//'fmavto.pvd'
     &    )
      ELSE
!!
!! Initialize vtk xml data file.
!!
        WRITE (IO_UNIT%LVTO,'(A/)') '<?xml version="1.0"?>'
!!
!! Analysis QA information.
!!
        WRITE (IO_UNIT%LVTO,'(A )') '<!--'
        WRITE (IO_UNIT%LVTO,'(A )') '   Title: '//TRIM(JOB_ID_RECORD%CURRENT%TITLE)
        WRITE (IO_UNIT%LVTO,'(A )') ' Program: '//JOB_ID_RECORD%PROGRAM
        WRITE (IO_UNIT%LVTO,'(A )') ' Version: '//JOB_ID_RECORD%VERSION
        WRITE (IO_UNIT%LVTO,'(A )') '    Date: '//JOB_ID_RECORD%CURRENT%DATE
        WRITE (IO_UNIT%LVTO,'(A )') '    Time: '//JOB_ID_RECORD%CURRENT%TIME
        WRITE (IO_UNIT%LVTO,'(A/)') ' -->'
!!
!! Last time and cycle number in this file.
!!
        WRITE (IO_UNIT%LVTO,'(A )')        '<!--'
        WRITE (IO_UNIT%LVTO,'(A,1PE15.7)') ' Last Problem Time: ',REAL(TIME%Total,KIND(0E0))
        WRITE (IO_UNIT%LVTO,'(A,I8)')      ' Last Cycle Number: ',TIME%Step
        WRITE (IO_UNIT%LVTO,'(A/)')        ' -->'
!!
!! Start vtk "Collection" data.
!!
        WRITE (IO_UNIT%LVTO,'(A)') '<VTKFile type="Collection" version="0.1" byte_order="LittleEndian">'
        WRITE (IO_UNIT%LVTO,'(A)') '  <Collection>'
!!
!! Loop on vtk "Part" (actually material domain).
!!
        DO I = 1,IVTO
          WRITE (TimeStep(1:12),'(1PE12.5)') Time_Values(I) 
          WRITE (CVTO,'(I4.4)') I
          CVTO(1:1) = 't'
          DO M = 1,NUMMT
            IF (MATERIAL(M)%NNodes .GT. 0) THEN
              WRITE (PVTO,'(I4.4)') M
              PVTO(1:1) = 'm'
              File_Name(1:) = 'fmavto.'//PVTO//'.'//CVTO//'.vtu'
              Part_Name(1:) = 'Asmb:'//MATERIAL(M)%A_LABEL
              Part_Name(1:) = TRIM(Part_Name)//' Part:'//MATERIAL(M)%P_LABEL
              Part_Name(1:) = TRIM(Part_Name)//' Matl:'//MATERIAL(M)%LABEL
              WRITE (IO_UNIT%LVTO,'(4X,A)')
     & '<DataSet timestep="'//TimeStep//'" part="'//PVTO(2:4)//'" file="'//TRIM(File_Name)//'" name="'//TRIM(Part_Name)//'"/>'
            ENDIF
          ENDDO
        ENDDO
!!
!! End vtk "Collection" data.
!!
        WRITE (IO_UNIT%LVTO,'(A)') '  </Collection>'
!!
!! Terminate vtk file.
!!
        WRITE (IO_UNIT%LVTO,'(A)') '</VTKFile>'
!!
!! Close and save file.
!!
        CLOSE (UNIT=IO_UNIT%LVTO, STATUS='KEEP')
      ENDIF

      RETURN

      CONTAINS
!!

      FUNCTION ELEMENTS_AND_NODES_USED ( M )
!!
!! Copyright (c) by FMA Development, LLC, 26-MAY-2004
!!
!! Purpose: Mark elements and nodes used, count number of unique elements 
!! and nodes used by the elements, and create index translation arrays 
!! for material "M".
!!
!! Arguments.
      INTEGER(ITYPE), INTENT(IN) :: M  !  Material Index
!!
!! Function return value.
      INTEGER(ITYPE) :: ELEMENTS_AND_NODES_USED
!!
!! Local Variables.
      INTEGER(ITYPE), PARAMETER :: IUNITY(8) = (/1,1,1,1,1,1,1,1/)
      INTEGER(ITYPE) :: K,N
!!
!! Clear marker/index-sequence and translation arrays.
!!
      NELUSED = 0
      NPTUSED = 0
      NPTNOWI = 0
!!
!! Scan all elements for the elements using MATERIAL(M).
!! Note: The element scan order here must match that in
!! the other extraction routines: NUMHX, NUMPX, NUMPY,
!! NUMTX, NUMM3, NUMP3, NUMM4, NUMP4, NUMTR.

!!
      K = 0
      ELEMENTS_AND_NODES_USED = 0

      DO N = 1,NUMHX
        K = K + 1
        IF (HEXAH(N)%PAR%MatID .EQ. M) THEN
          NELUSED(K) = 1
          ELEMENTS_AND_NODES_USED = 1
          NPTUSED(HEXAH(N)%PAR%IX(1:8)) = IUNITY(1:8)
        ENDIF
      ENDDO

      DO N = 1,NUMPX
        K = K + 1
        IF (PENTA(N)%PAR%MatID .EQ. M) THEN
          NELUSED(K) = 1
          ELEMENTS_AND_NODES_USED = 1
          NPTUSED(PENTA(N)%PAR%IX(1:6)) = IUNITY(1:6)
        ENDIF
      ENDDO

      DO N = 1,NUMPY
        K = K + 1
        IF (PYRAMID(N)%PAR%MatID .EQ. M) THEN
          NELUSED(K) = 1
          ELEMENTS_AND_NODES_USED = 1
          NPTUSED(PYRAMID(N)%PAR%IX(1:5)) = IUNITY(1:5)
        ENDIF
      ENDDO

      DO N = 1,NUMTX
        K = K + 1
        IF (TETRA(N)%PAR%MatID .EQ. M) THEN
          NELUSED(K) = 1
          ELEMENTS_AND_NODES_USED = 1

! ParaView does not know how to handle 8-node tetrahedrons.
!          Iform = SECTION_3D( TETRA(N)%PAR%SecID )%Iform
!          IF (Iform .EQ. Eight_Nodes) Then
!            NPTUSED(TETRA(N)%PAR%IX(1:8)) = IUNITY(1:8)
!          ELSE
!            NPTUSED(TETRA(N)%PAR%IX(1:4)) = IUNITY(1:4)
!          ENDIF

          NPTUSED(TETRA(N)%PAR%IX(1:4)) = IUNITY(1:4)
        ENDIF
      ENDDO

      DO N = 1,NUMM3
        K = K + 1
        IF (MEMBT(N)%PAR%MatID .EQ. M) THEN
          NELUSED(K) = 1
          ELEMENTS_AND_NODES_USED = 1
          NPTUSED(MEMBT(N)%PAR%IX(1:3)) = IUNITY(1:3)
        ENDIF
      ENDDO

      DO N = 1,NUMP3
        K = K + 1
        IF (PLATT(N)%PAR%MatID .EQ. M) THEN
          NELUSED(K) = 1
          ELEMENTS_AND_NODES_USED = 1
          NPTUSED(PLATT(N)%PAR%IX(1:3)) = IUNITY(1:3)
        ENDIF
      ENDDO

      DO N = 1,NUMM4
        K = K + 1
        IF (MEMBQ(N)%PAR%MatID .EQ. M) THEN
          NELUSED(K) = 1
          ELEMENTS_AND_NODES_USED = 1
          NPTUSED(MEMBQ(N)%PAR%IX(1:4)) = IUNITY(1:4)
        ENDIF
      ENDDO

      DO N = 1,NUMP4
        K = K + 1
        IF (PLATQ(N)%PAR%MatID .EQ. M) THEN
          NELUSED(K) = 1
          ELEMENTS_AND_NODES_USED = 1
          NPTUSED(PLATQ(N)%PAR%IX(1:4)) = IUNITY(1:4)
        ENDIF
      ENDDO

      DO N = 1,NUMTR
        K = K + 1
        IF (TRUSS(N)%PAR%MatID .EQ. M) THEN
          NELUSED(K) = 1
          ELEMENTS_AND_NODES_USED = 1
          NPTUSED(TRUSS(N)%PAR%IX(1:2)) = IUNITY(1:2)
        ENDIF
      ENDDO
!!
!! Get count of elements and nodes used by this material.
!!
      MATERIAL(M)%NElems = SUM ( NELUSED(1:NUMXL) )
      MATERIAL(M)%NNodes = SUM ( NPTUSED(1:NUMNP) )

!!    write (IO_UNIT%LELO,*) ' *** Material Number:',M
!!    write (IO_UNIT%LELO,*) '              NElems:',MATERIAL(M)%NElems
!!    write (IO_UNIT%LELO,*) '              NNodes:',MATERIAL(M)%NNodes
!!    write (IO_UNIT%LELO,*) '    NELUSED(1:NUMXL):',(NELUSED(n), n=1,NUMXL)
!!    write (IO_UNIT%LELO,*) '    NPTUSED(1:NUMNP):',(NPTUSED(n), n=1,NUMNP)

!!
!! Create nodal point index map NPTNOWI for use with 
!! element connectivity n-tuples. (Maps program index 
!! to index written to vtk files for this material.)
!!
!! Also, covert NPTUSED into a sequential index map.
!!
      K = 0
      DO N = 1,NUMNP
        IF (NPTUSED(N) .EQ. 1) THEN
          K = K + 1
          NPTNOWI(N) = K
          NPTUSED(K) = N
        ENDIF
      ENDDO
!!
!! Covert NELUSED into a sequential index map.
!!
      K= 0 
      DO N = 1,NUMXL
        IF (NELUSED(N) .EQ. 1) THEN
          K = K + 1
          NELUSED(K) = N
        ENDIF
      ENDDO

      RETURN
      END FUNCTION ELEMENTS_AND_NODES_USED
!!

      FUNCTION ELEMENT_N_TUPLE( NEL )
!!
!! Copyright (c) by FMA Development, LLC, 26-MAY-2004
!!
!! Arguments.
      INTEGER(ITYPE), INTENT(IN) :: NEL   ! Nth element
!!
!! Function return value.
      INTEGER(ITYPE) :: ELEMENT_N_TUPLE
!!
!! Local variables.
      LOGICAL,        SAVE :: FIRST = .TRUE.
      INTEGER(ITYPE), SAVE :: NHX,NPX,NPY,NTX,NM3,NP3,NM4,NP4,NTR,N

      INTEGER(ITYPE), PARAMETER :: IUNITY(8) = (/1,1,1,1,1,1,1,1/)
!!
!! Note:  This routine supplies element connectivity n-tuples.
!! However, the n-tuples are being crafted for a C-geek programmer
!! who thinks the first location in his/her arrays is location "0"
!! Hence, the indecies supplied are reduced by "1" with IUNITY.
!! They are so inconsistent. If they count by starting with "0"
!! why is an array with 16 locations not described by setting
!! its dimension to "15," i equal to 15 is the last location?? 
!!
      IF (FIRST) THEN
        NHX = NUMHX
        NPX = NHX + NUMPX
        NPY = NPX + NUMPY
        NTX = NPY + NUMTX
        NM3 = NTX + NUMM3
        NP3 = NM3 + NUMP3
        NM4 = NP3 + NUMM4
        NP4 = NM4 + NUMP4
        NTR = NP4 + NUMTR
        FIRST = .FALSE.
      ENDIF
!!
      IF (NEL .LE. NHX) THEN
        N = NEL
        ELEMENT_N_TUPLE = 8
        NTUPLE(1:8) = NPTNOWI(HEXAH(N)%PAR%IX(1:8)) - IUNITY(1:8)
      ELSE IF (NEL .LE. NPX) THEN
        N = NEL - NHX
        ELEMENT_N_TUPLE = 6
        NTUPLE(1:6) = NPTNOWI(PENTA(N)%PAR%IX(1:6)) - IUNITY(1:6)
      ELSE IF (NEL .LE. NPY) THEN
        N = NEL - NPX
        ELEMENT_N_TUPLE = 5
        NTUPLE(1:5) = NPTNOWI(PYRAMID(N)%PAR%IX(1:5)) - IUNITY(1:5)
      ELSE IF (NEL .LE. NTX) THEN
        N = NEL - NPY
        ELEMENT_N_TUPLE = 4
        NTUPLE(1:4) = NPTNOWI(TETRA(N)%PAR%IX(1:4)) - IUNITY(1:4)
      ELSE IF (NEL .LE. NM3) THEN
        N = NEL - NTX
        ELEMENT_N_TUPLE = 3
        NTUPLE(1:3) = NPTNOWI(MEMBT(N)%PAR%IX(1:3)) - IUNITY(1:3)
      ELSE IF (NEL .LE. NP3) THEN
        N = NEL - NM3
        ELEMENT_N_TUPLE = 3
        NTUPLE(1:3) = NPTNOWI(PLATT(N)%PAR%IX(1:3)) - IUNITY(1:3)
      ELSE IF (NEL .LE. NM4) THEN
        N = NEL - NP3
        ELEMENT_N_TUPLE = 4
        NTUPLE(1:4) = NPTNOWI(MEMBQ(N)%PAR%IX(1:4)) - IUNITY(1:4)
      ELSE IF (NEL .LE. NP4) THEN
        N = NEL - NM4
        ELEMENT_N_TUPLE = 4
        NTUPLE(1:4) = NPTNOWI(PLATQ(N)%PAR%IX(1:4)) - IUNITY(1:4)
      ELSE IF (NEL .LE. NTR) THEN
        N = NEL - NP4
        ELEMENT_N_TUPLE = 2
        NTUPLE(1:2) = NPTNOWI(TRUSS(N)%PAR%IX(1:2)) - IUNITY(1:2)
      ENDIF

      RETURN
      END FUNCTION ELEMENT_N_TUPLE
!!

      FUNCTION ELEMENT_VTK_OFFSET( NEL, IRESET )
!!
!! Copyright (c) by FMA Development, LLC, 26-MAY-2004
!!
!! Arguments.
      INTEGER(ITYPE), INTENT(IN) :: NEL      ! Nth element
      INTEGER(ITYPE), INTENT(IN) :: IRESET   ! Reset trigger
!!
!! Note: When this ftn is used in a loop that starts with 1,
!! IRESET = 1 will trigger a reset for the IOFFSET counter.
!!
!! Function return value.
      INTEGER(ITYPE) :: ELEMENT_VTK_OFFSET
!!
!! Local variables.
      LOGICAL,        SAVE :: FIRST = .TRUE.
      INTEGER(ITYPE), SAVE :: NHX,NPX,NPY,NTX,NM3,NP3,NM4,NP4,NTR,N
      INTEGER(ITYPE), SAVE :: IOFFSET
!!
      IF (FIRST) THEN
        NHX = NUMHX
        NPX = NHX + NUMPX
        NPY = NPX + NUMPY
        NTX = NPY + NUMTX
        NM3 = NTX + NUMM3
        NP3 = NM3 + NUMP3
        NM4 = NP3 + NUMM4
        NP4 = NM4 + NUMP4
        NTR = NP4 + NUMTR
        FIRST = .FALSE.
      ENDIF

      IF (IRESET .EQ. 1) IOFFSET = 0
 
      IF (NEL .LE. NHX) THEN
        N = NEL
        IOFFSET = IOFFSET + 8  ! HEXAH(N)%PAR%IX
      ELSE IF (NEL .LE. NPX) THEN
        N = NEL - NHX
        IOFFSET = IOFFSET + 6  ! PENTA(N)%PAR%IX
      ELSE IF (NEL .LE. NPY) THEN
        N = NEL - NPX
        IOFFSET = IOFFSET + 5  ! PYRAMID(N)%PAR%IX
      ELSE IF (NEL .LE. NTX) THEN
        N = NEL - NPY
        IOFFSET = IOFFSET + 4  ! TETRA(N)%PAR%IX
      ELSE IF (NEL .LE. NM3) THEN
        N = NEL - NTX
        IOFFSET = IOFFSET + 3  ! MEMBT(N)%PAR%IX
      ELSE IF (NEL .LE. NP3) THEN
        N = NEL - NM3
        IOFFSET = IOFFSET + 3  ! PLATT(N)%PAR%IX
      ELSE IF (NEL .LE. NM4) THEN
        N = NEL - NP3
        IOFFSET = IOFFSET + 4  ! MEMBQ(N)%PAR%IX
      ELSE IF (NEL .LE. NP4) THEN
        N = NEL - NM4
        IOFFSET = IOFFSET + 4  ! PLATQ(N)%PAR%IX
      ELSE IF (NEL .LE. NTR) THEN
        N = NEL - NP4
        IOFFSET = IOFFSET + 2  ! TRUSS(N)%PAR%IX
      ENDIF

      ELEMENT_VTK_OFFSET = IOFFSET

      RETURN
      END FUNCTION ELEMENT_VTK_OFFSET
!!

      FUNCTION ELEMENT_VTK_TYPE( NEL )
!!
!! Copyright (c) by FMA Development, LLC, 26-MAY-2004
!!
!! Arguments.
      INTEGER(ITYPE), INTENT(IN) :: NEL   ! Nth element
!!
!! Function return value.
      INTEGER(ITYPE) :: ELEMENT_VTK_TYPE
!!
!! Local variables.
      LOGICAL,        SAVE :: FIRST = .TRUE.
      INTEGER(ITYPE), SAVE :: NHX,NPX,NPY,NTX,NM3,NP3,NM4,NP4,NTR,N

      INTEGER(ITYPE), PARAMETER :: VTK_VERTEX         =  1
      INTEGER(ITYPE), PARAMETER :: VTK_POLY_VERTEX    =  2
      INTEGER(ITYPE), PARAMETER :: VTK_LINE           =  3
      INTEGER(ITYPE), PARAMETER :: VTK_POLY_LINE      =  4
      INTEGER(ITYPE), PARAMETER :: VTK_TRIANGLE       =  5
      INTEGER(ITYPE), PARAMETER :: VTK_TRIANGLE_STRIP =  6
      INTEGER(ITYPE), PARAMETER :: VTK_POLYGON        =  7
      INTEGER(ITYPE), PARAMETER :: VTK_PIXEL          =  8
      INTEGER(ITYPE), PARAMETER :: VTK_QUAD           =  9
      INTEGER(ITYPE), PARAMETER :: VTK_TETRAHEDRON    = 10
      INTEGER(ITYPE), PARAMETER :: VTK_VOXEL          = 11
      INTEGER(ITYPE), PARAMETER :: VTK_HEXAHEDRON     = 12
      INTEGER(ITYPE), PARAMETER :: VTK_WEDGE          = 13
      INTEGER(ITYPE), PARAMETER :: VTK_PYRAMID        = 14
!!
      IF (FIRST) THEN
        NHX = NUMHX
        NPX = NHX + NUMPX
        NPY = NPX + NUMPY
        NTX = NPY + NUMTX
        NM3 = NTX + NUMM3
        NP3 = NM3 + NUMP3
        NM4 = NP3 + NUMM4
        NP4 = NM4 + NUMP4
        NTR = NP4 + NUMTR
        FIRST = .FALSE.
      ENDIF
!!
      ELEMENT_VTK_TYPE = 0
      IF (NEL .LE. NHX) THEN
        N = NEL
        ELEMENT_VTK_TYPE = VTK_HEXAHEDRON  ! HEXAH(N)%PAR%EleID
      ELSE IF (NEL .LE. NPX) THEN
        N = NEL - NHX
        ELEMENT_VTK_TYPE = VTK_WEDGE       ! PENTA(N)%PAR%EleID
      ELSE IF (NEL .LE. NPY) THEN
        N = NEL - NPX
        ELEMENT_VTK_TYPE = VTK_PYRAMID     ! PYRAMID(N)%PAR%EleID
      ELSE IF (NEL .LE. NTX) THEN
        N = NEL - NPY
        ELEMENT_VTK_TYPE = VTK_TETRAHEDRON ! TETRA(N)%PAR%EleID
      ELSE IF (NEL .LE. NM3) THEN
        N = NEL - NTX
        ELEMENT_VTK_TYPE = VTK_TRIANGLE    ! MEMBT(N)%PAR%EleID
      ELSE IF (NEL .LE. NP3) THEN
        N = NEL - NM3
        ELEMENT_VTK_TYPE = VTK_TRIANGLE    ! PLATT(N)%PAR%EleID
      ELSE IF (NEL .LE. NM4) THEN
        N = NEL - NP3
        ELEMENT_VTK_TYPE = VTK_QUAD        ! MEMBQ(N)%PAR%EleID
      ELSE IF (NEL .LE. NP4) THEN
        N = NEL - NM4
        ELEMENT_VTK_TYPE = VTK_QUAD        ! PLATQ(N)%PAR%EleID
      ELSE IF (NEL .LE. NTR) THEN
        N = NEL - NP4
        ELEMENT_VTK_TYPE = VTK_LINE        ! TRUSS(N)%PAR%EleID
      ENDIF

      RETURN
      END FUNCTION ELEMENT_VTK_TYPE
!!

!      FUNCTION EleID_DATA ( NEL )
!!
!! Copyright (c) by FMA Development, LLC, 12-APR-1991 18:59:44 
!!
!! Arguments.
!      INTEGER(ITYPE), INTENT(IN) :: NEL   ! Nth element
!!
!! Function return value.
!      INTEGER(ITYPE) :: EleID_DATA
!!
!! Local variables.
!      LOGICAL,        SAVE :: FIRST = .TRUE.
!      INTEGER(ITYPE), SAVE :: NHX,NPX,NPY,NTX,NM3,NP3,NM4,NP4,NTR,N
!!
!      IF (FIRST) THEN
!        NHX = NUMHX
!        NPX = NHX + NUMPX
!        NPY = NPX + NUMPY
!        NTX = NPY + NUMTX
!        NM3 = NTX + NUMM3
!        NP3 = NM3 + NUMP3
!        NM4 = NP3 + NUMM4
!        NP4 = NM4 + NUMP4
!        NTR = NP4 + NUMTR
!        FIRST = .FALSE.
!      ENDIF
!!
!      EleID_DATA = 0
!      IF (NEL .LE. NHX) THEN
!        N = NEL
!        EleID_DATA = HEXAH(N)%PAR%EleID
!      ELSE IF (NEL .LE. NPX) THEN
!        N = NEL - NHX
!        EleID_DATA = PENTA(N)%PAR%EleID
!      ELSE IF (NEL .LE. NPY) THEN
!        N = NEL - NPX
!        EleID_DATA = PYRAMID(N)%PAR%EleID
!      ELSE IF (NEL .LE. NTX) THEN
!        N = NEL - NPY
!        EleID_DATA = TETRA(N)%PAR%EleID
!      ELSE IF (NEL .LE. NM3) THEN
!        N = NEL - NTX
!        EleID_DATA = MEMBT(N)%PAR%EleID
!      ELSE IF (NEL .LE. NP3) THEN
!        N = NEL - NM3
!        EleID_DATA = PLATT(N)%PAR%EleID
!      ELSE IF (NEL .LE. NM4) THEN
!        N = NEL - NP3
!        EleID_DATA = MEMBQ(N)%PAR%EleID
!      ELSE IF (NEL .LE. NP4) THEN
!        N = NEL - NM4
!        EleID_DATA = PLATQ(N)%PAR%EleID
!      ELSE IF (NEL .LE. NTR) THEN
!        N = NEL - NP4
!        EleID_DATA = TRUSS(N)%PAR%EleID
!      ENDIF
!
!      RETURN
!      END FUNCTION EleID_DATA
!!

      FUNCTION MatID_DATA ( NEL )
!!
!! Copyright (c) by FMA Development, LLC, 12-APR-1991 18:59:44 
!!
!! Arguments.
      INTEGER(ITYPE), INTENT(IN) :: NEL   ! Nth element
!!
!! Function return value.
      INTEGER(ITYPE) :: MatID_DATA
!!
!! Local variables.
      LOGICAL,        SAVE :: FIRST = .TRUE.
      INTEGER(ITYPE), SAVE :: NHX,NPX,NPY,NTX,NM3,NP3,NM4,NP4,NTR,N
!!
      IF (FIRST) THEN
        NHX = NUMHX
        NPX = NHX + NUMPX
        NPY = NPX + NUMPY
        NTX = NPY + NUMTX
        NM3 = NTX + NUMM3
        NP3 = NM3 + NUMP3
        NM4 = NP3 + NUMM4
        NP4 = NM4 + NUMP4
        NTR = NP4 + NUMTR
        FIRST = .FALSE.
      ENDIF
!!
      MatID_DATA = 0
      IF (NEL .LE. NHX) THEN
        N = NEL
        MatID_DATA = HEXAH(N)%PAR%MatID
      ELSE IF (NEL .LE. NPX) THEN
        N = NEL - NHX
        MatID_DATA = PENTA(N)%PAR%MatID
      ELSE IF (NEL .LE. NPY) THEN
        N = NEL - NPX
        MatID_DATA = PYRAMID(N)%PAR%MatID
      ELSE IF (NEL .LE. NTX) THEN
        N = NEL - NPY
        MatID_DATA = TETRA(N)%PAR%MatID
      ELSE IF (NEL .LE. NM3) THEN
        N = NEL - NTX
        MatID_DATA = MEMBT(N)%PAR%MatID
      ELSE IF (NEL .LE. NP3) THEN
        N = NEL - NM3
        MatID_DATA = PLATT(N)%PAR%MatID
      ELSE IF (NEL .LE. NM4) THEN
        N = NEL - NP3
        MatID_DATA = MEMBQ(N)%PAR%MatID
      ELSE IF (NEL .LE. NP4) THEN
        N = NEL - NM4
        MatID_DATA = PLATQ(N)%PAR%MatID
      ELSE IF (NEL .LE. NTR) THEN
        N = NEL - NP4
        MatID_DATA = TRUSS(N)%PAR%MatID
      ENDIF

      RETURN
      END FUNCTION MatID_DATA
!!

      FUNCTION STRESS_DATA ( NEL, I )
!!
!! Copyright (c) by FMA Development, LLC, 8-APR-1991 20:33:30 
!!
!! Arguments.
      INTEGER(ITYPE), INTENT(IN) :: NEL  ! Nth element
      INTEGER(ITYPE), INTENT(IN) :: I    ! Stress component requested
!!
!! Function return value.
      REAL :: STRESS_DATA
!!
!! Local variables.
      LOGICAL,        SAVE :: FIRST = .TRUE.
      INTEGER(ITYPE), SAVE :: NHX,NPX,NPY,NTX,NM3,NP3,NM4,NP4,NTR,N
      INTEGER(ITYPE)       :: NDEX(4)
!!
      IF (FIRST) THEN
        NHX = NUMHX
        NPX = NHX + NUMPX
        NPY = NPX + NUMPY
        NTX = NPY + NUMTX
        NM3 = NTX + NUMM3
        NP3 = NM3 + NUMP3
        NM4 = NP3 + NUMM4
        NP4 = NM4 + NUMP4
        NTR = NP4 + NUMTR
        FIRST = .FALSE.
      ENDIF
!!
      STRESS_DATA = 0.0
      IF (NEL .LE. NHX) THEN
        N = NEL
        STRESS_DATA = HEXAH(N)%RES%Stress(I)
      ELSE IF (NEL .LE. NPX) THEN
        N = NEL - NHX
        STRESS_DATA = PENTA(N)%RES%Stress(I)
      ELSE IF (NEL .LE. NPY) THEN
        N = NEL - NPX
        STRESS_DATA = PYRAMID(N)%RES%Stress(I)
      ELSE IF (NEL .LE. NTX) THEN
        N = NEL - NPY
        Iform = SECTION_3D( TETRA(N)%PAR%SecID )%Iform
        IF (Iform .EQ. Nodal_Based) Then
          NDEX = TETRA(N)%RES%IN
          STRESS_DATA = P4TH * SUM( TETNP(NDEX)%Stress(I) )
        ELSE
          STRESS_DATA = TETRA(N)%RES%Stress(I)
        ENDIF
      ELSE IF (NEL .LE. NM3) THEN
        N = NEL - NTX
        IF (I .LE. 2) THEN
          STRESS_DATA = MEMBT(N)%RES%Stress(I)
        ELSE IF (I .EQ. 4) THEN
          STRESS_DATA = MEMBT(N)%RES%Stress(3)
        ENDIF
      ELSE IF (NEL .LE. NP3) THEN
        N = NEL - NM3
        Ist = PLATT(N)%PAR%Ist
        STRESS_DATA = STRESS(I,Ist)
      ELSE IF (NEL .LE. NM4) THEN
        N = NEL - NP3
        IF (I .LE. 2) THEN
          STRESS_DATA = MEMBQ(N)%RES%Stress(I)
        ELSE IF (I .EQ. 4) THEN
          STRESS_DATA = MEMBQ(N)%RES%Stress(3)
        ENDIF
      ELSE IF (NEL .LE. NP4) THEN
        N = NEL - NM4
        Ist = PLATQ(N)%PAR%Ist
        STRESS_DATA = STRESS(I,Ist)
      ELSE IF (NEL .LE. NTR) THEN
        N = NEL - NP4
        IF (I .EQ. 1) THEN
          STRESS_DATA = TRUSS(N)%RES%Stress
        ELSE
          STRESS_DATA = 0.0
        ENDIF
      ENDIF

      RETURN
      END FUNCTION STRESS_DATA
!!

      FUNCTION BULK_STRAIN ( NEL )
!!
!! Copyright (c) by FMA Development, LLC, 12-APR-1991 18:59:44 
!!
!! Arguments.
      INTEGER(ITYPE), INTENT(IN) :: NEL  ! Nth element
!!
!! Function return value.
      REAL :: BULK_STRAIN
!!
!! Local variables.
      LOGICAL,        SAVE :: FIRST = .TRUE.
      INTEGER(ITYPE), SAVE :: NHX,NPX,NPY,NTX,NM3,NP3,NM4,NP4,NTR,N
!!
!! Function reference.
      REAL(RTYPE), EXTERNAL :: LOG_POS
!!
      IF (FIRST) THEN
        NHX = NUMHX
        NPX = NHX + NUMPX
        NPY = NPX + NUMPY
        NTX = NPY + NUMTX
        NM3 = NTX + NUMM3
        NP3 = NM3 + NUMP3
        NM4 = NP3 + NUMM4
        NP4 = NM4 + NUMP4
        NTR = NP4 + NUMTR
        FIRST = .FALSE.
      ENDIF
!!
      BULK_STRAIN = 0.0
      IF (NEL .LE. NHX) THEN
        N = NEL
        BULK_STRAIN = LOG_POS(HEXAH(N)%RES%Volume/HEXAH(N)%PAR%Volume)
      ELSE IF (NEL .LE. NPX) THEN
        N = NEL - NHX
        BULK_STRAIN = LOG_POS(PENTA(N)%RES%Volume/PENTA(N)%PAR%Volume)
      ELSE IF (NEL .LE. NPY) THEN
        N = NEL - NPX
        BULK_STRAIN = LOG_POS(PYRAMID(N)%RES%Volume/PYRAMID(N)%PAR%Volume)
      ELSE IF (NEL .LE. NTX) THEN
        N = NEL - NPY
        BULK_STRAIN = LOG_POS(TETRA(N)%RES%Volume/TETRA(N)%PAR%Volume)
      ELSE IF (NEL .LE. NM3) THEN
        N = NEL - NTX
        BULK_STRAIN = LOG_POS(MEMBT(N)%RES%Area/MEMBT(N)%PAR%Area)
      ELSE IF (NEL .LE. NP3) THEN
        N = NEL - NM3
        BULK_STRAIN = LOG_POS(PLATT(N)%RES%Area/PLATT(N)%PAR%Area)
      ELSE IF (NEL .LE. NM4) THEN
        N = NEL - NP3
        BULK_STRAIN = LOG_POS(MEMBQ(N)%RES%Area/MEMBQ(N)%PAR%Area)
      ELSE IF (NEL .LE. NP4) THEN
        N = NEL - NM4
        BULK_STRAIN = LOG_POS(PLATQ(N)%RES%Area/PLATQ(N)%PAR%Area)
      ELSE IF (NEL .LE. NTR) THEN
        N = NEL - NP4
        BULK_STRAIN = LOG_POS(TRUSS(N)%RES%Length/TRUSS(N)%PAR%Length)
      ENDIF

      RETURN
      END FUNCTION BULK_STRAIN
!!

      FUNCTION STRAIN_ENERGY_DENSITY ( NEL )
!!
!! Copyright (c) by FMA Development, LLC, 12-APR-1991 18:59:44 
!!
!! Arguments.
      INTEGER(ITYPE), INTENT(IN) :: NEL   ! Nth element
!!
!! Function return value.
      REAL :: STRAIN_ENERGY_DENSITY
!!
!! Local variables.
      LOGICAL,        SAVE :: FIRST = .TRUE.
      INTEGER(ITYPE), SAVE :: NHX,NPX,NPY,NTX,NM3,NP3,NM4,NP4,NTR,N
      INTEGER(ITYPE)       :: NDEX(4)
!!
      IF (FIRST) THEN
        NHX = NUMHX
        NPX = NHX + NUMPX
        NPY = NPX + NUMPY
        NTX = NPY + NUMTX
        NM3 = NTX + NUMM3
        NP3 = NM3 + NUMP3
        NM4 = NP3 + NUMM4
        NP4 = NM4 + NUMP4
        NTR = NP4 + NUMTR
        FIRST = .FALSE.
      ENDIF
!!
      STRAIN_ENERGY_DENSITY = 0.0
      IF (NEL .LE. NHX) THEN
        N = NEL
        STRAIN_ENERGY_DENSITY = HEXAH(N)%RES%Str_Eng
      ELSE IF (NEL .LE. NPX) THEN
        N = NEL - NHX
        STRAIN_ENERGY_DENSITY = PENTA(N)%RES%Str_Eng
      ELSE IF (NEL .LE. NPY) THEN
        N = NEL - NPX
        STRAIN_ENERGY_DENSITY = PYRAMID(N)%RES%Str_Eng
      ELSE IF (NEL .LE. NTX) THEN
        N = NEL - NPY
        Iform = SECTION_3D( TETRA(N)%PAR%SecID )%Iform
        IF (Iform .EQ. Nodal_Based) Then
          NDEX = TETRA(N)%RES%IN
          STRAIN_ENERGY_DENSITY = P4TH * SUM( TETNP(NDEX)%Str_Eng )
        ELSE
          STRAIN_ENERGY_DENSITY = TETRA(N)%RES%Str_Eng
        ENDIF
      ELSE IF (NEL .LE. NM3) THEN
        N = NEL - NTX
        STRAIN_ENERGY_DENSITY = MEMBT(N)%RES%Str_Eng
      ELSE IF (NEL .LE. NP3) THEN
        N = NEL - NM3
        STRAIN_ENERGY_DENSITY = PLATT(N)%RES%Str_Eng
      ELSE IF (NEL .LE. NM4) THEN
        N = NEL - NP3
        STRAIN_ENERGY_DENSITY = MEMBQ(N)%RES%Str_Eng
      ELSE IF (NEL .LE. NP4) THEN
        N = NEL - NM4
        STRAIN_ENERGY_DENSITY = PLATQ(N)%RES%Str_Eng
      ELSE IF (NEL .LE. NTR) THEN
        N = NEL - NP4
        STRAIN_ENERGY_DENSITY = TRUSS(N)%RES%Str_Eng
      ENDIF
!!
      RETURN
      END FUNCTION STRAIN_ENERGY_DENSITY
!!

      FUNCTION PRESSURE ( NEL )
!!
!! Copyright (c) by FMA Development, LLC, 8-APR-1991 20:33:30 
!!
!! Arguments.
      INTEGER(ITYPE), INTENT(IN) :: NEL   ! Nth element
!!
!! Function return value.
      REAL :: PRESSURE
!!
!! Local variables.
      LOGICAL,        SAVE :: FIRST = .TRUE.
      INTEGER(ITYPE), SAVE :: NHX,NPX,NPY,NTX,NM3,NP3,NM4,NP4,NTR,N
      INTEGER(ITYPE)       :: NDEX(4)
      REAL(RTYPE)          :: TEMP(4)
!!
      IF (FIRST) THEN
        NHX = NUMHX
        NPX = NHX + NUMPX
        NPY = NPX + NUMPY
        NTX = NPY + NUMTX
        NM3 = NTX + NUMM3
        NP3 = NM3 + NUMP3
        NM4 = NP3 + NUMM4
        NP4 = NM4 + NUMP4
        NTR = NP4 + NUMTR
        FIRST = .FALSE.
      ENDIF
!!
      PRESSURE = 0.0
      IF (NEL .LE. NHX) THEN
        N = NEL
        PRESSURE = P3RD * SUM( HEXAH(N)%RES%Stress(1:3) )
      ELSE IF (NEL .LE. NPX) THEN
        N = NEL - NHX
        PRESSURE = P3RD * SUM( PENTA(N)%RES%Stress(1:3) )
      ELSE IF (NEL .LE. NPY) THEN
        N = NEL - NPX
        PRESSURE = P3RD * SUM( PYRAMID(N)%RES%Stress(1:3) )
      ELSE IF (NEL .LE. NTX) THEN
        N = NEL - NPY
        Iform = SECTION_3D( TETRA(N)%PAR%SecID )%Iform
        IF (Iform .EQ. Nodal_Based) Then
          NDEX = TETRA(N)%RES%IN
          TEMP = (/ZERO,ZERO,ZERO,ZERO/)
          TEMP = TEMP + TETNP(NDEX)%Stress(1)
          TEMP = TEMP + TETNP(NDEX)%Stress(2)
          TEMP = TEMP + TETNP(NDEX)%Stress(3)
          PRESSURE = P12TH * SUM( TEMP ) 
        ELSE
          PRESSURE = P3RD * SUM( TETRA(N)%RES%Stress(1:3) )
        ENDIF
      ELSE IF (NEL .LE. NM3) THEN
        N = NEL - NTX
        PRESSURE = P3RD * SUM( MEMBT(N)%RES%Stress(1:2) )
      ELSE IF (NEL .LE. NP3) THEN
        N = NEL - NM3
        Ist = PLATT(N)%PAR%Ist
        PRESSURE = P3RD * SUM( STRESS(1:2,Ist) )
      ELSE IF (NEL .LE. NM4) THEN
        N = NEL - NP3
        PRESSURE = P3RD * SUM( MEMBQ(N)%RES%Stress(1:2) )
      ELSE IF (NEL .LE. NP4) THEN
        N = NEL - NM4
        Ist = PLATQ(N)%PAR%Ist
        PRESSURE = P3RD * SUM( STRESS(1:2,Ist) )
      ELSE IF (NEL .LE. NTR) THEN
        N = NEL - NP4
        PRESSURE = P3RD * TRUSS(N)%RES%Stress
      ENDIF

      RETURN
      END FUNCTION PRESSURE
!!

      FUNCTION EFFECTIVE_STRESS ( NEL )
!!
!! Copyright (c) by FMA Development, LLC, 8-APR-1991 20:33:30 
!!
!! Arguments.
      INTEGER(ITYPE), INTENT(IN) :: NEL   ! Nth element
!!
!! Function return value.
      REAL :: EFFECTIVE_STRESS
!!
!! Local variables.
      LOGICAL,        SAVE :: FIRST = .TRUE.
      INTEGER(ITYPE), SAVE :: NHX,NPX,NPY,NTX,NM3,NP3,NM4,NP4,NTR,N
      INTEGER(ITYPE)       :: NDEX(4)
      REAL(RTYPE)          :: TEMP(4)
      REAL(RTYPE)          :: PRESSURE,S1,S2,S3,S4,S5,S6
!!
!! Function reference.
      REAL(RTYPE) :: EFF_STR
!!
      IF (FIRST) THEN
        NHX = NUMHX
        NPX = NHX + NUMPX
        NPY = NPX + NUMPY
        NTX = NPY + NUMTX
        NM3 = NTX + NUMM3
        NP3 = NM3 + NUMP3
        NM4 = NP3 + NUMM4
        NP4 = NM4 + NUMP4
        NTR = NP4 + NUMTR
        FIRST = .FALSE.
      ENDIF
!!
      EFFECTIVE_STRESS = 0.0
      IF (NEL .LE. NHX) THEN
        N = NEL
        PRESSURE = P3RD * SUM( HEXAH(N)%RES%Stress(1:3) )
        S1 = HEXAH(N)%RES%Stress(1) - PRESSURE
        S2 = HEXAH(N)%RES%Stress(2) - PRESSURE
        S3 = HEXAH(N)%RES%Stress(3) - PRESSURE
        S4 = HEXAH(N)%RES%Stress(4) * HEXAH(N)%RES%Stress(4)
        S5 = HEXAH(N)%RES%Stress(5) * HEXAH(N)%RES%Stress(5) 
        S6 = HEXAH(N)%RES%Stress(6) * HEXAH(N)%RES%Stress(6)
        S4 = S4 + S5 + S6
        EFFECTIVE_STRESS = EFF_STR (S1,S2,S3,S4)
      ELSE IF (NEL .LE. NPX) THEN
        N = NEL - NHX
        PRESSURE = P3RD * SUM( PENTA(N)%RES%Stress(1:3) )
        S1 = PENTA(N)%RES%Stress(1) - PRESSURE
        S2 = PENTA(N)%RES%Stress(2) - PRESSURE
        S3 = PENTA(N)%RES%Stress(3) - PRESSURE
        S4 = PENTA(N)%RES%Stress(4) * PENTA(N)%RES%Stress(4)
        S5 = PENTA(N)%RES%Stress(5) * PENTA(N)%RES%Stress(5) 
        S6 = PENTA(N)%RES%Stress(6) * PENTA(N)%RES%Stress(6)
        S4 = S4 + S5 + S6
        EFFECTIVE_STRESS = EFF_STR (S1,S2,S3,S4)
      ELSE IF (NEL .LE. NPY) THEN
        N = NEL - NPX
        PRESSURE = P3RD * SUM( PYRAMID(N)%RES%Stress(1:3) )
        S1 = PYRAMID(N)%RES%Stress(1) - PRESSURE
        S2 = PYRAMID(N)%RES%Stress(2) - PRESSURE
        S3 = PYRAMID(N)%RES%Stress(3) - PRESSURE
        S4 = PYRAMID(N)%RES%Stress(4) * PYRAMID(N)%RES%Stress(4)
        S5 = PYRAMID(N)%RES%Stress(5) * PYRAMID(N)%RES%Stress(5) 
        S6 = PYRAMID(N)%RES%Stress(6) * PYRAMID(N)%RES%Stress(6)
        S4 = S4 + S5 + S6
        EFFECTIVE_STRESS = EFF_STR (S1,S2,S3,S4)
      ELSE IF (NEL .LE. NTX) THEN
        N = NEL - NPY
        Iform = SECTION_3D( TETRA(N)%PAR%SecID )%Iform
        IF (Iform .EQ. Nodal_Based) THEN
          NDEX = TETRA(N)%RES%IN
          TEMP = (/ZERO,ZERO,ZERO,ZERO/)
          TEMP = TEMP + TETNP(NDEX)%Stress(1)
          TEMP = TEMP + TETNP(NDEX)%Stress(2)
          TEMP = TEMP + TETNP(NDEX)%Stress(3)
          PRESSURE = P12TH * SUM( TEMP ) 
        ELSE
          PRESSURE = P3RD * SUM( TETRA(N)%RES%Stress(1:3) )
        ENDIF
        IF (Iform .EQ. Nodal_Based) THEN
          S1 =  P4TH * SUM( TETNP(NDEX)%Stress(1) ) - PRESSURE
          S2 =  P4TH * SUM( TETNP(NDEX)%Stress(2) ) - PRESSURE
          S3 =  P4TH * SUM( TETNP(NDEX)%Stress(3) ) - PRESSURE
          S4 = (P4TH * SUM( TETNP(NDEX)%Stress(4) ) )**2
          S5 = (P4TH * SUM( TETNP(NDEX)%Stress(5) ) )**2
          S6 = (P4TH * SUM( TETNP(NDEX)%Stress(6) ) )**2
          S4 = (S4 + S5 + S6)
        ELSE
          S1 = TETRA(N)%RES%Stress(1) - PRESSURE
          S2 = TETRA(N)%RES%Stress(2) - PRESSURE
          S3 = TETRA(N)%RES%Stress(3) - PRESSURE
          S4 = TETRA(N)%RES%Stress(4) * TETRA(N)%RES%Stress(4)
          S5 = TETRA(N)%RES%Stress(5) * TETRA(N)%RES%Stress(5) 
          S6 = TETRA(N)%RES%Stress(6) * TETRA(N)%RES%Stress(6)
          S4 = S4 + S5 + S6
        ENDIF
        EFFECTIVE_STRESS = EFF_STR (S1,S2,S3,S4)
      ELSE IF (NEL .LE. NM3) THEN
        N = NEL - NTX
        PRESSURE = P3RD * SUM ( MEMBT(N)%RES%Stress(1:2) )
        S1 = MEMBT(N)%RES%Stress(1) - PRESSURE
        S2 = MEMBT(N)%RES%Stress(2) - PRESSURE
        S3 =                        - PRESSURE
        S4 = MEMBT(N)%RES%Stress(3) * MEMBT(N)%RES%Stress(3)
        EFFECTIVE_STRESS = EFF_STR (S1,S2,S3,S4)
      ELSE IF (NEL .LE. NP3) THEN
        N = NEL - NM3
        Ist = PLATT(N)%PAR%Ist
        PRESSURE = P3RD * SUM( STRESS(1:2,Ist) )
        S1 = STRESS(1,Ist) - PRESSURE
        S2 = STRESS(2,Ist) - PRESSURE
        S3 =               - PRESSURE
        S4 = STRESS(4,Ist) * STRESS(4,Ist) 
        EFFECTIVE_STRESS = EFF_STR (S1,S2,S3,S4)
      ELSE IF (NEL .LE. NM4) THEN
        N = NEL - NP3
        PRESSURE = P3RD * SUM( MEMBQ(N)%RES%Stress(1:2) )
        S1 = MEMBQ(N)%RES%Stress(1) - PRESSURE
        S2 = MEMBQ(N)%RES%Stress(2) - PRESSURE
        S3 =                        - PRESSURE
        S4 = MEMBQ(N)%RES%Stress(3) * MEMBQ(N)%RES%Stress(3)
        EFFECTIVE_STRESS = EFF_STR (S1,S2,S3,S4)
      ELSE IF (NEL .LE. NP4) THEN
        N = NEL - NM4 
        Ist = PLATQ(N)%PAR%Ist
        PRESSURE = P3RD * SUM( STRESS(1:2,Ist) )
        S1 = STRESS(1,Ist) - PRESSURE
        S2 = STRESS(2,Ist) - PRESSURE
        S3 =               - PRESSURE
        S4 = STRESS(4,Ist) * STRESS(4,Ist) 
        EFFECTIVE_STRESS = EFF_STR (S1,S2,S3,S4)
      ELSE IF (NEL .LE. NTR) THEN
        N = NEL - NP4
        PRESSURE = P3RD * TRUSS(N)%RES%Stress
        S1 = TRUSS(N)%RES%Stress - PRESSURE
        S2 =                     - PRESSURE
        S3 =                     - PRESSURE
        S4 = 0.0
        EFFECTIVE_STRESS = EFF_STR (S1,S2,S3,S4)
      ENDIF

      RETURN
      END FUNCTION EFFECTIVE_STRESS
!!

      FUNCTION SEGMENTS_AND_NODES_USED ( M )
!!
!! Copyright (c) by FMA Development, LLC, 26-MAY-2004
!!
!! Purpose: Mark segments and nodes used, count number of unique segments
!! and nodes used by the segment set, and create index translation arrays 
!! for segment set "M".
!!
!! Arguments.
      INTEGER(ITYPE), INTENT(IN) :: M   !  Segment set ID
!!
!! Function return value.
      INTEGER(ITYPE) :: SEGMENTS_AND_NODES_USED
!!
!! Local Variables.
      INTEGER(ITYPE), SAVE :: IX(4),N,K
!!
!! Clear marker/index-sequence and translation arrays.
!!
      NELUSED = 0
      NPTUSED = 0
      NPTNOWI = 0
!!
!! Mark nodes used by this segment set.
!!
      SEGMENTS_AND_NODES_USED = 0

      N = 0
      DO WHILE (NEXT_SEG_ID(M,N))
        NELUSED(N) = 1
        IX(1:4) = SEGMENT(N)%PAR%IX(1:4)
        IF (IX(4) .LE. 0) THEN
          NPTUSED(IX(1:3)) = (/1,1,1/)            
        ELSE
          NPTUSED(IX(1:4)) = (/1,1,1,1/)            
        ENDIF
        SEGMENTS_AND_NODES_USED = 1
      ENDDO
!!
!! Create nodal point index map NPTNOWI for use with 
!! element connectivity n-tuples. (Maps program index 
!! to index written to vtk files for this segment set.)
!!
!! Also, covert NPTUSED into a sequential index map.
!!
      K = 0
      DO N = 1,NUMNP
        IF (NPTUSED(N) .EQ. 1) THEN
          K = K + 1
          NPTNOWI(N) = K
          NPTUSED(K) = N
        ENDIF
      ENDDO
      NNodes = K
!!
!! Covert NELUSED into a sequential index map.
!!
      K= 0 
      DO N = 1,NUMSG
        IF (NELUSED(N) .EQ. 1) THEN
          K = K + 1
          NELUSED(K) = N
        ENDIF
      ENDDO
      NElems = K

      RETURN
      END FUNCTION SEGMENTS_AND_NODES_USED
!!

      FUNCTION SEGMENT_N_TUPLE( NEL )
!!
!! Copyright (c) by FMA Development, LLC, 26-MAY-2004
!!
!! Arguments.
      INTEGER(ITYPE), INTENT(IN) :: NEL   ! Segment ID
!!
!! Function return value.
      INTEGER(ITYPE) :: SEGMENT_N_TUPLE
!!
!! Local variables.
      INTEGER(ITYPE), SAVE :: IX(4)
!!
!! Note:  This routine supplies element connectivity n-tuples.
!! However, the n-tuples are being crafted for a C-geek programmer
!! who thinks the first location in his/her arrays is location "0"
!! Hence, the indecies supplied are reduced by "1" with IUNITY.
!! They are so inconsistent. If they count by starting with "0"
!! why is an array with 16 locations not described by setting
!! its dimension to "15," i equal to 15 is the last location?? 
!!
      IX(1:4) = SEGMENT(NEL)%PAR%IX(1:4)
      IF (IX(4) .LE. 0) THEN
        SEGMENT_N_TUPLE = 3
        NTUPLE(1:3) = NPTNOWI(IX(1:3)) - (/1,1,1/)
      ELSE
        SEGMENT_N_TUPLE = 4
        NTUPLE(1:4) = NPTNOWI(IX(1:4)) - (/1,1,1,1/)
      ENDIF

      RETURN
      END FUNCTION SEGMENT_N_TUPLE
!!

      FUNCTION SEGMENT_VTK_OFFSET( NEL, IRESET )
!!
!! Copyright (c) by FMA Development, LLC, 26-MAY-2004
!!
!! Arguments.
      INTEGER(ITYPE), INTENT(IN) :: NEL     ! Segment ID
      INTEGER(ITYPE), INTENT(IN) :: IRESET  ! Reset trigger
!!
!! Note: When this ftn is used in a loop that starts with 1,
!! IRESET = 1 will trigger a reset for the IOFFSET counter.
!!
!! Function return value.
      INTEGER(ITYPE) :: SEGMENT_VTK_OFFSET
!!
!! Local variables.
      INTEGER(ITYPE), SAVE :: IOFFSET
!!
      IF (IRESET .EQ. 1) IOFFSET = 0
 
      IF (SEGMENT(NEL)%PAR%IX(4) .LE. 0) THEN
        IOFFSET = IOFFSET + 3
      ELSE
        IOFFSET = IOFFSET + 4
      ENDIF

      SEGMENT_VTK_OFFSET = IOFFSET

      RETURN
      END FUNCTION SEGMENT_VTK_OFFSET
!!

      FUNCTION SEGMENT_VTK_TYPE( NEL )
!!
!! Copyright (c) by FMA Development, LLC, 26-MAY-2004
!!
!! Arguments.
      INTEGER(ITYPE), INTENT(IN) :: NEL   ! Segment ID
!!
!! Function return value.
      INTEGER(ITYPE) :: SEGMENT_VTK_TYPE
!!
!! Local variables.
      INTEGER(ITYPE), PARAMETER :: VTK_TRIANGLE =  5
      INTEGER(ITYPE), PARAMETER :: VTK_QUAD     =  9
!!
      IF (SEGMENT(NEL)%PAR%IX(4) .LE. 0) THEN
        SEGMENT_VTK_TYPE = VTK_TRIANGLE
      ELSE
        SEGMENT_VTK_TYPE = VTK_QUAD
      ENDIF

      RETURN
      END FUNCTION SEGMENT_VTK_TYPE
!!

      FUNCTION WEDGES_AND_NODES_USED ( M )
!!
!! Copyright (c) by FMA Development, LLC, 26-MAY-2004
!!
!! Purpose: Mark wedges and nodes used, count number of unique wedges
!! and nodes used by the wedge set, and create index translation arrays 
!! for wedge set "M".
!!
!! Arguments.
      INTEGER(ITYPE), INTENT(IN) :: M   ! Solid-to-solid interface ID
!!
!! Function return value.
      INTEGER(ITYPE) :: WEDGES_AND_NODES_USED
!!
!! Local Variables.
      INTEGER(ITYPE), SAVE :: IX(4),N,K
      LOGICAL              :: FOUND
!!
!! Clear marker/index-sequence and translation arrays.
!!
      NELUSED = 0
      NPTUSED = 0
      NPTNOWI = 0
!!
!! Mark wedges used by this solid-to-solid interface.
!!
      WEDGES_AND_NODES_USED = 0

      DO N = 1,NUMWX
        IF (WEDGE(N)%MPCID .EQ. M) THEN
          NELUSED(N) = 1
          WEDGES_AND_NODES_USED = 1
        ENDIF
      ENDDO
!!
!! Note: The wedges don't use the nodal points of the
!! mesh, but contain information for building their
!! own vertex coordinates, see WEDGE_NP_COORDINATE.
!!
!! Create nodal point index map NPTNOWI for use with 
!! element connectivity n-tuples. (Maps program index 
!! to index written to vtk files for this wedge set.)
!!
!! Also, covert NPTUSED into a sequential index map.
!!
!!      K = 0
!!      DO N = 1,NUMNP
!!        IF (NPTUSED(N) .EQ. 1) THEN
!!          K = K + 1
!!          NPTNOWI(N) = K
!!          NPTUSED(K) = N
!!        ENDIF
!!      ENDDO
!!      NNodes = K
!!
!! Covert NELUSED into a sequential index map.
!!
      K= 0 
      DO N = 1,NUMWX
        IF (NELUSED(N) .EQ. 1) THEN
          K = K + 1
          NELUSED(K) = N
        ENDIF
      ENDDO

      NElems = K
      NNodes = 6 * NElems

      RETURN
      END FUNCTION WEDGES_AND_NODES_USED
!!

      FUNCTION WEDGE_N_TUPLE( NEL )
!!
!! Copyright (c) by FMA Development, LLC, 26-MAY-2004
!!
!! Arguments.
      INTEGER(ITYPE), INTENT(IN) :: NEL   ! Wedge ID
!!
!! Function return value.
      INTEGER(ITYPE) :: WEDGE_N_TUPLE
!!
!! Note:  This routine supplies element connectivity n-tuples.
!! However, the n-tuples are being crafted for a C-geek programmer
!! who thinks the first location in his/her arrays is location "0"
!! Hence, the indecies supplied are reduced by "1" with IUNITY.
!! They are so inconsistent. If they count by starting with "0"
!! why is an array with 16 locations not described by setting
!! its dimension to "15," i equal to 15 is the last location?? 
!!
      IOS = 6*NEL - 6

      NTUPLE(1:6) = (/0+IOS,1+IOS,2+IOS,3+IOS,4+IOS,5+IOS/)

      WEDGE_N_TUPLE = 6

      RETURN
      END FUNCTION WEDGE_N_TUPLE
!!

      FUNCTION WEDGE_VTK_OFFSET( NEL, IRESET )
!!
!! Copyright (c) by FMA Development, LLC, 26-MAY-2004
!!
!! Arguments.
      INTEGER(ITYPE), INTENT(IN) :: NEL     ! Wedge ID
      INTEGER(ITYPE), INTENT(IN) :: IRESET  ! Reset trigger
!!
!! Note: When this ftn is used in a loop that starts with 1,
!! IRESET = 1 will trigger a reset for the IOFFSET counter.
!!
!! Function return value.
      INTEGER(ITYPE) :: WEDGE_VTK_OFFSET
!!
!! Local variables.
      INTEGER(ITYPE), SAVE :: IOFFSET
!!
      IF (IRESET .EQ. 1) IOFFSET = 0
 
      IOFFSET = IOFFSET + 6

      WEDGE_VTK_OFFSET = IOFFSET

      RETURN
      END FUNCTION WEDGE_VTK_OFFSET
!!

      FUNCTION WEDGE_VTK_TYPE( NEL )
!!
!! Copyright (c) by FMA Development, LLC, 26-MAY-2004
!!
!! Arguments.
      INTEGER(ITYPE), INTENT(IN) :: NEL   ! Wedge ID
!!
!! Function return value.
      INTEGER(ITYPE) :: WEDGE_VTK_TYPE
!!
!! Local variables.
      INTEGER(ITYPE), PARAMETER :: VTK_WEDGE = 13
!!
      WEDGE_VTK_TYPE = VTK_WEDGE

      RETURN
      END FUNCTION WEDGE_VTK_TYPE
!!

      FUNCTION WEDGE_NP_COORDINATE( I, J )
!!
!! Copyright (c) by FMA Development, LLC, 01-JUL-2016
!!
!! Arguments.
      INTEGER(ITYPE), INTENT(IN) :: I     ! Nodal counter 
      INTEGER(ITYPE), INTENT(IN) :: J     ! 1/2/3=x/y/z
!!
!! Function return value.
      REAL(RTYPE) :: WEDGE_NP_COORDINATE
!!
!! Local variables.
      REAL(RTYPE)    :: Px(3),Py(3),Pz(3),PXYZ
      INTEGER(ITYPE) :: Slave_TriaID,Master_TriaID
      INTEGER(ITYPE) :: NEL,NPT,MEL
!!
!! Caution: This routine contains a hard-coded dependency.
!! This routine will generate nodal point coordinates for
!! the sequence of wedges contained in NELUSED(*). Each
!! wedge has its own six nodal points.
!!
      NEL = ((I-1)/6) + 1
      NPT = I - 6*((I-1)/6) !! NPT is this WEDGE's vertex: [1|2|3|4|5|6] 

      MEL = NELUSED(NEL)

      PXYZ = ZERO

      SELECT CASE(NPT)

        CASE(1,2,3)  !! This wedge's Slave-Surface end.

          Slave_TriaID = WEDGE(MEL)%SlaID

          IF (J == 1) THEN
            Px(1:3) = SLAVE_TRIAS(Slave_TriaID)%X(1:3)
            PXYZ = DOT_PRODUCT( WEDGE(MEL)%W(1:3,NPT), Px(1:3) )

          ELSE IF (J == 2) THEN
            Py(1:3) = SLAVE_TRIAS(Slave_TriaID)%Y(1:3)
            PXYZ = DOT_PRODUCT( WEDGE(MEL)%W(1:3,NPT), Py(1:3) )

          ELSE IF (J == 3) THEN
            Pz(1:3) = SLAVE_TRIAS(Slave_TriaID)%Z(1:3)
            PXYZ = DOT_PRODUCT( WEDGE(MEL)%W(1:3,NPT), Pz(1:3) )

          ENDIF

        CASE(4,5,6)  !! This wedge's Master-Surface end.

          Master_TriaID = WEDGE(MEL)%MasID

          IF (J == 1) THEN
            Px(1:3) = MASTER_TRIAS(Master_TriaID)%X(1:3)
            PXYZ = DOT_PRODUCT( WEDGE(MEL)%W(1:3,NPT), Px(1:3) )

          ELSE IF (J == 2) THEN
            Py(1:3) = MASTER_TRIAS(Master_TriaID)%Y(1:3)
            PXYZ = DOT_PRODUCT( WEDGE(MEL)%W(1:3,NPT), Py(1:3) )

          ELSE IF (J == 3) THEN
            Pz(1:3) = MASTER_TRIAS(Master_TriaID)%Z(1:3)
            PXYZ = DOT_PRODUCT( WEDGE(MEL)%W(1:3,NPT), Pz(1:3) )

         ENDIF

      END SELECT

      WEDGE_NP_COORDINATE = PXYZ

      RETURN
      END FUNCTION WEDGE_NP_COORDINATE
!!

      FUNCTION WEDGE_NP_VELOCITY( I, J )
!!
!! Copyright (c) by FMA Development, LLC, 01-JUL-2016
!!
!! Arguments.
      INTEGER(ITYPE), INTENT(IN) :: I     ! Nodal counter
      INTEGER(ITYPE), INTENT(IN) :: J     ! 1/2/3=x/y/z
!!
!! Function return value.
      REAL(RTYPE) :: WEDGE_NP_VELOCITY
!!
!! Local variables.
      REAL(RTYPE)    :: Vx(3),Vy(3),Vz(3),VXYZ
      INTEGER(ITYPE) :: Slave_TriaID,Master_TriaID
      INTEGER(ITYPE) :: NEL,NPT,MEL
!!
!! Caution: This routine contains a hard-coded dependency.
!! This routine will generate nodal point velocities for
!! the sequence of wedges contained in NELUSED(*). Each
!! wedge has its own six nodal points.
!!
      NEL = ((I-1)/6) + 1
      NPT = I - 6*((I-1)/6) !! NPT is this WEDGE's vertex: [1|2|3|4|5|6] 

      MEL = NELUSED(NEL)

      VXYZ = ZERO

      SELECT CASE(NPT)

        CASE(1,2,3)  !! This wedge's Slave-Surface end.

          Slave_TriaID = WEDGE(MEL)%SlaID

          IF (J == 1) THEN
            Vx(1:3) = SLAVE_TRIAS(Slave_TriaID)%Vx(1:3)
            VXYZ = DOT_PRODUCT( WEDGE(MEL)%W(1:3,NPT), Vx(1:3) )

          ELSE IF (J == 2) THEN
            Vy(1:3) = SLAVE_TRIAS(Slave_TriaID)%Vy(1:3)
            VXYZ = DOT_PRODUCT( WEDGE(MEL)%W(1:3,NPT), Vy(1:3) )

          ELSE IF (J == 3) THEN
            Vz(1:3) = SLAVE_TRIAS(Slave_TriaID)%Vz(1:3)
            VXYZ = DOT_PRODUCT( WEDGE(MEL)%W(1:3,NPT), Vz(1:3) )

          ENDIF

        CASE(4,5,6)  !! This wedge's Master-Surface end.

          Master_TriaID = WEDGE(MEL)%MasID

          IF (J == 1) THEN
            Vx(1:3) = MASTER_TRIAS(Master_TriaID)%Vx(1:3)
            VXYZ = DOT_PRODUCT( WEDGE(MEL)%W(1:3,NPT), Vx(1:3) )

          ELSE IF (J == 2) THEN
            Vy(1:3) = MASTER_TRIAS(Master_TriaID)%Vy(1:3)
            VXYZ = DOT_PRODUCT( WEDGE(MEL)%W(1:3,NPT), Vy(1:3) )

          ELSE IF (J == 3) THEN
            Vz(1:3) = MASTER_TRIAS(Master_TriaID)%Vz(1:3)
            VXYZ = DOT_PRODUCT( WEDGE(MEL)%W(1:3,NPT), Vz(1:3) )

         ENDIF

      END SELECT

      WEDGE_NP_VELOCITY = VXYZ

      RETURN
      END FUNCTION WEDGE_NP_VELOCITY

      END SUBROUTINE WRITE_TO_VTK_RESULTS_FILE
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vtk-file-formats.pdf
Type: application/pdf
Size: 256044 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/paraview/attachments/20171121/c8dabba6/attachment-0001.pdf>


More information about the ParaView mailing list