Skip to content

Commit 0b7df47

Browse files
committed
Fix out of bounds lookup in reduced lung
1 parent 185ceb3 commit 0b7df47

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

src/reduced_lung/4C_reduced_lung_helpers.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -180,45 +180,46 @@ namespace ReducedLung
180180
void collect_runtime_output_data(
181181
Core::IO::DiscretizationVisualizationWriterMesh& visualization_writer,
182182
const std::vector<Airway>& airways, const std::vector<TerminalUnit>& terminal_units,
183-
const Core::LinAlg::Vector<double>& dofs, const Core::LinAlg::Map* element_row_map)
183+
const Core::LinAlg::Vector<double>& locally_relevant_dofs,
184+
const Core::LinAlg::Map* element_row_map)
184185
{
185186
Core::LinAlg::Vector<double> pressure_in(*element_row_map, true);
186187
Core::LinAlg::Vector<double> pressure_out(*element_row_map, true);
187188
Core::LinAlg::Vector<double> flow_in(*element_row_map, true);
188189
for (const auto& airway : airways)
189190
{
190191
[[maybe_unused]] int err = pressure_in.replace_local_value(
191-
airway.local_element_id, 0, dofs[airway.local_dof_ids[p_in]]);
192+
airway.local_element_id, 0, locally_relevant_dofs[airway.local_dof_ids[p_in]]);
192193
FOUR_C_ASSERT(err == 0,
193194
"Internal error: replace_local_value for runtime output (p_in from airways) did not "
194195
"work.");
195196
err = pressure_out.replace_local_value(
196-
airway.local_element_id, 0, dofs[airway.local_dof_ids[p_out]]);
197+
airway.local_element_id, 0, locally_relevant_dofs[airway.local_dof_ids[p_out]]);
197198
FOUR_C_ASSERT(err == 0,
198199
"Internal error: replace_local_value for runtime output (p_out from airways) did not "
199200
"work.");
200-
err =
201-
flow_in.replace_local_value(airway.local_element_id, 0, dofs[airway.local_dof_ids[q_in]]);
201+
err = flow_in.replace_local_value(
202+
airway.local_element_id, 0, locally_relevant_dofs[airway.local_dof_ids[q_in]]);
202203
FOUR_C_ASSERT(err == 0,
203204
"Internal error: replace_local_value for runtime output (q_in from airways) did not "
204205
"work.");
205206
}
206207
for (const auto& terminal_unit : terminal_units)
207208
{
208-
[[maybe_unused]] int err = pressure_in.replace_local_value(
209-
terminal_unit.local_element_id, 0, dofs[terminal_unit.local_dof_ids[p_in]]);
209+
[[maybe_unused]] int err = pressure_in.replace_local_value(terminal_unit.local_element_id, 0,
210+
locally_relevant_dofs[terminal_unit.local_dof_ids[p_in]]);
210211
FOUR_C_ASSERT(err == 0,
211212
"Internal error: replace_local_value for runtime output (p_in from terminal units) did "
212213
"not "
213214
"work.");
214-
err = pressure_out.replace_local_value(
215-
terminal_unit.local_element_id, 0, dofs[terminal_unit.local_dof_ids[p_out]]);
215+
err = pressure_out.replace_local_value(terminal_unit.local_element_id, 0,
216+
locally_relevant_dofs[terminal_unit.local_dof_ids[p_out]]);
216217
FOUR_C_ASSERT(err == 0,
217218
"Internal error: replace_local_value for runtime output (p_out from terminal units) did "
218219
"not "
219220
"work.");
220-
err = flow_in.replace_local_value(
221-
terminal_unit.local_element_id, 0, dofs[terminal_unit.local_dof_ids[q_in]]);
221+
err = flow_in.replace_local_value(terminal_unit.local_element_id, 0,
222+
locally_relevant_dofs[terminal_unit.local_dof_ids[q_in]]);
222223
FOUR_C_ASSERT(err == 0,
223224
"Internal error: replace_local_value for runtime output (q_in from terminal units) did "
224225
"not "

src/reduced_lung/4C_reduced_lung_helpers.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ namespace ReducedLung
106106
// dofs: {p1, p2, q} for resistive airways; {p1, p2, q1, q2} for compliant airways
107107
std::vector<int> global_dof_ids{};
108108
int n_state_equations = 1;
109+
// local dof ids in locally relevant dof map!
109110
std::vector<int> local_dof_ids{};
110111
};
111112

@@ -126,6 +127,7 @@ namespace ReducedLung
126127
double eta;
127128
std::vector<int> global_dof_ids{};
128129
int n_state_equations = 1;
130+
// local dof ids in locally relevant dof map!
129131
std::vector<int> local_dof_ids{};
130132
};
131133

@@ -208,7 +210,8 @@ namespace ReducedLung
208210
void collect_runtime_output_data(
209211
Core::IO::DiscretizationVisualizationWriterMesh& visualization_writer,
210212
const std::vector<Airway>& airways, const std::vector<TerminalUnit>& terminal_units,
211-
const Core::LinAlg::Vector<double>& dofs, const Core::LinAlg::Map* element_row_map);
213+
const Core::LinAlg::Vector<double>& locally_relevant_dofs,
214+
const Core::LinAlg::Map* element_row_map);
212215
} // namespace ReducedLung
213216

214217
FOUR_C_NAMESPACE_CLOSE

src/reduced_lung/4C_reduced_lung_main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,8 +748,8 @@ namespace ReducedLung
748748
if (n % results_every == 0)
749749
{
750750
visualization_writer->reset();
751-
collect_runtime_output_data(
752-
*visualization_writer, airways, terminal_units, dofs, actdis->element_row_map());
751+
collect_runtime_output_data(*visualization_writer, airways, terminal_units,
752+
locally_relevant_dofs, actdis->element_row_map());
753753
visualization_writer->write_to_disk(dt * n, n);
754754
}
755755
}

0 commit comments

Comments
 (0)