1#ifndef COMMA_PROJECT_COARSE_CELL_H
2#define COMMA_PROJECT_COARSE_CELL_H
19#include <unordered_set>
34 typename CoMMAIndexType,
35 typename CoMMAWeightType,
36 typename CoMMAIntType>
41 std::shared_ptr<Dual_Graph<CoMMAIndexType, CoMMAWeightType, CoMMAIntType>>;
56 const std::unordered_set<CoMMAIndexType> &s_fc,
57 CoMMAIntType compactness,
58 bool is_isotropic =
true
87 std::unordered_set<CoMMAIndexType>
_s_fc;
102 const CoMMAIndexType i_fc,
const std::optional<CoMMAIntType> new_compactness
107 ? new_compactness.value()
117 const std::unordered_set<CoMMAIndexType> &fcs,
118 const std::optional<CoMMAIntType> new_compactness
120 _s_fc.insert(fcs.begin(), fcs.end());
123 ? new_compactness.value()
137 typename CoMMAIndexType,
138 typename CoMMAWeightType,
139 typename CoMMAIntType>
141 Coarse_Cell<CoMMAIndexType, CoMMAWeightType, CoMMAIntType> {
168 const std::unordered_set<CoMMAIndexType> &s_fc,
169 CoMMAIntType compactness,
170 bool is_isotropic =
true
172 BaseClass(fc_graph, i_cc, s_fc, compactness, is_isotropic),
176 CoMMAIndexType position = 0;
177 std::vector<CoMMAWeightType> volumes;
178 std::vector<CoMMAWeightType> CSR_vals{};
179 std::vector<CoMMAIndexType> CSR_row = {0};
180 std::vector<CoMMAIndexType> CSR_col{};
181 std::vector<CoMMAIndexType> col_ind{};
182 std::vector<CoMMAIndexType> mapping{};
183 for (
const CoMMAIndexType &i_fc : this->
_s_fc) {
185 mapping.push_back(i_fc);
186 auto n_it = this->
_fc_graph->neighbours_cbegin(i_fc);
187 auto w_it = this->
_fc_graph->weights_cbegin(i_fc);
188 for (; n_it != this->
_fc_graph->neighbours_cend(i_fc)
189 && w_it != this->
_fc_graph->weights_cend(i_fc);
191 if (std::find(this->_s_fc.begin(), this->_s_fc.end(), *n_it)
192 != this->_s_fc.end()) {
194 col_ind.push_back(*n_it);
195 CSR_vals.push_back(*w_it);
198 CSR_row.push_back(position);
199 volumes.push_back(this->
_fc_graph->_volumes[i_fc]);
203 for (
auto it = col_ind.begin(); it != col_ind.end(); ++it) {
204 auto indx = std::find(mapping.begin(), mapping.end(), *it);
205 CSR_col.push_back(indx - mapping.begin());
208 _cc_graph = std::make_shared<SubGraphType>(
209 s_fc.size(), CSR_row, CSR_col, CSR_vals, volumes, mapping, is_isotropic
219 const CoMMAIndexType i_fc,
const std::optional<CoMMAIntType> new_compactness
222 this->
_s_fc.insert(i_fc);
225 ? new_compactness.value()
226 : this->
_fc_graph->compute_min_fc_compactness_inside_a_cc(this->
_s_fc);
231 this->_fc_graph->_volumes[i_fc],
232 this->_fc_graph->get_weights(i_fc)
242 const std::unordered_set<CoMMAIndexType> &fcs,
243 const std::optional<CoMMAIntType> new_compactness
246 this->
_s_fc.insert(fcs.begin(), fcs.end());
249 ? new_compactness.value()
250 : this->
_fc_graph->compute_min_fc_compactness_inside_a_cc(this->
_s_fc);
252 for (
const auto &i_fc : fcs) {
256 this->_fc_graph->_volumes[i_fc],
257 this->_fc_graph->get_weights(i_fc)
Class describing a coarse cell with a full description, that is, it also holds a subgraph describing ...
Definition: Coarse_Cell.h:141
SubGraphPtr _cc_graph
Shared pointer of the subgraph structure (CSR representation)
Definition: Coarse_Cell.h:269
void insert_cell(const CoMMAIndexType i_fc, const std::optional< CoMMAIntType > new_compactness) override
Insert a FC in the CC (and update sub-graph if necessary)
Definition: Coarse_Cell.h:218
void update_connectivity()
Analyse subgraph and update the connectivity.
Definition: Coarse_Cell.h:263
std::shared_ptr< Dual_Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType > > DualGraphPtr
Type for a shared pointer to a Dual_Graph object.
Definition: Coarse_Cell.h:41
bool _is_connectivity_up_to_date
Whether the connectivity has been checked.
Definition: Coarse_Cell.h:275
void insert_cells(const std::unordered_set< CoMMAIndexType > &fcs, const std::optional< CoMMAIntType > new_compactness) override
Insert several FC in the CC (and update sub-graph if necessary)
Definition: Coarse_Cell.h:241
bool _is_connected
Whether the cell connected.
Definition: Coarse_Cell.h:272
std::shared_ptr< SubGraphType > SubGraphPtr
Type for a shared pointer to a Subgraph object.
Definition: Coarse_Cell.h:153
Coarse_Cell_Subgraph(DualGraphPtr fc_graph, CoMMAIndexType i_cc, const std::unordered_set< CoMMAIndexType > &s_fc, CoMMAIntType compactness, bool is_isotropic=true)
Constructor of the class.
Definition: Coarse_Cell.h:165
Class describing a coarse cell.
Definition: Coarse_Cell.h:37
CoMMAIndexType _idx
Index of the coarse cell (It seems to be unused, but useful to have)
Definition: Coarse_Cell.h:72
CoMMAIntType _cardinality
Number of FC in the CC.
Definition: Coarse_Cell.h:81
std::shared_ptr< Dual_Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType > > DualGraphPtr
Type for a shared pointer to a Dual_Graph object.
Definition: Coarse_Cell.h:41
bool _is_isotropic
Whether the cell isotropic or anisotropic.
Definition: Coarse_Cell.h:84
Coarse_Cell(DualGraphPtr fc_graph, CoMMAIndexType i_cc, const std::unordered_set< CoMMAIndexType > &s_fc, CoMMAIntType compactness, bool is_isotropic=true)
Constructor of the class.
Definition: Coarse_Cell.h:53
virtual void insert_cell(const CoMMAIndexType i_fc, const std::optional< CoMMAIntType > new_compactness)
Insert a FC in the CC (and update sub-graph if necessary)
Definition: Coarse_Cell.h:101
std::unordered_set< CoMMAIndexType > _s_fc
Set of fine cells composing the Coarse cell.
Definition: Coarse_Cell.h:87
DualGraphPtr _fc_graph
The global dual graph.
Definition: Coarse_Cell.h:75
CoMMAIntType _compactness
Compactness degree of the CC.
Definition: Coarse_Cell.h:78
bool is_connected()
Method that return a boolean determining if the coarse cell is defined by a connected sub-graph or no...
Definition: Coarse_Cell.h:94
virtual ~Coarse_Cell()=default
Destructor of the class.
virtual void insert_cells(const std::unordered_set< CoMMAIndexType > &fcs, const std::optional< CoMMAIntType > new_compactness)
Insert several FC in the CC (and update sub-graph if necessary)
Definition: Coarse_Cell.h:116
A class implementing the CRS subgraph representation. It is used in the framework of CoMMA for the im...
Definition: Dual_Graph.h:320
Definition: Agglomerator.h:37