Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invalid unchecked cast to StFlow #1226

Merged
merged 1 commit into from
Mar 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions src/oneD/Boundary1D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,19 @@ void Boundary1D::_init(size_t n)
// check for left and right flow objects
if (m_index > 0) {
Domain1D& r = container().domain(m_index-1);
if (!r.isConnector()) { // flow domain
m_flow_left = (StFlow*)&r;
m_left_nv = m_flow_left->nComponents();
m_left_points = m_flow_left->nPoints();
if (!r.isConnector()) { // multi-point domain
m_left_nv = r.nComponents();
if (m_left_nv > c_offset_Y) {
m_left_nsp = m_left_nv - c_offset_Y;
} else {
m_left_nsp = 0;
}
m_left_loc = container().start(m_index-1);
m_left_nsp = m_left_nv - c_offset_Y;
m_phase_left = &m_flow_left->phase();
m_left_points = r.nPoints();
m_flow_left = dynamic_cast<StFlow*>(&r);
if (m_flow_left != nullptr) {
m_phase_left = &m_flow_left->phase();
}
} else {
throw CanteraError("Boundary1D::_init",
"Boundary domains can only be connected on the left to flow "
Expand All @@ -59,12 +65,18 @@ void Boundary1D::_init(size_t n)
// if this is not the last domain, see what is connected on the right
if (m_index + 1 < container().nDomains()) {
Domain1D& r = container().domain(m_index+1);
if (!r.isConnector()) { // flow domain
m_flow_right = (StFlow*)&r;
m_right_nv = m_flow_right->nComponents();
if (!r.isConnector()) { // multi-point domain
m_right_nv = r.nComponents();
if (m_right_nv > c_offset_Y) {
m_right_nsp = m_right_nv - c_offset_Y;
} else {
m_right_nsp = 0;
}
m_right_loc = container().start(m_index+1);
m_right_nsp = m_right_nv - c_offset_Y;
m_phase_right = &m_flow_right->phase();
m_flow_right = dynamic_cast<StFlow*>(&r);
if (m_flow_right != nullptr) {
m_phase_right = &m_flow_right->phase();
}
} else {
throw CanteraError("Boundary1D::_init",
"Boundary domains can only be connected on the right to flow "
Expand Down