diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000000..55264923b0
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,14 @@
+BasedOnStyle: WebKit
+BraceWrapping:
+ AfterClass: true
+ AfterControlStatement: true
+ AfterFunction: true
+ AfterNamespace: true
+ SplitEmptyFunction: false
+BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Custom
+BreakBeforeInheritanceComma: true
+BreakConstructorInitializers: AfterColon
+MaxEmptyLinesToKeep: 2
+SortIncludes: false
+SpaceBeforeCtorInitializerColon: false
diff --git a/.compileOF1812.sh b/.compileOF1812.sh
index 5a1eb7ee8e..aa8ab16de2 100755
--- a/.compileOF1812.sh
+++ b/.compileOF1812.sh
@@ -1,5 +1,5 @@
docker pull ithacafv/openfoam1812-muq2-pytorch
docker run -ti -d --name foam1812 -v "${PWD}":/home/ofuser/app:rw ithacafv/openfoam1812-muq2-pytorch /bin/bash
docker exec foam1812 /bin/bash -c "cd /home/ofuser/app; ls"
-docker exec foam1812 /bin/bash -c "export MUQ_LIBRARIES=/home/Installations/MUQ_INSTALL; export MUQ_EXT_LIBRARIES=/home/Installations/MUQ_INSTALL/muq_external; export TORCH_LIBRARIES=/pytorch/torch; cd /home/ofuser/app; source /root/OpenFOAM/OpenFOAM-v1812/etc/bashrc; source etc/bashrc; ./Allwmake -taumq"
+docker exec foam1812 /bin/bash -c "export MUQ_LIBRARIES=/home/Installations/MUQ_INSTALL; export MUQ_EXT_LIBRARIES=/home/Installations/MUQ_INSTALL/muq_external; export TORCH_LIBRARIES=/pytorch/torch; cd /home/ofuser/app; source /root/OpenFOAM/OpenFOAM-v1812/etc/bashrc; source etc/bashrc; git submodule update --init; ./Allwmake -taumq"
diff --git a/.compileOF1906.sh b/.compileOF1906.sh
index 2eb6a9b4f3..1095940290 100755
--- a/.compileOF1906.sh
+++ b/.compileOF1906.sh
@@ -1,5 +1,5 @@
docker pull ithacafv/openfoam1906-muq2-pytorch
docker run -ti -d --name foam1906 -v "${PWD}":/home/ofuser/app:rw ithacafv/openfoam1906-muq2-pytorch /bin/bash
docker exec foam1906 /bin/bash -c "cd /home/ofuser/app; ls"
-docker exec foam1906 /bin/bash -c "export MUQ_LIBRARIES=/home/Installations/MUQ_INSTALL; export MUQ_EXT_LIBRARIES=/home/Installations/MUQ_INSTALL/muq_external; export TORCH_LIBRARIES=/pytorch/torch; cd /home/ofuser/app; source /root/OpenFOAM/OpenFOAM-v1906/etc/bashrc; source etc/bashrc; ./Allwmake -taumq"
+docker exec foam1906 /bin/bash -c "export MUQ_LIBRARIES=/home/Installations/MUQ_INSTALL; export MUQ_EXT_LIBRARIES=/home/Installations/MUQ_INSTALL/muq_external; export TORCH_LIBRARIES=/pytorch/torch; cd /home/ofuser/app; source /root/OpenFOAM/OpenFOAM-v1906/etc/bashrc; source etc/bashrc; git submodule update --init; ./Allwmake -taumq"
diff --git a/.compileOF1912.sh b/.compileOF1912.sh
index aa8305013e..64aec18bf7 100755
--- a/.compileOF1912.sh
+++ b/.compileOF1912.sh
@@ -1,5 +1,5 @@
docker pull ithacafv/openfoam1912-muq2-pytorch
docker run -ti -d --name foam1912 -v "${PWD}":/home/ofuser/app:rw ithacafv/openfoam1912-muq2-pytorch /bin/bash
docker exec foam1912 /bin/bash -c "cd /home/ofuser/app; ls"
-docker exec foam1912 /bin/bash -c "export MUQ_LIBRARIES=/home/Installations/MUQ_INSTALL; export MUQ_EXT_LIBRARIES=/home/Installations/MUQ_INSTALL/muq_external; export TORCH_LIBRARIES=/pytorch/torch; cd /home/ofuser/app; source /usr/lib/openfoam/openfoam1912/etc/bashrc; source etc/bashrc; ./Allwmake -taumq"
+docker exec foam1912 /bin/bash -c "export MUQ_LIBRARIES=/home/Installations/MUQ_INSTALL; export MUQ_EXT_LIBRARIES=/home/Installations/MUQ_INSTALL/muq_external; export TORCH_LIBRARIES=/pytorch/torch; cd /home/ofuser/app; source /usr/lib/openfoam/openfoam1912/etc/bashrc; source etc/bashrc; git submodule update --init; ./Allwmake -taumq"
diff --git a/.compileOF2006.sh b/.compileOF2006.sh
index 47d1c36c0e..203d4b6714 100755
--- a/.compileOF2006.sh
+++ b/.compileOF2006.sh
@@ -1,4 +1,4 @@
docker pull ithacafv/openfoam2006-muq2-pytorch
docker run -ti -d --name foam2006 -v "${PWD}":/home/ofuser/app:rw ithacafv/openfoam2006-muq2-pytorch /bin/bash
docker exec foam2006 /bin/bash -c "cd /home/ofuser/app; ls"
-docker exec foam2006 /bin/bash -c "export MUQ_LIBRARIES=/home/Installations/MUQ_INSTALL; export MUQ_EXT_LIBRARIES=/home/Installations/MUQ_INSTALL/muq_external; export TORCH_LIBRARIES=/pytorch/torch; cd /home/ofuser/app; source /usr/lib/openfoam/openfoam2006/etc/bashrc; source etc/bashrc; ./Allwmake -taumq"
+docker exec foam2006 /bin/bash -c "export MUQ_LIBRARIES=/home/Installations/MUQ_INSTALL; export MUQ_EXT_LIBRARIES=/home/Installations/MUQ_INSTALL/muq_external; export TORCH_LIBRARIES=/pytorch/torch; cd /home/ofuser/app; source /usr/lib/openfoam/openfoam2006/etc/bashrc; source etc/bashrc; git submodule update --init; ./Allwmake -taumq"
diff --git a/.compileOF2012.sh b/.compileOF2012.sh
index 9b2695189b..493b4ac0e2 100755
--- a/.compileOF2012.sh
+++ b/.compileOF2012.sh
@@ -2,4 +2,4 @@
docker pull ithacafv/openfoam2012-muq2-pytorch
docker run -ti -d --name foam2012 -v "${PWD}":/home/ofuser/app:rw ithacafv/openfoam2012-muq2-pytorch /bin/bash
docker exec foam2012 /bin/bash -c "cd /home/ofuser/app; ls"
-docker exec foam2012 /bin/bash -c "export MUQ_LIBRARIES=/home/Installations/MUQ_INSTALL; export MUQ_EXT_LIBRARIES=/home/Installations/MUQ_INSTALL/muq_external; export TORCH_LIBRARIES=/pytorch/torch; cd /home/ofuser/app; source /usr/lib/openfoam/openfoam2012/etc/bashrc; source etc/bashrc; ./Allwmake -taumq"
+docker exec foam2012 /bin/bash -c "export MUQ_LIBRARIES=/home/Installations/MUQ_INSTALL; export MUQ_EXT_LIBRARIES=/home/Installations/MUQ_INSTALL/muq_external; export TORCH_LIBRARIES=/pytorch/torch; cd /home/ofuser/app; source /usr/lib/openfoam/openfoam2012/etc/bashrc; source etc/bashrc; git submodule update --init; ./Allwmake -taumq"
diff --git a/.compileOF2106.sh b/.compileOF2106.sh
index 1e6cd674d3..9e5866c124 100755
--- a/.compileOF2106.sh
+++ b/.compileOF2106.sh
@@ -1,4 +1,4 @@
#!/bin/bash
docker pull ithacafv/openfoam2106-muq2-pytorch
docker run -ti -d --name foam2106 -v "${PWD}":/home/ofuser/app:rw ithacafv/openfoam2106-muq2-pytorch /bin/bash
-docker exec foam2106 /bin/bash -c "source /usr/lib/openfoam/openfoam2106/etc/bashrc; cd /home/ofuser/app; source etc/bashrc; ./Allwmake -taumq"
+docker exec foam2106 /bin/bash -c "source /usr/lib/openfoam/openfoam2106/etc/bashrc; cd /home/ofuser/app; source etc/bashrc; git submodule update --init; ./Allwmake -taumq"
diff --git a/.github/Singularity/Singularity_from_def.yml b/.github/Singularity/Singularity_from_def.yml
new file mode 100644
index 0000000000..7f6fb14984
--- /dev/null
+++ b/.github/Singularity/Singularity_from_def.yml
@@ -0,0 +1,36 @@
+name: Singularity_from_Definition_file
+
+on:
+ push:
+ branches: [ master ]
+ pull_request:
+ branches: [ master ]
+
+jobs:
+ singularity-from-defination-file:
+ runs-on: ubuntu-latest
+ steps:
+
+ - name: Checkout
+ uses: actions/checkout@v2
+
+ - uses: eWaterCycle/setup-singularity@v7
+ with:
+ singularity-version: 3.8.3
+
+ - name: Singularity build in detached mode
+ run: singularity build --fakeroot -d singularity_image_def.sif `pwd`/singularity/singularity-reciepe.def
+
+ - name: copying necessary files
+ run: |
+ mv singularity_image_def.sif `pwd`/tutorials/CFD/01POD/
+ mv `pwd`/singularity/Of.sh `pwd`/tutorials/CFD/01POD/
+
+ - name: Run singulairty in batch mode
+ run: |
+ cd `pwd`/tutorials/CFD/01POD/
+ singularity exec singularity_image_def.sif /bin/bash Of.sh
+
+
+
+
diff --git a/.github/Singularity/Singularity_from_docker.yml b/.github/Singularity/Singularity_from_docker.yml
new file mode 100644
index 0000000000..324ba4ec03
--- /dev/null
+++ b/.github/Singularity/Singularity_from_docker.yml
@@ -0,0 +1,36 @@
+name: Singularity_from_Docker_Image
+
+on:
+ push:
+ branches: [ master ]
+ pull_request:
+ branches: [ master ]
+
+jobs:
+ singularity-from-docker-image:
+ runs-on: ubuntu-latest
+ steps:
+
+ - name: Checkout
+ uses: actions/checkout@v2
+
+ - uses: eWaterCycle/setup-singularity@v7
+ with:
+ singularity-version: 3.8.3
+
+ - name: Singularity build
+ run: singularity build singularity_image.sif docker://ithacafv/ithacafv:manifest-amd64
+
+ - name: copying necessary files
+ run: |
+ mv singularity_image.sif `pwd`/tutorials/CFD/01POD/
+ mv `pwd`/singularity/Of.sh `pwd`/tutorials/CFD/01POD/
+
+ - name: Singulairty in batch mode
+ run: |
+ cd `pwd`/tutorials/CFD/01POD/
+ singularity exec singularity_image.sif /bin/bash Of.sh
+
+
+
+
diff --git a/.github/workflows/docker_ithaca.yml b/.github/workflows/docker_ithaca.yml
index 538f5d6635..c6a71da4fc 100755
--- a/.github/workflows/docker_ithaca.yml
+++ b/.github/workflows/docker_ithaca.yml
@@ -2,7 +2,9 @@ name: Docker
on:
push:
- branches: [ master ]
+ # Pattern matched against refs/tags
+ tags:
+ - '*' # Push events to every tag not containing /
jobs:
docker-arm64:
@@ -61,29 +63,29 @@ jobs:
- build-manifest:
- needs: [docker-amd64, docker-arm64]
+ #build-manifest:
+ #needs: [docker-amd64, docker-arm64]
- runs-on: ubuntu-latest
- steps:
+ #runs-on: ubuntu-latest
+ #steps:
- - name: Checkout
- uses: actions/checkout@v2
+ #- name: Checkout
+ #uses: actions/checkout@v2
- - name: Set up QEMU
- uses: docker/setup-qemu-action@v1
+ #- name: Set up QEMU
+ #uses: docker/setup-qemu-action@v1
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v1
+ #- name: Set up Docker Buildx
+ #uses: docker/setup-buildx-action@v1
- - name: Login to DockerHub
- uses: docker/login-action@v1
- with:
- username: ${{ secrets.DOCKER_USERNAME }}
- password: ${{ secrets.DOCKER_PASSWORD }}
+ #- name: Login to DockerHub
+ #uses: docker/login-action@v1
+ #with:
+ #username: ${{ secrets.DOCKER_USERNAME }}
+ #password: ${{ secrets.DOCKER_PASSWORD }}
- - name: manifest creation
- run: docker manifest create ithacafv/ithacafv:manifest-latest --amend ithacafv/ithacafv:manifest-amd64 --amend ithacafv/ithacafv:manifest-arm64
+ #- name: manifest creation
+ #run: docker manifest create ithacafv/ithacafv:manifest-latest --amend ithacafv/ithacafv:manifest-amd64 --amend ithacafv/ithacafv:manifest-arm64
- - name: push manifest
- run: docker manifest push ithacafv/ithacafv:manifest-latest
+ #- name: push manifest
+ #run: docker manifest push ithacafv/ithacafv:manifest-latest
diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml
new file mode 100644
index 0000000000..a2bd3bab54
--- /dev/null
+++ b/.github/workflows/sync.yml
@@ -0,0 +1,52 @@
+name: 'Upstream Sync'
+
+on:
+ schedule:
+ - cron: '*/60 * * * *' # every 30 minutes
+
+ workflow_dispatch: # click the button on Github repo!
+
+jobs:
+ sync_latest_from_upstream:
+ runs-on: ubuntu-latest
+ name: Sync latest commits from upstream repo
+
+ steps:
+ # REQUIRED step
+ # Step 1: run a standard checkout action, provided by github
+ - name: Checkout target repo
+ uses: actions/checkout@v2
+ with:
+ # optional: set the branch to checkout,
+ # sync action checks out your 'target_sync_branch' anyway
+ ref: master
+ # REQUIRED if your upstream repo is private (see wiki)
+ persist-credentials: false
+
+ # REQUIRED step
+ # Step 2: run the sync action
+ - name: Sync upstream changes
+ id: sync
+ uses: aormsby/Fork-Sync-With-Upstream-action@v3.4
+ with:
+ target_sync_branch: master
+ # REQUIRED 'target_repo_token' exactly like this!
+ target_repo_token: ${{ secrets.GITHUB_TOKEN }}
+ upstream_sync_branch: master
+ upstream_sync_repo: aormsby/Fork-Sync-With-Upstream-action
+ upstream_repo_access_token: ${{ secrets.UPSTREAM_REPO_SECRET }}
+
+ # Set test_mode true to run tests instead of the true action!!
+ test_mode: true
+
+ # Step 3: Display a sample message based on the sync output var 'has_new_commits'
+ - name: New commits found
+ if: steps.sync.outputs.has_new_commits == 'true'
+ run: echo "New commits were found to sync."
+
+ - name: No new commits
+ if: steps.sync.outputs.has_new_commits == 'false'
+ run: echo "There were no new commits."
+
+ - name: Show value of 'has_new_commits'
+ run: echo ${{ steps.sync.outputs.has_new_commits }}
\ No newline at end of file
diff --git a/.github/workflows/unit_test.yml b/.github/workflows/unit_test.yml
deleted file mode 100755
index 3b25bcf7d9..0000000000
--- a/.github/workflows/unit_test.yml
+++ /dev/null
@@ -1,16 +0,0 @@
-name: Unit Testing
-
-on:
- push:
- branches: [ master ]
-
-jobs:
- gtest:
- runs-on: ubuntu-latest
- steps:
-
- - name: Checkout
- uses: actions/checkout@v2
-
- - name: Running docker container with openfoam
- run : docker run -v "$PWD/:/root" opencfd/openfoam2106-dev /root/gtest/script.sh
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000000..c8272cfbfe
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,7 @@
+[submodule "extern/pybind11"]
+ path = extern/pybind11
+ url = ../../pybind/pybind11
+ branch = stable
+[submodule "src/thirdparty/Eigen"]
+ path = src/thirdparty/Eigen
+ url = https://gitlab.com/libeigen/eigen.git
diff --git a/README.md b/README.md
index 2ca1686e21..6b68d89519 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-
+
@@ -10,19 +10,19 @@
-
+
-
-
-
-
+
+
+
+
### 0. Introduction
-**ITHACA-FV** is an implementation in **OpenFOAM** of several reduced order modelling techniques. **ITHACA-FV** is designed for [**OpenFOAM v2106**](https://www.openfoam.com/releases/openfoam-v2106/) and older openfoam.com versions but it can be easily adapted also to other versions of OpenFOAM.
+**ITHACA-FV** is an implementation in **OpenFOAM** of several reduced order modelling techniques. **ITHACA-FV** is designed for [**OpenFOAM v2212**](https://www.openfoam.com/news/main-news/openfoam-v2212/) and older openfoam.com versions but it can be easily adapted also to other versions of OpenFOAM.
**ITHACA-FV** can also be used as a basis for more advanced projects that would like to assess the capability of reduced order models in their existing **OpenFOAM**-based software, thanks to the availability of several reduced order methods and algorithms.
@@ -32,12 +32,13 @@ Linear and non-linear algebra operations which are not already implemented in Op
### 1. Prerequisites
**ITHACA-FV** requires
-* [**OpenFOAM 1812**](https://www.openfoam.com/releases/openfoam-v1812/) or
-* [**OpenFOAM 1906**](https://www.openfoam.com/releases/openfoam-v1906/) or
-* [**OpenFOAM 1912**](https://www.openfoam.com/releases/openfoam-v1912/) or
-* [**OpenFOAM 2006**](https://www.openfoam.com/releases/openfoam-v2006/) or
-* [**OpenFOAM 2012**](https://www.openfoam.com/releases/openfoam-v2012/) or
-* [**OpenFOAM 2106**](https://www.openfoam.com/news/main-news/openfoam-v2106)
+* [**OpenFOAM 1812**](https://www.openfoam.com/news/main-news/openfoam-v1812/) or
+* [**OpenFOAM 1906**](https://www.openfoam.com/news/main-news/openfoam-v1906/) or
+* [**OpenFOAM 1912**](https://www.openfoam.com/news/main-news/openfoam-v1912/) or
+* [**OpenFOAM 2006**](https://www.openfoam.com/news/main-news/openfoam-v2006/) or
+* [**OpenFOAM 2012**](https://www.openfoam.com/news/main-news/openfoam-v2012/) or
+* [**OpenFOAM 2106**](https://www.openfoam.com/news/main-news/openfoam-v2106) or
+* [**OpenFOAM 2212**](https://www.openfoam.com/news/main-news/openfoam-v2212)
### 2. Installation and usage
@@ -51,11 +52,12 @@ cd ~
```
Now you can clone the **ITHACA-FV** repository inside the selected folder
```
-git clone https://github.com/mathLab/ITHACA-FV
+git clone --depth 1 https://github.com/ITHACA-FV/ITHACA-FV
```
and you can compile **ITHACA-FV** by navigating inside the src folder, sourcing the bashrc file of ITHACA-FV and compiling using wmake:
```
cd ITHACA-FV
+git submodule update --init
source etc/bashrc
./Allwmake
```
@@ -81,7 +83,7 @@ In the near future the ITHACA-FV will also be linked with the pytorch package fo
unzip libtorch.zip -d opt/ && \
```
-For a brief description of the classes and methods, you can check the official ITHACA-FV doxygen [documentation](https://mathlab.github.io/ITHACA-FV/).
+For a brief description of the classes and methods, you can check the official ITHACA-FV doxygen [documentation](https://ithaca-fv.github.io/ITHACA-FV).
### 3. Docker Image
@@ -100,26 +102,86 @@ Once the image is downloaded, you can start the container and mount the $HOME di
docker run -ti --rm -v "${HOME}:/home/ithacafv/${USER}" ithacafv/ithacafv:manifest-latest
```
-### 4. [Tutorials](https://mathlab.github.io/ITHACA-FV//examples.html)
+### 4. Singularity
+
+
+Create a local directory (which you own), followed by using the variables, `SINGULARITY_TMPDIR` and `SINGULARITY_CACHEDIR` for temporary and cache directory during built proccess. This step is highly recommended if you do NOT have `root` access, as singularity uses a temporary directory to build the squashfs filesystem, and this temp space needs to be large enough to hold the entire resulting Singularity image.
+
+```
+export SINGULARITY_TMPDIR=$HOME/mycontainter
+```
+and
+
+```
+export SINGULARITY_CACHEDIR=$HOME/mycontainter
+```
+
+Buidling singularity image file `.sif` from the docker image, which is build and stored in `$HOME/mycontainter`, The below image used is based **OpenFOAM-v2106**, and where you can find a compiled version of the master branch of **ITHACA-FV**.
+
+```
+singularity build ithacafv.sif docker://ithacafv/ithacafv:manifest-latest
+```
+
+To view / list all the images/cache,
+
+```
+singularity cache list -v
+```
+
+To run the singulairty image interactively, use `shell` from your working directory. This mounts your working directory to the container. Activate the the OpenFOAM environment after`shell`, using `source /usr/lib/openfoam/openfoam2106/etc/bashrc` (or, `source /etc/bash.bashrc`)
+
+```
+singularity shell $HOME/mycontainter/ithacafv.sif
+```
+
+To build singularity images from scratch use defination files, `singularity-reciepe.def` provided in singularity directory. This require `sudo` prilvildges. Recommened to build in detached mode, by passing the flag `-d`.
+
+```
+sudo singularity build -d ithacafv.sif singularity/singularity-reciepe.def
+```
+
+Additionally, `--fakeroot` can be passed if you do NOT have root access for the build.
+
+```
+singularity build --fakeroot ithacafv.sif singularity/singularity-reciepe.def
+```
+
+Running singualrity in batch mode, you can add the following in your the batch script,
+
+```
+singularity exec .sif
+```
+
+For example, running the any tutorial, add the following in the batch script,
+
+```
+singularity exec ithacafv.sif /bin/bash -c Of.sh
+```
+
+the shell script `Of.sh` is provided within the singularity directory. A sample batch scipt is also proived. Please note, over slurm machine, mpi binds without passing any flags.
+
+
+
+### 5. [Tutorials](https://ithaca-fv.github.io/ITHACA-FV//examples.html)
Several tutorials are provided in the [**tutorials** subfolder](./tutorials).
-* [**CFD/Tutorial 1**](https://github.com/mathLab/ITHACA-FV/tree/master/tutorials/CFD/01POD): In this tutorial it is shown how to perform POD on an already run standard **OpenFOAM** case.
-* [**CFD/Tutorial 2**](https://github.com/mathLab/ITHACA-FV/tree/master/tutorials/CFD/02thermalBlock): In this tutorial the development of a parametrized POD-Galerkin ROM for a steady heat transfer problem is implemented. The parametrization is on the diffusivity constant. The OpenFOAM full order problem is based on **laplacianFoam**.
-* [**CFD/Tutorial 3**](https://github.com/mathLab/ITHACA-FV/tree/master/tutorials/CFD/03steadyNS): In this tutorial, the development of a parametrized POD-Galerkin ROM for a steady NS-problem. The parametrization is on the viscosity is implemented. The OpenFOAM full order problem is based on **simpleFoam**.
-* [**CFD/Tutorial 4**](https://mathlab.github.io/ITHACA-FV/04unsteadyNS_8C-example.html): In this tutorial, the development of a parametrized POD-Galerkin method for an unsteady Navier-Stokes problem is implemented. The parametrization is on the viscosity. The OpenFOAM full order problem is based on **pimpleFoam**.
+* [**CFD/Tutorial 1**](https://github.com/ithaca-fv/ITHACA-FV/tree/master/tutorials/CFD/01POD): In this tutorial it is shown how to perform POD on an already run standard **OpenFOAM** case.
+* [**CFD/Tutorial 2**](https://github.com/ithaca-fv/ITHACA-FV/tree/master/tutorials/CFD/02thermalBlock): In this tutorial the development of a parametrized POD-Galerkin ROM for a steady heat transfer problem is implemented. The parametrization is on the diffusivity constant. The OpenFOAM full order problem is based on **laplacianFoam**.
+* [**CFD/Tutorial 3**](https://github.com/ithaca-fv/ITHACA-FV/tree/master/tutorials/CFD/03steadyNS): In this tutorial, the development of a parametrized POD-Galerkin ROM for a steady NS-problem. The parametrization is on the viscosity is implemented. The OpenFOAM full order problem is based on **simpleFoam**.
+* [**CFD/Tutorial 4**](https://ithaca-fv.github.io/ITHACA-FV/04unsteadyNS_8C-example.html): In this tutorial, the development of a parametrized POD-Galerkin method for an unsteady Navier-Stokes problem is implemented. The parametrization is on the viscosity. The OpenFOAM full order problem is based on **pimpleFoam**.
-* [**CFD/Tutorial 6**](https://mathlab.github.io/ITHACA-FV/06POD_RBF_8C-example.html): This tutorial presents the application of data driven POD-Galerkin model to RANS equation in steady state setting. The components of the velocity at the inlet are paramertized. The OpenFOAM full order problem is based on **simpleFoam**.
+* [**CFD/Tutorial 6**](https://ithaca-fv.github.io/ITHACA-FV/06POD_RBF_8C-example.html): This tutorial presents the application of data driven POD-Galerkin model to RANS equation in steady state setting. The components of the velocity at the inlet are paramertized. The OpenFOAM full order problem is based on **simpleFoam**.
-* [**CFD/Tutorial 8**](https://mathlab.github.io/ITHACA-FV/08DEIM_8C-example.html): In this tutorial we propose an example concerning the usage of the Discrete Empirical Interpolation Methods for the reconstruction of a non-linear function. In this case we do not perform model reduction but we test just the motodology a non-linear function.
+* [**CFD/Tutorial 8**](https://ithaca-fv.github.io/ITHACA-FV/08DEIM_8C-example.html): In this tutorial we propose an example concerning the usage of the Discrete Empirical Interpolation Methods for the reconstruction of a non-linear function. In this case we do not perform model reduction but we test just the motodology a non-linear function.
-* [**CFD/Tutorial 9**](https://mathlab.github.io/ITHACA-FV/09DEIM_ROM_8C-example.html): In this tutorial we propose an example concerning the usage of the Discrete Empirical Interpolation Methods for model reduction purposes. The non-linearity is in the forcing term of a heat transfer problem. The OpenFOAM full order problem is based on **laplacianFoam**.
+* [**CFD/Tutorial 9**](https://ithaca-fv.github.io/ITHACA-FV/09DEIM_ROM_8C-example.html): In this tutorial we propose an example concerning the usage of the Discrete Empirical Interpolation Methods for model reduction purposes. The non-linearity is in the forcing term of a heat transfer problem. The OpenFOAM full order problem is based on **laplacianFoam**.
-### 5. Authors and contributors
-**ITHACA-FV** is currently developed and mantained at [SISSA mathLab](http://mathlab.sissa.it/) by [Dr. Giovanni Stabile](mailto:gstabile@sissa.it) under the supervision of [Prof. Gianluigi Rozza](mailto:gianluigi.rozza@sissa.it)
+### 6. Authors and contributors
+**ITHACA-FV** is currently developed and maintained at the [University of Urbino Carlo Bo](https://www.uniurb.it/) by [Dr. Giovanni Stabile](www.giovannistabile.com) and at [SISSA mathLab](http://mathlab.sissa.it/) in collaboration with [Prof. Gianluigi Rozza](https://people.sissa.it/~grozza/)'s group.
-Contact us by email for further information or questions about **ITHACA-FV**, or open an ''Issue'' on this website. **ITHACA-FV** is at an early development stage, so contributions improving either the code or the documentation are welcome, both as patches or merge requests on this website. If you are willing to contribute please follow the [developer instructions](https://github.com/mathLab/ITHACA-FV/tree/master/src).
+Contact us by email for further information or questions about **ITHACA-FV**, or open an ''Issue'' on this website. **ITHACA-FV** is at an early development stage, so contributions improving either the code or the documentation are welcome, both as patches or merge requests on this website. If you are willing to contribute please follow the [developer instructions](https://github.com/ithaca-fv/ITHACA-FV/tree/master/src).
-### 6. How to cite
+### 7. How to cite
Most of the theoretical aspects behind **ITHACA-FV** are deeply explained in [ Stabile2017CAIM ](https://arxiv.org/pdf/1701.03424.pdf) and [ Stabile2017CAF ](https://arxiv.org/pdf/1710.11580.pdf).
For this reason, if you use this software, please consider citing the mentioned works, reported in the following bibtex entries:
```
@@ -143,9 +205,14 @@ Year = {2018},
Doi = {10.1016/j.compfluid.2018.01.035}}
```
+and cite the [ITHACA-FV website](https://ithaca-fv.github.io/ITHACA-FV).
+
+### 8. Funding
+A significant part of ITHACA-FV has been written either as a by-product for other projects people were funded for, or by people on university-funded positions. There are probably many of such projects that have led to some development of ITHACA-FV. We are very grateful for this support!
-and cite the [ITHACA-FV website](http://mathlab.sissa.it/ITHACA-FV).
+Beyond this, ITHACA-FV has also been supported by some dedicated projects that have allowed us to work on extensions, documentation, training and dissemination that would otherwise not have been possible. In particular, we acknowledge the following sources of support with great gratitude:
+* [H2020 ERC CoG 2015 AROMA-CFD project 681447](https://people.sissa.it/~grozza/aroma-cfd/), P.I. Professor [Gianluigi Rozza](https://people.sissa.it/~grozza) at [SISSA mathLab](https://mathlab.sissa.it/).
-### 7. License
+### 8. License
**ITHACA-FV** is freely available under the GNU LGPL, version 3.
diff --git a/dockerfiles/amd64/Dockerfile b/dockerfiles/amd64/Dockerfile
index 27b20d68f7..a4e21aa0ee 100644
--- a/dockerfiles/amd64/Dockerfile
+++ b/dockerfiles/amd64/Dockerfile
@@ -2,8 +2,10 @@ FROM opencfd/openfoam2106-dev
LABEL maintainer="moaadkhamlich@gmail.com"
-# add and enable the default user
+# add enviromental variables and enable the default user
ARG USER=ithacafv
+ARG of_var="source /usr/lib/openfoam/openfoam2106/etc/bashrc"
+ARG ithaca_var="source /usr/lib/ITHACA-FV/etc/bashrc"
ENV USER $USER
# Create the user
@@ -36,11 +38,23 @@ RUN chown -R $USER:$USER openfoam ITHACA-FV
RUN chown -R $USER:$USER /home/$USER
USER $USER
-RUN /bin/bash -c "source openfoam/openfoam2106/etc/bashrc && \
- cd ITHACA-FV && source etc/bashrc && \
- ./Allwmake -au -j 4";
+RUN /bin/bash -c "source /usr/lib/openfoam/openfoam2106/etc/bashrc && \
+ cd ITHACA-FV && git submodule update --init && source /etc/bash.bashrc && \
+ ./Allwmake -tau -j 4";
+
+USER root
+RUN cp -r /home/ithacafv/OpenFOAM/ithacafv-v2106/platforms/linux64GccDPInt32Opt/bin/* /bin/
+RUN cp -r /home/ithacafv/OpenFOAM/ithacafv-v2106/platforms/linux64GccDPInt32Opt/lib/* /lib/
+
+#Update bashrc
+RUN echo $of_var >> /etc/bash.bashrc
+RUN echo $ithaca_var >> /etc/bash.bashrc
+
+#Source bashrc
+USER $USER
+RUN /bin/bash -c "source /etc/bash.bashrc"
USER $USER
WORKDIR $HOME
-COPY .bashrc $HOME/.bashrc
ENTRYPOINT ["/bin/bash"]
+
diff --git a/dockerfiles/arm64/Dockerfile b/dockerfiles/arm64/Dockerfile
index 8023a33d56..b7a91bcde2 100644
--- a/dockerfiles/arm64/Dockerfile
+++ b/dockerfiles/arm64/Dockerfile
@@ -21,15 +21,22 @@ WORKDIR /opt/
RUN git clone https://github.com/mathLab/ITHACA-FV.git
RUN chown -R $USER:$USER OpenFOAM-v2106 OpenFOAM-v2106 ITHACA-FV
RUN chown -R $USER:$USER /home/$USER
+ARG of_var="source /opt/OpenFOAM-v2106/etc/bashrc"
+ARG ithaca_var="source /opt/ITHACA-FV/etc/bashrc"
+#Update bashrc
+RUN echo $of_var >> /etc/bash.bashrc
+RUN echo $ithaca_var >> /etc/bash.bashrc
USER $USER
ENV HOME /home/$USER
ENV USER $USER
RUN /bin/bash -c "source OpenFOAM-v2106/etc/bashrc && \
- cd ITHACA-FV && source etc/bashrc && \
+ cd ITHACA-FV && git submodule update --init && source etc/bashrc && \
./Allwmake -au -j 4";
+#Source bashrc
+RUN /bin/bash -c "source /etc/bash.bashrc"
+
WORKDIR $HOME
-COPY .bashrc $HOME/.bashrc
ENTRYPOINT ["/bin/bash"]
diff --git a/docs/Doxyfile b/docs/Doxyfile
index 046e32c3bd..192c8f8620 100755
--- a/docs/Doxyfile
+++ b/docs/Doxyfile
@@ -38,13 +38,13 @@ PROJECT_NAME = "ITHACA-FV"
# could be handy for archiving the generated documentation or if some version
# control system is used.
-PROJECT_NUMBER = "3.0"
+PROJECT_NUMBER = "2023.1"
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
# quick idea about the purpose of the project. Keep the description short.
-PROJECT_BRIEF = "SISSA mathLab"
+PROJECT_BRIEF = ""
# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
# in the documentation. The maximum height of the logo should not exceed 55
diff --git a/etc/bashrc b/etc/bashrc
index 23ae559232..35e9fc33a8 100755
--- a/etc/bashrc
+++ b/etc/bashrc
@@ -17,6 +17,8 @@ export LIB_ITHACA="$ithacaDir"
export LIB_ITHACA_SRC="$ithacaDir/src"
export PYTHONPATH="$PYTHONPATH:${PYTHONPATH:+:}${LIB_ITHACA_SRC}"/python
export PATH="$PATH:${LIB_ITHACA}"/bin
+export includepybind1=$(python3 -m pybind11 --includes | awk -F '-I' '{print $2}')
+export includepybind2=$(python3 -m pybind11 --includes | awk -F '-I' '{print $3}')
alias ithaca='cd ${LIB_ITHACA:?}'
unset ithacaDir
diff --git a/extern/pybind11 b/extern/pybind11
new file mode 160000
index 0000000000..e315e1fe2b
--- /dev/null
+++ b/extern/pybind11
@@ -0,0 +1 @@
+Subproject commit e315e1fe2bad553ff541ce3bc00804e0e70583a2
diff --git a/singularity/Of.sh b/singularity/Of.sh
new file mode 100755
index 0000000000..9211ab5ab6
--- /dev/null
+++ b/singularity/Of.sh
@@ -0,0 +1,9 @@
+##sourcing the correct bashrc is important
+##bashrc for OpenFOAM
+source /usr/lib/openfoam/openfoam2106/etc/bashrc
+## bashrc for OpenFOAM and Ithaca-FV
+##source /etc/bash.bashrc
+
+##./Allrun
+icoFoam ##-paralell
+perform_POD
diff --git a/singularity/batch_script b/singularity/batch_script
new file mode 100644
index 0000000000..103dabbacb
--- /dev/null
+++ b/singularity/batch_script
@@ -0,0 +1,33 @@
+#!/bin/bash
+#SBATCH -n 4 # Number of cores
+#SBATCH -t 0-00:45 # Runtime in D-HH:MM
+#SBATCH --job-name=singularity
+#SBATCH -p regular1
+
+
+#load singularity and MPI modules
+module load singularity/3.4.1
+module load intel/2021.2
+module load openmpi3
+
+
+echo "Starting singularity on host $HOSTNAME"
+
+#this binds mpi, so we do not need to
+#srun -n 4 singularity exec ithacafv.sif /bin/bash Of.sh
+
+#without MPI
+singularity exec ithicafv.sif /bin/bash Of.sh
+
+#Other valid
+
+#mpi run not recomeneded
+#mpirun -n 4 singularity exec ithacafv.sif /bin/bash Of.sh
+
+#mpiexec -n 4 singularity exec ithacafv.sif /bin/bash Of.sh
+
+#singularity exec ithicafv.sif /bin/bash Of.sh
+
+echo "Completed singularity on host $HOSTNAME"
+
+
diff --git a/singularity/singularity-recipe.def b/singularity/singularity-recipe.def
new file mode 100644
index 0000000000..d75d366e92
--- /dev/null
+++ b/singularity/singularity-recipe.def
@@ -0,0 +1,104 @@
+
+Bootstrap: docker
+From: opencfd/openfoam2106-dev
+Stage: build
+
+
+%environment
+ of_var="source /usr/lib/openfoam/openfoam2106/etc/bashrc"
+ ithaca_var="source /usr/lib/ITHACA-FV/etc/bashrc"
+ export of_var ithaca_var
+
+%post
+
+ #Define variables
+ USER="ithacafv"
+ of_var="source /usr/lib/openfoam/openfoam2106/etc/bashrc"
+ ithaca_var="source /usr/lib/ITHACA-FV/etc/bashrc"
+
+ # Create the user
+ cd ~
+ adduser --disabled-password --gecos '' $USER && \
+ adduser $USER sudo; echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers && \
+ usermod -a -G $USER $USER && \
+ userdel sudofoam && \
+ usermod -u 1000 ithacafv && \
+ groupmod -g 1000 ithacafv
+
+ cd /home/$USER
+
+ chown -R $USER:$USER /home/$USER
+ chown -R $USER:$USER /home/openfoam && rm -r /home/openfoam && \
+ chown -R $USER:$USER /home/sudofoam && rm -r /home/sudofoam
+
+ #install necessary packages
+ cd ~
+
+ sudo apt-get update
+ sudo apt-get install git -y
+ sudo apt-get install vim -y
+
+ #get the lastest version of ITHACA-FV
+ cd /usr/lib/
+
+ git clone https://github.com/mathLab/ITHACA-FV.git
+
+ #install ITHACA-FV
+ /bin/bash -c "source /usr/lib/openfoam/openfoam2106/etc/bashrc && \
+ cd ITHACA-FV && git submodule update --init && source /etc/bash.bashrc && \
+ ./Allwmake -tau -j 4 && \
+ cd ~ && \
+ cp -r /root/OpenFOAM/-v2106/platforms/linux64GccDPInt32Opt/bin/* /bin/ &&\
+ cp -r /root/OpenFOAM/-v2106/platforms/linux64GccDPInt32Opt/lib/* /lib/"
+
+ #Update bashrc
+ echo $of_var >> /etc/bash.bashrc
+ echo $ithaca_var >> /etc/bash.bashrc
+
+ #source bashrc
+ /bin/bash -c "source /etc/bash.bashrc"
+
+
+%runscript
+ /bin/bash -c "source /etc/bash.bashrc"
+ echo "singularity container for ithacafv with openfoam"
+ echo "to activate the openfoam environment use"
+ echo "source /usr/lib/openfoam/openfoam2106/etc/bashrc"
+ echo "to activate the openfoam and ithacafv environment use"
+ echo "source /etc/bash.bashrc"
+
+
+%labels
+ Author Pavan Pranjivan Mehta, Email : pavan_pranjivan_mehta@alumni.brown.edu
+ Version v0.1
+
+%help
+ This is a singularity container for ITHACA-FV.
+
+ Please note the openFoam version is as per the docker image : "opencfd/openfoam2106-dev".
+
+ Change the docker image in the ".def" file for a different openFoam version.
+
+ Source code : https://github.com/mathLab/ITHACA-FV.git
+
+ 1. To run intertactively, use "run" or "shell",
+ singularity shell
+
+ 2. To run in batch mode, use "exec" / "run"
+ singularity exec
+
+ 3. MPI over slurm binds itself, with "exec"
+ mpirun -n $n singularity exec
+
+ Other valid statements,
+
+ srun -n $n singularity exec
+
+ mpiexec -n $n singularity exec
+
+ 4. Using MPI over non-slurm machine, you will need to pass "--bind" with path to MPI installation directory.
+
+
+ Author : Pavan Pranjivan Mehta
+ Email : pavan.mehta@sissa.it
+
diff --git a/src/ITHACA_CORE/Foam2Eigen/Foam2Eigen.C b/src/ITHACA_CORE/Foam2Eigen/Foam2Eigen.C
old mode 100755
new mode 100644
index 761d4e02a5..42af14dfe3
--- a/src/ITHACA_CORE/Foam2Eigen/Foam2Eigen.C
+++ b/src/ITHACA_CORE/Foam2Eigen/Foam2Eigen.C
@@ -36,7 +36,28 @@ License
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
-template class PatchField, class GeoMesh>
+template class PatchField, class GeoMesh>
+Eigen::VectorXd Foam2Eigen::field2Eigen(
+ GeometricField& field)
+{
+ Eigen::VectorXd out;
+ out.resize(label(field.size() * 9));
+
+ for (label l = 0; l < field.size(); l++)
+ {
+ for (label j = 0; j < 9; j++)
+ {
+ out(j * field.size() + l) = field[l][j];
+ }
+ }
+
+ return out;
+}
+
+template Eigen::VectorXd Foam2Eigen::field2Eigen(
+ volTensorField& field);
+
+template class PatchField, class GeoMesh>
Eigen::VectorXd Foam2Eigen::field2Eigen(
GeometricField& field)
{
@@ -45,9 +66,10 @@ Eigen::VectorXd Foam2Eigen::field2Eigen(
for (label l = 0; l < field.size(); l++)
{
- out(l) = field[l][0];
- out(field.size() + l ) = field[l][1];
- out(2 * field.size() + l ) = field[l][2];
+ for (label j = 0; j < 3; j++)
+ {
+ out(j * field.size() + l) = field[l][j];
+ }
}
return out;
@@ -56,7 +78,7 @@ Eigen::VectorXd Foam2Eigen::field2Eigen(
template Eigen::VectorXd Foam2Eigen::field2Eigen(
volVectorField& field);
-template class PatchField, class GeoMesh>
+template class PatchField, class GeoMesh>
Eigen::VectorXd Foam2Eigen::field2Eigen(
GeometricField& field)
{
@@ -71,12 +93,23 @@ Eigen::VectorXd Foam2Eigen::field2Eigen(
return out;
}
+template class PatchField, class GeoMesh>
+Eigen::Map Foam2Eigen::field2EigenMap(
+ GeometricField& field)
+{
+ Eigen::Map output(field.ref().data(), field.size(), 1);
+ return std::move(output);
+}
+
+template Eigen::Map Foam2Eigen::field2EigenMap(
+ volScalarField& field);
+
template Eigen::VectorXd Foam2Eigen::field2Eigen(
volScalarField& field);
template Eigen::VectorXd Foam2Eigen::field2Eigen(
surfaceScalarField& field);
-template<>
+template <>
Eigen::VectorXd Foam2Eigen::field2Eigen(const Field& field)
{
Eigen::VectorXd out;
@@ -90,7 +123,7 @@ Eigen::VectorXd Foam2Eigen::field2Eigen(const Field& field)
return out;
}
-template<>
+template <>
Eigen::VectorXd Foam2Eigen::field2Eigen(const Field& field)
{
Eigen::VectorXd out;
@@ -98,15 +131,33 @@ Eigen::VectorXd Foam2Eigen::field2Eigen(const Field& field)
for (label l = 0; l < field.size(); l++)
{
- out(l) = field[l][0];
- out(field.size() + l ) = field[l][1];
- out(2 * field.size() + l ) = field[l][2];
+ for (label j = 0; j < 3; j++)
+ {
+ out(j * field.size() + l) = field[l][j];
+ }
}
return out;
}
-template<>
+template <>
+Eigen::VectorXd Foam2Eigen::field2Eigen(const Field& field)
+{
+ Eigen::VectorXd out;
+ out.resize(label(field.size() * 9));
+
+ for (label l = 0; l < field.size(); l++)
+ {
+ for (label j = 0; j < 9; j++)
+ {
+ out(j * field.size() + l) = field[l][j];
+ }
+ }
+
+ return out;
+}
+
+template <>
Eigen::VectorXd Foam2Eigen::field2Eigen(const
DimensionedField& field)
{
@@ -121,7 +172,35 @@ Eigen::VectorXd Foam2Eigen::field2Eigen(const
return out;
}
-template class PatchField, class GeoMesh>
+template class PatchField, class GeoMesh>
+List Foam2Eigen::field2EigenBC(
+ GeometricField& field)
+{
+ List Out;
+ label size = field.boundaryField().size();
+ Out.resize(size);
+
+ for (label i = 0; i < size; i++)
+ {
+ label sizei = field.boundaryField()[i].size();
+ Out[i].resize(sizei * 9);
+
+ for (label k = 0; k < sizei; k++)
+ {
+ for (label j = 0; j < 9; j++)
+ {
+ Out[i](k + j * sizei) = field.boundaryField()[i][k][j];
+ }
+ }
+ }
+
+ return Out;
+}
+
+template List Foam2Eigen::field2EigenBC(
+ volTensorField& field);
+
+template class PatchField, class GeoMesh>
List Foam2Eigen::field2EigenBC(
GeometricField& field)
{
@@ -129,16 +208,17 @@ List Foam2Eigen::field2EigenBC(
label size = field.boundaryField().size();
Out.resize(size);
- for (label i = 0; i < size; i++ )
+ for (label i = 0; i < size; i++)
{
label sizei = field.boundaryField()[i].size();
Out[i].resize(sizei * 3);
- for (label k = 0; k < sizei ; k++)
+ for (label k = 0; k < sizei; k++)
{
- Out[i](k) = field.boundaryField()[i][k][0];
- Out[i](k + sizei) = field.boundaryField()[i][k][1];
- Out[i](k + 2 * sizei) = field.boundaryField()[i][k][2];
+ for (label j = 0; j < 3; j++)
+ {
+ Out[i](k + j * sizei) = field.boundaryField()[i][k][j];
+ }
}
}
@@ -149,7 +229,7 @@ template List Foam2Eigen::field2EigenBC(
volVectorField& field);
-template class PatchField, class GeoMesh>
+template class PatchField, class GeoMesh>
List Foam2Eigen::field2EigenBC(
GeometricField& field)
{
@@ -157,12 +237,12 @@ List Foam2Eigen::field2EigenBC(
label size = field.boundaryField().size();
Out.resize(size);
- for (label i = 0; i < size; i++ )
+ for (label i = 0; i < size; i++)
{
label sizei = field.boundaryField()[i].size();
Out[i].resize(sizei);
- for (label k = 0; k < sizei ; k++)
+ for (label k = 0; k < sizei; k++)
{
Out[i](k) = field.boundaryField()[i][k];
}
@@ -173,10 +253,11 @@ List Foam2Eigen::field2EigenBC(
template List Foam2Eigen::field2EigenBC(
volScalarField& field);
-template class PatchField, class GeoMesh>
+template class PatchField, class GeoMesh>
List Foam2Eigen::PtrList2EigenBC(
PtrList>&
- fields, label Nfields)
+ fields,
+ label Nfields)
{
label Nf;
M_Assert(Nfields <= fields.size(),
@@ -221,10 +302,11 @@ template List Foam2Eigen::PtrList2EigenBC(
PtrList& fields, label Nfields);
-template class PatchField, class GeoMesh>
+template class PatchField, class GeoMesh>
List Foam2Eigen::PtrList2EigenBC(
PtrList>&
- fields, label Nfields)
+ fields,
+ label Nfields)
{
label Nf;
M_Assert(Nfields <= fields.size(),
@@ -266,7 +348,80 @@ List Foam2Eigen::PtrList2EigenBC(
template List Foam2Eigen::PtrList2EigenBC(
PtrList& fields, label Nfields);
-template class PatchField, class GeoMesh>
+
+template class PatchField, class GeoMesh>
+List Foam2Eigen::PtrList2EigenBC(
+ PtrList>&
+ fields,
+ label Nfields)
+{
+ label Nf;
+ M_Assert(Nfields <= fields.size(),
+ "The Number of requested fields cannot be bigger than the number of requested entries.");
+
+ if (Nfields == -1)
+ {
+ Nf = fields.size();
+ }
+ else
+ {
+ Nf = Nfields;
+ }
+
+ List Out;
+ label NBound = fields[0].boundaryField().size();
+ Out.resize(NBound);
+
+ for (label i = 0; i < NBound; i++)
+ {
+ label sizei = fields[0].boundaryField()[i].size();
+ Out[i].resize(sizei * 9, Nf);
+ }
+
+ for (label k = 0; k < Nf; k++)
+ {
+ List temp;
+ temp = field2EigenBC(fields[k]);
+
+ for (label i = 0; i < NBound; i++)
+ {
+ Out[i].col(k) = temp[i];
+ }
+ }
+
+ return Out;
+}
+
+template List Foam2Eigen::PtrList2EigenBC(
+ PtrList& fields, label Nfields);
+
+template class PatchField, class GeoMesh>
+GeometricField Foam2Eigen::Eigen2field(
+ GeometricField& field_in,
+ Eigen::VectorXd& eigen_vector, bool correctBC)
+{
+ GeometricField field_out(field_in);
+
+ for (auto i = 0; i < field_out.size(); i++)
+ {
+ for (label j = 0; j < 9; j++)
+ {
+ field_out.ref()[i][j] = eigen_vector(i + field_out.size() * j);
+ }
+ }
+
+ if (correctBC)
+ {
+ field_out.correctBoundaryConditions();
+ }
+
+ return field_out;
+}
+
+template volTensorField Foam2Eigen::Eigen2field(
+ volTensorField& field_in, Eigen::VectorXd& eigen_vector, bool correctBC);
+
+template class PatchField, class GeoMesh>
GeometricField Foam2Eigen::Eigen2field(
GeometricField& field_in,
Eigen::VectorXd& eigen_vector, bool correctBC)
@@ -275,9 +430,10 @@ GeometricField Foam2Eigen::Eigen2field(
for (auto i = 0; i < field_out.size(); i++)
{
- field_out.ref()[i][0] = eigen_vector(i);
- field_out.ref()[i][1] = eigen_vector(i + field_out.size());
- field_out.ref()[i][2] = eigen_vector(i + field_out.size() * 2);
+ for (label j = 0; j < 3; j++)
+ {
+ field_out.ref()[i][j] = eigen_vector(i + field_out.size() * j);
+ }
}
if (correctBC)
@@ -291,7 +447,7 @@ GeometricField Foam2Eigen::Eigen2field(
template volVectorField Foam2Eigen::Eigen2field(
volVectorField& field_in, Eigen::VectorXd& eigen_vector, bool correctBC);
-template class PatchField, class GeoMesh>
+template class PatchField, class GeoMesh>
GeometricField Foam2Eigen::Eigen2field(
GeometricField& field_in,
Eigen::VectorXd& eigen_vector, bool correctBC)
@@ -311,7 +467,7 @@ template surfaceScalarField Foam2Eigen::Eigen2field(
Eigen::VectorXd& eigen_vector,
bool correctBC);
-template<>
+template <>
volScalarField Foam2Eigen::Eigen2field(
volScalarField& field_in, Eigen::VectorXd& eigen_vector, bool correctBC)
{
@@ -330,7 +486,7 @@ volScalarField Foam2Eigen::Eigen2field(
return field_out;
}
-template<>
+template <>
Field Foam2Eigen::Eigen2field(
Field& field, Eigen::MatrixXd& matrix, bool correctBC)
{
@@ -359,7 +515,7 @@ Field Foam2Eigen::Eigen2field(
return field;
}
-template<>
+template <>
Field Foam2Eigen::Eigen2field(
Field& field, Eigen::MatrixXd& matrix, bool correctBC)
{
@@ -382,15 +538,48 @@ Field Foam2Eigen::Eigen2field(
for (auto i = 0; i < sizeBC; i++)
{
- field[i][0] = matrix(i, 0);
- field[i][1] = matrix(i, 1);
- field[i][2] = matrix(i, 2);
+ for (label j = 0; j < 3; j++)
+ {
+ field[i][j] = matrix(i, j);
+ }
}
return field;
}
-template class PatchField, class GeoMesh>
+template <>
+Field Foam2Eigen::Eigen2field(
+ Field& field, Eigen::MatrixXd& matrix, bool correctBC)
+{
+ label sizeBC = field.size();
+ M_Assert(matrix.cols() == 9,
+ "The number of columns of the Input members is not correct, it should be 1");
+
+ if (matrix.rows() == 1)
+ {
+ Eigen::MatrixXd new_matrix = matrix.replicate(sizeBC, 1);
+ matrix.conservativeResize(sizeBC, 9);
+ matrix = new_matrix;
+ }
+
+ std::string message = "The input Eigen::MatrixXd has size " + name(
+ matrix.rows()) +
+ ". It should have the same size of the Field, i.e. " +
+ name(sizeBC);
+ M_Assert(matrix.rows() == sizeBC, message.c_str());
+
+ for (auto i = 0; i < sizeBC; i++)
+ {
+ for (label j = 0; j < 9; j++)
+ {
+ field[i][j] = matrix(i, j);
+ }
+ }
+
+ return field;
+}
+
+template class PatchField, class GeoMesh>
Eigen::MatrixXd Foam2Eigen::PtrList2Eigen(
PtrList>& fields,
label Nfields)
@@ -422,14 +611,21 @@ Eigen::MatrixXd Foam2Eigen::PtrList2Eigen(
template Eigen::MatrixXd
Foam2Eigen::PtrList2Eigen(PtrList&
- fields, label Nfields);
+ fields,
+ label Nfields);
template Eigen::MatrixXd Foam2Eigen::PtrList2Eigen(PtrList&
- fields, label Nfields);
+ fields,
+ label Nfields);
template Eigen::MatrixXd
Foam2Eigen::PtrList2Eigen(PtrList&
- fields, label Nfields);
+ fields,
+ label Nfields);
+template Eigen::MatrixXd
+Foam2Eigen::PtrList2Eigen(PtrList&
+ fields,
+ label Nfields);
-template<>
+template <>
void Foam2Eigen::fvMatrix2Eigen(fvMatrix foam_matrix,
Eigen::MatrixXd& A,
Eigen::VectorXd& b)
@@ -460,12 +656,12 @@ void Foam2Eigen::fvMatrix2Eigen(fvMatrix foam_matrix,
label w = ptch.faceCells()[J];
const double intern = foam_matrix.internalCoeffs()[I][J];
A(w, w) += intern;
- b(w, 0) += foam_matrix.boundaryCoeffs()[I][J];
+ b(w, 0) += foam_matrix.boundaryCoeffs()[I][J];
}
}
}
-template<>
+template <>
void Foam2Eigen::fvMatrix2Eigen(fvMatrix foam_matrix,
Eigen::MatrixXd& A,
Eigen::VectorXd& b)
@@ -505,14 +701,14 @@ void Foam2Eigen::fvMatrix2Eigen(fvMatrix foam_matrix,
A(w, w) += foam_matrix.internalCoeffs()[I][J][0];
A(w + sizeA, w + sizeA) += foam_matrix.internalCoeffs()[I][J][1];
A(w + sizeA * 2, w + sizeA * 2) += foam_matrix.internalCoeffs()[I][J][2];
- b(w) += foam_matrix.boundaryCoeffs()[I][J][0];
- b(w + sizeA) += foam_matrix.boundaryCoeffs()[I][J][1];
- b(w + sizeA * 2) += foam_matrix.boundaryCoeffs()[I][J][2];
+ b(w) += foam_matrix.boundaryCoeffs()[I][J][0];
+ b(w + sizeA) += foam_matrix.boundaryCoeffs()[I][J][1];
+ b(w + sizeA * 2) += foam_matrix.boundaryCoeffs()[I][J][2];
}
}
}
-template<>
+template <>
void Foam2Eigen::fvMatrix2Eigen(fvMatrix foam_matrix,
Eigen::SparseMatrix& A, Eigen::VectorXd& b)
{
@@ -547,13 +743,13 @@ void Foam2Eigen::fvMatrix2Eigen(fvMatrix foam_matrix,
{
label w = ptch.faceCells()[J];
tripletList.push_back(Trip(w, w, foam_matrix.internalCoeffs()[I][J]));
- b(w, 0) += foam_matrix.boundaryCoeffs()[I][J];
+ b(w, 0) += foam_matrix.boundaryCoeffs()[I][J];
}
}
A.setFromTriplets(tripletList.begin(), tripletList.end());
}
-template<>
+template <>
void Foam2Eigen::fvMatrix2Eigen(fvMatrix foam_matrix,
Eigen::SparseMatrix& A, Eigen::VectorXd& b)
{
@@ -605,15 +801,15 @@ void Foam2Eigen::fvMatrix2Eigen(fvMatrix foam_matrix,
foam_matrix.internalCoeffs()[I][J][1]));
tripletList.push_back(Trip(w + sizeA * 2, w + sizeA * 2,
foam_matrix.internalCoeffs()[I][J][2]));
- b(w) += foam_matrix.boundaryCoeffs()[I][J][0];
- b(w + sizeA) += foam_matrix.boundaryCoeffs()[I][J][1];
- b(w + sizeA * 2) += foam_matrix.boundaryCoeffs()[I][J][2];
+ b(w) += foam_matrix.boundaryCoeffs()[I][J][0];
+ b(w + sizeA) += foam_matrix.boundaryCoeffs()[I][J][1];
+ b(w + sizeA * 2) += foam_matrix.boundaryCoeffs()[I][J][2];
}
}
A.setFromTriplets(tripletList.begin(), tripletList.end());
}
-template<>
+template <>
void Foam2Eigen::fvMatrix2EigenM(fvMatrix& foam_matrix,
Eigen::MatrixXd& A)
{
@@ -644,7 +840,7 @@ void Foam2Eigen::fvMatrix2EigenM(fvMatrix& foam_matrix,
}
}
-template<>
+template <>
void Foam2Eigen::fvMatrix2EigenM(fvMatrix& foam_matrix,
Eigen::SparseMatrix& A)
{
@@ -682,7 +878,7 @@ void Foam2Eigen::fvMatrix2EigenM(fvMatrix& foam_matrix,
A.setFromTriplets(tripletList.begin(), tripletList.end());
}
-template<>
+template <>
void Foam2Eigen::fvMatrix2EigenM(fvMatrix& foam_matrix,
Eigen::MatrixXd& A)
{
@@ -722,7 +918,7 @@ void Foam2Eigen::fvMatrix2EigenM(fvMatrix& foam_matrix,
}
-template<>
+template <>
void Foam2Eigen::fvMatrix2EigenM(fvMatrix& foam_matrix,
Eigen::SparseMatrix& A)
{
@@ -775,7 +971,7 @@ void Foam2Eigen::fvMatrix2EigenM(fvMatrix& foam_matrix,
A.setFromTriplets(tripletList.begin(), tripletList.end());
}
-template<>
+template <>
void Foam2Eigen::fvMatrix2EigenV(fvMatrix& foam_matrix,
Eigen::VectorXd& b)
{
@@ -793,12 +989,12 @@ void Foam2Eigen::fvMatrix2EigenV(fvMatrix& foam_matrix,
forAll(ptch, J)
{
label w = ptch.faceCells()[J];
- b(w, 0) += foam_matrix.boundaryCoeffs()[I][J];
+ b(w, 0) += foam_matrix.boundaryCoeffs()[I][J];
}
}
}
-template<>
+template <>
void Foam2Eigen::fvMatrix2EigenV(fvMatrix& foam_matrix,
Eigen::VectorXd& b)
{
@@ -818,14 +1014,14 @@ void Foam2Eigen::fvMatrix2EigenV(fvMatrix& foam_matrix,
forAll(ptch, J)
{
label w = ptch.faceCells()[J];
- b(w) += foam_matrix.boundaryCoeffs()[I][J][0];
- b(w + sizeA) += foam_matrix.boundaryCoeffs()[I][J][1];
- b(w + sizeA * 2) += foam_matrix.boundaryCoeffs()[I][J][2];
+ b(w) += foam_matrix.boundaryCoeffs()[I][J][0];
+ b(w + sizeA) += foam_matrix.boundaryCoeffs()[I][J][1];
+ b(w + sizeA * 2) += foam_matrix.boundaryCoeffs()[I][J][2];
}
}
}
-template class PatchField, class GeoMesh>
+template class PatchField, class GeoMesh>
Eigen::VectorXd Foam2Eigen::projectField(
GeometricField& field,
PtrList>& modes,
@@ -850,7 +1046,7 @@ Eigen::VectorXd Foam2Eigen::projectField(
return fr;
}
-template class PatchField, class GeoMesh>
+template class PatchField, class GeoMesh>
std::tuple Foam2Eigen::projectFvMatrix(
fvMatrix& matrix,
PtrList>& modes, label Nmodes)
@@ -888,12 +1084,12 @@ std::tuple Foam2Eigen::projectFvMatrix(
Ar = Eig_Modes.transpose() * A * Eig_Modes;
br = Eig_Modes.transpose() * b;
- std::tuple tupla;
+ std::tuple tupla;
tupla = std::make_tuple(Ar, br);
return tupla;
}
-template class PatchField, class GeoMesh>
+template class PatchField, class GeoMesh>
Eigen::MatrixXd Foam2Eigen::MassMatrix(
PtrList>& modes, label Nmodes)
{
@@ -928,13 +1124,13 @@ Eigen::MatrixXd Foam2Eigen::MassMatrix(
return Mr;
}
-template
+template
std::tuple>, List>
Foam2Eigen::LFvMatrix2LSM(PtrList>& MatrixList)
{
List> SM_list;
List V_list;
- label LSize = MatrixList.size();
+ label LSize = MatrixList.size();
SM_list.resize(LSize);
V_list.resize(LSize);
Eigen::SparseMatrix A;
@@ -947,7 +1143,7 @@ std::tuple>, List>
V_list[j] = b;
}
- std::tuple >, List> tupla;
+ std::tuple>, List> tupla;
tupla = std::make_tuple(SM_list, V_list);
return tupla;
}
@@ -957,9 +1153,9 @@ Foam2Eigen::LFvMatrix2LSM(PtrList>& MatrixList);
template std::tuple>, List>
Foam2Eigen::LFvMatrix2LSM(PtrList>& MatrixList);
-template
+template
Eigen::Matrix
-Foam2Eigen::List2EigenMatrix ( List list )
+Foam2Eigen::List2EigenMatrix(List list)
{
Eigen::Matrix matrix(list.size(),
1);
@@ -973,13 +1169,13 @@ Foam2Eigen::List2EigenMatrix ( List list )
}
template Eigen::Matrix
-Foam2Eigen::List2EigenMatrix ( List list );
+Foam2Eigen::List2EigenMatrix(List list);
template Eigen::Matrix
-Foam2Eigen::List2EigenMatrix ( List list );
+Foam2Eigen::List2EigenMatrix(List list);
-template
-List Foam2Eigen::EigenMatrix2List (
- Eigen::Matrix matrix )
+template
+List Foam2Eigen::EigenMatrix2List(
+ Eigen::Matrix matrix)
{
if (matrix.cols() == 1)
{
@@ -1000,12 +1196,12 @@ List Foam2Eigen::EigenMatrix2List (
}
}
-template List Foam2Eigen::EigenMatrix2List (
- Eigen::Matrix matrix );
-template List Foam2Eigen::EigenMatrix2List (
- Eigen::Matrix matrix );
+template List Foam2Eigen::EigenMatrix2List(
+ Eigen::Matrix matrix);
+template List Foam2Eigen::EigenMatrix2List(
+ Eigen::Matrix matrix);
-template<>
+template <>
Eigen::MatrixXd Foam2Eigen::field2Eigen(const List& field)
{
Eigen::MatrixXd out;
@@ -1013,15 +1209,16 @@ Eigen::MatrixXd Foam2Eigen::field2Eigen(const List& field)
for (label l = 0; l < field.size(); l++)
{
- out(l, 0) = field[l][0];
- out(field.size() + l, 0 ) = field[l][1];
- out(2 * field.size() + l, 0 ) = field[l][2];
+ for (label j = 0; j < 3; j++)
+ {
+ out(j * field.size() + l, 0) = field[l][j];
+ }
}
return out;
}
-template<>
+template <>
Eigen::MatrixXd Foam2Eigen::field2Eigen(const List& field)
{
Eigen::MatrixXd out;
diff --git a/src/ITHACA_CORE/Foam2Eigen/Foam2Eigen.H b/src/ITHACA_CORE/Foam2Eigen/Foam2Eigen.H
index 12d02f39c2..208a6e08bb 100644
--- a/src/ITHACA_CORE/Foam2Eigen/Foam2Eigen.H
+++ b/src/ITHACA_CORE/Foam2Eigen/Foam2Eigen.H
@@ -142,6 +142,20 @@ class Foam2Eigen
PtrList>& fields,
label Nfields = -1);
+ //----------------------------------------------------------------------
+ /// @brief Convert a vector OpenFOAM field into an Eigen Vector
+ ///
+ /// @param[in] field The field
+ ///
+ /// @tparam PatchField fvPatchField or fvsPatchField.
+ /// @tparam GeoMesh volMesh or surfaceMesh.
+ ///
+ /// @return Dense Eigen vector
+ ///
+ template class PatchField, class GeoMesh>
+ static Eigen::VectorXd field2Eigen(GeometricField&
+ field);
+
//----------------------------------------------------------------------
/// @brief Convert a vector OpenFOAM field into an Eigen Vector
///
@@ -170,6 +184,21 @@ class Foam2Eigen
static Eigen::VectorXd field2Eigen(GeometricField&
field);
+ //----------------------------------------------------------------------
+ /// @brief Convert a scalar OpenFOAM field into an Eigen Vector
+ ///
+ /// @param[in] field The field
+ ///
+ /// @tparam PatchField fvPatchField or fvsPatchField.
+ /// @tparam GeoMesh volMesh or surfaceMesh.
+ ///
+ /// @return Dense Eigen vector
+ ///
+ template class PatchField, class GeoMesh>
+ static Eigen::Map field2EigenMap(
+ GeometricField&
+ field);
+
//----------------------------------------------------------------------
/// @brief Convert an OpenFOAM field into an Eigen Vector
///
@@ -227,6 +256,21 @@ class Foam2Eigen
static List field2EigenBC(
GeometricField& field);
+ //----------------------------------------------------------------------
+ /// @brief Convert an OpenFOAM tensor field to a List of Eigen
+ /// Vectors, one for each boundary
+ ///
+ /// @param[in] field The field
+ ///
+ /// @tparam PatchField fvPatchField or fvsPatchField.
+ /// @tparam GeoMesh volMesh or surfaceMesh.
+ ///
+ /// @return Dense Eigen vector
+ ///
+ template class PatchField, class GeoMesh>
+ static List field2EigenBC(
+ GeometricField& field);
+
//----------------------------------------------------------------------
/// @brief Convert an OpenFOAM scalar field to a List of Eigen
@@ -262,6 +306,23 @@ class Foam2Eigen
PtrList>& fields,
label Nfields = -1);
+ //----------------------------------------------------------------------
+ /// @brief Convert an OpenFOAM vector field to a List of Eigen
+ /// Vectors, one for each boundary
+ ///
+ /// @param[in] fields The field
+ /// @param[in] Nfields The nfields
+ ///
+ /// @tparam PatchField fvPatchField or fvsPatchField.
+ /// @tparam GeoMesh volMesh or surfaceMesh.
+ ///
+ /// @return Dense Eigen matrix
+ ///
+ template class PatchField, class GeoMesh>
+ static List PtrList2EigenBC(
+ PtrList>& fields,
+ label Nfields = -1);
+
//----------------------------------------------------------------------
/// @brief Convert a vector in Eigen format into an OpenFOAM
/// scalar GeometricField
@@ -296,6 +357,23 @@ class Foam2Eigen
GeometricField& field,
Eigen::VectorXd& eigen_vector, bool correctBC = true);
+ //----------------------------------------------------------------------
+ /// @brief Convert a vector in Eigen format into an OpenFOAM
+ /// tensor GeometricField
+ ///
+ /// @param[in/out] field OpenFOAM GeometricField
+ /// @param[in] eigen_vector Vector in Eigen format
+ ///
+ /// @tparam PatchField fvPatchField or fvsPatchField.
+ /// @tparam GeoMesh volMesh or surfaceMesh.
+ ///
+ /// @return OpenFOAM GeometricField
+ ///
+ template class PatchField, class GeoMesh>
+ static GeometricField Eigen2field(
+ GeometricField& field,
+ Eigen::VectorXd& eigen_vector, bool correctBC = true);
+
//----------------------------------------------------------------------
/// @brief Converts a matrix in Eigen format into an OpenFOAM
/// Field
diff --git a/src/ITHACA_CORE/ITHACAstream/ITHACAparameters.H b/src/ITHACA_CORE/ITHACAstream/ITHACAparameters.H
index b10d3ab796..42ed0efa44 100755
--- a/src/ITHACA_CORE/ITHACAstream/ITHACAparameters.H
+++ b/src/ITHACA_CORE/ITHACAstream/ITHACAparameters.H
@@ -22,11 +22,11 @@ License
You should have received a copy of the GNU Lesser General Public License
along with ITHACA-FV. If not, see .
Class
- IHACAparameters
+ ITHACAparameters
Description
Some parameters for input output informations
SourceFiles
- IHACAparameters.H
+ ITHACAparameters.H
\*---------------------------------------------------------------------------*/
#ifndef Parameters_H
#define Parameters_H
diff --git a/src/ITHACA_CORE/ITHACAstream/ITHACAstream.C b/src/ITHACA_CORE/ITHACAstream/ITHACAstream.C
index 112d5ec1a0..e782b06978 100644
--- a/src/ITHACA_CORE/ITHACAstream/ITHACAstream.C
+++ b/src/ITHACA_CORE/ITHACAstream/ITHACAstream.C
@@ -121,24 +121,25 @@ void exportMatrix(Eigen::Matrix < T, -1, dim > & matrix,
std::ofstream ofs;
ofs.precision(20);
ofs.open (folder + "/" + Name + "_mat.txt");
+
for (int i = 0; i < matrix.rows(); i++)
{
for (int j = 0; j < matrix.cols(); j++)
{
- if (j == 0)
- {
- ofs << matrix(i,j);
- }
- else
- {
- ofs << " " << matrix(i,j);
- }
+ if (j == 0)
+ {
+ ofs << matrix(i, j);
+ }
+ else
+ {
+ ofs << " " << matrix(i, j);
+ }
}
if (i != (matrix.rows() - 1))
{
- ofs << std::endl;
- }
+ ofs << std::endl;
+ }
}
ofs.close();
@@ -737,6 +738,9 @@ template void exportFields(
template void exportFields(
PtrList>& field,
word folder, word fieldname);
+template void exportFields(
+ PtrList>& field,
+ word folder, word fieldname);
template class PatchField, class GeoMesh>
void exportSolution(GeometricField& s,
@@ -828,6 +832,9 @@ template void exportSolution(
template void exportSolution(
GeometricField& s,
fileName subfolder, fileName folder);
+template void exportSolution(
+ GeometricField& s,
+ fileName subfolder, fileName folder);
void writePoints(pointField points, fileName folder,
fileName subfolder)
@@ -905,6 +912,9 @@ template void read_fields(PtrList& Lfield,
template void read_fields(PtrList& Lfield,
word Name,
fileName casename, int first_snap, int n_snap);
+template void read_fields(PtrList& Lfield,
+ word Name,
+ fileName casename, int first_snap, int n_snap);
template void read_fields(PtrList& Lfield,
word Name,
fileName casename, int first_snap, int n_snap);
@@ -915,6 +925,8 @@ template void read_fields(PtrList& Lfield,
volScalarField& field, fileName casename, int first_snap, int n_snap);
template void read_fields(PtrList& Lfield,
volVectorField& field, fileName casename, int first_snap, int n_snap);
+template void read_fields(PtrList& Lfield,
+ volTensorField& field, fileName casename, int first_snap, int n_snap);
template void read_fields(PtrList& Lfield,
surfaceScalarField& field, fileName casename, int first_snap, int n_snap);
template void read_fields(PtrList& Lfield,
@@ -923,6 +935,8 @@ template void readMiddleFields(PtrList& Lfield,
volScalarField& field, fileName casename);
template void readMiddleFields(PtrList& Lfield,
volVectorField& field, fileName casename);
+template void readMiddleFields(PtrList& Lfield,
+ volTensorField& field, fileName casename);
template void readMiddleFields(PtrList&
Lfield, surfaceScalarField& field, fileName casename);
template void readMiddleFields(PtrList&
@@ -931,6 +945,8 @@ template void readConvergedFields(PtrList& Lfield,
volScalarField& field, fileName casename);
template void readConvergedFields(PtrList& Lfield,
volVectorField& field, fileName casename);
+template void readConvergedFields(PtrList& Lfield,
+ volTensorField& field, fileName casename);
template void readConvergedFields(PtrList&
Lfield, surfaceScalarField& field, fileName casename);
template void readConvergedFields(PtrList&
@@ -953,6 +969,8 @@ template void exportList(Field& list, word folder,
word filename);
template void exportList(Field& list, word folder,
word filename);
+template void exportList(Field& list, word folder,
+ word filename);
template void save(const List>& MatrixList,
word folder, word MatrixName);
diff --git a/src/ITHACA_CORE/ITHACAutilities/ITHACAassign.C b/src/ITHACA_CORE/ITHACAutilities/ITHACAassign.C
index cbaadc16d7..0c22bc7b89 100644
--- a/src/ITHACA_CORE/ITHACAutilities/ITHACAassign.C
+++ b/src/ITHACA_CORE/ITHACAutilities/ITHACAassign.C
@@ -256,6 +256,22 @@ void assignBC(GeometricField& s, label BC_ind,
assignBC(s, BC_ind, valueList);
}
+void assignBC(GeometricField& s, label BC_ind,
+ tensor value)
+{
+ M_Assert(value.size() == 9,
+ "The size of the given vector has to be equal to 3x3 for the 3x3 components");
+ label sizeBC = s.boundaryField()[BC_ind].size();
+ List valueList(sizeBC);
+
+ for (label i = 0; i < sizeBC; i++)
+ {
+ valueList[i] = value;
+ }
+
+ assignBC(s, BC_ind, valueList);
+}
+
void assignBC(GeometricField& s, label BC_ind,
Eigen::MatrixXd valueVec)
{
@@ -263,12 +279,31 @@ void assignBC(GeometricField& s, label BC_ind,
M_Assert(sizeBC * 3 == valueVec.size(),
"The size of the given values matrix has to be equal to 3 times the dimension of the boundaryField");
List valueList(sizeBC);
+ for (label i = 0; i < sizeBC; i++)
+ {
+ for (label j = 0; j < 3; j++)
+ {
+ valueList[i].component(j) = valueVec(i + sizeBC * j);
+ }
+ }
+
+ assignBC(s, BC_ind, valueList);
+}
+
+void assignBC(GeometricField& s, label BC_ind,
+ Eigen::MatrixXd valueVec)
+{
+ label sizeBC = s.boundaryField()[BC_ind].size();
+ M_Assert(sizeBC * 9 == valueVec.size(),
+ "The size of the given values matrix has to be equal to 9 times the dimension of the boundaryField");
+ List valueList(sizeBC);
for (label i = 0; i < sizeBC; i++)
{
- valueList[i].component(0) = valueVec(i);
- valueList[i].component(1) = valueVec(i + sizeBC);
- valueList[i].component(2) = valueVec(i + sizeBC * 2);
+ for (label j = 0; j < 9; j++)
+ {
+ valueList[i].component(j) = valueVec(i + sizeBC * j);
+ }
}
assignBC(s, BC_ind, valueList);
@@ -369,6 +404,69 @@ void assignBC(GeometricField& s, label BC_ind,
}
}
+
+// Assign a BC for a tensor field
+void assignBC(GeometricField& s, label BC_ind,
+ List valueList)
+{
+ word typeBC = s.boundaryField()[BC_ind].type();
+ label sizeBC = s.boundaryField()[BC_ind].size();
+ M_Assert(sizeBC == valueList.size(),
+ "The size of the given values list has to be equal to the dimension of the boundaryField");
+ ITHACAparameters* para(ITHACAparameters::getInstance());
+
+ if (s.boundaryField()[BC_ind].type() == "fixedGradient")
+ {
+ Info << "This Feature is not implemented for this boundary condition" << endl;
+ exit(0);
+ }
+ else if (s.boundaryField()[BC_ind].type() == "freestream")
+ {
+ for (label i = 0; i < s.boundaryField()[BC_ind].size(); i++)
+ {
+ s.boundaryFieldRef()[BC_ind][i] = valueList[i];
+ }
+
+ freestreamFvPatchField& Tpatch =
+ refCast>(s.boundaryFieldRef()[BC_ind]);
+ tensorField& gradTpatch = Tpatch.freestreamValue();
+ forAll(gradTpatch, faceI)
+ {
+ gradTpatch[faceI] = valueList[faceI];
+ }
+ }
+ else if (s.boundaryField()[BC_ind].type() == "empty"
+ || s.boundaryField()[BC_ind].type() == "zeroGradient")
+ {}
+ else
+ {
+ try
+ {
+ if (typeBC != "fixedGradient" && typeBC != "freestream" && typeBC != "empty"
+ && typeBC != "zeroGradient" && typeBC != "fixedValue" && typeBC != "calculated"
+ && typeBC != "processor")
+ {
+ word message = "Pay attention, your typeBC " + typeBC + " for " + s.name() +
+ " is not included into the developed ones. Your BC will be treated as a classical fixedValue.";
+ throw (message);
+ }
+ }
+ catch (const word message)
+ {
+ if (para->warnings)
+ {
+ WarningInFunction << message << endl;
+ }
+ }
+
+ for (label i = 0; i < sizeBC; i++)
+ {
+ s.boundaryFieldRef()[BC_ind][i] = valueList[i];
+ }
+ }
+}
+
+
template
void assignBC(GeometricField& s, label BC_ind,
List& valueList)
diff --git a/src/ITHACA_CORE/ITHACAutilities/ITHACAassign.H b/src/ITHACA_CORE/ITHACAutilities/ITHACAassign.H
index e21ba736d9..673790200e 100644
--- a/src/ITHACA_CORE/ITHACAutilities/ITHACAassign.H
+++ b/src/ITHACA_CORE/ITHACAutilities/ITHACAassign.H
@@ -177,6 +177,16 @@ void assignBC(GeometricField