Skip to content

Commit

Permalink
LCM: Enabling Yaml input. (#74)
Browse files Browse the repository at this point in the history
If Teuchos is compiled with Yaml support, Albany's solver factory
and LCM's material database can optionally be read as Yaml files.

This is determined by the file extension. If the extension is .xml,
the XMl parser for Teuchos ParameterList is invoked. If the extension
is .yaml, the Yaml parser is invoked.

Add small example (test) specifying the same problem with XML and Yaml
formats. The readability of the input using Yaml is significantly
improved.

Only LCM is tested for this. A cursory search finds that ATO and QCAD
call the XML parser for their own purposes. Adding support for
the Yaml parser is not difficult, following the example of the LCM
material database.

Enable Yaml support by default on Fedora.
  • Loading branch information
lxmota committed Feb 25, 2017
1 parent 7e88762 commit 0827968
Show file tree
Hide file tree
Showing 14 changed files with 765 additions and 23 deletions.
59 changes: 37 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,6 @@ ELSE()
SET(ALBANY_TEMPUS FALSE)
ENDIF()

# Check if Trilinos has ROL

# Check if Trilinos has ROL
LIST(FIND Trilinos_PACKAGE_LIST ROL ROL_List_ID)
IF (ROL_List_ID GREATER -1)
Expand All @@ -495,12 +493,12 @@ IF (ENABLE_ATO)
MESSAGE("-- ATO requires LCM... compiling with -DALBANY_LCM")
SET(ALBANY_LCM TRUE)
ENDIF()
IF (ENABLE_ALBANY_EPETRA_EXE)
IF (ENABLE_ATO_SOLVER_EPETRA)
IF (ENABLE_ALBANY_EPETRA_EXE)
IF (ENABLE_ATO_SOLVER_EPETRA)
SET(ALBANY_ATO_SOLVER_EPETRA TRUE)
ADD_DEFINITIONS(-DALBANY_ATO_SOLVER_EPETRA)
MESSAGE("-- ATO_SOLVER_EPETRA is Enabled.")
ELSE()
ELSE()
MESSAGE("-- ATO_SOLVER_EPETRA is disabled.")
ENDIF()
ELSE()
Expand Down Expand Up @@ -575,22 +573,22 @@ ENDIF()
OPTION(ENABLE_CISM_INTERFACE "Flag to turn on FELIX Interface to the CISM code" OFF)
OPTION(ENABLE_CISM_REDUCED_COMM "Flag to turn on reduced communicator for CISM-Albany runs" ON)
OPTION(ENABLE_CISM_EPETRA "Flag to turn on Epetra for CISM-Albany" OFF)
OPTION(ENABLE_CISM_CHECK_COMPARISONS "Flag to turn on comparisons checking for CISM-Albany" OFF)
OPTION(ENABLE_CISM_CHECK_COMPARISONS "Flag to turn on comparisons checking for CISM-Albany" OFF)

IF (ENABLE_CISM_INTERFACE AND ENABLE_FELIX)
IF (ENABLE_CISM_CHECK_COMPARISONS)
ADD_DEFINITIONS(-DCISM_CHECK_COMPARISONS)
IF (ENABLE_CISM_CHECK_COMPARISONS)
ADD_DEFINITIONS(-DCISM_CHECK_COMPARISONS)
MESSAGE("---> CISM_CHECK_COMPARISONS is Enabled, compiling with -DCISM_CHECK_COMPARISONS. Error will be thrown if comparisons fail for CISM-Albany run.")
ELSE()
MESSAGE("---> CISM_CHECK_COMPARISONS is Disabled, NOT compiling with -DCISM_CHECK_COMPARISONS. Error will NOT be thrown if comparisons fail for CISM-Albany run. Please be cautious when running ctest from CISM!")
ENDIF()
IF (ENABLE_CISM_REDUCED_COMM)
ELSE()
MESSAGE("---> CISM_CHECK_COMPARISONS is Disabled, NOT compiling with -DCISM_CHECK_COMPARISONS. Error will NOT be thrown if comparisons fail for CISM-Albany run. Please be cautious when running ctest from CISM!")
ENDIF()
IF (ENABLE_CISM_REDUCED_COMM)
ADD_DEFINITIONS(-DREDUCED_COMM)
MESSAGE("---> CISM_REDUCED_COMM is Enabled, compiling with -DREDUCED_COMM. CISM-Albany will use reduced communicator.")
ENDIF()
IF (ENABLE_ALBANY_EPETRA_EXE)
IF (ENABLE_CISM_EPETRA)
ADD_DEFINITIONS(-DCISM_USE_EPETRA)
IF (ENABLE_ALBANY_EPETRA_EXE)
IF (ENABLE_CISM_EPETRA)
ADD_DEFINITIONS(-DCISM_USE_EPETRA)
MESSAGE("---> CISM_EPETRA is Enabled, compiling with -DCISM_USE_EPETRA. CISM-Albany will run with Epetra software stack.")
ELSE()
MESSAGE("---> CISM_EPETRA is Disabled, NOT compiling with -DCISM_USE_EPETRA. CISM-Albany will run with Tpetra software stack.")
Expand Down Expand Up @@ -828,16 +826,16 @@ ENDIF()
# Set optional build of MOR (Model Order Reduction) defaults to OFF
OPTION(ENABLE_MOR "Flag to turn on MOR Source code" OFF)
IF (ENABLE_MOR)
#Check if RBGen library has been built as a part of Anasazi.
#If it has not, turn MOR off despite what user requested and print message explaining that MOR requires RBGen library.
#Check if RBGen library has been built as a part of Anasazi.
#If it has not, turn MOR off despite what user requested and print message explaining that MOR requires RBGen library.
LIST(FIND Trilinos_LIBRARIES rbgen rbgen_List_ID)
IF (rbgen_List_ID GREATER -1)
MESSAGE("-- Looking for rbgen library: -- found! Continuing.")
ADD_DEFINITIONS(-DALBANY_MOR)
MESSAGE("-- MOR is Enabled, compiling with -DALBANY_MOR")
SET(ALBANY_MOR TRUE)
ELSE()
MESSAGE("---- Looking for rbgen library: -- NOT found!")
MESSAGE("---- Looking for rbgen library: -- NOT found!")
MESSAGE("-- MOR requires RBGen library. To turn on, rebuild Trilinos with Anasazi_ENABLE_RBGen turned ON")
MESSAGE("-- MOR is NOT Enabled.")
SET(ALBANY_MOR FALSE)
Expand Down Expand Up @@ -1128,8 +1126,8 @@ IF (ENABLE_KOKKOS_UNDER_DEVELOPMENT)
ADD_DEFINITIONS(-DALBANY_KOKKOS_UNDER_DEVELOPMENT)
MESSAGE("-- Kokkos development is Enabled, compiling with -DALBANY_KOKKOS_UNDER_DEVELOPMENT")
SET(ALBANY_KOKKOS_UNDER_DEVELOPMENT TRUE)
IF (ENABLE_CUDA_ERROR_CHECK)
ADD_DEFINITIONS(-DALBANY_CUDA_ERROR_CHECK)
IF (ENABLE_CUDA_ERROR_CHECK)
ADD_DEFINITIONS(-DALBANY_CUDA_ERROR_CHECK)
MESSAGE("-- CUDA Error Check is Enabled, compiling with -DALBANY_CUDA_ERROR_CHECK")
ELSE()
MESSAGE("-- CUDA Error Check is NOT Enabled.")
Expand Down Expand Up @@ -1276,6 +1274,23 @@ COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif(DOXYGEN_FOUND)

# Enable yaml parsing for reading parameters lists
IF (EXISTS "${Trilinos_INCLUDE_DIRS}/TeuchosCore_config.h")
FILE(READ ${Trilinos_INCLUDE_DIRS}/TeuchosCore_config.h CURRENT_CONFIG)
STRING(REGEX MATCH "\#define HAVE_TEUCHOSCORE_YAML_CPP" TEUCHOS_YAML_IS_SET ${CURRENT_CONFIG})
IF ("#define HAVE_TEUCHOSCORE_YAML_CPP" STREQUAL "${TEUCHOS_YAML_IS_SET}")
MESSAGE("-- Looking for YAML in Teuchos: Found, compiling with -DALBANY_YAML")
SET(ALBANY_YAML TRUE)
ADD_DEFINITIONS(-DALBANY_YAML)
ELSE ("#define HAVE_TEUCHOSCORE_YAML_CPP" STREQUAL "${TEUCHOS_YAML_IS_SET}")
MESSAGE("-- Looking for YAML in Teuchos: NOT found.")
SET(ALBANY_YAML FALSE)
ENDIF ("#define HAVE_TEUCHOSCORE_YAML_CPP" STREQUAL "${TEUCHOS_YAML_IS_SET}")
ELSE (EXISTS "${Trilinos_INCLUDE_DIRS}/TeuchosCore_config.h")
MESSAGE("-- Looking for YAML in Teuchos: NOT found.")
SET(ALBANY_YAML FALSE)
ENDIF (EXISTS "${Trilinos_INCLUDE_DIRS}/TeuchosCore_config.h")

## End of CMake options to Albany

add_subdirectory(src)
Expand Down Expand Up @@ -1323,15 +1338,15 @@ IF(ALBANY_MPI)
ENDIF(ALBANY_MPI)

#Add option to run any pretest executables in a specific environment (mpiexec.hydra, srun, or other)
IF (DEFINED ALBANY_PRETEST_EXEC)
IF (DEFINED ALBANY_PRETEST_EXEC)
MESSAGE("-- ALBANY_PRETEST_EXEC is ${ALBANY_PRETEST_EXEC}")
ELSE()
# Not set in configure - set it to be empty
SET(ALBANY_PRETEST_EXEC "" CACHE STRING "Command to use to execute pretests")
ENDIF()

#Add option to specify path to desired SEACAS utils
IF (DEFINED ALBANY_SEACAS_PATH)
IF (DEFINED ALBANY_SEACAS_PATH)
MESSAGE("-- ALBANY_SEACAS_PATH is ${ALBANY_SEACAS_PATH}")
ENDIF()

Expand Down
2 changes: 1 addition & 1 deletion doc/LCM/build/trilinos-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ cmake \
\
-D Teuchos_ENABLE_STACKTRACE:BOOL=OFF \
-D Teuchos_ENABLE_DEFAULT_STACKTRACE:BOOL=OFF \
-D HAVE_INTREPID_KOKKOSCORE:BOOL=ON \
-D TeuchosCore_ENABLE_yaml-cpp:BOOL=ON \
-D Kokkos_ENABLE_CXX11:BOOL=ON \
-D Kokkos_ENABLE_Cuda_UVM:BOOL=lcm_enable_uvm \
-D Kokkos_ENABLE_EXAMPLES:BOOL=lcm_enable_kokkos_examples \
Expand Down
3 changes: 3 additions & 0 deletions examples/LCM/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ IF(ALBANY_SEACAS)
add_subdirectory(ThermoMechanicalContact)
add_subdirectory(BoreDemo)
add_subdirectory(RigidBody)
IF(ALBANY_YAML)
add_subdirectory(YamlInput)
ENDIF()
IF(ALBANY_EPETRA)
add_subdirectory(HMC)
ENDIF()
Expand Down
26 changes: 26 additions & 0 deletions examples/LCM/YamlInput/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
##*****************************************************************//
## Albany 3.0: Copyright 2016 Sandia Corporation //
## This Software is released under the BSD license detailed //
## in the file "license.txt" in the top-level Albany directory //
##*****************************************************************//

# Copy Input file from source to binary dir
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cuboid.g
${CMAKE_CURRENT_BINARY_DIR}/cuboid.g COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cuboid.xml
${CMAKE_CURRENT_BINARY_DIR}/cuboid.xml COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cuboid.yaml
${CMAKE_CURRENT_BINARY_DIR}/cuboid.yaml COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/materials.xml
${CMAKE_CURRENT_BINARY_DIR}/materials.xml COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/materials.yaml
${CMAKE_CURRENT_BINARY_DIR}/materials.yaml COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/runtest.py
${CMAKE_CURRENT_BINARY_DIR}/runtest.py COPYONLY)

# Create symlink to AlbanyT
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${AlbanyTPath} ${CMAKE_CURRENT_BINARY_DIR}/AlbanyT)
get_filename_component(testName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
# Create the test with this name and standard executable
add_test(NAME ${testName} COMMAND "python" "runtest.py")
Binary file added examples/LCM/YamlInput/cuboid.g
Binary file not shown.
Loading

0 comments on commit 0827968

Please sign in to comment.