Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for EGADS geometry system #330

Open
wants to merge 91 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 86 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
0232dae
Created barebones framework for EGADS model support. Need to look at …
tuckerbabcock Nov 13, 2019
9ffeda7
Added implementation of gmi_egads_load. Reqiuired adding methods to E…
tuckerbabcock Nov 13, 2019
4678b2d
re-implemented gmi_egads_load to use existing EGADS functions
tuckerbabcock Nov 14, 2019
dd0c9bd
more implementation of gmi functions.
tuckerbabcock Nov 14, 2019
a71b5c3
all methods have preliminary implementation. Now trying to link and c…
tuckerbabcock Nov 17, 2019
4698365
moved gmi_egads files to new gmi_egads directory
tuckerbabcock Nov 17, 2019
494b48c
Added cmake files for finding and compiling with EGADS. Currently the…
tuckerbabcock Nov 17, 2019
56de2bd
fix some typos causing compile erros
tuckerbabcock Nov 19, 2019
4d11165
gmi-egads builds without any erros now
tuckerbabcock Nov 19, 2019
749572f
gmi_egads compiles and links, though mesh verify fails.
tuckerbabcock Nov 20, 2019
542eb7f
testing fails with 3D and 2D meshes.For 2D at least it seems the AFLR…
tuckerbabcock Nov 23, 2019
13c02dc
added 2D ugrid support
tuckerbabcock Dec 13, 2019
25ffd58
Merge branch 'ugrid2D-dev' into egads-dev
tuckerbabcock Dec 13, 2019
79a1869
read dummy face ID
tuckerbabcock Dec 13, 2019
432bea2
Merge branch 'ugrid2D-dev' into egads-dev
tuckerbabcock Dec 13, 2019
f7f35a2
fix read amount for dummy face ID
tuckerbabcock Dec 13, 2019
e56f39d
Merge branch 'ugrid2D-dev' into egads-dev
tuckerbabcock Dec 13, 2019
83bab38
changed to egads reader based on how memory was being managed. Needs …
tuckerbabcock Dec 16, 2019
c7f8a65
2D ugrid reader now reads a 2D ugrid mesh and can verify and write to…
tuckerbabcock Dec 16, 2019
c6cdfc6
Merge branch 'ugrid2D-dev' into egads-dev
tuckerbabcock Dec 16, 2019
4619442
added algorithm include
tuckerbabcock Dec 16, 2019
e77a4ef
Merge branch 'ugrid1D-dev' into egads-dev
tuckerbabcock Dec 16, 2019
dbe89db
changed gmi_normal to use correct get topology
tuckerbabcock Dec 16, 2019
f474a5b
added print statements for debug
tuckerbabcock Dec 16, 2019
6e64cda
added function for vertex reparameterization on an edge
tuckerbabcock Dec 16, 2019
dc51601
added parameterization of vertices onto edges and faces in ugrid read…
tuckerbabcock Dec 18, 2019
761f5e5
Merge branch 'ugrid2D-dev' into egads-dev
tuckerbabcock Dec 18, 2019
67b60e9
rewrote apf function loadMdsFromUgrid to read the header and figure o…
tuckerbabcock Jan 24, 2020
dc71643
Merge branch 'ugrid2D-dev' into egads-dev
tuckerbabcock Jan 24, 2020
8964abe
cleaning up code prior to pull request
tuckerbabcock Jan 24, 2020
640d67b
removed static from gmi_egads_load
tuckerbabcock Jan 24, 2020
faf8e46
Merge branch 'ugrid2D-dev' into egads-dev
tuckerbabcock Jan 24, 2020
24dab6d
curved 2D meshing works with EGADS with ugrid reading
tuckerbabcock Jan 25, 2020
2576981
removing old code
tuckerbabcock Jan 25, 2020
7437a90
removed print statements
tuckerbabcock Jan 25, 2020
2f07637
Merge branch 'ugrid2D-dev' into egads-dev
tuckerbabcock Jan 25, 2020
dd95ea8
added egads_ent struct that wraps ego, and attempts to support 3D mod…
tuckerbabcock Jan 26, 2020
c733e03
quick change to struct typedef so it will compile on scorec
tuckerbabcock Jan 26, 2020
eae7fd6
changing pointers and mallocs
tuckerbabcock Jan 27, 2020
572326e
Merge branch 'egads-dev' of github.com:tuckerbabcock/core into egads-dev
tuckerbabcock Jan 27, 2020
5e2ef43
more pointer/reference changes
tuckerbabcock Jan 27, 2020
383e168
changes from last night on scorec
tuckerbabcock Jan 27, 2020
843e549
merged changes
tuckerbabcock Jan 27, 2020
23de3fc
seem to have fixed strange malloc issue. Wasn't allocating room for t…
tuckerbabcock Jan 27, 2020
54d6a06
Added new method to initialize used in pumiAIM
tuckerbabcock Feb 5, 2020
114273a
changed FindEGADS file to make it work better.
tuckerbabcock Feb 5, 2020
a55157a
Merge branch 'egads-dev' of github.com:tuckerbabcock/core into egads-dev
tuckerbabcock Feb 5, 2020
420a015
re-wrote gmi_egads to use new global array of ents to handle allocati…
tuckerbabcock Feb 27, 2020
7bbb112
implemented getVertexUV
tuckerbabcock Feb 27, 2020
7571748
pumi verifies tetgen mesh with multiple regions
tuckerbabcock Feb 29, 2020
a4e7219
can read adjacency binary file from PUMI AIM
tuckerbabcock Mar 1, 2020
edef983
freeing adjacency table
tuckerbabcock Mar 1, 2020
b63e7e5
commenting out prints
tuckerbabcock Mar 18, 2020
cb96614
fix errors
tuckerbabcock Mar 18, 2020
e317b7e
temporarily making isParamPointInsideModel always return true to allo…
tuckerbabcock Mar 26, 2020
4664d05
cleaning up memory use more
tuckerbabcock Apr 24, 2020
f5b9220
merge upstream develop into egads-dev
tuckerbabcock Aug 10, 2020
38f65e1
merge updates
tuckerbabcock Aug 10, 2020
7c43f81
made everything not part of the interface static, moved non-public pa…
tuckerbabcock Sep 22, 2020
38b539f
fix compiler warnings related to fread on gcc 10
tuckerbabcock Oct 20, 2020
cf181ef
removing unneeded forward declaration of struct
tuckerbabcock Nov 5, 2020
c51a0fa
adding egads related things to the split executable, making egads_glo…
tuckerbabcock Nov 20, 2020
e14c8fe
Merge branch 'develop' into egads-dev
tuckerbabcock Feb 12, 2021
bdaf4ca
Merge branch 'egads-dev' of github.com:tuckerbabcock/core into egads-dev
tuckerbabcock Feb 12, 2021
7d5d26e
reverting example_config
tuckerbabcock Feb 12, 2021
f3c0892
address clang warning about firstFace being used uninitialized
tuckerbabcock Feb 12, 2021
1832ccc
attempting to add EGADS split tests
tuckerbabcock Feb 13, 2021
46f75a8
introduced new egads_model struct to store model specific things and …
tuckerbabcock Feb 15, 2021
9a47057
cleaning up old print statements
tuckerbabcock Feb 15, 2021
a7e41e3
document sup filename and free it
tuckerbabcock Feb 15, 2021
ad8ab1f
use private linkage and header file includes for EGADS headers and li…
tuckerbabcock Feb 16, 2021
bf4420b
revert changes from isParamPointInsideModel
tuckerbabcock Feb 16, 2021
31a02f5
remove iostream include from apfMesh.cc
tuckerbabcock Feb 16, 2021
2e505f6
using cmake's configure_file to define the locations of the egads and…
tuckerbabcock Mar 25, 2021
6bfd4c6
added function pointers and routines for opening/closing dylib
tuckerbabcock Mar 25, 2021
a4a41ef
function pointers loaded and switched to using them
tuckerbabcock Mar 25, 2021
2e1012d
switched to lazy symbol loading
tuckerbabcock Mar 25, 2021
0f8ea73
added error checking to make sure EGADS is loaded correctly
tuckerbabcock Mar 25, 2021
3ae5571
got rid of EG_isEquivalent since it does not work with EGADSlite
tuckerbabcock Mar 25, 2021
3fa7bc7
added egads stuff to verify executable
tuckerbabcock Mar 25, 2021
64e1dec
remove goto from getVertexUV
tuckerbabcock Mar 26, 2021
9aff5b6
make fail str buffers larger to address compile error on gcc 8.1.0
tuckerbabcock Mar 27, 2021
b6f2b42
switching to only using EGADSlite
tuckerbabcock Mar 29, 2021
4f58438
added back the option to build gmi_egads with EGADS or EGADSlite, opt…
tuckerbabcock Apr 2, 2021
f145720
change USE_EGADSLITE to PUMI_USE_EGADSLITE
tuckerbabcock Apr 2, 2021
f98fe6d
remove egadslite include accidentally commited
tuckerbabcock Apr 3, 2021
83e59a5
Merge branch 'master' into egads-dev
tuckerbabcock Feb 18, 2022
407ead5
Merge branch 'master' into egads-dev
tuckerbabcock Feb 18, 2022
afb21d5
update CMake support for finding EGADS, import it as a target now, an…
tuckerbabcock Jul 25, 2022
910b12a
Update gmi EGADS CMake setup to use target_compile_definitions for HA…
tuckerbabcock Aug 2, 2022
3f13376
enable testing EGADS with EGADSLITE enabled
tuckerbabcock Aug 2, 2022
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
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ set(Trilinos_PREFIX "" CACHE STRING "Trilinos installation directory")
option(SKIP_SIMMETRIX_VERSION_CHECK "enable at your own risk; it may result in undefined behavior" OFF)
option(ENABLE_SIMMETRIX "Build with Simmetrix support" OFF)
message(STATUS "ENABLE_SIMMETRIX: ${ENABLE_SIMMETRIX}")
option(ENABLE_EGADS "Build with EGADS support" OFF)
message(STATUS "ENABLE_EGADS: ${ENABLE_EGADS}")
if(ENABLE_EGADS)
add_definitions(-DHAVE_EGADS)
Copy link
Contributor

