xref: /libCEED/examples/solids/Makefile (revision d4cc18453651bd0f94c1a2e078b2646a92dafdcc)
1*9ba83ac0SJeremy L Thompson# Copyright (c) 2017-2026, Lawrence Livermore National Security, LLC and other CEED contributors.
25aed82e4SJeremy L Thompson# All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
3ccaff030SJeremy L Thompson#
45aed82e4SJeremy L Thompson# SPDX-License-Identifier: BSD-2-Clause
5ccaff030SJeremy L Thompson#
65aed82e4SJeremy L Thompson# This file is part of CEED:  http://github.com/ceed
7ccaff030SJeremy L Thompson
8777ff853SJeremy L ThompsonCOMMON ?= ../../common.mk
9777ff853SJeremy L Thompson-include $(COMMON)
10777ff853SJeremy L Thompson
11ccaff030SJeremy L Thompson# Note: PETSC_ARCH can be undefined or empty for installations which do not use
12ccaff030SJeremy L Thompson#       PETSC_ARCH - for example when using PETSc installed through Spack.
13ccaff030SJeremy L ThompsonPETSc.pc := $(PETSC_DIR)/$(PETSC_ARCH)/lib/pkgconfig/PETSc.pc
14ccaff030SJeremy L ThompsonCEED_DIR ?= ../..
15ccaff030SJeremy L Thompsonceed.pc := $(CEED_DIR)/lib/pkgconfig/ceed.pc
16ccaff030SJeremy L Thompson
17ccaff030SJeremy L ThompsonCC = $(call pkgconf, --variable=ccompiler $(PETSc.pc) $(ceed.pc))
18d4f9124cSJed BrownCFLAGS = -std=c11 \
19ccaff030SJeremy L Thompson  $(call pkgconf, --variable=cflags_extra $(PETSc.pc)) \
20ccaff030SJeremy L Thompson  $(call pkgconf, --cflags-only-other $(PETSc.pc)) \
2128b8c626SJed Brown  $(OPT)
2228b8c626SJed BrownCPPFLAGS = $(call pkgconf, --cflags-only-I $(PETSc.pc) $(ceed.pc)) \
2328b8c626SJed Brown  $(call pkgconf, --variable=cflags_dep $(PETSc.pc))
24ccaff030SJeremy L ThompsonLDFLAGS = $(call pkgconf, --libs-only-L --libs-only-other $(PETSc.pc) $(ceed.pc))
25ccaff030SJeremy L ThompsonLDFLAGS += $(patsubst -L%, $(call pkgconf, --variable=ldflag_rpath $(PETSc.pc))%, $(call pkgconf, --libs-only-L $(PETSc.pc) $(ceed.pc)))
26ccaff030SJeremy L ThompsonLDLIBS = $(call pkgconf, --libs-only-l $(PETSc.pc) $(ceed.pc)) -lm
27ccaff030SJeremy L Thompson
28ccaff030SJeremy L ThompsonOBJDIR := build
29ccaff030SJeremy L ThompsonSRCDIR := src
305754ecacSJeremy L ThompsonPROBLEMDIR := problems
31ccaff030SJeremy L Thompson
325754ecacSJeremy L Thompsonsrc.c := elasticity.c $(sort $(wildcard $(PROBLEMDIR)/*.c)) $(sort $(wildcard $(SRCDIR)/*.c))
33ccaff030SJeremy L Thompsonsrc.o = $(src.c:%.c=$(OBJDIR)/%.o)
34ccaff030SJeremy L Thompson
35ccaff030SJeremy L Thompsonall: elasticity
36ccaff030SJeremy L Thompson
37ccaff030SJeremy L Thompsonelasticity: $(src.o) | $(PETSc.pc) $(ceed.pc)
3828b8c626SJed Brown	$(call quiet,LINK.o) $(CEED_LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@
39ccaff030SJeremy L Thompson
40ccaff030SJeremy L Thompson.SECONDEXPANSION: # to expand $$(@D)/.DIR
41ccaff030SJeremy L Thompson%/.DIR :
42ccaff030SJeremy L Thompson	@mkdir -p $(@D)
43ccaff030SJeremy L Thompson	@touch $@
44ccaff030SJeremy L Thompson
45777ff853SJeremy L Thompson# Quiet, color output
46777ff853SJeremy L Thompsonquiet ?= $($(1))
47ccaff030SJeremy L Thompson
48ccaff030SJeremy L Thompson$(OBJDIR)/%.o : %.c | $$(@D)/.DIR
49ccaff030SJeremy L Thompson	$(call quiet,CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(abspath $<)
50ccaff030SJeremy L Thompson
51ccaff030SJeremy L Thompson# Rules for building the examples
52ccaff030SJeremy L Thompson#%: %.c
53ccaff030SJeremy L Thompson
54ccaff030SJeremy L Thompsonprint: $(PETSc.pc) $(ceed.pc)
55ccaff030SJeremy L Thompson	$(info CC      : $(CC))
56ccaff030SJeremy L Thompson	$(info CFLAGS  : $(CFLAGS))
57ccaff030SJeremy L Thompson	$(info CPPFLAGS: $(CPPFLAGS))
58ccaff030SJeremy L Thompson	$(info LDFLAGS : $(LDFLAGS))
59ccaff030SJeremy L Thompson	$(info LDLIBS  : $(LDLIBS))
60ccaff030SJeremy L Thompson	@true
61ccaff030SJeremy L Thompson
62ccaff030SJeremy L Thompsonclean:
63788f67f3Sjeremylt	$(RM) -r $(OBJDIR) elasticity *.vtu
64ccaff030SJeremy L Thompson
65ccaff030SJeremy L Thompson$(PETSc.pc):
66ccaff030SJeremy L Thompson	$(if $(wildcard $@),,$(error \
67ccaff030SJeremy L Thompson	  PETSc config not found at $@. Please set PETSC_DIR and PETSC_ARCH))
68ccaff030SJeremy L Thompson
69ccaff030SJeremy L Thompson.PHONY: all print clean
70ccaff030SJeremy L Thompson
71ccaff030SJeremy L Thompsonpkgconf = $(shell pkg-config $1 | sed -e 's/^"//g' -e 's/"$$//g')
72ccaff030SJeremy L Thompson
738355605fSKaren (Ren) Stengel# E = 2 * mu + (1 + nu)
74ffa5d67cSJeremy L Thompsontests-output/NH-strain.csv: args = -problem FSInitial-NH1 -E 2.8 -nu 0.4
75ffa5d67cSJeremy L Thompsontests-output/MR-strain.csv: args = -problem FSInitial-MR1 -mu_1 1 -mu_2 0.0 -nu .4
76ffa5d67cSJeremy L Thompsontests-output/MR-strain1.csv: args = -problem FSInitial-MR1 -mu_1 .5 -mu_2 0.5 -nu .4
778355605fSKaren (Ren) Stengel
78ffa5d67cSJeremy L Thompsontests-output/%.csv: elasticity
798355605fSKaren (Ren) Stengel	./$<  $(args) -degree 2 -dm_plex_box_faces 3,3,3 -num_steps 15 -bc_clamp 6 -bc_traction 5 -bc_traction_5 0,0,-1 -snes_converged_reason -snes_linesearch_atol 1e-30 -strain_energy_monitor $@
808355605fSKaren (Ren) Stengel
81ccaff030SJeremy L Thompson-include $(src.o:%.o=%.d)
82