git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@9322 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
36
src/VORONOI/Install.sh
Executable file
36
src/VORONOI/Install.sh
Executable file
@ -0,0 +1,36 @@
|
||||
# Install/unInstall package files in LAMMPS
|
||||
# edit 2 Makefile.package files to include/exclude package info
|
||||
|
||||
if (test $1 = 1) then
|
||||
|
||||
if (test -e ../Makefile.package) then
|
||||
sed -i -e 's/[^ \t]*voronoi[^ \t]* //g' ../Makefile.package
|
||||
sed -i -e 's|^PKG_SYSINC =[ \t]*|&$(voronoi_SYSINC) |' ../Makefile.package
|
||||
sed -i -e 's|^PKG_SYSLIB =[ \t]*|&$(voronoi_SYSLIB) |' ../Makefile.package
|
||||
sed -i -e 's|^PKG_SYSPATH =[ \t]*|&$(voronoi_SYSPATH) |' ../Makefile.package
|
||||
fi
|
||||
|
||||
if (test -e ../Makefile.package.settings) then
|
||||
sed -i -e '/^include.*VORONOI.*$/d' ../Makefile.package.settings
|
||||
# multiline form needed for BSD sed on Macs
|
||||
sed -i -e '4 i \
|
||||
include ..\/VORONOI\/Makefile.lammps
|
||||
' ../Makefile.package.settings
|
||||
fi
|
||||
|
||||
cp compute_voronoi_atom.h ..
|
||||
cp compute_voronoi_atom.cpp ..
|
||||
|
||||
elif (test $1 = 0) then
|
||||
|
||||
if (test -e ../Makefile.package) then
|
||||
sed -i -e 's/[^ \t]*voronoi[^ \t]* //g' ../Makefile.package
|
||||
fi
|
||||
|
||||
if (test -e ../Makefile.package.settings) then
|
||||
sed -i -e '/^include.*VORONOI.*$/d' ../Makefile.package.settings
|
||||
fi
|
||||
|
||||
rm -f ../compute_voronoi_atom.h
|
||||
rm -f ../compute_voronoi_atom.cpp
|
||||
fi
|
||||
20
src/VORONOI/Makefile.lammps
Normal file
20
src/VORONOI/Makefile.lammps
Normal file
@ -0,0 +1,20 @@
|
||||
# This file contains the hooks to build and link LAMMPS with the Voro++
|
||||
# library so that a LAMMPS input script can calculate a Voronoi tesselation,
|
||||
# via the compute voronoi/atom command.
|
||||
#
|
||||
# See the README in this directory for more info on installing Voro++.
|
||||
#
|
||||
# When you build LAMMPS with the VORONOI package installed, it will use the
|
||||
# 3 settings in this file. They should be set as follows.
|
||||
#
|
||||
# voronoi_SYSINC = a path to the Voro++ include files
|
||||
# voronoi_SYSLIB = the Voro++ library
|
||||
# voronoi_SYSPATH = a path to the Voro++ library
|
||||
|
||||
# -----------------------------------------------------------
|
||||
|
||||
# Settings that the LAMMPS build will import when this package is installed
|
||||
|
||||
voronoi_SYSINC = -I/usr/local/include/voro++
|
||||
voronoi_SYSLIB = -lvoro++
|
||||
voronoi_SYSPATH = -L/usr/local/lib
|
||||
37
src/VORONOI/README
Normal file
37
src/VORONOI/README
Normal file
@ -0,0 +1,37 @@
|
||||
The VORONOI package adds a compute voronoi/atom command which
|
||||
calculates a Voronoi tesselation of the system.
|
||||
|
||||
It uses the Voro++ library, available at http://math.lbl.gov/voro++ to
|
||||
compute the tesselation locally on each processor.
|
||||
|
||||
== Installation of the Voro++ library ==
|
||||
|
||||
1. Download Voro++ at http://math.lbl.gov/voro++/download
|
||||
which gives instructions for using SVN to check-out the source:
|
||||
% svn checkout https://codeforge.lbl.gov/anonscm/voro/trunk
|
||||
|
||||
2. compile Voro++
|
||||
% make
|
||||
|
||||
3. install Voro++ at the default location (/usr/local)
|
||||
% sudo make install
|
||||
|
||||
3b. ..or change the PREFIX variable in the config.mk file
|
||||
to a location that is writable by the user i.e.
|
||||
PREFIX=/home/maxuser/install/
|
||||
|
||||
4. In the LAMMPS src directory add the VORONOI package
|
||||
% make yes-voronoi
|
||||
|
||||
4b. if a different PREFIX than the default was used to install Voro++
|
||||
update the paths in the src/VORONOI/Makefile.lammps file
|
||||
|
||||
5. Compile LAMMPS (you should know how that works)
|
||||
|
||||
|
||||
== Credits and license ==
|
||||
|
||||
This compute was written by Daniel Schwen (daniel@schwen.de) and is
|
||||
licensed under the GPLv2 license.
|
||||
|
||||
Please contribute changes back to the community.
|
||||
143
src/VORONOI/compute_voronoi_atom.cpp
Normal file
143
src/VORONOI/compute_voronoi_atom.cpp
Normal file
@ -0,0 +1,143 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, Sandia National Laboratories
|
||||
Steve Plimpton, sjplimp@sandia.gov
|
||||
|
||||
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
certain rights in this software. This software is distributed under
|
||||
the GNU General Public License.
|
||||
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing author: Daniel Schwen
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "math.h"
|
||||
#include "string.h"
|
||||
#include "stdlib.h"
|
||||
#include "compute_voronoi_atom.h"
|
||||
#include "atom.h"
|
||||
#include "update.h"
|
||||
#include "modify.h"
|
||||
#include "domain.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include "comm.h"
|
||||
|
||||
#include <vector>
|
||||
#include "voro++.hh"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace voro;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeVoronoi::ComputeVoronoi(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg)
|
||||
{
|
||||
if (narg != 3) error->all(FLERR,"Illegal compute voronoi/atom command");
|
||||
|
||||
peratom_flag = 1;
|
||||
size_peratom_cols = 2;
|
||||
|
||||
nmax = 0;
|
||||
voro = NULL;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeVoronoi::~ComputeVoronoi()
|
||||
{
|
||||
memory->destroy(voro);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeVoronoi::init()
|
||||
{
|
||||
if (domain->dimension != 3)
|
||||
error->all(FLERR,"Compute voronoi/atom not allowed for 2d systems");
|
||||
if (domain->triclinic != 0)
|
||||
error->all(FLERR,"Compute voronoi/atom not allowed for triclinic boxes");
|
||||
|
||||
int count = 0;
|
||||
for (int i = 0; i < modify->ncompute; i++)
|
||||
if (strcmp(modify->compute[i]->style,"voronoi/atom") == 0) count++;
|
||||
if (count > 1 && comm->me == 0)
|
||||
error->warning(FLERR,"More than one compute voronoi/atom command");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
gather compute vector data from other nodes
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ComputeVoronoi::compute_peratom()
|
||||
{
|
||||
int i;
|
||||
|
||||
invoked_peratom = update->ntimestep;
|
||||
|
||||
// grow per atom array if necessary
|
||||
|
||||
int local = atom->nlocal;
|
||||
if (nlocal > nmax) {
|
||||
memory->destroy(voro);
|
||||
nmax = atom->nmax;
|
||||
memory->create(voro,nmax,size_peratom_cols,"voronoi/atom:voro");
|
||||
array_atom = voro;
|
||||
}
|
||||
|
||||
// n = # of voro++ spatial hash cells
|
||||
// TODO: make square
|
||||
|
||||
int nall = nlocal + atom->nghost;
|
||||
int n = int(floor( pow( double(nall)/8.0, 0.333333 ) ));
|
||||
n = (n==0) ? 1 : n;
|
||||
|
||||
// initialize voro++ container
|
||||
// preallocates 8 atoms per cell
|
||||
// voro++ allocates more memory if needed
|
||||
|
||||
double *sublo = domain->sublo;
|
||||
double *subhi = domain->subhi;
|
||||
double *cut = comm->cutghost;
|
||||
|
||||
container con(sublo[0]-cut[0],subhi[0]+cut[0],
|
||||
sublo[1]-cut[1],subhi[1]+cut[1],
|
||||
sublo[2]-cut[2],subhi[2]+cut[2],
|
||||
n,n,n,false,false,false,8);
|
||||
|
||||
// pass coordinates for local and ghost atoms to voro++
|
||||
|
||||
double **x = atom->x;
|
||||
for (i = 0; i < nall; i++)
|
||||
con.put(i,x[i][0],x[i][1],x[i][2]);
|
||||
|
||||
// invoke voro++ and fetch results for owned atoms in group
|
||||
|
||||
std::vector<int> neigh;
|
||||
|
||||
voronoicell_neighbor c;
|
||||
c_loop_all cl(con);
|
||||
if (cl.start()) do if (con.compute_cell(c,cl)) {
|
||||
i = cl.pid();
|
||||
if (i < nlocal && (mask[i] & groupbit)) {
|
||||
voro[i][0] = c.volume();
|
||||
c.neighbors(neigh);
|
||||
voro[i][1] = neigh.size();
|
||||
} else if (i < nlocal) voro[i][0] = voro[i][1] = 0.0;
|
||||
} while (cl.inc());
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
memory usage of local atom-based array
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
double ComputeVoronoi::memory_usage()
|
||||
{
|
||||
double bytes = size_peratom_cols * nmax * sizeof(double);
|
||||
return bytes;
|
||||
}
|
||||
53
src/VORONOI/compute_voronoi_atom.h
Normal file
53
src/VORONOI/compute_voronoi_atom.h
Normal file
@ -0,0 +1,53 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, Sandia National Laboratories
|
||||
Steve Plimpton, sjplimp@sandia.gov
|
||||
|
||||
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
certain rights in this software. This software is distributed under
|
||||
the GNU General Public License.
|
||||
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef COMPUTE_CLASS
|
||||
|
||||
ComputeStyle(voronoi/atom,ComputeVoronoi)
|
||||
|
||||
#else
|
||||
|
||||
#ifndef LMP_COMPUTE_VORONOI_H
|
||||
#define LMP_COMPUTE_VORONOI_H
|
||||
|
||||
#include "compute.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class ComputeVoronoi : public Compute {
|
||||
public:
|
||||
ComputeVoronoi(class LAMMPS *, int, char **);
|
||||
~ComputeVoronoi();
|
||||
void init();
|
||||
void compute_peratom();
|
||||
double memory_usage();
|
||||
|
||||
private:
|
||||
int nmax;
|
||||
double **voro;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ERROR/WARNING messages:
|
||||
|
||||
E: Illegal ... command
|
||||
|
||||
Self-explanatory. Check the input script syntax and compare to the
|
||||
documentation for the command. You can use -echo screen as a
|
||||
command-line option when running LAMMPS to see the offending line.
|
||||
|
||||
*/
|
||||
Reference in New Issue
Block a user