Skip to content

Commit

Permalink
fix: Use python for arithmetic in Makefile
Browse files Browse the repository at this point in the history
Shell doesn't understand scientific notation and POSIX arithmetic is
extremely brittle.
  • Loading branch information
adigitoleo committed Mar 26, 2024
1 parent 84c2ced commit fdebcf2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion examples/fluidity/corner2d/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ OUT_DIR := _out
# Initial geometry options (in units of metres), passed to `pydrex-mesh`.
WIDTH := 1e6
DEPTH := 2e5
HALF_WIDTH := $(shell python3 -c 'print($(WIDTH)/2)')
HALF_DEPTH := $(shell python3 -c 'print($(DEPTH)/2)')
RESOLUTION_HI := 1e2
RESOLUTION_LO := 1e4
# Initial conditions, used to parametrise velocity fields and spawn particles.
Expand Down Expand Up @@ -57,7 +59,7 @@ $(OUT_DIR)/$(SIM_NAME).msh:
@echo "********** Building the mesh file..."
./envcheck.sh -m
pydrex-mesh -k="rectangle" -a xy $(WIDTH),$(DEPTH) \
-c $$(($(WIDTH)/2)),$$((-$(DEPTH)/2)) -r NW:$(RESOLUTION_HI),SE:$(RESOLUTION_LO) $@
-c $(HALF_WIDTH),$(HALF_DEPTH) -r NW:$(RESOLUTION_HI),SE:$(RESOLUTION_LO) $@

.PHONY: clean
clean:
Expand Down

0 comments on commit fdebcf2

Please sign in to comment.