diff --git a/hog/forms.py b/hog/forms.py index 4b0d0ef4f1060658c98fa05f3d6494efeb65d092..b959b215a52d2f2f5c48f1d5806e1f221a64510f 100644 --- a/hog/forms.py +++ b/hog/forms.py @@ -84,7 +84,7 @@ Weak formulation geometry, symbolizer, blending=blending, - is_symmetric=trial == test, # type: ignore[comparison-overlap] + is_symmetric=trial == test, docstring=docstring, ) @@ -118,7 +118,7 @@ Weak formulation geometry, symbolizer, blending=blending, - is_symmetric=trial == test, # type: ignore[comparison-overlap] + is_symmetric=trial == test, docstring=docstring, ) @@ -164,7 +164,7 @@ Weak formulation symbolizer, blending=blending, fe_coefficients={"k": coefficient_function_space}, - is_symmetric=trial == test, # type: ignore[comparison-overlap] + is_symmetric=trial == test, docstring=docstring, ) @@ -197,7 +197,7 @@ Note: :math:`a(c) = 1/8 + u^2` is currently hard-coded and the form is intended "The nonlinear-diffusion form does currently not support blending." ) - if trial != test: # type: ignore[comparison-overlap] + if trial != test: raise HOGException( "Trial space must be equal to test space to assemble non-linear diffusion matrix." ) @@ -228,7 +228,7 @@ Note: :math:`a(c) = 1/8 + u^2` is currently hard-coded and the form is intended geometry, symbolizer, blending=blending, - is_symmetric=trial == test, # type: ignore[comparison-overlap] + is_symmetric=trial == test, docstring=docstring, fe_coefficients={"u": coefficient_function_space}, ) @@ -257,7 +257,7 @@ Weak formulation Note: :math:`a(k) = 1/8 + k^2` is currently hard-coded and the form is intended for :math:`k = u`. """ - if trial != test: # type: ignore[comparison-overlap] + if trial != test: raise HOGException( "Trial space must be equal to test space to assemble diffusion matrix." ) @@ -360,7 +360,7 @@ where geometry, symbolizer, blending=blending, - is_symmetric=trial == test, # type: ignore[comparison-overlap] + is_symmetric=trial == test, docstring=docstring, fe_coefficients={"mu": coefficient_function_space}, ) @@ -397,7 +397,7 @@ Weak formulation geometry, symbolizer, blending=blending, - is_symmetric=trial == test, # type: ignore[comparison-overlap] + is_symmetric=trial == test, docstring=docstring, ) @@ -455,7 +455,7 @@ for details. geometry, symbolizer, blending=blending, - is_symmetric=trial == test, # type: ignore[comparison-overlap] + is_symmetric=trial == test, docstring=docstring, ) @@ -476,7 +476,7 @@ def linear_form( where psi a test function and k = k(x) a scalar, external function. """ - if trial != test: # type: ignore[comparison-overlap] + if trial != test: raise HOGException( "Trial space must be equal to test space to assemble linear form (jep this is weird, but linear forms are implemented as diagonal matrices)." ) @@ -654,7 +654,7 @@ where geometry, symbolizer, blending=blending, - is_symmetric=trial == test, # type: ignore[comparison-overlap] + is_symmetric=trial == test, docstring=docstring, fe_coefficients={"mu": coefficient_function_space}, ) @@ -762,7 +762,7 @@ The resulting matrix must be multiplied with a vector of ones to be used as the "wy": velocity_function_space, "wz": velocity_function_space, }, - is_symmetric=trial == test, # type: ignore[comparison-overlap] + is_symmetric=trial == test, docstring=docstring, ) @@ -807,7 +807,7 @@ Weak formulation geometry, symbolizer, blending=blending, - is_symmetric=trial == test, # type: ignore[comparison-overlap] + is_symmetric=trial == test, docstring=docstring, ) @@ -1021,7 +1021,7 @@ Weak formulation ) mat[data.row, data.col] = form - return Form(mat, tabulation, symmetric=trial == test, docstring=docstring) # type: ignore[comparison-overlap] + return Form(mat, tabulation, symmetric=trial == test, docstring=docstring) def zero_form( @@ -1040,6 +1040,6 @@ def zero_form( geometry, symbolizer, blending=blending, - is_symmetric=trial == test, # type: ignore[comparison-overlap] + is_symmetric=trial == test, docstring="", ) diff --git a/hog/forms_boundary.py b/hog/forms_boundary.py index 49a810d1fc4b0967274a3fd57a3c585d9bee8c78..5fde334d33540ce2165cf674eded1374d8f8c48f 100644 --- a/hog/forms_boundary.py +++ b/hog/forms_boundary.py @@ -54,7 +54,7 @@ Weak formulation symbolizer, blending=blending, boundary_geometry=boundary_geometry, - is_symmetric=trial == test, # type: ignore[comparison-overlap] + is_symmetric=trial == test, docstring=docstring, ) @@ -124,7 +124,7 @@ Geometry map: {blending} symbolizer, blending=blending, boundary_geometry=boundary_geometry, - is_symmetric=trial == test, # type: ignore[comparison-overlap] + is_symmetric=trial == test, fe_coefficients={"mu": function_space_mu}, docstring=docstring, ) diff --git a/hog/function_space.py b/hog/function_space.py index 1818c0fc45f061e9f3b644b325fec6b2f20117a8..af4088369061277242670f6742b05fd230a9cdc1 100644 --- a/hog/function_space.py +++ b/hog/function_space.py @@ -131,6 +131,10 @@ class FunctionSpace(ABC): """The number of DoFs per element.""" return len(self.shape(geometry)) + @abstractmethod + def __eq__(self, other: Any) -> bool: + ... + TrialSpace = NewType("TrialSpace", FunctionSpace) TestSpace = NewType("TestSpace", FunctionSpace) @@ -543,6 +547,9 @@ class EnrichedGalerkinFunctionSpace(FunctionSpace): """Returns the number of DoFs per element.""" return len(self.shape(geometry)) + def __eq__(self, other: Any) -> bool: + return type(self) == type(other) + def __str__(self): return f"EnrichedDG" diff --git a/hog/manifold_forms.py b/hog/manifold_forms.py index f3e87d08ba5fcc862cb8c48c71f06df558296ee2..2273bba4680d4174038cd68059588c2b5a14c703 100644 --- a/hog/manifold_forms.py +++ b/hog/manifold_forms.py @@ -59,7 +59,7 @@ Weak formulation ∫ ∇u · G^(-1) · ∇v · (det(G))^0.5 """ - if trial != test: # type: ignore[comparison-overlap] + if trial != test: raise HOGException( "Trial space must be equal to test space to assemble laplace beltrami matrix." ) @@ -135,7 +135,7 @@ Weak formulation ∫ uv · (det(G))^0.5 """ - if trial != test: # type: ignore[comparison-overlap] + if trial != test: raise HOGException( "Trial space must be equal to test space to assemble laplace beltrami matrix." )