Chi-Tech
fv_03_buildsparsity.cc
Go to the documentation of this file.
1#include "FiniteVolume.h"
2
5
7{
8
9// ###################################################################
10/**Builds finite volume based sparsity pattern.*/
12 BuildSparsityPattern(std::vector<int64_t>& nodal_nnz_in_diag,
13 std::vector<int64_t>& nodal_nnz_off_diag,
14 const chi_math::UnknownManager& unknown_manager) const
15{
16 unsigned int num_uk = unknown_manager.unknowns_.size(); // Number of unknowns
17 unsigned int N =
18 unknown_manager.GetTotalUnknownStructureSize(); // Total number of unknowns
19
20 nodal_nnz_in_diag.clear();
21 nodal_nnz_off_diag.clear();
22
23 const size_t num_local_cells = ref_grid_.local_cells.size();
24
25 nodal_nnz_in_diag.resize(num_local_cells * N, 0.0);
26 nodal_nnz_off_diag.resize(num_local_cells * N, 0.0);
27
28 for (int uk = 0; uk < num_uk; ++uk)
29 {
30 const unsigned int num_comps =
31 unknown_manager.unknowns_[uk].num_components_;
32 for (int comp = 0; comp < num_comps; ++comp)
33 {
34 for (auto& cell : ref_grid_.local_cells)
35 {
36 const int64_t i = MapDOFLocal(cell, 0, unknown_manager, uk, comp);
37
38 nodal_nnz_in_diag[i] += 1;
39
40 for (auto& face : cell.faces_)
41 {
42 if (not face.has_neighbor_) continue;
43
44 if (face.IsNeighborLocal(ref_grid_)) nodal_nnz_in_diag[i] += 1;
45 else
46 nodal_nnz_off_diag[i] += 1;
47 }
48 } // for cell
49 } // for components
50 } // for unknown
51}
52
53} // namespace chi_math::spatial_discretization
const chi_mesh::MeshContinuum & ref_grid_
std::vector< Unknown > unknowns_
unsigned int GetTotalUnknownStructureSize() const
void BuildSparsityPattern(std::vector< int64_t > &nodal_nnz_in_diag, std::vector< int64_t > &nodal_nnz_off_diag, const UnknownManager &unknown_manager) const override
int64_t MapDOFLocal(const chi_mesh::Cell &cell, unsigned int node, const UnknownManager &unknown_manager, unsigned int unknown_id, unsigned int component) const override
LocalCellHandler local_cells