fluxfem 0.1.1a0__py3-none-any.whl → 0.1.4__py3-none-any.whl

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.
@@ -1,4 +1,4 @@
1
- """Numeric helpers (array operators)."""
1
+ """Tensor helpers (array operators)."""
2
2
  from __future__ import annotations
3
3
 
4
4
  from .physics.operators import dot, ddot, sym_grad, transpose_last2
fluxfem/helpers_wf.py CHANGED
@@ -10,11 +10,14 @@ from .core.weakform import (
10
10
  inner,
11
11
  action,
12
12
  gaction,
13
+ outer,
13
14
  I,
14
15
  det,
15
16
  inv,
16
17
  transpose,
17
18
  transpose_last2,
19
+ matmul,
20
+ matmul_std,
18
21
  log,
19
22
  normal,
20
23
  ds,
@@ -30,11 +33,14 @@ __all__ = [
30
33
  "inner",
31
34
  "action",
32
35
  "gaction",
36
+ "outer",
33
37
  "I",
34
38
  "det",
35
39
  "inv",
36
40
  "transpose",
37
41
  "transpose_last2",
42
+ "matmul",
43
+ "matmul_std",
38
44
  "log",
39
45
  "normal",
40
46
  "ds",
fluxfem/mesh/base.py CHANGED
@@ -8,6 +8,11 @@ import jax.numpy as jnp
8
8
 
9
9
  @dataclass
10
10
  class BaseMeshClosure:
11
+ """
12
+ Base mesh container with coordinates, connectivity, and optional tags.
13
+
14
+ Concrete mesh types should implement face_node_patterns() for boundary queries.
15
+ """
11
16
  coords: jnp.ndarray
12
17
  conn: jnp.ndarray
13
18
  cell_tags: Optional[jnp.ndarray] = None
@@ -230,6 +235,7 @@ class BaseMeshClosure:
230
235
 
231
236
  @jax.tree_util.register_pytree_node_class
232
237
  class BaseMeshPytree(BaseMeshClosure):
238
+ """BaseMesh variant that registers as a JAX pytree."""
233
239
  def tree_flatten(self):
234
240
  children = (self.coords, self.conn, self.cell_tags, self.node_tags)
235
241
  return children, {}
@@ -241,4 +247,3 @@ class BaseMeshPytree(BaseMeshClosure):
241
247
 
242
248
 
243
249
  BaseMesh = BaseMeshClosure
244
-
fluxfem/mesh/hex.py CHANGED
@@ -36,6 +36,7 @@ class HexMesh(BaseMesh):
36
36
  @jax.tree_util.register_pytree_node_class
37
37
  @dataclass(eq=False)
38
38
  class HexMeshPytree(BaseMeshPytree):
39
+ """Hex mesh registered as a JAX pytree."""
39
40
  def face_node_patterns(self):
40
41
  return [
41
42
  (0, 1, 2, 3), # -z
fluxfem/mesh/io.py CHANGED
@@ -69,6 +69,7 @@ def load_gmsh_mesh(path: str):
69
69
 
70
70
 
71
71
  def load_gmsh_hex_mesh(path: str):
72
+ """Load a Gmsh mesh and return a HexMesh with optional facets/tags."""
72
73
  mesh, facets, tags = load_gmsh_mesh(path)
73
74
  if not isinstance(mesh, HexMesh):
74
75
  raise ValueError("gmsh mesh is not hexahedral")
@@ -76,6 +77,7 @@ def load_gmsh_hex_mesh(path: str):
76
77
 
77
78
 
78
79
  def load_gmsh_tet_mesh(path: str):
80
+ """Load a Gmsh mesh and return a TetMesh with optional facets/tags."""
79
81
  mesh, facets, tags = load_gmsh_mesh(path)
80
82
  if not isinstance(mesh, TetMesh):
81
83
  raise ValueError("gmsh mesh is not tetrahedral")
@@ -1,45 +1,55 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.1
2
2
  Name: fluxfem
3
- Version: 0.1.1a0
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
- License-File: LICENSE
7
6
  Author: Kohei Watanabe
8
7
  Author-email: koheitech001@gmail.com
9
8
  Requires-Python: >=3.11,<3.14
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
- Classifier: Programming Language :: Python :: 3.13
14
- Requires-Dist: jax (==0.8.2)
15
- 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)
16
15
  Requires-Dist: matplotlib (>=3.10.7,<4.0.0)
17
16
  Requires-Dist: meshio (>=5.3.5,<6.0.0)
18
17
  Requires-Dist: pyvista (>=0.46.4,<0.47.0)
19
18
  Description-Content-Type: text/markdown
20
19
 
20
+ [![PyPI version](https://img.shields.io/pypi/v/fluxfem.svg?cacheSeconds=60)](https://pypi.org/project/fluxfem/)
21
21
  [![License: Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
22
22
  [![Python Version](https://img.shields.io/pypi/pyversions/fluxfem.svg)](https://pypi.org/project/fluxfem/)
23
23
  ![CI](https://github.com/kevin-tofu/fluxfem/actions/workflows/python-tests.yml/badge.svg)
24
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
+
25
27
 
26
28
  # FluxFEM
27
29
  A weak-form-centric differentiable finite element framework in JAX
28
30
 
29
31
  ## Examples and Features
30
- ### Example 1 : Diffusion
31
- <p align="center">
32
- <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;">
33
- </p>
34
-
35
- ## Features
36
- - Built on JAX, enabling automatic differentiation and high-performance execution via grad, jit, vmap, and related transformations.
37
-
38
- - 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>
39
46
 
40
- - Supports two assembly approaches: weak-form-based assembly and a tensor-based (scikit-fem–style) assembly.
41
47
 
42
- - 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.
43
53
 
44
54
  ## Usage
45
55
 
@@ -51,14 +61,18 @@ The first approach offers simplicity and convenience, as mathematical expression
51
61
  However, for more complex operations, the second approach can be easier to implement in practice.
52
62
  This is because the weak-form-based assembly is ultimately transformed into the tensor-based representation internally during computation.
53
63
 
64
+ ## Weak Form Compile Flow
65
+ Weak-form expressions are compiled into an evaluation plan and then executed per element.
66
+
54
67
  ### weak-form-based assembly
55
68
  ```Python
56
69
  import fluxfem as ff
70
+ import fluxfem.helpers_wf as h_wf
57
71
 
58
72
  space = ff.make_hex_space(mesh, dim=3, intorder=2)
59
73
  D = ff.isotropic_3d_D(1.0, 0.3)
60
74
  bilinear_form = ff.BilinearForm.volume(
61
- 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()
62
76
  )
63
77
  K_wf = space.assemble_bilinear_form(
64
78
  bilinear_form.get_compiled(),
@@ -71,11 +85,12 @@ K_wf = space.assemble_bilinear_form(
71
85
  ```Python
72
86
  import fluxfem as ff
73
87
  import numpy as np
88
+ import fluxfem.helpers_ts as h_ts
74
89
 
75
90
  def linear_elasticity_form(ctx: ff.FormContext, D: np.ndarray) -> ff.jnp.ndarray:
76
- Bu = h_num.sym_grad(ctx.trial)
77
- Bv = h_num.sym_grad(ctx.test)
78
- 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)
79
94
 
80
95
 
81
96
  space = ff.make_hex_space(mesh, dim=3, intorder=2)
@@ -88,11 +103,11 @@ K = space.assemble_bilinear_form(linear_elasticity_form, params=D)
88
103
 
89
104
  ## SetUp
90
105
 
91
- You can install **Scikit-Topt** either via **pip** or **Poetry**.
106
+ You can install **FluxFEM** either via **pip** or **Poetry**.
92
107
 
93
108
  #### Supported Python Versions
94
109
 
95
- Scikit-Topt supports **Python 3.10–3.13**:
110
+ FluxFEM supports **Python 3.11–3.13**:
96
111
 
97
112
 
98
113
  **Choose one of the following methods:**
@@ -109,3 +124,4 @@ poetry add fluxfem
109
124
 
110
125
  ## Acknowledgements
111
126
  I acknoldege everythings that made this work possible.
127
+
@@ -1,20 +1,21 @@
1
- fluxfem/__init__.py,sha256=wpnJOQj4PSIzWfYd6R0WjAAxN6V8CV7GfxeZqM1WNjc,8145
2
- fluxfem/core/__init__.py,sha256=NLQmREchOhDqg6kLKrXZhbvVz-4OrZvB_MpIffT9LNk,7464
1
+ fluxfem/__init__.py,sha256=VXd7BM-dOt74bF_W8NumTMlE7lCrz3jTwoCFNZnpDW0,6122
2
+ fluxfem/core/__init__.py,sha256=LzHXumR__i656SEmZuGZa09TqTDltTzMIyBBbN1GOKs,8156
3
3
  fluxfem/core/assembly.py,sha256=yhc14y4XWvmBpiLun2eH9k1mjAsNmpTbHPJS2VJFO3M,25370
4
4
  fluxfem/core/basis.py,sha256=ZxTQUAEC2UBuvxGhiSqAPjVnUwP_nIptY_b9Wn2etak,32113
5
+ fluxfem/core/context_types.py,sha256=QGv1oc_9Crn3vztyPy_uUN0TpmDkgH5HPrhYzZ_kuys,663
5
6
  fluxfem/core/data.py,sha256=_byAZTasIGGwNRU3gqw_ZZR1HMVLJpk9gix2AI3AJWk,1818
6
7
  fluxfem/core/dtypes.py,sha256=WQ_wfJW_R8Mty76mS7h-R2xgCokraEWjsUvjeKYmVJU,118
7
- fluxfem/core/forms.py,sha256=ZxmpmaZa-uTRi-0Dltvn0VkEcXpW4HgNFr8Po0b8JyQ,7264
8
+ fluxfem/core/forms.py,sha256=qDaN750oiH44aSReVbOISBR9IsWSEnsv1gxHB7We_D0,7374
8
9
  fluxfem/core/interp.py,sha256=v9HzkYgQnEqf6GnB9tXqfrNk0N7YsmPcZBfNGNUU3b8,2004
9
10
  fluxfem/core/solver.py,sha256=nNpb90ddZq8Ek6XPerlKzV4YWtC5ZgEcsRv4KeoFIug,3770
10
11
  fluxfem/core/space.py,sha256=jj4koa6_7lBBtXWGrF1CehOBKWg--uUW_7q8pB2EFCk,13902
11
- fluxfem/core/weakform.py,sha256=VnGHc0lWz0zH6pBTRXOtKVPGW0szX2HV6VqAhFcheI8,27113
12
- fluxfem/helpers_num.py,sha256=1Ehi5ur31E5ewrnr-XC2quTk9NFyCKKJdg0n_4i5gyE,222
13
- fluxfem/helpers_wf.py,sha256=X9YUDD9_eBdBRZz-hPhiCvHAyjspfmTuociA-ekI7bw,548
12
+ fluxfem/core/weakform.py,sha256=ux4gZukZZBMO6vUegjOn_oaQ2l-nwQMO9L2D98LFh6E,41249
13
+ fluxfem/helpers_ts.py,sha256=T3HCqXniF116lvznq0b7CDUok5_yZZc8l9XtlE81yvg,221
14
+ fluxfem/helpers_wf.py,sha256=InXhYr0WqyibiNWRJllAPf23sluTyaGSJApbv-Yn8b0,632
14
15
  fluxfem/mesh/__init__.py,sha256=3ECN0qsVzOnEGTHfrWJ2PV7RJUbSboow1ewfpknI4F4,927
15
- fluxfem/mesh/base.py,sha256=NCJxqKLb6AOC2oGN-GfjC8Uu1Mddpa3E10RNYCyLYtI,10214
16
- fluxfem/mesh/hex.py,sha256=37xSQDDIndbz7JfBCSdI9ptV19L4_OZ4XgKfkFRGS00,12373
17
- fluxfem/mesh/io.py,sha256=ZNTXNRB9_tx_J99y-c46ypboQh1IpTHretWXtYWdCag,2834
16
+ fluxfem/mesh/base.py,sha256=cxfv-m-0qQq3UL4aM0YUJEiAyVrKmtSszwe8rE7PQyQ,10448
17
+ fluxfem/mesh/hex.py,sha256=diFF6AngLpA9OllbaPAT00P_0YR4vMVgpc04_IqOLv8,12420
18
+ fluxfem/mesh/io.py,sha256=3Nx5WLFP9gG_Ruks4F7jSTVGnc_i5qcxkLBQkQhsmhk,2984
18
19
  fluxfem/mesh/predicate.py,sha256=7O9kcKYg_OPtwhqYVdA-j9LQYtcG2Nl781UupKm6U-A,1505
19
20
  fluxfem/mesh/surface.py,sha256=mmtePb1ptd9BSbD79oyPnQwiKadpyVO41xSHDr2XylE,9176
20
21
  fluxfem/mesh/tet.py,sha256=Yjmx_2UsCxO_rl0Jr60au5zccBVWLJvAaGEzhLCi_LA,9768
@@ -41,7 +42,7 @@ fluxfem/tools/__init__.py,sha256=S7flze8kfHABc0fdhGgdELzKO8aeBCrDbwRUE3aTGpA,95
41
42
  fluxfem/tools/jit.py,sha256=WVThoNs2XD8ZVCeyLjBgbFaZXHot5RK_RNzvvAjSaew,1110
42
43
  fluxfem/tools/timer.py,sha256=fvMrKqjOT2S_DoGlTYC5L5TtBnoLS4zyiAZtJVJGt0o,22848
43
44
  fluxfem/tools/visualizer.py,sha256=aDqSgtX9xOu120-zCzJfwlCOUmxjL_kJ6kAvj27-H14,3733
44
- fluxfem-0.1.1a0.dist-info/METADATA,sha256=A7vMRRSSnCGpeyRvl0YifhlMrCOv-xTKMpZ76CyTJQI,3794
45
- fluxfem-0.1.1a0.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
46
- fluxfem-0.1.1a0.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
47
- fluxfem-0.1.1a0.dist-info/RECORD,,
45
+ fluxfem-0.1.4.dist-info/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
46
+ fluxfem-0.1.4.dist-info/METADATA,sha256=hn8uJc3N47pozgegKrVvXCbdFhTQX6sbuLLdpnhQT7U,4463
47
+ fluxfem-0.1.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
48
+ fluxfem-0.1.4.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.2.1
2
+ Generator: poetry-core 1.9.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any