From: David Wells Date: Fri, 23 Jun 2023 15:57:31 +0000 (-0400) Subject: Fix the braid example. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=86fdf48056a0bc0fe684dabd4416797dc98134fb;p=code-gallery.git Fix the braid example. - Rewrite CMakeLists.txt - Fix test output --- diff --git a/parallel_in_time/CMakeLists.txt b/parallel_in_time/CMakeLists.txt index f6fbb8b..2eb9385 100644 --- a/parallel_in_time/CMakeLists.txt +++ b/parallel_in_time/CMakeLists.txt @@ -1,41 +1,10 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.3.0) -# Set the name of the project and target: -SET(TARGET "parallel_in_time") - -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic") - -SET(PROJECT_PATH "${CMAKE_CURRENT_SOURCE_DIR}") -SET(SRC_PATH "${PROJECT_PATH}/src") -SET(TEST_SRC_PATH "${PROJECT_PATH}/test") -# SET(BIN_PATH "${PROJECT_BINARY_DIR}/bin") -SET(LIB_NAME "${TARGET}_lib") -SET(BIN_NAME "${TARGET}") -SET(TEST_PATH "${PROJECT_BINARY_DIR}/test") -SET(TEST_NAME "test_${TARGET}") - -SET(LIB_SRC - ${SRC_PATH}/BraidFuncs.cc - ${SRC_PATH}/Utilities.cc - ) - -SET(TARGET_SRC - ${SRC_PATH}/${TARGET}.cc - ) - -SET(TEST_SRC - ${TEST_SRC_PATH}/test_braid.cc - ) - -OPTION(DO_MFG "Do the manufactured solution run" OFF) - -IF(DO_MFG) - # If we are doing the manufactured solution, tell - # the C++ processor so it can enable MFG solutions - MESSAGE(STATUS "Manufactured solution enabled") - ADD_DEFINITIONS(-DDO_MFG) -ENDIF(DO_MFG) +PROJECT("parallel_in_time") +# +# setup deal.II +# FIND_PACKAGE(deal.II 9.4.0 HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR} ) @@ -46,9 +15,17 @@ IF(NOT ${deal.II_FOUND}) "or set an environment variable \"DEAL_II_DIR\" that contains this path." ) ENDIF() +DEAL_II_INITIALIZE_CACHED_VARIABLES() + +IF(NOT ${DEAL_II_WITH_MPI}) + MESSAGE(FATAL_ERROR "parallel_in_time requires that deal.II be set up with MPI.") +ENDIF() -# Find braid details -SET(BRAID_DIR "$ENV{BRAID_DIR}" CACHE INTERNAL "Copied BRAID_DIR from environment variable") +# +# setup braid +# +SET(BRAID_DIR "$ENV{BRAID_DIR}" CACHE INTERNAL + "Copied BRAID_DIR from environment variable") FIND_PATH(BRAID_INCLUDE_DIR NAMES braid.h @@ -63,32 +40,39 @@ FIND_LIBRARY(BRAID_LIBRARY MESSAGE(STATUS "Braid include directory: ${BRAID_INCLUDE_DIR}") MESSAGE(STATUS "Braid library: ${BRAID_LIBRARY}") -# Include the braid paths and libraries INCLUDE_DIRECTORIES(${BRAID_INCLUDE_DIR}) -# Build the library -ADD_LIBRARY(${LIB_NAME} SHARED ${LIB_SRC}) -DEAL_II_SETUP_TARGET(${LIB_NAME}) - -DEAL_II_INITIALIZE_CACHED_VARIABLES() -PROJECT(${TARGET}) +# +# setup parallel_in_time +# +SET(SRC_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src") +SET(LIB_NAME "parallel_in_time_lib") -# Tell CMake to find MPI -FIND_PACKAGE(MPI REQUIRED) -ADD_DEFINITIONS(-DUSE_MPI) -INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH}) +SET(LIB_SRC + ${SRC_PATH}/BraidFuncs.cc + ${SRC_PATH}/Utilities.cc + ) -DEAL_II_INVOKE_AUTOPILOT() -TARGET_LINK_LIBRARIES(${TARGET} ${BRAID_LIBRARY}) # link braid -TARGET_LINK_LIBRARIES(${TARGET} ${LIB_NAME}) -SET_TARGET_PROPERTIES(${TARGET} PROPERTIES - LINK_FLAGS "${MPI_LINK_FLAGS}") # Link MPI -SET_TARGET_PROPERTIES(${MAIN_NAME} PROPERTIES - COMPILE_FLAGS "${MPI_COMPILE_FLAGS}") # Use MPI compile flags +OPTION(DO_MFG "Do the manufactured solution run" OFF) -# Lastly build the tests -ENABLE_TESTING() -ADD_SUBDIRECTORY(test) +IF(DO_MFG) + # If we are doing the manufactured solution, tell + # the C++ processor so it can enable MFG solutions + MESSAGE(STATUS "Manufactured solution enabled") + ADD_DEFINITIONS(-DDO_MFG) +ENDIF(DO_MFG) +ADD_LIBRARY(${LIB_NAME} SHARED ${LIB_SRC}) +DEAL_II_SETUP_TARGET(${LIB_NAME}) +TARGET_LINK_LIBRARIES(${LIB_NAME} ${BRAID_LIBRARY}) +ADD_EXECUTABLE(parallel_in_time) +TARGET_SOURCES(parallel_in_time PRIVATE src/parallel_in_time.cc) +TARGET_LINK_LIBRARIES(parallel_in_time ${LIB_NAME}) +DEAL_II_SETUP_TARGET(parallel_in_time) +# +# setup tests +# +ENABLE_TESTING() +ADD_SUBDIRECTORY(test) diff --git a/parallel_in_time/test/CMakeLists.txt b/parallel_in_time/test/CMakeLists.txt index 27c696a..f414d8a 100644 --- a/parallel_in_time/test/CMakeLists.txt +++ b/parallel_in_time/test/CMakeLists.txt @@ -1,5 +1,5 @@ INCLUDE_DIRECTORIES(${SRC_PATH}) -SET(TEST_LIBRARIES ${LIB_NAME} ${BRAID_LIBRARY}) +SET(TEST_LIBRARIES ${LIB_NAME}) IF(DO_MFG) DEAL_II_PICKUP_TESTS() diff --git a/parallel_in_time/test/test_braid.output b/parallel_in_time/test/test_braid.output index e1b73fc..98d8d28 100644 --- a/parallel_in_time/test/test_braid.output +++ b/parallel_in_time/test/test_braid.output @@ -4,6 +4,9 @@ Starting braid_TestInitAccess braid_TestInitAccess: Starting Test 1 braid_TestInitAccess: u = init(t=2.00e-01) braid_TestInitAccess: access(u) +Cycle 0: + Number of active cells: 12288 + Number of degrees of freedom: 12545 cycle cells dofs L2 H1 Linfty 0 12288 12545 8.657e-01 7.696e+00 1.001e+00 @@ -18,11 +21,17 @@ Starting braid_TestClone braid_TestClone: u = init(t=2.00e-01) braid_TestClone: v = clone(u) braid_TestClone: access(u) +Cycle 0: + Number of active cells: 12288 + Number of degrees of freedom: 12545 cycle cells dofs L2 H1 Linfty 0 12288 12545 8.657e-01 7.696e+00 1.001e+00 0 12288 12545 8.657e-01 7.696e+00 1.001e+00 braid_TestClone: access(v) +Cycle 0: + Number of active cells: 12288 + Number of degrees of freedom: 12545 cycle cells dofs L2 H1 Linfty 0 12288 12545 8.657e-01 7.696e+00 1.001e+00 @@ -41,6 +50,9 @@ Starting braid_TestSum braid_TestSum: v = clone(u) braid_TestSum: v = u - v braid_TestSum: access(v) +Cycle 0: + Number of active cells: 12288 + Number of degrees of freedom: 12545 cycle cells dofs L2 H1 Linfty 0 12288 12545 8.657e-01 7.696e+00 1.001e+00 @@ -52,6 +64,9 @@ cycle cells dofs L2 H1 Linfty braid_TestSum: Starting Test 2 braid_TestSum: v = 2*u + v braid_TestSum: access(v) +Cycle 0: + Number of active cells: 12288 + Number of degrees of freedom: 12545 cycle cells dofs L2 H1 Linfty 0 12288 12545 8.657e-01 7.696e+00 1.001e+00 @@ -60,6 +75,9 @@ cycle cells dofs L2 H1 Linfty 0 12288 12545 3.225e-04 2.865e-03 3.723e-04 0 12288 12545 1.732e+00 1.539e+01 2.003e+00 braid_TestSum: access(u) +Cycle 0: + Number of active cells: 12288 + Number of degrees of freedom: 12545 cycle cells dofs L2 H1 Linfty 0 12288 12545 8.657e-01 7.696e+00 1.001e+00