Skip to content

Commit

Permalink
Add LAMMPS build (idaholab#349)
Browse files Browse the repository at this point in the history
  • Loading branch information
dschwen committed Aug 23, 2018
1 parent c2cda6a commit bb7199e
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "contrib/mytrim"]
path = contrib/mytrim
url = https://github.com/idaholab/mytrim.git
[submodule "contrib/lammps"]
path = contrib/lammps
url = https://github.com/dschwen/lammps
1 change: 1 addition & 0 deletions contrib/lammps
Submodule lammps added at 0a2220
22 changes: 22 additions & 0 deletions contrib/lammps.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
###############################################################################
################################### LAMMPS ####################################
###############################################################################

# run Make.sh to recreate the style_*.h files
OUT := $(shell cd $(LAMMPS_DIR)/src && make yes-GRANULAR && make lmpinstalledpkgs.h && bash ./Make.sh style)

# source files (main stuff and GRANULAR package)
lammps_cppsrcfiles := $(shell find $(LAMMPS_DIR)/src -maxdepth 1 -name "*.cpp" -not -name "main.cpp")

# We need to be careful about the mpi STUBS (not including those for now)
#lammps_csrcfiles := $(shell find $(LAMMPS_DIR) -name "*.c")

app_HEADERS := $(shell find $(LAMMPS_DIR)/src -maxdepth 1 -name "*.h")

# object files
ADDITIONAL_APP_OBJECTS += $(patsubst %.cpp, %.$(obj-suffix), $(lammps_cppsrcfiles)) \
$(patsubst %.c, %.$(obj-suffix), $(lammps_csrcfiles))

# dependencies (C, C++ files only)
ADDITIONAL_APP_DEPS += $(patsubst %.cpp, %.$(obj-suffix).d, $(lammps_cppsrcfiles)) \
$(patsubst %.c, %.$(obj-suffix).d, $(lammps_csrcfiles))
3 changes: 1 addition & 2 deletions contrib/spparks.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################################
############################### SPPARKS #######################################
################################### SPPARKS ###################################
###############################################################################

# run Make.sh to recreate the stytle_*.h files
Expand All @@ -20,4 +20,3 @@ ADDITIONAL_APP_OBJECTS += $(patsubst %.cpp, %.$(obj-suffix), $(spparks_cppsr
# dependencies (C, C++ files only)
ADDITIONAL_APP_DEPS += $(patsubst %.cpp, %.$(obj-suffix).d, $(spparks_cppsrcfiles)) \
$(patsubst %.c, %.$(obj-suffix).d, $(spparks_csrcfiles))

20 changes: 20 additions & 0 deletions doc/content/getting_started/BuildingLAMMPS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Building LAMMPS

Check out the LAMMPS repository and use the CMake based build system

```
git clone [email protected]:lammps/lammps.git
cd lammps
mkdir build && cd build
cmake ../cmake -DBUILD_LIB=yes -DPKG_GRANULAR=yes -DWITH_JPEG=no
make -j 8
make install
```

Adjust the `-j 8` argument to the number of available CPU cores for building.

This builds LAMMPS as a library and installs it (`sudo` may be required on your
system for the install step). The LAMMPS cmake build system will install a
pkg-config file `liblammps.pc` (into `/usr/local/lib/pkgconfig/liblammps.pc/` by
default). Make sure this path is listed in the `PKG_CONFIG_PATH` environment
variable.
8 changes: 6 additions & 2 deletions doc/content/getting_started/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ or the `MOOSE_DIR` environment variable to point to the MOOSE directory.

## Install prerequisite packages

Magpie needs GSL (GNU Scientific Library) and the fast Fourier transform library
FFTW3 installed for a feature complete build. The configuration of these
The SPPARKS and LAMMPS Monte Carlo and molecular dynamics packages are optional
dependencies for Magpie. See [building SPPARKS](BuildingSPPARKS.md) and
[building LAMMPS](BuildingLAMMPS.md) for instructions on how to build them.

Magpie also needs GSL (GNU Scientific Library) and the fast Fourier transform
library FFTW3 installed for a feature complete build. The configuration of these
external packages is performed using
[pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/).
Installation of these dependencies is system specific:
Expand Down
19 changes: 14 additions & 5 deletions magpie.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@
# Check the existence of the contrib submodules and build accordingly
#

SPPARKS_DIR ?= $(MAGPIE_DIR)/contrib/spparks
ifneq ($(wildcard $(SPPARKS_DIR)/src/Makefile),)
ADDITIONAL_CPPFLAGS += -DSPPARKS_ENABLED
app_INCLUDES += -I $(SPPARKS_DIR)/..
include $(MAGPIE_DIR)/contrib/spparks.mk
# first check if LAMMPS is present
LAMMPS_DIR ?= $(MAGPIE_DIR)/contrib/lammps
ifneq ($(wildcard $(LAMMPS_DIR)/src/Makefile),)
ADDITIONAL_CPPFLAGS += -DLAMMPS_ENABLED
app_INCLUDES += -I $(LAMMPS_DIR)/..
include $(MAGPIE_DIR)/contrib/lammps.mk
else
# if not check for SPPARKS (we cannot currently build with both enabled!)
SPPARKS_DIR ?= $(MAGPIE_DIR)/contrib/spparks
ifneq ($(wildcard $(SPPARKS_DIR)/src/Makefile),)
ADDITIONAL_CPPFLAGS += -DSPPARKS_ENABLED
app_INCLUDES += -I $(SPPARKS_DIR)/..
include $(MAGPIE_DIR)/contrib/spparks.mk
endif
endif

MYTRIM_DIR ?= $(MAGPIE_DIR)/contrib/mytrim
Expand Down

0 comments on commit bb7199e

Please sign in to comment.