From b5ce6befa1ede3c9f3ba0136ded2abf0e812a410 Mon Sep 17 00:00:00 2001 From: Francesco Fiusco Date: Mon, 16 Jun 2025 16:31:30 +0200 Subject: [PATCH 01/17] WIP refactoring w/ foundation version --- content/index.rst | 1 + content/introduction.rst | 25 +-- content/workflow.rst | 365 +++++++++++++++++++-------------------- 3 files changed, 189 insertions(+), 202 deletions(-) diff --git a/content/index.rst b/content/index.rst index 3f2c5f5..c060084 100644 --- a/content/index.rst +++ b/content/index.rst @@ -87,6 +87,7 @@ Schedule About the course ---------------- + See also -------- diff --git a/content/introduction.rst b/content/introduction.rst index 43be27b..f863782 100644 --- a/content/introduction.rst +++ b/content/introduction.rst @@ -21,7 +21,7 @@ OpenFOAM Introduction What is OpenFOAM ? ------------------ -- OpenFOAM® (for “Open-source Field Operation And Manipulation”) is an open source Computation Fluid Dynamics (CFD) solve released and developed primarily by OpenCFD Ltd since 2004. +- OpenFOAM® (for “Open-source Field Operation And Manipulation”) is an open source general solver of Partial differential equations (PDEs) via the finite volume method. It is particularly popular in the computational fluid dynamics (CFD) community. - It has a large user base across most areas of engineering and science, from both commercial and academic organizations. @@ -33,14 +33,14 @@ Different variants of OpenFOAM There are two main variants of OpenFOAM: - OpenCFD Ltd version (`www.openfoam.com `_): + OpenCFD Ltd aka ESI version (`www.openfoam.com `_): - New versions released twice a year (June-December) - Versions are named as (vYYMM) e.g. v1912 - Website: https://www.openfoam.com OpenFOAM foundation version (`www.openfoam.org `_): - No defined date for new release - - Versions are named with with two digits like 4.1 + - Semantic versioning is used. The most recent version is 12. - Website: https://openfoam.org @@ -57,26 +57,19 @@ It depends on the features you want to use - If both include the features you need, do some performance and accuracy benchmarks to see which one is better - Otherwise it is just matter of taste! -We will be using the OpenCFD Ltd version with vXXXXXX for the training - OpenFOAM executables -------------------- -Unlike many other software, OpenFOAM does not have a unique executable. -Once compiled, a large number of excutebles is generated and they fall into two categories: +Historically, unlike many other software, OpenFOAM does not have a unique executable. +Once compiled, a large number of executables is generated, which fall into two categories: - **solver**: that is designed to solve a specific continuum mechanics problem - - **utility**: that is designed to perform tasks that involve data manipulation. - -For every solver, mesh generation etc. there is a separate executable! -You should run the right executable according to the solver you are using! -Check the documentation to see recommended solvers for different cases. - -- ‘simpleFoam’: if you use SIMPLE algorithm -- ‘icoFoam’: if you use PISO algorithm for laminar flow -- ... + - **utility**: that is designed to perform tasks that involve data manipulation, mesh generation/conversion, etc. +This is the case for the ESI version of OpenFOAM and used to be for OpenFOAM foundation until version 10. +From OpenFOAM 11 onwards, a radical shift of paradigm has taken place: so-called `modular `__ +solvers have been introduced OpenFOAM vs commercial software ------------------------------- diff --git a/content/workflow.rst b/content/workflow.rst index 3265a7c..bb21722 100644 --- a/content/workflow.rst +++ b/content/workflow.rst @@ -5,8 +5,8 @@ Workflow .. questions:: - - What is - - What problem do + - How are OpenFOAM cases organised? + - What files do I need to create to generate a test case? .. objectives:: @@ -24,46 +24,54 @@ Case structure To setup a case, you need to have at least 3 directories in your case directory, namely **system**, **constant** and **** (normally **0**). -.. code:: bash +.. code:: terminal $ ls 0 constant system -OpenFOAM cases are configured using plain text input files located across the three directories, in each input file, OpenFOAM uses a plain text dictionary format with keywords and values +OpenFOAM cases are configured using plain text input files located across the three directories. In each input file, OpenFOAM uses a plain text dictionary format with keywords and values -**system**: contains input files for grid generators and solvers +**system** contains input files for grid generators and solvers. Files commonly found in this folder include the following: - - ``controlDict``: the main simulation control parameters. This includes, e.g. timing information, write format, and optional libraries that can be loaded at run time - - ``fvSchemes``: the selection of the numerical schemes - - ``fvSolution``: the iterative solver and pressure-velocity coupling parameters - - ``fvOptions``: user-specified finite volume options. Many OpenFOAM applications contain equation systems that can be manipulated at run time. These provide, e.g. additional source/sink terms, or enforce constraints. - - ``blockMeshDict``: to control the block-structrued mesher blockMesh - - ``snappyHexMeshDict``: to set the parameters for snappyHexMesh, another mesher shipped with OpenFOAM - - ``decomposeParDict`` : to set the parameters of the domain decomposition used for running OpenFOAM in parallel + - ``controlDict``: the main simulation control parameters. This includes e.g. the type of solver, timing information, write format, and optional libraries that can be loaded at run time; + - ``fvSchemes``: the selection of the numerical schemes used to discretise the terms in the governing equations; + - ``fvSolution``: the iterative solver and pressure-velocity coupling parameters, as well as residual controls; + - ``blockMeshDict``: to control the block-structured mesher blockMesh; + - ``snappyHexMeshDict``: to set the parameters for snappyHexMesh, another mesher shipped with OpenFOAM used to generate hex-dominant meshes of complex geometries; + - ``decomposeParDict`` : to set the parameters of the domain decomposition used for running OpenFOAM in parallel. - ... +.. note:: + + Of these, the first one is always needed, the following two are needed when the case is run, ``blockMeshDict`` and ``snappyHexMeshDict`` are needed in the meshing phase. + ``decomposeParDict`` is needed both at mesh-time and runtime in case of parallel processing. + **constant**: Contains values that are constant during simulation like transport properties of the fluid (viscosity models) and mesh coordinates - - ``polyMesh``: where the computational mesh is stored - - ``transportProperties``: the material properties of the fluid - - ``turbulenceProperties``: the turbulence modelling + - ``polyMesh``: where the computational mesh is stored, as generated by the mesher; + - ``physicalProperties``: the material properties of the fluid, such as density and viscosity; + - ``momentumTransport``: turbulence modelling and rheological properties. - ... -****: contains initial fields of the flow e.g. velocity, pressure etc. and boundary conditions +**0**: contains initial fields of the flow e.g. velocity, pressure etc. and boundary conditions + + - U; + - p; + - ... -Additional directories can be generated, depending on user cases, most common ones include e.g.: +Additional directories can be generated, depending on use cases. The most common ones include: - : field predictions as a function of iteration count or time - postProcessing: data typically generated by function objects - data conversion, e.g. VTK -A typical workflow for an OpenFOAM case is schematically shown below +A typical workflow for an OpenFOAM case is schematically shown below: -.. code:: bash +.. code:: text Start | @@ -77,14 +85,14 @@ A typical workflow for an OpenFOAM case is schematically shown below snappyHexMesh // create complex mesh (set by system/snappyHexMeshDict) | V - simpleFoam // run application(OpenFOAM solver) (set by system/controlDict) + foamRun // run application(OpenFOAM solver) (set by system/controlDict) | - V + v reconstructPar // Stitch together the solutions from the submeshes -Of course, this can vary depending on what mesher you use, wether you run in parallel, etc. There may also be additional pre- or post-processing steps. +Of course, this can vary depending on the mesher, whether or not it is a parallel run, additional pre- or post-processing steps. @@ -96,169 +104,174 @@ A few examples of the dictionaries are shown below: .. code-block:: cpp - /*--------------------------------*- C++ -*----------------------------------*\ - | ========= | | - | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | - | \\ / O peration | Version: v2306 | - | \\ / A nd | Website: www.openfoam.com | - | \\/ M anipulation | | - \*---------------------------------------------------------------------------*/ - FoamFile - { - version 2.0; - format ascii; - class dictionary; - object controlDict; - } - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - - application icoFoam; - - startFrom startTime; - - startTime 0; - - stopAt endTime; - - endTime 0.5; - - deltaT 0.005; - - writeControl timeStep; - - writeInterval 20; - - purgeWrite 0; - - writeFormat ascii; - - writePrecision 6; - - writeCompression off; - - timeFormat general; - - timePrecision 6; - - runTimeModifiable true; - - - // ************************************************************************* // + /*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | + \*---------------------------------------------------------------------------*/ + FoamFile + { + format ascii; + class dictionary; + location "system"; + object controlDict; + } + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + application foamRun; + + solver incompressibleFluid; + + startFrom startTime; + + startTime 0; + + stopAt endTime; + endTime 10; + + deltaT 0.005; + + writeControl timeStep; + + writeInterval 100; + + purgeWrite 0; + + writeFormat ascii; + + writePrecision 6; + + writeCompression off; + + timeFormat general; + + timePrecision 6; + + runTimeModifiable true; + + // ************************************************************************* // .. tab:: fvSchemes .. code-block:: cpp - /*--------------------------------*- C++ -*----------------------------------*\ - | ========= | | - | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | - | \\ / O peration | Version: v2306 | - | \\ / A nd | Website: www.openfoam.com | - | \\/ M anipulation | | - \*---------------------------------------------------------------------------*/ - FoamFile - { - version 2.0; - format ascii; - class dictionary; - object fvSchemes; - } - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - - ddtSchemes - { - default Euler; - } - - gradSchemes - { - default Gauss linear; - grad(p) Gauss linear; - } - - divSchemes - { - default none; - div(phi,U) Gauss linear; - } - - laplacianSchemes - { - default Gauss linear orthogonal; - } - - interpolationSchemes - { - default linear; - } - - snGradSchemes - { - default orthogonal; - } - - - // ************************************************************************* // - + /*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | + \*---------------------------------------------------------------------------*/ + FoamFile + { + format ascii; + class dictionary; + location "system"; + object fvSchemes; + } + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + ddtSchemes + { + default Euler; + } + + gradSchemes + { + default Gauss linear; + } + + divSchemes + { + default none; + div(phi,U) Gauss limitedLinearV 1; + div(phi,k) Gauss limitedLinear 1; + div(phi,epsilon) Gauss limitedLinear 1; + div(phi,omega) Gauss limitedLinear 1; + div(phi,R) Gauss limitedLinear 1; + div(R) Gauss linear; + div(phi,nuTilda) Gauss limitedLinear 1; + div((nuEff*dev2(T(grad(U))))) Gauss linear; + } + + laplacianSchemes + { + default Gauss linear corrected; + } + + interpolationSchemes + { + default linear; + } + + snGradSchemes + { + default corrected; + } + + + // ************************************************************************* // .. tab:: fvSolution .. code-block:: cpp - /*--------------------------------*- C++ -*----------------------------------*\ - | ========= | | - | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | - | \\ / O peration | Version: v2306 | - | \\ / A nd | Website: www.openfoam.com | - | \\/ M anipulation | | - \*---------------------------------------------------------------------------*/ - FoamFile + /*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | + \*---------------------------------------------------------------------------*/ + FoamFile + { + format ascii; + class dictionary; + location "system"; + object fvSolution; + } + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + solvers + { + p { - version 2.0; - format ascii; - class dictionary; - object fvSolution; + solver GAMG; + tolerance 1e-06; + relTol 0.1; + smoother GaussSeidel; } - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - - solvers + + pFinal { - p - { - solver PCG; - preconditioner DIC; - tolerance 1e-06; - relTol 0.05; - } - - pFinal - { - $p; - relTol 0; - } - - U - { - solver smoothSolver; - smoother symGaussSeidel; - tolerance 1e-05; - relTol 0; - } + $p; + tolerance 1e-06; + relTol 0; } - - PISO + + "(U|k|epsilon|omega|R|nuTilda).*" { - nCorrectors 2; - nNonOrthogonalCorrectors 0; - pRefCell 0; - pRefValue 0; + solver smoothSolver; + smoother GaussSeidel; + tolerance 1e-05; + relTol 0; } - - - // ************************************************************************* // + } + + PIMPLE + { + nCorrectors 2; + nNonOrthogonalCorrectors 0; + pRefCell 0; + pRefValue 0; + } + + // ************************************************************************* // Input types @@ -327,23 +340,3 @@ The main basic entry types include: - `(0 0 0 0 0 0 0 0 0)` -Expressions -~~~~~~~~~~~ - -The Expressions functionality is a re-implementation of swak4Foam(SWiss Army Knife for Foam) created by Bernhard Gschaider and it was introduced since version v1912. -The Expressions syntax enables users to define custom expressions for use in a variety of scenarios that don’t exist yet in OpenFOAM, without the need to rely on coding in -C++, including: - - - pre-processing utilities - - input dictionaries - - boundary conditions - - function objects (co-processing) - - utilities, e.g. setting field values - - -Summary -------- - -- ``fvOptions`` and ``functionObject`` practically remove the need for modifying the solver, as long as it captures your physics. -- Lots of ``fvOptions`` and ``functionObjects`` out there. Try and play with them! -- There is a coded type of ``fvOption`` and ``functionObject``, which allows you to simply write you own C++ to be executed! Will be compiled when the case runs, with no involvment from your side. From c174418166e9228485d448c973eff579ec04ef23 Mon Sep 17 00:00:00 2001 From: Francesco Fiusco Date: Thu, 19 Jun 2025 08:11:31 +0200 Subject: [PATCH 02/17] WIP --- content/introduction.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/content/introduction.rst b/content/introduction.rst index f863782..bb9e907 100644 --- a/content/introduction.rst +++ b/content/introduction.rst @@ -69,7 +69,8 @@ Once compiled, a large number of executables is generated, which fall into two c This is the case for the ESI version of OpenFOAM and used to be for OpenFOAM foundation until version 10. From OpenFOAM 11 onwards, a radical shift of paradigm has taken place: so-called `modular `__ -solvers have been introduced +solvers have been introduced. This approach consists in each solver being a *class* (in the OOP sense) and having one single executable `foamRun` which +launches the solver. This makes it easier to include multiphysics in the solution strategy, as well as adding additional equations to be solved. OpenFOAM vs commercial software ------------------------------- From 852f7b487bd4d21d533c2829bbc084ca0d1398d6 Mon Sep 17 00:00:00 2001 From: Francesco Fiusco Date: Mon, 23 Jun 2025 12:01:27 +0200 Subject: [PATCH 03/17] Updated introduction.rst with new OpenFOAM versions & info. --- content/introduction.rst | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/content/introduction.rst b/content/introduction.rst index bb9e907..2927538 100644 --- a/content/introduction.rst +++ b/content/introduction.rst @@ -45,18 +45,27 @@ There are two main variants of OpenFOAM: One can read the history if interested: -https://www.openfoam.com/news/history +https://www.openfoam.com/news/history. + +Moreover, another fork exists called `foam-extend`, a community-driven effort currently at version 5.0. This project, while being on a generally slower development +cycle, is more open to contributions from other actors and provides some experimental features not found in the other flavours, such as +turbomachinery toolboxes, immersed boundary method and tooling for reduced order models such as POD. Which version to use? --------------------- -It depends on the features you want to use +It depends on the features you want to use: - - Check the website and release notes to see which one fits better to your framework - - If both include the features you need, do some performance and accuracy benchmarks to see which one is better + - Check the website and release notes to see which one fits better to your framework; + - If both include the features you need, do some performance and accuracy benchmarks to see which one is better; - Otherwise it is just matter of taste! +Some features are only available in one flavour (e.g. overset meshes only implemented in ESI), while others have been introduced in one and +then ported to the other. The foundation version is more prone to breaking changes (see e.g. the modular solvers below), whereas the ESI version +tends to require minor modifications across subsequent versions. foam-extend offers some features that neither of the other two have; while it +generally strives to have some degree of compatibility with the foundation version, some porting effort is probably required. + OpenFOAM executables -------------------- @@ -69,18 +78,15 @@ Once compiled, a large number of executables is generated, which fall into two c This is the case for the ESI version of OpenFOAM and used to be for OpenFOAM foundation until version 10. From OpenFOAM 11 onwards, a radical shift of paradigm has taken place: so-called `modular `__ -solvers have been introduced. This approach consists in each solver being a *class* (in the OOP sense) and having one single executable `foamRun` which -launches the solver. This makes it easier to include multiphysics in the solution strategy, as well as adding additional equations to be solved. +solvers have been introduced. This approach consists in each solver being a *class* (in the OOP sense) and having one single executable (``foamRun``) +which launches the solver. This makes it easier to include multiple physics in the solution strategy, as well as adding additional equations to be solved. +While this makes for much cleaner and maintainable code, it also means that a wealth of older tutorial cases/learning materials (such as blog and forum posts) +cannot immediately be reused on OpenFOAM :math:`\geq` 11. OpenFOAM vs commercial software ------------------------------- -Being an open source software, the advantages of OpenFOAM is quite obvious: - - - free to use - - a strong focus on customization and flexibility - - full control over the simulation - -All these nice features come with a price: very deep learning curve. -For example, contrary to the commercial CFD softwares, there are no default values in OpenFOAM. -It is up to the user to set those values which means the user has to know what he/she is doing. +OpenFOAM is open-source and it has a degree of focus on customisability and flexibility. The possibility of having full control on the simulation +and the fact that it is free make it very appealing for research use, but it is also widely used in industry (e.g. some automakers and F1 teams, pharma, chemical engineering...). +The costs lie in its steeper learning curve, as users need to have some solid theoretical understanding of CFD, and the absence of bells and whistles that come with +commercial software like friendly GUIs (even though some `commercial `__ and `free `__ efforts are underway). From 14e323e48590562dc04c4a5f5e28b6a1264df433 Mon Sep 17 00:00:00 2001 From: ffrancesco94 Date: Mon, 23 Jun 2025 14:04:16 +0200 Subject: [PATCH 04/17] Update sphinx.yml Merge from main where I updated the GH actions --- .github/workflows/sphinx.yml | 176 ++++++++++++++++++++--------------- 1 file changed, 99 insertions(+), 77 deletions(-) diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index a978849..cd77db2 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -1,54 +1,69 @@ -# From: https://github.com/rkdarst/sphinx-actions-test/blob/master/.github/workflows/sphinx-build.yml +# Deploy Sphinx. This could be shorter, but we also do some extra +# stuff. +# +# License: CC-0. This is the canonical location of this file, which +# you may want to link to anyway: +# https://github.com/coderefinery/sphinx-lesson-template/blob/main/.github/workflows/sphinx.yml +# https://raw.githubusercontent.com/coderefinery/sphinx-lesson-template/main/.github/workflows/sphinx.yml + name: sphinx on: [push, pull_request] -# If these SPHINXOPTS are enabled, then be strict about the builds and -# fail on any warnings -#env: -# SPHINXOPTS: "-W --keep-going -T" env: - DEFAULT_BRANCH: main + DEFAULT_BRANCH: "main" + # If these SPHINXOPTS are enabled, then be strict about the + # builds and fail on any warnings. + #SPHINXOPTS: "-W --keep-going -T" + GENERATE_PDF: false # to enable, must be 'true' lowercase + GENERATE_SINGLEHTML: false # to enable, must be 'true' lowercase + PDF_FILENAME: lesson.pdf + MULTIBRANCH: false # to enable, must be 'true' lowercase jobs: - build-and-deploy: - name: Build and gh-pages + build: + name: Build runs-on: ubuntu-latest + permissions: + contents: read + steps: # https://github.com/marketplace/actions/checkout - uses: actions/checkout@v4 with: fetch-depth: 0 lfs: true + # https://github.com/marketplace/actions/setup-python # ^-- This gives info on matrix testing. - name: Install Python uses: actions/setup-python@v4 with: - python-version: "3.12" - # https://docs.github.com/en/actions/guides/building-and-testing-python#caching-dependencies - # ^-- How to set up caching for pip on Ubuntu - - name: Cache pip - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - ${{ runner.os }}- + python-version: '3.11' + cache: 'pip' + # https://docs.github.com/en/actions/guides/building-and-testing-python#installing-dependencies # ^-- This gives info on installing dependencies with pip - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt + + # Debug - name: Debugging information + env: + ref: ${{github.ref}} + event_name: ${{github.event_name}} + head_ref: ${{github.head_ref}} + base_ref: ${{github.base_ref}} run: | - echo "github.ref:" ${{github.ref}} - echo "github.event_name:" ${{github.event_name}} - echo "github.head_ref:" ${{github.head_ref}} - echo "github.base_ref:" ${{github.base_ref}} + echo "github.ref: ${ref}" + echo "github.event_name: ${event_name}" + echo "github.head_ref: ${head_ref}" + echo "github.base_ref: ${base_ref}" + echo "GENERATE_PDF: ${GENERATE_PDF}" + echo "GENERATE_SINGLEHTML: ${GENERATE_SINGLEHTML}" set -x git rev-parse --abbrev-ref HEAD git branch @@ -61,7 +76,8 @@ jobs: # Build - uses: ammaraskar/sphinx-problem-matcher@master - - name: Build Sphinx docs + - name: Build Sphinx docs (dirhtml) + # SPHINXOPTS used via environment variables run: | make dirhtml # This fixes broken copy button icons, as explained in @@ -73,60 +89,38 @@ jobs: # https://github.com/readthedocs/sphinx_rtd_theme/pull/1025 sed -i 's/url_root="#"/url_root=""/' _build/dirhtml/index.html || true + # singlehtml + - name: Generate singlehtml + if: ${{ env.GENERATE_SINGLEHTML == 'true' }} + run: | + make singlehtml + mv _build/singlehtml/ _build/dirhtml/singlehtml/ - # The following supports building all branches and combining on - # gh-pages + # PDF if requested + - name: Generate PDF + if: ${{ env.GENERATE_PDF == 'true' }} + run: | + pip install https://github.com/rkdarst/sphinx_pyppeteer_builder/archive/refs/heads/main.zip + make pyppeteer + mv _build/pyppeteer/*.pdf _build/dirhtml/${PDF_FILENAME} - # Clone and set up the old gh-pages branch - - name: Clone old gh-pages + # Stage all deployed assets in _gh-pages/ for simplicity, and to + # prepare to do a multi-branch deployment. + - name: Copy deployment data to _gh-pages/ if: ${{ github.event_name == 'push' }} - run: | - set -x - git fetch - ( git branch gh-pages remotes/origin/gh-pages && git clone . --branch=gh-pages _gh-pages/ ) || mkdir _gh-pages - rm -rf _gh-pages/.git/ - mkdir -p _gh-pages/branch/ - # If a push and default branch, copy build to _gh-pages/ as the "main" - # deployment. - - name: Copy new build (default branch) - if: | - contains(github.event_name, 'push') && - contains(github.ref, env.DEFAULT_BRANCH) - run: | - set -x - # Delete everything under _gh-pages/ that is from the - # primary branch deployment. Eicludes the other branches - # _gh-pages/branch-* paths, and not including - # _gh-pages itself. - find _gh-pages/ -mindepth 1 ! -path '_gh-pages/branch*' -delete + run: rsync -a _build/dirhtml/ _gh-pages/ - # If a push and not on default branch, then copy the build to - # _gh-pages/branch/$brname (transforming '/' into '--') - - name: Copy new build (branch) - if: | - contains(github.event_name, 'push') && - !contains(github.ref, env.DEFAULT_BRANCH) - run: | - set -x - #brname=$(git rev-parse --abbrev-ref HEAD) - brname="${{github.ref}}" - brname="${brname##refs/heads/}" - brdir=${brname//\//--} # replace '/' with '--' - rm -rf _gh-pages/branch/${brdir} - rsync -a _build/dirhtml/ _gh-pages/branch/${brdir} - # Go through each branch in _gh-pages/branch/, if it's not a - # ref, then delete it. - - name: Delete old feature branches - if: ${{ github.event_name == 'push' }} - run: | - set -x - for brdir in `ls _gh-pages/branch/` ; do - brname=${brdir//--/\/} # replace '--' with '/' - if ! git show-ref remotes/origin/$brname ; then - echo "Removing $brdir" - rm -r _gh-pages/branch/$brdir/ - fi - done + + # Use gh-pages-multibranch to multiplex different branches into + # one deployment. See + # https://github.com/coderefinery/gh-pages-multibranch + - name: gh-pages multibranch + uses: coderefinery/gh-pages-multibranch@main + if: ${{ github.event_name == 'push' && env.MULTIBRANCH == 'true' }} + with: + directory: _gh-pages/ + default_branch: ${{ env.DEFAULT_BRANCH }} + publish_branch: gh-pages # Add the .nojekyll file - name: nojekyll @@ -134,15 +128,43 @@ jobs: run: | touch _gh-pages/.nojekyll + # Save artifact for the next step. + - uses: actions/upload-artifact@v4 + if: ${{ github.event_name == 'push' }} + with: + name: gh-pages-build + path: _gh-pages/ + + # Deploy in a separate job so that write permissions are restricted + # to the minimum steps. + deploy: + name: Deploy + runs-on: ubuntu-latest + needs: build + # This if can't use the env context - find better way later. + if: ${{ github.event_name == 'push' }} + permissions: + contents: write + + steps: + - uses: actions/download-artifact@v4 + if: ${{ github.event_name == 'push' && ( env.MULTIBRANCH == 'true' || github.ref == format('refs/heads/{0}', env.DEFAULT_BRANCH )) }} + with: + name: gh-pages-build + path: _gh-pages/ + + # As of 2023, we could publish to pages via a Deployment. This + # isn't done yet to give it time to stabilize (out of beta), and + # also having a gh-pages branch to check out is rather + # convenient. + # Deploy # https://github.com/peaceiris/actions-gh-pages - name: Deploy uses: peaceiris/actions-gh-pages@v3 - if: ${{ github.event_name == 'push' }} - #if: ${{ success() && github.event_name == 'push' && github.ref == 'refs/heads/${{ env.DEFAULT_BRANCH }}' }} + if: ${{ github.event_name == 'push' && ( env.MULTIBRANCH == 'true' || github.ref == format('refs/heads/{0}', env.DEFAULT_BRANCH )) }} with: publish_branch: gh-pages github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: _gh-pages/ force_orphan: true - From 2312f690b978805938709d96a2cfaf73705df4dc Mon Sep 17 00:00:00 2001 From: Francesco Fiusco Date: Mon, 23 Jun 2025 14:31:47 +0200 Subject: [PATCH 05/17] Updated index.rst --- content/index.rst | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/content/index.rst b/content/index.rst index c060084..e32cbce 100644 --- a/content/index.rst +++ b/content/index.rst @@ -36,6 +36,15 @@ who would like to get started with OpenFOAM using a HPC resource. Basic knowledge of using Linux will be required. Participants are expected to know basic numerical analysis and have CFD theoretical background. +About the course +---------------- + +This workshop will provide an introduction to OpenFOAM, its different versions and how it differs from commercial CFD solvers. +This will be followed by an overview of the OpenFOAM case structure, meshing tools, run in serial and parallel of some example cases +and an introduction to postprocessing in Paraview. Emphasis will be placed on numerics considerations and solution schemes available +in OpenFOAM. +The workshop will assume OpenFOAM foundation version, at least 11. + Schedule -------- @@ -84,9 +93,6 @@ Schedule - Hands-on session -About the course ----------------- - See also -------- From 1d674cae732975e20f1275fc82c723494b8cb185 Mon Sep 17 00:00:00 2001 From: Francesco Fiusco Date: Mon, 23 Jun 2025 16:13:59 +0200 Subject: [PATCH 06/17] Fixed workflows and started working on numerics --- content/numerics.rst | 99 +++++++++++++++++++------------------------- content/workflow.rst | 25 ++++++++++- 2 files changed, 67 insertions(+), 57 deletions(-) diff --git a/content/numerics.rst b/content/numerics.rst index d11f5b3..751b8cb 100644 --- a/content/numerics.rst +++ b/content/numerics.rst @@ -5,12 +5,15 @@ Numerics .. questions:: - - What is - - What problem do + - What is the general form of the equations we are trying to solve? + - Which discretisation schemes are available in OpenFOAM and how do we prescribe them? + - Which linear solvers are available in OpenFOAM and how do we prescribe them? .. objectives:: - - Explain + - Know in which files discretisation schemes and linear solvers are prescribed + - Know which schemes are available for each term + - Use some rule of thumb to decide which schemes are more suitable for each term .. instructor-note:: @@ -128,30 +131,9 @@ Interpolation schemes are specified in the ``fvSchemes`` file under the interpol } -A wide variety of interpolation schemes are available, ranging from those that are based solely on geometry, and others, e.g. convection schemes that are functions of the local flow: +A wide variety of interpolation schemes are available; some of them only depend on the geometry, while others are mainly used with convection (divergence) fluxes. +For non-convective fluxes, the ``linear`` scheme is the most used. - - Linear scheme: The most obvious option is linear interpolation, 2nd order accurate. However, for convective fluxes it introduces oscillations - - Convection scheme: Many options for interpolating the convective flux exist. Often it is the most important numerical choice in the simulation. Many of the convection schemes available in OpenFOAM are based on the TVD and NVD: - - - NVD/TVD convection schemes:: - - - Limited linear divergence scheme - - Linear divergence scheme - - Linear-upwind divergence scheme - - MUSCL divergence scheme - - Mid-point divergence scheme - - Minmod divergence scheme - - QUICK divergence scheme - - UMIST divergence scheme - - Upwind divergence scheme - - Van Leer divergence scheme - - - Non-NVD/TVD convection schemes:: - - - Courant number blended divergence scheme - - DES hybrid divergence scheme - - Filtered Linear (2) divergence scheme - - LUST divergence scheme @@ -173,7 +155,7 @@ Now it is the time to choose a time integration scheme. Temporal schemes define } -Available **