Skip to main content

Connector to allow you to easily add Simvue tracking and monitoring to OpenFOAM simulations.

Project description

Simvue Connectors - OpenFoam


Simvue

Allow easy connection between Simvue and OpenFOAM, allowing for easy tracking and monitoring of CFD simulations in real time.

WebsiteDocumentation

Implementation

A customised OpenfoamRun class has been created which automatically does the following:

  • Uploads the input files stored in the Constant and System directories, as well as the initial conditions in the 0 directory, as input artifacts
  • Uploads the Allrun script as a code artifact
  • Uploads information from the top of the log files, such as the OpenFOAM build used, as metadata
  • Uploads information from the log files before the solve begins to the events log
  • Tracks the residuals being calculated for each parameter as metrics
  • Once complete, uploads all of the outputs for each time step as output artifacts

The OpenfoamRun class also inherits from the Run() class of the Simvue Python API, allowing for further detailed control over how your simulation is tracked.

Installation

To install and use this connector, first create a virtual environment:

python -m venv venv

Then activate it:

source venv/bin/activate

And then use pip to install this module:

pip install simvue-openfoam

Configuration

The service URL and token can be defined as environment variables:

export SIMVUE_URL=...
export SIMVUE_TOKEN=...

or a file simvue.toml can be created containing:

[server]
url = "..."
token = "..."

The exact contents of both of the above options can be obtained directly by clicking the Create new run button on the web UI. Note that the environment variables have preference over the config file.

Usage example

from simvue_openfoam.connector import OpenfoamRun

...

if __name__ == "__main__":

    ...

    # Using a context manager means that the status will be set to completed automatically,
    # and also means that if the code exits with an exception this will be reported to Simvue
    with OpenfoamRun() as run:

        # Specify a run name, along with any other optional parameters:
        run.init(
          name = 'my-openfoam-simulation',                              # Run name
          metadata = {'angle_of_attack': 30},                           # Metadata
          tags = ['fds', 'airfoil', '2D'],                              # Tags
          description = 'OpenFOAM simulation of a 2D airfoil.',         # Description
          folder = '/openfoam/airfoil2D/trial_1'                        # Folder path
        )

        # Set folder details if necessary
        run.set_folder_details(
          metadata = {'simulation_type': 'airfoil2D'},             # Metadata
          tags = ['openfoam'],                                     # Tags
          description = 'OpenFOAM simulations of airfoils'         # Description
        )

        # Can use the base Simvue Run() methods to upload extra information, eg:
        run.save_file(os.path.abspath(__file__), "code")

        # Can add alerts specific to your simulation, eg:
        run.create_metric_threshold_alert(
          name='ux_residuals_too_high',           # Name of Alert
          metric='residuals.initial.Ux',          # Metric to monitor
          frequency=1,                            # Frequency to evaluate rule at (mins)
          rule="is above",                        # Rule to alert on
          threshold=0.1,                          # Threshold to alert on
          notification='email',                   # Notification type
          trigger_abort=True                      # Abort simulation if triggered
        )

        # Launch the OpenFOAM simulation
        run.launch(
            openfoam_case_dir='path/to/my/openfoam/case',   # Path to your OpenFOAM case directory
            upload_as_zip=True,                              # Whether to upload inputs & results as zip files
            )

License

Released under the terms of the Apache 2 license.

Citation

To reference Simvue, please use the information outlined in this citation file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simvue_openfoam-1.0.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simvue_openfoam-1.0.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file simvue_openfoam-1.0.0.tar.gz.

File metadata

  • Download URL: simvue_openfoam-1.0.0.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for simvue_openfoam-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9df99ff85cd335230c7595b4d96edb99b082abe2eeae60981e494ec7a6924eaf
MD5 1f75d0d2eac3710250a561ded7ffda33
BLAKE2b-256 c2e34ac49939e4cf4d14c5134868161d33de8526eebc6e5325c37c1b89f8c9cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for simvue_openfoam-1.0.0.tar.gz:

Publisher: deploy.yaml on simvue-io/connectors-openfoam

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simvue_openfoam-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for simvue_openfoam-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 453bb46c962dde128c2bb5d9e85c6693c70191f7a2fc0802ec7e3868d83ca0b5
MD5 ead86ad907805d9686c5ceddd6667bd8
BLAKE2b-256 df2e8e5a3b7c490b6e0e42b0ebb13a8cccc97214c44a8c5582a7713149ad578e

See more details on using hashes here.

Provenance

The following attestation bundles were made for simvue_openfoam-1.0.0-py3-none-any.whl:

Publisher: deploy.yaml on simvue-io/connectors-openfoam

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page