Example input and output routines can be found at the end of this document.
str1(1:20) = 'This is a string.'//char(0)//char(0)//char(0) str2(1:8) = 'This too'
A HHDB solution file is composed of multiple records. Within the HHSFD, a record is defined as a byte stream delimited by a 4-byte big-endian integer header and a 4-byte integer trailer both of which are the size, in bytes, of the delimited record. For example, an empty record is composed of 8 zero bytes. Every record size measured in bytes must be a multiple of 4.
real*4 record(*) open(unit=1,file='solution.hhdb',form='unformatted') write(1) (record(i),i=1,record_size_in_4_byte_units)
fp=fopen("solution.hhdb","wb"); rsize=4*record_size_in_4_byte_units; fwrite(&rsize,4,1,fp); fwrite(record,4,record_size_in_4_byte_units,fp); fwrite(&rsize,4,1,fp);
MAGIC | The first component of every solution file must be a magic number record containing a single big-endian integer. (This record as with all records must be delimited by the record size in bytes. Therefore, the MAGIC record is actually composed of twelve bytes.) |
ITEM | A single record typically containing data. Items may be context sensitive. |
SECTION | Multi-record components that are delimited by a Beginning-Of-Section (BOS) record and an End-Of-Section (EOS) record. Sections may contain other sections (i.e. subsections) as well as items. |
The first word of every record is an integer tag. The following tags are currently defined:
Record Type | Tag | |
MAGIC | 1212432974 | The magic number. |
ITM_COMM | 0 | A comment. |
BOS_HHDB | 32 | BOS for a HHDB solution. |
EOS_HHDB | 33 | EOS for a HHDB solution. |
BOS_UNSTR | 64 | BOS for an unstructured mesh/data block. |
EOS_UNSTR | 65 | EOS for an unstructured mesh/data block. |
BOS_STRUC | 66 | BOS for a structured mesh/data block. |
EOS_STRUC | 67 | EOS for a structured mesh/data block. |
ITM_VCINT | 256 | Vertex-centered interior data. |
ITM_CCINT | 257 | Cell-centered interior data. |
ITM_VCBOU | 258 | Vertex-centered boundary data. |
ITM_CCBOU | 259 | Cell-centered boundary data. |
"file structure anchor"
A valid HHDB solution file is structured as follows:
ITM_VCINT | | | ITM_CCINT | (See 3 below.) |
ITM_VCBOU | | | ITM_CCBOU | (See 4 below.) |
ITM_VCINT | | | ITM_CCINT | (See 3 below.) |
ITM_VCBOU | | | ITM_CCBOU | (See 4 below.) |
(1) Comments may appear anywhere within the file following MAGIC.
We must stress that for word alignment reasons, the number of
characters in a comment must be a multiple of four. Pad with
null characters if not.
(2) Structured and/or unstructured blocks may be mixed within a HHDB
solution section.
(3) Every block, both structured and unstructured, must contain
exactly one item of type ITM_VCINT or ITM_CCINT. Note that the
format of these items is context sensitive depending on whether the
block is structured or unstructured.
(4) Blocks may have any number of boundary patches of
type ITM_VCBOU and/or ITM_CCBOU. The format of these items is also
context sensitive.
(5) Any number of HHDB solution sections are allowed within the file.
open(unit=1,file='solution.hhdb',form='unformatted')
read(1) magn ! check that magn == 1212432974Return to "file structure anchor".
character str(*) read(1) tag,num,(str(i),i=1,num) ! num must be a multiple of 4.Return to "file structure anchor".
read(1) tag,soln,nblks,ndims,nvars,bvarswhere
read(1) tag,blk,nptchswhere
read(1) tag,nnodes,ncells,nconns, * ((node(id,no),id=1,ndims),no=1,nnodes), * ((solu(no,va),no=1,nnodes),va=1,nvars), * (type,(conn(ve,ce),ve=1,nperc(type)),ce=1,ncells)where
read(1) tag,nnodes,ncells,nconns, * ((node(id,no),id=1,ndims),no=1,nnodes), * ((solu(ce,va),ce=1,ncells),va=1,nvars), * (type,(conn(ve,ce),ve=1,nperc(type)),ce=1,ncells)where
read(1) tag,ptch,bnodes,bcells,bconns, * ((bnod(no),no=1,bnodes), * ((bsol(no,va),no=1,bnodes),va=1,bvars), * (type,(bcon(ve,ce),ve=1,nperc(type)),ce=1,bcells)where
read(1) tag,ptch,bnodes,bcells,bconns, * ((bnod(no),no=1,bnodes), * ((bsol(ce,va),ce=1,bcells),va=1,bvars), * (type,(bcon(ve,ce),ve=1,nperc(type)),ce=1,bcells)where
read(1) tagwhere
read(1) tag,blk,nptchswhere
read(1) tag,idim,jdim,kdim, * ((((node(id,i,j,k),id=1,ndims), * i=1,idim), * j=1,jdim), * k=1,kdim), * ((((solu(i,j,k,va),i=1,idim), * j=1,jdim), * k=1,kdim),va=1,nvars)where
read(1) tag,idim,jdim,kdim, * ((((node(id,i,j,k),id=1,ndims), * i=1,idim), * j=1,jdim), * k=1,kdim), * ((((solu(i,j,k,va),i=1,max(idim-1,1)), * j=1,max(jdim-1,1)), * k=1,max(kdim-1,1)),va=1,nvars)where
read(1) tag,ptch,ilo,ihi,jlo,jhi,klo,khi, * ((((bsol(i,j,k,va),i=1,ihi-ilo+1), * j=1,jhi-jlo+1), * k=1,khi-klo+1),va=1,bvars)where
read(1) tag,ptch,ilo,ihi,jlo,jhi,klo,khi, * ((((bsol(i,j,k,va),i=1,max(ihi-ilo,1)), * j=1,max(jhi-jlo,1)), * k=1,max(khi-klo,1)),va=1,bvars)where
read(1) tagwhere
read(1) tagwhere
The HHDB solution file compression routine, hhdbzip.c, can be found by following this link.
A routine for checking the integrity of an HHDB solution file can be found by following this link.
Last modified: Fri Sep 11 14:15:50 MET DST 1998