Hi Rainer,

This is not quite correct. Thrust still supports the OpenMP backend. It’s just 
that in recent versions they introduced these dependencies on CUDA headers and 
so it cannot be used anymore without a CUDA installation (thrust is distributed 
as part of it) even though one may never use CUDA (as is the case in our case 
here).

I’m not sure what the best solution is here. For now, I suggest simply not 
enabling the Chrono::Multicore module. Akthem, looking at the problem you 
describe, I don’t see why you would need that module anyway.  Note that FEA in 
Chrono does use OpenMP parallelization, but it does not rely on Thrust.

--Radu

From: [email protected] <[email protected]> On Behalf 
Of [email protected]
Sent: Monday, May 8, 2023 9:50 AM
To: ProjectChrono <[email protected]>
Subject: [chrono] Re: Mac Ventura Installation Issues

Hi Akthem,

your mail was a surprise for me, since I had no problems with thrust-1.16.0. No 
further configuration is necessary when configuring chrono. I tried the actual 
thrust-2.1.0 yet - and got the same error that you reported. The thrust project 
has changed its policy of supporting different configurations (serial, OMP, 
CUDA). It looks to me only cuda is supported now. The last version to work with 
chrono is 1.7.2. I tested it today and was able to run all unit tests 
successfully. So I can recommend it to you.

Best,
Rainer

[email protected]<mailto:[email protected]> schrieb am Dienstag, 2. Mai 2023 um 
22:39:03 UTC+2:
As for the CFD coupling with Chrono, yes it would be great have an expert help 
with that.
On Tuesday, May 2, 2023 at 11:29:57 PM UTC+3 Akthem Rehab wrote:
Hi Rainer,
Thank you for your helpful reply and apologies for the delayed response. 
Following your lead, I did the following:

1- - Install libomp with homebrew (that will bring omp.h for and other good 
things). Straight forward!
2- - Install thrust, well it is header-only, you must tell cmake the correct 
include path. I added this line to chrono's cmakelists.txt:
set(THRUST_INCLUDE_DIR /Users/Akthem/Downloads/thrust)
include_directories(${THRUST_INCLUDE_DIR})
3- - Install blaze, also header only, same procedure like thrust. I added this 
line to chrono's cmakelists.txt:
include_directories(/Users/Akthem/Downloads/blaze-3.8.2)

Further, I changed cmake/FindThrust.cmake contents to (with chatgpt help):
find_path(THRUST_INCLUDE_DIR thrust/version.h PATHS ${THRUST_ROOT_DIR} 
NO_DEFAULT_PATH)
if (THRUST_INCLUDE_DIR)
    file(READ "${THRUST_INCLUDE_DIR}/thrust/version.h" THRUST_VERSION_FILE)
    string(REGEX MATCH "#define THRUST_VERSION_MAJOR ([0-9]*)" _ 
"${THRUST_VERSION_FILE}")
    set(THRUST_VERSION_MAJOR ${CMAKE_MATCH_1})
    string(REGEX MATCH "#define THRUST_VERSION_MINOR ([0-9]*)" _ 
"${THRUST_VERSION_FILE}")
    set(THRUST_VERSION_MINOR ${CMAKE_MATCH_1})
    string(REGEX MATCH "#define THRUST_VERSION_PATCH ([0-9]*)" _ 
"${THRUST_VERSION_FILE}")
    set(THRUST_VERSION_PATCH ${CMAKE_MATCH_1})
    set(THRUST_VERSION 
"${THRUST_VERSION_MAJOR}.${THRUST_VERSION_MINOR}.${THRUST_VERSION_PATCH}")
    set(THRUST_FOUND TRUE)
    message(STATUS "Found Thrust: ${THRUST_INCLUDE_DIR} (found version 
${THRUST_VERSION})")
else ()
    message(FATAL_ERROR "Could not find Thrust library.")
endif ()

This leads to a successful cmake as per the below command:


cmake -S /Users/Akthem/chrono -B build \

-DCMAKE_BUILD_TYPE=Release \

-DOpenMP_CXX_FLAGS:STRING="-Xclang -fopenmp" \

-DOpenMP_C_FLAGS:STRING="-Xclang -fopenmp" \

-DOpenMP_C_INCLUDE_DIR:PATH=-L/opt/homebrew/opt/libomp/lib \

-DOpenMP_CXX_INCLUDE_DIR:PATH=/opt/homebrew/opt/libomp/include \

-DOpenMP_C_LIB_NAMES:STRING=libomp \

-DOpenMP_CXX_LIB_NAMES:STRING=libomp \

-DOpenMP_libomp_LIBRARY:FILEPATH="/opt/homebrew/opt/libomp/lib/libomp.dylib" \

-DTHRUST_INCLUDE_DIR:PATH=${DEPFIX}/include \

-DBLAZE_INSTALL_DIR:PATH=/usr/local/include \

-DENABLE_MODULE_POSTPROCESS:BOOL=ON \

-DENABLE_MODULE_VEHICLE:BOOL=ON \

-DENABLE_MODULE_IRRLICHT:BOOL=ON \

