Skip to content

Commit 58d92fc

Browse files
committed
Initial commit of openfoam connector
1 parent 050408a commit 58d92fc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+141874
-539
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Change log
2+
3+
## [v1.0.0](https://github.com/simvue-io/connectors-openfoam/releases/tag/v1.0.0) - 2025-03-07
4+
5+
* Initial release of OpenFOAM Connector.

README.md

Lines changed: 11 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</p>
1212

1313
<p align="center">
14-
This is a template repository which allows you to quickly create new Connectors which provide Simvue tracking and monitoring functionality to Non-Python simulations.
14+
Allow easy connection between Simvue and OpenFOAM, allowing for easy tracking and monitoring of CFD simulations in real time.
1515
</p>
1616

1717
<div align="center">
@@ -25,65 +25,17 @@ This is a template repository which allows you to quickly create new Connectors
2525
<a href="https://docs.simvue.io"><b>Documentation</b></a>
2626
</h3>
2727

28-
## How to use this template
29-
30-
### Naming your connector
31-
First, make a name for your new connector. Typically, the module name is of the form `simvue-{software_name}`, and the connector class itself is of the form `{SoftwareName}Run`. Update the `pyproject.toml` file with the name of your module, and also update the directory currently called `simvue_template` with your module name.
32-
33-
### Creating the code
34-
Your connector class should be made in the `connector.py` file inside your module, with any extra functionality which it needs to work (but you don't want inside the class itself) put in files inside the `extras` directory. The connector should inherit from the `WrappedRun` class provided by the `simvue-connector` module, and should use `multiparser` to track and parse output files as they are being written. See an example in the [connectors-generic repository](https://github.com/simvue-io/connectors-generic), or check out any of our premade connectors for ideas:
35-
36-
* [FDS](https://github.com/simvue-io/connectors-fds)
37-
38-
Also look at the `CONTRIBUTING.md` file for expected coding standards.
39-
40-
41-
### Writing examples
42-
In the `examples` directory, please provide at least one example of your connector being used to track your simulation software. Create this example inside a function so that it can be used in the integration tests. If your software is difficult to install, you may want to provide setup instructions for using a Docker container or similar, as well as instructions assuming that the software is already installed on the user's system.
43-
44-
### Writing tests
45-
You should create two types of tests:
46-
47-
* Unit tests: Check each element of your connector independently, such as file parsers and callbacks, each method etc. You should use `pytest`, and use Mockers to mock out any functionality which your simulation software would typically provide so that the simulation software itself is **not** required to run these tests.
48-
* Integration tests: These check the end-to-end functionality of your connector when used with the actual simulation software. You should parametrize the test to include offline mode, as well as online. You can use the example(s) which you created earlier as the basis for these tests.
49-
50-
### CI Workflows
51-
Inside the `.github` directory, there are a number of workflows already created. You should adit these to work for your connector. They include:
52-
53-
* `test_macos`, `test_ubuntu`, `test_windows`: These run the unit tests, should not need to be altered
54-
* `test_integration`: These run the integration tests, you will need to provide a docker container to use and whatever installation steps are required for your case
55-
* `deploy`: Automates deployment to test-PyPI and PyPI for tagged releases (see below). You need to update the module names in this file - see the curly brackets.
56-
57-
### Deployment
58-
When you are happy with your connector and are ready to deploy it to PyPI for the first time, you need to do the following:
59-
60-
* Install `poetry` and `twine` if you haven't already: `pip install poetry twine`
61-
* Check your `pyproject.toml` file is valid by running `poetry check`
62-
* Install your module: `poetry install`
63-
* Build the distribution: `poetry build`
64-
* Go to `test.pypi.org`, create an account, and get a token
65-
* Upload your package with Twine: `twine upload -r testpypi dist/*`
66-
* Enter the token when prompted
67-
* Go to `https://test.pypi.org/project/{your-package-name}`, check it has been published
68-
* Click 'Manage Project'
69-
* If you wish to enable automatic deployments, click 'Publishing' -> 'Add a new publisher' and fill in the details for your repository, setting Workflow name to `deploy.yaml` and Environment name to `test_pypi`
70-
71-
If this was all successful, repeat with the real PyPI instance at `pypi.org`, using `twine upload dist/*`, and setting the Environment name in the publisher settings to `pypi`.
72-
73-
From now on, you can do deployments automatically. Simply:
74-
75-
* Update the `pyproject.toml` with a new version number, eg `v1.0.1`
76-
* Update the CHANGELOG to reflect your newest changes
77-
* Tag a branch with a semantic version number, eg `git tag v1.0.1`
78-
* Push the tag: `git push origin v1.0.1`
79-
80-
This should automatically start the deployment workflow - check that it completes successfully on the Github UI.
28+
## Implementation
29+
A customised `OpenfoamRun` class has been created which automatically does the following:
8130

82-
### Updating the README
83-
When finished, delete all of the information above under the 'How to use this template' heading. Then update the information below to be relevant for your connector:
31+
* Uploads the input files stored in the Constant and System directories, as well as the initial conditions in the 0 directory, as input artifacts
32+
* Uploads the Allrun script as a code artifact
33+
* Uploads information from the top of the log files, such as the OpenFOAM build used, as metadata
34+
* Uploads information from the log files before the solve begins to the events log
35+
* Tracks the residuals being calculated for each parameter as metrics
36+
* Once complete, uploads all of the outputs for each time step as output artifacts
8437

85-
## Implementation
86-
{List here how your Connector works, and the things about the simulation it tracks by default.}
38+
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.
8739

8840
## Installation
8941
To install and use this connector, first create a virtual environment:
@@ -96,7 +48,7 @@ source venv/bin/activate
9648
```
9749
And then use pip to install this module:
9850
```
99-
pip install {your_module_name_here}
51+
pip install simvue-openfoam
10052
```
10153

10254
## Configuration

examples/activate_vents.fds

Lines changed: 0 additions & 47 deletions
This file was deleted.

examples/airFoil2D/0/U

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*--------------------------------*- C++ -*----------------------------------*\
2+
========= |
3+
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4+
\\ / O peration | Website: https://openfoam.org
5+
\\ / A nd | Version: 10
6+
\\/ M anipulation |
7+
\*---------------------------------------------------------------------------*/
8+
FoamFile
9+
{
10+
format ascii;
11+
class volVectorField;
12+
object U;
13+
}
14+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
15+
16+
dimensions [0 1 -1 0 0 0 0];
17+
18+
internalField uniform (25.75 3.62 0);
19+
20+
boundaryField
21+
{
22+
inlet
23+
{
24+
type freestreamVelocity;
25+
freestreamValue $internalField;
26+
}
27+
28+
outlet
29+
{
30+
type freestreamVelocity;
31+
freestreamValue $internalField;
32+
}
33+
34+
walls
35+
{
36+
type noSlip;
37+
}
38+
39+
frontAndBack
40+
{
41+
type empty;
42+
}
43+
}
44+
45+
// ************************************************************************* //

examples/airFoil2D/0/nuTilda

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*--------------------------------*- C++ -*----------------------------------*\
2+
========= |
3+
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4+
\\ / O peration | Website: https://openfoam.org
5+
\\ / A nd | Version: 10
6+
\\/ M anipulation |
7+
\*---------------------------------------------------------------------------*/
8+
FoamFile
9+
{
10+
format ascii;
11+
class volScalarField;
12+
object nuTilda;
13+
}
14+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
15+
16+
dimensions [0 2 -1 0 0 0 0];
17+
18+
internalField uniform 0.14;
19+
20+
boundaryField
21+
{
22+
inlet
23+
{
24+
type freestream;
25+
freestreamValue uniform 0.14;
26+
}
27+
28+
outlet
29+
{
30+
type freestream;
31+
freestreamValue uniform 0.14;
32+
}
33+
34+
walls
35+
{
36+
type fixedValue;
37+
value uniform 0;
38+
}
39+
40+
frontAndBack
41+
{
42+
type empty;
43+
}
44+
}
45+
46+
// ************************************************************************* //

examples/airFoil2D/0/nut

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*--------------------------------*- C++ -*----------------------------------*\
2+
========= |
3+
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4+
\\ / O peration | Website: https://openfoam.org
5+
\\ / A nd | Version: 10
6+
\\/ M anipulation |
7+
\*---------------------------------------------------------------------------*/
8+
FoamFile
9+
{
10+
format ascii;
11+
class volScalarField;
12+
object nut;
13+
}
14+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
15+
16+
dimensions [0 2 -1 0 0 0 0];
17+
18+
internalField uniform 0.14;
19+
20+
boundaryField
21+
{
22+
inlet
23+
{
24+
type freestream;
25+
freestreamValue uniform 0.14;
26+
}
27+
28+
outlet
29+
{
30+
type freestream;
31+
freestreamValue uniform 0.14;
32+
}
33+
34+
walls
35+
{
36+
type nutUSpaldingWallFunction;
37+
value uniform 0;
38+
}
39+
40+
frontAndBack
41+
{
42+
type empty;
43+
}
44+
}
45+
46+
// ************************************************************************* //

examples/airFoil2D/0/p

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*--------------------------------*- C++ -*----------------------------------*\
2+
========= |
3+
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4+
\\ / O peration | Website: https://openfoam.org
5+
\\ / A nd | Version: 10
6+
\\/ M anipulation |
7+
\*---------------------------------------------------------------------------*/
8+
FoamFile
9+
{
10+
format ascii;
11+
class volScalarField;
12+
object p;
13+
}
14+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
15+
16+
dimensions [0 2 -2 0 0 0 0];
17+
18+
internalField uniform 0;
19+
20+
boundaryField
21+
{
22+
inlet
23+
{
24+
type freestreamPressure;
25+
freestreamValue $internalField;
26+
}
27+
28+
outlet
29+
{
30+
type freestreamPressure;
31+
freestreamValue $internalField;
32+
}
33+
34+
walls
35+
{
36+
type zeroGradient;
37+
}
38+
39+
frontAndBack
40+
{
41+
type empty;
42+
}
43+
}
44+
45+
// ************************************************************************* //

examples/airFoil2D/Allclean

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
cd ${0%/*} || exit 1 # Run from this directory
3+
4+
# Clean time directories only
5+
6+
rm -rf *[1-9]*
7+
rm -f log.*
8+
9+
#------------------------------------------------------------------------------

examples/airFoil2D/Allrun

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
cd ${0%/*} || exit 1 # Run from this directory
3+
4+
# Source tutorial run functions
5+
. $WM_PROJECT_DIR/bin/tools/RunFunctions
6+
7+
application=$(getApplication)
8+
9+
runApplication $application
10+
11+
#------------------------------------------------------------------------------
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*--------------------------------*- C++ -*----------------------------------*\
2+
========= |
3+
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4+
\\ / O peration | Website: https://openfoam.org
5+
\\ / A nd | Version: 10
6+
\\/ M anipulation |
7+
\*---------------------------------------------------------------------------*/
8+
FoamFile
9+
{
10+
format ascii;
11+
class dictionary;
12+
location "constant";
13+
object momentumTransport;
14+
}
15+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
16+
17+
simulationType RAS;
18+
19+
RAS
20+
{
21+
model SpalartAllmaras;
22+
23+
turbulence on;
24+
25+
printCoeffs on;
26+
}
27+
28+
// ************************************************************************* //

0 commit comments

Comments
 (0)