CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Installation

[OpenFOAM.org] Unable to Install OpenFOAM11 on M3 MacBook Pro With Docker

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By may3rd

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 7, 2024, 12:45
Default Unable to Install OpenFOAM11 on M3 MacBook Pro With Docker
  #1
New Member
 
Richard Fox
Join Date: Jan 2024
Posts: 2
Rep Power: 0
rpf1968 is on a distinguished road
Hi
I have been been trying to install OpenFOAM 11 on my M3 MacBook Pro but without success.

I have been following the instructions on the OpenFOAM installation page and have followed steps:


1. Downloaded Paraview and checked that sudo is working.

2. Installed Docker (can open Docker Desktop - but little to no understanding)

3. Attempted to install openfoam 11 with the following 2 commands:

sudo curl --create-dirs -o /usr/local/bin/openfoam11-macos http://dl.openfoam.org/docker/openfoam11-macos

sudo chmod 755 /usr/local/bin/openfoam11-macos


4. Downloaded Quartz - checked the boxes:

'Allow connections from network clients'

and

'Authenticate connections'.

And then restarted XQuartz.

5. Omitted this section as I had read that this was not necessary. (Taken on trust because I don't know).

Step 6 . Attempted to run OpenFOAM with the following text input:

cd OpenFOAM-Docker

openfoam11-macos

I then get the following:

richardfox@Richards-MacBook-Pro OpenFOAM-Docker % ls
openfoam11-macos openfoam11-macos.txt
richardfox@Richards-MacBook-Pro OpenFOAM-Docker % openfoam11-macos
No directory exists:

Usage: openfoam11-macos [OPTIONS]
options:
-d | -dir host directory mounted (defaults to current directory)
-h | -help help
-p | -paraview [vers] include paraview, with version 56 | 510 (default)
-u | -upgrade install latest upgrades to the Docker image
-x | -xhost use custom X authority and give container host network

Launches the OpenFOAM-11 Docker image.
- Requires installation of docker-engine.
- Runs a "containerized" bash shell environment where the user can run OpenFOAM
and, optionally, ParaView (see below).
- The container mounts the user's file system so that case files are stored
permanently. The container mounts the current directory by default, but the
user can also specify a particular directory using the "-d" option.
- Mounting the user's HOME directory is disallowed.
- The '-xhost' option is useful when accessing the host via 'ssh -X'.
This option should only be used when strictly necessary, as it relies on the
option '--net=host' when launching the container in Docker, which will
give to the container full access to the Docker host network stack and
potentially the host's system services that rely on network communication,
making it potentially insecure.

ParaView:
Graphical applications from the Docker container require installation of the
Xquartz X server to display on the host machine. While applications such as
Gedit, Emacs and GnuPlot will run effectively using Xquartz, more intensive
OpenGL applications, in particular ParaView, can be prohibitively slow.

Therefore, the default Docker image does not contain ParaView and users can
instead install ParaView directly from the vendor and use the built-in reader
module for OpenFOAM: https://www.paraview.org/download

However, if the user wishes to include ParaView with the official OpenFOAM
reader module in their Docker container, they can do so with the "-p" option.

Example:
To store data in /Users/richardfox/OpenFOAM/richardfox-11, the user can launch
openfoam11-macos either by:
cd /Users/richardfox/OpenFOAM/richardfox-11 && openfoam11-macos
or
openfoam11-macos -d /Users/richardfox/OpenFOAM/richardfox-11

Further Information:
https://openfoam.org/download/11-macos

Note:
The container user name appears as "openfoam" but it is just an alias.

richardfox@Richards-MacBook-Pro OpenFOAM-Docker % openfoam11-macos


I have tried this many times and have tried some other ways which escape me now but I am stumped.

Please can someone help?

Thanks in advance.

Richard

(p.s. apologies if any pertinent detail is missing - I am really not experienced in this).
rpf1968 is offline   Reply With Quote

Old   January 13, 2024, 13:26
Default
  #2
New Member
 
faris
Join Date: Jan 2024
Posts: 1
Rep Power: 0
frsb is on a distinguished road
I have the exact same error and I couldn't find any solution. I am using an Intel Macbook with macOS 13.4.

Hopefully someone can help.
frsb is offline   Reply With Quote

Old   January 16, 2024, 01:21
Default
  #3
New Member
 
Peter Wallhead
Join Date: Jan 2024
Posts: 1
Rep Power: 0
peterwallhead is on a distinguished road
Followed same steps as the OP and hit the same issue here, macOS 13.6.


Instructions used were from https://openfoam.org/download/11-macos/
peterwallhead is offline   Reply With Quote

Old   January 29, 2024, 15:51
Default
  #4
New Member
 
Join Date: Jan 2024
Posts: 1
Rep Power: 0
ssmm is on a distinguished road
I also have same problem and not able to solve it yet
ssmm is offline   Reply With Quote

Old   February 9, 2024, 22:14
Default my workaround
  #5
New Member
 
Maetee Lor
Join Date: Feb 2024
Posts: 3
Rep Power: 2
may3rd is on a distinguished road
You have to edit the openfoam11-macos that you downloaded using your favorite text editor following:

1. change the line no. 92 from

docker_image='openfoam/openfoam$ver-graphical-apps'

to

docker_image="openfoam/openfoam$ver-graphical-apps"

2. remove the line no. 143-144

[ -d "$MOUNT_DIR" ] || usage "No directory exists: $MOUNT_DIR"
MOUNT_DIR=$(cd "$MOUNT_DIR" && pwd -P)


3. Save and rerun the openfoam11-mac

the following is the content of the file that I can run normally.

#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2017-2023 OpenFOAM Foundation
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
#
# Script
# openfoam11-macos
#
# Description
# Run script for an OpenFOAM 11 Docker image at:
# https://hub.docker.com/r/openfoam
#
#------------------------------------------------------------------------------
Script=${0##*/}
ver=11

usage () {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat <<USAGE

Usage: ${0##*/} [OPTIONS]
options:
-d | -dir host directory mounted (defaults to current directory)
-h | -help help
-p | -paraview [vers] include paraview, with version 56 | 510 (default)
-u | -upgrade install latest upgrades to the Docker image
-x | -xhost use custom X authority and give container host network

Launches the OpenFOAM-$ver Docker image.
- Requires installation of docker-engine.
- Runs a "containerized" bash shell environment where the user can run OpenFOAM
and, optionally, ParaView (see below).
- The container mounts the user's file system so that case files are stored
permanently. The container mounts the current directory by default, but the
user can also specify a particular directory using the "-d" option.
- Mounting the user's HOME directory is disallowed.
- The '-xhost' option is useful when accessing the host via 'ssh -X'.
This option should only be used when strictly necessary, as it relies on the
option '--net=host' when launching the container in Docker, which will
give to the container full access to the Docker host network stack and
potentially the host's system services that rely on network communication,
making it potentially insecure.

ParaView:
Graphical applications from the Docker container require installation of the
Xquartz X server to display on the host machine. While applications such as
Gedit, Emacs and GnuPlot will run effectively using Xquartz, more intensive
OpenGL applications, in particular ParaView, can be prohibitively slow.

Therefore, the default Docker image does not contain ParaView and users can
instead install ParaView directly from the vendor and use the built-in reader
module for OpenFOAM: https://www.paraview.org/download

However, if the user wishes to include ParaView with the official OpenFOAM
reader module in their Docker container, they can do so with the "-p" option.

Example:
To store data in $HOME/OpenFOAM/$USER-$ver, the user can launch
$Script either by:
cd $HOME/OpenFOAM/$USER-$ver && $Script
or
$Script -d $HOME/OpenFOAM/$USER-$ver

Further Information:
https://openfoam.org/download/$ver-macos

Note:
The container user name appears as "openfoam" but it is just an alias.

USAGE
exit 1
}

docker_image="openfoam/openfoam$ver-graphical-apps"
#docker_image="$HOME/.openfoam.dmg.sparseimage"
paraview_vers=""
mount_dir=$(pwd)
custom_xauth=""
docker_options=""

while [ "$#" -gt 0 ]
do
case "$1" in
-d | -dir)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
mount_dir=$2
shift 2
;;
-h | -help)
usage
;;
-p | -paraview)
# No version specified
{ [ "$#" -eq 1 ] || [ "$(echo "$2" | cut -c1)" = "-" ] ; } && \
paraview_vers=510 && \
shift 1 && \
continue
# Version specified
paraview_vers=$2
case "$paraview_vers" in
56|510) ;;
*) usage "'$2' is not a valid ParaView version." \
"Valid versions are 56 | 510."
;;
esac
shift 2
;;
-u | -upgrade)
upgrade=yes
shift
;;
-x | -xhost)
custom_xauth=yes
shift
;;
*)
usage "Invalid option '$1'"
;;
esac
done

