Skip to content

Commit

Permalink
feat: Add 2D advection Fluidity example
Browse files Browse the repository at this point in the history
And modify simple shear `dudz_pathline` test to use the same parameters.
  • Loading branch information
adigitoleo committed Mar 25, 2024
1 parent 782cf0b commit d92aa82
Show file tree
Hide file tree
Showing 8 changed files with 646 additions and 1 deletion.
18 changes: 18 additions & 0 deletions examples/fluidity/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Fluidity examples

Most parameters can be set in the relevant makefiles, except for the number of
grains, which is defined by `(N - 22) / 10` where `N` is the dimension of the
`CPO_` array in the Fluidity `.flml` file. Timestepping options are also set
in the `.flml` file.

To run the example contained in `example_directory`,
ensure that the `envcheck.sh` script is available, and simply run
`make -f example_directory/Makefile`.
To clean previous simulation output use the
`make -f example_directory/Makefile clean` target.

This table lists the corresponding PyDRex tests:

| Fluidity example | PyDRex test |
| --- | --- |
| `advection2d` | `test_simple_shear_2d.TestOlivineA.test_dudz_pathline` |
63 changes: 63 additions & 0 deletions examples/fluidity/advection2d/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Make options to keep what's left of our sanity.
.SHELLFLAGS += -u
.ONESHELL:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
# Path options, SIM_NAME is the name of the .msh and .py files.
SIM_NAME := advection2d
SRC_DIR := advection2d
OUT_DIR := _out
# Initial geometry options (in units of metres), passed to `pydrex-mesh`.
WIDTH := 4e5
DEPTH := 4e5
RESOLUTION := 1e3
# Initial conditions, used to parametrise velocity fields and spawn particles.
# INIT_HORIZ can be a space-delimited array of values (for multiple particles).
STRAIN_RATE := 1e-15
INIT_HORIZ := -1e5
INIT_VERT := 1e5
# Recrystallisation parameters.
STRESS_EXPONENT := 1.5
DEFORMATION_EXPONENT := 3.5
GBM_MOBILITY := 10
GBS_THRESHOLD := 0.3
NUCLEATION_EFFICIENCY := 5

$(OUT_DIR)/fluidity.log-0: $(OUT_DIR)/$(SIM_NAME).flml $(OUT_DIR)/$(SIM_NAME).msh $(OUT_DIR)/$(SIM_NAME).py $(OUT_DIR)/$(SIM_NAME).ini
@echo "********** Running fluidity with verbose logging enabled..."
./envcheck.sh -f
cd $(OUT_DIR) && fluidity -v2 -l $(SIM_NAME).flml

$(OUT_DIR)/$(SIM_NAME).ini: $(OUT_DIR)/$(SIM_NAME).py
@echo "********** Setting up initial conditions and recryst. parameters..."
echo "[initial conditions]" > $@
echo "WIDTH = $(WIDTH)" >> $@
echo "DEPTH = $(DEPTH)" >> $@
echo "RESOLUTION = $(RESOLUTION)" >> $@
echo "STRAIN_RATE = $(STRAIN_RATE)" >> $@
echo "INIT_HORIZ = $(INIT_HORIZ)" >> $@
echo "INIT_VERT = $(INIT_VERT)" >> $@
echo "STRESS_EXPONENT = $(STRESS_EXPONENT)" >> $@
echo "DEFORMATION_EXPONENT = $(DEFORMATION_EXPONENT)" >> $@
echo "GBM_MOBILITY = $(GBM_MOBILITY)" >> $@
echo "GBS_THRESHOLD = $(GBS_THRESHOLD)" >> $@
echo "NUCLEATION_EFFICIENCY = $(NUCLEATION_EFFICIENCY)" >> $@

$(OUT_DIR)/$(SIM_NAME).py: $(SRC_DIR)/$(SIM_NAME).py
@echo "********** Copying python velocity callables..."
mkdir -p $(@D)
cp -f $< $@

$(OUT_DIR)/$(SIM_NAME).flml: $(SRC_DIR)/$(SIM_NAME).flml
@echo "********** Copying serial flml file..."
mkdir -p $(@D)
cp -f $< $@

$(OUT_DIR)/$(SIM_NAME).msh:
@echo "********** Building the mesh file..."
./envcheck.sh -m
pydrex-mesh -k="rectangle" -a xy $(WIDTH),$(DEPTH) $(RESOLUTION) $@

.PHONY: clean
clean:
rm -rf $(OUT_DIR)
Loading

0 comments on commit d92aa82

Please sign in to comment.