fluxfem 0.1.3__py3-none-any.whl → 0.2.0__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.
Files changed (46) hide show
  1. fluxfem/__init__.py +136 -161
  2. fluxfem/core/__init__.py +172 -41
  3. fluxfem/core/assembly.py +676 -91
  4. fluxfem/core/basis.py +73 -52
  5. fluxfem/core/context_types.py +36 -0
  6. fluxfem/core/dtypes.py +9 -1
  7. fluxfem/core/forms.py +15 -1
  8. fluxfem/core/mixed_assembly.py +263 -0
  9. fluxfem/core/mixed_space.py +348 -0
  10. fluxfem/core/mixed_weakform.py +97 -0
  11. fluxfem/core/solver.py +2 -0
  12. fluxfem/core/space.py +262 -17
  13. fluxfem/core/weakform.py +1503 -312
  14. fluxfem/helpers_wf.py +53 -0
  15. fluxfem/mesh/__init__.py +54 -2
  16. fluxfem/mesh/base.py +322 -8
  17. fluxfem/mesh/contact.py +825 -0
  18. fluxfem/mesh/dtypes.py +12 -0
  19. fluxfem/mesh/hex.py +18 -16
  20. fluxfem/mesh/io.py +8 -4
  21. fluxfem/mesh/mortar.py +3907 -0
  22. fluxfem/mesh/supermesh.py +316 -0
  23. fluxfem/mesh/surface.py +22 -4
  24. fluxfem/mesh/tet.py +10 -4
  25. fluxfem/physics/diffusion.py +3 -0
  26. fluxfem/physics/elasticity/hyperelastic.py +3 -0
  27. fluxfem/physics/elasticity/linear.py +9 -2
  28. fluxfem/solver/__init__.py +42 -2
  29. fluxfem/solver/bc.py +38 -2
  30. fluxfem/solver/block_matrix.py +132 -0
  31. fluxfem/solver/block_system.py +454 -0
  32. fluxfem/solver/cg.py +115 -33
  33. fluxfem/solver/dirichlet.py +334 -4
  34. fluxfem/solver/newton.py +237 -60
  35. fluxfem/solver/petsc.py +439 -0
  36. fluxfem/solver/preconditioner.py +106 -0
  37. fluxfem/solver/result.py +18 -0
  38. fluxfem/solver/solve_runner.py +168 -1
  39. fluxfem/solver/solver.py +12 -1
  40. fluxfem/solver/sparse.py +124 -9
  41. fluxfem-0.2.0.dist-info/METADATA +303 -0
  42. fluxfem-0.2.0.dist-info/RECORD +59 -0
  43. fluxfem-0.1.3.dist-info/METADATA +0 -125
  44. fluxfem-0.1.3.dist-info/RECORD +0 -47
  45. {fluxfem-0.1.3.dist-info → fluxfem-0.2.0.dist-info}/LICENSE +0 -0
  46. {fluxfem-0.1.3.dist-info → fluxfem-0.2.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,303 @@
1
+ Metadata-Version: 2.1
2
+ Name: fluxfem
3
+ Version: 0.2.0
4
+ Summary: FluxFEM: A weak-form-centric differentiable finite element framework in JAX
5
+ License: Apache-2.0
6
+ Author: Kohei Watanabe
7
+ Author-email: koheitech001@gmail.com
8
+ Requires-Python: >=3.12,<3.14
9
+ Classifier: License :: OSI Approved :: Apache Software License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Provides-Extra: cpu
13
+ Provides-Extra: cuda12
14
+ Provides-Extra: petsc
15
+ Requires-Dist: jax (>=0.8.2,<0.9.0) ; extra == "cpu" or extra == "cuda12"
16
+ Requires-Dist: jax-cuda12-pjrt (==0.8.2) ; extra == "cuda12"
17
+ Requires-Dist: jax-cuda12-plugin (==0.8.2) ; extra == "cuda12"
18
+ Requires-Dist: jaxlib (>=0.8.2,<0.9.0) ; extra == "cpu" or extra == "cuda12"
19
+ Requires-Dist: matplotlib (>=3.10.7,<4.0.0)
20
+ Requires-Dist: meshio (>=5.3.5,<6.0.0)
21
+ Requires-Dist: petsc4py (==3.23.6) ; extra == "petsc"
22
+ Requires-Dist: pyproject (>=1!0.1.2,<1!0.2.0)
23
+ Requires-Dist: pyproject-toml (>=0.1.0,<0.2.0)
24
+ Requires-Dist: pyvista (>=0.46.4,<0.47.0)
25
+ Description-Content-Type: text/markdown
26
+
27
+ [![PyPI version](https://img.shields.io/pypi/v/fluxfem.svg?cacheSeconds=60)](https://pypi.org/project/fluxfem/)
28
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
29
+ [![Python Version](https://img.shields.io/pypi/pyversions/fluxfem.svg)](https://pypi.org/project/fluxfem/)
30
+ ![CI](https://github.com/kevin-tofu/fluxfem/actions/workflows/python-tests.yml/badge.svg)
31
+ ![CI](https://github.com/kevin-tofu/fluxfem/actions/workflows/sphinx.yml/badge.svg)
32
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.18055465.svg)](https://doi.org/10.5281/zenodo.18055465)
33
+
34
+
35
+ # FluxFEM
36
+ A weak-form-centric differentiable finite element framework in JAX,
37
+ where variational forms are treated as first-class, differentiable programs.
38
+
39
+ ## Examples and Features
40
+ <table>
41
+ <tr>
42
+ <td align="center"><b>Example 1: Diffusion</b></td>
43
+ <td align="center"><b>Example 2: Neo Neohookean Hyper Elasticity</b></td>
44
+ </tr>
45
+ <tr>
46
+ <td align="center">
47
+ <img src="https://media.githubusercontent.com/media/kevin-tofu/fluxfem/main/assets/diffusion_mms_timeseries.gif" alt="Diffusion-mms" width="400">
48
+ </td>
49
+ <td align="center">
50
+ <img src="https://media.githubusercontent.com/media/kevin-tofu/fluxfem/main/assets/Neo-Hookean-deformedx20000.png" alt="Neo-Hookean" width="400">
51
+ </td>
52
+ </tr>
53
+ </table>
54
+
55
+
56
+ ## Features
57
+ - Built on JAX, enabling automatic differentiation with grad, jit, vmap, and related transformations.
58
+ - Weak-form–centric API that keeps formulations close to code; weak forms are represented as expression trees and compiled into element kernels, enabling automatic differentiation of residuals, tangents, and objectives.
59
+ - Two assembly approaches: tensor-based (scikit-fem–style) assembly and weak-form-based assembly.
60
+ - Handles both linear and nonlinear analyses with AD in JAX.
61
+ - Optional PETSc/PETSc-shell solvers via `petsc4py` for scalable linear solves (add `fluxfem[petsc]`).
62
+
63
+ ## Usage
64
+
65
+ This library provides two assembly approaches.
66
+
67
+ - A tensor-based assembly, where trial and test functions are represented explicitly as element-level tensors and assembled accordingly (in the style of scikit-fem).
68
+ - A weak-form-based assembly, where the variational form is written symbolically and compiled before assembly.
69
+
70
+ The two approaches are functionally equivalent and share the same element-level execution model,
71
+ but they differ in how you author the weak form. The example below mirrors the paper's diffusion
72
+ case and makes the distinction explicit with `jnp`.
73
+
74
+
75
+ ## Assembly Flow
76
+ All expressions are first compiled into an element-level evaluation plan,
77
+ which operates on quadrature-point–major tensors.
78
+ This plan is then executed independently for each element during assembly.
79
+
80
+ As a result, both assembly approaches:
81
+ - use the same quadrature-major (q, a, i) data layout,
82
+ - perform element-local tensor contractions,
83
+ - and are fully compatible with JAX transformations such as `jit`, `vmap`, and automatic differentiation.
84
+
85
+ ### kernel-based assembly (explicit JIT units)
86
+ If you want to control JIT boundaries explicitly, build a JIT-compiled element kernel
87
+ and pass it to `space.assemble`. The kernel must return the integrated element
88
+ contribution (not the quadrature integrand). For untagged raw kernels, pass `kind=`.
89
+
90
+ ```Python
91
+ import fluxfem as ff
92
+ import jax
93
+ import jax.numpy as jnp
94
+
95
+ space = ff.make_hex_space(mesh, dim=1, intorder=2)
96
+
97
+ # bilinear: kernel(ctx) -> (n_ldofs, n_ldofs)
98
+ ker_K = ff.make_element_bilinear_kernel(ff.diffusion_form, 1.0, jit=True)
99
+ K = space.assemble(ff.diffusion_form, 1.0, kernel=ker_K)
100
+
101
+ # linear: kernel(ctx) -> (n_ldofs,)
102
+ def linear_kernel(ctx):
103
+ integrand = ff.scalar_body_force_form(ctx, 2.0)
104
+ wJ = ctx.w * ctx.test.detJ
105
+ return (integrand * wJ[:, None]).sum(axis=0)
106
+
107
+ ker_F = jax.jit(linear_kernel)
108
+ F = space.assemble(ff.scalar_body_force_form, 2.0, kernel=ker_F)
109
+ ```
110
+
111
+ ### tensor-based vs weak-form-based (diffusion example)
112
+
113
+ #### tensor-based assembly
114
+ The tensor-based assembly provides an explicit, low-level formulation with element kernels written using jax.numpy.(`jnp`).
115
+ ```Python
116
+ import fluxfem as ff
117
+ import jax.numpy as jnp
118
+
119
+ @ff.kernel(kind="bilinear", domain="volume")
120
+ def diffusion_form(ctx: ff.FormContext, kappa):
121
+ # ctx.test.gradN / ctx.trial.gradN: (n_qp, n_nodes, dim)
122
+ # output tensor: (n_qp, n_nodes, n_nodes)
123
+ return kappa * jnp.einsum("qia,qja->qij", ctx.test.gradN, ctx.trial.gradN)
124
+
125
+ space = ff.make_hex_space(mesh, dim=3, intorder=2)
126
+ params = ff.Params(kappa=1.0)
127
+ K_ts = space.assemble(diffusion_form, params=params.kappa)
128
+ ```
129
+
130
+ #### weak-form-based assembly
131
+ In the weak-form-based assembly, the variational formulation itself is the primary object.
132
+ The expression below defines a symbolic computation graph, which is later compiled and executed at the element level.
133
+
134
+ ```Python
135
+ import fluxfem as ff
136
+ import fluxfem.helpers_wf as h_wf
137
+
138
+ space = ff.make_hex_space(mesh, dim=3, intorder=2)
139
+ params = ff.Params(kappa=1.0)
140
+
141
+ # u, v are symbolic trial/test fields (weak-form DSL objects).
142
+ # u.grad / v.grad are symbolic nodes (expression tree), not numeric arrays.
143
+ # dOmega() is the integral measure; the whole expression is compiled before assembly.
144
+ form_wf = ff.BilinearForm.volume(
145
+ lambda u, v, p: p.kappa * (v.grad @ u.grad) * h_wf.dOmega()
146
+ ).get_compiled()
147
+
148
+ K_wf = space.assemble(form_wf, params=params)
149
+ ```
150
+
151
+ ### Linear Elasticity assembly (weak-form based assembly)
152
+
153
+ ```Python
154
+ import fluxfem as ff
155
+ import fluxfem.helpers_wf as h_wf
156
+
157
+ space = ff.make_hex_space(mesh, dim=3, intorder=2)
158
+ D = ff.isotropic_3d_D(1.0, 0.3)
159
+
160
+ form_wf = ff.BilinearForm.volume(
161
+ lambda u, v, D: h_wf.ddot(v.sym_grad, D @ u.sym_grad) * h_wf.dOmega()
162
+ ).get_compiled()
163
+
164
+ K = space.assemble(form_wf, params=D)
165
+ ```
166
+
167
+ ### Neo-Hookean residual assembly (weak-form DSL)
168
+ Below is a Neo-Hookean hyperelasticity example written in weak form.
169
+ The residual is expressed symbolically and compiled into element-level kernels executed per element.
170
+ No manual derivation of tangent operators is required; consistent tangents (Jacobians) for Newton-type solvers are obtained automatically via JAX AD.
171
+
172
+ ```Python
173
+ def neo_hookean_residual_wf(v, u, params):
174
+ mu = params["mu"]
175
+ lam = params["lam"]
176
+ F = h_wf.I(3) + h_wf.grad(u) # deformation gradient
177
+ C = h_wf.matmul(h_wf.transpose(F), F)
178
+ C_inv = h_wf.inv(C)
179
+ J = h_wf.det(F)
180
+
181
+ S = mu * (h_wf.I(3) - C_inv) + lam * h_wf.log(J) * C_inv
182
+ dE = 0.5 * (h_wf.matmul(h_wf.grad(v), F) + h_wf.transpose(h_wf.matmul(h_wf.grad(v), F)))
183
+ return h_wf.ddot(S, dE) * h_wf.dOmega()
184
+
185
+ res_form = ff.ResidualForm.volume(neo_hookean_residual_wf).get_compiled()
186
+ ```
187
+
188
+
189
+ ### autodiff + jit compile
190
+
191
+ You can differentiate through the solve and JIT compile the hot path.
192
+ The inverse diffusion tutorial shows this pattern:
193
+
194
+ ```Python
195
+ def loss_theta(theta):
196
+ kappa = jnp.exp(theta)
197
+ u = solve_u_jit(kappa, traction_true)
198
+ diff = u[obs_idx_j] - u_obs[obs_idx_j]
199
+ return 0.5 * jnp.mean(diff * diff)
200
+
201
+ solve_u_jit = jax.jit(solve_u)
202
+ loss_theta_jit = jax.jit(loss_theta)
203
+ grad_fn = jax.jit(jax.grad(loss_theta))
204
+ ```
205
+
206
+ ### Mixed systems
207
+
208
+ Mixed problems can be assembled from residual blocks and solved as a coupled system.
209
+
210
+ ```Python
211
+ import fluxfem as ff
212
+ import jax.numpy as jnp
213
+
214
+ mixed = ff.MixedFESpace({"u": space_u, "p": space_p})
215
+ residuals = ff.make_mixed_residuals(
216
+ u=res_u, # (v, u, params) -> Expr
217
+ p=res_p, # (q, u, params) -> Expr
218
+ )
219
+ problem = ff.MixedProblem(mixed, residuals, params=ff.Params(alpha=1.0))
220
+
221
+ u0 = jnp.zeros(mixed.n_dofs)
222
+ R = problem.assemble_residual(u0)
223
+ J = problem.assemble_jacobian(u0, return_flux_matrix=True)
224
+ ```
225
+
226
+ ### Block assembly
227
+
228
+ For constraints like contact problems (e.g., adding Lagrange multipliers), build
229
+ a block matrix explicitly:
230
+
231
+ ```Python
232
+ from fluxfem import solver as ff_solver
233
+
234
+ # Example blocks from contact coupling
235
+ K_uu = ...
236
+ K_cc = ...
237
+ K_uc = ...
238
+
239
+ blocks = ff_solver.make_block_matrix(
240
+ diag=ff_solver.block_diag(u=K_uu, c=K_cc),
241
+ rel={("u", "c"): K_uc},
242
+ sizes={"u": K_uu.shape[0], "c": K_cc.shape[0]},
243
+ symmetric=True,
244
+ transpose_rule="T",
245
+ )
246
+ ```
247
+
248
+ FluxFEM also provides contact utilities like `ContactSurfaceSpace` to build constraint contributions.
249
+
250
+
251
+ ## Documentation
252
+
253
+ Full documentation, tutorials, and API reference are hosted at [this site](https://fluxfem.readthedocs.io/en/latest/).
254
+
255
+ ## Tutorials
256
+
257
+ - `tutorials/linearelastic_tensile_bar.py` (linear elasticity, weak-form assembly)
258
+ - `tutorials/neo_hookean_cantilever.py` (nonlinear hyperelasticity)
259
+ - `tutorials/thermoelastic_bar_1d.py` / `tutorials/thermoelastic_bar_1d_mixed.py` (thermoelastic coupling)
260
+ - `tutorials/petsc_shell_poisson_demo.py` (PETSc shell solver integration; see also `tutorials/petsc_shell_poisson_pmat_demo.py`)
261
+
262
+ ## Setup
263
+
264
+ You can install **FluxFEM** either via **pip** or **Poetry**.
265
+
266
+ #### Supported Python Versions
267
+
268
+ FluxFEM supports **Python 3.11–3.13**:
269
+
270
+
271
+ **Choose one of the following methods:**
272
+
273
+ ### Using pip
274
+ ```bash
275
+ pip install fluxfem
276
+ pip install "fluxfem[cuda12]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
277
+ ```
278
+
279
+ ### Using poetry
280
+ ```bash
281
+ poetry add fluxfem
282
+ poetry add fluxfem[cuda12]
283
+ ```
284
+
285
+ ## PETSc Integration
286
+
287
+ Optional PETSc-based solvers are available via `petsc4py`. Enable with the extra:
288
+
289
+ ```bash
290
+ poetry add fluxfem --extras "petsc"
291
+ ```
292
+
293
+ Note: newer `petsc4py` expects PETSc builds that include the `PetscRegressor`
294
+ API. If your PETSc build does not have it, `petsc4py` will fail to compile. In
295
+ that case, rebuild PETSc with regressor support or pin `petsc4py` to a version
296
+ compatible with your PETSc build.
297
+
298
+ GPU note: this repo currently tests CUDA via the `cuda12` extra only. Other CUDA
299
+ versions are not covered by CI and may require manual JAX installation.
300
+
301
+ ## Acknowledgements
302
+ I acknowledge the open-source software, libraries, and communities that made this work possible.
303
+
@@ -0,0 +1,59 @@
1
+ fluxfem/__init__.py,sha256=KPEgeWjheIAHQ28MWazyzLCN-lR0khSRltq06Q9tlUg,8022
2
+ fluxfem/core/__init__.py,sha256=BKhJR8dK8oZkX9yW0W8m7u5nHDhnwmUg0wWF3iL4Hm8,10964
3
+ fluxfem/core/assembly.py,sha256=rBQ3RPEVxfCuCnKc9Xxz6vLrRZ9ROO8JNggfV4uGWTc,46070
4
+ fluxfem/core/basis.py,sha256=bh1evqiS5tNG7bqyq7ZzipQR8SBEIM-B7MzJ6_niK0A,32397
5
+ fluxfem/core/context_types.py,sha256=QGv1oc_9Crn3vztyPy_uUN0TpmDkgH5HPrhYzZ_kuys,663
6
+ fluxfem/core/data.py,sha256=_byAZTasIGGwNRU3gqw_ZZR1HMVLJpk9gix2AI3AJWk,1818
7
+ fluxfem/core/dtypes.py,sha256=FnJ98C3yIibaatN-wmLO3ksI6XabA7G3rI_SOxPmko8,251
8
+ fluxfem/core/forms.py,sha256=uC5WxG3h3G7I9FxNRVvA8JLVpJP-QjNZtj8fjxavqVE,7697
9
+ fluxfem/core/interp.py,sha256=v9HzkYgQnEqf6GnB9tXqfrNk0N7YsmPcZBfNGNUU3b8,2004
10
+ fluxfem/core/mixed_assembly.py,sha256=4lL15AsKV4KA-D_mhwc_zXyIhff1fwMkYj4iPWDbDwk,8513
11
+ fluxfem/core/mixed_space.py,sha256=8LZU2VibMdHP4tq_1wrf1rY1LVZo6zZiw8UE6cPaqus,13285
12
+ fluxfem/core/mixed_weakform.py,sha256=1RizZ1KuyCGse3LDbHwCcMHP0YjVKBrwE_USm7COIoQ,2848
13
+ fluxfem/core/solver.py,sha256=OOKiEsW9j4BPCtwgIYyaUHh0Bw5dAd975aGl2izOYqQ,3772
14
+ fluxfem/core/space.py,sha256=XHs0NamEBVNyvaXU6FdIY9xgeY3VU8jiy8cX8qZnOyk,22159
15
+ fluxfem/core/weakform.py,sha256=Sgov4zXfEtYtUASDcy5g1bZu0XsnBMUtQuw1bwj6Abg,70163
16
+ fluxfem/helpers_ts.py,sha256=T3HCqXniF116lvznq0b7CDUok5_yZZc8l9XtlE81yvg,221
17
+ fluxfem/helpers_wf.py,sha256=pA8bprvbdXZL_qourm07xaJAsGyNnAP8wXmJf8fOj-k,2158
18
+ fluxfem/mesh/__init__.py,sha256=u2CzTjFxj_CRbi18FezIDh73k_lan_3wGBifTkdJH4w,2418
19
+ fluxfem/mesh/base.py,sha256=ghsvH8kvwpprmR6x1HkSG0H6QTOpl0CVk4HCBDSIdPY,22716
20
+ fluxfem/mesh/contact.py,sha256=WDwwB0s_Zbd7qAEx4eLGr9_zn2KKh5SS0tfTOgnSTRU,28921
21
+ fluxfem/mesh/dtypes.py,sha256=FnJ98C3yIibaatN-wmLO3ksI6XabA7G3rI_SOxPmko8,251
22
+ fluxfem/mesh/hex.py,sha256=VhH0THJMHPhNtwAvqBjIaeNMzBUd8SWzkih2FcR1NWc,12455
23
+ fluxfem/mesh/io.py,sha256=Nlg0urKVDluX1r2guMjvPWNL-SlS2lOc4eLKuKLex9s,3044
24
+ fluxfem/mesh/mortar.py,sha256=-OhyHkaFEYCOoIvf8GpNUJB0lMGQe7hBGzEQ3rV7zYk,147865
25
+ fluxfem/mesh/predicate.py,sha256=7O9kcKYg_OPtwhqYVdA-j9LQYtcG2Nl781UupKm6U-A,1505
26
+ fluxfem/mesh/supermesh.py,sha256=DNDE3-Tck9KSWIbOWGJ7Dduuag9ofZF_B7PqjNecjtA,10407
27
+ fluxfem/mesh/surface.py,sha256=-xNhs3pLnU5-a8ct8hQTd8YzvjETgTRA3tYK9Dwb-Fw,9791
28
+ fluxfem/mesh/tet.py,sha256=Q-2S-b3N4CF3i40u5tt5mbPn_fYcvCJx4K6Xiyq11-A,10077
29
+ fluxfem/physics/__init__.py,sha256=gUrVF1FSiSVZezqRGvKSTcZDH79Ty3opiJ9-H1gycqY,1426
30
+ fluxfem/physics/diffusion.py,sha256=T3jIGqnuaoSMB8q9x6qNwY23V55-lQGb6ome_WQnOS8,537
31
+ fluxfem/physics/elasticity/__init__.py,sha256=4pAqAstT9T20pY5q417c9FQAarq_T8g2hpqDtrUDkcw,1061
32
+ fluxfem/physics/elasticity/hyperelastic.py,sha256=TvclMK050_h8cO97b3vx2Br8QOoKYzzDfM4nbUfOfL8,3461
33
+ fluxfem/physics/elasticity/linear.py,sha256=JU_LiQoYbABMrJzvFRHKnnCT44iK4WQKZxRu1GLxyq8,2255
34
+ fluxfem/physics/elasticity/materials.py,sha256=f2y7_nY3KMSmD2-G4znondAOvh-XDvJD_-zcE2EZcKw,977
35
+ fluxfem/physics/elasticity/stress.py,sha256=i3TypnLB-Hhd3UsV2tftOCjF1-KNNpnVEy8rYqT2wIM,1135
36
+ fluxfem/physics/operators.py,sha256=LgEvtcDvhskd7BokVsX_wtzceoI2zrLYyB5HWsUBFg4,3009
37
+ fluxfem/physics/postprocess.py,sha256=7NKcSJO_Himw1WTJgM4YWxf1KkjGuBwojxY_0Vwy9Ow,4418
38
+ fluxfem/solver/__init__.py,sha256=gv57yXua8RSsubZ5SbTaXnKALnRdsKOSuCBR7nuBiCo,2337
39
+ fluxfem/solver/bc.py,sha256=IJa9WmAkeLu73fmxppEZRXfB-1o_B-9tQ8uKXZHdxFU,16649
40
+ fluxfem/solver/block_matrix.py,sha256=qJ6rOtiJyxYlSHkzYbi-T_BN7Xfd0drNzXrM8mdq8uo,4187
41
+ fluxfem/solver/block_system.py,sha256=r5nvt2OWGS9iYq0n2G2HB3MM--ThwGsGoUwcM-w6ZFw,17659
42
+ fluxfem/solver/cg.py,sha256=ZP4OcFeB-froIXcg_PVEobf5BYKz5gONALcEpKCbr_k,11101
43
+ fluxfem/solver/dirichlet.py,sha256=tmKpXWP_8v_jIb337dTkvDxsgkOcoE8ViKuZajQn8L4,14875
44
+ fluxfem/solver/history.py,sha256=HhKSmo2B1GaBYEsrifxQxeaeRMiaqm5f6g6DNz5Qb0U,764
45
+ fluxfem/solver/newton.py,sha256=fVqASbzXrQb9ZqjKol2lWioEr7coi4sWaYMGvYDztqc,23444
46
+ fluxfem/solver/petsc.py,sha256=PjCRomFU3BWjwCO_ZAa8dS5sh_OhXvNSZykURmSroRY,14910
47
+ fluxfem/solver/preconditioner.py,sha256=PdjaHUVgwHGUSO29Od04aQtr24cq9XX9atgClfKKZ-8,3578
48
+ fluxfem/solver/result.py,sha256=DLLyaHVJ9NYotDqFD0IHlhxg9Hbs726bepqCG_59t94,3256
49
+ fluxfem/solver/solve_runner.py,sha256=OuEQlxSIhp9ahaRzS45ZWqgq1ztkf-oDcvp394nGZ7g,30417
50
+ fluxfem/solver/solver.py,sha256=sU9z4btnX5pPUAzxFLRusKNGsGg3pu1njRqfkRjQE9I,5640
51
+ fluxfem/solver/sparse.py,sha256=Znn50ncFDrqoWNOwxIvXmcK5WpDtLy5ktvBuavkAFFU,11875
52
+ fluxfem/tools/__init__.py,sha256=S7flze8kfHABc0fdhGgdELzKO8aeBCrDbwRUE3aTGpA,95
53
+ fluxfem/tools/jit.py,sha256=WVThoNs2XD8ZVCeyLjBgbFaZXHot5RK_RNzvvAjSaew,1110
54
+ fluxfem/tools/timer.py,sha256=fvMrKqjOT2S_DoGlTYC5L5TtBnoLS4zyiAZtJVJGt0o,22848
55
+ fluxfem/tools/visualizer.py,sha256=aDqSgtX9xOu120-zCzJfwlCOUmxjL_kJ6kAvj27-H14,3733
56
+ fluxfem-0.2.0.dist-info/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
57
+ fluxfem-0.2.0.dist-info/METADATA,sha256=3RicCvbWhQOUTeQoMgmpYz-q6EznEmYcCn9h63B-Dv0,10931
58
+ fluxfem-0.2.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
59
+ fluxfem-0.2.0.dist-info/RECORD,,
@@ -1,125 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: fluxfem
3
- Version: 0.1.3
4
- Summary: FluxFEM: A weak-form-centric differentiable finite element framework in JAX
5
- License: Apache-2.0
6
- Author: Kohei Watanabe
7
- Author-email: koheitech001@gmail.com
8
- Requires-Python: >=3.11,<3.14
9
- Classifier: License :: OSI Approved :: Apache Software License
10
- Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.11
12
- Classifier: Programming Language :: Python :: 3.12
13
- Requires-Dist: jax (==0.8.2)
14
- Requires-Dist: jaxlib (==0.8.2)
15
- Requires-Dist: matplotlib (>=3.10.7,<4.0.0)
16
- Requires-Dist: meshio (>=5.3.5,<6.0.0)
17
- Requires-Dist: pyvista (>=0.46.4,<0.47.0)
18
- Description-Content-Type: text/markdown
19
-
20
- [![PyPI version](https://img.shields.io/pypi/v/fluxfem.svg?cacheSeconds=60)](https://pypi.org/project/fluxfem/)
21
- [![License: Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
22
- [![Python Version](https://img.shields.io/pypi/pyversions/fluxfem.svg)](https://pypi.org/project/fluxfem/)
23
- ![CI](https://github.com/kevin-tofu/fluxfem/actions/workflows/python-tests.yml/badge.svg)
24
- ![CI](https://github.com/kevin-tofu/fluxfem/actions/workflows/sphinx.yml/badge.svg)
25
-
26
- # FluxFEM
27
- A weak-form-centric differentiable finite element framework in JAX
28
-
29
- ## Examples and Features
30
- <table>
31
- <tr>
32
- <td align="center"><b>Example 1: Diffusion</b></td>
33
- <td align="center"><b>Example 2: Neo Neohookean Hyper Elasticity</b></td>
34
- </tr>
35
- <tr>
36
- <td align="center">
37
- <img src="https://media.githubusercontent.com/media/kevin-tofu/fluxfem/main/assets/diffusion_mms_timeseries.gif" alt="Diffusion-mms" width="400">
38
- </td>
39
- <td align="center">
40
- <img src="https://media.githubusercontent.com/media/kevin-tofu/fluxfem/main/assets/Neo-Hookean-deformedx20000.png" alt="Neo-Hookean" width="400">
41
- </td>
42
- </tr>
43
- </table>
44
-
45
-
46
- ## 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
54
-
55
- ## Usage
56
-
57
- This library provides two assembly approaches.
58
-
59
- - A weak-form-based assembly, where the variational form is written and assembled directly.
60
- - A tensor-based assembly, where trial and test functions are represented explicitly as tensors and assembled accordingly (in the style of scikit-fem).
61
- The first approach offers simplicity and convenience, as mathematical expressions can be written almost directly in code.
62
- However, for more complex operations, the second approach can be easier to implement in practice.
63
- This is because the weak-form-based assembly is ultimately transformed into the tensor-based representation internally during computation.
64
-
65
- ### weak-form-based assembly
66
- ```Python
67
- import fluxfem as ff
68
- import fluxfem.helpers_wf as h_wf
69
-
70
- space = ff.make_hex_space(mesh, dim=3, intorder=2)
71
- D = ff.isotropic_3d_D(1.0, 0.3)
72
- bilinear_form = ff.BilinearForm.volume(
73
- lambda u, v, D: h_wf.ddot(v.sym_grad, D @ u.sym_grad) * h_wf.dOmega()
74
- )
75
- K_wf = space.assemble_bilinear_form(
76
- bilinear_form.get_compiled(),
77
- params=D,
78
- )
79
- ```
80
-
81
- ### tensor-based assembly (scikit-fem-style)
82
-
83
- ```Python
84
- import fluxfem as ff
85
- import numpy as np
86
- import fluxfem.helpers_ts as h_ts
87
-
88
- def linear_elasticity_form(ctx: ff.FormContext, D: np.ndarray) -> ff.jnp.ndarray:
89
- Bu = h_ts.sym_grad(ctx.trial)
90
- Bv = h_ts.sym_grad(ctx.test)
91
- return h_ts.ddot(Bv, D, Bu)
92
-
93
-
94
- space = ff.make_hex_space(mesh, dim=3, intorder=2)
95
- D = ff.isotropic_3d_D(1.0, 0.3)
96
- K = space.assemble_bilinear_form(linear_elasticity_form, params=D)
97
- ```
98
-
99
- ## Documentation
100
-
101
-
102
- ## SetUp
103
-
104
- You can install **FluxFEM** either via **pip** or **Poetry**.
105
-
106
- #### Supported Python Versions
107
-
108
- FluxFEM supports **Python 3.11–3.13**:
109
-
110
-
111
- **Choose one of the following methods:**
112
-
113
- ### Using pip
114
- ```bash
115
- pip install fluxfem
116
- ```
117
-
118
- ### Using poetry
119
- ```bash
120
- poetry add fluxfem
121
- ```
122
-
123
- ## Acknowledgements
124
- I acknoldege everythings that made this work possible.
125
-
@@ -1,47 +0,0 @@
1
- fluxfem/__init__.py,sha256=wpnJOQj4PSIzWfYd6R0WjAAxN6V8CV7GfxeZqM1WNjc,8145
2
- fluxfem/core/__init__.py,sha256=DgGJ1Z8ZPfEFjv-q_srihazOxqcPMyEWM2w495ojmHQ,7490
3
- fluxfem/core/assembly.py,sha256=yhc14y4XWvmBpiLun2eH9k1mjAsNmpTbHPJS2VJFO3M,25370
4
- fluxfem/core/basis.py,sha256=ZxTQUAEC2UBuvxGhiSqAPjVnUwP_nIptY_b9Wn2etak,32113
5
- fluxfem/core/data.py,sha256=_byAZTasIGGwNRU3gqw_ZZR1HMVLJpk9gix2AI3AJWk,1818
6
- fluxfem/core/dtypes.py,sha256=WQ_wfJW_R8Mty76mS7h-R2xgCokraEWjsUvjeKYmVJU,118
7
- fluxfem/core/forms.py,sha256=ZxmpmaZa-uTRi-0Dltvn0VkEcXpW4HgNFr8Po0b8JyQ,7264
8
- fluxfem/core/interp.py,sha256=v9HzkYgQnEqf6GnB9tXqfrNk0N7YsmPcZBfNGNUU3b8,2004
9
- fluxfem/core/solver.py,sha256=nNpb90ddZq8Ek6XPerlKzV4YWtC5ZgEcsRv4KeoFIug,3770
10
- fluxfem/core/space.py,sha256=jj4koa6_7lBBtXWGrF1CehOBKWg--uUW_7q8pB2EFCk,13902
11
- fluxfem/core/weakform.py,sha256=Q2SoOX1KwwPTigJMDUygQnEuKoxBAHh0R3qwI_sf4gY,27470
12
- fluxfem/helpers_ts.py,sha256=T3HCqXniF116lvznq0b7CDUok5_yZZc8l9XtlE81yvg,221
13
- fluxfem/helpers_wf.py,sha256=JUKiA5p_V9NmUdskHYgYYOlsa8xKTZzBkJCoeUqTu1c,574
14
- 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
18
- fluxfem/mesh/predicate.py,sha256=7O9kcKYg_OPtwhqYVdA-j9LQYtcG2Nl781UupKm6U-A,1505
19
- fluxfem/mesh/surface.py,sha256=mmtePb1ptd9BSbD79oyPnQwiKadpyVO41xSHDr2XylE,9176
20
- fluxfem/mesh/tet.py,sha256=Yjmx_2UsCxO_rl0Jr60au5zccBVWLJvAaGEzhLCi_LA,9768
21
- fluxfem/physics/__init__.py,sha256=gUrVF1FSiSVZezqRGvKSTcZDH79Ty3opiJ9-H1gycqY,1426
22
- fluxfem/physics/diffusion.py,sha256=gBRKMuhWGnp7wSlbqYKn2WDKvBrVdtCQKV8-qBabmw4,462
23
- fluxfem/physics/elasticity/__init__.py,sha256=4pAqAstT9T20pY5q417c9FQAarq_T8g2hpqDtrUDkcw,1061
24
- fluxfem/physics/elasticity/hyperelastic.py,sha256=uDZIgSeVJ1JgIf5aEFzFyng6qcDHP-seoHNH_aUA4Zg,3364
25
- fluxfem/physics/elasticity/linear.py,sha256=upiX8Qq5v8J0Y-Lhq8OsIFnwQ_AnJc9nJj0g0vWeNcg,2074
26
- fluxfem/physics/elasticity/materials.py,sha256=f2y7_nY3KMSmD2-G4znondAOvh-XDvJD_-zcE2EZcKw,977
27
- fluxfem/physics/elasticity/stress.py,sha256=i3TypnLB-Hhd3UsV2tftOCjF1-KNNpnVEy8rYqT2wIM,1135
28
- fluxfem/physics/operators.py,sha256=LgEvtcDvhskd7BokVsX_wtzceoI2zrLYyB5HWsUBFg4,3009
29
- fluxfem/physics/postprocess.py,sha256=7NKcSJO_Himw1WTJgM4YWxf1KkjGuBwojxY_0Vwy9Ow,4418
30
- fluxfem/solver/__init__.py,sha256=WkQRDWVIxqXuRGrbizl0KVkr7a_yY0jWlsTDI66gaiE,1133
31
- fluxfem/solver/bc.py,sha256=EYrvQbTMQG2WxHbJYJD2nefxwrpiGS7p8ant6R3APgU,15555
32
- fluxfem/solver/cg.py,sha256=3fLtK3oUpR7lQtRPPtE64-PHUjeIp3pDuMZZqVdCXfk,8974
33
- fluxfem/solver/dirichlet.py,sha256=MCXgpJ9lAF7NrK2NeuCxVWgOVfCiPeswIYhbadkwh-Q,3982
34
- fluxfem/solver/history.py,sha256=HhKSmo2B1GaBYEsrifxQxeaeRMiaqm5f6g6DNz5Qb0U,764
35
- fluxfem/solver/newton.py,sha256=aeSQ1ET9dc-xU6HJWn6KNrEg0FA49nSXsoaYuW5BTvM,16251
36
- fluxfem/solver/result.py,sha256=LDtazqofyBmA0pd3zE5eadgKwW053HRcOwJ5k7ClbsA,2357
37
- fluxfem/solver/solve_runner.py,sha256=MCwmHUKnJCX_mFDPFKNp-_yMbviWln5s56ENWZvOj4c,20974
38
- fluxfem/solver/solver.py,sha256=kqXz2qW50gyyFQagUePgNiFcgsLVA94H99_8sHZWiyo,5162
39
- fluxfem/solver/sparse.py,sha256=wyT_XBIMYD2Nrw_ko8FkaPzLWnLm25M41wF2Z2YAbZk,7550
40
- fluxfem/tools/__init__.py,sha256=S7flze8kfHABc0fdhGgdELzKO8aeBCrDbwRUE3aTGpA,95
41
- fluxfem/tools/jit.py,sha256=WVThoNs2XD8ZVCeyLjBgbFaZXHot5RK_RNzvvAjSaew,1110
42
- fluxfem/tools/timer.py,sha256=fvMrKqjOT2S_DoGlTYC5L5TtBnoLS4zyiAZtJVJGt0o,22848
43
- 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,,