-
Notifications
You must be signed in to change notification settings - Fork 21
Add Trilinos for linear solver #69
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
a376e0d
8f0210a
31539bb
03fc84f
aafaf46
8ab068d
f920ea4
8641536
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| if(TARGET Trilinos::Trilinos) | ||
| return() | ||
| endif() | ||
|
|
||
| message(STATUS "Third-party: creating target 'Trilinos::Trilinos'") | ||
|
|
||
| find_package(Trilinos COMPONENTS ML Epetra) | ||
|
|
||
| if(NOT Trilinos_FOUND) | ||
| message("Trilinos not found.") | ||
| endif() | ||
|
|
||
| find_package(MPI) | ||
|
|
||
| if(NOT MPI_FOUND) | ||
| message("MPI not found.") | ||
| endif() | ||
|
|
||
| MESSAGE("\nFound Trilinos! Here are the details: ") | ||
| MESSAGE(" Trilinos_DIR = ${Trilinos_DIR}") | ||
| MESSAGE(" Trilinos_VERSION = ${Trilinos_VERSION}") | ||
| MESSAGE(" Trilinos_PACKAGE_LIST = ${Trilinos_PACKAGE_LIST}") | ||
| MESSAGE(" Trilinos_LIBRARIES = ${Trilinos_LIBRARIES} ") | ||
| MESSAGE(" Trilinos_INCLUDE_DIRS = ${Trilinos_INCLUDE_DIRS} ") | ||
| MESSAGE(" Trilinos_TPL_LIST = ${Trilinos_TPL_LIST}") | ||
| MESSAGE(" Trilinos_TPL_LIBRARIES = ${Trilinos_TPL_LIBRARIES}") | ||
| MESSAGE(" Trilinos_BUILD_SHARED_LIBS = ${Trilinos_BUILD_SHARED_LIBS}") | ||
| MESSAGE("End of Trilinos details\n") | ||
| # include(trilinos) | ||
| if(TARGET Trilinos::Trilinos) | ||
| else() | ||
| add_library(trilinos INTERFACE) | ||
| add_library(Trilinos::Trilinos ALIAS trilinos) | ||
| target_include_directories(trilinos INTERFACE ${Trilinos_INCLUDE_DIRS} ) | ||
| target_link_libraries(trilinos INTERFACE ${Trilinos_LIBRARIES} ) | ||
| target_link_libraries(trilinos INTERFACE MPI::MPI_C MPI::MPI_CXX ) | ||
| endif() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,8 @@ | |
| "Eigen::MINRES", | ||
| "Pardiso", | ||
| "Hypre", | ||
| "AMGCL" | ||
| "AMGCL", | ||
| "Trilinos" | ||
| ], | ||
| "doc": "Settings for the linear solver." | ||
| }, | ||
|
|
@@ -42,6 +43,7 @@ | |
| "Pardiso", | ||
| "Hypre", | ||
| "AMGCL", | ||
| "Trilinos", | ||
| "Eigen::LeastSquaresConjugateGradient", | ||
| "Eigen::DGMRES", | ||
| "Eigen::ConjugateGradient", | ||
|
|
@@ -153,6 +155,16 @@ | |
| ], | ||
| "doc": "Settings for the AMGCL solver." | ||
| }, | ||
| { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i dont think you need any of these, there are no options for trilinos There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you need to add the options from trilinos There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
| "pointer": "/Trilinos", | ||
| "default": null, | ||
| "type": "object", | ||
| "optional": [ | ||
| "solver", | ||
| "precond" | ||
| ], | ||
| "doc": "Settings for the Trilinos solver." | ||
| }, | ||
| { | ||
| "pointer": "/Eigen::LeastSquaresConjugateGradient/max_iter", | ||
| "default": 1000, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,12 +36,42 @@ | |
| #ifdef POLYSOLVE_WITH_AMGCL | ||
| #include "AMGCL.hpp" | ||
| #endif | ||
| #ifdef POLYSOLVE_WITH_TRILINOS | ||
| #include "TrilinosSolver.hpp" | ||
| #endif | ||
| #ifdef POLYSOLVE_WITH_CUSOLVER | ||
| #include "CuSolverDN.cuh" | ||
| #endif | ||
| #include <unsupported/Eigen/IterativeSolvers> | ||
|
|
||
| //////////////////////////////////////////////////////////////////////////////// | ||
| Eigen::MatrixXd test_vertices; | ||
| Eigen::MatrixXd init_vertices; | ||
| std::vector<int> test_boundary_nodes; | ||
| Eigen::MatrixXd remove_boundary_vertices(const Eigen::MatrixXd &vertices, const std::vector<int> &boundary_nodes) | ||
|
||
| { | ||
| // Remove boundary vertices | ||
| if (boundary_nodes.empty()) | ||
| { | ||
| return vertices; | ||
| } | ||
| else | ||
| { | ||
| std::vector<int> order_nodes = boundary_nodes; | ||
| std::sort(order_nodes.begin(), order_nodes.end()); | ||
| Eigen::MatrixXd out_vertices; | ||
| std::vector<int> keep; | ||
| for (int i = 0; i < vertices.rows(); i++) | ||
| { | ||
| if (!std::binary_search(order_nodes.begin(), order_nodes.end(),i)) | ||
| { | ||
| keep.push_back(i); | ||
| } | ||
| } | ||
| out_vertices = vertices(keep, Eigen::all); | ||
| return out_vertices; | ||
| } | ||
| } | ||
|
|
||
| namespace polysolve::linear | ||
| { | ||
|
|
@@ -377,6 +407,12 @@ namespace polysolve::linear | |
| { | ||
| return std::make_unique<AMGCL>(); | ||
| #endif | ||
| #ifdef POLYSOLVE_WITH_TRILINOS | ||
| } | ||
| else if (solver == "Trilinos") | ||
| { | ||
| return std::make_unique<TrilinosSolver>(); | ||
| #endif | ||
| #if EIGEN_VERSION_AT_LEAST(3, 3, 0) | ||
| // Available only with Eigen 3.3.0 and newer | ||
| #ifndef POLYSOLVE_LARGE_INDEX | ||
|
|
@@ -499,6 +535,9 @@ namespace polysolve::linear | |
| #ifdef POLYSOLVE_WITH_AMGCL | ||
| "AMGCL", | ||
| #endif | ||
| #ifdef POLYSOLVE_WITH_TRILINOS | ||
| "Trilinos", | ||
| #endif | ||
| #if EIGEN_VERSION_AT_LEAST(3, 3, 0) | ||
| #ifndef POLYSOLVE_LARGE_INDEX | ||
| "Eigen::LeastSquaresConjugateGradient", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,12 +4,21 @@ | |
|
|
||
| #include <memory> | ||
|
|
||
| #include <Eigen/Dense> | ||
| #include <Eigen/Sparse> | ||
| #include <vector> | ||
|
||
|
|
||
| #define POLYSOLVE_DELETE_MOVE_COPY(Base) \ | ||
| Base(Base &&) = delete; \ | ||
| Base &operator=(Base &&) = delete; \ | ||
| Base(const Base &) = delete; \ | ||
| Base &operator=(const Base &) = delete; | ||
|
|
||
| extern Eigen::MatrixXd init_vertices; | ||
| extern Eigen::MatrixXd test_vertices; | ||
| extern std::vector<int> test_boundary_nodes; | ||
| Eigen::MatrixXd remove_boundary_vertices(const Eigen::MatrixXd &vertices, const std::vector<int> &boundary_nodes); | ||
|
||
|
|
||
| //////////////////////////////////////////////////////////////////////////////// | ||
| // TODO: | ||
| // - [ ] Support both RowMajor + ColumnMajor sparse matrices | ||
|
|
@@ -25,6 +34,11 @@ namespace spdlog | |
|
|
||
| namespace polysolve::linear | ||
| { | ||
| #ifdef POLYSOLVE_LARGE_INDEX | ||
|
||
| typedef Eigen::SparseMatrix<double, Eigen::ColMajor, std::ptrdiff_t> StiffnessMatrix; | ||
| #else | ||
| typedef Eigen::SparseMatrix<double, Eigen::ColMajor> StiffnessMatrix; | ||
| #endif | ||
| /** | ||
| * @brief Base class for linear solver. | ||
| */ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.