Skip to content

Commit

Permalink
Merge branch 'main' into subsheat3D/test_from_grids
Browse files Browse the repository at this point in the history
  • Loading branch information
adamchengtkc authored Dec 4, 2023
2 parents 63441d9 + 8612ac6 commit 99ba2e4
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 61 deletions.
25 changes: 1 addition & 24 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,8 @@
FROM dolfinx/dolfinx:v0.6.0


RUN DEBIAN_FRONTEND=noninteractive \
RUN DEBIAN_FRONTEND=noninteractive TZ=Europe/Oslo \
&& apt-get update \
&& apt-get install -y curl
# build-essential --no-install-recommends make \
# ca-certificates \
# git \
# libssl-dev \
# zlib1g-dev \
# libbz2-dev \
# libreadline-dev \
# libsqlite3-dev \
# wget \
# \
# llvm \
# libncurses5-dev \
# xz-utils \
# tk-dev \
# libxml2-dev \
# libxmlsec1-dev \
# libffi-dev \
# liblzma-dev

# RUN useradd -rm -d /home/vscode -s /bin/bash -g root -G sudo -u 1000 vscode -p ""
# USER vscode
# WORKDIR /home/vscode
# ENV HOME=/home/vscode
ENV PATH="/root/.local/bin:$HOME/.local/bin::$PATH"
RUN curl -sSL https://install.python-poetry.org | python3 -
1 change: 1 addition & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "warmth dolfinx poetry",
"build": {"dockerfile": "Dockerfile"},


// 👇 Features to add to the Dev Container. More info: https://containers.dev/implementors/features.
// "features": {},

Expand Down
15 changes: 11 additions & 4 deletions .github/workflows/python-test-3d.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
name: Tests3D

on:
workflow_dispatch:
workflow_call:
inputs:
event_type:
Expand All @@ -13,22 +12,30 @@ on:
action_type:
required: true
type: string
workflow_dispatch:
push:
branches: [main, dev]
paths:
- 'warmth/warmth3d/**'
pull_request:
branches: [main, dev]
paths:
- 'warmth/warmth3d/**'
jobs:
build:

environment: test3d
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Run
uses: tj-actions/docker-run@v2

with:
image: ghcr.io/equinor/warmth:latest
name: dolfinx
options: -v ${{ github.workspace }}:/home/warmth
args: |
bash -c "cd /home/warmth" && pip install . pytest==7.4.2 pytest-cov==4.1.0 && pytest --cov-report=term-missing --cov=warmth tests | tee pytest-coverage.txt

- name: Comment coverage
if: ${{ github.event_name == 'pull_request' && github.event.action == 'opened' }}
Expand Down
16 changes: 0 additions & 16 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,3 @@ jobs:
with:
pytest-coverage: pytest-coverage.txt


