NeoFOAM
WIP Prototype of a modern OpenFOAM core
Loading...
Searching...
No Matches
linearSystem.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// SPDX-FileCopyrightText: 2023 NeoFOAM authors
3#pragma once
4
7
8
9namespace NeoFOAM::la
10{
11
20template<typename ValueType, typename IndexType>
22{
23public:
24
26 : matrix_(matrix), rhs_(rhs)
27 {
28 NF_ASSERT(matrix.exec() == rhs.exec(), "Executors are not the same");
29 NF_ASSERT(matrix.nRows() == rhs.size(), "Matrix and RHS size mismatch");
30 };
31
32 ~LinearSystem() = default;
33
34 [[nodiscard]] CSRMatrix<ValueType, IndexType>& matrix() { return matrix_; }
35 [[nodiscard]] Field<ValueType>& rhs() { return rhs_; }
36
37 [[nodiscard]] const CSRMatrix<ValueType, IndexType>& matrix() const { return matrix_; }
38 [[nodiscard]] const Field<ValueType>& rhs() const { return rhs_; }
39
40 const Executor& exec() const { return matrix_.exec(); }
41
42private:
43
46};
47
48} // namespace NeoFOAM::la
A class to contain the data and executors for a field and define some basic operations.
Definition field.hpp:49
A class representing a linear system of equations.
const Executor & exec() const
Field< ValueType > & rhs()
const Field< ValueType > & rhs() const
const CSRMatrix< ValueType, IndexType > & matrix() const
CSRMatrix< ValueType, IndexType > & matrix()
LinearSystem(const CSRMatrix< ValueType, IndexType > &matrix, const Field< ValueType > &rhs)
#define NF_ASSERT(condition, message)
Macro for asserting a condition and printing an error message if the condition is false.
Definition error.hpp:142
std::variant< SerialExecutor, CPUExecutor, GPUExecutor > Executor
Definition executor.hpp:16