Skip to content
Open
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# CMake usual build directory
build/

# qmake builds at the root
.qmake.stash
Makefile
*.o
*.so
*.a
ui_*.h
moc_*.h
moc_*.cpp
BEMUse

# Default runtime output directory
Output/
4 changes: 3 additions & 1 deletion BEMUse.pro
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ DEFINES += SinglePrec

INCLUDEPATH += ..\eigen

INCLUDEPATH += src

#------------------------
# Source and header files
#------------------------
Expand All @@ -47,7 +49,7 @@ SOURCES += main.cpp\
src/Boundary/Ellipsoid.cpp \
src/Boundary/GDF_Geo.cpp \
src/Boundary/Half_Volume_of_Revolution.cpp \
src/Boundary/Hoizontal_Volume_of_Revolution.cpp \
src/Boundary/Horizontal_Volume_of_Revolution.cpp \
src/Boundary/MAR_Geo.cpp \
src/Boundary/PNL_Geo.cpp \
src/Boundary/STL_Geo.cpp \
Expand Down
76 changes: 33 additions & 43 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,44 @@ cmake_minimum_required(VERSION 3.10)

project(BEMUse VERSION 1.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17) # Set c++ standard
set(CMAKE_CXX_STANDARD_REQUIRED ON) # Enforce
set(CMAKE_CXX_FLAGS "-std=gnu++11 -O3 -march=native -fopenmp") # Set compiler optimisation flags
option(BUILD_GUI "Build GUI version" OFF) # Option to build GUI version# Optional GUI
option(BUILD_SHARED_LIBS "Build shared library" ON)

find_package(OpenMP REQUIRED)
IF(NOT DEFINED CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release)
ENDIF()

set(CMAKE_CXX_STANDARD 17) # Set c++ standard
set(CMAKE_CXX_STANDARD_REQUIRED ON) # Enforce
set(CMAKE_CXX_FLAGS "-march=native") # Set compiler optimisation flags

#--- Preprocessor Directives
add_compile_definitions(SinglePrec) # Single precision compile
#add_compile_definitions(DoublePrec) # Double precision compile

