2.2 C and Fortran users¶
The source package includes a Makefile for building the static library and the C and Fortran examples. It uses GCC and GFortran by default and requires GNU Make and a compatible shell. On Windows, an appropriate build environment must be configured; compiler names, paths, and options may need to be adapted.
Extract the source package in the chosen working directory:
tar -zxvf voftools-6.tgz
Enter the extracted directory:
cd voftools-6
Build the library and example programs:
make
The compiler commands can be specified explicitly. For example:
make CC=gcc F77=gfortran
Replace
gccandgfortranwith the appropriate executable names or paths if necessary. Compiler-specific options in theMakefilemust also be reviewed when using a different compiler family.To use dimensions other than the defaults, specify both parameters:
make NS=240 NV=300
This sets
nsto 240 andnvto 300 insrc/dimpol.hbefore compilation. When invokingmakewithout these assignments, theMakefileuses its default values of 140 and 200.The build creates the static library
lib/libvoftools.aand the following executables in the package root directory:C:
test2d_c,test3d_c,testfit_c, andtestparab_c.Fortran:
test2d_f,test3d_f,testfit_f, andtestparab_f.
To clean the compiled files before rebuilding, run:
make cleanThen repeat the build command, including any custom compiler settings and dimension values.
Configure input parameters: Before running
test2d_c,test2d_f,test3d_c, ortest3d_f, edit thevofvardeffile in the working directory to select the desired case. The 2D and 3D programs read the same file, so its values must be adjusted when switching between cases. Parameter descriptions are provided in the example source files and in Chapter 4.The
testfitandtestparabprograms do not usevofvardef; their configuration is described in Section 4.2.Example configuration: The following configuration corresponds to a 3D test case involving:
A half-space defined by the unit normal vector (\(\texttt{xnc}=0\); \(\texttt{ync}=-1\); \(\texttt{znc}=0\)).
Intersection with a cubic cell (\(\texttt{icelltype}=11\)) having a truncated volume fraction \(\texttt{f}=0.5\).
Computation of the distance from point \(P\) (\(\texttt{xp}=0\); \(\texttt{yp}=0\); \(\texttt{zp}=0\)) to the reconstructed PLIC interface. This distance calculation requires a convex interfacial polygon. The example program performs it only for the selected convex cell types and when the cutting plane leaves nonzero portions of the cell on both sides.
Estimation of the volume of a spherical material body (\(\texttt{ishape}=11\)) within the cell using the initialization procedure with
nc=10 subdivisions per coordinate direction and tolerancetol=10.
Cell geometry, ICELLTYPE: 11 Material body shape, ISHAPE: 11 Material volume/area fraction, F: 0.5 X coordinate of the unit-length normal vector of the interface plane, XNC: 0.0 Y coordinate of the unit-length normal vector of the interface plane, YNC: -1.0 Z coordinate of the unit-length normal vector of the interface plane, ZNC: 0.0 !Ignore for 2D test programs X coordinate of point P from which the distance is calculated, XP: 0.0 Y coordinate of point P from which the distance is calculated, YP: 0.0 Z coordinate of point P from which the distance is calculated, ZP: 0.0 !Ignore for 2D test programs Subdivision number in the volume fraction cell initialization, NC: 10 Tolerance for the initialization procedure, TOL: 10.0
Execute a test program: Run the executable from the package root directory, where the required input files are located. For example, to run the 3D Fortran test:
./test3d_f
To run the corresponding C test:
./test3d_c
The
testfitexecutables requirepolygons-set.txtin the working directory; theMakefilecopies this file fromdata/during the build. Output files are written to the working directory. See Chapter 4 for the configuration and interpretation of each example.