ldc.LidDrivenCavitySolver#

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

Bases: ABC

Abstract base solver for lid-driven cavity problem.

Handles: - Parameter management (input configuration) - Metrics tracking (output results) - Iteration loop with residual computation - MLflow logging

Subclasses must: - Set Parameters class attribute (e.g., FVParameters) - Implement step() - perform one iteration - Call _init_fields(x, y) after setting up grid - Implement _compute_algebraic_residuals() for Ax-b residuals

Methods

__init__

Initialize solver with parameters.

mlflow_end

End MLflow run and log final metrics.

mlflow_log_artifact

Log an artifact (e.g., saved HDF5 file) to MLflow.

mlflow_start

Start MLflow run and log parameters.

save

Save complete solver state to HDF5 file.

solve

Solve the lid-driven cavity problem using iterative stepping.

step

Perform one iteration/time step of the solver.

Attributes

Parameters = None#
mlflow_end()[source]#

End MLflow run and log final metrics.

mlflow_log_artifact(filepath: str)[source]#

Log an artifact (e.g., saved HDF5 file) to MLflow.

Parameters:
filepathstr

Path to the file to log as artifact.

mlflow_start(experiment_name: str, run_name: str, parent_run_name: str = None)[source]#

Start MLflow run and log parameters.

Parameters:
experiment_namestr

Name of the MLflow experiment.

run_namestr

Name of the run within the experiment.

parent_run_namestr, optional

If specified, creates a nested run under a parent with this name. Parent is created if it doesn’t exist, or resumed if it does.

save(filepath)[source]#

Save complete solver state to HDF5 file.

Saves params, metrics, time_series, and fields for later analysis.

Parameters:
filepathstr or Path

Output file path (use .h5 extension).

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.metrics : Metrics dataclass with solver metrics

Parameters:
tolerancefloat, optional

Convergence tolerance. If None, uses params.tolerance.

max_iterint, optional

Maximum iterations. If None, uses params.max_iterations.

abstractmethod step()[source]#

Perform one iteration/time step of the solver.

Returns:
u, v, pnp.ndarray

Updated velocity and pressure fields