next up previous contents index
Next: Examples for the implementation Up: General Meshes Previous: Methods on Mesh3d

Conversion Methods

 

The major purpose of the Mesh3d concept is to allow the access to data of various formats in a unique way. Therefore there is not one single format to read or write this data. It highly depends on the numerical method and the users data structures. Nevertheless some data formats will be supported. They will be discussed in the following.

   

(MESH3D *)GRAPE(tr3d, "convert-to-mesh")()
(MESH3D *)GRAPE(fe3d, "convert-to-mesh")()
TRIANG3D *tr3d
FE3D *fe3d

A Triang3d or Fe3d object is referred to by a Mesh3d instance which is the returned value of the first two methods. The original triangulation and data are kept unchanged. The Mesh3d evaluation functions only refer to them. Later changes in tr3d or fe3d will therefore also effect the new Mesh3d instance. The methods ''convert-to-mesh-send'' on Scene replaces the object in the instance scene by a Mesh3d object referring to the previous object data.

           

(MESH3D *)GRAPE(Mesh3d, "read-ascii-fdiff")()
(MESH3D *)GRAPE(Mesh3d, "read-binary-fdiff")()
(MESH3D *)GRAPE(Mesh3d, "write-binary-fdiff")()

These three methods support the reading and writing of finite difference data on a possibly deformed cubic mesh. The values of several solution functions can be handled at the same time. A button in the interactive environment deals with the switching between them. An automatic compression of large data sets to a smaller space resolution is possible. A ruler effects the rate of discretizations points which will be taken into account in each coordinate direction.

Remark : The coord_to_world function works correctly if and only if the deformation of the standard reference cube onto the deformed cube has a constant normal direction in two directions and a varying one solely in the third direction. For arbitrary deformations the user has to exchange this function by an appropriate one.

We will now list the input format for the read method dealing with the ASCII data type (the parentheses at the end of the lines contain comments) :

time 

geo           (flag == 1 x_i y_i z_i are defined, == 0 not defined) 
dim           (dimension of the solution vector)
parts         (number of segments in the solution vector,
              for example velocity, pressure, density, grad pressure ...)
part_0 name_0 (index to segment 0 of the function vector and its name) 
.
.
.
part_(parts-1) name_(parts-1) (index of the last segment and its name)
n_x n_y n_z  (int number of steps in x,y,z direction)
             (n = n_x * n_y * n_z)  
x_0 y_0 z_0 f_0[0]..f_0[dim-1] (x_i y_i z_i only if geo == 1) 
     .                         (x is the slowest running index)
     .                         (z the fastest)    
     .                         (point[i,j,k]=(x,y,z)[(i*y_n+j)*z_n+k])
     .                         (f_. solution vector on the points)
x_(n-1) y_(n-1) z_(n-1) f_(n-1)[0]..f_(n-1)[dim-1]

The following example illustrates this. A small 3D mesh is defined with a velocity and pressure defined on it.

0.0   
1

4
2

0 velocity
3 pressure

3 3 3

0.0 0.0 0.0  1.0 2.0 1.0 0.012
0.0 0.0 0.5  1.0 2.0 1.0 0.012  
0.0 0.0 1.0  1.2 1.6 0.5 0.018
0.0 0.5 0.0  1.2 1.6 0.5 0.018 
0.0 0.5 0.5  0.9 2.2 0.7 0.008 
0.0 0.5 1.0  1.2 1.6 0.5 0.018
0.0 1.0 0.0  1.0 2.0 1.0 0.012 
0.0 1.0 0.5  1.2 1.6 0.5 0.018 
0.0 1.0 1.0  0.9 2.2 0.7 0.008
0.5 0.0 0.0  1.2 1.6 0.5 0.018 
0.5 0.0 0.5  1.0 2.0 1.0 0.012 
0.5 0.0 1.0  1.2 1.6 0.5 0.018
0.5 0.5 0.0  0.9 2.2 0.7 0.008 
0.5 0.5 0.5  1.0 2.0 1.0 0.012 
0.5 0.5 1.0  0.9 2.2 0.7 0.008
0.5 1.0 0.0  1.2 1.6 0.5 0.018 
0.5 1.0 0.5  1.0 2.0 1.0 0.012 
0.5 1.0 1.0  0.9 2.2 0.7 0.008
1.0 0.0 0.0  1.0 2.0 1.0 0.012 
1.0 0.0 0.5  0.9 2.2 0.7 0.008 
1.0 0.0 1.0  1.2 1.6 0.5 0.018
1.0 0.5 0.0  0.9 2.2 0.7 0.008 
1.0 0.5 0.5  1.0 2.0 1.0 0.012 
1.0 0.5 1.0  0.9 2.2 0.7 0.008
1.0 1.0 0.0  1.0 2.0 1.0 0.012 
1.0 1.0 0.5  1.0 2.0 1.0 0.012 
1.0 1.0 1.0  1.0 2.0 1.0 0.012

If possible, the following binary format is preferable. It consists in replacing above all ASCII written integers and floats to binary written once and the character strings by char arrays of fixed length 100. Furthermore, the block of function data information is separated from the coordinate arrays.

(float ) time 

(int ) geo,dim,parts
(int ) part_0,(char[100] ) name_0 
...
(int ) part_(parts-1),(char[100]) name_(parts-1)
(int ) n_x,n_y,n_z
(float ) x_0,y_0,z_0 
...
(float ) x_(n-1),y_(n-1),z_(n-1) 
(float ) f_0[0], .. f_0[dim-1] 
...
(float ) f_(n-1)[0], .. f_(n-1)[dim-1]


next up previous contents index
Next: Examples for the implementation Up: General Meshes Previous: Methods on Mesh3d

SFB 256 Universität Bonn and IAM Universität Freiburg

Copyright © by the Sonderforschungsbereich 256 at the Institut für Angewandte Mathematik, Universität Bonn.