Debian Codegraph @

examples/sundials/makefile

raw
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/sundials/,)
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 = ex9 ex10 ex16
24 PAR_EXAMPLES = ex9p ex10p ex16p
25 SEQ_DEVICE_EXAMPLES = ex9
26 PAR_DEVICE_EXAMPLES = ex9p
27 ifeq ($(MFEM_USE_MPI),NO)
28 EXAMPLES = $(SEQ_EXAMPLES)
29 else
30 EXAMPLES = $(PAR_EXAMPLES) $(SEQ_EXAMPLES)
31 endif
32
33 .SUFFIXES:
34 .SUFFIXES: .o .cpp .mk
35 .PHONY: all clean clean-build clean-exec
36
37 # Remove built-in rule
38 %: %.cpp
39
40 # Replace the default implicit rule for *.cpp files
41 %: $(SRC)%.cpp $(MFEM_LIB_FILE) $(CONFIG_MK)
42 $(MFEM_CXX) $(MFEM_FLAGS) $< -o $@ $(MFEM_LIBS)
43
44 all: $(EXAMPLES)
45
46 ifeq ($(MFEM_USE_SUNDIALS),NO)
47 $(EXAMPLES):
48 $(error MFEM is not configured with SUNDIALS)
49 endif
50
51 MFEM_TESTS = EXAMPLES
52 include $(MFEM_TEST_MK)
53
54 # Testing: Parallel vs. serial runs
55 RUN_MPI = $(MFEM_MPIEXEC) $(MFEM_MPIEXEC_NP) $(MFEM_MPI_NP)
56 SERIAL_NAME := Serial SUNDIALS example
57 PARALLEL_NAME := Parallel SUNDIALS example
58 SERIAL_CUDA_NAME := Serial SUNDIALS CUDA example
59 PARALLEL_CUDA_NAME := Parallel SUNDIALS CUDA example
60 SERIAL_HIP_NAME := Serial SUNDIALS HIP example
61 PARALLEL_HIP_NAME := Parallel SUNDIALS HIP example
62 %-test-par: %
63 @$(call mfem-test,$<, $(RUN_MPI), $(PARALLEL_NAME))
64 %-test-seq: %
65 @$(call mfem-test,$<,, $(SERIAL_NAME))
66 %-test-par-cuda: %
67 @$(call mfem-test,$<, $(RUN_MPI), $(PARALLEL_CUDA_NAME),-d cuda)
68 %-test-seq-cuda: %
69 @$(call mfem-test,$<,, $(SERIAL_CUDA_NAME),-d cuda)
70 %-test-par-hip: %
71 @$(call mfem-test,$<, $(RUN_MPI), $(PARALLEL_HIP_NAME),-d hip)
72 %-test-seq-hip: %
73 @$(call mfem-test,$<,, $(SERIAL_HIP_NAME),-d hip)
74
75 # Testing: Specific execution options:
76 # Example 9: test CVODE with CV_ADAMS (non-stiff implicit) time stepping
77 EX9_COMMON_ARGS := -m ../../data/periodic-hexagon.mesh -p 0 -s 7
78 EX9_ARGS := $(EX9_COMMON_ARGS) -r 2 -dt 0.0018 -vs 25
79 EX9P_ARGS := $(EX9_COMMON_ARGS) -rp 1 -dt 0.0009 -vs 50
80 ex9-test-seq: ex9
81 @$(call mfem-test,$<,, $(SERIAL_NAME),$(EX9_ARGS))
82 ex9p-test-par: ex9p
83 @$(call mfem-test,$<, $(RUN_MPI), $(PARALLEL_NAME),$(EX9P_ARGS))
84 ex9-test-seq-cuda: ex9
85 @$(call mfem-test,$<,, $(SERIAL_CUDA_NAME),-d cuda $(EX9_ARGS))
86 ex9p-test-par-cuda: ex9p
87 @$(call mfem-test,$<, $(RUN_MPI), $(PARALLEL_CUDA_NAME),-d cuda \
88 $(EX9P_ARGS))
89 ex9-test-seq-hip: ex9
90 @$(call mfem-test,$<,, $(SERIAL_HIP_NAME),-d hip $(EX9_ARGS))
91 ex9p-test-par-hip: ex9p
92 @$(call mfem-test,$<, $(RUN_MPI), $(PARALLEL_HIP_NAME),-d hip \
93 $(EX9P_ARGS))
94 # Example 10: test CVODE with CV_BDF (stiff implicit) time stepping
95 EX10_COMMON_ARGS := -m ../../data/beam-quad.mesh -o 2 -s 5 -dt 0.15 -tf 6 -vs 10
96 EX10_ARGS := $(EX10_COMMON_ARGS) -r 2
97 EX10P_ARGS := $(EX10_COMMON_ARGS) -rp 1
98 ex10-test-seq: ex10
99 @$(call mfem-test,$<,, $(SERIAL_NAME),$(EX10_ARGS))
100 ex10p-test-par: ex10p
101 @$(call mfem-test,$<, $(RUN_MPI), $(PARALLEL_NAME),$(EX10P_ARGS))
102 # Example 16: test ARKODE with implicit time stepping using mass form
103 EX16_COMMON_ARGS := -s 15
104 ex16-test-seq: ex16
105 @$(call mfem-test,$<,, $(SERIAL_NAME),$(EX16_COMMON_ARGS))
106 ex16p-test-par: ex16p
107 @$(call mfem-test,$<, $(RUN_MPI), $(PARALLEL_NAME),$(EX16_COMMON_ARGS))
108
109 # Testing: "test" target and mfem-test* variables are defined in config/test.mk
110
111 # Generate an error message if the MFEM library is not built and exit
112 $(MFEM_LIB_FILE):
113 $(error The MFEM library is not built)
114
115 clean: clean-build clean-exec
116
117 clean-build:
118 rm -f *.o *~ $(SEQ_EXAMPLES) $(PAR_EXAMPLES)
119 rm -rf *.dSYM *.TVD.*breakpoints
120
121 clean-exec:
122 @rm -f ex9.mesh ex9-mesh.* ex9-init.* ex9-final.* Example9*
123 @rm -f deformed.* velocity.* elastic_energy.*
124 @rm -f ex16.mesh ex16-mesh.* ex16-init.* ex16-final.* Example16*