[ "$paraview_vers" ] && \
echo "Including ParaView $paraview_vers" && \
docker_image="openfoam/openfoam$ver-paraview$paraview_vers"

[ -d "$mount_dir" ] || usage "No directory exists -: $mount_dir"
mount_dir=$(cd "$mount_dir" && pwd -P)

[ "$mount_dir" = "$(cd "$HOME" && pwd -P)" ] && \
usage "Mount directory cannot be the user's home directory" \
"Make a subdirectory and run from there, e.g." \
" mkdir -p $HOME/OpenFOAM/$(whoami)-$ver" \
" $Script -d $HOME/OpenFOAM/$(whoami)-$ver"

if [ -n "$custom_xauth" ]
then
xauth_path="$mount_dir/.docker.xauth.$$"
touch "$xauth_path"

# Generate a custom X-authority file that allows any hostname
xauth nlist "$DISPLAY" | sed -e 's/^..../ffff/' | \
xauth -f "$xauth_path" nmerge -

docker_options="-e XAUTHORITY=$xauth_path
-v $xauth_path:$xauth_path
--net=host"
fi

user_id=$(id -u 2> /dev/null)
[ -n "$user_id" ] || usage "Cannot determine current user ID"
group_id=$(id -g)

home_dir='/home/openfoam'

