From 2c9f928ad38b6e487acfc4b7e236e9e4bb149040 Mon Sep 17 00:00:00 2001 From: Emmanuel Branlard Date: Fri, 18 Nov 2022 13:49:20 -0700 Subject: [PATCH 1/4] NWTC_Lib: Adding Yaml and VTK to library (moved from SD and AD) --- modules/aerodyn/CMakeLists.txt | 1 - modules/aerodyn/src/FVW.f90 | 2 +- modules/aerodyn/src/FVW_IO.f90 | 16 +- modules/aerodyn/src/FVW_Tests.f90 | 4 +- modules/nwtc-library/CMakeLists.txt | 2 + .../FVW_VTK.f90 => nwtc-library/src/VTK.f90} | 1224 +++++++++-------- modules/{subdyn => nwtc-library}/src/Yaml.f90 | 0 modules/subdyn/CMakeLists.txt | 1 - modules/wakedynamics/CMakeLists.txt | 2 +- modules/wakedynamics/src/WakeDynamics.f90 | 4 +- vs-build/AeroDyn/AeroDyn_Driver.vfproj | 4 +- .../AeroDyn_Inflow_c_lib.vfproj | 4 +- vs-build/BeamDyn/BeamDyn.vfproj | 3 +- vs-build/FASTlib/FASTlib.vfproj | 8 +- vs-build/SubDyn/SubDyn.vfproj | 4 +- 15 files changed, 640 insertions(+), 639 deletions(-) rename modules/{aerodyn/src/FVW_VTK.f90 => nwtc-library/src/VTK.f90} (91%) rename modules/{subdyn => nwtc-library}/src/Yaml.f90 (100%) diff --git a/modules/aerodyn/CMakeLists.txt b/modules/aerodyn/CMakeLists.txt index f0b8a41f8b..c28b8806e6 100644 --- a/modules/aerodyn/CMakeLists.txt +++ b/modules/aerodyn/CMakeLists.txt @@ -71,7 +71,6 @@ set(FVW_LIBS_SOURCES src/FVW_BiotSavart.f90 src/FVW_Tests.f90 src/FVW_Types.f90 - src/FVW_VTK.f90 ) # ADI lib diff --git a/modules/aerodyn/src/FVW.f90 b/modules/aerodyn/src/FVW.f90 index 15afd48479..1516202254 100644 --- a/modules/aerodyn/src/FVW.f90 +++ b/modules/aerodyn/src/FVW.f90 @@ -1408,7 +1408,7 @@ end subroutine CalcOutputForAD !---------------------------------------------------------------------------------------------------------------------------------- !> Routine for computing outputs, used in both loose and tight coupling. subroutine FVW_CalcOutput(t, u, p, x, xd, z, OtherState, y, m, ErrStat, ErrMsg) - use FVW_VTK, only: set_vtk_coordinate_transform + use VTK, only: set_vtk_coordinate_transform use FVW_VortexTools, only: interpextrap_cp2node real(DbKi), intent(in ) :: t !< Current simulation time in seconds type(FVW_InputType), intent(in ) :: u !< Inputs at Time t diff --git a/modules/aerodyn/src/FVW_IO.f90 b/modules/aerodyn/src/FVW_IO.f90 index b55ecd6499..ecd1b1a64d 100644 --- a/modules/aerodyn/src/FVW_IO.f90 +++ b/modules/aerodyn/src/FVW_IO.f90 @@ -349,7 +349,7 @@ end function is_int !> Export FVW variables to VTK !! NOTE: when entering this function nNW and nFW has been incremented by 1 subroutine WrVTK_FVW(p, x, z, m, FileRootName, VTKcount, Twidth, bladeFrame, HubOrientation, HubPosition) - use FVW_VTK ! for all the vtk_* functions + use VTK ! for all the vtk_* functions type(FVW_ParameterType), intent(in ) :: p !< Parameters type(FVW_ContinuousStateType), intent(in ) :: x !< States type(FVW_ConstraintStateType), intent(in ) :: z !< Constraints @@ -373,7 +373,7 @@ subroutine WrVTK_FVW(p, x, z, m, FileRootName, VTKcount, Twidth, bladeFrame, Hub real(Reki), dimension(:,:,:), allocatable :: Arr3D !< real(Reki), dimension(:,:), allocatable :: Arr2D !< - type(FVW_VTK_Misc) :: mvtk + type(VTK_Misc) :: mvtk call vtk_misc_init(mvtk) @@ -473,7 +473,7 @@ end subroutine WrVTK_FVW !> Export Grid velocity field to VTK subroutine WrVTK_FVW_Grid(p, x, z, m, iGrid, FileRootName, VTKcount, Twidth, HubOrientation, HubPosition) use FVW_VortexTools, only: curl_regular_grid - use FVW_VTK ! for all the vtk_* functions + use VTK ! for all the vtk_* functions type(FVW_ParameterType), intent(in ) :: p !< Parameters type(FVW_ContinuousStateType), intent(in ) :: x !< States type(FVW_ConstraintStateType), intent(in ) :: z !< Constraints @@ -490,7 +490,7 @@ subroutine WrVTK_FVW_Grid(p, x, z, m, iGrid, FileRootName, VTKcount, Twidth, Hub character(Twidth) :: Tstr ! string for current VTK write-out step (padded with zeros) real(ReKi), dimension(3) :: dx type(GridOutType), pointer :: g - type(FVW_VTK_Misc) :: mvtk + type(VTK_Misc) :: mvtk call vtk_misc_init(mvtk) call set_vtk_binary_format(.false.,mvtk) ! TODO binary fails @@ -524,9 +524,9 @@ end subroutine WrVTK_FVW_Grid subroutine WrVTK_Segments(filename, mvtk, SegPoints, SegConnct, SegGamma, SegEpsilon, bladeFrame) - use FVW_VTK + use VTK character(len=*),intent(in) :: filename - type(FVW_VTK_Misc), intent(inout) :: mvtk !< miscvars for VTK output + type(VTK_Misc), intent(inout) :: mvtk !< miscvars for VTK output real(ReKi), dimension(:,:), intent(in) :: SegPoints !< integer(IntKi), dimension(:,:), intent(in) :: SegConnct !< real(ReKi), dimension(:) , intent(in) :: SegGamma !< @@ -545,9 +545,9 @@ subroutine WrVTK_Segments(filename, mvtk, SegPoints, SegConnct, SegGamma, SegEps end subroutine subroutine WrVTK_Lattice(filename, mvtk, LatticePoints, LatticeGamma, LatticeData3d, bladeFrame) - use FVW_VTK ! for all the vtk_* functions + use VTK ! for all the vtk_* functions character(len=*), intent(in) :: filename - type(FVW_VTK_Misc), intent(inout) :: mvtk !< miscvars for VTK output + type(VTK_Misc), intent(inout) :: mvtk !< miscvars for VTK output real(Reki), dimension(:,:,:), intent(in ) :: LatticePoints !< Array of points 3 x nSpan x nDepth real(Reki), dimension(:,:), intent(in ) :: LatticeGamma !< Array of nSpan x nDepth real(Reki), dimension(:,:,:), intent(in ), optional :: LatticeData3d !< Array of n x nSpan x nDepth KEEP ME diff --git a/modules/aerodyn/src/FVW_Tests.f90 b/modules/aerodyn/src/FVW_Tests.f90 index 9d72854fd7..82375990ef 100644 --- a/modules/aerodyn/src/FVW_Tests.f90 +++ b/modules/aerodyn/src/FVW_Tests.f90 @@ -8,7 +8,7 @@ module FVW_Tests use FVW_Wings use FVW_IO use FVW_BiotSavart - use FVW_VTK, only : FVW_VTK_Misc + use VTK, only : VTK_Misc implicit none @@ -602,7 +602,7 @@ end subroutine Test_SegmentsToPart !> subroutine Test_LatticeToSegment(mvtk,iStat) - type(FVW_VTK_Misc),intent(inout) :: mvtk !< miscvars for VTK output + type(VTK_Misc),intent(inout) :: mvtk !< miscvars for VTK output integer(IntKi), intent( out) :: iStat !< Status for test ! Local integer(IntKi),dimension(:,:), allocatable :: SegConnct !< Segment connectivity diff --git a/modules/nwtc-library/CMakeLists.txt b/modules/nwtc-library/CMakeLists.txt index 7186913a20..bae87c8985 100644 --- a/modules/nwtc-library/CMakeLists.txt +++ b/modules/nwtc-library/CMakeLists.txt @@ -25,6 +25,8 @@ set(NWTCLIBS_SOURCES src/NWTC_RandomNumber.f90 src/SingPrec.f90 src/NWTC_Library_Types.f90 + src/VTK.f90 + src/Yaml.f90 # RanLux sources src/ranlux/RANLUX.f90 diff --git a/modules/aerodyn/src/FVW_VTK.f90 b/modules/nwtc-library/src/VTK.f90 similarity index 91% rename from modules/aerodyn/src/FVW_VTK.f90 rename to modules/nwtc-library/src/VTK.f90 index a99aad9162..e052b77f0b 100644 --- a/modules/aerodyn/src/FVW_VTK.f90 +++ b/modules/nwtc-library/src/VTK.f90 @@ -1,610 +1,614 @@ -module FVW_VTK - !use PrecisionMod, only: ReKi - use NWTC_Library, only: ReKi, GetNewUnit, NewLine - implicit none -! character(8), parameter :: RFMT='F14.5' - !character(8), parameter :: RFMT='E24.15E3' - character(8), parameter :: RFMT='E17.8E3' - character(8), parameter :: IFMT='I7' - - TYPE, PUBLIC :: FVW_VTK_Misc - integer :: vtk_unit - logical :: bFileOpen=.false. - - integer :: nData=0; - integer :: nPoints=0; - - logical :: bBinary = .false. - character(len=255) :: buffer - - ! Reference Frame - real(ReKi),dimension(3,3) :: T_g2b - real(ReKi),dimension(3) :: PO_g - END TYPE FVW_VTK_Misc - - interface vtk_dataset_structured_grid; module procedure & - vtk_dataset_structured_grid_flat, & - vtk_dataset_structured_grid_grid - end interface - - interface vtk_point_data_vector; module procedure & - vtk_point_data_vector_flat, & - vtk_point_data_vector_grid2D,& - vtk_point_data_vector_grid - end interface - interface vtk_point_data_scalar; module procedure & - vtk_point_data_scalar_flat, & - vtk_point_data_scalar_2D, & - vtk_point_data_scalar_grid2D, & - vtk_point_data_scalar_grid - end interface - interface vtk_cell_data_scalar; module procedure & - vtk_cell_data_scalar_1d,& - vtk_cell_data_scalar_2d - end interface - - public - -contains - - subroutine vtk_misc_init(mvtk) - type(FVW_VTK_Misc),intent(inout) :: mvtk - mvtk%vtk_unit = -1 !< VTK output unit [-] - mvtk%bFileOpen = .false. !< binary file is open [-] - mvtk%bBinary = .false. !< write binary files [-] - mvtk%nData = 0 !< number of data lines [-] - mvtk%nPoints = 0 !< number of points [-] - end subroutine - - !> - subroutine set_vtk_binary_format(bBin,mvtk) - logical, intent(in)::bBin - type(FVW_VTK_Misc),intent(inout) :: mvtk - mvtk%bBinary=bBin - end subroutine - - - !> Save a coordinate transform - ! ALL VTK Will be exported in this coordinate system! - subroutine set_vtk_coordinate_transform(T_g2b_in,PO_g_in,mvtk) - real(ReKi),dimension(3,3), intent(in) :: T_g2b_in - real(ReKi),dimension(3) , intent(in) :: PO_g_in - type(FVW_VTK_Misc),intent(inout) :: mvtk - mvtk%T_g2b=T_g2b_in - mvtk%PO_g=PO_g_in - end subroutine - - logical function vtk_new_ascii_file(filename,label,mvtk) - !use MainIO, only: get_free_unit ,check_io - !use MainIOData, only: bSTOP_ALLOWED - !use FileSystem, only: file_exists - !use Logging, only: log_warning,log_error,log_info - ! - character(len=*),intent(in) :: filename - character(len=*),intent(in) :: label - type(FVW_VTK_Misc),intent(inout) :: mvtk - ! - integer :: iostatvar - logical :: b - - if (.not. mvtk%bFileOpen) then - CALL GetNewUnit( mvtk%vtk_unit ) - if (mvtk%bBinary) then - ! Fortran 2003 stream, otherwise intel fortran ! - !form='UNFORMATTED',access='SEQUENTIAL',action='WRITE',convert='BIG_ENDIAN',recordtype='STREAM',buffered='YES', - !print*,'Not available for this compiler' !COMPAQ-COMPILER - !STOP !COMPAQ-COMPILER -!bjj: CONVERT is non-standard, so maybe this should be part of Sys*.f90? Like OpenUnfInpBEFile()? - open(unit = mvtk%vtk_unit,file= trim(adjustl(filename)),form='UNFORMATTED',access = 'stream',& !OTHER-COMPILER - action = 'WRITE',convert= 'BIG_ENDIAN',iostat=iostatvar,status='replace') !OTHER-COMPILER - else - open(mvtk%vtk_unit,file=trim(adjustl(filename)),iostat=iostatvar,action="write",status='replace') - endif - if (iostatvar == 0) then - if (mvtk%bBinary) then - write(mvtk%vtk_unit)'# vtk DataFile Version 3.0'//NewLine - write(mvtk%vtk_unit)trim(label)//NewLine - write(mvtk%vtk_unit)'BINARY'//NewLine - else - write(mvtk%vtk_unit,'(a)') '# vtk DataFile Version 2.0' - write(mvtk%vtk_unit,'(a)') trim(label) - write(mvtk%vtk_unit,'(a)') 'ASCII' - write(mvtk%vtk_unit,'(a)') ' ' - endif - - mvtk%bFileOpen=.true. - mvtk%nData=-1; - endif - else - b=.false. - !call log_error('VTK: Cannot open two vtk files at the same time, call vtk_close first') - endif - if (iostatvar ==0) then - vtk_new_ascii_file=.true. - else - vtk_new_ascii_file=.false. - endif - end function - - subroutine vtk_close_file(mvtk) - type(FVW_VTK_Misc),intent(inout) :: mvtk - if ( mvtk%bFileOpen ) then - close(mvtk%vtk_unit) - mvtk%bFileOpen=.false. - endif - endsubroutine - - - ! ------------------------------------------------------------------------- - ! --- POLYDATA STUFF - ! ------------------------------------------------------------------------- - subroutine vtk_dataset_polydata(Points,mvtk,bladeFrame) - real(ReKi), dimension(:,:),intent(in) :: Points !< 3 x n - type(FVW_VTK_Misc),intent(inout) :: mvtk - logical, intent(in) :: bladeFrame - integer :: i - if ( mvtk%bFileOpen ) then - mvtk%nPoints=size(Points,2) - if (mvtk%bBinary) then - write(mvtk%vtk_unit)'DATASET POLYDATA'//NewLine - write(mvtk%buffer,'(A,I0,A)') 'POINTS ', mvtk%nPoints ,' double' - write(mvtk%vtk_unit)trim(mvtk%buffer)//NewLine - if (bladeFrame) then - do i=1,mvtk%nPoints - write(mvtk%vtk_unit)matmul(mvtk%T_g2b,Points(1:3,i)-mvtk%PO_g) - enddo - else - do i=1,mvtk%nPoints - write(mvtk%vtk_unit)Points(1:3,i) - enddo - endif - write(mvtk%vtk_unit)NewLine - else - write(mvtk%vtk_unit,'(A)') 'DATASET POLYDATA' - write(mvtk%vtk_unit,'(A,I0,A)') 'POINTS ', mvtk%nPoints ,' double' - if (bladeFrame) then - do i=1,mvtk%nPoints - write(mvtk%vtk_unit,'(3'//RFMT//')') matmul(mvtk%T_g2b,Points(1:3,i)-mvtk%PO_g) - enddo - else - do i=1,mvtk%nPoints - write(mvtk%vtk_unit,'(3'//RFMT//')') Points(1:3,i) - enddo - endif - write(mvtk%vtk_unit,*) ' ' - endif - endif - end subroutine - - - subroutine vtk_lines(L,mvtk) - integer, dimension(:,:),intent(in) :: L !< 2 x n - type(FVW_VTK_Misc),intent(inout) :: mvtk - - integer :: i - - if ( mvtk%bFileOpen ) then - mvtk%nData=size(L,2) - if (mvtk%bBinary) then - write(mvtk%buffer,'(A,I0,A,I0)')'LINES ',mvtk%nData,' ',3*mvtk%nData - write(mvtk%vtk_unit)trim(mvtk%buffer)//NewLine - do i=1,mvtk%nData - write(mvtk%vtk_unit)2,L(1:2,i) - enddo - write(mvtk%vtk_unit)NewLine - else - write(mvtk%vtk_unit,'(A,I0,A,I0)')'LINES ',mvtk%nData,' ',3*mvtk%nData - do i=1,mvtk%nData - write(mvtk%vtk_unit,'(3'//IFMT//')') 2, L(1:2,i) - enddo - write(mvtk%vtk_unit,*) ' ' - endif - endif - end subroutine - - subroutine vtk_quad(Q,mvtk) - integer, dimension(:,:),intent(in) :: Q !< 4 x n - type(FVW_VTK_Misc),intent(inout) :: mvtk - integer :: i - if ( mvtk%bFileOpen ) then - mvtk%nData=size(Q,2) - if (mvtk%bBinary) then - write(mvtk%buffer,'(A,I0,A,I0)')'POLYGONS ',mvtk%nData,' ',5*mvtk%nData - write(mvtk%vtk_unit)trim(mvtk%buffer)//NewLine - do i=1,mvtk%nData - write(mvtk%vtk_unit)4,Q(1:4,i) - enddo - write(mvtk%vtk_unit)NewLine - else - write(mvtk%vtk_unit,'(A,I0,A,I0)') 'POLYGONS ', mvtk%nData,' ',5*mvtk%nData - do i=1,mvtk%nData - write(mvtk%vtk_unit,'(5'//IFMT//')') 4, Q(1:4,i) - enddo - write(mvtk%vtk_unit,*) ' ' - endif - endif - end subroutine - - ! ------------------------------------------------------------------------- - ! --- RECTILINEAR - ! ------------------------------------------------------------------------- - subroutine vtk_dataset_rectilinear(v1,v2,v3,mvtk) - real(ReKi), dimension(:),intent(in) :: v1,v2,v3 !< n - type(FVW_VTK_Misc),intent(inout) :: mvtk - - if ( mvtk%bFileOpen ) then - mvtk%nPoints=size(v1)*size(v2)*size(v3) - if (mvtk%bBinary) then - write(mvtk%vtk_unit) 'DATASET RECTILINEAR_GRID'//NewLine - write(mvtk%buffer,'(A,I0,A,I0,A,I0)') 'DIMENSIONS ', size(v1),' ',size(v2),' ',size(v3) - write(mvtk%vtk_unit) trim(mvtk%buffer)//NewLine - write(mvtk%buffer,'(A,I0,A)') 'X_COORDINATES ', size(v1), ' double' - write(mvtk%vtk_unit) trim(mvtk%buffer)//NewLine - write(mvtk%vtk_unit)v1 - write(mvtk%vtk_unit)NewLine - write(mvtk%buffer,'(A,I0,A)') 'Y_COORDINATES ', size(v2), ' double' - write(mvtk%vtk_unit) trim(mvtk%buffer)//NewLine - write(mvtk%vtk_unit)v2 - write(mvtk%vtk_unit)NewLine - write(mvtk%buffer,'(A,I0,A)') 'Z_COORDINATES ', size(v3), ' double' - write(mvtk%vtk_unit) trim(mvtk%buffer)//NewLine - write(mvtk%vtk_unit)v3 - !write(mvtk%vtk_unit)NewLine - else - write(mvtk%vtk_unit,'(A)') 'DATASET RECTILINEAR_GRID' - write(mvtk%vtk_unit,'(A,I0,A,I0,A,I0)') 'DIMENSIONS ', size(v1),' ',size(v2),' ',size(v3) - write(mvtk%vtk_unit,'(A,I0,A)') 'X_COORDINATES ', size(v1), ' double' - write(mvtk%vtk_unit,'('//RFMT//')') v1 - write(mvtk%vtk_unit,'(A,I0,A)') 'Y_COORDINATES ', size(v2), ' double' - write(mvtk%vtk_unit,'('//RFMT//')') v2 - write(mvtk%vtk_unit,'(A,I0,A)') 'Z_COORDINATES ', size(v3), ' double' - write(mvtk%vtk_unit,'('//RFMT//')') v3 - write(mvtk%vtk_unit,*) ' ' - endif - endif - end subroutine - - subroutine vtk_dataset_structured_points(x0,dx,n,mvtk) - real(ReKi), dimension(3), intent(in) :: x0 !< origin - real(ReKi), dimension(3), intent(in) :: dx !< spacing - integer, dimension(3), intent(in) :: n !< length - type(FVW_VTK_Misc),intent(inout) :: mvtk - - if ( mvtk%bFileOpen ) then - mvtk%nPoints=n(1)*n(2)*n(3) - if (mvtk%bBinary) then - write(mvtk%vtk_unit) 'DATASET STRUCTURED_POINTS'//NewLine - write(mvtk%buffer,'(A,I0,A,I0,A,I0)') 'DIMENSIONS ',n(1),' ',n(2),' ',n(3) - write(mvtk%vtk_unit) trim(mvtk%buffer)//NewLine - write(mvtk%buffer,'(A,3F16.8)') 'ORIGIN ', x0 - write(mvtk%vtk_unit) trim(mvtk%buffer)//NewLine - write(mvtk%buffer,'(A,3F16.8)') 'SPACING ', dx - write(mvtk%vtk_unit) trim(mvtk%buffer)//NewLine - else - write(mvtk%vtk_unit,'(A)') 'DATASET STRUCTURED_POINTS' - write(mvtk%vtk_unit,'(A,I0,A,I0,A,I0)') 'DIMENSIONS ', n(1),' ',n(2),' ',n(3) - write(mvtk%vtk_unit,'(A,3F16.8,A)') 'ORIGIN ',x0 - write(mvtk%vtk_unit,'(A,3F16.8,A)') 'SPACING ',dx - endif - endif - end subroutine - - - ! ------------------------------------------------------------------------- - ! --- STRUCTURED GRID (Points dumped without for loop since memory is in proper order) - ! ------------------------------------------------------------------------- - !> Subroutine using flat data as input (not in natural order) - subroutine vtk_dataset_structured_grid_flat(D,n1,n2,n3,mvtk) - integer , intent(in) :: n1,n2,n3 - real(ReKi), dimension(:,:),intent(in)::D - type(FVW_VTK_Misc),intent(inout) :: mvtk - if ( mvtk%bFileOpen ) then - mvtk%nPoints=n1*n2*n3 - if (mvtk%bBinary) then - write(mvtk%vtk_unit) 'DATASET STRUCTURED_GRID'//NewLine - write(mvtk%buffer,'(A,I0,A,I0,A,I0)') 'DIMENSIONS ', n1,' ',n2,' ',n3 - write(mvtk%vtk_unit) trim(mvtk%buffer)//NewLine - write(mvtk%buffer,'(A,I0,A)') 'POINTS ', mvtk%nPoints, ' double' - write(mvtk%vtk_unit) trim(mvtk%buffer)//NewLine - write(mvtk%vtk_unit)D - write(mvtk%vtk_unit)NewLine - else - write(mvtk%vtk_unit,'(A)') 'DATASET STRUCTURED_GRID' - write(mvtk%vtk_unit,'(A,I0,A,I0,A,I0)') 'DIMENSIONS ', n1,' ',n2,' ',n3 - write(mvtk%vtk_unit,'(A,I0,A)') 'POINTS ', mvtk%nPoints, ' double' - write(mvtk%vtk_unit,'(3'//RFMT//')')D - write(mvtk%vtk_unit,*) ' ' - endif - endif - end subroutine - - !> Using Grid data 4d as input - subroutine vtk_dataset_structured_grid_grid(D,n1,n2,n3,mvtk) - integer , intent(in) :: n1,n2,n3 - real(ReKi), dimension(:,:,:,:),intent(in)::D - type(FVW_VTK_Misc),intent(inout) :: mvtk - - if ( mvtk%bFileOpen ) then - mvtk%nPoints=n1*n2*n3 - if (mvtk%bBinary) then - write(mvtk%vtk_unit) 'DATASET STRUCTURED_GRID'//NewLine - write(mvtk%buffer,'(A,I0,A,I0,A,I0)') 'DIMENSIONS ', n1,' ',n2,' ',n3 - write(mvtk%vtk_unit) trim(mvtk%buffer)//NewLine - write(mvtk%buffer,'(A,I0,A)') 'POINTS ', mvtk%nPoints, ' double' - write(mvtk%vtk_unit) trim(mvtk%buffer)//NewLine - write(mvtk%vtk_unit)D - write(mvtk%vtk_unit)NewLine - else - write(mvtk%vtk_unit,'(A)') 'DATASET STRUCTURED_GRID' - write(mvtk%vtk_unit,'(A,I0,A,I0,A,I0)') 'DIMENSIONS ', n1,' ',n2,' ',n3 - write(mvtk%vtk_unit,'(A,I0,A)') 'POINTS ', mvtk%nPoints, ' double' - write(mvtk%vtk_unit,'(3'//RFMT//')')D - write(mvtk%vtk_unit,*) ' ' - endif - endif - end subroutine - - - - ! ------------------------------------------------------------------------- - ! --- POINT DATA - ! ------------------------------------------------------------------------- - subroutine vtk_point_data_init(mvtk) - type(FVW_VTK_Misc),intent(inout) :: mvtk - if ( mvtk%bFileOpen ) then - if(mvtk%bBinary) then - write(mvtk%buffer,'(A,I0)')'POINT_DATA ',mvtk%nPoints - write(mvtk%vtk_unit)trim(mvtk%buffer)//NewLine - else - write(mvtk%vtk_unit,'(A,I0)') 'POINT_DATA ', mvtk%nPoints - endif - endif - end subroutine - - subroutine vtk_point_data_scalar_flat(D,sname,mvtk) - real(ReKi), dimension(:),intent(in)::D - character(len=*),intent(in) ::sname - type(FVW_VTK_Misc),intent(inout) :: mvtk - - if ( mvtk%bFileOpen ) then - if (mvtk%bBinary) then - write(mvtk%vtk_unit)'SCALARS '//trim(sname)//' double'//NewLine - write(mvtk%vtk_unit)'LOOKUP_TABLE default'//NewLine - write(mvtk%vtk_unit)D - write(mvtk%vtk_unit)NewLine - else - write(mvtk%vtk_unit,'(A,A,A)') 'SCALARS ', sname, ' double' - write(mvtk%vtk_unit,'(A)') 'LOOKUP_TABLE default' - write(mvtk%vtk_unit,'(1'//RFMT//')')D - endif - endif - end subroutine - - subroutine vtk_point_data_scalar_2D(D,sname,mvtk) - real(ReKi), dimension(:,:),intent(in)::D - character(len=*),intent(in) ::sname - type(FVW_VTK_Misc),intent(inout) :: mvtk - - if ( mvtk%bFileOpen ) then - if (mvtk%bBinary) then - write(mvtk%vtk_unit)'SCALARS '//trim(sname)//' double'//NewLine - write(mvtk%vtk_unit)'LOOKUP_TABLE default'//NewLine - write(mvtk%vtk_unit)D - write(mvtk%vtk_unit)NewLine - else - write(mvtk%vtk_unit,'(A,A,A)') 'SCALARS ', sname, ' double' - write(mvtk%vtk_unit,'(A)') 'LOOKUP_TABLE default' - write(mvtk%vtk_unit,'(1'//RFMT//')')D - endif - endif - end subroutine - - subroutine vtk_point_data_scalar_grid(D,sname,mvtk) - real(ReKi), dimension(:,:,:,:),intent(in)::D - character(len=*),intent(in) ::sname - type(FVW_VTK_Misc),intent(inout) :: mvtk - - if ( mvtk%bFileOpen ) then - if (mvtk%bBinary) then - write(mvtk%vtk_unit)'SCALARS '//trim(sname)//' double'//NewLine - write(mvtk%vtk_unit)'LOOKUP_TABLE default'//NewLine - write(mvtk%vtk_unit)D - write(mvtk%vtk_unit)NewLine - else - write(mvtk%vtk_unit,'(A,A,A)') 'SCALARS ', sname, ' double' - write(mvtk%vtk_unit,'(A)') 'LOOKUP_TABLE default' - write(mvtk%vtk_unit,'(1'//RFMT//')')D - endif - endif - end subroutine - - subroutine vtk_point_data_scalar_grid2D(D,sname,mvtk) - real(ReKi), dimension(:,:,:),intent(in)::D - character(len=*),intent(in) ::sname - type(FVW_VTK_Misc),intent(inout) :: mvtk - - if ( mvtk%bFileOpen ) then - if (mvtk%bBinary) then - write(mvtk%vtk_unit)'SCALARS '//trim(sname)//' double'//NewLine - write(mvtk%vtk_unit)'LOOKUP_TABLE default'//NewLine - write(mvtk%vtk_unit)D - write(mvtk%vtk_unit)NewLine - else - write(mvtk%vtk_unit,'(A,A,A)') 'SCALARS ', sname, ' double' - write(mvtk%vtk_unit,'(A)') 'LOOKUP_TABLE default' - write(mvtk%vtk_unit,'(1'//RFMT//')')D - endif - endif - end subroutine - - !> - subroutine vtk_point_data_vector_flat(D,sname,mvtk) - real(ReKi), dimension(:,:),intent(in) :: D !< 3 x n - character(len=*),intent(in) ::sname - type(FVW_VTK_Misc),intent(inout) :: mvtk - if ( mvtk%bFileOpen ) then - if (mvtk%bBinary) then - write(mvtk%vtk_unit)'VECTORS '//trim(sname)//' double'//NewLine - write(mvtk%vtk_unit)D - write(mvtk%vtk_unit)NewLine - else - write(mvtk%vtk_unit,'(A,A,A)') 'VECTORS ', sname, ' double' - write(mvtk%vtk_unit,'(3'//RFMT//')')D - endif - endif - end subroutine - !> - subroutine vtk_point_data_vector_grid(D,sname,mvtk) - real(ReKi), dimension(:,:,:,:),intent(in) :: D !< 3 x n - character(len=*),intent(in) ::sname - type(FVW_VTK_Misc),intent(inout) :: mvtk - if ( mvtk%bFileOpen ) then - if (mvtk%bBinary) then - write(mvtk%vtk_unit)'VECTORS '//trim(sname)//' double'//NewLine - write(mvtk%vtk_unit)D - write(mvtk%vtk_unit)NewLine - else - write(mvtk%vtk_unit,'(A,A,A)') 'VECTORS ', sname, ' double' - write(mvtk%vtk_unit,'(3'//RFMT//')')D - endif - endif - end subroutine - !> - subroutine vtk_point_data_vector_grid2D(D,sname,mvtk) - real(ReKi), dimension(:,:,:),intent(in) :: D !< - character(len=*),intent(in) ::sname - type(FVW_VTK_Misc),intent(inout) :: mvtk - if ( mvtk%bFileOpen ) then - if (mvtk%bBinary) then - write(mvtk%vtk_unit)'VECTORS '//trim(sname)//' double'//NewLine - write(mvtk%vtk_unit)D - write(mvtk%vtk_unit)NewLine - else - write(mvtk%vtk_unit,'(A,A,A)') 'VECTORS ', sname, ' double' - write(mvtk%vtk_unit,'(3'//RFMT//')')D - endif - endif - end subroutine - - - ! ------------------------------------------------------------------------- - ! --- CELL DATA - ! ------------------------------------------------------------------------- - subroutine vtk_cell_data_init(mvtk) - type(FVW_VTK_Misc),intent(inout) :: mvtk - if ( mvtk%bFileOpen ) then - if (mvtk%bBinary) then - write(mvtk%buffer,'(A,I0)')'CELL_DATA ',mvtk%nData - write(mvtk%vtk_unit)trim(mvtk%buffer)//NewLine - else - write(mvtk%vtk_unit,'(A,I0)') 'CELL_DATA ', mvtk%nData - endif - endif - end subroutine - - subroutine vtk_cell_data_scalar_1d(D,sname,mvtk) - real(ReKi), dimension(:),intent(in)::D - character(len=*),intent(in) ::sname - type(FVW_VTK_Misc),intent(inout) :: mvtk - - if ( mvtk%bFileOpen ) then - if (mvtk%bBinary) then - write(mvtk%vtk_unit)'SCALARS '//trim(sname)//' double 1'//NewLine - write(mvtk%vtk_unit)'LOOKUP_TABLE default'//NewLine - write(mvtk%vtk_unit)D - write(mvtk%vtk_unit)NewLine - else - write(mvtk%vtk_unit,fmt='(A,A,A)') 'SCALARS ', sname, ' double' - write(mvtk%vtk_unit,'(A)') 'LOOKUP_TABLE default' - write(mvtk%vtk_unit,'(1'//RFMT//')')D - endif - endif - end subroutine - - subroutine vtk_cell_data_scalar_2d(D,sname,mvtk) - real(ReKi), dimension(:,:),intent(in)::D - character(len=*),intent(in) ::sname - type(FVW_VTK_Misc),intent(inout) :: mvtk - - if ( mvtk%bFileOpen ) then - if (mvtk%bBinary) then - write(mvtk%vtk_unit)'SCALARS '//trim(sname)//' double 1'//NewLine - write(mvtk%vtk_unit)'LOOKUP_TABLE default'//NewLine - write(mvtk%vtk_unit)D - write(mvtk%vtk_unit)NewLine - else - write(mvtk%vtk_unit,fmt='(A,A,A)') 'SCALARS ', sname, ' double' - write(mvtk%vtk_unit,'(A)') 'LOOKUP_TABLE default' - write(mvtk%vtk_unit,'(1'//RFMT//')')D - endif - endif - end subroutine - - - subroutine vtk_cell_data_vector(D,sname,mvtk) - real(ReKi), dimension(:,:),intent(in) :: D !< 3 x n - character(len=*),intent(in) ::sname - type(FVW_VTK_Misc),intent(inout) :: mvtk - if ( mvtk%bFileOpen ) then - if (mvtk%bBinary) then - write(mvtk%vtk_unit)'VECTORS '//trim(sname)//' double'//NewLine - write(mvtk%vtk_unit)D - write(mvtk%vtk_unit)NewLine - else - write(mvtk%vtk_unit,'(A,A,A)') 'VECTORS ', sname, ' double' - write(mvtk%vtk_unit,'(3'//RFMT//')')D - endif - endif - end subroutine - - ! --------------------------------------------------------------------------------} - ! --- VTK Tools - ! --------------------------------------------------------------------------------{ - !> Exports a Plane From a mesh - subroutine export_plane_grid3d(fname,v1,v2,v3,Values,mvtk) - character(len=*),intent(in) :: fname - real(ReKi),dimension(:), intent(in) :: v1,v2,v3 - real(ReKi),dimension(:,:,:,:), intent(in) :: Values - type(FVW_VTK_Misc),intent(inout) :: mvtk - ! Variables - integer :: nD - - ! Writting - if ( vtk_new_ascii_file(trim(fname),'grid',mvtk)) then - nD=size(Values,1) - call vtk_dataset_rectilinear(v1,v2,v3,mvtk) - ! Output as a structured grid, No need to reorder - call vtk_point_data_init(mvtk) - ! Could be a function of nDim, be careful - if(nD==3) then - call vtk_point_data_vector(Values(1:3,:,:,:),'Velocity',mvtk) ! Label... - endif - - call vtk_close_file(mvtk) - endif ! file opening - end subroutine - - !> Exports a Plane From a mesh - subroutine export_plane_grid2d(fname,v1,v2,v3,Values,mvtk) - character(len=*),intent(in) :: fname - real(ReKi),dimension(:), intent(in) :: v1,v2,v3 - real(ReKi),dimension(:,:,:), intent(in) :: Values - type(FVW_VTK_Misc),intent(inout) :: mvtk - ! Variables - integer :: nD - - ! Writting - if ( vtk_new_ascii_file(trim(fname),'plane',mvtk) ) then - nD=size(Values,1) - call vtk_dataset_rectilinear(v1,v2,v3,mvtk) - ! Output as a structured grid, No need to reorder - call vtk_point_data_init(mvtk) - ! Could be a function of nDim, be careful - if(nD==3) then - call vtk_point_data_vector(Values(1:3,:,:),'Velocity',mvtk) ! Label... - endif - - call vtk_close_file(mvtk) - endif ! file opening - end subroutine -end module FVW_VTK +module VTK + !use PrecisionMod, only: ReKi + use NWTC_Library, only: ReKi, GetNewUnit, NewLine, WrScr + implicit none +! character(8), parameter :: RFMT='F14.5' + !character(8), parameter :: RFMT='E24.15E3' + character(8), parameter :: RFMT='E17.8E3' + character(8), parameter :: IFMT='I7' + + ! Internal type to ensure the same options are used in between calls for the functions + TYPE, PUBLIC :: VTK_Misc + integer :: vtk_unit + logical :: bFileOpen=.false. + + integer :: nData=0; + integer :: nPoints=0; + + logical :: bBinary = .false. + character(len=255) :: buffer + + ! Reference Frame + real(ReKi),dimension(3,3) :: T_g2b + real(ReKi),dimension(3) :: PO_g + END TYPE VTK_Misc + + interface vtk_dataset_structured_grid; module procedure & + vtk_dataset_structured_grid_flat, & + vtk_dataset_structured_grid_grid + end interface + + interface vtk_point_data_vector; module procedure & + vtk_point_data_vector_flat, & + vtk_point_data_vector_grid2D,& + vtk_point_data_vector_grid + end interface + interface vtk_point_data_scalar; module procedure & + vtk_point_data_scalar_flat, & + vtk_point_data_scalar_2D, & + vtk_point_data_scalar_grid2D, & + vtk_point_data_scalar_grid + end interface + interface vtk_cell_data_scalar; module procedure & + vtk_cell_data_scalar_1d,& + vtk_cell_data_scalar_2d + end interface + + public + +contains + + subroutine vtk_misc_init(mvtk) + type(VTK_Misc),intent(inout) :: mvtk + mvtk%vtk_unit = -1 !< VTK output unit [-] + mvtk%bFileOpen = .false. !< binary file is open [-] + mvtk%bBinary = .false. !< write binary files [-] + mvtk%nData = 0 !< number of data lines [-] + mvtk%nPoints = 0 !< number of points [-] + end subroutine + + !> + subroutine set_vtk_binary_format(bBin,mvtk) + logical, intent(in)::bBin + type(VTK_Misc),intent(inout) :: mvtk + mvtk%bBinary=bBin + end subroutine + + + !> Save a coordinate transform + ! ALL VTK Will be exported in this coordinate system! + subroutine set_vtk_coordinate_transform(T_g2b_in,PO_g_in,mvtk) + real(ReKi),dimension(3,3), intent(in) :: T_g2b_in + real(ReKi),dimension(3) , intent(in) :: PO_g_in + type(VTK_Misc),intent(inout) :: mvtk + mvtk%T_g2b=T_g2b_in + mvtk%PO_g=PO_g_in + end subroutine + + logical function vtk_new_ascii_file(filename,label,mvtk) + !use MainIO, only: get_free_unit ,check_io + !use MainIOData, only: bSTOP_ALLOWED + !use FileSystem, only: file_exists + !use Logging, only: log_warning,log_error,log_info + ! + character(len=*),intent(in) :: filename + character(len=*),intent(in) :: label + type(VTK_Misc),intent(inout) :: mvtk + ! + integer :: iostatvar + logical :: b + + if (.not. mvtk%bFileOpen) then + CALL GetNewUnit( mvtk%vtk_unit ) + if (mvtk%bBinary) then + ! Fortran 2003 stream, otherwise intel fortran ! + !form='UNFORMATTED',access='SEQUENTIAL',action='WRITE',convert='BIG_ENDIAN',recordtype='STREAM',buffered='YES', + !print*,'Not available for this compiler' !COMPAQ-COMPILER + !STOP !COMPAQ-COMPILER +!bjj: CONVERT is non-standard, so maybe this should be part of Sys*.f90? Like OpenUnfInpBEFile()? +!eb : Commented out for now since it doesnt work anymore anyway (worked 5 years ago..). Adding binary would be great though! + !open(unit = mvtk%vtk_unit,file= trim(adjustl(filename)),form='UNFORMATTED',access = 'stream',& !OTHER-COMPILER + ! action = 'WRITE',convert= 'BIG_ENDIAN',iostat=iostatvar,status='replace') !OTHER-COMPILER + call WrScr('Binary VTK output not available at the moment') + STOP ! Temporary, but easiest for now. + else + open(mvtk%vtk_unit,file=trim(adjustl(filename)),iostat=iostatvar,action="write",status='replace') + endif + if (iostatvar == 0) then + if (mvtk%bBinary) then + write(mvtk%vtk_unit)'# vtk DataFile Version 3.0'//NewLine + write(mvtk%vtk_unit)trim(label)//NewLine + write(mvtk%vtk_unit)'BINARY'//NewLine + else + write(mvtk%vtk_unit,'(a)') '# vtk DataFile Version 2.0' + write(mvtk%vtk_unit,'(a)') trim(label) + write(mvtk%vtk_unit,'(a)') 'ASCII' + write(mvtk%vtk_unit,'(a)') ' ' + endif + + mvtk%bFileOpen=.true. + mvtk%nData=-1; + endif + else + b=.false. + !call log_error('VTK: Cannot open two vtk files at the same time, call vtk_close first') + endif + if (iostatvar ==0) then + vtk_new_ascii_file=.true. + else + vtk_new_ascii_file=.false. + endif + end function + + subroutine vtk_close_file(mvtk) + type(VTK_Misc),intent(inout) :: mvtk + if ( mvtk%bFileOpen ) then + close(mvtk%vtk_unit) + mvtk%bFileOpen=.false. + endif + endsubroutine + + + ! ------------------------------------------------------------------------- + ! --- POLYDATA STUFF + ! ------------------------------------------------------------------------- + subroutine vtk_dataset_polydata(Points,mvtk,bladeFrame) + real(ReKi), dimension(:,:),intent(in) :: Points !< 3 x n + type(VTK_Misc),intent(inout) :: mvtk + logical, intent(in) :: bladeFrame + integer :: i + if ( mvtk%bFileOpen ) then + mvtk%nPoints=size(Points,2) + if (mvtk%bBinary) then + write(mvtk%vtk_unit)'DATASET POLYDATA'//NewLine + write(mvtk%buffer,'(A,I0,A)') 'POINTS ', mvtk%nPoints ,' double' + write(mvtk%vtk_unit)trim(mvtk%buffer)//NewLine + if (bladeFrame) then + do i=1,mvtk%nPoints + write(mvtk%vtk_unit)matmul(mvtk%T_g2b,Points(1:3,i)-mvtk%PO_g) + enddo + else + do i=1,mvtk%nPoints + write(mvtk%vtk_unit)Points(1:3,i) + enddo + endif + write(mvtk%vtk_unit)NewLine + else + write(mvtk%vtk_unit,'(A)') 'DATASET POLYDATA' + write(mvtk%vtk_unit,'(A,I0,A)') 'POINTS ', mvtk%nPoints ,' double' + if (bladeFrame) then + do i=1,mvtk%nPoints + write(mvtk%vtk_unit,'(3'//RFMT//')') matmul(mvtk%T_g2b,Points(1:3,i)-mvtk%PO_g) + enddo + else + do i=1,mvtk%nPoints + write(mvtk%vtk_unit,'(3'//RFMT//')') Points(1:3,i) + enddo + endif + write(mvtk%vtk_unit,*) ' ' + endif + endif + end subroutine + + + subroutine vtk_lines(L,mvtk) + integer, dimension(:,:),intent(in) :: L !< 2 x n + type(VTK_Misc),intent(inout) :: mvtk + + integer :: i + + if ( mvtk%bFileOpen ) then + mvtk%nData=size(L,2) + if (mvtk%bBinary) then + write(mvtk%buffer,'(A,I0,A,I0)')'LINES ',mvtk%nData,' ',3*mvtk%nData + write(mvtk%vtk_unit)trim(mvtk%buffer)//NewLine + do i=1,mvtk%nData + write(mvtk%vtk_unit)2,L(1:2,i) + enddo + write(mvtk%vtk_unit)NewLine + else + write(mvtk%vtk_unit,'(A,I0,A,I0)')'LINES ',mvtk%nData,' ',3*mvtk%nData + do i=1,mvtk%nData + write(mvtk%vtk_unit,'(3'//IFMT//')') 2, L(1:2,i) + enddo + write(mvtk%vtk_unit,*) ' ' + endif + endif + end subroutine + + subroutine vtk_quad(Q,mvtk) + integer, dimension(:,:),intent(in) :: Q !< 4 x n + type(VTK_Misc),intent(inout) :: mvtk + integer :: i + if ( mvtk%bFileOpen ) then + mvtk%nData=size(Q,2) + if (mvtk%bBinary) then + write(mvtk%buffer,'(A,I0,A,I0)')'POLYGONS ',mvtk%nData,' ',5*mvtk%nData + write(mvtk%vtk_unit)trim(mvtk%buffer)//NewLine + do i=1,mvtk%nData + write(mvtk%vtk_unit)4,Q(1:4,i) + enddo + write(mvtk%vtk_unit)NewLine + else + write(mvtk%vtk_unit,'(A,I0,A,I0)') 'POLYGONS ', mvtk%nData,' ',5*mvtk%nData + do i=1,mvtk%nData + write(mvtk%vtk_unit,'(5'//IFMT//')') 4, Q(1:4,i) + enddo + write(mvtk%vtk_unit,*) ' ' + endif + endif + end subroutine + + ! ------------------------------------------------------------------------- + ! --- RECTILINEAR + ! ------------------------------------------------------------------------- + subroutine vtk_dataset_rectilinear(v1,v2,v3,mvtk) + real(ReKi), dimension(:),intent(in) :: v1,v2,v3 !< n + type(VTK_Misc),intent(inout) :: mvtk + + if ( mvtk%bFileOpen ) then + mvtk%nPoints=size(v1)*size(v2)*size(v3) + if (mvtk%bBinary) then + write(mvtk%vtk_unit) 'DATASET RECTILINEAR_GRID'//NewLine + write(mvtk%buffer,'(A,I0,A,I0,A,I0)') 'DIMENSIONS ', size(v1),' ',size(v2),' ',size(v3) + write(mvtk%vtk_unit) trim(mvtk%buffer)//NewLine + write(mvtk%buffer,'(A,I0,A)') 'X_COORDINATES ', size(v1), ' double' + write(mvtk%vtk_unit) trim(mvtk%buffer)//NewLine + write(mvtk%vtk_unit)v1 + write(mvtk%vtk_unit)NewLine + write(mvtk%buffer,'(A,I0,A)') 'Y_COORDINATES ', size(v2), ' double' + write(mvtk%vtk_unit) trim(mvtk%buffer)//NewLine + write(mvtk%vtk_unit)v2 + write(mvtk%vtk_unit)NewLine + write(mvtk%buffer,'(A,I0,A)') 'Z_COORDINATES ', size(v3), ' double' + write(mvtk%vtk_unit) trim(mvtk%buffer)//NewLine + write(mvtk%vtk_unit)v3 + !write(mvtk%vtk_unit)NewLine + else + write(mvtk%vtk_unit,'(A)') 'DATASET RECTILINEAR_GRID' + write(mvtk%vtk_unit,'(A,I0,A,I0,A,I0)') 'DIMENSIONS ', size(v1),' ',size(v2),' ',size(v3) + write(mvtk%vtk_unit,'(A,I0,A)') 'X_COORDINATES ', size(v1), ' double' + write(mvtk%vtk_unit,'('//RFMT//')') v1 + write(mvtk%vtk_unit,'(A,I0,A)') 'Y_COORDINATES ', size(v2), ' double' + write(mvtk%vtk_unit,'('//RFMT//')') v2 + write(mvtk%vtk_unit,'(A,I0,A)') 'Z_COORDINATES ', size(v3), ' double' + write(mvtk%vtk_unit,'('//RFMT//')') v3 + write(mvtk%vtk_unit,*) ' ' + endif + endif + end subroutine + + subroutine vtk_dataset_structured_points(x0,dx,n,mvtk) + real(ReKi), dimension(3), intent(in) :: x0 !< origin + real(ReKi), dimension(3), intent(in) :: dx !< spacing + integer, dimension(3), intent(in) :: n !< length + type(VTK_Misc),intent(inout) :: mvtk + + if ( mvtk%bFileOpen ) then + mvtk%nPoints=n(1)*n(2)*n(3) + if (mvtk%bBinary) then + write(mvtk%vtk_unit) 'DATASET STRUCTURED_POINTS'//NewLine + write(mvtk%buffer,'(A,I0,A,I0,A,I0)') 'DIMENSIONS ',n(1),' ',n(2),' ',n(3) + write(mvtk%vtk_unit) trim(mvtk%buffer)//NewLine + write(mvtk%buffer,'(A,3F16.8)') 'ORIGIN ', x0 + write(mvtk%vtk_unit) trim(mvtk%buffer)//NewLine + write(mvtk%buffer,'(A,3F16.8)') 'SPACING ', dx + write(mvtk%vtk_unit) trim(mvtk%buffer)//NewLine + else + write(mvtk%vtk_unit,'(A)') 'DATASET STRUCTURED_POINTS' + write(mvtk%vtk_unit,'(A,I0,A,I0,A,I0)') 'DIMENSIONS ', n(1),' ',n(2),' ',n(3) + write(mvtk%vtk_unit,'(A,3F16.8,A)') 'ORIGIN ',x0 + write(mvtk%vtk_unit,'(A,3F16.8,A)') 'SPACING ',dx + endif + endif + end subroutine + + + ! ------------------------------------------------------------------------- + ! --- STRUCTURED GRID (Points dumped without for loop since memory is in proper order) + ! ------------------------------------------------------------------------- + !> Subroutine using flat data as input (not in natural order) + subroutine vtk_dataset_structured_grid_flat(D,n1,n2,n3,mvtk) + integer , intent(in) :: n1,n2,n3 + real(ReKi), dimension(:,:),intent(in)::D + type(VTK_Misc),intent(inout) :: mvtk + if ( mvtk%bFileOpen ) then + mvtk%nPoints=n1*n2*n3 + if (mvtk%bBinary) then + write(mvtk%vtk_unit) 'DATASET STRUCTURED_GRID'//NewLine + write(mvtk%buffer,'(A,I0,A,I0,A,I0)') 'DIMENSIONS ', n1,' ',n2,' ',n3 + write(mvtk%vtk_unit) trim(mvtk%buffer)//NewLine + write(mvtk%buffer,'(A,I0,A)') 'POINTS ', mvtk%nPoints, ' double' + write(mvtk%vtk_unit) trim(mvtk%buffer)//NewLine + write(mvtk%vtk_unit)D + write(mvtk%vtk_unit)NewLine + else + write(mvtk%vtk_unit,'(A)') 'DATASET STRUCTURED_GRID' + write(mvtk%vtk_unit,'(A,I0,A,I0,A,I0)') 'DIMENSIONS ', n1,' ',n2,' ',n3 + write(mvtk%vtk_unit,'(A,I0,A)') 'POINTS ', mvtk%nPoints, ' double' + write(mvtk%vtk_unit,'(3'//RFMT//')')D + write(mvtk%vtk_unit,*) ' ' + endif + endif + end subroutine + + !> Using Grid data 4d as input + subroutine vtk_dataset_structured_grid_grid(D,n1,n2,n3,mvtk) + integer , intent(in) :: n1,n2,n3 + real(ReKi), dimension(:,:,:,:),intent(in)::D + type(VTK_Misc),intent(inout) :: mvtk + + if ( mvtk%bFileOpen ) then + mvtk%nPoints=n1*n2*n3 + if (mvtk%bBinary) then + write(mvtk%vtk_unit) 'DATASET STRUCTURED_GRID'//NewLine + write(mvtk%buffer,'(A,I0,A,I0,A,I0)') 'DIMENSIONS ', n1,' ',n2,' ',n3 + write(mvtk%vtk_unit) trim(mvtk%buffer)//NewLine + write(mvtk%buffer,'(A,I0,A)') 'POINTS ', mvtk%nPoints, ' double' + write(mvtk%vtk_unit) trim(mvtk%buffer)//NewLine + write(mvtk%vtk_unit)D + write(mvtk%vtk_unit)NewLine + else + write(mvtk%vtk_unit,'(A)') 'DATASET STRUCTURED_GRID' + write(mvtk%vtk_unit,'(A,I0,A,I0,A,I0)') 'DIMENSIONS ', n1,' ',n2,' ',n3 + write(mvtk%vtk_unit,'(A,I0,A)') 'POINTS ', mvtk%nPoints, ' double' + write(mvtk%vtk_unit,'(3'//RFMT//')')D + write(mvtk%vtk_unit,*) ' ' + endif + endif + end subroutine + + + + ! ------------------------------------------------------------------------- + ! --- POINT DATA + ! ------------------------------------------------------------------------- + subroutine vtk_point_data_init(mvtk) + type(VTK_Misc),intent(inout) :: mvtk + if ( mvtk%bFileOpen ) then + if(mvtk%bBinary) then + write(mvtk%buffer,'(A,I0)')'POINT_DATA ',mvtk%nPoints + write(mvtk%vtk_unit)trim(mvtk%buffer)//NewLine + else + write(mvtk%vtk_unit,'(A,I0)') 'POINT_DATA ', mvtk%nPoints + endif + endif + end subroutine + + subroutine vtk_point_data_scalar_flat(D,sname,mvtk) + real(ReKi), dimension(:),intent(in)::D + character(len=*),intent(in) ::sname + type(VTK_Misc),intent(inout) :: mvtk + + if ( mvtk%bFileOpen ) then + if (mvtk%bBinary) then + write(mvtk%vtk_unit)'SCALARS '//trim(sname)//' double'//NewLine + write(mvtk%vtk_unit)'LOOKUP_TABLE default'//NewLine + write(mvtk%vtk_unit)D + write(mvtk%vtk_unit)NewLine + else + write(mvtk%vtk_unit,'(A,A,A)') 'SCALARS ', sname, ' double' + write(mvtk%vtk_unit,'(A)') 'LOOKUP_TABLE default' + write(mvtk%vtk_unit,'(1'//RFMT//')')D + endif + endif + end subroutine + + subroutine vtk_point_data_scalar_2D(D,sname,mvtk) + real(ReKi), dimension(:,:),intent(in)::D + character(len=*),intent(in) ::sname + type(VTK_Misc),intent(inout) :: mvtk + + if ( mvtk%bFileOpen ) then + if (mvtk%bBinary) then + write(mvtk%vtk_unit)'SCALARS '//trim(sname)//' double'//NewLine + write(mvtk%vtk_unit)'LOOKUP_TABLE default'//NewLine + write(mvtk%vtk_unit)D + write(mvtk%vtk_unit)NewLine + else + write(mvtk%vtk_unit,'(A,A,A)') 'SCALARS ', sname, ' double' + write(mvtk%vtk_unit,'(A)') 'LOOKUP_TABLE default' + write(mvtk%vtk_unit,'(1'//RFMT//')')D + endif + endif + end subroutine + + subroutine vtk_point_data_scalar_grid(D,sname,mvtk) + real(ReKi), dimension(:,:,:,:),intent(in)::D + character(len=*),intent(in) ::sname + type(VTK_Misc),intent(inout) :: mvtk + + if ( mvtk%bFileOpen ) then + if (mvtk%bBinary) then + write(mvtk%vtk_unit)'SCALARS '//trim(sname)//' double'//NewLine + write(mvtk%vtk_unit)'LOOKUP_TABLE default'//NewLine + write(mvtk%vtk_unit)D + write(mvtk%vtk_unit)NewLine + else + write(mvtk%vtk_unit,'(A,A,A)') 'SCALARS ', sname, ' double' + write(mvtk%vtk_unit,'(A)') 'LOOKUP_TABLE default' + write(mvtk%vtk_unit,'(1'//RFMT//')')D + endif + endif + end subroutine + + subroutine vtk_point_data_scalar_grid2D(D,sname,mvtk) + real(ReKi), dimension(:,:,:),intent(in)::D + character(len=*),intent(in) ::sname + type(VTK_Misc),intent(inout) :: mvtk + + if ( mvtk%bFileOpen ) then + if (mvtk%bBinary) then + write(mvtk%vtk_unit)'SCALARS '//trim(sname)//' double'//NewLine + write(mvtk%vtk_unit)'LOOKUP_TABLE default'//NewLine + write(mvtk%vtk_unit)D + write(mvtk%vtk_unit)NewLine + else + write(mvtk%vtk_unit,'(A,A,A)') 'SCALARS ', sname, ' double' + write(mvtk%vtk_unit,'(A)') 'LOOKUP_TABLE default' + write(mvtk%vtk_unit,'(1'//RFMT//')')D + endif + endif + end subroutine + + !> + subroutine vtk_point_data_vector_flat(D,sname,mvtk) + real(ReKi), dimension(:,:),intent(in) :: D !< 3 x n + character(len=*),intent(in) ::sname + type(VTK_Misc),intent(inout) :: mvtk + if ( mvtk%bFileOpen ) then + if (mvtk%bBinary) then + write(mvtk%vtk_unit)'VECTORS '//trim(sname)//' double'//NewLine + write(mvtk%vtk_unit)D + write(mvtk%vtk_unit)NewLine + else + write(mvtk%vtk_unit,'(A,A,A)') 'VECTORS ', sname, ' double' + write(mvtk%vtk_unit,'(3'//RFMT//')')D + endif + endif + end subroutine + !> + subroutine vtk_point_data_vector_grid(D,sname,mvtk) + real(ReKi), dimension(:,:,:,:),intent(in) :: D !< 3 x n + character(len=*),intent(in) ::sname + type(VTK_Misc),intent(inout) :: mvtk + if ( mvtk%bFileOpen ) then + if (mvtk%bBinary) then + write(mvtk%vtk_unit)'VECTORS '//trim(sname)//' double'//NewLine + write(mvtk%vtk_unit)D + write(mvtk%vtk_unit)NewLine + else + write(mvtk%vtk_unit,'(A,A,A)') 'VECTORS ', sname, ' double' + write(mvtk%vtk_unit,'(3'//RFMT//')')D + endif + endif + end subroutine + !> + subroutine vtk_point_data_vector_grid2D(D,sname,mvtk) + real(ReKi), dimension(:,:,:),intent(in) :: D !< + character(len=*),intent(in) ::sname + type(VTK_Misc),intent(inout) :: mvtk + if ( mvtk%bFileOpen ) then + if (mvtk%bBinary) then + write(mvtk%vtk_unit)'VECTORS '//trim(sname)//' double'//NewLine + write(mvtk%vtk_unit)D + write(mvtk%vtk_unit)NewLine + else + write(mvtk%vtk_unit,'(A,A,A)') 'VECTORS ', sname, ' double' + write(mvtk%vtk_unit,'(3'//RFMT//')')D + endif + endif + end subroutine + + + ! ------------------------------------------------------------------------- + ! --- CELL DATA + ! ------------------------------------------------------------------------- + subroutine vtk_cell_data_init(mvtk) + type(VTK_Misc),intent(inout) :: mvtk + if ( mvtk%bFileOpen ) then + if (mvtk%bBinary) then + write(mvtk%buffer,'(A,I0)')'CELL_DATA ',mvtk%nData + write(mvtk%vtk_unit)trim(mvtk%buffer)//NewLine + else + write(mvtk%vtk_unit,'(A,I0)') 'CELL_DATA ', mvtk%nData + endif + endif + end subroutine + + subroutine vtk_cell_data_scalar_1d(D,sname,mvtk) + real(ReKi), dimension(:),intent(in)::D + character(len=*),intent(in) ::sname + type(VTK_Misc),intent(inout) :: mvtk + + if ( mvtk%bFileOpen ) then + if (mvtk%bBinary) then + write(mvtk%vtk_unit)'SCALARS '//trim(sname)//' double 1'//NewLine + write(mvtk%vtk_unit)'LOOKUP_TABLE default'//NewLine + write(mvtk%vtk_unit)D + write(mvtk%vtk_unit)NewLine + else + write(mvtk%vtk_unit,fmt='(A,A,A)') 'SCALARS ', sname, ' double' + write(mvtk%vtk_unit,'(A)') 'LOOKUP_TABLE default' + write(mvtk%vtk_unit,'(1'//RFMT//')')D + endif + endif + end subroutine + + subroutine vtk_cell_data_scalar_2d(D,sname,mvtk) + real(ReKi), dimension(:,:),intent(in)::D + character(len=*),intent(in) ::sname + type(VTK_Misc),intent(inout) :: mvtk + + if ( mvtk%bFileOpen ) then + if (mvtk%bBinary) then + write(mvtk%vtk_unit)'SCALARS '//trim(sname)//' double 1'//NewLine + write(mvtk%vtk_unit)'LOOKUP_TABLE default'//NewLine + write(mvtk%vtk_unit)D + write(mvtk%vtk_unit)NewLine + else + write(mvtk%vtk_unit,fmt='(A,A,A)') 'SCALARS ', sname, ' double' + write(mvtk%vtk_unit,'(A)') 'LOOKUP_TABLE default' + write(mvtk%vtk_unit,'(1'//RFMT//')')D + endif + endif + end subroutine + + + subroutine vtk_cell_data_vector(D,sname,mvtk) + real(ReKi), dimension(:,:),intent(in) :: D !< 3 x n + character(len=*),intent(in) ::sname + type(VTK_Misc),intent(inout) :: mvtk + if ( mvtk%bFileOpen ) then + if (mvtk%bBinary) then + write(mvtk%vtk_unit)'VECTORS '//trim(sname)//' double'//NewLine + write(mvtk%vtk_unit)D + write(mvtk%vtk_unit)NewLine + else + write(mvtk%vtk_unit,'(A,A,A)') 'VECTORS ', sname, ' double' + write(mvtk%vtk_unit,'(3'//RFMT//')')D + endif + endif + end subroutine + + ! --------------------------------------------------------------------------------} + ! --- VTK Tools + ! --------------------------------------------------------------------------------{ + !> Exports a Plane From a mesh + subroutine export_plane_grid3d(fname,v1,v2,v3,Values,mvtk) + character(len=*),intent(in) :: fname + real(ReKi),dimension(:), intent(in) :: v1,v2,v3 + real(ReKi),dimension(:,:,:,:), intent(in) :: Values + type(VTK_Misc),intent(inout) :: mvtk + ! Variables + integer :: nD + + ! Writting + if ( vtk_new_ascii_file(trim(fname),'grid',mvtk)) then + nD=size(Values,1) + call vtk_dataset_rectilinear(v1,v2,v3,mvtk) + ! Output as a structured grid, No need to reorder + call vtk_point_data_init(mvtk) + ! Could be a function of nDim, be careful + if(nD==3) then + call vtk_point_data_vector(Values(1:3,:,:,:),'Velocity',mvtk) ! Label... + endif + + call vtk_close_file(mvtk) + endif ! file opening + end subroutine + + !> Exports a Plane From a mesh + subroutine export_plane_grid2d(fname,v1,v2,v3,Values,mvtk) + character(len=*),intent(in) :: fname + real(ReKi),dimension(:), intent(in) :: v1,v2,v3 + real(ReKi),dimension(:,:,:), intent(in) :: Values + type(VTK_Misc),intent(inout) :: mvtk + ! Variables + integer :: nD + + ! Writting + if ( vtk_new_ascii_file(trim(fname),'plane',mvtk) ) then + nD=size(Values,1) + call vtk_dataset_rectilinear(v1,v2,v3,mvtk) + ! Output as a structured grid, No need to reorder + call vtk_point_data_init(mvtk) + ! Could be a function of nDim, be careful + if(nD==3) then + call vtk_point_data_vector(Values(1:3,:,:),'Velocity',mvtk) ! Label... + endif + + call vtk_close_file(mvtk) + endif ! file opening + end subroutine +end module VTK diff --git a/modules/subdyn/src/Yaml.f90 b/modules/nwtc-library/src/Yaml.f90 similarity index 100% rename from modules/subdyn/src/Yaml.f90 rename to modules/nwtc-library/src/Yaml.f90 diff --git a/modules/subdyn/CMakeLists.txt b/modules/subdyn/CMakeLists.txt index 8d56cc80f8..452832fea3 100644 --- a/modules/subdyn/CMakeLists.txt +++ b/modules/subdyn/CMakeLists.txt @@ -26,7 +26,6 @@ set(SUBDYN_SOURCES src/SubDyn_Output_Params.f90 src/SubDyn_Tests.f90 src/IntegerList.f90 - src/Yaml.f90 src/SubDyn_Types.f90 ) diff --git a/modules/wakedynamics/CMakeLists.txt b/modules/wakedynamics/CMakeLists.txt index 53c1ee50d6..0fbfa59183 100644 --- a/modules/wakedynamics/CMakeLists.txt +++ b/modules/wakedynamics/CMakeLists.txt @@ -24,7 +24,7 @@ set(WD_LIBS_SOURCES ) add_library(wdlib ${WD_LIBS_SOURCES}) -target_link_libraries(wdlib aerodynlib nwtclibs) # TEMPORARY FOR VTK +target_link_libraries(wdlib nwtclibs) diff --git a/modules/wakedynamics/src/WakeDynamics.f90 b/modules/wakedynamics/src/WakeDynamics.f90 index bc5ed2bb3e..0f0edbcbdc 100644 --- a/modules/wakedynamics/src/WakeDynamics.f90 +++ b/modules/wakedynamics/src/WakeDynamics.f90 @@ -1475,7 +1475,7 @@ subroutine WD_CalcOutput( t, u, p, x, xd, z, OtherState, y, m, errStat, errMsg ) ! All of the calculated output channels are placed into the m%AllOuts(:), while the channels selected for outputs are ! placed in the y%WriteOutput(:) array. !.................................................................................................................................. - use FVW_VTK ! + use VTK ! REAL(DbKi), INTENT(IN ) :: t !< Current simulation time in seconds TYPE(WD_InputType), INTENT(IN ) :: u !< Inputs at Time t @@ -1498,7 +1498,7 @@ subroutine WD_CalcOutput( t, u, p, x, xd, z, OtherState, y, m, errStat, errMsg ) character(*), parameter :: RoutineName = 'WD_CalcOutput' real(ReKi) :: correction(3) character(1024) :: Filename - type(FVW_VTK_Misc) :: mvtk + type(VTK_Misc) :: mvtk real(ReKi), dimension(3) :: dx errStat = ErrID_None errMsg = "" diff --git a/vs-build/AeroDyn/AeroDyn_Driver.vfproj b/vs-build/AeroDyn/AeroDyn_Driver.vfproj index 382653666f..9d916b6141 100644 --- a/vs-build/AeroDyn/AeroDyn_Driver.vfproj +++ b/vs-build/AeroDyn/AeroDyn_Driver.vfproj @@ -368,9 +368,6 @@ - - - @@ -1027,6 +1024,7 @@ + diff --git a/vs-build/AeroDyn_Inflow_c_lib/AeroDyn_Inflow_c_lib.vfproj b/vs-build/AeroDyn_Inflow_c_lib/AeroDyn_Inflow_c_lib.vfproj index a839df194b..5b3b302b8f 100644 --- a/vs-build/AeroDyn_Inflow_c_lib/AeroDyn_Inflow_c_lib.vfproj +++ b/vs-build/AeroDyn_Inflow_c_lib/AeroDyn_Inflow_c_lib.vfproj @@ -338,9 +338,6 @@ - - - @@ -997,6 +994,7 @@ + diff --git a/vs-build/BeamDyn/BeamDyn.vfproj b/vs-build/BeamDyn/BeamDyn.vfproj index e476eb1783..9d4954ee06 100644 --- a/vs-build/BeamDyn/BeamDyn.vfproj +++ b/vs-build/BeamDyn/BeamDyn.vfproj @@ -290,6 +290,7 @@ - + + diff --git a/vs-build/FASTlib/FASTlib.vfproj b/vs-build/FASTlib/FASTlib.vfproj index 699b384c91..29c2922616 100644 --- a/vs-build/FASTlib/FASTlib.vfproj +++ b/vs-build/FASTlib/FASTlib.vfproj @@ -150,7 +150,6 @@ - @@ -2274,6 +2273,7 @@ + @@ -2290,7 +2290,8 @@ - + + @@ -2464,8 +2465,7 @@ - - + diff --git a/vs-build/SubDyn/SubDyn.vfproj b/vs-build/SubDyn/SubDyn.vfproj index 06c25bbbf4..b71b4cc7f7 100644 --- a/vs-build/SubDyn/SubDyn.vfproj +++ b/vs-build/SubDyn/SubDyn.vfproj @@ -152,7 +152,8 @@ - + + @@ -174,7 +175,6 @@ - From dd76966b32f1bfcb6d5d83980ff05b4e9e01e998 Mon Sep 17 00:00:00 2001 From: Emmanuel Branlard Date: Fri, 18 Nov 2022 16:56:52 -0700 Subject: [PATCH 2/4] BD: yaml summary file output --- modules/beamdyn/src/BeamDyn.f90 | 14 +- modules/beamdyn/src/BeamDyn_IO.f90 | 198 +++++++++-------------------- 2 files changed, 65 insertions(+), 147 deletions(-) diff --git a/modules/beamdyn/src/BeamDyn.f90 b/modules/beamdyn/src/BeamDyn.f90 index a8b4ff9685..8484dcc76e 100644 --- a/modules/beamdyn/src/BeamDyn.f90 +++ b/modules/beamdyn/src/BeamDyn.f90 @@ -6711,6 +6711,7 @@ END SUBROUTINE BD_GetOP SUBROUTINE BD_WriteMassStiff( p, m, ErrStat, ErrMsg ) + use Yaml, only: yaml_write_array TYPE(BD_ParameterType), INTENT(IN ) :: p !< Parameters TYPE(BD_MiscVarType), INTENT(INOUT) :: m !< misc/optimization variables ! intent(out) so that we can update the accelerations here... INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation @@ -6731,17 +6732,16 @@ SUBROUTINE BD_WriteMassStiff( p, m, ErrStat, ErrMsg ) ! Write out the mass and stiffness in the calculation frame WRITE(m%Un_Sum,'()') - CALL WrMatrix(RESHAPE(m%StifK, (/p%dof_total, p%dof_total/)), m%Un_Sum, p%OutFmt, 'Full stiffness matrix (BD calculation coordinate frame)') + call yaml_write_array(m%Un_Sum, 'K_BD', RESHAPE(m%StifK, (/p%dof_total, p%dof_total/)), p%OutFmt, ErrStat, ErrMsg, comment='Full stiffness matrix (BD calculation coordinate frame).') WRITE(m%Un_Sum,'()') - CALL WrMatrix(RESHAPE(m%MassM, (/p%dof_total, p%dof_total/)), m%Un_Sum, p%OutFmt, 'Full mass matrix (BD calculation coordinate frame)') - - RETURN + call yaml_write_array(m%Un_Sum, 'M_BD', RESHAPE(m%MassM, (/p%dof_total, p%dof_total/)), p%OutFmt, ErrStat, ErrMsg, comment='Full mass matrix (BD calculation coordinate frame)') END SUBROUTINE BD_WriteMassStiff !---------------------------------------------------------------------------------------------------------------------------------- SUBROUTINE BD_WriteMassStiffInFirstNodeFrame( p, x, m, ErrStat, ErrMsg ) + use Yaml, only: yaml_write_array TYPE(BD_ParameterType), INTENT(IN ) :: p !< Parameters TYPE(BD_ContinuousStateType), INTENT(IN ) :: x !< Continuous states at t TYPE(BD_MiscVarType), INTENT(INOUT) :: m !< misc/optimization variables ! intent(out) so that we can update the accelerations here... @@ -6789,10 +6789,8 @@ SUBROUTINE BD_WriteMassStiffInFirstNodeFrame( p, x, m, ErrStat, ErrMsg ) enddo ! Write out the mass and stiffness in the first node frame - WRITE(m%Un_Sum,'()') - CALL WrMatrix(RESHAPE(TmpStifK, (/p%dof_total, p%dof_total/)), m%Un_Sum, p%OutFmt, 'Full stiffness matrix (IEC blade first node coordinate frame)') - WRITE(m%Un_Sum,'()') - CALL WrMatrix(RESHAPE(TmpMassM, (/p%dof_total, p%dof_total/)), m%Un_Sum, p%OutFmt, 'Full mass matrix (IEC blade first node coordinate frame)') + call yaml_write_array(m%Un_Sum, 'K_IEC', TmpStifK, p%OutFmt, ErrStat, ErrMsg, comment='Full stiffness matrix (IEC blade first node coordinate frame)') + call yaml_write_array(m%Un_Sum, 'M_IEC', TmpMassM, p%OutFmt, ErrStat, ErrMsg, comment='Full mass matrix (IEC blade first node coordinate frame)') diff --git a/modules/beamdyn/src/BeamDyn_IO.f90 b/modules/beamdyn/src/BeamDyn_IO.f90 index 1558f29290..fdd5b75e04 100644 --- a/modules/beamdyn/src/BeamDyn_IO.f90 +++ b/modules/beamdyn/src/BeamDyn_IO.f90 @@ -1911,7 +1911,7 @@ END SUBROUTINE Calc_WriteOutput !---------------------------------------------------------------------------------------------------------------------------------- !> This routine generates the summary file, which contains a regurgitation of the input data and interpolated flexible body data. SUBROUTINE BD_PrintSum( p, x, m, InitInp, ErrStat, ErrMsg ) - + use Yaml, only: yaml_write_var, yaml_write_array, yaml_write_list ! passed variables TYPE(BD_ParameterType), INTENT(IN) :: p !< Parameters of the structural dynamics module type(BD_ContinuousStateType), intent(in) :: x !< Continuous states @@ -1930,193 +1930,113 @@ SUBROUTINE BD_PrintSum( p, x, m, InitInp, ErrStat, ErrMsg ) CHARACTER(*), PARAMETER :: FmtDat = '(A,T35,1(:,F13.3))' ! Format for outputting mass and modal data. CHARACTER(*), PARAMETER :: FmtDatT = '(A,T35,1(:,F13.8))' ! Format for outputting time steps. - CHARACTER(30) :: OutPFmt ! Format to print list of selected output channels to summary file + CHARACTER(80) :: OutPFmt ! Format to print list of selected output channels to summary file ! Open the summary file and give it a heading. CALL GetNewUnit( UnSu, ErrStat, ErrMsg ) - CALL OpenFOutFile ( UnSu, TRIM( InitInp%RootName )//'.sum', ErrStat, ErrMsg ) + CALL OpenFOutFile ( UnSu, TRIM( InitInp%RootName )//'.sum.yaml', ErrStat, ErrMsg ) IF ( ErrStat >= AbortErrLev ) RETURN ! Heading: - WRITE (UnSu,'(/,A)') 'This summary information was generated by '//TRIM( GetNVD(BeamDyn_Ver) )// & - ' on '//CurDate()//' at '//CurTime()//'.' - - WRITE (UnSu,'(A,F13.3)') 'Blade mass (kg) ', p%blade_mass - WRITE (UnSu,'(A,F13.3)' ) 'Blade length (m) ', p%blade_length - - WRITE (UnSu,'(A)') 'Blade center of mass (IEC coords): ' - WRITE (UnSu,'(3ES18.5)' ) p%blade_CG(:) - - WRITE (UnSu,'(A)') 'Blade mass moment of inertia: ' - DO i=1,3 - WRITE (UnSu,'(3ES18.5)' ) p%blade_IN(i,:) - ENDDO - - WRITE (UnSu,'(A)') 'Global position vector (IEC coords):' - WRITE (UnSu,'(3ES18.5)' ) p%GlbPos(:) - - WRITE (UnSu,'(A)') 'Global rotation tensor (IEC coords):' - DO i=1,3 - WRITE (UnSu,'(3ES18.5)' ) p%GlbRot(i,:) - ENDDO - - WRITE (UnSu,'(A)') 'Initial blade orientation tensor (relative to global rotation tensor):' - DO i=1,3 - WRITE (UnSu,'(3ES18.5)' ) InitInp%RootOri(i,:) - ENDDO - - WRITE (UnSu,'(A)') 'Global rotation WM parameters (IEC coords):' - WRITE (UnSu,'(3ES18.5)' ) p%Glb_crv(:) - - WRITE (UnSu,'(A)') 'Gravity vector (m/s^2) (IEC coords):' - WRITE (UnSu,'(3ES18.5)' ) p%gravity(:) + WRITE (UnSu,'(A)') '#This summary information was generated by '//TRIM( GetNVD(BeamDyn_Ver) ) + + WRITE (UnSu,'(/,A)') '# --- Main parameters' + call yaml_write_var (UnSu, 'Bld_mass' , p%blade_mass , 'F13.3', ErrStat, ErrMsg, comment='(kg)') + call yaml_write_var (UnSu, 'Bld_length' , p%blade_length , 'F13.3', ErrStat, ErrMsg, comment='(m)') + call yaml_write_list (UnSu, 'Bld_CG' , p%blade_CG , 'ES18.5', ErrStat, ErrMsg, comment='Blade center of mass (IEC coords) (m)') + call yaml_write_array(UnSu, 'Bld_IN' , p%blade_IN , 'ES18.5', ErrStat, ErrMsg, comment='Blade mass moment of inertia') + call yaml_write_list (UnSu, 'GlbPos' , p%GlbPos , 'ES18.5', ErrStat, ErrMsg, comment='Global position vector (IEC coords)') + call yaml_write_array(UnSu, 'GlbRot' , p%GlbRot , 'ES18.5', ErrStat, ErrMsg, comment='Global rotation tensor (IEC coords)') + call yaml_write_array(UnSu, 'BldRootOri' , InitInp%RootOri , 'ES18.5', ErrStat, ErrMsg, comment='Initial blade orientation tensor (relative to global rotation tensor)') + call yaml_write_list (UnSu, 'Glb_crv' , p%Glb_crv , 'ES18.5', ErrStat, ErrMsg, comment='Global rotation WM parameters (IEC coords)') + call yaml_write_list (UnSu, 'Gravity' , p%gravity , 'ES18.5', ErrStat, ErrMsg, comment='Gravity vector (m/s^2) (IEC coords)') !FIXME:analysis_type IF(p%analysis_type .EQ. BD_STATIC_ANALYSIS) THEN - WRITE (UnSu,'(A,T59,A15)') 'Analysis type:','STATIC' + WRITE (UnSu,'(A,T59,A15)') 'Analysis_type:','"STATIC"' ELSEIF(p%analysis_type .EQ. BD_DYNAMIC_ANALYSIS) THEN - WRITE (UnSu,'(A,T59,A15)') 'Analysis type:','DYNAMIC' + WRITE (UnSu,'(A,T59,A15)') 'Analysis_type:','"DYNAMIC"' ELSEIF(p%analysis_type .EQ. BD_DYN_SSS_ANALYSIS) THEN - WRITE (UnSu,'(A,T37,A)') 'Analysis type:','DYNAMIC with quasi-steady-state start' + WRITE (UnSu,'(A,T37,A)') 'Analysis_type:','"DYNAMIC with quasi-steady-state start"' ENDIF - WRITE (UnSu,'(A,T59,1ES15.5)') 'Numerical damping parameter:',p%rhoinf - - WRITE (UnSu,'(A,T59,1ES15.5)') 'Time increment:',p%dt - - WRITE (UnSu,'(A,T59,I15)' ) 'Maximum number of iterations in Newton-Raphson solution:', p%niter - WRITE (UnSu,'(A,T59,1ES15.5)' ) 'Convergence parameter:', p%tol - WRITE (UnSu,'(A,T59,I15)' ) 'Factorization frequency in Newton-Raphson solution:', p%n_fact + call yaml_write_var (UnSu, 'Rhoinf' , p%rhoinf , 'ES15.5', ErrStat, ErrMsg, comment='Numerical damping parameter') + call yaml_write_var (UnSu, 'dt' , p%dt , 'ES15.5', ErrStat, ErrMsg, comment='Time increment') + call yaml_write_var (UnSu, 'niter' , p%niter , 'I15' , ErrStat, ErrMsg, comment='Maximum number of iterations in Newton-Raphson solution') + call yaml_write_var (UnSu, 'tol' , p%tol , 'ES15.5' , ErrStat, ErrMsg, comment='Convergence parameter') + call yaml_write_var (UnSu, 'n_fact' , p%n_fact , 'I15' , ErrStat, ErrMsg, comment='Factorization frequency in Newton-Raphson solution') IF(p%quadrature .EQ. GAUSS_QUADRATURE) THEN - WRITE (UnSu,'(A,T59,A15)') 'Quadrature method: ', 'Gaussian' + WRITE (UnSu,'(A,T59,A15)') 'Quadrature_method: ', 'Gaussian' ELSEIF(p%quadrature .EQ. TRAP_QUADRATURE) THEN - WRITE (UnSu,'(A,T59,A15)') 'Quadrature method: ', 'Trapezoidal' - WRITE (UnSu,'(A,T59,I15)' ) 'FE mesh refinement factor:', p%refine + WRITE (UnSu,'(A,T59,A15)') 'Quadrature_method: ', 'Trapezoidal' + WRITE (UnSu,'(A,T59,I15)' ) 'FE_mesh_refinement_factor:', p%refine ENDIF + WRITE (UnSu,'(A,T59,I15)' ) 'Number_of_elements: ', p%elem_total + WRITE (UnSu,'(A,T59,I15)' ) 'Number_of_nodes: ', p%node_total - WRITE (UnSu,'(A,T59,I15)' ) 'Number of elements: ', p%elem_total - - WRITE (UnSu,'(A,T59,I15)' ) 'Number of nodes: ', p%node_total - - WRITE (UnSu,'(/,A)') 'Initial position vectors (IEC coordinate system)' - k=1 + WRITE (UnSu,'(/,A)') '# --- Initial values and conditions' + ! EB: NOTE: information about node and global node were lost here. Can be reintroduced by creating a matrix with indices and u in it. Or use "label" keyword in Yaml. + ! OK until we introduce more elements + WRITE (UnSu,'(A)') '# Initial position and Weiner-Milenkovic rotation vectors (IEC coordinate system)' DO i=1,p%elem_total - WRITE (UnSu,'(2x,A,I4)') 'Element number: ',i - WRITE (UnSu, '(2x,A,1x,A,1x,3(1x,A))') 'Node', 'Global node',' X ',' Y ',' Z ' - WRITE (UnSu, '(2x,A,1x,A,1x,3(1x,A))') '----', '-----------','-----------------','-----------------','-----------------' - DO j = 1, p%nodes_per_elem - WRITE(UnSu,'(I6,1x,I9,2x,3ES18.5)') j,k,p%uuN0(1:3,j,i) - k=k+1 - ENDDO - k = k-1 - ENDDO - WRITE (UnSu,'(/,A)') 'Initial Weiner-Milenkovic rotation vectors (IEC coordinate system)' - k=1 - DO i=1,p%elem_total - WRITE (UnSu,'(2x,A,I4)') 'Element number: ',i - WRITE (UnSu, '(2x,A,1x,A,1x,3(1x,A))') 'Node', 'Global node',' WM_x ',' WM_y ',' WM_z ' - WRITE (UnSu, '(2x,A,1x,A,1x,3(1x,A))') '----', '-----------','-----------------','-----------------','-----------------' - DO j = 1, p%nodes_per_elem - WRITE(UnSu,'(I6,1x,I9,2x,3ES18.5)') j,k,p%uuN0(4:6,j,i) - k=k+1 - ENDDO - k = k-1 + WRITE (UnSu, '("#", 1x,A,I4)') 'Element number: ',i + WRITE (UnSu, '("#", 6(2x,A))') ' X ',' Y ',' Z ',' WM_x ',' WM_y ',' WM_z ' + WRITE (UnSu, '("#", 6(2x,A))') ' -----------------','-----------------','-----------------','-----------------','-----------------','-----------------' + call yaml_write_array(UnSu, 'Init_Node'//num2lstr(i), transpose(p%uuN0(1:6,:,i)), p%OutFmt, ErrStat, ErrMsg, AllFmt='6(ES18.5,",")') ENDDO - WRITE (UnSu,'(/,A)') 'Quadrature point position vectors' - k=1 - DO i=1,p%elem_total - WRITE (UnSu,'(2x,A,I4)') 'Element number: ',i - WRITE (UnSu, '(2x,A,1x,A,1x,3(1x,A))') ' QP ', ' Global QP ',' X ',' Y ',' Z ' - WRITE (UnSu, '(2x,A,1x,A,1x,3(1x,A))') '----', '-----------','-----------------','-----------------','-----------------' - DO j = 1, p%nqp - WRITE(UnSu,'(I6,1x,I9,2x,3ES18.5)') j,k,p%uu0(1:3,j,i) - k=k+1 - ENDDO - k = k-1 - ENDDO - WRITE (UnSu,'(/,A)') 'Quadrature point rotation vectors' - k=1 + WRITE (UnSu,'(/,A)') '# Quadrature point position and rotation vectors' DO i=1,p%elem_total - WRITE (UnSu,'(2x,A,I4)') 'Element number: ',i - WRITE (UnSu, '(2x,A,1x,A,1x,3(1x,A))') ' QP ', ' Global QP ',' WM_x ',' WM_y ',' WM_z ' - WRITE (UnSu, '(2x,A,1x,A,1x,3(1x,A))') '----', '-----------','-----------------','-----------------','-----------------' - DO j = 1, p%nqp - WRITE(UnSu,'(I6,1x,I9,2x,3ES18.5)') j,k,p%uu0(4:6,j,i) - k=k+1 - ENDDO - k = k-1 + WRITE (UnSu, '("#", 1x,A,I4)') 'Element number: ',i + WRITE (UnSu, '("#", 6(2x,A))') ' X ',' Y ',' Z ',' WM_x ',' WM_y ',' WM_z ' + WRITE (UnSu, '("#", 6(2x,A))') ' -----------------','-----------------','-----------------','-----------------','-----------------','-----------------' + call yaml_write_array(UnSu, 'Init_QP'//num2lstr(i), transpose(p%uu0(1:6,:,i)), p%OutFmt, ErrStat, ErrMsg, AllFmt='6(ES18.5,",")') ENDDO - WRITE (UnSu,'(/,A)') 'Sectional stiffness and mass matrices at quadrature points (in IEC coordinates)' + WRITE (UnSu,'(/,A)') '# Sectional stiffness and mass matrices at quadrature points (in IEC coordinates)' DO i=1,size(p%Stif0_QP,3) - WRITE (UnSu,'(/,A,I4)') 'Quadrature point number: ',i - DO j=1,6 - WRITE(UnSu,'(6ES15.5)') p%Stif0_QP(j,1:6,i) - ENDDO - WRITE(UnSu,'(A)') - DO j=1,6 - WRITE(UnSu,'(6ES15.5)') p%Mass0_QP(j,1:6,i) - ENDDO - ENDDO - - WRITE (UnSu,'(/,A)') 'Initial displacement' - DO i=1,p%node_total - WRITE(UnSu,'(I4,3ES18.5)') i,x%q(1:3,i) - ENDDO - - WRITE (UnSu,'(/,A)') 'Initial rotation' - DO i=1,p%node_total - WRITE(UnSu,'(I4,3ES18.5)') i,x%q(4:6,i) - ENDDO - - WRITE (UnSu,'(/,A)') 'Initial velocity' - DO i=1,p%node_total - WRITE(UnSu,'(I4,3ES18.5)') i,x%dqdt(1:3,i) - ENDDO - - WRITE (UnSu,'(/,A)') 'Initial angular velocity' - DO i=1,p%node_total - WRITE(UnSu,'(I4,3ES18.5)') i,x%dqdt(4:6,i) + WRITE (UnSu,'(A,I4)') '# Quadrature point number: ',i + call yaml_write_array(UnSu, 'Init_K_QP'//num2lstr(i), p%Stif0_QP(:,1:6,i), 'ES15.5', ErrStat, ErrMsg) + call yaml_write_array(UnSu, 'Init_M_QP'//num2lstr(i), p%Mass0_QP(:,1:6,i), 'ES15.5', ErrStat, ErrMsg) ENDDO + call yaml_write_array(UnSu, 'Init_q' , transpose(x%q(1:6,:) ), 'ES18.5', ErrStat, ErrMsg, comment='Initial displacement and rotation') + call yaml_write_array(UnSu, 'Init_dqdt', transpose(x%dqdt(1:6,:)), 'ES18.5', ErrStat, ErrMsg, comment='Initial velocity and angular velocity') + WRITE (UnSu,'(/,A)') '# --- Outputs' select case (p%BldMotionNodeLoc) case (BD_MESH_FE) - WRITE (UnSu, '(/,A)') 'Output nodes located at finite element nodes.' + WRITE (UnSu, '(A)') 'Output_nodes_location: "finite element nodes"' case (BD_MESH_QP) - WRITE (UnSu, '(/,A)') 'Output nodes located at quadrature points.' + WRITE (UnSu, '(A)') 'Output_nodes_location: "quadrature points"' case (BD_MESH_STATIONS) - WRITE (UnSu, '(/,A)') 'Output nodes located at blade propery input station locations.' + WRITE (UnSu, '(A)') 'Output_nodes_location: "blade propery input station locations"' !bjj: need to write where these nodes are located... end select - ! output channels: - OutPFmt = '( I4, 3X,A '//TRIM(Num2LStr(ChanLen))//',1 X, A'//TRIM(Num2LStr(ChanLen))//' )' - WRITE (UnSu,'(//,A,/)') 'Requested Outputs:' - WRITE (UnSu,"( ' Col Parameter Units', /, ' --- -------------- ----------')") + ! Output channels: + OutPFmt = '("# - [", I4, ",", 3X, A'//TRIM(Num2LStr(ChanLen+2))//', "," , 1 X, A'//TRIM(Num2LStr(ChanLen+2))//', "]" )' + WRITE (UnSu, '(A)') "# OutList: # Requested Outputs (Index, Parameter, Unit)" DO I = 0,p%NumOuts - WRITE (UnSu,OutPFmt) I, p%OutParam(I)%Name, p%OutParam(I)%Units + WRITE (UnSu,OutPFmt) I, '"'//trim(p%OutParam(I)%Name)//'"', '"'//trim(p%OutParam(I)%Units)//'"' END DO - WRITE (UnSu,'(15x,A)') - WRITE (UnSu,'(15x,A)') - WRITE (UnSu,'(15x,A)') 'Requested Output Channels at each blade station:' - WRITE (UnSu,'(15x,A)') 'Col Parameter Units' - WRITE (UnSu,'(15x,A)') '---- --------- -----' + WRITE (UnSu,'("#", 15x,A)') + WRITE (UnSu, '(A)') "# OutList_BldNd: # Requested Outputs at each blade station (Index, Parameter, Unit)" DO I = 1,p%BldNd_NumOuts - WRITE (UnSu,OutPFmt) I, p%BldNd_OutParam(I)%Name, p%BldNd_OutParam(I)%Units + WRITE (UnSu,OutPFmt) I, '"'//trim(p%BldNd_OutParam(I)%Name)//'"', '"'//trim(p%BldNd_OutParam(I)%Units)//'"' END DO if ( p%analysis_type /= BD_STATIC_ANALYSIS ) then !dynamic analysis ! we'll add mass and stiffness matrices in the first call to UpdateStates m%Un_Sum = UnSu + WRITE (UnSu,'(/,A)') '# --- System matrices' else CLOSE(UnSu) end if From 5878485bce894b250213ca568f0d8ad3083fb8d0 Mon Sep 17 00:00:00 2001 From: Emmanuel Branlard Date: Fri, 18 Nov 2022 17:45:35 -0700 Subject: [PATCH 3/4] Bug Fix: BD: root name of summary file (see #1336) --- modules/beamdyn/src/Driver_Beam.f90 | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/beamdyn/src/Driver_Beam.f90 b/modules/beamdyn/src/Driver_Beam.f90 index 18b1f87e62..9d0611e66c 100644 --- a/modules/beamdyn/src/Driver_Beam.f90 +++ b/modules/beamdyn/src/Driver_Beam.f90 @@ -98,6 +98,7 @@ PROGRAM BeamDyn_Driver_Program ! initialize the BD_InitInput values not in the driver input file BD_InitInput%RootName = TRIM(BD_Initinput%InputFile) + BD_InitInput%RootName = TRIM(RootName)//'.BD' BD_InitInput%RootDisp = 0.d0 BD_InitInput%DynamicSolve = DvrData%DynamicSolve ! QuasiStatic options handled within the BD code. From 109f974087ac2500d7571297fa4ff976dd5bfd33 Mon Sep 17 00:00:00 2001 From: Emmanuel Branlard Date: Mon, 28 Nov 2022 16:58:20 -0700 Subject: [PATCH 4/4] BD: formatting/renaming of variables in yaml file, comments --- modules/beamdyn/src/BeamDyn.f90 | 4 ++-- modules/beamdyn/src/BeamDyn_IO.f90 | 36 +++++++++++++++--------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/modules/beamdyn/src/BeamDyn.f90 b/modules/beamdyn/src/BeamDyn.f90 index 8484dcc76e..b5d0e1bed1 100644 --- a/modules/beamdyn/src/BeamDyn.f90 +++ b/modules/beamdyn/src/BeamDyn.f90 @@ -6711,7 +6711,7 @@ END SUBROUTINE BD_GetOP SUBROUTINE BD_WriteMassStiff( p, m, ErrStat, ErrMsg ) - use Yaml, only: yaml_write_array + use YAML, only: yaml_write_array TYPE(BD_ParameterType), INTENT(IN ) :: p !< Parameters TYPE(BD_MiscVarType), INTENT(INOUT) :: m !< misc/optimization variables ! intent(out) so that we can update the accelerations here... INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation @@ -6741,7 +6741,7 @@ END SUBROUTINE BD_WriteMassStiff SUBROUTINE BD_WriteMassStiffInFirstNodeFrame( p, x, m, ErrStat, ErrMsg ) - use Yaml, only: yaml_write_array + use YAML, only: yaml_write_array TYPE(BD_ParameterType), INTENT(IN ) :: p !< Parameters TYPE(BD_ContinuousStateType), INTENT(IN ) :: x !< Continuous states at t TYPE(BD_MiscVarType), INTENT(INOUT) :: m !< misc/optimization variables ! intent(out) so that we can update the accelerations here... diff --git a/modules/beamdyn/src/BeamDyn_IO.f90 b/modules/beamdyn/src/BeamDyn_IO.f90 index fdd5b75e04..1ba845f46a 100644 --- a/modules/beamdyn/src/BeamDyn_IO.f90 +++ b/modules/beamdyn/src/BeamDyn_IO.f90 @@ -1911,7 +1911,7 @@ END SUBROUTINE Calc_WriteOutput !---------------------------------------------------------------------------------------------------------------------------------- !> This routine generates the summary file, which contains a regurgitation of the input data and interpolated flexible body data. SUBROUTINE BD_PrintSum( p, x, m, InitInp, ErrStat, ErrMsg ) - use Yaml, only: yaml_write_var, yaml_write_array, yaml_write_list + use YAML, only: yaml_write_var, yaml_write_array, yaml_write_list ! passed variables TYPE(BD_ParameterType), INTENT(IN) :: p !< Parameters of the structural dynamics module type(BD_ContinuousStateType), intent(in) :: x !< Continuous states @@ -1942,15 +1942,15 @@ SUBROUTINE BD_PrintSum( p, x, m, InitInp, ErrStat, ErrMsg ) WRITE (UnSu,'(A)') '#This summary information was generated by '//TRIM( GetNVD(BeamDyn_Ver) ) WRITE (UnSu,'(/,A)') '# --- Main parameters' - call yaml_write_var (UnSu, 'Bld_mass' , p%blade_mass , 'F13.3', ErrStat, ErrMsg, comment='(kg)') - call yaml_write_var (UnSu, 'Bld_length' , p%blade_length , 'F13.3', ErrStat, ErrMsg, comment='(m)') - call yaml_write_list (UnSu, 'Bld_CG' , p%blade_CG , 'ES18.5', ErrStat, ErrMsg, comment='Blade center of mass (IEC coords) (m)') - call yaml_write_array(UnSu, 'Bld_IN' , p%blade_IN , 'ES18.5', ErrStat, ErrMsg, comment='Blade mass moment of inertia') - call yaml_write_list (UnSu, 'GlbPos' , p%GlbPos , 'ES18.5', ErrStat, ErrMsg, comment='Global position vector (IEC coords)') - call yaml_write_array(UnSu, 'GlbRot' , p%GlbRot , 'ES18.5', ErrStat, ErrMsg, comment='Global rotation tensor (IEC coords)') - call yaml_write_array(UnSu, 'BldRootOri' , InitInp%RootOri , 'ES18.5', ErrStat, ErrMsg, comment='Initial blade orientation tensor (relative to global rotation tensor)') - call yaml_write_list (UnSu, 'Glb_crv' , p%Glb_crv , 'ES18.5', ErrStat, ErrMsg, comment='Global rotation WM parameters (IEC coords)') - call yaml_write_list (UnSu, 'Gravity' , p%gravity , 'ES18.5', ErrStat, ErrMsg, comment='Gravity vector (m/s^2) (IEC coords)') + call yaml_write_var (UnSu, 'Mass' , p%blade_mass , 'F13.3', ErrStat, ErrMsg, comment='(kg)') + call yaml_write_var (UnSu, 'Length' , p%blade_length , 'F13.3', ErrStat, ErrMsg, comment='(m)') + call yaml_write_list (UnSu, 'CG' , p%blade_CG , 'ES18.5', ErrStat, ErrMsg, comment='Blade center of mass (IEC coords) (m) from blade root') + call yaml_write_array(UnSu, 'JRoot' , p%blade_IN , 'ES18.5', ErrStat, ErrMsg, comment='Blade mass moment of inertia at blade root. NOTE: from mass distribution only, missing some important inertial contributions (see PR#1337)') + call yaml_write_list (UnSu, 'GlbPos' , p%GlbPos , 'ES18.5', ErrStat, ErrMsg, comment='Global position vector (IEC coords) of blade root') + call yaml_write_array(UnSu, 'GlbRot' , p%GlbRot , 'ES18.5', ErrStat, ErrMsg, comment='Global rotation tensor (IEC coords)') + call yaml_write_array(UnSu, 'RootOri' , InitInp%RootOri , 'ES18.5', ErrStat, ErrMsg, comment='Initial blade orientation tensor (relative to global rotation tensor)') + call yaml_write_list (UnSu, 'GlbCrv' , p%Glb_crv , 'ES18.5', ErrStat, ErrMsg, comment='Global rotation WM parameters (IEC coords)') + call yaml_write_list (UnSu, 'Gravity' , p%gravity , 'ES18.5', ErrStat, ErrMsg, comment='Gravity vector (m/s^2) (IEC coords)') !FIXME:analysis_type IF(p%analysis_type .EQ. BD_STATIC_ANALYSIS) THEN @@ -1979,20 +1979,20 @@ SUBROUTINE BD_PrintSum( p, x, m, InitInp, ErrStat, ErrMsg ) WRITE (UnSu,'(/,A)') '# --- Initial values and conditions' ! EB: NOTE: information about node and global node were lost here. Can be reintroduced by creating a matrix with indices and u in it. Or use "label" keyword in Yaml. ! OK until we introduce more elements - WRITE (UnSu,'(A)') '# Initial position and Weiner-Milenkovic rotation vectors (IEC coordinate system)' + WRITE (UnSu,'(A)') '# Initial position and Weiner-Milenkovic rotation vectors of nodes (IEC coordinate system)' + WRITE (UnSu, '("#", 6(2x,A))') ' X ',' Y ',' Z ',' WM_x ',' WM_y ',' WM_z ' + WRITE (UnSu, '("#", 6(2x,A))') ' -----------------','-----------------','-----------------','-----------------','-----------------','-----------------' DO i=1,p%elem_total WRITE (UnSu, '("#", 1x,A,I4)') 'Element number: ',i - WRITE (UnSu, '("#", 6(2x,A))') ' X ',' Y ',' Z ',' WM_x ',' WM_y ',' WM_z ' - WRITE (UnSu, '("#", 6(2x,A))') ' -----------------','-----------------','-----------------','-----------------','-----------------','-----------------' - call yaml_write_array(UnSu, 'Init_Node'//num2lstr(i), transpose(p%uuN0(1:6,:,i)), p%OutFmt, ErrStat, ErrMsg, AllFmt='6(ES18.5,",")') + call yaml_write_array(UnSu, 'Init_Nodes_E'//num2lstr(i), transpose(p%uuN0(1:6,:,i)), 'DummyFmt', ErrStat, ErrMsg, AllFmt='5(ES18.5,","),ES18.5') ENDDO - WRITE (UnSu,'(/,A)') '# Quadrature point position and rotation vectors' + WRITE (UnSu,'(/,A)') '# Quadrature points position and rotation vectors' + WRITE (UnSu, '("#", 6(2x,A))') ' X ',' Y ',' Z ',' WM_x ',' WM_y ',' WM_z ' + WRITE (UnSu, '("#", 6(2x,A))') ' -----------------','-----------------','-----------------','-----------------','-----------------','-----------------' DO i=1,p%elem_total WRITE (UnSu, '("#", 1x,A,I4)') 'Element number: ',i - WRITE (UnSu, '("#", 6(2x,A))') ' X ',' Y ',' Z ',' WM_x ',' WM_y ',' WM_z ' - WRITE (UnSu, '("#", 6(2x,A))') ' -----------------','-----------------','-----------------','-----------------','-----------------','-----------------' - call yaml_write_array(UnSu, 'Init_QP'//num2lstr(i), transpose(p%uu0(1:6,:,i)), p%OutFmt, ErrStat, ErrMsg, AllFmt='6(ES18.5,",")') + call yaml_write_array(UnSu, 'Init_QP_E'//num2lstr(i), transpose(p%uu0(1:6,:,i)), 'DummyFmt', ErrStat, ErrMsg, AllFmt='5(ES18.5,","),ES18.5') ENDDO WRITE (UnSu,'(/,A)') '# Sectional stiffness and mass matrices at quadrature points (in IEC coordinates)'