CSG-EB
This library is for parsing Constructive Solid Geometry (CSG) for use in AMReX Embedded Boundaries (EB).
CSG is a file format used by the open source CAD modelling tool
OpenSCAD. CSG is a subset of the SCAD language,
equivalent in the kinds of geometries that can be expressed, but with fewer
primitives (OpenSCAD can export .scad
files to .csg
). SCAD code is easier to
read and write by humans; CSG files are easier to parse and process by software.
Dependencies:
How to Build
Build dependencies
- C++17 compiler (GCC >=7.x, Clang >=5.x)
- CMake >=3.14
- Conan (CMake will try to install Conan if
conan
is not inPATH
)
CMake will try to install Conan if conan
is not in PATH
.
However, installing Conan (pip install conan
) is recommended for faster builds.
Build
> cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
> cmake --build build
Run tests
> cd build
> ctest
Using CSG-EB in your project
- Include the header file
csg.hpp
- Call
csg::get_csgif
with the path to a CSG file to create an Implicit Function object.
#include <csg.hpp>
// for EB2::makeShop
#include <AMReX_EB2_GeometryShop.H>
...
auto csg_file = "~/my_geometry.csg";
auto is_internal_flow = true;
auto csg_if = csg::get_csgif(csg_file, is_internal_flow);
auto gshop = EB2::makeShop(*csg_if);
Note on the return value
If is_internal_flow==true
, the CSG geometry defines a hollow space for the domain:
- csg_if(x, y, z) < 0 ⇒ (x, y, z) is INSIDE
- csg_if(x, y, z) > 0 ⇒ (x, y, z) is OUTSIDE
If is_internal_flow==false
, the CSG geometry defines a solid boundary to the domain:
- csg_if(x, y, z) < 0 ⇒ (x, y, z) is OUTSIDE
- csg_if(x, y, z) > 0 ⇒ (x, y, z) is INSIDE
Add to the CMake build
- Add this repo as a CMake subdirectory in your
CMakeLists.txt
:
add_subdirectory(/path/to/repo/csg-eb)
- Add the
csg
target to the CMake target that uses code like in the the above example:
target_link_libraries(<target> PRIVATE csg)