Giter Club home page Giter Club logo

openfoam-applem1's Introduction

OpenFOAM-AppleM1

Patch to compile OpenFOAM-v2312 on Apple Silicon.

Procedures

  1. Install these dependencies from homebrew
brew install cmake open-mpi libomp adios2 boost cgal fftw kahip metis petsc scotch hypre
  1. Create a case-sensitive APFS volume like this

I usually create a soft link to keep everything consistent with Linux.

ln -s /Volumes/OpenFOAM ~/OpenFOAM
  1. Clone the OpenFOAM source code into this volume
cd ~/OpenFOAM
git clone https://develop.openfoam.com/Development/openfoam.git OpenFOAM-v2312
cd OpenFOAM-v2312
git checkout OpenFOAM-v2312

Optional: adding submodules such as petsc4Foam

git submodule init
git submodule update
  1. Apply my patch for M1.
curl -OL https://github.com/BrushXue/OpenFOAM-AppleM1/raw/main/M1.patch
git apply M1.patch
  1. Add OpenFOAM to .zshrc or .bashrc(if you wish)
echo 'source ~/OpenFOAM/OpenFOAM-v2312/etc/bashrc' >> ~/.zshrc

Important: you need to add the following for M1 (but not for x86):

export CPATH=/opt/homebrew/include
export LIBRARY_PATH=/opt/homebrew/lib
  1. Compile the code
./Allwmake -j -s -l

It takes 40~45 minutes on M1.

Optional: you may add -with-bear option after installing bear.

See https://openfoamwiki.net/index.php/HowTo_Use_OpenFOAM_with_Visual_Studio_Code for more information

Optional: Install paraview from Homebrew

brew install --cask paraview

Known issue

Currently on Apple Silicon, floating point exception will trap SIGILL instead of SIGFPE. It is known that Asahi Linux can correctly trap SIGFPE so the problem is from macOS or XCode. The workaround is to use SIGILL for now. If you don't like this workaround, please submit a bug report to Apple (but don't expect they'll fix it).

openfoam-applem1's People

Contributors

brushxue avatar gerlero avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

openfoam-applem1's Issues

FOAM FATAL ERROR: (openfoam-2206) in M1 Ultra

Hi,

I have compiled openfoam-2206 in my M1 Ultra.

I can run openfoam-2206 with serial mode.
But, in parallel mode, I have the following FATAL Error.

Are there any missing points?

--> FOAM FATAL ERROR: (openfoam-2206)
The dummy Pstream library cannot be used in parallel mode

From static bool Foam::UPstream::init(int &, char **&, const bool)
in file UPstream.C at line 49.

FOAM exiting

您好,怎么在mac上安装 rheoTool 呢?安装出现错误

提示错误如下:


Petsc has been downloaded successfully to directory:

/Users/pfg/OpenFOAM/pfg-v2212/ThirdParty/petsc-3.14.5

Using python3 for Python

         Configuring PETSc to compile on your system                       

===============================================================================
TESTING: configureDirectories from PETSc.options.petscdir(config/PETSc/options/petscdir.py:23) *******************************************************************************
UNABLE to CONFIGURE with GIVEN OPTIONS (see configure.log for details):

The environmental variable PETSC_DIR /usr/local/Cellar/petsc/3.15.4 MUST be the current directory /Users/pfg/OpenFOAM/pfg-v2212/ThirdParty/petsc-3.14.5


非常感谢!
非常愿意有偿帮助在mac上编译rheoTool。

我的QQ 254679746

Parallel run with method `scotch` not working

Hi Guanyang Xue,

Happy that it's working and single core performance seems better than my desktop with i9 + 32GB RAM. Found another problem now. Parallel run with the method simple is working but it blurts out the following when I tried to use scotch:

