Debian Codegraph @

miniapps/meshing/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)/miniapps/meshing/,)
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_MINIAPPS = mobius-strip klein-bottle toroid trimmer twist mesh-explorer\
24 shaper extruder mesh-optimizer minimal-surface polar-nc reflector\
25 ref321 mesh-quality hpref
26 PAR_MINIAPPS = pmesh-optimizer pminimal-surface pmesh-fitting fit-node-position\
27 phpref mesh-bounding-boxes
28 ifeq ($(MFEM_USE_MPI),NO)
29 MINIAPPS = $(SEQ_MINIAPPS)
30 else
31 MINIAPPS = $(PAR_MINIAPPS) $(SEQ_MINIAPPS)
32 endif
33
34 COMMON_LIB = -L$(MFEM_BUILD_DIR)/miniapps/common -lmfem-common
35
36 # If MFEM_SHARED is set, add the ../common rpath
37 COMMON_LIB += $(if $(MFEM_SHARED:YES=),,\
38 $(MFEM_XLINKER)-rpath,$(abspath $(MFEM_BUILD_DIR)/miniapps/common))
39
40 .SUFFIXES:
41 .SUFFIXES: .o .cpp .mk
42 .PHONY: all lib-common clean clean-build clean-exec
43
44 # Remove built-in rule
45 %: %.cpp
46
47 # Replace the default implicit rule for *.cpp files
48 %: $(SRC)%.cpp $(MFEM_LIB_FILE) $(CONFIG_MK) | lib-common
49 $(MFEM_CXX) $(MFEM_FLAGS) $< -o $@ $(COMMON_LIB) $(MFEM_LIBS)
50
51 all: $(MINIAPPS)
52
53 # Rule for building lib-common
54 lib-common:
55 $(MAKE) -C $(MFEM_BUILD_DIR)/miniapps/common
56
57 # Rules to copy the *.mesh files - needed for running the sample runs when
58 # building out-of-source:
59 ifneq ($(SRC),)
60 MESH_FILES = amr-quad-q2.mesh blade.mesh cube.mesh cube-tet.mesh icf.mesh\
61 jagged.mesh square01.mesh square01-tri.mesh stretched2D.mesh
62 $(MESH_FILES): %: $(SRC)%
63 ln -sf $(<) .
64 mesh-optimizer pmesh-optimizer pmesh-fitting fit-node-position: | $(MESH_FILES)
65 .PHONY: copy-data
66 copy-data: | $(MESH_FILES)
67 endif
68
69 MFEM_TESTS = MINIAPPS
70 include $(MFEM_TEST_MK)
71
72 # Testing: Parallel vs. serial runs
73 RUN_MPI = $(MFEM_MPIEXEC) $(MFEM_MPIEXEC_NP) $(MFEM_MPI_NP)
74 %-test-par: %
75 @$(call mfem-test-file,$<, $(RUN_MPI), Meshing miniapp,$(<).mesh)
76 %-test-seq: %
77 @$(call mfem-test-file,$<,, Meshing miniapp,$(<).mesh)
78 toroid-test-seq: toroid
79 @$(call mfem-test-file,$<,, Meshing miniapp,$(<)-wedge-o3-s0.mesh)
80 twist-test-seq: twist
81 @$(call mfem-test-file,$<,, Meshing miniapp,$(<)-hex-o3-s2-p.mesh)
82 mesh-optimizer-test-seq: mesh-optimizer
83 @$(call mfem-test,$<,, Meshing miniapp)
84 pmesh-optimizer-test-par: pmesh-optimizer
85 @$(call mfem-test,$<, $(RUN_MPI), Parallel meshing miniapp)
86 mesh-quality-test-seq: mesh-quality
87 @$(call mfem-test,$<,, Mesh quality miniapp)
88 pmesh-fitting-test-par: pmesh-fitting
89 @$(call mfem-test,$<, $(RUN_MPI), Parallel mesh fitting miniapp)
90 fit-node-position-test-par: fit-node-position
91 @$(call mfem-test,$<, $(RUN_MPI), Parallel position fitting miniapp)
92 minimal-surface-test-seq: minimal-surface
93 @$(call mfem-test,$<,, Meshing miniapp)
94 pminimal-surface-test-par: pminimal-surface
95 @$(call mfem-test,$<, $(RUN_MPI), Parallel meshing miniapp)
96 reflector-test-seq: reflector
97 @$(call mfem-test-file,$<,, Meshing miniapp,reflected.mesh)
98 hpref-test-seq: hpref
99 @$(call mfem-test,$<,, Serial hp-refinement)
100 phpref-test-par: phpref
101 @$(call mfem-test,$<, $(RUN_MPI), Parallel hp-refinement)
102 mesh-bounding-boxes-test-par: mesh-bounding-boxes
103 @$(call mfem-test,$<, $(RUN_MPI), Parallel bounding boxes)
104 ref321-test-seq: ref321
105 @$(call mfem-test-file,$<,, Meshing miniapp,ref321.mesh)
106
107 # Testing: Specific execution options
108 mesh-explorer-test-seq:
109 @true
110 shaper-test-seq:
111 @true
112
113 # Testing: "test" target and mfem-test* variables are defined in config/test.mk
114
115 # Generate an error message if the MFEM library is not built and exit
116 $(MFEM_LIB_FILE):
117 $(error The MFEM library is not built)
118
119 clean: clean-build clean-exec
120
121 clean-build:
122 rm -f *.o *~ $(SEQ_MINIAPPS) $(PAR_MINIAPPS)
123 rm -rf *.dSYM *.TVD.*breakpoints
124
125 clean-exec:
126 @rm -f mobius-strip.mesh klein-bottle.mesh mesh-explorer.mesh*
127 @rm -f toroid-*.mesh twist-*.mesh trimmer.mesh reflected.mesh
128 @rm -f partitioning.txt shaper.mesh extruder.mesh ref321.mesh sol.gf
129 @rm -f optimized* perturbed* polar-nc.mesh
130 @rm -rf mesh-explorer-{visit,paraview}*
131 @rm -f mesh.* order.* sol.* refined.mesh
132 @rm -rf jacobian-determinant-bounds* bounding-box*