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/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..dd51b816ce 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,13 @@ 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) ### 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 +73,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 +88,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 +114,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..86ebba8dc3 100755 --- a/applications/POD/perform_POD.C +++ b/applications/POD/perform_POD.C @@ -84,10 +84,7 @@ 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) { 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/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..7714b8fc2b 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); @@ -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.H b/src/ITHACA_CORE/EigenFunctions/EigenFunctions.H index 9c9b0742bf..b7c9197811 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 @@ -323,7 +323,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 +343,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 +373,7 @@ T EigenFunctions::innerProduct(Eigen::SparseMatrix& A, } template -Eigen::SparseMatrix EigenFunctions::MVproduct(List> & +Eigen::SparseMatrix EigenFunctions::MVproduct(List>& A , Eigen::DenseBase>& C) { @@ -390,7 +390,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 +409,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 +420,7 @@ List> EigenFunctions::MMproduct( col = C.col(i); out[i] = MVproduct(A, col); } + return out; } @@ -462,12 +463,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