Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions cmake/configure/configure_Qhull.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,23 @@
#
# SPDX-License-Identifier: LGPL-3.0-or-later

find_package(Qhull REQUIRED)
message(STATUS "Fetch content for Qhull")

if(QHULL_FOUND)
message(STATUS "QHULL include directory: ${QHULL_INCLUDE_DIR}")
message(STATUS "QHULL library directory: ${QHULL_LIBRARY}")
set(QHULL_ENABLE_TESTING "OFF")
set(BUILD_APPLICATIONS "OFF")
set(BUILD_STATIC_LIBS "OFF")
set(LINK_APPS_SHARED "OFF")
set(BUILD_SHARED_LIBS "ON")
Comment thread
maxfirmbach marked this conversation as resolved.

target_link_libraries(four_c_all_enabled_external_dependencies INTERFACE qhull::qhull)
fetchcontent_declare(
libqhull
GIT_REPOSITORY https://github.com/qhull/qhull.git
GIT_TAG d1c2fc0caa5f644f3a0f220290d4a868c68ed4f6
Comment thread
maxfirmbach marked this conversation as resolved.
Outdated
)

four_c_remember_variable_for_install(QHULL_INCLUDE_DIR QHULL_LIBRARY)
endif()
fetchcontent_makeavailable(libqhull)
set(FOUR_C_QHULL_ROOT "${CMAKE_INSTALL_PREFIX}")

four_c_add_external_dependency(four_c_all_enabled_external_dependencies qhull_r)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
four_c_add_external_dependency(four_c_all_enabled_external_dependencies qhull_r)
four_c_add_external_dependency(four_c_all_enabled_external_dependencies QHull::qhull_r)

Does this work? I am looking at https://github.com/qhull/qhull/blob/master/CMakeLists.txt#L744, which gives an export namespace but unfortunately they do not alias the qhull_r target as QHull::qhull_r. Maybe we need to do this ourselves here.

Also, QHull is still installed in the image, right? I think the wrong one is picked up during the install test: https://github.com/4C-multiphysics/4C/actions/runs/20850200696/job/59903586127?pr=1649#step:9:46
which would give you a pretty random result. I would drop the QHull from the image. Afterwards, you probably need to fix the install process here.


four_c_remember_variable_for_install(FOUR_C_QHULL_ROOT)
26 changes: 0 additions & 26 deletions cmake/modules/FindQhull.cmake

This file was deleted.

49 changes: 28 additions & 21 deletions src/cut/4C_cut_tetmesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

extern "C"
{
#include <libqhull/qhull_a.h>
#include <libqhull_r/qhull_ra.h>
}

FOUR_C_NAMESPACE_OPEN
Expand Down Expand Up @@ -392,6 +392,28 @@ void Cut::TetMesh::call_q_hull(
}
}

// If you want some debugging information replace the 0 pointer
// with stdout or some other file open for writing.

#ifdef QHULL_EXTENDED_DEBUG_OUTPUT
FILE* outfile = stdout;
#else
FILE* outfile = nullptr;
#endif

#ifdef QHULL_DEBUG_OUTPUT
FILE* errfile = stderr;
#else
static NullFile errfile;
#endif

qhT qh_qh; /* Qhull's data structure. First argument of most calls */
qhT* qh = &qh_qh;

QHULL_LIB_CHECK

qh_zero(qh, errfile);

boolT ismalloc = false;

// a set of option we try to process the input with
Expand All @@ -410,21 +432,6 @@ void Cut::TetMesh::call_q_hull(
options.push_back("qhull d Qt Qbb Qc Qz Pp");
options.push_back("qhull d Qt Qbb Qc QJ Pp");

// If you want some debugging information replace the 0 pointer
// with stdout or some other file open for writing.

#ifdef QHULL_EXTENDED_DEBUG_OUTPUT
FILE* outfile = stdout;
#else
FILE* outfile = nullptr;
#endif

#ifdef QHULL_DEBUG_OUTPUT
FILE* errfile = stderr;
#else
static NullFile errfile;
#endif

#ifdef QHULL_EXTENDED_DEBUG_OUTPUT
int counter_qhull = 0;
#endif
Expand All @@ -434,11 +441,11 @@ void Cut::TetMesh::call_q_hull(
std::cout << "counter_qhull: " << counter_qhull << std::endl;
#endif
std::string& ostr = *i;
if (not qh_new_qhull(dim, n, coordinates.data(), ismalloc, const_cast<char*>(ostr.c_str()),
if (not qh_new_qhull(qh, dim, n, coordinates.data(), ismalloc, const_cast<char*>(ostr.c_str()),
outfile, errfile))
{
// triangulate non-simplicial facets
qh_triangulate();
qh_triangulate(qh);

facetT* facet;
int nf = 0;
Expand Down Expand Up @@ -471,7 +478,7 @@ void Cut::TetMesh::call_q_hull(
for (void** vertexp = &facet->vertices->e[0].p;
(vertex = static_cast<vertexT*>(*vertexp++));)
{
int p = qh_pointid(vertex->point);
int p = qh_pointid(qh, vertex->point);
if (p >= n)
{
FOUR_C_THROW("new node in delaunay");
Expand All @@ -486,11 +493,11 @@ void Cut::TetMesh::call_q_hull(
}

// free long memory
qh_freeqhull(not qh_ALL);
qh_freeqhull(qh, not qh_ALL);

// free short memory and memory allocator
int curlong, totlong;
qh_memfreeshort(&curlong, &totlong);
qh_memfreeshort(qh, &curlong, &totlong);

if (curlong or totlong)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ RESULT DESCRIPTION:
NODE: 3461
QUANTITY: "vely"
VALUE: 0.00668161125310244
TOLERANCE: 1e-13
TOLERANCE: 1e-12
- XFLUID:
DIS: "fluid"
NODE: 3461
Expand Down
Loading