22template<
typename ValueType,
typename IndexType>
36template<
typename ValueType,
typename IndexType>
53template<
typename ValueType,
typename IndexType>
63 : matrix_(
matrix), rhs_(
rhs), auxiliaryCoefficients_(aux)
70 : matrix_(ls.matrix_), rhs_(ls.rhs_), auxiliaryCoefficients_(ls.auxiliaryCoefficients_) {};
86 return LinearSystem(matrix_.copyToHost(), rhs_.copyToHost());
91 fill(matrix_.values(), zero<ValueType>());
92 fill(rhs_, zero<ValueType>());
124template<
typename ValueTypeIn,
typename IndexTypeIn,
typename ValueTypeOut,
typename IndexTypeOut>
125LinearSystem<ValueTypeOut, IndexTypeOut>
128 auto exec = ls.
exec();
131 convert<ValueTypeIn, IndexTypeIn, ValueTypeOut, IndexTypeOut>(exec, ls.
view.matrix),
140template<
typename ValueType,
typename IndexType>
141LinearSystem<ValueType, IndexType>
144 const auto& exec = mesh.
exec();
150 const auto [diagOffset, rowOffs, faceCells] =
160 auto [mValue, mColIdx, rhsValue, rhsIdx] =
161 views(bcCoeffs.matrixValues, bcCoeffs.matrixIdxs, bcCoeffs.rhsValues, bcCoeffs.rhsIdxs);
166 KOKKOS_LAMBDA(
const localIdx bfacei) {
169 mValue[bfacei] = zero<ValueType>();
170 mColIdx[bfacei] = celli + diagOffset[celli];
171 rhsValue[bfacei] = zero<ValueType>();
172 rhsIdx[bfacei] = celli;
177 aux.
insert(
"boundaryCoefficients", bcCoeffs);
const labelVector & faceCells() const
Get the field of face cells.
A class representing a dictionary that stores key-value pairs.
void insert(const std::string &key, const std::any &value)
Inserts a key-value pair into the dictionary.
Represents an unstructured mesh in NeoN.
const Executor & exec() const
Get the executor.
const BoundaryMesh & boundaryMesh() const
Get the boundary mesh.
A class to contain the data and executors for a field and define some basic operations.
localIdx size() const
Gets the size of the field.
Sparse matrix class with compact storage by row (CSR) format.
A class representing a linear system of equations.
const CSRMatrix< ValueType, IndexType > & matrix() const
LinearSystemView< ValueType, IndexType > view() const &&=delete
CSRMatrix< ValueType, IndexType > & matrix()
LinearSystem copyToHost() const
const Vector< ValueType > & rhs() const
LinearSystem(const CSRMatrix< ValueType, IndexType > &matrix, const Vector< ValueType > &rhs, const Dictionary &aux={})
LinearSystem(const LinearSystem &ls)
LinearSystem(const Executor exec)
LinearSystemView< const ValueType, const IndexType > view() const &
const Dictionary & auxiliaryCoefficients() const
const Executor & exec() const
Vector< ValueType > & rhs()
Dictionary & auxiliaryCoefficients()
LinearSystemView< ValueType, IndexType > view() &&=delete
const Vector< localIdx > & colIdxs() const
const Vector< localIdx > & rowOffs() const
const Array< uint8_t > & diagOffset() const
#define NF_ASSERT(condition, message)
Macro for asserting a condition and printing an error message if the condition is false.
LinearSystem< ValueTypeOut, IndexTypeOut > convertLinearSystem(const LinearSystem< ValueTypeIn, IndexTypeIn > &ls)
LinearSystem< ValueType, IndexType > createEmptyLinearSystem(const UnstructuredMesh &mesh, const SparsityPattern &sparsity)
void parallelFor(const Executor &exec, std::pair< localIdx, localIdx > range, Kernel kernel, std::string name="parallelFor")
std::variant< SerialExecutor, CPUExecutor, GPUExecutor > Executor
void fill(ContType< ValueType > &cont, const std::type_identity_t< ValueType > value, std::pair< localIdx, localIdx > range={0, 0})
Fill the field with a vector value using a specific executor.
auto views(Types &... args)
Unpacks all views of the passed classes.
Vector< ValueType > matrixValues
Vector< IndexType > rhsIdxs
Vector< IndexType > matrixIdxs
Vector< ValueType > rhsValues
A view struct to allow easy read/write on all executors.
A view linear into a linear system's data.
LinearSystemView()=default
LinearSystemView(CSRMatrixView< ValueType, IndexType > matrixView, View< ValueType > rhsView)
CSRMatrixView< ValueType, IndexType > matrix
~LinearSystemView()=default