Skip to content

Commit

Permalink
Merge pull request #2 from daavid00/development
Browse files Browse the repository at this point in the history
Updating to OpenFOAM 11
  • Loading branch information
daavid00 authored Feb 16, 2024
2 parents 6ff545e + 86844de commit 34b8678
Show file tree
Hide file tree
Showing 22 changed files with 229 additions and 151 deletions.
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ This repository provides a workflow to perform computational fluid dynamics (CFD

## Installation
You will first need to install
* OpenFOAM (https://www.openfoam.com) (tested with OpenFOAM v2206)
* Gmsh (https://gmsh.info) (tested with Gmsh 4.11.0)

You will also need to install some python packages, see ```requirements.txt``` for a complete list. You can install all the required python packages in a virtual environment with the following commands:
* OpenFOAM (https://www.openfoam.com) (tested with OpenFOAM-11)
* Gmsh (https://gmsh.info) (tested with Gmsh 4.8.4)

You will also need to install some Python packages, see ```requirements.txt``` for a complete list. You can install all the required Python packages in a virtual environment with the following commands:
```bash
# Clone the repo
git clone https://github.com/daavid00/pymm.git
Expand All @@ -33,6 +32,16 @@ pip install -e .
# For contributions/testing/linting, install the dev-requirements
pip install -r dev-requirements.txt
```
Depending on the location where OpenFOAM is installed, then before running pymm (inside the vpymm Python environment), you need to enter the OpenFoam environment:
```bash
# Check where openFOAM is installed
echo $WM_PROJECT_DIR
# The return value was /opt/openfoam11, then we activate the environment
source /opt/openfoam11/etc/bashrc
# Then, if everything went fine, typing
gmshToFoam
# should print the argument flags for that OpenFOAM executable.
```

## Running pymm
You can run _pymm_ as a single command line:
Expand All @@ -48,7 +57,7 @@ See the [_documentation_](https://daavid00.github.io/pymm/introduction.html).
The following is a list of journal papers in which _pymm_ is used:

1. Liu, N., Haugen, M., Benali, B., Landa-Marbán, D., Fernø, M.A., 2023. Pore-scale spatiotemporal dynamics of microbial-induced calcium carbonate growth and distribution in porous media. Int. J. Greenh. Gas Control 125, 103885. https://doi.org/10.1016/j.ijggc.2023.103885
1. Liu, N., Haugen, M., Benali, B., Landa-Marbán, D., Fernø, M.A., 2023. Pore-scale kinetics of calcium dissolution and secondary precipitation during geological carbon storage. Chem. Geol., to appear.
1. Liu, N., Haugen, M., Benali, B., Landa-Marbán, D., Fernø, M.A., 2023. Pore-scale kinetics of calcium dissolution and secondary precipitation during geological carbon storage. Chem. Geol. 641, 121782. https://doi.org/10.1016/j.chemgeo.2023.121782.

## About pymm
The image-based Python package for computational fluid dynamics pymm is funded by [_Center for Sustainable Subsurface Resources_](https://cssr.no) [project no. 331841] and [_NORCE Norwegian Research Centre As_](https://www.norceresearch.no) [project number 101070].
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
porespy
pypardiso
mako
26 changes: 16 additions & 10 deletions src/pymm/core/pymm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Main script"""

import os
import csv
import glob
Expand Down Expand Up @@ -540,8 +541,8 @@ def run_stokes(dic):
for file in [
"0/p",
"0/U",
"constant/transportProperties",
"constant/turbulenceProperties",
"constant/physicalProperties",
"constant/momentumTransport",
"system/controlDict",
"system/fvSchemes",
"system/fvSolution",
Expand All @@ -564,7 +565,7 @@ def run_stokes(dic):

with open("constant/polyMesh/boundary", "r", encoding="utf8") as file:
dic["boundary"] = file.readlines()
dic["boundary"][22] = "type empty;"
dic["boundary"][20] = "type empty;"
mytemplate = Template(filename=f"{dic['pat']}/templates/utils/boundary.mako")
var = {"dic": dic}
filled_template = mytemplate.render(**var)
Expand All @@ -573,7 +574,7 @@ def run_stokes(dic):

os.system(f"rm -rf {dic['cwd']}/{dic['fol']}/VTK_flowStokes")
# Running the steady-state flow simulation
os.system("simpleFoam & wait")
os.system("foamRun -solver incompressibleFluid & wait")
os.system("foamToVTK & wait")
os.system(f"mkdir {dic['cwd']}/{dic['fol']}/VTK_flowStokes")
os.system(f"cp -r VTK/* {dic['cwd']}/{dic['fol']}/VTK_flowStokes")
Expand All @@ -596,11 +597,12 @@ def run_tracer(dic):
os.system(f"mkdir {dic['cwd']}/{dic['fol']}/OpenFOAM/tracerTransport/system")
var = {"dic": dic}
for file in [
"inlet",
"0/T",
"constant/transportProperties",
"constant/fvOptions",
"constant/physicalProperties",
"constant/momentumTransport",
"constant/fvConstraints",
"system/controlDict",
"system/topoSetDict",
"system/fvSchemes",
"system/fvSolution",
]:
Expand All @@ -621,15 +623,19 @@ def run_tracer(dic):
os.system(
f"cp {latest_folder}U {dic['cwd']}/{dic['fol']}/OpenFOAM/tracerTransport/0/"
)
os.system(
f"cp {latest_folder}p {dic['cwd']}/{dic['fol']}/OpenFOAM/tracerTransport/0/"
)
os.system(
f"cp -r {dic['cwd']}/{dic['fol']}/OpenFOAM/flowStokes/constant/polyMesh "
f"{dic['cwd']}/{dic['fol']}/OpenFOAM/tracerTransport/constant/"
)
os.chdir(f"{dic['cwd']}/{dic['fol']}/OpenFOAM/tracerTransport")
os.system("setSet -batch inlet & wait")
os.system("topoSet & wait")

# Running the simulation of tracer transport
os.system("scalarTransportFoam & wait")
os.system("foamRun & wait")
# exit()
os.system("foamToVTK & wait")
os.system(f"cp -r VTK/* {dic['cwd']}/{dic['fol']}/VTK_tracerTransport")

Expand All @@ -650,7 +656,7 @@ def main():
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# ad-wa is distributed in the hope that it will be useful,
# pymm is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
Expand Down
11 changes: 5 additions & 6 deletions src/pymm/templates/OpenFOAM/flowStokes/0/U.mako
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2206 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 11
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
Expand Down
11 changes: 5 additions & 6 deletions src/pymm/templates/OpenFOAM/flowStokes/0/p.mako
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2206 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 11
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 11
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "constant";
object momentumTransport;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

simulationType laminar;


// ************************************************************************* //
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 11
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "constant";
object physicalProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

viscosityModel constant;

nu [0 2 -1 0 0 0 0] ${dic['nu']};

// ************************************************************************* //

This file was deleted.

This file was deleted.

15 changes: 8 additions & 7 deletions src/pymm/templates/OpenFOAM/flowStokes/system/controlDict.mako
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 11
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application simpleFoam;
application foamRun;

solver incompressibleFluid;

startFrom startTime;

Expand Down
11 changes: 5 additions & 6 deletions src/pymm/templates/OpenFOAM/flowStokes/system/fvSchemes.mako
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 11
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
Expand Down
11 changes: 5 additions & 6 deletions src/pymm/templates/OpenFOAM/flowStokes/system/fvSolution.mako
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 11
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
Expand Down
16 changes: 8 additions & 8 deletions src/pymm/templates/OpenFOAM/tracerTransport/0/T.mako
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2206 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 11
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object T;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 0 0 0 0 0 0];
dimensions [0 0 0 1 0 0 0];

internalField uniform 0;

Expand All @@ -26,7 +25,8 @@ boundaryField
}
inlet
{
type zeroGradient;
type fixedValue;
value uniform 1;
}
outlet
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,11 @@ FoamFile

fixedTemperature
{
type scalarFixedValueConstraint;

type fixedTemperatureConstraint;
mode uniform;
selectionMode cellZone;
cellZone c0Zone;
fieldValues
{
T 1.0;
}


temperature 1.0;
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 11
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "constant";
object momentumTransport;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

simulationType laminar;


// ************************************************************************* //
Loading

0 comments on commit 34b8678

Please sign in to comment.