-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
1,110 additions
and
27 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
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,108 @@ | ||
#ifndef GOMA_SPARSE_MATRIX | ||
#define GOMA_SPARSE_MATRIX | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
#ifdef GOMA_MATRIX_GO_LONG_LONG | ||
typedef long long GomaGlobalOrdinal; | ||
#define MPI_GOMA_ORDINAL MPI_LONG_LONG | ||
#else | ||
typedef int GomaGlobalOrdinal; | ||
#define MPI_GOMA_ORDINAL MPI_INT | ||
#endif | ||
|
||
#ifdef DISABLE_CPP | ||
#define CPP_ALREADY_DISABLED | ||
#endif | ||
#define DISABLE_CPP | ||
#include "dp_types.h" | ||
#include "exo_struct.h" | ||
#include "mm_eh.h" | ||
#include "rf_node_const.h" | ||
#include "sl_util_structs.h" | ||
#ifndef CPP_ALREADY_DISABLED | ||
#undef DISABLE_CPP | ||
#endif | ||
|
||
|
||
enum GomaSparseMatrixType { | ||
GOMA_SPARSE_MATRIX_TYPE_EPETRA, | ||
GOMA_SPARSE_MATRIX_TYPE_AZTEC_MRS, | ||
GOMA_SPARSE_MATRIX_TYPE_TPETRA, | ||
GOMA_SPARSE_MATRIX_TYPE_PETSC | ||
}; | ||
|
||
struct g_GomaSparseMatrix { | ||
enum GomaSparseMatrixType type; | ||
void *data; | ||
GomaGlobalOrdinal *global_ids; | ||
GomaGlobalOrdinal n_rows; | ||
GomaGlobalOrdinal n_cols; | ||
// Create matrix with given rows and columns | ||
// coo_rows and coo_cols are the COO representation of the matrix ordered by row | ||
// local_nnz is the number of non-zero entries in the local partition | ||
// max_nz_per_row is the maximum number of non-zero entries in any row | ||
goma_error (*create_graph)(struct g_GomaSparseMatrix *matrix, | ||
GomaGlobalOrdinal n_rows, | ||
GomaGlobalOrdinal *row_list, | ||
GomaGlobalOrdinal n_cols, | ||
GomaGlobalOrdinal *col_list, | ||
GomaGlobalOrdinal local_nnz, | ||
GomaGlobalOrdinal max_nz_per_row, | ||
GomaGlobalOrdinal *coo_rows, | ||
GomaGlobalOrdinal *coo_cols); | ||
// optional, run after create graph to finalize structure | ||
goma_error (*complete_graph)(struct g_GomaSparseMatrix *matrix); | ||
// Insert values into matrix row replacing existing values | ||
goma_error (*insert_row_values)(struct g_GomaSparseMatrix *matrix, | ||
GomaGlobalOrdinal global_row, | ||
GomaGlobalOrdinal num_entries, | ||
double *values, | ||
GomaGlobalOrdinal *indices); | ||
// Add values into a matrix row, sums existing values | ||
goma_error (*sum_into_row_values)(struct g_GomaSparseMatrix *matrix, | ||
GomaGlobalOrdinal global_row, | ||
GomaGlobalOrdinal num_entries, | ||
double *values, | ||
GomaGlobalOrdinal *indices); | ||
// set matrix non-zeros to specified scalar value (commonly re-zero for next assembly) | ||
goma_error (*put_scalar)(struct g_GomaSparseMatrix *matrix, double scalar); | ||
// row sum scaling, compute row sum scale, scale matrix and b, and return scaling vector | ||
goma_error (*row_sum_scaling)(struct g_GomaSparseMatrix *matrix, double *b, double *scale); | ||
// delete the allocated matrix; | ||
goma_error (*destroy)(struct g_GomaSparseMatrix *matrix); | ||
}; | ||
typedef struct g_GomaSparseMatrix *GomaSparseMatrix; | ||
|
||
goma_error GomaSparseMatrix_Create(GomaSparseMatrix *matrix, enum GomaSparseMatrixType type); | ||
// populates: | ||
// - global_ids | ||
// - n_rows | ||
// - n_cols | ||
goma_error GomaSparseMatrix_SetProblemGraph( | ||
GomaSparseMatrix matrix, | ||
int num_internal_dofs, | ||
int num_boundary_dofs, | ||
int num_external_dofs, | ||
int local_nodes, | ||
NODE_INFO_STRUCT **Nodes, | ||
int MaxVarPerNode, | ||
int *Matilda, | ||
int Inter_Mask[MAX_NUM_MATRICES][MAX_VARIABLE_TYPES][MAX_VARIABLE_TYPES], | ||
Exo_DB *exo, | ||
Dpi *dpi, | ||
Comm_Ex *cx, | ||
int imtrx, | ||
int Debug_Flag, | ||
struct GomaLinearSolverData *ams); | ||
|
||
goma_error GomaSparseMatrix_LoadLec(GomaSparseMatrix matrix, int ielem, struct Local_Element_Contributions *lec, double resid_vector[]); | ||
|
||
goma_error GomaSparseMatrix_Destroy(GomaSparseMatrix *matrix); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // GOMA_SPARSE_MATRIX |
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,60 @@ | ||
#ifndef GOMA_SPARSE_MATRIX_TPETRA | ||
#define GOMA_SPARSE_MATRIX_TPETRA | ||
#ifdef __cplusplus | ||
#include "Teuchos_RCP.hpp" | ||
#include <Tpetra_FECrsMatrix.hpp> | ||
|
||
#include "linalg/sparse_matrix.h" | ||
|
||
using LO = int; | ||
using GO = GomaGlobalOrdinal; | ||
|
||
struct TpetraSparseMatrix { | ||
Teuchos::RCP<Tpetra::FECrsMatrix<double, LO, GO>> matrix; | ||
Teuchos::RCP<Tpetra::Map<LO, GO>> row_map; | ||
Teuchos::RCP<Tpetra::Map<LO, GO>> col_map; | ||
Teuchos::RCP<Tpetra::FECrsGraph<LO, GO>> crs_graph; | ||
TpetraSparseMatrix() = default; | ||
}; | ||
|
||
extern "C" { | ||
#endif | ||
|
||
|
||
goma_error GomaSparseMatrix_Tpetra_Create(GomaSparseMatrix *matrix); | ||
|
||
goma_error g_tpetra_create_graph(GomaSparseMatrix matrix, | ||
GomaGlobalOrdinal n_rows, | ||
GomaGlobalOrdinal *row_list, | ||
GomaGlobalOrdinal n_cols, | ||
GomaGlobalOrdinal *col_list, | ||
GomaGlobalOrdinal local_nnz, | ||
GomaGlobalOrdinal max_per_row, | ||
GomaGlobalOrdinal *coo_rows, | ||
GomaGlobalOrdinal *coo_cols); | ||
|
||
goma_error complete_graph(GomaSparseMatrix matrix); | ||
|
||
goma_error g_tpetra_insert_row_values(GomaSparseMatrix matrix, | ||
GomaGlobalOrdinal global_row, | ||
GomaGlobalOrdinal num_entries, | ||
double *values, | ||
GomaGlobalOrdinal *indices); | ||
|
||
goma_error g_tpetra_sum_into_row_values(GomaSparseMatrix matrix, | ||
GomaGlobalOrdinal global_row, | ||
GomaGlobalOrdinal num_entries, | ||
double *values, | ||
GomaGlobalOrdinal *indices); | ||
|
||
goma_error g_tpetra_put_scalar(GomaSparseMatrix matrix, double scalar); | ||
|
||
goma_error g_tpetra_row_sum_scaling(GomaSparseMatrix matrix, double *b, double *scale); | ||
|
||
goma_error g_tpetra_destroy(GomaSparseMatrix matrix); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // GOMA_SPARSE_MATRIX_TPETRA |
Empty file.
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
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
Oops, something went wrong.