echo "Launching $0"
echo "User: "$(id -un)" (ID $user_id, group ID $group_id)"

ifaces=$(ifconfig | grep ^en | cut -d: -f1)
[ "$ifaces" ] || \
usage "Cannot find a network interface for DISPLAY with ifconfig" \
"Please report an issue at http://bugs.openfoam.org" \
" providing the output of the command: ifconfig"

for i in $ifaces
do
ip=$(ifconfig "$i" | grep inet | awk '$1=="inet" {print $2}')
[ "$ip" ] && break
done

[ "$ip" ] || \
usage "Cannot find a network IP for DISPLAY with ifconfig" \
"Please report an issue at https://bugs.openfoam.org" \
" providing the output of the command: ifconfig"

xhost + "$ip"

[ "$upgrade" ] && docker pull "$docker_image"

# shellcheck disable=SC2086
echo "docker_image = $docker_image"

docker run -it \
--rm \
-e DISPLAY=$IP:0 \
-u "$user_id":"$group_id" \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v "$mount_dir":$home_dir \
$docker_options \
"$docker_image"

[ -n "$custom_xauth" ] && [ -e "$xauth_path" ] && rm "$xauth_path"
azeem raza likes this.
may3rd is offline   Reply With Quote

Old   February 10, 2024, 10:17
Default
  #6
New Member
 
Join Date: Dec 2019
Posts: 5
Rep Power: 6
moh raafat is on a distinguished road
has not someone solved it yet?
moh raafat is offline   Reply With Quote

Old   February 11, 2024, 20:15
Default
  #7
New Member
 
Maetee Lor
Join Date: Feb 2024
Posts: 3
Rep Power: 2
may3rd is on a distinguished road
Quote:
Originally Posted by moh raafat View Post
has not someone solved it yet?
please see my reply.
may3rd is offline   Reply With Quote

Old   February 11, 2024, 20:29
Default The modify code for openfoam11-macos
  #8
New Member
 
Maetee Lor
Join Date: Feb 2024
Posts: 3
Rep Power: 2
may3rd is on a distinguished road
copy the following modified code and save as /usr/local/bin/openfoam11-macos

and run openfoam-macos-file-system create and then you should be able to run openfoam11-macos

#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2017-2023 OpenFOAM Foundation
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
#
# Script
# openfoam11-macos
#
# Description
# Run script for an OpenFOAM 11 Docker image at:
# https://hub.docker.com/r/openfoam
#
#------------------------------------------------------------------------------
Script=${0##*/}
ver=11

usage () {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat <<USAGE

Usage: ${0##*/} [OPTIONS]
options:
-d | -dir host directory mounted (defaults to current directory)
-h | -help help
-p | -paraview [vers] include paraview, with version 56 | 510 (default)
-u | -upgrade install latest upgrades to the Docker image
-x | -xhost use custom X authority and give container host network

Launches the OpenFOAM-$ver Docker image.
- Requires installation of docker-engine.
- Runs a "containerized" bash shell environment where the user can run OpenFOAM
and, optionally, ParaView (see below).
- The container mounts the user's file system so that case files are stored
permanently. The container mounts the current directory by default, but the
user can also specify a particular directory using the "-d" option.
- Mounting the user's HOME directory is disallowed.
- The '-xhost' option is useful when accessing the host via 'ssh -X'.
This option should only be used when strictly necessary, as it relies on the
option '--net=host' when launching the container in Docker, which will
give to the container full access to the Docker host network stack and
potentially the host's system services that rely on network communication,
making it potentially insecure.

ParaView:
Graphical applications from the Docker container require installation of the
Xquartz X server to display on the host machine. While applications such as
Gedit, Emacs and GnuPlot will run effectively using Xquartz, more intensive
OpenGL applications, in particular ParaView, can be prohibitively slow.

Therefore, the default Docker image does not contain ParaView and users can
instead install ParaView directly from the vendor and use the built-in reader
module for OpenFOAM: https://www.paraview.org/download

However, if the user wishes to include ParaView with the official OpenFOAM
reader module in their Docker container, they can do so with the "-p" option.

Example:
To store data in $HOME/OpenFOAM/$USER-$ver, the user can launch
$Script either by:
cd $HOME/OpenFOAM/$USER-$ver && $Script
or
$Script -d $HOME/OpenFOAM/$USER-$ver

Further Information:
https://openfoam.org/download/$ver-macos

Note:
The container user name appears as "openfoam" but it is just an alias.

USAGE
exit 1
}

docker_image="openfoam/openfoam$ver-graphical-apps"
#docker_image="$HOME/.openfoam.dmg.sparseimage"
paraview_vers=""
mount_dir=$(pwd)
custom_xauth=""
docker_options=""

while [ "$#" -gt 0 ]
do
case "$1" in
-d | -dir)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
mount_dir=$2
shift 2
;;
-h | -help)
usage
;;
-p | -paraview)
# No version specified
{ [ "$#" -eq 1 ] || [ "$(echo "$2" | cut -c1)" = "-" ] ; } && \
paraview_vers=510 && \
shift 1 && \
continue
# Version specified
paraview_vers=$2
case "$paraview_vers" in
56|510) ;;
*) usage "'$2' is not a valid ParaView version." \
"Valid versions are 56 | 510."
;;
esac
shift 2
;;
-u | -upgrade)
upgrade=yes
shift
;;
-x | -xhost)
custom_xauth=yes
shift
;;
*)
usage "Invalid option '$1'"
;;
esac
done

