Skip to content

Converting "VoxCad" graphic editor data into text data for mathematical calculations using Fortran

License

Notifications You must be signed in to change notification settings

JNSresearcher/convert_VoxCad_data

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Motivation

VoxCad is a simple 3D editor, but unlike other similar editors, it allows you to enter arbitrary text data about the characteristics of the elements that are included in the 3D image. This circumstance allows you to use VoxCad for visual data entry for various mathematical calculations (for example, calculations of 3D fields or graphical input of large matrices to study storage formats, to study block algorithms, etc.)
VoxCad has its own data format (with the vxc extension), which is small in size due to the use of zlib data compression (it is possible to save data in uncompressed form, but the file size increases).
  The goal of this project is to convert the VoxCad format into text data that can be used in mathematical calculations (additionally the data is converted to vtk format for visualization in ParaView )

Required Software

Repository Structure

Directory /src:

  • vxc2data.f90 - main program;
  • utilites.f90 - contains routines for working with character strings (convert a string to an array of words, convert to upper case, converting a word to a number taking into account the prefix (in details: https://github.com/JNSresearcher/convert_prefix);
  • write_vtk.f90 - creating 3D image in vtk format on an unstructured grid;
  • uncompress_zlib.py - for create a temporary file with converted uncompressed data into ACSII for later processing;
  • Makefile - creating an executable using make.
  • example1.vxc - file for VoxCad with a simple scheme of 4 domains;
  • motor.vxc- file for VoxCad with a more complex image.

Build

  To build the executable file vxc2data, should be configure the makefile first. It is possible to build in Windows or Linux, gfortran or ifort. To configure, you need to comment/uncomment the top lines, for example, for Windows and gfortran:

          OS=win  
        # OS=unix  
          F90=gfortran  
        # F90=ifort

  Type make at the command prompt and run.

Launch of calculation

  First, on need to save the data, for example example1.vxc, to a working file named in.vxc in the same directory as the vxc2data executable.
Run the executable: ./vxc2data or vxc2data.exe. As a result, 2 output files will be created: with extensions txt and vtk.

Example of preparing a source file in VoxCad

  Example of a simple file (example1.vxc) with the dimensions of the working area 5 х 5 х 5. On the left is an image of the file example1.vxc in VoxCad, on the right is an image in ParaVew of the generated file example1.vtk.

  First, in VoxCad the 4 domains were entered, then a line with additional data.
  Text entered for domains:

        d1 z=1 
        d2 z=2 
        d3 z=3 
        d4 z=4 
        e0 environ z=1k files=example1

  Here are some rules.
  A line consists of words separated by spaces (when processing, string characters are automatically converted to uppercase).
For each domain (in each line) on entering:

  • 1st word - line name. Names can be arbitrary, no more than 6 characters. In this case, names start with the symbol "d";
  • 2nd word - "z" - this is a keyword, after which after the symbol "=" the domain parameter is entered - a number.
    The symbol "=" is entered for clarity, the program puts a space instead of it;
  • 3rd word - number , will be automatically converted to REAL8 format (here, for demonstration purposes, each domain is assigned a parameter equal to the domain number).

  The last line with text information is entered, but the domain should not be displayed on the workspace.
This line contains additional text data.
In this case:

  • 1st word - line name (arbitrary, here is e0);
  • 2nd word "environ" - keyword, followed by the environment parameter.
  • 3rd word "z" - keyword, after which the environment domain parameter - a number - is entered after the "=" symbol.
  • 4th word - a number. In this case 1k, the number was entered taking into account the prefix. The prefix should not be separated from the number by a space. Otherwise it will be perceived as a separate word, which will lead to an error. 1k is 1.0e3;
  • 5th word "files" (can "file"). This is a keyword, after which for clarity you can put the "=" symbol;
  • 6th word is the name for the output files. In this case, two files will be generated: EXAMPLE1.txt - text data about domains and EXAMPLE1.vtk for display in ParaView

  If the line with additional data is not entered, then by default the environment parameter "z=1" is set and the name "OUT" is set for the files, i.e. OUT.txt and OUT.vtk (or OUT_bin.vtk) will be created.

Note. When the keyword "z" is entered, the domain is assigned the conditional type "R".

Output files composition

  For small objects (working area size no more than 1000 cells, for example 10 x 10 x 10, the output text file (.txt) contains data of domains, as well as a 3D matrix with a map of physical domains. The vtk file has an ASCII text format.
  For example, for the simple example above, the contents of the EXAMPLE1.txt file would be as follows:

Lattice Dimension= 0.500E-02
Grid spacing along X= 0.500E-02
Grid spacing along Y= 0.500E-02
Grid spacing along Z= 0.500E-02
Number of cells along X=  5
Number of cells along Y=  5
Number of cells along Z=  5

Cells=       125
nPHYS=   4 nPHYS_env=   1 nPHYS_glob=nPHYS+nPHYS_env=  5

numPHYS=   1 valPHYS=  0.100E+01 typPHYS= R namPHYS= D1
numPHYS=   2 valPHYS=  0.200E+01 typPHYS= R namPHYS= D2
numPHYS=   3 valPHYS=  0.300E+01 typPHYS= R namPHYS= D3
numPHYS=   4 valPHYS=  0.400E+01 typPHYS= R namPHYS= D4
created environment with parameters:
numPHYS=   5 valPHYS=  0.100E+04 typPHYS= R namPHYS= E0

3d matrix of geometric location of physical domains:

          k=  1
 j ^
 5 |    5    5    5    5    5
 4 |    5    5    5    5    5
 3 |    5    5    5    5    5
 2 |    5    5    5    5    5
 1 |    5    5    5    5    5
      ------------------------->
    i=  1    2    3    4    5   

          k=  2
 j ^
 5 |    5    5    5    5    5
 4 |    5    1    5    2    5
 3 |    5    1    5    2    5
 2 |    5    1    5    2    5
 1 |    5    5    5    5    5
      ------------------------->
    i=  1    2    3    4    5   

          k=  3
 j ^
 5 |    5    5    5    5    5
 4 |    5    5    5    5    5
 3 |    5    5    5    5    5
 2 |    5    5    5    5    5
 1 |    5    5    5    5    5
      ------------------------->
    i=  1    2    3    4    5   

          k=  4
 j ^
 5 |    5    5    5    5    5
 4 |    5    4    4    4    5
 3 |    5    5    5    5    5
 2 |    5    3    3    3    5
 1 |    5    5    5    5    5
      ------------------------->
    i=  1    2    3    4    5   

          k=  5
 j ^
 5 |    5    5    5    5    5
 4 |    5    5    5    5    5
 3 |    5    5    5    5    5
 2 |    5    5    5    5    5
 1 |    5    5    5    5    5
      ------------------------->
    i=  1    2    3    4    5   

  If the number of cells is more than 1000, only data on physical domains is output to the text file. The vtk file has a binary format.

  In this project, the scalar field is specified in the vtk file in each domain. Each domain cell is assigned a scalar equal to the domain number. This is for demonstration purposes.Of course, when calculating a specific 3D field (scalar or vector), on can place the calculated field value in the appropriate cell.

  Example of file with a more complex image (motor.vxc) with the dimensions of the working area 33 х 33 х 15. On the left is an image of the file motor.vxc in VoxCad, on the right is an image in ParaVew of the generated file MOTOR_bin.vtk.

Note. The generated vtk binary can be loaded to other graphic 3D editors (for example FreeCad, etc.). From ParaView on can export an image to other formats: x3d, vrml, etc.

About

Converting "VoxCad" graphic editor data into text data for mathematical calculations using Fortran

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published