Wed, 22 Apr 2026 22:32:00 -0500
Dolfin update, fixes, additional experiment, build instructions.
|
1
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
1 | |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
2 | # Codes for “Leak localisation with a measure source convection--diffusion model” |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
3 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
4 | These are the codes for the numerical demonstrations of the manuscript |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
5 | _“Leak localisation with a measure source convection--diffusion model”_ |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
6 | ([arXiv:????.????](https://arxiv.org/abs/????.????)) by Thi Tam Dang and Tuomo Valkonen. |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
7 | It should be relatively easy to to use this package and the algorithms it provides |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
8 | for other PDE-based point source localisation problems. |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
9 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
10 | ## Building |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
11 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
12 | Sorry, although the core of program is written in Rust with a modern dependency management and build process, we also have legacy C++ and Python dependencies, i.e., the Fenicsx PDE library. Therefore, the build process is difficult. |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
13 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
14 | (We admit it, we made a mistake by going with the crowd and using Fenicsx. In the end it would have been less effort to write low-level PDE code in Rust.) |
|
1
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
15 | |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
16 | ### Phase 1: Python and Fenics |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
17 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
18 | #### Option 1.A that avoids Conda hell, but is more work (macOS and Linux) |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
19 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
20 | ##### Phase 1.A.1: C++ dependencies of Fenics |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
21 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
22 | First install C++ dependencies using [Homebrew](https://brew.sh). |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
23 | Even on Linux, **use Homebrew**, or install from official sources; distribution packages are usually obsolete and buggy, often non-standard, and will cause problems (see above). |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
24 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
25 | brew install openmpi boost pugixml fmt spdlog hdf5-mpi cmake kahip slepc petsc gsl |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
26 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
27 | (Fenics recommends ParMETIS instead of Kahip, but only the latter is available from Homebrew at the time of writing this.) |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
28 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
29 | There's no guarantee that this will install compatible versions of these packages. Homebrew, while better than most Linux distributions, is also obsolete in its philosophy: it does not allow easily installing specific versions of packages. Versions known to work are: |
|
1
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
30 | |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
31 | package | version |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
32 | ---------|-------- |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
33 | boost | 1.90.0 |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
34 | cmake | 4.2.1 |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
35 | fmt | 12.1.0 |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
36 | hdf5-mpi | 1.14.6 |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
37 | kahip | 3.22 |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
38 | petsc | 3.24.3 |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
39 | pugixml | 1.15 |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
40 | slepc | 3.24.2 |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
41 | spdlog | 1.17.0 |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
42 | gsl | 2.8 |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
43 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
44 | You can get the list of installed versions with: |
|
1
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
45 | |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
46 | brew list --versions openmpi boost pugixml fmt spdlog hdf5-mpi cmake kahip slepc petsc gsl |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
47 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
48 | ##### Phase 1.A.2: Python dependencies of Fenics |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
49 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
50 | In this source directory, create and activate a virtual environment for Python, and |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
51 | install Python packages: |
|
1
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
52 | |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
53 | python3 -m venv .venv |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
54 | source .venv/bin/activate |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
55 | PETSC_DIR=/opt/homebrew/ SLEPC_DIR=/opt/homebrew/ pip install -r requirements.lock |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
56 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
57 | To not have to activate the virtual environment manually every time, and to not mess up your global settings, it is recommended to install [direnv](https://direnv.net) and put the following in `.envrc` in this directory: |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
58 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
59 | source .venv/bin/activate |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
60 | export PYTHONPATH=$(echo .venv/lib/python*/site-packages) |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
61 | export PYO3_PYTHON="$(which python)" |
|
1
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
62 | |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
63 | (The last two lines are required later.) |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
64 | This template is also available in `misc/_envrc`. |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
65 | For changes `.envrc` to take effect, you should use |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
66 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
67 | direnv allow |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
68 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
69 | ##### Phase 1.A.3: Fenicx-basix |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
70 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
71 | Install basix from <https://github.com/FEniCS/basix/releases/tag/v0.10.0.post0> according to |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
72 | instructions. First do the C++ bit: |
|
1
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
73 | |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
74 | tar xzf basix-0.10.0.post0.tar.gz |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
75 | cd basix-0.10.0.post0/cpp |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
76 | mkdir build |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
77 | cd build |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
78 | cmake .. |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
79 | make |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
80 | make install |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
81 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
82 | Then the Python bit. This has to be done with the `venv` created above, active. |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
83 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
84 | cd ../../python |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
85 | pip install . |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
86 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
87 | ##### Phase 1.A.4: Fenicx-dolfinx |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
88 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
89 | Install dolfinx from <https://github.com/FEniCS/dolfinx/releases/tag/v0.10.0.post5> according to |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
90 | instructions. First do the C++ bit: |
|
1
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
91 | |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
92 | tar xzf dolfinx-0.10.0.post5.tar.gz |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
93 | cd dolfinx-0.10.0.post5/cpp |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
94 | mkdir build |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
95 | cd build |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
96 | cmake .. |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
97 | make |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
98 | make install |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
99 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
100 | Skip the `source /usr/local/lib/dolfinx/dolfinx.conf` recommended at the end |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
101 | of the compilation. It will likely break things. |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
102 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
103 | Then the Python bit. This has to be done with the virtual environment created above, active. |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
104 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
105 | cd ../../python |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
106 | python -m scikit_build_core.build requires | python -c "import sys, json; print(' '.join(json.load(sys.stdin)))" | xargs pip install |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
107 | pip install --check-build-dependencies --no-build-isolation . |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
108 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
109 | If you didn't already do these steps with `direnv` above, you should: |
|
1
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
110 | |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
111 | export PYTHONPATH=$(echo .venv/lib/python*/site-packages) |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
112 | export PYO3_PYTHON="$(which python)" |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
113 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
114 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
115 | #### Option 1.B: Conda |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
116 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
117 | You can *try to* install Fenicsx in Conda according to instructions on the Fenics website. Additionally you need to install `scipy`: |
|
1
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
118 | |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
119 | conda create -n fenicsx-env |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
120 | conda activate fenicsx-env |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
121 | conda install -c conda-forge fenics-dolfinx=0.10.0 scipy=1.17.1 mpich |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
122 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
123 | This is, however, unlikely to not work, as Conda, despite its sandboxing separation attempts, conflicts with system packages, or Conda packages have weird ideas. You're likely to run into runtime problems with the FFCX form compiler (*bad* *bad* *bad* idea, running a C compiler runtime) failing due to something, somewhere, in the extremely fragile Conda setup, trying to load system libraries wrongly, etc. |
|
1
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
124 | |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
125 | #### Option 1.C: Debian/Ubuntu |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
126 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
127 | You may be able to use the system package manager, but beware of obsolete and modified versions. As of 2026-03-23, the packages available in Debian/Ubuntu cause massive memory leaks and eventual system crash. |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
128 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
129 | ### Phase 2: Rust |
|
1
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
130 | |
|
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
131 | You will only need to install the “nightly” Rust compiler and the |
|
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
132 | [GNU Scientific Library] manually. At the time of writing this README, |
|
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
133 | [alg_tools] also needs to be downloaded separately. |
|
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
134 | |
|
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
135 | 1. Install the [Rust] infrastructure (including Cargo) with [rustup]. |
|
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
136 | 2. Install a “nightly” release of the Rust compiler. With rustup, installed in |
|
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
137 | the previous step, this can be done with |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
138 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
139 | rustup toolchain install nightly |
|
1
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
140 | |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
141 | 3. Download [alg_tools], [pointsource_algs], and [measures] and unpack them under |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
142 | the same directory as this package. |
|
1
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
143 | |
|
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
144 | [rustup]: https://rustup.rs |
|
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
145 | [alg_tools]: https://tuomov.iki.fi/software/alg_tools/ |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
146 | [pointsource_algs]: https://tuomov.iki.fi/software/pointsource_algs/ |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
147 | [measures]: https://tuomov.iki.fi/repos/measures/ |
|
1
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
148 | [Rust]: https://www.rust-lang.org/ |
|
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
149 | [GNU Scientific Library]: https://www.gnu.org/software/gsl/ |
|
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
150 | [rust-GSL]: https://docs.rs/GSL/6.0.0/rgsl/ |
|
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
151 | [Homebrew]: https://brew.sh |
|
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
152 | [arXiv:2212.02991]: https://arxiv.org/abs/2212.02991 |
|
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
153 | [arXiv:2502.12417]: https://arxiv.org/abs/2502.12417 |
|
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
154 | [doi:10.46298/jnsao-2023-10433]: http://doi.org/10.46298/jnsao-2023-10433 |
|
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
155 | |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
156 | ### Linux / further patching |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
157 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
158 | Due to both Fenics and typical Linux system being completely broken, you may need to do further patching to get things to compile: |
|
1
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
159 | |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
160 | 1. I had to set (in my [direnv](https://direnv.net) `.envrc`) |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
161 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
162 | export PKG_CONFIG_PATH=/home/linuxbrew/.linuxbrew/lib/pkgconfig:/usr/local/lib/pkgconfig/:/usr/lib/aarch64-linux-gnu/pkgconfig/ |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
163 | export LD_LIBRARY_PATH=/home/linuxbrew/.linuxbrew/lib |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
164 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
165 | 2. Some libraries, in particular `libfmt` and `libspdlog` installed in Homebrew, may conflict with system versions, that must be removed. |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
166 | Lack of proper sandboxing in legacy Linux distributions, effectively prohibits multiple versions of the same library. |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
167 | 2. I had to add `Libs` in `/usr/local/lib/pkgconfig/dolfinx.pc` the bit `-L/home/linuxbrew/.linuxbrew/lib/ -lopenblas`. Nothing in the fenics stack seems to explicitly require it. Basix, that depends on openblas, is entirely missing a `pkg-config` file. |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
168 | 3. Also `export export OMP_NUM_THREADS=1` (in `.envrc`). We don't do MPI. We cannot do MPI in Fenics' lame “it's all just parallel solution of PDEs, with no other computation, ever” aka “single-program multiple-data, with no controller at all” way. If you don't do this, you may have multiple threads wasting CPU just being there. We try to control the thread count in our code, but OpenMPI on Linux doesn't seem to respect it. |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
169 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
170 | ## Building and running the experiments |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
171 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
172 | To compile the program, run |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
173 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
174 | cargo build --release |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
175 | |
|
1
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
176 | When doing this for the first time, several dependencies will be downloaded. |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
177 | Now you can run the experiments in the article with |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
178 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
179 | cargo run --release -- \ |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
180 | -o results -a radon_sliding_fb -a radon_fb --max-iter 20000 |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
181 | experiments/laser_and_mirrors_aux.py experiments/laser_and_mirrors_aux2.py |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
182 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
183 | The `-o results` option tells `pointsource_pde` to write results in the `results` directory. |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
184 | The other options indicate the algorithms and experiments to run, as well as the maximum number |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
185 | of iterations. |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
186 | The double-dash separates the options for the Cargo build system and `pointsource_pde`. |
|
1
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
187 | |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
188 | ### Visualising the results |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
189 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
190 | The results may be plotted with |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
191 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
192 | python3 ./plot.py results/laser_and_mirrors_aux/radon_sliding_fb |
|
1
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
193 | |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
194 | Vary the path to `laser_and_mirrors_aux2` and `radon_fb` for the alternative experiment and basic algorithm. |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
195 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
196 | The script `misc/copy_results.sh` may be generate the images and copy the results in the manuscript |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
197 | to `../gasleak`. |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
198 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
199 | ## Documentation |
|
1
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
200 | |
|
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
201 | Use the `--help` option to get an extensive listing of command line options to |
|
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
202 | customise algorithm parameters and the experiments performed. |
|
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
203 | |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
204 | ### Internals |
|
1
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
205 | |
|
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
206 | If you are interested in the program internals, the integrated source code |
|
a4137aedcb3a
Initial working version for known convectivity and diffusivity
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
207 | documentation may be built and opened with |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
208 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
209 | cargo doc # build dependency docs |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
210 | misc/cargo-d --open # build and open KaTeX-aware docs for this crate |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
211 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
212 | The `cargo-d` script ensures that KaTeX mathematics is rendered in the generated documentation through an ugly workaround. Unfortunately, `rustdoc` is stuck in 80's 7-bit gringo ASCII world, |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
1
diff
changeset
|
213 | and does not support modern markdown features, such as mathematics. |