fluxfem 0.1.1b0__tar.gz → 0.1.4__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.
Files changed (49) hide show
  1. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/PKG-INFO +38 -21
  2. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/README.md +34 -18
  3. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/pyproject.toml +7 -7
  4. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/__init__.py +68 -161
  5. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/core/__init__.py +59 -31
  6. fluxfem-0.1.4/src/fluxfem/core/context_types.py +36 -0
  7. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/core/forms.py +5 -1
  8. fluxfem-0.1.4/src/fluxfem/core/weakform.py +1258 -0
  9. fluxfem-0.1.1b0/src/fluxfem/helpers_num.py → fluxfem-0.1.4/src/fluxfem/helpers_ts.py +1 -1
  10. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/helpers_wf.py +6 -0
  11. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/mesh/base.py +6 -1
  12. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/mesh/hex.py +1 -0
  13. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/mesh/io.py +2 -0
  14. fluxfem-0.1.1b0/src/fluxfem/core/weakform.py +0 -818
  15. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/LICENSE +0 -0
  16. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/core/assembly.py +0 -0
  17. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/core/basis.py +0 -0
  18. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/core/data.py +0 -0
  19. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/core/dtypes.py +0 -0
  20. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/core/interp.py +0 -0
  21. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/core/solver.py +0 -0
  22. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/core/space.py +0 -0
  23. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/mesh/__init__.py +0 -0
  24. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/mesh/predicate.py +0 -0
  25. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/mesh/surface.py +0 -0
  26. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/mesh/tet.py +0 -0
  27. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/physics/__init__.py +0 -0
  28. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/physics/diffusion.py +0 -0
  29. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/physics/elasticity/__init__.py +0 -0
  30. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/physics/elasticity/hyperelastic.py +0 -0
  31. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/physics/elasticity/linear.py +0 -0
  32. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/physics/elasticity/materials.py +0 -0
  33. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/physics/elasticity/stress.py +0 -0
  34. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/physics/operators.py +0 -0
  35. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/physics/postprocess.py +0 -0
  36. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/solver/__init__.py +0 -0
  37. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/solver/bc.py +0 -0
  38. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/solver/cg.py +0 -0
  39. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/solver/dirichlet.py +0 -0
  40. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/solver/history.py +0 -0
  41. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/solver/newton.py +0 -0
  42. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/solver/result.py +0 -0
  43. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/solver/solve_runner.py +0 -0
  44. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/solver/solver.py +0 -0
  45. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/solver/sparse.py +0 -0
  46. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/tools/__init__.py +0 -0
  47. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/tools/jit.py +0 -0
  48. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/tools/timer.py +0 -0
  49. {fluxfem-0.1.1b0 → fluxfem-0.1.4}/src/fluxfem/tools/visualizer.py +0 -0
@@ -1,44 +1,55 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fluxfem
3
- Version: 0.1.1b0
3
+ Version: 0.1.4
4
4
  Summary: FluxFEM: A weak-form-centric differentiable finite element framework in JAX
5
5
  License: Apache-2.0
6
- Author: Kevin-Tofu
6
+ Author: Kohei Watanabe
7
7
  Author-email: koheitech001@gmail.com
8
8
  Requires-Python: >=3.11,<3.14
9
9
  Classifier: License :: OSI Approved :: Apache Software License
10
10
  Classifier: Programming Language :: Python :: 3
11
11
  Classifier: Programming Language :: Python :: 3.11
12
12
  Classifier: Programming Language :: Python :: 3.12
13
- Requires-Dist: jax (==0.8.2)
14
- Requires-Dist: jaxlib (==0.8.2)
13
+ Requires-Dist: jax (>=0.8.2,<0.9.0)
14
+ Requires-Dist: jaxlib (>=0.8.2,<0.9.0)
15
15
  Requires-Dist: matplotlib (>=3.10.7,<4.0.0)
16
16
  Requires-Dist: meshio (>=5.3.5,<6.0.0)
17
17
  Requires-Dist: pyvista (>=0.46.4,<0.47.0)
18
18
  Description-Content-Type: text/markdown