[ "$paraview_vers" ] && \
echo "Including ParaView $paraview_vers" && \
docker_image="openfoam/openfoam$ver-paraview$paraview_vers"

[ -d "$mount_dir" ] || usage "No directory exists -: $mount_dir"
mount_dir=$(cd "$mount_dir" && pwd -P)

[ "$mount_dir" = "$(cd "$HOME" && pwd -P)" ] && \
usage "Mount directory cannot be the user's home directory" \
"Make a subdirectory and run from there, e.g." \
" mkdir -p $HOME/OpenFOAM/$(whoami)-$ver" \
" $Script -d $HOME/OpenFOAM/$(whoami)-$ver"

if [ -n "$custom_xauth" ]
then
xauth_path="$mount_dir/.docker.xauth.$$"
touch "$xauth_path"

# Generate a custom X-authority file that allows any hostname
xauth nlist "$DISPLAY" | sed -e 's/^..../ffff/' | \
xauth -f "$xauth_path" nmerge -

docker_options="-e XAUTHORITY=$xauth_path
-v $xauth_path:$xauth_path
--net=host"
fi

user_id=$(id -u 2> /dev/null)
[ -n "$user_id" ] || usage "Cannot determine current user ID"
group_id=$(id -g)

home_dir='/home/openfoam'

echo "Launching $0"
echo "User: "$(id -un)" (ID $user_id, group ID $group_id)"

ifaces=$(ifconfig | grep ^en | cut -d: -f1)
[ "$ifaces" ] || \
usage "Cannot find a network interface for DISPLAY with ifconfig" \
"Please report an issue at http://bugs.openfoam.org" \
" providing the output of the command: ifconfig"

for i in $ifaces
do
ip=$(ifconfig "$i" | grep inet | awk '$1=="inet" {print $2}')
[ "$ip" ] && break
done

[ "$ip" ] || \
usage "Cannot find a network IP for DISPLAY with ifconfig" \
"Please report an issue at https://bugs.openfoam.org" \
" providing the output of the command: ifconfig"

xhost + "$ip"

[ "$upgrade" ] && docker pull "$docker_image"

# shellcheck disable=SC2086
echo "docker_image = $docker_image"

docker run -it \
--rm \
-e DISPLAY=$IP:0 \
-u "$user_id":"$group_id" \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v "$mount_dir":$home_dir \
$docker_options \
"$docker_image"

[ -n "$custom_xauth" ] && [ -e "$xauth_path" ] && rm "$xauth_path"
may3rd is offline   Reply With Quote

Old   February 12, 2024, 13:04
Default
  #9
New Member
 
Richard Fox
Join Date: Jan 2024
Posts: 2
Rep Power: 0
rpf1968 is on a distinguished road
Quote:
Originally Posted by may3rd View Post
You have to edit the openfoam11-macos that you downloaded using your favorite text editor following:

1. change the line no. 92 from

docker_image='openfoam/openfoam$ver-graphical-apps'

to

docker_image="openfoam/openfoam$ver-graphical-apps"

2. remove the line no. 143-144

[ -d "$MOUNT_DIR" ] || usage "No directory exists: $MOUNT_DIR"
MOUNT_DIR=$(cd "$MOUNT_DIR" && pwd -P)


3. Save and rerun the openfoam11-mac

the following is the content of the file that I can run normally.

