Skip to content

Commit aab85f1

Browse files
Remove std::vector for component_sparsities
1 parent e8f841d commit aab85f1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

GridKit/Model/PowerElectronics/SystemModelPowerElectronics.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,7 @@ namespace GridKit
168168

169169
// A reverse mapping from system variables -> component variables
170170
std::vector<std::vector<ComponentContribution>> reverse_map(size_);
171-
std::vector<CsrSparsity> component_sparsities;
172-
component_sparsities.reserve(components_.size());
171+
CsrSparsity* component_sparsities = new CsrSparsity[components_.size()];
173172

174173
// Loop over all components, evaluate their jacobians, save their sparsity information,
175174
// and construct the reverse variable mapping.
@@ -180,10 +179,10 @@ namespace GridKit
180179

181180
auto [row_indices, col_indices, _] = component->getJacobian().setDataToCSR();
182181

183-
component_sparsities.push_back({
182+
component_sparsities[comp_idx] = CsrSparsity{
184183
.row_indices_ = std::move(row_indices),
185184
.col_indices_ = std::move(col_indices),
186-
});
185+
};
187186

188187
for (IdxT local_row = 0; local_row < component->size(); local_row++)
189188
{
@@ -262,6 +261,8 @@ namespace GridKit
262261
// Copy column indices
263262
std::copy(global_col_indices.begin(), global_col_indices.end(), jac_sparsity_col_indices);
264263

264+
delete[] component_sparsities;
265+
265266
return 1;
266267
}
267268

0 commit comments

Comments
 (0)