custemx 0.9.5.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- custemx-0.9.5.1/.gitignore +26 -0
- custemx-0.9.5.1/CHANGELOG.md +4 -0
- custemx-0.9.5.1/CONTRIBUTING.md +8 -0
- custemx-0.9.5.1/INSTALL.md +51 -0
- custemx-0.9.5.1/PKG-INFO +93 -0
- custemx-0.9.5.1/README.md +70 -0
- custemx-0.9.5.1/VERSION.md +8 -0
- custemx-0.9.5.1/custemx/Types table.md +45 -0
- custemx-0.9.5.1/custemx/__init__.py +183 -0
- custemx-0.9.5.1/custemx/custemx_config.json +21 -0
- custemx-0.9.5.1/custemx/fe/__init__.py +38 -0
- custemx-0.9.5.1/custemx/fe/fe_class.py +922 -0
- custemx-0.9.5.1/custemx/fe/fe_forms.py +372 -0
- custemx-0.9.5.1/custemx/fe/fe_lib.py +514 -0
- custemx-0.9.5.1/custemx/fe/primary_fields.py +126 -0
- custemx-0.9.5.1/custemx/inv/__init__.py +15 -0
- custemx-0.9.5.1/custemx/inv/fop_class.py +815 -0
- custemx-0.9.5.1/custemx/inv/inv_class.py +547 -0
- custemx-0.9.5.1/custemx/inv/run_fwd.sh +17 -0
- custemx-0.9.5.1/custemx/inv/run_fwd_from_config.py +42 -0
- custemx-0.9.5.1/custemx/inv/setup_persistent_workers.py +77 -0
- custemx-0.9.5.1/custemx/io/__init__.py +23 -0
- custemx-0.9.5.1/custemx/io/mesh_io.py +481 -0
- custemx-0.9.5.1/custemx/io/misc_io.py +905 -0
- custemx-0.9.5.1/custemx/io/mt_edi_io.py +537 -0
- custemx-0.9.5.1/custemx/io/result_io.py +326 -0
- custemx-0.9.5.1/custemx/meshtools/__init__.py +25 -0
- custemx-0.9.5.1/custemx/meshtools/bathy_tools.py +1109 -0
- custemx-0.9.5.1/custemx/meshtools/dem_interpolator.py +347 -0
- custemx-0.9.5.1/custemx/meshtools/icosphere.py +303 -0
- custemx-0.9.5.1/custemx/meshtools/interface_mesh.py +13 -0
- custemx-0.9.5.1/custemx/meshtools/invmesh_tools.py +391 -0
- custemx-0.9.5.1/custemx/meshtools/mesh_utils.py +186 -0
- custemx-0.9.5.1/custemx/meshtools/meshgen_tools.py +2901 -0
- custemx-0.9.5.1/custemx/meshtools/meshgen_utils.py +1457 -0
- custemx-0.9.5.1/custemx/misc/__init__.py +20 -0
- custemx-0.9.5.1/custemx/misc/decorators.py +206 -0
- custemx-0.9.5.1/custemx/misc/errors.py +57 -0
- custemx-0.9.5.1/custemx/misc/logfile.py +341 -0
- custemx-0.9.5.1/custemx/misc/semi_analytic.py +459 -0
- custemx-0.9.5.1/custemx/misc/tools.py +776 -0
- custemx-0.9.5.1/custemx/misc/unit_test.py +132 -0
- custemx-0.9.5.1/custemx/mod/__init__.py +12 -0
- custemx-0.9.5.1/custemx/mod/mod_class.py +694 -0
- custemx-0.9.5.1/custemx/mod/mp_class.py +541 -0
- custemx-0.9.5.1/custemx/mod/post_proc.py +879 -0
- custemx-0.9.5.1/custemx/plot/__init__.py +11 -0
- custemx-0.9.5.1/custemx/plot/plot_class.py +105 -0
- custemx-0.9.5.1/custemx/plot/plot_lib.py +309 -0
- custemx-0.9.5.1/custemx/solver/__init__.py +12 -0
- custemx-0.9.5.1/custemx/solver/solver_classes.py +859 -0
- custemx-0.9.5.1/custemx.egg-info/PKG-INFO +93 -0
- custemx-0.9.5.1/custemx.egg-info/SOURCES.txt +143 -0
- custemx-0.9.5.1/custemx.egg-info/dependency_links.txt +1 -0
- custemx-0.9.5.1/custemx.egg-info/requires.txt +12 -0
- custemx-0.9.5.1/custemx.egg-info/scm_file_list.json +142 -0
- custemx-0.9.5.1/custemx.egg-info/scm_version.json +8 -0
- custemx-0.9.5.1/custemx.egg-info/top_level.txt +4 -0
- custemx-0.9.5.1/docs/.readthedocs.yaml +14 -0
- custemx-0.9.5.1/docs/Makefile +20 -0
- custemx-0.9.5.1/docs/_static/custemxlogo.png +0 -0
- custemx-0.9.5.1/docs/changelog.md +109 -0
- custemx-0.9.5.1/docs/conf.py +119 -0
- custemx-0.9.5.1/docs/configuration.md +582 -0
- custemx-0.9.5.1/docs/contributing.md +527 -0
- custemx-0.9.5.1/docs/development.md +42 -0
- custemx-0.9.5.1/docs/index.md +72 -0
- custemx-0.9.5.1/docs/installation.md +2 -0
- custemx-0.9.5.1/docs/license.md +164 -0
- custemx-0.9.5.1/docs/make.bat +35 -0
- custemx-0.9.5.1/docs/notes.md +295 -0
- custemx-0.9.5.1/docs/requirements.txt +6 -0
- custemx-0.9.5.1/docs/team.md +21 -0
- custemx-0.9.5.1/emtools/__init__.py +11 -0
- custemx-0.9.5.1/emtools/base.py +1583 -0
- custemx-0.9.5.1/emtools/csem.py +560 -0
- custemx-0.9.5.1/emtools/modeling.py +52 -0
- custemx-0.9.5.1/emtools/mt.py +612 -0
- custemx-0.9.5.1/emtools/plotting.py +226 -0
- custemx-0.9.5.1/emtools/survey.py +766 -0
- custemx-0.9.5.1/emtools/utils.py +385 -0
- custemx-0.9.5.1/pyhed/IO/__init__.py +29 -0
- custemx-0.9.5.1/pyhed/IO/saveload.py +325 -0
- custemx-0.9.5.1/pyhed/IO/vtk.py +247 -0
- custemx-0.9.5.1/pyhed/__init__.py +157 -0
- custemx-0.9.5.1/pyhed/__version__ +1 -0
- custemx-0.9.5.1/pyhed/apps/app_test.py +46 -0
- custemx-0.9.5.1/pyhed/apps/secondaryFieldCalculation.py +101 -0
- custemx-0.9.5.1/pyhed/apps/secondaryFieldCalculation.sh +45 -0
- custemx-0.9.5.1/pyhed/apps/totalFieldCalculation.py +64 -0
- custemx-0.9.5.1/pyhed/apps/totalFieldCalculation.sh +41 -0
- custemx-0.9.5.1/pyhed/apps/totalFieldInterpolation.py +120 -0
- custemx-0.9.5.1/pyhed/apps/totalFieldInterpolation.sh +45 -0
- custemx-0.9.5.1/pyhed/config.py +453 -0
- custemx-0.9.5.1/pyhed/hed/__init__.py +34 -0
- custemx-0.9.5.1/pyhed/hed/hed_bib.py +966 -0
- custemx-0.9.5.1/pyhed/hed/hed_para.py +178 -0
- custemx-0.9.5.1/pyhed/hed/libHED.py +1448 -0
- custemx-0.9.5.1/pyhed/hed/reference/__init__.py +24 -0
- custemx-0.9.5.1/pyhed/hed/reference/dipole1d.py +362 -0
- custemx-0.9.5.1/pyhed/hed/reference/homogeneous_fullspace.py +69 -0
- custemx-0.9.5.1/pyhed/hed/reference/homogeneous_halfspace.py +134 -0
- custemx-0.9.5.1/pyhed/loop/__init__.py +34 -0
- custemx-0.9.5.1/pyhed/loop/loop_bib.py +5387 -0
- custemx-0.9.5.1/pyhed/loop/loop_para.py +642 -0
- custemx-0.9.5.1/pyhed/misc/__init__.py +54 -0
- custemx-0.9.5.1/pyhed/misc/console_call.py +389 -0
- custemx-0.9.5.1/pyhed/misc/load_save.py +124 -0
- custemx-0.9.5.1/pyhed/misc/matrixWrapper.py +79 -0
- custemx-0.9.5.1/pyhed/misc/mesh_tools.py +169 -0
- custemx-0.9.5.1/pyhed/misc/mpi_tools.py +221 -0
- custemx-0.9.5.1/pyhed/misc/para_lib.py +134 -0
- custemx-0.9.5.1/pyhed/misc/poly_tools.py +148 -0
- custemx-0.9.5.1/pyhed/misc/test_class.py +34 -0
- custemx-0.9.5.1/pyhed/misc/timer.py +149 -0
- custemx-0.9.5.1/pyhed/misc/toolbox.py +553 -0
- custemx-0.9.5.1/pyhed/misc/vec.py +1120 -0
- custemx-0.9.5.1/pyhed/plot/__init__.py +25 -0
- custemx-0.9.5.1/pyhed/plot/plotHankel.py +66 -0
- custemx-0.9.5.1/pyhed/plot/plot_bib.py +935 -0
- custemx-0.9.5.1/pyproject.toml +49 -0
- custemx-0.9.5.1/pytest/conftest.py +20 -0
- custemx-0.9.5.1/pytest/mwe/11_csem_fwd/mwe_hed.py +44 -0
- custemx-0.9.5.1/pytest/mwe/test_mwe.py +22 -0
- custemx-0.9.5.1/pytest/test_assembly.py +146 -0
- custemx-0.9.5.1/pytest/test_boundary_detection.py +266 -0
- custemx-0.9.5.1/pytest/test_class_init.py +49 -0
- custemx-0.9.5.1/pytest/test_fem_io.py +59 -0
- custemx-0.9.5.1/pytest/test_fwd_emdata.py +207 -0
- custemx-0.9.5.1/pytest/test_get_from_all.py +84 -0
- custemx-0.9.5.1/pytest/test_locate_transmitter.py +49 -0
- custemx-0.9.5.1/pytest/test_logfile_lifecycle.py +391 -0
- custemx-0.9.5.1/pytest/test_mesh_io.py +201 -0
- custemx-0.9.5.1/pytest/test_mesh_utils.py +42 -0
- custemx-0.9.5.1/pytest/test_meshes/minimalistic.h5 +0 -0
- custemx-0.9.5.1/pytest/test_meshes/minimalistic.xdmf +23 -0
- custemx-0.9.5.1/pytest/test_meshes/minimalistic_para.json +102 -0
- custemx-0.9.5.1/pytest/test_meshgen_cylinder.py +38 -0
- custemx-0.9.5.1/pytest/test_mp_io.py +170 -0
- custemx-0.9.5.1/pytest/test_mt_edi_io.py +114 -0
- custemx-0.9.5.1/pytest/test_multi_fwd.py +75 -0
- custemx-0.9.5.1/pytest/test_multiclass.json +53 -0
- custemx-0.9.5.1/pytest/test_petsc_prefix_stack.py +97 -0
- custemx-0.9.5.1/pytest.ini +11 -0
- custemx-0.9.5.1/setup.cfg +4 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
**/__pycache__
|
|
2
|
+
*/*.vtu
|
|
3
|
+
*/*.pvtu
|
|
4
|
+
*/*.pvd
|
|
5
|
+
*.pdf
|
|
6
|
+
*.edge
|
|
7
|
+
*.poly
|
|
8
|
+
*.xdmf
|
|
9
|
+
*.h5
|
|
10
|
+
*.pyc
|
|
11
|
+
*instructions.md
|
|
12
|
+
.conda
|
|
13
|
+
.vscode
|
|
14
|
+
.pytest_cache
|
|
15
|
+
default_model_parameter.json
|
|
16
|
+
pytest/results/**
|
|
17
|
+
pytest/fwd/**
|
|
18
|
+
pytest/mwe/fwd/**
|
|
19
|
+
pytest/mwe/meshes/**
|
|
20
|
+
pytest/mwe/results/**
|
|
21
|
+
results/**
|
|
22
|
+
docs/_build/**
|
|
23
|
+
docs/api/**
|
|
24
|
+
uv.lock
|
|
25
|
+
custemx.egg-info/*
|
|
26
|
+
custemx/mod/default_model_parameter_old.json
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Contributing to custemx
|
|
2
|
+
|
|
3
|
+
The project contribution, engineering, testing, documentation, configuration,
|
|
4
|
+
MPI, and automation-agent policies are maintained in
|
|
5
|
+
[docs/contributing.md](docs/contributing.md).
|
|
6
|
+
|
|
7
|
+
Read that guide before proposing or implementing a change. For release and
|
|
8
|
+
deployment process, see [docs/development.md](docs/development.md).
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Installation
|
|
2
|
+
|
|
3
|
+
**Clone custemx and the corresponding custemx-examples**
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
git clone https://gitlab.com/custem/custemx.git
|
|
7
|
+
git clone https://gitlab.com/custem/custemx-examples.git
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
**Create conda environment with fenicsx library and its dependencies**
|
|
11
|
+
|
|
12
|
+
- download Anaconda or Miniconda
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
conda create -n dfx11 -c conda-forge fenics-dolfinx tetgen mpich
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
**Activate conda environment**
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
conda activate "name"
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**Install pygimli via pip and other dependencies**
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install pygimli
|
|
28
|
+
pip install meshio utm pyvista empymod
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Add custemx and datatools to your PYTHONPATH variable and adjust OMP NUM THREADS variable**
|
|
32
|
+
|
|
33
|
+
```{note}
|
|
34
|
+
We recommended to add the following three commands to your .bashrc file
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
export PYTHONPATH=${PYTHONPATH}:$HOME/"path_to_custemx":$HOME/"path_to_custemx"/datatools
|
|
39
|
+
export OMP_NUM_THREADS=1
|
|
40
|
+
conda activate "name"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
<!--
|
|
44
|
+
## add custemx git to environment
|
|
45
|
+
cd custemx
|
|
46
|
+
pip install --no-build-isolation --no-deps -e .
|
|
47
|
+
|
|
48
|
+
## add pygimli git to environment
|
|
49
|
+
cd ../pygimli
|
|
50
|
+
pip install --no-build-isolation --no-deps -e .
|
|
51
|
+
-->
|
custemx-0.9.5.1/PKG-INFO
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: custemx
|
|
3
|
+
Version: 0.9.5.1
|
|
4
|
+
Summary: A library for electromagnetic modeling with FEniCSx and pyGIMLi integration.
|
|
5
|
+
Author-email: Nico Skibbe <nico.skibbe@liag-institut.de>, Raphael Rochlitz <raphael.rochlitz@liag-institut.de>
|
|
6
|
+
License-Expression: LGPL-3.0-only
|
|
7
|
+
Project-URL: Homepage, https://custemx.readthedocs.io
|
|
8
|
+
Project-URL: Repository, https://gitlab.com/custem/custemx
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
Requires-Dist: pygimli
|
|
14
|
+
Requires-Dist: meshio
|
|
15
|
+
Requires-Dist: utm
|
|
16
|
+
Requires-Dist: pyvista
|
|
17
|
+
Requires-Dist: empymod
|
|
18
|
+
Provides-Extra: test
|
|
19
|
+
Requires-Dist: pytest; extra == "test"
|
|
20
|
+
Provides-Extra: fenics
|
|
21
|
+
Requires-Dist: dolfinx; extra == "fenics"
|
|
22
|
+
Requires-Dist: fenics-dolfinx; extra == "fenics"
|
|
23
|
+
|
|
24
|
+
# custemx
|
|
25
|
+
|
|
26
|
+
custemx is an open-source Python toolkit for 3D electromagnetic forward
|
|
27
|
+
modeling and inversion in geophysics. Built on FEniCSx, it brings together
|
|
28
|
+
finite-element formulations, mesh and model setup, field calculation, and
|
|
29
|
+
post-processing for controlled-source EM (CSEM) and magnetotellurics (MT).
|
|
30
|
+
|
|
31
|
+
[Documentation](https://custemx.readthedocs.io/) ·
|
|
32
|
+
[Examples](https://gitlab.com/custem/custemx-examples) ·
|
|
33
|
+
[Source code](https://gitlab.com/custem/custemx)
|
|
34
|
+
|
|
35
|
+
## Capabilities
|
|
36
|
+
|
|
37
|
+
- Model 3D CSEM and MT problems on unstructured tetrahedral meshes, with
|
|
38
|
+
utilities for mesh generation, import, and export.
|
|
39
|
+
- Use Nedelec finite elements to calculate complex electric fields and derive
|
|
40
|
+
magnetic fields and MT responses.
|
|
41
|
+
- Represent isotropic or anisotropic electrical and electromagnetic properties,
|
|
42
|
+
including VTI and full anisotropy for conductivity, permeability, and
|
|
43
|
+
permittivity.
|
|
44
|
+
- Include frequency-dependent induced polarization using Cole-Cole parameters.
|
|
45
|
+
- Choose direct PETSc/MUMPS or iterative PETSc solver workflows, and run
|
|
46
|
+
distributed simulations with MPI.
|
|
47
|
+
- Adapt the Python workflow through configurable model parameters, sources,
|
|
48
|
+
receivers, formulations, and post-processing components.
|
|
49
|
+
|
|
50
|
+
## Start with an example
|
|
51
|
+
|
|
52
|
+
The examples repository is the recommended place to start: each case includes
|
|
53
|
+
working model setup and run scripts, rather than a disconnected API snippet.
|
|
54
|
+
|
|
55
|
+
- [3D CSEM half-space][halfspace]: a first mesh-generation and
|
|
56
|
+
forward-modeling workflow.
|
|
57
|
+
- [Layered-earth crooked-loop CSEM][crooked-loop]: a next step with a more
|
|
58
|
+
involved source and earth model.
|
|
59
|
+
- [Induced-polarization examples][ip-examples]: frequency-domain IP modeling.
|
|
60
|
+
- [Inversion examples][inversion-examples]: workflows from minimal examples
|
|
61
|
+
to research applications.
|
|
62
|
+
|
|
63
|
+
See the [examples README](https://gitlab.com/custem/custemx-examples/-/blob/main/README.md)
|
|
64
|
+
for repository layout and run instructions.
|
|
65
|
+
|
|
66
|
+
[halfspace]: https://gitlab.com/custem/custemx-examples/-/tree/main/modeling/csem/01_hed_halfspace
|
|
67
|
+
[crooked-loop]: https://gitlab.com/custem/custemx-examples/-/tree/main/modeling/csem/02_crooked_loop_layered
|
|
68
|
+
[ip-examples]: https://gitlab.com/custem/custemx-examples/-/tree/main/modeling/fd_ip
|
|
69
|
+
[inversion-examples]: https://gitlab.com/custem/custemx-examples/-/tree/main/inversion
|
|
70
|
+
|
|
71
|
+
## Installation
|
|
72
|
+
|
|
73
|
+
custemx requires Python 3.10 or later and a working FEniCSx, PETSc, and MPI
|
|
74
|
+
environment. Create the recommended environment with conda, then install the
|
|
75
|
+
published Python package with pip:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
conda create -n custemx -c conda-forge fenics-dolfinx tetgen mpich
|
|
79
|
+
conda activate custemx
|
|
80
|
+
python -m pip install custemx
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The conda environment provides the FEniCSx runtime; pip installs custemx and
|
|
84
|
+
its declared Python dependencies.
|
|
85
|
+
|
|
86
|
+
## Project information
|
|
87
|
+
|
|
88
|
+
- **Maintainers:** Raphael Rochlitz and Nico Skibbe ([team and contact
|
|
89
|
+
information](https://custemx.readthedocs.io/en/latest/team.html))
|
|
90
|
+
- **License:** [LGPL-3.0-only](https://custemx.readthedocs.io/en/latest/license.html)
|
|
91
|
+
|
|
92
|
+
See the [full documentation](https://custemx.readthedocs.io/) for more
|
|
93
|
+
information.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# custemx
|
|
2
|
+
|
|
3
|
+
custemx is an open-source Python toolkit for 3D electromagnetic forward
|
|
4
|
+
modeling and inversion in geophysics. Built on FEniCSx, it brings together
|
|
5
|
+
finite-element formulations, mesh and model setup, field calculation, and
|
|
6
|
+
post-processing for controlled-source EM (CSEM) and magnetotellurics (MT).
|
|
7
|
+
|
|
8
|
+
[Documentation](https://custemx.readthedocs.io/) ·
|
|
9
|
+
[Examples](https://gitlab.com/custem/custemx-examples) ·
|
|
10
|
+
[Source code](https://gitlab.com/custem/custemx)
|
|
11
|
+
|
|
12
|
+
## Capabilities
|
|
13
|
+
|
|
14
|
+
- Model 3D CSEM and MT problems on unstructured tetrahedral meshes, with
|
|
15
|
+
utilities for mesh generation, import, and export.
|
|
16
|
+
- Use Nedelec finite elements to calculate complex electric fields and derive
|
|
17
|
+
magnetic fields and MT responses.
|
|
18
|
+
- Represent isotropic or anisotropic electrical and electromagnetic properties,
|
|
19
|
+
including VTI and full anisotropy for conductivity, permeability, and
|
|
20
|
+
permittivity.
|
|
21
|
+
- Include frequency-dependent induced polarization using Cole-Cole parameters.
|
|
22
|
+
- Choose direct PETSc/MUMPS or iterative PETSc solver workflows, and run
|
|
23
|
+
distributed simulations with MPI.
|
|
24
|
+
- Adapt the Python workflow through configurable model parameters, sources,
|
|
25
|
+
receivers, formulations, and post-processing components.
|
|
26
|
+
|
|
27
|
+
## Start with an example
|
|
28
|
+
|
|
29
|
+
The examples repository is the recommended place to start: each case includes
|
|
30
|
+
working model setup and run scripts, rather than a disconnected API snippet.
|
|
31
|
+
|
|
32
|
+
- [3D CSEM half-space][halfspace]: a first mesh-generation and
|
|
33
|
+
forward-modeling workflow.
|
|
34
|
+
- [Layered-earth crooked-loop CSEM][crooked-loop]: a next step with a more
|
|
35
|
+
involved source and earth model.
|
|
36
|
+
- [Induced-polarization examples][ip-examples]: frequency-domain IP modeling.
|
|
37
|
+
- [Inversion examples][inversion-examples]: workflows from minimal examples
|
|
38
|
+
to research applications.
|
|
39
|
+
|
|
40
|
+
See the [examples README](https://gitlab.com/custem/custemx-examples/-/blob/main/README.md)
|
|
41
|
+
for repository layout and run instructions.
|
|
42
|
+
|
|
43
|
+
[halfspace]: https://gitlab.com/custem/custemx-examples/-/tree/main/modeling/csem/01_hed_halfspace
|
|
44
|
+
[crooked-loop]: https://gitlab.com/custem/custemx-examples/-/tree/main/modeling/csem/02_crooked_loop_layered
|
|
45
|
+
[ip-examples]: https://gitlab.com/custem/custemx-examples/-/tree/main/modeling/fd_ip
|
|
46
|
+
[inversion-examples]: https://gitlab.com/custem/custemx-examples/-/tree/main/inversion
|
|
47
|
+
|
|
48
|
+
## Installation
|
|
49
|
+
|
|
50
|
+
custemx requires Python 3.10 or later and a working FEniCSx, PETSc, and MPI
|
|
51
|
+
environment. Create the recommended environment with conda, then install the
|
|
52
|
+
published Python package with pip:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
conda create -n custemx -c conda-forge fenics-dolfinx tetgen mpich
|
|
56
|
+
conda activate custemx
|
|
57
|
+
python -m pip install custemx
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The conda environment provides the FEniCSx runtime; pip installs custemx and
|
|
61
|
+
its declared Python dependencies.
|
|
62
|
+
|
|
63
|
+
## Project information
|
|
64
|
+
|
|
65
|
+
- **Maintainers:** Raphael Rochlitz and Nico Skibbe ([team and contact
|
|
66
|
+
information](https://custemx.readthedocs.io/en/latest/team.html))
|
|
67
|
+
- **License:** [LGPL-3.0-only](https://custemx.readthedocs.io/en/latest/license.html)
|
|
68
|
+
|
|
69
|
+
See the [full documentation](https://custemx.readthedocs.io/) for more
|
|
70
|
+
information.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# custemx release version
|
|
2
|
+
|
|
3
|
+
The canonical package version is stored in `custemx/__version__` and mirrored
|
|
4
|
+
in `pyproject.toml`.
|
|
5
|
+
|
|
6
|
+
Release history is in [docs/changelog.md](docs/changelog.md); the release and versioning
|
|
7
|
+
process is documented in [docs/development.md](docs/development.md) and
|
|
8
|
+
[docs/contributing.md](docs/contributing.md).
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Types table
|
|
2
|
+
|
|
3
|
+
# Numpy
|
|
4
|
+
np.ndarray:
|
|
5
|
+
Numpy Array
|
|
6
|
+
|
|
7
|
+
# Petsc
|
|
8
|
+
petsc4py.PETSc.Mat
|
|
9
|
+
System matrix
|
|
10
|
+
|
|
11
|
+
petsc4py.PETSc.Vec
|
|
12
|
+
Right hand side
|
|
13
|
+
|
|
14
|
+
# dolfinx
|
|
15
|
+
dfx.mesh.Mesh
|
|
16
|
+
Dolfinx Mesh
|
|
17
|
+
|
|
18
|
+
dfx.mesh.MeshTags
|
|
19
|
+
Marker for a mesh
|
|
20
|
+
|
|
21
|
+
dfx.fem.Constant
|
|
22
|
+
Constant function on a mesh
|
|
23
|
+
|
|
24
|
+
dfx.fem.FunctionSpace
|
|
25
|
+
Function space for dof definition
|
|
26
|
+
|
|
27
|
+
dfx.fem.function.Function
|
|
28
|
+
Empty dolfinx function for coeffiecients
|
|
29
|
+
|
|
30
|
+
# UFL
|
|
31
|
+
ufl.argument.Argument
|
|
32
|
+
e.g. u = ufl.TrialFunction(V)
|
|
33
|
+
e.g. v = ufl.TestFunction(V)
|
|
34
|
+
|
|
35
|
+
# pyGIMLi
|
|
36
|
+
pg.Mesh
|
|
37
|
+
pyGIMLi mesh
|
|
38
|
+
|
|
39
|
+
# MPI
|
|
40
|
+
mpi4py.MPI.Intracomm
|
|
41
|
+
Communicator for the different MPI processes
|
|
42
|
+
|
|
43
|
+
# custEMx
|
|
44
|
+
cx.mod.ModelParameter
|
|
45
|
+
Model parameter class instance
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""
|
|
4
|
+
@author: Rochlitz & Skibbe
|
|
5
|
+
|
|
6
|
+
Main initialization file for the custEMx module.
|
|
7
|
+
Imports submodules and configuration file as well as the logger instance.
|
|
8
|
+
"""
|
|
9
|
+
import logging
|
|
10
|
+
import dolfinx as dx
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
import tempfile
|
|
13
|
+
import json
|
|
14
|
+
import mpi4py.MPI as MPI
|
|
15
|
+
from logging.handlers import MemoryHandler
|
|
16
|
+
|
|
17
|
+
# CONFIG
|
|
18
|
+
class _cfg():
|
|
19
|
+
""" Class for handling the configuration of the custemx module."""
|
|
20
|
+
def __init__(self, config='custemx_config.json') -> dict:
|
|
21
|
+
# dolfinx mesh partitioner
|
|
22
|
+
self._partitioner = None
|
|
23
|
+
with open(Path(__file__).with_name(config), 'r') as infile:
|
|
24
|
+
self._cfg = json.load(infile)
|
|
25
|
+
|
|
26
|
+
for key in self._cfg.keys():
|
|
27
|
+
setattr(self, key, self._cfg[key])
|
|
28
|
+
|
|
29
|
+
if not hasattr(self, 'global_timeout') or self.global_timeout == 0:
|
|
30
|
+
self.global_timeout = None
|
|
31
|
+
|
|
32
|
+
self.basepath = Path(__file__).parent
|
|
33
|
+
self.testpath = self.basepath.parent.joinpath('pytest')
|
|
34
|
+
|
|
35
|
+
@property
|
|
36
|
+
def partitioner(self):
|
|
37
|
+
"""Get the mesh partitioner for dolfinx meshes."""
|
|
38
|
+
if self._partitioner is None:
|
|
39
|
+
# FIXME allow ordering in module config
|
|
40
|
+
try:
|
|
41
|
+
from dolfinx.graph import partitioner_scotch
|
|
42
|
+
log.info('Use partitioner "Scotch"')
|
|
43
|
+
use_partitioner = partitioner_scotch()
|
|
44
|
+
except ImportError:
|
|
45
|
+
try:
|
|
46
|
+
from dolfinx.graph import partitioner_kahip
|
|
47
|
+
log.info('Use partitioner "Kahip"')
|
|
48
|
+
use_partitioner = partitioner_kahip()
|
|
49
|
+
except ImportError:
|
|
50
|
+
try:
|
|
51
|
+
from dolfinx.graph import partitioner_parmetis
|
|
52
|
+
log.info('Use partitioner "Parmetis"')
|
|
53
|
+
use_partitioner = partitioner_parmetis()
|
|
54
|
+
except ImportError:
|
|
55
|
+
pass
|
|
56
|
+
finally:
|
|
57
|
+
if use_partitioner is not None:
|
|
58
|
+
self._partitioner =\
|
|
59
|
+
dx.mesh.create_cell_partitioner(use_partitioner)
|
|
60
|
+
return self._partitioner
|
|
61
|
+
|
|
62
|
+
cfg = _cfg()
|
|
63
|
+
|
|
64
|
+
# LOGGER
|
|
65
|
+
log = logging.getLogger('cx')
|
|
66
|
+
_MEMORY_EXPORT_FMT = '%(asctime)s %(message)s'
|
|
67
|
+
_MEMORY_EXPORT_DATEFMT = '%Y-%m-%d %H:%M:%S'
|
|
68
|
+
|
|
69
|
+
# Custom logging level between INFO (20) and WARNING (30)
|
|
70
|
+
NOTICE = 25
|
|
71
|
+
logging.addLevelName(NOTICE, "NOTICE")
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _notice(self, message, *args, **kwargs):
|
|
75
|
+
if self.isEnabledFor(NOTICE):
|
|
76
|
+
self._log(NOTICE, message, args, **kwargs)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def _log_line(self, char="-", length=80):
|
|
80
|
+
if MPI.COMM_WORLD.rank == 0:
|
|
81
|
+
"""Print a separator line without logging prefix."""
|
|
82
|
+
if log.level < 24:
|
|
83
|
+
print(char * length, flush=True)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def _log_header(self, text, char="-", length=80):
|
|
87
|
+
if MPI.COMM_WORLD.rank == 0:
|
|
88
|
+
"""Print header lines without logging prefix."""
|
|
89
|
+
if log.level < 24:
|
|
90
|
+
print(char * length, flush=True)
|
|
91
|
+
print(text, flush=True)
|
|
92
|
+
print(char * length, flush=True)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def _ensure_root_console_handler(root_logger):
|
|
96
|
+
"""Set the formatter of all root console handlers."""
|
|
97
|
+
|
|
98
|
+
if not root_logger.handlers:
|
|
99
|
+
root_logger.addHandler(logging.StreamHandler())
|
|
100
|
+
|
|
101
|
+
elif len(root_logger.handlers) > 1:
|
|
102
|
+
root_logger.handlers = [root_logger.handlers[0]]
|
|
103
|
+
|
|
104
|
+
for handler in root_logger.handlers:
|
|
105
|
+
if isinstance(handler, logging.StreamHandler):
|
|
106
|
+
handler.setFormatter(
|
|
107
|
+
logging.Formatter(
|
|
108
|
+
fmt='CX - %(levelname)s - %(asctime)s - %(message)s',
|
|
109
|
+
datefmt='%H:%M:%S'))
|
|
110
|
+
|
|
111
|
+
def _ensure_memory_handler(logger):
|
|
112
|
+
"""Keep one MemoryHandler on cx logger for logfile message export."""
|
|
113
|
+
memory_handlers = [h for h in logger.handlers if
|
|
114
|
+
isinstance(h, MemoryHandler)]
|
|
115
|
+
if memory_handlers:
|
|
116
|
+
memory_handler = memory_handlers[0]
|
|
117
|
+
else:
|
|
118
|
+
memory_handler = MemoryHandler(
|
|
119
|
+
capacity=99999,
|
|
120
|
+
flushLevel=logging.CRITICAL,
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
memory_handler.setLevel(logging.NOTSET)
|
|
124
|
+
memory_handler.setFormatter(
|
|
125
|
+
logging.Formatter(
|
|
126
|
+
fmt=_MEMORY_EXPORT_FMT,
|
|
127
|
+
datefmt=_MEMORY_EXPORT_DATEFMT,
|
|
128
|
+
)
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
# Keep cx handler setup minimal and deterministic: memory capture locally,
|
|
132
|
+
# console output through root logger propagation.
|
|
133
|
+
logger.handlers = [memory_handler]
|
|
134
|
+
logger.propagate = True
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def _get_memory_messages(logger):
|
|
138
|
+
"""Return buffered messages from cx MemoryHandler."""
|
|
139
|
+
memory_handler = next(
|
|
140
|
+
(h for h in logger.handlers if isinstance(h, MemoryHandler)),
|
|
141
|
+
None,
|
|
142
|
+
)
|
|
143
|
+
messages = []
|
|
144
|
+
if memory_handler is not None:
|
|
145
|
+
for record in memory_handler.buffer:
|
|
146
|
+
try:
|
|
147
|
+
messages.append(memory_handler.formatter.format(record))
|
|
148
|
+
except Exception:
|
|
149
|
+
messages.append(record.getMessage())
|
|
150
|
+
return messages
|
|
151
|
+
|
|
152
|
+
logging.Logger.notice = _notice
|
|
153
|
+
log.get_messages = lambda: _get_memory_messages(log)
|
|
154
|
+
log.line = _log_line.__get__(log, logging.Logger)
|
|
155
|
+
log.header = _log_header.__get__(log, logging.Logger)
|
|
156
|
+
log.setLevel(cfg.log_level)
|
|
157
|
+
|
|
158
|
+
if MPI.COMM_WORLD.rank != 0:
|
|
159
|
+
log.setLevel(40)
|
|
160
|
+
|
|
161
|
+
# VERSION
|
|
162
|
+
try:
|
|
163
|
+
from importlib.metadata import version, PackageNotFoundError
|
|
164
|
+
__version__ = version("custemx")
|
|
165
|
+
except PackageNotFoundError:
|
|
166
|
+
__version__ = None
|
|
167
|
+
|
|
168
|
+
# SUBMODULES
|
|
169
|
+
from . import mod
|
|
170
|
+
from . import misc
|
|
171
|
+
from . import plot
|
|
172
|
+
from . import fe
|
|
173
|
+
from . import meshtools
|
|
174
|
+
from . import io
|
|
175
|
+
from . import solver
|
|
176
|
+
from . import inv
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
_ensure_root_console_handler(log.root)
|
|
180
|
+
_ensure_memory_handler(log)
|
|
181
|
+
|
|
182
|
+
# init default model parameters
|
|
183
|
+
mod.update_default_model_parameter(version=__version__)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"log_level": 20,
|
|
3
|
+
"max_cpu": 64,
|
|
4
|
+
"cpu_per_task": 16,
|
|
5
|
+
"global_timeout": 86400,
|
|
6
|
+
"inner_maxiter_warning": 50,
|
|
7
|
+
"petsc_options": {
|
|
8
|
+
"mumps": {
|
|
9
|
+
"ksp_type": "preonly",
|
|
10
|
+
"mat_mumps_cntl_1": 1e-8,
|
|
11
|
+
"mat_mumps_cntl_2": 1e-8,
|
|
12
|
+
"mat_mumps_icntl_8": 0,
|
|
13
|
+
"mat_mumps_icntl_14": 80,
|
|
14
|
+
"mat_mumps_icntl_48": 0,
|
|
15
|
+
"pc_factor_reuse_ordering": true,
|
|
16
|
+
"pc_factor_reuse_fill": true,
|
|
17
|
+
"pc_type": "cholesky",
|
|
18
|
+
"pc_factor_mat_solver_type": "mumps"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This file is part of custemx.
|
|
3
|
+
Licensed under the GNU LGPLv3, see LICENSE for details.
|
|
4
|
+
|
|
5
|
+
Authors: Nico Skibbe, Raphael Rochlitz
|
|
6
|
+
|
|
7
|
+
Public finite-element formulations and helper exports.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from .fe_class import BaseFormulation
|
|
11
|
+
from .fe_forms import FormEFD
|
|
12
|
+
from .fe_lib import (
|
|
13
|
+
LocalAssembler,
|
|
14
|
+
adjust_parameter,
|
|
15
|
+
check_attributes,
|
|
16
|
+
check_cell_markers,
|
|
17
|
+
create_delta_sigma,
|
|
18
|
+
eval_current_dir,
|
|
19
|
+
find_source_dofs_geometrical,
|
|
20
|
+
get_boundary_dofs,
|
|
21
|
+
parameter_to_array,
|
|
22
|
+
)
|
|
23
|
+
from .primary_fields import PF
|
|
24
|
+
|
|
25
|
+
__all__ = [
|
|
26
|
+
"BaseFormulation",
|
|
27
|
+
"FormEFD",
|
|
28
|
+
"LocalAssembler",
|
|
29
|
+
"adjust_parameter",
|
|
30
|
+
"check_attributes",
|
|
31
|
+
"check_cell_markers",
|
|
32
|
+
"create_delta_sigma",
|
|
33
|
+
"eval_current_dir",
|
|
34
|
+
"find_source_dofs_geometrical",
|
|
35
|
+
"get_boundary_dofs",
|
|
36
|
+
"parameter_to_array",
|
|
37
|
+
"PF",
|
|
38
|
+
]
|