| 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/shifted/,) |
| 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 |
DIFFUSION_SRC = diffusion.cpp sbm_solver.cpp marking.cpp |
| 24 |
DIFFUSION_OBJ = $(DIFFUSION_SRC:.cpp=.o) |
| 25 |
DISTANCE_SRC = distance.cpp |
| 26 |
DISTANCE_OBJ = $(DISTANCE_SRC:.cpp=.o) |
| 27 |
EXTRAPOLATE_SRC = extrapolate.cpp extrapolator.cpp marking.cpp |
| 28 |
EXTRAPOLATE_OBJ = $(EXTRAPOLATE_SRC:.cpp=.o) |
| 29 |
ALGOIM_SRC = lsf_integral.cpp |
| 30 |
ALGOIM_OBJ = $(ALGOIM_SRC:.cpp=.o) |
| 31 |
|
| 32 |
SEQ_MINIAPPS = lsf_integral |
| 33 |
PAR_MINIAPPS = distance diffusion extrapolate |
| 34 |
|
| 35 |
ifeq ($(MFEM_USE_MPI),NO) |
| 36 |
MINIAPPS = $(SEQ_MINIAPPS) |
| 37 |
else |
| 38 |
MINIAPPS = $(PAR_MINIAPPS) $(SEQ_MINIAPPS) |
| 39 |
endif |
| 40 |
|
| 41 |
COMMON_LIB = -L$(MFEM_BUILD_DIR)/miniapps/common -lmfem-common |
| 42 |
|
| 43 |
# If MFEM_SHARED is set, add the ../common rpath |
| 44 |
COMMON_LIB += $(if $(MFEM_SHARED:YES=),,\ |
| 45 |
$(MFEM_XLINKER)-rpath,$(abspath $(MFEM_BUILD_DIR)/miniapps/common)) |
| 46 |
|
| 47 |
.SUFFIXES: |
| 48 |
.SUFFIXES: .o .cpp .mk |
| 49 |
.PHONY: all lib-common clean clean-build clean-exec |
| 50 |
|
| 51 |
# Remove built-in rule |
| 52 |
%: %.cpp |
| 53 |
%.o: %.cpp |
| 54 |
|
| 55 |
%.o: $(SRC)%.cpp $(SRC)sbm_aux.hpp $(wildcard $(SRC)%.hpp) $(MFEM_LIB_FILE)\ |
| 56 |
$(CONFIG_MK) | lib-common |
| 57 |
$(MFEM_CXX) $(MFEM_FLAGS) -c $< -o $@ |
| 58 |
|
| 59 |
all: $(MINIAPPS) |
| 60 |
|
| 61 |
lsf_integral: $(ALGOIM_OBJ) |
| 62 |
$(MFEM_CXX) $(MFEM_LINK_FLAGS) -o $@ $(ALGOIM_OBJ) $(COMMON_LIB) $(MFEM_LIBS) |
| 63 |
|
| 64 |
distance: $(DISTANCE_OBJ) |
| 65 |
$(MFEM_CXX) $(MFEM_LINK_FLAGS) -o $@ $(DISTANCE_OBJ) $(COMMON_LIB) $(MFEM_LIBS) |
| 66 |
|
| 67 |
diffusion: $(DIFFUSION_OBJ) |
| 68 |
$(MFEM_CXX) $(MFEM_LINK_FLAGS) -o $@ $(DIFFUSION_OBJ) $(COMMON_LIB) $(MFEM_LIBS) |
| 69 |
|
| 70 |
extrapolate: $(EXTRAPOLATE_OBJ) |
| 71 |
$(MFEM_CXX) $(MFEM_LINK_FLAGS) -o $@ $(EXTRAPOLATE_OBJ) $(COMMON_LIB) $(MFEM_LIBS) |
| 72 |
|
| 73 |
# Rule for building lib-common |
| 74 |
lib-common: |
| 75 |
$(MAKE) -C $(MFEM_BUILD_DIR)/miniapps/common |
| 76 |
|
| 77 |
MFEM_TESTS = MINIAPPS |
| 78 |
include $(MFEM_TEST_MK) |
| 79 |
|
| 80 |
# Testing: Parallel vs. serial runs |
| 81 |
RUN_MPI = $(MFEM_MPIEXEC) $(MFEM_MPIEXEC_NP) $(MFEM_MPI_NP) |
| 82 |
TEST_NAME := Shifted miniapp |
| 83 |
%-test-par: % |
| 84 |
@$(call mfem-test,$<, $(RUN_MPI), $(TEST_NAME)) |
| 85 |
%-test-seq: % |
| 86 |
@$(call mfem-test,$<,, $(TEST_NAME)) |
| 87 |
|
| 88 |
# Testing: "test" target and mfem-test* variables are defined in config/test.mk |
| 89 |
|
| 90 |
# Generate an error message if the MFEM library is not built and exit |
| 91 |
$(MFEM_LIB_FILE): |
| 92 |
$(error The MFEM library is not built) |
| 93 |
|
| 94 |
clean: clean-build clean-exec |
| 95 |
|
| 96 |
clean-build: |
| 97 |
rm -f *.o *~ distance diffusion extrapolate lsf_integral |
| 98 |
rm -rf *.dSYM *.TVD.*breakpoints |
| 99 |
|
| 100 |
clean-exec: |
| 101 |
@rm -f diffusion.mesh diffusion.gf |
| 102 |
@rm -rf ParaViewDistance ParaViewDiffusion ParaViewExtrapolate ParaViewLSF |