Richard,
I started learning OpenDX recently myself. I have a similar aerodynamics
application for boundary element data, and I found it easier to write a
conversion utility to create the DX header/data files. I've attached a
slightly modified version of my F90 conversion program to create a group
of fields corresponding to your TecPlot zones. Check out the code to see
if it will be helpful to you. You'll need to fill in a bit of code to
read in the data from the TECPLOT file.
Trevor Wood
AME Dept., Boston University
110 Cummington St., Boston, MA, 02215
(617)353-4989
> Hello,
>
> I have spent some time running the samples and reading the doc to learn
> about OpenDX. Now I am trying to build a simple program and I am looking
> for an advice to import my own datas from a TECPLOT file.
>
> My test program is very simple :
>
> import->autocolor->rubbersheet-> image
>
> My datas are typically velocities and pressures at the surface of a 3D
> object (an aircraft) composed of an unknown number of 2D surfaces grids.
> The TECPLOT file has 2 header lines followed by N zones, each zone
> corresponding to a surface grid and having one header line including the
> I and J dimensions of the grid followed by its datas (xyz locations, uvw
> velocity components and pressure) :
>
> TITLE=.....
> VARIABLES .....
> ZONE F=POINT, I=xx1, J=yy1
> ...
> x,y,z,u,v,w,p
> ...
> ZONE F=POINT, I=xx2, J=yy2
> ...
> x,y,z,u,v,w,p
> ...
>
> I used the Data Prompter to build a DX header calling my TECPLOT file
> but I was able to import and view only one zone at a time. I would like
> to know if there is a simple way to modify the DX header file to force
> importation of all zones from the TECPLOT file, or should I build an
> interface to rewrite my data file in the native DX format ?
>
> Thanks for your help.
>
> --
> Richard GRENON
> ONERA
> Departement d'Aerodynamique Appliquee - DAAP/ACI
> BP 72, 92322 CHATILLON CEDEX - FRANCE
> phone : +33 1 46 73 42 17
> fax : +33 1 46 73 41 46
> mailto:[EMAIL PROTECTED]
> http://www.onera.fr
>
>
>
>
>
module TECPLOTtoDX_mod
! Utilities for converting TECPLOT data to IBM DX file format
private
public :: ReadTECPLOT, Convert_to_DX
type, public :: dat
real, dimension(:,:,:), pointer, private :: X,U
real, dimension(:,:) , pointer, private :: P
end type dat
type(dat), dimension(:), private :: Surf
integer , private :: NZONES
integer, parameter , private :: MAX_STR_LEN = 80
contains
subroutine ReadTECPLOT(tecfile)
character(len=*), intent(in) :: tecfile
integer :: i,j,k, Nx,Ny
open(unit=1,file=tecfile,action="read",access="sequential",&
status="old",form="formatted")
! First determine NZONES
... file in code ...
rewind(unit=1)
! Allocate data
nullify(Surf)
allocate(Surf(NZONES))
do k = 1, NZONES
! READ Nx, Ny
... file in code ...
! Allocate Zone
nullify(Surf(k)%X,Surf(k)%U,Surf(k)%P)
allocate(Surf(k)%X(Nx,Ny,3),Surf(k)%U(Nx,Ny,3),Surf(k)%P(Nx,Ny))
! Read Surf(k)%X, U, and P
... file in code ...
do i = 1, Nx
do j = 1, Ny
read(unit=1,fmt=*) Surf(k)%X(i,j,:),Surf(k)%U(i,j,:),Surf(k)%P
end do
end do
end do
close(unit=1)
end subroutine ReadBEM
subroutine Convert_to_DX()
! Creates IBM DX data files named by the hdr and bin variables declared
! below. The bin file contains the binary data. The hdr file is the
! DX header used for the the Import DX module.
!
! The Zones are stored in one group object named `Aircraft'
! The default data points to the Pressure, P.
! Other data are named: P, U, V, W
integer :: i,j,k,l,M,N, shp, noff,nskp,nobj,iol, np,nd,nc
integer, dimension(NZONES) :: NGROUP
real, dimension(:,:) , pointer :: t2
real, dimension(:,:,:), pointer :: t3
character(len=MAX_STR_LEN), parameter :: hdr="Aircraft.dx" , &
bin="Aircraft.dx.bin"
nskp = 4
noff = nskp
nobj = 1
open(unit=1,file=trim(hdr),action="readwrite",access="sequential",&
status="unknown",form="formatted")
open(unit=2,file=trim(bin),action="readwrite",access="sequential",&
status="unknown",form="unformatted")
write(unit=1,fmt=*) "data mode lsb binary"
write(unit=1,fmt=*)
do l = 1, NZONES
t3 => Surf(l)%X
M = size(t3,1)
N = size(t3,2)
shp = size(t3,3)
write(unit=1,fmt=*) "object ",nobj," class array type float rank 1 ", &
"shape ",shp," items ",M*N, &
" data file """,trim(bin),""",",noff
np = nobj
nobj = nobj + 1
write(unit=2) (/ (((t3(i,j,:)),j=1,N),i=1,M) /)
inquire(iolength=iol) t3
noff = noff + iol + 2*nskp
write(unit=1,fmt=*) "object ",nobj," class gridconnections counts ",M,N
nc = nobj
nobj = nobj + 1
t2 => Surf(l)%P ! Write Pressure
M = size(t2,1)
N = size(t2,2)
write(unit=1,fmt=*) "object ",nobj," class array type float rank 1 ", &
"shape 1 items ",M*N, &
" data file """,trim(bin),""",",noff
write(unit=1,fmt=*) " attribute ""dep"" string ""positions"""
nd = nobj
nobj = nobj + 1
write(unit=2) (/ ((t2(i,j)),j=1,N),i=1,M) /)
inquire(iolength=iol) t2
noff = noff + iol + 2*nskp
t3 => Surf(i)%U
M = size(t3,1)
N = size(t3,2)
shp = size(t3,3)
do k = 1, shp ! Write Velocities
write(unit=1,fmt=*) "object ",nobj," class array type float rank 1
", &
"shape 1 items ",M*N,
&
" data file """,trim(bin),""",",noff
nobj = nobj + 1
write(unit=2) (/ (((t3(i,j,k)),j=1,N),i=1,M) /)
inquire(iolength=iol) t3(:,:,k)
noff = noff + iol + 2*nskp
end do
NGROUP(l) = nobj
write(unit=1,fmt=*) "object ",nobj," class field"
write(unit=1,fmt=*) " component ""positions"" value ",np
write(unit=1,fmt=*) " component ""connections"" value ",nc
write(unit=1,fmt=*) " component ""data"" value ",nd
write(unit=1,fmt=*) " component ""P"" value ",nd
write(unit=1,fmt=*) " component ""U"" value ",nd+1
write(unit=1,fmt=*) " component ""V"" value ",nd+2
write(unit=1,fmt=*) " component ""W"" value ",nd+3
write(unit=1,fmt=*)
nobj = nobj + 1
end do
write(unit=1,fmt=*) "object ""Aircraft"" class group"
do k = 1, NZONES
write(unit=1,fmt=*) " member value ",NGROUP(k)
end do
write(unit=1,fmt=*)
write(unit=1,fmt=*) "end"
end subroutine Convert_BEM_to_DX
end module TECPLOTtoDX_mod
program TECPLOTtoDX
! Program for converting TECPLOT data to IBM DX file format
use TECPLOTtoDX_mod
implicit none
call ReadTECPLOT("TECPLOT_file.ext")
call Convert_to_DX()
stop
end program TECPLOTtoDX