Table of Contents

1. Introduction

The DevTools software development system from Visual Kinematics, Inc. is a suite of object oriented software libraries which provide methods in support of application software developers in engineering and science. DevTools currently consists of the following libraries.

Table of Contents

1.1 Application Development Environment

Each library contains a set of object oriented modules which implement the functionality of a particular library. Modules are object-based in that they support the encapsulation of a set of functions and data within an object, so that the data is only accessible though a well defined interface. A module (also termed a "class" in object-oriented technology) also supports the instantiation of multiple objects, each with its own private data. An object may be destroyed at any time, freeing its private data and local memory resources.

The application programming interface (API) consists of a header file and a series of entry points defining the functional interface (also termed "methods" in object-oriented technology) for each module. The private data for each module is defined in a C language structure, struct, which is a defined type, typedef. In order to avoid naming conflicts, all function names and defined types of the modules delivered with DevTools begin with vut_, vml_, vsy_, vis_, vgl_, vfe_, vfs_, vdm_ or vfx_. The four character prefix is followed by the module and function name in initial capital letters. For example the function to draw contours on a curvilinear array of computational cells in VisTools is vis_ContourCurv. All arguments to module functions are either simple variables, arrays or pointers to structures containing the private data of an object. Each module contains functions to begin and end an instance of the module. For example to create a Contour object use vis_ContourBegin. This function allocates an instance (an object) of the module and returns a pointer (object handle) to a struct containing the private data of the object. If object creation fails, a NULL pointer is returned. The end function destroys the object and frees its memory resources. For example, use vis_ContourEnd to destroy a Contour object.

Table of Contents

1.2 Directory Structure

All DevTools component source libraries require the base source library as a foundation. The installation procedure for DevTools creates the following directory structure under the devtools directory. The libraries which appear are site dependent.

devtools                      DevTools MAKEDEFS for built-in make system
devtools/lib                  Empty directory for DevTools archives
devtools/src/base             DevTools base source and header files
devtools/src/base/ext         DevTools ZLIB source
devtools/src/base/exam        DevTools base examples
devtools/src/vgl              VglTools source and header files
devtools/src/vgl/exam         VglTools examples
devtools/src/vgl/ext          VglTools PNG, TIFF, JPEG source
devtools/src/vgl/fonts        VglTools FreeType font files
devtools/src/vgl/test         VglTools feature and performance tests
devtools/src/vis              VisTools source and header files
devtools/src/vis/exam         VisTools examples
devtools/src/vdm              VdmTools source and header files
devtools/src/vdm/exam         VdmTools examples
devtools/src/vfe              VfeTools source and header files
devtools/src/vfe/exam         VfeTools examples
devtools/src/vfs              VfsTools source and header files
devtools/src/vfs/exam         VfsTools examples
devtools/src/vfx              VfxTools source and header files
devtools/src/vfx/exam         VfxTools examples
In addition to the above directories, each toolkit directory contains subdirectories "fortran", "cplusplus", and "csharp" that contain the bindings for FORTRAN, C++, and C#, respectively.

Each DevTools module exists as a source file (.c or .cxx) and associated header file (.h) in the source directory. For example the Contour module source and header files are contour.c and contour.h respectively and reside in the VisTools src/vis directory. There are additional source and header files which contain internal utility procedures and DevTools-wide macro definitions.

The base directory contains all the foundation module source and header files for all DevTools components. Examples of foundation modules are Error, List and Stack.

The lib directory contains a set of subdirectories which are empty at initial installation. They may be used to place object or archive files resulting from compiling DevTools components on a specific platform.

Table of Contents

1.3 Compiling and Linking DevTools

DevTools libraries are delivered in obfuscated source code form. This means that the source code has been processed so that it is not readily understandable by human beings but compiles properly on any supported computer platform. As a result, a single DevTools source code deliverable is generally immune to operating system and compilation system changes. The general concepts of compiling and linking DevTools source is outlined below. The user may use this information to integrate the compilation of DevTools source into their custom development environment. As an option, a built-in compilation and linking system is provided which is described in the next section.