-DENABLE_MODULE_MULTICORE=ON \

-DIRRLICHT_INSTALL_DIR:PATH=/opt/homebrew



Then, I follow through with cmake --build build and get the below error:



/Users/Akthem/Downloads/thrust/thrust/detail/type_traits.h:27:10: fatal error: 
'cuda/std/type_traits' file not found

#include <cuda/std/type_traits>

         ^~~~~~~~~~~~~~~~~~~~~~

10 warnings and 1 error generated.

make[2]: *** [src/chrono/CMakeFiles/ChronoEngine.dir/physics/ChBody.cpp.o] 
Error 1

make[1]: *** [src/chrono/CMakeFiles/ChronoEngine.dir/all] Error 2

make: *** [all] Error 2



I tried to comment out the line causing the error in the above mentioned file:

#include <cuda/std/type_traits>



This leads to other errors and a fatal error linked to cuda too. Could you 
please check my workflow/syntax and let me know where did I go wrong. 
Alternatively, if all went well, then how to overcome this hurdle?



Thank you,



Sincerely,

Akthem



On Thursday, April 27, 2023 at 5:24:33 PM UTC+2 
[email protected]<mailto:[email protected]> wrote:
Hi Akthem,

I cannot answer all your questions, since I know nearly nothing about the 
subject of your work, but I can try to find other collegues familiar with 
chrono and fluid simulation.

I can help you to get over the macOS issues yet.

1) Xcode, I sometimes have the same error you got. That helped on my machine, 
type on the command line :
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

2) Using OpenMP on the Mac:
- install libomp with homebrew (that will bring omp.h for and other good things)
- install thrust, well it is header-only, you must tell cmake the correct 
include path
- install blaze, also header only, same procedure like thrust

Now comes the cumbersome part, give all information to cmake

cmake  -G Ninja -S $REPOSITORY -B build \
               -DCMAKE_BUILD_TYPE=Release \
               -DOpenMP_CXX_FLAGS:STRING="-Xclang -fopenmp" \
               -DOpenMP_C_FLAGS:STRING="-Xclang -fopenmp" \
               -DOpenMP_C_INCLUDE_DIR:PATH=-L/opt/homebrew/opt/libomp/lib \
               -DOpenMP_CXX_INCLUDE_DIR:PATH=/opt/homebrew/opt/libomp/include \
               -DOpenMP_C_LIB_NAMES:STRING=libomp \
               -DOpenMP_CXX_LIB_NAMES:STRING=libomp \
               
-DOpenMP_libomp_LIBRARY:FILEPATH="/opt/homebrew/opt/libomp/lib/libomp.dylib" \
               -DTHRUST_INCLUDE_DIR:PATH=${DEPFIX}/include \
               -DBLAZE_INSTALL_DIR:PATH=${DEPFIX}/include \
               ... your desired settings ...

Best Regards

Rainer
[email protected]<mailto:[email protected]> schrieb am Donnerstag, 27. April 2023 
um 01:02:45 UTC+2:
Hi Rainer,
Thank you! Following the instructions to the letter successfully builds and 
installs Chrono as per the two scenarios you provided above. On a side note, 
Ninja and the default Unix Makefiles worked while Xcode returned errors asking 
for default compilers. Perhaps this is an error related to my mac setup!

Having another go on the documentation, it clearly states that the FSI and 
Sensor modules are not supported in MacOS. However, I think Multicore could be 
built on MacOS if Thrust could be built on top of openMP. Could you please 
confirm if this is correct/doable? If correct, could you share updated syntax 
and dependencies for the cmake and build? From my end I had a failed attempt 
trying to cmake Thrust with the following command: cmake 
-DTHRUST_DEVICE_BACKEND=OMP /path/to/thrust/source

Based on  a pump health monitoring simulation use-case I am working on, and 
given that FSI and Sensor are not within my disposal, I came up with this 
workflow utilizing open-source Mac friendly tools:

  1.  Create the pump geometry using FreeCAD.
  2.  Mesh the pump geometry using GMSH (or perhaps CFMesh) and export it to 
OpenFOAM format.
  3.  Set up the simulation using OpenFOAM and the Elmer-OpenFOAM library. Use 
OpenFOAM to solve for the fluid flow and ElmerFEM to solve for the structural 
mechanics. Use the Elmer-OpenFOAM library to couple the two solvers.
  4.  In the simulation, introduce random faults (such as misalignment, 
unbalance, bearing fault, or others) and simulate the vibration acceleration.
  5.  Use Chrono to simulate the fault propagation and pump failure. Although 
Chrono's Sensor and FSI modules are not available, Chrono is still used for 
rigid body dynamics capabilities to simulate the mechanical behavior of the 
pump.
  6.  Export the vibration (acceleration) data from Chrono to Paraview for 
visualization and analysis.
  7.  Use the FEM workbench in FreeCAD to analyze the vibration data and 
estimate the remaining useful life of the pump and/or faulty component.
As I am researching and picking my toolset before getting to work, your input 
on the workflow will be highly valued and appreciated. If any of the above can 
still be done with Chrono to minimize the number of tools, handovers, and of 
course the learning curve and time, please let me know. Any other feedback is 
welcome too!