#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2017-2023 OpenFOAM Foundation
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
#
# Script
# openfoam11-macos
#
# Description
# Run script for an OpenFOAM 11 Docker image at:
# https://hub.docker.com/r/openfoam
#
#------------------------------------------------------------------------------
Script=${0##*/}
ver=11

usage () {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat <<USAGE

Usage: ${0##*/} [OPTIONS]
options:
-d | -dir host directory mounted (defaults to current directory)
-h | -help help
-p | -paraview [vers] include paraview, with version 56 | 510 (default)
-u | -upgrade install latest upgrades to the Docker image
-x | -xhost use custom X authority and give container host network

Launches the OpenFOAM-$ver Docker image.
- Requires installation of docker-engine.
- Runs a "containerized" bash shell environment where the user can run OpenFOAM
and, optionally, ParaView (see below).
- The container mounts the user's file system so that case files are stored
permanently. The container mounts the current directory by default, but the
user can also specify a particular directory using the "-d" option.
- Mounting the user's HOME directory is disallowed.
- The '-xhost' option is useful when accessing the host via 'ssh -X'.
This option should only be used when strictly necessary, as it relies on the
option '--net=host' when launching the container in Docker, which will
give to the container full access to the Docker host network stack and
potentially the host's system services that rely on network communication,
making it potentially insecure.

ParaView:
Graphical applications from the Docker container require installation of the
Xquartz X server to display on the host machine. While applications such as
Gedit, Emacs and GnuPlot will run effectively using Xquartz, more intensive
OpenGL applications, in particular ParaView, can be prohibitively slow.

Therefore, the default Docker image does not contain ParaView and users can
instead install ParaView directly from the vendor and use the built-in reader
module for OpenFOAM: https://www.paraview.org/download

However, if the user wishes to include ParaView with the official OpenFOAM
reader module in their Docker container, they can do so with the "-p" option.

Example:
To store data in $HOME/OpenFOAM/$USER-$ver, the user can launch
$Script either by:
cd $HOME/OpenFOAM/$USER-$ver && $Script
or
$Script -d $HOME/OpenFOAM/$USER-$ver

Further Information:
https://openfoam.org/download/$ver-macos

Note:
The container user name appears as "openfoam" but it is just an alias.

USAGE
exit 1
}

docker_image="openfoam/openfoam$ver-graphical-apps"
#docker_image="$HOME/.openfoam.dmg.sparseimage"
paraview_vers=""
mount_dir=$(pwd)
custom_xauth=""
docker_options=""

while [ "$#" -gt 0 ]
do
case "$1" in
-d | -dir)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
mount_dir=$2
shift 2
;;
-h | -help)
usage
;;
-p | -paraview)
# No version specified
{ [ "$#" -eq 1 ] || [ "$(echo "$2" | cut -c1)" = "-" ] ; } && \
paraview_vers=510 && \
shift 1 && \
continue
# Version specified
paraview_vers=$2
case "$paraview_vers" in
56|510) ;;
*) usage "'$2' is not a valid ParaView version." \
"Valid versions are 56 | 510."
;;
esac
shift 2
;;
-u | -upgrade)
upgrade=yes
shift
;;
-x | -xhost)
custom_xauth=yes
shift
;;
*)
usage "Invalid option '$1'"
;;
esac
done

[ "$paraview_vers" ] && \
echo "Including ParaView $paraview_vers" && \
docker_image="openfoam/openfoam$ver-paraview$paraview_vers"

[ -d "$mount_dir" ] || usage "No directory exists -: $mount_dir"
mount_dir=$(cd "$mount_dir" && pwd -P)

[ "$mount_dir" = "$(cd "$HOME" && pwd -P)" ] && \
usage "Mount directory cannot be the user's home directory" \
"Make a subdirectory and run from there, e.g." \
" mkdir -p $HOME/OpenFOAM/$(whoami)-$ver" \
" $Script -d $HOME/OpenFOAM/$(whoami)-$ver"

if [ -n "$custom_xauth" ]
then
xauth_path="$mount_dir/.docker.xauth.$$"
touch "$xauth_path"

# Generate a custom X-authority file that allows any hostname
xauth nlist "$DISPLAY" | sed -e 's/^..../ffff/' | \
xauth -f "$xauth_path" nmerge -

docker_options="-e XAUTHORITY=$xauth_path
-v $xauth_path:$xauth_path
--net=host"
fi

user_id=$(id -u 2> /dev/null)
[ -n "$user_id" ] || usage "Cannot determine current user ID"
group_id=$(id -g)

home_dir='/home/openfoam'

echo "Launching $0"
echo "User: "$(id -un)" (ID $user_id, group ID $group_id)"

ifaces=$(ifconfig | grep ^en | cut -d: -f1)
[ "$ifaces" ] || \
usage "Cannot find a network interface for DISPLAY with ifconfig" \
"Please report an issue at http://bugs.openfoam.org" \
" providing the output of the command: ifconfig"

for i in $ifaces
do
ip=$(ifconfig "$i" | grep inet | awk '$1=="inet" {print $2}')
[ "$ip" ] && break
done

[ "$ip" ] || \
usage "Cannot find a network IP for DISPLAY with ifconfig" \
"Please report an issue at https://bugs.openfoam.org" \
" providing the output of the command: ifconfig"

xhost + "$ip"

[ "$upgrade" ] && docker pull "$docker_image"

# shellcheck disable=SC2086
echo "docker_image = $docker_image"

docker run -it \
--rm \
-e DISPLAY=$IP:0 \
-u "$user_id":"$group_id" \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v "$mount_dir":$home_dir \
$docker_options \
"$docker_image"

