add some support functions to cast pointers and get values from pointers
This commit is contained in:
@ -1,5 +1,14 @@
|
||||
%{
|
||||
%include "cpointer.i"
|
||||
%include "carrays.i"
|
||||
%include "cdata.i"
|
||||
|
||||
%array_functions(char, charp);
|
||||
%pointer_functions(int, intp);
|
||||
%pointer_functions(double, doublep);
|
||||
%pointer_cast(void *, int *, void_to_int);
|
||||
%pointer_cast(void *, double *, void_to_double);
|
||||
|
||||
%{
|
||||
enum _LMP_DATATYPE_CONST {
|
||||
LAMMPS_INT = 0, /*!< 32-bit integer (array) */
|
||||
LAMMPS_INT_2D = 1, /*!< two-dimensional 32-bit integer array */
|
||||
|
||||
@ -14,7 +14,8 @@ lualammps.lammps_command(lmp, "create_atoms 1 box")
|
||||
|
||||
print("LAMMPS version ", ver)
|
||||
print("Number of created atoms: ", lualammps.lammps_get_natoms(lmp))
|
||||
lualammps.lammps_close(lmp )
|
||||
print("Current size of timestep: ", lualammps.doublep_value(lualammps.void_to_double(lualammps.lammps_extract_global(lmp,"dt"))))
|
||||
lualammps.lammps_close(lmp)
|
||||
EOF
|
||||
|
||||
lua example.lua
|
||||
|
||||
@ -14,6 +14,7 @@ pllammps::lammps_command(\$lmp, "create_atoms 1 box");
|
||||
|
||||
print("LAMMPS version ",\$ver,"\n");
|
||||
print("Number of created atoms: ", pllammps::lammps_get_natoms(\$lmp), "\n");
|
||||
print("Current size of timestep: ", pllammps::doublep_value(pllammps::void_to_double(pllammps::lammps_extract_global(\$lmp,"dt"))), "\n");
|
||||
pllammps::lammps_close(\$lmp)
|
||||
EOF
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@ lammps_command(lmp, "create_atoms 1 box")
|
||||
|
||||
print("LAMMPS version ",ver)
|
||||
print("Number of created atoms: %g" % lammps_get_natoms(lmp))
|
||||
print("Current size of timestep: %g" % doublep_value(void_to_double(lammps_extract_global(lmp,'dt'))))
|
||||
lammps_close(lmp)
|
||||
EOF
|
||||
|
||||
|
||||
@ -12,8 +12,10 @@ lammps_command \$lmp "region box block -5 5 -5 5 -5 5"
|
||||
lammps_command \$lmp "create_box 1 box"
|
||||
lammps_command \$lmp "create_atoms 1 box"
|
||||
|
||||
set dt [doublep_value [void_to_double [lammps_extract_global \$lmp dt]]]
|
||||
puts "LAMMPS version \$ver"
|
||||
puts [format "Number of created atoms: %g" [lammps_get_natoms \$lmp]]
|
||||
puts "Current size of timestep: \$dt"
|
||||
lammps_close \$lmp
|
||||
EOF
|
||||
|
||||
|
||||
Reference in New Issue
Block a user