/*---------------------------------------------------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2106                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
Build  : _c15bfde3cb-20210624 OPENFOAM=2106
Arch   : "LSB;label=32;scalar=64"
Exec   : decomposePar -force
Date   : Jan 01 2022
Time   : 20:30:35
Host   : coldandwhite.local
PID    : 77116
I/O    : uncollated
Case   : /Users/massisenergy/OpenFOAM/pitzDaily
nProcs : 1
trapFpe: Floating point exception trapping - not supported on this platform
fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 5, maxFileModificationPolls 20)
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time



Decomposing mesh

Removing 8 existing processor directories
Create mesh

Calculating distribution of cells
Decomposition method scotch [8] (region region0)


--> FOAM FATAL ERROR: (openfoam-2106)
Attempted to use <scotch> without the scotchDecomp library loaded.
This message is from the dummy scotchDecomp stub library instead.

Please install <scotch> and ensure libscotch.so is in LD_LIBRARY_PATH.
The scotchDecomp library can then be built from src/parallel/decompose/scotchDecomp.
Dynamically loading or linking this library will add <scotch> as a decomposition method.


    From virtual Foam::labelList Foam::scotchDecomp::decompose(const Foam::polyMesh &, const Foam::pointField &, const Foam::scalarField &) const
    in file dummyScotchDecomp.C at line 102.

FOAM exiting

Is it working for you? How do I go about this?

I have installed scotch from home-brew:

$brew info scotch
scotch: stable 6.1.3 (bottled), HEAD
Package for graph partitioning, graph clustering, and sparse matrix ordering
https://gitlab.inria.fr/scotch/scotch
/opt/homebrew/Cellar/scotch/6.1.2 (76 files, 5.7MB) *
  Poured from bottle on 2021-12-28 at 12:08:27
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/scotch.rb
License: CECILL-C
==> Dependencies
Required: open-mpi ✔
==> Options
--HEAD
	Install HEAD version
==> Analytics
install: 53 (30 days), 227 (90 days), 524 (365 days)
install-on-request: 51 (30 days), 220 (90 days), 499 (365 days)
build-error: 0 (30 days)

"wmake" doesn't work.

Hello BrushXue.

I am trying to get openfoamv2112 into my M1Mac based on your article.
I was able to run it up to step 4.
But step 5 ". /Allwmake -j -s -l" does not work.
It should take about 30 minutes, but it takes about 10 seconds.
Here is the link to log.darwinARM64ClangDPInt32Opt
https://drive.google.com/file/d/1LGqfLOIFjyrYnj_KwLBEC4vIMaEzooYP/view?usp=sharing
Also, there is one error in the foamInstallationTest. Here is the link.
https://drive.google.com/file/d/1lTR1dy4xxWQ0xSO0-qL8P3D9ZRoOBHVn/view?usp=sharing

Incidentally, I also got an error in wmake that there was no "~Cloud.H file", so I copy-pasted the ~Cloud.H file from openfoamv2006 to improve the situation. (I don't know if this is a good idea)

I would like to know if there is any way to improve this.
Iseo

Make unsuccessful

Hi there,

I couldn't compile on Apple M1 with your patch

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:858:15: note: expanded from macro '_VSTD' #define _VSTD std::_LIBCPP_ABI_NAMESPACE ^ fatal error: too many errors emitted, stopping now [-ferror-limit=] 20 errors generated.

Trying in M1Pro, build process halts soon.

Firstly, kudos for making it work in the new architecture and thanks for putting the instructions here for others. I recently got a M1Pro, and I could reach to the point without any errors (applying the two patches) when I start the build process:Allwmake -j,
which starts without any error but then exit after maybe a minute or two, with the following end:

clang++ -std=c++14 -pthread -DOPENFOAM=2106 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-undefined-var-template -Wno-unknown-warning-option  -O3  -DNoRepository -ftemplate-depth-100  -iquote. -IlnInclude -I/Volumes/OpenFOAM/OpenFOAM-v2106/src/OpenFOAM/lnInclude -I/Volumes/OpenFOAM/OpenFOAM-v2106/src/OSspecific/POSIX/lnInclude   -fPIC -c sampledSetWriters/nastran/nastranSetWriterRunTime.C -o /Volumes/OpenFOAM/OpenFOAM-v2106/build/darwinARM64ClangDPInt32Opt/src/fileFormats/sampledSetWriters/nastran/nastranSetWriterRunTime.o
/Volumes/OpenFOAM/OpenFOAM-v2106/build/darwinARM64ClangDPInt32Opt/src/fileFormats/stl/STLAsciiParseFlex.L.C:5949:18: error: out-of-line definition of 'LexerInput' does not match any declaration in 'yySTLFlexLexer'
int yyFlexLexer::LexerInput( char* buf, int max_size )
                 ^~~~~~~~~~
/Volumes/OpenFOAM/OpenFOAM-v2106/build/darwinARM64ClangDPInt32Opt/src/fileFormats/stl/STLAsciiParseFlex.L.C:5976:19: error: out-of-line definition of 'LexerOutput' does not match any declaration in 'yySTLFlexLexer'
void yyFlexLexer::LexerOutput( const char* buf, int size )
                  ^~~~~~~~~~~
/Volumes/OpenFOAM/OpenFOAM-v2106/build/darwinARM64ClangDPInt32Opt/src/fileFormats/stl/STLAsciiParseFlex.L.C:6104:38: warning: comparison of integers of different signs: 'unsigned long' and 'int' [-Wsign-compare]
        if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning and 2 errors generated.
make: *** [/Volumes/OpenFOAM/OpenFOAM-v2106/build/darwinARM64ClangDPInt32Opt/src/fileFormats/stl/STLAsciiParseFlex.o] Error 1
make: *** Waiting for unfinished jobs....
$

I absolutely couldn't make any sense out of it. Can you take a look what might be possibly went wrong? I can provide more info if you need.

Problems with apple-native flex

Hi,

I am installing OpenFOAM on macOS 14.0 and stumbled onto the following error while following the instructions:

flex -+ -f -o /Volumes/OpenFOAM/OpenFOAM-v2306/build/darwin64ClangDPInt32Opt/src/fileFormats/stl/STLAsciiParseFlex.L.C stl/STLAsciiParseFlex.L &&  clang++ -std=c++14 -pthread -ftrapping-math -ffp-contract=off -DOPENFOAM=2306 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-undefined-var-template -Wno-unknown-warning-option -O3  -DNoRepository -ftemplate-depth-100   -iquote. -IlnInclude -I/Volumes/OpenFOAM/OpenFOAM-v2306/src/OpenFOAM/lnInclude -I/Volumes/OpenFOAM/OpenFOAM-v2306/src/OSspecific/POSIX/lnInclude   -fPIC -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-tautological-undefined-compare -Wno-shift-negative-value -Wno-null-pointer-arithmetic -Wno-null-pointer-subtraction -Wno-unknown-warning-option -Wno-deprecated-copy-with-user-provided-copy -Wno-tautological-overlap-compare -Wno-#pragma-messages -c /Volumes/OpenFOAM/OpenFOAM-v2306/build/darwin64ClangDPInt32Opt/src/fileFormats/stl/STLAsciiParseFlex.L.C -o /Volumes/OpenFOAM/OpenFOAM-v2306/build/darwin64ClangDPInt32Opt/src/fileFormats/stl/STLAsciiParseFlex.o
/Volumes/OpenFOAM/OpenFOAM-v2306/build/darwin64ClangDPInt32Opt/src/fileFormats/stl/STLAsciiParseFlex.L.C:5949:18: error: out-of-line definition of 'LexerInput' does not match any declaration in 'yySTLFlexLexer'
int yyFlexLexer::LexerInput( char* buf, int max_size )
                 ^~~~~~~~~~
/Volumes/OpenFOAM/OpenFOAM-v2306/build/darwin64ClangDPInt32Opt/src/fileFormats/stl/STLAsciiParseFlex.L.C:5976:19: error: out-of-line definition of 'LexerOutput' does not match any declaration in 'yySTLFlexLexer'
void yyFlexLexer::LexerOutput( const char* buf, int size )
                  ^~~~~~~~~~~
/Volumes/OpenFOAM/OpenFOAM-v2306/build/darwin64ClangDPInt32Opt/src/fileFormats/stl/STLAsciiParseFlex.L.C:6104:38: warning: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Wsign-compare]
        if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning and 2 errors generated.

I choose to install flex and bison using homebrew and adjust the CPATH accordingly to get around this problem

brew install flex bison
export CPATH=/opt/homebrew/include:/opt/homebrew/opt/flex/include
export LIBRARY_PATH=/opt/homebrew/lib
export PATH="/opt/homebrew/opt/flex/bin:$PATH"
export PATH="/opt/homebrew/opt/bison/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/flex/lib -L/opt/homebrew/opt/bison/lib"
export CPPFLAGS="-I/opt/homebrew/opt/flex/include"
source /Volumes/OpenFOAM/OpenFOAM-v2306/etc/bashrc

Then it works.

Hope I didn't miss anything obvious - would be great to have a completely working instruction here.

Yours,
dharly

Tutorial case `backwardFacingStep2D` hangs forever after compiling with Xcode CLT >= 14.3

$FOAM_TUTORIALS/incompressible/simpleFoam/backwardFacingStep2D gets stuck before the completing the first timestep after OpenFOAM is compiled with Xcode Command Line Tools >= 14.3 (gerlero/openfoam-app#160). Apparently, it hangs between the processing these lines:

    #includeFunc "pressureCoefficient"
    #includeFunc "sample"

in the controlDict.

I tried with your repo to see if I it was me who was doing something wrong, but after following the build instructions here I still run into the same problem. Do you have an idea on what could be going on here?

EDIT: removing mention of "Clang 14" as it might be confusing (Xcode CLT < 14.3 also comes with Clang 14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.