Skip to content

Commit

Permalink
convert dt to fem.Constant
Browse files Browse the repository at this point in the history
  • Loading branch information
jhdark committed Oct 20, 2023
1 parent b094ab8 commit 8fdc1be
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 1 addition & 4 deletions festim/hydrogen_transport_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def initialise(self):
self.assign_functions_to_species()

self.t = fem.Constant(self.mesh.mesh, 0.0)
self.dt = self.settings.stepsize.get_dt(self.mesh.mesh)

self.define_boundary_conditions()
self.create_formulation()
Expand Down Expand Up @@ -218,10 +219,6 @@ def create_formulation(self):
if len(self.species) > 1:
raise NotImplementedError("Multiple species not implemented yet")

self.dt = F.as_fenics_constant(
self.settings.stepsize.initial_value, self.mesh.mesh
)

self.formulation = 0

for spe in self.species:
Expand Down
12 changes: 12 additions & 0 deletions festim/stepsize.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import festim as F


class Stepsize:
"""
A class for evaluating the stepsize of transient simulations.
Expand All @@ -14,3 +17,12 @@ def __init__(
initial_value,
) -> None:
self.initial_value = initial_value

def get_dt(self, mesh):
"""Defines the dt value
Args:
mesh (dolfinx.mesh.Mesh): the domain mesh
Returns:
fem.Constant: the dt value
"""
return F.as_fenics_constant(self.initial_value, mesh)

0 comments on commit 8fdc1be

Please sign in to comment.