-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from precice/bundle_solver
Bundle solver into a single executable
- Loading branch information
Showing
25 changed files
with
1,090 additions
and
1,496 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0) | ||
|
||
FIND_PACKAGE(deal.II 9.1 QUIET | ||
HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR} | ||
) | ||
IF(NOT ${deal.II_FOUND}) | ||
MESSAGE(FATAL_ERROR "\n" | ||
"*** Could not locate deal.II. ***\n\n" | ||
"You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to cmake\n" | ||
"or set an environment variable \"DEAL_II_DIR\" that contains this path." | ||
) | ||
ENDIF() | ||
|
||
# Enable a switchable dimension choice | ||
IF (NOT DEFINED DIM) | ||
SET(DIM 2) | ||
ENDIF() | ||
ADD_DEFINITIONS(-DDIM=${DIM}) | ||
|
||
# Set the target and the target source | ||
SET( TARGET "elasticity" ) | ||
SET( TARGET_SRC ${TARGET}.cc include/adapter/parameters.cc) | ||
|
||
DEAL_II_INITIALIZE_CACHED_VARIABLES() | ||
|
||
IF(NOT CMAKE_BUILD_TYPE) | ||
SET(CMAKE_BUILD_TYPE "RELEASE") | ||
MESSAGE(STATUS "No build type specified. Building in ${CMAKE_BUILD_TYPE} mode.") | ||
ENDIF() | ||
|
||
# Set the include directory and the name of the project | ||
PROJECT(${TARGET}) | ||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) | ||
|
||
# Set the executable | ||
ADD_EXECUTABLE(${TARGET} ${TARGET_SRC}) | ||
|
||
# Use deal.II macros for setting up the target | ||
DEAL_II_SETUP_TARGET(${TARGET}) | ||
DEAL_II_INITIALIZE_CACHED_VARIABLES() | ||
|
||
# Query the git information and set it in the source | ||
DEAL_II_QUERY_GIT_INFORMATION() | ||
SET_PROPERTY(TARGET ${TARGET} APPEND PROPERTY COMPILE_DEFINITIONS | ||
GIT_BRANCH="${GIT_BRANCH}" | ||
GIT_REVISION="${GIT_REVISION}" | ||
GIT_SHORTREV="${GIT_SHORTREV}") | ||
|
||
|
||
FIND_PACKAGE(precice REQUIRED | ||
HINTS ${PRECICE_DIR} $ENV{precice_DIR}) | ||
TARGET_LINK_LIBRARIES(${TARGET} precice::precice) | ||
|
||
MESSAGE(STATUS "Using the preCICE version found at ${precice_CONFIG}") | ||
|
||
# add the individual solver | ||
ADD_SUBDIRECTORY(source) | ||
|
||
# ...and link them | ||
TARGET_LINK_LIBRARIES(${TARGET} nonlinear_elasticity linear_elasticity) | ||
|
||
|
||
# | ||
# Custom "debug" and "release" make targets: | ||
# | ||
ADD_CUSTOM_TARGET(debug | ||
COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} | ||
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all | ||
COMMENT "Switch CMAKE_BUILD_TYPE to Debug" | ||
) | ||
|
||
ADD_CUSTOM_TARGET(release | ||
COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} | ||
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all | ||
COMMENT "Switch CMAKE_BUILD_TYPE to Release" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#include <adapter/parameters.h> | ||
|
||
#include "source/linear_elasticity/include/linear_elasticity.h" | ||
#include "source/nonlinear_elasticity/include/nonlinear_elasticity.h" | ||
|
||
int | ||
main(int argc, char **argv) | ||
{ | ||
using namespace dealii; | ||
|
||
#ifdef DEAL_II_WITH_MPI | ||
Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv); | ||
#endif | ||
|
||
try | ||
{ | ||
deallog.depth_console(0); | ||
static const unsigned int n_threads = MultithreadInfo::n_threads(); | ||
|
||
// Query adapter and deal.II info | ||
const std::string adapter_info = | ||
GIT_SHORTREV == std::string("") ? | ||
"unknown" : | ||
(GIT_SHORTREV + std::string(" on branch ") + GIT_BRANCH); | ||
const std::string dealii_info = | ||
DEAL_II_GIT_SHORTREV == std::string("") ? | ||
"unknown" : | ||
(DEAL_II_GIT_SHORTREV + std::string(" on branch ") + | ||
DEAL_II_GIT_BRANCH); | ||
|
||
std::cout | ||
<< "-----------------------------------------------------------------------------" | ||
<< std::endl | ||
<< "-- . running with " << n_threads << " thread" | ||
<< (n_threads == 1 ? "" : "s") << std::endl; | ||
|
||
std::cout << "-- . adapter revision " << adapter_info << std::endl; | ||
std::cout << "-- . deal.II " << DEAL_II_PACKAGE_VERSION | ||
<< " (revision " << dealii_info << ")" << std::endl; | ||
std::cout | ||
<< "-----------------------------------------------------------------------------" | ||
<< std::endl | ||
<< std::endl; | ||
|
||
// Store the name of the parameter file | ||
const std::string parameter_file = argc > 1 ? argv[1] : "parameters.prm"; | ||
|
||
// Extract case path for the output directory | ||
size_t pos = parameter_file.find_last_of("/"); | ||
std::string case_path = | ||
std::string::npos == pos ? "" : parameter_file.substr(0, pos + 1); | ||
|
||
// Query solver type from the parameter file | ||
ParameterHandler prm; | ||
Parameters::Solver solver; | ||
solver.add_output_parameters(prm); | ||
prm.parse_input(parameter_file, "", true); | ||
|
||
if (solver.model == "neo-Hookean") // nonlinear | ||
{ | ||
Nonlinear_Elasticity::Solid<DIM> solid(case_path, parameter_file); | ||
solid.run(); | ||
} | ||
else if (solver.model == "linear") // linear | ||
{ | ||
Linear_Elasticity::ElastoDynamics<DIM> elastic_solver(case_path, | ||
parameter_file); | ||
elastic_solver.run(); | ||
} | ||
else | ||
AssertThrow(false, ExcNotImplemented()) | ||
} | ||
catch (std::exception &exc) | ||
{ | ||
std::cerr << std::endl | ||
<< std::endl | ||
<< "----------------------------------------------------" | ||
<< std::endl; | ||
std::cerr << "Exception on processing: " << std::endl | ||
<< exc.what() << std::endl | ||
<< "Aborting!" << std::endl | ||
<< "----------------------------------------------------" | ||
<< std::endl; | ||
|
||
return 1; | ||
} | ||
catch (...) | ||
{ | ||
std::cerr << std::endl | ||
<< std::endl | ||
<< "----------------------------------------------------" | ||
<< std::endl; | ||
std::cerr << "Unknown exception!" << std::endl | ||
<< "Aborting!" << std::endl | ||
<< "----------------------------------------------------" | ||
<< std::endl; | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.