ldc.LidDrivenCavitySolver#

class ldc.LidDrivenCavitySolver(config=None, **kwargs)[source]#

Bases: ABC

Abstract base solver for lid-driven cavity problem.

Handles: - Configuration management - Iteration loop with residual computation - Result storage

Subclasses must: - Set Config and ResultFields class attributes - Implement step() - perform one iteration - Implement _create_result_fields() - create result dataclass - Extend __init__() for solver-specific setup

Methods

__init__

Initialize solver with configuration.

save

Save results to HDF5 file.

solve

Solve the lid-driven cavity problem using iterative stepping.

step

Perform one iteration/time step of the solver.

Attributes

Config = None#
ResultFields = None#
save(filepath)[source]#

Save results to HDF5 file.

Parameters:
filepathstr or Path

Output file path.

solve(tolerance: float = None, max_iter: int = None)[source]#

Solve the lid-driven cavity problem using iterative stepping.

This method implements the common iteration loop with residual calculation. Subclasses implement step() to define one iteration.

Stores results in solver attributes: - self.fields : Fields dataclass with solution fields - self.time_series : TimeSeries dataclass with time series data - self.metadata : Metadata dataclass with solver metadata

Parameters:
tolerancefloat, optional

Convergence tolerance. If None, uses config.tolerance.

max_iterint, optional

Maximum iterations. If None, uses config.max_iterations.

abstractmethod step()[source]#

Perform one iteration/time step of the solver.

This method should: 1. Update the solution fields (u, v, p) 2. Return the updated fields as a tuple (u, v, p)

The fields should be stored as instance variables that can be accessed for residual computation.

Returns:
unp.ndarray

Updated u velocity field

vnp.ndarray

Updated v velocity field

pnp.ndarray

Updated pressure field