minimal C++ build and example

Provides a system for patient-specific cardiovascular modeling and simulation.
User avatar
Randy Heiland
Posts: 9
Joined: Tue Mar 27, 2007 6:43 am

minimal C++ build and example

Post by Randy Heiland » Mon Feb 07, 2022 12:07 pm

Is it possible to build a core/minimal C++ example from source? For example, if I don't care about the Python wrapper or GUI or visualization, can I build a minimal executable to read in a mesh, run the flow solver, and write output files?

thank you, Randy

User avatar
David Parker
Posts: 1719
Joined: Tue Aug 23, 2005 2:43 pm

Re: minimal C++ build and example

Post by David Parker » Mon Feb 07, 2022 3:49 pm

Hi Randy,

I don't believe that it is possible to build a minimal SV version without the GUI, there is no clean separation of MITK and key SV functionality.

You don't need the SV to run the solver, it can all be run from the command line. However, SV is needed to create the mesh-complete and .svpre files needed by the solver.

Cheers,
Dave

User avatar
Randy Heiland
Posts: 9
Joined: Tue Mar 27, 2007 6:43 am

Re: minimal C++ build and example

Post by Randy Heiland » Tue Feb 08, 2022 10:14 am

Thanks. In that case, I'll try to build from source. However, based on this page: https://github.com/SimVascular/SimVascu ... quirements, it seems that you don't support recent versions of macOS (I'm using 12.12).

Nevertheless, using the CMake option, I end up getting the following error, in case you have any suggestions:
...
from /Users/heiland/git/SimVascular/Code/Source/sv4gui/Modules/svFSI/sv4gui_MitksvFSIJob.cxx:32:
/Users/heiland/git/SimVascular/Build/Externals-build/svExternals/bin/itk-4.13.2/include/ITK-4.13/vcl_compiler.h:101:4: error: #error "Dunno about this gcc"
101 | # error "Dunno about this gcc"
| ^~~~~
make[5]: *** [Source/sv4gui/Modules/svFSI/CMakeFiles/_simvascular_module_svfsi.dir/sv4gui_MitksvFSIJob.cxx.o] Error 1

I see that the #ifdefs in vcl_compiler.h only go up to about gcc 8 and I'm using gcc 11:
~/git/SimVascular/Build$ cmake -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_C_COMPILER=gcc-11 ..
-- The C compiler identification is GNU 11.2.0
...

I may try my luck with the pure "Make" build option too.

User avatar
David Parker
Posts: 1719
Joined: Tue Aug 23, 2005 2:43 pm

Re: minimal C++ build and example

Post by David Parker » Tue Feb 08, 2022 12:13 pm

Hi Randy,

Dunno about this gcc, what an excellent error message! We use pre-compiled external libraries (mitk, vtk, etc.) when building SV so there seems to be an incompatibility with the GCC version you are using and the version used to build the libraries.

I can build SV on my Mac which is running MacOS 10.15, Apple clang version 12.0.0. SV will run on MacOS 11 with Intel and M1 chips, haven't tried it on MacOS 12.

Note that SV does not have a well-defined C++ API to access the functionality you want. You will need to hack something together. It would be better to use the SV Python API to run scripts from the command-line. The API does not yet support svSolver simulations so you would need to implement that.

Cheers,
Dave

User avatar
Randy Heiland
Posts: 9
Joined: Tue Mar 27, 2007 6:43 am

Re: minimal C++ build and example

Post by Randy Heiland » Tue Feb 08, 2022 1:35 pm

Now switching to Linux (Ubuntu 20) in hopes of some success just using precompiled binaries. From here: https://simtk.org/frs/index.php?group_id=188, I see there's an Ubuntu binary for svOneDSolver, so I download that .deb and install it, then try to run it:

$ /usr/local/sv/oneDSolver/2021-09-29/bin/OneDSolver
---------------------------------
oneDSolver
1D Finite Element Hemodynamics
---------------------------------
basic_string::_M_construct null not valid
Terminated.

I don't think I've found the correct doc showing me how to install/run it properly. The install/extraction also provided this file, just not sure if I need to do something with it:
$ more control
Architecture: amd64
Description: 1D Solver
Maintainer: SimVascular<sv@simvascular.org>
Package: oned-solver
Priority: optional
Section: devel
Version: 0.1.1
Installed-Size: 5476

And it seems the svSolver on the same simtk download page only provides a macOS pkg?

User avatar
Randy Heiland
Posts: 9
Joined: Tue Mar 27, 2007 6:43 am

Re: minimal C++ build and example

Post by Randy Heiland » Wed Feb 09, 2022 8:40 am

Ugh, I have to sheepishly admit I wasn't even downloading the full SimVascular binary package. It was hiding in plain sight at the top of the links. Let me try to make some progress with that before bugging you further.

User avatar
Randy Heiland
Posts: 9
Joined: Tue Mar 27, 2007 6:43 am

Re: minimal C++ build and example

Post by Randy Heiland » Wed Feb 09, 2022 1:18 pm

First, the failed attempt to run SV on Ubuntu, but then the partial success to run on macOS 12.12...

I downloaded/installed the SV .deb for Ubuntu and got an error (perhaps related to my GPU or driver):
heiland@asus:/usr/local/sv/simvascular/2021-09-29$ sudo bash setup-symlinks.sh

heiland@asus:/usr/local/sv/simvascular/2021-09-29$ ./simvascular
No plugins installed for current SimVascular installed version.
...
!3.873! WARNING: QOpenGLWidget: Failed to create context
!3.937! WARNING: WebEngineContext used before QtWebEngine::initialize() or OpenGL context creation failed.
!4.060! WARNING: QObject::connect: No such signal QWebEngineView::linkClicked(const QUrl& )
#4.329# ERROR: Failed to create OpenGL context for format QSurfaceFormat(version 3.2, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize 24, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize 1, stencilBufferSize 8, samples 0, swapBehavior QSurfaceFormat::SwapBehavior(DefaultSwapBehavior), swapInterval 1, colorSpace QSurfaceFormat::ColorSpace(DefaultColorSpace), profile QSurfaceFormat::OpenGLContextProfile(CoreProfile))
...
#55 0x7fb290b9ac0d mitk::BaseApplication::main()
#56 0x7fb28f508d81 Poco::Util::Application::run()
#57 0x7fb292c68ddc sv4guiMain()
#58 0x56125b694ef8 main
#59 0x7fb290d5b083 __libc_start_main
#60 0x56125b6953ae _start
r8: 0000000000000000 r9: 00007ffc23f962a0 r10: 0000000000000008 r11: 0000000000000246
r12: 000056125e021fc8 r13: 00007ffc23f96580 r14: 0000000000000003 r15: 00007ffc23f97220
di: 0000000000000002 si: 00007ffc23f962a0 bp: 00007ffc23f96590 bx: 00007fb2771c9900
dx: 0000000000000000 ax: 0000000000000000 cx: 00007fb290d7a15b sp: 00007ffc23f962a0
ip: 00007fb290d7a15b efl: 0000000000000246 cgf: 002b000000000033 erf: 0000000000000000
trp: 0000000000000000 msk: 0000000000001000 cr2: 0000000000000000
[end of stack trace]
-----------------------------------------

I then downloaded/installed the SV .dmg (for macOS 10.13) which seemed to run fine on 12.12. I then brought up the Python Console and ran the demo Python script that I found in one of your slide decks ("Software Eng for the SV Project"), that uses "demo.vtp". I get to the last line:
mesh_surface = mesher.get_surface()

but wondering where to go from here, starting with how do I display that mesh_surface in the GUI. And beyond that, how to run a solver and simulation of it? Again, maybe I simply haven't come across the proper doc, in which case I'll apologize in advance.

thanks, Randy

User avatar
David Parker
Posts: 1719
Joined: Tue Aug 23, 2005 2:43 pm

Re: minimal C++ build and example

Post by David Parker » Thu Feb 10, 2022 1:20 pm

Hi Randy,

The error on Ubuntu can be cause by your graphics card not supporting OpenGL version 2.1 or your graphics card drivers need to be updated.

So SV runs on MacOS 12.12, that's good to know!

Users create svSolver files using the SV GUI using the Simulations tool (see http://simvascular.github.io/docsFlowSolver.html). A simulation can then be run in parallel from the command-line using something like

Code: Select all

mpiexec -np 4 /usr/local/sv/svsolver/2022-02-07/bin/svsolver solver.inp 
There is currently no support in the SV Python API for svSolver simulations but there is for ROM simulations (https://github.com/SimVascular/SimVascu ... ulation.py).

For what you would like to do it would be better to run Python scripts from the command-line using the SV Python shell (see http://simvascular.github.io/docsPython ... thon_shell).

Cheers,
Dave

User avatar
Mandar Kulkarni
Posts: 16
Joined: Tue Jul 13, 2021 10:38 am

Re: minimal C++ build and example

Post by Mandar Kulkarni » Fri Jun 03, 2022 10:48 am

Hi Randy and Dave,

This entire thread was very useful. I wanted to do something very similar: Compile from source and use only the solver (I have some mesh files from my earlier use).

Is there any way of calling the svSolver recursively (with the same mesh) but different input settings (that is by a different input file)?

Can the phython scrpits help me do this with the svSolver?

After going through the thread, I was able to successfully download/install the Sept. 2021 binary (MacOS-10.13-2021.09.30.) on my I have macOS Monterey version 12.0.1.

Will be trying the python scripts next.

A couple of more things:

1) The wiki page that has installation instructions https://github.com/SimVascular/SimVascu ... te_install is not directly linked with the Downlads page https://simtk.org/frs/?group_id=188. It will be useful to cite the instructions next to the downloads.

2) I wasn't able to "Setup SimVascular to run from a terminal" as per instruction #5 on this page. I get the error:
"ln: /usr/local/bin/simvascular: No such file or directory"
I am not sure if it is required to run the python scripts, but will try next.

Thanks,
Mandar

User avatar
David Parker
Posts: 1719
Joined: Tue Aug 23, 2005 2:43 pm

Re: minimal C++ build and example

Post by David Parker » Fri Jun 03, 2022 11:41 am

Hi Mandar,

You will need to create separate directories duplicating all solver data with different solver.inp files and run the solver from each directory.

The current SV Python API does not support any svSolver functionality. This is something I would like to add in the future.

1) The wiki page that has installation instructions https://github.com/SimVascular/SimVascu ... te_install is not directly linked with the Downlads page https://simtk.org/frs/?group_id=188. It will be useful to cite the instructions next to the downloads.

That's a good idea! I will add the links.

2) I wasn't able to "Setup SimVascular to run from a terminal" as per instruction #5 on this page. I get the error:
"ln: /usr/local/bin/simvascular: No such file or directory"
I am not sure if it is required to run the python scripts, but will try next.


I just tried this on MacOS Catalina and it worked fine. In a terminal do the following to check that /usr/local/bin is a directory

Code: Select all

$ file /usr/local/bin
/usr/local/bin: directory
To execute SV from the command line I create an alias like this

Code: Select all

alias sv='/Applications/SimVascular.app/Contents/Resources/simvascular'
Cheers,
Dave

POST REPLY