Choose a reason for hiding this comment

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

To add compiler definitions you should be target_compile_definitions. Since you use this option in the header it will need to be public. Because this leaks into the user's downstream code you should use a prefixed name. I.e. PUMI_HAVE_EGADS

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for taking another look at this @jacobmerson. I wrote the -DHAVE_EGADS definition to be consistent with the simmetrix definition:

core/CMakeLists.txt

Lines 97 to 99 in 30a332d

if(ENABLE_SIMMETRIX)
add_definitions(-DHAVE_SIMMETRIX)
endif()

Based on the way that HAVE_SIMMETRIX is used, it seems convenient to use add_definitions so that it applies to all the executables so that multiple calls to target_compile_definitions can be skipped, but I am aware that this approach is considered bad practice in modern cmake. In any case I thought it would be best to stay consistent, though I'm not tied to the current approach.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer that all of those other HAVE_XXX definitions get prefixed eventually and you have a valid point about consistency. The problem with adding compile definitions without a namespace is that any other consuming project linking against pumi_egads has that compile definition on their target. So, what if a consumer wants to use PUMI compiled with egads but they have conditional code behind HAVE_EGADS that they don't want to compile for some reason...currently they cannot do that since compile definitions are infectious. I think @cwsmith has last word on this sort of thing since he has to deal with all the xsdk people/rules.

