Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move block system code into the base library #560

Merged
merged 26 commits into from
May 20, 2024
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3b244f7
Add space_default_space_type
jrmaddison May 10, 2024
bbff470
Firedrake backend: Set default space type
jrmaddison May 10, 2024
c9b7624
Remove a use of space_new
jrmaddison May 10, 2024
c2b3ffd
Remove action_type argument from matrix_multiply
jrmaddison May 10, 2024
8c7ecca
Access via properties
jrmaddison May 10, 2024
6478af0
Consistent use of MixedSpace
jrmaddison May 10, 2024
7fdcb17
Add space types to MixedSpace
jrmaddison May 10, 2024
d5bb04c
Move MixedSpace into base
jrmaddison May 10, 2024
4e38040
Reuse PETScVecInterface
jrmaddison May 10, 2024
51ca760
Bugfix
jrmaddison May 10, 2024
7a349d0
Move Nullspace, NoneNullspace, and BlockNullspace
jrmaddison May 13, 2024
e7637c9
Move Matrix and BlockMatrix
jrmaddison May 13, 2024
63d26c3
Move PETScInterface, SystemMatrix, and Preconditioner
jrmaddison May 13, 2024
b48daf5
Move System
jrmaddison May 13, 2024
6be9652
Move documentation
jrmaddison May 13, 2024
9413140
Replace System with LinearSolver
jrmaddison May 13, 2024
e3c2ac1
Use the PETSc options dictionary
jrmaddison May 13, 2024
7f2a530
Tidying and fixes
jrmaddison May 13, 2024
0f09448
Add non-Firedrake block system test
jrmaddison May 14, 2024
fb088a3
Move space dimensions onto spaces
jrmaddison May 14, 2024
4e42d45
Sphinx fix
jrmaddison May 14, 2024
3ea0813
Add TypedSpace wrapper class
jrmaddison May 15, 2024
e241744
Tidying
jrmaddison May 16, 2024
1074da8
except ImportError -> except ModuleNotFoundError
jrmaddison May 20, 2024
166c7d0
Tidying
jrmaddison May 20, 2024
7f108a0
Weaken test tolerances
jrmaddison May 20, 2024
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
Next Next commit
Add space_default_space_type
  • Loading branch information
jrmaddison committed May 20, 2024
commit 3b244f7032c5a0598b0699f4804fb30360cc84fa
22 changes: 19 additions & 3 deletions tlm_adjoint/interface.py
Original file line number Diff line number Diff line change
@@ -78,6 +78,7 @@ def call(obj, /, *args, **kwargs):
"SpaceInterface",
"is_space",
"space_comm",
"space_default_space_type",
"space_dtype",
"space_id",
"space_new",
@@ -432,11 +433,14 @@ class SpaceInterface:
"""

prefix = "_tlm_adjoint__space_interface"
names = ("_comm", "_dtype", "_id", "_new")
names = ("_default_space_type", "_comm", "_dtype", "_id", "_new")

def __init__(self):
raise RuntimeError("Cannot instantiate SpaceInterface object")

def _default_space_type(self):
return "primal"

def _comm(self):
raise NotImplementedError("Method not overridden")

@@ -471,6 +475,15 @@ def space_comm(space):
return space._tlm_adjoint__space_interface_comm()


def space_default_space_type(space):
"""
:arg space: A space.
:returns: The default space type associated with the space.
"""

return space._tlm_adjoint__space_interface_default_space_type()


def space_dtype(space):
"""
:arg space: A space.
@@ -498,14 +511,15 @@ def space_id(space):
return space._tlm_adjoint__space_interface_id()


def space_new(space, *, name=None, space_type="primal", static=False,
def space_new(space, *, name=None, space_type=None, static=False,
cache=None):
"""Return a new variable.

:arg space: The space.
:arg name: A :class:`str` name for the variable.
:arg space_type: The space type for the new variable. `'primal'`, `'dual'`,
`'conjugate'`, or `'conjugate_dual'`.
`'conjugate'`, or `'conjugate_dual'`. Defaults to
`space_default_space_type(space)`.
:arg static: Defines whether the new variable is static, meaning that it is
stored by reference in checkpointing/replay, and an associated
tangent-linear variable is zero.
@@ -514,6 +528,8 @@ def space_new(space, *, name=None, space_type="primal", static=False,
:returns: The new variable.
"""

if space_type is None:
space_type = space_default_space_type(space)
if space_type not in {"primal", "conjugate", "dual", "conjugate_dual"}:
raise ValueError("Invalid space type")
return space._tlm_adjoint__space_interface_new(