xref: /libCEED/examples/solids/Makefile (revision 5435e9103596fe211e572db2eb3560365642b4c9)
1# Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC.
2# Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707.
3# All Rights reserved. See files LICENSE and NOTICE for details.
4#
5# This file is part of CEED, a collection of benchmarks, miniapps, software
6# libraries and APIs for efficient high-order finite element and spectral
7# element discretizations for exascale applications. For more information and
8# source code availability see http://github.com/ceed.
9#
10# The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
11# a collaborative effort of two U.S. Department of Energy organizations (Office
12# of Science and the National Nuclear Security Administration) responsible for
13# the planning and preparation of a capable exascale ecosystem, including
14# software, applications, hardware, advanced system engineering and early
15# testbed platforms, in support of the nation's exascale computing imperative.
16
17COMMON ?= ../../common.mk
18-include $(COMMON)
19
20# Note: PETSC_ARCH can be undefined or empty for installations which do not use
21#       PETSC_ARCH - for example when using PETSc installed through Spack.
22PETSc.pc := $(PETSC_DIR)/$(PETSC_ARCH)/lib/pkgconfig/PETSc.pc
23CEED_DIR ?= ../..
24ceed.pc := $(CEED_DIR)/lib/pkgconfig/ceed.pc
25
26CC = $(call pkgconf, --variable=ccompiler $(PETSc.pc) $(ceed.pc))
27CFLAGS = -std=c99 \
28  $(call pkgconf, --variable=cflags_extra $(PETSc.pc)) \
29  $(call pkgconf, --cflags-only-other $(PETSc.pc)) \
30  $(OPT)
31CPPFLAGS = $(call pkgconf, --cflags-only-I $(PETSc.pc) $(ceed.pc)) \
32  $(call pkgconf, --variable=cflags_dep $(PETSc.pc))
33LDFLAGS = $(call pkgconf, --libs-only-L --libs-only-other $(PETSc.pc) $(ceed.pc))
34LDFLAGS += $(patsubst -L%, $(call pkgconf, --variable=ldflag_rpath $(PETSc.pc))%, $(call pkgconf, --libs-only-L $(PETSc.pc) $(ceed.pc)))
35LDLIBS = $(call pkgconf, --libs-only-l $(PETSc.pc) $(ceed.pc)) -lm
36
37OBJDIR := build
38SRCDIR := src
39PROBLEMDIR := problems
40
41src.c := elasticity.c $(sort $(wildcard $(PROBLEMDIR)/*.c)) $(sort $(wildcard $(SRCDIR)/*.c))
42src.o = $(src.c:%.c=$(OBJDIR)/%.o)
43
44all: elasticity
45
46elasticity: $(src.o) | $(PETSc.pc) $(ceed.pc)
47	$(call quiet,LINK.o) $(CEED_LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@
48
49.SECONDEXPANSION: # to expand $$(@D)/.DIR
50%/.DIR :
51	@mkdir -p $(@D)
52	@touch $@
53
54# Quiet, color output
55quiet ?= $($(1))
56
57$(OBJDIR)/%.o : %.c | $$(@D)/.DIR
58	$(call quiet,CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(abspath $<)
59
60# Rules for building the examples
61#%: %.c
62
63print: $(PETSc.pc) $(ceed.pc)
64	$(info CC      : $(CC))
65	$(info CFLAGS  : $(CFLAGS))
66	$(info CPPFLAGS: $(CPPFLAGS))
67	$(info LDFLAGS : $(LDFLAGS))
68	$(info LDLIBS  : $(LDLIBS))
69	@true
70
71clean:
72	$(RM) -r $(OBJDIR) elasticity *.vtu
73
74$(PETSc.pc):
75	$(if $(wildcard $@),,$(error \
76	  PETSc config not found at $@. Please set PETSC_DIR and PETSC_ARCH))
77
78.PHONY: all print clean
79
80pkgconf = $(shell pkg-config $1 | sed -e 's/^"//g' -e 's/"$$//g')
81
82# E = 2 * mu + (1 + nu)
83tests-output/NH-strain.csv: args = -problem FSInitial-NH1 -E 2.8 -nu 0.4
84tests-output/MR-strain.csv: args = -problem FSInitial-MR1 -mu_1 1 -mu_2 0.0 -nu .4
85tests-output/MR-strain1.csv: args = -problem FSInitial-MR1 -mu_1 .5 -mu_2 0.5 -nu .4
86
87tests-output/%.csv: elasticity
88	./$<  $(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 $@
89
90-include $(src.o:%.o=%.d)
91