The issue with the non-target version of add_definitions (especially in the top level cmake file) is that it will be applied to every single target and library at the current or lower sub-directory level. So, even random libraries that have nothing to do with egads are getting that compile definition added. Since these compile definitions will be infectious to anyone who uses any SCOREC target it has the potential to cause issues for down stream users.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cwsmith do you have any thoughts on the concerns raised by @jacobmerson?

Copy link
Contributor

Choose a reason for hiding this comment

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

@jacobmerson is correct. We should have all the *HAVE*,*ENABLE*, etc... variables prefixed with PUMI_ to avoid conflicts with packages that use PUMI. +1 for using target_compile_definitions as well.

I created an issue to clean this up in develop after this is merged. #337


option(PUMI_USE_EGADSLITE "Build with EGADSlite" ON)
message(STATUS "PUMI_USE_EGADSLITE: ${PUMI_USE_EGADSLITE}")
endif()
option(ENABLE_OMEGA_H "Enable the Omega_h interface" OFF)
message(STATUS "ENABLE_OMEGA_H: ${ENABLE_OMEGA_H}")
if(ENABLE_SIMMETRIX)
Expand All @@ -113,6 +121,10 @@ if(ENABLE_SIMMETRIX)
find_package(SimModSuite MODULE REQUIRED)
endif()

