enable to non-transposed tensor data

usually, we store per data per cell, i.e. len(shape(x)) == 3 means x is
a tensor.
Due to the use of transposed tensors (due to column-major storage order
in Fortran), we usually want to store the transpose of (3x3) tensors.
Now the default can be changed
This commit is contained in:
Martin Diehl 2019-10-17 07:46:20 +02:00
parent 008f717c08
commit b386dc73b2
2 changed files with 20 additions and 6 deletions

View File

@ -753,7 +753,7 @@ subroutine tElement_init(self,elemType)
self%cell = CELL10 self%cell = CELL10
end select end select
self%NcellNodesPerCell = NCELLNODEPERCELL(self%cellType) self%NcellnodesPerCell = NCELLNODEPERCELL(self%cellType)
select case(self%cellType) select case(self%cellType)
case(1) case(1)

View File

@ -296,21 +296,35 @@ end subroutine results_writeVectorDataset_real
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief stores a tensor dataset in a group !> @brief stores a tensor dataset in a group
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
subroutine results_writeTensorDataset_real(group,dataset,label,description,SIunit) subroutine results_writeTensorDataset_real(group,dataset,label,description,SIunit,transposed)
character(len=*), intent(in) :: label,group,description character(len=*), intent(in) :: label,group,description
character(len=*), intent(in), optional :: SIunit character(len=*), intent(in), optional :: SIunit
logical, intent(in), optional :: transposed
real(pReal), intent(in), dimension(:,:,:) :: dataset real(pReal), intent(in), dimension(:,:,:) :: dataset
integer :: i integer :: i
logical :: T
integer(HID_T) :: groupHandle integer(HID_T) :: groupHandle
real(pReal), dimension(:,:,:), allocatable :: dataset_transposed real(pReal), dimension(:,:,:), allocatable :: dataset_transposed
if(present(transposed)) then
T = transposed
else
T = .true.
endif
allocate(dataset_transposed,mold=dataset) if(T) then
do i=1,size(dataset,3) if(size(dataset_transposed,1) /= size(dataset_transposed,2)) &
dataset_transposed(1:3,1:3,i) = transpose(dataset(1:3,1:3,i)) call IO_error(0,ext_msg='transpose non-symmetric tensor')
enddo allocate(dataset_transposed,mold=dataset)
do i=1,size(dataset_transposed,3)
dataset_transposed(:,:,i) = transpose(dataset(:,:,i))
enddo
else
allocate(dataset_transposed,source=dataset)
endif
groupHandle = results_openGroup(group) groupHandle = results_openGroup(group)