rename USER-SMD package to MACHDYN
This commit is contained in:
5
lib/machdyn/.gitignore
vendored
Normal file
5
lib/machdyn/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
# ignore these entries with git
|
||||
/eigen.tar.gz
|
||||
/eigen-eigen-*
|
||||
/includelink
|
||||
/eigen3
|
||||
112
lib/machdyn/Install.py
Normal file
112
lib/machdyn/Install.py
Normal file
@ -0,0 +1,112 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
Install.py tool to download, unpack, and point to the Eigen library
|
||||
used to automate the steps described in the README file in this dir
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
import sys, os, glob, shutil, tarfile
|
||||
from argparse import ArgumentParser
|
||||
|
||||
sys.path.append('..')
|
||||
from install_helpers import fullpath, geturl, checkmd5sum
|
||||
|
||||
parser = ArgumentParser(prog='Install.py',
|
||||
description="LAMMPS library build wrapper script")
|
||||
|
||||
# settings
|
||||
|
||||
version = '3.3.7'
|
||||
tarball = "eigen.tar.gz"
|
||||
|
||||
# known checksums for different Eigen versions. used to validate the download.
|
||||
checksums = { \
|
||||
'3.3.7' : '9e30f67e8531477de4117506fe44669b' \
|
||||
}
|
||||
|
||||
|
||||
# help message
|
||||
|
||||
HELP = """
|
||||
Syntax from src dir: make lib-smd args="-b"
|
||||
or: make lib-smd args="-p /usr/include/eigen3"
|
||||
|
||||
Syntax from lib dir: python Install.py -b
|
||||
or: python Install.py -p /usr/include/eigen3"
|
||||
or: python Install.py -v 3.3.7 -b
|
||||
|
||||
Example:
|
||||
|
||||
make lib-smd args="-b" # download/build in default lib/smd/eigen-eigen-*
|
||||
make lib-smd args="-p /usr/include/eigen3" # use existing Eigen installation in /usr/include/eigen3
|
||||
"""
|
||||
|
||||
pgroup = parser.add_mutually_exclusive_group()
|
||||
pgroup.add_argument("-b", "--build", action="store_true",
|
||||
help="download and build the Eigen3 library")
|
||||
pgroup.add_argument("-p", "--path",
|
||||
help="specify folder of existing Eigen installation")
|
||||
parser.add_argument("-v", "--version", default=version,
|
||||
help="set version of Eigen to download and build (default: %s)" % version)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# print help message and exit, if neither build nor path options are given
|
||||
if not args.build and not args.path:
|
||||
parser.print_help()
|
||||
sys.exit(HELP)
|
||||
|
||||
homepath = fullpath(".")
|
||||
eigenpath = os.path.join(homepath, "eigen3")
|
||||
|
||||
buildflag = args.build
|
||||
pathflag = args.path is not None
|
||||
version = args.version
|
||||
|
||||
if pathflag:
|
||||
eigenpath = args.path
|
||||
if not os.path.isdir(eigenpath):
|
||||
sys.exit("Eigen path %s does not exist" % eigenpath)
|
||||
eigenpath = fullpath(eigenpath)
|
||||
|
||||
# download and unpack Eigen tarball
|
||||
# use glob to find name of dir it unpacks to
|
||||
|
||||
if buildflag:
|
||||
print("Downloading Eigen ...")
|
||||
eigentar = os.path.join(homepath, tarball)
|
||||
url = "https://gitlab.com/libeigen/eigen/-/archive/%s/eigen-%s.tar.gz" % (version,version)
|
||||
geturl(url, eigentar)
|
||||
|
||||
# verify downloaded archive integrity via md5 checksum, if known.
|
||||
if version in checksums:
|
||||
print("checking version %s\n" % version)
|
||||
if not checkmd5sum(checksums[version], eigentar):
|
||||
sys.exit("Checksum for Eigen library does not match")
|
||||
|
||||
|
||||
print("Cleaning up old folders ...")
|
||||
edir = glob.glob(os.path.join(homepath, "eigen-*"))
|
||||
edir.append(eigenpath)
|
||||
for one in edir:
|
||||
if os.path.isdir(one):
|
||||
shutil.rmtree(one)
|
||||
|
||||
print("Unpacking Eigen tarball ...")
|
||||
if tarfile.is_tarfile(eigentar):
|
||||
tgz = tarfile.open(eigentar)
|
||||
tgz.extractall(path=homepath)
|
||||
os.remove(eigentar)
|
||||
else:
|
||||
sys.exit("File %s is not a supported archive" % eigentar)
|
||||
edir = os.path.join(homepath, "eigen-%s" % version)
|
||||
os.rename(edir, eigenpath)
|
||||
|
||||
# create link in lib/smd to Eigen src dir
|
||||
|
||||
print("Creating link to Eigen include folder")
|
||||
if os.path.isfile("includelink") or os.path.islink("includelink"):
|
||||
os.remove("includelink")
|
||||
linkdir = eigenpath
|
||||
os.symlink(linkdir, 'includelink')
|
||||
5
lib/machdyn/Makefile.lammps
Normal file
5
lib/machdyn/Makefile.lammps
Normal file
@ -0,0 +1,5 @@
|
||||
# Settings that the LAMMPS build will import when this package library is used
|
||||
|
||||
machdyn_SYSINC = -I../../lib/includelink/eigen3
|
||||
machdyn_SYSLIB =
|
||||
machdyn_SYSPATH =
|
||||
44
lib/machdyn/README
Normal file
44
lib/machdyn/README
Normal file
@ -0,0 +1,44 @@
|
||||
This directory contains links to the Eigen library which is required
|
||||
to use the MACHDYN package in a LAMMPS input script.
|
||||
|
||||
The Eigen library is available at http://eigen.tuxfamily.org. It's
|
||||
a general C++ template library for linear algebra.
|
||||
|
||||
You can type "make lib-smd" from the src directory to see help on how
|
||||
to download build this library via make commands, or you can do the
|
||||
same thing by typing "python Install.py" from within this directory,
|
||||
or you can do it manually by following the instructions below.
|
||||
|
||||
Instructions:
|
||||
|
||||
1. Download the Eigen tarball at http://eigen.tuxfamily.org and
|
||||
unpack the tarball either in this /lib/smd directory or somewhere
|
||||
else on your system. It should unpack with into a directory with
|
||||
a name similar to eigen-eigen-bdd17ee3b1b3. You can rename
|
||||
the directory to just "eigen" if you wish. Note that Eigen is a
|
||||
template library, so you do not have to build it.
|
||||
|
||||
2. Create a soft link in this dir (lib/smd)
|
||||
to the eigen directory. E.g if you unpacked Eigen in this dir:
|
||||
% ln -s eigen-eigen-bdd17ee3b1b3 includelink
|
||||
If you unpacked Eigen somewhere else and renamed
|
||||
the resulting directory to just eigen, then do something like this:
|
||||
% ln -s /home/sjplimp/tools/eigen includelink
|
||||
|
||||
When these steps are complete you can build LAMMPS
|
||||
with the MACHDYN package installed:
|
||||
|
||||
% cd lammps/src
|
||||
% make yes-machdyn
|
||||
% make g++ (or whatever target you wish)
|
||||
|
||||
Note that if you download and unpack a new LAMMPS tarball, the
|
||||
"includelink" and "liblink" files will be lost and you will need to
|
||||
re-create them (step 2). If you unpacked the Eigen library in this
|
||||
directory (as opposed to somewhere else on your system), you will also
|
||||
need to repeat step 1.
|
||||
|
||||
The Makefile.lammps file in this directory is there for compatibility
|
||||
with the way other libraries under the lib dir are linked with by
|
||||
LAMMPS. However, the Eigen library requires no auxiliary files or
|
||||
settings, so its variables are blank.
|
||||
Reference in New Issue
Block a user