MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ configure()

bool MayaFlux::Kinesis::Acoustics::DuctLoss::configure ( const DuctGrid & grid,
double friction,
double viscosity )
nodiscard

Factor the loss for a grid.

Parameters
gridGrid the velocities belong to
frictionFriction in 1/s, not negative
viscosityViscosity 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)
61 || !not_negative_finite(friction) || !not_negative_finite(viscosity)) {
62 return false;
63 }
64
65 const double k = grid.time_step;
66 const double diffusion = viscosity * k / (grid.spacing * grid.spacing);
67
68 m_mass.resize(n);
69 m_edge.resize(n - 1);
70 m_upper.resize(n);
71 m_inverse_pivot.resize(n);
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) {
77 m_edge[l] = diffusion * 0.5 * (m_mass[l] + m_mass[l + 1]);
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);
90 m_inverse_pivot[l] = 1.0 / pivot;
91 m_upper[l] = l + 1 < n ? m_edge[l] * m_inverse_pivot[l] : 0.0;
92 upper_before = m_upper[l];
93 }
94
97 m_active = friction > 0.0 || viscosity > 0.0;
98 return true;
99}
double friction() const noexcept
Definition DuctLoss.hpp:91
double viscosity() const noexcept
Definition DuctLoss.hpp:92
std::vector< double > m_inverse_pivot
Definition DuctLoss.hpp:98

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().

Here is the call graph for this function: