From d5749099edee404ef5a210dc66576eac648c250b Mon Sep 17 00:00:00 2001 From: ksagiyam Date: Fri, 19 Apr 2024 20:24:37 +0100 Subject: [PATCH] k --- ufl/algorithms/apply_derivatives.py | 5 ++--- ufl/domain.py | 28 ++++++++++++---------------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/ufl/algorithms/apply_derivatives.py b/ufl/algorithms/apply_derivatives.py index c3a6b3fab..36f3bdf2b 100644 --- a/ufl/algorithms/apply_derivatives.py +++ b/ufl/algorithms/apply_derivatives.py @@ -625,13 +625,12 @@ def reference_value(self, o): if esh == (): esh = (1, ) rdim, gdim = K.ufl_shape - assert rdim == ref_dim - assert gdim == self._var_shape[0] + assert rdim == ref_dim, f"{rdim} != {ref_dim}" + assert gdim == self._var_shape[0], f"{gdim} != {self._var_shape[0]}" for idx in range(int(numpy.prod(esh))): for i in range(gdim): temp = Zero() for j in range(rdim): - g[(dofoffset + idx, ) + (j, )] temp += g[(dofoffset + idx, ) + (j, )] * K[j, i] components.append(temp) dofoffset += int(numpy.prod(esh)) diff --git a/ufl/domain.py b/ufl/domain.py index 2e2b51ee6..73d55616a 100644 --- a/ufl/domain.py +++ b/ufl/domain.py @@ -135,10 +135,15 @@ def __init__(self, *meshes, ufl_id=None, cargo=None): self._ufl_cargo = cargo if cargo is not None and cargo.ufl_id() != self._ufl_id: raise ValueError("Expecting cargo object (e.g. dolfin.Mesh) to have the same ufl_id.") - coordinate_element = meshes[0]._ufl_coordinate_element - self._ufl_coordinate_element = coordinate_element - gdim, = coordinate_element.value_shape - tdim = coordinate_element.cell.topological_dimension() + if any(isinstance(m, MixedMesh) for m in meshes): + raise NotImplementedError("Currently component meshes can not include MixedMesh instances") + # TODO: Should make a "MixedCell" object here: + # currently only support single cell type. + self._ufl_cell, = set(m.ufl_cell() for m in meshes) + gdim, = set(m.geometric_dimension() for m in meshes) + # ReferenceGrad requires topological_dimension of the mixed mesh: + # set tdim to max topological dim for a general mixed mesh (currently not implemented). + tdim = max(m.topological_dimension() for m in meshes) AbstractDomain.__init__(self, tdim, gdim) self._meshes = tuple(meshes) @@ -146,18 +151,9 @@ def ufl_cargo(self): """Return carried object that will not be used by UFL.""" return self._ufl_cargo - def ufl_coordinate_element(self): - """Get the coordinate element.""" - return self._ufl_coordinate_element - def ufl_cell(self): """Get the cell.""" - return self._ufl_coordinate_element.cell - - def is_piecewise_linear_simplex_domain(self): - """Check if the domain is a piecewise linear simplex.""" - ce = self._ufl_coordinate_element - return ce.embedded_superdegree <= 1 and ce in H1 and self.ufl_cell().is_simplex() + return self._ufl_cell def __repr__(self): """Representation.""" @@ -170,7 +166,7 @@ def __str__(self): def _ufl_hash_data_(self): """UFL hash data.""" - return (type(self), self._ufl_id, self._ufl_coordinate_element) + return ("MixedMesh", self._ufl_id) def _ufl_signature_data_(self, renumbering): """UFL signature data.""" @@ -178,7 +174,7 @@ def _ufl_signature_data_(self, renumbering): def _ufl_sort_key_(self): """UFL sort key.""" - typespecific = (self._ufl_id, self._ufl_coordinate_element) + typespecific = (self._ufl_id, ) return (self.geometric_dimension(), self.topological_dimension(), "MixedMesh", typespecific)