Each DevTools library has a different set of compilation options (C preprocessor directives) which are required for proper compilation on a particular platform, operating system, window system, etc. These options are documented in the "Compiling and Linking" section of each library. The base library must be compiled for all DevTools installations, along with each of the DevTools libraries delivered.

There are a variety of C preprocessor definitions which are used to conditionally compile source code. The following definitions are common to all DevTools libraries. The primary category is machine architecture which is related to the overall computing platform. The machine architecture implies an operating system such as LINUX, Microsoft Windows and platform dependent varitions of UNIX. Possible architectures are the following,

VKI_ARCH_HP       Hewlett Packard HPUX systems
VKI_ARCH_IBM      IBM AIX systems
VKI_ARCH_LINUX    LINUX operating system
VKI_ARCH_SGI      Silicon Graphics IRIX systems
VKI_ARCH_SUN      SUN Solaris systems
VKI_ARCH_WIN32    MicroSoft Windows
Publicly available external library support for compression. There are two options. The user may conditionally compile source to reference a user supplied installation of the external library or conditionally compile source to reference a modified version of the publicly available source which is delivered in the base/ext directory.

VKI_LIBAPI_ZLIB     ZLIB user installed external library
VKI_EXTAPI_ZLIB     ZLIB base/ext/zlib source
Enable Intel's MKL BLAS functionality. These definitions must be used when compiling all objects in the base, vfs and vfx directories.

VKI_LIBAPI_BLASMKL_SEQUENTIAL  Enable MKL sequential BLAS functionality
VKI_LIBAPI_BLASMKL_THREAD      Enable MKL threaded BLAS functionality
Enable multi-threading functionality which uses OpenMP. These definitions must be used when compiling all objects in the base, vfs and vfx directories.

VKI_LIBAPI_OPENMP    Enable OpenMP Threading functionality
Enable sockets functionality. This definition must be used when compiling all objects in the base directory.

VKI_LIBAPI_SOCKETS    Enable sockets functionality
In general, most user input arguments to functions are checked for validity. In some cases where the error checking may degrade performance, a compile time option is available to conditionally compile the additional error checking code. This option also adds some memory integrity checking. The compile time definition related to error and memory checking is the following.

VKI_CHECK_ERRS    Include additional error checking
Once the DevTools source code is compiled, either the object files may be used directly or they may be installed in an object library archive so that the loader may selectively relocate only the objects which are required. DevTools is written in ANSI C. It is suggested to use the highest level of serial optimization options available on the C compiler.

For example, on LINUX systems, create a directory LINUX under lib to hold the final devtools.a archive file. Then from the devtools/src/base directory compile using

creating .o files in the base directory. To place the object files in an archive file issue

ar rs ../../lib/LINUX/devtools.a *.o
The object files may be deleted after the devtools.a archive is successfully created. At this point the devtools.a archive contains all base objects. Place the devtools.a archive immediately after the application code libraries in the load line. A devtools.a archive must be built for each computer platform using the methodology outlined above.

To build a dynamic link library on LINUX systems, use the same LINUX directory under lib to hold the final library file. Then from the devtools/src/base directory compile using

creating .o files in the base directory that are suitable for building a dynamic link library. The library itself may be created with

gcc -shared -Wl,-soname, -o ../../lib/ *.o -lc
This will create the shared library in the LINUX subdirectory. You can now link with this library, provided your environment variable LD_LIBRARY_PATH contains this subdirectory (separated by a colon).

On Microsoft Windows systems, compile from within a nmake file using:

     !include <ntwin32.mak>
     cl.exe $(cflags) $(cvars) /O2 -DVKI_ARCH_WIN32 -DVKI_CHECK_ERRS -I.. *.c

creating .obj files in the base directory. To place the object files in a library file issue

lib /out:../../lib/INTEL/devtools.lib *.obj
The object files may be deleted after the devtools.lib library is successfully created.

