diff --git a/.compileOF2412.sh b/.compileOF2412.sh new file mode 100755 index 0000000000..eae639057a --- /dev/null +++ b/.compileOF2412.sh @@ -0,0 +1,4 @@ +#!/bin/bash +docker pull ithacafv/openfoam2412-muq2-pytorch +docker run -ti -d --name foam2412 -v "${PWD}":/home/ofuser/app:rw ithacafv/openfoam2412-muq2-pytorch /bin/bash +docker exec foam2412 /bin/bash -c "source /usr/lib/openfoam/openfoam2412/etc/bashrc; cd /home/ofuser/app; git config --global --add safe.directory /home/ofuser/app; source etc/bashrc; git submodule update --init; ./Allwclean; ./Allwmake -taumq" diff --git a/.compileOF2506.sh b/.compileOF2506.sh new file mode 100755 index 0000000000..f8d282320e --- /dev/null +++ b/.compileOF2506.sh @@ -0,0 +1,4 @@ +#!/bin/bash +docker pull ithacafv/openfoam2506-muq2-pytorch +docker run -ti -d --name foam2506 -v "${PWD}":/home/ofuser/app:rw ithacafv/openfoam2506-muq2-pytorch /bin/bash +docker exec foam2506 /bin/bash -c "source /usr/lib/openfoam/openfoam2506/etc/bashrc; cd /home/ofuser/app; git config --global --add safe.directory /home/ofuser/app; source etc/bashrc; git submodule update --init; ./Allwclean; ./Allwmake -taumq" diff --git a/.github/workflows/docker-dependencies.yml b/.github/workflows/docker-dependencies.yml new file mode 100644 index 0000000000..e86d331c7c --- /dev/null +++ b/.github/workflows/docker-dependencies.yml @@ -0,0 +1,69 @@ +name: Build Dependencies Docker Images + +on: + workflow_dispatch: + +env: + REGISTRY: docker.io + IMAGE_NAME: ithacafv/ithacafv-dependencies + +jobs: + build-amd64-deps: + runs-on: ubuntu-latest + outputs: + digest: ${{ steps.build.outputs.digest }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push AMD64 dependencies + id: build + uses: docker/build-push-action@v5 + with: + context: ./dockerfiles/OF2506/amd64-deps + platforms: linux/amd64 + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:amd64 + cache-from: type=gha + cache-to: type=gha,mode=max + + build-arm64-deps: + runs-on: ubuntu-24.04-arm + outputs: + digest: ${{ steps.build.outputs.digest }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push ARM64 dependencies + id: build + uses: docker/build-push-action@v5 + with: + context: ./dockerfiles/OF2506/arm64-deps + platforms: linux/arm64 + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:arm64 + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000000..0dc3aedf12 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,129 @@ +name: Build and Push Multi-Arch Docker Images + +on: + release: + types: [published] + workflow_dispatch: + +env: + REGISTRY: docker.io + IMAGE_NAME: ithacafv/ithacafv + +jobs: + build-amd64: + runs-on: ubuntu-latest + outputs: + digest: ${{ steps.build.outputs.digest }} + metadata: ${{ steps.meta.outputs.json }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata for ITHACA-FV image + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=semver,pattern={{version}} + type=raw,value=latest + + - name: Build and push AMD64 image + id: build + uses: docker/build-push-action@v5 + with: + context: ./dockerfiles + file: ./dockerfiles/Dockerfile + platforms: linux/amd64 + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true + + build-arm64: + runs-on: ubuntu-24.04-arm + outputs: + digest: ${{ steps.build.outputs.digest }} + metadata: ${{ steps.meta.outputs.json }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata for ITHACA-FV image + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=semver,pattern={{version}} + type=raw,value=latest + + - name: Build and push ARM64 image + id: build + uses: docker/build-push-action@v5 + with: + context: ./dockerfiles + file: ./dockerfiles/Dockerfile + platforms: linux/arm64 + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true + + merge: + runs-on: ubuntu-latest + needs: + - build-amd64 + - build-arm64 + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata for ITHACA-FV image + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=semver,pattern={{version}} + type=raw,value=latest + + - name: Create and push manifest list + working-directory: /tmp + run: | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + ${{ needs.build-amd64.outputs.digest }} \ + ${{ needs.build-arm64.outputs.digest }} + env: + DOCKER_METADATA_OUTPUT_JSON: ${{ steps.meta.outputs.json }} \ No newline at end of file diff --git a/.github/workflows/docker_ithaca.yml b/.github/workflows/docker_ithaca.yml deleted file mode 100755 index c6a71da4fc..0000000000 --- a/.github/workflows/docker_ithaca.yml +++ /dev/null @@ -1,91 +0,0 @@ -name: Docker - -on: - push: - # Pattern matched against refs/tags - tags: - - '*' # Push events to every tag not containing / - -jobs: - docker-arm64: - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v2 - - - name: Set up QEMU - uses: docker/setup-qemu-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: Build and push - uses: docker/build-push-action@v2 - with: - context: ./dockerfiles/arm64 - platforms: linux/arm64 - push: true - tags: ithacafv/ithacafv:manifest-arm64 - - docker-amd64: - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v2 - - - name: Set up QEMU - uses: docker/setup-qemu-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: Build and push - uses: docker/build-push-action@v2 - with: - context: ./dockerfiles/amd64 - platforms: linux/amd64 - push: true - tags: ithacafv/ithacafv:manifest-amd64 - - - - #build-manifest: - #needs: [docker-amd64, docker-arm64] - - #runs-on: ubuntu-latest - #steps: - - #- name: Checkout - #uses: actions/checkout@v2 - - #- name: Set up QEMU - #uses: docker/setup-qemu-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: 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 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 577a898df2..647c173fd3 100755 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -14,6 +14,13 @@ jobs: steps: - uses: actions/checkout@v2 + # Aggiorna la versione nel Doxyfile con anno e mese correnti + - name: Update version in Doxyfile + run: | + CURRENT_VERSION=$(date +'%Y.%m') + cd docs + sed -i "s/^PROJECT_NUMBER.*/PROJECT_NUMBER = \"$CURRENT_VERSION\"/" Doxyfile + # Build the HTML documentation - name: Doxygen Action uses: mattnotmitt/doxygen-action@v1.1.0 diff --git a/.github/workflows/of2412.yml b/.github/workflows/of2412.yml new file mode 100755 index 0000000000..625661c2fe --- /dev/null +++ b/.github/workflows/of2412.yml @@ -0,0 +1,27 @@ +name: OF2412 + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + include: + - name: "OpenFOAM 2412" + install: "cd ." + compile: ./.compileOF2412.sh + + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: install OF + run: ${{ matrix.install}} + - name: make + run: ${{ matrix.compile}} diff --git a/.github/workflows/of2512.yml b/.github/workflows/of2512.yml new file mode 100755 index 0000000000..0ba698a275 --- /dev/null +++ b/.github/workflows/of2512.yml @@ -0,0 +1,27 @@ +name: OF2506 + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + include: + - name: "OpenFOAM 2506" + install: "cd ." + compile: ./.compileOF2506.sh + + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: install OF + run: ${{ matrix.install}} + - name: make + run: ${{ matrix.compile}} diff --git a/.gitmodules b/.gitmodules index c8272cfbfe..3322f3369b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,3 +5,12 @@ [submodule "src/thirdparty/Eigen"] path = src/thirdparty/Eigen url = https://gitlab.com/libeigen/eigen.git +[submodule "src/thirdparty/spectra"] + path = src/thirdparty/spectra + url = https://github.com/yixuan/spectra.git +[submodule "src/thirdparty/OptimLib"] + path = src/thirdparty/OptimLib + url = https://github.com/kthohr/optim.git +[submodule "src/thirdparty/mathtoolbox"] + path = src/thirdparty/mathtoolbox + url = https://github.com/yuki-koyama/mathtoolbox.git diff --git a/README.md b/README.md index ee04cd07ca..d4160b47ef 100644 --- a/README.md +++ b/README.md @@ -14,18 +14,15 @@ Codacy Badge

-

-OF1812 -

