neofoam.framework.solver.spec

SolverSpec — immutable solver definition registered once at module import.

Stores only callables; all mutable state lives on SolverRuntime created per instantiate().

neofoam.framework.solver.spec.Solver(name: str) SolverSpec[source]

Create a new SolverSpec instance.

Args:

name: Name of the solver

Returns:

SolverSpec that can be used to decorate operations

Example:

solver = Solver(“SimpleSolver”)

@solver.operation(operation_number=”1.0”) def solve_momentum(self, field1: float) -> FieldUpdates:

pass

class neofoam.framework.solver.spec.SolverSpec(name: str)[source]

Bases: object

Immutable solver definition. Read-only after module import.

Decorator methods store callables only; execution is delegated to SolverRuntime so that multiple runtimes can coexist independently.

config(cls: type) type[source]

Decorator to register solver configuration class.

Usage:

@solver.config @dataclass class MySolverConfig:

tolerance: float = 1e-6

execution_graph_step(func: Callable[[...], tuple[Any, Any]]) Callable[[...], tuple[Any, Any]][source]

Decorator to register execution graph construction step.

initializer(func: Callable[[...], Context]) Callable[[...], Context][source]

Decorator to register solver initializer with dependency injection support.

instantiate(argv: list[Any] | None = None) SolverRuntime[source]

Create a fresh SolverRuntime for one run of this solver.

Args:

argv: Optional command-line arguments for initialization.

Returns:

A new SolverRuntime bound to this spec.

operation(operation_number: str | None = None, depends_on: list[str] | None = None, before: list[str] | None = None, name: str | None = None) Callable[[...], Any][source]

Decorator to register a solver operation.

Stores the raw function — wrapping is deferred to _build_operations_for.