G+Smo
24.08.0
Geometry + Simulation Modules
|
In this tutorial we collect some tips and guidelines for writing code in G+Smo.
Information regarding code formatting are found in the wiki.
Upon configuration, G+Smo presents a set of basic configuration options, which are ON (enabled):
Configuration: CMAKE_BUILD_TYPE RelWithDebInfo GISMO_COEFF_TYPE double GISMO_BUILD_LIB ON GISMO_BUILD_EXAMPLES ON CMAKE_INSTALL_PREFIX /usr/local
The full list of options can be accessed using the cmake-gui utility, or using the command-line version:
ccmake .
inside the build folder.
CMAKE_BUILD_TYPE
Available values are the standard CMake build configurations: Debug, Release, RelWithDebInfo?, MinSizeRel?.
GISMO_COEFF_TYPE
The arithmetic type to be used for all computations. Available options include double, long double, float. This is the type is alias as real_t.
GISMO_WITH_XDEBUG
If set to ON additional debugging tools are enabled during compilation. These include checked iterators for GCC and MSVC compilers and call stack back-trace printout when a runtime exception occurs.
GISMO_BUILD_LIB
If enabled a dynamic library is created using GISMO_COEFF_TYPE arithmetic. A target for a static library named gismo_static is also created but not compiled by default.
GISMO_BUILD_EXAMPLES
If enabled the programs in the examples folder are compiled, and executables are created in build-folder/bin.
GISMO_PLUGIN_AXL
If enabled the plugin for Axel modeler is compiled (requires Axel).
GISMO_WITH_PSOLID
If enabled the extensions using functionalities of Parasolid geometric kernel are compiled.(requires Parasolid).
gsOpennurbs
Extension for reading and writing of Rhinoceros' 3DM.
CMAKE_INSTALL_PREFIX
The location for installation of the library, e.g. /usr/local on some Linux systems.
There are 2 main tools for debugging C++ code:
If the CMake option GISMO_WITH_XDEBUG is set to ON, more checks are performed while running the code. In particular the Standard library containers are checked for invalid access, invalid iterators, and so on. Also upon failure of the program the call stack is printed on the screen.
CMake provides with a tool to execute programs and report the result status. Result status zero (main() function returns 0) means program succeded, return 1 means program failed. To run this check inside the build folder do:
ctest -j3
Problems or bugs might also be related to the platform or operating system. Nightly compilations and tests on several systems detects such problems. The CDash server:
https://cdash-ci.irisa.fr/index.php?project=Gismo
collects the result of compilation and testing from compilation nodes. To Submit your compilation and test log to the CDash server you can type:
make -j2 Experimental
inside the build folder. After building and executing all programs, a log file will be posted on the CDash server, under the section Experimental.
Gismo should be able to compile with C++98 and on different machines with different datatypes and maybe architectures. To ensure this, and still be able to use some of the benefits of newer compilers like C++11, there are some helping functions inside gsUtils and gsMemory that should be used instead of native C++11 calls. It is helpful to keep in mind that real_t and size_t are definitions that will be exchanged by cmake and should be used instead of double and int.
Cxx(11) | Gismo |
---|---|
std::move(...) | give(...) |
double | real_t |
int | index_t |
std::unique_ptr | memory::unique_ptr or gs...::uPtr |
std::shared_ptr | memory::shared_ptr or gs...::Ptr |
std::to_string | util::to_string |
Also keep in mind that C++98 std::ios doesn't like "strings". Therefore, just call .c_str() if you give a string to an fstream (like ofstream::open).
And please don't use auto and the fancy new foreach loop.
/** @file fitting_example.cpp @brief Demonstrates adaptive fitting of data samples This file is part of the G+Smo library. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. Author(s): G. Kiss, A. Mantzaflaris */