Factor the loss for a grid.
- Parameters
-
| grid | Grid the velocities belong to |
| friction | Friction in 1/s, not negative |
| viscosity | Viscosity in m^2/s, not negative |
- Returns
- False, leaving the loss as it was, for a grid of fewer than two intervals or a rate that is negative or not finite
- Note
- Allocates only when the grid size changes, so a retune at a block boundary on the same grid allocates nothing.
Definition at line 57 of file DuctLoss.cpp.
58{
59 const size_t n = grid.intervals;
60 if (n < 2 || grid.velocity_gain.size() != n || !positive_finite(grid.time_step) || !positive_finite(grid.spacing)
62 return false;
63 }
64
65 const double k = grid.time_step;
66 const double diffusion =
viscosity * k / (grid.spacing * grid.spacing);
67
72
73 for (size_t l = 0; l < n; ++l) {
74 m_mass[l] = k / grid.velocity_gain[l];
75 }
76 for (size_t l = 0; l + 1 < n; ++l) {
78 }
79
80 const double ghost_left = 2.0 *
m_edge.front();
81 const double ghost_right = 2.0 *
m_edge.back();
82
83 double upper_before = 0.0;
84 for (size_t l = 0; l < n; ++l) {
85 const double left = l > 0 ?
m_edge[l - 1] : ghost_left;
86 const double right = l + 1 < n ?
m_edge[l] : ghost_right;
87 const double diagonal =
m_mass[l] * (1.0 + k *
friction) + left + right;
88
89 const double pivot = diagonal - (l > 0 ? left * upper_before : 0.0);
93 }
94
98 return true;
99}
std::vector< double > m_edge
double friction() const noexcept
double viscosity() const noexcept
std::vector< double > m_inverse_pivot
std::vector< double > m_mass
std::vector< double > m_upper
References friction(), MayaFlux::Kinesis::Acoustics::DuctGrid::intervals, m_active, m_edge, m_friction, m_inverse_pivot, m_mass, m_upper, m_viscosity, MayaFlux::Kinesis::Acoustics::DuctGrid::spacing, MayaFlux::Kinesis::Acoustics::DuctGrid::time_step, MayaFlux::Kinesis::Acoustics::DuctGrid::velocity_gain, and viscosity().