diff --git a/CMakeLists.txt b/CMakeLists.txt index 33c1950f3bef..01f7a476c14a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,38 @@ INCLUDE(${CMAKE_CURRENT_LIST_DIR}/ProjectName.cmake) # not in an include file :-( PROJECT(${PROJECT_NAME} NONE) +# Set up to use ccache +if($ENV{CCACHE_NODISABLE}) +# ccache must be requested explicitly by setting env-var CCACHE_NODISABLE +find_program(CCACHE_PROGRAM ccache) +if(CCACHE_PROGRAM) + # Set up wrapper scripts + set(C_LAUNCHER "${CCACHE_PROGRAM}") + set(CXX_LAUNCHER "${CCACHE_PROGRAM}") + configure_file(launch-c.in launch-c) + configure_file(launch-cxx.in launch-cxx) + execute_process(COMMAND chmod a+rx + "${CMAKE_BINARY_DIR}/launch-c" + "${CMAKE_BINARY_DIR}/launch-cxx" + ) + + if(CMAKE_GENERATOR STREQUAL "Xcode") + # Set Xcode project attributes to route compilation and linking + # through our scripts + set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_BINARY_DIR}/launch-c") + set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_BINARY_DIR}/launch-cxx") + set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_BINARY_DIR}/launch-c") + set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_BINARY_DIR}/launch-cxx") + else() + # Support Unix Makefiles and Ninja + set(CMAKE_C_COMPILER_LAUNCHER "${CMAKE_BINARY_DIR}/launch-c") + set(CMAKE_CXX_COMPILER_LAUNCHER "${CMAKE_BINARY_DIR}/launch-cxx") + endif() +else() + message(WARNING "ccache requested but not found") +endif() +endif() + # Set an env so we know we are in configure set(ENV{CMAKE_IS_IN_CONFIGURE_MODE} 1) diff --git a/cmake/TPLs/FindTPLSuperLUDist.cmake b/cmake/TPLs/FindTPLSuperLUDist.cmake index 249f05879263..5ca9883ab471 100644 --- a/cmake/TPLs/FindTPLSuperLUDist.cmake +++ b/cmake/TPLs/FindTPLSuperLUDist.cmake @@ -81,7 +81,7 @@ int main() SET(CMAKE_REQUIRED_LIBRARIES SuperLUDist::all_libs) SET(CMAKE_REQUIRED_FLAGS ${CMAKE_EXE_LINKER_FLAGS}) - CHECK_C_SOURCE_COMPILES("${SOURCE}" ${VARNAME}) + CHECK_CXX_SOURCE_COMPILES("${SOURCE}" ${VARNAME}) ENDFUNCTION() # Version 4.0 of SuperLU_DIST changed the calling parameters of the @@ -102,7 +102,7 @@ int main() SET(CMAKE_REQUIRED_LIBRARIES SuperLUDist::all_libs) SET(CMAKE_REQUIRED_FLAGS ${CMAKE_EXE_LINKER_FLAGS}) - CHECK_C_SOURCE_COMPILES("${SOURCE}" ${VARNAME}) + CHECK_CXX_SOURCE_COMPILES("${SOURCE}" ${VARNAME}) ENDFUNCTION() IF (TPL_ENABLE_SuperLUDist) diff --git a/launch-c.in b/launch-c.in new file mode 100644 index 000000000000..59e72937b180 --- /dev/null +++ b/launch-c.in @@ -0,0 +1,10 @@ +#!/bin/bash + +# Xcode generator doesn't include the compiler as the +# first argument, Ninja and Makefiles do. Handle both cases. +if [[ "$1" = "${CMAKE_C_COMPILER}" ]] ; then + shift +fi + +export CCACHE_CPP2=true +exec "${C_LAUNCHER}" "${CMAKE_C_COMPILER}" "$@" diff --git a/launch-cxx.in b/launch-cxx.in new file mode 100644 index 000000000000..4076eff2a47f --- /dev/null +++ b/launch-cxx.in @@ -0,0 +1,10 @@ +#!/bin/bash + +# Xcode generator doesn't include the compiler as the +# first argument, Ninja and Makefiles do. Handle both cases. +if [[ "$1" = "${CMAKE_CXX_COMPILER}" ]] ; then + shift +fi + +export CCACHE_CPP2=true +exec "${CXX_LAUNCHER}" "${CMAKE_CXX_COMPILER}" "$@" diff --git a/packages/framework/ini-files/config-specs.ini b/packages/framework/ini-files/config-specs.ini index 782987c8cc1e..87efb550fc1d 100644 --- a/packages/framework/ini-files/config-specs.ini +++ b/packages/framework/ini-files/config-specs.ini @@ -723,6 +723,7 @@ opt-set-cmake-var Trilinos_ENABLE_SECONDARY_TESTED_CODE BOOL : ON [USE-RDC|YES] opt-set-cmake-var CMAKE_CXX_FLAGS STRING FORCE : ${CMAKE_CXX_FLAGS|CMAKE} --remove-duplicate-link-files opt-set-cmake-var Kokkos_ENABLE_CUDA_RELOCATABLE_DEVICE_CODE BOOL FORCE : ON +opt-set-cmake-var Stokhos_ENABLE_MueLu BOOL FORCE : OFF [USE-RDC|NO] opt-set-cmake-var Kokkos_ENABLE_CUDA_RELOCATABLE_DEVICE_CODE BOOL : OFF @@ -1882,3 +1883,198 @@ use PACKAGE-ENABLES|ALL opt-set-cmake-var Trilinos_AUTOGENERATE_TEST_RESOURCE_FILE BOOL : ON opt-set-cmake-var Trilinos_CUDA_NUM_GPUS STRING : 4 opt-set-cmake-var Trilinos_CUDA_SLOTS_PER_GPU STRING : 2 + +[rhel7_ascdo-gnu-10.3.0-serial_debug_shared_no-kokkos-arch_no-asan_no-complex_no-fpic_no-mpi_no-pt_no-rdc_no-uvm_deprecated-on_no-package-enables] +use NODE-TYPE|SERIAL +use BUILD-TYPE|DEBUG +use RHEL7_SEMS_LIB-TYPE|SHARED +use KOKKOS-ARCH|NO-KOKKOS-ARCH +use USE-ASAN|NO +use USE-COMPLEX|NO +use USE-FPIC|NO +use USE-MPI|NO +use USE-PT|NO +use USE-RDC|NO +use USE-UVM|NO +use USE-DEPRECATED|YES +use PACKAGE-ENABLES|NO-PACKAGE-ENABLES + +opt-set-cmake-var CMAKE_CXX_STANDARD STRING : 17 +opt-set-cmake-var Trilinos_ENABLE_TESTS BOOL FORCE : ON + +# There is no netcdf available via ascdo +opt-set-cmake-var TPL_ENABLE_Netcdf BOOL : OFF + +# PyTrilinos config fails with: +# -- Found NumPy: 1.21.5 (found suitable version "1.21.5", minimum required is "1.0") +# CMake Error at packages/PyTrilinos/CMakeLists.txt:206 (MESSAGE): +# SWIG version 2.0.10 is less than minimum version 3.0.11 +opt-set-cmake-var Trilinos_ENABLE_PyTrilinos BOOL : OFF + +[rhel7_ascdo-gnu-10.3.0-serial_debug_shared_no-kokkos-arch_no-asan_no-complex_no-fpic_no-mpi_no-pt_no-rdc_no-uvm_deprecated-on_all] +use rhel7_ascdo-gnu-10.3.0-serial_debug_shared_no-kokkos-arch_no-asan_no-complex_no-fpic_no-mpi_no-pt_no-rdc_no-uvm_deprecated-on_no-package-enables +use PACKAGE-ENABLES|ALL + +[rhel7_ascdo-gnu-10.3.0-openmp_debug_shared_no-kokkos-arch_no-asan_no-complex_no-fpic_no-mpi_no-pt_no-rdc_no-uvm_deprecated-on_no-package-enables] +use NODE-TYPE|OPENMP +use BUILD-TYPE|DEBUG +use RHEL7_SEMS_LIB-TYPE|SHARED +use KOKKOS-ARCH|NO-KOKKOS-ARCH +use USE-ASAN|NO +use USE-COMPLEX|NO +use USE-FPIC|NO +use USE-MPI|NO +use USE-PT|NO +use USE-RDC|NO +use USE-UVM|NO +use USE-DEPRECATED|YES +use PACKAGE-ENABLES|NO-PACKAGE-ENABLES + +opt-set-cmake-var CMAKE_CXX_STANDARD STRING : 17 +opt-set-cmake-var Trilinos_ENABLE_TESTS BOOL FORCE : ON + +# There is no netcdf available via ascdo +opt-set-cmake-var TPL_ENABLE_Netcdf BOOL : OFF + +# PyTrilinos config fails with: +# -- Found NumPy: 1.21.5 (found suitable version "1.21.5", minimum required is "1.0") +# CMake Error at packages/PyTrilinos/CMakeLists.txt:206 (MESSAGE): +# SWIG version 2.0.10 is less than minimum version 3.0.11 +opt-set-cmake-var Trilinos_ENABLE_PyTrilinos BOOL : OFF + +opt-set-cmake-var CMAKE_GENERATOR STRING : Ninja + +[rhel7_ascdo-gnu-10.3.0-openmp_debug_shared_no-kokkos-arch_no-asan_no-complex_no-fpic_no-mpi_no-pt_no-rdc_no-uvm_deprecated-on_all] +use rhel7_ascdo-gnu-10.3.0-openmp_debug_shared_no-kokkos-arch_no-asan_no-complex_no-fpic_no-mpi_no-pt_no-rdc_no-uvm_deprecated-on_no-package-enables +use PACKAGE-ENABLES|ALL + +[rhel7_ascdo-gnu-10.3.0-openmpi-4.1.4-serial_debug_shared_no-kokkos-arch_no-asan_no-complex_no-fpic_mpi_no-pt_no-rdc_no-uvm_deprecated-on_no-package-enables] +use NODE-TYPE|SERIAL +use BUILD-TYPE|DEBUG +use RHEL7_SEMS_LIB-TYPE|SHARED +use KOKKOS-ARCH|NO-KOKKOS-ARCH +use USE-ASAN|NO +use USE-COMPLEX|NO +use USE-FPIC|NO +use USE-MPI|YES +use USE-PT|NO +use USE-RDC|NO +use USE-UVM|NO +use USE-DEPRECATED|YES +use PACKAGE-ENABLES|NO-PACKAGE-ENABLES + +opt-set-cmake-var CMAKE_CXX_STANDARD STRING : 17 +opt-set-cmake-var Trilinos_ENABLE_TESTS BOOL FORCE : ON + +# There is no netcdf available via ascdo +opt-set-cmake-var TPL_ENABLE_Netcdf BOOL : OFF + +# PyTrilinos config fails with: +# -- Found NumPy: 1.21.5 (found suitable version "1.21.5", minimum required is "1.0") +# CMake Error at packages/PyTrilinos/CMakeLists.txt:206 (MESSAGE): +# SWIG version 2.0.10 is less than minimum version 3.0.11 +#opt-set-cmake-var Trilinos_ENABLE_PyTrilinos BOOL : OFF + +opt-set-cmake-var CMAKE_GENERATOR STRING : Ninja + +[rhel7_ascdo-gnu-10.3.0-openmpi-4.1.4-serial_debug_shared_no-kokkos-arch_no-asan_no-complex_no-fpic_mpi_no-pt_no-rdc_no-uvm_deprecated-on_all] +use rhel7_ascdo-gnu-10.3.0-openmpi-4.1.4-serial_debug_shared_no-kokkos-arch_no-asan_no-complex_no-fpic_mpi_no-pt_no-rdc_no-uvm_deprecated-on_no-package-enables +use PACKAGE-ENABLES|ALL + + +[rhel7_ascdo-gnu-12.1.0-serial_debug_shared_no-kokkos-arch_no-asan_no-complex_no-fpic_no-mpi_no-pt_no-rdc_no-uvm_deprecated-on_no-package-enables] +use NODE-TYPE|SERIAL +use BUILD-TYPE|DEBUG +use RHEL7_SEMS_LIB-TYPE|SHARED +use KOKKOS-ARCH|NO-KOKKOS-ARCH +use USE-ASAN|NO +use USE-COMPLEX|NO +use USE-FPIC|NO +use USE-MPI|NO +use USE-PT|NO +use USE-RDC|NO +use USE-UVM|NO +use USE-DEPRECATED|YES +use PACKAGE-ENABLES|NO-PACKAGE-ENABLES + +opt-set-cmake-var CMAKE_CXX_STANDARD STRING : 17 +opt-set-cmake-var Trilinos_ENABLE_TESTS BOOL FORCE : ON + +# There is no netcdf available via ascdo +opt-set-cmake-var TPL_ENABLE_Netcdf BOOL : OFF + +# PyTrilinos config fails with: +# -- Found NumPy: 1.21.5 (found suitable version "1.21.5", minimum required is "1.0") +# CMake Error at packages/PyTrilinos/CMakeLists.txt:206 (MESSAGE): +# SWIG version 2.0.10 is less than minimum version 3.0.11 +opt-set-cmake-var Trilinos_ENABLE_PyTrilinos BOOL : OFF + +[rhel7_ascdo-gnu-12.1.0-serial_debug_shared_no-kokkos-arch_no-asan_no-complex_no-fpic_no-mpi_no-pt_no-rdc_no-uvm_deprecated-on_all] +use rhel7_ascdo-gnu-12.1.0-serial_debug_shared_no-kokkos-arch_no-asan_no-complex_no-fpic_no-mpi_no-pt_no-rdc_no-uvm_deprecated-on_no-package-enables +use PACKAGE-ENABLES|ALL + +[rhel7_ascdo-gnu-12.1.0-openmp_debug_shared_no-kokkos-arch_no-asan_no-complex_no-fpic_no-mpi_no-pt_no-rdc_no-uvm_deprecated-on_no-package-enables] +use NODE-TYPE|OPENMP +use BUILD-TYPE|DEBUG +use RHEL7_SEMS_LIB-TYPE|SHARED +use KOKKOS-ARCH|NO-KOKKOS-ARCH +use USE-ASAN|NO +use USE-COMPLEX|NO +use USE-FPIC|NO +use USE-MPI|NO +use USE-PT|NO +use USE-RDC|NO +use USE-UVM|NO +use USE-DEPRECATED|YES +use PACKAGE-ENABLES|NO-PACKAGE-ENABLES + +opt-set-cmake-var CMAKE_CXX_STANDARD STRING : 17 +opt-set-cmake-var Trilinos_ENABLE_TESTS BOOL FORCE : ON + +# There is no netcdf available via ascdo +opt-set-cmake-var TPL_ENABLE_Netcdf BOOL : OFF + +# PyTrilinos config fails with: +# -- Found NumPy: 1.21.5 (found suitable version "1.21.5", minimum required is "1.0") +# CMake Error at packages/PyTrilinos/CMakeLists.txt:206 (MESSAGE): +# SWIG version 2.0.10 is less than minimum version 3.0.11 +opt-set-cmake-var Trilinos_ENABLE_PyTrilinos BOOL : OFF + +opt-set-cmake-var CMAKE_GENERATOR STRING : Ninja + +[rhel7_ascdo-gnu-12.1.0-openmp_debug_shared_no-kokkos-arch_no-asan_no-complex_no-fpic_no-mpi_no-pt_no-rdc_no-uvm_deprecated-on_all] +use rhel7_ascdo-gnu-12.1.0-openmp_debug_shared_no-kokkos-arch_no-asan_no-complex_no-fpic_no-mpi_no-pt_no-rdc_no-uvm_deprecated-on_no-package-enables +use PACKAGE-ENABLES|ALL + +[rhel7_ascdo-gnu-12.1.0-openmpi-4.1.4-serial_debug_shared_no-kokkos-arch_no-asan_no-complex_no-fpic_mpi_no-pt_no-rdc_no-uvm_deprecated-on_no-package-enables] +use NODE-TYPE|SERIAL +use BUILD-TYPE|DEBUG +use RHEL7_SEMS_LIB-TYPE|SHARED +use KOKKOS-ARCH|NO-KOKKOS-ARCH +use USE-ASAN|NO +use USE-COMPLEX|NO +use USE-FPIC|NO +use USE-MPI|YES +use USE-PT|NO +use USE-RDC|NO +use USE-UVM|NO +use USE-DEPRECATED|YES +use PACKAGE-ENABLES|NO-PACKAGE-ENABLES + +opt-set-cmake-var CMAKE_CXX_STANDARD STRING : 17 +opt-set-cmake-var Trilinos_ENABLE_TESTS BOOL FORCE : ON + +# There is no netcdf available via ascdo +opt-set-cmake-var TPL_ENABLE_Netcdf BOOL : OFF + +# PyTrilinos config fails with: +# -- Found NumPy: 1.21.5 (found suitable version "1.21.5", minimum required is "1.0") +# CMake Error at packages/PyTrilinos/CMakeLists.txt:206 (MESSAGE): +# SWIG version 2.0.10 is less than minimum version 3.0.11 +opt-set-cmake-var Trilinos_ENABLE_PyTrilinos BOOL : OFF + +opt-set-cmake-var CMAKE_GENERATOR STRING : Ninja + +[rhel7_ascdo-gnu-12.1.0-openmpi-4.1.4-serial_debug_shared_no-kokkos-arch_no-asan_no-complex_no-fpic_mpi_no-pt_no-rdc_no-uvm_deprecated-on_all] +use rhel7_ascdo-gnu-12.1.0-openmpi-4.1.4-serial_debug_shared_no-kokkos-arch_no-asan_no-complex_no-fpic_mpi_no-pt_no-rdc_no-uvm_deprecated-on_no-package-enables +use PACKAGE-ENABLES|ALL diff --git a/packages/framework/ini-files/supported-envs.ini b/packages/framework/ini-files/supported-envs.ini index 6821c58c0a8c..6d37af6ccc1d 100644 --- a/packages/framework/ini-files/supported-envs.ini +++ b/packages/framework/ini-files/supported-envs.ini @@ -155,3 +155,9 @@ sems-cuda-11.4.2-sems-gnu-10.1.0-sems-openmpi-4.0.5: sems-cuda-11.4.2 sems-intel-2021.3-sems-openmpi-4.0.5: sems-intel-2021.3 +ascdo-gnu-10.3.0-serial +ascdo-gnu-10.3.0-openmp +ascdo-gnu-10.3.0-openmpi-4.1.4-serial +ascdo-gnu-12.1.0-serial +ascdo-gnu-12.1.0-openmp +ascdo-gnu-12.1.0-openmpi-4.1.4-serial diff --git a/packages/muelu/CMakeLists.txt b/packages/muelu/CMakeLists.txt index 9833457fd50f..d9c9ab309bda 100644 --- a/packages/muelu/CMakeLists.txt +++ b/packages/muelu/CMakeLists.txt @@ -106,6 +106,18 @@ IF (NOT ${PACKAGE_NAME}_ENABLE_Tpetra) GLOBAL_SET(HAVE_${PACKAGE_NAME_UC}_IFPACK2 OFF) ENDIF () + +# Print a warning when we might be lacking a coarse solver. +ASSERT_DEFINED(${PACKAGE_NAME}_ENABLE_Amesos) +IF (${PACKAGE_NAME}_ENABLE_Epetra AND NOT ${PACKAGE_NAME}_ENABLE_Amesos) + MESSAGE(WARNING "MueLu's Epetra backend is enabled, but Amesos is disabled. This means only iterative coarse solves are available when using Epetra.") +ENDIF () +ASSERT_DEFINED(${PACKAGE_NAME}_ENABLE_Amesos2) +IF (${PACKAGE_NAME}_ENABLE_Tpetra AND NOT ${PACKAGE_NAME}_ENABLE_Amesos2) + MESSAGE(WARNING "MueLu's Tpetra backend is enabled, but Amesos2 is disabled. This means only iterative coarse solves are available when using Tpetra.") +ENDIF () + + # Enable experimental code TRIBITS_ADD_OPTION_AND_DEFINE( ${PACKAGE_NAME}_ENABLE_Experimental diff --git a/packages/panzer/adapters-stk/example/CurlLaplacianExample/CMakeLists.txt b/packages/panzer/adapters-stk/example/CurlLaplacianExample/CMakeLists.txt index 1ba16b9cdd28..a1f8655edd18 100644 --- a/packages/panzer/adapters-stk/example/CurlLaplacianExample/CMakeLists.txt +++ b/packages/panzer/adapters-stk/example/CurlLaplacianExample/CMakeLists.txt @@ -10,19 +10,31 @@ TRIBITS_ADD_EXECUTABLE( SOURCES ${ASSEMBLY_EXAMPLE_SOURCES} ) -TRIBITS_ADD_ADVANCED_TEST( - CurlLaplacianExample - EXCLUDE_IF_NOT_TRUE ${${PARENT_PACKAGE_NAME}_ADD_EXPENSIVE_CUDA_TESTS} - TEST_0 EXEC CurlLaplacianExample - ARGS --use-epetra --output-filename="base-curl-test-" - PASS_REGULAR_EXPRESSION "ALL PASSED: Epetra" - NUM_MPI_PROCS 4 - TEST_1 EXEC CurlLaplacianExample - ARGS --use-tpetra --output-filename="base-curl-test-" - PASS_REGULAR_EXPRESSION "ALL PASSED: Tpetra" - NUM_MPI_PROCS 4 - COMM mpi - ) +IF(PANZER_HAVE_EPETRA) + TRIBITS_ADD_ADVANCED_TEST( + CurlLaplacianExample + EXCLUDE_IF_NOT_TRUE ${${PARENT_PACKAGE_NAME}_ADD_EXPENSIVE_CUDA_TESTS} + TEST_0 EXEC CurlLaplacianExample + ARGS --use-epetra --output-filename="base-curl-test-" + PASS_REGULAR_EXPRESSION "ALL PASSED: Epetra" + NUM_MPI_PROCS 4 + TEST_1 EXEC CurlLaplacianExample + ARGS --use-tpetra --output-filename="base-curl-test-" + PASS_REGULAR_EXPRESSION "ALL PASSED: Tpetra" + NUM_MPI_PROCS 4 + COMM mpi + ) +ELSE(PANZER_HAVE_EPETRA) + TRIBITS_ADD_ADVANCED_TEST( + CurlLaplacianExample + EXCLUDE_IF_NOT_TRUE ${${PARENT_PACKAGE_NAME}_ADD_EXPENSIVE_CUDA_TESTS} + TEST_0 EXEC CurlLaplacianExample + ARGS --use-tpetra --output-filename="base-curl-test-" + PASS_REGULAR_EXPRESSION "ALL PASSED: Tpetra" + NUM_MPI_PROCS 4 + COMM mpi + ) +ENDIF(PANZER_HAVE_EPETRA) FOREACH( ORDER 1 2 3 4 ) TRIBITS_ADD_ADVANCED_TEST( diff --git a/packages/panzer/adapters-stk/example/MixedCurlLaplacianExample/CMakeLists.txt b/packages/panzer/adapters-stk/example/MixedCurlLaplacianExample/CMakeLists.txt index 21a44dee18e9..1240537da054 100644 --- a/packages/panzer/adapters-stk/example/MixedCurlLaplacianExample/CMakeLists.txt +++ b/packages/panzer/adapters-stk/example/MixedCurlLaplacianExample/CMakeLists.txt @@ -10,19 +10,31 @@ TRIBITS_ADD_EXECUTABLE( SOURCES ${ASSEMBLY_EXAMPLE_SOURCES} ) -TRIBITS_ADD_ADVANCED_TEST( - MixedCurlLaplacianExample - EXCLUDE_IF_NOT_TRUE ${${PARENT_PACKAGE_NAME}_ADD_EXPENSIVE_CUDA_TESTS} - TEST_0 EXEC MixedCurlLaplacianExample - ARGS --use-epetra --output-filename="base-curl-test-" - PASS_REGULAR_EXPRESSION "ALL PASSED: Epetra" - NUM_MPI_PROCS 4 - TEST_1 EXEC MixedCurlLaplacianExample - ARGS --use-tpetra --output-filename="base-curl-test-" - PASS_REGULAR_EXPRESSION "ALL PASSED: Tpetra" - NUM_MPI_PROCS 4 - COMM mpi - ) +IF(PANZER_HAVE_EPETRA) + TRIBITS_ADD_ADVANCED_TEST( + MixedCurlLaplacianExample + EXCLUDE_IF_NOT_TRUE ${${PARENT_PACKAGE_NAME}_ADD_EXPENSIVE_CUDA_TESTS} + TEST_0 EXEC MixedCurlLaplacianExample + ARGS --use-epetra --output-filename="base-curl-test-" + PASS_REGULAR_EXPRESSION "ALL PASSED: Epetra" + NUM_MPI_PROCS 4 + TEST_1 EXEC MixedCurlLaplacianExample + ARGS --use-tpetra --output-filename="base-curl-test-" + PASS_REGULAR_EXPRESSION "ALL PASSED: Tpetra" + NUM_MPI_PROCS 4 + COMM mpi + ) +ELSE(PANZER_HAVE_EPETRA) + TRIBITS_ADD_ADVANCED_TEST( + MixedCurlLaplacianExample + EXCLUDE_IF_NOT_TRUE ${${PARENT_PACKAGE_NAME}_ADD_EXPENSIVE_CUDA_TESTS} + TEST_0 EXEC MixedCurlLaplacianExample + ARGS --use-tpetra --output-filename="base-curl-test-" + PASS_REGULAR_EXPRESSION "ALL PASSED: Tpetra" + NUM_MPI_PROCS 4 + COMM mpi + ) +ENDIF(PANZER_HAVE_EPETRA) FOREACH( ORDER 1 2 ) TRIBITS_ADD_ADVANCED_TEST( diff --git a/packages/panzer/adapters-stk/example/MixedPoissonExample/CMakeLists.txt b/packages/panzer/adapters-stk/example/MixedPoissonExample/CMakeLists.txt index 19d7ed50f62c..ad1f7a999de2 100644 --- a/packages/panzer/adapters-stk/example/MixedPoissonExample/CMakeLists.txt +++ b/packages/panzer/adapters-stk/example/MixedPoissonExample/CMakeLists.txt @@ -10,19 +10,31 @@ TRIBITS_ADD_EXECUTABLE( SOURCES ${ASSEMBLY_EXAMPLE_SOURCES} ) -TRIBITS_ADD_ADVANCED_TEST( - MixedPoissonExample - EXCLUDE_IF_NOT_TRUE ${PARENT_PACKAGE_NAME}_ADD_EXPENSIVE_CUDA_TESTS - TEST_0 EXEC MixedPoissonExample - ARGS --use-epetra --x-elements=5 --y-elements=5 --z-elements=5 --output-filename="base_mixed_poisson_epetra_" - PASS_REGULAR_EXPRESSION "ALL PASSED: Epetra" - NUM_MPI_PROCS 4 - TEST_1 EXEC MixedPoissonExample - ARGS --use-tpetra --x-elements=5 --y-elements=5 --z-elements=5 --output-filename="base_mixed_poisson_tpetra_" - PASS_REGULAR_EXPRESSION "ALL PASSED: Tpetra" - NUM_MPI_PROCS 4 - COMM mpi +IF (PANZER_HAVE_EPETRA) + TRIBITS_ADD_ADVANCED_TEST( + MixedPoissonExample + EXCLUDE_IF_NOT_TRUE ${PARENT_PACKAGE_NAME}_ADD_EXPENSIVE_CUDA_TESTS + TEST_0 EXEC MixedPoissonExample + ARGS --use-epetra --x-elements=5 --y-elements=5 --z-elements=5 --output-filename="base_mixed_poisson_epetra_" + PASS_REGULAR_EXPRESSION "ALL PASSED: Epetra" + NUM_MPI_PROCS 4 + TEST_1 EXEC MixedPoissonExample + ARGS --use-tpetra --x-elements=5 --y-elements=5 --z-elements=5 --output-filename="base_mixed_poisson_tpetra_" + PASS_REGULAR_EXPRESSION "ALL PASSED: Tpetra" + NUM_MPI_PROCS 4 + COMM mpi + ) +ELSE (PANZER_HAVE_EPETRA) + TRIBITS_ADD_ADVANCED_TEST( + MixedPoissonExample + EXCLUDE_IF_NOT_TRUE ${PARENT_PACKAGE_NAME}_ADD_EXPENSIVE_CUDA_TESTS + TEST_0 EXEC MixedPoissonExample + ARGS --use-tpetra --x-elements=5 --y-elements=5 --z-elements=5 --output-filename="base_mixed_poisson_tpetra_" + PASS_REGULAR_EXPRESSION "ALL PASSED: Tpetra" + NUM_MPI_PROCS 4 + COMM mpi ) +ENDIF (PANZER_HAVE_EPETRA) ## basis order 1-3 FOREACH( ORDER 1 2 3) diff --git a/packages/panzer/adapters-stk/src/Panzer_STK_ParameterListCallbackBlocked.cpp b/packages/panzer/adapters-stk/src/Panzer_STK_ParameterListCallbackBlocked.cpp index 03e5c6834f40..2d8f883f7ae3 100644 --- a/packages/panzer/adapters-stk/src/Panzer_STK_ParameterListCallbackBlocked.cpp +++ b/packages/panzer/adapters-stk/src/Panzer_STK_ParameterListCallbackBlocked.cpp @@ -104,9 +104,11 @@ bool ParameterListCallbackBlocked::handlesRequest(const Teko::RequestMesg & rm) if(pl->isType("Coordinates")){ field = pl->get("Coordinates"); } +#ifdef PANZER_HAVE_EPETRA if(pl->isType("Coordinates-Epetra")){ field = pl->get("Coordinates-Epetra"); } +#endif return isHandled; } @@ -141,10 +143,13 @@ void ParameterListCallbackBlocked::preRequest(const Teko::RequestMesg & rm) block = blocked_ugi_->getFieldBlock(blocked_ugi_->getFieldNum(field)); // Empty... Nothing to do. +#ifdef PANZER_HAVE_EPETRA if (rm.getParameterList()->isType("Coordinates-Epetra")) { buildArrayToVectorEpetra(block, field, useAux); buildCoordinatesEpetra(field, useAux); - } else { + } else +#endif + { buildArrayToVectorTpetra(block, field, useAux); buildCoordinatesTpetra(field, useAux); } @@ -166,9 +171,11 @@ void ParameterListCallbackBlocked::setFieldByKey(const std::string & key,const s pl.set(key,z); } else if(key == "Coordinates") { pl.set > >(key,coordsVecTp_); +#ifdef PANZER_HAVE_EPETRA } else if(key == "Coordinates-Epetra") { pl.set >("Coordinates",coordsVecEp_); // pl.remove("Coordinates-Epetra"); +#endif } else TEUCHOS_TEST_FOR_EXCEPTION(true,std::runtime_error, @@ -187,6 +194,7 @@ void ParameterListCallbackBlocked::buildArrayToVectorTpetra(int block,const std: } } +#ifdef PANZER_HAVE_EPETRA void ParameterListCallbackBlocked::buildArrayToVectorEpetra(int block,const std::string & field, const bool useAux) { if(arrayToVectorEpetra_[field]==Teuchos::null) { @@ -198,6 +206,7 @@ void ParameterListCallbackBlocked::buildArrayToVectorEpetra(int block,const std: arrayToVectorEpetra_[field] = Teuchos::rcp(new panzer::ArrayToFieldVectorEpetra(ugi)); } } +#endif void ParameterListCallbackBlocked::buildCoordinatesTpetra(const std::string & field, const bool useAux) { @@ -256,6 +265,7 @@ void ParameterListCallbackBlocked::buildCoordinatesTpetra(const std::string & fi } } +#ifdef PANZER_HAVE_EPETRA void ParameterListCallbackBlocked::buildCoordinatesEpetra(const std::string & field, const bool useAux) { std::map > data; @@ -293,6 +303,7 @@ void ParameterListCallbackBlocked::buildCoordinatesEpetra(const std::string & fi coordsVecEp_ = arrayToVectorEpetra_[field]->template getDataVector(field,data); } +#endif std::string ParameterListCallbackBlocked:: getHandledField(const Teuchos::ParameterList & pl) const @@ -302,11 +313,16 @@ getHandledField(const Teuchos::ParameterList & pl) const return pl.get("x-coordinates"); else if(pl.isType("Coordinates")) return pl.get("Coordinates"); +#ifdef PANZER_HAVE_EPETRA else if(pl.isType("Coordinates-Epetra")) return pl.get("Coordinates-Epetra"); +#endif else +#ifdef PANZER_HAVE_EPETRA TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,"Neither x-coordinates nor Coordinates or Coordinates-Epetra field provided."); - +#else + TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,"Neither x-coordinates or Coordinates field provided."); +#endif } const std::vector & ParameterListCallbackBlocked:: diff --git a/packages/panzer/adapters-stk/src/Panzer_STK_ParameterListCallbackBlocked.hpp b/packages/panzer/adapters-stk/src/Panzer_STK_ParameterListCallbackBlocked.hpp index b325eb7c89ab..74fc91b44b49 100644 --- a/packages/panzer/adapters-stk/src/Panzer_STK_ParameterListCallbackBlocked.hpp +++ b/packages/panzer/adapters-stk/src/Panzer_STK_ParameterListCallbackBlocked.hpp @@ -53,7 +53,9 @@ #include "Panzer_STKConnManager.hpp" #include "Panzer_GlobalIndexer_Utilities.hpp" +#ifdef PANZER_HAVE_EPETRA #include "Panzer_GlobalIndexer_EpetraUtilities.hpp" +#endif #include "Panzer_BlockedDOFManager.hpp" #include @@ -102,9 +104,12 @@ class ParameterListCallbackBlocked : public Teko::RequestCallback > zcoords_; mutable std::map > arrayToVectorTpetra_; +#ifdef PANZER_HAVE_EPETRA mutable std::map > arrayToVectorEpetra_; +#endif Teuchos::RCP > coordsVecTp_; +#ifdef PANZER_HAVE_EPETRA Teuchos::RCP coordsVecEp_; +#endif bool returnTpetraObjects_; }; diff --git a/packages/panzer/adapters-stk/src/Panzer_STK_SetupLOWSFactory.cpp b/packages/panzer/adapters-stk/src/Panzer_STK_SetupLOWSFactory.cpp index f27bb254aa50..b5dabc2c8d08 100644 --- a/packages/panzer/adapters-stk/src/Panzer_STK_SetupLOWSFactory.cpp +++ b/packages/panzer/adapters-stk/src/Panzer_STK_SetupLOWSFactory.cpp @@ -42,8 +42,6 @@ #include "PanzerAdaptersSTK_config.hpp" -#ifdef PANZER_HAVE_EPETRA - #include "Panzer_STK_SetupLOWSFactory.hpp" #include "Panzer_STK_ParameterListCallback.hpp" #include "Panzer_STK_ParameterListCallbackBlocked.hpp" @@ -52,11 +50,12 @@ #include "Stratimikos_DefaultLinearSolverBuilder.hpp" +#ifdef PANZER_HAVE_EPETRA #include "Epetra_MpiComm.h" #include "Epetra_Vector.h" #include "EpetraExt_VectorOut.h" - #include "ml_rbm.h" +#endif // PANZER_HAVE_EPETRA #include "Tpetra_Map.hpp" #include "Tpetra_MultiVector.hpp" @@ -287,6 +286,7 @@ namespace { const std::vector & zcoords = callback->getZCoordsVector(); // use epetra to write coordinates to matrix market files +#ifdef PANZER_HAVE_EPETRA Epetra_MpiComm ep_comm(*mpi_comm->getRawMpiComm()); // this is OK access to RawMpiComm becase its declared on the stack? // and all users of this object are on the stack (within scope of mpi_comm Epetra_Map map(-1,xcoords.size(),0,ep_comm); @@ -308,9 +308,12 @@ namespace { default: TEUCHOS_ASSERT(false); } +#else + TEUCHOS_TEST_FOR_EXCEPTION(true,std::runtime_error,"ERROR: Panzer_STK_SetupLOWSFactory.cpp - writeCoordinates not implemented for Tpetra yet!"); +#endif } - #ifdef PANZER_HAVE_MUELU +#ifdef PANZER_HAVE_MUELU if(rcp_dynamic_cast(globalIndexer)!=Teuchos::null && useCoordinates) { if(!writeCoordinates) @@ -379,6 +382,7 @@ namespace { Teko::addTekoToStratimikosBuilder(linearSolverBuilder,reqHandler_local); if(writeCoordinates) { +#ifdef PANZER_HAVE_EPETRA RCP blkDofs = rcp_dynamic_cast(globalIndexer); @@ -466,6 +470,9 @@ namespace { #endif } /* end loop over all physical fields */ +#else // PANZER_HAVE EPETRA + TEUCHOS_TEST_FOR_EXCEPTION(true,std::runtime_error,"ERROR: Panzer_STK_SetupLOWSFactory - writeCoordinates not implemented for Tpetra yet!") +#endif } if(writeTopo) { @@ -528,5 +535,3 @@ namespace { return Teuchos::null; } } - -#endif // PANZER_HAVE_EPETRA diff --git a/packages/panzer/dof-mgr/src/Panzer_ElemFieldPattern.cpp b/packages/panzer/dof-mgr/src/Panzer_ElemFieldPattern.cpp index fee2650a6edd..963dd84f1105 100644 --- a/packages/panzer/dof-mgr/src/Panzer_ElemFieldPattern.cpp +++ b/packages/panzer/dof-mgr/src/Panzer_ElemFieldPattern.cpp @@ -71,7 +71,7 @@ int ElemFieldPattern::getSubcellCount(int dim) const const std::vector & ElemFieldPattern::getSubcellIndices(int dim,int cellIndex) const { - if(dim==3) + if(dim==getDimension()) return ElemIndices_[cellIndex]; // only Elems diff --git a/packages/panzer/dof-mgr/test/field_pattern/CMakeLists.txt b/packages/panzer/dof-mgr/test/field_pattern/CMakeLists.txt index 8470b23b1f7b..2e4464e00569 100644 --- a/packages/panzer/dof-mgr/test/field_pattern/CMakeLists.txt +++ b/packages/panzer/dof-mgr/test/field_pattern/CMakeLists.txt @@ -26,3 +26,9 @@ TRIBITS_ADD_EXECUTABLE_AND_TEST( SOURCES tFieldAggPattern_DG.cpp ${UNIT_TEST_DRIVER} COMM serial mpi ) + +TRIBITS_ADD_EXECUTABLE_AND_TEST( + tEntityFieldPattern + SOURCES tEntityFieldPattern.cpp ${UNIT_TEST_DRIVER} + COMM serial mpi + ) diff --git a/packages/panzer/dof-mgr/test/field_pattern/tEntityFieldPattern.cpp b/packages/panzer/dof-mgr/test/field_pattern/tEntityFieldPattern.cpp new file mode 100644 index 000000000000..1313bba8106f --- /dev/null +++ b/packages/panzer/dof-mgr/test/field_pattern/tEntityFieldPattern.cpp @@ -0,0 +1,222 @@ +// @HEADER +// *********************************************************************** +// +// Panzer: A partial differential equation assembly +// engine for strongly coupled complex multiphysics systems +// Copyright (2011) Sandia Corporation +// +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +// the U.S. Government retains certain rights in this software. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. Neither the name of the Corporation nor the names of the +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Questions? Contact Roger P. Pawlowski (rppawlo@sandia.gov) and +// Eric C. Cyr (eccyr@sandia.gov) +// *********************************************************************** +// @HEADER + +#include +#include +#include +#include + +#include +#include + +#include "Panzer_NodalFieldPattern.hpp" +#include "Panzer_EdgeFieldPattern.hpp" +#include "Panzer_FaceFieldPattern.hpp" +#include "Panzer_ElemFieldPattern.hpp" + +using Teuchos::rcp; +using Teuchos::rcp_dynamic_cast; +using Teuchos::RCP; +using Teuchos::rcpFromRef; + +namespace panzer { + + std::string note = "*** NOTE: UNIT TEST BASED ON SEPT 2010 ***\n" + "*** INTREPID AND SHARDS Trilinos-dev ***\n" + "*** DOXYGEN WEBSITE ***\n"; + + // Nodal FP + TEUCHOS_UNIT_TEST(tEntityFieldPattern, node) + { + using namespace shards; + out << note << std::endl; + + auto hexa = CellTopology(getCellTopologyData>()); + auto tria = CellTopology(getCellTopologyData>()); + auto line = CellTopology(getCellTopologyData>()); + + NodalFieldPattern fp_hexa (hexa); + NodalFieldPattern fp_tria (tria); + NodalFieldPattern fp_line (line); + + TEST_ASSERT (fp_hexa.getDimension()==3); + TEST_ASSERT (fp_tria.getDimension()==2); + TEST_ASSERT (fp_line.getDimension()==1); + + // Nodes + TEST_ASSERT (fp_hexa.getSubcellIndices(0,0).size()==1); + TEST_ASSERT (fp_tria.getSubcellIndices(0,0).size()==1); + TEST_ASSERT (fp_line.getSubcellIndices(0,0).size()==1); + + // Edges + TEST_ASSERT (fp_hexa.getSubcellIndices(1,0).size()==0); + TEST_ASSERT (fp_tria.getSubcellIndices(1,0).size()==0); + TEST_ASSERT (fp_line.getSubcellIndices(1,0).size()==0); + + // Faces + TEST_ASSERT (fp_hexa.getSubcellIndices(2,0).size()==0); + TEST_ASSERT (fp_tria.getSubcellIndices(2,0).size()==0); + TEST_ASSERT (fp_line.getSubcellIndices(2,0).size()==0); + + // Volumes + TEST_ASSERT (fp_hexa.getSubcellIndices(3,0).size()==0); + TEST_ASSERT (fp_tria.getSubcellIndices(3,0).size()==0); + TEST_ASSERT (fp_line.getSubcellIndices(3,0).size()==0); + } + + // Edge FP + TEUCHOS_UNIT_TEST(tEntityFieldPattern, edge) + { + using namespace shards; + out << note << std::endl; + + auto hexa = CellTopology(getCellTopologyData>()); + auto tria = CellTopology(getCellTopologyData>()); + auto line = CellTopology(getCellTopologyData>()); + + EdgeFieldPattern fp_hexa (hexa); + EdgeFieldPattern fp_tria (tria); + EdgeFieldPattern fp_line (line); + + TEST_ASSERT (fp_hexa.getDimension()==3); + TEST_ASSERT (fp_tria.getDimension()==2); + TEST_ASSERT (fp_line.getDimension()==1); + + // Nodes + TEST_ASSERT (fp_hexa.getSubcellIndices(0,0).size()==0); + TEST_ASSERT (fp_tria.getSubcellIndices(0,0).size()==0); + TEST_ASSERT (fp_line.getSubcellIndices(0,0).size()==0); + + // Edges + TEST_ASSERT (fp_hexa.getSubcellIndices(1,0).size()==1); + TEST_ASSERT (fp_tria.getSubcellIndices(1,0).size()==1); + TEST_ASSERT (fp_line.getSubcellIndices(1,0).size()==1); + + // Faces + TEST_ASSERT (fp_hexa.getSubcellIndices(2,0).size()==0); + TEST_ASSERT (fp_tria.getSubcellIndices(2,0).size()==0); + TEST_ASSERT (fp_line.getSubcellIndices(2,0).size()==0); + + // Volumes + TEST_ASSERT (fp_hexa.getSubcellIndices(3,0).size()==0); + TEST_ASSERT (fp_tria.getSubcellIndices(3,0).size()==0); + TEST_ASSERT (fp_line.getSubcellIndices(3,0).size()==0); + } + + // Face FP + TEUCHOS_UNIT_TEST(tEntityFieldPattern, face) + { + using namespace shards; + out << note << std::endl; + + auto hexa = CellTopology(getCellTopologyData>()); + auto tria = CellTopology(getCellTopologyData>()); + auto line = CellTopology(getCellTopologyData>()); + + FaceFieldPattern fp_hexa (hexa); + FaceFieldPattern fp_tria (tria); + FaceFieldPattern fp_line (line); + + TEST_ASSERT (fp_hexa.getDimension()==3); + TEST_ASSERT (fp_tria.getDimension()==2); + TEST_ASSERT (fp_line.getDimension()==1); + + // Nodes + TEST_ASSERT (fp_hexa.getSubcellIndices(0,0).size()==0); + TEST_ASSERT (fp_tria.getSubcellIndices(0,0).size()==0); + TEST_ASSERT (fp_line.getSubcellIndices(0,0).size()==0); + + // Edges + TEST_ASSERT (fp_hexa.getSubcellIndices(1,0).size()==0); + TEST_ASSERT (fp_tria.getSubcellIndices(1,0).size()==0); + TEST_ASSERT (fp_line.getSubcellIndices(1,0).size()==0); + + // Faces + TEST_ASSERT (fp_hexa.getSubcellIndices(2,0).size()==1); + TEST_ASSERT (fp_tria.getSubcellIndices(2,0).size()==1); + TEST_ASSERT (fp_line.getSubcellIndices(2,0).size()==1); + + // Volumes + TEST_ASSERT (fp_hexa.getSubcellIndices(3,0).size()==0); + TEST_ASSERT (fp_tria.getSubcellIndices(3,0).size()==0); + TEST_ASSERT (fp_line.getSubcellIndices(3,0).size()==0); + } + + // Elem FP + TEUCHOS_UNIT_TEST(tEntityFieldPattern, elem) + { + using namespace shards; + out << note << std::endl; + + auto hexa = CellTopology(getCellTopologyData>()); + auto tria = CellTopology(getCellTopologyData>()); + auto line = CellTopology(getCellTopologyData>()); + + ElemFieldPattern fp_hexa (hexa); + ElemFieldPattern fp_tria (tria); + ElemFieldPattern fp_line (line); + + TEST_ASSERT (fp_hexa.getDimension()==3); + TEST_ASSERT (fp_tria.getDimension()==2); + TEST_ASSERT (fp_line.getDimension()==1); + + // Nodes + TEST_ASSERT (fp_hexa.getSubcellIndices(0,0).size()==0); + TEST_ASSERT (fp_tria.getSubcellIndices(0,0).size()==0); + TEST_ASSERT (fp_line.getSubcellIndices(0,0).size()==0); + + // Edges + TEST_ASSERT (fp_hexa.getSubcellIndices(1,0).size()==0); + TEST_ASSERT (fp_tria.getSubcellIndices(1,0).size()==0); + TEST_ASSERT (fp_line.getSubcellIndices(1,0).size()==1); // Edge==Element + + // Faces + TEST_ASSERT (fp_hexa.getSubcellIndices(2,0).size()==0); + TEST_ASSERT (fp_tria.getSubcellIndices(2,0).size()==1); // Face==Element + TEST_ASSERT (fp_line.getSubcellIndices(2,0).size()==0); + + // Volumes + TEST_ASSERT (fp_hexa.getSubcellIndices(3,0).size()==1); + TEST_ASSERT (fp_tria.getSubcellIndices(3,0).size()==0); + TEST_ASSERT (fp_line.getSubcellIndices(3,0).size()==0); + } +} diff --git a/packages/panzer/mini-em/example/BlockPrec/main.cpp b/packages/panzer/mini-em/example/BlockPrec/main.cpp index 6c0ab3d9149e..ffb03788efa5 100644 --- a/packages/panzer/mini-em/example/BlockPrec/main.cpp +++ b/packages/panzer/mini-em/example/BlockPrec/main.cpp @@ -23,8 +23,10 @@ #include "Panzer_String_Utilities.hpp" #include "Panzer_TpetraLinearObjContainer.hpp" #include "Panzer_BlockedTpetraLinearObjFactory.hpp" +#ifdef PANZER_HAVE_EPETRA #include "Panzer_EpetraLinearObjContainer.hpp" #include "Panzer_BlockedEpetraLinearObjFactory.hpp" +#endif #include "Panzer_ElementBlockIdToPhysicsIdMap.hpp" #include "Panzer_DOFManagerFactory.hpp" #include "Panzer_BlockedDOFManagerFactory.hpp" @@ -1055,10 +1057,12 @@ int main(int argc,char * argv[]){ typedef typename panzer::BlockedTpetraLinearObjFactory blockedLinObjFactory; retVal = main_(clp, argc, argv); // } +#ifdef PANZER_HAVE_EPETRA } else if (linAlgebra == linAlgEpetra) { // TEUCHOS_ASSERT(!useComplex); typedef typename panzer::BlockedEpetraLinearObjFactory blockedLinObjFactory; retVal = main_(clp, argc, argv); +#endif } else TEUCHOS_ASSERT(false); diff --git a/packages/panzer/mini-em/src/eqn_sets/MiniEM_AuxiliaryEquationSet_MassMatrix_impl.hpp b/packages/panzer/mini-em/src/eqn_sets/MiniEM_AuxiliaryEquationSet_MassMatrix_impl.hpp index 623fae10323c..de14482f78a9 100644 --- a/packages/panzer/mini-em/src/eqn_sets/MiniEM_AuxiliaryEquationSet_MassMatrix_impl.hpp +++ b/packages/panzer/mini-em/src/eqn_sets/MiniEM_AuxiliaryEquationSet_MassMatrix_impl.hpp @@ -21,7 +21,9 @@ #include "Panzer_Constant.hpp" #include "Panzer_BlockedDOFManager.hpp" #include "Panzer_BlockedTpetraLinearObjFactory.hpp" +#ifdef PANZER_HAVE_EPETRA #include "Panzer_BlockedEpetraLinearObjFactory.hpp" +#endif #include "Panzer_ReorderADValues_Evaluator.hpp" #include "Panzer_LOCPair_GlobalEvaluationData.hpp" @@ -165,14 +167,18 @@ buildAndRegisterScatterEvaluators(PHX::FieldManager& fm, typedef panzer::Traits::Jacobian EvalT; typedef double Scalar; +#ifdef PANZER_HAVE_EPETRA typedef int LocalOrdinalEpetra; +#endif typedef int LocalOrdinalTpetra; typedef panzer::GlobalOrdinal GlobalOrdinalTpetra; typedef typename panzer::BlockedTpetraLinearObjFactory blockedTpetraLinObjFactory; typedef typename panzer::TpetraLinearObjFactory tpetraLinObjFactory; +#ifdef PANZER_HAVE_EPETRA typedef typename panzer::BlockedEpetraLinearObjFactory blockedEpetraLinObjFactory; typedef typename panzer::BlockedEpetraLinearObjFactory epetraLinObjFactory; +#endif std::string fieldStr = (*this->m_dof_names)[0]; const std::string residualField = "AUX_MASS_RESIDUAL_"+opLabel+dof_name; @@ -186,8 +192,10 @@ buildAndRegisterScatterEvaluators(PHX::FieldManager& fm, // must be able to cast to a block linear object factory Teuchos::RCP tblof = Teuchos::rcp_dynamic_cast(Teuchos::rcpFromRef(lof)); +#ifdef PANZER_HAVE_EPETRA Teuchos::RCP eblof = Teuchos::rcp_dynamic_cast(Teuchos::rcpFromRef(lof)); +#endif if(tblof != Teuchos::null) { Teuchos::RCP blockedDOFMngr = tblof->getGlobalIndexer(); @@ -220,7 +228,7 @@ buildAndRegisterScatterEvaluators(PHX::FieldManager& fm, fm.registerEvaluator(op); } - +#ifdef PANZER_HAVE_EPETRA } else if(eblof != Teuchos::null) { Teuchos::RCP blockedDOFMngr = eblof->getGlobalIndexer(); TEUCHOS_ASSERT(blockedDOFMngr!=Teuchos::null); @@ -252,6 +260,7 @@ buildAndRegisterScatterEvaluators(PHX::FieldManager& fm, fm.registerEvaluator(op); } +#endif } else TEUCHOS_ASSERT(false); diff --git a/packages/panzer/mini-em/src/eqn_sets/MiniEM_AuxiliaryEquationSet_ProjectedSchurComplement_impl.hpp b/packages/panzer/mini-em/src/eqn_sets/MiniEM_AuxiliaryEquationSet_ProjectedSchurComplement_impl.hpp index 05c7532a887d..1b0b694f7842 100644 --- a/packages/panzer/mini-em/src/eqn_sets/MiniEM_AuxiliaryEquationSet_ProjectedSchurComplement_impl.hpp +++ b/packages/panzer/mini-em/src/eqn_sets/MiniEM_AuxiliaryEquationSet_ProjectedSchurComplement_impl.hpp @@ -22,7 +22,9 @@ #include "Panzer_Constant.hpp" #include "Panzer_BlockedDOFManager.hpp" #include "Panzer_BlockedTpetraLinearObjFactory.hpp" +#ifdef PANZER_HAVE_EPETRA #include "Panzer_BlockedEpetraLinearObjFactory.hpp" +#endif #include "Panzer_ReorderADValues_Evaluator.hpp" #include "Panzer_LOCPair_GlobalEvaluationData.hpp" @@ -167,14 +169,18 @@ buildAndRegisterScatterEvaluators(PHX::FieldManager& fm, typedef panzer::Traits::Jacobian EvalT; typedef double Scalar; +#ifdef PANZER_HAVE_EPETRA typedef int LocalOrdinalEpetra; +#endif typedef int LocalOrdinalTpetra; typedef panzer::GlobalOrdinal GlobalOrdinalTpetra; typedef typename panzer::BlockedTpetraLinearObjFactory blockedTpetraLinObjFactory; typedef typename panzer::TpetraLinearObjFactory tpetraLinObjFactory; +#ifdef PANZER_HAVE_EPETRA typedef typename panzer::BlockedEpetraLinearObjFactory blockedEpetraLinObjFactory; typedef typename panzer::BlockedEpetraLinearObjFactory epetraLinObjFactory; +#endif std::string fieldStr = (*this->m_dof_names)[0]; const std::string residualField = "AUX_PROJECTEDSCHURCOMPLEMENT_RESIDUAL_"+dof_name; @@ -188,8 +194,10 @@ buildAndRegisterScatterEvaluators(PHX::FieldManager& fm, // must be able to cast to a block linear object factory Teuchos::RCP tblof = Teuchos::rcp_dynamic_cast(Teuchos::rcpFromRef(lof)); +#ifdef PANZER_HAVE_EPETRA Teuchos::RCP eblof = Teuchos::rcp_dynamic_cast(Teuchos::rcpFromRef(lof)); +#endif if(tblof != Teuchos::null) { Teuchos::RCP blockedDOFMngr = tblof->getGlobalIndexer(); @@ -223,6 +231,7 @@ buildAndRegisterScatterEvaluators(PHX::FieldManager& fm, fm.registerEvaluator(op); } +#ifdef PANZER_HAVE_EPETRA } else if(eblof != Teuchos::null) { Teuchos::RCP blockedDOFMngr = eblof->getGlobalIndexer(); TEUCHOS_ASSERT(blockedDOFMngr!=Teuchos::null); @@ -254,6 +263,7 @@ buildAndRegisterScatterEvaluators(PHX::FieldManager& fm, fm.registerEvaluator(op); } +#endif } else TEUCHOS_ASSERT(false); diff --git a/packages/panzer/mini-em/src/eqn_sets/MiniEM_AuxiliaryEquationSet_SchurComplement_impl.hpp b/packages/panzer/mini-em/src/eqn_sets/MiniEM_AuxiliaryEquationSet_SchurComplement_impl.hpp index 7f8e75369897..6ff84239b84c 100644 --- a/packages/panzer/mini-em/src/eqn_sets/MiniEM_AuxiliaryEquationSet_SchurComplement_impl.hpp +++ b/packages/panzer/mini-em/src/eqn_sets/MiniEM_AuxiliaryEquationSet_SchurComplement_impl.hpp @@ -14,6 +14,7 @@ #include "Panzer_BasisIRLayout.hpp" // include evaluators here +#include "PanzerAdaptersSTK_config.hpp" #include "Panzer_Integrator_BasisTimesVector.hpp" #include "Panzer_Integrator_BasisTimesTensorTimesVector.hpp" #include "Panzer_Integrator_CurlBasisDotVector.hpp" @@ -22,7 +23,9 @@ #include "Panzer_Constant.hpp" #include "Panzer_BlockedDOFManager.hpp" #include "Panzer_BlockedTpetraLinearObjFactory.hpp" +#ifdef PANZER_HAVE_EPETRA #include "Panzer_BlockedEpetraLinearObjFactory.hpp" +#endif #include "Panzer_ReorderADValues_Evaluator.hpp" #include "Panzer_LOCPair_GlobalEvaluationData.hpp" @@ -184,14 +187,18 @@ buildAndRegisterScatterEvaluators(PHX::FieldManager& fm, typedef panzer::Traits::Jacobian EvalT; typedef double Scalar; +#ifdef PANZER_HAVE_EPETRA typedef int LocalOrdinalEpetra; +#endif typedef int LocalOrdinalTpetra; typedef panzer::GlobalOrdinal GlobalOrdinalTpetra; typedef typename panzer::BlockedTpetraLinearObjFactory blockedTpetraLinObjFactory; typedef typename panzer::TpetraLinearObjFactory tpetraLinObjFactory; +#ifdef PANZER_HAVE_EPETRA typedef typename panzer::BlockedEpetraLinearObjFactory blockedEpetraLinObjFactory; typedef typename panzer::BlockedEpetraLinearObjFactory epetraLinObjFactory; +#endif std::string fieldStr = (*this->m_dof_names)[0]; const std::string residualField = "AUX_SCHURCOMPLEMENT_RESIDUAL_"+dof_name; @@ -205,8 +212,10 @@ buildAndRegisterScatterEvaluators(PHX::FieldManager& fm, // must be able to cast to a block linear object factory Teuchos::RCP tblof = Teuchos::rcp_dynamic_cast(Teuchos::rcpFromRef(lof)); +#ifdef PANZER_HAVE_EPETRA Teuchos::RCP eblof = Teuchos::rcp_dynamic_cast(Teuchos::rcpFromRef(lof)); +#endif if(tblof != Teuchos::null) { Teuchos::RCP blockedDOFMngr = tblof->getGlobalIndexer(); @@ -239,7 +248,7 @@ buildAndRegisterScatterEvaluators(PHX::FieldManager& fm, fm.registerEvaluator(op); } - +#ifdef PANZER_HAVE_EPETRA } else if(eblof != Teuchos::null) { Teuchos::RCP blockedDOFMngr = eblof->getGlobalIndexer(); TEUCHOS_ASSERT(blockedDOFMngr!=Teuchos::null); @@ -271,6 +280,7 @@ buildAndRegisterScatterEvaluators(PHX::FieldManager& fm, fm.registerEvaluator(op); } +#endif } else TEUCHOS_ASSERT(false); diff --git a/packages/panzer/mini-em/src/eqn_sets/MiniEM_AuxiliaryEquationSet_WeakGradient_impl.hpp b/packages/panzer/mini-em/src/eqn_sets/MiniEM_AuxiliaryEquationSet_WeakGradient_impl.hpp index f364ee2ae2e4..d8efeb61b8c3 100644 --- a/packages/panzer/mini-em/src/eqn_sets/MiniEM_AuxiliaryEquationSet_WeakGradient_impl.hpp +++ b/packages/panzer/mini-em/src/eqn_sets/MiniEM_AuxiliaryEquationSet_WeakGradient_impl.hpp @@ -18,7 +18,9 @@ #include "Panzer_Sum.hpp" #include "Panzer_Constant.hpp" #include "Panzer_BlockedDOFManager.hpp" +#ifdef PANZER_HAVE_EPETRA #include "Panzer_BlockedEpetraLinearObjFactory.hpp" +#endif #include "Panzer_BlockedTpetraLinearObjFactory.hpp" #include "Panzer_TpetraLinearObjFactory.hpp" #include "Panzer_ReorderADValues_Evaluator.hpp" @@ -125,14 +127,18 @@ buildAndRegisterScatterEvaluators(PHX::FieldManager& fm, typedef panzer::Traits::Jacobian EvalT; typedef double Scalar; +#ifdef PANZER_HAVE_EPETRA typedef int LocalOrdinalEpetra; +#endif typedef int LocalOrdinalTpetra; typedef panzer::GlobalOrdinal GlobalOrdinalTpetra; typedef typename panzer::BlockedTpetraLinearObjFactory blockedTpetraLinObjFactory; typedef typename panzer::TpetraLinearObjFactory tpetraLinObjFactory; +#ifdef PANZER_HAVE_EPETRA typedef typename panzer::BlockedEpetraLinearObjFactory blockedEpetraLinObjFactory; typedef typename panzer::BlockedEpetraLinearObjFactory epetraLinObjFactory; +#endif std::string fieldStr = (*this->m_dof_names)[0]; int pFieldNum; @@ -149,8 +155,10 @@ buildAndRegisterScatterEvaluators(PHX::FieldManager& fm, // must be able to cast to a block linear object factory Teuchos::RCP tblof = Teuchos::rcp_dynamic_cast(Teuchos::rcpFromRef(lof)); +#ifdef PANZER_HAVE_EPETRA Teuchos::RCP eblof = Teuchos::rcp_dynamic_cast(Teuchos::rcpFromRef(lof)); +#endif if(tblof != Teuchos::null) { @@ -191,7 +199,7 @@ buildAndRegisterScatterEvaluators(PHX::FieldManager& fm, fm.registerEvaluator(op); } - +#ifdef PANZER_HAVE_EPETRA } else if(eblof != Teuchos::null) { Teuchos::RCP blockedDOFMngr; Teuchos::RCP rowUgi; @@ -230,6 +238,7 @@ buildAndRegisterScatterEvaluators(PHX::FieldManager& fm, fm.registerEvaluator(op); } +#endif } else TEUCHOS_ASSERT(false); diff --git a/packages/panzer/mini-em/src/solvers/MiniEM_DiscreteCurl.hpp b/packages/panzer/mini-em/src/solvers/MiniEM_DiscreteCurl.hpp index f320c288cd2b..38607d4215cb 100644 --- a/packages/panzer/mini-em/src/solvers/MiniEM_DiscreteCurl.hpp +++ b/packages/panzer/mini-em/src/solvers/MiniEM_DiscreteCurl.hpp @@ -6,7 +6,9 @@ #include "Panzer_IntrepidBasisFactory.hpp" #include "Intrepid2_OrientationTools.hpp" #include "Intrepid2_LagrangianInterpolation.hpp" +#ifdef PANZER_HAVE_EPETRA #include "Thyra_EpetraThyraWrappers.hpp" +#endif class CurlRequestCallback : public Teko::RequestCallback { private: @@ -57,7 +59,9 @@ void addDiscreteCurlToRequestHandler( typedef panzer::GlobalOrdinal GlobalOrdinal; typedef typename panzer::BlockedTpetraLinearObjFactory tpetraBlockedLinObjFactory; +#ifdef PANZER_HAVE_EPETRA typedef typename panzer::BlockedEpetraLinearObjFactory epetraBlockedLinObjFactory; +#endif typedef panzer::GlobalIndexer UGI; typedef PHX::Device DeviceSpace; typedef Kokkos::HostSpace HostSpace; @@ -70,7 +74,9 @@ void addDiscreteCurlToRequestHandler( // must be able to cast to a block linear object factory RCP tblof = rcp_dynamic_cast(linObjFactory); +#ifdef PANZER_HAVE_EPETRA RCP eblof = rcp_dynamic_cast(linObjFactory); +#endif if (tblof != Teuchos::null) { typedef typename panzer::BlockedTpetraLinearObjContainer linObjContainer; typedef Tpetra::CrsMatrix matrix; @@ -288,6 +294,7 @@ void addDiscreteCurlToRequestHandler( // add curl callback to request handler reqHandler->addRequestCallback(Teuchos::rcp(new CurlRequestCallback(thyra_curl))); +#ifdef PANZER_HAVE_EPETRA } else if (eblof != Teuchos::null) { typedef typename panzer::BlockedEpetraLinearObjContainer linObjContainer; @@ -506,7 +513,7 @@ void addDiscreteCurlToRequestHandler( // add curl callback to request handler reqHandler->addRequestCallback(Teuchos::rcp(new CurlRequestCallback(thyra_curl))); - +#endif } else TEUCHOS_ASSERT(false); } diff --git a/packages/panzer/mini-em/src/solvers/MiniEM_DiscreteGradient.hpp b/packages/panzer/mini-em/src/solvers/MiniEM_DiscreteGradient.hpp index be847ec22233..de4e351dc3f2 100644 --- a/packages/panzer/mini-em/src/solvers/MiniEM_DiscreteGradient.hpp +++ b/packages/panzer/mini-em/src/solvers/MiniEM_DiscreteGradient.hpp @@ -4,7 +4,9 @@ #include "Panzer_LOCPair_GlobalEvaluationData.hpp" #include "Panzer_IntrepidOrientation.hpp" #include "Thyra_TpetraLinearOp.hpp" +#ifdef PANZER_HAVE_EPETRA #include "Thyra_EpetraThyraWrappers.hpp" +#endif #include "Tpetra_Import.hpp" class GradientRequestCallback : public Teko::RequestCallback { @@ -51,12 +53,16 @@ void addDiscreteGradientToRequestHandler( using Teuchos::rcp_dynamic_cast; typedef double Scalar; +#ifdef PANZER_HAVE_EPETRA typedef int LocalOrdinalEpetra; +#endif typedef int LocalOrdinalTpetra; typedef panzer::GlobalOrdinal GlobalOrdinalTpetra; typedef typename panzer::BlockedTpetraLinearObjFactory tpetraBlockedLinObjFactory; +#ifdef PANZER_HAVE_EPETRA typedef typename panzer::BlockedEpetraLinearObjFactory epetraBlockedLinObjFactory; +#endif typedef PHX::Device DeviceSpace; @@ -66,7 +72,9 @@ void addDiscreteGradientToRequestHandler( // must be able to cast to a block linear object factory RCP tblof = rcp_dynamic_cast(linObjFactory); +#ifdef PANZER_HAVE_EPETRA RCP eblof = rcp_dynamic_cast(linObjFactory); +#endif if (tblof != Teuchos::null) { typedef LocalOrdinalTpetra LocalOrdinal; typedef GlobalOrdinalTpetra GlobalOrdinal; @@ -161,6 +169,7 @@ void addDiscreteGradientToRequestHandler( // add gradient callback to request handler reqHandler->addRequestCallback(Teuchos::rcp(new GradientRequestCallback(thyra_gradient))); +#ifdef PANZER_HAVE_EPETRA } else if (eblof != Teuchos::null) { typedef panzer::GlobalIndexer UGI; typedef typename panzer::BlockedEpetraLinearObjContainer linObjContainer; @@ -263,6 +272,7 @@ void addDiscreteGradientToRequestHandler( // add gradient callback to request handler reqHandler->addRequestCallback(Teuchos::rcp(new GradientRequestCallback(thyra_gradient))); +#endif } else TEUCHOS_ASSERT(false); diff --git a/packages/panzer/mini-em/src/solvers/MiniEM_FullMaxwellPreconditionerFactory.cpp b/packages/panzer/mini-em/src/solvers/MiniEM_FullMaxwellPreconditionerFactory.cpp index a076d5a78992..d33243e6d940 100644 --- a/packages/panzer/mini-em/src/solvers/MiniEM_FullMaxwellPreconditionerFactory.cpp +++ b/packages/panzer/mini-em/src/solvers/MiniEM_FullMaxwellPreconditionerFactory.cpp @@ -17,7 +17,9 @@ #include "Thyra_TpetraLinearOp.hpp" #include "Panzer_NodeType.hpp" +#ifdef PANZER_HAVE_EPETRA #include "Thyra_EpetraThyraWrappers.hpp" +#endif #include "Panzer_LOCPair_GlobalEvaluationData.hpp" #include "Panzer_LinearObjContainer.hpp" #include "Panzer_ThyraObjContainer.hpp" @@ -125,8 +127,8 @@ Teko::LinearOp FullMaxwellPreconditionerFactory::buildPreconditionerOperator(Tek } // Check whether we are using Tpetra or Epetra - RCP EOp = rcp_dynamic_cast(Q_E); - bool useTpetra = (EOp == Teuchos::null); + RCP > checkTpetra = Teuchos::rcp_dynamic_cast>(Q_E); + bool useTpetra = nonnull(checkTpetra); ///////////////////////////////////////////////// // Debug and matrix dumps // @@ -227,6 +229,7 @@ Teko::LinearOp FullMaxwellPreconditionerFactory::buildPreconditionerOperator(Tek #endif RCP > Coordinates = S_E_prec_pl.get > >("Coordinates"); S_E_prec_pl.sublist("Preconditioner Types").sublist(S_E_prec_type_).set("Coordinates",Coordinates); +#ifdef PANZER_HAVE_EPETRA #ifndef PANZER_HIDE_DEPRECATED_CODE } else if (!useTpetra && ((S_E_prec_type_ == "MueLuRefMaxwell") || (S_E_prec_type_ == "MueLuRefMaxwell-Tpetra"))) { #else @@ -234,6 +237,7 @@ Teko::LinearOp FullMaxwellPreconditionerFactory::buildPreconditionerOperator(Tek #endif RCP Coordinates = S_E_prec_pl.get >("Coordinates"); S_E_prec_pl.sublist("Preconditioner Types").sublist(S_E_prec_type_).set("Coordinates",Coordinates); + } else if (S_E_prec_type_ == "ML") { double* x_coordinates = S_E_prec_pl.sublist("ML Settings").get("x-coordinates"); S_E_prec_pl.sublist("ML Settings").sublist("refmaxwell: 11list").set("x-coordinates",x_coordinates); @@ -244,6 +248,7 @@ Teko::LinearOp FullMaxwellPreconditionerFactory::buildPreconditionerOperator(Tek double* z_coordinates = S_E_prec_pl.sublist("ML Settings").get("z-coordinates"); S_E_prec_pl.sublist("ML Settings").sublist("refmaxwell: 11list").set("z-coordinates",z_coordinates); S_E_prec_pl.sublist("ML Settings").sublist("refmaxwell: 22list").set("z-coordinates",z_coordinates); +#endif // PANZER_HAVE_EPETRA } else TEUCHOS_ASSERT(false); } @@ -265,11 +270,15 @@ Teko::LinearOp FullMaxwellPreconditionerFactory::buildPreconditionerOperator(Tek { Teko::InverseLibrary myInvLib = invLib; if (S_E_prec_type_ == "ML") { +#ifdef PANZER_HAVE_EPETRA RCP eInvDiagQ_rho = get_Epetra_CrsMatrix(*invDiagQ_rho,get_Epetra_CrsMatrix(*Q_B)->RowMap().Comm()); S_E_prec_pl.sublist("ML Settings").set("M0inv",eInvDiagQ_rho); S_E_prec_pl.set("Type",S_E_prec_type_); myInvLib.addInverse("S_E Preconditioner",S_E_prec_pl); +#else + TEUCHOS_TEST_FOR_EXCEPTION(true,std::runtime_error,"ERROR: MiniEM_FullMaxwellPreconditionerFactory: ML is not supported in this build! Requires Epetra support be enabled!"); +#endif } else { S_E_prec_pl.sublist("Preconditioner Types").sublist(S_E_prec_type_).set("M0inv",invDiagQ_rho); @@ -446,12 +455,16 @@ void FullMaxwellPreconditionerFactory::initializeFromParameterList(const Teuchos Teko::LinearOp Q_E_aux_weighted = getRequestHandler()->request(Teko::RequestMesg("Mass Matrix weighted AUXILIARY_EDGE")); Teko::LinearOp T = getRequestHandler()->request(Teko::RequestMesg("Discrete Gradient")); if (S_E_prec_type_ == "ML") { +#ifdef PANZER_HAVE_EPETRA RCP eT = get_Epetra_CrsMatrix(*T); RCP eQ_E_aux = get_Epetra_CrsMatrix(*Q_E_aux); RCP eQ_E_aux_weighted = get_Epetra_CrsMatrix(*Q_E_aux_weighted); S_E_prec_pl.sublist("ML Settings").set("D0",eT); S_E_prec_pl.sublist("ML Settings").set("M1",eQ_E_aux); S_E_prec_pl.sublist("ML Settings").set("Ms",eQ_E_aux_weighted); +#else + TEUCHOS_TEST_FOR_EXCEPTION(true,std::runtime_error,"ERROR: MiniEM_FullMaxwellPreconditionerFactory: ML is not supported in this build! Requires Epetra support be enabled!"); +#endif } else { S_E_prec_pl.sublist("Preconditioner Types").sublist(S_E_prec_type_).set("D0",T); S_E_prec_pl.sublist("Preconditioner Types").sublist(S_E_prec_type_).set("M1",Q_E_aux); diff --git a/packages/panzer/mini-em/src/solvers/MiniEM_FullMaxwellPreconditionerFactory_Augmentation.cpp b/packages/panzer/mini-em/src/solvers/MiniEM_FullMaxwellPreconditionerFactory_Augmentation.cpp index 7f933816265e..03939287aa3c 100644 --- a/packages/panzer/mini-em/src/solvers/MiniEM_FullMaxwellPreconditionerFactory_Augmentation.cpp +++ b/packages/panzer/mini-em/src/solvers/MiniEM_FullMaxwellPreconditionerFactory_Augmentation.cpp @@ -17,7 +17,6 @@ #include "Thyra_TpetraLinearOp.hpp" #include "Panzer_NodeType.hpp" -#include "Thyra_EpetraThyraWrappers.hpp" #include "Panzer_LOCPair_GlobalEvaluationData.hpp" #include "Panzer_LinearObjContainer.hpp" #include "Panzer_ThyraObjContainer.hpp" diff --git a/packages/panzer/mini-em/src/solvers/MiniEM_Interpolation.hpp b/packages/panzer/mini-em/src/solvers/MiniEM_Interpolation.hpp index afbb9b090b1b..97dda483f88d 100644 --- a/packages/panzer/mini-em/src/solvers/MiniEM_Interpolation.hpp +++ b/packages/panzer/mini-em/src/solvers/MiniEM_Interpolation.hpp @@ -7,7 +7,9 @@ #include "Panzer_IntrepidBasisFactory.hpp" #include "Intrepid2_OrientationTools.hpp" #include "Intrepid2_LagrangianInterpolation.hpp" +#ifdef PANZER_HAVE_EPETRA #include "Thyra_EpetraThyraWrappers.hpp" +#endif #include "MiniEM_Utils.hpp" #include "MiniEM_MatrixFreeInterpolationOp.hpp" #include "MiniEM_MatrixFreeInterpolationOp.cpp" @@ -31,7 +33,9 @@ Teko::LinearOp buildInterpolation(const Teuchos::RCP; typedef typename panzer::BlockedTpetraLinearObjFactory tpetraBlockedLinObjFactory; +#ifdef PANZER_HAVE_EPETRA typedef typename panzer::BlockedEpetraLinearObjFactory epetraBlockedLinObjFactory; +#endif typedef panzer::GlobalIndexer UGI; typedef PHX::Device DeviceSpace; typedef Kokkos::HostSpace HostSpace; @@ -42,26 +46,33 @@ Teko::LinearOp buildInterpolation(const Teuchos::RCP tblof = rcp_dynamic_cast(linObjFactory); +#ifdef PANZER_HAVE_EPETRA RCP eblof = rcp_dynamic_cast(linObjFactory); +#endif typedef Tpetra::CrsMatrix tp_matrix; typedef Tpetra::Map tp_map; +#ifdef PANZER_HAVE_EPETRA typedef typename panzer::BlockedEpetraLinearObjContainer ep_linObjContainer; typedef Epetra_CrsMatrix ep_matrix; typedef Epetra_Map ep_map; +#endif RCP blockedDOFMngr; - if (tblof != Teuchos::null) + if (tblof != Teuchos::null) { blockedDOFMngr = tblof->getGlobalIndexer(); - else if (eblof != Teuchos::null) { +#ifdef PANZER_HAVE_EPETRA + } else if (eblof != Teuchos::null) { TEUCHOS_ASSERT(false); // The Epetra code path works, expect for the fact that Epetra // does not implement the needed matrix entry insertion. We'd need // to handle the overwriting (instead of summing into) of already // existing entries by hand. blockedDOFMngr = eblof->getGlobalIndexer(); - } else +#endif + } else { TEUCHOS_ASSERT(false); + } // get global indexers for LO and HO dofs std::vector > fieldDOFMngrs = blockedDOFMngr->getFieldDOFManagers(); @@ -90,8 +101,10 @@ Teko::LinearOp buildInterpolation(const Teuchos::RCP tp_rangemap, tp_domainmap, tp_rowmap, tp_colmap; RCP tp_interp_matrix; +#ifdef PANZER_HAVE_EPETRA RCP ep_rangemap, ep_domainmap, ep_rowmap, ep_colmap; RCP ep_interp_matrix; +#endif RCP > thyra_interp; if (tblof != Teuchos::null) { @@ -144,6 +157,7 @@ Teko::LinearOp buildInterpolation(const Teuchos::RCP(tp_domainmap), tp_interp_matrix); } +#ifdef PANZER_HAVE_EPETRA else if (eblof != Teuchos::null) { RCP dataObject = rcp(new panzer::LOCPair_GlobalEvaluationData(eblof,panzer::LinearObjContainer::Mat)); @@ -173,7 +187,7 @@ Teko::LinearOp buildInterpolation(const Teuchos::RCP >(th_ep_interp); } - +#endif RCP conn = blockedDOFMngr->getConnManager(); @@ -310,10 +324,14 @@ Teko::LinearOp buildInterpolation(const Teuchos::RCPisNodeLocalElement(ho_row); else isOwned = ep_rowmap->MyLID(ho_row); +#else + isOwned = tp_rowmap->isNodeLocalElement(ho_row); +#endif if (isOwned) { // filter entries for zeros @@ -327,11 +345,14 @@ Teko::LinearOp buildInterpolation(const Teuchos::RCPinsertLocalValues(ho_row, rowNNZ, values_h.data(), indices_h.data(), Tpetra::INSERT); else ep_interp_matrix->InsertMyValues(ho_row, rowNNZ, values_h.data(), indices_h.data()); - +#else + tp_interp_matrix->insertLocalValues(ho_row, rowNNZ, values_h.data(), indices_h.data(), Tpetra::INSERT); +#endif } //end if owned } //end HO LID loop } //end workset loop @@ -394,8 +415,10 @@ Teko::LinearOp buildInterpolation(const Teuchos::RCPFillComplete(*ep_domainmap, *ep_rangemap); +#endif return thyra_interp; } diff --git a/packages/panzer/mini-em/src/solvers/MiniEM_Utils.cpp b/packages/panzer/mini-em/src/solvers/MiniEM_Utils.cpp index 822e63e1513a..ff6d143ce394 100644 --- a/packages/panzer/mini-em/src/solvers/MiniEM_Utils.cpp +++ b/packages/panzer/mini-em/src/solvers/MiniEM_Utils.cpp @@ -13,7 +13,10 @@ namespace mini_em { using Teuchos::rcp_dynamic_cast; using NT = panzer::TpetraNodeType; const RCP > tOp = rcp_dynamic_cast >(Teuchos::rcpFromRef(op)); +#ifdef PANZER_HAVE_EPETRA const RCP eOp = rcp_dynamic_cast(Teuchos::rcpFromRef(op)); +#endif + if(tOp != Teuchos::null) { *Teko::getOutputStream() << "Dumping matrix \'" << s << "\'" << std::endl; const RCP > crsOp = rcp_dynamic_cast >(tOp->getConstTpetraOperator()); @@ -33,6 +36,7 @@ namespace mini_em { } *Teko::getOutputStream() << "Cannot dump operator \'" << s << "\'" << std::endl; } +#ifdef PANZER_HAVE_EPETRA } else if (eOp != Teuchos::null) { *Teko::getOutputStream() << "Dumping matrix \'" << s << "\'" << std::endl; const RCP crsOp = rcp_dynamic_cast(eOp->epetra_op(),true); @@ -41,6 +45,7 @@ namespace mini_em { EpetraExt::BlockMapToMatrixMarketFile(("domainmap_"+s).c_str(), crsOp->DomainMap()); EpetraExt::BlockMapToMatrixMarketFile(("rangemap_"+s).c_str(), crsOp->RangeMap()); EpetraExt::RowMatrixToMatrixMarketFile(s.c_str(), *crsOp); +#endif } else TEUCHOS_ASSERT(false); } @@ -53,15 +58,19 @@ namespace mini_em { using NT = Tpetra::Map<>::node_type; if (out!=Teuchos::null) { const RCP > tOp = rcp_dynamic_cast >(Teuchos::rcpFromRef(op)); +#ifdef PANZER_HAVE_EPETRA const RCP eOp = rcp_dynamic_cast(Teuchos::rcpFromRef(op)); +#endif if(tOp != Teuchos::null) { const RCP > crsOp = rcp_dynamic_cast >(tOp->getConstTpetraOperator(),true); *out << "\nDebug: " << s << std::endl; crsOp->describe(*out,Teuchos::VERB_MEDIUM); +#ifdef PANZER_HAVE_EPETRA } else if (eOp != Teuchos::null) { const RCP crsOp = rcp_dynamic_cast(eOp->epetra_op(),true); *out << "\nDebug: " << s << std::endl; // crsOp->describe(*out,Teuchos::VERB_MEDIUM); +#endif } else TEUCHOS_ASSERT(false); } @@ -83,7 +92,7 @@ namespace mini_em { return crsOp; } - +#ifdef PANZER_HAVE_EPETRA Teuchos::RCP get_Epetra_CrsMatrix(const Thyra::LinearOpBase & op) { using Teuchos::RCP; using Teuchos::rcp_dynamic_cast; @@ -113,6 +122,7 @@ namespace mini_em { crsMatrix->FillComplete(); return crsMatrix; } +#endif template Teuchos::RCP > @@ -132,6 +142,7 @@ namespace mini_em { return identityMatrix; } +#ifdef PANZER_HAVE_EPETRA Teuchos::RCP getIdentityMatrixEpetra (const Epetra_Map& rowMap, double scaling) @@ -146,6 +157,7 @@ namespace mini_em { identityMatrix->FillComplete(); return identityMatrix; } +#endif Teko::LinearOp getIdentityMatrix(const Teko::LinearOp& op, double scaling) { @@ -154,7 +166,9 @@ namespace mini_em { using Node = panzer::TpetraNodeType; const RCP > tOp = rcp_dynamic_cast >(op); +#ifdef PANZER_HAVE_EPETRA const RCP eOp = rcp_dynamic_cast(op); +#endif if(tOp != Teuchos::null) { using Scalar = double; using LocalOrdinal = int; @@ -167,6 +181,7 @@ namespace mini_em { Teko::domainSpace(op), tpId); return thyId; +#ifdef PANZER_HAVE_EPETRA } else if (eOp != Teuchos::null) { const RCP crsOp = rcp_dynamic_cast(eOp->epetra_op(),true); auto epMap = crsOp->RowMap(); @@ -180,6 +195,7 @@ namespace mini_em { Teko::domainSpace(op)); // return Teuchos::rcp_const_cast >(thyConst); return thyConst; +#endif } else TEUCHOS_ASSERT(false); } diff --git a/packages/panzer/mini-em/src/solvers/MiniEM_Utils.hpp b/packages/panzer/mini-em/src/solvers/MiniEM_Utils.hpp index d8b082a2c088..6cec47bae511 100644 --- a/packages/panzer/mini-em/src/solvers/MiniEM_Utils.hpp +++ b/packages/panzer/mini-em/src/solvers/MiniEM_Utils.hpp @@ -1,20 +1,22 @@ #ifndef _MiniEM_Utils_hpp_ #define _MiniEM_Utils_hpp_ +#include "PanzerAdaptersSTK_config.hpp" #include "Teuchos_RCP.hpp" #include "Teko_TpetraHelpers.hpp" #include "Teko_TpetraOperatorWrapper.hpp" #include "Thyra_TpetraLinearOp.hpp" -#include "Thyra_EpetraLinearOp.hpp" #include "MatrixMarket_Tpetra.hpp" #include "Panzer_NodeType.hpp" +#ifdef PANZER_HAVE_EPETRA +#include "Thyra_EpetraLinearOp.hpp" #include "EpetraExt_RowMatrixOut.h" #include "EpetraExt_BlockMapOut.h" #include "Epetra_CombineMode.h" #include "Epetra_Comm.h" #include "Epetra_CrsMatrix.h" #include "Thyra_EpetraThyraWrappers.hpp" -#include "Panzer_NodeType.hpp" +#endif #include "Panzer_LOCPair_GlobalEvaluationData.hpp" #include "Panzer_LinearObjContainer.hpp" #include "Panzer_ThyraObjContainer.hpp" @@ -32,9 +34,11 @@ namespace mini_em { template::node_type> Teuchos::RCP > get_Tpetra_CrsMatrix(const Thyra::LinearOpBase & op); +#ifdef PANZER_HAVE_EPETRA Teuchos::RCP get_Epetra_CrsMatrix(const Thyra::LinearOpBase & op); Teuchos::RCP get_Epetra_CrsMatrix(const Thyra::DiagonalLinearOpBase & op, const Epetra_Comm& comm); +#endif Teko::LinearOp getIdentityMatrix(const Teko::LinearOp& op, double scaling); diff --git a/packages/percept/src/percept/mesh/mod/smoother/GenericAlgorithm_total_element_metric.hpp b/packages/percept/src/percept/mesh/mod/smoother/GenericAlgorithm_total_element_metric.hpp index 34cc4f9310c9..e257e792b9fa 100644 --- a/packages/percept/src/percept/mesh/mod/smoother/GenericAlgorithm_total_element_metric.hpp +++ b/packages/percept/src/percept/mesh/mod/smoother/GenericAlgorithm_total_element_metric.hpp @@ -58,12 +58,14 @@ class PerceptMesh; {m_metric = metric; m_eMesh = eMesh; valid = valid_in; num_invalid = num_invalid_in; mtot = mtot_in; n_invalid = n_invalid_in;} inline + KOKKOS_FUNCTION void operator()(const unsigned& index, Double& mtot_loc) const { const_cast(this)->operator()(index, mtot_loc); } inline + KOKKOS_FUNCTION void operator()(const unsigned& index, Double& mtot_loc); }; diff --git a/packages/shylu/shylu_node/tacho/example/Tacho_ExampleDriver.hpp b/packages/shylu/shylu_node/tacho/example/Tacho_ExampleDriver.hpp index 7b43043baef5..e332f63dd85a 100644 --- a/packages/shylu/shylu_node/tacho/example/Tacho_ExampleDriver.hpp +++ b/packages/shylu/shylu_node/tacho/example/Tacho_ExampleDriver.hpp @@ -61,6 +61,7 @@ template int driver(int argc, char *argv[]) { opts.set_option("device-solve-thres", "Device function is used above this subproblem size", &device_solve_thres); opts.set_option("variant", "algorithm variant in levelset scheduling; 0, 1 and 2", &variant); opts.set_option("nstreams", "# of streams used in CUDA; on host, it is ignored", &nstreams); + opts.set_option("nfacts", "# of factorizations to perform", &nfacts); opts.set_option("nsolves", "# of solves to perform", &nsolves); const bool r_parse = opts.parse(argc, argv); diff --git a/packages/shylu/shylu_node/tacho/src/impl/Tacho_NumericTools_LevelSet.hpp b/packages/shylu/shylu_node/tacho/src/impl/Tacho_NumericTools_LevelSet.hpp index 7e8037468065..d92f7c62f83e 100644 --- a/packages/shylu/shylu_node/tacho/src/impl/Tacho_NumericTools_LevelSet.hpp +++ b/packages/shylu/shylu_node/tacho/src/impl/Tacho_NumericTools_LevelSet.hpp @@ -3027,8 +3027,9 @@ class NumericToolsLevelSet : public NumericToolsBase { track_alloc(_buf.span() * sizeof(value_type)); #if defined(KOKKOS_ENABLE_CUDA) || defined(KOKKOS_ENABLE_HIP) - value_type_matrix T(NULL, _info.max_supernode_size, _info.max_supernode_size); - ordinal_type_array P(NULL, _info.max_supernode_size); + // NOTE : move this to symbolic with the actual max worksize? + value_type_matrix T(NULL, _info.max_supernode_size, _info.max_num_cols); + ordinal_type_array P(NULL, std::min(_info.max_supernode_size, _info.max_num_cols)); const size_type worksize = LU::invoke(_handle_lapack, T, P, work); work = value_type_array(do_not_initialize_tag("work"), worksize * (_nstreams + 1)); diff --git a/packages/shylu/shylu_node/tacho/src/impl/Tacho_SupernodeInfo.hpp b/packages/shylu/shylu_node/tacho/src/impl/Tacho_SupernodeInfo.hpp index 19d9790c78bb..cb634215da08 100644 --- a/packages/shylu/shylu_node/tacho/src/impl/Tacho_SupernodeInfo.hpp +++ b/packages/shylu/shylu_node/tacho/src/impl/Tacho_SupernodeInfo.hpp @@ -31,6 +31,7 @@ struct SuperNodeInfoInitReducer { struct ValueType { ordinal_type max_nchildren; ordinal_type max_supernode_size; + ordinal_type max_num_cols; ordinal_type max_schur_size; size_type nnz; }; @@ -48,6 +49,8 @@ struct SuperNodeInfoInitReducer { dst.max_nchildren = (src.max_nchildren > dst.max_nchildren ? src.max_nchildren : dst.max_nchildren); dst.max_supernode_size = (src.max_supernode_size > dst.max_supernode_size ? src.max_supernode_size : dst.max_supernode_size); + dst.max_num_cols = + (src.max_num_cols > dst.max_num_cols ? src.max_num_cols : dst.max_num_cols); dst.max_schur_size = (src.max_schur_size > dst.max_schur_size ? src.max_schur_size : dst.max_schur_size); dst.nnz += src.nnz; } @@ -56,6 +59,8 @@ struct SuperNodeInfoInitReducer { dst.max_nchildren = (src.max_nchildren > dst.max_nchildren ? src.max_nchildren : dst.max_nchildren); dst.max_supernode_size = (src.max_supernode_size > dst.max_supernode_size ? src.max_supernode_size : dst.max_supernode_size); + dst.max_num_cols = + (src.max_num_cols > dst.max_num_cols ? src.max_num_cols : dst.max_num_cols); dst.max_schur_size = (src.max_schur_size > dst.max_schur_size ? src.max_schur_size : dst.max_schur_size); dst.nnz += src.nnz; } @@ -63,6 +68,7 @@ struct SuperNodeInfoInitReducer { KOKKOS_INLINE_FUNCTION void init(value_type &val) const { val.max_nchildren = Kokkos::reduction_identity::max(); val.max_supernode_size = Kokkos::reduction_identity::max(); + val.max_num_cols = Kokkos::reduction_identity::max(); val.max_schur_size = Kokkos::reduction_identity::max(); val.nnz = Kokkos::reduction_identity::sum(); } @@ -153,7 +159,7 @@ template struct SupernodeInfo { /// /// max parameter /// - ordinal_type max_nchildren, max_supernode_size, max_schur_size; + ordinal_type max_nchildren, max_supernode_size, max_num_cols, max_schur_size; /// /// frontal matrix subassembly mode and serialization parameter @@ -166,14 +172,14 @@ template struct SupernodeInfo { KOKKOS_INLINE_FUNCTION SupernodeInfo() - : supernodes(), gid_colidx(), sid_block_colidx(), max_nchildren(), max_supernode_size(), max_schur_size(), + : supernodes(), gid_colidx(), sid_block_colidx(), max_nchildren(), max_supernode_size(), max_num_cols(), max_schur_size(), front_update_mode(), serial_thres_size(), x() {} //= default; KOKKOS_INLINE_FUNCTION SupernodeInfo(const SupernodeInfo &b) : supernodes(b.supernodes), gid_colidx(b.gid_colidx), sid_block_colidx(b.sid_block_colidx), - max_nchildren(b.max_nchildren), max_supernode_size(b.max_supernode_size), max_schur_size(b.max_schur_size), + max_nchildren(b.max_nchildren), max_supernode_size(b.max_supernode_size), max_num_cols(b.max_num_cols), max_schur_size(b.max_schur_size), front_update_mode(b.front_update_mode), serial_thres_size(b.serial_thres_size), x(b.x) {} //= default; @@ -204,6 +210,7 @@ template struct SupernodeInfo { /// workspace parameter initialization self.max_nchildren = 0; self.max_supernode_size = 0; + self.max_num_cols = 0; self.max_schur_size = 0; Kokkos::RangePolicy supernodes_range_policy(0, nsupernodes); @@ -235,6 +242,7 @@ template struct SupernodeInfo { update.max_nchildren = max(update.max_nchildren, s.nchildren); update.max_supernode_size = max(update.max_supernode_size, s.m); + update.max_num_cols = max(update.max_num_cols, s.n); update.max_schur_size = max(update.max_schur_size, s.n - s.m); update.nnz += (s.m * s.n); /// upper @@ -265,6 +273,7 @@ template struct SupernodeInfo { self.max_nchildren = init_reduce_val.max_nchildren; self.max_supernode_size = init_reduce_val.max_supernode_size; + self.max_num_cols = init_reduce_val.max_num_cols; self.max_schur_size = init_reduce_val.max_schur_size; // supernodal factor array; data is held outside with a managed view diff --git a/packages/stk/stk_integration_tests/stk_mesh_doc/IntegrationTestBulkData.cpp b/packages/stk/stk_integration_tests/stk_mesh_doc/IntegrationTestBulkData.cpp index 0da6136b4013..74d48457d4c9 100644 --- a/packages/stk/stk_integration_tests/stk_mesh_doc/IntegrationTestBulkData.cpp +++ b/packages/stk/stk_integration_tests/stk_mesh_doc/IntegrationTestBulkData.cpp @@ -36,6 +36,7 @@ #include "../stk_unit_tests/stk_mesh/Setup8Quad4ProcMesh.hpp" #include "stk_io/StkMeshIoBroker.hpp" +#include "stk_io/FillMesh.hpp" #include "stk_mesh/base/Bucket.hpp" // for Bucket, has_superset #include "stk_mesh/base/Entity.hpp" // for Entity #include "stk_mesh/base/EntityKey.hpp" // for EntityKey @@ -90,13 +91,7 @@ TEST(BulkData_test, use_entity_ids_for_resolving_sharing) { std::string exodusFileName = stk::unit_test_util::simple_fields::get_option("-i", "mesh.exo"); - { - stk::io::StkMeshIoBroker exodusFileReader(communicator); - exodusFileReader.set_bulk_data(stkMeshBulkData); - exodusFileReader.add_mesh_database(exodusFileName, stk::io::READ_MESH); - exodusFileReader.create_input_mesh(); - exodusFileReader.populate_bulk_data(); - } + stk::io::fill_mesh(exodusFileName, stkMeshBulkData); } stkMeshBulkData.set_use_entity_ids_for_resolving_sharing(false); @@ -117,14 +112,7 @@ TEST(BulkData_test, testTwoDimProblemForSharingOfDifferentEdgesWithSameNodesFour { std::string exodusFileName = stk::unit_test_util::simple_fields::get_option("-i", "mesh.exo"); - { - stk::io::StkMeshIoBroker exodusFileReader(communicator); - exodusFileReader.set_bulk_data(stkMeshBulkData); - exodusFileReader.add_mesh_database(exodusFileName, stk::io::READ_MESH); - exodusFileReader.create_input_mesh(); - // With in populate_bulk_data, the option set_use_entity_ids_for_resolving_sharing is set to true - exodusFileReader.populate_bulk_data(); - } + stk::io::fill_mesh(exodusFileName, stkMeshBulkData); std::vector globalCounts; stk::mesh::comm_mesh_counts(stkMeshBulkData, globalCounts); @@ -148,10 +136,7 @@ TEST(BulkData_test, test3DProblemSharingOfDifferentFacesWithSameNodesTwoProc) { stk::io::StkMeshIoBroker exodusFileReader(communicator); exodusFileReader.set_sideset_face_creation_behavior(stk::io::StkMeshIoBroker::STK_IO_SIDESET_FACE_CREATION_CURRENT); - exodusFileReader.set_bulk_data(stkMeshBulkData); - exodusFileReader.add_mesh_database(exodusFileName, stk::io::READ_MESH); - exodusFileReader.create_input_mesh(); - exodusFileReader.populate_bulk_data(); + stk::io::fill_mesh_preexisting(exodusFileReader, exodusFileName, stkMeshBulkData); } std::vector globalCounts; @@ -174,10 +159,7 @@ TEST(BulkData_test, test3DProblemSharingOfDifferentFacesWithSameNodesOneProc) { stk::io::StkMeshIoBroker exodusFileReader(communicator); exodusFileReader.set_sideset_face_creation_behavior(stk::io::StkMeshIoBroker::STK_IO_SIDESET_FACE_CREATION_CURRENT); - exodusFileReader.set_bulk_data(stkMeshBulkData); - exodusFileReader.add_mesh_database(exodusFileName, stk::io::READ_MESH); - exodusFileReader.create_input_mesh(); - exodusFileReader.populate_bulk_data(); + stk::io::fill_mesh_preexisting(exodusFileReader, exodusFileName, stkMeshBulkData); } std::vector globalCounts; @@ -203,10 +185,7 @@ TEST(IntegrationTest, PartChangeGenerated) { stk::io::StkMeshIoBroker exodusFileReader(communicator); exodusFileReader.property_add(Ioss::Property("DECOMPOSITION_METHOD", "RIB")); - exodusFileReader.set_bulk_data(stkMeshBulkData); - exodusFileReader.add_mesh_database("generated:1x1x4", stk::io::READ_MESH); - exodusFileReader.create_input_mesh(); - exodusFileReader.populate_bulk_data(); + stk::io::fill_mesh_preexisting(exodusFileReader, "generated:1x1x4", stkMeshBulkData); stkMeshBulkData.modification_begin(); stk::mesh::EntityVector entities; stk::mesh::Selector select_owned(stkMeshMetaData.locally_owned_part()); @@ -242,10 +221,7 @@ TEST(IntegrationTest, ShellPartChangeCylinder) stk::io::StkMeshIoBroker exodusFileReader(communicator); exodusFileReader.property_add(Ioss::Property("DECOMPOSITION_METHOD", "RIB")); - exodusFileReader.set_bulk_data(stkMeshBulkData); - exodusFileReader.add_mesh_database(exodusFileName, stk::io::READ_MESH); - exodusFileReader.create_input_mesh(); - exodusFileReader.populate_bulk_data(); + stk::io::fill_mesh_preexisting(exodusFileReader, exodusFileName, stkMeshBulkData); stk::mesh::EntityVector entities; stk::mesh::get_entities(stkMeshBulkData, stk::topology::ELEM_RANK, stkMeshMetaData.locally_owned_part(), entities); stkMeshBulkData.modification_begin(); @@ -272,10 +248,7 @@ TEST(IntegrationTest, ShellPartChange2Hexes2Shells) stk::io::StkMeshIoBroker exodusFileReader(communicator); exodusFileReader.property_add(Ioss::Property("DECOMPOSITION_METHOD", "RIB")); - exodusFileReader.set_bulk_data(stkMeshBulkData); - exodusFileReader.add_mesh_database(exodusFileName, stk::io::READ_MESH); - exodusFileReader.create_input_mesh(); - exodusFileReader.populate_bulk_data(); + stk::io::fill_mesh_preexisting(exodusFileReader, exodusFileName, stkMeshBulkData); stk::mesh::EntityVector entities; stk::mesh::Selector select_owned(stkMeshMetaData.locally_owned_part()); diff --git a/packages/stk/stk_io/stk_io/IossBridge.cpp b/packages/stk/stk_io/stk_io/IossBridge.cpp index 7bf3e2f72f52..0820b80ef7af 100644 --- a/packages/stk/stk_io/stk_io/IossBridge.cpp +++ b/packages/stk/stk_io/stk_io/IossBridge.cpp @@ -762,6 +762,9 @@ const stk::mesh::FieldBase *declare_stk_field_internal(stk::mesh::MetaData &meta void set_alternate_part_name(stk::mesh::Part& part, const std::string& altPartName) { stk::mesh::impl::set_unique_part_attribute(part, altPartName); + + mesh::MetaData & meta = mesh::MetaData::get(part); + meta.add_part_alias(part, altPartName); } bool has_alternate_part_name(const stk::mesh::Part& part) @@ -830,24 +833,6 @@ const stk::mesh::FieldBase *declare_stk_field_internal(stk::mesh::MetaData &meta return part.name(); } - stk::mesh::Part *getPart(const stk::mesh::MetaData& metaData, const std::string& name) - { - stk::mesh::Part *part = metaData.get_part(name); - if(nullptr != part) { - return part; - } - - const mesh::PartVector & parts = metaData.get_parts(); - for (unsigned ii=0; ii < parts.size(); ++ii) - { - stk::mesh::Part *pp = parts[ii]; - std::string altName = getPartName(*pp); - if (stk::equal_case(altName, name)) - return pp; - } - return 0; - } - Ioss::GroupingEntity* get_grouping_entity(const Ioss::Region& region, const stk::mesh::Part& part) { if(!stk::io::is_part_io_part(part)) { return nullptr; } @@ -3232,7 +3217,7 @@ const stk::mesh::FieldBase *declare_stk_field_internal(stk::mesh::MetaData &meta const stk::mesh::BulkData &bulk = params.bulk_data(); const stk::mesh::MetaData & metaData = bulk.mesh_meta_data(); const std::string& name = block->name(); - mesh::Part* part = getPart( metaData, name); + mesh::Part* part = metaData.get_part(name); assert(part != nullptr); stk::topology topo = part->topology(); @@ -3343,7 +3328,7 @@ const stk::mesh::FieldBase *declare_stk_field_internal(stk::mesh::MetaData &meta const stk::mesh::BulkData &bulk = params.bulk_data(); const stk::mesh::MetaData & metaData = bulk.mesh_meta_data(); const std::string& name = ns->name(); - mesh::Part* part = getPart( metaData, name); + mesh::Part* part = metaData.get_part(name); // If part is null, then it is possible that this nodeset is a "viz nodeset" which // means that it is a nodeset containing the nodes of an element block. @@ -3352,7 +3337,7 @@ const stk::mesh::FieldBase *declare_stk_field_internal(stk::mesh::MetaData &meta if (part == nullptr) { if (ns->property_exists(base_stk_part_name)) { std::string baseName = ns->get_property(base_stk_part_name).get_string(); - part = getPart( metaData, baseName); + part = metaData.get_part(baseName); } if (part == nullptr) { std::ostringstream msg ; @@ -3450,7 +3435,7 @@ const stk::mesh::FieldBase *declare_stk_field_internal(stk::mesh::MetaData &meta for (size_t i=0; i < blockCount; i++) { Ioss::SideBlock *block = ss->get_block(i); if (stk::io::include_entity(block)) { - stk::mesh::Part * part = getPart(meta, block->name()); + stk::mesh::Part * part = meta.get_part(block->name()); const Ioss::ElementTopology *parent_topology = block->parent_element_topology(); stk::io::write_side_data_to_ioss(params, *block, part, parent_topology); } @@ -3463,7 +3448,7 @@ const stk::mesh::FieldBase *declare_stk_field_internal(stk::mesh::MetaData &meta const stk::mesh::BulkData &bulk = params.bulk_data(); const stk::mesh::MetaData & metaData = bulk.mesh_meta_data(); const std::string& name = fb->name(); - mesh::Part* part = getPart( metaData, name); + mesh::Part* part = metaData.get_part(name); assert(part != nullptr); stk::topology topo = part->topology(); @@ -3523,7 +3508,7 @@ const stk::mesh::FieldBase *declare_stk_field_internal(stk::mesh::MetaData &meta const stk::mesh::BulkData &bulk = params.bulk_data(); const stk::mesh::MetaData & metaData = bulk.mesh_meta_data(); const std::string& name = eb->name(); - mesh::Part* part = getPart( metaData, name); + mesh::Part* part = metaData.get_part(name); assert(part != nullptr); stk::topology topo = part->topology(); diff --git a/packages/stk/stk_io/stk_io/IossBridge.hpp b/packages/stk/stk_io/stk_io/IossBridge.hpp index 512ac0ea80fb..398e48240374 100644 --- a/packages/stk/stk_io/stk_io/IossBridge.hpp +++ b/packages/stk/stk_io/stk_io/IossBridge.hpp @@ -137,8 +137,6 @@ struct FieldNameToPartLess typedef std::vector FieldNameToPartVector; -stk::mesh::Part *getPart(const stk::mesh::MetaData& meta_data, const std::string& name); - bool is_valid_for_output(stk::io::OutputParams ¶ms, const stk::mesh::Part &part); void get_selected_nodes(OutputParams ¶ms, const stk::mesh::Selector &selector, diff --git a/packages/stk/stk_io/stk_io/OutputFile.cpp b/packages/stk/stk_io/stk_io/OutputFile.cpp index fcfee6f454fb..b495ffc13477 100644 --- a/packages/stk/stk_io/stk_io/OutputFile.cpp +++ b/packages/stk/stk_io/stk_io/OutputFile.cpp @@ -199,8 +199,10 @@ std::vector OutputFile::get_output_entities(const stk::mesh:: std::vector entities; - stk::io::OutputParams params(*m_region, bulk_data); - setup_output_params(params); + if (m_outputParams == nullptr){ + m_outputParams = std::make_shared(*m_region, bulk_data); + setup_output_params(*m_outputParams); + } Ioss::GroupingEntity *ge = m_region->get_entity(name); ThrowErrorMsgIf (ge == nullptr, @@ -213,7 +215,7 @@ std::vector OutputFile::get_output_entities(const stk::mesh:: } else if(type == Ioss::NODESET) { part_type = stk::topology::NODE_RANK; } else if(type == Ioss::ELEMENTBLOCK) { - part_type = params.has_skin_mesh_selector() ? meta.side_rank() : stk::topology::ELEMENT_RANK; + part_type = m_outputParams->has_skin_mesh_selector() ? meta.side_rank() : stk::topology::ELEMENT_RANK; } else if(type == Ioss::SIDESET) { part = meta.get_part(name); ThrowRequireMsg(nullptr != part, "Could not find a sideset with name: " + name); @@ -231,15 +233,15 @@ std::vector OutputFile::get_output_entities(const stk::mesh:: } if(type == Ioss::SIDEBLOCK) { - Ioss::Region &io_region = params.io_region(); + Ioss::Region &io_region = m_outputParams->io_region(); bool ints64bit = db_api_int_size(&io_region) == 8; if (ints64bit) { - internal_fill_output_entities_for_sideblock(params, ge, part, entities); + internal_fill_output_entities_for_sideblock(*m_outputParams, ge, part, entities); } else { - internal_fill_output_entities_for_sideblock(params, ge, part, entities); + internal_fill_output_entities_for_sideblock(*m_outputParams, ge, part, entities); } } else { - get_output_entity_list(ge, part_type, params, entities); + get_output_entity_list(ge, part_type, *m_outputParams, entities); } return entities; diff --git a/packages/stk/stk_io/stk_io/OutputFile.hpp b/packages/stk/stk_io/stk_io/OutputFile.hpp index b46d87507c52..526dd01a1eca 100644 --- a/packages/stk/stk_io/stk_io/OutputFile.hpp +++ b/packages/stk/stk_io/stk_io/OutputFile.hpp @@ -97,6 +97,7 @@ class OutputFile m_enableEdgeIO(false), m_dbPurpose(db_type), m_inputRegion(input_region), + m_outputParams(nullptr), m_subsetSelector(nullptr), m_sharedSelector(nullptr), m_skinMeshSelector(nullptr), @@ -127,6 +128,7 @@ class OutputFile m_enableEdgeIO(false), m_dbPurpose(db_type), m_inputRegion(input_region), + m_outputParams(nullptr), m_subsetSelector(nullptr), m_sharedSelector(nullptr), m_skinMeshSelector(nullptr), @@ -255,6 +257,7 @@ class OutputFile bool m_enableEdgeIO; DatabasePurpose m_dbPurpose; const Ioss::Region* m_inputRegion; + std::shared_ptr m_outputParams; Teuchos::RCP m_subsetSelector; Teuchos::RCP m_sharedSelector; Teuchos::RCP m_outputSelector[stk::topology::ELEM_RANK+1]; diff --git a/packages/stk/stk_mesh/stk_mesh/base/Bucket.hpp b/packages/stk/stk_mesh/stk_mesh/base/Bucket.hpp index 8e1901b49ca9..5a9dc86160f8 100644 --- a/packages/stk/stk_mesh/stk_mesh/base/Bucket.hpp +++ b/packages/stk/stk_mesh/stk_mesh/base/Bucket.hpp @@ -59,6 +59,21 @@ namespace stk { namespace mesh { namespace impl { struct OverwriteEntityFunctor; namespace stk { namespace mesh { +constexpr +inline +bool does_rank_have_valid_permutations(stk::mesh::EntityRank rank) +{ + return rank > stk::topology::NODE_RANK && rank < stk::topology::CONSTRAINT_RANK; +} + +constexpr +inline +bool should_store_permutations(EntityRank fromRank, EntityRank toRank) +{ + return does_rank_have_valid_permutations(fromRank) + && does_rank_have_valid_permutations(toRank); +} + /** \addtogroup stk_mesh_module * \{ */ diff --git a/packages/stk/stk_mesh/stk_mesh/base/BulkData.cpp b/packages/stk/stk_mesh/stk_mesh/base/BulkData.cpp index 4f4762ec63f1..808953f188a0 100644 --- a/packages/stk/stk_mesh/stk_mesh/base/BulkData.cpp +++ b/packages/stk/stk_mesh/stk_mesh/base/BulkData.cpp @@ -986,7 +986,7 @@ void BulkData::entity_comm_list_insert(Entity node) } } -void BulkData::add_node_sharing( Entity node, int sharing_proc ) +void BulkData::add_node_sharing(Entity node, int sharing_proc) { // Only valid to specify sharing information for non-deleted nodes ThrowRequire(entity_rank(node) == stk::topology::NODE_RANK); @@ -1006,6 +1006,41 @@ void BulkData::add_node_sharing( Entity node, int sharing_proc ) entity_comm_list_insert(node); } +void BulkData::add_node_sharing(const EntityProcVec& nodesAndProcs) +{ + EntityCommListInfoVector newCommListEntries; + newCommListEntries.reserve(nodesAndProcs.size()); + + for(const EntityProc& nodeAndSharingProc : nodesAndProcs) { + Entity node = nodeAndSharingProc.first; + int sharing_proc = nodeAndSharingProc.second; + + // Only valid to specify sharing information for non-deleted nodes + ThrowRequire(entity_rank(node) == stk::topology::NODE_RANK); + ThrowRequire(state(node) != Deleted); + + protect_orphaned_node(node); + + if (state(node) == Unchanged) { + mark_entity_and_upward_related_entities_as_modified(node); + } + + internal_mark_entity(node, IS_SHARED); + std::pair result = entity_comm_map_insert(node, EntityCommInfo(stk::mesh::BulkData::SHARED, sharing_proc)); + entity_comm_map_erase(entity_key(node), EntityCommInfo(stk::mesh::BulkData::AURA, sharing_proc)); + + const bool inserted = result.second; + if (inserted) { + EntityKey key = entity_key(node); + EntityCommListInfo info = {key, node, result.first}; + newCommListEntries.push_back(info); + } + } + + internal_add_comm_list_entries(newCommListEntries); + m_add_node_sharing_called = true; +} + EntityId BulkData::get_solo_side_id() { return m_soloSideIdGenerator.get_solo_side_id(); @@ -3408,16 +3443,7 @@ void BulkData::ghost_entities_and_fields(Ghosting & ghosting, ThrowErrorMsgIf( error_count, error_msg.str() ); #endif - if (!newCommListEntries.empty()) { - // Added new ghosting entities to the list, - // must now sort and merge. - - stk::util::sort_and_unique(newCommListEntries); - if (newCommListEntries.capacity() >= newCommListEntries.size()+m_entity_comm_list.size()) { - m_entity_comm_list.swap(newCommListEntries); - } - stk::util::insert_keep_sorted_and_unique(newCommListEntries, m_entity_comm_list); - } + internal_add_comm_list_entries(newCommListEntries); OrdinalVector addParts, scratchOrdinalVec; removeParts = {ghosting_part(ghosting).mesh_meta_data_ordinal()}; @@ -4077,6 +4103,18 @@ void BulkData::add_comm_list_entries_for_entities(const std::vector= newCommListEntries.size()+m_entity_comm_list.size()) { + m_entity_comm_list.swap(newCommListEntries); + } + stk::util::insert_keep_sorted_and_unique(newCommListEntries, m_entity_comm_list); + } +} + //---------------------------------------------------------------------- // Postconditions: @@ -4589,8 +4627,15 @@ void BulkData::internal_resolve_shared_membership(const stk::mesh::EntityVector buf.unpack(key); buf.unpack(remoteState); Entity entity = get_entity(key); + int numSharingProcs = 0; + buf.unpack(numSharingProcs); + for(int sp=0; sp(sharingProc); + entity_comm_map_insert(entity, EntityCommInfo(SHARED, sharingProc)); + } + const EntityState localState = state(entity); - if (!in_shared(entity,p)) { if (localState == Unchanged) { stk::util::insert_keep_sorted_and_unique(EntityProc(entity,p), diff --git a/packages/stk/stk_mesh/stk_mesh/base/BulkData.hpp b/packages/stk/stk_mesh/stk_mesh/base/BulkData.hpp index 349109def030..76390ffc5480 100644 --- a/packages/stk/stk_mesh/stk_mesh/base/BulkData.hpp +++ b/packages/stk/stk_mesh/stk_mesh/base/BulkData.hpp @@ -31,12 +31,10 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // - #ifndef stk_mesh_BulkData_hpp #define stk_mesh_BulkData_hpp //---------------------------------------------------------------------- - #include // for size_t #include // for uint16_t #include // for max @@ -415,7 +413,8 @@ class BulkData { * on all sharing processors. Otherwise, the nodes will remain unique * on different processors. */ - void add_node_sharing( Entity node, int sharing_proc ); + void add_node_sharing(Entity node, int sharing_proc ); + void add_node_sharing(const EntityProcVec& nodesAndProcs); /** \brief Change an entity's EntityId, for Framework implementation. * Only intended for use in supporting Framework implementation. @@ -1128,6 +1127,7 @@ void get_entities(EntityRank rank, Selector const& selector, EntityVector& outpu void move_entities_to_proper_part_ownership( const std::vector &shared_modified ); // Mod Mark void add_comm_list_entries_for_entities(const std::vector& shared_modified); + void internal_add_comm_list_entries(EntityCommListInfoVector& newCommListEntries); std::pair entity_comm_map_insert(Entity entity, const EntityCommInfo &val) { diff --git a/packages/stk/stk_mesh/stk_mesh/base/EntityCommDatabase.cpp b/packages/stk/stk_mesh/stk_mesh/base/EntityCommDatabase.cpp index c8984950b9ad..28a00a37ae41 100644 --- a/packages/stk/stk_mesh/stk_mesh/base/EntityCommDatabase.cpp +++ b/packages/stk/stk_mesh/stk_mesh/base/EntityCommDatabase.cpp @@ -122,11 +122,9 @@ void pack_entity_info(const BulkData& mesh, ThrowAssert(rel_ordinals); buf.pack( mesh.entity_key(rel_entities[i]) ); buf.pack( rel_ordinals[i] ); - if (bucket.has_permutation(irank)) { + if (should_store_permutations(bucket.entity_rank(),irank)) { ThrowAssert(rel_permutations); buf.pack( rel_permutations[i] ); - } else { - buf.pack(0u); } } } @@ -168,7 +166,9 @@ void unpack_entity_info( unsigned rel_attr = 0 ; buf.unpack( rel_key ); buf.unpack( rel_id ); - buf.unpack( rel_attr ); + if (should_store_permutations(key.rank(), rel_key.rank())) { + buf.unpack( rel_attr ); + } Entity const entity = mesh.get_entity( rel_key.rank(), rel_key.id() ); if ( mesh.is_valid(entity) ) { diff --git a/packages/stk/stk_mesh/stk_mesh/base/EntityCommDatabase.hpp b/packages/stk/stk_mesh/stk_mesh/base/EntityCommDatabase.hpp index c8605a819eee..08dbfa086abb 100644 --- a/packages/stk/stk_mesh/stk_mesh/base/EntityCommDatabase.hpp +++ b/packages/stk/stk_mesh/stk_mesh/base/EntityCommDatabase.hpp @@ -46,14 +46,13 @@ #include #include "stk_mesh/base/EntityKey.hpp" // for EntityKey, hash_value #include "stk_mesh/base/Ghosting.hpp" +#include "stk_mesh/base/HashEntityAndEntityKey.hpp" #include "stk_util/util/MCSR.hpp" namespace stk { class CommBuffer; } namespace stk { namespace mesh { class BulkData; } } namespace stk { namespace mesh { class Relation; } } namespace stk { namespace mesh { struct Entity; } } - - //---------------------------------------------------------------------- namespace stk { @@ -68,7 +67,7 @@ class CommMapChangeListener { class EntityCommDatabase { - typedef std::unordered_map map_type; + typedef std::unordered_map> map_type; public: EntityCommDatabase(); diff --git a/packages/stk/stk_mesh/stk_mesh/base/EntityKey.hpp b/packages/stk/stk_mesh/stk_mesh/base/EntityKey.hpp index 2305ed8d4b46..e23ee4f27ac7 100644 --- a/packages/stk/stk_mesh/stk_mesh/base/EntityKey.hpp +++ b/packages/stk/stk_mesh/stk_mesh/base/EntityKey.hpp @@ -96,7 +96,8 @@ struct EntityKey std::ostream & operator << ( std::ostream & out, EntityKey key); -struct HashValueForEntityKey +#ifndef STK_HIDE_DEPRECATED_CODE // Delete after Jan 2023 +struct STK_DEPRECATED HashValueForEntityKey { KOKKOS_FUNCTION size_t operator()(EntityKey k) const @@ -104,7 +105,7 @@ struct HashValueForEntityKey return static_cast(k.m_value); } }; - +#endif }} // namespace stk::mesh #endif /* STK_MESH_ENTITYKEY_HPP */ diff --git a/packages/stk/stk_mesh/stk_mesh/base/Stencils.hpp b/packages/stk/stk_mesh/stk_mesh/base/Stencils.hpp deleted file mode 100644 index 2b31bcc03169..000000000000 --- a/packages/stk/stk_mesh/stk_mesh/base/Stencils.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2002 - 2008, 2010, 2011 National Technology Engineering -// Solutions of Sandia, LLC (NTESS). Under the terms of Contract -// DE-NA0003525 with NTESS, the U.S. Government retains certain rights -// in this software. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// -// * Neither the name of NTESS nor the names of its contributors -// may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// - -#ifndef stk_mesh_Stencils_hpp -#define stk_mesh_Stencils_hpp - -#include // for size_t -#include // for EntityRank, etc -#include "stk_topology/topology.hpp" // for topology, etc - - - -namespace stk { -namespace mesh { - - -} // namespace mesh -} // namespace stk - -#endif // stk_mesh_Stencils_hpp diff --git a/packages/stk/stk_mesh/stk_mesh/base/Types.hpp b/packages/stk/stk_mesh/stk_mesh/base/Types.hpp index 13d2475aa8b3..6876555c51a6 100644 --- a/packages/stk/stk_mesh/stk_mesh/base/Types.hpp +++ b/packages/stk/stk_mesh/stk_mesh/base/Types.hpp @@ -305,7 +305,7 @@ using ConnectivityOrdinal = uint32_t; constexpr ConnectivityOrdinal INVALID_CONNECTIVITY_ORDINAL = ~0U; #endif -enum Permutation +enum Permutation : unsigned char { DEFAULT_PERMUTATION = 0, INVALID_PERMUTATION = 128 diff --git a/packages/stk/stk_mesh/stk_mesh/baseImpl/DeletedEntityCache.hpp b/packages/stk/stk_mesh/stk_mesh/baseImpl/DeletedEntityCache.hpp index f516d7fe42f0..40252923588d 100644 --- a/packages/stk/stk_mesh/stk_mesh/baseImpl/DeletedEntityCache.hpp +++ b/packages/stk/stk_mesh/stk_mesh/baseImpl/DeletedEntityCache.hpp @@ -37,13 +37,14 @@ #include // for MeshIndex, EntityRank, etc #include -#include "stk_mesh/base/EntityKey.hpp" +#include +#include namespace stk { namespace mesh { class BulkData; -typedef std::unordered_map GhostReuseMap; +typedef std::unordered_map> GhostReuseMap; namespace impl { @@ -78,4 +79,4 @@ class DeletedEntityCache } } -#endif \ No newline at end of file +#endif diff --git a/packages/stk/stk_mesh/stk_mesh/baseImpl/MeshCommImplUtils.cpp b/packages/stk/stk_mesh/stk_mesh/baseImpl/MeshCommImplUtils.cpp index 502fe635fbba..cba0ce43bf04 100644 --- a/packages/stk/stk_mesh/stk_mesh/baseImpl/MeshCommImplUtils.cpp +++ b/packages/stk/stk_mesh/stk_mesh/baseImpl/MeshCommImplUtils.cpp @@ -232,12 +232,24 @@ bool pack_and_send_modified_shared_entity_states(stk::CommSparse& comm, for (int sharingProc : sharingProcs) { comm.send_buffer(sharingProc).pack(info.key) .pack(state); + //if I'm the owner, and the shared entity is modified, send the current list of + //other sharers also, to make sure all sharers know about each other. + int numOtherSharingProcs = bulk.bucket(info.entity).owned() ? sharingProcs.size()-1 : 0; + comm.send_buffer(sharingProc).pack(numOtherSharingProcs); + if (numOtherSharingProcs > 0) { + for(int sp : sharingProcs) { + if (sp != sharingProc) { + comm.send_buffer(sharingProc).pack(sp); + } + } + } } if (sharingProcs.empty() && state == Modified) { const int owner = bulk.parallel_owner_rank(info.entity); if (owner != bulk.parallel_rank() && bulk.bucket(info.entity).in_aura()) { comm.send_buffer(owner).pack(info.key) - .pack(state); + .pack(state) + .pack(0); } } } diff --git a/packages/stk/stk_mesh/stk_mesh/baseImpl/MeshModification.cpp b/packages/stk/stk_mesh/stk_mesh/baseImpl/MeshModification.cpp index 183e48d58fbb..5e2739985d95 100644 --- a/packages/stk/stk_mesh/stk_mesh/baseImpl/MeshModification.cpp +++ b/packages/stk/stk_mesh/stk_mesh/baseImpl/MeshModification.cpp @@ -132,16 +132,6 @@ bool MeshModification::modification_end(modification_optimization opt) } bool MeshModification::resolve_node_sharing() -{ - return this->internal_resolve_node_sharing( MOD_END_SORT ); -} - -bool MeshModification::modification_end_after_node_sharing_resolution() -{ - return this->internal_modification_end_after_node_sharing_resolution( MOD_END_SORT ); -} - -bool MeshModification::internal_resolve_node_sharing(modification_optimization opt) { if(this->in_synchronized_state()) { @@ -169,7 +159,7 @@ bool MeshModification::internal_resolve_node_sharing(modification_optimization o return true; } -bool MeshModification::internal_modification_end_after_node_sharing_resolution(modification_optimization opt) +bool MeshModification::modification_end_after_node_sharing_resolution() { if(this->in_synchronized_state()) { @@ -215,7 +205,7 @@ bool MeshModification::internal_modification_end_after_node_sharing_resolution(m } } - m_bulkData.internal_finish_modification_end(opt); + m_bulkData.internal_finish_modification_end(MOD_END_SORT); return true; } @@ -507,11 +497,11 @@ void MeshModification::internal_resolve_ghosted_modify_delete(const std::vector< } } else { - if (!m_bulkData.in_ghost(m_bulkData.aura_ghosting(), entity) && m_bulkData.state(entity)==Unchanged) { + const bool shouldPromoteToShared = !isAlreadyDestroyed && i->remote_owned_closure==1 && key.rank() < stk::topology::ELEM_RANK; + if ((shouldPromoteToShared || !m_bulkData.in_ghost(m_bulkData.aura_ghosting(), entity)) && m_bulkData.state(entity)==Unchanged) { m_bulkData.set_state(entity, Modified); } - const bool shouldPromoteToShared = !isAlreadyDestroyed && i->remote_owned_closure==1 && key.rank() < stk::topology::ELEM_RANK; if (shouldPromoteToShared) { m_bulkData.entity_comm_map_insert(entity, EntityCommInfo(BulkData::SHARED, remote_proc)); promotingToShared.push_back(entity); diff --git a/packages/stk/stk_mesh/stk_mesh/baseImpl/MeshModification.hpp b/packages/stk/stk_mesh/stk_mesh/baseImpl/MeshModification.hpp index 1569914c7a4a..531a52c6a25b 100644 --- a/packages/stk/stk_mesh/stk_mesh/baseImpl/MeshModification.hpp +++ b/packages/stk/stk_mesh/stk_mesh/baseImpl/MeshModification.hpp @@ -136,9 +136,6 @@ class MeshModification void reset_undeleted_entity_states_to_unchanged(); void ensure_meta_data_is_committed(); - bool internal_resolve_node_sharing(modification_optimization opt); - bool internal_modification_end_after_node_sharing_resolution(modification_optimization opt); - stk::mesh::BulkData &m_bulkData; std::vector m_entity_states; DeletedEntityCache m_deleted_entity_cache; diff --git a/packages/stk/stk_mesh/stk_mesh/base/Stencils.cpp b/packages/stk/stk_performance_tests/general/perfVectorConcat.cpp similarity index 56% rename from packages/stk/stk_mesh/stk_mesh/base/Stencils.cpp rename to packages/stk/stk_performance_tests/general/perfVectorConcat.cpp index 4dcd9325fed0..97a82441613c 100644 --- a/packages/stk/stk_mesh/stk_mesh/base/Stencils.cpp +++ b/packages/stk/stk_performance_tests/general/perfVectorConcat.cpp @@ -32,59 +32,51 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // +#include +#include +#include +#include -#include -#include // for ThrowRequire -#include "stk_mesh/base/Types.hpp" // for EntityRank, etc +namespace { -namespace stk { -namespace mesh { - -int -element_node_stencil_2d( - EntityRank from_type , - EntityRank to_type , - unsigned identifier ) +TEST(ParallelVectorConcat, Timing) { - static const size_t spatial_dimension = 2; + if (stk::parallel_machine_size(MPI_COMM_WORLD) != 2) { GTEST_SKIP(); } - int ordinal = -1 ; + constexpr unsigned numIters = 3; + constexpr unsigned numRuns = 5; - if ( spatial_dimension == from_type && stk::topology::NODE_RANK == to_type ) { - ordinal = static_cast(identifier); - } + stk::unit_test_util::BatchTimer batchTimer(MPI_COMM_WORLD); + batchTimer.initialize_batch_timer(); - return ordinal ; -} + for(unsigned run=0; run; + const size_t bufSize = size_t(std::numeric_limits::max())/sizeof(Item) + 1000; + std::vector localBuf(bufSize); + std::vectorglobalBuf; - int ordinal = -1 ; + const int myrank = stk::parallel_machine_rank(MPI_COMM_WORLD); + for (size_t i=0; i < bufSize; ++i) { + localBuf[i] = std::make_pair(static_cast(i + myrank),static_cast(i + myrank)); + } - if ( spatial_dimension == from_type && stk::topology::NODE_RANK == to_type ) { - ordinal = static_cast(identifier); + for(unsigned iter=0; iter +#include +#include +#include +#include + +namespace +{ + +void build_mesh_in_batches(stk::mesh::BulkData& mesh, + size_t numElemsPerProc, + size_t batchSize) +{ + unsigned numOwnedNodes = (numElemsPerProc+1)*2; + unsigned numSharedNodes = (numElemsPerProc+1)*2; + + std::vector ownedNodes(numOwnedNodes); + std::vector sharedNodes(numSharedNodes); + + int localProc = mesh.parallel_rank(); + int numProcs = mesh.parallel_size(); + stk::mesh::EntityId firstLocalOwnedNode = 1 + numOwnedNodes*localProc; + stk::mesh::EntityId firstLocalSharedNode = 1 + numOwnedNodes*numProcs; + + for(size_t inode=0; inode bulk = stk::mesh::MeshBuilder(MPI_COMM_WORLD).set_spatial_dimension(3).create(); + build_mesh_in_batches(*bulk, numElemsPerProc, batchSize); + + batchTimer.stop_batch_timer(); + } + + batchTimer.print_batch_timing(numRuns); +} + +} + diff --git a/packages/stk/stk_unit_tests/stk_mesh/UnitTestAuraToShared.cpp b/packages/stk/stk_unit_tests/stk_mesh/UnitTestAuraToShared.cpp index aa3c4ee6f822..4d1d13a063dd 100644 --- a/packages/stk/stk_unit_tests/stk_mesh/UnitTestAuraToShared.cpp +++ b/packages/stk/stk_unit_tests/stk_mesh/UnitTestAuraToShared.cpp @@ -116,5 +116,130 @@ TEST_F(AuraToSharedToAura, makeAuraNodeSharedThenDelete) create_elem3_p1_and_delete_elem1_p0(); } +class Aura2DTri4Procs : public TestTextMeshAura2d +{ +public: + Aura2DTri4Procs() {} + + void p1_starts_sharing_node2() + { + get_bulk().modification_begin(); + + if (get_bulk().parallel_rank() == 1) { + stk::mesh::Entity elem4 = get_bulk().get_entity(stk::topology::ELEM_RANK, 4); + stk::mesh::Entity node8 = get_bulk().get_entity(stk::topology::NODE_RANK, 8); + stk::mesh::Entity node2 = get_bulk().get_entity(stk::topology::NODE_RANK, 2); + stk::mesh::ConnectivityOrdinal ord = 2; + get_bulk().destroy_relation(elem4, node8, ord); + get_bulk().declare_relation(elem4, node2, ord); + } + + get_bulk().modification_end(); + } + + void p2_starts_sharing_node2() + { + get_bulk().modification_begin(); + + if (get_bulk().parallel_rank() == 2) { + stk::mesh::Entity elem4 = get_bulk().get_entity(stk::topology::ELEM_RANK, 4); + stk::mesh::Entity node10 = get_bulk().get_entity(stk::topology::NODE_RANK, 10); + stk::mesh::Entity node2 = get_bulk().get_entity(stk::topology::NODE_RANK, 2); + stk::mesh::ConnectivityOrdinal ord = 2; + get_bulk().destroy_relation(elem4, node10, ord); + get_bulk().declare_relation(elem4, node2, ord); + } + + get_bulk().modification_end(); + } +}; + +TEST_F(Aura2DTri4Procs, addSharerToAlreadySharedAuraNode) +{ + if (get_parallel_size() != 4) { GTEST_SKIP(); } + + std::string meshDesc = "0, 1, TRI_3_2D, 1,2,3\n" + "1, 3, TRI_3_2D, 1,6,7\n" + "1, 4, TRI_3_2D, 1,7,8\n" + "2, 5, TRI_3_2D, 9,10,4\n" + "3, 2, TRI_3_2D, 2,4,5\n"; + setup_text_mesh(meshDesc); + + stk::mesh::Entity node2 = get_bulk().get_entity(stk::topology::NODE_RANK, 2); + EXPECT_TRUE(get_bulk().is_valid(node2)); + const int proc = get_bulk().parallel_rank(); + EXPECT_EQ(0, get_bulk().parallel_owner_rank(node2)); + if (proc == 1 || proc == 2) { + EXPECT_TRUE(get_bulk().bucket(node2).in_aura()); + EXPECT_FALSE(get_bulk().bucket(node2).shared()); + } + else { + EXPECT_TRUE(get_bulk().bucket(node2).shared()); + EXPECT_FALSE(get_bulk().bucket(node2).in_aura()); + } + + p1_starts_sharing_node2(); + + node2 = get_bulk().get_entity(stk::topology::NODE_RANK, 2); + EXPECT_TRUE(get_bulk().is_valid(node2)); + EXPECT_EQ(0, get_bulk().parallel_owner_rank(node2)); + + if (proc == 2) { + EXPECT_TRUE(get_bulk().bucket(node2).in_aura()); + EXPECT_FALSE(get_bulk().bucket(node2).shared()); + } + else { + EXPECT_TRUE(get_bulk().bucket(node2).shared()); + EXPECT_FALSE(get_bulk().bucket(node2).in_aura()); + } + + if (proc == 1 || proc == 3) { + int ownerProc = 0; + int otherSharingProc = proc==1 ? 3 : 1; + EXPECT_TRUE(get_bulk().in_shared(node2, ownerProc)); + EXPECT_TRUE(get_bulk().in_shared(node2, otherSharingProc)); + } +} + +TEST_F(Aura2DTri4Procs, addSharerToAlreadySharedAuraNode_addsRemoteGhostingRequestForAlreadyShared) +{ + if (get_parallel_size() != 3) { GTEST_SKIP(); } + + std::string meshDesc = "0, 1, TRI_3_2D, 1,2,3\n" + "1, 2, TRI_3_2D, 2,4,5\n" + "2, 4, TRI_3_2D, 8,9,10\n" + "2, 3, TRI_3_2D, 6,7,4\n"; + setup_text_mesh(meshDesc); + + stk::mesh::Entity node2 = get_bulk().get_entity(stk::topology::NODE_RANK, 2); + EXPECT_TRUE(get_bulk().is_valid(node2)); + const int proc = get_bulk().parallel_rank(); + EXPECT_EQ(0, get_bulk().parallel_owner_rank(node2)); + if (proc == 2) { + EXPECT_TRUE(get_bulk().bucket(node2).in_aura()); + EXPECT_FALSE(get_bulk().bucket(node2).shared()); + } + else { + EXPECT_TRUE(get_bulk().bucket(node2).shared()); + EXPECT_FALSE(get_bulk().bucket(node2).in_aura()); + } + + p2_starts_sharing_node2(); + + node2 = get_bulk().get_entity(stk::topology::NODE_RANK, 2); + EXPECT_TRUE(get_bulk().is_valid(node2)); + EXPECT_EQ(0, get_bulk().parallel_owner_rank(node2)); + + EXPECT_TRUE(get_bulk().bucket(node2).shared()); + EXPECT_FALSE(get_bulk().bucket(node2).in_aura()); + + if (proc == 1 || proc == 2) { + int ownerProc = 0; + int otherSharingProc = proc==1 ? 2 : 1; + EXPECT_TRUE(get_bulk().in_shared(node2, ownerProc)); + EXPECT_TRUE(get_bulk().in_shared(node2, otherSharingProc)); + } +} + } // empty namespace diff --git a/packages/stk/stk_unit_tests/stk_mesh/UnitTestBulkData.cpp b/packages/stk/stk_unit_tests/stk_mesh/UnitTestBulkData.cpp index e0a3a95608bc..cbbc47bc5bc4 100644 --- a/packages/stk/stk_unit_tests/stk_mesh/UnitTestBulkData.cpp +++ b/packages/stk/stk_unit_tests/stk_mesh/UnitTestBulkData.cpp @@ -387,10 +387,7 @@ TEST(BulkData, testCreateMoreExistingOwnershipIsKept) const int p_size = stk::parallel_machine_size( pm ); const int p_rank = stk::parallel_machine_rank( pm ); - if (p_size != 2) { - return; - } - + if (p_size != 2) { GTEST_SKIP(); } const unsigned id_total = nPerProc * p_size ; const unsigned id_begin = nPerProc * p_rank ; @@ -434,19 +431,24 @@ TEST(BulkData, testCreateMoreExistingOwnershipIsKept) { ASSERT_TRUE( bulk.modification_begin() ); + int otherProc = 1 - p_rank; + stk::mesh::EntityProcVec sharedNodesAndProcs; + if (0 == p_rank) { Entity n10 = bulk.get_entity( stk::topology::NODE_RANK , 10 ); + sharedNodesAndProcs.push_back(EntityProc(n10, otherProc)); Entity n11 = bulk.declare_node(11, no_parts); - bulk.add_node_sharing(n10, 1); - bulk.add_node_sharing(n11, 1); + sharedNodesAndProcs.push_back(EntityProc(n11, otherProc)); } else if ( 1 == p_rank ) { Entity n10 = bulk.declare_node(10, no_parts); + sharedNodesAndProcs.push_back(EntityProc(n10, otherProc)); Entity n11 = bulk.get_entity( stk::topology::NODE_RANK , 11 ); - bulk.add_node_sharing(n10, 0); - bulk.add_node_sharing(n11, 0); + sharedNodesAndProcs.push_back(EntityProc(n11, otherProc)); } + bulk.add_node_sharing(sharedNodesAndProcs); + ASSERT_TRUE(bulk.modification_end()); { @@ -462,13 +464,16 @@ TEST(BulkData, testCreateMoreExistingOwnershipIsKept) { ASSERT_TRUE(bulk.modification_begin()); + int otherProc = 1 - p_rank; + stk::mesh::EntityProcVec sharedNodesAndProcs; + if ( 0 == p_rank ) { Entity n8 = bulk.get_entity( stk::topology::NODE_RANK , 8 ); Entity n9 = bulk.get_entity( stk::topology::NODE_RANK , 9 ); + sharedNodesAndProcs.push_back(EntityProc(n9, otherProc)); Entity n20 = bulk.declare_node(20, no_parts); - bulk.add_node_sharing(n9, 1); - bulk.add_node_sharing(n20, 1); + sharedNodesAndProcs.push_back(EntityProc(n20, otherProc)); Entity e_9_20 = bulk.declare_edge(1, stk::mesh::ConstPartVector{edge_part}); bulk.declare_relation( e_9_20 , n9 , 0 ); @@ -485,9 +490,9 @@ TEST(BulkData, testCreateMoreExistingOwnershipIsKept) Entity n18 = bulk.get_entity( stk::topology::NODE_RANK , 18 ); Entity n9 = bulk.declare_node(9, no_parts); + sharedNodesAndProcs.push_back(EntityProc(n9, otherProc)); Entity n20 = bulk.get_entity( stk::topology::NODE_RANK , 20 ); - bulk.add_node_sharing(n9, 0); - bulk.add_node_sharing(n20, 0); + sharedNodesAndProcs.push_back(EntityProc(n20, otherProc)); Entity e_9_20 = bulk.declare_edge(1, stk::mesh::ConstPartVector{edge_part}); bulk.declare_relation( e_9_20 , n9 , 0 ); @@ -501,6 +506,8 @@ TEST(BulkData, testCreateMoreExistingOwnershipIsKept) bulk.declare_element_side( tri_shell, 0, stk::mesh::ConstPartVector{tri_part} ); } + bulk.add_node_sharing(sharedNodesAndProcs); + ASSERT_TRUE(bulk.modification_end()); { diff --git a/packages/stk/stk_unit_tests/stk_util/parallel/UnitTestParallelVectorConcat.cpp b/packages/stk/stk_unit_tests/stk_util/parallel/UnitTestParallelVectorConcat.cpp index 995bed2a46ff..c9d79efe9117 100644 --- a/packages/stk/stk_unit_tests/stk_util/parallel/UnitTestParallelVectorConcat.cpp +++ b/packages/stk/stk_unit_tests/stk_util/parallel/UnitTestParallelVectorConcat.cpp @@ -187,28 +187,3 @@ TEST(UnitTestParallel, testParallelVectorConcat) { } } -TEST(UnitTestParallel, testParallelVectorConcatLargeBuffer) -{ - if (stk::parallel_machine_size(MPI_COMM_WORLD) != 2) - { - GTEST_SKIP(); - } - - using Item = std::pair; - const size_t bufSize = size_t(std::numeric_limits::max())/sizeof(Item) + 1000; - std::vector localBuf(bufSize); - - const int myrank = stk::parallel_machine_rank(MPI_COMM_WORLD); - for (size_t i=0; i < bufSize; ++i) { - localBuf[i] = std::make_pair(static_cast(i + myrank),static_cast(i + myrank)); - } - - std::vectorglobalBuf; - stk::parallel_vector_concat(MPI_COMM_WORLD, localBuf, globalBuf); - EXPECT_EQ(globalBuf.size(), 2*bufSize); - - for (size_t j=0; j < bufSize; ++j) { - EXPECT_EQ(globalBuf[j], Item(double(j), double(j))); - EXPECT_EQ(globalBuf[bufSize + j], Item(double(1 + j), double(1 + j))); - } -} diff --git a/packages/stk/stk_unit_tests/stk_util/util/UnitTestThrowMacros.cpp b/packages/stk/stk_unit_tests/stk_util/util/UnitTestThrowMacros.cpp index 6a76325efd2f..1c7b8b2efc13 100644 --- a/packages/stk/stk_unit_tests/stk_util/util/UnitTestThrowMacros.cpp +++ b/packages/stk/stk_unit_tests/stk_util/util/UnitTestThrowMacros.cpp @@ -265,8 +265,10 @@ TEST(UnitTestingOfThrowMacros, NGP_ThrowRequireMsg) // Also, OpenMP seems to produce an abort (in adddition to a throw?). // // testNGPThrowRequireMsg(); + std::cout<<"NGP_ThrowRequireMsg: #if cuda, openmp or hip"<(version)); + get_stk_coupling_version().set_version_for_testing(static_cast(version)); #endif } diff --git a/packages/stk/stk_util/stk_util/registry/ProductRegistry.cpp b/packages/stk/stk_util/stk_util/registry/ProductRegistry.cpp index 11ed0ebd605e..adddf0d8934f 100644 --- a/packages/stk/stk_util/stk_util/registry/ProductRegistry.cpp +++ b/packages/stk/stk_util/stk_util/registry/ProductRegistry.cpp @@ -42,7 +42,7 @@ //In Sierra, STK_VERSION_STRING is provided on the compile line by bake. //For Trilinos stk snapshots, the following macro definition gets populated with //the real version string by the trilinos_snapshot.sh script. -#define STK_VERSION_STRING "5.11.3-456-g36f8322e" +#define STK_VERSION_STRING "5.11.4-192-g9193da2c" #endif namespace stk { diff --git a/packages/stk/stk_util/stk_util/stk_config.h b/packages/stk/stk_util/stk_util/stk_config.h index df76bc6105d0..89551060ddce 100644 --- a/packages/stk/stk_util/stk_util/stk_config.h +++ b/packages/stk/stk_util/stk_util/stk_config.h @@ -74,6 +74,7 @@ // Use macro below to deprecate: // classes (class STK_DEPRECATED Class;), +// structs (struct STK_DEPRECATED Struct;), // typedefs (STK_DEPRECATED typedef Type 1 Type2;, using Type1 STK_DEPRECATED = Type2;), // variables (STK_DEPRECATED int variable;), // non-static data members (union Union { STK_DEPRECATED int variable; }), diff --git a/packages/stokhos/src/CMakeLists.txt b/packages/stokhos/src/CMakeLists.txt index a073e5b5aa1e..4ec6986b2677 100644 --- a/packages/stokhos/src/CMakeLists.txt +++ b/packages/stokhos/src/CMakeLists.txt @@ -1095,6 +1095,9 @@ IF (Stokhos_ENABLE_Sacado) ENDIF() IF (Stokhos_ENABLE_MueLu) + IF (Kokkos_ENABLE_CUDA_RELOCATABLE_DEVICE_CODE) + message(WARNING "Enabling MueLu in Stokhos when compiling with CUDA relocatable device code may cause infinite compile times") + ENDIF() SET(MUELU_HEADERS "") SET(MUELU_CPP_SOURCES Stokhos_Dummy.cpp) SET(STOKHOS_MUELU_DEPLIBS "") diff --git a/packages/teko/CMakeLists.txt b/packages/teko/CMakeLists.txt index 9eda4d957647..65f6980db6a8 100644 --- a/packages/teko/CMakeLists.txt +++ b/packages/teko/CMakeLists.txt @@ -22,6 +22,14 @@ TRIBITS_ADD_OPTION_AND_DEFINE( # "Enable ml block smoothers." # OFF ) +IF(${PROJECT_NAME}_ENABLE_Epetra AND DEFINED Teko_ENABLE_Epetra) + GLOBAL_SET(TEKO_HAVE_EPETRA ${Teko_ENABLE_Epetra}) +ELSE() + GLOBAL_SET(TEKO_HAVE_EPETRA ${${PROJECT_NAME}_ENABLE_Epetra}) +ENDIF() + +MESSAGE(STATUS "TEKO_HAVE_EPETRA = ${TEKO_HAVE_EPETRA}") + IF(${PACKAGE_NAME}_ENABLE_MueLu) GLOBAL_SET(HAVE_MUELU ON) ELSE() @@ -56,7 +64,9 @@ ENDIF() ADD_SUBDIRECTORY(src) TRIBITS_ADD_TEST_DIRECTORIES(tests) -TRIBITS_ADD_EXAMPLE_DIRECTORIES(examples) +IF(TEKO_HAVE_EPETRA) + TRIBITS_ADD_EXAMPLE_DIRECTORIES(examples) +ENDIF() TRIBITS_EXCLUDE_FILES( tests/data/nsjac.mm diff --git a/packages/teko/cmake/Dependencies.cmake b/packages/teko/cmake/Dependencies.cmake index 7fbc4f0c4768..84c9e3e7adf6 100644 --- a/packages/teko/cmake/Dependencies.cmake +++ b/packages/teko/cmake/Dependencies.cmake @@ -1,5 +1,5 @@ -SET(LIB_REQUIRED_DEP_PACKAGES Teuchos Thyra ThyraEpetraAdapters ThyraEpetraExtAdapters Stratimikos AztecOO Anasazi ML Ifpack Amesos Tpetra ThyraTpetraAdapters) -SET(LIB_OPTIONAL_DEP_PACKAGES Isorropia Ifpack2 Amesos2 Belos) +SET(LIB_REQUIRED_DEP_PACKAGES Teuchos Thyra Stratimikos Anasazi Tpetra ThyraTpetraAdapters) +SET(LIB_OPTIONAL_DEP_PACKAGES Isorropia Ifpack2 Ifpack AztecOO Amesos Amesos2 Belos ThyraEpetraAdapters ThyraEpetraExtAdapters ML) SET(TEST_REQUIRED_DEP_PACKAGES Ifpack2) SET(TEST_OPTIONAL_DEP_PACKAGES) SET(LIB_REQUIRED_DEP_TPLS) diff --git a/packages/teko/cmake/Teko_Config.h.in b/packages/teko/cmake/Teko_Config.h.in index 06ca579a139c..643008ff9c1e 100644 --- a/packages/teko/cmake/Teko_Config.h.in +++ b/packages/teko/cmake/Teko_Config.h.in @@ -2,6 +2,8 @@ #cmakedefine HAVE_Teko_ENABLE_Ifpack2 +#cmakedefine TEKO_HAVE_EPETRA + /* For enabling probing */ #cmakedefine Teko_ENABLE_Isorropia diff --git a/packages/teko/examples/BuildPreconditioner/CMakeLists.txt b/packages/teko/examples/BuildPreconditioner/CMakeLists.txt index a0cbe45ad5c3..8fd2dadc2dfb 100644 --- a/packages/teko/examples/BuildPreconditioner/CMakeLists.txt +++ b/packages/teko/examples/BuildPreconditioner/CMakeLists.txt @@ -7,17 +7,19 @@ ASSERT_DEFINED(${PACKAGE_NAME}_ENABLE_Ifpack2) ASSERT_DEFINED(Tpetra_INST_DOUBLE) IF (Tpetra_INST_DOUBLE) - TRIBITS_ADD_EXECUTABLE( - BuildPreconditioner_Driver_Example - SOURCES - example-driver.cpp - COMM mpi - ) + IF (TEKO_ENABLE_EPETRA) + TRIBITS_ADD_EXECUTABLE( + BuildPreconditioner_Driver_Example + SOURCES + example-driver.cpp + COMM mpi + ) + ENDIF() IF(${PACKAGE_NAME}_ENABLE_Ifpack2) TRIBITS_ADD_EXECUTABLE( BuildPreconditioner_Driver_Example-Belos - SOURCES + SOURCES example-driver-belos.cpp COMM mpi ) diff --git a/packages/teko/examples/BuildPreconditioner/example-driver-belos.cpp b/packages/teko/examples/BuildPreconditioner/example-driver-belos.cpp index 591a84ab3907..003a9c4afb20 100644 --- a/packages/teko/examples/BuildPreconditioner/example-driver-belos.cpp +++ b/packages/teko/examples/BuildPreconditioner/example-driver-belos.cpp @@ -52,27 +52,16 @@ #include "Teuchos_DefaultComm.hpp" #include "Teuchos_AbstractFactoryStd.hpp" -// Epetra includes #include "mpi.h" -#include "Epetra_MpiComm.h" -#include "Epetra_CrsMatrix.h" -#include "Epetra_Vector.h" - #include "Tpetra_CrsMatrix.hpp" #include "Tpetra_Core.hpp" #include "MatrixMarket_Tpetra.hpp" -// EpetraExt includes -#include "EpetraExt_CrsMatrixIn.h" -#include "EpetraExt_VectorIn.h" - // Teko-Package includes #include "Teko_Utilities.hpp" #include "Teko_InverseFactory.hpp" #include "Teko_InverseLibrary.hpp" -#include "Teko_StridedEpetraOperator.hpp" -#include "Teko_EpetraBlockPreconditioner.hpp" #include "Teko_LSCPreconditionerFactory.hpp" #include "Teko_InvLSCStrategy.hpp" #include "Teko_SIMPLEPreconditionerFactory.hpp" diff --git a/packages/teko/examples/BuildPreconditioner/example-driver.cpp b/packages/teko/examples/BuildPreconditioner/example-driver.cpp index 17a7bce22433..b4b6ddc143fa 100644 --- a/packages/teko/examples/BuildPreconditioner/example-driver.cpp +++ b/packages/teko/examples/BuildPreconditioner/example-driver.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -116,7 +116,7 @@ int main(int argc,char * argv[]) // build an InverseLibrary RCP invLib = Teko::InverseLibrary::buildFromStratimikos(); /*@ \label{lned:define-inv-params} @*/ - + // build the inverse factory needed by the example preconditioner RCP inverse /*@ \label{lned:define-inv-fact} @*/ = invLib->getInverseFactory("Amesos"); @@ -133,7 +133,7 @@ int main(int argc,char * argv[]) // Build and solve the linear system ///////////////////////////////////////////////////////// - // Setup the linear solve: notice A is used directly + // Setup the linear solve: notice A is used directly Epetra_LinearProblem problem(&*A,&*x,&*b); /*@ \label{lned:aztec-solve} @*/ // build the solver diff --git a/packages/teko/examples/CMakeLists.txt b/packages/teko/examples/CMakeLists.txt index 6e16b1f7c8eb..360f396e2853 100644 --- a/packages/teko/examples/CMakeLists.txt +++ b/packages/teko/examples/CMakeLists.txt @@ -7,7 +7,6 @@ IF (ML_ENABLE_TekoSmoothers) ADD_SUBDIRECTORY(ML-Teko-Coupling) ENDIF() - TRIBITS_COPY_FILES_TO_BINARY_DIR(example_copyfiles SOURCE_FILES nslhs_test.mm nsrhs_test.mm diff --git a/packages/teko/src/CMakeLists.txt b/packages/teko/src/CMakeLists.txt index 594101e865c6..79b8e4e8e5b1 100644 --- a/packages/teko/src/CMakeLists.txt +++ b/packages/teko/src/CMakeLists.txt @@ -29,8 +29,12 @@ SET(HEADERS ${HEADERS} TRIBITS_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) TRIBITS_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/NS) -TRIBITS_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/Epetra) TRIBITS_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/Tpetra) + +IF(TEKO_HAVE_EPETRA) + TRIBITS_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/Epetra) +ENDIF() + IF (ML_ENABLE_TekoSmoothers) TRIBITS_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/mlutils) ENDIF() @@ -38,17 +42,31 @@ ENDIF() APPEND_GLOB(HEADERS *.hpp NS/*.hpp - Epetra/*.hpp Tpetra/*.hpp ) APPEND_GLOB(SOURCES *.cpp NS/*.cpp - Epetra/*.cpp Tpetra/*.cpp ) +IF(NOT TEKO_HAVE_EPETRA) + LIST(REMOVE_ITEM SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/NS/Teko_ALOperator.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Teko_DiagonalPreconditionerOp.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Teko_DiagonalPreconditionerFactory.cpp + ) + LIST(REMOVE_ITEM HEADERS + ${CMAKE_CURRENT_SOURCE_DIR}/NS/Teko_ALOperator.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/Teko_DiagonalPreconditionerOp.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/Teko_DiagonalPreconditionerFactory.hpp + ) +ELSE() + APPEND_GLOB(HEADERS Epetra/*.hpp) + APPEND_GLOB(SOURCES Epetra/*.cpp) +ENDIF() + IF (ML_ENABLE_TekoSmoothers) APPEND_GLOB(HEADERS mlutils/*.hpp) APPEND_GLOB(SOURCES mlutils/*.cpp) @@ -61,7 +79,7 @@ ENDIF() # TRIBITS_ADD_LIBRARY( - teko + teko HEADERS ${HEADERS} SOURCES ${SOURCES} ) diff --git a/packages/teko/src/NS/Teko_InvLSCStrategy.cpp b/packages/teko/src/NS/Teko_InvLSCStrategy.cpp index de1b0017016d..b77780524d7f 100644 --- a/packages/teko/src/NS/Teko_InvLSCStrategy.cpp +++ b/packages/teko/src/NS/Teko_InvLSCStrategy.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -47,17 +47,22 @@ #include "NS/Teko_InvLSCStrategy.hpp" #include "Thyra_DefaultDiagonalLinearOp.hpp" +#include "Thyra_VectorStdOps.hpp" + +#include "Teko_ConfigDefs.hpp" + +#ifdef TEKO_HAVE_EPETRA #include "Thyra_EpetraThyraWrappers.hpp" #include "Thyra_get_Epetra_Operator.hpp" #include "Thyra_EpetraLinearOp.hpp" -#include "Thyra_VectorStdOps.hpp" - #include "Epetra_Vector.h" #include "Epetra_Map.h" - #include "EpetraExt_RowMatrixOut.h" #include "EpetraExt_MultiVectorOut.h" #include "EpetraExt_VectorOut.h" +#include "Teko_EpetraHelpers.hpp" +#include "Teko_EpetraOperatorWrapper.hpp" +#endif #include "Teuchos_Time.hpp" #include "Teuchos_TimeMonitor.hpp" @@ -65,8 +70,7 @@ // Teko includes #include "Teko_Utilities.hpp" #include "NS/Teko_LSCPreconditionerFactory.hpp" -#include "Teko_EpetraHelpers.hpp" -#include "Teko_EpetraOperatorWrapper.hpp" + #include "Teko_TpetraHelpers.hpp" #include "Thyra_TpetraLinearOp.hpp" @@ -217,12 +221,12 @@ void InvLSCStrategy::initializeState(const BlockedLinearOp & A,LSCPrecondState * // otherwise, there is already an invMass_ matrix that is appropriate // --> use that one if(massMatrix_==Teuchos::null) { - Teko_DEBUG_MSG("LSC::initializeState Build Scaling type \"" + Teko_DEBUG_MSG("LSC::initializeState Build Scaling type \"" << getDiagonalName(scaleType_) << "\"" ,1); state->invMass_ = getInvDiagonalOp(F,scaleType_); } else if(state->invMass_==Teuchos::null) { - Teko_DEBUG_MSG("LSC::initializeState Build Scaling type \"" + Teko_DEBUG_MSG("LSC::initializeState Build Scaling type \"" << getDiagonalName(scaleType_) << "\"" ,1); state->invMass_ = getInvDiagonalOp(massMatrix_,scaleType_); } @@ -236,14 +240,14 @@ void InvLSCStrategy::initializeState(const BlockedLinearOp & A,LSCPrecondState * if(wScaling_!=Teuchos::null && hScaling_==Teuchos::null) { // from W vector build H operator scaling RCP > w = wScaling_->col(0); - RCP > iQu + RCP > iQu = rcp_dynamic_cast >(state->invMass_)->getDiag(); RCP > h = Thyra::createMember(iQu->space()); Thyra::put_scalar(0.0,h.ptr()); Thyra::ele_wise_prod(1.0,*w,*iQu,h.ptr()); hScaling_ = Teuchos::rcp(new Thyra::DefaultDiagonalLinearOp(h)); - } + } LinearOp H = hScaling_; if(H==Teuchos::null && not isSymmetric_) @@ -276,6 +280,7 @@ void InvLSCStrategy::initializeState(const BlockedLinearOp & A,LSCPrecondState * // for Epetra_CrsMatrix...zero out certain rows: this ensures spectral radius is correct LinearOp modF = F; if(!Teko::TpetraHelpers::isTpetraLinearOp(F)){ // Epetra +#ifdef TEKO_HAVE_EPETRA const RCP epF = Thyra::get_Epetra_Operator(*F); if(epF!=Teuchos::null && rowZeroingNeeded_) { // try to get a CRS matrix @@ -284,7 +289,7 @@ void InvLSCStrategy::initializeState(const BlockedLinearOp & A,LSCPrecondState * // if it is a CRS matrix get rows that need to be zeroed if(crsF!=Teuchos::null) { std::vector zeroIndices; - + // get rows in need of zeroing Teko::Epetra::identityRowIndices(crsF->RowMap(), *crsF,zeroIndices); @@ -292,13 +297,17 @@ void InvLSCStrategy::initializeState(const BlockedLinearOp & A,LSCPrecondState * modF = Thyra::epetraLinearOp(rcp(new Teko::Epetra::ZeroedOperator(zeroIndices,crsF))); } } +#else + throw std::logic_error("InvLSCStrategy::initializeState is trying to use " + "Epetra code, but TEKO is not built with Epetra!"); +#endif } else { //Tpetra ST scalar = 0.0; bool transp = false; RCP > crsF = Teko::TpetraHelpers::getTpetraCrsMatrix(F, &scalar, &transp); std::vector zeroIndices; - + // get rows in need of zeroing Teko::TpetraHelpers::identityRowIndices(*crsF->getRowMap(), *crsF,zeroIndices); @@ -312,14 +321,14 @@ void InvLSCStrategy::initializeState(const BlockedLinearOp & A,LSCPrecondState * // do 6 power iterations to compute spectral radius: EHSST2007 Eq. 4.28 Teko::LinearOp stabMatrix; // this is the pressure stabilization matrix to use - state->gamma_ = std::fabs(Teko::computeSpectralRad(iQuF,5e-2,false,eigSolveParam_))/3.0; + state->gamma_ = std::fabs(Teko::computeSpectralRad(iQuF,5e-2,false,eigSolveParam_))/3.0; Teko_DEBUG_MSG("Calculated gamma",10); if(userPresStabMat_!=Teuchos::null) { Teko::LinearOp invDGl = Teko::getInvDiagonalOp(userPresStabMat_); Teko::LinearOp gammaOp = multiply(invDGl,C); state->gamma_ *= std::fabs(Teko::computeSpectralRad(gammaOp,5e-2,false,eigSolveParam_)); stabMatrix = userPresStabMat_; - } else + } else stabMatrix = C; // compute alpha scaled inv(D): EHSST2007 Eq. 4.29 @@ -383,7 +392,7 @@ void InvLSCStrategy::computeInverses(const BlockedLinearOp & A,LSCPrecondState * InverseLinearOp invF = state->getInverse("invF"); if(invF==Teuchos::null) { invF = buildInverse(*invFactoryF_,F); - state->addInverse("invF",invF); + state->addInverse("invF",invF); } else { rebuildInverse(*invFactoryF_,F,invF); } @@ -392,14 +401,14 @@ void InvLSCStrategy::computeInverses(const BlockedLinearOp & A,LSCPrecondState * ///////////////////////////////////////////////////////// - // (re)build the inverse of BQBt + // (re)build the inverse of BQBt Teko_DEBUG_MSG("LSC::computeInverses Building inv(BQBtmC)",1); Teko_DEBUG_EXPR(invTimer.start(true)); const LinearOp BQBt = state->getInverse("BQBtmC"); InverseLinearOp invBQBt = state->getInverse("invBQBtmC"); if(invBQBt==Teuchos::null) { invBQBt = buildInverse(*invFactoryS_,BQBt); - state->addInverse("invBQBtmC",invBQBt); + state->addInverse("invBQBtmC",invBQBt); } else { rebuildInverse(*invFactoryS_,BQBt,invBQBt); } @@ -411,27 +420,27 @@ void InvLSCStrategy::computeInverses(const BlockedLinearOp & A,LSCPrecondState * // Compute the inverse of BHBt or just use BQBt ModifiableLinearOp invBHBt = state->getInverse("invBHBtmC"); if(hScaling_!=Teuchos::null || not isSymmetric_) { - // (re)build the inverse of BHBt + // (re)build the inverse of BHBt Teko_DEBUG_MSG("LSC::computeInverses Building inv(BHBtmC)",1); Teko_DEBUG_EXPR(invTimer.start(true)); const LinearOp BHBt = state->getInverse("BHBtmC"); if(invBHBt==Teuchos::null) { invBHBt = buildInverse(*invFactoryS_,BHBt); - state->addInverse("invBHBtmC",invBHBt); + state->addInverse("invBHBtmC",invBHBt); } else { rebuildInverse(*invFactoryS_,BHBt,invBHBt); } Teko_DEBUG_EXPR(invTimer.stop()); Teko_DEBUG_MSG("LSC::computeInverses GetInvBHBt = " << invTimer.totalElapsedTime(),1); - } + } else if(invBHBt==Teuchos::null) { // just use the Q version - state->addInverse("invBHBtmC",invBQBt); + state->addInverse("invBHBtmC",invBQBt); } } //! Initialize from a parameter list -void InvLSCStrategy::initializeFromParameterList(const Teuchos::ParameterList & pl,const InverseLibrary & invLib) +void InvLSCStrategy::initializeFromParameterList(const Teuchos::ParameterList & pl,const InverseLibrary & invLib) { // get string specifying inverse std::string invStr="", invVStr="", invPStr=""; @@ -444,7 +453,7 @@ void InvLSCStrategy::initializeFromParameterList(const Teuchos::ParameterList & invStr = pl.get("Inverse Type"); if(pl.isParameter("Inverse Velocity Type")) invVStr = pl.get("Inverse Velocity Type"); - if(pl.isParameter("Inverse Pressure Type")) + if(pl.isParameter("Inverse Pressure Type")) invPStr = pl.get("Inverse Pressure Type"); if(pl.isParameter("Ignore Boundary Rows")) rowZeroing = pl.get("Ignore Boundary Rows"); @@ -462,7 +471,7 @@ void InvLSCStrategy::initializeFromParameterList(const Teuchos::ParameterList & scaleType_ = getDiagonalType(pl.get("Scaling Type")); TEUCHOS_TEST_FOR_EXCEPT(scaleType_==NotDiag); } - if(pl.isParameter("Assume Stable Discretization")) + if(pl.isParameter("Assume Stable Discretization")) assumeStable_ = pl.get("Assume Stable Discretization"); Teko_DEBUG_MSG_BEGIN(5) @@ -498,7 +507,7 @@ void InvLSCStrategy::initializeFromParameterList(const Teuchos::ParameterList & if(useMass_) { Teuchos::RCP rh = getRequestHandler(); rh->preRequest(Teko::RequestMesg("Velocity Mass Matrix")); - Teko::LinearOp mass + Teko::LinearOp mass = rh->request(Teko::RequestMesg("Velocity Mass Matrix")); setMassMatrix(mass); } @@ -506,7 +515,7 @@ void InvLSCStrategy::initializeFromParameterList(const Teuchos::ParameterList & } //! For assiting in construction of the preconditioner -Teuchos::RCP InvLSCStrategy::getRequestedParameters() const +Teuchos::RCP InvLSCStrategy::getRequestedParameters() const { Teuchos::RCP result; Teuchos::RCP pl = rcp(new Teuchos::ParameterList()); @@ -539,11 +548,11 @@ Teuchos::RCP InvLSCStrategy::getRequestedParameters() co } //! For assiting in construction of the preconditioner -bool InvLSCStrategy::updateRequestedParameters(const Teuchos::ParameterList & pl) +bool InvLSCStrategy::updateRequestedParameters(const Teuchos::ParameterList & pl) { Teko_DEBUG_SCOPE("InvLSCStrategy::updateRequestedParameters",10); bool result = true; - + // update requested parameters in solvers result &= invFactoryF_->updateRequestedParameters(pl); result &= invFactoryS_->updateRequestedParameters(pl); diff --git a/packages/teko/src/NS/Teko_InvModALStrategy.cpp b/packages/teko/src/NS/Teko_InvModALStrategy.cpp index 45406906b93f..e7c2be317da9 100644 --- a/packages/teko/src/NS/Teko_InvModALStrategy.cpp +++ b/packages/teko/src/NS/Teko_InvModALStrategy.cpp @@ -5,18 +5,9 @@ */ #include "Thyra_DefaultDiagonalLinearOp.hpp" -#include "Thyra_EpetraThyraWrappers.hpp" -#include "Thyra_get_Epetra_Operator.hpp" -#include "Thyra_EpetraLinearOp.hpp" #include "Thyra_DefaultAddedLinearOp_def.hpp" #include "Thyra_DefaultIdentityLinearOp_decl.hpp" -#include "Epetra_Vector.h" -#include "Epetra_Map.h" - -#include "EpetraExt_RowMatrixOut.h" -#include "EpetraExt_MultiVectorOut.h" - #include "Teuchos_Time.hpp" #include "Teko_Utilities.hpp" diff --git a/packages/teko/src/NS/Teko_InvModALStrategy.hpp b/packages/teko/src/NS/Teko_InvModALStrategy.hpp index 15ef1daa3d03..4de67c77db01 100644 --- a/packages/teko/src/NS/Teko_InvModALStrategy.hpp +++ b/packages/teko/src/NS/Teko_InvModALStrategy.hpp @@ -15,8 +15,6 @@ #include "Teko_InverseFactory.hpp" #include "Teko_BlockPreconditionerFactory.hpp" -#include "Teko_ALOperator.hpp" - namespace Teko { diff --git a/packages/teko/src/NS/Teko_LSCPreconditionerFactory.cpp b/packages/teko/src/NS/Teko_LSCPreconditionerFactory.cpp index 0c5d46bdd9d5..9680e0cf7b25 100644 --- a/packages/teko/src/NS/Teko_LSCPreconditionerFactory.cpp +++ b/packages/teko/src/NS/Teko_LSCPreconditionerFactory.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -50,7 +50,6 @@ #include "Thyra_DefaultAddedLinearOp.hpp" #include "Thyra_DefaultIdentityLinearOp.hpp" #include "Thyra_DefaultZeroLinearOp.hpp" -#include "Thyra_get_Epetra_Operator.hpp" #include "Teko_LU2x2InverseOp.hpp" #include "Teko_Utilities.hpp" @@ -60,8 +59,6 @@ #include "Teko_PresLaplaceLSCStrategy.hpp" #include "Teko_LSCSIMPLECStrategy.hpp" -#include "EpetraExt_RowMatrixOut.h" - #include "Teuchos_Time.hpp" namespace Teko { @@ -106,7 +103,7 @@ LinearOp LSCPreconditionerFactory::buildPreconditionerOperator(BlockedLinearOp & Teko_DEBUG_EXPR(Teuchos::Time totalTimer("")); Teko_DEBUG_EXPR(totalTimer.start()); - // extract sub-matrices from source operator + // extract sub-matrices from source operator LinearOp F = blockOp->getBlock(0,0); LinearOp B = blockOp->getBlock(1,0); LinearOp Bt = blockOp->getBlock(0,1); @@ -139,21 +136,21 @@ LinearOp LSCPreconditionerFactory::buildPreconditionerOperator(BlockedLinearOp & // need to build Schur complement, inv(P) = inv(B*Bt)*(B*F*Bt)*inv(B*Bt) // first construct middle operator: M = B * inv(Mass) * F * inv(Mass) * Bt - LinearOp M = + LinearOp M = // (B * inv(Mass) ) * F * (inv(Mass) * Bt) multiply( multiply(B,invMass), F , multiply(HScaling,Bt)); if(innerStab!=Teuchos::null) // deal with inner stabilization M = add(M, innerStab); - + // now construct a linear operator schur complement - LinearOp invPschur; + LinearOp invPschur; if(outerStab!=Teuchos::null) invPschur = add(multiply(invBQBtmC, M , invBHBtmC), outerStab); else invPschur = multiply(invBQBtmC, M , invBHBtmC); // build the preconditioner operator: Use LDU or upper triangular approximation - if(invOpsStrategy_->useFullLDU()) { + if(invOpsStrategy_->useFullLDU()) { Teko_DEBUG_EXPR(totalTimer.stop()); Teko_DEBUG_MSG("LSCPrecFact::buildPO TotalTime = " << totalTimer.totalElapsedTime(),2); @@ -166,7 +163,7 @@ LinearOp LSCPreconditionerFactory::buildPreconditionerOperator(BlockedLinearOp & invDiag[1] = Thyra::scale(-1.0,invPschur); // get upper triangular matrix - BlockedLinearOp U = getUpperTriBlocks(blockOp); + BlockedLinearOp U = getUpperTriBlocks(blockOp); Teko_DEBUG_EXPR(totalTimer.stop()); Teko_DEBUG_MSG("LSCPrecFact::buildPO TotalTime = " << totalTimer.totalElapsedTime(),2); @@ -206,7 +203,7 @@ void LSCPreconditionerFactory::initializeFromParameterList(const Teuchos::Parame // build the strategy object RCP strategy = buildStrategy(name,*stratPL,invLib,getRequestHandler()); - + // strategy could not be built if(strategy==Teuchos::null) { RCP out = getOutputStream(); @@ -241,7 +238,7 @@ CloneFactory LSCPreconditionerFactory::strategyBuilder_; /** \brief Builder function for creating strategies. * * Builder function for creating strategies. - * + * * \param[in] name String name of strategy to build * \param[in] settings Parameter list describing the parameters for the * strategy to build @@ -250,7 +247,7 @@ CloneFactory LSCPreconditionerFactory::strategyBuilder_; * \returns If the name is associated with a strategy * a pointer is returned, otherwise Teuchos::null is returned. */ -RCP LSCPreconditionerFactory::buildStrategy(const std::string & name, +RCP LSCPreconditionerFactory::buildStrategy(const std::string & name, const Teuchos::ParameterList & settings, const RCP & invLib, const RCP & rh) @@ -275,7 +272,7 @@ RCP LSCPreconditionerFactory::buildStrategy(const std::string & nam } /** \brief Add a strategy to the builder. This is done using the - * clone pattern. + * clone pattern. * * Add a strategy to the builder. This is done using the * clone pattern. If your class does not support the Cloneable interface then @@ -293,7 +290,7 @@ void LSCPreconditionerFactory::addStrategy(const std::string & name,const RCPgetInverse("invF"); if(invF==Teuchos::null) { invF = buildInverse(*invFactoryF_,F); - state->addInverse("invF",invF); + state->addInverse("invF",invF); } else { rebuildInverse(*invFactoryF_,F,invF); } @@ -220,14 +208,14 @@ void LSCSIMPLECStrategy::computeInverses(const BlockedLinearOp & A,LSCPrecondSta ///////////////////////////////////////////////////////// - // (re)build the inverse of BQBt + // (re)build the inverse of BQBt Teko_DEBUG_MSG("LSC-SIMPLEC::computeInverses Building inv(BQBtmC)",1); Teko_DEBUG_EXPR(invTimer.start(true)); const LinearOp BQBt = state->getInverse("BQBtmC"); InverseLinearOp invBQBt = state->getInverse("invBQBtmC"); if(invBQBt==Teuchos::null) { invBQBt = buildInverse(*invFactoryS_,BQBt); - state->addInverse("invBQBtmC",invBQBt); + state->addInverse("invBQBtmC",invBQBt); } else { rebuildInverse(*invFactoryS_,BQBt,invBQBt); } @@ -236,7 +224,7 @@ void LSCSIMPLECStrategy::computeInverses(const BlockedLinearOp & A,LSCPrecondSta } //! Initialize from a parameter list -void LSCSIMPLECStrategy::initializeFromParameterList(const Teuchos::ParameterList & pl,const InverseLibrary & invLib) +void LSCSIMPLECStrategy::initializeFromParameterList(const Teuchos::ParameterList & pl,const InverseLibrary & invLib) { // get string specifying inverse std::string invStr="", invVStr="", invPStr=""; @@ -248,7 +236,7 @@ void LSCSIMPLECStrategy::initializeFromParameterList(const Teuchos::ParameterLis invStr = pl.get("Inverse Type"); if(pl.isParameter("Inverse Velocity Type")) invVStr = pl.get("Inverse Velocity Type"); - if(pl.isParameter("Inverse Pressure Type")) + if(pl.isParameter("Inverse Pressure Type")) invPStr = pl.get("Inverse Pressure Type"); if(pl.isParameter("Use LDU")) useLDU = pl.get("Use LDU"); diff --git a/packages/teko/src/NS/Teko_ModALPreconditionerFactory.cpp b/packages/teko/src/NS/Teko_ModALPreconditionerFactory.cpp index 692d573b00fc..d8aa6853e89f 100644 --- a/packages/teko/src/NS/Teko_ModALPreconditionerFactory.cpp +++ b/packages/teko/src/NS/Teko_ModALPreconditionerFactory.cpp @@ -10,7 +10,6 @@ #include "Thyra_DefaultAddedLinearOp.hpp" #include "Thyra_DefaultIdentityLinearOp.hpp" #include "Thyra_DefaultZeroLinearOp.hpp" -#include "Thyra_get_Epetra_Operator.hpp" #include "Teko_LU2x2InverseOp.hpp" #include "Teko_Utilities.hpp" @@ -20,8 +19,6 @@ #include "Teko_InvLSCStrategy.hpp" #include "Teko_PresLaplaceLSCStrategy.hpp" -#include "EpetraExt_RowMatrixOut.h" - #include "Teuchos_Time.hpp" namespace Teko diff --git a/packages/teko/src/NS/Teko_PresLaplaceLSCStrategy.cpp b/packages/teko/src/NS/Teko_PresLaplaceLSCStrategy.cpp index e310f5b24535..005becc3b5ac 100644 --- a/packages/teko/src/NS/Teko_PresLaplaceLSCStrategy.cpp +++ b/packages/teko/src/NS/Teko_PresLaplaceLSCStrategy.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -47,9 +47,6 @@ #include "NS/Teko_PresLaplaceLSCStrategy.hpp" #include "Thyra_DefaultDiagonalLinearOp.hpp" -#include "Thyra_EpetraThyraWrappers.hpp" -#include "Thyra_get_Epetra_Operator.hpp" -#include "Thyra_EpetraLinearOp.hpp" #include "Teuchos_Time.hpp" #include "Teuchos_TimeMonitor.hpp" @@ -191,12 +188,12 @@ void PresLaplaceLSCStrategy::initializeState(const BlockedLinearOp & A,LSCPrecon // otherwise, there is already an invMass_ matrix that is appropriate // --> use that one if(massMatrix==Teuchos::null) { - Teko_DEBUG_MSG("PL-LSC::initializeState Build Scaling type \"" + Teko_DEBUG_MSG("PL-LSC::initializeState Build Scaling type \"" << getDiagonalName(scaleType_) << "\"" ,1); state->invMass_ = getInvDiagonalOp(F,scaleType_); } else if(state->invMass_==Teuchos::null) { - Teko_DEBUG_MSG("PL-LSC::initializeState Build Scaling type \"" + Teko_DEBUG_MSG("PL-LSC::initializeState Build Scaling type \"" << getDiagonalName(scaleType_) << "\"" ,1); state->invMass_ = getInvDiagonalOp(massMatrix,scaleType_); } @@ -282,7 +279,7 @@ void PresLaplaceLSCStrategy::computeInverses(const BlockedLinearOp & A,LSCPrecon } //! Initialize from a parameter list -void PresLaplaceLSCStrategy::initializeFromParameterList(const Teuchos::ParameterList & pl,const InverseLibrary & invLib) +void PresLaplaceLSCStrategy::initializeFromParameterList(const Teuchos::ParameterList & pl,const InverseLibrary & invLib) { // get string specifying inverse std::string invStr="Amesos", invVStr="", invPStr=""; @@ -294,7 +291,7 @@ void PresLaplaceLSCStrategy::initializeFromParameterList(const Teuchos::Paramete invStr = pl.get("Inverse Type"); if(pl.isParameter("Inverse Velocity Type")) invVStr = pl.get("Inverse Velocity Type"); - if(pl.isParameter("Inverse Pressure Type")) + if(pl.isParameter("Inverse Pressure Type")) invPStr = pl.get("Inverse Pressure Type"); if(pl.isParameter("Use LDU")) useLDU = pl.get("Use LDU"); @@ -333,7 +330,7 @@ void PresLaplaceLSCStrategy::initializeFromParameterList(const Teuchos::Paramete } //! For assiting in construction of the preconditioner -Teuchos::RCP PresLaplaceLSCStrategy::getRequestedParameters() const +Teuchos::RCP PresLaplaceLSCStrategy::getRequestedParameters() const { Teko_DEBUG_SCOPE("PresLaplaceLSCStrategy::getRequestedParameters",10); Teuchos::RCP pl = rcp(new Teuchos::ParameterList()); @@ -363,11 +360,11 @@ Teuchos::RCP PresLaplaceLSCStrategy::getRequestedParamet } //! For assiting in construction of the preconditioner -bool PresLaplaceLSCStrategy::updateRequestedParameters(const Teuchos::ParameterList & pl) +bool PresLaplaceLSCStrategy::updateRequestedParameters(const Teuchos::ParameterList & pl) { Teko_DEBUG_SCOPE("PresLaplaceLSCStrategy::updateRequestedParameters",10); bool result = true; - + // update requested parameters in solvers result &= invFactoryV_->updateRequestedParameters(pl); result &= invFactoryP_->updateRequestedParameters(pl); @@ -376,7 +373,7 @@ bool PresLaplaceLSCStrategy::updateRequestedParameters(const Teuchos::ParameterL // get required operator acknowledgment...user must set these to true bool plo = hackList.get(getPressureLaplaceString(),false); - + bool vmo = true; if(useMass_) vmo = hackList.get(getVelocityMassString(),false); diff --git a/packages/teko/src/NS/Teko_SIMPLEPreconditionerFactory.cpp b/packages/teko/src/NS/Teko_SIMPLEPreconditionerFactory.cpp index b14f7cb88030..459ff5b3014e 100644 --- a/packages/teko/src/NS/Teko_SIMPLEPreconditionerFactory.cpp +++ b/packages/teko/src/NS/Teko_SIMPLEPreconditionerFactory.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -50,16 +50,12 @@ #include "Teko_InverseFactory.hpp" #include "Teko_BlockLowerTriInverseOp.hpp" #include "Teko_BlockUpperTriInverseOp.hpp" +#include +#ifdef TEKO_HAVE_EPETRA #include "Teko_DiagonalPreconditionerFactory.hpp" +#endif #include "Teuchos_Time.hpp" -#include "Epetra_FECrsGraph.h" -#include "Epetra_FECrsMatrix.h" -#include "EpetraExt_PointToBlockDiagPermute.h" -#include "EpetraExt_MatrixMatrix.h" -#include "Thyra_EpetraOperatorWrapper.hpp" -#include "Thyra_EpetraLinearOp.hpp" - using Teuchos::RCP; @@ -94,7 +90,7 @@ LinearOp SIMPLEPreconditionerFactory int rows = blockRowCount(blockOp); int cols = blockColCount(blockOp); - + TEUCHOS_ASSERT(rows==2); // sanity checks TEUCHOS_ASSERT(cols==2); @@ -123,11 +119,12 @@ LinearOp SIMPLEPreconditionerFactory buildExplicitSchurComplement = false; } else if(fInverseType_==BlkDiag) { +#ifdef TEKO_HAVE_EPETRA // Block diagonal approximation for H DiagonalPreconditionerFactory Hfact; DiagonalPrecondState Hstate; - Hfact.initializeFromParameterList(BlkDiagList_); - H = Hfact.buildPreconditionerOperator(matF,Hstate); + Hfact.initializeFromParameterList(BlkDiagList_); + H = Hfact.buildPreconditionerOperator(matF,Hstate); /* // Get a FECrsMarix out of the BDP @@ -135,8 +132,13 @@ LinearOp SIMPLEPreconditionerFactory H=Thyra::epetraLinearOp(Hcrs); */ - buildExplicitSchurComplement = true; // NTS: Do I need this? + buildExplicitSchurComplement = true; // NTS: Do I need this? // Answer - no, but it is documenting whats going on here. +#else + throw std::logic_error("SIMPLEPreconditionerFactory fInverseType_ == " + "BlkDiag but EPETRA is turned off!"); +#endif + } else { // get generic diagonal @@ -180,15 +182,15 @@ LinearOp SIMPLEPreconditionerFactory else { // build an implicit Schur complement HBt = multiply(H,Bt); - + hatS = add(C,scale(-1.0,multiply(B,HBt))); } - // build the inverse for F + // build the inverse for F ModifiableLinearOp & invF = state.getModifiableOp("invF"); if(invF==Teuchos::null) invF = buildInverse(*invVelFactory_,F); - else + else rebuildInverse(*invVelFactory_,F,invF); // build the approximate Schur complement @@ -231,7 +233,7 @@ void SIMPLEPreconditionerFactory::initializeFromParameterList(const Teuchos::Par useMass_ = false; customHFactory_ = Teuchos::null; fInverseType_ = Diagonal; - + // get string specifying inverse std::string invStr="", invVStr="", invPStr=""; alpha_ = 1.0; @@ -241,7 +243,7 @@ void SIMPLEPreconditionerFactory::initializeFromParameterList(const Teuchos::Par invStr = pl.get("Inverse Type"); if(pl.isParameter("Inverse Velocity Type")) invVStr = pl.get("Inverse Velocity Type"); - if(pl.isParameter("Inverse Pressure Type")) + if(pl.isParameter("Inverse Pressure Type")) invPStr = pl.get("Inverse Pressure Type"); if(pl.isParameter("Alpha")) alpha_ = pl.get("Alpha"); @@ -255,7 +257,7 @@ void SIMPLEPreconditionerFactory::initializeFromParameterList(const Teuchos::Par // Grab the sublist if we're using the block diagonal if(fInverseType_==BlkDiag) - BlkDiagList_=pl.sublist("H options"); + BlkDiagList_=pl.sublist("H options"); } if(pl.isParameter("Use Mass Scaling")) useMass_ = pl.get("Use Mass Scaling"); @@ -287,20 +289,20 @@ void SIMPLEPreconditionerFactory::initializeFromParameterList(const Teuchos::Par invPFact = invLib->getInverseFactory(invPStr); // based on parameter type build a strategy - invVelFactory_ = invVFact; + invVelFactory_ = invVFact; invPrsFactory_ = invPFact; if(useMass_) { Teuchos::RCP rh = getRequestHandler(); rh->preRequest(Teko::RequestMesg("Velocity Mass Matrix")); - Teko::LinearOp mass + Teko::LinearOp mass = rh->request(Teko::RequestMesg("Velocity Mass Matrix")); setMassMatrix(mass); } } //! For assiting in construction of the preconditioner -Teuchos::RCP SIMPLEPreconditionerFactory::getRequestedParameters() const +Teuchos::RCP SIMPLEPreconditionerFactory::getRequestedParameters() const { Teuchos::RCP result; Teuchos::RCP pl = rcp(new Teuchos::ParameterList()); @@ -338,11 +340,11 @@ Teuchos::RCP SIMPLEPreconditionerFactory::getRequestedPa } //! For assiting in construction of the preconditioner -bool SIMPLEPreconditionerFactory::updateRequestedParameters(const Teuchos::ParameterList & pl) +bool SIMPLEPreconditionerFactory::updateRequestedParameters(const Teuchos::ParameterList & pl) { Teko_DEBUG_SCOPE("InvLSCStrategy::updateRequestedParameters",10); bool result = true; - + // update requested parameters in solvers result &= invVelFactory_->updateRequestedParameters(pl); result &= invPrsFactory_->updateRequestedParameters(pl); diff --git a/packages/teko/src/NS/Teko_StaticLSCStrategy.cpp b/packages/teko/src/NS/Teko_StaticLSCStrategy.cpp index 4bb858743c49..2989a42d1289 100644 --- a/packages/teko/src/NS/Teko_StaticLSCStrategy.cpp +++ b/packages/teko/src/NS/Teko_StaticLSCStrategy.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -47,15 +47,6 @@ #include "NS/Teko_StaticLSCStrategy.hpp" #include "Thyra_DefaultDiagonalLinearOp.hpp" -#include "Thyra_EpetraThyraWrappers.hpp" -#include "Thyra_get_Epetra_Operator.hpp" -#include "Thyra_EpetraLinearOp.hpp" - -#include "Epetra_Vector.h" -#include "Epetra_Map.h" - -#include "EpetraExt_RowMatrixOut.h" -#include "EpetraExt_MultiVectorOut.h" #include "Teuchos_Time.hpp" @@ -76,7 +67,7 @@ StaticLSCStrategy::StaticLSCStrategy(const LinearOp & invF, const LinearOp & invMass) : invF_(invF), invBQBtmC_(invBQBtmC), invD_(invD), invMass_(invMass) { } - + // Stable constructor StaticLSCStrategy::StaticLSCStrategy(const LinearOp & invF, const LinearOp & invBQBtmC, diff --git a/packages/teko/src/NS/Teko_TimingsSIMPLEPreconditionerFactory.cpp b/packages/teko/src/NS/Teko_TimingsSIMPLEPreconditionerFactory.cpp index e5bb23ac1714..e7a2f25d9e5d 100644 --- a/packages/teko/src/NS/Teko_TimingsSIMPLEPreconditionerFactory.cpp +++ b/packages/teko/src/NS/Teko_TimingsSIMPLEPreconditionerFactory.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -50,16 +50,11 @@ #include "Teko_InverseFactory.hpp" #include "Teko_BlockLowerTriInverseOp.hpp" #include "Teko_BlockUpperTriInverseOp.hpp" +#ifdef TEKO_HAVE_EPETRA #include "Teko_DiagonalPreconditionerFactory.hpp" +#endif #include "Teuchos_Time.hpp" -#include "Epetra_FECrsGraph.h" -#include "Epetra_FECrsMatrix.h" -#include "EpetraExt_PointToBlockDiagPermute.h" -#include "EpetraExt_MatrixMatrix.h" -#include "Thyra_EpetraOperatorWrapper.hpp" -#include "Thyra_EpetraLinearOp.hpp" - using Teuchos::RCP; @@ -89,7 +84,7 @@ TimingsSIMPLEPreconditionerFactory::TimingsSIMPLEPreconditionerFactory() TimingsSIMPLEPreconditionerFactory::~TimingsSIMPLEPreconditionerFactory() { - if(constrTotal_.totalElapsedTime()>0.0) { + if(constrTotal_.totalElapsedTime()>0.0) { Teuchos::FancyOStream out(Teuchos::rcpFromRef(std::cout)); out.setOutputToRootOnly(0); @@ -115,7 +110,7 @@ LinearOp TimingsSIMPLEPreconditionerFactory int rows = blockRowCount(blockOp); int cols = blockColCount(blockOp); - + TEUCHOS_ASSERT(rows==2); // sanity checks TEUCHOS_ASSERT(cols==2); @@ -144,14 +139,19 @@ LinearOp TimingsSIMPLEPreconditionerFactory buildExplicitSchurComplement = false; } else if(fInverseType_==BlkDiag) { +#ifdef TEKO_HAVE_EPETRA // Block diagonal approximation for H DiagonalPreconditionerFactory Hfact; DiagonalPrecondState Hstate; - Hfact.initializeFromParameterList(BlkDiagList_); - H = Hfact.buildPreconditionerOperator(matF,Hstate); + Hfact.initializeFromParameterList(BlkDiagList_); + H = Hfact.buildPreconditionerOperator(matF,Hstate); - buildExplicitSchurComplement = true; // NTS: Do I need this? + buildExplicitSchurComplement = true; // NTS: Do I need this? // Answer - no, but it is documenting whats going on here. +#else + throw std::logic_error("TimingsSIMPLEPreconditionerFactory fInverseType_ == " + "BlkDiag but EPETRA is turned off!"); +#endif } else { // get generic diagonal @@ -203,10 +203,10 @@ LinearOp TimingsSIMPLEPreconditionerFactory else { // build an implicit Schur complement HBt = multiply(H,Bt); - + hatS = add(C,scale(-1.0,multiply(B,HBt))); } - + // time the application of HBt if(timed_HBt_==Teuchos::null) { timed_HBt_ = Teuchos::rcp(new DiagnosticLinearOp(getOutputStream(),HBt,"HBt")); @@ -215,7 +215,7 @@ LinearOp TimingsSIMPLEPreconditionerFactory timed_HBt_->setLinearOp(HBt); } - // time the application of B + // time the application of B if(timed_B_==Teuchos::null) { timed_B_ = Teuchos::rcp(new DiagnosticLinearOp(getOutputStream(),B,"B")); } @@ -223,7 +223,7 @@ LinearOp TimingsSIMPLEPreconditionerFactory timed_B_->setLinearOp(B); } - // build the inverse for F + // build the inverse for F ModifiableLinearOp & invF = state.getModifiableOp("invF"); subTotal_.start(); if(invF==Teuchos::null) { @@ -248,7 +248,7 @@ LinearOp TimingsSIMPLEPreconditionerFactory } else { rebuildInverse(*invPrsFactory_,hatS,invS); - + timed_invS_->setLinearOp(invS); } subTotal_.stop(); @@ -298,7 +298,7 @@ void TimingsSIMPLEPreconditionerFactory::initializeFromParameterList(const Teuch useMass_ = false; customHFactory_ = Teuchos::null; fInverseType_ = Diagonal; - + // get string specifying inverse std::string invStr="", invVStr="", invPStr=""; alpha_ = 1.0; @@ -308,7 +308,7 @@ void TimingsSIMPLEPreconditionerFactory::initializeFromParameterList(const Teuch invStr = pl.get("Inverse Type"); if(pl.isParameter("Inverse Velocity Type")) invVStr = pl.get("Inverse Velocity Type"); - if(pl.isParameter("Inverse Pressure Type")) + if(pl.isParameter("Inverse Pressure Type")) invPStr = pl.get("Inverse Pressure Type"); if(pl.isParameter("Alpha")) alpha_ = pl.get("Alpha"); @@ -322,7 +322,7 @@ void TimingsSIMPLEPreconditionerFactory::initializeFromParameterList(const Teuch // Grab the sublist if we're using the block diagonal if(fInverseType_==BlkDiag) - BlkDiagList_=pl.sublist("H options"); + BlkDiagList_=pl.sublist("H options"); } if(pl.isParameter("Use Mass Scaling")) useMass_ = pl.get("Use Mass Scaling"); @@ -354,20 +354,20 @@ void TimingsSIMPLEPreconditionerFactory::initializeFromParameterList(const Teuch invPFact = invLib->getInverseFactory(invPStr); // based on parameter type build a strategy - invVelFactory_ = invVFact; + invVelFactory_ = invVFact; invPrsFactory_ = invPFact; if(useMass_) { Teuchos::RCP rh = getRequestHandler(); rh->preRequest(Teko::RequestMesg("Velocity Mass Matrix")); - Teko::LinearOp mass + Teko::LinearOp mass = rh->request(Teko::RequestMesg("Velocity Mass Matrix")); setMassMatrix(mass); } } //! For assiting in construction of the preconditioner -Teuchos::RCP TimingsSIMPLEPreconditionerFactory::getRequestedParameters() const +Teuchos::RCP TimingsSIMPLEPreconditionerFactory::getRequestedParameters() const { Teuchos::RCP result; Teuchos::RCP pl = rcp(new Teuchos::ParameterList()); @@ -405,11 +405,11 @@ Teuchos::RCP TimingsSIMPLEPreconditionerFactory::getRequ } //! For assiting in construction of the preconditioner -bool TimingsSIMPLEPreconditionerFactory::updateRequestedParameters(const Teuchos::ParameterList & pl) +bool TimingsSIMPLEPreconditionerFactory::updateRequestedParameters(const Teuchos::ParameterList & pl) { Teko_DEBUG_SCOPE("InvLSCStrategy::updateRequestedParameters",10); bool result = true; - + // update requested parameters in solvers result &= invVelFactory_->updateRequestedParameters(pl); result &= invPrsFactory_->updateRequestedParameters(pl); diff --git a/packages/teko/src/Teko_DiagonalPreconditionerFactory.cpp b/packages/teko/src/Teko_DiagonalPreconditionerFactory.cpp index 838614142613..3428bddd2a1f 100644 --- a/packages/teko/src/Teko_DiagonalPreconditionerFactory.cpp +++ b/packages/teko/src/Teko_DiagonalPreconditionerFactory.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -66,7 +66,7 @@ DiagonalPreconditionerFactory::DiagonalPreconditionerFactory() {} RCP DiagonalPreconditionerFactory::buildPreconditionerState() const { - return Teuchos::rcp(new DiagonalPrecondState()); + return Teuchos::rcp(new DiagonalPrecondState()); } LinearOp DiagonalPreconditionerFactory::buildPreconditionerOperator(LinearOp & lo,PreconditionerState & state) const @@ -75,14 +75,14 @@ LinearOp DiagonalPreconditionerFactory::buildPreconditionerOperator(LinearOp & l // Sanity check the state DiagonalPrecondState & MyState = Teuchos::dyn_cast(state); - TEUCHOS_TEST_FOR_EXCEPTION(TpetraHelpers::isTpetraLinearOp(lo),std::runtime_error,"BlkDiag not implemented for Tpetra operators"); + TEUCHOS_TEST_FOR_EXCEPTION(TpetraHelpers::isTpetraLinearOp(lo),std::runtime_error,"BlkDiag not implemented for Tpetra operators"); // Get the underlying Epetra_CrsMatrix, if we have one Teuchos::RCP eo=Thyra::get_Epetra_Operator(*lo); TEUCHOS_ASSERT(eo!=Teuchos::null); Teuchos::RCP MAT = Teuchos::rcp_dynamic_cast(eo); TEUCHOS_ASSERT(MAT!=Teuchos::null); - + // Create a new EpetraExt_PointToBlockDiagPermute for the state object, if we don't have one Teuchos::RCP BDP; if(MyState.BDP_==Teuchos::null) { @@ -94,7 +94,7 @@ LinearOp DiagonalPreconditionerFactory::buildPreconditionerOperator(LinearOp & l RCP Hcrs=rcp(MyState.BDP_->CreateFECrsMatrix()); return Thyra::epetraLinearOp(Hcrs); - + // Build the LinearOp object (NTS: swapping the range and domain) // LinearOp MyOp = Teuchos::rcp(new DiagonalPreconditionerOp(MyState.BDP_,lo->domain(),lo->range())); } @@ -114,7 +114,7 @@ void DiagonalPreconditionerFactory::initializeFromParameterList(const Teuchos::P if(diagonalType_==BlkDiag) { // Reset default to invert mode if the user hasn't specified something else - Teuchos::ParameterList & SubList=List_.sublist("blockdiagmatrix: list"); + Teuchos::ParameterList & SubList=List_.sublist("blockdiagmatrix: list"); SubList.set("apply mode",SubList.get("apply mode","invert")); } } diff --git a/packages/teko/src/Teko_PreconditionerFactory.cpp b/packages/teko/src/Teko_PreconditionerFactory.cpp index 8ded468b9ec8..b7140e2f6c71 100644 --- a/packages/teko/src/Teko_PreconditionerFactory.cpp +++ b/packages/teko/src/Teko_PreconditionerFactory.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -59,7 +59,9 @@ #include "Teko_IterativePreconditionerFactory.hpp" #include "Teko_DiagnosticPreconditionerFactory.hpp" #include "Teko_DiagonallyScaledPreconditionerFactory.hpp" +#ifdef TEKO_HAVE_EPETRA #include "Teko_DiagonalPreconditionerFactory.hpp" +#endif #include "Teko_ProbingPreconditionerFactory.hpp" #include "Teko_IdentityPreconditionerFactory.hpp" #include "NS/Teko_LSCPreconditionerFactory.hpp" @@ -108,7 +110,7 @@ void PreconditionerFactory::initializePrec(const RCP(prec); TEUCHOS_ASSERT(blkPrec!=0); - + // grab the state object RCP state = blkPrec->getStateObject(); state->setInitialized(false); @@ -116,7 +118,7 @@ void PreconditionerFactory::initializePrec(const RCP > M = buildPreconditionerOperator(A,*state); - // set the request handler for the + // set the request handler for the setOpRequestHandler(*this,M); // must first cast that to be initialized @@ -137,7 +139,7 @@ void PreconditionerFactory::initializePrec(const RCP * /* prec */, +void PreconditionerFactory::uninitializePrec(PreconditionerBase * /* prec */, RCP > * /* fwdOpSrc */, ESupportSolveUse * /* supportSolveUse */) const { @@ -162,7 +164,7 @@ RCP< Teuchos::ParameterList > PreconditionerFactory::getNonconstParameterList() return paramList_; } -//! Unset the parameter list that was set using setParameterList(). +//! Unset the parameter list that was set using setParameterList(). RCP< Teuchos::ParameterList > PreconditionerFactory::unsetParameterList() { RCP _paramList = paramList_; @@ -203,7 +205,7 @@ void PreconditionerFactory::setOpRequestHandler(const RequestHandlerContainer & else { // is null } - + } //! for creating the preconditioner factories objects @@ -214,7 +216,7 @@ CloneFactory PreconditionerFactory::precFactoryBuilder_; * * Builder function for creating preconditioner factories (yes * this is a factory factory. - * + * * \param[in] name String name of factory to build * \param[in] settings Parameter list describing the parameters for the * factory to build @@ -223,7 +225,7 @@ CloneFactory PreconditionerFactory::precFactoryBuilder_; * \returns If the name is associated with a preconditioner * a pointer is returned, otherwise Teuchos::null is returned. */ -RCP +RCP PreconditionerFactory::buildPreconditionerFactory(const std::string & name, const Teuchos::ParameterList & settings, const RCP & invLib) @@ -241,7 +243,7 @@ PreconditionerFactory::buildPreconditionerFactory(const std::string & name, DEBUG_STREAM << "Built " << precFact << std::endl; Teko_DEBUG_MSG_END(); - if(precFact==Teuchos::null) + if(precFact==Teuchos::null) return Teuchos::null; // add in the inverse library @@ -258,7 +260,7 @@ PreconditionerFactory::buildPreconditionerFactory(const std::string & name, } /** \brief Add a preconditioner factory to the builder. This is done using the - * clone pattern. + * clone pattern. * * Add a preconditioner factory to the builder. This is done using the * clone pattern. If your class does not support the Cloneable interface then @@ -276,7 +278,7 @@ void PreconditionerFactory::addPreconditionerFactory(const std::string & name,co if(precFactoryBuilder_.cloneCount()==0) initializePrecFactoryBuilder(); // add clone to builder - precFactoryBuilder_.addClone(name,clone); + precFactoryBuilder_.addClone(name,clone); } //! This is where the default objects are put into the precFactoryBuilder_ @@ -312,8 +314,10 @@ void PreconditionerFactory::initializePrecFactoryBuilder() clone = rcp(new AutoClone()); precFactoryBuilder_.addClone("Iterative Preconditioner",clone); +#ifdef TEKO_HAVE_EPETRA clone = rcp(new AutoClone()); precFactoryBuilder_.addClone("Explicit Diagonal Preconditioner",clone); +#endif clone = rcp(new AutoClone()); precFactoryBuilder_.addClone("Diagnostic Inverse",clone); @@ -336,10 +340,10 @@ void PreconditionerFactory::initializePrecFactoryBuilder() } void PreconditionerFactory::getPreconditionerFactoryNames(std::vector & names) -{ +{ // initialize the defaults if necessary if(precFactoryBuilder_.cloneCount()==0) initializePrecFactoryBuilder(); - precFactoryBuilder_.getCloneNames(names); + precFactoryBuilder_.getCloneNames(names); } } // end namespace Teko diff --git a/packages/teko/src/Teko_StratimikosFactory.cpp b/packages/teko/src/Teko_StratimikosFactory.cpp index 519bd875466b..cac484f0f812 100644 --- a/packages/teko/src/Teko_StratimikosFactory.cpp +++ b/packages/teko/src/Teko_StratimikosFactory.cpp @@ -3,20 +3,22 @@ #include "Teuchos_Time.hpp" #include "Teuchos_AbstractFactoryStd.hpp" -#include "Thyra_EpetraOperatorViewExtractorStd.hpp" -#include "Thyra_EpetraLinearOp.hpp" #include "Thyra_DefaultPreconditioner.hpp" #include "Teko_InverseLibrary.hpp" #include "Teko_Preconditioner.hpp" -#include "Teko_InverseFactoryOperator.hpp" #include "Teko_Utilities.hpp" #include "Teko_InverseLibrary.hpp" -#include "Teko_StridedEpetraOperator.hpp" -#include "Teko_BlockedEpetraOperator.hpp" #include "Teko_ReorderedLinearOp.hpp" +#ifdef TEKO_HAVE_EPETRA +#include "Teko_InverseFactoryOperator.hpp" // an epetra specific object +#include "Thyra_EpetraOperatorViewExtractorStd.hpp" +#include "Teko_StridedEpetraOperator.hpp" +#include "Teko_BlockedEpetraOperator.hpp" +#include "Thyra_EpetraLinearOp.hpp" #include "EpetraExt_RowMatrixOut.h" +#endif namespace Teko { @@ -55,6 +57,8 @@ namespace { }; } +#ifdef TEKO_HAVE_EPETRA + // Constructors/initializers/accessors StratimikosFactory::StratimikosFactory() :epetraFwdOpViewExtractor_(Teuchos::rcp(new Thyra::EpetraOperatorViewExtractorStd())) @@ -67,14 +71,19 @@ StratimikosFactory::StratimikosFactory(const Teuchos::RCP setRequestHandler(rh); } +#endif // TEKO_HAVE_EPETRA + StratimikosFactory::StratimikosFactory(const Teuchos::RCP & builder, const Teuchos::RCP & rh) - :epetraFwdOpViewExtractor_(Teuchos::rcp(new Thyra::EpetraOperatorViewExtractorStd())), builder_(builder) + : +#ifdef TEKO_HAVE_EPETRA + epetraFwdOpViewExtractor_(Teuchos::rcp(new Thyra::EpetraOperatorViewExtractorStd())), +#endif + builder_(builder) { setRequestHandler(rh); } - // Overridden from PreconditionerFactoryBase bool StratimikosFactory::isCompatible(const Thyra::LinearOpSourceBase &/* fwdOpSrc */) const { @@ -133,9 +142,11 @@ void StratimikosFactory::initializePrec( { Teuchos::RCP > fwdOp = fwdOpSrc->getOp(); +#ifdef TEKO_HAVE_EPETRA if(epetraFwdOpViewExtractor_->isCompatible(*fwdOp)) initializePrec_Epetra(fwdOpSrc,prec,supportSolveUse); else +#endif initializePrec_Thyra(fwdOpSrc,prec,supportSolveUse); } @@ -241,6 +252,7 @@ void StratimikosFactory::initializePrec_Thyra( *out << "\nLeaving Teko::StratimikosFactory::initializePrec_Thyra(...) ...\n"; } +#ifdef TEKO_HAVE_EPETRA void StratimikosFactory::initializePrec_Epetra( const Teuchos::RCP > &fwdOpSrc, Thyra::PreconditionerBase *prec, @@ -402,7 +414,7 @@ void StratimikosFactory::initializePrec_Epetra( if(mediumVerbosity) *out << "\nLeaving Teko::StratimikosFactory::initializePrec(...) ...\n"; } - +#endif // TEKO_HAVE_EPETRA void StratimikosFactory::uninitializePrec( Thyra::PreconditionerBase * /* prec */, @@ -501,6 +513,7 @@ StratimikosFactory::getValidParameters() const return validPL; } +#ifdef TEKO_HAVE_EPETRA /** Build the segregated jacobian operator according to * the input parameter list. */ @@ -569,6 +582,7 @@ Teuchos::RCP StratimikosFactory::buildWrappedEpetraOperator( return wrappedOp; } +#endif // TEKO_HAVE_EPETRA std::string StratimikosFactory::description() const { @@ -577,6 +591,7 @@ std::string StratimikosFactory::description() const return oss.str(); } +#ifdef TEKO_HAVE_EPETRA void StratimikosFactory::buildStridedVectors(const Epetra_Operator & Jac, const std::vector & decomp, std::vector > & vars) const @@ -606,6 +621,7 @@ void StratimikosFactory::buildStridedVectors(const Epetra_Operator & Jac, } } } +#endif // TEKO_HAVE_EPETRA void addTekoToStratimikosBuilder(Stratimikos::DefaultLinearSolverBuilder & builder, const std::string & stratName) diff --git a/packages/teko/src/Teko_StratimikosFactory.hpp b/packages/teko/src/Teko_StratimikosFactory.hpp index 82d0c575f845..e8f573121a4a 100644 --- a/packages/teko/src/Teko_StratimikosFactory.hpp +++ b/packages/teko/src/Teko_StratimikosFactory.hpp @@ -4,14 +4,16 @@ #include #include "Thyra_PreconditionerFactoryBase.hpp" -#include "Thyra_EpetraOperatorViewExtractorBase.hpp" #include "Teuchos_StandardCompositionMacros.hpp" #include "Teko_RequestHandler.hpp" #include "Teko_InverseLibrary.hpp" #include "Teko_InverseFactory.hpp" +#ifdef TEKO_HAVE_EPETRA +#include "Thyra_EpetraOperatorViewExtractorBase.hpp" #include "Epetra_Operator.h" +#endif namespace Teko { @@ -32,6 +34,7 @@ class StratimikosFactory : public Thyra::PreconditionerFactoryBase { StratimikosFactory(const Teuchos::RCP & builder, const Teuchos::RCP & rh); +#ifdef TEKO_HAVE_EPETRA /** \brief Set the strategy object used to extract an * Epetra_Operator view of an input forward operator. * @@ -42,6 +45,7 @@ class StratimikosFactory : public Thyra::PreconditionerFactoryBase { */ STANDARD_COMPOSITION_MEMBERS( Thyra::EpetraOperatorViewExtractorBase, epetraFwdOpViewExtractor ); +#endif //@} @@ -105,6 +109,7 @@ class StratimikosFactory : public Thyra::PreconditionerFactoryBase { const Thyra::ESupportSolveUse supportSolveUse ) const; +#ifdef TEKO_HAVE_EPETRA /** Setup an epetra preconditioner. */ void initializePrec_Epetra( @@ -112,6 +117,7 @@ class StratimikosFactory : public Thyra::PreconditionerFactoryBase { Thyra::PreconditionerBase *prec, const Thyra::ESupportSolveUse supportSolveUse ) const; +#endif /** Access to the application communication request handling mechnism */ @@ -129,6 +135,7 @@ class StratimikosFactory : public Thyra::PreconditionerFactoryBase { private: +#ifdef TEKO_HAVE_EPETRA /** Build the segragated jacobian operator according to * the input parameter list. * @@ -157,6 +164,7 @@ class StratimikosFactory : public Thyra::PreconditionerFactoryBase { void buildStridedVectors(const Epetra_Operator & Jac, const std::vector & decomp, std::vector > & vars) const; +#endif // TEKO_HAVE_EPETRA Teuchos::RCP paramList_; @@ -175,7 +183,7 @@ class StratimikosFactory : public Thyra::PreconditionerFactoryBase { * that list of solvers/precondtioners. */ void addTekoToStratimikosBuilder(Stratimikos::DefaultLinearSolverBuilder & builder, - const std::string & stratName="Teko"); + const std::string & stratName="Teko"); /** Inject Teko into a solver builder with a specified name. Note that the builder * is used to define the default solvers in Teko. Therefore any dynamically specified @@ -185,8 +193,8 @@ void addTekoToStratimikosBuilder(Stratimikos::DefaultLinearSolverBuilder & build * that list of solvers/precondtioners. */ void addTekoToStratimikosBuilder(Stratimikos::DefaultLinearSolverBuilder & builder, - const Teuchos::RCP & rh, - const std::string & stratName="Teko"); + const Teuchos::RCP & rh, + const std::string & stratName="Teko"); } // namespace Teko diff --git a/packages/teko/src/Teko_Utilities.cpp b/packages/teko/src/Teko_Utilities.cpp index 505984442557..863521b78285 100644 --- a/packages/teko/src/Teko_Utilities.cpp +++ b/packages/teko/src/Teko_Utilities.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -52,9 +52,6 @@ #include "Thyra_ZeroLinearOpBase.hpp" #include "Thyra_DefaultDiagonalLinearOp.hpp" #include "Thyra_DefaultAddedLinearOp.hpp" -#include "Thyra_EpetraExtDiagScaledMatProdTransformer.hpp" -#include "Thyra_EpetraExtDiagScalingTransformer.hpp" -#include "Thyra_EpetraExtAddTransformer.hpp" #include "Thyra_DefaultScaledAdjointLinearOp.hpp" #include "Thyra_DefaultMultipliedLinearOp.hpp" #include "Thyra_DefaultZeroLinearOp.hpp" @@ -63,15 +60,23 @@ #include "Thyra_MultiVectorStdOps.hpp" #include "Thyra_VectorStdOps.hpp" #include "Thyra_SpmdVectorBase.hpp" +#include + +#ifdef TEKO_HAVE_EPETRA +#include "Thyra_EpetraExtDiagScaledMatProdTransformer.hpp" +#include "Thyra_EpetraExtDiagScalingTransformer.hpp" +#include "Thyra_EpetraExtAddTransformer.hpp" #include "Thyra_get_Epetra_Operator.hpp" #include "Thyra_EpetraThyraWrappers.hpp" #include "Thyra_EpetraOperatorWrapper.hpp" #include "Thyra_EpetraLinearOp.hpp" +#endif // Teuchos includes #include "Teuchos_Array.hpp" // Epetra includes +#ifdef TEKO_HAVE_EPETRA #include "Epetra_Operator.h" #include "Epetra_CrsGraph.h" #include "Epetra_CrsMatrix.h" @@ -81,6 +86,10 @@ #include "EpetraExt_Transpose_RowMatrix.h" #include "EpetraExt_MatrixMatrix.h" +#include "Teko_EpetraHelpers.hpp" +#include "Teko_EpetraOperatorWrapper.hpp" +#endif + // Anasazi includes #include "AnasaziBasicEigenproblem.hpp" #include "AnasaziThyraAdapter.hpp" @@ -94,8 +103,6 @@ #endif // Teko includes -#include "Teko_EpetraHelpers.hpp" -#include "Teko_EpetraOperatorWrapper.hpp" #include "Teko_TpetraHelpers.hpp" #include "Teko_TpetraOperatorWrapper.hpp" @@ -119,10 +126,10 @@ using Isorropia::Epetra::Prober; #endif const Teuchos::RCP getOutputStream() -{ - Teuchos::RCP os = - Teuchos::VerboseObjectBase::getDefaultOStream(); - +{ + Teuchos::RCP os = + Teuchos::VerboseObjectBase::getDefaultOStream(); + //os->setShowProcRank(true); //os->setOutputToRootOnly(-1); return os; @@ -169,6 +176,7 @@ inline double dist(double * x,double * y,double * z,int stride,int row,int col) * * \returns The graph Laplacian matrix to be filled according to the stencil matrix. */ +#ifdef TEKO_HAVE_EPETRA RCP buildGraphLaplacian(int dim,double * coords,const Epetra_CrsMatrix & stencil) { // allocate a new matrix with storage for the laplacian...in case of diagonals add one extra storage @@ -188,7 +196,7 @@ RCP buildGraphLaplacian(int dim,double * coords,const Epetra_C // extract a copy of this row...put it in rowData, rowIndicies stencil.ExtractGlobalRowCopy(row,stencil.MaxNumEntries(),rowSz,&rowData[0],&rowInd[0]); - + // loop over elements of row for(int i=0;i buildGraphLaplacian(int dim,double * coords,const Epetra_C rowData[i] = -1.0/d; diagValue += rowData[i]; } - else + else diagInd = i; } - + // handle diagonal entry if(diagInd<0) { // diagonal not in row rowData[rowSz] = -diagValue; @@ -226,6 +234,7 @@ RCP buildGraphLaplacian(int dim,double * coords,const Epetra_C return gl; } +#endif RCP > buildGraphLaplacian(int dim,ST * coords,const Tpetra::CrsMatrix & stencil) { @@ -246,7 +255,7 @@ RCP > buildGraphLaplacian(int dim,ST * coords,con // extract a copy of this row...put it in rowData, rowIndicies stencil.getGlobalRowCopy(row,rowInd,rowData,rowSz); - + // loop over elements of row for(size_t i=0;i > buildGraphLaplacian(int dim,ST * coords,con rowData[i] = -1.0/d; diagValue += rowData(i); } - else + else diagInd = i; } - + // handle diagonal entry if(diagInd<0) { // diagonal not in row rowData(rowSz) = -diagValue; @@ -307,6 +316,7 @@ RCP > buildGraphLaplacian(int dim,ST * coords,con * * \returns The graph Laplacian matrix to be filled according to the stencil matrix. */ +#ifdef TEKO_HAVE_EPETRA RCP buildGraphLaplacian(double * x,double * y,double * z,int stride,const Epetra_CrsMatrix & stencil) { // allocate a new matrix with storage for the laplacian...in case of diagonals add one extra storage @@ -326,7 +336,7 @@ RCP buildGraphLaplacian(double * x,double * y,double * z,int s // extract a copy of this row...put it in rowData, rowIndicies stencil.ExtractGlobalRowCopy(row,stencil.MaxNumEntries(),rowSz,&rowData[0],&rowInd[0]); - + // loop over elements of row for(int i=0;i buildGraphLaplacian(double * x,double * y,double * z,int s rowData[i] = -1.0/d; diagValue += rowData[i]; } - else + else diagInd = i; } - + // handle diagonal entry if(diagInd<0) { // diagonal not in row rowData[rowSz] = -diagValue; @@ -364,6 +374,7 @@ RCP buildGraphLaplacian(double * x,double * y,double * z,int s return gl; } +#endif RCP > buildGraphLaplacian(ST * x,ST * y,ST * z,GO stride,const Tpetra::CrsMatrix & stencil) { @@ -384,7 +395,7 @@ RCP > buildGraphLaplacian(ST * x,ST * y,ST * z,GO // extract a copy of this row...put it in rowData, rowIndicies stencil.getGlobalRowCopy(row,rowInd,rowData,rowSz); - + // loop over elements of row for(size_t i=0;i > buildGraphLaplacian(ST * x,ST * y,ST * z,GO rowData[i] = -1.0/d; diagValue += rowData(i); } - else + else diagInd = i; } - + // handle diagonal entry if(diagInd<0) { // diagonal not in row rowData(rowSz) = -diagValue; @@ -428,7 +439,7 @@ RCP > buildGraphLaplacian(ST * x,ST * y,ST * z,GO * * Apply a linear operator to a multivector. This also permits arbitrary scaling * and addition of the result. This function gives - * + * * \f$ y = \alpha A x + \beta y \f$ * * \param[in] A @@ -448,7 +459,7 @@ void applyOp(const LinearOp & A,const MultiVector & x,MultiVector & y,double alp * * Apply a transposed linear operator to a multivector. This also permits arbitrary scaling * and addition of the result. This function gives - * + * * \f$ y = \alpha A^T x + \beta y \f$ * * \param[in] A @@ -490,15 +501,15 @@ BlockedLinearOp getUpperTriBlocks(const BlockedLinearOp & blo,bool callEndBlockF // allocate new operator BlockedLinearOp upper = createBlockedOp(); - - // build new operator + + // build new operator upper->beginBlockFill(rows,rows); for(int i=0;i > zed + RCP > zed = Thyra::zero(range->getBlock(i),domain->getBlock(i)); upper->setBlock(i,i,zed); @@ -529,15 +540,15 @@ BlockedLinearOp getLowerTriBlocks(const BlockedLinearOp & blo,bool callEndBlockF // allocate new operator BlockedLinearOp lower = createBlockedOp(); - - // build new operator + + // build new operator lower->beginBlockFill(rows,rows); for(int i=0;i > zed + RCP > zed = Thyra::zero(range->getBlock(i),domain->getBlock(i)); lower->setBlock(i,i,zed); @@ -571,10 +582,10 @@ BlockedLinearOp getLowerTriBlocks(const BlockedLinearOp & blo,bool callEndBlockF * \returns A zero operator with the same block structure as * the argument blo. * - * \notes The caller is responsible for calling + * \notes The caller is responsible for calling * endBlockFill on the returned blocked * operator. - */ + */ BlockedLinearOp zeroBlockedOp(const BlockedLinearOp & blo) { int rows = blockRowCount(blo); @@ -586,15 +597,15 @@ BlockedLinearOp zeroBlockedOp(const BlockedLinearOp & blo) // allocate new operator BlockedLinearOp zeroOp = createBlockedOp(); - - // build new operator + + // build new operator zeroOp->beginBlockFill(rows,rows); for(int i=0;i > zed + RCP > zed = Thyra::zero(range->getBlock(i),domain->getBlock(i)); zeroOp->setBlock(i,i,zed); } @@ -623,95 +634,120 @@ bool isZeroOp(const LinearOp op) return test!=Teuchos::null; } -/** \brief Compute absolute row sum matrix. - * - * Compute the absolute row sum matrix. That is - * a diagonal operator composed of the absolute value of the - * row sum. - * - * \returns A diagonal operator. - */ -ModifiableLinearOp getAbsRowSumMatrix(const LinearOp & op) -{ - bool isTpetra = false; - RCP eCrsOp; - RCP > tCrsOp; +std::pair getAbsRowSumMatrixEpetra(const LinearOp &op) { +#ifndef TEKO_HAVE_EPETRA + return std::make_pair(ModifiableLinearOp{}, false); +#else + RCP eCrsOp; - try { - // get Epetra or Tpetra Operator - RCP eOp = rcp_dynamic_cast(op); - RCP > tOp = rcp_dynamic_cast >(op); + const auto eOp = rcp_dynamic_cast(op); - // cast it to a CrsMatrix - RCP out = Teuchos::VerboseObjectBase::getDefaultOStream(); - if (!eOp.is_null()){ - eCrsOp = rcp_dynamic_cast(eOp->epetra_op(),true); - } - else if (!tOp.is_null()){ - tCrsOp = rcp_dynamic_cast >(tOp->getConstTpetraOperator(),true); - isTpetra = true; - } - else - throw std::logic_error("Neither Epetra nor Tpetra"); - } - catch (std::exception & e) { - RCP out = Teuchos::VerboseObjectBase::getDefaultOStream(); + if(!eOp) { + return std::make_pair(ModifiableLinearOp{}, false); + } - *out << "Teko: getAbsRowSumMatrix requires an Epetra_CrsMatrix or a Tpetra::CrsMatrix\n"; - *out << " Could not extract an Epetra_Operator or a Tpetra_Operator from a \"" << op->description() << std::endl; - *out << " OR\n"; - *out << " Could not cast an Epetra_Operator to a Epetra_CrsMatrix or a Tpetra_Operator to a Tpetra::CrsMatrix\n"; - *out << std::endl; - *out << "*** THROWN EXCEPTION ***\n"; - *out << e.what() << std::endl; - *out << "************************\n"; - - throw e; - } + eCrsOp = rcp_dynamic_cast(eOp->epetra_op(), true); - if(!isTpetra){ - // extract diagonal - const RCP ptrDiag = rcp(new Epetra_Vector(eCrsOp->RowMap())); - Epetra_Vector & diag = *ptrDiag; - // compute absolute value row sum - diag.PutScalar(0.0); - for(int i=0;iNumMyRows();i++) { - double * values = 0; - int numEntries; - eCrsOp->ExtractMyRowView(i,numEntries,values); + // extract diagonal + const auto ptrDiag = rcp(new Epetra_Vector(eCrsOp->RowMap())); + Epetra_Vector &diag = *ptrDiag; - // build abs value row sum - for(int j=0;jNumMyRows(); i++) { + double *values = 0; + int numEntries; + eCrsOp->ExtractMyRowView(i, numEntries, values); - // build Thyra diagonal operator - return Teko::Epetra::thyraDiagOp(ptrDiag,eCrsOp->RowMap(),"absRowSum( " + op->getObjectLabel() + " )"); - } - else { - // extract diagonal - const RCP > ptrDiag = Tpetra::createVector(tCrsOp->getRowMap()); - Tpetra::Vector & diag = *ptrDiag; + // build abs value row sum + for (int j = 0; j < numEntries; j++) + diag[i] += std::abs(values[j]); + } - // compute absolute value row sum - diag.putScalar(0.0); - for(LO i=0;i<(LO) tCrsOp->getLocalNumRows();i++) { - LO numEntries = tCrsOp->getNumEntriesInLocalRow (i); - typename Tpetra::CrsMatrix::local_inds_host_view_type indices; - typename Tpetra::CrsMatrix::values_host_view_type values; - tCrsOp->getLocalRowView(i,indices,values); + // build Thyra diagonal operator + return std::make_pair( + Teko::Epetra::thyraDiagOp(ptrDiag, eCrsOp->RowMap(), + "absRowSum( " + op->getObjectLabel() + " )"), + true); +#endif +} - // build abs value row sum - for(LO j=0;j getAbsRowSumMatrixTpetra(const LinearOp &op) { + RCP> tCrsOp; - // build Thyra diagonal operator - return Teko::TpetraHelpers::thyraDiagOp(ptrDiag,*tCrsOp->getRowMap(),"absRowSum( " + op->getObjectLabel() + " ))"); + const auto tOp = + rcp_dynamic_cast>(op); - } + tCrsOp = rcp_dynamic_cast>( + tOp->getConstTpetraOperator(), true); + + // extract diagonal + const auto ptrDiag = + Tpetra::createVector(tCrsOp->getRowMap()); + auto &diag = *ptrDiag; + // compute absolute value row sum + diag.putScalar(0.0); + for (LO i = 0; i < (LO)tCrsOp->getLocalNumRows(); i++) { + auto numEntries = tCrsOp->getNumEntriesInLocalRow(i); + typename Tpetra::CrsMatrix::local_inds_host_view_type + indices; + typename Tpetra::CrsMatrix::values_host_view_type values; + tCrsOp->getLocalRowView(i, indices, values); + + // build abs value row sum + for (size_t j = 0; j < numEntries; j++) + diag.sumIntoLocalValue(i, std::abs(values(j))); + } + + // build Thyra diagonal operator + return std::make_pair(Teko::TpetraHelpers::thyraDiagOp( + ptrDiag, *tCrsOp->getRowMap(), + "absRowSum( " + op->getObjectLabel() + " ))"), + true); +} + +/** \brief Compute absolute row sum matrix. + * + * Compute the absolute row sum matrix. That is + * a diagonal operator composed of the absolute value of the + * row sum. + * + * \returns A diagonal operator. + */ +ModifiableLinearOp getAbsRowSumMatrix(const LinearOp & op) +{ + try { + auto eResult = getAbsRowSumMatrixEpetra(op); + if (eResult.second) { + return eResult.first; + } + + auto tResult = getAbsRowSumMatrixTpetra(op); + if (tResult.second) { + return tResult.first; + } else { + throw std::logic_error("Neither Epetra nor Tpetra"); + } + } catch (std::exception &e) { + auto out = Teuchos::VerboseObjectBase::getDefaultOStream(); + + *out << "Teko: getAbsRowSumMatrix requires an Epetra_CrsMatrix or a " + "Tpetra::CrsMatrix\n"; + *out << " Could not extract an Epetra_Operator or a Tpetra_Operator " + "from a \"" + << op->description() << std::endl; + *out << " OR\n"; + *out << " Could not cast an Epetra_Operator to a Epetra_CrsMatrix or " + "a Tpetra_Operator to a Tpetra::CrsMatrix\n"; + *out << std::endl; + *out << "*** THROWN EXCEPTION ***\n"; + *out << e.what() << std::endl; + *out << "************************\n"; + + throw e; + } } /** \brief Compute inverse of the absolute row sum matrix. @@ -773,6 +809,7 @@ ModifiableLinearOp getAbsRowSumInvMatrix(const LinearOp & op) } else{ +#ifdef TEKO_HAVE_EPETRA RCP eOp = rcp_dynamic_cast(op,true); RCP eCrsOp = rcp_dynamic_cast(eOp->epetra_op(),true); @@ -795,6 +832,10 @@ ModifiableLinearOp getAbsRowSumInvMatrix(const LinearOp & op) // build Thyra diagonal operator return Teko::Epetra::thyraDiagOp(ptrDiag,eCrsOp->RowMap(),"absRowSum( " + op->getObjectLabel() + " )"); +#else + throw std::logic_error("getAbsRowSumInvMatrix is trying to use Epetra " + "code, but TEKO_HAVE_EPETRA is disabled!"); +#endif } } @@ -844,6 +885,54 @@ ModifiableLinearOp getInvLumpedMatrix(const LinearOp & op) return rcp(new Thyra::DefaultDiagonalLinearOp(diag)); } +const std::pair getDiagonalOpEpetra(const LinearOp &op) { +#ifndef TEKO_HAVE_EPETRA + return std::make_pair(ModifiableLinearOp{}, false); +#else + RCP eCrsOp; + + const auto eOp = rcp_dynamic_cast(op); + if (!eOp) { + return std::make_pair(ModifiableLinearOp{}, false); + } + + eCrsOp = rcp_dynamic_cast(eOp->epetra_op(), true); + + // extract diagonal + const auto diag = rcp(new Epetra_Vector(eCrsOp->RowMap())); + TEUCHOS_TEST_FOR_EXCEPT(eCrsOp->ExtractDiagonalCopy(*diag)); + + // build Thyra diagonal operator + return std::make_pair( + Teko::Epetra::thyraDiagOp(diag, eCrsOp->RowMap(), + "inv(diag( " + op->getObjectLabel() + " ))"), + true); +#endif +} + +const std::pair getDiagonalOpTpetra(const LinearOp &op) { + RCP> tCrsOp; + + const auto tOp = + rcp_dynamic_cast>(op); + if (!tOp) { + return std::make_pair(ModifiableLinearOp{}, false); + } + + tCrsOp = rcp_dynamic_cast>( + tOp->getConstTpetraOperator(), true); + + // extract diagonal + const auto diag = Tpetra::createVector(tCrsOp->getRowMap()); + tCrsOp->getLocalDiagCopy(*diag); + + // build Thyra diagonal operator + return std::make_pair(Teko::TpetraHelpers::thyraDiagOp( + diag, *tCrsOp->getRowMap(), + "inv(diag( " + op->getObjectLabel() + " ))"), + true); +} + /** \brief Get the diaonal of a linear operator * * Get the diagonal of a linear operator. Currently @@ -857,23 +946,17 @@ ModifiableLinearOp getInvLumpedMatrix(const LinearOp & op) */ const ModifiableLinearOp getDiagonalOp(const LinearOp & op) { - bool isTpetra = false; - RCP eCrsOp; - RCP > tCrsOp; - try { // get Epetra or Tpetra Operator - RCP eOp = rcp_dynamic_cast(op); - RCP > tOp = rcp_dynamic_cast >(op); + const auto eDiagOp = getDiagonalOpEpetra(op); - // cast it to a CrsMatrix - RCP out = Teuchos::VerboseObjectBase::getDefaultOStream(); - if (!eOp.is_null()){ - eCrsOp = rcp_dynamic_cast(eOp->epetra_op(),true); - } - else if (!tOp.is_null()){ - tCrsOp = rcp_dynamic_cast >(tOp->getConstTpetraOperator(),true); - isTpetra = true; + if (eDiagOp.second) { + return eDiagOp.first; + } + + const auto tDiagOp = getDiagonalOpTpetra(op); + if (tDiagOp.second) { + return tDiagOp.first; } else throw std::logic_error("Neither Epetra nor Tpetra"); @@ -889,59 +972,31 @@ const ModifiableLinearOp getDiagonalOp(const LinearOp & op) *out << "*** THROWN EXCEPTION ***\n"; *out << e.what() << std::endl; *out << "************************\n"; - - throw e; - } - - if(!isTpetra){ - // extract diagonal - const RCP diag = rcp(new Epetra_Vector(eCrsOp->RowMap())); - TEUCHOS_TEST_FOR_EXCEPT(eCrsOp->ExtractDiagonalCopy(*diag)); - - // build Thyra diagonal operator - return Teko::Epetra::thyraDiagOp(diag,eCrsOp->RowMap(),"inv(diag( " + op->getObjectLabel() + " ))"); - } - else { - // extract diagonal - const RCP > diag = Tpetra::createVector(tCrsOp->getRowMap()); - tCrsOp->getLocalDiagCopy(*diag); - - // build Thyra diagonal operator - return Teko::TpetraHelpers::thyraDiagOp(diag,*tCrsOp->getRowMap(),"inv(diag( " + op->getObjectLabel() + " ))"); + throw e; } } const MultiVector getDiagonal(const LinearOp & op) { - bool isTpetra = false; - RCP eCrsOp; - RCP > tCrsOp; - try { // get Epetra or Tpetra Operator - RCP eOp = rcp_dynamic_cast(op); - RCP > tOp = rcp_dynamic_cast >(op); + auto diagOp = getDiagonalOpEpetra(op); - // cast it to a CrsMatrix - RCP out = Teuchos::VerboseObjectBase::getDefaultOStream(); - if (!eOp.is_null()){ - eCrsOp = rcp_dynamic_cast(eOp->epetra_op(),true); - } - else if (!tOp.is_null()){ - tCrsOp = rcp_dynamic_cast >(tOp->getConstTpetraOperator(),true); - isTpetra = true; + if (!diagOp.second) { + diagOp = getDiagonalOpTpetra(op); + + if(!diagOp.second){ + throw std::logic_error("Neither Epetra nor Tpetra"); + } } - else - throw std::logic_error("Neither Epetra nor Tpetra"); + + Teuchos::RCP > v = + Teuchos::rcp_dynamic_cast >(diagOp.first)->getDiag(); + return Teuchos::rcp_const_cast >(v); } catch (std::exception & e) { RCP out = Teuchos::VerboseObjectBase::getDefaultOStream(); - - RCP eOp = rcp_dynamic_cast(op); - RCP > tOp = rcp_dynamic_cast >(op); - *out << eOp; - *out << tOp; *out << "Teko: getDiagonal requires an Epetra_CrsMatrix or a Tpetra::CrsMatrix\n"; *out << " Could not extract an Epetra_Operator or a Tpetra_Operator from a \"" << op->description() << std::endl; @@ -951,25 +1006,8 @@ const MultiVector getDiagonal(const LinearOp & op) *out << "*** THROWN EXCEPTION ***\n"; *out << e.what() << std::endl; *out << "************************\n"; - - throw e; - } - - if(!isTpetra){ - // extract diagonal - const RCP diag = rcp(new Epetra_Vector(eCrsOp->RowMap())); - TEUCHOS_TEST_FOR_EXCEPT(eCrsOp->ExtractDiagonalCopy(*diag)); - - return Thyra::create_Vector(diag,Thyra::create_VectorSpace(Teuchos::rcpFromRef(eCrsOp->RowMap()))); - } - else { - // extract diagonal - const RCP > diag = Tpetra::createVector(tCrsOp->getRowMap()); - tCrsOp->getLocalDiagCopy(*diag); - - // build Thyra diagonal operator - return Thyra::createVector(diag,Thyra::createVectorSpace(tCrsOp->getRowMap())); + throw e; } } @@ -977,8 +1015,8 @@ const MultiVector getDiagonal(const Teko::LinearOp & A,const DiagonalType & dt) { LinearOp diagOp = Teko::getDiagonalOp(A,dt); - Teuchos::RCP > v = - Teuchos::rcp_dynamic_cast >(diagOp)->getDiag(); + Teuchos::RCP > v = + Teuchos::rcp_dynamic_cast >(diagOp)->getDiag(); return Teuchos::rcp_const_cast >(v); } @@ -1039,7 +1077,8 @@ const ModifiableLinearOp getInvDiagonalOp(const LinearOp & op) } else { - RCP eOp = rcp_dynamic_cast(op,true); +#ifdef TEKO_HAVE_EPETRA + RCP eOp = rcp_dynamic_cast(op,true); RCP eCrsOp = rcp_dynamic_cast(eOp->epetra_op(),true); // extract diagonal @@ -1049,10 +1088,14 @@ const ModifiableLinearOp getInvDiagonalOp(const LinearOp & op) // build Thyra diagonal operator return Teko::Epetra::thyraDiagOp(diag,eCrsOp->RowMap(),"inv(diag( " + op->getObjectLabel() + " ))"); +#else + throw std::logic_error("getInvDiagonalOp is trying to use Epetra " + "code, but TEKO_HAVE_EPETRA is disabled!"); +#endif } } -/** \brief Multiply three linear operators. +/** \brief Multiply three linear operators. * * Multiply three linear operators. This currently assumes * that the underlying implementation uses Epetra_CrsMatrix. @@ -1171,7 +1214,7 @@ const LinearOp explicitMultiply(const LinearOp & opl,const LinearOp & opm,const bool isTpetral = Teko::TpetraHelpers::isTpetraLinearOp(opl); bool isTpetram = Teko::TpetraHelpers::isTpetraLinearOp(opm); bool isTpetrar = Teko::TpetraHelpers::isTpetraLinearOp(opr); - + if(isTpetral && isTpetram && isTpetrar){ // Both operators are Tpetra matrices so explicitly multiply them // Get left and right Tpetra crs operators @@ -1192,12 +1235,12 @@ const LinearOp explicitMultiply(const LinearOp & opl,const LinearOp & opm,const // Do explicit matrix-matrix multiply RCP > tCrsOplm = Tpetra::createCrsMatrix(tCrsOpl->getRowMap()); RCP > explicitCrsOp = Tpetra::createCrsMatrix(tCrsOpl->getRowMap()); - Tpetra::MatrixMatrix::Multiply(*tCrsOpl,transpl,*tCrsOpm,transpm,*tCrsOplm); - Tpetra::MatrixMatrix::Multiply(*tCrsOplm,false,*tCrsOpr,transpr,*explicitCrsOp); + Tpetra::MatrixMatrix::Multiply(*tCrsOpl,transpl,*tCrsOpm,transpm,*tCrsOplm); + Tpetra::MatrixMatrix::Multiply(*tCrsOplm,false,*tCrsOpr,transpr,*explicitCrsOp); explicitCrsOp->resumeFill(); explicitCrsOp->scale(scalarl*scalarm*scalarr); explicitCrsOp->fillComplete(tCrsOpr->getDomainMap(),tCrsOpl->getRangeMap()); - tExplicitOp->initialize(Thyra::tpetraVectorSpace(explicitCrsOp->getRangeMap()),Thyra::tpetraVectorSpace(explicitCrsOp->getDomainMap()),explicitCrsOp); + tExplicitOp->initialize(Thyra::tpetraVectorSpace(explicitCrsOp->getRangeMap()),Thyra::tpetraVectorSpace(explicitCrsOp->getDomainMap()),explicitCrsOp); return tExplicitOp; } else if (isTpetral && !isTpetram && isTpetrar){ // Assume that the middle operator is diagonal @@ -1209,7 +1252,7 @@ const LinearOp explicitMultiply(const LinearOp & opl,const LinearOp & opm,const ST scalarr = 0.0; bool transpr = false; RCP > tCrsOpr = Teko::TpetraHelpers::getTpetraCrsMatrix(opr, &scalarr, &transpr); - + RCP > diagPtr; // Cast middle operator as DiagonalLinearOp and extract diagonal as Vector @@ -1224,27 +1267,27 @@ const LinearOp explicitMultiply(const LinearOp & opl,const LinearOp & opm,const } else TEUCHOS_ASSERT(false); - + RCP > tCrsOplm = Tpetra::importAndFillCompleteCrsMatrix >(tCrsOpl, Tpetra::Import(tCrsOpl->getRowMap(),tCrsOpl->getRowMap())); // Do the diagonal scaling tCrsOplm->rightScale(*diagPtr); - + // Build output operator RCP > explicitOp = rcp(new Thyra::TpetraLinearOp()); RCP > tExplicitOp = rcp_dynamic_cast >(explicitOp); // Do explicit matrix-matrix multiply RCP > explicitCrsOp = Tpetra::createCrsMatrix(tCrsOpl->getRowMap()); - Tpetra::MatrixMatrix::Multiply(*tCrsOplm,false,*tCrsOpr,transpr,*explicitCrsOp); + Tpetra::MatrixMatrix::Multiply(*tCrsOplm,false,*tCrsOpr,transpr,*explicitCrsOp); explicitCrsOp->resumeFill(); explicitCrsOp->scale(scalarl*scalarr); explicitCrsOp->fillComplete(tCrsOpr->getDomainMap(),tCrsOpl->getRangeMap()); - tExplicitOp->initialize(Thyra::tpetraVectorSpace(explicitCrsOp->getRangeMap()),Thyra::tpetraVectorSpace(explicitCrsOp->getDomainMap()),explicitCrsOp); + tExplicitOp->initialize(Thyra::tpetraVectorSpace(explicitCrsOp->getRangeMap()),Thyra::tpetraVectorSpace(explicitCrsOp->getDomainMap()),explicitCrsOp); return tExplicitOp; } else { // Assume Epetra and we can use transformers - +#ifdef TEKO_HAVE_EPETRA // build implicit multiply const LinearOp implicitOp = Thyra::multiply(opl,opm,opr); @@ -1260,11 +1303,14 @@ const LinearOp explicitMultiply(const LinearOp & opl,const LinearOp & opm,const " * " + opr->getObjectLabel() + " )"); return explicitOp; - +#else + throw std::logic_error("explicitMultiply is trying to use Epetra " + "code, but TEKO_HAVE_EPETRA is disabled!"); +#endif } } -/** \brief Multiply three linear operators. +/** \brief Multiply three linear operators. * * Multiply three linear operators. This currently assumes * that the underlying implementation uses Epetra_CrsMatrix. @@ -1284,7 +1330,7 @@ const ModifiableLinearOp explicitMultiply(const LinearOp & opl,const LinearOp & bool isTpetral = Teko::TpetraHelpers::isTpetraLinearOp(opl); bool isTpetram = Teko::TpetraHelpers::isTpetraLinearOp(opm); bool isTpetrar = Teko::TpetraHelpers::isTpetraLinearOp(opr); - + if(isTpetral && isTpetram && isTpetrar){ // Both operators are Tpetra matrices so explicitly multiply them // Get left and right Tpetra crs operators @@ -1306,12 +1352,12 @@ const ModifiableLinearOp explicitMultiply(const LinearOp & opl,const LinearOp & // Do explicit matrix-matrix multiply RCP > tCrsOplm = Tpetra::createCrsMatrix(tCrsOpl->getRowMap()); RCP > explicitCrsOp = Tpetra::createCrsMatrix(tCrsOpl->getRowMap()); - Tpetra::MatrixMatrix::Multiply(*tCrsOpl,transpl,*tCrsOpm,transpm,*tCrsOplm); - Tpetra::MatrixMatrix::Multiply(*tCrsOplm,false,*tCrsOpr,transpr,*explicitCrsOp); + Tpetra::MatrixMatrix::Multiply(*tCrsOpl,transpl,*tCrsOpm,transpm,*tCrsOplm); + Tpetra::MatrixMatrix::Multiply(*tCrsOplm,false,*tCrsOpr,transpr,*explicitCrsOp); explicitCrsOp->resumeFill(); explicitCrsOp->scale(scalarl*scalarm*scalarr); explicitCrsOp->fillComplete(tCrsOpr->getDomainMap(),tCrsOpl->getRangeMap()); - tExplicitOp->initialize(Thyra::tpetraVectorSpace(explicitCrsOp->getRangeMap()),Thyra::tpetraVectorSpace(explicitCrsOp->getDomainMap()),explicitCrsOp); + tExplicitOp->initialize(Thyra::tpetraVectorSpace(explicitCrsOp->getRangeMap()),Thyra::tpetraVectorSpace(explicitCrsOp->getDomainMap()),explicitCrsOp); return tExplicitOp; } else if (isTpetral && !isTpetram && isTpetrar){ // Assume that the middle operator is diagonal @@ -1323,7 +1369,7 @@ const ModifiableLinearOp explicitMultiply(const LinearOp & opl,const LinearOp & ST scalarr = 0.0; bool transpr = false; RCP > tCrsOpr = Teko::TpetraHelpers::getTpetraCrsMatrix(opr, &scalarr, &transpr); - + // Cast middle operator as DiagonalLinearOp and extract diagonal as Vector RCP > dOpm = rcp_dynamic_cast >(opm,true); RCP > tPtr = rcp_dynamic_cast >(dOpm->getDiag(),true); @@ -1332,22 +1378,22 @@ const ModifiableLinearOp explicitMultiply(const LinearOp & opl,const LinearOp & // Do the diagonal scaling tCrsOplm->rightScale(*diagPtr); - + // Build output operator RCP > explicitOp = rcp(new Thyra::TpetraLinearOp()); RCP > tExplicitOp = rcp_dynamic_cast >(explicitOp); // Do explicit matrix-matrix multiply RCP > explicitCrsOp = Tpetra::createCrsMatrix(tCrsOpl->getRowMap()); - Tpetra::MatrixMatrix::Multiply(*tCrsOplm,false,*tCrsOpr,transpr,*explicitCrsOp); + Tpetra::MatrixMatrix::Multiply(*tCrsOplm,false,*tCrsOpr,transpr,*explicitCrsOp); explicitCrsOp->resumeFill(); explicitCrsOp->scale(scalarl*scalarr); explicitCrsOp->fillComplete(tCrsOpr->getDomainMap(),tCrsOpl->getRangeMap()); - tExplicitOp->initialize(Thyra::tpetraVectorSpace(explicitCrsOp->getRangeMap()),Thyra::tpetraVectorSpace(explicitCrsOp->getDomainMap()),explicitCrsOp); + tExplicitOp->initialize(Thyra::tpetraVectorSpace(explicitCrsOp->getRangeMap()),Thyra::tpetraVectorSpace(explicitCrsOp->getDomainMap()),explicitCrsOp); return tExplicitOp; } else { // Assume Epetra and we can use transformers - +#ifdef TEKO_HAVE_EPETRA // build implicit multiply const LinearOp implicitOp = Thyra::multiply(opl,opm,opr); @@ -1356,7 +1402,7 @@ const ModifiableLinearOp explicitMultiply(const LinearOp & opl,const LinearOp & Thyra::epetraExtDiagScaledMatProdTransformer(); // build operator destination operator - ModifiableLinearOp explicitOp; + ModifiableLinearOp explicitOp; // if neccessary build a operator to put the explicit multiply into if(destOp==Teuchos::null) @@ -1373,11 +1419,14 @@ const ModifiableLinearOp explicitMultiply(const LinearOp & opl,const LinearOp & " * " + opr->getObjectLabel() + " )"); return explicitOp; - +#else + throw std::logic_error("explicitMultiply is trying to use Epetra " + "code, but TEKO_HAVE_EPETRA is disabled!"); +#endif } } -/** \brief Multiply two linear operators. +/** \brief Multiply two linear operators. * * Multiply two linear operators. This currently assumes * that the underlying implementation uses Epetra_CrsMatrix. @@ -1475,7 +1524,7 @@ const LinearOp explicitMultiply(const LinearOp & opl,const LinearOp & opr) bool isTpetral = Teko::TpetraHelpers::isTpetraLinearOp(opl); bool isTpetrar = Teko::TpetraHelpers::isTpetraLinearOp(opr); - + if(isTpetral && isTpetrar){ // Both operators are Tpetra matrices so explicitly multiply them // Get left and right Tpetra crs operators ST scalarl = 0.0; @@ -1495,7 +1544,7 @@ const LinearOp explicitMultiply(const LinearOp & opl,const LinearOp & opr) explicitCrsOp->resumeFill(); explicitCrsOp->scale(scalarl*scalarr); explicitCrsOp->fillComplete(tCrsOpr->getDomainMap(),tCrsOpl->getRangeMap()); - tExplicitOp->initialize(Thyra::tpetraVectorSpace(explicitCrsOp->getRangeMap()),Thyra::tpetraVectorSpace(explicitCrsOp->getDomainMap()),explicitCrsOp); + tExplicitOp->initialize(Thyra::tpetraVectorSpace(explicitCrsOp->getRangeMap()),Thyra::tpetraVectorSpace(explicitCrsOp->getDomainMap()),explicitCrsOp); return tExplicitOp; } else if (isTpetral && !isTpetrar){ // Assume that the right operator is diagonal @@ -1504,18 +1553,18 @@ const LinearOp explicitMultiply(const LinearOp & opl,const LinearOp & opr) ST scalarl = 0.0; bool transpl = false; RCP > tCrsOpl = Teko::TpetraHelpers::getTpetraCrsMatrix(opl, &scalarl, &transpl); - + // Cast right operator as DiagonalLinearOp and extract diagonal as Vector RCP > dOpr = rcp_dynamic_cast >(opr,true); RCP > tPtr = rcp_dynamic_cast >(dOpr->getDiag(),true); RCP > diagPtr = rcp_dynamic_cast >(tPtr->getConstTpetraVector(),true); RCP > explicitCrsOp = Tpetra::importAndFillCompleteCrsMatrix >(tCrsOpl, Tpetra::Import(tCrsOpl->getRowMap(),tCrsOpl->getRowMap())); - + explicitCrsOp->rightScale(*diagPtr); explicitCrsOp->resumeFill(); explicitCrsOp->scale(scalarl); explicitCrsOp->fillComplete(tCrsOpl->getDomainMap(),tCrsOpl->getRangeMap()); - + return Thyra::constTpetraLinearOp(Thyra::tpetraVectorSpace(explicitCrsOp->getRangeMap()),Thyra::tpetraVectorSpace(explicitCrsOp->getDomainMap()),explicitCrsOp); } else if (!isTpetral && isTpetrar){ // Assume that the left operator is diagonal @@ -1524,7 +1573,7 @@ const LinearOp explicitMultiply(const LinearOp & opl,const LinearOp & opr) ST scalarr = 0.0; bool transpr = false; RCP > tCrsOpr = Teko::TpetraHelpers::getTpetraCrsMatrix(opr, &scalarr, &transpr); - + RCP > diagPtr; // Cast left operator as DiagonalLinearOp and extract diagonal as Vector @@ -1539,26 +1588,26 @@ const LinearOp explicitMultiply(const LinearOp & opl,const LinearOp & opr) } else TEUCHOS_ASSERT(false); - + RCP > explicitCrsOp = Tpetra::importAndFillCompleteCrsMatrix >(tCrsOpr, Tpetra::Import(tCrsOpr->getRowMap(),tCrsOpr->getRowMap())); - + explicitCrsOp->leftScale(*diagPtr); explicitCrsOp->resumeFill(); explicitCrsOp->scale(scalarr); explicitCrsOp->fillComplete(tCrsOpr->getDomainMap(),tCrsOpr->getRangeMap()); - + return Thyra::constTpetraLinearOp(Thyra::tpetraVectorSpace(explicitCrsOp->getRangeMap()),Thyra::tpetraVectorSpace(explicitCrsOp->getDomainMap()),explicitCrsOp); } else { // Assume Epetra and we can use transformers - +#ifdef TEKO_HAVE_EPETRA // build implicit multiply const LinearOp implicitOp = Thyra::multiply(opl,opr); - + // build a scaling transformer - RCP > prodTrans + RCP > prodTrans = Thyra::epetraExtDiagScalingTransformer(); - // check to see if a scaling transformer works: if not use the + // check to see if a scaling transformer works: if not use the // DiagScaledMatrixProduct transformer if(not prodTrans->isCompatible(*implicitOp)) prodTrans = Thyra::epetraExtDiagScaledMatProdTransformer(); @@ -1570,10 +1619,14 @@ const LinearOp explicitMultiply(const LinearOp & opl,const LinearOp & opr) " * " + opr->getObjectLabel() + " )"); return explicitOp; +#else + throw std::logic_error("explicitMultiply is trying to use Epetra " + "code, but TEKO_HAVE_EPETRA is disabled!"); +#endif } } -/** \brief Multiply two linear operators. +/** \brief Multiply two linear operators. * * Multiply two linear operators. This currently assumes * that the underlying implementation uses Epetra_CrsMatrix. @@ -1676,7 +1729,7 @@ const ModifiableLinearOp explicitMultiply(const LinearOp & opl,const LinearOp & bool isTpetral = Teko::TpetraHelpers::isTpetraLinearOp(opl); bool isTpetrar = Teko::TpetraHelpers::isTpetraLinearOp(opr); - + if(isTpetral && isTpetrar){ // Both operators are Tpetra matrices so use the explicit Tpetra matrix-matrix multiply // Get left and right Tpetra crs operators @@ -1697,11 +1750,11 @@ const ModifiableLinearOp explicitMultiply(const LinearOp & opl,const LinearOp & // Do explicit matrix-matrix multiply RCP > explicitCrsOp = Tpetra::createCrsMatrix(tCrsOpl->getRowMap()); - Tpetra::MatrixMatrix::Multiply(*tCrsOpl,transpl,*tCrsOpr,transpr,*explicitCrsOp); + Tpetra::MatrixMatrix::Multiply(*tCrsOpl,transpl,*tCrsOpr,transpr,*explicitCrsOp); explicitCrsOp->resumeFill(); explicitCrsOp->scale(scalarl*scalarr); explicitCrsOp->fillComplete(tCrsOpr->getDomainMap(),tCrsOpl->getRangeMap()); - tExplicitOp->initialize(Thyra::tpetraVectorSpace(explicitCrsOp->getRangeMap()),Thyra::tpetraVectorSpace(explicitCrsOp->getDomainMap()),explicitCrsOp); + tExplicitOp->initialize(Thyra::tpetraVectorSpace(explicitCrsOp->getRangeMap()),Thyra::tpetraVectorSpace(explicitCrsOp->getDomainMap()),explicitCrsOp); return tExplicitOp; } else if (isTpetral && !isTpetrar){ // Assume that the right operator is diagonal @@ -1710,7 +1763,7 @@ const ModifiableLinearOp explicitMultiply(const LinearOp & opl,const LinearOp & ST scalarl = 0.0; bool transpl = false; RCP > tCrsOpl = Teko::TpetraHelpers::getTpetraCrsMatrix(opl, &scalarl, &transpl); - + // Cast right operator as DiagonalLinearOp and extract diagonal as Vector RCP > dOpr = rcp_dynamic_cast >(opr); RCP > tPtr = rcp_dynamic_cast >(dOpr->getDiag(),true); @@ -1718,7 +1771,7 @@ const ModifiableLinearOp explicitMultiply(const LinearOp & opl,const LinearOp & // Scale by the diagonal operator RCP > explicitCrsOp = Tpetra::importAndFillCompleteCrsMatrix >(tCrsOpl, Tpetra::Import(tCrsOpl->getRowMap(),tCrsOpl->getRowMap())); - explicitCrsOp->rightScale(*diagPtr); + explicitCrsOp->rightScale(*diagPtr); explicitCrsOp->resumeFill(); explicitCrsOp->scale(scalarl); explicitCrsOp->fillComplete(tCrsOpl->getDomainMap(),tCrsOpl->getRangeMap()); @@ -1730,7 +1783,7 @@ const ModifiableLinearOp explicitMultiply(const LinearOp & opl,const LinearOp & ST scalarr = 0.0; bool transpr = false; RCP > tCrsOpr = Teko::TpetraHelpers::getTpetraCrsMatrix(opr, &scalarr, &transpr); - + // Cast leftt operator as DiagonalLinearOp and extract diagonal as Vector RCP > dOpl = rcp_dynamic_cast >(opl,true); RCP > tPtr = rcp_dynamic_cast >(dOpl->getDiag(),true); @@ -1745,22 +1798,22 @@ const ModifiableLinearOp explicitMultiply(const LinearOp & opl,const LinearOp & return Thyra::tpetraLinearOp(Thyra::tpetraVectorSpace(explicitCrsOp->getRangeMap()),Thyra::tpetraVectorSpace(explicitCrsOp->getDomainMap()),explicitCrsOp); } else { // Assume Epetra and we can use transformers - +#ifdef TEKO_HAVE_EPETRA // build implicit multiply const LinearOp implicitOp = Thyra::multiply(opl,opr); - + // build a scaling transformer - - RCP > prodTrans + + RCP > prodTrans = Thyra::epetraExtDiagScalingTransformer(); - // check to see if a scaling transformer works: if not use the + // check to see if a scaling transformer works: if not use the // DiagScaledMatrixProduct transformer if(not prodTrans->isCompatible(*implicitOp)) prodTrans = Thyra::epetraExtDiagScaledMatProdTransformer(); // build operator destination operator - ModifiableLinearOp explicitOp; + ModifiableLinearOp explicitOp; // if neccessary build a operator to put the explicit multiply into if(destOp==Teuchos::null) @@ -1776,10 +1829,14 @@ const ModifiableLinearOp explicitMultiply(const LinearOp & opl,const LinearOp & " * " + opr->getObjectLabel() + " )"); return explicitOp; +#else + throw std::logic_error("explicitMultiply is trying to use Epetra " + "code, but TEKO_HAVE_EPETRA is disabled!"); +#endif } } -/** \brief Add two linear operators. +/** \brief Add two linear operators. * * Add two linear operators. This currently assumes * that the underlying implementation uses Epetra_CrsMatrix. @@ -1814,7 +1871,7 @@ const LinearOp explicitAdd(const LinearOp & opl_in,const LinearOp & opr_in) blocked_sum->endBlockFill(); return blocked_sum; } - + // if only one is blocked, it must be 1x1 LinearOp opl = opl_in; LinearOp opr = opr_in; @@ -1881,14 +1938,15 @@ const LinearOp explicitAdd(const LinearOp & opl_in,const LinearOp & opr_in) RCP > tExplicitOp = rcp_dynamic_cast >(explicitOp); // Do explicit matrix-matrix add - RCP > explicitCrsOp = Tpetra::MatrixMatrix::add(scalarl,transpl,*tCrsOpl,scalarr,transpr,*tCrsOpr); - tExplicitOp->initialize(Thyra::tpetraVectorSpace(explicitCrsOp->getRangeMap()),Thyra::tpetraVectorSpace(explicitCrsOp->getDomainMap()),explicitCrsOp); + RCP > explicitCrsOp = Tpetra::MatrixMatrix::add(scalarl,transpl,*tCrsOpl,scalarr,transpr,*tCrsOpr); + tExplicitOp->initialize(Thyra::tpetraVectorSpace(explicitCrsOp->getRangeMap()),Thyra::tpetraVectorSpace(explicitCrsOp->getDomainMap()),explicitCrsOp); return tExplicitOp; }else{//Assume Epetra +#ifdef TEKO_HAVE_EPETRA // build implicit add const LinearOp implicitOp = Thyra::add(opl,opr); - + // build transformer const RCP > prodTrans = Thyra::epetraExtAddTransformer(); @@ -1900,10 +1958,14 @@ const LinearOp explicitAdd(const LinearOp & opl_in,const LinearOp & opr_in) " + " + opr->getObjectLabel() + " )"); return explicitOp; +#else + throw std::logic_error("explicitAdd is trying to use Epetra " + "code, but TEKO_HAVE_EPETRA is disabled!"); +#endif } } -/** \brief Add two linear operators. +/** \brief Add two linear operators. * * Add two linear operators. This currently assumes * that the underlying implementation uses Epetra_CrsMatrix. @@ -1921,7 +1983,7 @@ const ModifiableLinearOp explicitAdd(const LinearOp & opl,const LinearOp & opr, // if blocked, add block by block if(isPhysicallyBlockedLinearOp(opl)){ TEUCHOS_ASSERT(isPhysicallyBlockedLinearOp(opr)); - + double scalarl = 0.0; bool transpl = false; RCP > blocked_opl = getPhysicallyBlockedLinearOp(opl, &scalarl, &transpl); @@ -1962,7 +2024,7 @@ const ModifiableLinearOp explicitAdd(const LinearOp & opl,const LinearOp & opr, bool isTpetral = Teko::TpetraHelpers::isTpetraLinearOp(opl); bool isTpetrar = Teko::TpetraHelpers::isTpetraLinearOp(opr); - + if(isTpetral && isTpetrar){ // Both operators are Tpetra matrices so use the explicit Tpetra matrix-matrix add // Get left and right Tpetra crs operators @@ -1982,15 +2044,15 @@ const ModifiableLinearOp explicitAdd(const LinearOp & opl,const LinearOp & opr, RCP > tExplicitOp = rcp_dynamic_cast >(explicitOp); // Do explicit matrix-matrix add - RCP > explicitCrsOp = Tpetra::MatrixMatrix::add(scalarl,transpl,*tCrsOpl,scalarr,transpr,*tCrsOpr); - tExplicitOp->initialize(Thyra::tpetraVectorSpace(explicitCrsOp->getRangeMap()),Thyra::tpetraVectorSpace(explicitCrsOp->getDomainMap()),explicitCrsOp); + RCP > explicitCrsOp = Tpetra::MatrixMatrix::add(scalarl,transpl,*tCrsOpl,scalarr,transpr,*tCrsOpr); + tExplicitOp->initialize(Thyra::tpetraVectorSpace(explicitCrsOp->getRangeMap()),Thyra::tpetraVectorSpace(explicitCrsOp->getDomainMap()),explicitCrsOp); return tExplicitOp; }else{ // Assume Epetra - +#ifdef TEKO_HAVE_EPETRA // build implicit add const LinearOp implicitOp = Thyra::add(opl,opr); - + // build transformer const RCP > prodTrans = Thyra::epetraExtAddTransformer(); @@ -2008,6 +2070,10 @@ const ModifiableLinearOp explicitAdd(const LinearOp & opl,const LinearOp & opr, " + " + opr->getObjectLabel() + " )"); return explicitOp; +#else + throw std::logic_error("explicitAdd is trying to use Epetra " + "code, but TEKO_HAVE_EPETRA is disabled!"); +#endif } } @@ -2018,6 +2084,7 @@ const ModifiableLinearOp explicitAdd(const LinearOp & opl,const LinearOp & opr, const ModifiableLinearOp explicitSum(const LinearOp & op, const ModifiableLinearOp & destOp) { +#ifdef TEKO_HAVE_EPETRA // convert operators to Epetra_CrsMatrix const RCP epetraOp = rcp_dynamic_cast(get_Epetra_Operator(*op), true); @@ -2034,6 +2101,10 @@ const ModifiableLinearOp explicitSum(const LinearOp & op, EpetraExt::MatrixMatrix::Add(*epetraOp,false,1.0,*epetraDest,1.0); return destOp; +#else + throw std::logic_error("explicitSum is trying to use Epetra " + "code, but TEKO_HAVE_EPETRA is disabled!"); +#endif } const LinearOp explicitTranspose(const LinearOp & op) @@ -2051,11 +2122,11 @@ const LinearOp explicitTranspose(const LinearOp & op) transOp); } else { - +#ifdef TEKO_HAVE_EPETRA RCP eOp = Thyra::get_Epetra_Operator(*op); TEUCHOS_TEST_FOR_EXCEPTION(eOp==Teuchos::null,std::logic_error, "Teko::explicitTranspose Not an Epetra_Operator"); - RCP eRowMatrixOp + RCP eRowMatrixOp = Teuchos::rcp_dynamic_cast(eOp); TEUCHOS_TEST_FOR_EXCEPTION(eRowMatrixOp==Teuchos::null,std::logic_error, "Teko::explicitTranspose Not an Epetra_RowMatrix"); @@ -2064,12 +2135,16 @@ const LinearOp explicitTranspose(const LinearOp & op) EpetraExt::RowMatrix_Transpose tranposeOp; Epetra_RowMatrix & eMat = tranposeOp(const_cast(*eRowMatrixOp)); - // this copy is because of a poor implementation of the EpetraExt::Transform + // this copy is because of a poor implementation of the EpetraExt::Transform // implementation - Teuchos::RCP crsMat + Teuchos::RCP crsMat = Teuchos::rcp(new Epetra_CrsMatrix(dynamic_cast(eMat))); return Thyra::epetraLinearOp(crsMat); +#else + throw std::logic_error("explicitTranspose is trying to use Epetra " + "code, but TEKO_HAVE_EPETRA is disabled!"); +#endif } } @@ -2093,9 +2168,14 @@ double frobeniusNorm(const LinearOp & op_in) const RCP > crsOp = rcp_dynamic_cast >(tOp->getConstTpetraOperator(),true); return crsOp->getFrobeniusNorm(); } else { +#ifdef TEKO_HAVE_EPETRA const RCP epOp = Thyra::get_Epetra_Operator(*op); const RCP crsOp = rcp_dynamic_cast(epOp,true); return crsOp->NormFrobenius(); +#else + throw std::logic_error("frobeniusNorm is trying to use Epetra " + "code, but TEKO_HAVE_EPETRA is disabled!"); +#endif } } @@ -2103,11 +2183,16 @@ double oneNorm(const LinearOp & op) { if(Teko::TpetraHelpers::isTpetraLinearOp(op)){ TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,"One norm not currently implemented for Tpetra matrices"); - + } else { +#ifdef TEKO_HAVE_EPETRA const RCP epOp = Thyra::get_Epetra_Operator(*op); const RCP crsOp = rcp_dynamic_cast(epOp,true); return crsOp->NormOne(); +#else + throw std::logic_error("oneNorm is trying to use Epetra " + "code, but TEKO_HAVE_EPETRA is disabled!"); +#endif } } @@ -2134,27 +2219,32 @@ double infNorm(const LinearOp & op) for(LO j=0;j epOp = Thyra::get_Epetra_Operator(*op); const RCP crsOp = rcp_dynamic_cast(epOp,true); return crsOp->NormInf(); +#else + throw std::logic_error("infNorm is trying to use Epetra " + "code, but TEKO_HAVE_EPETRA is disabled!"); +#endif } } const LinearOp buildDiagonal(const MultiVector & src,const std::string & lbl) { - RCP > dst = Thyra::createMember(src->range()); + RCP > dst = Thyra::createMember(src->range()); Thyra::copy(*src->col(0),dst.ptr()); - + return Thyra::diagonal(dst,lbl); } const LinearOp buildInvDiagonal(const MultiVector & src,const std::string & lbl) { const RCP > srcV = src->col(0); - RCP > dst = Thyra::createMember(srcV->range()); + RCP > dst = Thyra::createMember(srcV->range()); Thyra::reciprocal(*srcV,dst.ptr()); return Thyra::diagonal(dst,lbl); @@ -2180,7 +2270,7 @@ BlockedMultiVector buildBlockedMultiVector(const std::vector & mvv) return Thyra::defaultProductMultiVector(vs,mvA); } -/** Construct an indicator vector specified by a vector of indices to +/** Construct an indicator vector specified by a vector of indices to * be set to ``on''. * * \param[in] indices Vector of indicies to turn on @@ -2197,13 +2287,13 @@ Teuchos::RCP > indicatorVector( { using Teuchos::RCP; - + // create a new vector RCP > v = Thyra::createMember(vs); Thyra::put_scalar(offValue,v.ptr()); // fill it with "off" values // set on values - for(std::size_t i=0;i(indices[i],onValue,v.ptr()); return v; @@ -2211,7 +2301,7 @@ Teuchos::RCP > indicatorVector( /** \brief Compute the spectral radius of a matrix * - * Compute the spectral radius of matrix A. This utilizes the + * Compute the spectral radius of matrix A. This utilizes the * Trilinos-Anasazi BlockKrylovShcur method for computing eigenvalues. * It attempts to compute the largest (in magnitude) eigenvalue to a given * level of tolerance. @@ -2244,7 +2334,7 @@ double computeSpectralRad(const RCP > & A, dou // construct an initial guess const RCP ivec = Thyra::createMember(A->domain()); Thyra::randomize(-1.0,1.0,ivec.ptr()); - + RCP > eigProb = rcp(new Anasazi::BasicEigenproblem(A,ivec)); eigProb->setNEV(1); @@ -2266,7 +2356,7 @@ double computeSpectralRad(const RCP > & A, dou MyPL.set( "Which", which ); MyPL.set( "Block Size", startVectors ); MyPL.set( "Num Blocks", numBlocks ); - MyPL.set( "Maximum Restarts", restart ); + MyPL.set( "Maximum Restarts", restart ); MyPL.set( "Convergence Tolerance", tol ); // build status test manager @@ -2276,7 +2366,7 @@ double computeSpectralRad(const RCP > & A, dou // Create the Block Krylov Schur solver // This takes as inputs the eigenvalue problem and the solver parameters Anasazi::BlockKrylovSchurSolMgr MyBlockKrylovSchur(eigProb, MyPL ); - + // Solve the eigenvalue problem, and save the return code Anasazi::ReturnType solverreturn = MyBlockKrylovSchur.solve(); @@ -2286,7 +2376,7 @@ double computeSpectralRad(const RCP > & A, dou return -std::abs(std::sqrt(real*real+comp*comp)); - // cout << "Anasazi::BlockKrylovSchur::solve() did not converge!" << std::endl; + // cout << "Anasazi::BlockKrylovSchur::solve() did not converge!" << std::endl; // return -std::abs(MyBlockKrylovSchur.getRitzValues().begin()->realpart); } else { // solverreturn==Anasazi::Converged @@ -2302,7 +2392,7 @@ double computeSpectralRad(const RCP > & A, dou /** \brief Compute the smallest eigenvalue of an operator * - * Compute the smallest eigenvalue of matrix A. This utilizes the + * Compute the smallest eigenvalue of matrix A. This utilizes the * Trilinos-Anasazi BlockKrylovShcur method for computing eigenvalues. * It attempts to compute the smallest (in magnitude) eigenvalue to a given * level of tolerance. @@ -2334,7 +2424,7 @@ double computeSmallestMagEig(const RCP > & A, // construct an initial guess const RCP ivec = Thyra::createMember(A->domain()); Thyra::randomize(-1.0,1.0,ivec.ptr()); - + RCP > eigProb = rcp(new Anasazi::BasicEigenproblem(A,ivec)); eigProb->setNEV(1); @@ -2355,7 +2445,7 @@ double computeSmallestMagEig(const RCP > & A, MyPL.set( "Which", which ); MyPL.set( "Block Size", startVectors ); MyPL.set( "Num Blocks", numBlocks ); - MyPL.set( "Maximum Restarts", restart ); + MyPL.set( "Maximum Restarts", restart ); MyPL.set( "Convergence Tolerance", tol ); // build status test manager @@ -2365,7 +2455,7 @@ double computeSmallestMagEig(const RCP > & A, // Create the Block Krylov Schur solver // This takes as inputs the eigenvalue problem and the solver parameters Anasazi::BlockKrylovSchurSolMgr MyBlockKrylovSchur(eigProb, MyPL ); - + // Solve the eigenvalue problem, and save the return code Anasazi::ReturnType solverreturn = MyBlockKrylovSchur.solve(); @@ -2391,11 +2481,11 @@ ModifiableLinearOp getDiagonalOp(const Teko::LinearOp & A,const DiagonalType & d { switch(dt) { case Diagonal: - return getDiagonalOp(A); + return getDiagonalOp(A); case Lumped: - return getLumpedMatrix(A); + return getLumpedMatrix(A); case AbsRowSum: - return getAbsRowSumMatrix(A); + return getAbsRowSumMatrix(A); case NotDiag: default: TEUCHOS_TEST_FOR_EXCEPT(true); @@ -2416,11 +2506,11 @@ ModifiableLinearOp getInvDiagonalOp(const Teko::LinearOp & A,const Teko::Diagona { switch(dt) { case Diagonal: - return getInvDiagonalOp(A); + return getInvDiagonalOp(A); case Lumped: - return getInvLumpedMatrix(A); + return getInvLumpedMatrix(A); case AbsRowSum: - return getAbsRowSumInvMatrix(A); + return getAbsRowSumInvMatrix(A); case NotDiag: default: TEUCHOS_TEST_FOR_EXCEPT(true); @@ -2471,10 +2561,11 @@ DiagonalType getDiagonalType(std::string name) return AbsRowSum; if(name=="BlkDiag") return BlkDiag; - + return NotDiag; } +#ifdef TEKO_HAVE_EPETRA LinearOp probe(Teuchos::RCP &G,const LinearOp & Op){ #ifdef Teko_ENABLE_Isorropia Teuchos::ParameterList probeList; @@ -2482,13 +2573,14 @@ LinearOp probe(Teuchos::RCP &G,const LinearOp & Op){ Teuchos::RCP Mat=rcp(new Epetra_CrsMatrix(Copy,*G)); Teko::Epetra::EpetraOperatorWrapper Mwrap(Op); prober.probe(Mwrap,*Mat); - return Thyra::epetraLinearOp(Mat); + return Thyra::epetraLinearOp(Mat); #else (void)G; (void)Op; TEUCHOS_TEST_FOR_EXCEPTION(true,std::runtime_error,"Probe requires Isorropia"); #endif } +#endif double norm_1(const MultiVector & v,std::size_t col) { @@ -2506,7 +2598,8 @@ double norm_2(const MultiVector & v,std::size_t col) return n[col]; } -void putScalar(const ModifiableLinearOp & op,double scalar) +#ifdef TEKO_HAVE_EPETRA +void putScalar(const ModifiableLinearOp & op,double scalar) { try { // get Epetra_Operator @@ -2528,10 +2621,11 @@ void putScalar(const ModifiableLinearOp & op,double scalar) *out << "*** THROWN EXCEPTION ***\n"; *out << e.what() << std::endl; *out << "************************\n"; - + throw e; } } +#endif void clipLower(MultiVector & v,double lowerBound) { @@ -2539,13 +2633,13 @@ void clipLower(MultiVector & v,double lowerBound) using Teuchos::rcp_dynamic_cast; // cast so entries are accessible - // RCP > spmdMVec + // RCP > spmdMVec // = rcp_dynamic_cast >(v); - + for(Thyra::Ordinal i=0;idomain()->dim();i++) { - RCP > spmdVec + RCP > spmdVec = rcp_dynamic_cast >(v->col(i),true); - + Teuchos::ArrayRCP values; // spmdMVec->getNonconstLocalData(Teuchos::ptrFromRef(values),Teuchos::ptrFromRef(i)); spmdVec->getNonconstLocalData(Teuchos::ptrFromRef(values)); @@ -2562,12 +2656,12 @@ void clipUpper(MultiVector & v,double upperBound) using Teuchos::rcp_dynamic_cast; // cast so entries are accessible - // RCP > spmdMVec + // RCP > spmdMVec // = rcp_dynamic_cast >(v); for(Thyra::Ordinal i=0;idomain()->dim();i++) { - RCP > spmdVec + RCP > spmdVec = rcp_dynamic_cast >(v->col(i),true); - + Teuchos::ArrayRCP values; // spmdMVec->getNonconstLocalData(Teuchos::ptrFromRef(values),Teuchos::ptrFromRef(i)); spmdVec->getNonconstLocalData(Teuchos::ptrFromRef(values)); @@ -2584,12 +2678,12 @@ void replaceValue(MultiVector & v,double currentValue,double newValue) using Teuchos::rcp_dynamic_cast; // cast so entries are accessible - // RCP > spmdMVec + // RCP > spmdMVec // = rcp_dynamic_cast >(v,true); for(Thyra::Ordinal i=0;idomain()->dim();i++) { - RCP > spmdVec + RCP > spmdVec = rcp_dynamic_cast >(v->col(i),true); - + Teuchos::ArrayRCP values; // spmdMVec->getNonconstLocalData(Teuchos::ptrFromRef(values),Teuchos::ptrFromRef(i)); spmdVec->getNonconstLocalData(Teuchos::ptrFromRef(values)); diff --git a/packages/teko/src/Teko_Utilities.hpp b/packages/teko/src/Teko_Utilities.hpp index 131fce5db759..95f9ed065550 100644 --- a/packages/teko/src/Teko_Utilities.hpp +++ b/packages/teko/src/Teko_Utilities.hpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -55,7 +55,12 @@ #ifndef __Teko_Utilities_hpp__ #define __Teko_Utilities_hpp__ +#include "Teko_ConfigDefs.hpp" + +#ifdef TEKO_HAVE_EPETRA #include "Epetra_CrsMatrix.h" +#endif + #include "Tpetra_CrsMatrix.hpp" // Teuchos includes @@ -78,8 +83,6 @@ #include "Thyra_DefaultIdentityLinearOp.hpp" #include "Thyra_DefaultZeroLinearOp.hpp" -#include "Teko_ConfigDefs.hpp" - #ifdef _MSC_VER #ifndef _MSC_EXTENSIONS #define _MSC_EXTENSIONS @@ -120,7 +123,10 @@ using Thyra::block1x2; * * \returns The graph Laplacian matrix to be filled according to the stencil matrix. */ +#ifdef TEKO_HAVE_EPETRA Teuchos::RCP buildGraphLaplacian(int dim,double * coords,const Epetra_CrsMatrix & stencil); +#endif + Teuchos::RCP > buildGraphLaplacian(int dim,ST * coords,const Tpetra::CrsMatrix & stencil); /** \brief Build a graph Laplacian stenciled on a Epetra_CrsMatrix. @@ -145,11 +151,14 @@ Teuchos::RCP > buildGraphLaplacian(int dim,ST * c * * \returns The graph Laplacian matrix to be filled according to the stencil matrix. */ +#ifdef TEKO_HAVE_EPETRA Teuchos::RCP buildGraphLaplacian(double * x,double * y,double * z,int stride,const Epetra_CrsMatrix & stencil); +#endif + Teuchos::RCP > buildGraphLaplacian(ST * x,ST * y,ST * z,GO stride,const Tpetra::CrsMatrix & stencil); /** \brief Function used internally by Teko to find the output stream. - * + * * Function used internally by Teko to find the output stream. * * \returns An output stream to use for printing @@ -179,19 +188,19 @@ const Teuchos::RCP getOutputStream(); // struct __DebugScope__ { // __DebugScope__(const std::string & str,int level) // : str_(str), level_(level) -// { Teko_DEBUG_MSG("BEGIN "+str_,level_); Teko_DEBUG_PUSHTAB(); } +// { Teko_DEBUG_MSG("BEGIN "+str_,level_); Teko_DEBUG_PUSHTAB(); } // ~__DebugScope__() -// { Teko_DEBUG_POPTAB(); Teko_DEBUG_MSG("END "+str_,level_); } +// { Teko_DEBUG_POPTAB(); Teko_DEBUG_MSG("END "+str_,level_); } // std::string str_; int level_; }; // #define Teko_DEBUG_SCOPE(str,level) __DebugScope__ __dbgScope__(str,level); -#else +#else #define Teko_DEBUG_EXPR(str) #define Teko_DEBUG_MSG(str,level) #define Teko_DEBUG_MSG_BEGIN(level) if(false) { \ std::ostream & DEBUG_STREAM = *Teko::getOutputStream(); #define Teko_DEBUG_MSG_END() } - #define Teko_DEBUG_PUSHTAB() - #define Teko_DEBUG_POPTAB() + #define Teko_DEBUG_PUSHTAB() + #define Teko_DEBUG_POPTAB() #define Teko_DEBUG_SCOPE(str,level) #endif @@ -213,7 +222,7 @@ inline MultiVector toMultiVector(BlockedMultiVector & bmv) { return bmv; } inline const MultiVector toMultiVector(const BlockedMultiVector & bmv) { return bmv; } //! Convert to a BlockedMultiVector from a MultiVector -inline const BlockedMultiVector toBlockedMultiVector(const MultiVector & bmv) +inline const BlockedMultiVector toBlockedMultiVector(const MultiVector & bmv) { return Teuchos::rcp_dynamic_cast >(bmv); } //! Get the column count in a block linear operator @@ -250,13 +259,13 @@ inline BlockedMultiVector deepcopy(const BlockedMultiVector & v) * is returned. Otherwise a new multivector is returned. */ inline MultiVector datacopy(const MultiVector & src,MultiVector & dst) -{ +{ if(dst==Teuchos::null) return deepcopy(src); bool rangeCompat = src->range()->isCompatible(*dst->range()); bool domainCompat = src->domain()->isCompatible(*dst->domain()); - + if(not (rangeCompat && domainCompat)) return deepcopy(src); @@ -279,7 +288,7 @@ inline MultiVector datacopy(const MultiVector & src,MultiVector & dst) * is returned. Otherwise a new multivector is returned. */ inline BlockedMultiVector datacopy(const BlockedMultiVector & src,BlockedMultiVector & dst) -{ +{ if(dst==Teuchos::null) return deepcopy(src); @@ -297,7 +306,7 @@ inline BlockedMultiVector datacopy(const BlockedMultiVector & src,BlockedMultiVe //! build a BlockedMultiVector from a vector of MultiVectors BlockedMultiVector buildBlockedMultiVector(const std::vector & mvs); -/** Construct an indicator vector specified by a vector of indices to +/** Construct an indicator vector specified by a vector of indices to * be set to ``on''. * * \param[in] indices Vector of indicies to turn on @@ -328,7 +337,9 @@ inline LinearOp zero(const VectorSpace & vs) { return Thyra::zero(vs,vs); } //! Replace nonzeros with a scalar value, used to zero out an operator +#ifdef TEKO_HAVE_EPETRA void putScalar(const ModifiableLinearOp & op,double scalar); +#endif //! Get the range space of a linear operator inline VectorSpace rangeSpace(const LinearOp & lo) @@ -384,10 +395,10 @@ inline void setBlock(int i,int j,BlockedLinearOp & blo, const LinearOp & lo) inline BlockedLinearOp createBlockedOp() { return rcp(new Thyra::DefaultBlockedLinearOp()); } -/** \brief Let the blocked operator know that you are going to +/** \brief Let the blocked operator know that you are going to * set the sub blocks. * - * Let the blocked operator know that you are going to + * Let the blocked operator know that you are going to * set the sub blocks. This is a simple wrapper around the * member function of the same name in Thyra. * @@ -398,10 +409,10 @@ inline BlockedLinearOp createBlockedOp() inline void beginBlockFill(BlockedLinearOp & blo,int rowCnt,int colCnt) { blo->beginBlockFill(rowCnt,colCnt); } -/** \brief Let the blocked operator know that you are going to +/** \brief Let the blocked operator know that you are going to * set the sub blocks. * - * Let the blocked operator know that you are going to + * Let the blocked operator know that you are going to * set the sub blocks. This is a simple wrapper around the * member function of the same name in Thyra. * @@ -493,7 +504,7 @@ ModifiableLinearOp getInvLumpedMatrix(const LinearOp & op); * * Apply a linear operator to a multivector. This also permits arbitrary scaling * and addition of the result. This function gives - * + * * \f$ y = \alpha A x + \beta y \f$ * * It is required that the range space of A is compatible with y and the domain space @@ -514,7 +525,7 @@ void applyOp(const LinearOp & A,const MultiVector & x,MultiVector & y,double alp * * Apply a transposed linear operator to a multivector. This also permits arbitrary scaling * and addition of the result. This function gives - * + * * \f$ y = \alpha A^T x + \beta y \f$ * * It is required that the domain space of A is compatible with y and the range space @@ -534,7 +545,7 @@ void applyTransposeOp(const LinearOp & A,const MultiVector & x,MultiVector & y,d * * Apply a linear operator to a blocked multivector. This also permits arbitrary scaling * and addition of the result. This function gives - * + * * \f$ y = \alpha A x + \beta y \f$ * * It is required that the range space of A is compatible with y and the domain space @@ -556,7 +567,7 @@ inline void applyOp(const LinearOp & A,const BlockedMultiVector & x,BlockedMulti * * Apply a transposed linear operator to a blocked multivector. This also permits arbitrary scaling * and addition of the result. This function gives - * + * * \f$ y = \alpha A^T x + \beta y \f$ * * It is required that the domain space of A is compatible with y and the range space @@ -575,11 +586,11 @@ inline void applyTransposeOp(const LinearOp & A,const BlockedMultiVector & x,Blo /** \brief Update the y vector so that \f$y = \alpha x+\beta y\f$ * - * Compute the linear combination \f$y=\alpha x + \beta y\f$. + * Compute the linear combination \f$y=\alpha x + \beta y\f$. * * \param[in] alpha - * \param[in] x - * \param[in] beta + * \param[in] x + * \param[in] beta * \param[in,out] y */ void update(double alpha,const MultiVector & x,double beta,MultiVector & y); @@ -593,15 +604,15 @@ inline void update(double alpha,const BlockedMultiVector & x,double beta,Blocked inline void scale(const double alpha,MultiVector & x) { Thyra::scale(alpha,x.ptr()); } //! Scale a multivector by a constant -inline void scale(const double alpha,BlockedMultiVector & x) +inline void scale(const double alpha,BlockedMultiVector & x) { MultiVector x_mv = toMultiVector(x); scale(alpha,x_mv); } //! Scale a modifiable linear op by a constant -inline LinearOp scale(const double alpha,ModifiableLinearOp & a) +inline LinearOp scale(const double alpha,ModifiableLinearOp & a) { return Thyra::nonconstScale(alpha,a); } //! Construct an implicit adjoint of the linear operators -inline LinearOp adjoint(ModifiableLinearOp & a) +inline LinearOp adjoint(ModifiableLinearOp & a) { return Thyra::nonconstAdjoint(a); } //@} @@ -642,7 +653,7 @@ const MultiVector getDiagonal(const LinearOp & op); */ const ModifiableLinearOp getInvDiagonalOp(const LinearOp & op); -/** \brief Multiply three linear operators. +/** \brief Multiply three linear operators. * * Multiply three linear operators. This currently assumes * that the underlying implementation uses Epetra_CrsMatrix. @@ -656,7 +667,7 @@ const ModifiableLinearOp getInvDiagonalOp(const LinearOp & op); */ const LinearOp explicitMultiply(const LinearOp & opl,const LinearOp & opm,const LinearOp & opr); -/** \brief Multiply three linear operators. +/** \brief Multiply three linear operators. * * Multiply three linear operators. This currently assumes * that the underlying implementation uses Epetra_CrsMatrix. @@ -673,7 +684,7 @@ const LinearOp explicitMultiply(const LinearOp & opl,const LinearOp & opm,const const ModifiableLinearOp explicitMultiply(const LinearOp & opl,const LinearOp & opm,const LinearOp & opr, const ModifiableLinearOp & destOp); -/** \brief Multiply two linear operators. +/** \brief Multiply two linear operators. * * Multiply two linear operators. This currently assumes * that the underlying implementation uses Epetra_CrsMatrix. @@ -685,7 +696,7 @@ const ModifiableLinearOp explicitMultiply(const LinearOp & opl,const LinearOp & */ const LinearOp explicitMultiply(const LinearOp & opl,const LinearOp & opr); -/** \brief Multiply two linear operators. +/** \brief Multiply two linear operators. * * Multiply two linear operators. This currently assumes * that the underlying implementation uses Epetra_CrsMatrix. @@ -701,7 +712,7 @@ const LinearOp explicitMultiply(const LinearOp & opl,const LinearOp & opr); const ModifiableLinearOp explicitMultiply(const LinearOp & opl,const LinearOp & opr, const ModifiableLinearOp & destOp); -/** \brief Add two linear operators. +/** \brief Add two linear operators. * * Add two linear operators. This currently assumes * that the underlying implementation uses Epetra_CrsMatrix. @@ -713,7 +724,7 @@ const ModifiableLinearOp explicitMultiply(const LinearOp & opl,const LinearOp & */ const LinearOp explicitAdd(const LinearOp & opl,const LinearOp & opr); -/** \brief Add two linear operators. +/** \brief Add two linear operators. * * Add two linear operators. This currently assumes * that the underlying implementation uses Epetra_CrsMatrix. @@ -758,7 +769,7 @@ const LinearOp buildInvDiagonal(const MultiVector & v,const std::string & lbl="A /** \brief Compute the spectral radius of a matrix * - * Compute the spectral radius of matrix A. This utilizes the + * Compute the spectral radius of matrix A. This utilizes the * Trilinos-Anasazi BlockKrylovShcur method for computing eigenvalues. * It attempts to compute the largest (in magnitude) eigenvalue to a given * level of tolerance. @@ -784,7 +795,7 @@ double computeSpectralRad(const Teuchos::RCP > /** \brief Compute the smallest eigenvalue of an operator * - * Compute the smallest eigenvalue of matrix A. This utilizes the + * Compute the smallest eigenvalue of matrix A. This utilizes the * Trilinos-Anasazi BlockKrylovShcur method for computing eigenvalues. * It attempts to compute the smallest (in magnitude) eigenvalue to a given * level of tolerance. @@ -808,12 +819,12 @@ double computeSpectralRad(const Teuchos::RCP > double computeSmallestMagEig(const Teuchos::RCP > & A, double tol, bool isHermitian=false,int numBlocks=5,int restart=0,int verbosity=0); -//! Type describing the type of diagonal to construct. +//! Type describing the type of diagonal to construct. typedef enum { Diagonal //! Specifies that just the diagonal is used , Lumped //! Specifies that row sum is used to form a diagonal , AbsRowSum //! Specifies that the \f$i^{th}\f$ diagonal entry is \f$\sum_j |A_{ij}|\f$ , BlkDiag //! Specifies that a block diagonal approximation is to be used - , NotDiag //! For user convenience, if Teko recieves this value, exceptions will be thrown + , NotDiag //! For user convenience, if Teko recieves this value, exceptions will be thrown } DiagonalType; /** Get a diagonal operator from a matrix. The mechanism for computing @@ -861,7 +872,9 @@ std::string getDiagonalName(const DiagonalType & dt); */ DiagonalType getDiagonalType(std::string name); +#ifdef TEKO_HAVE_EPETRA LinearOp probe(Teuchos::RCP &G, const LinearOp & Op); +#endif /** Get the one norm of the vector */ diff --git a/packages/teko/src/Tpetra/Teko_TpetraHelpers.cpp b/packages/teko/src/Tpetra/Teko_TpetraHelpers.cpp index 8e421e00030a..2ddd3e887750 100644 --- a/packages/teko/src/Tpetra/Teko_TpetraHelpers.cpp +++ b/packages/teko/src/Tpetra/Teko_TpetraHelpers.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,31 +32,24 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ #include "Teko_TpetraHelpers.hpp" +#include "Teko_ConfigDefs.hpp" -// Thyra Includes +#ifdef TEKO_HAVE_EPETRA #include "Thyra_EpetraLinearOp.hpp" -#include "Thyra_BlockedLinearOpBase.hpp" -#include "Thyra_DefaultMultipliedLinearOp.hpp" -#include "Thyra_DefaultDiagonalLinearOp.hpp" -#include "Thyra_DefaultZeroLinearOp.hpp" -#include "Thyra_DefaultBlockedLinearOp.hpp" #include "Thyra_EpetraThyraWrappers.hpp" -#include "Thyra_SpmdVectorBase.hpp" -#include "Thyra_SpmdVectorSpaceBase.hpp" -#include "Thyra_ScalarProdVectorSpaceBase.hpp" // Epetra includes #include "Epetra_Vector.h" @@ -65,17 +58,30 @@ #include "EpetraExt_ProductOperator.h" #include "EpetraExt_MatrixMatrix.h" -// Teko includes #include "Teko_EpetraOperatorWrapper.hpp" +#endif + +// Thyra Includes +#include "Thyra_BlockedLinearOpBase.hpp" +#include "Thyra_DefaultMultipliedLinearOp.hpp" +#include "Thyra_DefaultDiagonalLinearOp.hpp" +#include "Thyra_DefaultZeroLinearOp.hpp" +#include "Thyra_DefaultBlockedLinearOp.hpp" + +#include "Thyra_SpmdVectorBase.hpp" +#include "Thyra_SpmdVectorSpaceBase.hpp" +#include "Thyra_ScalarProdVectorSpaceBase.hpp" + +// Teko includes #include "Teko_Utilities.hpp" // Tpetra -#include "Thyra_TpetraLinearOp.hpp" -#include "Thyra_TpetraMultiVector.hpp" -#include "Tpetra_CrsMatrix.hpp" -#include "Tpetra_Vector.hpp" -#include "Thyra_TpetraThyraWrappers.hpp" -#include "TpetraExt_MatrixMatrix.hpp" +#include "Thyra_TpetraLinearOp.hpp" +#include "Thyra_TpetraMultiVector.hpp" +#include "Tpetra_CrsMatrix.hpp" +#include "Tpetra_Vector.hpp" +#include "Thyra_TpetraThyraWrappers.hpp" +#include "TpetraExt_MatrixMatrix.hpp" using Teuchos::RCP; using Teuchos::rcp; @@ -88,7 +94,7 @@ namespace TpetraHelpers { /** \brief Convert a Tpetra_Vector into a diagonal linear operator. * - * Convert a Tpetra_Vector into a diagonal linear operator. + * Convert a Tpetra_Vector into a diagonal linear operator. * * \param[in] tv Tpetra_Vector to use as the diagonal * \param[in] map Map related to the Tpetra_Vector @@ -101,7 +107,7 @@ const Teuchos::RCP > thyraDiagOp(const RCP > thyraVec // need a Thyra::VectorBase object = Thyra::createConstVector(tv,Thyra::createVectorSpace(rcpFromRef(map))); - Teuchos::RCP > op + Teuchos::RCP > op = Teuchos::rcp(new Thyra::DefaultDiagonalLinearOp(thyraVec)); op->setObjectLabel(lbl); return op; @@ -109,7 +115,7 @@ const Teuchos::RCP > thyraDiagOp(const RCP > thyraDiagOp(const RCP > thyraVec // need a Thyra::VectorBase object = Thyra::createVector(tv,Thyra::createVectorSpace(rcpFromRef(map))); - Teuchos::RCP > op + Teuchos::RCP > op = Teuchos::rcp(new Thyra::DefaultDiagonalLinearOp(thyraVec)); op->setObjectLabel(lbl); return op; } -/** \brief Fill a Thyra vector with the contents of an epetra vector. This prevents the +/** \brief Fill a Thyra vector with the contents of a tpetra vector. This prevents the * - * Fill a Thyra vector with the contents of an epetra vector. This prevents the need + * Fill a Thyra vector with the contents of a tpetra vector. This prevents the need * to reallocate memory using a create_MultiVector routine. It also allows an aritrary * Thyra vector to be filled. * * \param[in,out] spmdMV Multi-vector to be filled. - * \param[in] mv Epetra multi-vector to be used in filling the Thyra vector. - */ + * \param[in] mv Tpetra multi-vector to be used in filling the Thyra vector. + */ void fillDefaultSpmdMultiVector(Teuchos::RCP > & spmdMV, Teuchos::RCP > & tpetraMV) { // first get desired range and domain //const RCP > range = spmdMV->spmdSpace(); const RCP > range = Thyra::tpetraVectorSpace(tpetraMV->getMap()); - const RCP > domain + const RCP > domain = rcp_dynamic_cast >(spmdMV->domain()); TEUCHOS_ASSERT((size_t) domain->dim()==tpetraMV->getNumVectors()); // New local view of raw data - if(!tpetraMV->isConstantStride()) + if(!tpetraMV->isConstantStride()) TEUCHOS_TEST_FOR_EXCEPT(true); // ToDo: Implement views of non-contiguous mult-vectors! // Build the MultiVector @@ -159,12 +165,12 @@ void fillDefaultSpmdMultiVector(Teuchos::RCP > >(tpetraMV,"Tpetra::MultiVector",Teuchos::outArg(spmdMV)); } -/** \brief Build a vector of the dirchlet row indices. +/** \brief Build a vector of the dirchlet row indices. * * Build a vector of the dirchlet row indices. That is, record the global * index of any row that is all zeros except for $1$ on the diagonal. * - * \param[in] rowMap Map specifying which global indices this process examines + * \param[in] rowMap Map specifying which global indices this process examines * \param[in] mat Matrix to be examined * \param[in,out] indices Output list of indices corresponding to dirchlet rows (GIDs). */ @@ -218,10 +224,10 @@ void zeroMultiVectorRowIndices(Tpetra::MultiVector & mv,const std:: { LO colCnt = mv.getNumVectors(); std::vector::const_iterator itr; - + // loop over the indices to zero for(itr=zeroIndices.begin();itr!=zeroIndices.end();++itr) { - + // loop over columns for(int j=0;j > getTpetraCrsMatrix(const LinearOp & o return Teuchos::null; } - +#ifdef TEKO_HAVE_EPETRA RCP > epetraCrsMatrixToTpetra(const RCP A_e, const RCP > comm) { int* ptr; int* ind; double* val; - + int info = A_e->ExtractCrsDataPointers (ptr, ind, val); TEUCHOS_TEST_FOR_EXCEPTION(info!=0,std::logic_error, "Could not extract data from Epetra_CrsMatrix"); const LO numRows = A_e->Graph ().NumMyRows (); @@ -342,7 +348,7 @@ RCP > nonConstEpetraCrsMatrixToTpetra(const RCPExtractCrsDataPointers (ptr, ind, val); TEUCHOS_TEST_FOR_EXCEPTION(info!=0,std::logic_error, "Could not extract data from Epetra_CrsMatrix"); const LO numRows = A_e->Graph ().NumMyRows (); @@ -381,6 +387,7 @@ RCP > epetraMapToTpetra(const Epetra_Map eMap, const return rcp(new const Tpetra::Map(Teuchos::OrdinalTraits::invalid(),Teuchos::ArrayView(myGIDs),0,comm)); } +#endif // TEKO_HAVE_EPETRA } // end namespace TpetraHelpers } // end namespace Teko diff --git a/packages/teko/src/Tpetra/Teko_TpetraHelpers.hpp b/packages/teko/src/Tpetra/Teko_TpetraHelpers.hpp index 30fd92e35e56..3206fe0da44a 100644 --- a/packages/teko/src/Tpetra/Teko_TpetraHelpers.hpp +++ b/packages/teko/src/Tpetra/Teko_TpetraHelpers.hpp @@ -50,10 +50,14 @@ // stl includes #include +#include "Teko_ConfigDefs.hpp" + +#ifdef TEKO_HAVE_EPETRA // Epetra includes #include "Epetra_Operator.h" #include "Epetra_CrsMatrix.h" #include "Epetra_MultiVector.h" +#endif // Teuchos includes #include "Teuchos_RCP.hpp" @@ -64,7 +68,6 @@ #include "Thyra_DefaultSpmdMultiVector.hpp" // Tpetra -#include "Teko_ConfigDefs.hpp" #include "Tpetra_Map.hpp" #include "Tpetra_Vector.hpp" #include "Tpetra_CrsMatrix.hpp" @@ -75,14 +78,14 @@ typedef Teuchos::RCP > LinearOp; namespace TpetraHelpers { -/** \brief Fill a Thyra vector with the contents of an epetra vector. This prevents the +/** \brief Fill a Thyra vector with the contents of a Tpetra vector. This prevents the * - * Fill a Thyra vector with the contents of an epetra vector. This prevents the need + * Fill a Thyra vector with the contents of a Tpetra vector. This prevents the need * to reallocate memory using a create_MultiVector routine. It also allows an aritrary * Thyra vector to be filled. * * \param[in,out] spmdMV Multi-vector to be filled. - * \param[in] epetraMV Epetra multi-vector to be used in filling the Thyra vector. + * \param[in] tpetraMV Tpetra multi-vector to be used in filling the Thyra vector. */ void fillDefaultSpmdMultiVector(Teuchos::RCP > & spmdMV, Teuchos::RCP > & tpetraMV); @@ -150,6 +153,7 @@ bool isTpetraLinearOp(const Teko::LinearOp & op); */ Teuchos::RCP > getTpetraCrsMatrix(const Teko::LinearOp & op, ST *scalar, bool *transp); +#ifdef TEKO_HAVE_EPETRA /** Takes an Epetra_CrsMatrix (from Trilinos_Util::CrsMatrixGallery for example) and converts to a Tpetra::CrsMatrix * * \param[in] A_e An RCP pointer to the Epetra_CrsMatrix @@ -162,6 +166,7 @@ Teuchos::RCP > epetraCrsMatrixToTpetra(cons Teuchos::RCP > nonConstEpetraCrsMatrixToTpetra(const Teuchos::RCP A_e, const Teuchos::RCP > comm); Teuchos::RCP > epetraMapToTpetra(const Epetra_Map eMap, const Teuchos::RCP > comm); +#endif // TEKO_HAVE_EPETRA /** A class that zeros out chosen rows of a matrix-vector * product. @@ -170,16 +175,16 @@ class ZeroedOperator : public Tpetra::Operator { public: /** \brief Constructor for a ZeroedOperator. * - * Build a ZeroedOperator based on a particular Epetra_Operator and + * Build a ZeroedOperator based on a particular Tpetra_Operator and * a set of indices to zero out. These indices must be local to this * processor as specified by RowMap(). * * \param[in] zeroIndices Set of indices to zero out (must be local). - * \param[in] op Underlying epetra operator to use. + * \param[in] op Underlying Tpetra operator to use. */ ZeroedOperator(const std::vector & zeroIndices,const Teuchos::RCP > & op); - //! \name Functions required by Epetra_Operator + //! \name Functions required by Tpetra_Operator //@{ //! Do nothing destructor diff --git a/packages/teko/tests/CMakeLists.txt b/packages/teko/tests/CMakeLists.txt index 05998128574f..10f4b9f00e5c 100644 --- a/packages/teko/tests/CMakeLists.txt +++ b/packages/teko/tests/CMakeLists.txt @@ -6,18 +6,51 @@ TRIBITS_INCLUDE_DIRECTORIES(REQUIRED_DURING_INSTALLATION_TESTING ${CMAKE_CURRENT SET(HEADERS "") SET(SOURCES "") -APPEND_GLOB( HEADERS - ./src/Epetra/*.hpp - ./src/Tpetra/*.hpp - ./src/*.hpp +APPEND_GLOB( HEADERS + ${CMAKE_CURRENT_SOURCE_DIR}/src/Tpetra/*.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp ) -APPEND_GLOB( SOURCES - ./src/Epetra/*.cpp - ./src/Tpetra/*.cpp - ./src/*.cpp +APPEND_GLOB( SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/src/Tpetra/*.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp ) +IF(TEKO_HAVE_EPETRA) + APPEND_GLOB(HEADERS ./src/Epetra/*.hpp) + APPEND_GLOB(SOURCES ./src/Epetra/*.cpp) +ELSE() + LIST(REMOVE_ITEM SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/src/tLU2x2PreconditionerFactory.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/tLSCStablePreconditionerFactory.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/tAbsRowSum.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/tLSCHIntegrationTest.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/tJacobi2x2PreconditionerFactory.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/tPCDStrategy.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/tLSCIntegrationTest.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/tBlockJacobiPreconditionerFactory.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/LSCIntegrationTest.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/tLSCStabilized.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/tNeumannSeries.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/tParallelInverse.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/tSIMPLEPreconditionerFactory.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/tLumping.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/tBlockLowerTriInverseOp.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/tExplicitOps.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/tGraphLaplacian.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/tBlockUpperTriInverseOp.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/tDiagonalPreconditionerFactory.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/tStratimikosFactory.cpp + + ${CMAKE_CURRENT_SOURCE_DIR}/src/tBlockJacobiPreconditionerFactory_tpetra.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/tDiagonalPreconditionerFactory_tpetra.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/tExplicitOps_tpetra.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/Tpetra/tTpetraOperatorWrapper.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/Tpetra/tBlockedTpetraOperator.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/Tpetra/tStridedTpetraOperator.cpp + ) +ENDIF() + SET(UNIT_TEST_DRIVER "${PACKAGE_SOURCE_DIR}/tests/Teko_UnitTestMain.cpp") @@ -39,33 +72,35 @@ ELSE() SET(CUSTOM_MPI_PROCS "4") ENDIF() -TRIBITS_ADD_EXECUTABLE( - testdriver - SOURCES - ${HEADERS} - ${SOURCES} - ./Test_Utils.cpp - ./Test_Utils.hpp - ./testdriver.cpp - COMM mpi serial - ) +IF(TEKO_HAVE_EPETRA) + TRIBITS_ADD_EXECUTABLE( + testdriver + SOURCES + ${HEADERS} + ${SOURCES} + ./Test_Utils.cpp + ./Test_Utils.hpp + ./testdriver.cpp + COMM mpi serial + ) -TRIBITS_ADD_TEST( - testdriver - ARGS ${PARALLEL_ARGS_STRING} - NUM_MPI_PROCS ${CUSTOM_MPI_PROCS} - FAIL_REGULAR_EXPRESSION "Teko tests failed" - ) + TRIBITS_ADD_TEST( + testdriver + ARGS ${PARALLEL_ARGS_STRING} + NUM_MPI_PROCS ${CUSTOM_MPI_PROCS} + FAIL_REGULAR_EXPRESSION "Teko tests failed" + ) -TRIBITS_ADD_TEST( - testdriver - ARGS ${SERIAL_ARGS_STRING} - NUM_MPI_PROCS 1 - FAIL_REGULAR_EXPRESSION "Teko tests failed" - ) + TRIBITS_ADD_TEST( + testdriver + ARGS ${SERIAL_ARGS_STRING} + NUM_MPI_PROCS 1 + FAIL_REGULAR_EXPRESSION "Teko tests failed" + ) -IF (${PACKAGE_NAME}_DISABLE_LSCSTABALIZED_TPETRA_ALPAH_INV_D) - SET(testdriver_TARGET_DEFINES -DTEKO_DISABLE_LSCSTABALIZED_TPETRA_ALPAH_INV_D) + IF (${PACKAGE_NAME}_DISABLE_LSCSTABALIZED_TPETRA_ALPAH_INV_D) + SET(testdriver_TARGET_DEFINES -DTEKO_DISABLE_LSCSTABALIZED_TPETRA_ALPAH_INV_D) + ENDIF() ENDIF() TRIBITS_ADD_EXECUTABLE( @@ -113,16 +148,25 @@ IF(${PROJECT_NAME}_ENABLE_DEVELOPMENT_MODE) SET(TEST_DRIVER_DATA_FILES ${TEST_DRIVER_DATA_FILES} nsjac.mm - nsjac_1.mm + nsjac_1.mm ) ENDIF() -TRIBITS_COPY_FILES_TO_BINARY_DIR(testdriver_copyfiles +TRIBITS_COPY_FILES_TO_BINARY_DIR(testdriver_tpetra_copyfiles SOURCE_FILES ${TEST_DRIVER_DATA_FILES} SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/data" DEST_DIR "${CMAKE_CURRENT_BINARY_DIR}/data" - EXEDEPS testdriver testdriver_tpetra + EXEDEPS testdriver_tpetra + ) + +IF(TEKO_HAVE_EPETRA) + TRIBITS_COPY_FILES_TO_BINARY_DIR(testdriver_copyfiles + SOURCE_FILES ${TEST_DRIVER_DATA_FILES} + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/data" + DEST_DIR "${CMAKE_CURRENT_BINARY_DIR}/data" + EXEDEPS testdriver ) +ENDIF() TRIBITS_ADD_EXECUTABLE_AND_TEST( IterativePreconditionerFactory_test @@ -144,18 +188,20 @@ TRIBITS_ADD_EXECUTABLE_AND_TEST( NUM_MPI_PROCS 1 ) -TRIBITS_ADD_EXECUTABLE_AND_TEST( - StridedEpetraOperator_test - SOURCES - unit_tests/tStridedEpetraOperator.cpp - ${UNIT_TEST_DRIVER} - COMM serial mpi - ARGS ${PARALLEL_ARGS_STRING} - NUM_MPI_PROCS ${CUSTOM_MPI_PROCS} +IF(TEKO_HAVE_EPETRA) + TRIBITS_ADD_EXECUTABLE_AND_TEST( + StridedEpetraOperator_test + SOURCES + unit_tests/tStridedEpetraOperator.cpp + ${UNIT_TEST_DRIVER} + COMM serial mpi + ARGS ${PARALLEL_ARGS_STRING} + NUM_MPI_PROCS ${CUSTOM_MPI_PROCS} ) +ENDIF() TRIBITS_ADD_EXECUTABLE_AND_TEST( - RequestInterface_test + RequestInterface_test SOURCES unit_tests/tRequestInterface.cpp ${UNIT_TEST_DRIVER} @@ -165,7 +211,7 @@ TRIBITS_ADD_EXECUTABLE_AND_TEST( ) TRIBITS_ADD_EXECUTABLE_AND_TEST( - DiagnosticLinearOp_test + DiagnosticLinearOp_test SOURCES unit_tests/tDiagnosticLinearOp.cpp ${UNIT_TEST_DRIVER} @@ -175,7 +221,7 @@ TRIBITS_ADD_EXECUTABLE_AND_TEST( ) TRIBITS_ADD_EXECUTABLE_AND_TEST( - DiagonallyScaledPreconditioner + DiagonallyScaledPreconditioner SOURCES unit_tests/tDiagonallyScaledPreconditioner.cpp ${UNIT_TEST_DRIVER} @@ -185,7 +231,7 @@ TRIBITS_ADD_EXECUTABLE_AND_TEST( ) TRIBITS_ADD_EXECUTABLE_AND_TEST( - InverseFactoryOperator + InverseFactoryOperator SOURCES unit_tests/tInverseFactoryOperator.cpp ${UNIT_TEST_DRIVER} @@ -194,48 +240,50 @@ TRIBITS_ADD_EXECUTABLE_AND_TEST( NUM_MPI_PROCS 1 ) -TRIBITS_ADD_EXECUTABLE_AND_TEST( - ProbingFactory - SOURCES +IF(TEKO_HAVE_EPETRA) + TRIBITS_ADD_EXECUTABLE_AND_TEST( + ProbingFactory + SOURCES unit_tests/tProbingFactory.cpp ${UNIT_TEST_DRIVER} - COMM serial mpi - ARGS ${SERIAL_ARGS_STRING} - NUM_MPI_PROCS 1 + COMM serial mpi + ARGS ${SERIAL_ARGS_STRING} + NUM_MPI_PROCS 1 ) -TRIBITS_ADD_EXECUTABLE_AND_TEST( - DiagonalPreconditionerFactory - SOURCES + TRIBITS_ADD_EXECUTABLE_AND_TEST( + DiagonalPreconditionerFactory + SOURCES unit_tests/tDiagonalPreconditionerFactory.cpp ${UNIT_TEST_DRIVER} - COMM serial mpi - ARGS ${SERIAL_ARGS_STRING} - NUM_MPI_PROCS 2 + COMM serial mpi + ARGS ${SERIAL_ARGS_STRING} + NUM_MPI_PROCS 2 ) -TRIBITS_ADD_EXECUTABLE_AND_TEST( - StratimikosFactory - SOURCES - unit_tests/tStratimikosFactory.cpp + TRIBITS_ADD_EXECUTABLE_AND_TEST( + ExplicitOps + SOURCES + unit_tests/tExplicitOps.cpp ${UNIT_TEST_DRIVER} - COMM serial mpi - ARGS ${SERIAL_ARGS_STRING} - NUM_MPI_PROCS 1 + COMM serial mpi + ARGS ${SERIAL_ARGS_STRING} + NUM_MPI_PROCS 2 ) -TRIBITS_ADD_EXECUTABLE_AND_TEST( - ExplicitOps - SOURCES - unit_tests/tExplicitOps.cpp + TRIBITS_ADD_EXECUTABLE_AND_TEST( + StratimikosFactory + SOURCES + unit_tests/tStratimikosFactory.cpp ${UNIT_TEST_DRIVER} - COMM serial mpi - ARGS ${SERIAL_ARGS_STRING} - NUM_MPI_PROCS 2 + COMM serial mpi + ARGS ${SERIAL_ARGS_STRING} + NUM_MPI_PROCS 1 ) +ENDIF() TRIBITS_ADD_EXECUTABLE_AND_TEST( - ALOperator + ALOperator SOURCES unit_tests/tALOperator.cpp ${UNIT_TEST_DRIVER} @@ -244,15 +292,17 @@ TRIBITS_ADD_EXECUTABLE_AND_TEST( NUM_MPI_PROCS 1 ) -TRIBITS_ADD_EXECUTABLE_AND_TEST( - ModALPreconditioner - SOURCES - unit_tests/tModALPreconditioner.cpp - ${UNIT_TEST_DRIVER} - COMM serial mpi - ARGS ${SERIAL_ARGS_STRING} - NUM_MPI_PROCS 1 - ) +IF(TEKO_HAVE_EPETRA) + TRIBITS_ADD_EXECUTABLE_AND_TEST( + ModALPreconditioner + SOURCES + unit_tests/tModALPreconditioner.cpp + ${UNIT_TEST_DRIVER} + COMM serial mpi + ARGS ${SERIAL_ARGS_STRING} + NUM_MPI_PROCS 1 + ) +ENDIF() TRIBITS_ADD_EXECUTABLE_AND_TEST( ReorderBlocking @@ -265,7 +315,7 @@ TRIBITS_ADD_EXECUTABLE_AND_TEST( ) TRIBITS_ADD_EXECUTABLE_AND_TEST( - UtilitiesTests + UtilitiesTests SOURCES unit_tests/tUtilitiesTests.cpp ${UNIT_TEST_DRIVER} diff --git a/packages/teko/tests/Test_Utils.cpp b/packages/teko/tests/Test_Utils.cpp index 52855dfa9652..e64495de89e8 100644 --- a/packages/teko/tests/Test_Utils.cpp +++ b/packages/teko/tests/Test_Utils.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -63,16 +63,21 @@ #include "Thyra_DetachedVectorView.hpp" #include "Thyra_OperatorVectorTypes.hpp" #include "Thyra_VectorStdOps.hpp" -#include "Thyra_EpetraThyraWrappers.hpp" -#include "Thyra_EpetraLinearOp.hpp" + #include "Teko_Utilities.hpp" +#ifdef TEKO_HAVE_EPETRA // Epetra includes #include "Epetra_SerialComm.h" #include "Epetra_Map.h" #include "Epetra_CrsMatrix.h" +#include "Thyra_EpetraThyraWrappers.hpp" +#include "Thyra_EpetraLinearOp.hpp" + +#endif + #include "Tpetra_Vector.hpp" #include "Tpetra_Core.hpp" #include "Thyra_TpetraThyraWrappers.hpp" @@ -84,6 +89,7 @@ using namespace Teuchos; namespace Teko { namespace Test { +#ifdef TEKO_HAVE_EPETRA const RCP > build2x2(const Epetra_Comm & comm,double a,double b,double c,double d) { RCP map = rcp(new Epetra_Map(2,0,comm)); @@ -105,6 +111,7 @@ const RCP > build2x2(const Epetra_Comm & comm, return Thyra::epetraLinearOp(blk); } +#endif const RCP > build2x2(const RCP > comm,ST a,ST b,ST c,ST d) { @@ -128,18 +135,19 @@ const RCP > build2x2(const RCP(Thyra::tpetraVectorSpace(blk->getDomainMap()),Thyra::tpetraVectorSpace(blk->getRangeMap()),blk); } +#ifdef TEKO_HAVE_EPETRA const RCP > BlockVector(const Epetra_Vector & eu, const Epetra_Vector & ev, const RCP > & vs) { typedef RCP > Vector; - const RCP > pvs + const RCP > pvs = rcp_dynamic_cast >(vs); RCP meu = rcpFromRef(eu); RCP mev = rcpFromRef(ev); - const Vector u = Thyra::create_MultiVector(meu,pvs->getBlock(0)); - const Vector v = Thyra::create_MultiVector(mev,pvs->getBlock(1)); + const Vector u = Thyra::create_MultiVector(meu,pvs->getBlock(0)); + const Vector v = Thyra::create_MultiVector(mev,pvs->getBlock(1)); // build rhs: this is ugly...in 2 steps // (i). allocate space for rhs "Product" vector, this is the range of A @@ -153,19 +161,20 @@ const RCP > BlockVector(const Epetra_Vector return buildBlockedMultiVector(blocks); } +#endif const RCP > BlockVector(const Tpetra::Vector & tu, const Tpetra::Vector & tv, const RCP > & vs) { typedef RCP > Vector; - const RCP > pvs + const RCP > pvs = rcp_dynamic_cast >(vs); RCP > mtu = rcpFromRef(tu); RCP > mtv = rcpFromRef(tv); - const Vector u = Thyra::createConstMultiVector(mtu,pvs->getBlock(0)); - const Vector v = Thyra::createConstMultiVector(mtv,pvs->getBlock(1)); + const Vector u = Thyra::createConstMultiVector(mtu,pvs->getBlock(0)); + const Vector v = Thyra::createConstMultiVector(mtv,pvs->getBlock(1)); // build rhs: this is ugly...in 2 steps // (i). allocate space for rhs "Product" vector, this is the range of A @@ -184,7 +193,7 @@ void Print(std::ostream & os,const std::string & s,const RCP view(v->col(0)); - os << s << " = "; + os << s << " = "; for(int i=0;irange()->dim();i++) os << view[i] << " "; os << std::endl; } @@ -208,22 +217,22 @@ void HardExtract(std::ostream & os,const RCP > using Teuchos::rcp; using Teuchos::rcpFromRef; - int ncols = A->domain()->dim(); - int nrows = A->range()->dim(); + int ncols = A->domain()->dim(); + int nrows = A->range()->dim(); // print the matrix the hard way for(int i=0;i > u = Teko::Test::BuildIVector(i,A->range()); for(int j=0;j > ej = Teko::Test::BuildIVector(j,A->domain()); - const RCP > v = Thyra::createMember(A->range()); + const RCP > v = Thyra::createMember(A->range()); ::Thyra::apply(*A, Thyra::NOTRANS, *ej, v.ptr()); - + // this for some reason messes up valgrind (2/9/09) double value = A->range()->scalarProd(*u,*v); - os << value << " "; - } + os << value << " "; + } os << std::endl; } } @@ -242,7 +251,7 @@ const Teuchos::RCP > Add(double ax,const Teuchos: Thyra::linear_combination(Teuchos::tuple(ax,ay), Teuchos::tuple(Teuchos::ptrInArg(*x),Teuchos::ptrInArg(*y)),0.0,z.ptr()); - + return z; } @@ -256,6 +265,7 @@ double Difference(const Teuchos::RCP > & x, } // construct a diagonal matrix +#ifdef TEKO_HAVE_EPETRA const Teuchos::RCP > DiagMatrix(int cnt,double * vec,std::string label) { const RCP comm = rcp(new Epetra_SerialComm()); @@ -270,6 +280,7 @@ const Teuchos::RCP > DiagMatrix(int cnt,double // return thyra object return Thyra::epetraLinearOp(ptrF,label); } +#endif const Teuchos::RCP > DiagMatrix_tpetra(GO cnt,ST * vec,std::string label) { @@ -293,7 +304,9 @@ const Teuchos::RCP > DiagMatrix_tpetra(GO cnt, // declare static allocation std::list,std::string> > UnitTest::testList; +#ifdef TEKO_HAVE_EPETRA Teuchos::RCP UnitTest::comm; +#endif Teuchos::RCP > UnitTest::comm_tpetra; void UnitTest::AddTest(const Teuchos::RCP & ut,const std::string & name) @@ -302,6 +315,7 @@ void UnitTest::AddTest(const Teuchos::RCP & ut,const std::string & nam testList.push_back(std::make_pair(ut,name)); } +#ifdef TEKO_HAVE_EPETRA bool UnitTest::RunTests(int verbosity, std::ostream & stdstrm,std::ostream & failstrm) { bool allPassed = true; @@ -319,7 +333,7 @@ bool UnitTest::RunTests(int verbosity, std::ostream & stdstrm,std::ostream & fai if(isParallel && not (itr->first)->isParallel()) continue; stdstrm << "Running test \"" << itr->second << (verbosity>=1 ? "\"\n" : "\" ... "); - + // run the tests (itr->first)->initializeTest(); bool status = 0==(localfail = (itr->first)->runTest(verbosity,stdstrm,failstrm,localrun)); @@ -331,8 +345,8 @@ bool UnitTest::RunTests(int verbosity, std::ostream & stdstrm,std::ostream & fai stdstrm << Teko::Test::toString(status) << " (" << localrun << ")" << std::endl; else stdstrm << Teko::Test::toString(status) << " (" << localfail << ")" << std::endl; - } - + } + allPassed &= status; if(not status) numfailed+=localfail; count += localrun; @@ -340,12 +354,13 @@ bool UnitTest::RunTests(int verbosity, std::ostream & stdstrm,std::ostream & fai // output status stdstrm << std::endl; - stdstrm << "Tests Passed: " << count-numfailed + stdstrm << "Tests Passed: " << count-numfailed << ", Tests Failed: " << numfailed << std::endl; stdstrm << "(Incidently, you want no failures)" << std::endl; return allPassed; } +#endif bool UnitTest::RunTests_tpetra(int verbosity, std::ostream & stdstrm,std::ostream & failstrm) { @@ -364,7 +379,7 @@ bool UnitTest::RunTests_tpetra(int verbosity, std::ostream & stdstrm,std::ostrea if(isParallel && not (itr->first)->isParallel()) continue; stdstrm << "Running test \"" << itr->second << (verbosity>=1 ? "\"\n" : "\" ... "); - + // run the tests (itr->first)->initializeTest(); bool status = 0==(localfail = (itr->first)->runTest(verbosity,stdstrm,failstrm,localrun)); @@ -376,8 +391,8 @@ bool UnitTest::RunTests_tpetra(int verbosity, std::ostream & stdstrm,std::ostrea stdstrm << Teko::Test::toString(status) << " (" << localrun << ")" << std::endl; else stdstrm << Teko::Test::toString(status) << " (" << localfail << ")" << std::endl; - } - + } + allPassed &= status; if(not status) numfailed+=localfail; count += localrun; @@ -385,27 +400,31 @@ bool UnitTest::RunTests_tpetra(int verbosity, std::ostream & stdstrm,std::ostrea // output status stdstrm << std::endl; - stdstrm << "Tests Passed: " << count-numfailed + stdstrm << "Tests Passed: " << count-numfailed << ", Tests Failed: " << numfailed << std::endl; stdstrm << "(Incidently, you want no failures)" << std::endl; return allPassed; } +#ifdef TEKO_HAVE_EPETRA Teuchos::RCP UnitTest::GetComm() { return comm; } +#endif Teuchos::RCP > UnitTest::GetComm_tpetra() { return comm_tpetra; } +#ifdef TEKO_HAVE_EPETRA void UnitTest::SetComm(const Teuchos::RCP & c) { comm = c; } +#endif void UnitTest::SetComm_tpetra(const Teuchos::RCP > & c) { @@ -415,41 +434,45 @@ void UnitTest::SetComm_tpetra(const Teuchos::RCP > & c) void UnitTest::ClearTests() { testList.clear(); +#ifdef TEKO_HAVE_EPETRA comm = Teuchos::null; +#endif comm_tpetra = Teuchos::null; } +#ifdef TEKO_HAVE_EPETRA bool UnitTest::CheckParallelBools(bool myBool,int & failPID) { int myInt = myBool ? 1 : 0; std::vector bools(GetComm()->NumProc()); GetComm()->GatherAll(&myInt,&bools[0],1); - + failPID = -1; bool result = true; for(unsigned int i=0;i bools(GetComm_tpetra()->getSize()); - GetComm_tpetra()->gatherAll(1,&myInt,1,&bools[0]); - + GetComm_tpetra()->gatherAll(1,&myInt,GetComm_tpetra()->getSize(),&bools[0]); + failPID = -1; bool result = true; for(unsigned int i=0;i #include @@ -69,7 +72,9 @@ namespace Teko { namespace Test { // build a 2x2 matrix...only in serial +#ifdef TEKO_HAVE_EPETRA const Teuchos::RCP > build2x2(const Epetra_Comm & comm,double a,double b,double c,double d); +#endif const Teuchos::RCP > build2x2(const Teuchos::RCP > comm,ST a,ST b,ST c,ST d); // prints a vector, with string "s" as the name @@ -97,13 +102,17 @@ double Difference(const Teuchos::RCP > & x, const Teuchos::RCP > & y); // construct a diagonal matrix +#ifdef TEKO_HAVE_EPETRA const Teuchos::RCP > DiagMatrix(int cnt,double * vec,std::string label=""); +#endif const Teuchos::RCP > DiagMatrix_tpetra(GO cnt,ST * vec,std::string label=""); // 2-Vector +#ifdef TEKO_HAVE_EPETRA const Teuchos::RCP > BlockVector(const Epetra_Vector & u, const Epetra_Vector & v, const Teuchos::RCP > & vs); +#endif const Teuchos::RCP > BlockVector(const Tpetra::Vector & u, const Tpetra::Vector & v, const Teuchos::RCP > & vs); @@ -116,22 +125,33 @@ class UnitTest { virtual bool isParallel() const = 0; static void AddTest(const Teuchos::RCP & ut,const std::string & name); +#ifdef TEKO_HAVE_EPETRA static bool RunTests(int verbosity, std::ostream & stdstrm,std::ostream & failstrm); +#endif static bool RunTests_tpetra(int verbosity, std::ostream & stdstrm,std::ostream & failstrm); +#ifdef TEKO_HAVE_EPETRA static Teuchos::RCP GetComm(); +#endif static Teuchos::RCP > GetComm_tpetra(); + +#ifdef TEKO_HAVE_EPETRA static void SetComm(const Teuchos::RCP & c); +#endif static void SetComm_tpetra(const Teuchos::RCP > & c); static void ClearTests(); protected: static std::list,std::string> > testList; +#ifdef TEKO_HAVE_EPETRA static Teuchos::RCP comm; +#endif static Teuchos::RCP > comm_tpetra; +#ifdef TEKO_HAVE_EPETRA static bool CheckParallelBools(bool myBool,int & failPID); +#endif static bool CheckParallelBools_tpetra(bool myBool,int & failPID); }; diff --git a/packages/teko/tests/src/Tpetra/tBlockedTpetraOperator.cpp b/packages/teko/tests/src/Tpetra/tBlockedTpetraOperator.cpp index 410a89082f6b..913fd3bedbba 100644 --- a/packages/teko/tests/src/Tpetra/tBlockedTpetraOperator.cpp +++ b/packages/teko/tests/src/Tpetra/tBlockedTpetraOperator.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -67,11 +67,10 @@ #include "Tpetra_Vector.hpp" #include "Tpetra_CrsMatrix.hpp" -// TriUtils includes -#include "Trilinos_Util_CrsMatrixGallery.h" - #include "tBlockedTpetraOperator.hpp" +#include "Trilinos_Util_CrsMatrixGallery.h" + #include "Teko_BlockedTpetraOperator.hpp" #include "Teko_TpetraHelpers.hpp" @@ -92,7 +91,7 @@ void tBlockedTpetraOperator::buildBlockGIDs(std::vector > & gids { LO numLocal = map.getLocalNumElements(); LO numHalf = numLocal/2; - numHalf += ((numHalf % 2 == 0) ? 0 : 1); + numHalf += ((numHalf % 2 == 0) ? 0 : 1); gids.clear(); gids.resize(3); @@ -100,7 +99,7 @@ void tBlockedTpetraOperator::buildBlockGIDs(std::vector > & gids std::vector & blk0 = gids[0]; std::vector & blk1 = gids[1]; std::vector & blk2 = gids[2]; - + // loop over global IDs: treat first block as strided GO gid = -1; for(LO i=0;i > & gids TEUCHOS_ASSERT(LO(blk0.size()+blk1.size()+blk2.size())==numLocal); } -void tBlockedTpetraOperator::initializeTest() +void tBlockedTpetraOperator::initializeTest() { tolerance_ = 1e-14; } @@ -137,7 +136,7 @@ int tBlockedTpetraOperator::runTest(int verbosity,std::ostream & stdstrm,std::os Teko_TEST_MSG(stdstrm,1," \"vector_constr\" ... PASSED"," \"vector_constr\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; - totalrun++; + totalrun++; status = test_reorder(verbosity,failstrm,0); Teko_TEST_MSG(stdstrm,1," \"reorder(flat reorder)\" ... PASSED"," \"reorder(flat reorder)\" ... FAILED"); @@ -146,14 +145,14 @@ int tBlockedTpetraOperator::runTest(int verbosity,std::ostream & stdstrm,std::os totalrun++; status = test_reorder(verbosity,failstrm,1); - Teko_TEST_MSG(stdstrm,1," \"reorder(composite reorder = " << 1 + Teko_TEST_MSG(stdstrm,1," \"reorder(composite reorder = " << 1 << ")\" ... PASSED"," \"reorder(composite reorder)\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_reorder(verbosity,failstrm,2); - Teko_TEST_MSG(stdstrm,1," \"reorder(composite reorder = " << 2 + Teko_TEST_MSG(stdstrm,1," \"reorder(composite reorder = " << 2 << ")\" ... PASSED"," \"reorder(composite reorder)\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; @@ -180,7 +179,7 @@ bool tBlockedTpetraOperator::test_vector_constr(int verbosity,std::ostream & os) TEST_MSG("\n tBlockedTpetraOperator::test_vector_constr: " << "Running on " << comm_epetra.NumProc() << " processors"); - // pick + // pick int nx = 5;// * comm_epetra.NumProc(); int ny = 5;// * comm_epetra.NumProc(); @@ -291,7 +290,7 @@ bool tBlockedTpetraOperator::test_reorder(int verbosity,std::ostream & os,int to TEST_MSG("\n tBlockedTpetraOperator::test_reorder" << tstr << ": " << "Running on " << comm_epetra.NumProc() << " processors"); - // pick + // pick int nx = 5;//3 * 25 * comm_epetra.NumProc(); int ny = 5;//3 * 50 * comm_epetra.NumProc(); @@ -315,7 +314,7 @@ bool tBlockedTpetraOperator::test_reorder(int verbosity,std::ostream & os,int to Teko::TpetraHelpers::BlockedTpetraOperator flatShell(vars,A,"Af"); Teko::TpetraHelpers::BlockedTpetraOperator reorderShell(vars,A,"Ar"); - + Teko::BlockReorderManager brm; switch (total) { case 0: diff --git a/packages/teko/tests/src/Tpetra/tBlockingTpetra.cpp b/packages/teko/tests/src/Tpetra/tBlockingTpetra.cpp index e95b1b4f5a3c..cd3c022c637e 100644 --- a/packages/teko/tests/src/Tpetra/tBlockingTpetra.cpp +++ b/packages/teko/tests/src/Tpetra/tBlockingTpetra.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -67,9 +67,6 @@ #include "Tpetra_Vector.hpp" #include "Tpetra_CrsMatrix.hpp" -// TriUtils includes -#include "Trilinos_Util_CrsMatrixGallery.h" - #include "tBlockingTpetra.hpp" #include "Teko_BlockingTpetra.hpp" @@ -88,7 +85,7 @@ using Thyra::LinearOpBase; using Thyra::createMember; using Thyra::LinearOpTester; -void tBlockingTpetra::initializeTest() +void tBlockingTpetra::initializeTest() { tolerance_ = 1e-14; } @@ -97,7 +94,7 @@ void buildGIDs(std::vector > & gids,const Tpetra::Map { LO numLocal = map.getLocalNumElements(); LO numHalf = numLocal/2; - numHalf += ((numHalf % 2 == 0) ? 0 : 1); + numHalf += ((numHalf % 2 == 0) ? 0 : 1); gids.clear(); gids.resize(3); @@ -105,7 +102,7 @@ void buildGIDs(std::vector > & gids,const Tpetra::Map std::vector & blk0 = gids[0]; std::vector & blk1 = gids[1]; std::vector & blk2 = gids[2]; - + // loop over global IDs: treat first block as strided GO gid = -1; for(LO i=0;i= 10) { - Teko_TEST_MSG(failstrm,0,"tBlockingTpetra...PASSED","tBlockingTpetra...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"tBlockingTpetra...PASSED","tBlockingTpetra...FAILED"); } else {// Normal Operating Procedures (NOP) - Teko_TEST_MSG(failstrm,0,"...PASSED","tBlockingTpetra...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"...PASSED","tBlockingTpetra...FAILED"); } return failcount; @@ -193,17 +190,17 @@ bool tBlockingTpetra::test_buildMaps(int verbosity,std::ostream & os) TEST_ASSERT(map0.first->getLocalNumElements()==gid0.size() && map0.second->getLocalNumElements()==gid0.size(), " tBlockingTpetra::test_buildMaps (" << Teko::Test::toString(status) << "): " - << " Checking map size: first=" << map0.first->getLocalNumElements() + << " Checking map size: first=" << map0.first->getLocalNumElements() << ", second="<< map0.second->getLocalNumElements() << ", gid="<< gid0.size()); TEST_ASSERT(map1.first->getLocalNumElements()==gid1.size() && map0.second->getLocalNumElements()==gid0.size(), " tBlockingTpetra::test_buildMaps (" << Teko::Test::toString(status) << "): " - << " Checking map size: first=" << map1.first->getLocalNumElements() + << " Checking map size: first=" << map1.first->getLocalNumElements() << ", second="<< map1.second->getLocalNumElements() << ", gid="<< gid1.size()); TEST_ASSERT(map2.first->getLocalNumElements()==gid2.size() && map0.second->getLocalNumElements()==gid0.size(), " tBlockingTpetra::test_buildMaps (" << Teko::Test::toString(status) << "): " - << " Checking map size: first=" << map2.first->getLocalNumElements() + << " Checking map size: first=" << map2.first->getLocalNumElements() << ", second="<< map2.second->getLocalNumElements() << ", gid="<< gid2.size()); @@ -233,37 +230,37 @@ bool tBlockingTpetra::test_buildMaps(int verbosity,std::ostream & os) // check contiguous and global maps test = true; for(size_t i=0;igetLocalNumElements();i++) { - GO gid = globalMaps[0]->getGlobalElement(i); - GO cid = contigMaps[0]->getGlobalElement(i); - + GO gid = globalMaps[0]->getGlobalElement(i); + GO cid = contigMaps[0]->getGlobalElement(i); + test &= gid==gid0[i]; test &= cid==(GO)(i+contigMaps[0]->getMinGlobalIndex()); } - TEST_ASSERT(test, + TEST_ASSERT(test, " tBlockingTpetra::test_buildMaps (" << Teko::Test::toString(status) << "): " << "checked that block maps were internally consitent"); test = true; for(size_t i=0;igetLocalNumElements();i++) { - GO gid = globalMaps[1]->getGlobalElement(i); - GO cid = contigMaps[1]->getGlobalElement(i); - + GO gid = globalMaps[1]->getGlobalElement(i); + GO cid = contigMaps[1]->getGlobalElement(i); + test &= gid==gid1[i]; test &= cid==(GO)(i+contigMaps[1]->getMinGlobalIndex()); } - TEST_ASSERT(test, + TEST_ASSERT(test, " tBlockingTpetra::test_buildMaps (" << Teko::Test::toString(status) << "): " << "checked that block maps were internally consitent"); test = true; for(size_t i=0;igetLocalNumElements();i++) { - GO gid = globalMaps[2]->getGlobalElement(i); - GO cid = contigMaps[2]->getGlobalElement(i); - + GO gid = globalMaps[2]->getGlobalElement(i); + GO cid = contigMaps[2]->getGlobalElement(i); + test &= gid==gid2[i]; test &= cid==(GO)(i+contigMaps[2]->getMinGlobalIndex()); } - TEST_ASSERT(test, + TEST_ASSERT(test, " tBlockingTpetra::test_buildMaps (" << Teko::Test::toString(status) << "): " << "checked that block maps were internally consitent"); @@ -299,8 +296,8 @@ bool tBlockingTpetra::test_one2many(int verbosity,std::ostream & os) std::vector > > subExport(3); for(int i=0;i<3;i++) { Blocking::ImExPair imex = Blocking::buildExportImport(*map,maps[i]); - subImport[i] = imex.first; - subExport[i] = imex.second; + subImport[i] = imex.first; + subExport[i] = imex.second; } TEST_MSG("\n tBlockingTpetra::test_one2many: Building sub vectors"); @@ -309,7 +306,7 @@ bool tBlockingTpetra::test_one2many(int verbosity,std::ostream & os) TEST_MSG("\n tBlockingTpetra::test_one2many: Performing data copy"); Blocking::one2many(subVectors,*v,subImport); - + // just assume it works! :) return allPassed; @@ -345,8 +342,8 @@ bool tBlockingTpetra::test_many2one(int verbosity,std::ostream & os) std::vector > > subExport(3); for(int i=0;i<3;i++) { Blocking::ImExPair imex = Blocking::buildExportImport(*map,maps[i]); - subImport[i] = imex.first; - subExport[i] = imex.second; + subImport[i] = imex.first; + subExport[i] = imex.second; } TEST_MSG("\n tBlockingTpetra::test_many2one: Building sub vectors"); @@ -369,7 +366,7 @@ bool tBlockingTpetra::test_many2one(int verbosity,std::ostream & os) one->norm2(Teuchos::ArrayView(norm2,4)); one->update(1.0,*v,-1.0); - + ST diff[4] = {0,0,0,0}; ST max=-1.0,maxn=-1,maxn2=-1; ST norm[4] = {0,0,0,0}; @@ -383,9 +380,9 @@ bool tBlockingTpetra::test_many2one(int verbosity,std::ostream & os) TEST_ASSERT(maxn>0.0," tBlockingTpetra::test_many2one maxn>0? maxn = " << maxn); TEST_ASSERT(max<=tolerance_, " tBlockingTpetra::test_many2one (" << Teko::Test::toString(status) << "): " - << "norm must be better than the tolerance ( " << max << " <=? " << tolerance_ + << "norm must be better than the tolerance ( " << max << " <=? " << tolerance_ << " maxn = " << maxn << ", maxn2 = " << maxn2 << " )"); - + return allPassed; } @@ -404,15 +401,15 @@ bool tBlockingTpetra::test_buildSubBlock(int verbosity,std::ostream & os) std::vector indices(numProc*2); std::vector values(numProc*2); RCP > A = Tpetra::createCrsMatrix (rcpFromRef(map),numProc*2); - for(std::size_t i=0;igetRowMap()->getGlobalElement(0); + grid = A->getRowMap()->getGlobalElement(0); A->replaceGlobalValues(grid,Teuchos::ArrayView(indices),Teuchos::ArrayView(values)); // build local row 1 @@ -420,7 +417,7 @@ bool tBlockingTpetra::test_buildSubBlock(int verbosity,std::ostream & os) values[2*i+0] = (mypid+1.0)*3.0+i; values[2*i+1] = (mypid+1.0)*4.0+i; } - grid = A->getRowMap()->getGlobalElement(1); + grid = A->getRowMap()->getGlobalElement(1); A->replaceGlobalValues(grid,Teuchos::ArrayView(indices),Teuchos::ArrayView(values)); A->fillComplete(); diff --git a/packages/teko/tests/src/Tpetra/tInterlacedTpetra.cpp b/packages/teko/tests/src/Tpetra/tInterlacedTpetra.cpp index f1e45c928751..66864288bb8f 100644 --- a/packages/teko/tests/src/Tpetra/tInterlacedTpetra.cpp +++ b/packages/teko/tests/src/Tpetra/tInterlacedTpetra.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -67,9 +67,6 @@ #include "Tpetra_Vector.hpp" #include "Tpetra_CrsMatrix.hpp" -// TriUtils includes -#include "Trilinos_Util_CrsMatrixGallery.h" - #include "tInterlacedTpetra.hpp" #include "Teko_InterlacedTpetra.hpp" @@ -88,7 +85,7 @@ using Thyra::LinearOpBase; using Thyra::createMember; using Thyra::LinearOpTester; -void tInterlacedTpetra::initializeTest() +void tInterlacedTpetra::initializeTest() { tolerance_ = 1e-14; } @@ -102,41 +99,41 @@ int tInterlacedTpetra::runTest(int verbosity,std::ostream & stdstrm,std::ostream failstrm << "tInterlacedTpetra"; status = test_buildSubMaps_num(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"buildSubMaps_num\" ... PASSED"," \"buildSubMaps_num\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"buildSubMaps_num\" ... PASSED"," \"buildSubMaps_num\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_buildSubMaps_vec(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"buildSubMaps_vec\" ... PASSED"," \"buildSubMaps_vec\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"buildSubMaps_vec\" ... PASSED"," \"buildSubMaps_vec\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_buildMaps(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"buildMaps\" ... PASSED"," \"buildMaps\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"buildMaps\" ... PASSED"," \"buildMaps\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_one2many(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"one2many\" ... PASSED"," \"one2many\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"one2many\" ... PASSED"," \"one2many\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_many2one(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"many2one\" ... PASSED"," \"many2one\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"many2one\" ... PASSED"," \"many2one\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = allTests; if(verbosity >= 10) { - Teko_TEST_MSG(failstrm,0,"tInterlacedTpetra...PASSED","tInterlacedTpetra...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"tInterlacedTpetra...PASSED","tInterlacedTpetra...FAILED"); } else {// Normal Operating Procedures (NOP) - Teko_TEST_MSG(failstrm,0,"...PASSED","tInterlacedTpetra...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"...PASSED","tInterlacedTpetra...FAILED"); } return failcount; @@ -155,13 +152,13 @@ bool tInterlacedTpetra::test_buildSubMaps_num(int verbosity,std::ostream & os) int numVars = 3; // build a set of submaps: this should fail - Strided::buildSubMaps(globals,numVars,comm,subMaps); + Strided::buildSubMaps(globals,numVars,comm,subMaps); TEST_ASSERT(false, "\n tInterlacedTpetra::test_buildSubMaps_num: " << toString(status) << ": " "buildSubMaps(int,vector > >) did not throw " "with incorrect parameters"); - } + } catch(...) { TEST_MSG( "\n tInterlacedTpetra::test_buildSubMaps_num: " @@ -174,7 +171,7 @@ bool tInterlacedTpetra::test_buildSubMaps_num(int verbosity,std::ostream & os) int numVars = 3; // build a set of submaps: this should fail - Strided::buildSubMaps(globals,numVars,comm,subMaps); + Strided::buildSubMaps(globals,numVars,comm,subMaps); TEST_EQUALITY(subMaps.size(),3, "\n tInterlacedTpetra::test_buildSubMaps_num: " << toString(status) << ": " @@ -221,7 +218,7 @@ bool tInterlacedTpetra::test_buildSubMaps_num(int verbosity,std::ostream & os) TEST_ASSERT(cur, "\n tInterlacedTpetra::test_buildSubMaps_num: " << toString(status) << ": " << "testing that third map is created correctly"); - } + } catch(...) { TEST_ASSERT(false, "\n tInterlacedTpetra::test_buildSubMaps_num: " << toString(status) << ": " @@ -244,18 +241,18 @@ bool tInterlacedTpetra::test_buildSubMaps_vec(int verbosity,std::ostream & os) GO globals = 15; std::vector vars(3); - vars[0] = 2; - vars[1] = 1; - vars[2] = 3; + vars[0] = 2; + vars[1] = 1; + vars[2] = 3; // build a set of submaps: this should fail - Strided::buildSubMaps(globals,vars,comm,subMaps); + Strided::buildSubMaps(globals,vars,comm,subMaps); TEST_ASSERT(false, "\n tInterlacedTpetra::test_buildSubMaps_vec: " << toString(status) << ": " "buildSubMaps(int,vector > >) did not throw " "with incorrect parameters"); - } + } catch(...) { TEST_MSG( "\n tInterlacedTpetra::test_buildSubMaps_vec: " @@ -267,12 +264,12 @@ bool tInterlacedTpetra::test_buildSubMaps_vec(int verbosity,std::ostream & os) GO globals = 18; std::vector vars(3); - vars[0] = 2; - vars[1] = 1; - vars[2] = 3; + vars[0] = 2; + vars[1] = 1; + vars[2] = 3; // build a set of submaps: this should fail - Strided::buildSubMaps(globals,vars,comm,subMaps); + Strided::buildSubMaps(globals,vars,comm,subMaps); TEST_EQUALITY(subMaps.size(),3, "\n tInterlacedTpetra::test_buildSubMaps_vec: " << toString(status) << ": " @@ -293,7 +290,7 @@ bool tInterlacedTpetra::test_buildSubMaps_vec(int verbosity,std::ostream & os) << "testing that first map has correct number of global elements ( " << subMaps[0].second->getGlobalNumElements() << " == " << 6 << " ?)"); gids = subMaps[0].second->getLocalElementList(); - cur = (gids[0] == 0 && gids[1] == 1 + cur = (gids[0] == 0 && gids[1] == 1 && gids[2] == 6 && gids[3] == 7 && gids[4] ==12 && gids[5] ==13); TEST_ASSERT(cur, @@ -323,7 +320,7 @@ bool tInterlacedTpetra::test_buildSubMaps_vec(int verbosity,std::ostream & os) TEST_ASSERT(cur, "\n tInterlacedTpetra::test_buildSubMaps_vec: " << toString(status) << ": " << "testing that third map is created correctly"); - } + } catch(...) { TEST_ASSERT(false, "\n tInterlacedTpetra::test_buildSubMaps_vec: " << toString(status) << ": " @@ -400,32 +397,32 @@ bool tInterlacedTpetra::test_buildMaps(int verbosity,std::ostream & os) test = true; for(size_t i=0;igetLocalNumElements();i+=2) { int block; - GO gid = globalMaps[0]->getGlobalElement(i); - GO cid = contigMaps[0]->getGlobalElement(i); - + GO gid = globalMaps[0]->getGlobalElement(i); + GO cid = contigMaps[0]->getGlobalElement(i); + block = gid/3; test &= cid==2*block; - GO gidp1 = globalMaps[0]->getGlobalElement(i+1); - GO cidp1 = contigMaps[0]->getGlobalElement(i+1); + GO gidp1 = globalMaps[0]->getGlobalElement(i+1); + GO cidp1 = contigMaps[0]->getGlobalElement(i+1); block = (gidp1-1)/3; test &= cidp1==2*block+1; } - TEST_ASSERT(test, + TEST_ASSERT(test, " tInterlacedTpetra::test_buildMaps (" << Teko::Test::toString(status) << "): " << "checked that block maps were internally consitent"); test = true; for(size_t i=0;igetLocalNumElements();i++) { int block; - GO gid = globalMaps[1]->getGlobalElement(i); - GO cid = contigMaps[1]->getGlobalElement(i); - + GO gid = globalMaps[1]->getGlobalElement(i); + GO cid = contigMaps[1]->getGlobalElement(i); + block = (gid-2)/3; test &= cid==block; } - TEST_ASSERT(test, + TEST_ASSERT(test, " tInterlacedTpetra::test_buildMaps (" << Teko::Test::toString(status) << "): " << "checked that block maps were internally consitent"); @@ -467,7 +464,7 @@ bool tInterlacedTpetra::test_one2many(int verbosity,std::ostream & os) TEST_MSG("\n tInterlacedTpetra::test_one2many: Performing data copy"); Strided::one2many(subVectors,*v,subImport); - + // just assume it works! :) return allPassed; @@ -518,7 +515,7 @@ bool tInterlacedTpetra::test_many2one(int verbosity,std::ostream & os) Strided::many2one(*one,cSubVectors,subExport); one->update(1.0,*v,-1.0); - + ST diff[4] = {0,0,0,0}; ST max=0.0,maxn=0; ST norm[4] = {0,0,0,0}; @@ -531,7 +528,7 @@ bool tInterlacedTpetra::test_many2one(int verbosity,std::ostream & os) TEST_ASSERT(max<=tolerance_, " tInterlacedTpetra::test_buildMaps (" << Teko::Test::toString(status) << "): " << "norm must be better than the tolerance ( " << max << " <=? " << tolerance_ << " maxn = " << maxn << " )"); - + return allPassed; } diff --git a/packages/teko/tests/src/Tpetra/tStridedTpetraOperator.cpp b/packages/teko/tests/src/Tpetra/tStridedTpetraOperator.cpp index 1a173ce84628..35ba76936cc7 100644 --- a/packages/teko/tests/src/Tpetra/tStridedTpetraOperator.cpp +++ b/packages/teko/tests/src/Tpetra/tStridedTpetraOperator.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -67,11 +67,10 @@ #include "Tpetra_Vector.hpp" #include "Tpetra_CrsMatrix.hpp" -// TriUtils includes -#include "Trilinos_Util_CrsMatrixGallery.h" - #include "tStridedTpetraOperator.hpp" +#include "Trilinos_Util_CrsMatrixGallery.h" + #include "Teko_StridedTpetraOperator.hpp" #include "Teko_TpetraHelpers.hpp" #include "Teko_ConfigDefs.hpp" @@ -89,7 +88,7 @@ using Thyra::LinearOpBase; using Thyra::createMember; using Thyra::LinearOpTester; -void tStridedTpetraOperator::initializeTest() +void tStridedTpetraOperator::initializeTest() { tolerance_ = 1e-14; } @@ -112,7 +111,7 @@ int tStridedTpetraOperator::runTest(int verbosity,std::ostream & stdstrm,std::os Teko_TEST_MSG(stdstrm,1," \"vector_constr\" ... PASSED"," \"vector_constr\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; - totalrun++; + totalrun++; status = test_reorder(verbosity,failstrm,0); Teko_TEST_MSG(stdstrm,1," \"reorder(flat reorder)\" ... PASSED"," \"reorder(flat reorder)\" ... FAILED"); @@ -121,14 +120,14 @@ int tStridedTpetraOperator::runTest(int verbosity,std::ostream & stdstrm,std::os totalrun++; status = test_reorder(verbosity,failstrm,1); - Teko_TEST_MSG(stdstrm,1," \"reorder(composite reorder = " << 1 + Teko_TEST_MSG(stdstrm,1," \"reorder(composite reorder = " << 1 << ")\" ... PASSED"," \"reorder(composite reorder)\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_reorder(verbosity,failstrm,2); - Teko_TEST_MSG(stdstrm,1," \"reorder(composite reorder = " << 2 + Teko_TEST_MSG(stdstrm,1," \"reorder(composite reorder = " << 2 << ")\" ... PASSED"," \"reorder(composite reorder)\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; @@ -155,7 +154,7 @@ bool tStridedTpetraOperator::test_numvars_constr(int verbosity,std::ostream & os TEST_MSG("\n tStridedTpetraOperator::test_numvars: " << "Running on " << comm_epetra.NumProc() << " processors"); - // pick + // pick int nx = 3 * comm_epetra.NumProc();//3 * 25 * comm_epetra.NumProc(); int ny = 3 * comm_epetra.NumProc();//3 * 50 * comm_epetra.NumProc(); @@ -262,7 +261,7 @@ bool tStridedTpetraOperator::test_vector_constr(int verbosity,std::ostream & os) TEST_MSG("\n tStridedTpetraOperator::test_vector_constr: " << "Running on " << comm_epetra.NumProc() << " processors"); - // pick + // pick int nx = 3 * comm_epetra.NumProc();//3 * 25 * comm_epetra.NumProc(); int ny = 3 * comm_epetra.NumProc();//3 * 50 * comm_epetra.NumProc(); @@ -328,7 +327,7 @@ bool tStridedTpetraOperator::test_vector_constr(int verbosity,std::ostream & os) shell.RebuildOps(); // test the operator against a lot of random vectors - + numtests = 10; max = 0.0; min = 1.0; @@ -374,7 +373,7 @@ bool tStridedTpetraOperator::test_reorder(int verbosity,std::ostream & os,int to TEST_MSG("\n tStridedTpetraOperator::test_reorder" << tstr << ": " << "Running on " << comm_epetra.NumProc() << " processors"); - // pick + // pick int nx = 3 * comm_epetra.NumProc();//3 * 25 * comm_epetra.NumProc(); int ny = 3 * comm_epetra.NumProc();//3 * 50 * comm_epetra.NumProc(); @@ -395,7 +394,7 @@ bool tStridedTpetraOperator::test_reorder(int verbosity,std::ostream & os,int to Teko::TpetraHelpers::StridedTpetraOperator flatShell(3,A,"Af"); Teko::TpetraHelpers::StridedTpetraOperator reorderShell(3,A,"Ar"); - + Teko::BlockReorderManager brm; switch (total) { case 0: diff --git a/packages/teko/tests/src/Tpetra/tTpetraThyraConverter.cpp b/packages/teko/tests/src/Tpetra/tTpetraThyraConverter.cpp index 5d126c9ee5e8..3a376c95dcdc 100644 --- a/packages/teko/tests/src/Tpetra/tTpetraThyraConverter.cpp +++ b/packages/teko/tests/src/Tpetra/tTpetraThyraConverter.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -127,7 +127,7 @@ double compareTpetraMVToThyra(const Tpetra::MultiVector & eX, for(int j=0;j diff ? maxerr : diff; } @@ -146,7 +146,7 @@ double compareTpetraMVToThyra(const Tpetra::MultiVector & eX, TEST_MSG(" " << "stride = " << stride); TEST_MSG(" " << "checking elements"); - int thyraIndex = 0; + int thyraIndex = 0; for(size_t i=0;i & eX, return maxerr; } - const RCP > prodVS = prodX->productSpace(); + const RCP > prodVS = prodX->productSpace(); TEST_MSG(" compareTpetraMVToThyra - recurse (" << indexStart << ", " << indexEnd << " )"); // loop over each subblock, comparing the thyra to tpetra @@ -176,7 +176,7 @@ double compareTpetraMVToThyra(const Tpetra::MultiVector & eX, GO size = prodVS->getBlock(i)->dim(); // run comparison routine on relavant values - ST val = compareTpetraMVToThyra(eX,prodX->getMultiVectorBlock(i),verbosity,os,indexStart,indexStart+size); + ST val = compareTpetraMVToThyra(eX,prodX->getMultiVectorBlock(i),verbosity,os,indexStart,indexStart+size); // shift starting index indexStart+= size; @@ -205,35 +205,35 @@ int tTpetraThyraConverter::runTest(int verbosity,std::ostream & stdstrm,std::ost failstrm << "tTpetraThyraConverter"; status = test_blockThyraToTpetra(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"blockThyraToTpetra\" ... PASSED"," \"blockThyraToTpetra\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"blockThyraToTpetra\" ... PASSED"," \"blockThyraToTpetra\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_single_blockThyraToTpetra(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"single_blockThyraToTpetra\" ... PASSED"," \"single_blockThyraToTpetra\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"single_blockThyraToTpetra\" ... PASSED"," \"single_blockThyraToTpetra\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_blockTpetraToThyra(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"blockTpetraToThyra\" ... PASSED"," \"blockTpetraToThyra\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"blockTpetraToThyra\" ... PASSED"," \"blockTpetraToThyra\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_single_blockTpetraToThyra(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"single_blockTpetraToThyra\" ... PASSED"," \"single_blockTpetraToThyra\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"single_blockTpetraToThyra\" ... PASSED"," \"single_blockTpetraToThyra\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = allTests; if(verbosity >= 10) { - Teko_TEST_MSG(failstrm,0,"tTpetraThyraConverter...PASSED","tTpetraThyraConverter...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"tTpetraThyraConverter...PASSED","tTpetraThyraConverter...FAILED"); } else {// Normal Operating Procedures (NOP) - Teko_TEST_MSG(failstrm,0,"...PASSED","tTpetraThyraConverter...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"...PASSED","tTpetraThyraConverter...FAILED"); } return failcount; @@ -257,8 +257,8 @@ bool tTpetraThyraConverter::test_blockThyraToTpetra(int verbosity,std::ostream & // build vector space const RCP > vs - = Thyra::defaultSpmdVectorSpace(tComm,myElmts,glElmts); - const RCP > prodVS = Thyra::productVectorSpace(vs,2); + = Thyra::defaultSpmdVectorSpace(tComm,myElmts,glElmts); + const RCP > prodVS = Thyra::productVectorSpace(vs,2); // from the vector space build an tpetra map TEST_MSG("\n 1. creating Map"); @@ -266,7 +266,7 @@ bool tTpetraThyraConverter::test_blockThyraToTpetra(int verbosity,std::ostream & // create a vector const RCP > tX = Thyra::createMembers(prodVS,5); - Thyra::randomize(-10.0,10.0,tX.ptr()); + Thyra::randomize(-10.0,10.0,tX.ptr()); TEST_MSG(" 2. creating MultiVector"); @@ -275,13 +275,13 @@ bool tTpetraThyraConverter::test_blockThyraToTpetra(int verbosity,std::ostream & Teko::TpetraHelpers::blockThyraToTpetra(tX,*eX); TEST_ASSERT(eX!=Teuchos::null, - "\n tTpetraThyraConverter::test_blockThyraToTpetra " << toString(status) + "\n tTpetraThyraConverter::test_blockThyraToTpetra " << toString(status) << ": blockThyraToTpetra returns not null"); TEST_MSG(" 4. comparing Tpetra to Thyra"); ST result = compareTpetraMVToThyra(*eX,tX,verbosity,os); TEST_ASSERT(result==0.0, - "\n tTpetraThyraConverter::test_blockThyraToTpetra: " << toString(status) + "\n tTpetraThyraConverter::test_blockThyraToTpetra: " << toString(status) << ": Tpetra MV is compared to Thyra MV (maxdiff = " << result << ")"); return allPassed; @@ -305,25 +305,25 @@ bool tTpetraThyraConverter::test_single_blockThyraToTpetra(int verbosity,std::os // build vector space const RCP > vs - = Thyra::defaultSpmdVectorSpace(tComm,myElmts,glElmts); + = Thyra::defaultSpmdVectorSpace(tComm,myElmts,glElmts); // from the vector space build an tpetra map const RCP > map = Teko::TpetraHelpers::thyraVSToTpetraMap(*vs,tComm); // create a vector const RCP > tX = Thyra::createMembers(vs,5); - Thyra::randomize(-10.0,10.0,tX.ptr()); + Thyra::randomize(-10.0,10.0,tX.ptr()); const RCP > eX = rcp(new Tpetra::MultiVector(map,5)); Teko::TpetraHelpers::blockThyraToTpetra(tX,*eX); TEST_ASSERT(eX!=Teuchos::null, - "\n tTpetraThyraConverter::test_single_blockThyraToTpetra: " << toString(status) + "\n tTpetraThyraConverter::test_single_blockThyraToTpetra: " << toString(status) << ": blockThyraToTpetra returns not null"); ST result = compareTpetraMVToThyra(*eX,tX,verbosity,os); TEST_ASSERT(result==0.0, - "\n tTpetraThyraConverter::test_single_blockThyraToTpetra: " << toString(status) + "\n tTpetraThyraConverter::test_single_blockThyraToTpetra: " << toString(status) << ": Tpetra MV is compared to Thyra MV (maxdiff = " << result << ")"); return allPassed; @@ -336,7 +336,7 @@ bool tTpetraThyraConverter::test_blockTpetraToThyra(int verbosity,std::ostream & const Teuchos::Comm & Comm = *GetComm_tpetra(); const RCP > tComm = Thyra::convertTpetraToThyraComm(rcpFromRef(Comm)); - + // get process information int numProc = Comm.getSize(); // int myPID = Comm.MyPID(); @@ -347,13 +347,13 @@ bool tTpetraThyraConverter::test_blockTpetraToThyra(int verbosity,std::ostream & // build vector space const RCP > vs - = Thyra::defaultSpmdVectorSpace(tComm,myElmts,glElmts); - const RCP > prodVS = Thyra::productVectorSpace(vs,2); - + = Thyra::defaultSpmdVectorSpace(tComm,myElmts,glElmts); + const RCP > prodVS = Thyra::productVectorSpace(vs,2); + // from the vector space build an tpetra map const RCP > map = Teko::TpetraHelpers::thyraVSToTpetraMap(*prodVS,tComm); - - // build an tpetra multivector + + // build an tpetra multivector Tpetra::MultiVector eX(map,3); eX.randomize(); @@ -363,7 +363,7 @@ bool tTpetraThyraConverter::test_blockTpetraToThyra(int verbosity,std::ostream & ST result = compareTpetraMVToThyra(eX,tX,verbosity,os); TEST_ASSERT(result==0.0, - "\n tTpetraThyraConverter::test_blockTpetraToThyra: " << toString(status) + "\n tTpetraThyraConverter::test_blockTpetraToThyra: " << toString(status) << ": Tpetra MV is compared to Thyra MV (maxdiff = " << result << ")"); return allPassed; @@ -376,7 +376,7 @@ bool tTpetraThyraConverter::test_single_blockTpetraToThyra(int verbosity, std::o const Teuchos::Comm & Comm = *GetComm_tpetra(); const RCP > tComm = Thyra::convertTpetraToThyraComm(rcpFromRef(Comm)); - + // get process information int numProc = Comm.getSize(); // int myPID = Comm.MyPID(); @@ -387,13 +387,13 @@ bool tTpetraThyraConverter::test_single_blockTpetraToThyra(int verbosity, std::o // build vector space const RCP > vs - = Thyra::defaultSpmdVectorSpace(tComm,myElmts,glElmts); + = Thyra::defaultSpmdVectorSpace(tComm,myElmts,glElmts); const RCP > prodVS = vs; - + // from the vector space build an tpetra map const RCP > map = Teko::TpetraHelpers::thyraVSToTpetraMap(*prodVS,tComm); - - // build an tpetra multivector + + // build an tpetra multivector int vecs = 10; Tpetra::MultiVector eX(map,vecs); eX.randomize(); @@ -403,12 +403,12 @@ bool tTpetraThyraConverter::test_single_blockTpetraToThyra(int verbosity, std::o Teko::TpetraHelpers::blockTpetraToThyra(eX,tX.ptr()); TEST_ASSERT(tX!=Teuchos::null, - "\n tTpetraThyraConverter::test_single_blockTpetraToThyra: " << toString(status) + "\n tTpetraThyraConverter::test_single_blockTpetraToThyra: " << toString(status) << ": blockTpetraToThyra returns not null"); ST result = compareTpetraMVToThyra(eX,tX,verbosity,os); TEST_ASSERT(result==0.0, - "\n tTpetraThyraConverter::test_single_blockTpetraToThyra: " << toString(status) + "\n tTpetraThyraConverter::test_single_blockTpetraToThyra: " << toString(status) << ": Tpetra MV is compared to Thyra MV (maxdiff = " << result << ")"); return allPassed; diff --git a/packages/teko/tests/src/tAbsRowSum_tpetra.cpp b/packages/teko/tests/src/tAbsRowSum_tpetra.cpp index 62f49e98dcc2..1b0f29f16ec7 100644 --- a/packages/teko/tests/src/tAbsRowSum_tpetra.cpp +++ b/packages/teko/tests/src/tAbsRowSum_tpetra.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -57,9 +57,6 @@ #include "Thyra_DefaultDiagonalLinearOp.hpp" #include "Thyra_LinearOpTester.hpp" -// TriUtils includes -#include "Trilinos_Util_CrsMatrixGallery.h" - // Test-rig #include "Test_Utils.hpp" @@ -85,23 +82,23 @@ int tAbsRowSum_tpetra::runTest(int verbosity,std::ostream & stdstrm,std::ostream failstrm << "tAbsRowSum_tpetra"; status = test_absRowSum(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"absRowSum\" ... PASSED"," \"absRowSum\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"absRowSum\" ... PASSED"," \"absRowSum\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_invAbsRowSum(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"invAbsRowSum\" ... PASSED"," \"invAbsRowSum\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"invAbsRowSum\" ... PASSED"," \"invAbsRowSum\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = allTests; if(verbosity >= 10) { - Teko_TEST_MSG(failstrm,0,"tAbsRowSum_tpetra...PASSED","tAbsRowSum_tpetra...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"tAbsRowSum_tpetra...PASSED","tAbsRowSum_tpetra...FAILED"); } else {// Normal Operating Procedures (NOP) - Teko_TEST_MSG(failstrm,0,"...PASSED","tAbsRowSum_tpetra...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"...PASSED","tAbsRowSum_tpetra...FAILED"); } return failcount; diff --git a/packages/teko/tests/src/tBlockJacobiPreconditionerFactory_tpetra.hpp b/packages/teko/tests/src/tBlockJacobiPreconditionerFactory_tpetra.hpp index c09088234b96..bc93bac46225 100644 --- a/packages/teko/tests/src/tBlockJacobiPreconditionerFactory_tpetra.hpp +++ b/packages/teko/tests/src/tBlockJacobiPreconditionerFactory_tpetra.hpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ diff --git a/packages/teko/tests/src/tBlockLowerTriInverseOp_tpetra.cpp b/packages/teko/tests/src/tBlockLowerTriInverseOp_tpetra.cpp index f837dcf4b221..5fb54128e63f 100644 --- a/packages/teko/tests/src/tBlockLowerTriInverseOp_tpetra.cpp +++ b/packages/teko/tests/src/tBlockLowerTriInverseOp_tpetra.cpp @@ -181,23 +181,23 @@ int tBlockLowerTriInverseOp_tpetra::runTest(int verbosity,std::ostream & stdstrm failstrm << "tLowerTriInverseOp"; status = test_apply(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"apply\" ... PASSED"," \"apply\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"apply\" ... PASSED"," \"apply\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_alphabeta(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"alphabeta\" ... PASSED"," \"alphabeta\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"alphabeta\" ... PASSED"," \"alphabeta\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = allTests; if(verbosity >= 10) { - Teko_TEST_MSG(failstrm,0,"tLowerTriInverseOp...PASSED","tLowerTriInverseOp...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"tLowerTriInverseOp...PASSED","tLowerTriInverseOp...FAILED"); } else {// Normal Operatoring Procedures (NOP) - Teko_TEST_MSG(failstrm,0,"...PASSED","tLowerTriInverseOp...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"...PASSED","tLowerTriInverseOp...FAILED"); } return failcount; diff --git a/packages/teko/tests/src/tBlockUpperTriInverseOp_tpetra.cpp b/packages/teko/tests/src/tBlockUpperTriInverseOp_tpetra.cpp index 60ed8383ed7d..ac2bd4dd4fc6 100644 --- a/packages/teko/tests/src/tBlockUpperTriInverseOp_tpetra.cpp +++ b/packages/teko/tests/src/tBlockUpperTriInverseOp_tpetra.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -147,7 +147,7 @@ void tBlockUpperTriInverseOp_tpetra::initializeTest() invA_->setBlock(0,1,blk); // build 0,2 matrix - blk = build2x2op(comm, 0.303571428571429, -0.271103896103896, + blk = build2x2op(comm, 0.303571428571429, -0.271103896103896, 0.069642857142857, 0.090746753246753); invA_->setBlock(0,2,blk); @@ -163,7 +163,7 @@ void tBlockUpperTriInverseOp_tpetra::initializeTest() invA_->setBlock(1,2,blk); // build 2,2 matrix - blk = build2x2op(comm, -0.016666666666667, 0.150000000000000, + blk = build2x2op(comm, -0.016666666666667, 0.150000000000000, 0.116666666666667, -0.050000000000000); invA_->setBlock(2,2,blk); invDiag_.push_back(blk); @@ -180,23 +180,23 @@ int tBlockUpperTriInverseOp_tpetra::runTest(int verbosity,std::ostream & stdstrm failstrm << "tUpperTriInverseOp"; status = test_apply(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"apply\" ... PASSED"," \"apply\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"apply\" ... PASSED"," \"apply\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_alphabeta(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"alphabeta\" ... PASSED"," \"alphabeta\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"alphabeta\" ... PASSED"," \"alphabeta\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = allTests; if(verbosity >= 10) { - Teko_TEST_MSG(failstrm,0,"tUpperTriInverseOp...PASSED","tUpperTriInverseOp...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"tUpperTriInverseOp...PASSED","tUpperTriInverseOp...FAILED"); } else {// Normal Operatoring Procedures (NOP) - Teko_TEST_MSG(failstrm,0,"...PASSED","tUpperTriInverseOp...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"...PASSED","tUpperTriInverseOp...FAILED"); } return failcount; @@ -211,9 +211,9 @@ bool tBlockUpperTriInverseOp_tpetra::test_alphabeta(int verbosity,std::ostream & BlockedLinearOp U = getUpperTriBlocks(A_); LinearOp invTri = createBlockUpperTriInverseOp(U,invDiag_); - RCP > src = Thyra::createMember(invA_->domain()); - RCP > dste = Thyra::createMember(invA_->range()); - + RCP > src = Thyra::createMember(invA_->domain()); + RCP > dste = Thyra::createMember(invA_->range()); + Thyra::randomize(-10,10,src.ptr()); Thyra::randomize(-10,10,dste.ptr()); @@ -226,7 +226,7 @@ bool tBlockUpperTriInverseOp_tpetra::test_alphabeta(int verbosity,std::ostream & MultiVector dste_mv = dste; MultiVector dstn_mv = dstn; - + applyOp(invA_,src,dste_mv,3.2,-1.9); applyOp(invTri,src,dstn_mv,3.2,-1.9); @@ -262,8 +262,8 @@ bool tBlockUpperTriInverseOp_tpetra::test_apply(int verbosity,std::ostream & os) TEST_ASSERT(result, std::endl << " tBlockUpperTriInverseOp_tpetra::test_apply " << ": Comparing implicitly generated operator to exact operator"); - if(not result || verbosity>=10) - os << ss.str(); + if(not result || verbosity>=10) + os << ss.str(); return allPassed; } diff --git a/packages/teko/tests/src/tDiagonalPreconditionerFactory_tpetra.hpp b/packages/teko/tests/src/tDiagonalPreconditionerFactory_tpetra.hpp index 57538b370627..868cfa7bdf51 100644 --- a/packages/teko/tests/src/tDiagonalPreconditionerFactory_tpetra.hpp +++ b/packages/teko/tests/src/tDiagonalPreconditionerFactory_tpetra.hpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -51,8 +51,6 @@ #include "Thyra_LinearOpBase.hpp" #include "Teko_PreconditionerFactory.hpp" -#include "Epetra_SerialComm.h" - #include #include "Test_Utils.hpp" @@ -73,7 +71,7 @@ class tDiagonalPreconditionerFactory_tpetra : public UnitTest { virtual void initializeTest(); virtual int runTest(int verbosity,std::ostream & stdstrm,std::ostream & failstrm,int & totalrun); virtual bool isParallel() const { return true; } - + void buildParameterList(int blocksize); bool test_createPrec(int verbosity,std::ostream & os,int blocksize); @@ -82,7 +80,7 @@ class tDiagonalPreconditionerFactory_tpetra : public UnitTest { protected: double tolerance_; - Teuchos::ParameterList List_; + Teuchos::ParameterList List_; DiagonalPreconditionerFactory *fact; DiagonalPrecondState *pstate; LinearOp pop; diff --git a/packages/teko/tests/src/tGraphLaplacian_tpetra.cpp b/packages/teko/tests/src/tGraphLaplacian_tpetra.cpp index 2ef3b717c9ca..1f9f36b47011 100644 --- a/packages/teko/tests/src/tGraphLaplacian_tpetra.cpp +++ b/packages/teko/tests/src/tGraphLaplacian_tpetra.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -78,9 +78,9 @@ Teuchos::RCP > stencil(const Teuchos::Comm & { Teuchos::RCP > map = rcp(new Tpetra::Map(5,0,rcpFromRef(comm))); Teuchos::RCP > mat = rcp(new Tpetra::CrsMatrix(map,6)); - // KDD 8/2019: The value 6 above is needed because this test inserts + // KDD 8/2019: The value 6 above is needed because this test inserts // three indices twice into row 4 of the matrix. - // Tpetra is robust enough to correctly handle the double insertion. + // Tpetra is robust enough to correctly handle the double insertion. // But if this double insertion is, in fact, an error, the 6 can probably // be changed to 3. Note that this test doesn't insert any nonzeros into // row 0 of the matrix. @@ -88,23 +88,23 @@ Teuchos::RCP > stencil(const Teuchos::Comm & // arrays for indicies and values GO indicies[3]; ST values[3] = {1,1,1}; - + // build linear system indicies[0] = 0; indicies[1] = 1; indicies[2] = 3; - mat->insertGlobalValues(1,Teuchos::ArrayView(indicies,3),Teuchos::ArrayView(values,3)); + mat->insertGlobalValues(1,Teuchos::ArrayView(indicies,3),Teuchos::ArrayView(values,3)); indicies[0] = 4; - mat->insertGlobalValues(2,Teuchos::ArrayView(indicies,1),Teuchos::ArrayView(values,1)); + mat->insertGlobalValues(2,Teuchos::ArrayView(indicies,1),Teuchos::ArrayView(values,1)); indicies[0] = 1; indicies[1] = 3; - mat->insertGlobalValues(3,Teuchos::ArrayView(indicies,2),Teuchos::ArrayView(values,2)); + mat->insertGlobalValues(3,Teuchos::ArrayView(indicies,2),Teuchos::ArrayView(values,2)); indicies[0] = 1; indicies[1] = 2; indicies[2] = 4; - mat->insertGlobalValues(4,Teuchos::ArrayView(indicies,3),Teuchos::ArrayView(values,3)); + mat->insertGlobalValues(4,Teuchos::ArrayView(indicies,3),Teuchos::ArrayView(values,3)); indicies[0] = 0; indicies[1] = 1; indicies[2] = 3; values[2] = 0.0; - mat->insertGlobalValues(4,Teuchos::ArrayView(indicies,3),Teuchos::ArrayView(values,3)); + mat->insertGlobalValues(4,Teuchos::ArrayView(indicies,3),Teuchos::ArrayView(values,3)); mat->fillComplete(); @@ -151,23 +151,23 @@ int tGraphLaplacian_tpetra::runTest(int verbosity,std::ostream & stdstrm,std::os failstrm << "tGraphLaplacian_tpetra"; status = test_single_array(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"single_array\" ... PASSED"," \"single_array\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"single_array\" ... PASSED"," \"single_array\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_multi_array(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"multi_array\" ... PASSED"," \"multi_array\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"multi_array\" ... PASSED"," \"multi_array\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = allTests; if(verbosity >= 10) { - Teko_TEST_MSG(failstrm,0,"tGraphLaplacian_tpetra...PASSED","tGraphLaplacian_tpetra...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"tGraphLaplacian_tpetra...PASSED","tGraphLaplacian_tpetra...FAILED"); } else {// Normal Operatoring Procedures (NOP) - Teko_TEST_MSG(failstrm,0,"...PASSED","tGraphLaplacian_tpetra...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"...PASSED","tGraphLaplacian_tpetra...FAILED"); } return failcount; @@ -186,8 +186,8 @@ bool tGraphLaplacian_tpetra::compareMatrix(const Tpetra::CrsMatrix for(size_t j=0;j > gl = buildGraphLaplacian(3,&points[0],*sten); TEST_ASSERT(compareMatrix(*gl,"test_single_array",verbosity,os), - "\n tGraphLaplacian_tpetra::test_single_array: " << toString(status) << "\n" + "\n tGraphLaplacian_tpetra::test_single_array: " << toString(status) << "\n" << " checked single array laplacian matrix"); return allPassed; @@ -241,14 +241,14 @@ bool tGraphLaplacian_tpetra::test_multi_array(int verbosity,std::ostream & os) RCP > gl = buildGraphLaplacian(&x[0],&y[0],&z[0],1,*sten); TEST_ASSERT(compareMatrix(*gl,"test_multi_array",verbosity,os), - "\n tGraphLaplacian_tpetra::test_multi_array: " << toString(status) << "\n" + "\n tGraphLaplacian_tpetra::test_multi_array: " << toString(status) << "\n" << " checked multi array laplacian matrix, unit stride"); // build the graph laplacian RCP > gl2 = buildGraphLaplacian(&points[0],&points[1],&points[2],3,*sten); TEST_ASSERT(compareMatrix(*gl2,"test_multi_array",verbosity,os), - "\n tGraphLaplacian_tpetra::test_multi_array: " << toString(status) << "\n" + "\n tGraphLaplacian_tpetra::test_multi_array: " << toString(status) << "\n" << " checked multi array laplacian matrix, 3 stride"); return allPassed; diff --git a/packages/teko/tests/src/tJacobi2x2PreconditionerFactory_tpetra.cpp b/packages/teko/tests/src/tJacobi2x2PreconditionerFactory_tpetra.cpp index 7a88c4f23ebb..69079a61b743 100644 --- a/packages/teko/tests/src/tJacobi2x2PreconditionerFactory_tpetra.cpp +++ b/packages/teko/tests/src/tJacobi2x2PreconditionerFactory_tpetra.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -56,23 +56,24 @@ #include "Teuchos_RCP.hpp" // Thyra includes -#include "Thyra_EpetraLinearOp.hpp" #include "Thyra_LinearOpBase.hpp" #include "Thyra_DefaultBlockedLinearOp.hpp" #include "Thyra_DefaultIdentityLinearOp.hpp" #include "Thyra_DefaultZeroLinearOp.hpp" #include "Thyra_DefaultLinearOpSource.hpp" #include "Thyra_DefaultPreconditioner.hpp" -#include "Thyra_EpetraThyraWrappers.hpp" #include "Thyra_DefaultMultipliedLinearOp.hpp" #include "Thyra_DefaultScaledAdjointLinearOp.hpp" #include "Thyra_PreconditionerFactoryHelpers.hpp" #include "Thyra_VectorStdOps.hpp" + +#include "Teko_Utilities.hpp" + +#ifdef TEKO_HAVE_EPETRA #include "Thyra_MLPreconditionerFactory.hpp" #include "Thyra_IfpackPreconditionerFactory.hpp" #include "Thyra_AmesosLinearOpWithSolveFactory.hpp" - -#include "Teko_Utilities.hpp" +#endif // Tpetra includes #include "Tpetra_Map.hpp" @@ -83,7 +84,7 @@ #include // This whole test rig is based on inverting the matrix -// +// // [ 1 2 1 -1 ] // A = [ 2 1 -3 1 ] // [ 1 -3 0 0 ] @@ -122,32 +123,32 @@ void tJacobi2x2PreconditionerFactory_tpetra::initializeTest() indices[1] = 1; // build F matrix - row0[0] = 1.0; row0[1] = 2.0; - row1[0] = 2.0; row1[1] = 1.0; + row0[0] = 1.0; row0[1] = 2.0; + row1[0] = 2.0; row1[1] = 1.0; ptrF->insertGlobalValues(0,Teuchos::ArrayView(indices),Teuchos::ArrayView(row0)); ptrF->insertGlobalValues(1,Teuchos::ArrayView(indices),Teuchos::ArrayView(row1)); ptrF->fillComplete(); F_ = Thyra::tpetraLinearOp(Thyra::tpetraVectorSpace(ptrF->getDomainMap()),Thyra::tpetraVectorSpace(ptrF->getRangeMap()),ptrF); // build D matrix - row0[0] = 1.0; row0[1] = -3.0; - row1[0] = -1.0; row1[1] = 1.0; + row0[0] = 1.0; row0[1] = -3.0; + row1[0] = -1.0; row1[1] = 1.0; ptrD->insertGlobalValues(0,Teuchos::ArrayView(indices),Teuchos::ArrayView(row0)); ptrD->insertGlobalValues(1,Teuchos::ArrayView(indices),Teuchos::ArrayView(row1)); ptrD->fillComplete(); D_ = Thyra::tpetraLinearOp(Thyra::tpetraVectorSpace(ptrD->getDomainMap()),Thyra::tpetraVectorSpace(ptrD->getRangeMap()),ptrD); - + // build G matrix - row0[0] = 1.0; row0[1] = -1.0; - row1[0] = -3.0; row1[1] = 1.0; + row0[0] = 1.0; row0[1] = -1.0; + row1[0] = -3.0; row1[1] = 1.0; ptrG->insertGlobalValues(0,Teuchos::ArrayView(indices),Teuchos::ArrayView(row0)); ptrG->insertGlobalValues(1,Teuchos::ArrayView(indices),Teuchos::ArrayView(row1)); ptrG->fillComplete(); G_ = Thyra::tpetraLinearOp(Thyra::tpetraVectorSpace(ptrG->getDomainMap()),Thyra::tpetraVectorSpace(ptrG->getRangeMap()),ptrG); // build C matrix - row0[0] = 9.0; row0[1] = 2.0; - row1[0] = 6.0; row1[1] = 5.0; + row0[0] = 9.0; row0[1] = 2.0; + row1[0] = 6.0; row1[1] = 5.0; ptrC->insertGlobalValues(0,Teuchos::ArrayView(indices),Teuchos::ArrayView(row0)); ptrC->insertGlobalValues(1,Teuchos::ArrayView(indices),Teuchos::ArrayView(row1)); ptrC->fillComplete(); @@ -181,59 +182,59 @@ int tJacobi2x2PreconditionerFactory_tpetra::runTest(int verbosity,std::ostream & failstrm << "tJacobi2x2PreconditionerFactory_tpetra"; status = test_createPrec(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"createPrec\" ... PASSED"," \"createPrec\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"createPrec\" ... PASSED"," \"createPrec\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_initializePrec(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"initializePrec\" ... PASSED"," \"initializePrec\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"initializePrec\" ... PASSED"," \"initializePrec\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_uninitializePrec(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"uninitializePrec\" ... PASSED"," \"uninitializePrec\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"uninitializePrec\" ... PASSED"," \"uninitializePrec\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_isCompatable(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"isCompatable\" ... PASSED"," \"isCompatable\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"isCompatable\" ... PASSED"," \"isCompatable\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_identity(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"identity\" ... PASSED"," \"identity\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"identity\" ... PASSED"," \"identity\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_diagonal(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"diagonal\" ... PASSED"," \"diagonal\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"diagonal\" ... PASSED"," \"diagonal\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_result(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"result\" ... PASSED"," \"result\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"result\" ... PASSED"," \"result\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_initializeFromParameterList(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"initializeFromParameterList\" ... PASSED"," \"initializeFromParameterList\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"initializeFromParameterList\" ... PASSED"," \"initializeFromParameterList\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = allTests; if(verbosity >= 10) { - Teko_TEST_MSG(failstrm,0,"tJacobi2x2PreconditionedFactory...PASSED","tJacobi2x2PreconditionedFactory...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"tJacobi2x2PreconditionedFactory...PASSED","tJacobi2x2PreconditionedFactory...FAILED"); } else {// Normal Operatoring Procedures (NOP) - Teko_TEST_MSG(failstrm,0,"...PASSED","tJacobi2x2PreconditionedFactory...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"...PASSED","tJacobi2x2PreconditionedFactory...FAILED"); } return failcount; @@ -264,7 +265,7 @@ bool tJacobi2x2PreconditionerFactory_tpetra::test_initializePrec(int verbosity,s bool allPassed = true; // Build block2x2 preconditioner - RCP > precFactory + RCP > precFactory = rcp(new JacobiPreconditionerFactory(invF_,invC_)); RCP > prec = precFactory->createPrec(); @@ -325,7 +326,7 @@ bool tJacobi2x2PreconditionerFactory_tpetra::test_identity(int verbosity,std::os LinearOp C = Thyra::identity(invC_->range()); LinearOp A = Thyra::block2x2(F,G,D,C); - RCP > precFactory + RCP > precFactory = rcp(new JacobiPreconditionerFactory(F,C)); RCP > prec = Thyra::prec(*precFactory,A); @@ -336,7 +337,7 @@ bool tJacobi2x2PreconditionerFactory_tpetra::test_identity(int verbosity,std::os // construct a couple of vectors Tpetra::Vector ea(map),eb(map); const RCP > x = BlockVector(ea,eb,A->domain()); - const RCP > y = Thyra::createMembers(A->range(),1); + const RCP > y = Thyra::createMembers(A->range(),1); // test vector [0 1 1 3] ea.replaceGlobalValue(0,0.0); @@ -345,8 +346,8 @@ bool tJacobi2x2PreconditionerFactory_tpetra::test_identity(int verbosity,std::os eb.replaceGlobalValue(1,3.0); Thyra::apply(*precOp,Thyra::NOTRANS,*x,y.ptr()); status = ((diff = Teko::Test::Difference(y,x)/Thyra::norm_2(*x->col(0)))=10) { - os << std::endl << " tJacobi2x2PreconditionerFactory_tpetra::test_identity " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " + if(not status || verbosity>=10) { + os << std::endl << " tJacobi2x2PreconditionerFactory_tpetra::test_identity " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " << diff << ")" << std::endl; os << " "; Print(os,"x",x); os << " "; Print(os,"y",y); @@ -360,8 +361,8 @@ bool tJacobi2x2PreconditionerFactory_tpetra::test_identity(int verbosity,std::os eb.replaceGlobalValue(1,9.0); Thyra::apply(*precOp,Thyra::NOTRANS,*x,y.ptr()); status = ((diff = Teko::Test::Difference(y,x)/Thyra::norm_2(*x->col(0)))=10) { - os << std::endl << " tJacobi2x2PreconditionerFactory_tpetra::test_identity " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " + if(not status || verbosity>=10) { + os << std::endl << " tJacobi2x2PreconditionerFactory_tpetra::test_identity " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " << diff << ")" << std::endl; os << " "; Print(os,"x",x); os << " "; Print(os,"y",y); @@ -375,8 +376,8 @@ bool tJacobi2x2PreconditionerFactory_tpetra::test_identity(int verbosity,std::os eb.replaceGlobalValue(1,-5.0); Thyra::apply(*precOp,Thyra::NOTRANS,*x,y.ptr()); status = ((diff = Teko::Test::Difference(y,x)/Thyra::norm_2(*x->col(0)))=10) { - os << std::endl << " tJacobi2x2PreconditionerFactory_tpetra::test_identity " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " + if(not status || verbosity>=10) { + os << std::endl << " tJacobi2x2PreconditionerFactory_tpetra::test_identity " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " << diff << ")" << std::endl; os << " "; Print(os,"x",x); os << " "; Print(os,"y",y); @@ -390,8 +391,8 @@ bool tJacobi2x2PreconditionerFactory_tpetra::test_identity(int verbosity,std::os eb.replaceGlobalValue(1,12.0); Thyra::apply(*precOp,Thyra::NOTRANS,*x,y.ptr()); status = ((diff = Teko::Test::Difference(y,x)/Thyra::norm_2(*x->col(0)))=10) { - os << std::endl << " tJacobi2x2PreconditionerFactory_tpetra::test_identity " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " + if(not status || verbosity>=10) { + os << std::endl << " tJacobi2x2PreconditionerFactory_tpetra::test_identity " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " << diff << ")" << std::endl; os << " "; Print(os,"x",x); os << " "; Print(os,"y",y); @@ -438,7 +439,7 @@ bool tJacobi2x2PreconditionerFactory_tpetra::test_diagonal(int verbosity,std::os LinearOp iC = Teko::Test::DiagMatrix_tpetra(2,vec); LinearOp A = Thyra::block2x2(F,G,D,C); - RCP > precFactory + RCP > precFactory = rcp(new JacobiPreconditionerFactory(iF,iC)); RCP > prec = Thyra::prec(*precFactory,A); @@ -451,7 +452,7 @@ bool tJacobi2x2PreconditionerFactory_tpetra::test_diagonal(int verbosity,std::os Tpetra::Vector ef(map),eg(map); const RCP > x = BlockVector(ea,eb,A->domain()); const RCP > z = BlockVector(ef,eg,A->domain()); - const RCP > y = Thyra::createMembers(A->range(),1); + const RCP > y = Thyra::createMembers(A->range(),1); // now checks of the preconditioner (should be exact!) ///////////////////////////////////////////////////////////////////////// @@ -467,8 +468,8 @@ bool tJacobi2x2PreconditionerFactory_tpetra::test_diagonal(int verbosity,std::os eg.replaceGlobalValue(1,0.75); Thyra::apply(*precOp,Thyra::NOTRANS,*x,y.ptr()); status = ((diff = Teko::Test::Difference(y,z)/Thyra::norm_2(*z->col(0)))=10 ) { - os << std::endl << " tJacobi2x2PreconditionerFactory_tpetra::test_diagonal " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " + if(not status || verbosity>=10 ) { + os << std::endl << " tJacobi2x2PreconditionerFactory_tpetra::test_diagonal " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " << diff << ")" << std::endl; os << " "; Print(os,"x",x); os << " "; Print(os,"y",y); @@ -487,8 +488,8 @@ bool tJacobi2x2PreconditionerFactory_tpetra::test_diagonal(int verbosity,std::os eg.replaceGlobalValue(1,2.250000000000000); Thyra::apply(*precOp,Thyra::NOTRANS,*x,y.ptr()); status = ((diff = Teko::Test::Difference(y,z)/Thyra::norm_2(*z->col(0)))=10 ) { - os << std::endl << " tJacobi2x2PreconditionerFactory_tpetra::test_diagonal " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " + if(not status || verbosity>=10 ) { + os << std::endl << " tJacobi2x2PreconditionerFactory_tpetra::test_diagonal " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " << diff << ")" << std::endl; os << " "; Print(os,"x",x); os << " "; Print(os,"y",y); @@ -507,8 +508,8 @@ bool tJacobi2x2PreconditionerFactory_tpetra::test_diagonal(int verbosity,std::os eg.replaceGlobalValue(1,-1.250000000000000); Thyra::apply(*precOp,Thyra::NOTRANS,*x,y.ptr()); status = ((diff = Teko::Test::Difference(y,z)/Thyra::norm_2(*z->col(0)))=10 ) { - os << std::endl << " tJacobi2x2PreconditionerFactory_tpetra::test_diagonal " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " + if(not status || verbosity>=10 ) { + os << std::endl << " tJacobi2x2PreconditionerFactory_tpetra::test_diagonal " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " << diff << ")" << std::endl; os << " "; Print(os,"x",x); os << " "; Print(os,"y",y); @@ -527,8 +528,8 @@ bool tJacobi2x2PreconditionerFactory_tpetra::test_diagonal(int verbosity,std::os eg.replaceGlobalValue(1,3.000000000000000); Thyra::apply(*precOp,Thyra::NOTRANS,*x,y.ptr()); status = ((diff = Teko::Test::Difference(y,z)/Thyra::norm_2(*z->col(0)))=10 ) { - os << std::endl << " tJacobi2x2PreconditionerFactory_tpetra::test_diagonal " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " + if(not status || verbosity>=10 ) { + os << std::endl << " tJacobi2x2PreconditionerFactory_tpetra::test_diagonal " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " << diff << ")" << std::endl; os << " "; Print(os,"x",x); os << " "; Print(os,"y",y); @@ -544,9 +545,9 @@ bool tJacobi2x2PreconditionerFactory_tpetra::test_result(int verbosity,std::ostr bool status = false; bool allPassed = true; ST diff; - + // Build block2x2 preconditioner - RCP > precFactory + RCP > precFactory = rcp(new JacobiPreconditionerFactory(invF_,invC_)); RCP > prec = Thyra::prec(*precFactory,A_); @@ -557,10 +558,10 @@ bool tJacobi2x2PreconditionerFactory_tpetra::test_result(int verbosity,std::ostr // construct a couple of vectors Tpetra::Vector ea(map),eb(map); Tpetra::Vector ef(map),eg(map); - + const RCP > x = BlockVector(ea,eb,A_->domain()); const RCP > z = BlockVector(ef,eg,A_->domain()); - const RCP > y = Thyra::createMembers(A_->range(),1); + const RCP > y = Thyra::createMembers(A_->range(),1); Thyra::apply(*precOp,Thyra::NOTRANS,*x,y.ptr()); @@ -578,8 +579,8 @@ bool tJacobi2x2PreconditionerFactory_tpetra::test_result(int verbosity,std::ostr eg.replaceGlobalValue(1,6.3636363636363635e-01); Thyra::apply(*precOp,Thyra::NOTRANS,*x,y.ptr()); status = ((diff = Teko::Test::Difference(y,z)/Thyra::norm_2(*z->col(0)))=10 ) { - os << std::endl << " tJacobi2x2PreconditionerFactory_tpetra::test_result " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " + if(not status || verbosity>=10 ) { + os << std::endl << " tJacobi2x2PreconditionerFactory_tpetra::test_result " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " << diff << ")" << std::endl; os << " "; Print(os,"x",x); os << " "; Print(os,"y",y); @@ -598,8 +599,8 @@ bool tJacobi2x2PreconditionerFactory_tpetra::test_result(int verbosity,std::ostr eg.replaceGlobalValue(1,1.1818181818181817e+00); Thyra::apply(*precOp,Thyra::NOTRANS,*x,y.ptr()); status = ((diff = Teko::Test::Difference(y,z)/Thyra::norm_2(*z->col(0)))=10 ) { - os << std::endl << " tJacobi2x2PreconditionerFactory_tpetra::test_result " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " + if(not status || verbosity>=10 ) { + os << std::endl << " tJacobi2x2PreconditionerFactory_tpetra::test_result " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " << diff << ")" << std::endl; os << " "; Print(os,"x",x); os << " "; Print(os,"y",y); @@ -618,8 +619,8 @@ bool tJacobi2x2PreconditionerFactory_tpetra::test_result(int verbosity,std::ostr eg.replaceGlobalValue(1,-1.3636363636363635e+00); Thyra::apply(*precOp,Thyra::NOTRANS,*x,y.ptr()); status = ((diff = Teko::Test::Difference(y,z)/Thyra::norm_2(*z->col(0)))=10 ) { - os << std::endl << " tJacobi2x2PreconditionerFactory_tpetra::test_result " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " + if(not status || verbosity>=10 ) { + os << std::endl << " tJacobi2x2PreconditionerFactory_tpetra::test_result " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " << diff << ")" << std::endl; os << " "; Print(os,"x",x); os << " "; Print(os,"y",y); @@ -638,8 +639,8 @@ bool tJacobi2x2PreconditionerFactory_tpetra::test_result(int verbosity,std::ostr eg.replaceGlobalValue(1,2.1818181818181817e+00); Thyra::apply(*precOp,Thyra::NOTRANS,*x,y.ptr()); status = ((diff = Teko::Test::Difference(y,z)/Thyra::norm_2(*z->col(0)))=10 ) { - os << std::endl << " tJacobi2x2PreconditionerFactory_tpetra::test_result " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " + if(not status || verbosity>=10 ) { + os << std::endl << " tJacobi2x2PreconditionerFactory_tpetra::test_result " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " << diff << ")" << std::endl; os << " "; Print(os,"x",x); os << " "; Print(os,"y",y); @@ -651,14 +652,14 @@ bool tJacobi2x2PreconditionerFactory_tpetra::test_result(int verbosity,std::ostr } template -Teuchos::RCP getLowsFactory(const RCP & invFact) +Teuchos::RCP getLowsFactory(const RCP & invFact) { return rcp_dynamic_cast( rcp_dynamic_cast(invFact)->getLowsFactory()); } template -Teuchos::RCP getPrecFactory(const RCP & invFact) +Teuchos::RCP getPrecFactory(const RCP & invFact) { return rcp_dynamic_cast( rcp_dynamic_cast(invFact)->getPrecFactory()); @@ -676,7 +677,7 @@ bool tJacobi2x2PreconditionerFactory_tpetra::test_initializeFromParameterList(in RCP fact = PreconditionerFactory::buildPreconditionerFactory("Block Jacobi",p,invLib); RCP jFact = rcp_dynamic_cast(fact); - + // check we have the right factory status = (jFact!=Teuchos::null); if(status) @@ -690,13 +691,14 @@ bool tJacobi2x2PreconditionerFactory_tpetra::test_initializeFromParameterList(in if(!status) os << "Dynnamic to InvFactoryDiagStrategy cast failed" << std::endl; allPassed &= status; - + const std::vector > & facts = diagStrat->getFactories(); status = (facts.size()==1); allPassed &= status; } { +#ifdef TEKO_HAVE_EPETRA Teuchos::ParameterList p; p.set("Inverse Type","ML"); p.set("Inverse Type 1","Amesos"); @@ -718,15 +720,18 @@ bool tJacobi2x2PreconditionerFactory_tpetra::test_initializeFromParameterList(in os << "Checking if Amesos inverse factory was consctructed" << std::endl; allPassed &= status; + status = (getPrecFactory(facts[1])!=Teuchos::null); if(!status) os << "Checking if ML inverse factory was consctructed" << std::endl; allPassed &= status; + status = (getPrecFactory(facts[2])!=Teuchos::null); if(!status) os << "Checking if ML inverse factory was consctructed" << std::endl; allPassed &= status; +#endif } return allPassed; diff --git a/packages/teko/tests/src/tLSCHIntegrationTest_tpetra.cpp b/packages/teko/tests/src/tLSCHIntegrationTest_tpetra.cpp index b8d42890610a..b132c833672b 100644 --- a/packages/teko/tests/src/tLSCHIntegrationTest_tpetra.cpp +++ b/packages/teko/tests/src/tLSCHIntegrationTest_tpetra.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -48,10 +48,6 @@ #include -// ML includes -#include "ml_include.h" -#include "ml_MultiLevelPreconditioner.h" - // Teko-Package includes #include "Teko_LSCPreconditionerFactory.hpp" #include "Teko_InvLSCStrategy.hpp" @@ -92,7 +88,6 @@ namespace Test { using Teuchos::rcp; using Teuchos::RCP; -using Thyra::epetraLinearOp; void tLSCHIntegrationTest_tpetra::initializeTest() { @@ -108,17 +103,17 @@ int tLSCHIntegrationTest_tpetra::runTest(int verbosity,std::ostream & stdstrm,st failstrm << "tLSCHIntegrationTest_tpetra"; status = test_hScaling(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"hScaling\" ... PASSED"," \"hScaling\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"hScaling\" ... PASSED"," \"hScaling\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = allTests; if(verbosity >= 10) { - Teko_TEST_MSG(failstrm,0,"tLSCHIntegrationTest_tpetra...PASSED","tLSCHIntegrationTest_tpetra...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"tLSCHIntegrationTest_tpetra...PASSED","tLSCHIntegrationTest_tpetra...FAILED"); } else {// Normal Operating Procedures (NOP) - Teko_TEST_MSG(failstrm,0,"...PASSED","tLSCHIntegrationTest_tpetra...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"...PASSED","tLSCHIntegrationTest_tpetra...FAILED"); } return failcount; @@ -128,7 +123,7 @@ bool tLSCHIntegrationTest_tpetra::test_hScaling(int verbosity,std::ostream & os) { bool status = false; bool allPassed = true; - + RCP > comm = GetComm_tpetra(); // build some operators @@ -137,7 +132,7 @@ bool tLSCHIntegrationTest_tpetra::test_hScaling(int verbosity,std::ostream & os) Teko::LinearOp D = Teko::Test::build2x2(comm,1,-3,-1,1); ST diag[2]; - + diag[0] = 1.0/3.0; diag[1] = 1.0/2.0; Teko::LinearOp M = Teko::Test::DiagMatrix_tpetra(2,diag,"M"); @@ -152,7 +147,7 @@ bool tLSCHIntegrationTest_tpetra::test_hScaling(int verbosity,std::ostream & os) Teko::LinearOp D0 = Teko::Test::build2x2(comm,-1.0/3.0,2.0/3.0,2.0/3.0,-1.0/3.0); Teko::LinearOp D1 = Teko::Test::build2x2(comm,-1.5,-3.0,-3.0,-5.5); Teko::LinearOp U = Teko::Test::build2x2(comm,-0.5,-1.5,-0.5,-0.5); - + exact = Thyra::block2x2(D0,U,Teuchos::null,D1); } @@ -179,7 +174,7 @@ bool tLSCHIntegrationTest_tpetra::test_hScaling(int verbosity,std::ostream & os) const RCP > map = rcp(new Tpetra::Map(2,0,GetComm_tpetra())); Tpetra::Vector ea(map),eb(map); const RCP > x = BlockVector(ea,eb,prec->domain()); - const RCP > y = Thyra::createMembers(prec->range(),1); + const RCP > y = Thyra::createMembers(prec->range(),1); ea.replaceGlobalValue(0,1.0); ea.replaceGlobalValue(1,0.0); eb.replaceGlobalValue(0,0.0); @@ -204,7 +199,7 @@ bool tLSCHIntegrationTest_tpetra::test_hScaling(int verbosity,std::ostream & os) eb.replaceGlobalValue(1,1.0); Thyra::apply(*prec,Thyra::NOTRANS,*x,y.ptr()); ss << "prec = " << Teuchos::describe(*y,Teuchos::VERB_EXTREME) << std::endl; - + Thyra::LinearOpTester tester; tester.show_all_tests(true); Teuchos::FancyOStream fos(Teuchos::rcpFromRef(ss),"|||"); @@ -230,8 +225,8 @@ bool tLSCHIntegrationTest_tpetra::test_hScaling(int verbosity,std::ostream & os) std::endl << " tLSCHIntegration::test_hScaling " << ": Comparing inv(BHBt) operator"); - if(not allPassed || verbosity>=10) - os << ss.str(); + if(not allPassed || verbosity>=10) + os << ss.str(); return allPassed; } diff --git a/packages/teko/tests/src/tLSCIntegrationTest_tpetra.cpp b/packages/teko/tests/src/tLSCIntegrationTest_tpetra.cpp index f4a514c0810a..0166ac805122 100644 --- a/packages/teko/tests/src/tLSCIntegrationTest_tpetra.cpp +++ b/packages/teko/tests/src/tLSCIntegrationTest_tpetra.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -48,10 +48,6 @@ #include -// ML includes -#include "ml_include.h" -#include "ml_MultiLevelPreconditioner.h" - // Teko-Package includes #include "Teko_LSCPreconditionerFactory.hpp" #include "Teko_InvLSCStrategy.hpp" @@ -79,8 +75,6 @@ #include "Tpetra_CrsMatrix.hpp" #include "Thyra_TpetraLinearOp.hpp" -#include "Trilinos_Util_CrsMatrixGallery.h" - namespace Teko { namespace Test { @@ -108,14 +102,6 @@ void tLSCIntegrationTest_tpetra::solveList(Teuchos::ParameterList & paramList,in gmresList.set( "Maximum Restarts", 15 ); // Maximum number of restarts allowed gmresList.set( "Convergence Tolerance", 1.0e-9 ); // Relative convergence tolerance requested paramList.set("Preconditioner Type","Ifpack2"); - - Teuchos::ParameterList & MLList = paramList.sublist("Preconditioner Types").sublist("ML").sublist("ML Settings"); - - // set default values for smoothed aggregation in MLList - ML_Epetra::SetDefaults("SA",MLList); - MLList.set("max levels",6); - MLList.set("cycle applications",vcycles); - MLList.set("coarse: type","Amesos-KLU"); } void tLSCIntegrationTest_tpetra::loadStableSystem() @@ -142,8 +128,8 @@ void tLSCIntegrationTest_tpetra::loadStableSystem() // read in RHS vector { RCP > vfull, temp; - - // read in rhs file + + // read in rhs file vfull = Tpetra::MatrixMarket::Reader >::readVectorFile("./data/lsc_rhs.mm",GetComm_tpetra(),fullMap_); temp = rcp(new Tpetra::Vector(sA_->getRangeMap())); @@ -154,8 +140,8 @@ void tLSCIntegrationTest_tpetra::loadStableSystem() // read in solution vector { RCP > vfull, temp; - - // read in exact solution file + + // read in exact solution file vfull = Tpetra::MatrixMarket::Reader >::readVectorFile("./data/lsc_exact_2.mm",GetComm_tpetra(),fullMap_); temp = rcp(new Tpetra::Vector(sA_->getRangeMap())); @@ -173,29 +159,29 @@ int tLSCIntegrationTest_tpetra::runTest(int verbosity,std::ostream & stdstrm,std failstrm << "tLSCIntegrationTest_tpetra"; status = test_withmassStable(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"withmassStable\" ... PASSED"," \"withmassStable\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"withmassStable\" ... PASSED"," \"withmassStable\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_nomassStable(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"nomassStable\" ... PASSED"," \"nomassStable\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"nomassStable\" ... PASSED"," \"nomassStable\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_plConstruction(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"plConstruction\" ... PASSED"," \"plConstruction\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"plConstruction\" ... PASSED"," \"plConstruction\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = allTests; if(verbosity >= 10) { - Teko_TEST_MSG(failstrm,0,"tLSCIntegrationTest_tpetra...PASSED","tLSCIntegrationTest_tpetra...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"tLSCIntegrationTest_tpetra...PASSED","tLSCIntegrationTest_tpetra...FAILED"); } else {// Normal Operating Procedures (NOP) - Teko_TEST_MSG(failstrm,0,"...PASSED","tLSCIntegrationTest_tpetra...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"...PASSED","tLSCIntegrationTest_tpetra...FAILED"); } return failcount; @@ -220,7 +206,7 @@ bool tLSCIntegrationTest_tpetra::test_withmassStable(int verbosity,std::ostream // if you get here you automatically pass the first test if(verbosity>=10 ) { - os << std::endl << " tLSCIntegrationTest_tpetra::test_withmassStable: loading system ... " + os << std::endl << " tLSCIntegrationTest_tpetra::test_withmassStable: loading system ... " << toString(true) << std::endl; } @@ -252,20 +238,20 @@ bool tLSCIntegrationTest_tpetra::test_withmassStable(int verbosity,std::ostream // check iteration count int numIters = solver->getNumIters(); status = (numIters<=18); - if(not status || verbosity>=10 ) { - os << std::endl << " tLSCIntegrationTest_tpetra::test_withmassStable " << toString(status) + if(not status || verbosity>=10 ) { + os << std::endl << " tLSCIntegrationTest_tpetra::test_withmassStable " << toString(status) << ": # of iterations = " << numIters << " (should be 18)" << std::endl; } allPassed &= status; - + // check exact answer (versus IFISS solution) x.update(-1.0,*sExact_,1.0); // x = x - x* ST errnorm,exactnorm,relerr; errnorm = x.norm2(); exactnorm = sExact_->norm2(); status = ((relerr = errnorm/exactnorm) <= tolerance_); - if(not status || verbosity>=10 ) { - os << std::endl << " tLSCIntegrationTest_tpetra::test_withmassStable " << toString(status) + if(not status || verbosity>=10 ) { + os << std::endl << " tLSCIntegrationTest_tpetra::test_withmassStable " << toString(status) << ": error in solution = " << std::scientific << relerr << " <= " << tolerance_ << std::endl; } allPassed &= status; @@ -294,7 +280,7 @@ bool tLSCIntegrationTest_tpetra::test_nomassStable(int verbosity,std::ostream & // if you get here you automatically pass! if(verbosity>=10 ) { - os << std::endl << " tLSCIntegrationTest_tpetra::test_nomassStable: loading system ... " + os << std::endl << " tLSCIntegrationTest_tpetra::test_nomassStable: loading system ... " << toString(true) << std::endl; } @@ -325,20 +311,20 @@ bool tLSCIntegrationTest_tpetra::test_nomassStable(int verbosity,std::ostream & // check iteration count int numIters = solver->getNumIters(); status = (numIters<=30); - if(not status || verbosity>=10 ) { - os << std::endl << " tLSCIntegrationTest_tpetra::test_nomassStable " << toString(status) + if(not status || verbosity>=10 ) { + os << std::endl << " tLSCIntegrationTest_tpetra::test_nomassStable " << toString(status) << ": # of iterations = " << numIters << " (should be 30)" << std::endl; } allPassed &= status; - + // check exact answer (versus IFISS solution) x.update(-1.0,*sExact_,1.0); // x = x - x* ST errnorm,exactnorm,relerr; errnorm = x.norm2(); exactnorm = sExact_->norm2(); status = ((relerr = errnorm/exactnorm) <= tolerance_); - if(not status || verbosity>=10 ) { - os << std::endl << " tLSCIntegrationTest_tpetra::test_nomassStable " << toString(status) + if(not status || verbosity>=10 ) { + os << std::endl << " tLSCIntegrationTest_tpetra::test_nomassStable " << toString(status) << ": error in solution = " << std::scientific << relerr << " <= " << tolerance_ << std::endl; } allPassed &= status; @@ -358,7 +344,7 @@ bool tLSCIntegrationTest_tpetra::test_plConstruction(int verbosity,std::ostream ///////////////////////////////////////////////////////////////////////////// - ParameterList pl; + ParameterList pl; pl.set("Inverse Type", "Amesos"); pl.set("Inverse Velocity Type", "Ifpack"); pl.set("Inverse Pressure Type", "Ifpack"); diff --git a/packages/teko/tests/src/tLSCStabilized_tpetra.cpp b/packages/teko/tests/src/tLSCStabilized_tpetra.cpp index fdba40a220b3..f0ae209de2a9 100644 --- a/packages/teko/tests/src/tLSCStabilized_tpetra.cpp +++ b/packages/teko/tests/src/tLSCStabilized_tpetra.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -53,20 +53,13 @@ // Teuchos includes #include "Teuchos_RCP.hpp" -// Epetra includes -#include "Epetra_Map.h" -#include "Epetra_CrsMatrix.h" -#include "Epetra_Vector.h" - // Thyra includes -#include "Thyra_EpetraLinearOp.hpp" #include "Thyra_LinearOpBase.hpp" #include "Thyra_DefaultBlockedLinearOp.hpp" #include "Thyra_DefaultIdentityLinearOp.hpp" #include "Thyra_DefaultZeroLinearOp.hpp" #include "Thyra_DefaultLinearOpSource.hpp" #include "Thyra_DefaultPreconditioner.hpp" -#include "Thyra_EpetraThyraWrappers.hpp" #include "Thyra_DefaultMultipliedLinearOp.hpp" #include "Thyra_DefaultScaledAdjointLinearOp.hpp" #include "Thyra_PreconditionerFactoryHelpers.hpp" @@ -84,7 +77,7 @@ #include // This whole test rig is based on inverting the matrix -// +// // [ 1 2 1 -1 ] // A = [ 2 1 -3 1 ] // [ 1 -3 0 0 ] @@ -115,19 +108,19 @@ int tLSCStabilized_tpetra::runTest(int verbosity,std::ostream & stdstrm,std::ost failstrm << "tLSCStabilized_tpetra"; status = test_diagonal(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"diagonal\" ... PASSED"," \"diagonal\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"diagonal\" ... PASSED"," \"diagonal\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; /* status = test_diagonalNotSym(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"diagonalNotSym\" ... PASSED"," \"diagonalNotSym\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"diagonalNotSym\" ... PASSED"," \"diagonalNotSym\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_strategy(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"strategy\" ... PASSED"," \"strategy\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"strategy\" ... PASSED"," \"strategy\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; @@ -135,10 +128,10 @@ int tLSCStabilized_tpetra::runTest(int verbosity,std::ostream & stdstrm,std::ost status = allTests; if(verbosity >= 10) { - Teko_TEST_MSG(failstrm,0,"tLSCStabilized_tpetra...PASSED","tLSCStabilized_tpetra...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"tLSCStabilized_tpetra...PASSED","tLSCStabilized_tpetra...FAILED"); } else {// Normal Operatoring Procedures (NOP) - Teko_TEST_MSG(failstrm,0,"...PASSED","tLSCStabilized_tpetra...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"...PASSED","tLSCStabilized_tpetra...FAILED"); } return failcount; @@ -184,13 +177,13 @@ bool tLSCStabilized_tpetra::test_diagonal(int verbosity,std::ostream & os) LinearOp aiD = Teko::Test::DiagMatrix_tpetra(2,vec); LinearOp A = Thyra::block2x2(F,G,D,C); - - const RCP > precFactory + + const RCP > precFactory = rcp(new LSCPreconditionerFactory(iF,iBBt,aiD,Teuchos::null)); RCP > prec = Thyra::prec(*precFactory,A); // build linear operator - RCP > precOp = prec->getUnspecifiedPrecOp(); + RCP > precOp = prec->getUnspecifiedPrecOp(); const RCP > map = rcp(new Tpetra::Map(2,0,comm)); // construct a couple of vectors @@ -198,7 +191,7 @@ bool tLSCStabilized_tpetra::test_diagonal(int verbosity,std::ostream & os) Tpetra::Vector ef(map),eg(map); const RCP > x = BlockVector(ea,eb,A->domain()); const RCP > z = BlockVector(ef,eg,A->domain()); - const RCP > y = Thyra::createMembers(A->range(),1); + const RCP > y = Thyra::createMembers(A->range(),1); // now checks of the preconditioner (should be exact!) ///////////////////////////////////////////////////////////////////////// @@ -218,8 +211,8 @@ bool tLSCStabilized_tpetra::test_diagonal(int verbosity,std::ostream & os) TEST_ASSERT((diff = Teko::Test::Difference(y,z)/Thyra::norm_2(*z->col(0)))col(0)))col(0)))col(0))) invLib = InverseLibrary::buildFromStratimikos(); RCP invFact = invLib->getInverseFactory("Ifpack2"); - + RCP lscStrat = rcp(new InvLSCStrategy(invFact)); // lscStrat->setSymmetric(false); - const RCP > precFactory + const RCP > precFactory = rcp(new LSCPreconditionerFactory(lscStrat)); RCP > prec = Thyra::prec(*precFactory,A); // build linear operator - RCP > precOp = prec->getUnspecifiedPrecOp(); + RCP > precOp = prec->getUnspecifiedPrecOp(); const RCP > map = rcp(new Tpetra::Map(2,0,comm)); // construct a couple of vectors @@ -341,7 +334,7 @@ bool tLSCStabilized_tpetra::test_diagonalNotSym(int verbosity,std::ostream & os) Tpetra::Vector ef(map),eg(map); const RCP > x = BlockVector(ea,eb,A->domain()); const RCP > z = BlockVector(ef,eg,A->domain()); - const RCP > y = Thyra::createMembers(A->range(),1); + const RCP > y = Thyra::createMembers(A->range(),1); // now checks of the preconditioner (should be exact!) ///////////////////////////////////////////////////////////////////////// @@ -361,8 +354,8 @@ bool tLSCStabilized_tpetra::test_diagonalNotSym(int verbosity,std::ostream & os) TEST_ASSERT((diff = Teko::Test::Difference(y,z)/Thyra::norm_2(*z->col(0)))col(0)))col(0)))col(0))) ea(map),eb(map); const RCP > x = BlockVector(ea,eb,A->domain()); - const RCP > y = Thyra::createMembers(A->range(),1); + const RCP > y = Thyra::createMembers(A->range(),1); RCP invLib = InverseLibrary::buildFromStratimikos(); RCP invFact = invLib->getInverseFactory("Ifpack2"); @@ -512,13 +505,13 @@ bool tLSCStabilized_tpetra::test_strategy(int verbosity,std::ostream & os) vec[4] = -0.115405114603879; LinearOp p11 = Teko::Test::DiagMatrix_tpetra(sz,vec); LinearOp P = Thyra::block2x2(p00,p01,p10,p11); - + // Kluge to get around problem with Anasazi // Teko::computeSpectralRad(Thyra::multiply(invMass,F),5e-2,false,3)/3.0; // Teko::computeSpectralRad(Thyra::multiply(invMass,F),5e-2,false,3)/3.0; - + // build inverse strategy - { + { bool result; Teko::NS::LSCPrecondState state; Teko::NS::InvLSCStrategy iStrat(invFact,mass,false); @@ -532,8 +525,8 @@ bool tLSCStabilized_tpetra::test_strategy(int verbosity,std::ostream & os) TEST_ASSERT(result, std::endl << " tLSCStabilized_tpetra::test_strategy " << toString(status) << " : Comparing mass operators"); - if(not result || verbosity>=10) - os << ss.str(); + if(not result || verbosity>=10) + os << ss.str(); // test inverse F ss.str(""); @@ -541,8 +534,8 @@ bool tLSCStabilized_tpetra::test_strategy(int verbosity,std::ostream & os) TEST_ASSERT(result, std::endl << " tLSCStabilized_tpetra::test_strategy " << toString(status) << " : Comparing F operators"); - if(not result || verbosity>=10) - os << ss.str(); + if(not result || verbosity>=10) + os << ss.str(); // test inverse B*Q*Bt-gamma*C ss.str(""); @@ -550,8 +543,8 @@ bool tLSCStabilized_tpetra::test_strategy(int verbosity,std::ostream & os) TEST_ASSERT(result, std::endl << " tLSCStabilized_tpetra::test_strategy " << toString(status) << " : Comparing B*Q*Bt-C operators"); - if(not result || verbosity>=10) - os << ss.str(); + if(not result || verbosity>=10) + os << ss.str(); // test alpha*inv(D) ss.str(""); @@ -563,8 +556,8 @@ bool tLSCStabilized_tpetra::test_strategy(int verbosity,std::ostream & os) TEST_ASSERT(result, std::endl << " tLSCStabilized_tpetra::test_strategy " << toString(status) << " : Comparing alpha*inv(D) operators"); - if(not result || verbosity>=10) - os << ss.str(); + if(not result || verbosity>=10) + os << ss.str(); #endif @@ -574,8 +567,8 @@ bool tLSCStabilized_tpetra::test_strategy(int verbosity,std::ostream & os) TEST_ASSERT(result, std::endl << " tLSCStabilized_tpetra::test_strategy " << toString(status) << " : Comparing full op"); - if(not result || verbosity>=10) - os << ss.str(); + if(not result || verbosity>=10) + os << ss.str(); } return allPassed; diff --git a/packages/teko/tests/src/tLSCStablePreconditionerFactory.hpp b/packages/teko/tests/src/tLSCStablePreconditionerFactory.hpp index 6b5b2ccbc4d8..71ee5284a4e6 100644 --- a/packages/teko/tests/src/tLSCStablePreconditionerFactory.hpp +++ b/packages/teko/tests/src/tLSCStablePreconditionerFactory.hpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -79,13 +79,13 @@ class tLSCStablePreconditionerFactory : public UnitTest { protected: // some simple matrix subblocks - Teuchos::RCP > A_; - Teuchos::RCP > F_; - Teuchos::RCP > B_; - Teuchos::RCP > Bt_; - Teuchos::RCP > invF_; - Teuchos::RCP > invBQBt_; - Teuchos::RCP > invMass_; + Teuchos::RCP > A_; + Teuchos::RCP > F_; + Teuchos::RCP > B_; + Teuchos::RCP > Bt_; + Teuchos::RCP > invF_; + Teuchos::RCP > invBQBt_; + Teuchos::RCP > invMass_; Teuchos::RCP comm; double tolerance_; diff --git a/packages/teko/tests/src/tLSCStablePreconditionerFactory_tpetra.cpp b/packages/teko/tests/src/tLSCStablePreconditionerFactory_tpetra.cpp index 9224d9839341..e57790bc8230 100644 --- a/packages/teko/tests/src/tLSCStablePreconditionerFactory_tpetra.cpp +++ b/packages/teko/tests/src/tLSCStablePreconditionerFactory_tpetra.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -51,14 +51,12 @@ #include "Teuchos_RCP.hpp" // Thyra includes -#include "Thyra_EpetraLinearOp.hpp" #include "Thyra_LinearOpBase.hpp" #include "Thyra_DefaultBlockedLinearOp.hpp" #include "Thyra_DefaultIdentityLinearOp.hpp" #include "Thyra_DefaultZeroLinearOp.hpp" #include "Thyra_DefaultLinearOpSource.hpp" #include "Thyra_DefaultPreconditioner.hpp" -#include "Thyra_EpetraThyraWrappers.hpp" #include "Thyra_DefaultMultipliedLinearOp.hpp" #include "Thyra_DefaultScaledAdjointLinearOp.hpp" #include "Thyra_PreconditionerFactoryHelpers.hpp" @@ -75,7 +73,7 @@ #include // This whole test rig is based on inverting the matrix -// +// // [ 1 2 1 -1 ] // A = [ 2 1 -3 1 ] // [ 1 -3 0 0 ] @@ -118,7 +116,7 @@ void tLSCStablePreconditionerFactory_tpetra::initializeTest() ptrF->insertGlobalValues(1,Teuchos::ArrayView(indices),Teuchos::ArrayView(row1)); ptrF->fillComplete(); F_ = Thyra::tpetraLinearOp(Thyra::tpetraVectorSpace(ptrF->getDomainMap()),Thyra::tpetraVectorSpace(ptrF->getRangeMap()),ptrF); - + // build B matrix row0[0] = 1.0; row0[1] = -3.0; row1[0] = -1.0; row1[1] = 1.0; @@ -171,53 +169,53 @@ int tLSCStablePreconditionerFactory_tpetra::runTest(int verbosity,std::ostream & failstrm << "tLSCStablePreconditionerFactory_tpetra"; status = test_createPrec(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"createPrec\" ... PASSED"," \"createPrec\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"createPrec\" ... PASSED"," \"createPrec\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_initializePrec(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"initializePrec\" ... PASSED"," \"initializePrec\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"initializePrec\" ... PASSED"," \"initializePrec\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_uninitializePrec(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"uninitializePrec\" ... PASSED"," \"uninitializePrec\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"uninitializePrec\" ... PASSED"," \"uninitializePrec\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_isCompatable(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"isCompatable\" ... PASSED"," \"isCompatable\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"isCompatable\" ... PASSED"," \"isCompatable\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_identity(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"identity\" ... PASSED"," \"identity\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"identity\" ... PASSED"," \"identity\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_diagonal(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"diagonal\" ... PASSED"," \"diagonal\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"diagonal\" ... PASSED"," \"diagonal\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_result(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"result\" ... PASSED"," \"result\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"result\" ... PASSED"," \"result\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = allTests; if(verbosity >= 10) { - Teko_TEST_MSG(failstrm,0,"tLSCStablePreconditionedFactory...PASSED","tLSCStablePreconditionedFactory...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"tLSCStablePreconditionedFactory...PASSED","tLSCStablePreconditionedFactory...FAILED"); } else {// Normal Operatoring Procedures (NOP) - Teko_TEST_MSG(failstrm,0,"...PASSED","tLSCStablePreconditionedFactory...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"...PASSED","tLSCStablePreconditionedFactory...FAILED"); } return failcount; @@ -249,9 +247,9 @@ bool tLSCStablePreconditionerFactory_tpetra::test_initializePrec(int verbosity,s bool allPassed = true; // Build block2x2 preconditioner - //RCP > precFactory + //RCP > precFactory // = rcp(new LSCStablePreconditionerFactory(invF_,invBQBt_)); - const RCP > precFactory + const RCP > precFactory = rcp(new LSCPreconditionerFactory(invF_,invBQBt_,Teuchos::null)); RCP > prec = precFactory->createPrec(); @@ -311,7 +309,7 @@ bool tLSCStablePreconditionerFactory_tpetra::test_identity(int verbosity,std::os LinearOp invBQBt = Ip; LinearOp A = Thyra::block2x2(Iu,Ip,Iu,Zp); - const RCP > precFactory + const RCP > precFactory = rcp(new LSCPreconditionerFactory(Iu,invBQBt,Teuchos::null)); RCP > prec = Thyra::prec(*precFactory,A); @@ -324,7 +322,7 @@ bool tLSCStablePreconditionerFactory_tpetra::test_identity(int verbosity,std::os Tpetra::Vector ef(map),eg(map); const RCP > x = BlockVector(ea,eb,A->domain()); const RCP > z = BlockVector(ef,eg,A->domain()); - const RCP > y = Thyra::createMembers(A->range(),1); + const RCP > y = Thyra::createMembers(A->range(),1); // test vector [0 1 1 3] ea.replaceGlobalValue(0,0.0); @@ -339,7 +337,7 @@ bool tLSCStablePreconditionerFactory_tpetra::test_identity(int verbosity,std::os Thyra::apply(*precOp,Thyra::NOTRANS,*x,y.ptr()); status = (Teko::Test::Difference(y,z)=10) { + if(not status || verbosity>=10) { os << std::endl << " tLSCStablePreconditionerFactory_tpetra::test_Identity " << toString(status) << ": (y=inv(A)*x) != z" << std::endl; os << " "; Print(os,"x",x); os << " "; Print(os,"y",y); @@ -360,7 +358,7 @@ bool tLSCStablePreconditionerFactory_tpetra::test_identity(int verbosity,std::os Thyra::apply(*precOp,Thyra::NOTRANS,*x,y.ptr()); status = (Teko::Test::Difference(y,z)=10) { + if(not status || verbosity>=10) { os << std::endl << " tLSCStablePreconditionerFactory_tpetra::test_Identity " << toString(status) << ": (y=inv(A)*x) != z" << std::endl; os << " "; Print(os,"x",x); os << " "; Print(os,"y",y); @@ -381,7 +379,7 @@ bool tLSCStablePreconditionerFactory_tpetra::test_identity(int verbosity,std::os Thyra::apply(*precOp,Thyra::NOTRANS,*x,y.ptr()); status = (Teko::Test::Difference(y,z)=10) { + if(not status || verbosity>=10) { os << std::endl << " tLSCStablePreconditionerFactory_tpetra::test_Identity " << toString(status) << ": (y=inv(A)*x) != z" << std::endl; os << " "; Print(os,"x",x); os << " "; Print(os,"y",y); @@ -402,7 +400,7 @@ bool tLSCStablePreconditionerFactory_tpetra::test_identity(int verbosity,std::os Thyra::apply(*precOp,Thyra::NOTRANS,*x,y.ptr()); status = (Teko::Test::Difference(y,z)=10) { + if(not status || verbosity>=10) { os << std::endl << " tLSCStablePreconditionerFactory_tpetra::test_Identity " << toString(status) << ": (y=inv(A)*x) != z" << std::endl; os << " "; Print(os,"x",x); os << " "; Print(os,"y",y); @@ -447,11 +445,11 @@ bool tLSCStablePreconditionerFactory_tpetra::test_diagonal(int verbosity,std::os LinearOp iF = Teko::Test::DiagMatrix_tpetra(2,vec); // S = -C+D*iF*G - vec[0] = 0.028571428571429; vec[1] = 0.020833333333333; + vec[0] = 0.028571428571429; vec[1] = 0.020833333333333; LinearOp iBBt = Teko::Test::DiagMatrix_tpetra(2,vec); LinearOp A = Thyra::block2x2(F,G,D,C); - const RCP > precFactory + const RCP > precFactory = rcp(new LSCPreconditionerFactory(iF,iBBt,Teuchos::null)); RCP > prec = Thyra::prec(*precFactory,A); @@ -464,7 +462,7 @@ bool tLSCStablePreconditionerFactory_tpetra::test_diagonal(int verbosity,std::os Tpetra::Vector ef(map),eg(map); const RCP > x = BlockVector(ea,eb,A->domain()); const RCP > z = BlockVector(ef,eg,A->domain()); - const RCP > y = Thyra::createMembers(A->range(),1); + const RCP > y = Thyra::createMembers(A->range(),1); // now checks of the preconditioner (should be exact!) ///////////////////////////////////////////////////////////////////////// @@ -482,8 +480,8 @@ bool tLSCStablePreconditionerFactory_tpetra::test_diagonal(int verbosity,std::os Thyra::apply(*precOp,Thyra::NOTRANS,*x,y.ptr()); status = ((diff = Teko::Test::Difference(y,z)/Thyra::norm_2(*z->col(0)))=10 ) { - os << std::endl << " tLSCStablePreconditionerFactory_tpetra::test_diagonal " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " + if(not status || verbosity>=10 ) { + os << std::endl << " tLSCStablePreconditionerFactory_tpetra::test_diagonal " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " << diff << ")" << std::endl; os << " "; Print(os,"x",x); os << " "; Print(os,"y",y); @@ -504,8 +502,8 @@ bool tLSCStablePreconditionerFactory_tpetra::test_diagonal(int verbosity,std::os Thyra::apply(*precOp,Thyra::NOTRANS,*x,y.ptr()); status = ((diff = Teko::Test::Difference(y,z)/Thyra::norm_2(*z->col(0)))=10 ) { - os << std::endl << " tLSCStablePreconditionerFactory_tpetra::test_diagonal " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " + if(not status || verbosity>=10 ) { + os << std::endl << " tLSCStablePreconditionerFactory_tpetra::test_diagonal " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " << diff << ")" << std::endl; os << " "; Print(os,"x",x); os << " "; Print(os,"y",y); @@ -526,8 +524,8 @@ bool tLSCStablePreconditionerFactory_tpetra::test_diagonal(int verbosity,std::os Thyra::apply(*precOp,Thyra::NOTRANS,*x,y.ptr()); status = ((diff = Teko::Test::Difference(y,z)/Thyra::norm_2(*z->col(0)))=10 ) { - os << std::endl << " tLSCStablePreconditionerFactory_tpetra::test_diagonal " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " + if(not status || verbosity>=10 ) { + os << std::endl << " tLSCStablePreconditionerFactory_tpetra::test_diagonal " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " << diff << ")" << std::endl; os << " "; Print(os,"x",x); os << " "; Print(os,"y",y); @@ -548,8 +546,8 @@ bool tLSCStablePreconditionerFactory_tpetra::test_diagonal(int verbosity,std::os Thyra::apply(*precOp,Thyra::NOTRANS,*x,y.ptr()); status = ((diff = Teko::Test::Difference(y,z)/Thyra::norm_2(*z->col(0)))=10 ) { - os << std::endl << " tLSCStablePreconditionerFactory_tpetra::test_diagonal " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " + if(not status || verbosity>=10 ) { + os << std::endl << " tLSCStablePreconditionerFactory_tpetra::test_diagonal " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " << diff << ")" << std::endl; os << " "; Print(os,"x",x); os << " "; Print(os,"y",y); @@ -565,11 +563,11 @@ bool tLSCStablePreconditionerFactory_tpetra::test_result(int verbosity,std::ostr bool status = false; bool allPassed = true; ST diff; - + // Build block2x2 preconditioner - //RCP > precFactory + //RCP > precFactory // = rcp(new LSCStablePreconditionerFactory(invF_,invBQBt_,invMass_)); - const RCP > precFactory + const RCP > precFactory = rcp(new LSCPreconditionerFactory(invF_,invBQBt_,invMass_)); RCP > prec = Thyra::prec(*precFactory,A_); @@ -580,10 +578,10 @@ bool tLSCStablePreconditionerFactory_tpetra::test_result(int verbosity,std::ostr // construct a couple of vectors Tpetra::Vector ea(map),eb(map); Tpetra::Vector ef(map),eg(map); - + const RCP > x = BlockVector(ea,eb,A_->domain()); const RCP > z = BlockVector(ef,eg,A_->domain()); - const RCP > y = Thyra::createMembers(A_->range(),1); + const RCP > y = Thyra::createMembers(A_->range(),1); Thyra::apply(*precOp,Thyra::NOTRANS,*x,y.ptr()); @@ -603,8 +601,8 @@ bool tLSCStablePreconditionerFactory_tpetra::test_result(int verbosity,std::ostr Thyra::apply(*precOp,Thyra::NOTRANS,*x,y.ptr()); status = ((diff = Teko::Test::Difference(y,z)/Thyra::norm_2(*z->col(0)))=10 ) { - os << std::endl << " tLSCStablePreconditionerFactory_tpetra::test_result " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " + if(not status || verbosity>=10 ) { + os << std::endl << " tLSCStablePreconditionerFactory_tpetra::test_result " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " << diff << ")" << std::endl; os << " "; Print(os,"x",x); os << " "; Print(os,"y",y); @@ -625,8 +623,8 @@ bool tLSCStablePreconditionerFactory_tpetra::test_result(int verbosity,std::ostr Thyra::apply(*precOp,Thyra::NOTRANS,*x,y.ptr()); status = ((diff = Teko::Test::Difference(y,z)/Thyra::norm_2(*z->col(0)))=10 ) { - os << std::endl << " tLSCStablePreconditionerFactory_tpetra::test_result " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " + if(not status || verbosity>=10 ) { + os << std::endl << " tLSCStablePreconditionerFactory_tpetra::test_result " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " << diff << ")" << std::endl; os << " "; Print(os,"x",x); os << " "; Print(os,"y",y); @@ -647,8 +645,8 @@ bool tLSCStablePreconditionerFactory_tpetra::test_result(int verbosity,std::ostr Thyra::apply(*precOp,Thyra::NOTRANS,*x,y.ptr()); status = ((diff = Teko::Test::Difference(y,z)/Thyra::norm_2(*z->col(0)))=10 ) { - os << std::endl << " tLSCStablePreconditionerFactory_tpetra::test_result " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " + if(not status || verbosity>=10 ) { + os << std::endl << " tLSCStablePreconditionerFactory_tpetra::test_result " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " << diff << ")" << std::endl; os << " "; Print(os,"x",x); os << " "; Print(os,"y",y); @@ -669,8 +667,8 @@ bool tLSCStablePreconditionerFactory_tpetra::test_result(int verbosity,std::ostr Thyra::apply(*precOp,Thyra::NOTRANS,*x,y.ptr()); status = ((diff = Teko::Test::Difference(y,z)/Thyra::norm_2(*z->col(0)))=10 ) { - os << std::endl << " tLSCStablePreconditionerFactory_tpetra::test_result " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " + if(not status || verbosity>=10 ) { + os << std::endl << " tLSCStablePreconditionerFactory_tpetra::test_result " << toString(status) << ": (y=inv(A)*x) != z (|y-z|_2/|z|_2 = " << diff << ")" << std::endl; os << " "; Print(os,"x",x); os << " "; Print(os,"y",y); diff --git a/packages/teko/tests/src/tLSCStablePreconditionerFactory_tpetra.hpp b/packages/teko/tests/src/tLSCStablePreconditionerFactory_tpetra.hpp index 33e163ead3b6..a35f331b1607 100644 --- a/packages/teko/tests/src/tLSCStablePreconditionerFactory_tpetra.hpp +++ b/packages/teko/tests/src/tLSCStablePreconditionerFactory_tpetra.hpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -50,8 +50,6 @@ // Thyra includes #include "Thyra_LinearOpBase.hpp" -#include "Epetra_SerialComm.h" - #include #include "Test_Utils.hpp" @@ -80,13 +78,13 @@ class tLSCStablePreconditionerFactory_tpetra : public UnitTest { protected: // some simple matrix subblocks - Teuchos::RCP > A_; - Teuchos::RCP > F_; - Teuchos::RCP > B_; - Teuchos::RCP > Bt_; - Teuchos::RCP > invF_; - Teuchos::RCP > invBQBt_; - Teuchos::RCP > invMass_; + Teuchos::RCP > A_; + Teuchos::RCP > F_; + Teuchos::RCP > B_; + Teuchos::RCP > Bt_; + Teuchos::RCP > invF_; + Teuchos::RCP > invBQBt_; + Teuchos::RCP > invMass_; Teuchos::RCP > comm; ST tolerance_; diff --git a/packages/teko/tests/src/tLumping_tpetra.cpp b/packages/teko/tests/src/tLumping_tpetra.cpp index 74fb2e6f0c6c..a81cc8fc8e26 100644 --- a/packages/teko/tests/src/tLumping_tpetra.cpp +++ b/packages/teko/tests/src/tLumping_tpetra.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -59,9 +59,6 @@ #include "Thyra_DefaultDiagonalLinearOp.hpp" #include "Thyra_LinearOpTester.hpp" -// TriUtils includes -#include "Trilinos_Util_CrsMatrixGallery.h" - // Test-rig #include "Test_Utils.hpp" @@ -87,23 +84,23 @@ int tLumping_tpetra::runTest(int verbosity,std::ostream & stdstrm,std::ostream & failstrm << "tLumping_tpetra"; status = test_lumping(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"lumping\" ... PASSED"," \"lumping\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"lumping\" ... PASSED"," \"lumping\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_invLumping(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"invLumping\" ... PASSED"," \"invLumping\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"invLumping\" ... PASSED"," \"invLumping\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = allTests; if(verbosity >= 10) { - Teko_TEST_MSG(failstrm,0,"tLumping_tpetra...PASSED","tLumping_tpetra...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"tLumping_tpetra...PASSED","tLumping_tpetra...FAILED"); } else {// Normal Operating Procedures (NOP) - Teko_TEST_MSG(failstrm,0,"...PASSED","tLumping_tpetra...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"...PASSED","tLumping_tpetra...FAILED"); } return failcount; diff --git a/packages/teko/tests/src/tNeumannSeries_tpetra.cpp b/packages/teko/tests/src/tNeumannSeries_tpetra.cpp index a57376164305..5fa19abd79e6 100644 --- a/packages/teko/tests/src/tNeumannSeries_tpetra.cpp +++ b/packages/teko/tests/src/tNeumannSeries_tpetra.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -59,9 +59,6 @@ #include "Thyra_DefaultDiagonalLinearOp.hpp" #include "Thyra_LinearOpTester.hpp" -// TriUtils includes -#include "Trilinos_Util_CrsMatrixGallery.h" - // Test-rig #include "Test_Utils.hpp" @@ -99,20 +96,20 @@ RCP > buildExampleOp(int type,RCPinsertGlobalValues(0,Teuchos::ArrayView(indices,3),Teuchos::ArrayView(values,3)); - + values[0] = 2.0; values[1] = 6.0; values[2] = 0.0; mat->insertGlobalValues(1,Teuchos::ArrayView(indices,3),Teuchos::ArrayView(values,3)); - + values[0] = 0.0; values[1] = 3.0; values[2] = 7.0; mat->insertGlobalValues(2,Teuchos::ArrayView(indices,3),Teuchos::ArrayView(values,3)); break; case 1: values[0] = 1.0; values[1] = 0.0; values[2] = 0.0; mat->insertGlobalValues(0,Teuchos::ArrayView(indices,3),Teuchos::ArrayView(values,3)); - + values[0] = 2.0; values[1] = 1.0; values[2] = 0.0; mat->insertGlobalValues(1,Teuchos::ArrayView(indices,3),Teuchos::ArrayView(values,3)); - + values[0] = 0.0; values[1] = 3.0; values[2] = 1.0; mat->insertGlobalValues(2,Teuchos::ArrayView(indices,3),Teuchos::ArrayView(values,3)); default: @@ -138,23 +135,23 @@ int tNeumannSeries_tpetra::runTest(int verbosity,std::ostream & stdstrm,std::ost failstrm << "tNeumannSeries_tpetra"; status = test_simpleOp(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"test_simpleOp\" ... PASSED"," \"test_simpleOp\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"test_simpleOp\" ... PASSED"," \"test_simpleOp\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = test_scaledOp(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"test_scaledOp\" ... PASSED"," \"test_scaledOp\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"test_scaledOp\" ... PASSED"," \"test_scaledOp\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = allTests; if(verbosity >= 10) { - Teko_TEST_MSG(failstrm,0,"tNeumannSeries_tpetra...PASSED","tNeumannSeries_tpetra...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"tNeumannSeries_tpetra...PASSED","tNeumannSeries_tpetra...FAILED"); } else {// Normal Operating Procedures (NOP) - Teko_TEST_MSG(failstrm,0,"...PASSED","tNeumannSeries_tpetra...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"...PASSED","tNeumannSeries_tpetra...FAILED"); } return failcount; @@ -186,7 +183,7 @@ bool tNeumannSeries_tpetra::test_simpleOp(int verbosity,std::ostream & os) RCP direct = invLib->getInverseFactory("Ifpack2"); Teko::LinearOp op = buildExampleOp(1,GetComm_tpetra()); - + Teko::LinearOp neuInv = Teko::buildInverse(*neumann,op); Teko::LinearOp dirInv = Teko::buildInverse(*direct,op); @@ -194,8 +191,8 @@ bool tNeumannSeries_tpetra::test_simpleOp(int verbosity,std::ostream & os) TEST_ASSERT(not result, std::endl << " tNeumannSeries_tpetra::test_simpleOp " << ": Comparing underresolved factory generated operator to correct operator"); - if(result || verbosity>=10) - os << ss.str(); + if(result || verbosity>=10) + os << ss.str(); } { @@ -212,7 +209,7 @@ bool tNeumannSeries_tpetra::test_simpleOp(int verbosity,std::ostream & os) RCP direct = invLib->getInverseFactory("Ifpack2"); Teko::LinearOp op = buildExampleOp(1,GetComm_tpetra()); - + Teko::LinearOp neuInv = Teko::buildInverse(*neumann,op); Teko::LinearOp dirInv = Teko::buildInverse(*direct,op); @@ -220,10 +217,10 @@ bool tNeumannSeries_tpetra::test_simpleOp(int verbosity,std::ostream & os) TEST_ASSERT(result, std::endl << " tNeumannSeries_tpetra::test_simpleOp " << ": Comparing factory generated operator to correct operator"); - if(not result || verbosity>=10) - os << ss.str(); + if(not result || verbosity>=10) + os << ss.str(); } - + return allPassed; } @@ -252,7 +249,7 @@ bool tNeumannSeries_tpetra::test_scaledOp(int verbosity,std::ostream & os) RCP direct = invLib->getInverseFactory("Ifpack2"); Teko::LinearOp op = buildExampleOp(2,GetComm_tpetra()); - + Teko::LinearOp neuInv = Teko::buildInverse(*neumann,op); Teko::LinearOp dirInv = Teko::buildInverse(*direct,op); @@ -260,10 +257,10 @@ bool tNeumannSeries_tpetra::test_scaledOp(int verbosity,std::ostream & os) TEST_ASSERT(result, std::endl << " tNeumannSeries_tpetra::test_scaledOp " << ": Comparing factory generated operator to correct operator"); - if(not result || verbosity>=10) - os << ss.str(); + if(not result || verbosity>=10) + os << ss.str(); } - + return allPassed; } diff --git a/packages/teko/tests/src/tPCDStrategy_tpetra.cpp b/packages/teko/tests/src/tPCDStrategy_tpetra.cpp index 7ab78acf6942..d02a243a3b1f 100644 --- a/packages/teko/tests/src/tPCDStrategy_tpetra.cpp +++ b/packages/teko/tests/src/tPCDStrategy_tpetra.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -58,9 +58,6 @@ #include "Thyra_DefaultBlockedLinearOp.hpp" #include "Thyra_LinearOpTester.hpp" -// TriUtils includes -#include "Trilinos_Util_CrsMatrixGallery.h" - // Test-rig #include "Test_Utils.hpp" @@ -139,17 +136,17 @@ int tPCDStrategy_tpetra::runTest(int verbosity,std::ostream & stdstrm,std::ostre failstrm << "tPCDStrategy_tpetra"; status = test_PCDStrategy(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"PCDStrategy\" ... PASSED"," \"PCDStrategy\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"PCDStrategy\" ... PASSED"," \"PCDStrategy\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; status = allTests; if(verbosity >= 10) { - Teko_TEST_MSG(failstrm,0,"tPCDStrategy_tpetra...PASSED","tPCDStrategy_tpetra...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"tPCDStrategy_tpetra...PASSED","tPCDStrategy_tpetra...FAILED"); } else {// Normal Operating Procedures (NOP) - Teko_TEST_MSG(failstrm,0,"...PASSED","tPCDStrategy_tpetra...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"...PASSED","tPCDStrategy_tpetra...FAILED"); } return failcount; diff --git a/packages/teko/tests/src/tParallelInverse_tpetra.cpp b/packages/teko/tests/src/tParallelInverse_tpetra.cpp index 98d5450765fa..4b84f0952918 100644 --- a/packages/teko/tests/src/tParallelInverse_tpetra.cpp +++ b/packages/teko/tests/src/tParallelInverse_tpetra.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -108,14 +108,14 @@ int tParallelInverse_tpetra::runTest(int verbosity,std::ostream & stdstrm,std::o status = test_inverse(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"inverse\" ... PASSED"," \"inverse\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"inverse\" ... PASSED"," \"inverse\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; #ifdef Teko_ENABLE_DEV_MODE // so the file nsjac.mm isn't required for release mode status = test_stridedInverse(verbosity,failstrm); - Teko_TEST_MSG(stdstrm,1," \"stridedInverse\" ... PASSED"," \"stridedInverse\" ... FAILED"); + Teko_TEST_MSG_tpetra(stdstrm,1," \"stridedInverse\" ... PASSED"," \"stridedInverse\" ... FAILED"); allTests &= status; failcount += status ? 0 : 1; totalrun++; @@ -123,10 +123,10 @@ int tParallelInverse_tpetra::runTest(int verbosity,std::ostream & stdstrm,std::o status = allTests; if(verbosity >= 10) { - Teko_TEST_MSG(failstrm,0,"tParallelInverse_tpetra...PASSED","tParallelInverse_tpetra...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"tParallelInverse_tpetra...PASSED","tParallelInverse_tpetra...FAILED"); } else {// Normal Operating Procedures (NOP) - Teko_TEST_MSG(failstrm,0,"...PASSED","tParallelInverse_tpetra...FAILED"); + Teko_TEST_MSG_tpetra(failstrm,0,"...PASSED","tParallelInverse_tpetra...FAILED"); } return failcount; diff --git a/packages/teko/tests/testdriver_tpetra.cpp b/packages/teko/tests/testdriver_tpetra.cpp index c7d4e7570a68..5372b848ca20 100644 --- a/packages/teko/tests/testdriver_tpetra.cpp +++ b/packages/teko/tests/testdriver_tpetra.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -59,37 +59,42 @@ #include "Kokkos_Core.hpp" -#ifdef HAVE_MPI - #include "Epetra_MpiComm.h" - #include "mpi.h" -#else - #include "Epetra_SerialComm.h" -#endif - #include "Test_Utils.hpp" -#include "src/tDiagonalPreconditionerFactory_tpetra.hpp" #include "src/tLU2x2PreconditionerFactory_tpetra.hpp" #include "src/tLSCStablePreconditionerFactory_tpetra.hpp" #include "src/tSIMPLEPreconditionerFactory_tpetra.hpp" #include "src/tLSCStabilized_tpetra.hpp" #include "src/tJacobi2x2PreconditionerFactory_tpetra.hpp" -#include "src/tBlockJacobiPreconditionerFactory_tpetra.hpp" #include "src/tBlockUpperTriInverseOp_tpetra.hpp" #include "src/tBlockLowerTriInverseOp_tpetra.hpp" #include "src/tLSCIntegrationTest_tpetra.hpp" #include "src/tLSCHIntegrationTest_tpetra.hpp" #include "src/tGraphLaplacian_tpetra.hpp" #include "src/tParallelInverse_tpetra.hpp" -#include "src/tExplicitOps_tpetra.hpp" + #include "src/tLumping_tpetra.hpp" #include "src/tAbsRowSum_tpetra.hpp" #include "src/tNeumannSeries_tpetra.hpp" #include "src/tPCDStrategy_tpetra.hpp" + + +#ifdef TEKO_HAVE_EPETRA +#include "src/tDiagonalPreconditionerFactory_tpetra.hpp" +#include "src/tBlockJacobiPreconditionerFactory_tpetra.hpp" +#include "src/tExplicitOps_tpetra.hpp" #include "src/Tpetra/tTpetraOperatorWrapper.hpp" #include "src/Tpetra/tStridedTpetraOperator.hpp" +#include "src/Tpetra/tBlockedTpetraOperator.hpp" +#ifdef HAVE_MPI + #include "Epetra_MpiComm.h" +#else + #include "Epetra_SerialComm.h" +#endif +#endif + #include "src/Tpetra/tInterlacedTpetra.hpp" #include "src/Tpetra/tBlockingTpetra.hpp" -#include "src/Tpetra/tBlockedTpetraOperator.hpp" + #include "src/Tpetra/tTpetraThyraConverter.hpp" #include "Tpetra_Core.hpp" @@ -109,38 +114,40 @@ int main(int argc,char * argv[]) { bool status = false; - { + { // need to protect kokkos and MPI // calls MPI_Init and MPI_Finalize Teuchos::GlobalMPISession mpiSession(&argc,&argv); Kokkos::initialize(argc,argv); +#ifdef TEKO_HAVE_EPETRA // build MPI/Serial communicators - #ifdef HAVE_MPI - Epetra_MpiComm Comm_epetra(MPI_COMM_WORLD); - #else - Epetra_SerialComm Comm_epetra; - #endif - Teuchos::RCP > Comm = Tpetra::getDefaultComm (); - +#ifdef HAVE_MPI + Epetra_MpiComm Comm_epetra(MPI_COMM_WORLD); +#else + Epetra_SerialComm Comm_epetra; +#endif // HAVE_MPI Teko::Test::UnitTest::SetComm(Teuchos::rcpFromRef(Comm_epetra)); +#endif // TEKO_HAVE_EPETRA + + Teuchos::RCP > Comm = Tpetra::getDefaultComm (); Teko::Test::UnitTest::SetComm_tpetra(Comm); - + Teuchos::CommandLineProcessor clp; - + int verbosity = 1; std::string faillog = "failure.log"; bool isfast = false; - + clp.setOption("verb",&verbosity,"How verbose is the output? 1 is normal 10 is a lot."); clp.setOption("log",&faillog,"File for failure information to go to (also high verbosity text)"); clp.setOption("fast","notfast",&isfast,"Run only fast tests"); clp.parse(argc,argv); - + Teuchos::RCP termout = Teuchos::getFancyOStream(Teuchos::rcpFromRef(std::cout)); Teuchos::RCP failout; std::ofstream failure; - + if(faillog=="stdout") { failout = termout; } @@ -148,27 +155,30 @@ int main(int argc,char * argv[]) failure.open(faillog.c_str()); failout = Teuchos::getFancyOStream(Teuchos::rcpFromRef(failure)); } - + termout->setOutputToRootOnly(0); failout->setOutputToRootOnly(0); - + // gdbIn(); Teko_ADD_UNIT_TEST(Teko::Test::tSIMPLEPreconditionerFactory_tpetra,SIMPLEPreconditionerFactory_tpetra); + #ifdef TEKO_HAVE_EPETRA Teko_ADD_UNIT_TEST(Teko::Test::tDiagonalPreconditionerFactory_tpetra,DiagonalPreconditionerFactory_tpetra); + Teko_ADD_UNIT_TEST(Teko::Test::tBlockJacobiPreconditionerFactory_tpetra,BlockJacobiPreconditionerFactory_tpetra); + Teko_ADD_UNIT_TEST(Teko::Test::tExplicitOps_tpetra,tExplicitOps_tpetra); + Teko_ADD_UNIT_TEST(Teko::Test::tTpetraOperatorWrapper,tTpetraOperatorWrapper); + #endif Teko_ADD_UNIT_TEST(Teko::Test::tLU2x2PreconditionerFactory_tpetra,LU2x2PreconditionerFactory_tpetra); Teko_ADD_UNIT_TEST(Teko::Test::tLSCStablePreconditionerFactory_tpetra,LSCStablePreconditionerFactory_tpetra); Teko_ADD_UNIT_TEST(Teko::Test::tLSCStabilized_tpetra,LSCStabilized_tpetra); Teko_ADD_UNIT_TEST(Teko::Test::tJacobi2x2PreconditionerFactory_tpetra,Jacobi2x2PreconditionerFactory_tpetra); - Teko_ADD_UNIT_TEST(Teko::Test::tBlockJacobiPreconditionerFactory_tpetra,BlockJacobiPreconditionerFactory_tpetra); Teko_ADD_UNIT_TEST(Teko::Test::tBlockUpperTriInverseOp_tpetra,BlockUpperTriInverseOp_tpetra); Teko_ADD_UNIT_TEST(Teko::Test::tBlockLowerTriInverseOp_tpetra,BlockLowerTriInverseOp_tpetra); - Teko_ADD_UNIT_TEST(Teko::Test::tTpetraOperatorWrapper,tTpetraOperatorWrapper); + Teko_ADD_UNIT_TEST(Teko::Test::tInterlacedTpetra,InterlacedTpetra); Teko_ADD_UNIT_TEST(Teko::Test::tBlockingTpetra,BlockingTpetra); Teko_ADD_UNIT_TEST(Teko::Test::tTpetraThyraConverter,TpetraThyraConverter); Teko_ADD_UNIT_TEST(Teko::Test::tGraphLaplacian_tpetra,tGraphLaplacian_tpetra); Teko_ADD_UNIT_TEST(Teko::Test::tParallelInverse_tpetra,tParallelInverse_tpetra); - Teko_ADD_UNIT_TEST(Teko::Test::tExplicitOps_tpetra,tExplicitOps_tpetra); Teko_ADD_UNIT_TEST(Teko::Test::tLSCHIntegrationTest_tpetra,LSCHIntegrationTest_tpetra); Teko_ADD_UNIT_TEST(Teko::Test::tLumping_tpetra,Lumping_tpetra); Teko_ADD_UNIT_TEST(Teko::Test::tAbsRowSum_tpetra,AbsRowSum_tpetra); @@ -176,14 +186,16 @@ int main(int argc,char * argv[]) Teko_ADD_UNIT_TEST(Teko::Test::tPCDStrategy_tpetra,PCDStrategy_tpetra); if(not isfast) { Teko_ADD_UNIT_TEST(Teko::Test::tLSCIntegrationTest_tpetra,LSCIntegrationTest_tpetra); + #ifdef TEKO_HAVE_EPETRA Teko_ADD_UNIT_TEST(Teko::Test::tStridedTpetraOperator,tStridedTpetraOperator); Teko_ADD_UNIT_TEST(Teko::Test::tBlockedTpetraOperator,tBlockedTpetraOperator); + #endif } - + status = Teko::Test::UnitTest::RunTests_tpetra(verbosity,*termout,*failout); - + if(not status) - *termout << "Teko tests failed" << std::endl; + *termout << "Teko tests failed" << std::endl; // release any stored Kokkos memory Teko::Test::UnitTest::ClearTests(); diff --git a/packages/teko/tests/unit_tests/tALOperator.cpp b/packages/teko/tests/unit_tests/tALOperator.cpp index 8a55c6fcfeca..a63dff21e029 100644 --- a/packages/teko/tests/unit_tests/tALOperator.cpp +++ b/packages/teko/tests/unit_tests/tALOperator.cpp @@ -11,6 +11,10 @@ * and test Teko_ALOperator. */ +#include "Teko_Config.h" + +#ifdef TEKO_HAVE_EPETRA + #include #include #include @@ -147,3 +151,5 @@ TEUCHOS_UNIT_TEST(tALOperator, test) TEST_ASSERT(errCode==0); } + +#endif // TEKO_HAVE_EPETRA \ No newline at end of file diff --git a/packages/teko/tests/unit_tests/tDiagnosticLinearOp.cpp b/packages/teko/tests/unit_tests/tDiagnosticLinearOp.cpp index 1871e3dbc4e8..ddc75d41f71d 100644 --- a/packages/teko/tests/unit_tests/tDiagnosticLinearOp.cpp +++ b/packages/teko/tests/unit_tests/tDiagnosticLinearOp.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,18 +32,20 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ +#include "Teko_Config.h" + #include #include #include @@ -52,14 +54,20 @@ #include #include +#ifdef TEKO_HAVE_EPETRA + #ifdef HAVE_MPI #include "Epetra_MpiComm.h" #else #include "Epetra_SerialComm.h" #endif +#include "Thyra_EpetraLinearOp.hpp" #include "Epetra_Map.h" #include "Epetra_CrsMatrix.h" + +#endif // TEKO_HAVE_EPETRA + #include "Tpetra_Map.hpp" #include "Tpetra_CrsMatrix.hpp" @@ -71,7 +79,7 @@ #include "Teko_PreconditionerInverseFactory.hpp" #include "Teko_PreconditionerLinearOp.hpp" -#include "Thyra_EpetraLinearOp.hpp" + #include "Thyra_TpetraLinearOp.hpp" // Test-rig @@ -85,6 +93,8 @@ using Teuchos::rcp; using Teuchos::rcp_dynamic_cast; using Teuchos::RCP; using Teuchos::rcpFromRef; + +#ifdef TEKO_HAVE_EPETRA using Thyra::epetraLinearOp; const RCP > buildSystem(const Epetra_Comm & comm,int size) @@ -107,7 +117,7 @@ const RCP > buildSystem(const Epetra_Comm & comm,int indices[0] = gid+iTemp[0]; indices[1] = gid+iTemp[1]; indices[2] = gid+iTemp[2]; - + if(gid==0) { vPtr = &values[1]; iPtr = &indices[1]; @@ -123,6 +133,7 @@ const RCP > buildSystem(const Epetra_Comm & comm,int return Thyra::nonconstEpetraLinearOp(mat); } +#endif // TEKO_HAVE_EPETRA const RCP > buildSystem(const Teuchos::RCP > comm,GO size) { @@ -144,7 +155,7 @@ const RCP > buildSystem(const Teuchos::RCP > buildSystem(const Teuchos::RCP(Thyra::tpetraVectorSpace(mat->getRangeMap()),Thyra::tpetraVectorSpace(mat->getDomainMap()),mat); } +#ifdef TEKO_HAVE_EPETRA TEUCHOS_UNIT_TEST(tDiagnosticLinearOp, application_test) { // build global (or serial communicator) @@ -192,6 +204,7 @@ TEUCHOS_UNIT_TEST(tDiagnosticLinearOp, application_test) // TEST_FLOATING_EQUALITY(timer.totalElapsedTime(),diag_A->totalTime(),0.05); // within 5% should be good enough TEST_EQUALITY(count,diag_A->numApplications()); } +#endif // TEKO_HAVE_EPETRA TEUCHOS_UNIT_TEST(tDiagnosticLinearOp, application_test_tpetra) { @@ -221,6 +234,7 @@ TEUCHOS_UNIT_TEST(tDiagnosticLinearOp, application_test_tpetra) TEST_EQUALITY(count,diag_A->numApplications()); } +#ifdef TEKO_HAVE_EPETRA TEUCHOS_UNIT_TEST(tDiagnosticPreconditionerFactory, inverse_lib_test) { // build global (or serial communicator) @@ -251,6 +265,7 @@ TEUCHOS_UNIT_TEST(tDiagnosticPreconditionerFactory, inverse_lib_test) Thyra::randomize(-1.0,1.0,x.ptr()); Teko::applyOp(invA,x,y); } +#endif // TEKO_HAVE_EPETRA TEUCHOS_UNIT_TEST(tDiagnosticPreconditionerFactory, inverse_lib_test_tpetra) { @@ -279,6 +294,7 @@ TEUCHOS_UNIT_TEST(tDiagnosticPreconditionerFactory, inverse_lib_test_tpetra) Teko::applyOp(invA,x,y); } +#ifdef TEKO_HAVE_EPETRA TEUCHOS_UNIT_TEST(tDiagnosticPreconditionerFactory, construction_test) { // build global (or serial communicator) @@ -308,12 +324,12 @@ TEUCHOS_UNIT_TEST(tDiagnosticPreconditionerFactory, construction_test) invA = Teko::buildInverse(*invFact,A); } - RCP > precOp = rcp_dynamic_cast >(invA,true); - RCP diagOp = rcp_dynamic_cast(precOp->getOperator(),true); + RCP > precOp = rcp_dynamic_cast >(invA,true); + RCP diagOp = rcp_dynamic_cast(precOp->getOperator(),true); } - TEST_EQUALITY(dpf.numInitialBuilds(),buildTime.numCalls()); + TEST_EQUALITY(dpf.numInitialBuilds(),buildTime.numCalls()); // TEST_FLOATING_EQUALITY(dpf.totalInitialBuildTime(), - // buildTime.totalElapsedTime(),0.05); // within 5% should be good enough + // buildTime.totalElapsedTime(),0.05); // within 5% should be good enough // test rebuild functionality Teuchos::Time rebuildTime("rebuild-time"); @@ -324,10 +340,11 @@ TEUCHOS_UNIT_TEST(tDiagnosticPreconditionerFactory, construction_test) Teko::rebuildInverse(*invFact,A,invA); } } - TEST_EQUALITY(dpf.numRebuilds(),rebuildTime.numCalls()); + TEST_EQUALITY(dpf.numRebuilds(),rebuildTime.numCalls()); // TEST_FLOATING_EQUALITY(dpf.totalRebuildTime(), - // rebuildTime.totalElapsedTime(),0.05); // within 5% should be good enough + // rebuildTime.totalElapsedTime(),0.05); // within 5% should be good enough } +#endif // TEKO_HAVE_EPETRA TEUCHOS_UNIT_TEST(tDiagnosticPreconditionerFactory, construction_test_tpetra) { @@ -354,12 +371,12 @@ TEUCHOS_UNIT_TEST(tDiagnosticPreconditionerFactory, construction_test_tpetra) invA = Teko::buildInverse(*invFact,A); } - RCP > precOp = rcp_dynamic_cast >(invA,true); - RCP diagOp = rcp_dynamic_cast(precOp->getOperator(),true); + RCP > precOp = rcp_dynamic_cast >(invA,true); + RCP diagOp = rcp_dynamic_cast(precOp->getOperator(),true); } - TEST_EQUALITY(dpf.numInitialBuilds(),buildTime.numCalls()); + TEST_EQUALITY(dpf.numInitialBuilds(),buildTime.numCalls()); // TEST_FLOATING_EQUALITY(dpf.totalInitialBuildTime(), - // buildTime.totalElapsedTime(),0.05); // within 5% should be good enough + // buildTime.totalElapsedTime(),0.05); // within 5% should be good enough // test rebuild functionality Teuchos::Time rebuildTime("rebuild-time"); @@ -370,11 +387,12 @@ TEUCHOS_UNIT_TEST(tDiagnosticPreconditionerFactory, construction_test_tpetra) Teko::rebuildInverse(*invFact,A,invA); } } - TEST_EQUALITY(dpf.numRebuilds(),rebuildTime.numCalls()); + TEST_EQUALITY(dpf.numRebuilds(),rebuildTime.numCalls()); // TEST_FLOATING_EQUALITY(dpf.totalRebuildTime(), - // rebuildTime.totalElapsedTime(),0.05); // within 5% should be good enough + // rebuildTime.totalElapsedTime(),0.05); // within 5% should be good enough } +#ifdef TEKO_HAVE_EPETRA TEUCHOS_UNIT_TEST(tDiagnosticLinearOp, residual_test) { // build global (or serial communicator) @@ -405,13 +423,13 @@ TEUCHOS_UNIT_TEST(tDiagnosticLinearOp, residual_test) Teko::applyOp(A,y,residual,-1.0,1.0); double myresid = Teko::norm_2(residual,0); - + TEST_FLOATING_EQUALITY(myresid,diag_invA->getResidualNorm(),1e-14); } // arbitrary alpha and beta { - double alpha = 3.141; + double alpha = 3.141; double beta = 1.618; Teko::MultiVector x = Thyra::createMember(invA->domain()); Teko::MultiVector y = Thyra::createMember(invA->range()); @@ -430,10 +448,11 @@ TEUCHOS_UNIT_TEST(tDiagnosticLinearOp, residual_test) // alpha (x - A z) - beta A y double myresid = Teko::norm_2(residual,0); - + TEST_FLOATING_EQUALITY(myresid,diag_invA->getResidualNorm(),1e-14); } } +#endif // TEKO_HAVE_EPETRA TEUCHOS_UNIT_TEST(tDiagnosticLinearOp, residual_test_tpetra) { @@ -461,14 +480,14 @@ TEUCHOS_UNIT_TEST(tDiagnosticLinearOp, residual_test_tpetra) Teko::applyOp(A,y,residual,-1.0,1.0); double myresid = Teko::norm_2(residual,0); - + // residual is O(1e-10), so check using rel tolerance of 1e-6 TEST_FLOATING_EQUALITY(myresid,diag_invA->getResidualNorm(),1e-6); } // arbitrary alpha and beta { - double alpha = 3.141; + double alpha = 3.141; double beta = 1.618; Teko::MultiVector x = Thyra::createMember(invA->domain()); Teko::MultiVector y = Thyra::createMember(invA->range()); diff --git a/packages/teko/tests/unit_tests/tDiagonalPreconditionerFactory.cpp b/packages/teko/tests/unit_tests/tDiagonalPreconditionerFactory.cpp index bca0a8da17e0..9f46b0bdbd67 100644 --- a/packages/teko/tests/unit_tests/tDiagonalPreconditionerFactory.cpp +++ b/packages/teko/tests/unit_tests/tDiagonalPreconditionerFactory.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -101,7 +101,7 @@ const RCP > buildSystem(const Epetra_Comm & comm,int indices[0] = gid+iTemp[0]; indices[1] = gid+iTemp[1]; indices[2] = gid+iTemp[2]; - + if(gid==0) { vPtr = &values[1]; iPtr = &indices[1]; @@ -167,18 +167,18 @@ TEUCHOS_UNIT_TEST(tDiagonalPreconditionerFactory, diag_inv_test) int numPrec = 3; RCP pl = buildLibPL(4); - RCP invLib = Teko::InverseLibrary::buildFromParameterList(*pl); + RCP invLib = Teko::InverseLibrary::buildFromParameterList(*pl); Teko::LinearOp A = buildSystem(Comm,20); - + for(int i=0;i invFact = invLib->getInverseFactory(precName[i]); Teko::LinearOp idA_fact = Teko::buildInverse(*invFact,A); - Teko::LinearOp idA_drct = Teko::getInvDiagonalOp(A,Teko::getDiagonalType(precName[i])); - + Teko::LinearOp idA_drct = Teko::getInvDiagonalOp(A,Teko::getDiagonalType(precName[i])); + Thyra::LinearOpTester tester; tester.show_all_tests(true); - + const bool result = tester.compare( *idA_fact, *idA_drct, Teuchos::ptrFromRef(out)); if (!result) { out << "Apply 0: FAILURE (\"" << precName[i] << "\")" << std::endl; @@ -218,15 +218,15 @@ TEUCHOS_UNIT_TEST(tDiagonalPreconditionerFactory, blkdiag_inv_test) { RCP pl = buildLibPL(1); // test diagonal construction - RCP invLib = Teko::InverseLibrary::buildFromParameterList(*pl); - + RCP invLib = Teko::InverseLibrary::buildFromParameterList(*pl); + RCP invFact = invLib->getInverseFactory(precName); Teko::LinearOp idA_fact = Teko::buildInverse(*invFact,A); // test type Teko::LinearOp srcOp = Teko::extractOperatorFromPrecOp(idA_fact); TEST_ASSERT(Teuchos::rcp_dynamic_cast(srcOp)!=Teuchos::null); - + Teko::LinearOp idA_drct = Teko::getInvDiagonalOp(A,Teko::Diagonal); Thyra::LinearOpTester tester; @@ -243,8 +243,8 @@ TEUCHOS_UNIT_TEST(tDiagonalPreconditionerFactory, blkdiag_inv_test) { RCP pl = buildLibPL(blockSize); - RCP invLib = Teko::InverseLibrary::buildFromParameterList(*pl); - + RCP invLib = Teko::InverseLibrary::buildFromParameterList(*pl); + RCP invFact = invLib->getInverseFactory(precName); Teko::LinearOp idA_fact = Teko::buildInverse(*invFact,A); diff --git a/packages/teko/tests/unit_tests/tDiagonallyScaledPreconditioner.cpp b/packages/teko/tests/unit_tests/tDiagonallyScaledPreconditioner.cpp index 44786fdc3e5e..a3cdbb6bd8dc 100644 --- a/packages/teko/tests/unit_tests/tDiagonallyScaledPreconditioner.cpp +++ b/packages/teko/tests/unit_tests/tDiagonallyScaledPreconditioner.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -52,6 +52,9 @@ #include #include +#include "Teko_Config.h" + +#ifdef TEKO_HAVE_EPETRA #ifdef HAVE_MPI #include "Epetra_MpiComm.h" #else @@ -60,6 +63,9 @@ #include "Epetra_Map.h" #include "Epetra_CrsMatrix.h" +#include "Thyra_EpetraLinearOp.hpp" +#endif + #include "Tpetra_Map.hpp" #include "Tpetra_CrsMatrix.hpp" @@ -70,7 +76,6 @@ #include "Teko_PreconditionerInverseFactory.hpp" #include "Teko_PreconditionerLinearOp.hpp" -#include "Thyra_EpetraLinearOp.hpp" #include "Thyra_TpetraLinearOp.hpp" #include "Thyra_LinearOpTester.hpp" @@ -85,8 +90,9 @@ using Teuchos::rcp; using Teuchos::rcp_dynamic_cast; using Teuchos::RCP; using Teuchos::rcpFromRef; -using Thyra::epetraLinearOp; +#ifdef TEKO_HAVE_EPETRA +using Thyra::epetraLinearOp; const RCP > buildSystem(const Epetra_Comm & comm,int size) { Epetra_Map map(size,0,comm); @@ -108,7 +114,7 @@ const RCP > buildSystem(const Epetra_Comm & comm,int indices[0] = gid+iTemp[0]; indices[1] = gid+iTemp[1]; indices[2] = gid+iTemp[2]; - + if(gid==0) { vPtr = &values[1]; iPtr = &indices[1]; @@ -124,6 +130,7 @@ const RCP > buildSystem(const Epetra_Comm & comm,int return Thyra::nonconstEpetraLinearOp(mat); } +#endif const RCP > buildSystem(const Teuchos::RCP > comm,GO size) { @@ -145,7 +152,7 @@ const RCP > buildSystem(const Teuchos::RCP > buildSystem(const Teuchos::RCP(Thyra::tpetraVectorSpace(mat->getRangeMap()),Thyra::tpetraVectorSpace(mat->getDomainMap()),mat); } +#ifdef TEKO_HAVE_EPETRA TEUCHOS_UNIT_TEST(tDiagonallyScaledPreconditioner, invfactory_test) { // build global (or serial communicator) @@ -177,8 +185,8 @@ TEUCHOS_UNIT_TEST(tDiagonallyScaledPreconditioner, invfactory_test) diagList.set("Inverse Factory","Amesos"); RCP invLib = Teko::InverseLibrary::buildFromParameterList(pl); - RCP invFact = invLib->getInverseFactory("DiagScal"); - RCP dirFact = invLib->getInverseFactory("Amesos"); + RCP invFact = invLib->getInverseFactory("DiagScal"); + RCP dirFact = invLib->getInverseFactory("Amesos"); RCP > A = buildSystem(Comm,50); @@ -197,6 +205,7 @@ TEUCHOS_UNIT_TEST(tDiagonallyScaledPreconditioner, invfactory_test) else out << "Apply 0: SUCCESS" << std::endl; } +#endif TEUCHOS_UNIT_TEST(tDiagonallyScaledPreconditioner, invfactory_test_tpetra) { @@ -209,8 +218,8 @@ TEUCHOS_UNIT_TEST(tDiagonallyScaledPreconditioner, invfactory_test_tpetra) diagList.set("Inverse Factory","Belos"); RCP invLib = Teko::InverseLibrary::buildFromParameterList(pl); - RCP invFact = invLib->getInverseFactory("DiagScal"); - RCP dirFact = invLib->getInverseFactory("Ifpack2"); + RCP invFact = invLib->getInverseFactory("DiagScal"); + RCP dirFact = invLib->getInverseFactory("Ifpack2"); RCP > A = buildSystem(Comm,50); @@ -230,6 +239,7 @@ TEUCHOS_UNIT_TEST(tDiagonallyScaledPreconditioner, invfactory_test_tpetra) out << "Apply 0: SUCCESS" << std::endl; } +#ifdef TEKO_HAVE_EPETRA TEUCHOS_UNIT_TEST(tDiagonallyScaledPreconditioner, application_test_row) { // build global (or serial communicator) @@ -284,6 +294,7 @@ TEUCHOS_UNIT_TEST(tDiagonallyScaledPreconditioner, application_test_row) else out << "Apply 0: SUCCESS" << std::endl; } +#endif TEUCHOS_UNIT_TEST(tDiagonallyScaledPreconditioner, application_test_row_tpetra) { @@ -336,6 +347,7 @@ TEUCHOS_UNIT_TEST(tDiagonallyScaledPreconditioner, application_test_row_tpetra) out << "Apply 0: SUCCESS" << std::endl; } +#ifdef TEKO_HAVE_EPETRA TEUCHOS_UNIT_TEST(tDiagonallyScaledPreconditioner, application_test_column) { // build global (or serial communicator) @@ -388,6 +400,7 @@ TEUCHOS_UNIT_TEST(tDiagonallyScaledPreconditioner, application_test_column) else out << "Apply 0: SUCCESS" << std::endl; } +#endif TEUCHOS_UNIT_TEST(tDiagonallyScaledPreconditioner, application_test_column_tpetra) { @@ -438,6 +451,7 @@ TEUCHOS_UNIT_TEST(tDiagonallyScaledPreconditioner, application_test_column_tpetr out << "Apply 0: SUCCESS" << std::endl; } +#ifdef TEKO_HAVE_EPETRA TEUCHOS_UNIT_TEST(tDiagonalOperator, replaceValues) { #ifdef HAVE_MPI @@ -452,6 +466,7 @@ TEUCHOS_UNIT_TEST(tDiagonalOperator, replaceValues) Teko::replaceValue(diag,0.0,1.0); Teko::LinearOp invDiagOp = Teko::buildInvDiagonal(diag); } +#endif TEUCHOS_UNIT_TEST(tDiagonalOperator, replaceValues_tpetra) { diff --git a/packages/teko/tests/unit_tests/tInverseFactoryOperator.cpp b/packages/teko/tests/unit_tests/tInverseFactoryOperator.cpp index 1c90a78a7e84..ce899f5f988f 100644 --- a/packages/teko/tests/unit_tests/tInverseFactoryOperator.cpp +++ b/packages/teko/tests/unit_tests/tInverseFactoryOperator.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -48,6 +48,9 @@ #include #include +#include "Teko_ConfigDefs.hpp" + +#ifdef TEKO_HAVE_EPETRA #ifdef HAVE_MPI # include "Epetra_MpiComm.h" #else @@ -55,21 +58,23 @@ #endif #include "Epetra_Vector.h" #include "Epetra_CrsMatrix.h" +#include "Teko_EpetraOperatorWrapper.hpp" +#include "Thyra_EpetraLinearOp.hpp" +#include "Teko_InverseFactoryOperator.hpp" +#endif + #include "Tpetra_Vector.hpp" #include "Tpetra_CrsMatrix.hpp" -#include "Teko_ConfigDefs.hpp" #include "Teko_Utilities.hpp" #include "Teko_PreconditionerFactory.hpp" #include "Teko_InverseLibrary.hpp" -#include "Teko_InverseFactoryOperator.hpp" #include "Teko_TpetraInverseFactoryOperator.hpp" #include "Teko_JacobiPreconditionerFactory.hpp" #include "Teko_PreconditionerInverseFactory.hpp" -#include "Teko_EpetraOperatorWrapper.hpp" + #include "Teko_TpetraOperatorWrapper.hpp" -#include "Thyra_EpetraLinearOp.hpp" #include "Thyra_TpetraLinearOp.hpp" #include "Thyra_LinearOpTester.hpp" #include "Thyra_DefaultBlockedLinearOp.hpp" @@ -88,6 +93,7 @@ using Teuchos::rcp_dynamic_cast; /////////////////////////////////////////////////////////// +#ifdef TEKO_HAVE_EPETRA const RCP buildSystem(const Epetra_Comm & comm,int size) { Epetra_Map map(size,0,comm); @@ -109,7 +115,7 @@ const RCP buildSystem(const Epetra_Comm & comm,int size) indices[0] = gid+iTemp[0]; indices[1] = gid+iTemp[1]; indices[2] = gid+iTemp[2]; - + if(gid==0) { vPtr = &values[1]; iPtr = &indices[1]; @@ -126,6 +132,7 @@ const RCP buildSystem(const Epetra_Comm & comm,int size) // return Thyra::nonconstEpetraLinearOp(mat); return mat; } +#endif const RCP > buildSystem(const Teuchos::RCP > comm,GO size) { @@ -147,7 +154,7 @@ const RCP > buildSystem(const Teuchos::RCP > buildSystem(const Teuchos::RCP(Thyra::tpetraVectorSpace(mat->getRangeMap()),Thyra::tpetraVectorSpace(mat->getDomainMap()),mat); } -TEUCHOS_UNIT_TEST(tInverseFactoryOperator, test_Direct_Solve) +#ifdef TEKO_HAVE_EPETRA +TEUCHOS_UNIT_TEST(tInverseFactoryOperator, test_Direct_Solve) { // build global (or serial communicator) #ifdef HAVE_MPI @@ -177,7 +185,7 @@ TEUCHOS_UNIT_TEST(tInverseFactoryOperator, test_Direct_Solve) Teuchos::RCP invLib = Teko::InverseLibrary::buildFromStratimikos(); Teuchos::RCP invFactory = invLib->getInverseFactory("Amesos"); - + Teuchos::RCP eA = buildSystem(comm,50); Teko::LinearOp A = Thyra::epetraLinearOp(eA); Teko::ModifiableLinearOp invA = Teko::buildInverse(*invFactory,A); @@ -194,7 +202,7 @@ TEUCHOS_UNIT_TEST(tInverseFactoryOperator, test_Direct_Solve) Thyra::LinearOpTester tester; tester.show_all_tests(true); tester.set_all_error_tol(1e-14); - + const bool result = tester.compare( *invA, *testInvA, Teuchos::ptrFromRef(out)); if (!result) { out << "Apply 0: FAILURE" << std::endl; @@ -214,7 +222,7 @@ TEUCHOS_UNIT_TEST(tInverseFactoryOperator, test_Direct_Solve) Thyra::LinearOpTester tester; tester.show_all_tests(true); tester.set_all_error_tol(1e-14); - + const bool result = tester.compare( *invA, *testInvA, Teuchos::ptrFromRef(out)); if (!result) { out << "Apply 0: FAILURE" << std::endl; @@ -224,8 +232,9 @@ TEUCHOS_UNIT_TEST(tInverseFactoryOperator, test_Direct_Solve) out << "Apply 0: SUCCESS" << std::endl; } } +#endif -TEUCHOS_UNIT_TEST(tInverseFactoryOperator, test_Direct_Solve_tpetra) +TEUCHOS_UNIT_TEST(tInverseFactoryOperator, test_Direct_Solve_tpetra) { // build global (or serial communicator) RCP > comm = Tpetra::getDefaultComm (); @@ -233,7 +242,7 @@ TEUCHOS_UNIT_TEST(tInverseFactoryOperator, test_Direct_Solve_tpetra) Teuchos::RCP invLib = Teko::InverseLibrary::buildFromStratimikos(); Teuchos::RCP invFactory = invLib->getInverseFactory("Ifpack2"); - + Teuchos::RCP > eA = buildSystem(comm,50); Teko::LinearOp A = Thyra::tpetraLinearOp(Thyra::tpetraVectorSpace(eA->getRangeMap()),Thyra::tpetraVectorSpace(eA->getDomainMap()),eA); Teko::ModifiableLinearOp invA = Teko::buildInverse(*invFactory,A); @@ -249,7 +258,7 @@ TEUCHOS_UNIT_TEST(tInverseFactoryOperator, test_Direct_Solve_tpetra) Thyra::LinearOpTester tester; tester.show_all_tests(true); tester.set_all_error_tol(1e-14); - + const bool result = tester.compare( *invA, *testInvA, Teuchos::ptrFromRef(out)); if (!result) { out << "Apply 0: FAILURE" << std::endl; @@ -268,7 +277,7 @@ TEUCHOS_UNIT_TEST(tInverseFactoryOperator, test_Direct_Solve_tpetra) Thyra::LinearOpTester tester; tester.show_all_tests(true); tester.set_all_error_tol(1e-14); - + const bool result = tester.compare( *invA, *testInvA, Teuchos::ptrFromRef(out)); if (!result) { out << "Apply 0: FAILURE" << std::endl; @@ -279,7 +288,8 @@ TEUCHOS_UNIT_TEST(tInverseFactoryOperator, test_Direct_Solve_tpetra) } } -TEUCHOS_UNIT_TEST(tInverseFactoryOperator, test_Block_Solve) +#ifdef TEKO_HAVE_EPETRA +TEUCHOS_UNIT_TEST(tInverseFactoryOperator, test_Block_Solve) { // build global (or serial communicator) #ifdef HAVE_MPI @@ -297,7 +307,7 @@ TEUCHOS_UNIT_TEST(tInverseFactoryOperator, test_Block_Solve) Teko::ModifiableLinearOp invA_00 = Teko::buildInverse(*amesosFactory,A_00); Teko::LinearOp A = Thyra::block2x2(A_00,Teuchos::null,Teuchos::null,A_00); - Teko::LinearOp invA = Thyra::block2x2(invA_00,Teuchos::null,Teuchos::null,invA_00); + Teko::LinearOp invA = Thyra::block2x2(invA_00,Teuchos::null,Teuchos::null,invA_00); Teuchos::RCP eInvA = Teuchos::rcp(new Teko::Epetra::EpetraOperatorWrapper(invA)); Teko::LinearOp cmpInvA = Thyra::epetraLinearOp(eInvA); @@ -317,7 +327,7 @@ TEUCHOS_UNIT_TEST(tInverseFactoryOperator, test_Block_Solve) Thyra::LinearOpTester tester; tester.show_all_tests(true); tester.set_all_error_tol(1e-14); - + const bool result = tester.compare( *cmpInvA, *testInvA, Teuchos::ptrFromRef(out)); if (!result) { out << "Apply 0: FAILURE" << std::endl; @@ -337,7 +347,7 @@ TEUCHOS_UNIT_TEST(tInverseFactoryOperator, test_Block_Solve) Thyra::LinearOpTester tester; tester.show_all_tests(true); tester.set_all_error_tol(1e-14); - + const bool result = tester.compare( *cmpInvA, *testInvA, Teuchos::ptrFromRef(out)); if (!result) { out << "Apply 0: FAILURE" << std::endl; @@ -347,8 +357,9 @@ TEUCHOS_UNIT_TEST(tInverseFactoryOperator, test_Block_Solve) out << "Apply 0: SUCCESS" << std::endl; } } +#endif -TEUCHOS_UNIT_TEST(tInverseFactoryOperator, test_Block_Solve_tpetra) +TEUCHOS_UNIT_TEST(tInverseFactoryOperator, test_Block_Solve_tpetra) { // build global (or serial communicator) RCP > comm = Tpetra::getDefaultComm (); @@ -362,7 +373,7 @@ TEUCHOS_UNIT_TEST(tInverseFactoryOperator, test_Block_Solve_tpetra) Teko::ModifiableLinearOp invA_00 = Teko::buildInverse(*amesosFactory,A_00); Teko::LinearOp A = Thyra::block2x2(A_00,Teuchos::null,Teuchos::null,A_00); - Teko::LinearOp invA = Thyra::block2x2(invA_00,Teuchos::null,Teuchos::null,invA_00); + Teko::LinearOp invA = Thyra::block2x2(invA_00,Teuchos::null,Teuchos::null,invA_00); Teuchos::RCP > eInvA = Teuchos::rcp(new Teko::TpetraHelpers::TpetraOperatorWrapper(invA)); Teko::LinearOp cmpInvA = Thyra::tpetraLinearOp(Thyra::tpetraVectorSpace(eInvA->getRangeMap()),Thyra::tpetraVectorSpace(eInvA->getDomainMap()),eInvA); @@ -381,7 +392,7 @@ TEUCHOS_UNIT_TEST(tInverseFactoryOperator, test_Block_Solve_tpetra) Thyra::LinearOpTester tester; tester.show_all_tests(true); tester.set_all_error_tol(1e-14); - + const bool result = tester.compare( *cmpInvA, *testInvA, Teuchos::ptrFromRef(out)); if (!result) { out << "Apply 0: FAILURE" << std::endl; @@ -400,7 +411,7 @@ TEUCHOS_UNIT_TEST(tInverseFactoryOperator, test_Block_Solve_tpetra) Thyra::LinearOpTester tester; tester.show_all_tests(true); tester.set_all_error_tol(1e-14); - + const bool result = tester.compare( *cmpInvA, *testInvA, Teuchos::ptrFromRef(out)); if (!result) { out << "Apply 0: FAILURE" << std::endl; diff --git a/packages/teko/tests/unit_tests/tIterativePreconditionerFactory.cpp b/packages/teko/tests/unit_tests/tIterativePreconditionerFactory.cpp index 88b6411d91e5..48e4520886d9 100644 --- a/packages/teko/tests/unit_tests/tIterativePreconditionerFactory.cpp +++ b/packages/teko/tests/unit_tests/tIterativePreconditionerFactory.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -51,6 +51,9 @@ #include #include +#include "Teko_Utilities.hpp" + +#ifdef TEKO_HAVE_EPETRA #ifdef HAVE_MPI #include "Epetra_MpiComm.h" #else @@ -59,16 +62,18 @@ #include "Epetra_Map.h" #include "Epetra_CrsMatrix.h" +#endif // Teko-Package includes -#include "Teko_Utilities.hpp" #include "Teko_InverseLibrary.hpp" #include "Teko_InverseFactory.hpp" #include "Teko_IterativePreconditionerFactory.hpp" #include "Teko_PreconditionerInverseFactory.hpp" // Thyra includes +#ifdef TEKO_HAVE_EPETRA #include "Thyra_EpetraLinearOp.hpp" +#endif #include "Thyra_LinearOpTester.hpp" // Tpetra includes @@ -88,8 +93,9 @@ typedef Teko::NT NT; using Teuchos::rcp; using Teuchos::RCP; using Teuchos::rcpFromRef; -using Thyra::epetraLinearOp; +#ifdef TEKO_HAVE_EPETRA +using Thyra::epetraLinearOp; const RCP > build2x2(const Epetra_Comm & comm,double a,double b,double c,double d) { RCP map = rcp(new Epetra_Map(2,0,comm)); @@ -111,6 +117,7 @@ const RCP > build2x2(const Epetra_Comm & comm, return Thyra::epetraLinearOp(blk); } +#endif const RCP > build2x2(const Teuchos::RCP > comm,ST a,ST b,ST c,ST d) { @@ -130,7 +137,7 @@ const RCP > build2x2(const Teuchos::RCPinsertGlobalValues(0,Teuchos::ArrayView(indices,2),Teuchos::ArrayView(row0,2)); blk->insertGlobalValues(1,Teuchos::ArrayView(indices,2),Teuchos::ArrayView(row1,2)); blk->fillComplete(); - + return Thyra::tpetraLinearOp(Thyra::tpetraVectorSpace(blk->getDomainMap()),Thyra::tpetraVectorSpace(blk->getRangeMap()),blk); } @@ -144,6 +151,7 @@ RCP buildLibPL(int count,std::string scalingType) return pl; } +#ifdef TEKO_HAVE_EPETRA TEUCHOS_UNIT_TEST(tIterativePreconditionerFactory, parameter_list_init) { // build global (or serial communicator) @@ -170,7 +178,7 @@ TEUCHOS_UNIT_TEST(tIterativePreconditionerFactory, parameter_list_init) Teko::LinearOp prec = Teko::buildInverse(*invFact,A); } catch(...) { - success = false; + success = false; out << "Failed correct parameter list" << std::endl; } } @@ -214,6 +222,7 @@ TEUCHOS_UNIT_TEST(tIterativePreconditionerFactory, parameter_list_init) } } } +#endif TEUCHOS_UNIT_TEST(tIterativePreconditionerFactory, parameter_list_init_tpetra) { @@ -237,7 +246,7 @@ TEUCHOS_UNIT_TEST(tIterativePreconditionerFactory, parameter_list_init_tpetra) Teko::LinearOp prec = Teko::buildInverse(*invFact,A); } catch(...) { - success = false; + success = false; out << "Failed correct parameter list" << std::endl; } } @@ -282,6 +291,7 @@ TEUCHOS_UNIT_TEST(tIterativePreconditionerFactory, parameter_list_init_tpetra) } } +#ifdef TEKO_HAVE_EPETRA TEUCHOS_UNIT_TEST(tIterativePreconditionerFactory, inverse_test) { // build global (or serial communicator) @@ -316,6 +326,7 @@ TEUCHOS_UNIT_TEST(tIterativePreconditionerFactory, inverse_test) out << "Apply 0: SUCCESS" << std::endl; } } +#endif TEUCHOS_UNIT_TEST(tIterativePreconditionerFactory, inverse_test_tpetra) { @@ -348,6 +359,7 @@ TEUCHOS_UNIT_TEST(tIterativePreconditionerFactory, inverse_test_tpetra) } } +#ifdef TEKO_HAVE_EPETRA TEUCHOS_UNIT_TEST(tIterativePreconditionerFactory, constructor_test) { // build global (or serial communicator) @@ -400,6 +412,7 @@ TEUCHOS_UNIT_TEST(tIterativePreconditionerFactory, constructor_test) out << "Apply 2: SUCCESS" << std::endl; } } +#endif TEUCHOS_UNIT_TEST(tIterativePreconditionerFactory, constructor_test_tpetra) { diff --git a/packages/teko/tests/unit_tests/tLU2x2InverseOp.cpp b/packages/teko/tests/unit_tests/tLU2x2InverseOp.cpp index f04269f4fd4b..4e1807682d2f 100644 --- a/packages/teko/tests/unit_tests/tLU2x2InverseOp.cpp +++ b/packages/teko/tests/unit_tests/tLU2x2InverseOp.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -51,6 +51,9 @@ #include #include +#include "Teko_ConfigDefs.hpp" + +#ifdef TEKO_HAVE_EPETRA #ifdef HAVE_MPI #include "Epetra_MpiComm.h" #else @@ -59,6 +62,7 @@ #include "Epetra_Map.h" #include "Epetra_CrsMatrix.h" +#endif // Teko-Package includes #include "Teko_Utilities.hpp" @@ -67,7 +71,9 @@ #include "Teko_LU2x2InverseOp.hpp" // Thyra includes +#ifdef TEKO_HAVE_EPETRA #include "Thyra_EpetraLinearOp.hpp" +#endif #include "Thyra_LinearOpTester.hpp" // Tpetra includes @@ -87,8 +93,9 @@ typedef Teko::NT NT; using Teuchos::rcp; using Teuchos::RCP; using Teuchos::rcpFromRef; -using Thyra::epetraLinearOp; +#ifdef TEKO_HAVE_EPETRA +using Thyra::epetraLinearOp; const RCP > build2x2(const Epetra_Comm & comm,double a,double b,double c,double d) { RCP map = rcp(new Epetra_Map(2,0,comm)); @@ -110,6 +117,7 @@ const RCP > build2x2(const Epetra_Comm & comm, return Thyra::epetraLinearOp(blk); } +#endif const RCP > build2x2(const Teuchos::RCP > comm,ST a,ST b,ST c,ST d) { @@ -129,10 +137,11 @@ const RCP > build2x2(const Teuchos::RCPinsertGlobalValues(0,Teuchos::ArrayView(indices,2),Teuchos::ArrayView(row0,2)); blk->insertGlobalValues(1,Teuchos::ArrayView(indices,2),Teuchos::ArrayView(row1,2)); blk->fillComplete(); - + return Thyra::tpetraLinearOp(Thyra::tpetraVectorSpace(blk->getRangeMap()),Thyra::tpetraVectorSpace(blk->getDomainMap()),blk); } +#ifdef TEKO_HAVE_EPETRA TEUCHOS_UNIT_TEST(tLU2x2InverseOp, exact_test) { // build global (or serial communicator) @@ -168,7 +177,7 @@ TEUCHOS_UNIT_TEST(tLU2x2InverseOp, exact_test) Teko::LinearOp invS = Teko::buildInverse(*invFact,S); Teko::LinearOp invA = Teko::createLU2x2InverseOp(A,invA_00,invA_00,invS,"Approximation"); - + const bool result = tester.compare( *invA, *iA, Teuchos::ptrFromRef(out)); if (!result) { out << "Apply: FAILURE" << std::endl; @@ -178,6 +187,7 @@ TEUCHOS_UNIT_TEST(tLU2x2InverseOp, exact_test) out << "Apply: SUCCESS" << std::endl; } } +#endif TEUCHOS_UNIT_TEST(tLU2x2InverseOp, exact_test_tpetra) { @@ -210,7 +220,7 @@ TEUCHOS_UNIT_TEST(tLU2x2InverseOp, exact_test_tpetra) Teko::LinearOp invS = Teko::buildInverse(*invFact,S); Teko::LinearOp invA = Teko::createLU2x2InverseOp(A,invA_00,invA_00,invS,"Approximation"); - + const bool result = tester.compare( *invA, *iA, Teuchos::ptrFromRef(out)); if (!result) { out << "Apply: FAILURE" << std::endl; diff --git a/packages/teko/tests/unit_tests/tProbingFactory.cpp b/packages/teko/tests/unit_tests/tProbingFactory.cpp index 6e3481439a62..b4aa9fb168fe 100644 --- a/packages/teko/tests/unit_tests/tProbingFactory.cpp +++ b/packages/teko/tests/unit_tests/tProbingFactory.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -107,7 +107,7 @@ const RCP > buildSystem(const Epetra_Comm & comm,int indices[0] = gid+iTemp[0]; indices[1] = gid+iTemp[1]; indices[2] = gid+iTemp[2]; - + if(gid==0) { vPtr = &values[1]; iPtr = &indices[1]; @@ -134,7 +134,7 @@ TEUCHOS_UNIT_TEST(tProbingFactory, basic_test) #endif Teko::LinearOp lo = buildSystem(Comm,10); - + Teuchos::RCP invLib = Teko::InverseLibrary::buildFromStratimikos(); Teuchos::RCP directSolveFactory = invLib->getInverseFactory("Amesos"); @@ -173,7 +173,7 @@ TEUCHOS_UNIT_TEST(tProbingFactory, parameterlist_constr) #endif Teko::LinearOp lo = buildSystem(Comm,10); - + Teuchos::RCP invLib = Teko::InverseLibrary::buildFromStratimikos(); Teuchos::RCP directSolveFactory = invLib->getInverseFactory("Amesos"); @@ -181,20 +181,20 @@ TEUCHOS_UNIT_TEST(tProbingFactory, parameterlist_constr) Teuchos::ParameterList pl; pl.set("Inverse Type","Amesos"); pl.set("Probing Graph Operator",lo); - + Teuchos::RCP probeFact = rcp(new Teko::ProbingPreconditionerFactory); probeFact->initializeFromParameterList(pl); - + RCP invFact = Teuchos::rcp(new Teko::PreconditionerInverseFactory(probeFact,Teuchos::null)); - + Teko::LinearOp probedInverse = Teko::buildInverse(*invFact,lo); Teko::LinearOp invLo = Teko::buildInverse(*directSolveFactory,lo); - + Thyra::LinearOpTester tester; tester.dump_all(true); tester.show_all_tests(true); - + { const bool result = tester.compare( *probedInverse, *invLo, Teuchos::ptrFromRef(out)); if (!result) { @@ -213,20 +213,20 @@ TEUCHOS_UNIT_TEST(tProbingFactory, parameterlist_constr) Teuchos::ParameterList pl; pl.set("Inverse Type","Amesos"); pl.set("Probing Graph",theGraph); - + Teuchos::RCP probeFact = rcp(new Teko::ProbingPreconditionerFactory); probeFact->initializeFromParameterList(pl); - + RCP invFact = Teuchos::rcp(new Teko::PreconditionerInverseFactory(probeFact,Teuchos::null)); - + Teko::LinearOp probedInverse = Teko::buildInverse(*invFact,lo); Teko::LinearOp invLo = Teko::buildInverse(*directSolveFactory,lo); - + Thyra::LinearOpTester tester; tester.dump_all(true); tester.show_all_tests(true); - + { const bool result = tester.compare( *probedInverse, *invLo, Teuchos::ptrFromRef(out)); if (!result) { @@ -257,8 +257,8 @@ TEUCHOS_UNIT_TEST(tProbingFactory, invlib_constr) Teuchos::ParameterList pl; pl.set("Prober",subList); - - + + Teuchos::RCP invLib = Teko::InverseLibrary::buildFromParameterList(pl); Teuchos::RCP proberFactory = invLib->getInverseFactory("Prober"); Teuchos::RCP directSolveFactory = invLib->getInverseFactory("Amesos"); @@ -266,11 +266,11 @@ TEUCHOS_UNIT_TEST(tProbingFactory, invlib_constr) { Teko::LinearOp probedInverse = Teko::buildInverse(*proberFactory,lo); Teko::LinearOp invLo = Teko::buildInverse(*directSolveFactory,lo); - + Thyra::LinearOpTester tester; tester.dump_all(true); tester.show_all_tests(true); - + { const bool result = tester.compare( *probedInverse, *invLo, Teuchos::ptrFromRef(out)); if (!result) { diff --git a/packages/teko/tests/unit_tests/tReorderBlocking.cpp b/packages/teko/tests/unit_tests/tReorderBlocking.cpp index ca967a667cc0..29f134ed0656 100644 --- a/packages/teko/tests/unit_tests/tReorderBlocking.cpp +++ b/packages/teko/tests/unit_tests/tReorderBlocking.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -51,6 +51,9 @@ #include #include +#include "Teko_ConfigDefs.hpp" + +#ifdef TEKO_HAVE_EPETRA #ifdef HAVE_MPI #include "Epetra_MpiComm.h" #else @@ -59,11 +62,13 @@ #include "Epetra_Map.h" #include "Epetra_CrsMatrix.h" +#include "Thyra_EpetraLinearOp.hpp" +#endif + #include "Tpetra_Map.hpp" #include "Tpetra_CrsMatrix.hpp" // Teko-Package includes -#include "Teko_ConfigDefs.hpp" #include "Teko_Utilities.hpp" #include "Teko_InverseLibrary.hpp" #include "Teko_InverseFactory.hpp" @@ -71,7 +76,6 @@ #include "Teko_ReorderedLinearOp.hpp" // Thyra includes -#include "Thyra_EpetraLinearOp.hpp" #include "Thyra_TpetraLinearOp.hpp" #include "Thyra_LinearOpTester.hpp" @@ -85,9 +89,10 @@ typedef Teko::NT NT; using Teuchos::rcp; using Teuchos::RCP; using Teuchos::rcpFromRef; -using Thyra::epetraLinearOp; using Thyra::tpetraLinearOp; +#ifdef TEKO_HAVE_EPETRA +using Thyra::epetraLinearOp; const RCP > build2x2(const Epetra_Comm & comm,double a,double b,double c,double d) { RCP map = rcp(new Epetra_Map(2,0,comm)); @@ -109,6 +114,7 @@ const RCP > build2x2(const Epetra_Comm & comm, return Thyra::epetraLinearOp(blk); } +#endif const RCP > build2x2(const Teuchos::RCP > comm,ST a,ST b,ST c,ST d) { @@ -128,10 +134,11 @@ const RCP > build2x2(const Teuchos::RCPinsertGlobalValues(0,Teuchos::ArrayView(indices,2),Teuchos::ArrayView(row0,2)); blk->insertGlobalValues(1,Teuchos::ArrayView(indices,2),Teuchos::ArrayView(row1,2)); blk->fillComplete(); - + return Thyra::tpetraLinearOp(Thyra::tpetraVectorSpace(blk->getRangeMap()),Thyra::tpetraVectorSpace(blk->getDomainMap()),blk); } +#ifdef TEKO_HAVE_EPETRA TEUCHOS_UNIT_TEST(tLU2x2InverseOp, exact_test) { // build global (or serial communicator) @@ -184,6 +191,7 @@ TEUCHOS_UNIT_TEST(tLU2x2InverseOp, exact_test) out << "Apply: SUCCESS" << std::endl; } } +#endif TEUCHOS_UNIT_TEST(tLU2x2InverseOp, exact_test_tpetra) { diff --git a/packages/teko/tests/unit_tests/tRequestInterface.cpp b/packages/teko/tests/unit_tests/tRequestInterface.cpp index 83d107813e49..b9afc723f367 100644 --- a/packages/teko/tests/unit_tests/tRequestInterface.cpp +++ b/packages/teko/tests/unit_tests/tRequestInterface.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -66,7 +66,7 @@ class TestFactory : public Teko::PreconditionerFactory { public: Teko::LinearOp buildPreconditionerOperator(Teko::LinearOp & lo, Teko::PreconditionerState & state) const; - + mutable double timestep_; mutable Teko::LinearOp pcdOp_; mutable std::string string_; @@ -92,7 +92,7 @@ class PCDCallback : public Teko::RequestCallback { Teko::LinearOp request(const Teko::RequestMesg & rd) { TEUCHOS_ASSERT(handlesRequest(rd)); - return Teuchos::null; + return Teuchos::null; } bool handlesRequest(const Teko::RequestMesg & rd) @@ -110,7 +110,7 @@ class TSCallback : public Teko::RequestCallback { double request(const Teko::RequestMesg & rd) { TEUCHOS_ASSERT(handlesRequest(rd)); - return 0.1; + return 0.1; } bool handlesRequest(const Teko::RequestMesg & rd) @@ -174,7 +174,7 @@ TEUCHOS_UNIT_TEST(tRequestInterface, test_request_interface) rh->preRequest(intMesg); out << "Found with name \"Int Op\" in preRequest" << std::endl; TEST_ASSERT(false); - } catch(std::exception & e) + } catch(std::exception & e) { out << "expected exception = " << e.what() << std::endl; } try { @@ -182,7 +182,7 @@ TEUCHOS_UNIT_TEST(tRequestInterface, test_request_interface) int size = rh->request(intMesg); out << "Found with name \"Int Op\" value=" << size << std::endl; TEST_ASSERT(false); - } catch(std::exception & e) + } catch(std::exception & e) { out << "expected exception = " << e.what() << std::endl; } try { @@ -190,11 +190,11 @@ TEUCHOS_UNIT_TEST(tRequestInterface, test_request_interface) int lo = rh->request(intMesg); out << "Found with name \"PCD Op\" value=" << lo << std::endl; TEST_ASSERT(false); - } catch(std::exception & e) + } catch(std::exception & e) { out << "expected exception = " << e.what() << std::endl; } } -// Test widget for the parameter list based call back: +// Test widget for the parameter list based call back: // used in preconditioner_request_interface unit test /////////////////////////////////////////////////////////////////// class PLCallback : public Teko::RequestCallback > { @@ -213,7 +213,7 @@ Teuchos::RCP PLCallback::request(const Teko::RequestMesg "Parameter list not included in request message"); Teuchos::RCP outputPL = Teuchos::rcp(new Teuchos::ParameterList); - + // build up new parameter list from message list Teuchos::ParameterList::ConstIterator itr; for(itr=inputPL->begin();itr!=inputPL->end();++itr) { @@ -226,11 +226,11 @@ Teuchos::RCP PLCallback::request(const Teko::RequestMesg return outputPL; } -void PLCallback::preRequest(const Teko::RequestMesg & rm) +void PLCallback::preRequest(const Teko::RequestMesg & rm) { } -bool PLCallback::handlesRequest(const Teko::RequestMesg & rm) +bool PLCallback::handlesRequest(const Teko::RequestMesg & rm) { if(rm.getName()=="Parameter List") return true; else return false; @@ -238,6 +238,7 @@ bool PLCallback::handlesRequest(const Teko::RequestMesg & rm) TEUCHOS_UNIT_TEST(tRequestInterface, preconditioner_request_interface) { +#ifdef TEKO_HAVE_EPETRA using Teuchos::RCP; using Teuchos::rcp; @@ -246,14 +247,14 @@ TEUCHOS_UNIT_TEST(tRequestInterface, preconditioner_request_interface) Teuchos::ParameterList & mlList = pl.sublist("ML-Test"); mlList.set("Type","ML"); mlList.sublist("ML Settings"); - mlList.sublist("Required Parameters").set("cat","dog"); + mlList.sublist("Required Parameters").set("cat","dog"); } { // ML-Test2 does not require a handler Teuchos::ParameterList & mlList = pl.sublist("ML-Test2"); mlList.set("Type","ML"); mlList.sublist("ML Settings").set("pet","horse"); } - + // make sure it throws if uses haven't set things up correctly { RCP invLib = Teko::InverseLibrary::buildFromParameterList(pl); @@ -272,13 +273,12 @@ TEUCHOS_UNIT_TEST(tRequestInterface, preconditioner_request_interface) RCP invFact = invLib->getInverseFactory("ML-Test"); // investigate the parameter list to see if it has bee correctly updated! - RCP pInvFact + RCP pInvFact = Teuchos::rcp_dynamic_cast(invFact); Teuchos::RCP pl = pInvFact->getPrecFactory()->getParameterList(); TEST_ASSERT(pl->sublist("ML Settings").isParameter("cat")); TEST_EQUALITY(pl->sublist("ML Settings").get("cat"),7); } - - +#endif } diff --git a/packages/teko/tests/unit_tests/tUtilitiesTests.cpp b/packages/teko/tests/unit_tests/tUtilitiesTests.cpp index a54205bd8f6a..86dd34bd8936 100644 --- a/packages/teko/tests/unit_tests/tUtilitiesTests.cpp +++ b/packages/teko/tests/unit_tests/tUtilitiesTests.cpp @@ -1,29 +1,29 @@ /* // @HEADER -// +// // *********************************************************************** -// +// // Teko: A package for block and physics based preconditioning -// Copyright 2010 Sandia Corporation -// +// Copyright 2010 Sandia Corporation +// // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// +// this software without specific prior written permission. +// // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,14 +32,14 @@ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Questions? Contact Eric C. Cyr (eccyr@sandia.gov) -// +// // *********************************************************************** -// +// // @HEADER */ @@ -52,12 +52,6 @@ #include #include -#ifdef HAVE_MPI - #include "Epetra_MpiComm.h" -#else - #include "Epetra_SerialComm.h" -#endif - // Teko-Package includes #include "Teko_Utilities.hpp" @@ -73,13 +67,6 @@ using Teuchos::rcpFromRef; TEUCHOS_UNIT_TEST(tUtilitiesTests, clipping) { - // build global (or serial communicator) - #ifdef HAVE_MPI - Epetra_MpiComm Comm(MPI_COMM_WORLD); - #else - Epetra_SerialComm Comm; - #endif - RCP > vs = Thyra::defaultSpmdVectorSpace(10); RCP > x = Thyra::createMembers(vs,2); @@ -96,7 +83,7 @@ TEUCHOS_UNIT_TEST(tUtilitiesTests, clipping) TEST_FLOATING_EQUALITY(Teko::norm_1(x,0),10.0*1.0,1e-16); TEST_FLOATING_EQUALITY(Teko::norm_1(x,1),10.0*1.0,1e-16); - Teuchos::ArrayRCP col0, col1; + Teuchos::ArrayRCP col0, col1; rcp_dynamic_cast >(x->col(0))->getNonconstLocalData(Teuchos::ptrFromRef(col0)); rcp_dynamic_cast >(x->col(1))->getNonconstLocalData(Teuchos::ptrFromRef(col1)); @@ -132,17 +119,10 @@ TEUCHOS_UNIT_TEST(tUtilitiesTests, clipping) TEUCHOS_UNIT_TEST(tUtilitiesTests, replaceValues) { - // build global (or serial communicator) - #ifdef HAVE_MPI - Epetra_MpiComm Comm(MPI_COMM_WORLD); - #else - Epetra_SerialComm Comm; - #endif - RCP > vs = Thyra::defaultSpmdVectorSpace(10); RCP > x = Thyra::createMembers(vs,2); - Teuchos::ArrayRCP col0, col1; + Teuchos::ArrayRCP col0, col1; rcp_dynamic_cast >(x->col(0))->getNonconstLocalData(Teuchos::ptrFromRef(col0)); rcp_dynamic_cast >(x->col(1))->getNonconstLocalData(Teuchos::ptrFromRef(col1)); @@ -163,17 +143,10 @@ TEUCHOS_UNIT_TEST(tUtilitiesTests, replaceValues) TEUCHOS_UNIT_TEST(tUtilitiesTests, averages) { - // build global (or serial communicator) - #ifdef HAVE_MPI - Epetra_MpiComm Comm(MPI_COMM_WORLD); - #else - Epetra_SerialComm Comm; - #endif - RCP > vs = Thyra::defaultSpmdVectorSpace(9); RCP > x = Thyra::createMembers(vs,2); - Teuchos::ArrayRCP col0, col1; + Teuchos::ArrayRCP col0, col1; rcp_dynamic_cast >(x->col(0))->getNonconstLocalData(Teuchos::ptrFromRef(col0)); rcp_dynamic_cast >(x->col(1))->getNonconstLocalData(Teuchos::ptrFromRef(col1)); diff --git a/packages/teuchos/comm/src/Teuchos_StackedTimer.cpp b/packages/teuchos/comm/src/Teuchos_StackedTimer.cpp index 038f3cade26d..e144017c390e 100644 --- a/packages/teuchos/comm/src/Teuchos_StackedTimer.cpp +++ b/packages/teuchos/comm/src/Teuchos_StackedTimer.cpp @@ -143,6 +143,12 @@ StackedTimer::collectRemoteData(Teuchos::RCP > comm, co max_.resize(num_names); if ( options.output_minmax ) sum_sq_.resize(num_names); + else + sum_sq_.resize(0); + } else { + min_.resize(0); + max_.resize(0); + sum_sq_.resize(0); } if (options.output_proc_minmax) { diff --git a/packages/tpetra/core/src/Tpetra_Details_DistributorActor.hpp b/packages/tpetra/core/src/Tpetra_Details_DistributorActor.hpp index e64cb6072809..5bef22dab599 100644 --- a/packages/tpetra/core/src/Tpetra_Details_DistributorActor.hpp +++ b/packages/tpetra/core/src/Tpetra_Details_DistributorActor.hpp @@ -334,7 +334,13 @@ void DistributorActor::doPosts(const DistributorPlan& plan, exports, plan.getStartsTo()[p]*numPackets, plan.getLengthsTo()[p]*numPackets); if (sendType == Details::DISTRIBUTOR_ISEND) { - requests_.push_back (isend (tmpSend, plan.getProcsTo()[p], + // NOTE: This looks very similar to the tmpSend above, but removing + // tmpSendBuf and uses tmpSend leads to a performance hit on Arm + // SerialNode builds + exports_view_type tmpSendBuf = + subview_offset (exports, plan.getStartsTo()[p] * numPackets, + plan.getLengthsTo()[p] * numPackets); + requests_.push_back (isend (tmpSendBuf, plan.getProcsTo()[p], mpiTag_, *plan.getComm())); } else { // DISTRIBUTOR_SEND