diff --git a/.gitignore b/.gitignore index 259148f..adffdbc 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,30 @@ *.exe *.out *.app + +# Images +*.png + +# Meshes +*.gmv +*.exo + +# vfgen input +*.inp + +# Binary data +*.bvf +*.dat + +.DS_Store +build +build-Debug +build-Release +install +install-Debug +install-Release +.vscode + +# Editor backup files +*~ +.idea \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 5dcb40a..7f32c27 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "cinch"] - path = cinch - url = ../../laristra/cinch.git -[submodule "wonton"] - path = wonton - url = ../../laristra/wonton.git +[submodule "googletest"] + path = googletest + url = ../../google/googletest diff --git a/.travis.yml b/.travis.yml index df5bfb5..922c1ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,13 +5,9 @@ sudo: required services: - docker -python: - - "3.6" +dist: xenial env: - global: - # Doctr deploy key for laristra/tangram - - secure: "VT6e1jEwGNu+71UYqtj12+dK4L/IBtoKdVgZ6NGb12QFgVzaB8x6sl8PTfS4xMa+Gav9z4x3qYBRHbhlU42TpKr/llFdFQHzTCVMk7Y8PVfF6vCmrqJWamcC6bVWnNEbJm4sdG/HK3XM8jKZdKRJVnUUskGcKiFzOMgl+GJaBTfHWr9XZhPW18k7rRWEeBevEsKPWGhD15ugno5kZYFkb4A1iV1nSap+VO3hSuQ3DqMzKYGyBBzBfSTdgWvqff6dFKgCA4Xr4AeMLppcG4cUyPyeSucF6Wq3PaOhHOksm15yA5a6LLcRD+Byabq4HU5qAYc0auMh3Csc1wqpu/fnCKKVKv9ZBB7EaWQYysa7RhFInYLSFS3RstVShENw2RtezIKNnIW+TaNlpYGMOGfbTngJnpjY54QNc6Gd22N/L4QKCpc+FwQHHukWAcf4fu/YqRhHWfoUaOOAMzedeChGWbxN+GnPy2QxxIKVUyxpS3+AwGv3cDD5vf9j47C7zPrw8L1FxNuFjYAioPAS+RxpYQGnqU+kCSvVtDmXBXPhA/2BZLqxrW1h1tnDx+kgVu2DXC5glv1PPdpUqg2cR9vdn8pmiKqSnED6AxGVwWmtwwKsrlQZGuLTpYSuCggcgqhbQSoZu3L1xSZj5LyFXvnZoGIGW7GzsjCSmKa0Ekkgmb0=" matrix: - MPI=OFF DOCS=true - MPI=ON DOCKERHUB=true @@ -33,6 +29,9 @@ script: --build-arg DOCS=${DOCS} -t ${TRAVIS_REPO_SLUG}:latest ${HOME}/docker/ +before_install: + - openssl aes-256-cbc -K $encrypted_79204e1bdcac_key -iv $encrypted_79204e1bdcac_iv -in github_deploy_key_laristra_tangram.enc -out github_deploy_key_laristra_tangram -d + after_success: - if [[ ${DOCKERHUB} = true && ${DOCKER_USERNAME} && ${DOCKER_PASSWORD} && ${TRAVIS_PULL_REQUEST} == false && ${TRAVIS_BRANCH} == master ]]; then docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"; @@ -41,7 +40,14 @@ after_success: - if [[ ${DOCS} || -n ${TRAVIS_TAG} ]]; then cd ${HOME}/docker/tangram; CON=$(docker run -d ${TRAVIS_REPO_SLUG}:latest) && docker cp ${CON}:/home/portage/tangram/build/doc . ; - pyenv local 3.6; - pip install doctr; - doctr deploy . --built-docs doc/doxygen/html; fi + +deploy: + provider: pages:git + edge: true # opt into version 2 of the dpl + deploy_key: github_deploy_key_laristra_tangram + local_dir: doc/doxygen/html + verbose: true + on: + tags: true # only deploy on tagged builds + condition: ${DOCS} && -d doc/doxygen/html diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c778e7..2b656ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,36 +4,212 @@ https://github.com/laristra/tangram/blob/master/LICENSE ]] -################################################################################ -# Please Do Not Edit This File Unless You Know What You Are Doing. -# -# Project-specific configuration rules should be added in the 'config' -# subdirectory of the top-level of this project in the appropriate file, -# e.g., package configuration options should go in 'config/packages.cmake'. -# -# For more documentation on the design philosophy of this build system -# and the recognized configuration files that can be added to the 'config' -# subdirectory, please look in 'cinch/README.md' and 'cinch/INSTALL.md' -# from the top-level of this project. -# -# Any changes to the basic build template should be discussed with the -# project maintainers. -################################################################################ +cmake_minimum_required(VERSION 3.13) -#------------------------------------------------------------------------------# -# Require some version of cmake -#------------------------------------------------------------------------------# +project(tangram CXX) + +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +if (CMAKE_VERSION_MAJOR GREATER_EQUAL 3.13) + CMAKE_POLICY(SET CMP0079 NEW) # allow target_link_libraries to reference + # targets from other directories +endif() + +cmake_policy(SET CMP0074 NEW) # Don't ignore Pkg_ROOT variables + + + +# SEMANTIC VERSION NUMBERS - UPDATE DILIGENTLY +# As soon as a change with a new version number is merged into the master, +# tag the central repository. + +set(TANGRAM_VERSION_MAJOR 1) +set(TANGRAM_VERSION_MINOR 0) +set(TANGRAM_VERSION_PATCH 1) + + +# Top level target +add_library(tangram INTERFACE) + +# Alias (Daniel Pfeiffer, Effective CMake) - this allows other +# projects that use Pkg as a subproject to find_package(Nmspc::Pkg) +# which does nothing because Pkg is already part of the project + +add_library(tangram::tangram ALIAS tangram) +set(TANGRAM_LIBRARIES tangram::tangram) + +# Find our modules first +if (CMAKE_VERSION GREATER_EQUAL 3.15) + list(PREPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") +else () + set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}") +endif () + + +#---------------------------------------------------------------------------- +# Find packages here and set CMake variables. Set link dependencies +# and compile definitions for tangram_support target in +# tangram/support. Since the top level tangram::tangram target depends +# on tangram_support, the transitive dependencies will be picked up by +# projects linking to Tangram +#---------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# Find Wonton +#----------------------------------------------------------------------------- + +# Link with an existing installation of Wonton, if provided. +find_package(WONTON QUIET REQUIRED NAMES wonton) + +target_include_directories(tangram INTERFACE ${WONTON_INCLUDE_DIR}) +message(STATUS "WONTON_INCLUDE_DIR=${WONTON_INCLUDE_DIR}") + +target_link_libraries(tangram INTERFACE ${WONTON_LIBRARIES}) +message(STATUS "WONTON_LIBRARIES=${WONTON_LIBRARIES}" ) + +if (TANGRAM_ENABLE_THRUST AND NOT WONTON_ENABLE_THRUST) + message(FATAL_ERROR "Thrust enabled for Tangram but Wonton is not built with Thrust") +endif () +if (NOT TANGRAM_ENABLE_THRUST AND WONTON_ENABLE_THRUST) + message(FATAL_ERROR "Thrust disabled for Tangram but Wonton is built with Thrust") +endif () + +if (TANGRAM_ENABLE_MPI AND NOT WONTON_ENABLE_MPI) + message(FATAL_ERROR "MPI enabled for Tangram but Wonton is not compiled with MPI") +endif () + +if (NOT TANGRAM_ENABLE_MPI AND WONTON_ENABLE_MPI) + message(FATAL_ERROR "MPI disabled for Tangram but Wonton is compiled with MPI") +endif () + +if (TANGRAM_ENABLE_Jali AND NOT WONTON_ENABLE_Jali) + message(FATAL_ERROR "Jali enabled for Tangram but Wonton is not built with Jali") +endif () + +if (TANGRAM_ENABLE_FleCSI AND NOT WONTON_ENABLE_FleCSI) + message(FATAL_ERROR "FleCSI enabled for Tangram but Wonton is not built with FleCSI") +endif () -cmake_minimum_required(VERSION 3.0) #------------------------------------------------------------------------------# -# Include project-level CMake configuration file +# Configure XMOF2D #------------------------------------------------------------------------------# -if(NOT "$ENV{CINCH_SOURCE_DIR}" STREQUAL "") - set(CINCH_SOURCE_DIR $ENV{CINCH_SOURCE_DIR}) -elseif(EXISTS ${CMAKE_SOURCE_DIR}/cinch) - set(CINCH_SOURCE_DIR ${CMAKE_SOURCE_DIR}/cinch) -endif() +set(TANGRAM_ENABLE_XMOF2D False CACHE BOOL "Is XMOF2D enabled?") +if (TANGRAM_ENABLE_XMOF2D) + + # Look for the XMOF2D package + + find_package(XMOF2D REQUIRED) + + message(STATUS "Located XMOF2D") + + target_include_directories(tangram INTERFACE ${XMOF2D_INCLUDE_DIRS}) + message(STATUS "XMOF2D_INCLUDE_DIR ${XMOF2D_INCLUDE_DIRS}") + + # XMOF2D_LIBRARIES doesn't contain a real target name. Until we + # upgrade XMOF2D's cmake to export the correct target, we have to + # also specify where to find the library + target_link_directories(tangram INTERFACE ${XMOF2D_LIBRARY_DIR}) + target_link_libraries(tangram INTERFACE ${XMOF2D_LIBRARIES}) + + if (NOT XMOF2D_ROOT) + set(XMOF2D_ROOT ${XMOF2D_INCLUDE_DIR}/../share/cmake CACHE FILEPATH "Where XMOF2D can be found") + endif () + + set(TANGRAM_ENABLE_XMOF2D True CACHE BOOL "Is XMOF2D enabled?" FORCE) +endif () + + +if (ENABLE_UNIT_TESTS) + + # This needs to be set in the root directory for tests to be run by + # 'make test' or ctest + enable_testing() + + include(cmake/unittest.cmake) + +endif () + + + +#----------------------------------------------------------------------------- +# Recurse down the source directories building up dependencies +#----------------------------------------------------------------------------- + +add_subdirectory(tangram) + + +# In addition to the include directories of the source, we need to +# include the build or directory to get the autogenerated +# tangram-config.h (The first of these is needed if Wonton is included +# as a submodule, the second is needed for the auto-generated config +# file if Tangram is included as a submodule, the third is to get the +# autogenerated config header if Tangram is being compiled separately +# and the last is for dependencies in installations) + +target_include_directories(tangram INTERFACE + $ + $ + $ + $) + + +# Tangram targets + +install(TARGETS tangram + EXPORT tangram_LIBRARIES + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin + PUBLIC_HEADER DESTINATION include + INCLUDES DESTINATION include + ) + + +#----------------------------------------------------------------------------- +# Add any applications built upon tangram +#----------------------------------------------------------------------------- + +add_subdirectory(app) + + +#----------------------------------------------------------------------------- +# Prepare output for configuration files to be used by projects importing Tangram +#----------------------------------------------------------------------------- + +# Write a configuration file from template replacing only variables enclosed +# by the @ sign. +configure_file(${PROJECT_SOURCE_DIR}/cmake/tangramConfig.cmake.in + tangramConfig.cmake @ONLY) +install(FILES ${PROJECT_BINARY_DIR}/tangramConfig.cmake DESTINATION lib/cmake/tangram) + + +# write out a version file +include(CMakePackageConfigHelpers) +write_basic_package_version_file(tangramConfigVersion.cmake + VERSION "${TANGRAM_MAJOR_VERSION}.${TANGRAM_MINOR_VERSION}.${TANGRAM_PATCH_VERSION}" + COMPATIBILITY SameMajorVersion) +install(FILES ${PROJECT_BINARY_DIR}/tangramConfigVersion.cmake + DESTINATION lib/cmake/tangram) + + +# export targets + +install(EXPORT tangram_LIBRARIES + FILE tangramTargets.cmake + NAMESPACE tangram:: + EXPORT_LINK_INTERFACE_LIBRARIES + DESTINATION lib/cmake/tangram) + + + +# Dynamically configured header files that contains defines like +# WONTON_ENABLE_MPI etc. if enabled -include(${CMAKE_SOURCE_DIR}/cinch/cmake/ProjectLists.txt) +configure_file(${PROJECT_SOURCE_DIR}/config/tangram-config.h.in + ${PROJECT_BINARY_DIR}/tangram-config.h @ONLY) +install(FILES ${PROJECT_BINARY_DIR}/tangram-config.h + DESTINATION ${CMAKE_INSTALL_PREFIX}/include) diff --git a/README.md b/README.md index f5720af..ee72067 100644 --- a/README.md +++ b/README.md @@ -37,22 +37,29 @@ Tangram uses standard C++11 features, so a fairly modern compiler is needed. We regularly test with Intel 18.0.1, GCC 6.4.0, and GCC 7.3.0. Utilizing the full capabilities of Tangram will require an MPI implementation; we regularly test with OpenMPI 2.1.2. The build system _requires_ CMake -version 3.0+. +version 3.13+. The following libraries are also _required_ (see examples below): -- **__Either__** Boost (1.68.0+) **__or__** Thrust (1.6.0+): +- **__Either__** Boost (1.68.0+) **__or__** Thrust (1.8.0+): We wrap some features of either one of these packages. If you would - like to run with OpenMP or TBB threads, then you _must_ use Thrust. - -Tangram provides wrappers for a few third-party mesh types. Building -support for these is _optional_: - -- [Jali](http://github.com/lanl/jali): - - We regularly test with verison 1.0.4. You will need to set the - `Jali_Dir` CMake variable if you wish to build support for Jali and - its tests (see examples below). + like to run with OpenMP, then you _must_ use Thrust. + +Tangram requires the [Wonton](https://github.com/laristra/wonton) +library. The path where Wonton is installed must be specified either +through the **WONTON_ROOT** variable or included in the +**CMAKE_PREFIX_PATH**. Tangram will pick up the third party libraries +that Wonton is built with (Jali, FleCSI and LAPACKE) based on the +installation. Some options requested for Tangram must match those of +the Wonton installation. For example, you cannot ask for Tangram to be +built with MPI (or Thrust) and link to an installation of Wonton built +without MPI (or Thrust). + +Tangram can optionally be built with the +[XMOF2D](https://github.com/laristra/xmof2d) library. Enable XMOF2D +support using the option "TANGRAM_ENABLE_XMOF2D=True" and point to the +location where *XMOF2DConfig.cmake* is installed either through the +**XMOF2D_ROOT** variable or include it in the **CMAKE_PREFIX_PATH**. ### Installing @@ -63,7 +70,7 @@ searches, then the build step is: ```sh tangram $ mkdir build tangram $ cd build -tangram/build $ cmake -DENABLE_APP_TESTS=True .. +tangram/build $ cmake -DWONTON_ROOT:FILEPATH=/path/to/wonton .. tangram/build $ make ``` @@ -97,36 +104,23 @@ assigned **LA-CC-17-133**. #!/bin/bash BUILD_TYPE=Release -JALI_INSTALL_PREFIX=/path/to/jali/installation -TPLS_INSTALL_PREFIX=/path/to/jali/tpls/installation -LAPACKE_INSTALL_PREFIX=/path/to/LAPACKE/intallation XMOF2D_INSTALL_PREFIX=/path/to/XMOF2D/installation -THRUST_PATH=/path/to/thrust -BOOST_PATH=/path/to/boost -TCMALLOC_PATH=/path/to/google/performance/tools/installation - -CC=`which mpicc` -CXX=`which mpiCC` rm -rf build mkdir build cd build cmake \ - -D CMAKE_C_COMPILER=${CC} \ - -D CMAKE_CXX_COMPILER=${CXX} \ -D CMAKE_BUILD_TYPE=${BUILD_TYPE} \ + -D CMAKE_INSTALL_PREFIX=/path/where/to/install/tangram \ -D ENABLE_UNIT_TESTS=True \ -D ENABLE_APP_TESTS=True \ - -D ENABLE_MPI=True \ + -D TANGRAM_ENABLE_MPI=True \ + -D WONTON_ROOT=/path/where/wonton/is/installed \ + -D TANGRAM_ENABLE_Jali=True \ + -D TANGRAM_ENABLE_XMOF2D=True \ -D XMOF2D_DIR:FILEPATH=${XMOF2D_INSTALL_PREFIX}/share/cmake \ - -D BOOST_ROOT:FILEPATH=${BOOST_PATH} \ - -D LAPACKE_DIR:FILEPATH=${LAPACKE_INSTALL_PREFIX} \ - -D ENABLE_THRUST:BOOL=True \ - -D THRUST_DIR:PATH=${THRUST_PATH} \ - -D Jali_DIR:FILEPATH=${JALI_INSTALL_PREFIX}/lib \ - -D ENABLE_TCMALLOC=True \ - -D TCMALLOC_LIB:FILEPATH={TCMALLOC_PATH}/libtcmalloc.so \ + -D TANGRAM_ENABLE_THRUST:BOOL=True \ .. make -j ``` @@ -144,11 +138,9 @@ Execute the following from the Tangram root directory: # machine=varan export MODULEPATH="" . /opt/local/packages/Modules/default/init/sh -module load intel/18.0.1 openmpi/2.1.2 cmake/3.10.2 -TPL_INSTALL_PREFIX=/usr/local/codes/ngc/private/jali-tpl/1.2.0-intel-18.0.1-openmpi-2.1.2 -NGC_INCLUDE_DIR=/usr/local/codes/ngc/private/include +module load intel/18.0.1 openmpi/2.1.2 cmake/3.14.0 XMOF2D_INSTALL_PREFIX=/usr/local/codes/ngc/private/xmof2d/0.9.5-intel-18.0.1 -JALI_INSTALL_PREFIX=/usr/local/codes/ngc/private/jali/1.0.4-intel-18.0.1-openmpi-2.1.2 +WONTON_INSTALL_PREFIX=/usr/local/codes/ngc/private/wonton/1.2.2-intel-18.0.1-openmpi-2.1.2 mkdir build cd build cmake \ @@ -156,12 +148,12 @@ cmake \ -D CMAKE_CXX_COMPILER=`which mpiCC` \ -D CMAKE_BUILD_TYPE=Release \ -D ENABLE_UNIT_TESTS=True \ - -D ENABLE_MPI=True \ + -D TANGRAM_ENABLE_MPI=True \ -D ENABLE_JENKINS_OUTPUT=True \ - -D Jali_DIR:FILEPATH=$JALI_INSTALL_PREFIX/lib \ - -D XMOF2D_DIR:FILEPATH=$XMOF2D_INSTALL_PREFIX/share/cmake \ - -D BOOST_ROOT:FILEPATH=$TPL_INSTALL_PREFIX \ - -D NGC_INCLUDE_DIR:FILEPATH=$NGC_INCLUDE_DIR \ + -D WONTON_ROOT=$WONTON_INSTALL_PREFIX \ + -D TANGRAM_ENABLE_Jali=True \ + -D TANGRAM_ENABLE_XMOF2D=True \ + -D XMOF2D_ROOT:FILEPATH=$XMOF2D_INSTALL_PREFIX/share/cmake \ .. make -j2 ctest --output-on-failure diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 6397bf2..5b5f002 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -11,15 +11,15 @@ add_subdirectory(test_mof) add_subdirectory(test_vof) add_subdirectory(test_slic) add_subdirectory(demo_rotor3d) -if (ENABLE_MPI AND Jali_DIR) +if (WONTON_ENABLE_MPI AND WONTON_ENABLE_Jali) add_subdirectory(demo-vof-app) add_subdirectory(demo-mof-app) add_subdirectory(demo-slic-app) -endif (ENABLE_MPI AND Jali_DIR) +endif (WONTON_ENABLE_MPI AND WONTON_ENABLE_Jali) if(XMOF2D_FOUND) add_subdirectory(test_xmof2d) - if (ENABLE_MPI AND Jali_DIR) + if (WONTON_ENABLE_MPI AND WONTON_ENABLE_Jali) add_subdirectory(demo-xmof-app) - add_subdirectory(vfgen) - endif (ENABLE_MPI AND Jali_DIR) + endif (WONTON_ENABLE_MPI AND WONTON_ENABLE_Jali) endif(XMOF2D_FOUND) +add_subdirectory(vfgen) diff --git a/app/apptest_cmp/apptest_cmp.cc b/app/apptest_cmp/apptest_cmp.cc index de77449..cc6cccb 100644 --- a/app/apptest_cmp/apptest_cmp.cc +++ b/app/apptest_cmp/apptest_cmp.cc @@ -50,29 +50,33 @@ int main(int argc, char** argv) { load_field(f1, gid1, values1); load_field(f2, gid2, values2); + std::pair field_size(gid1.size(), gid2.size()); + std::cout << std::scientific; std::cout.precision(17); std::cout << "Comparing files: " << argv[1] << " " << argv[2] << std::endl; std::cout << "Absolute Epsilon: " << abs_eps << std::endl; std::cout << "Relative Epsilon: " << rel_eps << std::endl; - std::cout << "Field sizes: " << gid1.size() << " " << gid2.size() << - std::endl; - if (gid1.size() != gid2.size()) { + std::cout << "Field sizes: " << field_size.first << " " << field_size.second + << std::endl; + + if (field_size.first != field_size.second) { throw std::runtime_error("The field sizes do not match."); } - double delta, maxval; - for (int i=0; i < gid1.size(); i++) { + + for (int i=0; i < field_size.first; i++) { if (gid1[i] != gid2[i]) { std::cout << i << " " << gid1[i] << " " << gid2[i] << std::endl; throw std::runtime_error("The field global IDs do not match."); } // Test absolute tolerance - delta = std::abs(values1[i] - values2[i]); + double delta = std::abs(values1[i] - values2[i]); if (delta <= abs_eps) continue; // Still might be the same if within the relative tolerance - maxval = (std::abs(values1[i]) > std::abs(values2[i])) ? - values1[i] : values2[i]; + double maxval = + std::abs(values1[i]) > std::abs(values2[i]) ? values1[i] : values2[i]; + if ((delta / std::abs(maxval)) <= rel_eps) continue; // Fails -- abort diff --git a/app/demo-mof-app/CMakeLists.txt b/app/demo-mof-app/CMakeLists.txt index b5c7be4..5ab6396 100644 --- a/app/demo-mof-app/CMakeLists.txt +++ b/app/demo-mof-app/CMakeLists.txt @@ -8,36 +8,5 @@ # demo-mof-app - uses 2D/3D mesh from Jali #------------------------------------------------------------------------------- add_executable(demo-mof-app demo-mof-app.cc) -target_link_libraries(demo-mof-app wonton ${Jali_LIBRARIES} ${Jali_TPL_LIBRARIES} - ${MPI_CXX_LIBRARIES} ${EXTRA_LIBS}) +target_link_libraries(demo-mof-app tangram) -if(ENABLE_MPI) - if(MPI_CXX_COMPILE_FLAGS) - set_target_properties(demo-mof-app PROPERTIES - COMPILE_FLAGS "${MPI_CXX_COMPILE_FLAGS}") - endif(MPI_CXX_COMPILE_FLAGS) - - if(MPI_CXX_LINK_FLAGS) - set_target_properties(demo-mof-app PROPERTIES - LINK_FLAGS "${MPI_CXX_LINK_FLAGS}") - endif(MPI_CXX_LINK_FLAGS) -endif(ENABLE_MPI) - -#TCMalloc option -set(ENABLE_TCMALLOC TRUE CACHE BOOL "Use TCMalloc") -if(ENABLE_TCMALLOC) - set(TCMALLOC_LIB "${HOME}" CACHE STRING "Set the TCMalloc library") - target_link_libraries(demo-mof-app ${TCMALLOC_LIB}) -endif(ENABLE_TCMALLOC) - - -#------------------------------------------------------------------------------- -# Other libraries -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# Testing -#------------------------------------------------------------------------------- -# if (ENABLE_APP_TESTS) -# add_subdirectory(test) -# endif (ENABLE_APP_TESTS) diff --git a/app/demo-mof-app/demo-mof-app.cc b/app/demo-mof-app/demo-mof-app.cc index 088daf7..da1e023 100644 --- a/app/demo-mof-app/demo-mof-app.cc +++ b/app/demo-mof-app/demo-mof-app.cc @@ -148,6 +148,7 @@ void run (std::shared_ptr inputMesh, std::vector offsets(ncells, 0); for (int icell = 0; icell < ncells - 1; icell++) offsets[icell + 1] = offsets[icell] + cell_num_mats[icell]; + for (int icell = 0; icell < ncells; icell++) { if (cell_num_mats[icell] == 1) { assert(cellmatpoly_list[icell] == nullptr); @@ -161,6 +162,7 @@ void run (std::shared_ptr inputMesh, cellmatpoly_list[icell] = cmp_ptr; } } + write_to_gmv(cellmatpoly_list, out_gmv_fname); } @@ -190,9 +192,10 @@ int main(int argc, char** argv) { Jali::MeshFactory mesh_factory(comm); mesh_factory.framework(Jali::MSTK); + if (dim == 2) { - mesh_factory.included_entities({Jali::Entity_kind::EDGE}); + mesh_factory.included_entities(Jali::Entity_kind::EDGE); std::shared_ptr mesh = mesh_factory(argv[4]); run<2>(mesh, isconvex, in_data_fname, out_gmv_fname); diff --git a/app/demo-slic-app/CMakeLists.txt b/app/demo-slic-app/CMakeLists.txt index ad3245c..eafa08d 100644 --- a/app/demo-slic-app/CMakeLists.txt +++ b/app/demo-slic-app/CMakeLists.txt @@ -8,35 +8,4 @@ # demo-slic-app3d - uses 3D Simple_Mesh #------------------------------------------------------------------------------- add_executable(demo-slic-app demo-slic-app.cc) -target_link_libraries(demo-slic-app wonton ${Jali_LIBRARIES} ${Jali_TPL_LIBRARIES} - ${MPI_CXX_LIBRARIES} ${EXTRA_LIBS}) - -if(ENABLE_MPI) - if(MPI_CXX_COMPILE_FLAGS) - set_target_properties(demo-slic-app PROPERTIES - COMPILE_FLAGS "${MPI_CXX_COMPILE_FLAGS}") - endif(MPI_CXX_COMPILE_FLAGS) - - if(MPI_CXX_LINK_FLAGS) - set_target_properties(demo-slic-app PROPERTIES - LINK_FLAGS "${MPI_CXX_LINK_FLAGS}") - endif(MPI_CXX_LINK_FLAGS) -endif(ENABLE_MPI) - -#TCMalloc option -set(ENABLE_TCMALLOC TRUE CACHE BOOL "Use TCMalloc") -if(ENABLE_TCMALLOC) - set(TCMALLOC_LIB "${HOME}" CACHE STRING "Set the TCMalloc library") - target_link_libraries(demo-slic-app ${TCMALLOC_LIB}) -endif(ENABLE_TCMALLOC) - -#------------------------------------------------------------------------------- -# Other libraries -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# Testing -#------------------------------------------------------------------------------- -# if (ENABLE_APP_TESTS) -# add_subdirectory(test) -# endif (ENABLE_APP_TESTS) +target_link_libraries(demo-slic-app tangram) diff --git a/app/demo-slic-app/demo-slic-app.cc b/app/demo-slic-app/demo-slic-app.cc index ed2e883..65c1c71 100644 --- a/app/demo-slic-app/demo-slic-app.cc +++ b/app/demo-slic-app/demo-slic-app.cc @@ -194,7 +194,7 @@ int main(int argc, char** argv) { if (dim == 2) { - mesh_factory.included_entities({Jali::Entity_kind::EDGE}); + mesh_factory.included_entities(Jali::Entity_kind::EDGE); std::shared_ptr mesh = mesh_factory(argv[4]); run<2>(mesh, isconvex, in_data_fname, out_gmv_fname); diff --git a/app/demo-vof-app/CMakeLists.txt b/app/demo-vof-app/CMakeLists.txt index 579b1e9..a8aa883 100644 --- a/app/demo-vof-app/CMakeLists.txt +++ b/app/demo-vof-app/CMakeLists.txt @@ -8,35 +8,5 @@ # demo-vof-app - uses 2D/3D mesh from Jali #------------------------------------------------------------------------------- add_executable(demo-vof-app demo-vof-app.cc) -target_link_libraries(demo-vof-app wonton ${Jali_LIBRARIES} ${Jali_TPL_LIBRARIES} - ${MPI_CXX_LIBRARIES} ${EXTRA_LIBS}) +target_link_libraries(demo-vof-app tangram) -if(ENABLE_MPI) - if(MPI_CXX_COMPILE_FLAGS) - set_target_properties(demo-vof-app PROPERTIES - COMPILE_FLAGS "${MPI_CXX_COMPILE_FLAGS}") - endif(MPI_CXX_COMPILE_FLAGS) - - if(MPI_CXX_LINK_FLAGS) - set_target_properties(demo-vof-app PROPERTIES - LINK_FLAGS "${MPI_CXX_LINK_FLAGS}") - endif(MPI_CXX_LINK_FLAGS) -endif(ENABLE_MPI) - -#TCMalloc option -set(ENABLE_TCMALLOC TRUE CACHE BOOL "Use TCMalloc") -if(ENABLE_TCMALLOC) - set(TCMALLOC_LIB "${HOME}" CACHE STRING "Set the TCMalloc library") - target_link_libraries(demo-vof-app ${TCMALLOC_LIB}) -endif(ENABLE_TCMALLOC) - -#------------------------------------------------------------------------------- -# Other libraries -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# Testing -#------------------------------------------------------------------------------- -# if (ENABLE_APP_TESTS) -# add_subdirectory(test) -# endif (ENABLE_APP_TESTS) diff --git a/app/demo-vof-app/demo-vof-app.cc b/app/demo-vof-app/demo-vof-app.cc index 4b0e281..a4421a8 100644 --- a/app/demo-vof-app/demo-vof-app.cc +++ b/app/demo-vof-app/demo-vof-app.cc @@ -147,6 +147,7 @@ void run (std::shared_ptr inputMesh, std::vector offsets(ncells, 0); for (int icell = 0; icell < ncells - 1; icell++) offsets[icell + 1] = offsets[icell] + cell_num_mats[icell]; + for (int icell = 0; icell < ncells; icell++) { if (cell_num_mats[icell] == 1) { assert(cellmatpoly_list[icell] == nullptr); @@ -160,6 +161,7 @@ void run (std::shared_ptr inputMesh, cellmatpoly_list[icell] = cmp_ptr; } } + write_to_gmv(cellmatpoly_list, out_gmv_fname); } @@ -189,9 +191,10 @@ int main(int argc, char** argv) { Jali::MeshFactory mesh_factory(comm); mesh_factory.framework(Jali::MSTK); + if (dim == 2) { - mesh_factory.included_entities({Jali::Entity_kind::EDGE}); + mesh_factory.included_entities(Jali::Entity_kind::EDGE); std::shared_ptr mesh = mesh_factory(argv[4]); run<2>(mesh, isconvex, in_data_fname, out_gmv_fname); diff --git a/app/demo-xmof-app/CMakeLists.txt b/app/demo-xmof-app/CMakeLists.txt index db0bfe1..1a6672e 100644 --- a/app/demo-xmof-app/CMakeLists.txt +++ b/app/demo-xmof-app/CMakeLists.txt @@ -8,37 +8,5 @@ # demo-xmof-app - uses 2D mesh from Jali #------------------------------------------------------------------------------- add_executable(demo-xmof-app demo-xmof-app.cc) -target_link_libraries(demo-xmof-app ${XMOF2D_LIBRARIES} ${Jali_LIBRARIES} ${Jali_TPL_LIBRARIES} - ${MPI_CXX_LIBRARIES} ${EXTRA_LIBS}) +target_link_libraries(demo-xmof-app tangram) -if(ENABLE_MPI) - if(MPI_CXX_COMPILE_FLAGS) - set_target_properties(demo-xmof-app PROPERTIES - COMPILE_FLAGS "${MPI_CXX_COMPILE_FLAGS}") - endif(MPI_CXX_COMPILE_FLAGS) - - if(MPI_CXX_LINK_FLAGS) - set_target_properties(demo-xmof-app PROPERTIES - LINK_FLAGS "${MPI_CXX_LINK_FLAGS}") - endif(MPI_CXX_LINK_FLAGS) -endif(ENABLE_MPI) - -#TCMalloc option -set(ENABLE_TCMALLOC TRUE CACHE BOOL "Use TCMalloc") -if(ENABLE_TCMALLOC) - set(TCMALLOC_LIB "${HOME}" CACHE STRING "Set the TCMalloc library") - target_link_libraries(demo-xmof-app ${TCMALLOC_LIB}) -endif(ENABLE_TCMALLOC) - -#------------------------------------------------------------------------------- -# Other libraries -#------------------------------------------------------------------------------- -# taget_link_libraries(tangramapp ${WONTON_LIBS}) -# include_directories(${WONTON_INCLUDE_DIRS}) - -#------------------------------------------------------------------------------- -# Testing -#------------------------------------------------------------------------------- -# if (ENABLE_APP_TESTS) -# add_subdirectory(test) -# endif (ENABLE_APP_TESTS) diff --git a/app/demo-xmof-app/demo-xmof-app.cc b/app/demo-xmof-app/demo-xmof-app.cc index 449229b..88893f9 100644 --- a/app/demo-xmof-app/demo-xmof-app.cc +++ b/app/demo-xmof-app/demo-xmof-app.cc @@ -38,6 +38,7 @@ void read_mat_data(const Mesh_Wrapper& Mesh, cell_mat_ids.clear(); cell_mat_volfracs.clear(); cell_mat_centroids.clear(); + std::ifstream os(mesh_data_fname.c_str(), std::ifstream::binary); if (!os.good()) { std::ostringstream os; @@ -45,16 +46,19 @@ void read_mat_data(const Mesh_Wrapper& Mesh, " for binary input" << std::endl; throw XMOF2D::Exception(os.str()); } + int nrank_cells = Mesh.num_owned_cells() + Mesh.num_ghost_cells(); cell_num_mats.resize(nrank_cells); std::vector> on_rank_mat_ids(nrank_cells); std::vector> on_rank_mat_volfracs(nrank_cells); std::vector> on_rank_mat_centroids(nrank_cells); + int data_dim; os.read(reinterpret_cast(&data_dim), sizeof(int)); assert(data_dim == 2); int ncells; os.read(reinterpret_cast(&ncells), sizeof(int)); + std::vector rank_cells_gid(nrank_cells); for (int irc = 0; irc < nrank_cells; irc++) rank_cells_gid[irc] = Mesh.get_global_id(irc, Tangram::Entity_kind::CELL); @@ -80,6 +84,7 @@ void read_mat_data(const Mesh_Wrapper& Mesh, on_rank_mat_centroids[on_rank_id].push_back(cur_cell_cen); } } + for (int im = 0; im < mesh_cell_num_mats[icell]; im++) { int imat; os.read(reinterpret_cast(&imat), sizeof(int)); @@ -124,6 +129,7 @@ void read_mat_data(const Mesh_Wrapper& Mesh, int main(int argc, char** argv) { MPI_Init(&argc, &argv); MPI_Comm comm = MPI_COMM_WORLD; + if (argc != 3) { std::ostringstream os; os << std::endl << @@ -149,6 +155,7 @@ int main(int argc, char** argv) { if (path_end != std::string::npos) out_gmv_fname = out_gmv_fname.substr(path_end + 1); out_gmv_fname += "_post_xmof_rank" + std::to_string(comm_rank) + ".gmv"; + Jali::MeshFactory mesh_factory(comm); mesh_factory.framework(Jali::MSTK); mesh_factory.included_entities({Jali::Entity_kind::EDGE, Jali::Entity_kind::FACE}); @@ -191,12 +198,12 @@ int main(int argc, char** argv) { const Tangram::CellMatPoly<2>* cell_mat_poly_ptr = cellmatpoly_list[icell].get(); if (cell_mat_poly_ptr) { int cur_npolys = cell_mat_poly_ptr->num_matpolys(); - if (cur_npolys > ncells_with_nmats.size()) { + if (unsigned(cur_npolys) > ncells_with_nmats.size()) { ncells_with_nmats.resize(cur_npolys, 0); imaxcells.resize(1); imaxcells[0] = icell; } - else if (cur_npolys == ncells_with_nmats.size()) + else if (unsigned(cur_npolys) == ncells_with_nmats.size()) imaxcells.push_back(icell); ncells_with_nmats[cur_npolys - 1]++; @@ -209,8 +216,8 @@ int main(int argc, char** argv) { MPI_COMM_WORLD); ncells_with_nmats.resize(top_max_nmats, 0); - int* ncells_per_rank = NULL; - int* nowned_cells_per_rank = NULL; + int* ncells_per_rank = nullptr; + int* nowned_cells_per_rank = nullptr; if (comm_rank == 0) { ncells_per_rank = new int [world_size]; nowned_cells_per_rank = new int [world_size]; @@ -239,13 +246,16 @@ int main(int argc, char** argv) { for (int irank = 0; irank < world_size; irank++) std::cout << cellmat_stats[0][irank] << " "; std::cout << std::endl; - for (int inm = 0; inm < ncells_with_nmats.size() - 1; inm++) { + + int const extent = static_cast(ncells_with_nmats.size() - 1); + for (int inm = 0; inm < extent; inm++) { std::cout << "Number of CellMatPoly's with " << inm + 2 << " materials created on each rank: "; for (int irank = 0; irank < world_size; irank++) std::cout << cellmat_stats[inm + 1][irank] << " "; std::cout << std::endl; } std::cout << std::endl; + delete ncells_per_rank; delete nowned_cells_per_rank; for (int inm = 0; inm < top_max_nmats; inm++) @@ -254,12 +264,13 @@ int main(int argc, char** argv) { if ( (world_size == 1) && (ncells_with_nmats.size() > 1) && (imaxcells.size() <= 25) ) { std::cout << "Cells with max number of material polygons are:" << std::endl; std::cout << "\t#CellID: [MaterialID, MaterialVolumeFraction] [..., ...]" << std::endl; - for (int imc = 0; imc < imaxcells.size(); imc++) { - double volume = mesh_wrapper.cell_volume(imaxcells[imc]); - std::cout << "\t#" << imaxcells[imc] << ": "; - for (int imp = 0; imp < ncells_with_nmats.size(); imp++) { + for (int imaxcell : imaxcells) { + double volume = mesh_wrapper.cell_volume(imaxcell); + std::cout << "\t#" << imaxcell << ": "; + int const extent = ncells_with_nmats.size(); + for (int imp = 0; imp < extent; imp++) { const Tangram::CellMatPoly<2>* cell_mat_poly = - cellmatpoly_list[imaxcells[imc]].get(); + cellmatpoly_list[imaxcell].get(); std::cout << "[" << cell_mat_poly->matpoly_matid(imp) << ", " << cell_mat_poly->matpoly_volume(imp)/volume << "]\t"; } @@ -267,9 +278,11 @@ int main(int argc, char** argv) { } std::cout << std::endl; } + int nmats = *std::max_element(cell_mat_ids.begin(), cell_mat_ids.end()) + 1; Tangram::write_to_gmv(mesh_wrapper, nmats, cell_num_mats, cell_mat_ids, cellmatpoly_list, out_gmv_fname); std::cout << "Resulting material polygons were written to " << out_gmv_fname << std::endl; + MPI_Finalize(); } diff --git a/app/demo_rotor3d/CMakeLists.txt b/app/demo_rotor3d/CMakeLists.txt index 39255ba..d7f7314 100644 --- a/app/demo_rotor3d/CMakeLists.txt +++ b/app/demo_rotor3d/CMakeLists.txt @@ -8,35 +8,5 @@ # Rotor demo for SimpleMesh #------------------------------------------------------------------------------- add_executable(demo_rotor demo_rotor.cc) -target_link_libraries(demo_rotor wonton ${MPI_CXX_LIBRARIES} ${EXTRA_LIBS}) +target_link_libraries(demo_rotor tangram) -if(ENABLE_MPI) - if(MPI_CXX_COMPILE_FLAGS) - set_target_properties(demo_rotor PROPERTIES - COMPILE_FLAGS "${MPI_CXX_COMPILE_FLAGS}") - endif(MPI_CXX_COMPILE_FLAGS) - - if(MPI_CXX_LINK_FLAGS) - set_target_properties(demo_rotor PROPERTIES - LINK_FLAGS "${MPI_CXX_LINK_FLAGS}") - endif(MPI_CXX_LINK_FLAGS) -endif(ENABLE_MPI) - -#TCMalloc option -set(ENABLE_TCMALLOC TRUE CACHE BOOL "Use TCMalloc") -if(ENABLE_TCMALLOC) - set(TCMALLOC_LIB "${HOME}" CACHE STRING "Set the TCMalloc library") - target_link_libraries(demo_rotor ${TCMALLOC_LIB}) - -endif(ENABLE_TCMALLOC) - -#------------------------------------------------------------------------------- -# Other libraries -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# Testing -#------------------------------------------------------------------------------- -#if (ENABLE_APP_TESTS) -# add_subdirectory(test) -#endif (ENABLE_APP_TESTS) diff --git a/app/demo_rotor3d/demo_rotor.cc b/app/demo_rotor3d/demo_rotor.cc index 3752e4a..3509c43 100644 --- a/app/demo_rotor3d/demo_rotor.cc +++ b/app/demo_rotor3d/demo_rotor.cc @@ -18,12 +18,12 @@ #include #include -#ifdef ENABLE_MPI +#ifdef WONTON_ENABLE_MPI #include "mpi.h" #endif -#include "wonton/wonton/mesh/simple/simple_mesh.h" -#include "wonton/wonton/mesh/simple/simple_mesh_wrapper.h" +#include "wonton/mesh/simple/simple_mesh.h" +#include "wonton/mesh/simple/simple_mesh_wrapper.h" #include "tangram/support/tangram.h" #include "tangram/driver/driver.h" @@ -45,7 +45,7 @@ reference poly's, and outputs reconstruction results to gmv files. */ int main(int argc, char** argv) { -#ifdef ENABLE_MPI +#ifdef WONTON_ENABLE_MPI MPI_Init(&argc, &argv); MPI_Comm comm = MPI_COMM_WORLD; @@ -131,7 +131,7 @@ int main(int argc, char** argv) { std::cout << "Time taken to generate reference material polyhedra and their moments -> " << seconds_taken << " (s)" << std::endl; - int nmesh_material_IDs = (int) mesh_material_IDs.size(); + int nmesh_material_IDs = mesh_material_IDs.size(); std::vector offsets(ncells, 0); for (int icell = 0; icell < ncells - 1; icell++) offsets[icell + 1] = offsets[icell] + cell_num_mats[icell]; @@ -180,7 +180,9 @@ int main(int argc, char** argv) { std::endl << " " << nmesh_material_IDs << " materials," << std::endl << " " << ncells_with_xmats[0] << " single-material cells," << std::endl << " " << nmmcells << " multi-material cells:" << std::endl; - for (int inm = 0; inm < ncells_with_xmats.size() - 1; inm++) + + int count_cells_with_xmats = ncells_with_xmats.size(); + for (int inm = 0; inm < count_cells_with_xmats - 1; inm++) std::cout << " Number of cells with " << inm + 2 << " materials -> " << ncells_with_xmats[inm + 1] << std::endl; @@ -289,14 +291,16 @@ int main(int argc, char** argv) { total_mat_sym_diff_vol[imat]/mmcells_material_volumes[imat]; std::cout << std::endl; - for (int mc = 0; mc < ncells_with_xmats.size() - 1; mc++) + for (int mc = 0; mc < count_cells_with_xmats - 1; mc++) { if (xmat_cells_material_volumes[imat][mc] != 0.0) { - std::cout << " over all " << mc + 2 << "-material cells:" << std::endl << + std::cout << " over all " << mc + 2 << "-material cells:" << std::endl << " Aggregate vol = " << xmat_cells_material_volumes[imat][mc] << "," << std::endl << - " aggregate sym.diff.vol = " << xmat_cells_mat_sym_diff_vol[imat][mc] << "," << std::endl << - " relative sym.diff.vol = " << - xmat_cells_mat_sym_diff_vol[imat][mc]/xmat_cells_material_volumes[imat][mc] << std::endl; + " aggregate sym.diff.vol = " << xmat_cells_mat_sym_diff_vol[imat][mc] << "," << std::endl << + " relative sym.diff.vol = " << + xmat_cells_mat_sym_diff_vol[imat][mc]/xmat_cells_material_volumes[imat][mc] << std::endl; } + } + std::cout << std::endl; } std::cout << std::endl; @@ -333,7 +337,7 @@ int main(int argc, char** argv) { ref_matpoly_list[icell] = std::make_shared< Tangram::CellMatPoly<3> >(icell); for (int icmat = 0; icmat < cell_num_mats[icell]; icmat++) { - int nmp = (int) reference_mat_polys[icell][icmat].size(); + int nmp = reference_mat_polys[icell][icmat].size(); for (int imp = 0; imp < nmp; imp++) { std::vector< Tangram::MatPoly<3> > cur_matpoly; Tangram::r3dpoly_to_matpolys(reference_mat_polys[icell][icmat][imp], @@ -356,7 +360,7 @@ int main(int argc, char** argv) { std::cout << "Time taken to write reference material polyhedra -> " << seconds_taken << " (s)" << std::endl; -#ifdef ENABLE_MPI +#ifdef WONTON_ENABLE_MPI MPI_Finalize(); #endif diff --git a/app/multidef/CMakeLists.txt b/app/multidef/CMakeLists.txt index 5bc68c2..06d5900 100644 --- a/app/multidef/CMakeLists.txt +++ b/app/multidef/CMakeLists.txt @@ -5,5 +5,5 @@ Please see the license file at the root of this repository, or at: ]] add_executable(tangram_multidef_check main.cc dummy.cc) -target_link_libraries(tangram_multidef_check wonton ${LAPACKE_LIBRARIES}) +target_link_libraries(tangram_multidef_check tangram) diff --git a/app/tangramapp/CMakeLists.txt b/app/tangramapp/CMakeLists.txt index d70b66f..c3671de 100644 --- a/app/tangramapp/CMakeLists.txt +++ b/app/tangramapp/CMakeLists.txt @@ -8,36 +8,5 @@ # tangramapp #------------------------------------------------------------------------------- add_executable(tangramapp tangramapp.cc) -target_link_libraries(tangramapp ${MPI_CXX_LIBRARIES} ${EXTRA_LIBS}) +target_link_libraries(tangramapp tangram) -if(ENABLE_MPI) - if(MPI_CXX_COMPILE_FLAGS) - set_target_properties(tangramapp PROPERTIES - COMPILE_FLAGS "${MPI_CXX_COMPILE_FLAGS}") - endif(MPI_CXX_COMPILE_FLAGS) - - if(MPI_CXX_LINK_FLAGS) - set_target_properties(tangramapp PROPERTIES - LINK_FLAGS "${MPI_CXX_LINK_FLAGS}") - endif(MPI_CXX_LINK_FLAGS) -endif(ENABLE_MPI) - -#TCMalloc option -set(ENABLE_TCMALLOC TRUE CACHE BOOL "Use TCMalloc") -if(ENABLE_TCMALLOC) - set(TCMALLOC_LIB "${HOME}" CACHE STRING "Set the TCMalloc library") - target_link_libraries(tangramapp ${TCMALLOC_LIB}) -endif(ENABLE_TCMALLOC) - -#------------------------------------------------------------------------------- -# Other libraries -#------------------------------------------------------------------------------- -# taget_link_libraries(tangramapp ${WONTON_LIBS}) -# include_directories(${WONTON_INCLUDE_DIRS}) - -#------------------------------------------------------------------------------- -# Testing -#------------------------------------------------------------------------------- -# if (ENABLE_APP_TESTS) -# add_subdirectory(test) -# endif (ENABLE_APP_TESTS) diff --git a/app/test_mof/CMakeLists.txt b/app/test_mof/CMakeLists.txt index 132d220..99e71db 100644 --- a/app/test_mof/CMakeLists.txt +++ b/app/test_mof/CMakeLists.txt @@ -8,56 +8,13 @@ # test_mof_3d - uses 3D mesh from SimpleMesh or Jali #------------------------------------------------------------------------------- add_executable(test_mof_3d test_mof_3d.cc) -target_link_libraries(test_mof_3d wonton ${Jali_LIBRARIES} ${Jali_TPL_LIBRARIES} - ${MPI_CXX_LIBRARIES} ${EXTRA_LIBS}) - -if(ENABLE_MPI) - if(MPI_CXX_COMPILE_FLAGS) - set_target_properties(test_mof_3d PROPERTIES - COMPILE_FLAGS "${MPI_CXX_COMPILE_FLAGS}") - endif(MPI_CXX_COMPILE_FLAGS) - - if(MPI_CXX_LINK_FLAGS) - set_target_properties(test_mof_3d PROPERTIES - LINK_FLAGS "${MPI_CXX_LINK_FLAGS}") - endif(MPI_CXX_LINK_FLAGS) -endif(ENABLE_MPI) - -#TCMalloc option -set(ENABLE_TCMALLOC TRUE CACHE BOOL "Use TCMalloc") -if(ENABLE_TCMALLOC) - set(TCMALLOC_LIB "${HOME}" CACHE STRING "Set the TCMalloc library") - target_link_libraries(test_mof_3d ${TCMALLOC_LIB}) -endif(ENABLE_TCMALLOC) +target_link_libraries(test_mof_3d tangram) #------------------------------------------------------------------------------- # test_mof_2d - uses 2D mesh from SimpleMesh or Jali #------------------------------------------------------------------------------- add_executable(test_mof_2d test_mof_2d.cc) -target_link_libraries(test_mof_2d wonton ${Jali_LIBRARIES} ${Jali_TPL_LIBRARIES} - ${MPI_CXX_LIBRARIES} ${EXTRA_LIBS}) - -if(ENABLE_MPI) - if(MPI_CXX_COMPILE_FLAGS) - set_target_properties(test_mof_2d PROPERTIES - COMPILE_FLAGS "${MPI_CXX_COMPILE_FLAGS}") - endif(MPI_CXX_COMPILE_FLAGS) - - if(MPI_CXX_LINK_FLAGS) - set_target_properties(test_mof_2d PROPERTIES - LINK_FLAGS "${MPI_CXX_LINK_FLAGS}") - endif(MPI_CXX_LINK_FLAGS) -endif(ENABLE_MPI) - -#TCMalloc option -set(ENABLE_TCMALLOC TRUE CACHE BOOL "Use TCMalloc") -if(ENABLE_TCMALLOC) - set(TCMALLOC_LIB "${HOME}" CACHE STRING "Set the TCMalloc library") - target_link_libraries(test_mof_2d ${TCMALLOC_LIB}) -endif(ENABLE_TCMALLOC) -#------------------------------------------------------------------------------- -# Other libraries -#------------------------------------------------------------------------------- +target_link_libraries(test_mof_2d tangram) #------------------------------------------------------------------------------- # Testing diff --git a/app/test_mof/test/CMakeLists.txt b/app/test_mof/test/CMakeLists.txt index 1d7bf71..b3ee34a 100644 --- a/app/test_mof/test/CMakeLists.txt +++ b/app/test_mof/test/CMakeLists.txt @@ -6,11 +6,11 @@ https://github.com/laristra/tangram/blob/master/LICENSE message(STATUS "Adding test_mof_3d test") # this app should be run in serial -if(ENABLE_MPI) +if(WONTON_ENABLE_MPI) set(RUN_COMMAND "mpirun -np 1") else() set(RUN_COMMAND "") -endif(ENABLE_MPI) +endif(WONTON_ENABLE_MPI) # 3D TEST macro(ADD_MOF_3D_TEST TEST_NUM) @@ -29,16 +29,16 @@ macro(ADD_MOF_3D_TEST TEST_NUM) PROPERTY PROCESSORS 1) endmacro(ADD_MOF_3D_TEST) -if (Jali_DIR) +if (WONTON_ENABLE_Jali) ADD_MOF_3D_TEST(2) ADD_MOF_3D_TEST(3) file(COPY cubic27.exo DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(COPY voronoi95.exo DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -else(Jali_DIR) +else(WONTON_ENABLE_Jali) ADD_MOF_3D_TEST(0) ADD_MOF_3D_TEST(1) -endif(Jali_DIR) +endif(WONTON_ENABLE_Jali) # 2D TEST macro(ADD_MOF_2D_TEST TEST_NUM) @@ -57,11 +57,11 @@ macro(ADD_MOF_2D_TEST TEST_NUM) PROPERTY PROCESSORS 1) endmacro(ADD_MOF_2D_TEST) -if (Jali_DIR) +if (WONTON_ENABLE_Jali) ADD_MOF_2D_TEST(2) file(COPY voronoi124.exo DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -else(Jali_DIR) +else(WONTON_ENABLE_Jali) ADD_MOF_2D_TEST(0) ADD_MOF_2D_TEST(1) -endif(Jali_DIR) +endif(WONTON_ENABLE_Jali) diff --git a/app/test_mof/test_mof_2d.cc b/app/test_mof/test_mof_2d.cc index 19bed4e..5c31eee 100644 --- a/app/test_mof/test_mof_2d.cc +++ b/app/test_mof/test_mof_2d.cc @@ -15,12 +15,12 @@ #include #include -#include "tangram/support/tangram.h" // TANGRAM_ENABLE_MPI defined in this file +#include "tangram/support/tangram.h" // WONTON_ENABLE_MPI defined in this file -#ifdef TANGRAM_ENABLE_MPI +#ifdef WONTON_ENABLE_MPI #include "mpi.h" #endif -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) #include "Mesh.hh" #include "MeshFactory.hh" #include "wonton/mesh/jali/jali_mesh_wrapper.h" @@ -58,7 +58,7 @@ const std::vector< Tangram::Point2 > material_interface_points = { }; int main(int argc, char** argv) { -#ifdef TANGRAM_ENABLE_MPI +#ifdef WONTON_ENABLE_MPI MPI_Init(&argc, &argv); MPI_Comm comm = MPI_COMM_WORLD; @@ -71,7 +71,7 @@ int main(int argc, char** argv) { assert((material_interface_normals.size() == material_interface_points.size()) && (mesh_materials.size() == material_interface_normals.size() + 1)); -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) if (argc != 3) { std::ostringstream os; os << std::endl << @@ -101,7 +101,7 @@ int main(int argc, char** argv) { material_interfaces[iplane].normal); } -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) std::string mesh_name = argv[2]; mesh_name.resize(mesh_name.size() - 4); #else @@ -119,10 +119,10 @@ int main(int argc, char** argv) { std::string out_gmv_fname = mesh_name + "_res_matpolys.gmv"; #endif -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) Jali::MeshFactory mesh_factory(comm); mesh_factory.framework(Jali::MSTK); - mesh_factory.included_entities({Jali::Entity_kind::EDGE}); + mesh_factory.included_entities(Jali::Entity_kind::EDGE); std::shared_ptr mesh = mesh_factory(argv[2]); assert(mesh != nullptr); @@ -149,7 +149,7 @@ int main(int argc, char** argv) { std::vector cell_mat_centroids; std::vector< std::vector< std::vector > > reference_mat_polys; -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) get_material_moments(mesh_wrapper, material_interfaces, mesh_materials, cell_num_mats, cell_mat_ids, cell_mat_volfracs, cell_mat_centroids, vol_tol, dst_tol, decompose_cells, &reference_mat_polys); @@ -201,7 +201,7 @@ int main(int argc, char** argv) { #endif // Build the driver -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) Tangram::Driver mof_driver(mesh_wrapper, ims_tols, !decompose_cells); @@ -266,6 +266,7 @@ int main(int argc, char** argv) { if (decompose_cells) res_out_fname += "_decomposed"; res_out_fname += ".txt"; + std::ofstream fout(res_out_fname); fout << std::scientific; fout.precision(17); @@ -278,7 +279,7 @@ int main(int argc, char** argv) { fout.close(); std::cout << std::endl << "Stats for "; -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) std::cout << "computational mesh " << mesh_name; #else std::cout << "structured " << nx << "x" << ny << @@ -291,11 +292,14 @@ std::cout << std::endl << "Stats for "; "For each material over all multi-material cells:" << std::endl; for (int imat = 0; imat < nmesh_materials; imat++) { - int imaxcell; - double max_sym_diff_mat_vol; + + int imaxcell = 0; + double max_sym_diff_mat_vol = 0.; + if (max_mat_sym_diff_icell[imat] != -1) { imaxcell = max_mat_sym_diff_icell[imat]; - int cell_matid = std::distance(cell_mat_ids.begin() + offsets[imaxcell], + int cell_matid = + std::distance(cell_mat_ids.begin() + offsets[imaxcell], std::find(cell_mat_ids.begin() + offsets[imaxcell], cell_mat_ids.begin() + offsets[imaxcell] + cell_num_mats[imaxcell], mesh_materials[imat])); @@ -303,13 +307,17 @@ std::cout << std::endl << "Stats for "; max_sym_diff_mat_vol = cell_mat_volfracs[offsets[imaxcell] + cell_matid]* mesh_wrapper.cell_volume(imaxcell); } + std::cout << " Material ID " << mesh_materials[imat] << " -> " << std::endl << " Aggregate vol = " << mmcells_material_volumes[imat] << "," << std::endl << " aggregate sym.diff.vol = " << total_mat_sym_diff_vol[imat]; + if (total_mat_sym_diff_vol[imat] >= vol_tol) std::cout << "," << std::endl << " relative sym.diff.vol = " << total_mat_sym_diff_vol[imat]/mmcells_material_volumes[imat]; + std::cout << std::endl; + if (max_mat_sym_diff_icell[imat] != -1) std::cout << " Max sym.diff.vol in cell " << imaxcell << ":" << std::endl << " cell material vol = " << max_sym_diff_mat_vol << "," << std::endl << @@ -337,7 +345,7 @@ std::cout << std::endl << "Stats for "; write_to_gmv(cellmatpoly_list, out_gmv_fname); #endif -#ifdef TANGRAM_ENABLE_MPI +#ifdef WONTON_ENABLE_MPI MPI_Finalize(); #endif diff --git a/app/test_mof/test_mof_3d.cc b/app/test_mof/test_mof_3d.cc index ffb0add..04d97d1 100644 --- a/app/test_mof/test_mof_3d.cc +++ b/app/test_mof/test_mof_3d.cc @@ -15,12 +15,12 @@ #include #include -#include "tangram/support/tangram.h" // TANGRAM_ENABLE_MPI defined in this file +#include "tangram/support/tangram.h" // WONTON_ENABLE_MPI defined in this file -#ifdef TANGRAM_ENABLE_MPI +#ifdef WONTON_ENABLE_MPI #include "mpi.h" #endif -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) #include "Mesh.hh" #include "MeshFactory.hh" #include "wonton/mesh/jali/jali_mesh_wrapper.h" @@ -60,7 +60,7 @@ const std::vector< Tangram::Point3 > material_interface_points = { int main(int argc, char** argv) { -#ifdef TANGRAM_ENABLE_MPI +#ifdef WONTON_ENABLE_MPI MPI_Init(&argc, &argv); MPI_Comm comm = MPI_COMM_WORLD; @@ -73,7 +73,7 @@ int main(int argc, char** argv) { assert((material_interface_normals.size() == material_interface_points.size()) && (mesh_materials.size() == material_interface_normals.size() + 1)); -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) if (argc != 3) { std::ostringstream os; os << std::endl << @@ -103,7 +103,7 @@ int main(int argc, char** argv) { material_interfaces[iplane].normal); } -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) std::string mesh_name = argv[2]; mesh_name.resize(mesh_name.size() - 4); #else @@ -121,7 +121,7 @@ int main(int argc, char** argv) { std::string out_gmv_fname = mesh_name + "_res_matpolys.gmv"; #endif -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) Jali::MeshFactory mesh_factory(comm); mesh_factory.framework(Jali::MSTK); mesh_factory.included_entities({Jali::Entity_kind::EDGE, Jali::Entity_kind::FACE}); @@ -151,7 +151,7 @@ int main(int argc, char** argv) { std::vector cell_mat_centroids; std::vector< std::vector< std::vector > > reference_mat_polys; -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) get_material_moments(mesh_wrapper, material_interfaces, mesh_materials, cell_num_mats, cell_mat_ids, cell_mat_volfracs, cell_mat_centroids, vol_tol, dst_tol, decompose_cells, &reference_mat_polys); @@ -207,7 +207,7 @@ int main(int argc, char** argv) { #endif // Build the driver -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) Tangram::Driver mof_driver(mesh_wrapper, ims_tols, !decompose_cells); @@ -272,6 +272,7 @@ int main(int argc, char** argv) { if (decompose_cells) res_out_fname += "_decomposed"; res_out_fname += ".txt"; + std::ofstream fout(res_out_fname); fout << std::scientific; fout.precision(17); @@ -284,7 +285,7 @@ int main(int argc, char** argv) { fout.close(); std::cout << std::endl << "Stats for "; -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) std::cout << "computational mesh " << mesh_name; #else std::cout << "structured " << nx << "x" << ny << @@ -297,11 +298,14 @@ std::cout << std::endl << "Stats for "; "For each material over all multi-material cells:" << std::endl; for (int imat = 0; imat < nmesh_materials; imat++) { - int imaxcell; - double max_sym_diff_mat_vol; + + int imaxcell = 0; + double max_sym_diff_mat_vol = 0.; + if (max_mat_sym_diff_icell[imat] != -1) { imaxcell = max_mat_sym_diff_icell[imat]; - int cell_matid = std::distance(cell_mat_ids.begin() + offsets[imaxcell], + int cell_matid = + std::distance(cell_mat_ids.begin() + offsets[imaxcell], std::find(cell_mat_ids.begin() + offsets[imaxcell], cell_mat_ids.begin() + offsets[imaxcell] + cell_num_mats[imaxcell], mesh_materials[imat])); @@ -309,13 +313,17 @@ std::cout << std::endl << "Stats for "; max_sym_diff_mat_vol = cell_mat_volfracs[offsets[imaxcell] + cell_matid]* mesh_wrapper.cell_volume(imaxcell); } + std::cout << " Material ID " << mesh_materials[imat] << " -> " << std::endl << " Aggregate vol = " << mmcells_material_volumes[imat] << "," << std::endl << " aggregate sym.diff.vol = " << total_mat_sym_diff_vol[imat]; + if (total_mat_sym_diff_vol[imat] >= vol_tol) std::cout << "," << std::endl << " relative sym.diff.vol = " << total_mat_sym_diff_vol[imat]/mmcells_material_volumes[imat]; + std::cout << std::endl; + if (max_mat_sym_diff_icell[imat] != -1) std::cout << " Max sym.diff.vol in cell " << imaxcell << ":" << std::endl << " cell material vol = " << max_sym_diff_mat_vol << "," << std::endl << @@ -329,7 +337,7 @@ std::cout << std::endl << "Stats for "; cellmatpoly_list, out_gmv_fname); #endif -#ifdef TANGRAM_ENABLE_MPI +#ifdef WONTON_ENABLE_MPI MPI_Finalize(); #endif diff --git a/app/test_slic/CMakeLists.txt b/app/test_slic/CMakeLists.txt index 77d62f5..d4155eb 100644 --- a/app/test_slic/CMakeLists.txt +++ b/app/test_slic/CMakeLists.txt @@ -8,59 +8,15 @@ # test_slic_2d - uses 2D mesh from SimpleMesh or Jali #------------------------------------------------------------------------------- add_executable(test_slic_2d test_slic_2d.cc) -target_link_libraries(test_slic_2d wonton ${Jali_TPL_LIBRARIES}) +target_link_libraries(test_slic_2d tangram) -if(Jali_DIR) - target_link_libraries(test_slic_2d wonton ${Jali_LIBRARIES} ${Jali_TPL_LIBRARIES}) -endif(Jali_DIR) - -if(ENABLE_MPI) - target_link_libraries(test_slic_2d wonton ${MPI_CXX_LIBRARIES} ${EXTRA_LIBS}) - if(MPI_CXX_COMPILE_FLAGS) - set_target_properties(test_slic_2d PROPERTIES - COMPILE_FLAGS "${MPI_CXX_COMPILE_FLAGS}") - endif(MPI_CXX_COMPILE_FLAGS) - - if(MPI_CXX_LINK_FLAGS) - set_target_properties(test_slic_2d PROPERTIES - LINK_FLAGS "${MPI_CXX_LINK_FLAGS}") - endif(MPI_CXX_LINK_FLAGS) -endif(ENABLE_MPI) - -#TCMalloc option -set(ENABLE_TCMALLOC TRUE CACHE BOOL "Use TCMalloc") -if(ENABLE_TCMALLOC) - set(TCMALLOC_LIB "${HOME}" CACHE STRING "Set the TCMalloc library") - target_link_libraries(test_slic_2d ${TCMALLOC_LIB}) -endif(ENABLE_TCMALLOC) #------------------------------------------------------------------------------- # test_slic_3d - uses 3D mesh from SimpleMesh or Jali #------------------------------------------------------------------------------- add_executable(test_slic_3d test_slic_3d.cc) -target_link_libraries(test_slic_3d wonton ${Jali_TPL_LIBRARIES}) - -if(Jali_DIR) - target_link_libraries(test_slic_3d wonton ${Jali_LIBRARIES} ${Jali_TPL_LIBRARIES}) -endif(Jali_DIR) - -if(ENABLE_MPI) - target_link_libraries(test_slic_3d wonton ${MPI_CXX_LIBRARIES} ${EXTRA_LIBS}) - if(MPI_CXX_COMPILE_FLAGS) - set_target_properties(test_slic_3d PROPERTIES - COMPILE_FLAGS "${MPI_CXX_COMPILE_FLAGS}") - endif(MPI_CXX_COMPILE_FLAGS) - - if(MPI_CXX_LINK_FLAGS) - set_target_properties(test_slic_3d PROPERTIES - LINK_FLAGS "${MPI_CXX_LINK_FLAGS}") - endif(MPI_CXX_LINK_FLAGS) -endif(ENABLE_MPI) +target_link_libraries(test_slic_3d tangram) -#TCMalloc option -if(ENABLE_TCMALLOC) - target_link_libraries(test_slic_3d ${TCMALLOC_LIB}) -endif(ENABLE_TCMALLOC) #------------------------------------------------------------------------------- # Testing diff --git a/app/test_slic/test/CMakeLists.txt b/app/test_slic/test/CMakeLists.txt index 08087e4..0cb88db 100644 --- a/app/test_slic/test/CMakeLists.txt +++ b/app/test_slic/test/CMakeLists.txt @@ -6,11 +6,11 @@ https://github.com/laristra/tangram/blob/master/LICENSE message(STATUS "Adding test_slic_3d test") # this app should be run in serial -if(ENABLE_MPI) +if(WONTON_ENABLE_MPI) set(RUN_COMMAND "mpirun -np 1") else() set(RUN_COMMAND "") -endif(ENABLE_MPI) +endif(WONTON_ENABLE_MPI) # 3D TEST @@ -30,16 +30,16 @@ macro(ADD_SLIC_3D_TEST TEST_NUM) PROPERTY PROCESSORS 1) endmacro(ADD_SLIC_3D_TEST) -if (Jali_DIR) +if (WONTON_ENABLE_Jali) ADD_SLIC_3D_TEST(2) ADD_SLIC_3D_TEST(3) file(COPY cubic27.exo DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(COPY voronoi95.exo DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -else(Jali_DIR) +else(WONTON_ENABLE_Jali) ADD_SLIC_3D_TEST(0) ADD_SLIC_3D_TEST(1) -endif(Jali_DIR) +endif(WONTON_ENABLE_Jali) # 2D TEST macro(ADD_SLIC_2D_TEST TEST_NUM) @@ -58,10 +58,10 @@ macro(ADD_SLIC_2D_TEST TEST_NUM) PROPERTY PROCESSORS 1) endmacro(ADD_SLIC_2D_TEST) -if (Jali_DIR) +if (WONTON_ENABLE_Jali) ADD_SLIC_2D_TEST(2) file(COPY voronoi124.exo DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -else(Jali_DIR) +else(WONTON_ENABLE_Jali) ADD_SLIC_2D_TEST(0) ADD_SLIC_2D_TEST(1) -endif(Jali_DIR) +endif(WONTON_ENABLE_Jali) diff --git a/app/test_slic/test_slic_2d.cc b/app/test_slic/test_slic_2d.cc index ae3cca0..ceadb92 100644 --- a/app/test_slic/test_slic_2d.cc +++ b/app/test_slic/test_slic_2d.cc @@ -4,7 +4,7 @@ https://github.com/laristra/tangram/blob/master/LICENSE */ -#include +#include #include #include @@ -15,12 +15,12 @@ #include #include -#include "tangram/support/tangram.h" // TANGRAM_ENABLE_MPI defined in this file +#include "tangram/support/tangram.h" // WONTON_ENABLE_MPI defined in this file -#ifdef TANGRAM_ENABLE_MPI +#ifdef WONTON_ENABLE_MPI #include "mpi.h" #endif -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) #include "Mesh.hh" #include "MeshFactory.hh" #include "wonton/mesh/jali/jali_mesh_wrapper.h" @@ -58,7 +58,7 @@ const std::vector< Tangram::Point2 > material_interface_points = { }; int main(int argc, char** argv) { -#ifdef TANGRAM_ENABLE_MPI +#ifdef WONTON_ENABLE_MPI MPI_Init(&argc, &argv); MPI_Comm comm = MPI_COMM_WORLD; @@ -71,7 +71,7 @@ int main(int argc, char** argv) { assert((material_interface_normals.size() == material_interface_points.size()) && (mesh_materials.size() == material_interface_normals.size() + 1)); -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) if (argc != 3) { std::ostringstream os; os << std::endl << @@ -101,7 +101,7 @@ int main(int argc, char** argv) { material_interfaces[iplane].normal); } -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) std::string mesh_name = argv[2]; mesh_name.resize(mesh_name.size() - 4); #else @@ -119,10 +119,10 @@ int main(int argc, char** argv) { std::string out_gmv_fname = mesh_name + "_res_matpolys.gmv"; #endif -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) Jali::MeshFactory mesh_factory(comm); mesh_factory.framework(Jali::MSTK); - mesh_factory.included_entities({Jali::Entity_kind::EDGE}); + mesh_factory.included_entities(Jali::Entity_kind::EDGE); std::shared_ptr mesh = mesh_factory(argv[2]); assert(mesh != nullptr); @@ -148,7 +148,7 @@ int main(int argc, char** argv) { std::vector cell_mat_centroids; std::vector< std::vector< std::vector > > reference_mat_polys; -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) get_material_moments(mesh_wrapper, material_interfaces, mesh_materials, cell_num_mats, cell_mat_ids, cell_mat_volfracs, cell_mat_centroids, vol_tol, dst_tol, decompose_cells, &reference_mat_polys); @@ -194,8 +194,9 @@ int main(int argc, char** argv) { cur_matpoly.set_mat_id(cell_mat_ids[offsets[icell] + icmat]); std::vector mt_pts = cur_matpoly.points(); - std::cout<<"nverts = "< slic_driver(mesh_wrapper, ims_tols, !decompose_cells); @@ -286,7 +287,7 @@ int main(int argc, char** argv) { fout.close(); std::cout << std::endl << "Stats for "; -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) std::cout << "computational mesh " << mesh_name; #else std::cout << "structured " << nx << "x" << ny << @@ -299,11 +300,14 @@ std::cout << std::endl << "Stats for "; "For each material over all multi-material cells:" << std::endl; for (int imat = 0; imat < nmesh_materials; imat++) { - int imaxcell; - double max_sym_diff_mat_vol; + + int imaxcell = 0; + double max_sym_diff_mat_vol = 0.; + if (max_mat_sym_diff_icell[imat] != -1) { imaxcell = max_mat_sym_diff_icell[imat]; - int cell_matid = std::distance(cell_mat_ids.begin() + offsets[imaxcell], + int cell_matid = + std::distance(cell_mat_ids.begin() + offsets[imaxcell], std::find(cell_mat_ids.begin() + offsets[imaxcell], cell_mat_ids.begin() + offsets[imaxcell] + cell_num_mats[imaxcell], mesh_materials[imat])); @@ -311,13 +315,17 @@ std::cout << std::endl << "Stats for "; max_sym_diff_mat_vol = cell_mat_volfracs[offsets[imaxcell] + cell_matid]* mesh_wrapper.cell_volume(imaxcell); } + std::cout << " Material ID " << mesh_materials[imat] << " -> " << std::endl << " Aggregate vol = " << mmcells_material_volumes[imat] << "," << std::endl << " aggregate sym.diff.vol = " << total_mat_sym_diff_vol[imat]; + if (total_mat_sym_diff_vol[imat] >= vol_tol) std::cout << "," << std::endl << " relative sym.diff.vol = " << total_mat_sym_diff_vol[imat]/mmcells_material_volumes[imat]; + std::cout << std::endl; + if (max_mat_sym_diff_icell[imat] != -1) std::cout << " Max sym.diff.vol in cell " << imaxcell << ":" << std::endl << " cell material vol = " << max_sym_diff_mat_vol << "," << std::endl << @@ -345,7 +353,7 @@ std::cout << std::endl << "Stats for "; write_to_gmv(cellmatpoly_list, out_gmv_fname); #endif -#ifdef TANGRAM_ENABLE_MPI +#ifdef WONTON_ENABLE_MPI MPI_Finalize(); #endif diff --git a/app/test_slic/test_slic_3d.cc b/app/test_slic/test_slic_3d.cc index 141c429..364b3f0 100644 --- a/app/test_slic/test_slic_3d.cc +++ b/app/test_slic/test_slic_3d.cc @@ -16,12 +16,12 @@ #include #include -#include "tangram/support/tangram.h" // TANGRAM_ENABLE_MPI defined in this file +#include "tangram/support/tangram.h" // WONTON_ENABLE_MPI defined in this file -#ifdef TANGRAM_ENABLE_MPI +#ifdef WONTON_ENABLE_MPI #include "mpi.h" #endif -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) #include "Mesh.hh" #include "MeshFactory.hh" #include "wonton/mesh/jali/jali_mesh_wrapper.h" @@ -58,7 +58,7 @@ const std::vector< Tangram::Point3 > material_interface_points = { int main(int argc, char** argv) { -#ifdef TANGRAM_ENABLE_MPI +#ifdef WONTON_ENABLE_MPI MPI_Init(&argc, &argv); MPI_Comm comm = MPI_COMM_WORLD; @@ -71,7 +71,7 @@ int main(int argc, char** argv) { assert((material_interface_normals.size() == material_interface_points.size()) && (mesh_materials.size() == material_interface_normals.size() + 1)); -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) if (argc != 3) { std::ostringstream os; os << std::endl << @@ -101,7 +101,7 @@ int main(int argc, char** argv) { material_interfaces[iplane].normal); } -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) std::string mesh_name = argv[2]; mesh_name.resize(mesh_name.size() - 4); #else @@ -119,7 +119,7 @@ int main(int argc, char** argv) { std::string out_gmv_fname = mesh_name + "_res_matpolys.gmv"; #endif -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) Jali::MeshFactory mesh_factory(comm); mesh_factory.framework(Jali::MSTK); mesh_factory.included_entities({Jali::Entity_kind::EDGE, Jali::Entity_kind::FACE}); @@ -148,7 +148,7 @@ int main(int argc, char** argv) { std::vector cell_mat_centroids; std::vector< std::vector< std::vector > > reference_mat_polys; -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) get_material_moments(mesh_wrapper, material_interfaces, mesh_materials, cell_num_mats, cell_mat_ids, cell_mat_volfracs, cell_mat_centroids, vol_tol, dst_tol, decompose_cells, &reference_mat_polys); @@ -201,7 +201,7 @@ int main(int argc, char** argv) { #endif // Build the driver -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) Tangram::Driver slic_driver(mesh_wrapper, ims_tols, !decompose_cells); @@ -279,7 +279,7 @@ int main(int argc, char** argv) { fout.close(); std::cout << std::endl << "Stats for "; -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) std::cout << "computational mesh " << mesh_name; #else std::cout << "structured " << nx << "x" << ny << @@ -292,11 +292,14 @@ std::cout << std::endl << "Stats for "; "For each material over all multi-material cells:" << std::endl; for (int imat = 0; imat < nmesh_materials; imat++) { - int imaxcell; - double max_sym_diff_mat_vol; + + int imaxcell = 0; + double max_sym_diff_mat_vol = 0.; + if (max_mat_sym_diff_icell[imat] != -1) { imaxcell = max_mat_sym_diff_icell[imat]; - int cell_matid = std::distance(cell_mat_ids.begin() + offsets[imaxcell], + int cell_matid = + std::distance(cell_mat_ids.begin() + offsets[imaxcell], std::find(cell_mat_ids.begin() + offsets[imaxcell], cell_mat_ids.begin() + offsets[imaxcell] + cell_num_mats[imaxcell], mesh_materials[imat])); @@ -304,13 +307,17 @@ std::cout << std::endl << "Stats for "; max_sym_diff_mat_vol = cell_mat_volfracs[offsets[imaxcell] + cell_matid]* mesh_wrapper.cell_volume(imaxcell); } + std::cout << " Material ID " << mesh_materials[imat] << " -> " << std::endl << " Aggregate vol = " << mmcells_material_volumes[imat] << "," << std::endl << " aggregate sym.diff.vol = " << total_mat_sym_diff_vol[imat]; + if (total_mat_sym_diff_vol[imat] >= vol_tol) std::cout << "," << std::endl << " relative sym.diff.vol = " << total_mat_sym_diff_vol[imat]/mmcells_material_volumes[imat]; + std::cout << std::endl; + if (max_mat_sym_diff_icell[imat] != -1) std::cout << " Max sym.diff.vol in cell " << imaxcell << ":" << std::endl << " cell material vol = " << max_sym_diff_mat_vol << "," << std::endl << @@ -338,7 +345,7 @@ std::cout << std::endl << "Stats for "; write_to_gmv(cellmatpoly_list, out_gmv_fname); #endif -#ifdef TANGRAM_ENABLE_MPI +#ifdef WONTON_ENABLE_MPI MPI_Finalize(); #endif diff --git a/app/test_vof/CMakeLists.txt b/app/test_vof/CMakeLists.txt index 32a7553..2495794 100644 --- a/app/test_vof/CMakeLists.txt +++ b/app/test_vof/CMakeLists.txt @@ -8,56 +8,14 @@ # test_vof_3d - uses 3D mesh from SimpleMesh or Jali #------------------------------------------------------------------------------- add_executable(test_vof_3d test_vof_3d.cc) -target_link_libraries(test_vof_3d wonton ${Jali_LIBRARIES} ${Jali_TPL_LIBRARIES} - ${MPI_CXX_LIBRARIES} ${EXTRA_LIBS}) +target_link_libraries(test_vof_3d tangram) -if(ENABLE_MPI) - if(MPI_CXX_COMPILE_FLAGS) - set_target_properties(test_vof_3d PROPERTIES - COMPILE_FLAGS "${MPI_CXX_COMPILE_FLAGS}") - endif(MPI_CXX_COMPILE_FLAGS) - - if(MPI_CXX_LINK_FLAGS) - set_target_properties(test_vof_3d PROPERTIES - LINK_FLAGS "${MPI_CXX_LINK_FLAGS}") - endif(MPI_CXX_LINK_FLAGS) -endif(ENABLE_MPI) - -#TCMalloc option -set(ENABLE_TCMALLOC TRUE CACHE BOOL "Use TCMalloc") -if(ENABLE_TCMALLOC) - set(TCMALLOC_LIB "${HOME}" CACHE STRING "Set the TCMalloc library") - target_link_libraries(test_vof_3d ${TCMALLOC_LIB}) -endif(ENABLE_TCMALLOC) #------------------------------------------------------------------------------- # test_vof_2d - uses 2D mesh from SimpleMesh or Jali #------------------------------------------------------------------------------- add_executable(test_vof_2d test_vof_2d.cc) -target_link_libraries(test_vof_2d wonton ${Jali_LIBRARIES} ${Jali_TPL_LIBRARIES} - ${MPI_CXX_LIBRARIES} ${EXTRA_LIBS}) - -if(ENABLE_MPI) - if(MPI_CXX_COMPILE_FLAGS) - set_target_properties(test_vof_2d PROPERTIES - COMPILE_FLAGS "${MPI_CXX_COMPILE_FLAGS}") - endif(MPI_CXX_COMPILE_FLAGS) - - if(MPI_CXX_LINK_FLAGS) - set_target_properties(test_vof_2d PROPERTIES - LINK_FLAGS "${MPI_CXX_LINK_FLAGS}") - endif(MPI_CXX_LINK_FLAGS) -endif(ENABLE_MPI) - -#TCMalloc option -set(ENABLE_TCMALLOC TRUE CACHE BOOL "Use TCMalloc") -if(ENABLE_TCMALLOC) - set(TCMALLOC_LIB "${HOME}" CACHE STRING "Set the TCMalloc library") - target_link_libraries(test_vof_2d ${TCMALLOC_LIB}) -endif(ENABLE_TCMALLOC) -#------------------------------------------------------------------------------- -# Other libraries -#------------------------------------------------------------------------------- +target_link_libraries(test_vof_2d tangram) #------------------------------------------------------------------------------- # Testing diff --git a/app/test_vof/test/CMakeLists.txt b/app/test_vof/test/CMakeLists.txt index 2239937..54b8184 100644 --- a/app/test_vof/test/CMakeLists.txt +++ b/app/test_vof/test/CMakeLists.txt @@ -6,11 +6,11 @@ https://github.com/laristra/tangram/blob/master/LICENSE message(STATUS "Adding test_vof_3d test") # this app should be run in serial -if(ENABLE_MPI) +if(WONTON_ENABLE_MPI) set(RUN_COMMAND "mpirun -np 1") else() set(RUN_COMMAND "") -endif(ENABLE_MPI) +endif(WONTON_ENABLE_MPI) # 3D TEST @@ -30,16 +30,16 @@ macro(ADD_VOF_3D_TEST TEST_NUM) PROPERTY PROCESSORS 1) endmacro(ADD_VOF_3D_TEST) -if (Jali_DIR) +if (WONTON_ENABLE_Jali) ADD_VOF_3D_TEST(2) ADD_VOF_3D_TEST(3) file(COPY cubic27.exo DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(COPY voronoi95.exo DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -else(Jali_DIR) +else(WONTON_ENABLE_Jali) ADD_VOF_3D_TEST(0) ADD_VOF_3D_TEST(1) -endif(Jali_DIR) +endif(WONTON_ENABLE_Jali) # 2D TEST macro(ADD_VOF_2D_TEST TEST_NUM) @@ -58,10 +58,10 @@ macro(ADD_VOF_2D_TEST TEST_NUM) PROPERTY PROCESSORS 1) endmacro(ADD_VOF_2D_TEST) -if (Jali_DIR) +if (WONTON_ENABLE_Jali) ADD_VOF_2D_TEST(2) file(COPY voronoi124.exo DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -else(Jali_DIR) +else(WONTON_ENABLE_Jali) ADD_VOF_2D_TEST(0) ADD_VOF_2D_TEST(1) -endif(Jali_DIR) +endif(WONTON_ENABLE_Jali) diff --git a/app/test_vof/test_vof_2d.cc b/app/test_vof/test_vof_2d.cc index 9dcc751..7babb97 100644 --- a/app/test_vof/test_vof_2d.cc +++ b/app/test_vof/test_vof_2d.cc @@ -15,12 +15,12 @@ #include #include -#include "tangram/support/tangram.h" // TANGRAM_ENABLE_MPI defined in this file +#include "tangram/support/tangram.h" // WONTON_ENABLE_MPI defined in this file -#ifdef TANGRAM_ENABLE_MPI +#ifdef WONTON_ENABLE_MPI #include "mpi.h" #endif -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) #include "Mesh.hh" #include "MeshFactory.hh" #include "wonton/mesh/jali/jali_mesh_wrapper.h" @@ -58,7 +58,7 @@ const std::vector< Tangram::Point2 > material_interface_points = { }; int main(int argc, char** argv) { -#ifdef TANGRAM_ENABLE_MPI +#ifdef WONTON_ENABLE_MPI MPI_Init(&argc, &argv); MPI_Comm comm = MPI_COMM_WORLD; @@ -71,7 +71,7 @@ int main(int argc, char** argv) { assert((material_interface_normals.size() == material_interface_points.size()) && (mesh_materials.size() == material_interface_normals.size() + 1)); -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) if (argc != 3) { std::ostringstream os; os << std::endl << @@ -101,7 +101,7 @@ int main(int argc, char** argv) { material_interfaces[iplane].normal); } -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) std::string mesh_name = argv[2]; mesh_name.resize(mesh_name.size() - 4); #else @@ -119,10 +119,10 @@ int main(int argc, char** argv) { std::string out_gmv_fname = mesh_name + "_res_matpolys.gmv"; #endif -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) Jali::MeshFactory mesh_factory(comm); mesh_factory.framework(Jali::MSTK); - mesh_factory.included_entities({Jali::Entity_kind::EDGE}); + mesh_factory.included_entities(Jali::Entity_kind::EDGE); std::shared_ptr mesh = mesh_factory(argv[2]); assert(mesh != nullptr); @@ -148,7 +148,7 @@ int main(int argc, char** argv) { std::vector cell_mat_centroids; std::vector< std::vector< std::vector > > reference_mat_polys; -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) get_material_moments(mesh_wrapper, material_interfaces, mesh_materials, cell_num_mats, cell_mat_ids, cell_mat_volfracs, cell_mat_centroids, vol_tol, dst_tol, decompose_cells, &reference_mat_polys); @@ -194,8 +194,9 @@ int main(int argc, char** argv) { cur_matpoly.set_mat_id(cell_mat_ids[offsets[icell] + icmat]); std::vector mt_pts = cur_matpoly.points(); - std::cout<<"nverts = "< vof_driver(mesh_wrapper, ims_tols, !decompose_cells); @@ -273,6 +274,7 @@ int main(int argc, char** argv) { if (decompose_cells) res_out_fname += "_decomposed"; res_out_fname += ".txt"; + std::ofstream fout(res_out_fname); fout << std::scientific; fout.precision(17); @@ -285,7 +287,7 @@ int main(int argc, char** argv) { fout.close(); std::cout << std::endl << "Stats for "; -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) std::cout << "computational mesh " << mesh_name; #else std::cout << "structured " << nx << "x" << ny << @@ -298,11 +300,14 @@ std::cout << std::endl << "Stats for "; "For each material over all multi-material cells:" << std::endl; for (int imat = 0; imat < nmesh_materials; imat++) { - int imaxcell; - double max_sym_diff_mat_vol; + + int imaxcell = 0; + double max_sym_diff_mat_vol = 0.; + if (max_mat_sym_diff_icell[imat] != -1) { imaxcell = max_mat_sym_diff_icell[imat]; - int cell_matid = std::distance(cell_mat_ids.begin() + offsets[imaxcell], + int cell_matid = + std::distance(cell_mat_ids.begin() + offsets[imaxcell], std::find(cell_mat_ids.begin() + offsets[imaxcell], cell_mat_ids.begin() + offsets[imaxcell] + cell_num_mats[imaxcell], mesh_materials[imat])); @@ -310,13 +315,17 @@ std::cout << std::endl << "Stats for "; max_sym_diff_mat_vol = cell_mat_volfracs[offsets[imaxcell] + cell_matid]* mesh_wrapper.cell_volume(imaxcell); } + std::cout << " Material ID " << mesh_materials[imat] << " -> " << std::endl << " Aggregate vol = " << mmcells_material_volumes[imat] << "," << std::endl << " aggregate sym.diff.vol = " << total_mat_sym_diff_vol[imat]; + if (total_mat_sym_diff_vol[imat] >= vol_tol) std::cout << "," << std::endl << " relative sym.diff.vol = " << total_mat_sym_diff_vol[imat]/mmcells_material_volumes[imat]; + std::cout << std::endl; + if (max_mat_sym_diff_icell[imat] != -1) std::cout << " Max sym.diff.vol in cell " << imaxcell << ":" << std::endl << " cell material vol = " << max_sym_diff_mat_vol << "," << std::endl << @@ -344,7 +353,7 @@ std::cout << std::endl << "Stats for "; write_to_gmv(cellmatpoly_list, out_gmv_fname); #endif -#ifdef TANGRAM_ENABLE_MPI +#ifdef WONTON_ENABLE_MPI MPI_Finalize(); #endif diff --git a/app/test_vof/test_vof_3d.cc b/app/test_vof/test_vof_3d.cc index 5f3dac9..2d4040d 100644 --- a/app/test_vof/test_vof_3d.cc +++ b/app/test_vof/test_vof_3d.cc @@ -15,12 +15,12 @@ #include #include -#include "tangram/support/tangram.h" // TANGRAM_ENABLE_MPI defined in this file +#include "tangram/support/tangram.h" // WONTON_ENABLE_MPI defined in this file -#ifdef TANGRAM_ENABLE_MPI +#ifdef WONTON_ENABLE_MPI #include "mpi.h" #endif -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) #include "Mesh.hh" #include "MeshFactory.hh" #include "wonton/mesh/jali/jali_mesh_wrapper.h" @@ -59,7 +59,7 @@ const std::vector< Tangram::Point3 > material_interface_points = { int main(int argc, char** argv) { -#ifdef TANGRAM_ENABLE_MPI +#ifdef WONTON_ENABLE_MPI MPI_Init(&argc, &argv); MPI_Comm comm = MPI_COMM_WORLD; @@ -72,7 +72,7 @@ int main(int argc, char** argv) { assert((material_interface_normals.size() == material_interface_points.size()) && (mesh_materials.size() == material_interface_normals.size() + 1)); -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) if (argc != 3) { std::ostringstream os; os << std::endl << @@ -102,7 +102,7 @@ int main(int argc, char** argv) { material_interfaces[iplane].normal); } -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) std::string mesh_name = argv[2]; mesh_name.resize(mesh_name.size() - 4); #else @@ -120,7 +120,7 @@ int main(int argc, char** argv) { std::string out_gmv_fname = mesh_name + "_res_matpolys.gmv"; #endif -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) Jali::MeshFactory mesh_factory(comm); mesh_factory.framework(Jali::MSTK); mesh_factory.included_entities({Jali::Entity_kind::EDGE, Jali::Entity_kind::FACE}); @@ -139,7 +139,7 @@ int main(int argc, char** argv) { // Volume and distance tolerance double dst_tol = sqrt(3)*std::numeric_limits::epsilon(); - double vol_tol = pow2(std::numeric_limits::epsilon()); + double vol_tol = std::numeric_limits::epsilon(); double rmdg_vol_tol = 1.0e-15; std::vector< Tangram::IterativeMethodTolerances_t> ims_tols(1); ims_tols[0] = {1000, dst_tol, vol_tol}; @@ -150,7 +150,7 @@ int main(int argc, char** argv) { std::vector cell_mat_centroids; std::vector< std::vector< std::vector > > reference_mat_polys; -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) get_material_moments(mesh_wrapper, material_interfaces, mesh_materials, cell_num_mats, cell_mat_ids, cell_mat_volfracs, cell_mat_centroids, rmdg_vol_tol, dst_tol, decompose_cells, &reference_mat_polys); @@ -203,7 +203,7 @@ int main(int argc, char** argv) { #endif // Build the driver -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) Tangram::Driver vof_driver(mesh_wrapper, ims_tols, !decompose_cells); @@ -268,6 +268,7 @@ int main(int argc, char** argv) { if (decompose_cells) res_out_fname += "_decomposed"; res_out_fname += ".txt"; + std::ofstream fout(res_out_fname); fout << std::scientific; fout.precision(17); @@ -280,7 +281,7 @@ int main(int argc, char** argv) { fout.close(); std::cout << std::endl << "Stats for "; -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) std::cout << "computational mesh " << mesh_name; #else std::cout << "structured " << nx << "x" << ny << @@ -293,11 +294,14 @@ std::cout << std::endl << "Stats for "; "For each material over all multi-material cells:" << std::endl; for (int imat = 0; imat < nmesh_materials; imat++) { - int imaxcell; - double max_sym_diff_mat_vol; + + int imaxcell = 0; + double max_sym_diff_mat_vol = 0; + if (max_mat_sym_diff_icell[imat] != -1) { imaxcell = max_mat_sym_diff_icell[imat]; - int cell_matid = std::distance(cell_mat_ids.begin() + offsets[imaxcell], + int cell_matid = + std::distance(cell_mat_ids.begin() + offsets[imaxcell], std::find(cell_mat_ids.begin() + offsets[imaxcell], cell_mat_ids.begin() + offsets[imaxcell] + cell_num_mats[imaxcell], mesh_materials[imat])); @@ -305,13 +309,17 @@ std::cout << std::endl << "Stats for "; max_sym_diff_mat_vol = cell_mat_volfracs[offsets[imaxcell] + cell_matid]* mesh_wrapper.cell_volume(imaxcell); } + std::cout << " Material ID " << mesh_materials[imat] << " -> " << std::endl << " Aggregate vol = " << mmcells_material_volumes[imat] << "," << std::endl << " aggregate sym.diff.vol = " << total_mat_sym_diff_vol[imat]; + if (total_mat_sym_diff_vol[imat] >= vol_tol) std::cout << "," << std::endl << " relative sym.diff.vol = " << total_mat_sym_diff_vol[imat]/mmcells_material_volumes[imat]; + std::cout << std::endl; + if (max_mat_sym_diff_icell[imat] != -1) std::cout << " Max sym.diff.vol in cell " << imaxcell << ":" << std::endl << " cell material vol = " << max_sym_diff_mat_vol << "," << std::endl << @@ -339,7 +347,7 @@ std::cout << std::endl << "Stats for "; write_to_gmv(cellmatpoly_list, out_gmv_fname); #endif -#ifdef TANGRAM_ENABLE_MPI +#ifdef WONTON_ENABLE_MPI MPI_Finalize(); #endif diff --git a/app/test_xmof2d/CMakeLists.txt b/app/test_xmof2d/CMakeLists.txt index 5b5bace..822a753 100644 --- a/app/test_xmof2d/CMakeLists.txt +++ b/app/test_xmof2d/CMakeLists.txt @@ -8,31 +8,7 @@ # test_mof_2d - uses 2D mesh from SimpleMesh or Jali #------------------------------------------------------------------------------- add_executable(test_xmof2d test_xmof2d.cc) -target_link_libraries(test_xmof2d wonton ${Jali_LIBRARIES} ${Jali_TPL_LIBRARIES} - ${XMOF2D_LIBRARIES} ${MPI_CXX_LIBRARIES} ${EXTRA_LIBS}) - -if(ENABLE_MPI) - if(MPI_CXX_COMPILE_FLAGS) - set_target_properties(test_xmof2d PROPERTIES - COMPILE_FLAGS "${MPI_CXX_COMPILE_FLAGS}") - endif(MPI_CXX_COMPILE_FLAGS) - - if(MPI_CXX_LINK_FLAGS) - set_target_properties(test_xmof2d PROPERTIES - LINK_FLAGS "${MPI_CXX_LINK_FLAGS}") - endif(MPI_CXX_LINK_FLAGS) -endif(ENABLE_MPI) - -#TCMalloc option -set(ENABLE_TCMALLOC TRUE CACHE BOOL "Use TCMalloc") -if(ENABLE_TCMALLOC) - set(TCMALLOC_LIB "${HOME}" CACHE STRING "Set the TCMalloc library") - target_link_libraries(test_xmof2d ${TCMALLOC_LIB}) -endif(ENABLE_TCMALLOC) - -#------------------------------------------------------------------------------- -# Other libraries -#------------------------------------------------------------------------------- +target_link_libraries(test_xmof2d tangram) #------------------------------------------------------------------------------- # Testing diff --git a/app/test_xmof2d/test/CMakeLists.txt b/app/test_xmof2d/test/CMakeLists.txt index c62f82f..6e99b29 100644 --- a/app/test_xmof2d/test/CMakeLists.txt +++ b/app/test_xmof2d/test/CMakeLists.txt @@ -6,11 +6,11 @@ https://github.com/laristra/tangram/blob/master/LICENSE message(STATUS "Adding test_xmof2d test") # this app should be run in serial -if(ENABLE_MPI) +if(WONTON_ENABLE_MPI) set(RUN_COMMAND "mpirun -np 1") else() set(RUN_COMMAND "") -endif(ENABLE_MPI) +endif(WONTON_ENABLE_MPI) macro(ADD_XMOF2D_TEST TEST_NUM) file(COPY xmof2d_test${TEST_NUM}.sh @@ -28,10 +28,10 @@ macro(ADD_XMOF2D_TEST TEST_NUM) PROPERTY PROCESSORS 1) endmacro(ADD_XMOF2D_TEST) -if (Jali_DIR) +if (WONTON_ENABLE_Jali) ADD_XMOF2D_TEST(1) file(COPY voronoi124.exo DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -else(Jali_DIR) +else(WONTON_ENABLE_Jali) ADD_XMOF2D_TEST(0) -endif(Jali_DIR) \ No newline at end of file +endif(WONTON_ENABLE_Jali) \ No newline at end of file diff --git a/app/test_xmof2d/test_xmof2d.cc b/app/test_xmof2d/test_xmof2d.cc index 0b89570..6ec6a8a 100644 --- a/app/test_xmof2d/test_xmof2d.cc +++ b/app/test_xmof2d/test_xmof2d.cc @@ -15,12 +15,12 @@ #include #include -#include "tangram/support/tangram.h" // TANGRAM_ENABLE_MPI enabled in this file +#include "tangram/support/tangram.h" // WONTON_ENABLE_MPI enabled in this file -#ifdef TANGRAM_ENABLE_MPI +#ifdef WONTON_ENABLE_MPI #include "mpi.h" #endif -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) #include "Mesh.hh" #include "MeshFactory.hh" #include "wonton/mesh/jali/jali_mesh_wrapper.h" @@ -60,7 +60,7 @@ const std::vector< Tangram::Point2 > material_interface_points = { int main(int argc, char** argv) { -#ifdef TANGRAM_ENABLE_MPI +#ifdef WONTON_ENABLE_MPI MPI_Init(&argc, &argv); MPI_Comm comm = MPI_COMM_WORLD; @@ -73,7 +73,7 @@ int main(int argc, char** argv) { assert((material_interface_normals.size() == material_interface_points.size()) && (mesh_materials.size() == material_interface_normals.size() + 1)); -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) if (argc != 2) { std::ostringstream os; os << std::endl << @@ -101,7 +101,7 @@ int main(int argc, char** argv) { material_interfaces[iline].normal); } -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) std::string mesh_name = argv[1]; mesh_name.resize(mesh_name.size() - 4); #else @@ -119,7 +119,7 @@ int main(int argc, char** argv) { std::string out_gmv_fname = mesh_name + "_res_matpolys.gmv"; #endif -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) Jali::MeshFactory mesh_factory(comm); mesh_factory.framework(Jali::MSTK); mesh_factory.included_entities({Jali::Entity_kind::EDGE, Jali::Entity_kind::FACE}); @@ -149,7 +149,7 @@ int main(int argc, char** argv) { std::vector cell_mat_centroids; std::vector< std::vector< std::vector > > reference_mat_polys; -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) get_material_moments(mesh_wrapper, material_interfaces, mesh_materials, cell_num_mats, cell_mat_ids, cell_mat_volfracs, cell_mat_centroids, vol_tol, dst_tol, decompose_cells, &reference_mat_polys); @@ -185,6 +185,7 @@ int main(int argc, char** argv) { for (int icmat = 0; icmat < cell_num_mats[icell]; icmat++) { int nmp = static_cast(reference_mat_polys[icell][icmat].size()); for (int imp = 0; imp < nmp; imp++) { + const r2d_poly& cur_r2d_poly = reference_mat_polys[icell][icmat][imp]; std::vector poly_vrts; int ir2dvrt = 0; @@ -206,7 +207,7 @@ int main(int argc, char** argv) { #endif // Build the driver -#if defined(ENABLE_JALI) && defined(TANGRAM_ENABLE_MPI) +#if defined(WONTON_ENABLE_Jali) && defined(WONTON_ENABLE_MPI) Tangram::Driver xmof_driver(mesh_wrapper, ims_tols, !decompose_cells); #else @@ -266,6 +267,7 @@ int main(int argc, char** argv) { if (decompose_cells) res_out_fname += "_decomposed"; res_out_fname += ".txt"; + std::ofstream fout(res_out_fname); fout << std::scientific; fout.precision(17); @@ -304,7 +306,7 @@ int main(int argc, char** argv) { write_to_gmv(cellmatpoly_list, out_gmv_fname); #endif -#ifdef TANGRAM_ENABLE_MPI +#ifdef WONTON_ENABLE_MPI MPI_Finalize(); #endif diff --git a/app/vfgen/CMakeLists.txt b/app/vfgen/CMakeLists.txt index 6a5e650..2c016e9 100644 --- a/app/vfgen/CMakeLists.txt +++ b/app/vfgen/CMakeLists.txt @@ -7,13 +7,11 @@ #------------------------------------------------------------------------------- # genvf - generate volume fractions and centroids #------------------------------------------------------------------------------- -add_executable(vfgen-sampling vfgen-sampling.cc) -target_link_libraries(vfgen-sampling ${Jali_LIBRARIES} ${Jali_TPL_LIBRARIES} - ${MPI_CXX_LIBRARIES} ${EXTRA_LIBS}) + if (WONTON_ENABLE_MPI AND WONTON_ENABLE_Jali) + add_executable(vfgen-sampling-jali vfgen-sampling-jali.cc) + target_link_libraries(vfgen-sampling-jali tangram) + endif (WONTON_ENABLE_MPI AND WONTON_ENABLE_Jali) + + add_executable(vfgen-sampling-sm vfgen-sampling-sm.cc) + target_link_libraries(vfgen-sampling-sm tangram) -#TCMalloc option -set(ENABLE_TCMALLOC TRUE CACHE BOOL "Use TCMalloc") -if(ENABLE_TCMALLOC) - set(TCMALLOC_LIB "${HOME}" CACHE STRING "Set the TCMalloc library") - target_link_libraries(vfgen-sampling ${TCMALLOC_LIB}) -endif(ENABLE_TCMALLOC) diff --git a/app/vfgen/vfgen-sampling-jali.cc b/app/vfgen/vfgen-sampling-jali.cc new file mode 100644 index 0000000..1858ef8 --- /dev/null +++ b/app/vfgen/vfgen-sampling-jali.cc @@ -0,0 +1,198 @@ +/* + This file is part of the Ristra tangram project. + Please see the license file at the root of this repository, or at: + https://github.com/laristra/tangram/blob/master/LICENSE +*/ + +// Generate volume fractions and centroids for materials in mesh cells +// given a configuration file with different geometric features. +// +// +// Assumption: 2D meshes are in X-Y plane only +// +// Author: Rao Garimella, rao@lanl.gov + +#include +#include +#include +#include +#include + +#include + + +// Jali mesh infrastructure library +// See https://github.com/lanl/jali + +#include "Mesh.hh" +#include "MeshFactory.hh" +#include "JaliStateVector.h" +#include "JaliState.h" + +// tangram includes +#include "tangram/support/tangram.h" + +// wonton includes +#include "wonton/mesh/jali/jali_mesh_wrapper.h" + +#include "vfgen.h" + + +int main(int argc, char *argv[]) { + int global_nmats; + + struct timeval begin_total {}; + struct timeval begin_core {}; + struct timeval end_total {}; + struct timeval end_core {}; + struct timeval diff_total {}; + struct timeval diff_core {}; + + double ptol = 1.0e-12; + + MPI_Init(&argc, &argv); + + if (argc < 3) { + std::cerr << "usage: " << argv[0] << + " meshfilename dim \n"; + exit(-1); + } + + gettimeofday(&begin_total, 0); + + std::string meshfilename(argv[1]); + std::size_t pos = meshfilename.find_last_of("."); + std::string basename(meshfilename.substr(0, pos)); + + std::string featfilename; +#ifdef DEBUG + int probdim = std::stoi(argv[2]); +#endif + if (argc > 3) + featfilename = argv[3]; + else + featfilename = basename + std::string(".inp"); + + + // Initialize the mesh from Jali + + std::shared_ptr mesh; + Jali::MeshFactory mf(MPI_COMM_WORLD); + mf.included_entities(Jali::Entity_kind::ALL_KIND); + + mf.partitioner(Jali::Partitioner_type::METIS); + mesh = mf(meshfilename); + + int meshdim = mesh->space_dimension(); +#ifdef DEBUG + assert(meshdim == probdim); +#endif + + int ncells = mesh->num_cells(); + + Wonton::Jali_Mesh_Wrapper mesh_wrapper(*mesh); + + std::string outfilename(basename + std::string(".vf")); + std::string boutfilename(basename + std::string(".bvf")); + + int ncells_nmats[MAXMATS] = {}; + + if (meshdim == 2) { + + std::vector> features; + read_features<2>(featfilename, &features, &global_nmats); + + Wonton::vector> vfcen(ncells); + InFeatureEvaluator<2> feature_functor(features); + VolfracEvaluator<2, Wonton::Jali_Mesh_Wrapper> + volfrac_calculator(mesh_wrapper, feature_functor, ptol, global_nmats); + + gettimeofday(&begin_core, 0); + + // Populate the vf array using the volfrac functor + Wonton::vector counter(ncells); + for (int i = 0; i < ncells; i++) counter[i] = i; + Wonton::transform(counter.begin(), counter.end(), vfcen.begin(), + volfrac_calculator); + + gettimeofday(&end_core, 0); + + writeAsciiFile<2>(outfilename, vfcen, global_nmats); + writeBinaryFile<2>(boutfilename, vfcen); + + + // Count the cells the with 1, 2 , 3 ... materials + for (int i = 0; i < ncells; i++) { + // When Thrust is turned on, vfcen is on the device and vfcen_i + // is on the host. Thrust does not allow us to modify device + // memory directly from host, so we have to use a const + // reference or do an explicit copy + + vfcen_t<2> const& vfcen_i = vfcen[i]; + + int nmats_i = vfcen_i.nmats; + ncells_nmats[nmats_i]++; + } + + } else if (meshdim == 3) { + + std::vector> features; + read_features<3>(featfilename, &features, &global_nmats); + + Wonton::vector> vfcen(ncells); + InFeatureEvaluator<3> feature_functor(features); + VolfracEvaluator<3, Wonton::Jali_Mesh_Wrapper> + volfrac_calculator(mesh_wrapper, feature_functor, ptol, global_nmats); + + gettimeofday(&begin_core, 0); + + // Populate the vf array using the volfrac functor + Wonton::vector counter(ncells); + for (int i = 0; i < ncells; i++) counter[i] = i; + Wonton::transform(counter.begin(), counter.end(), vfcen.begin(), + volfrac_calculator); + + gettimeofday(&end_core, 0); + + writeAsciiFile<3>(outfilename, vfcen, global_nmats); + writeBinaryFile<3>(boutfilename, vfcen); + + // Count the cells the with 1, 2 , 3 ... materials + for (int i = 0; i < ncells; i++) { + // When Thrust is turned on, vfcen is on the device and vfcen_i + // is on the host. Thrust does not allow us to modify device + // memory directly from host, so we have to use a const + // reference or do an explicit copy + + vfcen_t<3> const& vfcen_i = vfcen[i]; + + int nmats_i = vfcen_i.nmats; + ncells_nmats[nmats_i]++; + } + } + + int tot = 0; + for (int i = 0; i < 5; i++) { + std::cerr << "Number of cells with " << i << " materials " << + ncells_nmats[i] << "\n"; + tot += ncells_nmats[i]; + } + if (tot < ncells) + std::cerr << + "There may be cells with no materials or more than 5 materials\n"; + + MPI_Finalize(); + + gettimeofday(&end_total, 0); + + timersub(&end_core, &begin_core, &diff_core); + timersub(&end_total, &begin_total, &diff_total); + double core_seconds = diff_core.tv_sec + 1.0E-6*diff_core.tv_usec; + double total_seconds = diff_total.tv_sec + 1.0E-6*diff_total.tv_usec; + + std::cerr << "Time taken to compute volume fractions and centroids: " << + core_seconds << "\n"; + std::cerr << "Total time taken by app: " << total_seconds << "\n"; + + return 1; +} diff --git a/app/vfgen/vfgen-sampling-sm.cc b/app/vfgen/vfgen-sampling-sm.cc new file mode 100644 index 0000000..792a1e5 --- /dev/null +++ b/app/vfgen/vfgen-sampling-sm.cc @@ -0,0 +1,173 @@ +/* + This file is part of the Ristra tangram project. + Please see the license file at the root of this repository, or at: + https://github.com/laristra/tangram/blob/master/LICENSE +*/ + +// Generate volume fractions and centroids for materials in mesh cells +// given a configuration file with different geometric features. +// +// +// Assumption: 2D meshes are in X-Y plane only +// +// Author: Rao Garimella, rao@lanl.gov + +#include +#include +#include +#include +#include + +// wonton includes +#include "wonton/mesh/simple/simple_mesh.h" +#include "wonton/mesh/simple/simple_mesh_wrapper.h" +#include "wonton/state/simple/simple_state.h" +#include "wonton/state/simple/simple_state_mm_wrapper.h" + +// tangram includes +#include "tangram/support/tangram.h" + +#include "vfgen.h" + + +int main(int argc, char *argv[]) { + int global_nmats; + + struct timeval begin_total {}; + struct timeval begin_core {}; + struct timeval end_total {}; + struct timeval end_core {}; + struct timeval diff_total {}; + struct timeval diff_core {}; + + double ptol = 1.0e-12; + + if (argc < 3) { + std::cerr << "usage: " << argv[0] << + " ncells dim featurefile.inp\n"; + exit(-1); + } + + gettimeofday(&begin_total, 0); + + int ncells_each_dim = std::stoi(argv[1]); + int probdim = std::stoi(argv[2]); + std::string featfilename(argv[3]); + std::size_t pos = featfilename.find_last_of("."); + std::string basename(featfilename.substr(0, pos)); + + std::string outfilename(basename + std::string(".vf")); + std::string boutfilename(basename + std::string(".bvf")); + + int ncells; + int ncells_nmats[MAXMATS] = {}; + + if (probdim == 2) { + + // create the mesh and wrapper + Wonton::Simple_Mesh mesh(0., 0., 1., 1., ncells_each_dim, ncells_each_dim); + Wonton::Simple_Mesh_Wrapper mesh_wrapper(mesh); + + ncells = mesh_wrapper.num_owned_cells(); + + std::vector> features; + read_features<2>(featfilename, &features, &global_nmats); + + Wonton::vector> vfcen(ncells); + InFeatureEvaluator<2> feature_functor(features); + VolfracEvaluator<2, Wonton::Simple_Mesh_Wrapper> + volfrac_calculator(mesh_wrapper, feature_functor, ptol, global_nmats); + + gettimeofday(&begin_core, 0); + + // Populate the vf array using the volfrac functor + Wonton::vector counter(ncells); + for (int i = 0; i < ncells; i++) counter[i] = i; + Wonton::transform(counter.begin(), counter.end(), vfcen.begin(), + volfrac_calculator); + + gettimeofday(&end_core, 0); + + writeAsciiFile<2>(outfilename, vfcen, global_nmats); + writeBinaryFile<2>(boutfilename, vfcen); + + + // Count the cells the with 1, 2 , 3 ... materials + for (int i = 0; i < ncells; i++) { + // When Thrust is turned on, vfcen is on the device and vfcen_i + // is on the host. Thrust does not allow us to modify device + // memory directly from host, so we have to use a const + // reference or do an explicit copy + + vfcen_t<2> const& vfcen_i = vfcen[i]; + + int nmats_i = vfcen_i.nmats; + ncells_nmats[nmats_i]++; + } + + } else if (probdim == 3) { + + // create the mesh and wrapper + Wonton::Simple_Mesh mesh(0., 0., 0., 1., 1., 1., ncells_each_dim, ncells_each_dim, ncells_each_dim); + Wonton::Simple_Mesh_Wrapper mesh_wrapper(mesh); + + ncells = mesh_wrapper.num_owned_cells(); + + std::vector> features; + read_features<3>(featfilename, &features, &global_nmats); + + Wonton::vector> vfcen(ncells); + InFeatureEvaluator<3> feature_functor(features); + VolfracEvaluator<3, Wonton::Simple_Mesh_Wrapper> + volfrac_calculator(mesh_wrapper, feature_functor, ptol, global_nmats); + + gettimeofday(&begin_core, 0); + + // Populate the vf array using the volfrac functor + Wonton::vector counter(ncells); + for (int i = 0; i < ncells; i++) counter[i] = i; + Wonton::transform(counter.begin(), counter.end(), vfcen.begin(), + volfrac_calculator); + + gettimeofday(&end_core, 0); + + writeAsciiFile<3>(outfilename, vfcen, global_nmats); + writeBinaryFile<3>(boutfilename, vfcen); + + // Count the cells the with 1, 2 , 3 ... materials + for (int i = 0; i < ncells; i++) { + // When Thrust is turned on, vfcen is on the device and vfcen_i + // is on the host. Thrust does not allow us to modify device + // memory directly from host, so we have to use a const + // reference or do an explicit copy + + vfcen_t<3> const& vfcen_i = vfcen[i]; + + int nmats_i = vfcen_i.nmats; + ncells_nmats[nmats_i]++; + } + } + + int tot = 0; + for (int i = 0; i < 5; i++) { + std::cerr << "Number of cells with " << i << " materials " << + ncells_nmats[i] << "\n"; + tot += ncells_nmats[i]; + } + if (tot < ncells) + std::cerr << + "There may be cells with no materials or more than 5 materials\n"; + + gettimeofday(&end_total, 0); + + timersub(&end_core, &begin_core, &diff_core); + timersub(&end_total, &begin_total, &diff_total); + double core_seconds = diff_core.tv_sec + 1.0E-6*diff_core.tv_usec; + double total_seconds = diff_total.tv_sec + 1.0E-6*diff_total.tv_usec; + + std::cerr << "Time taken to compute volume fractions and centroids: " << + core_seconds << "\n"; + std::cerr << "Total time taken by app: " << total_seconds << "\n"; + + return 1; +} diff --git a/app/vfgen/vfgen.h b/app/vfgen/vfgen.h index e73959c..101d5cf 100644 --- a/app/vfgen/vfgen.h +++ b/app/vfgen/vfgen.h @@ -18,10 +18,11 @@ #include #include +#ifdef _OPENMP #include -#include +#endif -#ifdef THRUST +#ifdef WONTON_ENABLE_THRUST #include "thrust/device_vector.h" #include "thrust/transform.h" #include "thrust/for_each.h" @@ -45,7 +46,7 @@ struct vfcen_t { int nmats = 0; int matids[MAXMATS] = {}; // initialize to zero double vf[MAXMATS] = {}; // initialize to zero - Tangram::Point cen[MAXMATS]; // Constructor initializes to origin + Wonton::Point cen[MAXMATS]; // Constructor initializes to origin }; @@ -65,8 +66,8 @@ struct vfcen_t { // @param polypnts Polygon points // @return bool true if point is inside -bool P_InPoly2D(Tangram::Point<2> ptest, int np, - Tangram::Point<2> *polypnts) { +bool P_InPoly2D(Wonton::Point<2> ptest, int np, + Wonton::Point<2> *polypnts) { /* Basic test - will work for strictly interior and exterior points */ double x = ptest[0]; @@ -96,16 +97,16 @@ bool P_InPoly2D(Tangram::Point<2> ptest, int np, // @param tripnts Triangle points (3*ntri) // @return bool if point is inside -bool P_InTriPoly3D(Tangram::Point<3> ptest, - int ntri, Tangram::Point<3> *tripnts) { +bool P_InTriPoly3D(Wonton::Point<3> ptest, + int ntri, Wonton::Point<3> *tripnts) { for (int t = 0; t < ntri; t++) { - Tangram::Point<3>& p0 = tripnts[3*t]; - Tangram::Point<3>& p1 = tripnts[3*t+1]; - Tangram::Point<3>& p2 = tripnts[3*t+2]; - Tangram::Vector<3> v0 = p0 - ptest; - Tangram::Vector<3> v1 = p1 - ptest; - Tangram::Vector<3> v2 = p2 - ptest; - Tangram::Vector<3> vcross = cross(v0, v1); + Wonton::Point<3>& p0 = tripnts[3*t]; + Wonton::Point<3>& p1 = tripnts[3*t+1]; + Wonton::Point<3>& p2 = tripnts[3*t+2]; + Wonton::Vector<3> v0 = p0 - ptest; + Wonton::Vector<3> v1 = p1 - ptest; + Wonton::Vector<3> v2 = p2 - ptest; + Wonton::Vector<3> vcross = cross(v0, v1); double vol = dot(vcross, v2); if (vol < 0.0) return false; } @@ -127,15 +128,15 @@ bool P_InTriPoly3D(Tangram::Point<3> ptest, // of faceted polyhedron in 3D template -bool P_InPoly(Tangram::Point ptest, int npnts, Tangram::Point *points) {} +bool P_InPoly(Wonton::Point ptest, int npnts, Wonton::Point *points) {} template<> -bool P_InPoly<2>(Tangram::Point<2> ptest, int npnts, Tangram::Point<2> *points) { +bool P_InPoly<2>(Wonton::Point<2> ptest, int npnts, Wonton::Point<2> *points) { return P_InPoly2D(ptest, npnts, points); } template<> -bool P_InPoly<3>(Tangram::Point<3> ptest, int npnts, Tangram::Point<3> *points) { +bool P_InPoly<3>(Wonton::Point<3> ptest, int npnts, Wonton::Point<3> *points) { int ntris = npnts/3; return P_InTriPoly3D(ptest, ntris, points); } @@ -162,7 +163,7 @@ struct FEATURE { /* points of polygons and polyhedra - for polygons, these are * expected to be in ccw manner */ int nppoly; - Tangram::Point polyxyz[MAXPV2]; + Wonton::Point polyxyz[MAXPV2]; /* Additional info for 3D Polyhedron description - Not filled in for 2D */ int nfpoly; /* Number of polyhedron faces */ @@ -175,20 +176,20 @@ struct FEATURE { * triangle. It is derived from nfpoly, nfpnts and fpnts - has no * meaning and not filled in 2D */ int ntris; - Tangram::Point polytrixyz[MAXPF3*MAXPV2*3]; + Wonton::Point polytrixyz[MAXPF3*MAXPV2*3]; /* Circle or Sphere */ - Tangram::Point cen; + Wonton::Point cen; double radius; /* Half-space defined by plane */ - Tangram::Point plane_xyz; - Tangram::Point plane_normal; + Wonton::Point plane_xyz; + Wonton::Point plane_normal; /* Box */ - Tangram::Point minxyz; /* Lower left corner of box */ - Tangram::Point maxxyz; /* Upper right corner of box */ + Wonton::Point minxyz; /* Lower left corner of box */ + Wonton::Point maxxyz; /* Upper right corner of box */ }; @@ -202,19 +203,19 @@ struct FEATURE { template struct InFeatureEvaluator { - int nfeat_; - std::vector> features_; + std::vector> features_ {}; + int nfeat_ = 0; explicit InFeatureEvaluator(std::vector> const& features) : features_(features), nfeat_(features.size()) {} - int operator() (Tangram::Point const& ptxyz) { + int operator() (Wonton::Point const& ptxyz) { int pmatid = -1; int imat = 1; bool test_in = true; for (int j = nfeat_-1; j >= 0; j--) { - FEATURE curfeat = features_[j]; + FEATURE& curfeat = features_[j]; imat = curfeat.matid; test_in = (curfeat.inout == 1); @@ -245,7 +246,7 @@ struct InFeatureEvaluator { ptin = P_InPoly(ptxyz, curfeat.nppoly, &(curfeat.polytrixyz[0])); } } else if (curfeat.type == FEATURETYPE::SPHERE) { /* Circle */ - Tangram::Vector v = ptxyz-curfeat.cen; + Wonton::Vector v = ptxyz-curfeat.cen; ptin = (v.norm(false) < curfeat.radius*curfeat.radius); // norm does not compute square root by default } else { @@ -310,7 +311,7 @@ class VolfracEvaluator<2, Mesh_Wrapper> { unsigned int seed = 0; double XMIN, XMAX, YMIN, YMAX; - std::vector> fxyz; + std::vector> fxyz; mesh_.cell_get_coordinates(cellID, &fxyz); int nfv = fxyz.size(); @@ -325,16 +326,16 @@ class VolfracEvaluator<2, Mesh_Wrapper> { double XLEN = XMAX-XMIN; double YLEN = YMAX-YMIN; - Tangram::vector pmatid(NPARTICLES, -1); + Wonton::vector pmatid(NPARTICLES, -1); srand(cellID); - Tangram::vector> ptxyz; + Wonton::vector> ptxyz; ptxyz.reserve(NPARTICLES); double xmult = XLEN/RAND_MAX; double ymult = YLEN/RAND_MAX; for (int i = 0; i < NPARTICLES; i++) { - Tangram::Point<2> xyz; + Wonton::Point<2> xyz; xyz[0] = XMIN + rand_r(&seed)*xmult; xyz[1] = YMIN + rand_r(&seed)*ymult; @@ -350,7 +351,7 @@ class VolfracEvaluator<2, Mesh_Wrapper> { // Compute a material ID for each point based on their inclusion // in a feature - Tangram::transform(ptxyz.begin(), ptxyz.end(), pmatid.begin(), + Wonton::transform(ptxyz.begin(), ptxyz.end(), pmatid.begin(), feature_evaluator_); // Tally up the particles to compute volume fractions @@ -411,7 +412,7 @@ class VolfracEvaluator<3, Mesh_Wrapper> { XMIN = YMIN = ZMIN = 1.0e+20; XMAX = YMAX = ZMAX = -XMIN; - std::vector> rxyz; + std::vector> rxyz; mesh_.cell_get_coordinates(cellID, &rxyz); int nrv = rxyz.size(); @@ -430,7 +431,7 @@ class VolfracEvaluator<3, Mesh_Wrapper> { // Get a triangular facetization of cell boundary std::vector> tripnts; - std::vector> points; + std::vector> points; // ------ Will be replaced by call to mesh_.cell_get_facetization ------- // ------ when PR-26 will get merged in --------------------------------- @@ -441,27 +442,27 @@ class VolfracEvaluator<3, Mesh_Wrapper> { int ntris = tripnts.size(); - std::vector> tripnts_flat(3*ntris); + std::vector> tripnts_flat(3*ntris); for (int t = 0; t < ntris; t++) { tripnts_flat[3*t] = points[tripnts[t][0]]; tripnts_flat[3*t+1] = points[tripnts[t][1]]; tripnts_flat[3*t+2] = points[tripnts[t][2]]; } - Tangram::vector pmatid(NPARTICLES, -1); + Wonton::vector pmatid(NPARTICLES, -1); srand(cellID); /* Throw particles into cell and see which feature they lie in */ - Tangram::vector> ptxyz; + Wonton::vector> ptxyz; ptxyz.reserve(NPARTICLES); double xmult = XLEN/RAND_MAX; double ymult = YLEN/RAND_MAX; double zmult = ZLEN/RAND_MAX; for (int i = 0; i < NPARTICLES; i++) { - Tangram::Point<3> xyz; + Wonton::Point<3> xyz; xyz[0] = XMIN + rand_r(&seed)*xmult; xyz[1] = YMIN + rand_r(&seed)*ymult; xyz[2] = ZMIN + rand_r(&seed)*zmult; @@ -479,7 +480,7 @@ class VolfracEvaluator<3, Mesh_Wrapper> { // Compute a material ID for each point based on their inclusion // in a feature - Tangram::transform(ptxyz.begin(), ptxyz.end(), pmatid.begin(), + Wonton::transform(ptxyz.begin(), ptxyz.end(), pmatid.begin(), feature_evaluator_); // Tally up the particles to compute volume fractions @@ -522,7 +523,7 @@ class VolfracEvaluator<3, Mesh_Wrapper> { void cell_get_facetization(int const cellid, std::vector> *facetpoints, - std::vector> *points) const { + std::vector> *points) const { facetpoints->clear(); points->clear(); @@ -570,7 +571,7 @@ class VolfracEvaluator<3, Mesh_Wrapper> { // the geometric center of the nodes of the face // Add centroid of face a new point to the point list - Tangram::Point<3> fcen; + Wonton::Point<3> fcen; mesh_.face_centroid(cfaces[f], &fcen); points->push_back(fcen); int icen = points->size() - 1; @@ -600,7 +601,7 @@ class VolfracEvaluator<3, Mesh_Wrapper> { template void writeAsciiFile(std::string filename, - Tangram::vector> vfcen, + Wonton::vector> vfcen, int nmats_) { std::ofstream outfile; outfile.open(filename.c_str()); @@ -617,9 +618,7 @@ void writeAsciiFile(std::string filename, outfile << "mat" << i << "\n"; /* Write out volume fractions and centroids to file */ - int ncells_nmats[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; for (int i = 0; i < ncells; i++) { - double sum = 0.0; vfcen_t vfcen_i = vfcen[i]; // device to host copy, if Thrust is used @@ -665,7 +664,7 @@ void writeAsciiFile(std::string filename, // template -void writeBinaryFile(std::string filename, Tangram::vector> vfcen) { +void writeBinaryFile(std::string filename, Wonton::vector> vfcen) { std::ofstream outfile; outfile.open(filename.c_str(), std::ofstream::out | std::ofstream::binary); if (!outfile.is_open()) { @@ -680,7 +679,6 @@ void writeBinaryFile(std::string filename, Tangram::vector> vfcen) outfile.write((char *) &ncells, sizeof(int)); /* Write out volume fractions and centroids to file */ - int ncells_nmats[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; for (int i = 0; i < ncells; i++) { vfcen_t const& vfcen_i = vfcen[i]; int nmats_cell = vfcen_i.nmats; @@ -719,14 +717,14 @@ void writeBinaryFile(std::string filename, Tangram::vector> vfcen) // 0.5 0.5 0.5 // 0.3 // # -// # PLANE -// # 'front' means consider the front of the plane -// # i.e. in direction of normal -// # Alternative to 'front' is of course 'back' +// # HALFSPACE +// # 'in' means keep points with projections onto the normal +// # less than the normal projection of the reference point +// # Alternative to 'in' is of course 'out' // # to mean behind the plane -// # Plane is specified by point and normal +// # Halfspace is specified by reference point and normal // # -// plane front 2 +// halfspace in 2 // 0.5 0.5 0.5 // 1.0 1.0 2.0 // @@ -785,7 +783,6 @@ void read_features(std::string featfilename, std::string inout_str, feat_str; - int nfeat = 0; while (!featfile.eof()) { featfile >> feat_str; @@ -833,7 +830,6 @@ void read_features(std::string featfilename, // Read points of the polygon or polyhedron featfile >> this_feature.nppoly; for (int j = 0; j < this_feature.nppoly; j++) { - double polyx, polyy; featfile >> this_feature.polyxyz[j][0]; featfile >> this_feature.polyxyz[j][1]; } @@ -852,7 +848,7 @@ void read_features(std::string featfilename, this_feature.ntris = 0; int ntripnts = 0; for (int f = 0; f < this_feature.nfpoly; f++) { - Tangram::Point fcen; // will only come here when dim == 3 + Wonton::Point fcen; // will only come here when dim == 3 int nfp = this_feature.nfpnts[f]; for (int p = 0; p < nfp; p++) fcen += this_feature.polyxyz[this_feature.fpnts[f][p]]; @@ -893,7 +889,6 @@ void read_features(std::string featfilename, continue; } } - nfeat = features->size(); featfile.close(); } // read_features diff --git a/cinch b/cinch deleted file mode 160000 index 1dbfa48..0000000 --- a/cinch +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1dbfa48349f6a9f0cf6204f454cee310c62e8f5a diff --git a/cmake/tangramConfig.cmake.in b/cmake/tangramConfig.cmake.in new file mode 100644 index 0000000..02075aa --- /dev/null +++ b/cmake/tangramConfig.cmake.in @@ -0,0 +1,65 @@ +#----------------------------------------------------------------------------- +# This file is part of the Ristra Tangram project. +# Please see the license file at the root of this repository, or at: +# https://github.com/laristra/tangram/blob/master/LICENSE +# +# TANGRAM configuration file template +# +#----------------------------------------------------------------------------- + +set(TANGRAM_VERSION_MAJOR @TANGRAM_VERSION_MAJOR@ CACHE STRING "Major version of TANGRAM") +set(TANGRAM_VERSION_MINOR @TANGRAM_VERSION_MINOR@ CACHE STRING "Minor version of TANGRAM") +set(TANGRAM_VERSION_MINOR @TANGRAM_VERSION_PATCH@ CACHE STRING "Patch version of TANGRAM") + + +# Tangram installation path +set(TANGRAM_ROOT @CMAKE_INSTALL_PREFIX@ CACHE PATH "Path to Tangram installation") + +# Tangram library +set(TANGRAM_LIBRARIES @TANGRAM_LIBRARIES@ CACHE STRING "Name of Tangram library") + +# Wonton installation path +set(WONTON_ROOT @WONTON_ROOT@ CACHE PATH "Path to Wonton installation") + + +# Have to move this into the find dependencies section +set(TANGRAM_ENABLE_XMOF2D @TANGRAM_ENABLE_XMOF2D@ CACHE BOOL "Is XMOF2D enabled?") +set(XMOF2D_LIBRARIES @XMOF2D_LIBRARIES@ CACHE STRING "XMOF2D libraries") +set(XMOF2D_ROOT @XMOF2D_ROOT@ CACHE STRING "Where XMOF2DConfig.cmake is found") + + +# Find target dependencies + +# Temporarily modify CMAKE module path so we can find our custom +# modules for packages that don't have config files + +set(SAVED_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}) +if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.15) + list(PREPEND CMAKE_MODULE_PATH @CMAKE_INSTALL_PREFIX@/lib/cmake/tangram/modules) +else () + set(CMAKE_MODULE_PATH "@CMAKE_INSTALL_PREFIX@/lib/cmake/tangram/modules;${CMAKE_MODULE_PATH}") +endif () + +include(CMakeFindDependencyMacro) + +find_dependency(WONTON REQUIRED NAMES wonton) + +if (TANGRAM_ENABLE_XMOF2D) + find_dependency(XMOF2D) +endif () + +# Restore original CMAKE_MODULE_PATH +set(CMAKE_MODULE_PATH ${SAVED_CMAKE_MODULE_PATH}) + +# +# Import Tangram targets +# + +include("@CMAKE_INSTALL_PREFIX@/lib/cmake/tangram/tangramTargets.cmake") + + + + + + + diff --git a/cmake/test_main_mpi.cc b/cmake/test_main_mpi.cc new file mode 100644 index 0000000..bca3eb8 --- /dev/null +++ b/cmake/test_main_mpi.cc @@ -0,0 +1,42 @@ +/* +This file is part of the Ristra wonton project. +Please see the license file at the root of this repository, or at: + https://github.com/laristra/wonton/blob/master/LICENSE +*/ + +#include + +#include + +//----------------------------------------------------------------------------// +// Main +//----------------------------------------------------------------------------// + +int main(int argc, char ** argv) { + + // Initialize GTest + ::testing::InitGoogleTest(&argc, argv); + + // Initialize MPI + MPI_Init(&argc, &argv); + + int rank; + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + + // Make sure listeners are present only on rank 0 - otherwise the + // output could be quite garbled + ::testing::TestEventListeners& listeners = + ::testing::UnitTest::GetInstance()->listeners(); + if (rank != 0) + delete listeners.Release(listeners.default_result_printer()); + + int result(0); + + result = RUN_ALL_TESTS(); + + // Shutdown MPI + MPI_Finalize(); + + return result; +} + diff --git a/cmake/unittest.cmake b/cmake/unittest.cmake new file mode 100644 index 0000000..a18bdb0 --- /dev/null +++ b/cmake/unittest.cmake @@ -0,0 +1,153 @@ +#[[ +This file is part of the Ristra Tangram project. +Please see the license file at the root of this repository, or at: + https://github.com/laristra/tangram/blob/master/LICENSE +]] + + +#---------------------------------------------------------------------------- +# Google Test +#---------------------------------------------------------------------------- + +find_package(GTest QUIET) # This will catch externally installed GTest + +if (NOT GTest_FOUND OR NOT TARGET GTest::gtest) # build from submodule + find_package(Threads QUIET) # Find thread libraries for system + + option(INSTALL_GTEST OFF) + add_subdirectory(googletest) + + if (NOT TARGET GTest::gtest) + if (TARGET gtest) + # Add aliases that will allow us to refer to the targets the same way + # whether we use an extern googletest installation or the one we have + # as a submodule + add_library(GTest::gtest ALIAS gtest) + add_library(GTest::gtest_main ALIAS gtest_main) + else () + message(FATAL_ERROR "Added googletest subdirectory but cannot find target GTest::gtest or gtest") + endif () + endif () +endif () + +#[===========================================================================[ +.. command:: tangram_add_unittest + +The ``tangram_add_unittest`` function creates a custom unit test with +various runtime policies:: + +tangram_add_unittest( [