README.md

changeset 12
a0d61ac3719e
parent 9
a5e6fac08015
child 15
7c63af7c9acd
equal deleted inserted replaced
11:c4f923017349 12:a0d61ac3719e
1 1 # Numerical implementation of “Leak localisation with a measure source convection–diffusion model”
2 # Nuerical implementation of “Leak localisation with a measure source convection–diffusion model”
3 2
4 These are the codes for the numerical demonstrations of the manuscript 3 These are the codes for the numerical demonstrations of the manuscript
5 _“Leak localisation with a measure source convection--diffusion model”_ 4 _“Leak localisation with a measure source convection--diffusion model”_
6 ([arXiv:2605.12095](https://arxiv.org/abs/2605.12095)) by Thi Tam Dang and Tuomo Valkonen. 5 ([arXiv:2605.12095](https://arxiv.org/abs/2605.12095)) by Thi Tam Dang and Tuomo Valkonen.
7 It should be relatively easy to to use this package and the algorithms it provides 6 It should be relatively easy to to use this package and the algorithms it provides
11 10
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. 11 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.
13 12
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.) 13 (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.)
15 14
16 ### Phase 1: Python and Fenics 15 ### Phase 1: Python and Fenics
17 16
18 #### Option 1.A that avoids Conda hell, but is more work (macOS and Linux) 17 #### Option 1.A that avoids Conda hell, but is more work (macOS and Linux)
19 18
20 ##### Phase 1.A.1: C++ dependencies of Fenics 19 ##### Phase 1.A.1: C++ dependencies of Fenics
21 20
26 25
27 (Fenics recommends ParMETIS instead of Kahip, but only the latter is available from Homebrew at the time of writing this.) 26 (Fenics recommends ParMETIS instead of Kahip, but only the latter is available from Homebrew at the time of writing this.)
28 27
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: 28 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:
30 29
31 package | version 30 | package | version |
32 ---------|-------- 31 | -------- | ------- |
33 boost | 1.90.0 32 | boost | 1.90.0 |
34 cmake | 4.2.1 33 | cmake | 4.2.1 |
35 fmt | 12.1.0 34 | fmt | 12.1.0 |
36 hdf5-mpi | 1.14.6 35 | hdf5-mpi | 1.14.6 |
37 kahip | 3.22 36 | kahip | 3.22 |
38 petsc | 3.24.3 37 | petsc | 3.24.3 |
39 pugixml | 1.15 38 | pugixml | 1.15 |
40 slepc | 3.24.2 39 | slepc | 3.24.2 |
41 spdlog | 1.17.0 40 | spdlog | 1.17.0 |
42 gsl | 2.8 41 | gsl | 2.8 |
43 42
44 You can get the list of installed versions with: 43 You can get the list of installed versions with:
45 44
46 brew list --versions openmpi boost pugixml fmt spdlog hdf5-mpi cmake kahip slepc petsc gsl 45 brew list --versions openmpi boost pugixml fmt spdlog hdf5-mpi cmake kahip slepc petsc gsl
47 46
63 (The last two lines are required later.) 62 (The last two lines are required later.)
64 This template is also available in `misc/_envrc`. 63 This template is also available in `misc/_envrc`.
65 For changes `.envrc` to take effect, you should use 64 For changes `.envrc` to take effect, you should use
66 65
67 direnv allow 66 direnv allow
68 67
69 ##### Phase 1.A.3: Fenicx-basix 68 ##### Phase 1.A.3: Fenicx-basix
70 69
71 Install basix from <https://github.com/FEniCS/basix/releases/tag/v0.10.0.post0> according to 70 Install basix from <https://github.com/FEniCS/basix/releases/tag/v0.10.0.post0> according to
72 instructions. First do the C++ bit: 71 instructions. First do the C++ bit:
73 72
109 If you didn't already do these steps with `direnv` above, you should: 108 If you didn't already do these steps with `direnv` above, you should:
110 109
111 export PYTHONPATH=$(echo .venv/lib/python*/site-packages) 110 export PYTHONPATH=$(echo .venv/lib/python*/site-packages)
112 export PYO3_PYTHON="$(which python)" 111 export PYO3_PYTHON="$(which python)"
113 112
114
115 #### Option 1.B: Conda 113 #### Option 1.B: Conda
116 114
117 You can *try to* install Fenicsx in Conda according to instructions on the Fenics website. Additionally you need to install `scipy`: 115 You can _try to_ install Fenicsx in Conda according to instructions on the Fenics website. Additionally you need to install `scipy`:
118 116
119 conda create -n fenicsx-env 117 conda create -n fenicsx-env
120 conda activate fenicsx-env 118 conda activate fenicsx-env
121 conda install -c conda-forge fenics-dolfinx=0.10.0 scipy=1.17.1 mpich 119 conda install -c conda-forge fenics-dolfinx=0.10.0 scipy=1.17.1 mpich
122 120
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. 121 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.
124 122
125 #### Option 1.C: Debian/Ubuntu 123 #### Option 1.C: Debian/Ubuntu
126 124
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. 125 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.
128 126
133 [alg_tools] also needs to be downloaded separately. 131 [alg_tools] also needs to be downloaded separately.
134 132
135 1. Install the [Rust] infrastructure (including Cargo) with [rustup]. 133 1. Install the [Rust] infrastructure (including Cargo) with [rustup].
136 2. Install a “nightly” release of the Rust compiler. With rustup, installed in 134 2. Install a “nightly” release of the Rust compiler. With rustup, installed in
137 the previous step, this can be done with 135 the previous step, this can be done with
138 136
139 rustup toolchain install nightly 137 rustup toolchain install nightly
140 138
141 3. Download [alg_tools], [pointsource_algs], and [measures] and unpack them under 139 3. Download [alg_tools], [pointsource_algs], and [measures] and unpack them under
142 the same directory as this package. 140 the same directory as this package.
143 141
144 [rustup]: https://rustup.rs 142 [rustup]: https://rustup.rs
145 [alg_tools]: https://tuomov.iki.fi/software/alg_tools/ 143 [alg_tools]: https://tuomov.iki.fi/software/alg_tools/
146 [pointsource_algs]: https://tuomov.iki.fi/software/pointsource_algs/ 144 [pointsource_algs]: https://tuomov.iki.fi/software/pointsource_algs/
147 [measures]: https://tuomov.iki.fi/repos/measures/ 145 [measures]: https://tuomov.iki.fi/repos/measures/
148 [Rust]: https://www.rust-lang.org/ 146 [Rust]: https://www.rust-lang.org/
149 [GNU Scientific Library]: https://www.gnu.org/software/gsl/ 147 [GNU Scientific Library]: https://www.gnu.org/software/gsl/
150 [rust-GSL]: https://docs.rs/GSL/6.0.0/rgsl/ 148 [rust-GSL]: https://docs.rs/GSL/6.0.0/rgsl/
151 [Homebrew]: https://brew.sh 149 [Homebrew]: https://brew.sh
152 [arXiv:2212.02991]: https://arxiv.org/abs/2212.02991 150 [arXiv:2212.02991]: https://arxiv.org/abs/2212.02991
153 [arXiv:2502.12417]: https://arxiv.org/abs/2502.12417 151 [arXiv:2502.12417]: https://arxiv.org/abs/2502.12417
154 [doi:10.46298/jnsao-2023-10433]: http://doi.org/10.46298/jnsao-2023-10433 152 [doi:10.46298/jnsao-2023-10433]: http://doi.org/10.46298/jnsao-2023-10433
155 153
156 ### Linux / further patching 154 ### Linux / further patching
157 155
158 Due to both Fenics and typical Linux system being completely broken, you may need to do further patching to get things to compile: 156 Due to both Fenics and typical Linux system being completely broken, you may need to do further patching to get things to compile:
159 157
160 1. I had to set (in my [direnv](https://direnv.net) `.envrc`) 158 1. I had to set (in my [direnv](https://direnv.net) `.envrc`)
161 159
162 export PKG_CONFIG_PATH=/home/linuxbrew/.linuxbrew/lib/pkgconfig:/usr/local/lib/pkgconfig/:/usr/lib/aarch64-linux-gnu/pkgconfig/ 160 export PKG_CONFIG_PATH=/home/linuxbrew/.linuxbrew/lib/pkgconfig:/usr/local/lib/pkgconfig/:/usr/lib/aarch64-linux-gnu/pkgconfig/
163 export LD_LIBRARY_PATH=/home/linuxbrew/.linuxbrew/lib 161 export LD_LIBRARY_PATH=/home/linuxbrew/.linuxbrew/lib
164 162
165 2. Some libraries, in particular `libfmt` and `libspdlog` installed in Homebrew, may conflict with system versions, that must be removed. 163 2. Some libraries, in particular `libfmt` and `libspdlog` installed in Homebrew, may conflict with system versions, that must be removed.
166 Lack of proper sandboxing in legacy Linux distributions, effectively prohibits multiple versions of the same library. 164 Lack of proper sandboxing in legacy Linux distributions, effectively prohibits multiple versions of the same library.
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. 165 3. 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.
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. 166 4. 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.
169 167
170 ## Building and running the experiments 168 ## Building and running the experiments
171 169
172 To compile the program, run 170 To compile the program, run
173 171
185 of iterations. 183 of iterations.
186 The double-dash separates the options for the Cargo build system and `pointsource_pde`. 184 The double-dash separates the options for the Cargo build system and `pointsource_pde`.
187 185
188 ### Visualising the results 186 ### Visualising the results
189 187
190 The results may be plotted with 188 The results may be plotted with
191 189
192 python3 ./plot.py results/laser_and_mirrors_aux/radon_sliding_fb 190 python3 ./plot.py results/laser_and_mirrors_aux/radon_sliding_fb
193 191
194 Vary the path to `laser_and_mirrors_aux2` and `radon_fb` for the alternative experiment and basic algorithm. 192 Vary the path to `laser_and_mirrors_aux2` and `radon_fb` for the alternative experiment and basic algorithm.
195 193

mercurial