#--- Specify eigen directory
#--- Specify your correct Pfad here!
set(EIGEN_DIR C:\\Development\\eigen\\)
#--- RPATH tweaks for relocatable installation
include(GNUInstallDirs)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # Also add external library paths to RPATH
set(CMAKE_SKIP_BUILD_RPATH FALSE) # Do not skip build RPATH
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) # Use install RPATH during build
# Set RPATH to point to the lib directory relative to the executable
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
list(APPEND CMAKE_INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") # Not tested
list(APPEND CMAKE_INSTALL_RPATH "@loader_path/../${CMAKE_INSTALL_LIBDIR}")
endif()
# On Windows, shared libraries are typically in the same directory as the executable

#--- Add library directory
add_subdirectory(src) # Add the main BEMUse library source directory

# Specify target executable
add_executable(BEMUse main.cpp)

target_link_libraries(BEMUse PRIVATE OpenMP::OpenMP_CXX)

target_sources(BEMUse
PRIVATE
# Headers
"${PROJECT_SOURCE_DIR}/src/Boundary/FOWT_Platforms.h"
"${PROJECT_SOURCE_DIR}/src/Geometry/Node.h"

# Sources
"${PROJECT_SOURCE_DIR}/src/BEMUser_Console.cpp"
"${PROJECT_SOURCE_DIR}/src/Boundary/Barge.cpp"
"${PROJECT_SOURCE_DIR}/src/Boundary/Boundary_Base.cpp"
"${PROJECT_SOURCE_DIR}/src/Boundary/Ellipsoid.cpp"
"${PROJECT_SOURCE_DIR}/src/Boundary/GDF_Geo.cpp"
"${PROJECT_SOURCE_DIR}/src/Boundary/Half_Volume_of_Revolution.cpp"
"${PROJECT_SOURCE_DIR}/src/Boundary/Hoizontal_Volume_of_Revolution.cpp"
"${PROJECT_SOURCE_DIR}/src/Boundary/MAR_Geo.cpp"
"${PROJECT_SOURCE_DIR}/src/Boundary/STL_Geo.cpp"
"${PROJECT_SOURCE_DIR}/src/Boundary/Ship_Hulls.cpp"
"${PROJECT_SOURCE_DIR}/src/Boundary/Thin_Disc.cpp"
"${PROJECT_SOURCE_DIR}/src/Boundary/Triple_Spar.cpp"
"${PROJECT_SOURCE_DIR}/src/Boundary/Volume_of_Revolution.cpp"
"${PROJECT_SOURCE_DIR}/src/Boundary/Wing.cpp"
"${PROJECT_SOURCE_DIR}/src/Geometry/Geo_Elements.cpp"
"${PROJECT_SOURCE_DIR}/src/Geometry/Panel.cpp"
"${PROJECT_SOURCE_DIR}/src/Kernels.cpp"
"${PROJECT_SOURCE_DIR}/src/Solver/Aerodynamic_Solver.cpp"
"${PROJECT_SOURCE_DIR}/src/Solver/Hydrodynamic_Solver.cpp"
"${PROJECT_SOURCE_DIR}/src/Solver/Hydrodynamic_Solver_IO.cpp"
"${PROJECT_SOURCE_DIR}/src/Solver/Solver_Base.cpp"
"${PROJECT_SOURCE_DIR}/src/Kernels.cpp"
)

target_include_directories(BEMUse PRIVATE ${EIGEN_DIR})
add_executable(BEMUse src/BEMUser_Console.cpp main.cpp)

target_link_libraries(BEMUse PRIVATE BEMUse_lib)

install(TARGETS BEMUse)

if(BUILD_GUI)
add_subdirectory(src_gui) # Add GUI subdirectory if BUILD_GUI is ON
endif()
108 changes: 73 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ BEMUse is written in C++ and can be compiled in two configurations depending on
* **Command-line configuration:** For code development or for the inclusion of BEMUse into a design loop, a command-line interface is available;
* **GUI configuration:** For visual inspection of meshes and visualisation of analysis results, a minimal graphical user interface (GUI) is available.

The core architecture of BEMUse is identical in both cases.
The core architecture of BEMUse is identical in both cases.

## Why should you use BEMUse?
* You want a solver to carry out frequency-domain potential flow hydrodynamic calculations (1st order- radiation & diffraction);
* You want an open-source alternative to proprietary hydrodynamic solvers;
* Execution is fast: BEMUse leverages OpenMP in order to use multi-threading to speed up calculations;
* BEMUse can import, `WAMIT`®, `NEMOH` and `.stl` geometry formats;
* BEMUse can export meshes to `WAMIT`® and `NEMOH` geometry formats;
* BEMUse can import, `WAMIT`®, `NEMOH` and `.stl` geometry formats;
* BEMUse can export meshes to `WAMIT`® and `NEMOH` geometry formats;
* You want a simple GUI to visualise and perform sanity checks on your mesh;
* You want a simple GUI to inspect the radiation/excitation potential solution on the boundary of your mesh;
* You want a simple GUI to visualise free surface displacement due to radiation or diffraction potentials;
Expand All @@ -28,26 +28,26 @@ The core architecture of BEMUse is identical in both cases.
<img src="/img/OC4.PNG" width=75% height=75%>

## Licensing and authorship
BEMUse is developed by Joseph Saverin and is distributed under the GNU General Public License Version 2.0, copyright © Joseph Saverin 2022.
BEMUse is developed by Joseph Saverin and is distributed under the GNU General Public License Version 3.0, copyright © Joseph Saverin 2022.

## How to use the BEMUse command-line configuration
In order to carry out an analysis with BEMUse, you need to specify the geometry which you wish to analyse and the simulation parameters.
The geometry is specified over the command line. There are two options for specifying a geometry.
In order to carry out an analysis with BEMUse, you need to specify the geometry which you wish to analyse and the simulation parameters.
The geometry is specified over the command line. There are two options for specifying a geometry.

### Importing a Geometry
You can import an external geometry simply by specifying a `WAMIT`® (`.gdf`), `NEMOH` (`.mar`), `pyHAMS` (`.pnl`) or (`.stl`) geometry file.
You can import an external geometry simply by specifying a `WAMIT`® (`.gdf`), `NEMOH` (`.mar`), `pyHAMS` (`.pnl`) or (`.stl`) geometry file.
The specified path should be relative to the directory in which the executable is found. An example might be:
```
BEMUse <ExternalGeos/MyGeo.mar> <OutputPrefix>
```
BEMUse will automatically recognise the geometry type based on the file suffix. As the surface elements are externally defined,
BEMUse will automatically recognise the geometry type based on the file suffix. As the surface elements are externally defined,
you do not need to specify the input files `Discretisation.bemin` or `Dimensions.bemin` (these are described below).

### Using a Template Geometry
A range of template geometries are available which are already parametrised in BEMuse,
A range of template geometries are available which are already parametrised in BEMuse,
so that you only need to specify the discretisation or dimensions.
These geometries include analytical geometries as well as standard geometries for floating offshore wind turbine platforms.
This list is regularly being extended and if you would like to have your geometry on this list, please get in touch.
These geometries include analytical geometries as well as standard geometries for floating offshore wind turbine platforms.
This list is regularly being extended and if you would like to have your geometry on this list, please get in touch.
In order to see a list of the available geometries, type the following into the command line:
```
BEMUse Templates
Expand All @@ -56,17 +56,17 @@ In order to check what the necessary inputs (described below) are for your chose
```
BEMUse Inputs <GeoType>
```
You are required to specify a directory named `Outputs` within the directory of the executable where the output files will be written.
You are required to specify a directory named `Outputs` within the directory of the executable where the output files will be written.
In order to discern between multiple runs, you are also required to specify the output file prefix.
Provided you have provided the input parameters (described below), a complete call to execute BEMUse and write the outputs will look like this:
```
BEMUse <GeoType> <OutputPrefix>
BEMUse <GeoType> <OutputPrefix>
```
That simple! If there are insufficient inputs defined for the chosen geometry, the behaviour will be undefined.

### Specifying input files
A range of simulation parameters also need to be defined for a BEMUse simulation. These are defined in text-based input files.
You are required to specify a directory named `Inputs` within the directory of the executable from where the input files will be read.
A range of simulation parameters also need to be defined for a BEMUse simulation. These are defined in text-based input files.
You are required to specify a directory named `Inputs` within the directory of the executable from where the input files will be read.
These files are defined below along with the corresponding variables:
* `Frequencies.bemin`: Specify here the desired frequencies of analysis
* One frequency per line, ideally in increasing order
Expand All @@ -85,15 +85,15 @@ These files are defined below along with the corresponding variables:
* Hydrostatic Stiffness Matrix Option: 1) Calculates the hydrostatic stiffness matrix (H_ii) assuming a uniform density equal to water density. 2) Imported;
* Imported Hydrostatic Stiffness Matrix: If option 2) above has been selected, the elements of H_ii.
* `SolverParams.bemin`- Specify solver flags
* Irregular Frequency Removal- If this is specified as true, you need to specify the [IFS] values in the `Discretisation.bemin` file
* Irregular Frequency Removal- If this is specified as true, you need to specify the [IFS] values in the `Discretisation.bemin` file
* Kochin Angles [-]
* Density of the fluid [kg/m^3]
* Acceleration due to gravity [m/s^2]

## How to use the BEMUse GUI configuration
In this case you really don't need to do very much at all, just follow the steps in the GUI.
In this case you really don't need to do very much at all, just follow the steps in the GUI.
Once you have specified a geometry, you can toggle any of the visualisation options at the top right of the window.
BEMUse solves a radiation potential for each of the six degrees of freedom (surge, sway, heave, roll, pitch, yaw) at each frequency.
BEMUse solves a radiation potential for each of the six degrees of freedom (surge, sway, heave, roll, pitch, yaw) at each frequency.
BEMUse solves a diffraction potential for each of the six degree of freedom for each incoming wave angle selected in the specification of the analysis.
The radiation potential and diffraction potential can only be visualised once an analysis has completed.
The free surface visualisation is only possible if you have specified an exterior free surface grid in the creation of the geometry.
Expand All @@ -105,42 +105,80 @@ A number of options exist for modifying the visualisation:
* To snap to an isometric viewing angle double click the left mouse button;
* To toggle the degree of freedom which is visualised, hold the `Shift` button and use the scroll on your mouse;
* To toggle the frequency which is being visualised, hold the `Ctrl` button and use the scroll on your mouse;
* To toggle the incoming wave angle which is being visualised, hold the `Alt` button and use the scroll on your mouse.
* To toggle the incoming wave angle which is being visualised, hold the `Alt` button and use the scroll on your mouse.

<img src="/img/Wigley.PNG" width=75% height=75%>

## Citation information
I am currently in the process of preparing a simple reference paper for BEMUse on ArXiv.
## Citation information
I am currently in the process of preparing a simple reference paper for BEMUse on ArXiv.
In the meantime, if you use BEMUse please cite it in your publication as follows:
- Saverin, J., Grueter, L. **Quadrature Schemes for the Integration of the Free-Surface Greens Function within the Open-Source Boundary Element Method Library BEMUse**,
- Saverin, J., Grueter, L. **Quadrature Schemes for the Integration of the Free-Surface Greens Function within the Open-Source Boundary Element Method Library BEMUse**,
Proceedings of the ASME 2022 41st International Conference on Ocean, Offshore and Arctic Engineering. June 2022, Hamburg, Germany.

## Compilation
The only dependency of BEMUse is the [eigen](https://eigen.tuxfamily.org) lineary algebra library.
The compilation of BEMUse has been tested with GCC (v7.3).
The compilation of BEMUse has been tested with GCC (v7.3 and v12.2.0).

Two options are available for compiling:
- qmake: BEMUse was prepared with the cross-platform development environment [Qt Creator](https://www.qt.io/product/development-tools).
The .pro file required for compiling with qmake has been provided.
- [CMake](https://cmake.org/), a cross-platform build system generator
- [QMake](https://doc.qt.io/qt-6/qmake-manual.html), Qt's build system

### Dependencies

The only dependency of the BEMUse library and Command-Line Interface (CLI) is the [Eigen](https://eigen.tuxfamily.org) lineary algebra library (version 3).

The Graphical User Interface (GUI) also requires [Qt6](https://www.qt.io/product/qt6) and [OpenGL](https://www.opengl.org/).

### CMake

**Step 1: configure**

```bash
cmake -S. -Bbuild
```

Alternativaly, to also compile the GUI (not compiled by default):

```bash
cmake -S. -Bbuild -DBUILD_GUI=ON
```

**Step 2: build**

```bash
cmake --build build -j
```

**Step 3: install**

```bash
cmake --install build
```

**Note:** Use `sudo` to install BEMUse in a standard system location on Linux.

If you don't have administrative rights, you can install BEMUse at the location of your choice:

```bash
cmake --install build --prefix <install-directory>
```

### QMake

BEMUse was prepared with the cross-platform development environment [Qt Creator](https://www.qt.io/product/development-tools).
The .pro file required for compiling with qmake has been provided.
You simply need to include the path to the eigen directory on your device.
For example:
```
INCLUDEPATH += -L$$PWD/../eigen/
```
As the GUI config relies on the Qt widget libraries, this configuration is probably best compiled with [Qt Creator].
As the GUI config relies on the Qt widget libraries, this configuration is probably best compiled with [Qt Creator].
In order to avoid compiling the GUI config the entire section in the `.pro` file below the line `# GUI configuration` should be commented out.

- CMake: The `CMakeLists.txt` file has been provided.
You simply need to point the `EIGEN_DIR` variable to the eigen directory on your device.
For example:
```
set(EIGEN_DIR C:\\MyCodeisHere\\eigen\\)
```
Nb. The CMakeLists file is currently only configured to compile the command-line version of BEMUse.
**Note:** You might also need to modify `LIBS += -lOpengl32` (e.g. to `LIBS += -lOpenGL`) depending of the name of the OpenGL library on your system.

## Pre-compiled libraries
Pre-built binaries are available on the [releases](https://github.com/ZeppSav/BEMUse/releases) page.

## Documentation

A [readthedocs] page is currently being prepared.
A [readthedocs] page is currently being prepared.
56 changes: 56 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Dependencies
find_package(Eigen3 REQUIRED)
find_package(OpenMP REQUIRED)

add_library(BEMUse_lib) # Create a static library for BEMUse
set_target_properties(BEMUse_lib PROPERTIES OUTPUT_NAME BEMUse)

# Sources
target_sources(BEMUse_lib PRIVATE
Boundary/Barge.cpp
Boundary/Boundary_Base.cpp
Boundary/Ellipsoid.cpp
Boundary/GDF_Geo.cpp
Boundary/Half_Volume_of_Revolution.cpp
Boundary/Horizontal_Volume_of_Revolution.cpp
Boundary/MAR_Geo.cpp
Boundary/PNL_Geo.cpp
Boundary/STL_Geo.cpp
Boundary/Ship_Hulls.cpp
Boundary/Thin_Disc.cpp
Boundary/Triple_Spar.cpp
Boundary/Volume_of_Revolution.cpp
Boundary/Wing.cpp
Geometry/Geo_Elements.cpp
Geometry/Panel.cpp
Kernels.cpp
Solver/Aerodynamic_Solver.cpp
Solver/Hydrodynamic_Solver.cpp
Solver/Hydrodynamic_Solver_IO.cpp
Solver/Solver_Base.cpp
)

# Headers
target_sources(BEMUse_lib PUBLIC
FILE_SET HEADERS
FILES
Boundary/FOWT_Platforms.h
Geometry/Node.h
Boundary/Ellipsoid.h
Boundary/Volume_of_Revolution.h
Boundary/Horizontal_Volume_of_Revolution.h
Boundary/Triple_Spar.h
Boundary/Ship_Hulls.h
Boundary/STL_Geo.h
Boundary/GDF_Geo.h
Boundary/MAR_Geo.h
Boundary/PNL_Geo.h
Boundary/Barge.h
Boundary/Thin_Disc.h
Boundary/Wing.h
)

target_link_libraries(BEMUse_lib PUBLIC Eigen3::Eigen OpenMP::OpenMP_CXX)

include(GNUInstallDirs)
install(TARGETS BEMUse_lib FILE_SET HEADERS DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/BEMUse)
6 changes: 3 additions & 3 deletions src_gui/BEMUser_Interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
//--- BEMUse Source---
//--------------------

#include "src/Boundary/Boundary_Base.h"
#include "src/Solver/Solver_Base.h"
#include "src_gui/Visualise.h"
#include "Boundary/Boundary_Base.h"
#include "Solver/Solver_Base.h"
#include "Visualise.h"

#define GLPANELS 1

Expand Down
Loading