CMB 3D modeling

Hi. I´ve been working with the CMB2d example (ModelBuilder-2D — ModelBuilder-2D 1.0.0 documentation), and it seems to work very well. My question is: can I create a custom application (or, more specifically, how would I go about this) in order to extend this to work with 3D models? I assume I would have to connect with a different mesher (possibly Gmsh) and a different solver (possibly CalculiX), but currently I have no idea/experience on how to do this. Is there any example where I can base my work off?

Finally, would there be any difference with working on Linux? I have been working with WSL but I was thinking of dual booting my computer in order to work on Ubuntu, but I don´t have a lot of experience with that OS.

Best regards,
Tomas

1 Like

Glad to know you’ve been able to run the example on WSL.

To your question about creating a custom application, yes, it is possible to create your own custom application using the CMB platform. However it is not a trivial undertaking. To begin, you would need to build CMB and its dependencies from source code. We have a superbuild for that and I will paste a general outline for building modelbuilder in a subsequent post. Then once you have built modelbuilder, you can code & build plugins to support the meshers and solvers you want.

Because the process is very technical, Kitware generally provides contract services to implement new functionality like this, at least in minimal form. Nonetheless, all of the source code have an open/permissive license so that no one is prevented from doing it themselves.

As for WSL vs Linux:

  • I don’t know if a standalone Ubuntu system will offer much benefit over WSL. I am no expert, but I would expect anything that runs on Ubuntu will run on WSL.
  • I will also note that Kitware no longer uses dual-boot because of restrictions/roadblocks that are inherent to BIOS or maybe Windows itself.
  • Also fyi, CMB modelbuilder will build on the Windows OS. We don’t offer the CMB-2D on windows only because the XMS mesher doesn’t build with our superbuild on Windows without major modifications (XMS is developed by a different company). So you could try a windows build first; I’ll post my building-cmb notes shortly.

Regarding building your own customized version of modelbuilder, you first need to build from source code.

  • The starting point is the cmb-superbuild. The web page is https://gitlab.kitware.com/cmb/cmb-superbuild, which is used to build all of the dependent libraries. I am pretty sure you can pull the source without an account on our gitlab server.
  • Check the README.md for general requirements: cmake, ninja, gcc are the big ones. Ubuntu has a build-essential package that should have most or all of what you need.
  • Don’t install Qt from the ubuntu packages, but instead get the installer from Qt’s community page: Open Source Development | Open Source License | Qt. Go to that page and scroll down to find a green button labeled “Download the Qt Online Installer”. When you run that, you will need to create a (free) account with Qt before it will let you install.
  • When you get to the part where you can select what to install, open the “Qt” item, open its child item “Qt 5.15.2” and select “Desktop gcc 64-bit”. And unselected everything else, otherwise you will download a huge amount of other stuff you won’t need.
  • I might be getting ahead of things, but when you are ready to run cmake, be sure to set both DEVELOPER_MODE_cmb and DEVELOPER_MODE_smtk to ON. You’ll also need to set Qt5_DIR to point to your installed Qt.

That’s alot and we’re not done yet. Ping me back if you get stuck or when you are ready to build cmb-superbuild.