To build a dynamic link library (.dll) in Microsoft Windows rather than a static library, define the macro VKI_EXTERN to be __declspec(dllexport) when compiling DevTools source code as follows:

     !include <ntwin32.mak>
     cl.exe $(cflags) $(cvars) /O2 -DVKI_ARCH_WIN32 -DVKI_CHECK_ERRS \
            -DVKI_EXTERN=__declspec(dllexport) -I.. *.c
creating .obj files in the base directory. Then these .obj files must be linked into a dynamic link library using:
     link /dll /implib:devtools.lib /out:devtools.dll /machine:i386 *.obj
When compiling user code referencing a Devtools function which has been placed in a dynamic link library, it is suggested to define the macro VKI_EXTERN to be __declspec(dllimport). Note that the devtools.dll must be placed in a directory that can be found by Microsoft Windows when the application is executed.

Table of Contents

1.4 The Built-in Make System

The built-in DevTools make system may be used to build a standalone object archive or library and link the supplied examples. The system consists of a Makefile and Makefile.win32 in each toolkit directory and exam subdirectory. The Makefile.win32 is used for Microsoft Windows platforms and Makefile is used for all other (UNIX-like and LINUX) platforms. These make files reference a file in the main devtools directory, in which the xxx is a "machine" type. The files contain the "machine" dependent compiler switches, etc. The machine type is set with the environment variable VKI_MACH. Currently recognized values for VKI_MACH are the following.

LINUX    LINUX 32 bit
LINUX64  LINUX 64 bit
MAC      Apple MAC OS X
WIN32    Microsoft Windows 32 bit
WIN64    Microsoft Windows 64 bit
In order to build the source code, first set the appropriate VKI_MACH value. Then change directory to the devtools/src/base directory and enter the following command for Microsoft Windows:
     nmake /f Makefile.win32 build
or for all other systems enter
     make build
The base directory contains an ext sub directory. This directory contains ZLIB source. If you already use a pre-installed version of ZLIB you do not need to compile this source, Otherwise build it using the following command for Microsoft Windows:
     nmake /f Makefile.win32 buildext
or for all other systems enter
     make buildext
Then visit each licensed toolkit source directory and repeat the procedure. An ext subdirectory only exists in the base and vgl source directories. If the C++ interfaces are desired in addition to the standard C interfaces, then substitute buildCC for build in the make commands above. Once all files have been compiled, a final library resides in the directory lib/$(VKI_MACH) for the platform used.

In order to build any one of the supplied examples after the object library or archive has been built using the procedure above, change directory to the exam directory in any of the toolkit source directories. Then issue the appropriate make command to build one of the examples. For example to build Example 1 as a console application in the base library on Microsoft Windows, change directory to devtools/src/base/exam and enter

     nmake /f Makefile.win32 exam1
This will create exam1.exe.

Table of Contents

1.5 Include Files and Data Types

The first step in writing a DevTools application is to include the proper header files. All DevTools applications must include the base.h header file located in the base directory. This file includes typedefs for all basic data types and defined constants. The basic data types are listed below.

Vchar    character, a single byte
Vtchar   character, single byte or wchar_t
Vuchar   unsigned character
Vwchar   wide character, type wchar_t
Vshort   short integer, 16 bits
Vushort  unsigned short integer
Vint     integer, 32 bits
Vuint    unsigned integer
Vlong    long integer, 64 bits
Vulong   unsigned long integer
Vfloat   single precision floating point, the same size as Vint
Vdouble  double precision floating point, 64 bits
Vobject  void*
Vword    maximum sizeof Vint, Vfloat and Vobject
Vquad    quadruple precision floating point, 128 bits
All arguments (other than specific object pointers) passed to any user callable DevTools function are typed using the above defined types. The Vtchar type is single byte (char) by default or wide character (wchar_t) if the symbol VKI_WIDECHAR is defined.