Thank you!

Sincerely,
Akthem
On Wednesday, April 26, 2023 at 8:35:28 AM UTC+2 
[email protected]<mailto:[email protected]> wrote:
Hi Akthem,

beginning the work with a complex project is always a challenge and one problem 
is: macOS does not support all chrono modules!

It helps to begin with a minimal configuration:

rm -rf build
cmake -S /where/your/chrono/source/is -B build

my chrono sources are in ${HOME}/Documents/GitHub/chrono but this is not a law 
of nature, just take the path of your installation.
'build' is the directory, where the configuration and the build take place. The 
build directory must be empty! The configuration should work.

cmake --build build

or

cd build
make

This should run without errors. What you get is a basic configuration with a 
couple of demos in build/bin

Try the demos. Unfortunately we have to generate Mac Bundles, so to start an 
example you must write

cd bin
./demo_CH_EulerAngles.app/Content/MacOS/demo_CH_EulerAngles

or

run_app.sh demo_CH_EulerAngles.app

if you have installed the convenience script from 
chronoSRC/contrib/appbundle-macosx

I am a vehicle simulation guy and I want to have the vehicle module enabled. 
Also necessary is postprocessing and 3d graphics:

rm -rf build
cmake -S /where/your/chrono/source/is -B build \
                     -DCMAKE_BUILD_TYPE=Release \
                     -DENABLE_MODULE_POSTPROCESS:BOOL=ON \
                     -DENABLE_MODULE_VEHICLE:BOOL=ON \
                     -DENABLE_MODULE_IRRLICHT:BOOL=ON \
                     -DIRRLICHT_INSTALL_DIR:PATH=/opt/homebrew

cmake generates Unix Makefiles by default, a faster alternative is ninja (cmake 
-G Ninja ....) or even better with and IDE (cmake -G Xcode ...).
ninja can be installed with homebrew. You also need gnuplot, can also be 
installed with homebrew.

Some modules in chrono can only work with Nvidia hardware and require cuda. 
Cuda is not available for macOS as well as OptiX.
Alternative for Irrlicht is VSG. It also works well, but some functionality is 
lacking actually. The configuration for OpenGL is messed up for macOS, so don't 
try it, or better try it and repair it. Generally spoken: activate only the 
modules that you ar willing to use!

Good Start!

Rainer
[email protected]<mailto:[email protected]> schrieb am Mittwoch, 26. April 2023 
um 00:56:59 UTC+2:
Hi Project Chrono Team,
I spent the day trying to Cmake project chrono. I followed the Mac OS 
instructions in Chrono tutorial 
install<https://api.projectchrono.org/tutorial_install_chrono.html>. I used the 
preset "macOS CI Configuration" and generator "Unix Makefiles" in the cmake GUI.

This succeeds in building and generating project chrono after making sure the 
value for "THRUST_INCLUDE_DIR" is empty. However it was built and generated 
with Sensor, Distributed, GPU, FSI, and Multicore disabled. Multicore requires 
Thrust while the other modules require Cuda. Both were not found.

I failed to install Thrust without Cuda in a Mac Silicon. Question 1: Am I 
missing something or did I follow the steps correctly and none of these modules 
can be run on a Mac Silicon?

Moving forward, I attempted to make from the generated build using:



make CXXFLAGS="-Xpreprocessor -fopenmp" LDFLAGS="-lomp"



This was based on the MacOS clang++ issues highlighted in step 8. This results 
in 8 warnings and 1 error. The error being:



/opt/homebrew/include/eigen3/Eigen/Core:70:10: fatal error: 'omp.h' file not 
found

#include <omp.h>

         ^~~~~~~

8 warnings and 1 error generated.

make[2]: *** [src/chrono/CMakeFiles/ChronoEngine.dir/core/ChFilePS.cpp.o] Error 
1

make[1]: *** [src/chrono/CMakeFiles/ChronoEngine.dir/all] Error 2

make: *** [all] Error 2



Question 2: Again, where did I go wrong here?



I am new to the macOS, shell, and cmake and the learning curve was steep 
getting to this point. So, I hope you cut me some slack if any/all of my 
questions are basic/naive and I hope you can help me get over this hurdle and 
successfully run Chrono. Of course running the additional modules and 
parallelization would be an amazing bonus after successful installation.



>From what I read, Chrono sounds solid in multi-body dynamics. I hope I can 
>make it run on my mac and start benefiting from it.



Thank you,

Akthem
--
You received this message because you are subscribed to the Google Groups 
"ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
[email protected]<mailto:[email protected]>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/projectchrono/08214a60-0e0e-4bbf-8ff8-538e4b581465n%40googlegroups.com<https://groups.google.com/d/msgid/projectchrono/08214a60-0e0e-4bbf-8ff8-538e4b581465n%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/projectchrono/PH0PR06MB823743B120A8E5C0E6909C42A7719%40PH0PR06MB8237.namprd06.prod.outlook.com.

Reply via email to