Spaces:
Sleeping
Sleeping
tiffank1802 commited on
Commit ·
7a4a845
1
Parent(s): 724a1fa
Fix Poisson solver: LinearProblem compatibility for different dolfinx versions
Browse files- backend/poisson/solver.py +15 -9
backend/poisson/solver.py
CHANGED
|
@@ -103,15 +103,21 @@ def solve_poisson(params: Dict[str, Any]) -> Dict[str, Any]:
|
|
| 103 |
L = L + ufl.inner(g, v) * ds
|
| 104 |
|
| 105 |
# 5. Résolution
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
"
|
| 113 |
-
|
| 114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
uh = problem.solve()
|
| 116 |
|
| 117 |
computation_time = time.time() - start_time
|
|
|
|
| 103 |
L = L + ufl.inner(g, v) * ds
|
| 104 |
|
| 105 |
# 5. Résolution
|
| 106 |
+
# Essayer avec petsc_options_prefix (versions récentes de dolfinx)
|
| 107 |
+
# sinon sans (versions plus anciennes)
|
| 108 |
+
try:
|
| 109 |
+
problem = LinearProblem(
|
| 110 |
+
a, L,
|
| 111 |
+
bcs=bcs,
|
| 112 |
+
petsc_options_prefix="poisson",
|
| 113 |
+
petsc_options={
|
| 114 |
+
"ksp_type": "preonly",
|
| 115 |
+
"pc_type": "lu",
|
| 116 |
+
},
|
| 117 |
+
)
|
| 118 |
+
except TypeError:
|
| 119 |
+
# Version ancienne de dolfinx sans petsc_options_prefix
|
| 120 |
+
problem = LinearProblem(a, L, bcs=bcs)
|
| 121 |
uh = problem.solve()
|
| 122 |
|
| 123 |
computation_time = time.time() - start_time
|