Pointers to specific object types are typedefed using a four letter prefix, such as vis_ in the VisTools library, and the name of the module from which the object was instanced. For example, Contour objects are typed as vis_Contour. These module type definitions appear in the header file for each module. The base.h, vis.h, vismesh.h, vgl.h, vfe.h, vfs.h, vfx.h and vdm.h files include all the required module header files. It is recommended that one use the #include pre-processor directive as follows:

#include "base/base.h"
#include "vgl/vgl.h"
#include "vis/vis.h"
#include "vis/vismesh.h"
#include "vdm/vdm.h"
#include "vfe/vfe.h"
#include "vfs/vfs.h"
#include "vfx/vfx.h"

An include file, userdefs.h, is installed in the devtools/src/base directory specifically for user defined C preprocessor commands and is meant to be edited and customized by the user. This include file is guaranteed to be included by any DevTools include file. One particular use of userdefs.h is customization with respect to compiling features in VfxTools which are dependent upon underlying toolkits. The following #define's should be added indicating toolkits which are not licensed.


Table of Contents

1.6 Building an Application Using Visual Studio

DevTools includes an example that can be built with Microsoft Visual Studio. The project can be found in the DevTools distribution under src\base\exam\windows\exam.vcproj, and can be opened in Visual Studio with

File -> Open -> Project/Solution

and pointing the file selector to the above file. You can also use Windows Explorer to locate the file src\base\exam\windows\exam.vcproj and open Visual Studio by double clicking on it.

The chosen example is src\base\exam\exam1.c. Other examples can be built by following the same procedures as in this example. The example has been configured in both "Debug" and "Release" modes, and supports both Win32 and x64 platforms.

The example properties windows can be displayed by right-clicking on the example "exam" then choosing "Properties" (the last entry in Visual Studio 9.0). The following changes from the default empty project were made:

Configuration Properties -> C/C++ -> General

Under "Additional Include Directories" the path "..\..\.." was added to reflect the relative path for the "src" directory.

Configuration Properties -> C/C++ -> Preprocessor

Under "Preprocessor Definitions" we added

The first two are needed to specify that the Windows architecture and Windows windowing systems are being used; the last indicates that OpenGL will be used for all graphics displays.

Configuration Properties -> Linker -> General

Under "Additional Library Directories" the path ..\..\..\lib\WIN32 was added to the Win32 platform, and the path ..\..\..\lib\WIN64 was added to the x64 platform. It is expected that the 32-bit version of devtools.lib will be placed in lib\WIN32 while the 64-bit version of devtools.lib will be placed in lib\WIN64. Instructions for building devtools.lib are available elsewhere in this documentation.

Configuration Properties -> Linker -> Input

Under "Additional Dependencies" the libraries "devtools.lib opengl32.lib vfw32.lib" were added. The last two libraries - opengl32.lib and vfw32.lib - are standard Windows libraries.

Selecting an active configuration and platform is done by clicking on the "Configuration Manager..." button in the properties window and choosing a "Configuration" and a "Platform" for the "exam" Project.

Use the Visual Studio sequence "Debug -> Start Without Debugging" to build and run this console application. You can also debug the application by choosing the Visual Studio sequence "Debug -> Start Debugging".

Table of Contents

1.7 Versioning

DevTools releases are named using a string with three integers separated by decimal points. The first integer is the primary version indicating a major release with significant new functionality. The second integer is a secondary version consisting of minor enhancements. The third integer is primarily used for releases containing bug fixes. An example of a DevTools release string is 3.1.2. The include file base.h contains the defined constant SYS_VERSION which defines the version string without the decimal points. For example, the #define for version 3.1.2 is as follows:
#define SYS_VERSION 312
This integer is guaranteed to be monotonically increasing for each new release.

Table of Contents

1.8 C++ Language Bindings

DevTools supports a C++ language binding. The C++ language binding is a derivative of the C language binding. The object oriented technology of the C language binding maps naturally into C++ classes. The following rules determine the form of the C++ language binding from the C language binding.
       vis_Contour *contour;
       contour = new vis_Contour;
  (C)   vis_ContourSetTopology(contour,VIS_SHAPEQUAD,0,0)
  (C++) contour->SetTopology(VIS_SHAPEQUAD,0,0).
