Răsfoiți Sursa

corr

Signed-off-by: Jean-Michel Batto <jmbatto@eldarsoft.com>
Jean-Michel Batto 2 săptămâni în urmă
părinte
comite
818cc403c2
1 a modificat fișierele cu 23 adăugiri și 16 ștergeri
  1. 23 16
      electrolysis.jl

+ 23 - 16
electrolysis.jl

@@ -332,6 +332,21 @@ function solve_poisson_loop!(
     ls_advection::Bool,
     heat::Bool
 )
+    # =====================================================================
+    # DÉFINITION DE get_pure_float (DÉPLACÉE EN HAUT POUR LES DEUX APPELS PDI)
+    # =====================================================================
+    # Elle "creuse" jusqu'à trouver un nombre, même si c'est Vector{Vector{Float}}
+    function get_pure_float(x::Number)
+        return Float64(x)
+    end
+    function get_pure_float(x::AbstractArray)
+        if isempty(x) return 0.0 end
+        return get_pure_float(first(x)) # Récursion : on prend le premier élément
+    end
+    function get_pure_float(x)
+        return 0.0 # Sécurité pour Nothing ou autre
+    end
+
     update_electrical_conductivity!(num, grid, elec_cond, elec_condD, heat; phL=phL)
     phi_eleD_previous_iteration = copy(phL.phi_eleD)
 
@@ -354,7 +369,7 @@ function solve_poisson_loop!(
             "i_current_mag"::Cstring,   tmp_vec_p1::Ptr{Cdouble}, PDI_OUT::Cint,
             "phi_ele_1D"::Cstring,      phL.phi_eleD::Ptr{Cdouble}, PDI_OUT::Cint,   
             "elec_cond_1D"::Cstring,    elec_condD::Ptr{Cdouble}, PDI_OUT::Cint,  
-            "BC_phi_ele_left"::Cstring, Ref{Cdouble}(BC_phi_ele.left.val)::Ref{Cdouble}, PDI_OUT::Cint,
+            "BC_phi_ele_left"::Cstring, Ref{Cdouble}(get_pure_float(BC_phi_ele.left.val))::Ref{Cdouble}, PDI_OUT::Cint,
             "levelset_p"::Cstring,      grid.LS[num.index_levelset_pdi].u::Ptr{Cdouble}, PDI_OUT::Cint,
             C_NULL::Ptr{Cvoid})::Cint
 
@@ -379,19 +394,6 @@ function solve_poisson_loop!(
         # PREPARATION PDI : MODE PARANOÏAQUE (SÉCURITÉ TYPE & MÉMOIRE)
         # =====================================================================
 
-        # 1. FONCTION DE NETTOYAGE (Recursive)
-        # Elle "creuse" jusqu'à trouver un nombre, même si c'est Vector{Vector{Float}}
-        function get_pure_float(x::Number)
-            return Float64(x)
-        end
-        function get_pure_float(x::AbstractArray)
-            if isempty(x) return 0.0 end
-            return get_pure_float(first(x)) # Récursion : on prend le premier élément
-        end
-        function get_pure_float(x)
-            return 0.0 # Sécurité pour Nothing ou autre
-        end
-
         # 2. EXTRACTION ET CRÉATION DES REFS (Ligne par ligne pour isoler les erreurs)
         # On convertit tout en Float64 PUR
         val_resid_f64 = get_pure_float(residual_val)
@@ -538,7 +540,12 @@ function update_BC_electrical_potential_left!(
 
     # 3. Mise à jour de la Condition Limite (Dirichlet variable)
     # Formule : Potentiel paroi = Ref - Résistance * Courant moyen
-    BC_phi_ele.left.val = phi_ref - mean_j * 0.1
+    new_val = phi_ref - mean_j * 0.1
+    if isa(BC_phi_ele.left.val, AbstractArray)
+        BC_phi_ele.left.val .= new_val
+    else
+        BC_phi_ele.left.val = new_val
+    end
 end
 
 
@@ -554,4 +561,4 @@ end
 
 function handle_special_cells_electrical_potential!(args...) 
     return nothing 
-end
+end