[ -n "$custom_xauth" ] && [ -e "$xauth_path" ] && rm "$xauth_path"
Many thanks for sharing that.��
rpf1968 is offline   Reply With Quote

Old   February 13, 2024, 12:19
Default Where and how do I implement this change?
  #10
New Member
 
Delight Wellington
Join Date: Feb 2024
Posts: 1
Rep Power: 0
delighton is on a distinguished road
Quote:
Originally Posted by may3rd View Post
copy the following modified code and save as /usr/local/bin/openfoam11-macos

and run openfoam-macos-file-system create and then you should be able to run openfoam11-macos

#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2017-2023 OpenFOAM Foundation
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
#
# Script
# openfoam11-macos
#
# Description
# Run script for an OpenFOAM 11 Docker image at:
# https://hub.docker.com/r/openfoam
#
#------------------------------------------------------------------------------
Script=${0##*/}
ver=11

usage () {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat <<USAGE

Usage: ${0##*/} [OPTIONS]
options:
-d | -dir host directory mounted (defaults to current directory)
-h | -help help
-p | -paraview [vers] include paraview, with version 56 | 510 (default)
-u | -upgrade install latest upgrades to the Docker image
-x | -xhost use custom X authority and give container host network

Launches the OpenFOAM-$ver Docker image.
- Requires installation of docker-engine.
- Runs a "containerized" bash shell environment where the user can run OpenFOAM
and, optionally, ParaView (see below).
- The container mounts the user's file system so that case files are stored
permanently. The container mounts the current directory by default, but the
user can also specify a particular directory using the "-d" option.
- Mounting the user's HOME directory is disallowed.
- The '-xhost' option is useful when accessing the host via 'ssh -X'.
This option should only be used when strictly necessary, as it relies on the
option '--net=host' when launching the container in Docker, which will
give to the container full access to the Docker host network stack and
potentially the host's system services that rely on network communication,
making it potentially insecure.

ParaView:
Graphical applications from the Docker container require installation of the
Xquartz X server to display on the host machine. While applications such as
Gedit, Emacs and GnuPlot will run effectively using Xquartz, more intensive
OpenGL applications, in particular ParaView, can be prohibitively slow.

Therefore, the default Docker image does not contain ParaView and users can
instead install ParaView directly from the vendor and use the built-in reader
module for OpenFOAM: https://www.paraview.org/download

However, if the user wishes to include ParaView with the official OpenFOAM
reader module in their Docker container, they can do so with the "-p" option.

Example:
To store data in $HOME/OpenFOAM/$USER-$ver, the user can launch
$Script either by:
cd $HOME/OpenFOAM/$USER-$ver && $Script
or
$Script -d $HOME/OpenFOAM/$USER-$ver

Further Information:
https://openfoam.org/download/$ver-macos

Note:
The container user name appears as "openfoam" but it is just an alias.

USAGE
exit 1
}

docker_image="openfoam/openfoam$ver-graphical-apps"
#docker_image="$HOME/.openfoam.dmg.sparseimage"
paraview_vers=""
mount_dir=$(pwd)
custom_xauth=""
docker_options=""

while [ "$#" -gt 0 ]
do
case "$1" in
-d | -dir)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
mount_dir=$2
shift 2
;;
-h | -help)
usage
;;
-p | -paraview)
# No version specified
{ [ "$#" -eq 1 ] || [ "$(echo "$2" | cut -c1)" = "-" ] ; } && \
paraview_vers=510 && \
shift 1 && \
continue
# Version specified
paraview_vers=$2
case "$paraview_vers" in
56|510) ;;
*) usage "'$2' is not a valid ParaView version." \
"Valid versions are 56 | 510."
;;
esac
shift 2
;;
-u | -upgrade)
upgrade=yes
shift
;;
-x | -xhost)
custom_xauth=yes
shift
;;
*)
usage "Invalid option '$1'"
;;
esac
done

[ "$paraview_vers" ] && \
echo "Including ParaView $paraview_vers" && \
docker_image="openfoam/openfoam$ver-paraview$paraview_vers"

[ -d "$mount_dir" ] || usage "No directory exists -: $mount_dir"
mount_dir=$(cd "$mount_dir" && pwd -P)

[ "$mount_dir" = "$(cd "$HOME" && pwd -P)" ] && \
usage "Mount directory cannot be the user's home directory" \
"Make a subdirectory and run from there, e.g." \
" mkdir -p $HOME/OpenFOAM/$(whoami)-$ver" \
" $Script -d $HOME/OpenFOAM/$(whoami)-$ver"

if [ -n "$custom_xauth" ]
then
xauth_path="$mount_dir/.docker.xauth.$$"
touch "$xauth_path"

# Generate a custom X-authority file that allows any hostname
xauth nlist "$DISPLAY" | sed -e 's/^..../ffff/' | \
xauth -f "$xauth_path" nmerge -

docker_options="-e XAUTHORITY=$xauth_path
-v $xauth_path:$xauth_path
--net=host"
fi

