Improve physical geometry, fluid solvers, audio, and profiling
This commit is contained in:
@@ -6,6 +6,10 @@ namespace fluidsim::port {
|
||||
struct PipeSection {
|
||||
float length, inlet_diameter, outlet_diameter;
|
||||
};
|
||||
inline int profile_section_cells(float length,float maximum_cell_length) {
|
||||
const double count=double(length)/maximum_cell_length;
|
||||
return std::max(1,static_cast<int>(std::ceil(count-1e-6*std::max(1.,count))));
|
||||
}
|
||||
|
||||
// Linear diameter within each section. Cell area is the exact frustum-volume
|
||||
// average, so refining the mesh preserves the specified chamber volume.
|
||||
@@ -20,7 +24,7 @@ inline Pipe1D make_profiled_pipe(std::span<const PipeSection> sections, float ma
|
||||
section.inlet_diameter <= 0 || section.outlet_diameter <= 0 ||
|
||||
std::abs(section.inlet_diameter - previous_diameter) > 1e-6f)
|
||||
throw std::invalid_argument("invalid/discontinuous pipe profile");
|
||||
const int count = static_cast<int>(std::ceil(section.length / maximum_cell_length));
|
||||
const int count = profile_section_cells(section.length,maximum_cell_length);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
const float d0 = std::lerp(section.inlet_diameter, section.outlet_diameter, float(i) / count);
|
||||
const float d1 = std::lerp(section.inlet_diameter, section.outlet_diameter, float(i + 1) / count);
|
||||
|
||||
Reference in New Issue
Block a user