| 1 |
# Copyright (c) 2010-2025, Lawrence Livermore National Security, LLC. Produced |
| 2 |
# at the Lawrence Livermore National Laboratory. All Rights reserved. See files |
| 3 |
# LICENSE and NOTICE for details. LLNL-CODE-806117. |
| 4 |
# |
| 5 |
# This file is part of the MFEM library. For more information and source code |
| 6 |
# availability visit https://mfem.org. |
| 7 |
# |
| 8 |
# MFEM is free software; you can redistribute it and/or modify it under the |
| 9 |
# terms of the BSD-3 license. We welcome feedback and contributions, see file |
| 10 |
# CONTRIBUTING.md for details. |
| 11 |
|
| 12 |
# Use the MFEM build directory |
| 13 |
MFEM_DIR ?= ../.. |
| 14 |
MFEM_BUILD_DIR ?= ../.. |
| 15 |
MFEM_INSTALL_DIR ?= ../../mfem |
| 16 |
SRC = $(if $(MFEM_DIR:../..=),$(MFEM_DIR)/miniapps/hooke/,) |
| 17 |
CONFIG_MK = $(or $(wildcard $(MFEM_BUILD_DIR)/config/config.mk),\ |
| 18 |
$(wildcard $(MFEM_INSTALL_DIR)/share/mfem/config.mk)) |
| 19 |
|
| 20 |
MFEM_LIB_FILE = mfem_is_not_built |
| 21 |
-include $(CONFIG_MK) |
| 22 |
|
| 23 |
HOOKE_SRC = hooke.cpp\ |
| 24 |
operators/elasticity_operator.cpp\ |
| 25 |
operators/elasticity_gradient_operator.cpp\ |
| 26 |
preconditioners/diagonal_preconditioner.cpp |
| 27 |
HOOKE_OBJ = $(HOOKE_SRC:.cpp=.o) |
| 28 |
|
| 29 |
SEQ_MINIAPPS = |
| 30 |
PAR_MINIAPPS = hooke |
| 31 |
# The hooke miniapp crashes the AMD HIP compiler, so for now we disable it |
| 32 |
# when HIP is enabled: |
| 33 |
ifeq ($(MFEM_USE_HIP),YES) |
| 34 |
PAR_MINIAPPS = |
| 35 |
endif |
| 36 |
ifeq ($(MFEM_USE_MPI),NO) |
| 37 |
MINIAPPS = $(SEQ_MINIAPPS) |
| 38 |
else |
| 39 |
MINIAPPS = $(PAR_MINIAPPS) $(SEQ_MINIAPPS) |
| 40 |
endif |
| 41 |
MFEM_TESTS = MINIAPPS |
| 42 |
|
| 43 |
.SUFFIXES: |
| 44 |
.SUFFIXES: .o .cpp .mk |
| 45 |
.PHONY: all clean clean-build clean-exec |
| 46 |
.PRECIOUS: %.o |
| 47 |
|
| 48 |
all: $(MINIAPPS) |
| 49 |
|
| 50 |
# Remove built-in rules |
| 51 |
%: %.cpp |
| 52 |
%.o: %.cpp |
| 53 |
|
| 54 |
HOOKE_INCLUDES = $(if $(SRC),-I$(MFEM_DIR)) |
| 55 |
|
| 56 |
hooke: $(HOOKE_OBJ) |
| 57 |
$(MFEM_CXX) $(MFEM_LINK_FLAGS) -o $@ $(HOOKE_OBJ) $(MFEM_LIBS) |
| 58 |
|
| 59 |
$(HOOKE_OBJ): %.o: $(SRC)%.cpp $(MFEM_LIB_FILE) $(CONFIG_MK) |
| 60 |
@mkdir -p $(@D) |
| 61 |
$(MFEM_CXX) $(MFEM_FLAGS) $(HOOKE_INCLUDES) -c $< -o $@ |
| 62 |
|
| 63 |
include $(MFEM_TEST_MK) |
| 64 |
|
| 65 |
# Testing: Specific execution options |
| 66 |
RUN_MPI = $(MFEM_MPIEXEC) $(MFEM_MPIEXEC_NP) $(MFEM_MPI_NP) |
| 67 |
hooke-test-par: hooke |
| 68 |
@$(call mfem-test,$<, $(RUN_MPI), Hooke miniapp,-rs 0) |
| 69 |
|
| 70 |
# Generate an error message if the MFEM library is not built and exit |
| 71 |
$(MFEM_LIB_FILE): |
| 72 |
$(error The MFEM library is not built) |
| 73 |
|
| 74 |
clean: clean-build clean-exec |
| 75 |
|
| 76 |
clean-build: |
| 77 |
rm -f *.o *~ $(SEQ_MINIAPPS) $(PAR_MINIAPPS) $(HOOKE_OBJ) |
| 78 |
rm -rf *.dSYM *.TVD.*breakpoints |
| 79 |
|
| 80 |
clean-exec: |
| 81 |
@rm -rf mesh.* sol.* ParaView |