(Note: this was copied from Struggle to get the windtunnel modelbuilder running properly - #20 by johnt)

Hi John,

Thank you for the reply. I will try to build CMB and get back to you as soon as possible (possibly tomorrow). Since I don´t have a lot of experience with the software and how it works, I´ve been trying to read the documents. However, there´s a lot of information, so it´s been slow progress. I´m afraid this project might be too complex for my skills.

Best regards,
Tomas

Hi @johnt, I apologize for contacting so late, I´ve been trying to build the CMB superbuild but I´ve been getting an error (attached as image), and I´ve been stuck.



1. The first thing would be to make sure the “superbuild submodule” is up to date. If you haven’t done so already, run these commands in the cmb-superbuild source directory:

    > git submodule init
    > git submodule update

In response, you should see output like this:

    Cloning into '<source-path-on-your-machine>/superbuild'...'
    Submodule path 'superbuild': checked out '253cac1324bf083e26afeebd449bf7de9efc4be0'

2. If you have already set up the submodule, we can take a deeper look if you send me:

  • The CMakeCache.txt file that is generated in your build directory
  • Full logs when you run the cmake and build commands. If you aren’t familiar, you can redirect the terminal output to a log file with syntax like this:
    > cmake <path-to-source-directory> > cmake.log 2>&1
    > ninja > build.log 2>&1

Hi @johnt, thank you for the reply. I have run these two commands in the source directory:

git submodule init
git submodule update

However, I did not see an output. Since I don´t think it allows me to attach text documents, here is a link with all the documents mentioned (https://we.tl/t-NSV0UEX9hQ).

Once again thank you,
Tomas Ribeiro

Hi Tomas. Your first note (“I did not see an output”) is pretty surprising. As a sanity check, would you start a new terminal and run these 4 commands from a new (empty) directory, and report back what shows up on the terminal.

> git clone https://gitlab.kitware.com/cmb/cmb-superbuild.git
> cd cmb-superbuild
> git submodule init
> git submodule update

I’ll also send you a DM with the expected output (copied from my terminal). Thanks.

It works on this new directory. I tried to do it again on the other directory, and that one still does not show an output, which I find strange.

Thanks,
Tomas

Strange indeed. Maybe in the first terminal the git command got accidentally aliased to something else?

If you want to move forward with the “working” terminal, you can try running cmake if you have already installed Qt5.15. If not, I would do that first.

Hi John, before I proceed I just want to confirm something:

  • I should make a new directory first for the build, correct?

  • Last time, I installed Qt5.15 using the community page. However, I installed the Windows version. Since I´m currently working with WSL, should I instead install the Linux version?

Thank you,
Tomas

  1. Yes, you should always create a separate directory for building. Not a subdirectory under the source, but a separate directory. I typically make “src” and “build” directories under the same root path, for example:
.../src/
     cmb-superbuild/
     some_new_plugin/
.../build/
     cmb-superbuild/
     some_new_plugin/
  1. And yes, if you are building in WSL, get the Qt installer for linux and run it from a WSL termnial.

Hello @johnt, I apologize for getting back to you so late. I already managed to install Qt from the installer (the current version is 6.7.0), and created a new directory for the build. Is there anything else I should do? As an experiment, instead of using the command line, I was trying to use the CMake GUI to build, however I get the same errors that I was getting previously.

Best regards,
Tomas

1.0 Hi Tomas. Please post a full log when you run cmake configure. I’ve never used the gui tool, but from a terminal, run these commands:

    > cd <path-to-build-directory>
    > rm -f CMakeCache.txt
    > cmake -GNinja <path-to-cmb-superbuild-source-directory>

The output should look like the following. (Click on “Console Log”)

Console Log
cmake ../../git/cmb-superbuild/
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check size of void*
-- Check size of void* - done
-- found package: ace3p
-- found package: aeva
-- found package: cmb2d
-- found package: mb-docker
-- found package: modelbuilder
-- found package: truchas
-- found package: windtunnel
-- Default package: 
-- Found Git: /usr/bin/git (found version "2.25.1") 
-- Determined source version for cmb: 23.01.100
-- Determined source version for smtk: 24.01.101
-- Determined source version for paraview: 5.11.0
-- Determined source version for vtk: 9.0.0
-- Enabling cxx11 for: eigen, nlohmannjson, pegtl, pybind11, qt5, smtk, smtkresourcemanagerstate, units
-- Enabling boost for: cmb, paraview, smtk, smtkresourcemanagerstate
-- Enabling eigen for: moab, smtk, units
-- Enabling zlib for: freetype, hdf5, libarchive, netcdf, paraview, png, python3, qt5
-- Enabling szip for: hdf5
-- Enabling bzip2 for: libarchive, python3
-- Enabling png for: fontconfig, freetype, paraview, python3, qt5
-- Enabling ffi for: python3
-- Enabling sqlite for: python3
-- Enabling xz for: libarchive, python3
-- Enabling python3 for: cmb, pybind11, pythonsetuptools
-- Enabling hdf5 for: moab, netcdf, smtk
-- Enabling netcdf for: moab, paraview, smtk
-- Enabling moab for: cmb, smtk
-- Enabling nlohmannjson for: cmb, smtk, units
-- Enabling freetype for: fontconfig, paraview, qt5
-- Enabling libxml2 for: fontconfig, libarchive
-- Enabling gperf for: fontconfig
-- Enabling utillinux for: fontconfig
-- Enabling pkgconf for: fontconfig
-- Enabling fontconfig for: qt5
-- Enabling qt5 as requested.
-- Enabling paraview for: cmb, smtkresourcemanagerstate
-- Enabling pythonsetuptools for: pybind11
-- Enabling pybind11 for: cmb
-- Enabling libarchive for: smtk, smtkresourcemanagerstate
-- Enabling pegtl for: smtk, units
-- Enabling units for: smtk
-- Enabling fmt for: smtk
-- Enabling smtk as requested.
-- Enabling smtkresourcemanagerstate as requested.
-- Enabling cmb as requested.
-- Building projects: cxx11, boost, eigen, zlib, szip, bzip2, png, ffi, sqlite, xz, python3, hdf5, netcdf, moab, nlohmannjson, freetype, libxml2, gperf, utillinux, pkgconf, fontconfig, qt5, paraview, pythonsetuptools, pybind11, libarchive, pegtl, units, fmt, smtk, smtkresourcemanagerstate, cmb
CMake Warning (dev) at superbuild/cmake/SuperbuildMacros.cmake:224 (message):
  Optional dependencies for libarchive not found, is it in the list of
  projects?: openssl
Call Stack (most recent call first):
  projects/libarchive.cmake:8 (superbuild_add_project)
  superbuild/cmake/SuperbuildMacros.cmake:1066 (include)
  superbuild/CMakeLists.txt:185 (superbuild_process_dependencies)
This warning is for project developers.  Use -Wno-dev to suppress it.

– Configuring done
– Generating done
– Build files have been written to: /home/user/temp/build/cmb-superbuild

2. Send a file with your log so we can compare.

3. If your cmake call succeeds, DONT PROCEED TO BUILD. Because we still need to set up Qt.

4. As for Qt, you need to go back and specifically install Qt version 5.15 (on Linux I am pretty sure the installer has 5.15.2). Sometime this year we should update CMB to Qt 6 but we are not there yet.

5. I’m getting ahead of things, but after cmake is configuring and Qt 5.15 is installed, you want to rerun cmake with the following command to set the path to the installed Qt5. (Otherwise the superbuild will try to build Qt which can take a real long time and I’m not sure will succeed.)

> cmake -GNinja USE_SYSTEM_qt5=ON Qt5_DIR=<path-to-installed-Qt5-cmake-dir>

The “path-to-installed-Qt5-cmake-dir” starts with where you installed Qt on WSL. (The default is probably ~/Qt but you might be using something else.) From install directory, the relative path is to what cmake needs is .../5.15.2/gcc_64/lib/cmake/Qt5. Use the full/absolute path to that directory for .

Hi @johnt, here is my console log:

Console Log
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check size of void*
-- Check size of void* - done
-- found package: ace3p
-- found package: aeva
-- found package: cmb2d
-- found package: mb-docker
-- found package: modelbuilder
-- found package: truchas
-- found package: windtunnel
-- Default package: <none>
-- Found Git: /usr/bin/git (found version "2.34.1")
-- Determined source version for cmb: 23.01.100
-- Determined source version for smtk: 24.01.101
-- Determined source version for paraview: 5.11.0-599-g79a6058139
-- Determined source version for vtk: 9.0.0
-- Enabling cxx11 for: eigen, nlohmannjson, pegtl, pybind11, qt5, smtk, smtkresourcemanagerstate
-- Enabling boost for: cmb, paraview, smtk, smtkresourcemanagerstate
-- Enabling eigen for: moab, smtk
-- Enabling zlib for: freetype, hdf5, libarchive, netcdf, paraview, png, python3, qt5
-- Enabling szip for: hdf5
-- Enabling hdf5 for: moab, netcdf, smtk
-- Enabling netcdf for: moab, paraview, smtk
-- Enabling moab for: cmb, smtk
-- Enabling nlohmannjson for: cmb, smtk
-- Enabling bzip2 for: libarchive, python3
-- Enabling png for: fontconfig, freetype, paraview, python3, qt5
-- Enabling ffi for: python3
-- Enabling sqlite for: python3
-- Enabling python3 for: cmb, pybind11, pythonsetuptools
-- Enabling freetype for: fontconfig, paraview, qt5
-- Enabling libxml2 for: fontconfig, libarchive
-- Enabling gperf for: fontconfig
-- Enabling utillinux for: fontconfig
-- Enabling pkgconf for: fontconfig
-- Enabling fontconfig for: qt5
-- Enabling qt5 as requested.
-- Enabling paraview for: cmb, smtkresourcemanagerstate
-- Enabling pythonsetuptools for: pybind11
-- Enabling pybind11 for: cmb
-- Enabling libarchive for: smtk, smtkresourcemanagerstate
-- Enabling pegtl for: smtk
-- Enabling smtk as requested.
-- Enabling smtkresourcemanagerstate as requested.
-- Enabling cmb as requested.
-- Building projects: cxx11, boost, eigen, zlib, szip, hdf5, netcdf, moab, nlohmannjson, bzip2, png, ffi, sqlite, python3, freetype, libxml2, gperf, utillinux, pkgconf, fontconfig, qt5, paraview, pythonsetuptools, pybind11, libarchive, pegtl, smtk, smtkresourcemanagerstate, cmb
-- Configuring done
-- Generating done
-- Build files have been written to: /home/tomas/test-cmb/build

Also, I went back and installed the correct version of Qt 5.15.2.

Running these commands:

cd test-cmb/
cd build/
cmake -GNinja USE_SYSTEM_qt5=ON Qt5_DIR=../../Qt5.15/5.15.2/gcc_64/lib/cmake/Qt5

Qt5.15 is where I installed Qt 5.15.2
However, the last command does not seem to work (I might be getting the command wrong, please let me know).

Best regards,
Tomas

1. I should have advised that you also again delete the CMakeCache.txt file before rerunning cmake with the qt5 info. The CMakeCache.txt file tracks various data needed for building and you don’t want the previous Qt settings in there. I would delete it each time until we have a stable/predictable build.

2. If rerunning after deleting CMakeCache.txt still fails, I would also suggest passing in the absolute path to the Qt5 directory instead of the relative path.

3. If that’s still problematic, please grab the console log again and post that. I think we’re close to trying a build, but you never know :slight_smile:

Hi @johnt. I apologize for always having to contact you to solve this. I deleted the CMakeCache.txt, as you mentioned.

I tried to run both the commands:

cmake -GNinja USE_SYSTEM_qt5=ON Qt5_DIR=../../Qt5.15/5.15.2/gcc_64/lib/cmake/Qt5
cmake -GNinja USE_SYSTEM_qt5=ON Qt5_DIR=/home/tomas/Qt5.15/5.15.2/gcc_64/lib/cmake/Qt5

And they both fail (I get this error: CMake Error: The source directory “/home/tomas/test-cmb/build/Qt5_DIR=/home/tomas/Qt5.15/5.15.2/gcc_64/lib/cmake/Qt5” does not exist.)

I sincerely apologize once again,
Tomas

No problem, Tomas. You need to find where Qt is installed on your WSL partition. The most straightforward way to do this is brute force. Let’s try running this command in a WSL terminal:

    > find / -type d -name Qt5 -ls 2> /dev/null

Don’t be surprised if it takes a long time to finish (seconds to minutes) depending on the size of your disk.

If your Qt install is like mine, the command will return 2 paths, one with “Tools” in the path and the other with “5.15.2” in the path. Use the path that includes “5.15.2” in the cmake command. If you have different or more items returned, post the list if you are not sure which one to use.

Also, if the command doesn’t return anything, then open a WSL terminal with the “Run as administrator” option and retry the find command.

Tomas, looks like you forgot to include -D in front of your Qt5_DIR variable setting for CMake, and in front of all variables. So that first command should be

cmake -GNinja -DUSE_SYSTEM_qt5=ON -DQt5_DIR=../../Qt5.15/5.15.2/gcc_64/lib/cmake/Qt5

YES! Thanks for that correction, Aron. You need the “-D” before both arguments.