fluxfem 0.1.3__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.
fluxfem/helpers_wf.py CHANGED
@@ -10,12 +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,
18
19
  matmul,
20
+ matmul_std,
19
21
  log,
20
22
  normal,
21
23
  ds,
@@ -31,12 +33,14 @@ __all__ = [
31
33
  "inner",
32
34
  "action",
33
35
  "gaction",
36
+ "outer",
34
37
  "I",
35
38
  "det",
36
39
  "inv",
37
40
  "transpose",
38
41
  "transpose_last2",
39
42
  "matmul",
43
+ "matmul_std",
40
44
  "log",
41
45
  "normal",
42
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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fluxfem
3
- Version: 0.1.3
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
6
  Author: Kohei Watanabe
@@ -10,8 +10,8 @@ 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)
@@ -22,6 +22,8 @@ Description-Content-Type: text/markdown
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
@@ -44,13 +46,10 @@ Description-Content-Type: text/markdown
44
46
 
45
47
 
46
48
  ## Features
47
- - Built on JAX, enabling automatic differentiation and high-performance execution via grad, jit, vmap, and related transformations.
48
-
49
- - A FEM framework with a weak-form–centric API, emphasizing a smooth transition from theoretical formulations to practical code implementations.
50
-
51
- - Supports two assembly approaches: weak-form-based assembly and a tensor-based (scikit-fem–style) assembly.
52
-
53
- - enables to handle both Linear / Non-Linear analysis with AD in JAX
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.
54
53
 
55
54
  ## Usage
56
55
 
@@ -62,6 +61,9 @@ The first approach offers simplicity and convenience, as mathematical expression
62
61
  However, for more complex operations, the second approach can be easier to implement in practice.
63
62
  This is because the weak-form-based assembly is ultimately transformed into the tensor-based representation internally during computation.
64
63
 
64
+ ## Weak Form Compile Flow
65
+ Weak-form expressions are compiled into an evaluation plan and then executed per element.
66
+
65
67
  ### weak-form-based assembly
66
68
  ```Python
67
69
  import fluxfem as ff
@@ -70,7 +72,7 @@ import fluxfem.helpers_wf as h_wf
70
72
  space = ff.make_hex_space(mesh, dim=3, intorder=2)
71
73
  D = ff.isotropic_3d_D(1.0, 0.3)
72
74
  bilinear_form = ff.BilinearForm.volume(
73
- 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()
74
76
  )
75
77
  K_wf = space.assemble_bilinear_form(
76
78
  bilinear_form.get_compiled(),
@@ -1,20 +1,21 @@
1
- fluxfem/__init__.py,sha256=wpnJOQj4PSIzWfYd6R0WjAAxN6V8CV7GfxeZqM1WNjc,8145
2
- fluxfem/core/__init__.py,sha256=DgGJ1Z8ZPfEFjv-q_srihazOxqcPMyEWM2w495ojmHQ,7490
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=Q2SoOX1KwwPTigJMDUygQnEuKoxBAHh0R3qwI_sf4gY,27470
12
+ fluxfem/core/weakform.py,sha256=ux4gZukZZBMO6vUegjOn_oaQ2l-nwQMO9L2D98LFh6E,41249
12
13
  fluxfem/helpers_ts.py,sha256=T3HCqXniF116lvznq0b7CDUok5_yZZc8l9XtlE81yvg,221
13
- fluxfem/helpers_wf.py,sha256=JUKiA5p_V9NmUdskHYgYYOlsa8xKTZzBkJCoeUqTu1c,574
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.3.dist-info/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
45
- fluxfem-0.1.3.dist-info/METADATA,sha256=FkdJPsdozjTFWGBp3f87EOaRp2IPdo2G2oW1qPCA4-g,4259
46
- fluxfem-0.1.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
47
- fluxfem-0.1.3.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,,