user_id=$(id -u 2> /dev/null)
[ -n "$user_id" ] || usage "Cannot determine current user ID"
group_id=$(id -g)

home_dir='/home/openfoam'

echo "Launching $0"
echo "User: "$(id -un)" (ID $user_id, group ID $group_id)"

ifaces=$(ifconfig | grep ^en | cut -d: -f1)
[ "$ifaces" ] || \
usage "Cannot find a network interface for DISPLAY with ifconfig" \
"Please report an issue at http://bugs.openfoam.org" \
" providing the output of the command: ifconfig"

for i in $ifaces
do
ip=$(ifconfig "$i" | grep inet | awk '$1=="inet" {print $2}')
[ "$ip" ] && break
done

[ "$ip" ] || \
usage "Cannot find a network IP for DISPLAY with ifconfig" \
"Please report an issue at https://bugs.openfoam.org" \
" providing the output of the command: ifconfig"

xhost + "$ip"

[ "$upgrade" ] && docker pull "$docker_image"

# shellcheck disable=SC2086
echo "docker_image = $docker_image"

docker run -it \
--rm \
-e DISPLAY=$IP:0 \
-u "$user_id":"$group_id" \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v "$mount_dir":$home_dir \
$docker_options \
"$docker_image"

[ -n "$custom_xauth" ] && [ -e "$xauth_path" ] && rm "$xauth_path"
Apologies if this is too basic but I have tried for a long time with no success. How do I go about making this change?
delighton is offline   Reply With Quote

Old   February 15, 2024, 04:26
Default
  #11
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,695
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Have you tried with the www.openfoam.com versions? There are both x64 and arm64 docker images, or you can compile natively on MacOS too.

https://develop.openfoam.com/Develop...is/precompiled
https://develop.openfoam.com/Develop...#darwin-mac-os
olesen is offline   Reply With Quote

Old   May 14, 2024, 02:21
Default Solved!
  #12
New Member
 
Sark
Join Date: May 2024
Posts: 1
Rep Power: 0
sarkpiens is on a distinguished road
I solved this problem and uploaded the script.

https://github.com/skyiwalker/openfo...enfoam11-macos

Hope you solve it



#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2017-2023 OpenFOAM Foundation
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
#
# Script
# openfoam11-macos
#
# Description
# Run script for an OpenFOAM 11 Docker image at:
# https://hub.docker.com/r/openfoam
#
#------------------------------------------------------------------------------
Script=${0##*/}
ver=11

usage () {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat <<USAGE

Usage: ${0##*/} [OPTIONS]
options:
-d | -dir host directory mounted (defaults to current directory)
-h | -help help
-p | -paraview [vers] include paraview, with version 56 | 510 (default)
-u | -upgrade install latest upgrades to the Docker image
-x | -xhost use custom X authority and give container host network

Launches the OpenFOAM-$ver Docker image.
- Requires installation of docker-engine.
- Runs a "containerized" bash shell environment where the user can run OpenFOAM
and, optionally, ParaView (see below).
- The container mounts the user's file system so that case files are stored
permanently. The container mounts the current directory by default, but the
user can also specify a particular directory using the "-d" option.
- Mounting the user's HOME directory is disallowed.
- The '-xhost' option is useful when accessing the host via 'ssh -X'.
This option should only be used when strictly necessary, as it relies on the
option '--net=host' when launching the container in Docker, which will
give to the container full access to the Docker host network stack and
potentially the host's system services that rely on network communication,
making it potentially insecure.

ParaView:
Graphical applications from the Docker container require installation of the
Xquartz X server to display on the host machine. While applications such as
Gedit, Emacs and GnuPlot will run effectively using Xquartz, more intensive
OpenGL applications, in particular ParaView, can be prohibitively slow.

Therefore, the default Docker image does not contain ParaView and users can
instead install ParaView directly from the vendor and use the built-in reader
module for OpenFOAM: https://www.paraview.org/download

However, if the user wishes to include ParaView with the official OpenFOAM
reader module in their Docker container, they can do so with the "-p" option.

Example:
To store data in $HOME/OpenFOAM/$USER-$ver, the user can launch
$Script either by:
cd $HOME/OpenFOAM/$USER-$ver && $Script
or
$Script -d $HOME/OpenFOAM/$USER-$ver

Further Information:
https://openfoam.org/download/$ver-macos

Note:
The container user name appears as "openfoam" but it is just an alias.

USAGE
exit 1
}

docker_image="openfoam/openfoam${ver}-graphical-apps"
paraview_vers=""
mount_dir=$(pwd)
custom_xauth=""
docker_options=""

echo "Script started" # DEBUG

while [ "$#" -gt 0 ]
do
case "$1" in
-d | -dir)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
mount_dir=$2
shift 2
;;
-h | -help)
usage
;;
-p | -paraview)
# No version specified
{ [ "$#" -eq 1 ] || [ "$(echo "$2" | cut -c1)" = "-" ] ; } && \
paraview_vers=510 && \
shift 1 && \
continue
# Version specified
paraview_vers=$2
case "$paraview_vers" in
56|510) ;;
*) usage "'$2' is not a valid ParaView version." \
"Valid versions are 56 | 510."
;;
esac
shift 2
;;
-u | -upgrade)
upgrade=yes
shift
;;
-x | -xhost)
custom_xauth=yes
shift
;;
*)
usage "Invalid option '$1'"
;;
esac
done

