Skip to content

Commit

Permalink
New service for openFOAM org and com
Browse files Browse the repository at this point in the history
  • Loading branch information
chZehetner committed Jan 31, 2024
1 parent 4d75ee5 commit f897860
Show file tree
Hide file tree
Showing 90 changed files with 466,487 additions and 4 deletions.
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions services/openfoam_com/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# CADdrive OpenFOAM Service
## Openfoam2312 (openfoam.com)

## With ``docker``

To build the docker image:

```sh
cd <CADdrive>/services/openfoam_com

docker build --tag "caddrive-openfoam-com" .
```

To run the docker image:

```sh
docker run -p 127.0.0.1:5002:5000 "caddrive-openfoam-com"
```

## Without ``docker``

To run without docker (to obtain debug output):

```sh
cd <CADdrive>/services/openfoam_com

python main.py --debug
```
File renamed without changes.
15 changes: 15 additions & 0 deletions services/openfoam_org/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM openfoam/openfoam11-paraview510

USER root

RUN apt-get update && apt-get install python3-pip -y
RUN pip3 install Flask
RUN pip3 install requests_toolbelt

COPY main.py /root

WORKDIR /root

EXPOSE 5000/tcp

CMD python3 main.py
13 changes: 13 additions & 0 deletions services/openfoam_org/Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[[source]]
url = "https://github.com/ghackenberg/caddrive"
verify_ssl = true
name = "caddrive-openfoam"

[packages]
flask = "*"
requests-toolbelt = "*"

[dev-packages]

[requires]
python_version = "3.11"
10 changes: 6 additions & 4 deletions services/openfoam/README.md → services/openfoam_org/README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
# CADdrive OpenFOAM Service

## Openfoam11 (openfoam.org)

## With ``docker``

To build the docker image:

```sh
cd <CADdrive>/services/openfoam
cd <CADdrive>/services/openfoam_org

docker build --tag "caddrive-openfoam" .
docker build --tag "caddrive-openfoam-org" .
```

To run the docker image:

```sh
docker run -p 127.0.0.1:5002:5000 "caddrive-openfoam"
docker run -p 127.0.0.1:5002:5000 "caddrive-openfoam-org"
```

## Without ``docker``

To run without docker (to obtain debug output):

```sh
cd <CADdrive>/services/openfoam
cd <CADdrive>/services/openfoam_org

python main.py --debug
```
47 changes: 47 additions & 0 deletions services/openfoam_org/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# External dependencies
import os
import sys

from flask import Flask

# Ensure folder
if not os.path.exists("./output"):
os.makedirs("./output")

# Define constants
FLASK_HOST = "0.0.0.0"
FLASK_PORT = 5000
FLASK_DBUG = sys.argv.count("--debug") > 0

OPENFOAM_MSH_CMD = "blockMesh"
OPENFOAM_ICO_CMD = "icoFoam"

WORKDIR = "./output"
JOBNAME = "job"

# Create app
APP = Flask(__name__)

# Register route
@APP.post("/")
def simulate():

# Command to mesh the body
ret = os.system(f"{OPENFOAM_MSH_CMD}")

# Handle error
if ret:
return "blockMesh error", 400

# Command to start the simulation
ret = os.system(f"{OPENFOAM_ICO_CMD}")

# Handle error
if ret:
return "icoFaom error", 400

# Send response
return "OK"

# Run app
APP.run(host=FLASK_HOST, port=FLASK_PORT, debug=FLASK_DBUG)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file not shown.
39 changes: 39 additions & 0 deletions tests/openfoam_org_11/cavity/0/U
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*--------------------------------*- 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 volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

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

internalField uniform (0 0 0);

boundaryField
{
movingWall
{
type fixedValue;
value uniform (1 0 0);
}

fixedWalls
{
type noSlip;
}

frontAndBack
{
type empty;
}
}

// ************************************************************************* //
40 changes: 40 additions & 0 deletions tests/openfoam_org_11/cavity/0/epsilon
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*--------------------------------*- 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 volScalarField;
location "0";
object epsilon;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 2 -3 0 0 0 0];

internalField uniform 0.00754;

boundaryField
{
movingWall
{
type epsilonWallFunction;
value uniform 0.00754;
}
fixedWalls
{
type epsilonWallFunction;
value uniform 0.00754;
}
frontAndBack
{
type empty;
}
}


// ************************************************************************* //
40 changes: 40 additions & 0 deletions tests/openfoam_org_11/cavity/0/k
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*--------------------------------*- 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 volScalarField;
location "0";
object k;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 2 -2 0 0 0 0];

internalField uniform 0.00375;

boundaryField
{
movingWall
{
type kqRWallFunction;
value uniform 0.00375;
}
fixedWalls
{
type kqRWallFunction;
value uniform 0.00375;
}
frontAndBack
{
type empty;
}
}


// ************************************************************************* //
38 changes: 38 additions & 0 deletions tests/openfoam_org_11/cavity/0/nuTilda
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*--------------------------------*- 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 volScalarField;
object nuTilda;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 2 -1 0 0 0 0];

internalField uniform 0;

boundaryField
{
movingWall
{
type zeroGradient;
}

fixedWalls
{
type zeroGradient;
}

frontAndBack
{
type empty;
}
}

// ************************************************************************* //
40 changes: 40 additions & 0 deletions tests/openfoam_org_11/cavity/0/nut
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*--------------------------------*- 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 volScalarField;
location "0";
object nut;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 2 -1 0 0 0 0];

internalField uniform 0;

boundaryField
{
movingWall
{
type nutkWallFunction;
value uniform 0;
}
fixedWalls
{
type nutkWallFunction;
value uniform 0;
}
frontAndBack
{
type empty;
}
}


// ************************************************************************* //
40 changes: 40 additions & 0 deletions tests/openfoam_org_11/cavity/0/omega
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*--------------------------------*- 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 volScalarField;
location "0";
object omega;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

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

internalField uniform 22.4;

boundaryField
{
movingWall
{
type omegaWallFunction;
value uniform 22.4;
}
fixedWalls
{
type omegaWallFunction;
value uniform 22.4;
}
frontAndBack
{
type empty;
}
}


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

0 comments on commit f897860

Please sign in to comment.