Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundle solver into a single executable #50

Merged
merged 21 commits into from
Mar 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
09016bb
Move adapter files to separate directory
davidscn Feb 13, 2021
5e7c9d0
Add a cc file and CMakeLists file
davidscn Feb 13, 2021
4edff83
Add cmake macros and linear elasticity header
davidscn Feb 13, 2021
7e124c6
Port linear solver to new structure
davidscn Feb 13, 2021
8472967
port nonlinear case to new structure
davidscn Feb 13, 2021
f4a8305
Fix building test
davidscn Feb 13, 2021
61776fc
Merge branch 'develop' of https://github.com/precice/dealii-adapter i…
davidscn Mar 2, 2021
bf653bd
Move and unify parameter header file into include path
davidscn Mar 3, 2021
c3fe006
Move and unify parameter sources into include path
davidscn Mar 3, 2021
4057bbe
Configure CMake for new source file and adjust includes
davidscn Mar 3, 2021
8f8369c
Simplify parameter handling using add_parameter
davidscn Mar 3, 2021
bb7ed54
Remove specific parameter files and add unified one
davidscn Mar 3, 2021
d691fa2
Add parameter option for model selection
davidscn Mar 3, 2021
8997e9f
Add an entry for the parameter file location
davidscn Mar 3, 2021
5476c49
Fix Hook Hooke typo
davidscn Mar 3, 2021
81363a6
Apply suggestions from code review
davidscn Mar 21, 2021
005535a
Fix 'Force' data check for non-linear model
davidscn Mar 21, 2021
54893cc
Enfore compatibility to tutorial parameter file
davidscn Mar 22, 2021
273eff8
Merge pull request #51 from DavidSCN/unify_parameter
davidscn Mar 22, 2021
e96d9d0
Merge branch 'develop' into bundle_solver
davidscn Mar 22, 2021
0edace1
Specify linear residual in parameter file more in detail
davidscn Mar 23, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/building.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ jobs:
cd dealii-adapter && \
git fetch origin ${{ github.ref }} && \
git checkout FETCH_HEAD && \
cd linear_elasticity && \
cmake . && \
make && \
cd ../nonlinear_elasticity && \
cmake . && \
make";

Expand Down
76 changes: 76 additions & 0 deletions CMakeLists.txt
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"
)
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

Coupled structural solvers written with the C++ finite element library deal.II:

- `linear_elasticity` contains a linear-elastic solver based on the [step-8 tutorial program](https://www.dealii.org/developer/doxygen/deal.II/step_8.html) of deal.II
- `nonlinear_elasticity` contains a nonlinear elastic solver, which builds on previous work of Jean-Paul Pelteret and Andrew McBride in their deal.II code gallery program '[Quasi-Static Finite-Strain Compressible Elasticity](https://www.dealii.org/developer/doxygen/deal.II/code_gallery_Quasi_static_Finite_strain_Compressible_Elasticity.html).' This solver supports shared-memory parallelization.
- `source/linear_elasticity` contains a linear-elastic solver based on the [step-8 tutorial program](https://www.dealii.org/developer/doxygen/deal.II/step_8.html) of deal.II
- `source/nonlinear_elasticity` contains a nonlinear elastic solver, which builds on previous work of Jean-Paul Pelteret and Andrew McBride in their deal.II code gallery program '[Quasi-Static Finite-Strain Compressible Elasticity](https://www.dealii.org/developer/doxygen/deal.II/code_gallery_Quasi_static_Finite_strain_Compressible_Elasticity.html).' This solver supports shared-memory parallelization.

Applied coupling functionalities have been separated and can be found in the `adapter` directory.
Applied coupling functionalities have been separated and can be found in the `include/adapter` directory.

## Start here
Our [wiki](https://www.precice.org/adapter-dealii-overview.html) will help you start. If you are missing something, [let us know](https://www.precice.org/resources/#contact).
Expand Down
101 changes: 101 additions & 0 deletions elasticity.cc
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;
}
4 changes: 2 additions & 2 deletions adapter/adapter.h → include/adapter/adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
#include <deal.II/fe/fe.h>
#include <deal.II/fe/mapping_q1.h>

#include <adapter/dof_tools_extension.h>
#include <adapter/time_handler.h>
#include <precice/SolverInterface.hpp>

#include "dof_tools_extension.h"
#include "time.h"

namespace Adapter
{
Expand Down
File renamed without changes.
Loading