Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions festim/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ def volume(self):

@volume.setter
def volume(self, value):
# check that volume is festim.VolumeSubdomain1D
if not isinstance(value, F.VolumeSubdomain1D):
raise TypeError("volume must be of type festim.VolumeSubdomain1D")
# check that volume is festim.VolumeSubdomain
if not isinstance(value, F.VolumeSubdomain):
raise TypeError("volume must be of type festim.VolumeSubdomain")
self._volume = value

@property
Expand All @@ -74,9 +74,11 @@ def value_fenics(self, value):
if value is None:
self._value_fenics = value
return
if not isinstance(value, (fem.Function, fem.Constant, np.ndarray)):
if not isinstance(
value, (fem.Function, fem.Constant, np.ndarray, ufl.core.expr.Expr)
):
raise TypeError(
f"Value must be a dolfinx.fem.Function, dolfinx.fem.Constant, or a np.ndarray not {type(value)}"
f"Value must be a dolfinx.fem.Function, dolfinx.fem.Constant, np.ndarray or a ufl.core.expr.Expr, not {type(value)}"
)
self._value_fenics = value

Expand Down Expand Up @@ -125,6 +127,9 @@ def create_value_fenics(
if isinstance(self.value, (int, float)):
self.value_fenics = F.as_fenics_constant(mesh=mesh, value=self.value)

elif isinstance(self.value, (fem.Function, ufl.core.expr.Expr)):
self.value_fenics = self.value

elif callable(self.value):
arguments = self.value.__code__.co_varnames

Expand Down
Empty file added test/system_tests/__init__.py
Empty file.
Loading