| 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)/examples/,) |
| 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 |
SEQ_EXAMPLES = ex0 ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 ex9 ex10 ex14 ex15 ex16 \ |
| 24 |
ex17 ex18 ex19 ex20 ex21 ex22 ex23 ex24 ex25 ex26 ex27 ex28 ex29 ex30 \ |
| 25 |
ex31 ex33 ex34 ex36 ex37 ex38 ex39 ex40 ex41 |
| 26 |
PAR_EXAMPLES = ex0p ex1p ex2p ex3p ex4p ex5p ex6p ex7p ex8p ex9p ex10p ex11p \ |
| 27 |
ex12p ex13p ex14p ex15p ex16p ex17p ex18p ex19p ex20p ex21p ex22p ex24p \ |
| 28 |
ex25p ex26p ex27p ex28p ex29p ex30p ex31p ex32p ex33p ex34p ex35p ex36p \ |
| 29 |
ex37p ex39p ex40p ex41p |
| 30 |
SEQ_DEVICE_EXAMPLES = ex1 ex3 ex4 ex5 ex6 ex9 ex14 ex22 ex24 ex25 ex26 ex34 |
| 31 |
PAR_DEVICE_EXAMPLES = ex1p ex2p ex3p ex4p ex5p ex6p ex7p ex9p ex13p ex14p \ |
| 32 |
ex22p ex24p ex25p ex26p ex34p ex35p |
| 33 |
|
| 34 |
ifeq ($(MFEM_USE_LAPACK),YES) |
| 35 |
SEQ_EXAMPLES += ex38 |
| 36 |
endif |
| 37 |
|
| 38 |
ifeq ($(MFEM_USE_MPI),NO) |
| 39 |
EXAMPLES = $(SEQ_EXAMPLES) |
| 40 |
else |
| 41 |
EXAMPLES = $(PAR_EXAMPLES) $(SEQ_EXAMPLES) |
| 42 |
endif |
| 43 |
SUBDIRS = |
| 44 |
ifeq ($(MFEM_USE_AMGX),YES) |
| 45 |
SUBDIRS += amgx |
| 46 |
endif |
| 47 |
ifeq ($(MFEM_USE_GINKGO),YES) |
| 48 |
SUBDIRS += ginkgo |
| 49 |
endif |
| 50 |
ifeq ($(MFEM_USE_HIOP),YES) |
| 51 |
SUBDIRS += hiop |
| 52 |
endif |
| 53 |
ifeq ($(MFEM_USE_PETSC),YES) |
| 54 |
SUBDIRS += petsc |
| 55 |
endif |
| 56 |
ifeq ($(MFEM_USE_PUMI),YES) |
| 57 |
SUBDIRS += pumi |
| 58 |
endif |
| 59 |
ifeq ($(MFEM_USE_SUNDIALS),YES) |
| 60 |
SUBDIRS += sundials |
| 61 |
endif |
| 62 |
ifeq ($(MFEM_USE_SUPERLU),YES) |
| 63 |
SUBDIRS += superlu |
| 64 |
endif |
| 65 |
ifeq ($(MFEM_USE_MOONOLITH),YES) |
| 66 |
SUBDIRS += moonolith |
| 67 |
endif |
| 68 |
ifeq ($(MFEM_USE_CALIPER),YES) |
| 69 |
SUBDIRS += caliper |
| 70 |
endif |
| 71 |
|
| 72 |
SUBDIRS_ALL = $(addsuffix /all,$(SUBDIRS)) |
| 73 |
SUBDIRS_TEST = $(addsuffix /test,$(SUBDIRS)) |
| 74 |
SUBDIRS_CLEAN = $(addsuffix /clean,$(SUBDIRS)) |
| 75 |
SUBDIRS_TPRINT = $(addsuffix /test-print,$(SUBDIRS)) |
| 76 |
|
| 77 |
.SUFFIXES: |
| 78 |
.SUFFIXES: .o .cpp .mk |
| 79 |
.PHONY: all clean clean-build clean-exec |
| 80 |
|
| 81 |
# Remove built-in rule |
| 82 |
%: %.cpp |
| 83 |
|
| 84 |
# Replace the default implicit rule for *.cpp files |
| 85 |
%: $(SRC)%.cpp $(MFEM_LIB_FILE) $(CONFIG_MK) |
| 86 |
$(MFEM_CXX) $(MFEM_FLAGS) $< -o $@ $(MFEM_LIBS) |
| 87 |
|
| 88 |
all: $(EXAMPLES) $(SUBDIRS_ALL) |
| 89 |
|
| 90 |
.PHONY: $(SUBDIRS_ALL) $(SUBDIRS_TEST) $(SUBDIRS_CLEAN) $(SUBDIRS_TPRINT) |
| 91 |
$(SUBDIRS_ALL) $(SUBDIRS_TEST) $(SUBDIRS_CLEAN): |
| 92 |
$(MAKE) -C $(@D) $(@F) |
| 93 |
$(SUBDIRS_TPRINT): |
| 94 |
@$(MAKE) -C $(@D) $(@F) |
| 95 |
|
| 96 |
# Additional dependencies |
| 97 |
ex18: $(SRC)ex18.hpp |
| 98 |
ex33: $(SRC)ex33.hpp |
| 99 |
ex37: $(SRC)ex37.hpp |
| 100 |
|
| 101 |
ifeq ($(MFEM_USE_MPI),YES) |
| 102 |
ex18p: $(SRC)ex18.hpp |
| 103 |
ex33p: $(SRC)ex33.hpp |
| 104 |
ex37p: $(SRC)ex37.hpp |
| 105 |
endif |
| 106 |
|
| 107 |
MFEM_TESTS = EXAMPLES |
| 108 |
include $(MFEM_TEST_MK) |
| 109 |
test: $(SUBDIRS_TEST) |
| 110 |
test-print: $(SUBDIRS_TPRINT) |
| 111 |
|
| 112 |
# Testing: Parallel vs. serial runs |
| 113 |
RUN_MPI = $(MFEM_MPIEXEC) $(MFEM_MPIEXEC_NP) $(MFEM_MPI_NP) |
| 114 |
%-test-par: % |
| 115 |
@$(call mfem-test,$<, $(RUN_MPI), Parallel example) |
| 116 |
%-test-seq: % |
| 117 |
@$(call mfem-test,$<,, Serial example) |
| 118 |
%-test-par-cuda: % |
| 119 |
@$(call mfem-test,$<, $(RUN_MPI), Parallel CUDA example,-d cuda) |
| 120 |
%-test-seq-cuda: % |
| 121 |
@$(call mfem-test,$<,, Serial CUDA example,-d cuda) |
| 122 |
%-test-par-hip: % |
| 123 |
@$(call mfem-test,$<, $(RUN_MPI), Parallel HIP example,-d hip) |
| 124 |
%-test-seq-hip: % |
| 125 |
@$(call mfem-test,$<,, Serial HIP example,-d hip) |
| 126 |
|
| 127 |
# Testing: Specific execution options |
| 128 |
ex0-test-seq: ex0 |
| 129 |
@$(call mfem-test,$<,, Serial example,,1) |
| 130 |
ex0p-test-par: ex0p |
| 131 |
@$(call mfem-test,$<, $(RUN_MPI), Parallel example,,1) |
| 132 |
ex1-test-seq: ex1 |
| 133 |
@$(call mfem-test,$<,, Serial example) |
| 134 |
ex1p-test-par: ex1p |
| 135 |
@$(call mfem-test,$<, $(RUN_MPI), Parallel example) |
| 136 |
ex10-test-seq: ex10 |
| 137 |
@$(call mfem-test,$<,, Serial example,-tf 5) |
| 138 |
ex10p-test-par: ex10p |
| 139 |
@$(call mfem-test,$<, $(RUN_MPI), Parallel example,-tf 5) |
| 140 |
ex14-test-seq-cuda: ex14 |
| 141 |
@$(call mfem-test,$<,, Serial CUDA example,-r 2 -pa -d cuda) |
| 142 |
ex14p-test-par-cuda: ex14p |
| 143 |
@$(call mfem-test,$<, $(RUN_MPI), Parallel CUDA example,-rs 2 -rp 0 -pa -d cuda) |
| 144 |
ex14-test-seq-hip: ex14 |
| 145 |
@$(call mfem-test,$<,, Serial HIP example,-r 2 -pa -d hip) |
| 146 |
ex14p-test-par-hip: ex14p |
| 147 |
@$(call mfem-test,$<, $(RUN_MPI), Parallel HIP example,-rs 2 -rp 0 -pa -d hip) |
| 148 |
ex15-test-seq: ex15 |
| 149 |
@$(call mfem-test,$<,, Serial example,-e 1) |
| 150 |
ex15p-test-par: ex15p |
| 151 |
@$(call mfem-test,$<, $(RUN_MPI), Parallel example,-e 1) |
| 152 |
ex27-test-seq: ex27 |
| 153 |
@$(call mfem-test,$<,, Serial example,-dg) |
| 154 |
ex27p-test-par: ex27p |
| 155 |
@$(call mfem-test,$<, $(RUN_MPI), Parallel example,-dg) |
| 156 |
ex37-test-seq: ex37 |
| 157 |
@$(call mfem-test,$<,, Serial example,-mi 3) |
| 158 |
ex37p-test-par: ex37p |
| 159 |
@$(call mfem-test,$<, $(RUN_MPI), Parallel example,-mi 3) |
| 160 |
ex41-test-seq: ex41 |
| 161 |
@$(call mfem-test,$<,, Serial example,-tf 1.0) |
| 162 |
ex41p-test-par: ex41p |
| 163 |
@$(call mfem-test,$<, $(RUN_MPI), Parallel example,-tf 1.0) |
| 164 |
# Testing: optional tests |
| 165 |
ifeq ($(MFEM_USE_STRUMPACK),YES) |
| 166 |
ex11p-test-strumpack: ex11p |
| 167 |
@$(call mfem-test,$<, $(RUN_MPI), STRUMPACK example,--strumpack) |
| 168 |
test-par-YES: ex11p-test-strumpack |
| 169 |
endif |
| 170 |
ifeq ($(MFEM_USE_SUPERLU),YES) |
| 171 |
ex11p-test-superlu: ex11p |
| 172 |
@$(call mfem-test,$<, $(RUN_MPI), SuperLU_DIST example,--superlu) |
| 173 |
test-par-YES: ex11p-test-superlu |
| 174 |
endif |
| 175 |
ifeq ($(MFEM_USE_MKL_CPARDISO),YES) |
| 176 |
ex11p-test-cpardiso: ex11p |
| 177 |
@$(call mfem-test,$<, $(RUN_MPI), MKL_CPARDISO example,--cpardiso) |
| 178 |
test-par-YES: ex11p-test-cpardiso |
| 179 |
endif |
| 180 |
ifeq ($(MFEM_USE_CEED),YES) |
| 181 |
ex1p-test-ceed: ex1p |
| 182 |
@$(call mfem-test,$<, $(RUN_MPI),\ |
| 183 |
Parallel libCEED example,-d ceed-cpu -pa -a) |
| 184 |
test-par-YES: ex1p-test-ceed |
| 185 |
endif |
| 186 |
|
| 187 |
# Testing: "test" target and mfem-test* variables are defined in config/test.mk |
| 188 |
|
| 189 |
# Generate an error message if the MFEM library is not built and exit |
| 190 |
$(MFEM_LIB_FILE): |
| 191 |
$(error The MFEM library is not built) |
| 192 |
|
| 193 |
clean: clean-build clean-exec $(SUBDIRS_CLEAN) |
| 194 |
|
| 195 |
clean-build: |
| 196 |
rm -f *.o *~ $(SEQ_EXAMPLES) $(PAR_EXAMPLES) |
| 197 |
rm -rf *.dSYM *.TVD.*breakpoints |
| 198 |
|
| 199 |
clean-exec: |
| 200 |
@rm -f refined.mesh displaced.mesh mesh.* ex5.mesh ex6p-checkpoint.* |
| 201 |
@rm -rf Example5* Example9* Example15* Example16* Example23* ParaView |
| 202 |
@rm -f sphere_refined.* sol.* sol_u.* sol_p.* sol_r.* sol_i.* sol_z.* |
| 203 |
@rm -f order.* ex9.mesh ex9-mesh.* ex9-init.* ex9-final.* |
| 204 |
@rm -f deformed.* velocity.* elastic_energy.* mode_* mode_deriv_* flux.* |
| 205 |
@rm -f ex5-p-*.bp ex9-p-*.bp ex12-p-*.bp ex16-p-*.bp |
| 206 |
@rm -f ex16.mesh ex16-mesh.* ex16-init.* ex16-final.* |
| 207 |
@rm -f deformation.* pressure.* |
| 208 |
@rm -f ex20.dat ex20p_?????.dat gnuplot_ex20.inp gnuplot_ex20p.inp |
| 209 |
@rm -f ex21*.mesh ex21*.sol ex21p_*.* |
| 210 |
@rm -f ex23.mesh ex23-*.gf |
| 211 |
@rm -f ex25.mesh ex25-*.gf ex25p-*.* |
| 212 |
@rm -f euler-?-final.* euler-?-init.* euler-mesh-final.* euler-mesh.* |
| 213 |
@rm -rf ex28_* ex28p_* |
| 214 |
@rm -rf cond.* cond_mesh.* cond_j.* dsol.* port_mesh.* port_mode.* |