21std::unique_ptr<PETScMatrix> MatrixVectorTraits<PETScMatrix>::newInstance()
23 return std::make_unique<PETScMatrix>();
26std::unique_ptr<PETScMatrix> MatrixVectorTraits<PETScMatrix>::newInstance(
29 return std::make_unique<PETScMatrix>(A);
32std::unique_ptr<PETScMatrix> MatrixVectorTraits<PETScMatrix>::newInstance(
33 MatrixSpecifications
const& spec)
35 auto const nrows = spec.nrows;
36 auto const ncols = spec.ncols;
38 if (spec.sparsity_pattern)
41 assert(spec.sparsity_pattern->size() == 1);
43 auto const max_nonzeroes = spec.sparsity_pattern->front();
45 PETScMatrixOption mat_opt;
46 mat_opt.d_nz = max_nonzeroes;
47 mat_opt.o_nz = max_nonzeroes;
48 mat_opt.is_global_size =
false;
49 return std::make_unique<PETScMatrix>(nrows, ncols, mat_opt);
52 return std::make_unique<PETScMatrix>(nrows, ncols);
55std::unique_ptr<PETScVector> MatrixVectorTraits<PETScVector>::newInstance()
57 return std::make_unique<PETScVector>();
60std::unique_ptr<PETScVector> MatrixVectorTraits<PETScVector>::newInstance(
63 return std::make_unique<PETScVector>(x);
66std::unique_ptr<PETScVector> MatrixVectorTraits<PETScVector>::newInstance(
67 MatrixSpecifications
const& spec)
69 auto const is_global_size =
false;
71 if (spec.ghost_indices !=
nullptr)
73 return std::make_unique<PETScVector>(spec.nrows, *spec.ghost_indices,
78 return std::make_unique<PETScVector>(spec.nrows, is_global_size);
82std::unique_ptr<PETScVector> MatrixVectorTraits<PETScVector>::newInstance(
85 auto const is_global_size =
false;
87 return std::make_unique<PETScVector>(length, is_global_size);
95std::unique_ptr<EigenMatrix> MatrixVectorTraits<EigenMatrix>::newInstance()
97 return std::make_unique<EigenMatrix>(0, 0);
100std::unique_ptr<EigenMatrix> MatrixVectorTraits<EigenMatrix>::newInstance(
101 EigenMatrix
const& A)
103 return std::make_unique<EigenMatrix>(A);
106std::unique_ptr<EigenMatrix> MatrixVectorTraits<EigenMatrix>::newInstance(
107 MatrixSpecifications
const& spec)
109 auto A = std::make_unique<EigenMatrix>(spec.nrows);
111 if (spec.sparsity_pattern)
119std::unique_ptr<EigenVector> MatrixVectorTraits<EigenVector>::newInstance()
121 return std::make_unique<EigenVector>();
124std::unique_ptr<EigenVector> MatrixVectorTraits<EigenVector>::newInstance(
125 EigenVector
const& x)
127 return std::make_unique<EigenVector>(x);
130std::unique_ptr<EigenVector> MatrixVectorTraits<EigenVector>::newInstance(
131 MatrixSpecifications
const& spec)
133 return std::make_unique<EigenVector>(spec.nrows);
136std::unique_ptr<EigenVector> MatrixVectorTraits<EigenVector>::newInstance(
137 Eigen::SparseMatrix<double>::Index
const length)
139 return std::make_unique<EigenVector>(length);
void setMatrixSparsity(MATRIX &matrix, SPARSITY_PATTERN const &sparsity_pattern)