Skip to content

Commit

Permalink
BCs were not updated when only T was changing
Browse files Browse the repository at this point in the history
  • Loading branch information
RemDelaporteMathurin committed Oct 30, 2024
1 parent e1f4fde commit 14c7455
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/festim/boundary_conditions/dirichlet_bc.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,16 @@ def update(self, t: float):
"""Updates the boundary condition value
Args:
t (float): the time
t: the time
"""
if callable(self.value):
arguments = self.value.__code__.co_varnames
if isinstance(self.value_fenics, fem.Constant) and "t" in arguments:
self.value_fenics.value = self.value(t=t)
else:
self.value_fenics.interpolate(self.bc_expr)
elif self.bc_expr is not None:
self.value_fenics.interpolate(self.bc_expr)

Check warning on line 139 in src/festim/boundary_conditions/dirichlet_bc.py

View check run for this annotation

Codecov / codecov/patch

src/festim/boundary_conditions/dirichlet_bc.py#L138-L139

Added lines #L138 - L139 were not covered by tests


class FixedConcentrationBC(DirichletBCBase):
Expand Down
12 changes: 11 additions & 1 deletion src/festim/problem_change_of_var.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ def create_dirichletbc_form(self, bc: festim.FixedConcentrationBC):
function_space_value = bc.species.collapsed_function_space

# create K_S function
Q0 = fem.functionspace(self.mesh.mesh, ("DG", 0))
Q0 = fem.functionspace(
self.mesh.mesh, ("DG", 0)
) # NOTE K_S0 and E_KS could be constants here and don't have to be defined on several materials
K_S0 = fem.Function(Q0)
E_KS = fem.Function(Q0)
for subdomain in self.volume_subdomains:
Expand Down Expand Up @@ -233,3 +235,11 @@ def create_dirichletbc_form(self, bc: festim.FixedConcentrationBC):
)

return form

def update_time_dependent_values(self):
super().update_time_dependent_values()

if self.temperature_time_dependent:
for bc in self.boundary_conditions:
if isinstance(bc, boundary_conditions.FixedConcentrationBC):
bc.update(self.t)

Check warning on line 245 in src/festim/problem_change_of_var.py

View check run for this annotation

Codecov / codecov/patch

src/festim/problem_change_of_var.py#L243-L245

Added lines #L243 - L245 were not covered by tests

0 comments on commit 14c7455

Please sign in to comment.