### 0. Introduction **ITHACA-FV** is an implementation in **OpenFOAM** of several reduced order modelling techniques. **ITHACA-FV** is designed for [**OpenFOAM v2412**](https://www.openfoam.com/news/main-news/openfoam-v2412/) 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. -Linear and non-linear algebra operations which are not already implemented in OpenFOAM are performed with the external library [**Eigen**](http://eigen.tuxfamily.org/index.php?title=Main_Page). The source code of Eigen 3.3.7 is provided together with ITHACA-FV and is located in the [src/thirdyparty/Eigen](./src/thirdparty/Eigen) folder. For the EigenValue decomposition it is also possible to rely on the [**Spectra-0.7.0**](https://spectralib.org/) library and the source code is provided in the [src/thirdyparty/spectra](./src//thirdparty/spectra) folder. Numerical optimization can be performed using the external library [**OptimLib**](https://www.kthohr.com/optimlib.html) and the header based source code is provided in the [src/thirdyparty/OptimLib](./src/thirdparty/OptimLib) folder. +Linear and non-linear algebra operations which are not already implemented in OpenFOAM are performed with the external library [**Eigen**](http://eigen.tuxfamily.org/index.php?title=Main_Page). Eigen 3.4 is provided as a git submodule together with ITHACA-FV and is located in the [src/thirdyparty/Eigen](./src/thirdparty/Eigen) folder. For the EigenValue decomposition it is also possible to rely on the [**Spectra-1.2.0**](https://spectralib.org/) library and the source code, as a git submodule, is provided in the [src/thirdyparty/spectra](./src//thirdparty/spectra) folder. Numerical optimization can be performed using the external library [**OptimLib**](https://www.kthohr.com/optimlib.html) and the header based source code, as a git submodule, is provided in the [src/thirdyparty/OptimLib](./src/thirdparty/OptimLib) folder. -**ITHACA-FV** has been tested on ubuntu 16.04, CentOS 7, ArchLinux but can be easily compiled on any linux distribution with a compiled version of OpenFOAM 2106, OpenFOAM 2212, OpenFOAM 2306, OpenFOAM 2312, OpenFOAM 2406, and OpenFOAM 2412. +**ITHACA-FV** has been tested on several versions of ubuntu, CentOS 7, ArchLinux but can be easily compiled on any linux distribution with a compiled version of OpenFOAM 2106, OpenFOAM 2212, OpenFOAM 2306, OpenFOAM 2312, OpenFOAM 2406, OpenFOAM 2412 and OpenFOAM 2506. ### 1. Prerequisites **ITHACA-FV** requires @@ -35,12 +32,14 @@ Linear and non-linear algebra operations which are not already implemented in Op * [**OpenFOAM 2312**](https://www.openfoam.com/news/main-news/openfoam-v2312) or * [**OpenFOAM 2406**](https://www.openfoam.com/news/main-news/openfoam-v2406) or * [**OpenFOAM 2412**](https://www.openfoam.com/news/main-news/openfoam-v2412) or +* [**OpenFOAM 2506**](https://www.openfoam.com/news/main-news/openfoam-v2506) or +* [**OpenFOAM 2512**](https://www.openfoam.com/news/main-news/openfoam-v2512) ### 2. Installation and usage First of all you need to source the bashrc file of your installation **OpenFOAM**. This is of course depending on the location of your OpenFOAM installation and of your particular version of OpenFOAM ``` -source $HOME/OpenFOAM/OpenFOAM-v2106/etc/bashrc +source $HOME/OpenFOAM/OpenFOAM-v2506/etc/bashrc ``` Then navigate to the folder where you want to install ITHACA-FV such as, for example, your HOME folder ``` @@ -75,8 +74,9 @@ source etc/bashrc In the near future the ITHACA-FV will also be linked with the pytorch package for machine learning. Some basic functions are already available. In order to compile these additional functionalities one will need to have torch installed and compile the library with the `-m` options. Moreover one will need to install a version of libtorch with ABI enabled. The one available at the following link for example has it: ``` - curl https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.4.0%2Bcpu.zip > libtorch.zip && \ - unzip libtorch.zip -d opt/ && \ + wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.7.1%2Bcpu.zip > libtorch.zip && \ + unzip libtorch.zip && \ + export TORCH_LIBRARIES=libtorch ``` 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). @@ -89,13 +89,13 @@ These images are based **OpenFOAM-v2106**, and provided an isolated environment, In order to pull the image, run the following command: ``` -docker pull ithacafv/ithacafv:manifest-latest +docker pull ithacafv/ithacafv:latest ``` Once the image is downloaded, you can start the container and mount the $HOME directory by executing: ``` -docker run -ti --rm -v "${HOME}:/home/ithacafv/${USER}" ithacafv/ithacafv:manifest-latest +docker run -ti --rm -v "${HOME}:/home/ithacafv/${USER}" ithacafv/ithacafv:latest ``` ### 4. Singularity @@ -115,7 +115,7 @@ 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 +singularity build ithacafv.sif docker://ithacafv/ithacafv:latest ``` To view / list all the images/cache, diff --git a/applications/POD/Make/options b/applications/POD/Make/options index 421af160bd..9144064b7f 100644 --- a/applications/POD/Make/options +++ b/applications/POD/Make/options @@ -34,7 +34,7 @@ EXE_INC = \ -I$(LIB_ITHACA_SRC)/thirdparty/spectra/include \ -Wno-comment \ -w \ - -std=c++14 + -std=c++17 EXE_LIBS = \ -lturbulenceModels \ diff --git a/applications/POD/perform_POD.C b/applications/POD/perform_POD.C index 4ddd3bbd67..0c152a1a40 100755 --- a/applications/POD/perform_POD.C +++ b/applications/POD/perform_POD.C @@ -84,15 +84,12 @@ int main(int argc, char *argv[]) { pod_exist = false; Info << "POD don't exist, performing a POD decomposition" << endl; - mkDir("./ITHACAoutput/POD"); - system("ln -s ../../constant ./ITHACAoutput/POD/constant"); - system("ln -s ../../0 ./ITHACAoutput/POD/0"); - system("ln -s ../../system ./ITHACAoutput/POD/system"); + ITHACAutilities::createSymLink("./ITHACAoutput/POD"); } if(pod_exist == 1) { Info << "The POD has already been performed, please delete the ITHACAoutput folder and try again." << endl; - exit(0); + return 0; } // Initialize Variables diff --git a/applications/extract_time_evolution/Make/options b/applications/extract_time_evolution/Make/options index c047e7cdac..1d2854cba8 100644 --- a/applications/extract_time_evolution/Make/options +++ b/applications/extract_time_evolution/Make/options @@ -25,7 +25,7 @@ EXE_INC = \ -I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel \ -I$(LIB_SRC)/functionObjects/forces/lnInclude \ -w \ - -std=c++14 + -std=c++17 EXE_LIBS = \ -lturbulenceModels \ diff --git a/dockerfiles/Dockerfile b/dockerfiles/Dockerfile new file mode 100644 index 0000000000..a80764a21d --- /dev/null +++ b/dockerfiles/Dockerfile @@ -0,0 +1,47 @@ +# Multi-architecture Dockerfile for ITHACA-FV +# Automatically selects the correct base image based on target platform +ARG TARGETARCH +FROM ithacafv/ithacafv-dependencies:${TARGETARCH} AS base + +LABEL maintainer="giovannistabile@santannapisa.it" + +# Install additional packages +RUN apt-get update && \ + apt-get install -y \ + git \ + vim \ + ssh \ + sudo \ + wget \ + software-properties-common && \ + rm -rf /var/lib/apt/lists/* + +# Set working directory and clone ITHACA-FV +WORKDIR /usr/dir +RUN git clone https://github.com/ITHACA-FV/ITHACA-FV.git + +# Environment variables for bashrc +ARG of_var="source \$FOAM_ETC/bashrc" +ARG ithaca_var="source /opt/ITHACA-FV/etc/bashrc" + +# Update bashrc with OpenFOAM and ITHACA-FV sources +RUN echo $of_var >> /etc/bash.bashrc && \ + echo $ithaca_var >> /etc/bash.bashrc + +# Update bashrc with OpenFOAM and ITHACA-FV sources +RUN echo $of_var >> /etc/bash.bashrc && \ + echo $ithaca_var >> /etc/bash.bashrc + + +RUN /bin/bash -c "source \$FOAM_ETC/bashrc && \ + cd ITHACA-FV && git submodule update --init && source etc/bashrc && \ + if [ \"$TARGETARCH\" = \"amd64\" ]; then \ + ./Allwmake -taumq -j 4; \ + else \ + ./Allwmake -au -j 4; \ + fi" + + +# Source bashrc on container start +RUN /bin/bash -c "source /etc/bash.bashrc" +ENTRYPOINT ["/bin/bash"] diff --git a/dockerfiles/OF2412/Dockerfile b/dockerfiles/OF2412/Dockerfile new file mode 100644 index 0000000000..a849e580d4 --- /dev/null +++ b/dockerfiles/OF2412/Dockerfile @@ -0,0 +1,75 @@ +# Multi-architecture Dockerfile for ITHACA-FV +# Automatically selects the correct base image based on target platform +ARG TARGETARCH +FROM ithacafv/openfoam2412-muq2-pytorch:${TARGETARCH} AS base + +LABEL maintainer="giovannistabile@santannapisa.it" + +USER root + +# Install additional packages +RUN apt-get update && \ + apt-get install -y \ + git \ + vim \ + ssh \ + sudo \ + wget \ + software-properties-common && \ + rm -rf /var/lib/apt/lists/* + +# Create ithacafv user and group +ARG USER=ithacafv +RUN if id -u 1000 >/dev/null 2>&1; then \ + userdel $(id -nu 1000) || true; \ + fi && \ + if getent group 1000 >/dev/null 2>&1; then \ + groupdel $(getent group 1000 | cut -d: -f1) || true; \ + fi && \ + adduser --disabled-password --gecos '' --uid 1000 $USER && \ + adduser $USER sudo && \ + echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers + +# Set environment variables +ENV HOME=/home/$USER +ENV USER=$USER + +# Set working directory and clone ITHACA-FV +WORKDIR /opt +RUN git clone https://github.com/mathLab/ITHACA-FV.git && \ + chown -R $USER:$USER ITHACA-FV && \ + chown -R $USER:$USER /home/$USER + +# Environment variables for bashrc +ARG of_var="source /usr/lib/openfoam/openfoam2412/etc/bashrc" +ARG ithaca_var="source /opt/ITHACA-FV/etc/bashrc" + +# Update bashrc with OpenFOAM and ITHACA-FV sources +RUN echo $of_var >> /etc/bash.bashrc && \ + echo $ithaca_var >> /etc/bash.bashrc + +# Switch to ithacafv user +USER $USER + +# Build ITHACA-FV +RUN /bin/bash -c "source /usr/lib/openfoam/openfoam2412/etc/bashrc && \ + cd ITHACA-FV && \ + git submodule update --init && \ + source etc/bashrc && \ + ./Allwmake -au -j 4" + +# Copy binaries and libraries to system paths (as root) +USER root +RUN if [ -d "/home/$USER/OpenFOAM/$USER-openfoam2412/platforms/linux64GccDPInt32Opt/bin" ]; then \ + cp -r /home/$USER/OpenFOAM/$USER-openfoam2412/platforms/linux64GccDPInt32Opt/bin/* /usr/local/bin/ || true; \ + cp -r /home/$USER/OpenFOAM/$USER-openfoam2412/platforms/linux64GccDPInt32Opt/lib/* /usr/local/lib/ || true; \ + fi + +# Final setup +USER $USER +WORKDIR $HOME + +# Source bashrc on container start +RUN /bin/bash -c "source /etc/bash.bashrc" + +ENTRYPOINT ["/bin/bash"] diff --git a/dockerfiles/OF2412/amd64-deps/Dockerfile b/dockerfiles/OF2412/amd64-deps/Dockerfile new file mode 100644 index 0000000000..2e5533cebc --- /dev/null +++ b/dockerfiles/OF2412/amd64-deps/Dockerfile @@ -0,0 +1,41 @@ +# Start from the ubuntu Openfoam 2106 image +FROM opencfd/openfoam-dev:2412 +USER root +ARG PYTHON_VERSION=3.7 +ENV PATH="/root/miniconda3/bin:${PATH}" + +RUN rm /etc/apt/sources.list.d/openfoam.list && \ + cp /etc/apt/sources.list /etc/apt/sources.list.backup && \ + grep -v -e "openfoam" /etc/apt/sources.list.backup > /etc/apt/sources.list && \ + echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections && \ + apt-get update && \ + apt-get install -yy -q pwgen npm nodejs cmake git wget bzip2 unzip && \ + apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +# Anaconda installing +RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \ +bash Miniconda3-latest-Linux-x86_64.sh -b && \ +rm Miniconda3-latest-Linux-x86_64.sh && \ +. /root/miniconda3/etc/profile.d/conda.sh && \ +export PATH=/root/miniconda3/bin:$PATH && \ +wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.7.1%2Bcpu.zip && \ +unzip libtorch-cxx11-abi-shared-with-deps-2.7.1+cpu.zip && \ +rm libtorch-cxx11-abi-shared-with-deps-2.7.1+cpu.zip && \ +conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main && \ +conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r && \ +conda install -y -c conda-forge muq cmake pybind11 && \ +conda clean -y --all +ENV TORCH_LIBRARIES=/libtorch +ENV MUQ_LIBRARIES=/root/miniconda3 + +# Export OpenFOAM environment variables for use in subsequent builds +RUN /bin/bash -c "source /usr/lib/openfoam/openfoam2412/etc/bashrc && \ + echo 'export FOAM_ETC=${FOAM_ETC}' >> /etc/environment && \ + echo 'export FOAM_APP=${FOAM_APP}' >> /etc/environment && \ + echo 'export FOAM_APPBIN=${FOAM_APPBIN}' >> /etc/environment && \ + echo 'export FOAM_LIBBIN=${FOAM_LIBBIN}' >> /etc/environment && \ + echo 'export FOAM_SRC=${FOAM_SRC}' >> /etc/environment && \ + echo 'export WM_PROJECT_DIR=${WM_PROJECT_DIR}' >> /etc/environment" + +ENV FOAM_ETC=/usr/lib/openfoam/openfoam2412/etc +RUN echo 'source /usr/lib/openfoam/openfoam2412/etc/bashrc' >> ~/.bashrc \ No newline at end of file diff --git a/dockerfiles/OF2412/arm64-deps/Dockerfile b/dockerfiles/OF2412/arm64-deps/Dockerfile new file mode 100644 index 0000000000..5d419c583e --- /dev/null +++ b/dockerfiles/OF2412/arm64-deps/Dockerfile @@ -0,0 +1,43 @@ +# Start from the ubuntu Openfoam 2106 image +FROM opencfd/openfoam-dev:2412 +USER root +ARG PYTHON_VERSION=3.7 +ENV PATH="/root/miniconda3/bin:${PATH}" + +RUN rm /etc/apt/sources.list.d/openfoam.list && \ + cp /etc/apt/sources.list /etc/apt/sources.list.backup && \ + grep -v -e "openfoam" /etc/apt/sources.list.backup > /etc/apt/sources.list && \ + echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections && \ + apt-get update && \ + apt-get install -yy -q pwgen npm nodejs cmake git wget bzip2 unzip libc6-dev && \ + apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +# Anaconda installing +RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh && \ +bash Miniconda3-latest-Linux-aarch64.sh -b && \ +rm Miniconda3-latest-Linux-aarch64.sh && \ +. /root/miniconda3/etc/profile.d/conda.sh && \ +export PATH=/root/miniconda3/bin:$PATH && \ +conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main && \ +conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r && \ +conda install -y -c conda-forge cmake pybind11 eigen hdf5 nlopt && \ +git clone https://bitbucket.org/mituq/muq2.git /tmp/muq2 && \ +cd /tmp/muq2 && rm -rf build && mkdir build && cd build && \ +cmake -DCMAKE_INSTALL_PREFIX=/root/miniconda3 -DMUQ_USE_PYTHON=ON .. && \ +make -j4 && make install && \ +cd / && rm -rf /tmp/muq2 && \ +conda clean -y --all +ENV MUQ_LIBRARIES=/root/miniconda3 + +# Export OpenFOAM environment variables for use in subsequent builds +RUN /bin/bash -c "source /usr/lib/openfoam/openfoam2412/etc/bashrc && \ + echo 'export FOAM_ETC=${FOAM_ETC}' >> /etc/environment && \ + echo 'export FOAM_APP=${FOAM_APP}' >> /etc/environment && \ + echo 'export FOAM_APPBIN=${FOAM_APPBIN}' >> /etc/environment && \ + echo 'export FOAM_LIBBIN=${FOAM_LIBBIN}' >> /etc/environment && \ + echo 'export FOAM_SRC=${FOAM_SRC}' >> /etc/environment && \ + echo 'export WM_PROJECT_DIR=${WM_PROJECT_DIR}' >> /etc/environment" + +ENV FOAM_ETC=/usr/lib/openfoam/openfoam2412/etc +RUN echo 'source /usr/lib/openfoam/openfoam2412/etc/bashrc' >> ~/.bashrc + diff --git a/dockerfiles/OF2506/Dockerfile b/dockerfiles/OF2506/Dockerfile new file mode 100644 index 0000000000..d37e2ca71c --- /dev/null +++ b/dockerfiles/OF2506/Dockerfile @@ -0,0 +1,75 @@ +# Multi-architecture Dockerfile for ITHACA-FV +# Automatically selects the correct base image based on target platform +ARG TARGETARCH +FROM ithacafv/openfoam2506-muq2-pytorch:${TARGETARCH} AS base + +LABEL maintainer="giovannistabile@santannapisa.it" + +USER root + +# Install additional packages +RUN apt-get update && \ + apt-get install -y \ + git \ + vim \ + ssh \ + sudo \ + wget \ + software-properties-common && \ + rm -rf /var/lib/apt/lists/* + +# Create ithacafv user and group +ARG USER=ithacafv +RUN if id -u 1000 >/dev/null 2>&1; then \ + userdel $(id -nu 1000) || true; \ + fi && \ + if getent group 1000 >/dev/null 2>&1; then \ + groupdel $(getent group 1000 | cut -d: -f1) || true; \ + fi && \ + adduser --disabled-password --gecos '' --uid 1000 $USER && \ + adduser $USER sudo && \ + echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers + +# Set environment variables +ENV HOME=/home/$USER +ENV USER=$USER + +# Set working directory and clone ITHACA-FV +WORKDIR /opt +RUN git clone https://github.com/mathLab/ITHACA-FV.git && \ + chown -R $USER:$USER ITHACA-FV && \ + chown -R $USER:$USER /home/$USER + +# Environment variables for bashrc +ARG of_var="source /usr/lib/openfoam/openfoam2412/etc/bashrc" +ARG ithaca_var="source /opt/ITHACA-FV/etc/bashrc" + +# Update bashrc with OpenFOAM and ITHACA-FV sources +RUN echo $of_var >> /etc/bash.bashrc && \ + echo $ithaca_var >> /etc/bash.bashrc + +# Switch to ithacafv user +USER $USER + +# Build ITHACA-FV +RUN /bin/bash -c "source /usr/lib/openfoam/openfoam2412/etc/bashrc && \ + cd ITHACA-FV && \ + git submodule update --init && \ + source etc/bashrc && \ + ./Allwmake -au -j 4" + +# Copy binaries and libraries to system paths (as root) +USER root +RUN if [ -d "/home/$USER/OpenFOAM/$USER-openfoam2412/platforms/linux64GccDPInt32Opt/bin" ]; then \ + cp -r /home/$USER/OpenFOAM/$USER-openfoam2412/platforms/linux64GccDPInt32Opt/bin/* /usr/local/bin/ || true; \ + cp -r /home/$USER/OpenFOAM/$USER-openfoam2412/platforms/linux64GccDPInt32Opt/lib/* /usr/local/lib/ || true; \ + fi + +# Final setup +USER $USER +WORKDIR $HOME + +# Source bashrc on container start +RUN /bin/bash -c "source /etc/bash.bashrc" + +ENTRYPOINT ["/bin/bash"] diff --git a/dockerfiles/OF2506/amd64-deps/Dockerfile b/dockerfiles/OF2506/amd64-deps/Dockerfile new file mode 100644 index 0000000000..5efe519439 --- /dev/null +++ b/dockerfiles/OF2506/amd64-deps/Dockerfile @@ -0,0 +1,41 @@ +# Start from the ubuntu Openfoam 2106 image +FROM opencfd/openfoam-dev:2506 +USER root +ARG PYTHON_VERSION=3.7 +ENV PATH="/root/miniconda3/bin:${PATH}" + +RUN rm /etc/apt/sources.list.d/openfoam.list && \ + cp /etc/apt/sources.list /etc/apt/sources.list.backup && \ + grep -v -e "openfoam" /etc/apt/sources.list.backup > /etc/apt/sources.list && \ + echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections && \ + apt-get update && \ + apt-get install -yy -q pwgen npm nodejs cmake git wget bzip2 unzip && \ + apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +# Anaconda installing +RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \ +bash Miniconda3-latest-Linux-x86_64.sh -b && \ +rm Miniconda3-latest-Linux-x86_64.sh && \ +. /root/miniconda3/etc/profile.d/conda.sh && \ +export PATH=/root/miniconda3/bin:$PATH && \ +wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.7.1%2Bcpu.zip && \ +unzip libtorch-cxx11-abi-shared-with-deps-2.7.1+cpu.zip && \ +rm libtorch-cxx11-abi-shared-with-deps-2.7.1+cpu.zip && \ +conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main && \ +conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r && \ +conda install -y -c conda-forge muq cmake pybind11 && \ +conda clean -y --all +ENV TORCH_LIBRARIES=/libtorch +ENV MUQ_LIBRARIES=/root/miniconda3 + +# Export OpenFOAM environment variables for use in subsequent builds +RUN /bin/bash -c "source /usr/lib/openfoam/openfoam2506/etc/bashrc && \ + echo 'export FOAM_ETC=${FOAM_ETC}' >> /etc/environment && \ + echo 'export FOAM_APP=${FOAM_APP}' >> /etc/environment && \ + echo 'export FOAM_APPBIN=${FOAM_APPBIN}' >> /etc/environment && \ + echo 'export FOAM_LIBBIN=${FOAM_LIBBIN}' >> /etc/environment && \ + echo 'export FOAM_SRC=${FOAM_SRC}' >> /etc/environment && \ + echo 'export WM_PROJECT_DIR=${WM_PROJECT_DIR}' >> /etc/environment" + +ENV FOAM_ETC=/usr/lib/openfoam/openfoam2506/etc +RUN echo 'source /usr/lib/openfoam/openfoam2506/etc/bashrc' >> ~/.bashrc diff --git a/dockerfiles/OF2506/arm64-deps/Dockerfile b/dockerfiles/OF2506/arm64-deps/Dockerfile new file mode 100644 index 0000000000..6d7ea60125 --- /dev/null +++ b/dockerfiles/OF2506/arm64-deps/Dockerfile @@ -0,0 +1,43 @@ +# Start from the ubuntu Openfoam 2106 image +FROM opencfd/openfoam-dev:2506 +USER root +ARG PYTHON_VERSION=3.7 +ENV PATH="/root/miniconda3/bin:${PATH}" + +RUN rm /etc/apt/sources.list.d/openfoam.list && \ + cp /etc/apt/sources.list /etc/apt/sources.list.backup && \ + grep -v -e "openfoam" /etc/apt/sources.list.backup > /etc/apt/sources.list && \ + echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections && \ + apt-get update && \ + apt-get install -yy -q pwgen npm nodejs cmake git wget bzip2 unzip libc6-dev && \ + apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +# Anaconda installing +RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh && \ +bash Miniconda3-latest-Linux-aarch64.sh -b && \ +rm Miniconda3-latest-Linux-aarch64.sh && \ +. /root/miniconda3/etc/profile.d/conda.sh && \ +export PATH=/root/miniconda3/bin:$PATH && \ +conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main && \ +conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r && \ +conda install -y -c conda-forge cmake pybind11 eigen hdf5 nlopt && \ +git clone https://bitbucket.org/mituq/muq2.git /tmp/muq2 && \ +cd /tmp/muq2 && rm -rf build && mkdir build && cd build && \ +cmake -DCMAKE_INSTALL_PREFIX=/root/miniconda3 -DMUQ_USE_PYTHON=ON .. && \ +make -j4 && make install && \ +cd / && rm -rf /tmp/muq2 && \ +conda clean -y --all +ENV MUQ_LIBRARIES=/root/miniconda3 + +# Export OpenFOAM environment variables for use in subsequent builds +RUN /bin/bash -c "source /usr/lib/openfoam/openfoam2506/etc/bashrc && \ + echo 'export FOAM_ETC=${FOAM_ETC}' >> /etc/environment && \ + echo 'export FOAM_APP=${FOAM_APP}' >> /etc/environment && \ + echo 'export FOAM_APPBIN=${FOAM_APPBIN}' >> /etc/environment && \ + echo 'export FOAM_LIBBIN=${FOAM_LIBBIN}' >> /etc/environment && \ + echo 'export FOAM_SRC=${FOAM_SRC}' >> /etc/environment && \ + echo 'export WM_PROJECT_DIR=${WM_PROJECT_DIR}' >> /etc/environment" + +ENV FOAM_ETC=/usr/lib/openfoam/openfoam2506/etc +RUN echo 'source /usr/lib/openfoam/openfoam2506/etc/bashrc' >> ~/.bashrc + diff --git a/dockerfiles/amd64/Dockerfile b/dockerfiles/amd64/Dockerfile index a4e21aa0ee..cbb2a37d70 100644 --- a/dockerfiles/amd64/Dockerfile +++ b/dockerfiles/amd64/Dockerfile @@ -1,21 +1,20 @@ -FROM opencfd/openfoam2106-dev -LABEL maintainer="moaadkhamlich@gmail.com" +FROM ithacafv/openfoam2506-muq2-pytorch +LABEL maintainer="giovannistabile@santannapisa.it" # add enviromental variables and enable the default user ARG USER=ithacafv -ARG of_var="source /usr/lib/openfoam/openfoam2106/etc/bashrc" +ARG of_var="source /usr/lib/openfoam/openfoam2506/etc/bashrc" ARG ithaca_var="source /usr/lib/ITHACA-FV/etc/bashrc" -ENV USER $USER +# ENV USER=$USER -# Create the user +# # Create the user RUN 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 -#make sure everything is in place + usermod -u 9999 ithacafv && \ + groupmod -g 9999 ithacafv +# #make sure everything is in place ENV HOME /home/$USER RUN chown -R $USER:$USER /home/$USER RUN chown -R $USER:$USER /home/openfoam && rm -r /home/openfoam && \ @@ -33,24 +32,25 @@ RUN apt-get update &&\ sudo rm -rf /var/lib/apt/lists/* WORKDIR /usr/lib -RUN git clone https://github.com/mathLab/ITHACA-FV.git +RUN git clone https://github.com/ITHACA-FV/ITHACA-FV.git RUN chown -R $USER:$USER openfoam ITHACA-FV RUN chown -R $USER:$USER /home/$USER +RUN chown -R $USER:$USER /root/miniconda3/include USER $USER -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"; +RUN /bin/bash -c "source /usr/lib/openfoam/openfoam2506/etc/bashrc && \ + cd ITHACA-FV && git submodule update --init && source etc/bashrc && \ + ./Allwmake -taumq -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/ +RUN cp -r /home/ithacafv/OpenFOAM/ithacafv-v2506/platforms/linux64GccDPInt32Opt/bin/* /bin/ +RUN cp -r /home/ithacafv/OpenFOAM/ithacafv-v2506/platforms/linux64GccDPInt32Opt/lib/* /lib/ #Update bashrc RUN echo $of_var >> /etc/bash.bashrc -RUN echo $ithaca_var >> /etc/bash.bashrc +RUN echo $ithaca_var >> /root/.bashrc -#Source bashrc +# #Source bashrc USER $USER RUN /bin/bash -c "source /etc/bash.bashrc" diff --git a/docs/Doxyfile b/docs/Doxyfile index 192c8f8620..acf42e6fce 100755 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "ITHACA-FV" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = "2023.1" +PROJECT_NUMBER = "" # 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 @@ -118,7 +118,7 @@ REPEAT_BRIEF = YES # the entity):The $name class, The $name widget, The $name file, is, provides, # specifies, contains, represents, a, an and the. -ABBREVIATE_BRIEF = +ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # doxygen will generate a detailed section even if there is only a brief @@ -425,7 +425,7 @@ LOOKUP_CACHE_SIZE = 0 # normally produced when WARNINGS is set to YES. # The default value is: NO. -EXTRACT_ALL = YES +EXTRACT_ALL = NO # If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will # be included in the documentation. @@ -780,7 +780,7 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = ../src ../applications ../tutorials ../applications/lift_and_drag/FORCESdict ../applications/POD/ITHACAPODdict ../tutorials/01POD +INPUT = examples.md ../src ../applications ../tutorials ../applications/lift_and_drag/FORCESdict ../applications/POD/ITHACAPODdict # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses @@ -805,8 +805,7 @@ INPUT_ENCODING = UTF-8 # *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, # *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf and *.qsf. -FILE_PATTERNS = *.H \ - *.C +FILE_PATTERNS = *.c *.C *.cc *.cpp *.H *.md # The RECURSIVE tag can be used to specify whether or not subdirectories should # be searched for input files as well. @@ -854,21 +853,21 @@ EXCLUDE_SYMBOLS = # that contain example code fragments that are included (see the \include # command). -EXAMPLE_PATH = ../tutorials/ +EXAMPLE_PATH = examples.md # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and # *.h) to filter out the source-files in the directories. If left blank all # files are included. -EXAMPLE_PATTERNS = *.C +EXAMPLE_PATTERNS = *.md # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude commands # irrespective of the value of the RECURSIVE tag. # The default value is: NO. -EXAMPLE_RECURSIVE = YES +EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or directories # that contain images that are to be included in the documentation (see the @@ -1999,7 +1998,7 @@ ENABLE_PREPROCESSING = YES # The default value is: NO. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -MACRO_EXPANSION = NO +MACRO_EXPANSION = YES # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then # the macro expansion is limited to the macros specified with the PREDEFINED and @@ -2007,7 +2006,7 @@ MACRO_EXPANSION = NO # The default value is: NO. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -EXPAND_ONLY_PREDEF = NO +EXPAND_ONLY_PREDEF = YES # If the SEARCH_INCLUDES tag is set to YES, the include files in the # INCLUDE_PATH will be searched if a #include is found. @@ -2039,7 +2038,7 @@ INCLUDE_FILE_PATTERNS = # recursively expanded use the := operator instead of the = operator. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -PREDEFINED = +PREDEFINED = DOXYGEN # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The diff --git a/docs/DoxygenLayout.xml b/docs/DoxygenLayout.xml index 2437f4ca05..0979a688bf 100755 --- a/docs/DoxygenLayout.xml +++ b/docs/DoxygenLayout.xml @@ -2,9 +2,9 @@ - - - + + + @@ -19,7 +19,6 @@ - diff --git a/docs/customdoxygen.css b/docs/customdoxygen.css index 19c567ef28..74c596fbd3 100755 --- a/docs/customdoxygen.css +++ b/docs/customdoxygen.css @@ -67,3 +67,31 @@ content: "C++ Source Code Guide"; font-size: 180%; } + +.tutorials-grid { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); + gap: 20px; + margin: 30px 0; +} + +.tutorial-card { + border: 1px solid #e1e4e8; + border-radius: 8px; + padding: 20px; + background: #ffffff; +} + +.tutorial-image { + margin-top: 10px; + text-align: center; +} + +.tutorial-image img { + max-width: 100%; + max-height: 300px; + width: auto; + height: auto; + border-radius: 4px; + object-fit: contain; +} \ No newline at end of file diff --git a/docs/examples.md b/docs/examples.md new file mode 100755 index 0000000000..b3ee89eeef --- /dev/null +++ b/docs/examples.md @@ -0,0 +1,146 @@ +\page examples List of examples + +### Examples related to **CFD** + +
+
+[`01POD`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/CFD/01POD#tutorial-01): apply the POD to the lid-driven cavity test case. +
![Lid-driven cavity flow](images/01_cavity.gif)
+
+
+[`02thermalBlock`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/CFD/02thermalBlock#tutorial-02): solve a parametrized POD-Galerkin ROM for a steady heat transfer case. +
![Thermal Block](images/02_thermalblock.gif)
+
+
+[`03steadyNS`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/CFD/03steadyNS#tutorial-03): solve a POD-Galerkin ROM for a steady backstep flow with parametrized viscosity, using the supremizer approach. +
![Backstep](images/03_backstep.gif)
+
+
+[`04unsteadyNS`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/CFD/04unsteadyNS#tutorial-04): solve a POD-Galerkin ROM either with the supremizer or with the PPE approach, for the unsteady flow past a cylinder. +
![Cylinder](images/04_cylinder.gif)
+
+
+[`05PODI`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/CFD/05PODI#tutorial-05): apply POD to the backstep test case. +
![Velocity backstep modes](images/05_vel_modes.gif)
+
+
+[`06POD_RBF`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/CFD/06POD_RBF#tutorial-06): apply POD with RBF interpolation to the pitzdaily test case, with parametrized inlet velocity magnitude and orientation. +
![Velocity snapshots](images/06_pitzdaily.gif)
+
+
+[`07NonIsothermalMixingElbow`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/CFD/07NonIsothermalMixingElbow#tutorial-07): apply POD with RBF interpolation to the pitzdaily test case, with parametrized inlet velocity magnitude and orientation. +
![Temperature snapshots](images/07_elbow.gif)
+
+
+[`08DEIM`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/CFD/08DEIM#tutorial-08): reconstruction of a parametric Gaussian function using the Discrete Empirical Interpolation Method (DEIM). +
![DEIM approximations](images/08_deim.gif)
+
+
+[`09DEIM_ROM`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/CFD/09DEIM_ROM#tutorial-09): solves a parameterized heat-transfer problem and builds a reduced-order model using POD + DEIM. +
![DEIM approximations](images/09_deimrom.gif)
+
+
+[`10unsteadyBB_enclosed`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/CFD/10unsteadyBB_enclosed#tutorial-10): reduced order model for unsteady flow with prescribed heat flux in an enclosed domain. +
![Temperature snapshots](images/10_unsteadyBB_enclosed.gif)
+
+
+[`11UnsteadyBBOpen`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/CFD/11UnsteadyBBOpen#tutorial-11): unsteady buoyancy-driven flow in an open domain using POD reduction. +
![Temperature snapshots](images/11_unsteady_BB_open.gif)
+
+
+[`12simpleSteadyNS`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/CFD/12simpleSteadyNS#tutorial-12): POD-Galerkin ROM for steady turbulent Navier-Stokes using the SIMPLE algorithm. +
![Reconstructed pressure](images/12_simple.gif)
+
+
+[`14DMDexample`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/CFD/14DMDexample#tutorial-14): Dynamic Mode Decomposition applied to a transient flow problem. +
![Reconstructed velocity](images/14_cyl.gif)
+
+
+[`15MSR_cavity`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/CFD/15MSR_cavity#tutorial-15): reduced order model for molten salt reactor cavity with parametrized diffusivity. +
![Some velocity snapshots](images/15_cavity.gif)
+
+
+[`16MSR_FOMSA`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/CFD/16MSR_FOMSA#tutorial-16): sensitivity analysis of molten salt reactor cavity parameters. +
![Some flux snapshots](images/16_flux.gif)
+
+
+[`17YJunction`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/CFD/17YJunction#tutorial-17): unsteady Navier-Stokes problem with time-dependent and parametrized boundary conditions in a Y-junction geometry. +
![Velocity snapshots](images/17_junction.gif)
+
+
+[`18simpleTurbNS`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/CFD/18simpleTurbNS#tutorial-18): a steady-state backstep model with ROMs in turbulent regime. +
![Eddy viscosity snapshot](images/18_eddyviscosity.gif)
+
+
+[`19UnsteadyNSExplicit`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/CFD/19UnsteadyNSExplicit#tutorial-19): explicit time integration for POD-Galerkin ROM of lid-driven cavity. +
![Velocity POD modes](images/19_modes.gif)
+
+
+[`20incrementalPOD`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/CFD/20incrementalPOD#tutorial-20): incremental POD algorithm for adaptive basis enrichment. +
![POD modes](images/20_modes.gif)
+
+
+[`21unsteadyNSTurb_RBF`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/CFD/21unsteadyNSTurb_RBF#tutorial-21): solving a reduced unsteady system with RBF interpolation for eddy viscosity coefficients, in the flow past a cylinder test case. +
![POD modes](images/21_velocity_modes.gif)
+
+
+[`22datadriven_corrections`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/CFD/22datadriven_corrections#tutorial-22): data-driven pressure POD corrections for improved ROM accuracy on the flow past a cylinder case. +
![Eddy viscosity snapshots](images/22_eddyviscosity_cyl.gif)
+
+
+[`23burgers`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/CFD/23burgers#tutorial-23): solving a Burgers problem in a backstep domain, and apply POD. +
![POD modes](images/23_backstep.gif)
+
+
+[`24HyperReduction`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/CFD/24HyperReduction#tutorial-24): POD with hyper-reduction techniques (DEIM, gappy POD). +
![FOM-ROM comparison](images/24_comparison.gif)
+
+
+[`25Moving_Cylinder`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/CFD/25Moving_Cylinder#tutorial-25): reduced order model for flow around a moving cylinder. +
![Velocity snapshots with moving cylinder](images/25_moving.gif)
+
+
+[`26MovingAirfoil`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/CFD/26MovingAirfoil#tutorial-26): POD-based ROM for flow around a moving airfoil. +
![Velocity snapshots with moving airfoil](images/26_movingairfoil.gif)
+
+
+[`27SmagorinskyHyperreduction`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/CFD/27SmagorinskyHyperreduction#tutorial-27): Smagorinsky model with hyper-reduction for LES ROM. +
![Smagorinsky term](images/27_smag.gif)
+
+
+ +### Examples related to machine learning (**NN** folder) + +
+
+[`01simpleTurbGeomClosed`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/NN/01simpleTurbGeomClosed#tutorial-nn-01): neural network closure for steady turbulent flow in a closed geometry. +
![Varying mesh in backstep](images/nn01_mesh.gif)
+
+
+[`BumpCompressibleSteadyNS`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/NN/BumpCompressibleSteadyNS#tutorial-nn-02): neural network reduced model for compressible flow over a bump. +
![Velocity around airfoil](images/nn02_vel.gif)
+
+
+[`CompressibleSteadyNS`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/NN/CompressibleSteadyNS#tutorial-nn-03): neural network reduced model for compressible steady Navier-Stokes. +
![Pressure around airfoil](images/nn03_pres.gif)
+
+
+ +### Examples related to **UQ** + +
+
+[`01enKF`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/UQ/01enKF#tutorial-uq-01): ensemble Kalman filter applied to a linear dynamical system. +
+
+[`02enKF_1DinverseHeatTransfer`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/UQ/02enKF_1DinverseHeatTransfer#tutorial-uq-02): state reconstruction in 1D heat transfer using ensemble Kalman filter. +
+
+ +### Examples related to **Inverse Heat Transfer** + +
+
+[`IHTP01inverseLaplacian`](https://github.com/ITHACA-FV/ITHACA-FV/tree/master/tutorials/inverseHeatTransfer/IHTP01inverseLaplacian#tutorial-ihtp-01): inverse heat transfer problem using regularization (CG) and RBF parametrization methods. +
+
\ No newline at end of file diff --git a/docs/images/01_cavity.gif b/docs/images/01_cavity.gif new file mode 100644 index 0000000000..562e158f03 Binary files /dev/null and b/docs/images/01_cavity.gif differ diff --git a/docs/images/02_thermalblock.gif b/docs/images/02_thermalblock.gif new file mode 100644 index 0000000000..19f27f3a61 Binary files /dev/null and b/docs/images/02_thermalblock.gif differ diff --git a/docs/images/03_backstep.gif b/docs/images/03_backstep.gif new file mode 100644 index 0000000000..1ddfe23369 Binary files /dev/null and b/docs/images/03_backstep.gif differ diff --git a/docs/images/04_cylinder.gif b/docs/images/04_cylinder.gif new file mode 100644 index 0000000000..040b168b38 Binary files /dev/null and b/docs/images/04_cylinder.gif differ diff --git a/docs/images/05_vel_modes.gif b/docs/images/05_vel_modes.gif new file mode 100644 index 0000000000..11b0b99705 Binary files /dev/null and b/docs/images/05_vel_modes.gif differ diff --git a/docs/images/06_pitzdaily.gif b/docs/images/06_pitzdaily.gif new file mode 100644 index 0000000000..34e811eddf Binary files /dev/null and b/docs/images/06_pitzdaily.gif differ diff --git a/docs/images/07_elbow.gif b/docs/images/07_elbow.gif new file mode 100644 index 0000000000..bd3a1f8a96 Binary files /dev/null and b/docs/images/07_elbow.gif differ diff --git a/docs/images/08_deim.gif b/docs/images/08_deim.gif new file mode 100644 index 0000000000..c9b79acacb Binary files /dev/null and b/docs/images/08_deim.gif differ diff --git a/docs/images/09_deimrom.gif b/docs/images/09_deimrom.gif new file mode 100644 index 0000000000..2aa816ba41 Binary files /dev/null and b/docs/images/09_deimrom.gif differ diff --git a/docs/images/10_unsteadyBB.gif b/docs/images/10_unsteadyBB.gif new file mode 100644 index 0000000000..e93d57247b Binary files /dev/null and b/docs/images/10_unsteadyBB.gif differ diff --git a/docs/images/10_unsteadyBB_enclosed.gif b/docs/images/10_unsteadyBB_enclosed.gif new file mode 100644 index 0000000000..e93d57247b Binary files /dev/null and b/docs/images/10_unsteadyBB_enclosed.gif differ diff --git a/docs/images/11_unsteady_BB_open.gif b/docs/images/11_unsteady_BB_open.gif new file mode 100644 index 0000000000..6b2a4f1c5c Binary files /dev/null and b/docs/images/11_unsteady_BB_open.gif differ diff --git a/docs/images/12_simple.gif b/docs/images/12_simple.gif new file mode 100644 index 0000000000..62a4028b5e Binary files /dev/null and b/docs/images/12_simple.gif differ diff --git a/docs/images/14_cyl.gif b/docs/images/14_cyl.gif new file mode 100644 index 0000000000..2933a84ff5 Binary files /dev/null and b/docs/images/14_cyl.gif differ diff --git a/docs/images/15_cavity.gif b/docs/images/15_cavity.gif new file mode 100644 index 0000000000..d562657c14 Binary files /dev/null and b/docs/images/15_cavity.gif differ diff --git a/docs/images/16_flux.gif b/docs/images/16_flux.gif new file mode 100644 index 0000000000..9779df41aa Binary files /dev/null and b/docs/images/16_flux.gif differ diff --git a/docs/images/17_junction.gif b/docs/images/17_junction.gif new file mode 100644 index 0000000000..a9d968d248 Binary files /dev/null and b/docs/images/17_junction.gif differ diff --git a/docs/images/18_eddyviscosity.gif b/docs/images/18_eddyviscosity.gif new file mode 100644 index 0000000000..835e1c540e Binary files /dev/null and b/docs/images/18_eddyviscosity.gif differ diff --git a/docs/images/19_modes.gif b/docs/images/19_modes.gif new file mode 100644 index 0000000000..ca06b1cce1 Binary files /dev/null and b/docs/images/19_modes.gif differ diff --git a/docs/images/20_modes.gif b/docs/images/20_modes.gif new file mode 100644 index 0000000000..76c80b623d Binary files /dev/null and b/docs/images/20_modes.gif differ diff --git a/docs/images/21_velocity_modes.gif b/docs/images/21_velocity_modes.gif new file mode 100644 index 0000000000..91becfff60 Binary files /dev/null and b/docs/images/21_velocity_modes.gif differ diff --git a/docs/images/22_eddyviscosity_cyl.gif b/docs/images/22_eddyviscosity_cyl.gif new file mode 100644 index 0000000000..4296da6802 Binary files /dev/null and b/docs/images/22_eddyviscosity_cyl.gif differ diff --git a/docs/images/23_backstep.gif b/docs/images/23_backstep.gif new file mode 100644 index 0000000000..6810fdd2a1 Binary files /dev/null and b/docs/images/23_backstep.gif differ diff --git a/docs/images/24_comparison.gif b/docs/images/24_comparison.gif new file mode 100644 index 0000000000..41fd78a3a5 Binary files /dev/null and b/docs/images/24_comparison.gif differ diff --git a/docs/images/25_moving.gif b/docs/images/25_moving.gif new file mode 100644 index 0000000000..c185e466d6 Binary files /dev/null and b/docs/images/25_moving.gif differ diff --git a/docs/images/26_movingairfoil.gif b/docs/images/26_movingairfoil.gif new file mode 100644 index 0000000000..6de130d254 Binary files /dev/null and b/docs/images/26_movingairfoil.gif differ diff --git a/docs/images/27_smag.gif b/docs/images/27_smag.gif new file mode 100644 index 0000000000..398341ec9a Binary files /dev/null and b/docs/images/27_smag.gif differ diff --git a/docs/images/SmagorinskyCylinder.png b/docs/images/SmagorinskyCylinder.png new file mode 100644 index 0000000000..2aaebb16cd Binary files /dev/null and b/docs/images/SmagorinskyCylinder.png differ diff --git a/docs/images/nn01_mesh.gif b/docs/images/nn01_mesh.gif new file mode 100644 index 0000000000..8711de398d Binary files /dev/null and b/docs/images/nn01_mesh.gif differ diff --git a/docs/images/nn02_vel.gif b/docs/images/nn02_vel.gif new file mode 100644 index 0000000000..dc644f4580 Binary files /dev/null and b/docs/images/nn02_vel.gif differ diff --git a/docs/images/nn03_pres.gif b/docs/images/nn03_pres.gif new file mode 100644 index 0000000000..088db763f5 Binary files /dev/null and b/docs/images/nn03_pres.gif differ diff --git a/gtest/Make/options b/gtest/Make/options index 12747fdf65..b3fad9d664 100755 --- a/gtest/Make/options +++ b/gtest/Make/options @@ -13,7 +13,7 @@ EXE_INC = \ -I$(LIB_ITHACA_SRC)/thirdparty/splinter/include \ -w \ -DOFVER=$${WM_PROJECT_VERSION%.*} \ - -std=c++14 + -std=c++17 EXE_LIBS = \ -lturbulenceModels \ diff --git a/src/ITHACA_CORE/Containers/Modes.C b/src/ITHACA_CORE/Containers/Modes.C index 4a0414107d..0e8e2732cb 100644 --- a/src/ITHACA_CORE/Containers/Modes.C +++ b/src/ITHACA_CORE/Containers/Modes.C @@ -204,7 +204,7 @@ Modes::projectSnapshot( template class PatchField, class GeoMesh> Eigen::MatrixXd Modes::project( - PtrList> & + PtrList>& fields, label numberOfModes, word projType, fvMatrix* Af) { @@ -318,6 +318,7 @@ Modes::reconstruct( { PtrList> inputFields; inputFields.resize(0); + for (label i = 0; i < Coeff.size(); i++) { inputField = reconstruct(inputField, Coeff[i], Name); @@ -454,7 +455,7 @@ void Modes::projectSnapshots( } else { - std::cout << "Inner product not defined" << endl; + Foam::Info << "Inner product not defined" << Foam::endl; exit(0); } @@ -478,9 +479,10 @@ void Modes::projectSnapshots( template class PatchField, class GeoMesh> void Modes::operator=(const - PtrList> & modes) + PtrList>& modes) { this->resize(modes.size()); + for (label i = 0; i < modes.size(); i++) { (* this).set(i, modes[i].clone()); @@ -491,3 +493,4 @@ void Modes::operator=(const template class Modes; template class Modes; template class Modes; +template class Modes; diff --git a/src/ITHACA_CORE/Containers/Modes.H b/src/ITHACA_CORE/Containers/Modes.H index e41f33c70e..dc4aa25437 100644 --- a/src/ITHACA_CORE/Containers/Modes.H +++ b/src/ITHACA_CORE/Containers/Modes.H @@ -83,7 +83,7 @@ class Modes : public PtrList> /// /// @return The PtrList containing the modes /// - PtrList> & toPtrList() + PtrList>& toPtrList() { return static_cast>& > (* this); @@ -151,7 +151,7 @@ class Modes : public PtrList> /// /// @return An Eigen MatricxXd list. /// - Eigen::MatrixXd project(PtrList> & + Eigen::MatrixXd project(PtrList>& fields, label numberOfModes = 0, word projType = "G", fvMatrix* Af = NULL); @@ -248,13 +248,14 @@ class Modes : public PtrList> PtrList Volumes, word innerProduct); - void operator=(const PtrList> & + void operator=(const PtrList>& modes); }; typedef Modes volScalarModes; typedef Modes volVectorModes; typedef Modes surfaceScalarModes; +typedef Modes pointVectorModes; #endif diff --git a/src/ITHACA_CORE/EigenFunctions/EigenFunctions.C b/src/ITHACA_CORE/EigenFunctions/EigenFunctions.C index 6a8734be81..90b9844e1b 100644 --- a/src/ITHACA_CORE/EigenFunctions/EigenFunctions.C +++ b/src/ITHACA_CORE/EigenFunctions/EigenFunctions.C @@ -121,4 +121,49 @@ vectorTensorProduct( const Eigen::Matrix& g, const Eigen::Tensor& c, const Eigen::Matrix& a); + +Eigen::VectorXd repeatElements(Eigen::VectorXd input, int n) +{ + if (!(n > 0)) + { + Info << "The integer for the EigenFunctions::repeat method must be positive. Aborting" << endl; + abort(); + } + else + { + Eigen::VectorXd output(input.size() * n); + for (int i = 0; i < input.size(); i++) + { + for (int r = 0; r < n; r++) + { + output(i * n + r) = input(i); + } + } + return output; + } +} + +Eigen::VectorXd reorderVectorFromDim(Eigen::VectorXd input, int dim) +{ + if ((input.size() % dim) != 0) + { + Info << "EigenFunctions::reorderVectorFromDim has incompatible vector size " << + "and reordering dimension. Aborting" << endl; + abort(); + } + else + { + Eigen::VectorXd output(input.size()); + int n = int(input.size() / dim); + for (int i = 0; i < n; i++) + { + for (int d = 0; d < dim; d++) + { + output(i * dim + d) = input(i + d * dim); + } + } + return output; + } +} + } diff --git a/src/ITHACA_CORE/EigenFunctions/EigenFunctions.H b/src/ITHACA_CORE/EigenFunctions/EigenFunctions.H index 9c9b0742bf..09e813f25d 100644 --- a/src/ITHACA_CORE/EigenFunctions/EigenFunctions.H +++ b/src/ITHACA_CORE/EigenFunctions/EigenFunctions.H @@ -120,7 +120,7 @@ void sortEigenvalues(Eigen::VectorXd& eigenvalues, /// template Eigen::Matrix innerProduct( - List > & A, List >& B); + List >& A, List >& B); //-------------------------------------------------------------------------- /// @brief Perform Frobenius inner Product between a list of sparse matrices A and a sparse matrix B @@ -136,7 +136,7 @@ Eigen::Matrix innerProduct( /// template Eigen::Matrix innerProduct( - List > & A, Eigen::SparseMatrix& B); + List >& A, Eigen::SparseMatrix& B); //-------------------------------------------------------------------------- /// @brief Perform Frobenius inner Product between two sparse matrices A and B @@ -169,7 +169,7 @@ T innerProduct(Eigen::SparseMatrix& A, Eigen::SparseMatrix& B); /// @return out Sparse Matrix containing the sum of all the matrices multiplied by the vector coefficients /// template -Eigen::SparseMatrix MVproduct(List> & A, +Eigen::SparseMatrix MVproduct(List>& A, Eigen::DenseBase>& C); //-------------------------------------------------------------------------- @@ -188,7 +188,7 @@ Eigen::SparseMatrix MVproduct(List> & A, /// template Eigen::Matrix MVproduct( - const std::vector< Eigen::Matrix> & A, + const std::vector< Eigen::Matrix>& A, Eigen::DenseBase>& C); //-------------------------------------------------------------------------- @@ -207,7 +207,7 @@ Eigen::Matrix MVproduct( /// template List> MMproduct(List>& A, - Eigen::DenseBase> & C); + Eigen::DenseBase>& C); //-------------------------------------------------------------------------- /// @brief Conditioning number of a dense matrix @@ -249,6 +249,29 @@ Eigen::Matrix vectorTensorProduct( const Eigen::Tensor& c, const Eigen::Matrix& a); + +//------------------------------------------------------------------------------ +/// @brief Repeat each element n times after themselves +/// +/// @details Example: input = (a, b); n = 3 +/// output = (a, a, a, b, b, b) +/// +/// @param input Eigen::VectorXd +/// @param n int +Eigen::VectorXd repeatElements(Eigen::VectorXd input, int n); + +//------------------------------------------------------------------------------ +/// @brief Changes the order of the vector's elements given a dimension +/// +/// @details Example: input = (a_1, b_1, a_2, b_2, a_3, b_3); dim = 3 +/// output = (a_1, a_2, a_3, b_1, b_2, b_3) +/// Typically switch from a component then coordinate order to the opposite +/// as did the change in the Foam2Eigen mapping +/// +/// @param input Eigen::VectorXd +/// @param dim int +Eigen::VectorXd reorderVectorFromDim(Eigen::VectorXd input, int dim); + }; template @@ -323,7 +346,7 @@ T EigenFunctions::min(Eigen::SparseMatrix& mat, label& ind_row, template Eigen::Matrix EigenFunctions::innerProduct( - List > & A, List >& B) + List >& A, List >& B) { label rows = A.size(); label cols = B.size(); @@ -343,7 +366,7 @@ Eigen::Matrix EigenFunctions::innerProduct( template Eigen::Matrix EigenFunctions::innerProduct( - List> & A, Eigen::SparseMatrix& B) + List>& A, Eigen::SparseMatrix& B) { label rows = A.size(); label cols = 1; @@ -373,7 +396,7 @@ T EigenFunctions::innerProduct(Eigen::SparseMatrix& A, } template -Eigen::SparseMatrix EigenFunctions::MVproduct(List> & +Eigen::SparseMatrix EigenFunctions::MVproduct(List>& A , Eigen::DenseBase>& C) { @@ -390,7 +413,7 @@ Eigen::SparseMatrix EigenFunctions::MVproduct(List> & template Eigen::Matrix EigenFunctions::MVproduct( - const std::vector< Eigen::Matrix> & A, + const std::vector< Eigen::Matrix>& A, Eigen::DenseBase>& C) { Eigen::Matrix out; @@ -409,7 +432,7 @@ Eigen::Matrix EigenFunctions::MVproduct( template List> EigenFunctions::MMproduct( List>& A, - Eigen::DenseBase> & C) + Eigen::DenseBase>& C) { List> out; out.resize(C.cols()); @@ -420,6 +443,7 @@ List> EigenFunctions::MMproduct( col = C.col(i); out[i] = MVproduct(A, col); } + return out; } @@ -462,12 +486,14 @@ bool saveMarketVector (const VectorType & vec, const std::string & filename, { out << "%%MatrixMarket matrix array real general\n"; } + out << vec.size() << " " << 1 << "\n"; for (label i = 0; i < vec.size(); i++) { - internal::putVectorElt(vec(i), out); + internal::putDenseElt(vec(i), out); } + out.close(); return true; } diff --git a/src/ITHACA_CORE/Foam2Eigen/Foam2Eigen.C b/src/ITHACA_CORE/Foam2Eigen/Foam2Eigen.C index 4dbe2f5d4d..045299d7c7 100644 --- a/src/ITHACA_CORE/Foam2Eigen/Foam2Eigen.C +++ b/src/ITHACA_CORE/Foam2Eigen/Foam2Eigen.C @@ -36,136 +36,149 @@ License // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template