if(ENABLE_EGADS)
find_package(EGADS MODULE REQUIRED)
endif()

if(ENABLE_OMEGA_H)
# find the omega_h library
set(SCOREC_USE_Omega_h_DEFAULT ${ENABLE_OMEGA_H})
Expand All @@ -125,6 +137,7 @@ add_subdirectory(lion)
add_subdirectory(pcu)
add_subdirectory(gmi)
add_subdirectory(gmi_sim)
add_subdirectory(gmi_egads)
add_subdirectory(can)
add_subdirectory(mth)
add_subdirectory(apf)
Expand Down
10 changes: 10 additions & 0 deletions apf/apfMesh.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,16 @@ void Mesh::getParamOn(ModelEntity* g, MeshEntity* e, Vector3& p)
ModelEntity* from_g = toModel(e);
if (g == from_g)
return getParam(e, p);

// above comparison only compares pointer address, this check's the entity's
// dim and tag in case it's the same entity but a different point to it
int from_dim = getModelType(from_g);
int from_tag = getModelTag(from_g);
int to_dim = getModelType(g);
int to_tag = getModelTag(g);
if ((from_dim == to_dim) && (from_tag == to_tag))
return getParam(e, p);

tuckerbabcock marked this conversation as resolved.
Show resolved Hide resolved
gmi_ent* from = (gmi_ent*)from_g;
gmi_ent* to = (gmi_ent*)g;
Vector3 from_p;
Expand Down
1 change: 1 addition & 0 deletions cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ TRIBITS_PACKAGE_DEFINE_DEPENDENCIES(
LIB_OPTIONAL_PACKAGES
SCORECgmi_sim
SCORECapf_sim
SCORECgmi_egads
LIB_REQUIRED_PACKAGES
SCOREClion
SCORECpcu
Expand Down
33 changes: 33 additions & 0 deletions cmake/FindEGADS.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# - Try to find EGADS
# Once done this will define
# EGADS_FOUND - System has EGADS
# EGADS_INCLUDE_DIRS - The EGADS include directories
# EGADS_LIBRARIES - The libraries needed to use EGADS/EGADSlite
# EGADSLITE_LIBRARIES - The libraries needed to use EGADSlite
# EGADS_DEFINITIONS - Compiler switches required for using EGADS

find_path(EGADS_INCLUDE_DIR egads.h PATHS "${EGADS_DIR}/include")
set(EGADS_INCLUDE_DIRS ${EGADS_INCLUDE_DIR})

if(${PUMI_USE_EGADSLITE})
find_library(EGADS_LIBRARY
NAMES egadslite libegadslite.so libegadslite.dylib
PATHS "${EGADS_DIR}/lib")
else()
find_library(EGADS_LIBRARY
NAMES egads libegads.so libegads.dylib
PATHS "${EGADS_DIR}/lib")
endif()

set(EGADS_LIBRARIES ${EGADS_LIBRARY})

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set EGADS_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(
EGADS
DEFAULT_MSG
EGADS_INCLUDE_DIR EGADS_LIBRARY
)

mark_as_advanced(EGADS_INCLUDE_DIR EGADS_LIBRARY)
tuckerbabcock marked this conversation as resolved.
Show resolved Hide resolved
43 changes: 43 additions & 0 deletions gmi_egads/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
if(DEFINED TRIBITS_PACKAGE)
include(pkg_tribits.cmake)
return()
endif()

if(NOT ENABLE_EGADS)
return()
endif()

# this file brings PUMI_USE_EGADSLITE from CMake to C++
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/gmi_egads_config.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/gmi_egads_config.h")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jacobmerson this config file only defines PUMI_USE_EGADSLITE. Is conditionally calling target_compile_definitions a better approach here? It seems like it would be to me.

Copy link
Contributor

Choose a reason for hiding this comment

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

target_compile_definitions would be used instead of https://github.com/tuckerbabcock/core/blob/afb21d570ad03e75c346b4a45b714a0be1dbb815/CMakeLists.txt#L103

An example of its use is here:

target_compile_definitions(core INTERFACE -DPUMI_HAS_MALLINFO2)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cwsmith would you prefer the target be the interface target core, or just the gmi_egads target? I think the gmi_egads target would be more explicit and therefore preferable, but I don't have strong thoughts.

For my above thought on having PUMI_USE_EGADSLITE be set with target_compile_definitions, I was imagining it would be set as a PRIVATE property of gmi_egads, since I think that would be semantically equivalent to the current setup with the config file.

Copy link
Contributor

Choose a reason for hiding this comment

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

I spent some more time looking at the code and have a hopefully more complete response.

IIUC, the user needs to know if PUMI was installed with EGADS and/or EGADSLite support and gmi_egads/gmi_egads.c needs to know if EGADSLite is enabled (gmi_egads.c is only compiled if egads is enabled). If that is correct, I think the best option is to use target_compile_definitions(...) for both variables and remove the config header. We would also want to replace any use of HAVE_EGADS[LITE] with the PUMI_HAS_EGADS[LITE] variable (or equivalent).

To answer your questions:

  • target: Try setting it on gmi_egads, but that may cause problems compiling tests that use the preprocessor variables when gmi_egads is not available/installed.
  • visibility: If the first assumption was correct, then I think they should both have INTERFACE scoping/visibility.

Copy link
Contributor Author

@tuckerbabcock tuckerbabcock Aug 2, 2022

Choose a reason for hiding this comment

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

@cwsmith I've switched over all the EGADS stuff to use target_compile_definitions, and renamed the flags from HAVE_EGADS to PUMI_HAS_EGADS. PUMI_USE_EGADSLITE is a private definition on gmi_egads since it is only needed in gmi_egads.c, while PUMI_HAS_EGADS is an interface definition on gmi_egads since its needed by people who use the library. I did not experience any issues compiling and running the tests that use these variables when gmi_egads wasn't built, so I think it should be okay.


#Sources & Headers
set(SOURCES gmi_egads.c)
set(HEADERS gmi_egads.h)

add_library(gmi_egads ${SOURCES})

target_include_directories(gmi_egads
PRIVATE
${EGADS_INCLUDE_DIR}
)

target_link_libraries(gmi_egads
PUBLIC
gmi
PRIVATE
${EGADS_LIBRARIES}
)

# Include directories
target_include_directories(gmi_egads PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)
# make sure the compiler can find the config header
target_include_directories(gmi_egads PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)

scorec_export_library(gmi_egads)

bob_end_subdir()
Loading