Table of Contents

1.9 FORTRAN Language Bindings

DevTools supports a FORTRAN language binding. The FORTRAN language binding is a derivative of the C language binding and maintains the same object oriented technology as the C language binding. Functionality is in all cases identical for all language bindings. The following rules determine the form of the FORTRAN language binding from the C language binding.

Table of Contents

1.10 C# Language Bindings

DevTools supports a C# language binding. The C# language binding is a derivative of the C language binding and maintains the same object oriented technology as the C language binding. Functionality is in all cases identical for all language bindings. The following rules determine the form of the C# language binding from the C language binding.

       String mystring = Marshal.PtrToStringAnsi (myintptr);
       int id = 0;
       vis.IdTranGetId (idtran,10,ref id);
The built-in DevTools make system may be used to build the C# library and examples. Assuming all toolkits are available, the C# library can be built with the following steps:
     cd base
     nmake /f Makefile.win32 buildcs
     cd ../vdm
     nmake /f Makefile.win32 buildcs
     cd ../vis
     nmake /f Makefile.win32 buildcs
     cd ../vgl
     nmake /f Makefile.win32 buildcs
     cd ../vfe
     nmake /f Makefile.win32 buildcs
     cd ../vfs
     nmake /f Makefile.win32 buildcs
     cd ../vfx
     nmake /f Makefile.win32 buildcs
     cd ../..
     nmake -f Makefile.win32 buildcs

The last step in the sequence above creates a devtools.dll and devtoolscs.dll. While the path to devtools.dll may be added to the Windows PATH environment variable, devtoolscs.dll must be registered in the GAC. Alternatively, it may be copied to the location where the application that uses it resides. The latter is the approach utilized in the examples provided.

To build and run the intro1 example in vfe/exam use

     cd vfe/exam
     nmake /f Makefile.win32 intro1cs

Table of Contents

1.11 Parallelization and Thread Safety

All DevTools toolkits may be used in a straight-forward way to take advantage of multiprocessing computing platforms using an industry standard multithreading API such as OpenMP, Pthreads or Windows threads. Most modules are thread safe in that there are no writable global variables (the only modules which must be executed serially are the graphics device interface modules in the VglTools library). This allows multiple instances of DevTools objects to be executed simultaneously in a multithreaded, multiprocessor environment.

Single instances of objects containing global data such as finite element model and results information may be reliably shared and accessed by multiple threads through a set of read only functions. These functions will have const declarations of the object in their prototypes. There are additional functions which can be used by multiple threads with a single object which are not declared const. These functions are documented with (thread safe) in the function summary. These functions can not formally be declared as const since the object internal error flag may be set if a user input error is detected.

Certain DevTools functions are internally parallelized. There are two types of internally parallelized functions.

Using DevTools toolkits to implement parallelization may be performed with minimal impact on the host application. All required software architecture is local in scope. The object oriented technology of DevTools is critical from a practical standpoint to a successful implementation of parallelization in an application with a multithreading API.

Table of Contents

1.12 Floating Point Precision

A number of DevTools modules support various levels of floating point precision. The precision levels are the following:

The reduced precision type, SYS_HALF, is implemented using the 16 bit IEEE floating point standard. This standard represents approximately 3.3 decimal digits of precision. The minimum and maximum representable values are 6.10e-5 and 65504.

The modules which support varying precision levels have facilities for setting and accessing data in float and double precision. These access routines will ensure that the data which is set and returned is properly converted to the internal precision representation.

Table of Contents

1.13 Base Library

The base library contains modules of general utility which are used by all other DevTools libraries. These modules address, among other things, error handling, compact boolean values and the storage of collections of objects. Currently available modules include the following.

The naming conventions for base library modules use the prefixes vut_ and vsy_.