19
19
 
20
+ [![PyPI version](https://img.shields.io/pypi/v/fluxfem.svg?cacheSeconds=60)](https://pypi.org/project/fluxfem/)
20
21
  [![License: Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
21
22
  [![Python Version](https://img.shields.io/pypi/pyversions/fluxfem.svg)](https://pypi.org/project/fluxfem/)
22
23
  ![CI](https://github.com/kevin-tofu/fluxfem/actions/workflows/python-tests.yml/badge.svg)
23
24
  ![CI](https://github.com/kevin-tofu/fluxfem/actions/workflows/sphinx.yml/badge.svg)
25
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.18055465.svg)](https://doi.org/10.5281/zenodo.18055465)
26
+
24
27
 
25
28
  # FluxFEM
26
29
  A weak-form-centric differentiable finite element framework in JAX
27
30
 
28
31
  ## Examples and Features
29
- ### Example 1 : Diffusion
30
- <p align="center">
31
- <img src="https://media.githubusercontent.com/media/kevin-tofu/fluxfem/main/assets/diffusion_mms_timeseries.gif" alt="Optimization Process Pull-Down-0" width="400" style="margin-right: 20px;">
32
- </p>
33
-
34
- ## Features
35
- - Built on JAX, enabling automatic differentiation and high-performance execution via grad, jit, vmap, and related transformations.
36
-
37
- - A FEM framework with a weak-form–centric API, emphasizing a smooth transition from theoretical formulations to practical code implementations.
32
+ <table>
33
+ <tr>
34
+ <td align="center"><b>Example 1: Diffusion</b></td>
35
+ <td align="center"><b>Example 2: Neo Neohookean Hyper Elasticity</b></td>
36
+ </tr>
37
+ <tr>
38
+ <td align="center">
39
+ <img src="https://media.githubusercontent.com/media/kevin-tofu/fluxfem/main/assets/diffusion_mms_timeseries.gif" alt="Diffusion-mms" width="400">
40
+ </td>
41
+ <td align="center">
42
+ <img src="https://media.githubusercontent.com/media/kevin-tofu/fluxfem/main/assets/Neo-Hookean-deformedx20000.png" alt="Neo-Hookean" width="400">
43
+ </td>
44
+ </tr>
45
+ </table>
38
46
 
39
- - Supports two assembly approaches: weak-form-based assembly and a tensor-based (scikit-fem–style) assembly.
40
47
 
41
- - enables to handle both Linear / Non-Linear Analysis with AD with JAX
48
+ ## Features
49
+ - Built on JAX, enabling automatic differentiation with grad, jit, vmap, and related transformations.
50
+ - Weak-form–centric API that keeps formulations close to code; weak forms are represented as expression trees and compiled to element kernels.
51
+ - Two assembly approaches: weak-form-based assembly and a tensor-based (scikit-fem–style) assembly.
52
+ - Handles both linear and nonlinear analyses with AD in JAX.
42
53
 
43
54
  ## Usage
44
55
 
@@ -50,14 +61,18 @@ The first approach offers simplicity and convenience, as mathematical expression
50
61
  However, for more complex operations, the second approach can be easier to implement in practice.
51
62
  This is because the weak-form-based assembly is ultimately transformed into the tensor-based representation internally during computation.
52
63
 
64
+ ## Weak Form Compile Flow
65
+ Weak-form expressions are compiled into an evaluation plan and then executed per element.
66
+
53
67
  ### weak-form-based assembly
54
68
  ```Python
55
69
  import fluxfem as ff
70
+ import fluxfem.helpers_wf as h_wf
56
71
 
57
72
  space = ff.make_hex_space(mesh, dim=3, intorder=2)
58
73
  D = ff.isotropic_3d_D(1.0, 0.3)
59
74
  bilinear_form = ff.BilinearForm.volume(
60
- lambda u, v, D: h_wf.ddot(v.sym_grad, D @ u.sym_grad) * h_wf.dOmega()
75
+ lambda u, v, D: h_wf.ddot(v.sym_grad, h_wf.matmul_std(D, u.sym_grad)) * h_wf.dOmega()
61
76
  )
62
77
  K_wf = space.assemble_bilinear_form(
63
78
  bilinear_form.get_compiled(),
@@ -70,11 +85,12 @@ K_wf = space.assemble_bilinear_form(
70
85
  ```Python
71
86
  import fluxfem as ff
72
87
  import numpy as np
88
+ import fluxfem.helpers_ts as h_ts
73
89
 
74
90
  def linear_elasticity_form(ctx: ff.FormContext, D: np.ndarray) -> ff.jnp.ndarray:
75
- Bu = h_num.sym_grad(ctx.trial)
76
- Bv = h_num.sym_grad(ctx.test)
77
- return h_num.ddot(Bv, D, Bu)
91
+ Bu = h_ts.sym_grad(ctx.trial)
92
+ Bv = h_ts.sym_grad(ctx.test)
93
+ return h_ts.ddot(Bv, D, Bu)
78
94
 
79
95
 
80
96
  space = ff.make_hex_space(mesh, dim=3, intorder=2)
@@ -87,11 +103,11 @@ K = space.assemble_bilinear_form(linear_elasticity_form, params=D)
87
103
 
88
104
  ## SetUp
89
105
 
90
- You can install **Scikit-Topt** either via **pip** or **Poetry**.
106
+ You can install **FluxFEM** either via **pip** or **Poetry**.
91
107
 
92
108
  #### Supported Python Versions
93
109
 
94
- Scikit-Topt supports **Python 3.10–3.13**:
110
+ FluxFEM supports **Python 3.11–3.13**:
95
111
 
96
112
 
97
113
  **Choose one of the following methods:**
@@ -108,3 +124,4 @@ poetry add fluxfem
108
124
 
109
125
  ## Acknowledgements
110
126
  I acknoldege everythings that made this work possible.
127
+
@@ -1,25 +1,36 @@
1
+ [![PyPI version](https://img.shields.io/pypi/v/fluxfem.svg?cacheSeconds=60)](https://pypi.org/project/fluxfem/)
1
2
  [![License: Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
2
3
  [![Python Version](https://img.shields.io/pypi/pyversions/fluxfem.svg)](https://pypi.org/project/fluxfem/)
3
4
  ![CI](https://github.com/kevin-tofu/fluxfem/actions/workflows/python-tests.yml/badge.svg)
4
5
  ![CI](https://github.com/kevin-tofu/fluxfem/actions/workflows/sphinx.yml/badge.svg)
6
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.18055465.svg)](https://doi.org/10.5281/zenodo.18055465)
7
+
5
8
 
6
9
  # FluxFEM
7
10
  A weak-form-centric differentiable finite element framework in JAX
8
11
 
9
12
  ## Examples and Features
10
- ### Example 1 : Diffusion
11
- <p align="center">
12
- <img src="https://media.githubusercontent.com/media/kevin-tofu/fluxfem/main/assets/diffusion_mms_timeseries.gif" alt="Optimization Process Pull-Down-0" width="400" style="margin-right: 20px;">
13
- </p>
14
-
15
- ## Features
16
- - Built on JAX, enabling automatic differentiation and high-performance execution via grad, jit, vmap, and related transformations.
13
+ <table>
14
+ <tr>
15
+ <td align="center"><b>Example 1: Diffusion</b></td>
16
+ <td align="center"><b>Example 2: Neo Neohookean Hyper Elasticity</b></td>
17
+ </tr>
18
+ <tr>
19
+ <td align="center">
20
+ <img src="https://media.githubusercontent.com/media/kevin-tofu/fluxfem/main/assets/diffusion_mms_timeseries.gif" alt="Diffusion-mms" width="400">
21
+ </td>
22
+ <td align="center">
23
+ <img src="https://media.githubusercontent.com/media/kevin-tofu/fluxfem/main/assets/Neo-Hookean-deformedx20000.png" alt="Neo-Hookean" width="400">
24
+ </td>
25
+ </tr>
26
+ </table>
17
27
 
18
- - A FEM framework with a weak-form–centric API, emphasizing a smooth transition from theoretical formulations to practical code implementations.
19
28
 
20
- - Supports two assembly approaches: weak-form-based assembly and a tensor-based (scikit-fem–style) assembly.
21
-
22
- - enables to handle both Linear / Non-Linear Analysis with AD with JAX
29
+ ## Features
30
+ - Built on JAX, enabling automatic differentiation with grad, jit, vmap, and related transformations.
31
+ - Weak-form–centric API that keeps formulations close to code; weak forms are represented as expression trees and compiled to element kernels.
32
+ - Two assembly approaches: weak-form-based assembly and a tensor-based (scikit-fem–style) assembly.
33
+ - Handles both linear and nonlinear analyses with AD in JAX.
23
34
 
24
35
  ## Usage
25
36
 
@@ -31,14 +42,18 @@ The first approach offers simplicity and convenience, as mathematical expression
31
42
  However, for more complex operations, the second approach can be easier to implement in practice.
32
43
  This is because the weak-form-based assembly is ultimately transformed into the tensor-based representation internally during computation.
33
44
 
45
+ ## Weak Form Compile Flow
46
+ Weak-form expressions are compiled into an evaluation plan and then executed per element.
47
+
34
48
  ### weak-form-based assembly
35
49
  ```Python
36
50
  import fluxfem as ff
51
+ import fluxfem.helpers_wf as h_wf
37
52
 
38
53
  space = ff.make_hex_space(mesh, dim=3, intorder=2)
39
54
  D = ff.isotropic_3d_D(1.0, 0.3)
40
55
  bilinear_form = ff.BilinearForm.volume(
41
- lambda u, v, D: h_wf.ddot(v.sym_grad, D @ u.sym_grad) * h_wf.dOmega()
56
+ lambda u, v, D: h_wf.ddot(v.sym_grad, h_wf.matmul_std(D, u.sym_grad)) * h_wf.dOmega()
42
57
  )
43
58
  K_wf = space.assemble_bilinear_form(
44
59
  bilinear_form.get_compiled(),
@@ -51,11 +66,12 @@ K_wf = space.assemble_bilinear_form(
51
66
  ```Python
52
67
  import fluxfem as ff
53
68
  import numpy as np
69
+ import fluxfem.helpers_ts as h_ts
54
70
 
55
71
  def linear_elasticity_form(ctx: ff.FormContext, D: np.ndarray) -> ff.jnp.ndarray:
56
- Bu = h_num.sym_grad(ctx.trial)
57
- Bv = h_num.sym_grad(ctx.test)
58
- return h_num.ddot(Bv, D, Bu)
72
+ Bu = h_ts.sym_grad(ctx.trial)
73
+ Bv = h_ts.sym_grad(ctx.test)
74
+ return h_ts.ddot(Bv, D, Bu)
59
75
 
60
76
 
61
77
  space = ff.make_hex_space(mesh, dim=3, intorder=2)
@@ -68,11 +84,11 @@ K = space.assemble_bilinear_form(linear_elasticity_form, params=D)
68
84
 
69
85
  ## SetUp
70
86
 
71
- You can install **Scikit-Topt** either via **pip** or **Poetry**.
87
+ You can install **FluxFEM** either via **pip** or **Poetry**.
72
88
 
73
89
  #### Supported Python Versions
74
90
 
75
- Scikit-Topt supports **Python 3.10–3.13**:
91
+ FluxFEM supports **Python 3.11–3.13**:
76
92
 
77
93
 
78
94
  **Choose one of the following methods:**
@@ -88,4 +104,4 @@ poetry add fluxfem
88
104
  ```
89
105
 
90
106
  ## Acknowledgements
91
- I acknoldege everythings that made this work possible.
107
+ I acknoldege everythings that made this work possible.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fluxfem"
3
- version = "0.1.1b"
3
+ version = "0.1.4"
4
4
  description = ""
5
5
  authors = [
6
6
  {name = "Kohei Watanabe",email = "koheitech001@gmail.com"}
@@ -18,15 +18,15 @@ dependencies = [
18
18
  "meshio (>=5.3.5,<6.0.0)",
19
19
  "matplotlib (>=3.10.7,<4.0.0)",
20
20
  # Note: jax versioning currently around 0.8.x. Allow up to next minor.
21
- "jax (==0.8.2)",
22
- "jaxlib (==0.8.2)"
21
+ "jax (>=0.8.2,<0.9.0)",
22
+ "jaxlib (>=0.8.2,<0.9.0)"
23
23
  ]
24
24
 
25
25
  [tool.poetry]
26
26
  name = "fluxfem"
27
- version = "0.1.1b"
27
+ version = "0.1.4"
28
28
  description = "FluxFEM: A weak-form-centric differentiable finite element framework in JAX"
29
- authors = ["Kevin-Tofu <koheitech001@gmail.com>"]
29
+ authors = ["Kohei Watanabe <koheitech001@gmail.com>"]
30
30
  readme = "README.md"
31
31
  license = "Apache-2.0"
32
32
  packages = [
@@ -39,8 +39,8 @@ python = ">=3.11,<3.14"
39
39
  pyvista = ">=0.46.4,<0.47.0"
40
40
  meshio = ">=5.3.5,<6.0.0"
41
41
  matplotlib = ">=3.10.7,<4.0.0"
42
- jax = "==0.8.2"
43
- jaxlib = "==0.8.2"
42
+ jax = ">=0.8.2,<0.9.0"
43
+ jaxlib = ">=0.8.2,<0.9.0"
44
44
 
45
45
 
46
46
  [tool.poetry.group.dev]
@@ -1,159 +1,6 @@
1
- from .core import (
2
- FESpaceBase,
3
- FESpace,
4
- FESpacePytree,
5
- Expr,
6
- FieldRef,
7
- ParamRef,
8
- trial_ref,
9
- test_ref,
10
- unknown_ref,
11
- Params,
12
- LinearForm,
13
- BilinearForm,
14
- ResidualForm,
15
- MixedWeakForm,
16
- compile_bilinear,
17
- compile_linear,
18
- compile_residual,
19
- compile_surface_linear,
20
- compile_mixed_residual,
21
- sdot,
22
- dOmega,
23
- FormContext,
24
- MixedFormContext,
25
- FieldPair,
26
- ElementVector,
27
- vector_load_form,
28
- make_space,
29
- make_space_pytree,
30
- make_hex_basis,
31
- make_hex_basis_pytree,
32
- make_hex_space,
33
- make_hex_space_pytree,
34
- make_hex20_basis,
35
- make_hex20_basis_pytree,
36
- make_hex20_space,
37
- make_hex20_space_pytree,
38
- make_hex27_basis,
39
- make_hex27_basis_pytree,
40
- make_hex27_space,
41
- make_hex27_space_pytree,
42
- make_tet_basis,
43
- make_tet_basis_pytree,
44
- make_tet_space,
45
- make_tet_space_pytree,
46
- make_tet10_basis,
47
- make_tet10_basis_pytree,
48
- make_tet10_space,
49
- make_tet10_space_pytree,
50
- make_element_residual_kernel,
51
- make_element_jacobian_kernel,
52
- element_residual,
53
- element_jacobian,
54
- make_sparsity_pattern,
55
- assemble_functional,
56
- assemble_mass_matrix,
57
- scalar_body_force_form,
58
- make_scalar_body_force_form,
59
- constant_body_force_form,
60
- vector_body_force_form,
61
- BaseMeshPytree,
62
- bbox_predicate,
63
- plane_predicate,
64
- axis_plane_predicate,
65
- slab_predicate,
66
- HexMesh,
67
- HexMeshPytree,
68
- StructuredHexBox,
69
- SurfaceMesh,
70
- SurfaceMeshPytree,
71
- load_gmsh_mesh,
72
- load_gmsh_hex_mesh,
73
- load_gmsh_tet_mesh,
74
- make_surface_from_facets,
75
- TetMesh,
76
- TetMeshPytree,
77
- StructuredTetBox,
78
- StructuredTetTensorBox,
79
- tag_axis_minmax_facets,
80
- HexTriLinearBasis,
81
- HexTriLinearBasisPytree,
82
- HexSerendipityBasis20,
83
- HexSerendipityBasis20Pytree,
84
- HexTriQuadraticBasis27,
85
- HexTriQuadraticBasis27Pytree,
86
- TetLinearBasis,
87
- TetLinearBasisPytree,
88
- TetQuadraticBasis10,
89
- TetQuadraticBasis10Pytree,
90
- MeshData,
91
- BasisData,
92
- SpaceData,
93
- MeshData,
94
- BasisData,
95
- SpaceData,
96
- lame_parameters,
97
- isotropic_3d_D,
98
- spdirect_solve_cpu,
99
- spdirect_solve_gpu,
100
- spdirect_solve_jax,
101
- coo_to_csr,
102
- SparsityPattern,
103
- FluxSparseMatrix,
104
- LinearSolver,
105
- NonlinearSolver,
106
- enforce_dirichlet_dense,
107
- enforce_dirichlet_sparse,
108
- free_dofs,
109
- condense_dirichlet_fluxsparse,
110
- condense_dirichlet_dense,
111
- expand_dirichlet_solution,
112
- cg_solve,
113
- cg_solve_jax,
114
- NonlinearAnalysis,
115
- NewtonLoopConfig,
116
- LoadStepResult,
117
- NewtonSolveRunner,
118
- solve_nonlinear,
119
- LinearAnalysis,
120
- LinearSolveConfig,
121
- LinearStepResult,
122
- LinearSolveRunner,
123
- newton_solve,
124
- SurfaceFormField,
125
- SurfaceFormContext,
126
- vector_surface_load_form,
127
- make_vector_surface_load_form,
128
- assemble_surface_linear_form,
129
- )
130
- from .tools.visualizer import write_vtu, write_displacement_vtu
131
- from .tools.jit import make_jitted_residual, make_jitted_jacobian
132
- from .physics import (
133
- linear_elasticity_form,
134
- vector_body_force_form,
135
- constant_body_force_vector_form,
136
- diffusion_form,
137
- dot,
138
- ddot,
139
- transpose_last2,
140
- sym_grad,
141
- sym_grad_u,
142
- right_cauchy_green,
143
- green_lagrange_strain,
144
- deformation_gradient,
145
- pk2_neo_hookean,
146
- neo_hookean_residual_form,
147
- make_elastic_point_data,
148
- write_elastic_vtu,
149
- make_point_data_displacement,
150
- write_point_data_vtu,
151
- interpolate_at_points,
152
- principal_stresses,
153
- principal_sum,
154
- max_shear_stress,
155
- von_mises_stress,
156
- )
1
+ from __future__ import annotations
2
+
3
+ import importlib
157
4
 
158
5
  __all__ = [
159
6
  "FESpaceBase",
@@ -175,10 +22,13 @@ __all__ = [
175
22
  "compile_residual",
176
23
  "compile_surface_linear",
177
24
  "compile_mixed_residual",
25
+ "outer",
178
26
  "sdot",
179
27
  "dOmega",
180
28
  "FormContext",
181
29
  "MixedFormContext",
30
+ "VolumeContext",
31
+ "SurfaceContext",
182
32
  "FieldPair",
183
33
  "ElementVector",
184
34
  "vector_load_form",
@@ -243,6 +93,7 @@ __all__ = [
243
93
  "vector_surface_load_form",
244
94
  "make_vector_surface_load_form",
245
95
  "assemble_surface_linear_form",
96
+ "tag_axis_minmax_facets",
246
97
  "load_gmsh_mesh",
247
98
  "load_gmsh_hex_mesh",
248
99
  "load_gmsh_tet_mesh",
@@ -307,11 +158,71 @@ __all__ = [
307
158
  "von_mises_stress",
308
159
  ]
309
160
 
161
+ _PHYSICS_EXPORTS = {
162
+ "lame_parameters",
163
+ "isotropic_3d_D",
164
+ "linear_elasticity_form",
165
+ "vector_body_force_form",
166
+ "constant_body_force_vector_form",
167
+ "diffusion_form",
168
+ "dot",
169
+ "ddot",
170
+ "transpose_last2",
171
+ "sym_grad",
172
+ "sym_grad_u",
173
+ "right_cauchy_green",
174
+ "green_lagrange_strain",
175
+ "deformation_gradient",
176
+ "pk2_neo_hookean",
177
+ "neo_hookean_residual_form",
178
+ "make_elastic_point_data",
179
+ "write_elastic_vtu",
180
+ "make_point_data_displacement",
181
+ "write_point_data_vtu",
182
+ "interpolate_at_points",
183
+ "principal_stresses",
184
+ "principal_sum",
185
+ "max_shear_stress",
186
+ "von_mises_stress",
187
+ }
188
+
189
+ _TOOLS_VIS_EXPORTS = {
190
+ "write_vtu",
191
+ "write_displacement_vtu",
192
+ }
193
+
194
+ _TOOLS_JIT_EXPORTS = {
195
+ "make_jitted_residual",
196
+ "make_jitted_jacobian",
197
+ }
198
+
199
+ _CORE_EXPORTS = set(__all__) - _PHYSICS_EXPORTS - _TOOLS_VIS_EXPORTS - _TOOLS_JIT_EXPORTS
200
+
201
+
202
+ def __getattr__(name: str):
203
+ if name in _PHYSICS_EXPORTS:
204
+ module = importlib.import_module(".physics", __name__)
205
+ elif name in _TOOLS_VIS_EXPORTS:
206
+ module = importlib.import_module(".tools.visualizer", __name__)
207
+ elif name in _TOOLS_JIT_EXPORTS:
208
+ module = importlib.import_module(".tools.jit", __name__)
209
+ elif name in _CORE_EXPORTS:
210
+ module = importlib.import_module(".core", __name__)
211
+ else:
212
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
213
+
214
+ value = getattr(module, name)
215
+ globals()[name] = value
216
+ return value
217
+
218
+
219
+ def __dir__():
220
+ return sorted(set(globals()) | set(__all__))
221
+
310
222
 
311
223
  try:
312
224
  from importlib.metadata import version, PackageNotFoundError
313
225
  except ImportError:
314
- # old python
315
226
  from importlib_metadata import version, PackageNotFoundError
316
227
 
317
228
 
@@ -320,21 +231,17 @@ def read_version_from_pyproject():
320
231
  import re
321
232
 
322
233
  root = pathlib.Path(__file__).resolve().parent.parent
323
- # while root != root.parent and depth < max_depth:
324
234
  pyproject_path = root / "pyproject.toml"
325
235
  if pyproject_path.exists():
326
236
  content = pyproject_path.read_text()
327
237
  match = re.search(r'version\s*=\s*"(.*?)"', content)
328
238
  if match:
329
239
  return match.group(1)
330
- # root = root.parent
331
- # depth += 1
332
240
  return "0.0.0"
333
241
 
334
242
 
335
243
  def get_version(package_name):
336
244
  try:
337
- # print("version-", version(package_name))
338
245
  return version(package_name)
339
246
  except PackageNotFoundError:
340
247
  return read_version_from_pyproject()
@@ -1,4 +1,5 @@
1
1
  from .forms import FormContext, MixedFormContext, FieldPair, ElementVector, vector_load_form
2
+ from .context_types import VolumeContext, SurfaceContext
2
3
  from .space import (
3
4
  FESpaceBase,
4
5
  FESpace,
@@ -71,6 +72,7 @@ from .weakform import (
71
72
  compile_mixed_residual,
72
73
  grad,
73
74
  sym_grad,
75
+ outer,
74
76
  dot,
75
77
  sdot,
76
78
  ddot,
@@ -86,6 +88,8 @@ from .weakform import (
86
88
  transpose,
87
89
  log,
88
90
  transpose_last2,
91
+ matmul,
92
+ matmul_std,
89
93
  einsum,
90
94
  )
91
95
  from ..mesh import (
@@ -121,39 +125,56 @@ from .basis import (
121
125
  TetQuadraticBasis10,
122
126
  TetQuadraticBasis10Pytree,
123
127
  )
128
+ import importlib
129
+
124
130
  from ..physics import lame_parameters, isotropic_3d_D
125
131
  from .solver import spdirect_solve_cpu, spdirect_solve_gpu, spdirect_solve_jax, coo_to_csr
126
- from ..solver import (
127
- SparsityPattern,
128
- FluxSparseMatrix,
129
- LinearSolver,
130
- NonlinearSolver,
131
- enforce_dirichlet_dense,
132
- enforce_dirichlet_sparse,
133
- free_dofs,
134
- condense_dirichlet_fluxsparse,
135
- condense_dirichlet_dense,
136
- expand_dirichlet_solution,
137
- cg_solve,
138
- cg_solve_jax,
139
- NonlinearAnalysis,
140
- NewtonLoopConfig,
141
- LoadStepResult,
142
- NewtonSolveRunner,
143
- solve_nonlinear,
144
- LinearAnalysis,
145
- LinearSolveConfig,
146
- LinearStepResult,
147
- LinearSolveRunner,
148
- newton_solve,
149
- )
150
- from ..solver.bc import (
151
- SurfaceFormField,
152
- SurfaceFormContext,
153
- vector_surface_load_form,
154
- make_vector_surface_load_form,
155
- assemble_surface_linear_form,
156
- )
132
+
133
+ _SOLVER_EXPORTS = {
134
+ "SparsityPattern",
135
+ "FluxSparseMatrix",
136
+ "LinearSolver",
137
+ "NonlinearSolver",
138
+ "enforce_dirichlet_dense",
139
+ "enforce_dirichlet_sparse",
140
+ "free_dofs",
141
+ "condense_dirichlet_fluxsparse",
142
+ "condense_dirichlet_dense",
143
+ "expand_dirichlet_solution",
144
+ "cg_solve",
145
+ "cg_solve_jax",
146
+ "NonlinearAnalysis",
147
+ "NewtonLoopConfig",
148
+ "LoadStepResult",
149
+ "NewtonSolveRunner",
150
+ "solve_nonlinear",
151
+ "LinearAnalysis",
152
+ "LinearSolveConfig",
153
+ "LinearStepResult",
154
+ "LinearSolveRunner",
155
+ "newton_solve",
156
+ }
157
+
158
+ _SOLVER_BC_EXPORTS = {
159
+ "SurfaceFormField",
160
+ "SurfaceFormContext",
161
+ "vector_surface_load_form",
162
+ "make_vector_surface_load_form",
163
+ "assemble_surface_linear_form",
164
+ }
165
+
166
+
167
+ def __getattr__(name: str):
168
+ if name in _SOLVER_EXPORTS:
169
+ module = importlib.import_module("..solver", __name__)
170
+ elif name in _SOLVER_BC_EXPORTS:
171
+ module = importlib.import_module("..solver.bc", __name__)
172
+ else:
173
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
174
+
175
+ value = getattr(module, name)
176
+ globals()[name] = value
177
+ return value
157
178
 
158
179
  __all__ = [
159
180
  "FESpace",
@@ -161,6 +182,10 @@ __all__ = [
161
182
  "FESpacePytree",
162
183
  "FormContext",
163
184
  "MixedFormContext",
185
+ "VolumeContext",
186
+ "SurfaceContext",
187
+ "VolumeContext",
188
+ "SurfaceContext",
164
189
  "FieldPair",
165
190
  "ElementVector",
166
191
  "vector_load_form",
@@ -229,6 +254,7 @@ __all__ = [
229
254
  "compile_mixed_residual",
230
255
  "grad",
231
256
  "sym_grad",
257
+ "outer",
232
258
  "dot",
233
259
  "sdot",
234
260
  "ddot",
@@ -244,6 +270,8 @@ __all__ = [
244
270
  "transpose",
245
271
  "log",
246
272
  "transpose_last2",
273
+ "matmul",
274
+ "matmul_std",
247
275
  "einsum",
248
276
  "HexMesh",
249
277
  "HexMeshPytree",