# 디렉토리 설정 및 확인 부분
echo "Initial mount_dir: $mount_dir" # DEBUG
[ -d "$mount_dir" ] || usage "No directory exists: $mount_dir"
mount_dir=$(cd "$mount_dir" && pwd -P)
echo "Resolved mount_dir: $mount_dir" # DEBUG

[ "$mount_dir" = "$(cd "$HOME" && pwd -P)" ] && \
usage "Mount directory cannot be the user's home directory" \
"Make a subdirectory and run from there, e.g." \
" mkdir -p $HOME/OpenFOAM/$(whoami)-$ver" \
" $Script -d $HOME/OpenFOAM/$(whoami)-$ver"

echo "Mount directory is valid" # DEBUG

[ "$paraview_vers" ] && \
echo "Including ParaView $paraview_vers" && \
docker_image="openfoam/openfoam$ver-paraview$paraview_vers"

[ -d "$mount_dir" ] || usage "No directory exists: $mount_dir"
mount_dir=$(cd "$mount_dir" && pwd -P)

[ "$mount_dir" = "$(cd "$HOME" && pwd -P)" ] && \
usage "Mount directory cannot be the user's home directory" \
"Make a subdirectory and run from there, e.g." \
" mkdir -p $HOME/OpenFOAM/$(whoami)-$ver" \
" $Script -d $HOME/OpenFOAM/$(whoami)-$ver"

if [ -n "$custom_xauth" ]
then
xauth_path="$mount_dir/.docker.xauth.$$"
touch "$xauth_path"
echo "Xauth path: $xauth_path" # DEBUG

# Generate a custom X-authority file that allows any hostname
xauth nlist "$DISPLAY" | sed -e 's/^..../ffff/' | \
xauth -f "$xauth_path" nmerge -

docker_options="-e XAUTHORITY=$xauth_path
-v $xauth_path:$xauth_path
--net=host"
fi

user_id=$(id -u 2> /dev/null)
echo "User ID: $user_id" # DEBUG
[ -n "$user_id" ] || usage "Cannot determine current user ID"
group_id=$(id -g)
echo "Group ID: $group_id" # DEBUG

home_dir='/home/openfoam'

echo "Launching $0"
echo "User: "$(id -un)" (ID $user_id, group ID $group_id)"

ifaces=$(ifconfig | grep ^en | cut -d: -f1)
echo "Interfaces: $ifaces" # DEBUG
[ "$ifaces" ] || \
usage "Cannot find a network interface for DISPLAY with ifconfig" \
"Please report an issue at http://bugs.openfoam.org" \
" providing the output of the command: ifconfig"

for i in $ifaces
do
ip=$(ifconfig "$i" | grep inet | awk '$1=="inet" {print $2}')
echo "IP for $i: $ip" # DEBUG
[ "$ip" ] && break
done

[ "$ip" ] || \
usage "Cannot find a network IP for DISPLAY with ifconfig" \
"Please report an issue at https://bugs.openfoam.org" \
" providing the output of the command: ifconfig"

xhost + "$ip"

[ "$upgrade" ] && docker pull "$docker_image"

# DEBUG
echo "Docker image: $docker_image"
echo "Mount directory: $mount_dir"
echo "User ID: $user_id"
echo "Group ID: $group_id"
echo "Docker options: $docker_options"

# shellcheck disable=SC2086
docker run -it \
--rm \
-e DISPLAY=$IP:0 \
-u "$user_id":"$group_id" \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v "$mount_dir":$home_dir \
$docker_options \
"$docker_image"

[ -n "$custom_xauth" ] && [ -e "$xauth_path" ] && rm "$xauth_path"
sarkpiens is offline   Reply With Quote

Reply

Tags
installation mac


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ansys Installation on Docker Container mohsen.shiea ANSYS 11 March 14, 2024 11:18
[OpenFOAM.com] v1606+ Install pb with Docker on OSX El Capitan BPich OpenFOAM Installation 3 October 10, 2016 18:52
[OpenFOAM.com] Docker OpenFOAM install error on Mac OS X dersh OpenFOAM Installation 10 May 6, 2016 12:49
[OpenFOAM.org] A Mac OS X of23x Development Environment Using Docker rt08 OpenFOAM Installation 1 February 28, 2016 19:00
[Commercial meshers] ST_Malloc: out of memory.malloc_storage: unable to malloc Velocity SA, cfdproject OpenFOAM Meshing & Mesh Conversion 0 April 14, 2009 15:45


All times are GMT -4. The time now is 23:46.