test3d:
runs-on: ubuntu-latest
steps:
- name: check_3d_modified
uses: dorny/paths-filter@v2
id: filter3d
with:
filters: |
mesh3d:
- 'warmth/3d/**'
- uses: equinor/warmth/.github/workflows/python-test-3d.yml@main
if: ${{ steps.filter3d.outputs.mesh3d }} == 'true'
with:
event_type: ${{ github.event_name}}
action_type: ${{ github.event.action}}
2 changes: 2 additions & 0 deletions .github/workflows/snyk.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Snyk scan
on:
push:
branches: [main, dev]
workflow_call:
jobs:
security:
Expand Down
28 changes: 28 additions & 0 deletions docs/3D.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Setup
We use [dolfinx](https://github.com/FEniCS/dolfinx) for full 3D heat transfer model. Compiling and installing dolfinx can be challenging. We suggests using a Docker images.
```bash
docker run -ti -v <YOUR_WORK_DIR>:/ dolfinx:dolfinx:v0.7.0
# Then inside the interactive shell
pip install warmth
```
3D part of the library has only been tested with Python 3.10.x and Dolfinx v0.7.x

# Workflow
[Notebook example](https://github.com/equinor/warmth/tree/main/docs/notebooks/3D_simulation.ipynb)

Step 1 - Extract 1D models from maps

Step 2 - Find beta factor and curstal thickness through time using 1D simulation

Step 3 - Build 3D mesh and run simulation


### 3D heat equation simulation using dolfinx
The 3D simulation performs a series of heat equation solves, regularly updating the mesh positions from the 1D nodes. The equations are solved using the PETSc solver from the dolfinx package (part of the FeNiCs project). The compute mesh is built by defining hexahedra for every rectangle of 1D nodes and for every layer (i.e. each sediment, the crust, the lithosphere, and the aesthenosphere), which are then subdivided into tetrahedra.

The dolfinx model building and solving is managed by the class [UniformNodeGridFixedSizeMeshModel](warmth3D/fixed_mesh_model.py). The use of this class is demonstrated in [warmth3D_mapA_example.py](tests/warmth3D_mapA_example.py). Note that the NodeGrid class definition in this script should match the definition used in [parallel-1Dsed.py](warmth3D/parallel-1Dsed.py) to compute the 1D solutions. This script writes the results (mesh positions and function values) at every 1M years in xdmf format for visualization in ParaView.

### RESQML output
The test script [warmth3D_mapA_example.py](tests/warmth3D_mapA_example.py) further demonstrates writing the unstructured grid (with properties) in RESQML format, as a pair of .epc and .h5 files. The RESQML I/O functions are in a separate file, [resqpy_helpers.py](warmth3D/resqpy_helpers.py), and require a modified version of the resqpy library. To visualise RESQML data in ParaView, a 3rd-party plug-in can be installed, see [fespp](https://github.com/F2I-Consulting/fespp).


1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Welcome to warmth's documentation!

theory
example
3D
apireference


Expand Down
17 changes: 0 additions & 17 deletions docs/theory.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,2 @@
# Background theory


3D simulations in warmth are under active development. Currently, yhey are based on a uniform reactangular grid of 1D nodes (defined in a NodeGrid data structure). The sediment inputs, horizons are present day, are provided as .gri files, which are read into a SedimentStack class.

### Pre-requisite: grid of 1D node simulation
The complete 1D warmth simulation is run for some of the 1D nodes. For other 1D nodes the subsidence, beta factor, and crustal thickness are interpolated. The 1D simulations can be run using the script [parallel-1Dsed.py](warmth3D/parallel-1Dsed.py). Results for each node are pickled to a separate file (this is to be improved!).

### 3D heat equation simulation using dolfinx
The 3D simulation performs a series of heat equation solves, regularly updating the mesh positions from the 1D nodes. The equations are solved using the PETSc solver from the dolfinx package (part of the FeNiCs project). The compute mesh is built by defining hexahedra for every rectangle of 1D nodes and for every layer (i.e. each sediment, the crust, the lithosphere, and the aesthenosphere), which are then subdivided into tetrahedra.

The dolfinx model building and solving is managed by the class [UniformNodeGridFixedSizeMeshModel](warmth3D/fixed_mesh_model.py). The use of this class is demonstrated in [warmth3D_mapA_example.py](tests/warmth3D_mapA_example.py). Note that the NodeGrid class definition in this script should match the definition used in [parallel-1Dsed.py](warmth3D/parallel-1Dsed.py) to compute the 1D solutions. This script writes the results (mesh positions and function values) at every 1M years in xdmf format for visualization in ParaView.

### RESQML output
The test script [warmth3D_mapA_example.py](tests/warmth3D_mapA_example.py) further demonstrates writing the unstructured grid (with properties) in RESQML format, as a pair of .epc and .h5 files. The RESQML I/O functions are in a separate file, [resqpy_helpers.py](warmth3D/resqpy_helpers.py), and require a modified version of the resqpy library. To visualise RESQML data in ParaView, a 3rd-party plug-in can be installed, see [fespp](https://github.com/F2I-Consulting/fespp).

### 3D dependencies
The dolfinx package is Linux-only(?) and has to be compiled from source or installed using apt-get. The resqpy dependency can be installed with pip, but, for now, some writing of properties on unstructured grids requires a change in resqpy that is not yet merged. The other dependencies xtgeo and meshio can be installed using pip (requirements file is to be added).

0 comments on commit 99ba2e4

Please sign in to comment.